Allow a numeric ID to be preceeded by '#' to avoid the name lookup.
Update man pages to match.
This commit is contained in:
parent
703c60f5c6
commit
e045a0f96e
@ -29,9 +29,9 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" from: @(#)chgrp.1 8.3 (Berkeley) 3/31/94
|
.\" from: @(#)chgrp.1 8.3 (Berkeley) 3/31/94
|
||||||
.\" $NetBSD: chgrp.1,v 1.16 2003/08/07 11:25:14 agc Exp $
|
.\" $NetBSD: chgrp.1,v 1.17 2003/09/25 10:30:10 dsl Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd January 18, 2003
|
.Dd September 25, 2003
|
||||||
.Dt CHGRP 1
|
.Dt CHGRP 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -110,8 +110,11 @@ The
|
|||||||
.Ar group
|
.Ar group
|
||||||
operand can be either a group name from the group database,
|
operand can be either a group name from the group database,
|
||||||
or a numeric group ID.
|
or a numeric group ID.
|
||||||
If a group name is also a numeric group ID, the operand is used as a
|
Since it is valid to have a group name that is numeric (and
|
||||||
group name.
|
doesn't have the numeric ID that matches its name) the name lookup
|
||||||
|
is always done first.
|
||||||
|
Preceeding the ID with a ``#'' character will force it to be taken
|
||||||
|
as a number.
|
||||||
.Pp
|
.Pp
|
||||||
The user invoking
|
The user invoking
|
||||||
.Nm
|
.Nm
|
||||||
@ -147,5 +150,6 @@ utility is expected to be POSIX 1003.2 compatible.
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fl v
|
.Fl v
|
||||||
option is an extension to
|
option and the use of ``#'' to force a numeric group ID
|
||||||
|
are extensions to
|
||||||
.St -p1003.2 .
|
.St -p1003.2 .
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" from: @(#)chown.8 8.3 (Berkeley) 3/31/94
|
.\" from: @(#)chown.8 8.3 (Berkeley) 3/31/94
|
||||||
.\" $NetBSD: chown.8,v 1.18 2003/08/07 11:25:14 agc Exp $
|
.\" $NetBSD: chown.8,v 1.19 2003/09/25 10:30:10 dsl Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd January 18, 2003
|
.Dd September 25, 2003
|
||||||
.Dt CHOWN 8
|
.Dt CHOWN 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -114,14 +114,15 @@ operand is specified, it must be preceded by a colon (``:'') character.
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Ar owner
|
.Ar owner
|
||||||
may be either a numeric user ID or a user name.
|
may be either a user name or a numeric user ID.
|
||||||
If a user name is also a numeric user ID, the operand is used as a
|
|
||||||
user name.
|
|
||||||
The
|
The
|
||||||
.Ar group
|
.Ar group
|
||||||
may be either a numeric group ID or a group name.
|
may be either a group name or a numeric group ID.
|
||||||
If a group name is also a numeric group ID, the operand is used as a
|
Since it is valid to have a user or group name that is numeric (and
|
||||||
group name.
|
doesn't have the numeric ID that matches its name) the name lookup
|
||||||
|
is always done first.
|
||||||
|
Preceeding an ID with a ``#'' character will force it to be taken
|
||||||
|
as a number.
|
||||||
.Pp
|
.Pp
|
||||||
The ownership of a file may only be altered by a super-user for
|
The ownership of a file may only be altered by a super-user for
|
||||||
obvious security reasons.
|
obvious security reasons.
|
||||||
@ -155,5 +156,6 @@ command is expected to be POSIX 1003.2 compliant.
|
|||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fl v
|
.Fl v
|
||||||
option is an extension to
|
option and the use of ``#'' to force a numeric lookup
|
||||||
|
are extensions to
|
||||||
.St -p1003.2 .
|
.St -p1003.2 .
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: chown.c,v 1.28 2003/08/07 11:25:14 agc Exp $ */
|
/* $NetBSD: chown.c,v 1.29 2003/09/25 10:30:10 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1993, 1994, 2003
|
* Copyright (c) 1988, 1993, 1994, 2003
|
||||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994, 2003\n\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94";
|
static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: chown.c,v 1.28 2003/08/07 11:25:14 agc Exp $");
|
__RCSID("$NetBSD: chown.c,v 1.29 2003/09/25 10:30:10 dsl Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ a_gid(s)
|
|||||||
|
|
||||||
if (*s == '\0') /* Argument was "uid[:.]". */
|
if (*s == '\0') /* Argument was "uid[:.]". */
|
||||||
return;
|
return;
|
||||||
gr = getgrnam(s);
|
gr = *s == '#' ? NULL : getgrnam(s);
|
||||||
if (gr == NULL)
|
if (gr == NULL)
|
||||||
gid = id(s, "group");
|
gid = id(s, "group");
|
||||||
else
|
else
|
||||||
@ -245,7 +245,7 @@ a_uid(s)
|
|||||||
{
|
{
|
||||||
if (*s == '\0') /* Argument was "[:.]gid". */
|
if (*s == '\0') /* Argument was "[:.]gid". */
|
||||||
return;
|
return;
|
||||||
if (uid_from_user(s, &uid) == -1) {
|
if (*s == '#' || uid_from_user(s, &uid) == -1) {
|
||||||
uid = id(s, "user");
|
uid = id(s, "user");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -259,6 +259,8 @@ id(name, type)
|
|||||||
char *ep;
|
char *ep;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
if (*name == '#')
|
||||||
|
name++;
|
||||||
val = (id_t)strtoul(name, &ep, 10);
|
val = (id_t)strtoul(name, &ep, 10);
|
||||||
if (errno)
|
if (errno)
|
||||||
err(EXIT_FAILURE, "%s", name);
|
err(EXIT_FAILURE, "%s", name);
|
||||||
|
Loading…
Reference in New Issue
Block a user