]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
When -R is specified, make sure to clear the uname/gname
authorTim Kientzle <kientzle@gmail.com>
Sun, 15 Aug 2010 04:11:25 +0000 (00:11 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 15 Aug 2010 04:11:25 +0000 (00:11 -0400)
fields.  Add a TODO here for the -R parser to return
usable uname/gname text (only useful for tar output,
so not a huge priority right now).

SVN-Revision: 2554

cpio/cmdline.c
cpio/cpio.c
cpio/cpio.h

index 0e18f9f423d4dacccbd1d09d38bc895f2a42f869..22c5396f518cbb307d7c066079aec7d2296a2d5e 100644 (file)
@@ -286,6 +286,8 @@ cpio_getopt(struct cpio *cpio)
  * A period can be used instead of the colon.
  *
  * Sets uid/gid return as appropriate, -1 indicates uid/gid not specified.
+ * TODO: If the spec uses uname/gname, then return those to the caller
+ * as well.  If the spec provides uid/gid, just return names as NULL.
  *
  * Returns NULL if no error, otherwise returns error string for display.
  *
index ba59d398e28308ddb79730af0bb5b47e28879587..4b7ef00baab019453285f6093edb9f3ba98a3a70 100644 (file)
@@ -273,15 +273,21 @@ main(int argc, char *argv[])
                        cpio->quiet = 1;
                        break;
                case 'R': /* GNU cpio, also --owner */
+                       /* TODO: owner_parse should return uname/gname
+                        * also; use that to set [ug]name_override. */
                        errmsg = owner_parse(cpio->optarg, &uid, &gid);
                        if (errmsg) {
                                lafe_warnc(-1, "%s", errmsg);
                                usage();
                        }
-                       if (uid != -1)
+                       if (uid != -1) {
                                cpio->uid_override = uid;
-                       if (gid != -1)
+                               cpio->uname_override = NULL;
+                       }
+                       if (gid != -1) {
                                cpio->gid_override = gid;
+                               cpio->gname_override = NULL;
+                       }
                        break;
                case 'r': /* POSIX 1997 */
                        cpio->option_rename = 1;
@@ -586,10 +592,14 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
                return (r);
        }
 
-       if (cpio->uid_override >= 0)
+       if (cpio->uid_override >= 0) {
                archive_entry_set_uid(entry, cpio->uid_override);
-       if (cpio->gid_override >= 0)
+               archive_entry_set_uname(entry, cpio->uname_override);
+       }
+       if (cpio->gid_override >= 0) {
                archive_entry_set_gid(entry, cpio->gid_override);
+               archive_entry_set_gname(entry, cpio->gname_override);
+       }
 
        /*
         * Generate a destination path for this entry.
index 7917339cb32be2e8ff1fbf5099282abcd6a57147..46b26db29d1f9dadf225c335ddbdd0fcd7f28b7f 100644 (file)
@@ -69,7 +69,9 @@ struct cpio {
        size_t            pass_destpath_alloc;
        char             *pass_destpath;
        int               uid_override;
+       char             *uname_override;
        int               gid_override;
+       char             *gname_override;
        int               day_first; /* true if locale prefers day/mon */
 
        /* If >= 0, then close this when done. */