diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-04-27 12:41:24 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-04-27 12:41:24 +0200 |
commit | 20143cd6b0edf4756c556ed6626d6a6c6f22fb41 (patch) | |
tree | bcb6b8c800d55ea51179f67b19e46db5931401bf /bin/gensquashfs/options.c | |
parent | 5630c5fa818a38c180ee4b859539cd37a9c2b93a (diff) |
gensquashfs: Add options to globally override UID/GID values
A common use case for mksquashfs is to simply pack a directory and set
a magic option to force all user/group IDs to root.
This commit adds similar options to gensquashfs to maek it better
suited as a direct replacement for packing an input directory.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/options.c')
-rw-r--r-- | bin/gensquashfs/options.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/bin/gensquashfs/options.c b/bin/gensquashfs/options.c index 2369787..d029c09 100644 --- a/bin/gensquashfs/options.c +++ b/bin/gensquashfs/options.c @@ -6,7 +6,14 @@ */ #include "mkfs.h" +enum { + ALL_ROOT_OPTION = 1, +}; + static struct option long_opts[] = { + { "all-root", required_argument, NULL, ALL_ROOT_OPTION }, + { "set-uid", required_argument, NULL, 'u' }, + { "set-gid", required_argument, NULL, 'g' }, { "compressor", required_argument, NULL, 'c' }, { "block-size", required_argument, NULL, 'b' }, { "dev-block-size", required_argument, NULL, 'B' }, @@ -33,7 +40,7 @@ static struct option long_opts[] = { { NULL, 0, NULL, 0 }, }; -static const char *short_opts = "F:D:X:c:b:B:d:j:Q:kxoefqThV" +static const char *short_opts = "F:D:X:c:b:B:d:u:g:j:Q:kxoefqThV" #ifdef WITH_SELINUX "s:" #endif @@ -83,6 +90,14 @@ static const char *help_string = " mode=<value> 0755 if not set.\n" " mtime=<value> 0 if not set.\n" "\n" +" --set-uid, -u <number> Force the owners user ID for ALL inodes to\n" +" this value, no matter what the pack file or\n" +" directory entries actually specify.\n" +" --set-gid, -g <number> Force the owners group ID for ALL inodes to\n" +" this value, no matter what the pack file or\n" +" directory entries actually specify.\n" +" --all-root A short hand for `--set-uid 0 --set-gid 0`.\n" +"\n" #ifdef WITH_SELINUX " --selinux, -s <file> Specify an SELinux label file to get context\n" " attributes from.\n" @@ -162,6 +177,20 @@ void process_command_line(options_t *opt, int argc, char **argv) break; switch (i) { + case ALL_ROOT_OPTION: + opt->force_uid_value = 0; + opt->force_gid_value = 0; + opt->force_uid = true; + opt->force_gid = true; + break; + case 'u': + opt->force_uid_value = strtol(optarg, NULL, 0); + opt->force_uid = true; + break; + case 'g': + opt->force_gid_value = strtol(optarg, NULL, 0); + opt->force_gid = true; + break; case 'T': opt->no_tail_packing = true; break; |