Protect mountpoint from relative paths and duplicate pathsep
Use os.path.realpath() to clean up any path manipulations Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
parent
0d850d7a6d
commit
35c5a0b279
|
@ -16,6 +16,7 @@
|
|||
import json
|
||||
import logging
|
||||
import re
|
||||
from os.path import realpath
|
||||
|
||||
from .blockdev import Blockdev, Raiddev, Bcachedev, sort_actions
|
||||
import math
|
||||
|
@ -470,6 +471,9 @@ class FilesystemModel(ModelPolicy):
|
|||
if not mountpoint.startswith('/'):
|
||||
raise ValueError('Does not start with /')
|
||||
|
||||
# remove redundent // and ..
|
||||
mountpoint = realpath(mountpoint)
|
||||
|
||||
# /usr/include/linux/limits.h:PATH_MAX
|
||||
if len(mountpoint) > 4095:
|
||||
raise ValueError('Path exceeds PATH_MAX')
|
||||
|
|
Loading…
Reference in New Issue