]> pd.if.org Git - zpackage/commitdiff
mask the mode to the actual mode bits
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 15 Dec 2018 02:34:58 +0000 (02:34 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 15 Dec 2018 02:34:58 +0000 (02:34 +0000)
zpm-add.c

index 3cf7f17f51be829d1462f24b7380d451612ecf3f..d72a7896a9aed277b37b57cf100b1978dff6d76d 100644 (file)
--- 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 {