Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/chown Allow a numeric ID to be preceeded by '#' to ...
details: https://anonhg.NetBSD.org/src/rev/2e6bcab822dd
branches: trunk
changeset: 552405:2e6bcab822dd
user: dsl <dsl%NetBSD.org@localhost>
date: Thu Sep 25 10:30:10 2003 +0000
description:
Allow a numeric ID to be preceeded by '#' to avoid the name lookup.
Update man pages to match.
diffstat:
usr.sbin/chown/chgrp.1 | 14 +++++++++-----
usr.sbin/chown/chown.8 | 20 +++++++++++---------
usr.sbin/chown/chown.c | 10 ++++++----
3 files changed, 26 insertions(+), 18 deletions(-)
diffs (127 lines):
diff -r 8a7fa6e7c890 -r 2e6bcab822dd usr.sbin/chown/chgrp.1
--- a/usr.sbin/chown/chgrp.1 Thu Sep 25 09:38:09 2003 +0000
+++ b/usr.sbin/chown/chgrp.1 Thu Sep 25 10:30:10 2003 +0000
@@ -29,9 +29,9 @@
.\" SUCH DAMAGE.
.\"
.\" 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
.Os
.Sh NAME
@@ -110,8 +110,11 @@
.Ar group
operand can be either a group name from the group database,
or a numeric group ID.
-If a group name is also a numeric group ID, the operand is used as a
-group name.
+Since it is valid to have a group name that is numeric (and
+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
The user invoking
.Nm
@@ -147,5 +150,6 @@
.Pp
The
.Fl v
-option is an extension to
+option and the use of ``#'' to force a numeric group ID
+are extensions to
.St -p1003.2 .
diff -r 8a7fa6e7c890 -r 2e6bcab822dd usr.sbin/chown/chown.8
--- a/usr.sbin/chown/chown.8 Thu Sep 25 09:38:09 2003 +0000
+++ b/usr.sbin/chown/chown.8 Thu Sep 25 10:30:10 2003 +0000
@@ -26,9 +26,9 @@
.\" SUCH DAMAGE.
.\"
.\" 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
.Os
.Sh NAME
@@ -114,14 +114,15 @@
.Pp
The
.Ar owner
-may be either a numeric user ID or a user name.
-If a user name is also a numeric user ID, the operand is used as a
-user name.
+may be either a user name or a numeric user ID.
The
.Ar group
-may be either a numeric group ID or a group name.
-If a group name is also a numeric group ID, the operand is used as a
-group name.
+may be either a group name or a numeric group ID.
+Since it is valid to have a user or group name that is numeric (and
+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
The ownership of a file may only be altered by a super-user for
obvious security reasons.
@@ -155,5 +156,6 @@
.Pp
The
.Fl v
-option is an extension to
+option and the use of ``#'' to force a numeric lookup
+are extensions to
.St -p1003.2 .
diff -r 8a7fa6e7c890 -r 2e6bcab822dd usr.sbin/chown/chown.c
--- a/usr.sbin/chown/chown.c Thu Sep 25 09:38:09 2003 +0000
+++ b/usr.sbin/chown/chown.c Thu Sep 25 10:30:10 2003 +0000
@@ -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
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)chown.c 8.8 (Berkeley) 4/4/94";
#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 /* not lint */
@@ -231,7 +231,7 @@
if (*s == '\0') /* Argument was "uid[:.]". */
return;
- gr = getgrnam(s);
+ gr = *s == '#' ? NULL : getgrnam(s);
if (gr == NULL)
gid = id(s, "group");
else
@@ -245,7 +245,7 @@
{
if (*s == '\0') /* Argument was "[:.]gid". */
return;
- if (uid_from_user(s, &uid) == -1) {
+ if (*s == '#' || uid_from_user(s, &uid) == -1) {
uid = id(s, "user");
}
return;
@@ -259,6 +259,8 @@
char *ep;
errno = 0;
+ if (*name == '#')
+ name++;
val = (id_t)strtoul(name, &ep, 10);
if (errno)
err(EXIT_FAILURE, "%s", name);
Home |
Main Index |
Thread Index |
Old Index