From: Nathan Wagner Date: Sat, 15 Dec 2018 02:34:58 +0000 (+0000) Subject: mask the mode to the actual mode bits X-Git-Tag: v0.5.0~41 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=e5881edcbcd954977064910b2f2e1cc71c1f2e56 mask the mode to the actual mode bits --- diff --git a/zpm-add.c b/zpm-add.c index 3cf7f17..d72a789 100644 --- a/zpm-add.c +++ b/zpm-add.c @@ -21,6 +21,7 @@ struct opts { int complete, addcontent, isconfig, opt_l, recursive, verbose; int followsymlinks; int xargs, noclear; + int striparg; mode_t clmode; char *cltype, *clhash, *clmtime, *prefix, *strip, *cltarget; @@ -212,9 +213,9 @@ int stat_file(struct zpm_file *file, char *path, struct opts *opt) { } if (opt->clmode) { - file->mode = opt->clmode; + file->mode = opt->clmode & 07777; } else { - file->mode = st.st_mode; + file->mode = st.st_mode & 07777; } if (opt->cluser) { @@ -400,6 +401,7 @@ int main(int ac, char **av) { case 'N': opt.addcontent = 0; break; case 'P': opt.prefix = optarg; break; case 'S': opt.strip = optarg; break; + case 's': opt.striparg = 1; break; case 'T': opt.cltarget = optarg; break; case 'c': opt.isconfig = 1; break; case 'f': dbfile = optarg; break; @@ -465,6 +467,10 @@ int main(int ac, char **av) { die("can't stat %s: %s", av[i], strerror(errno)); } file.data = av[i]; + if (opt.striparg) { + opt.strip = av[i]; + } + if (add_file(&zpm, &file, &opt)) { free_file(&file); } else {