diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-01-02 15:44:36 -0500 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-01-30 13:33:47 +0200 |
commit | 033cd6816fe4db1a6a8f564183333f9b78354246 (patch) | |
tree | 482dd462b10dccd8f05ca968dc49d2abfbb4ab1e /src | |
parent | 9e2d258c81af9f8cedba2e4b8874fbaea59b43c4 (diff) | |
download | cpio-033cd6816fe4db1a6a8f564183333f9b78354246.tar.gz cpio-033cd6816fe4db1a6a8f564183333f9b78354246.tar.bz2 |
Treat UID/GID as numeric if prefixed by + (-R option)
The IDs supplied with the -R option are treated as numeric (without
looking them up in the system database), when prefixed with +. This
allows to force using numeric value if a user (group) with a numeric
name exists in the database.
Reported by Joshua Briefman <sirgatez@gmail.com>.
* src/userspec.c (parse_user_spec): Use + as an indicator of
a numeric UID/GID.
* doc/cpio.1: Document changes.
* doc/cpio.texi: Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/userspec.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/userspec.c b/src/userspec.c index 8cffd65..82cfcef 100644 --- a/src/userspec.c +++ b/src/userspec.c | |||
@@ -108,10 +108,16 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid, | |||
108 | 108 | ||
109 | if (u != NULL) | 109 | if (u != NULL) |
110 | { | 110 | { |
111 | if (*u == '+') | ||
112 | { | ||
113 | pwd = NULL; | ||
114 | ++u; | ||
115 | } | ||
116 | else | ||
111 | pwd = getpwnam (u); | 117 | pwd = getpwnam (u); |
118 | |||
112 | if (pwd == NULL) | 119 | if (pwd == NULL) |
113 | { | 120 | { |
114 | |||
115 | if (!isnumber_p (u)) | 121 | if (!isnumber_p (u)) |
116 | error_msg = _("invalid user"); | 122 | error_msg = _("invalid user"); |
117 | else | 123 | else |
@@ -155,7 +161,14 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid, | |||
155 | if (g != NULL && error_msg == NULL) | 161 | if (g != NULL && error_msg == NULL) |
156 | { | 162 | { |
157 | /* Explicit group. */ | 163 | /* Explicit group. */ |
164 | if (*g == '+') | ||
165 | { | ||
166 | grp = NULL; | ||
167 | ++g; | ||
168 | } | ||
169 | else | ||
158 | grp = getgrnam (g); | 170 | grp = getgrnam (g); |
171 | |||
159 | if (grp == NULL) | 172 | if (grp == NULL) |
160 | { | 173 | { |
161 | if (!isnumber_p (g)) | 174 | if (!isnumber_p (g)) |