aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-01-02 15:44:36 -0500
committerSergey Poznyakoff <gray@gnu.org.ua>2014-01-30 13:33:47 +0200
commit033cd6816fe4db1a6a8f564183333f9b78354246 (patch)
tree482dd462b10dccd8f05ca968dc49d2abfbb4ab1e /src
parent9e2d258c81af9f8cedba2e4b8874fbaea59b43c4 (diff)
downloadcpio-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.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/userspec.c b/src/userspec.c
index 8cffd65..82cfcef 100644
--- a/src/userspec.c
+++ b/src/userspec.c
@@ -105,16 +105,22 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
if (u == NULL && g == NULL)
return "can not omit both user and group";
if (u != NULL)
{
- pwd = getpwnam (u);
- if (pwd == NULL)
+ if (*u == '+')
{
+ pwd = NULL;
+ ++u;
+ }
+ else
+ pwd = getpwnam (u);
+ if (pwd == NULL)
+ {
if (!isnumber_p (u))
error_msg = _("invalid user");
else
{
int use_login_group;
use_login_group = (separator != NULL && g == NULL);
@@ -152,13 +158,20 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
endpwent ();
}
if (g != NULL && error_msg == NULL)
{
/* Explicit group. */
- grp = getgrnam (g);
+ if (*g == '+')
+ {
+ grp = NULL;
+ ++g;
+ }
+ else
+ grp = getgrnam (g);
+
if (grp == NULL)
{
if (!isnumber_p (g))
error_msg = _("invalid group");
else
*gid = atoi (g);

Return to:

Send suggestions and report system problems to the System administrator.