diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-09-10 12:28:02 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-09-11 09:39:12 +0200 |
commit | 96b73f5c7b4d49f88597d34b7d3250f259d13dbd (patch) | |
tree | 29bb653fafa5e5327c6d008e91fd5c2fb6e8bdce /scripts | |
parent | 55a0ac361a6b2443f691e0a84c7db7d4f2641f11 (diff) | |
download | ptxdist-96b73f5c7b4d49f88597d34b7d3250f259d13dbd.tar.gz ptxdist-96b73f5c7b4d49f88597d34b7d3250f259d13dbd.tar.xz |
ptxd_lib_check_dir_permissions: handle corner cases better
Change the whole permission checking to validate the final permission each
directory should have in the opkg package.
This means that:
- any explicitly created directory overwrites the ownership and
permissions of any implicit creation
- if a directory is created explicitly multiple times, then the last
ownership and permissions are used.
To handle this, collect all the data for one package first and merge
multiple occurrences according to the rules specified above.
Then check and merge with the global database.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/ptxd_lib_check_dir_permissions.awk | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/scripts/lib/ptxd_lib_check_dir_permissions.awk b/scripts/lib/ptxd_lib_check_dir_permissions.awk index 560a6a40f..a669b429b 100644 --- a/scripts/lib/ptxd_lib_check_dir_permissions.awk +++ b/scripts/lib/ptxd_lib_check_dir_permissions.awk @@ -4,10 +4,6 @@ BEGIN { FS = "\x1F"; } -FNR == 1 { - pkg = gensub(/.*\/(.*).perms/, "\\1", 1, FILENAME) -} - function check(path, perm, implicit) { if ((path in perms) && (perms[path] != perm)) { if (implicit && (pkg == names[path])) @@ -18,29 +14,43 @@ function check(path, perm, implicit) { print("\nOne of these packages must be fixed!\n") exit 1 } - names[path] = pkg - perms[path] = perm - imp[path] = implicit + if (!(path in perms)) { + names[path] = pkg + perms[path] = perm + imp[path] = implicit + } +} + +FNR == 1 { + for (path in dirs) + check(path, dirs[path], imps[path]) + pkg = gensub(/.*\/(.*).perms/, "\\1", 1, FILENAME) + delete dirs + delete imps } -function check_parents(base) { +function push_parents(base) { path = base while (1) { path = gensub(/\/[^/]*$/,"",1,path) if (path == "") break; - check(path, "0.0 0755", base) + if (!(path in dirs)) { + dirs[path] = "0.0 0755" + imps[path] = base + } } } $1 ~ "d" { path = gensub(/\/$/,"",1,$2) perm = $3 "." $4 " " sprintf("%04o", strtonum("0" $5)) - check(path, perm, "") - check_parents(path) + dirs[path] = perm + imps[path] = "" + push_parents(path) } $1 ~ "f" { path = $2 - check_parents(path) + push_parents(path) } |