raise e
return "%attr({:o},{},{}) ".format(mode, owner, group)
+ def escape_chars(p):
+ return p.replace("%", "%%")
+
path = rootpath.replace(walkpath, "")
if path.endswith("DEBIAN") or path.endswith("CONTROL"):
continue
- path = path.replace("%", "%%%%%%%%")
# Treat all symlinks to directories as normal files.
# os.walk() lists them as directories.
for dir in dirs:
if dir == "CONTROL" or dir == "DEBIAN":
continue
- dir = dir.replace("%", "%%%%%%%%")
p = path + '/' + dir
# All packages own the directories their files are in...
- target.append(get_attr(dir) + '%dir "' + p + '"')
+ target.append(get_attr(dir) + '%dir "' + escape_chars(p) + '"')
else:
# packages own only empty directories or explict directory.
# This will prevent the overlapping of security permission.
attr = get_attr(path)
if path and not files and not dirs:
- target.append(attr + '%dir "' + path + '"')
+ target.append(attr + '%dir "' + escape_chars(path) + '"')
elif path and path in dirfiles:
- target.append(attr + '%dir "' + path + '"')
+ target.append(attr + '%dir "' + escape_chars(path) + '"')
for file in files:
if file == "CONTROL" or file == "DEBIAN":
continue
- file = file.replace("%", "%%%%%%%%")
attr = get_attr(file)
p = path + '/' + file
if conffiles.count(p):
- target.append(attr + '%config "' + p + '"')
+ target.append(attr + '%config "' + escape_chars(p) + '"')
else:
- target.append(attr + '"' + p + '"')
+ target.append(attr + '"' + escape_chars(p) + '"')
# Prevent the prerm/postrm scripts from being run during an upgrade
def wrap_uninstall(scriptvar):