diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-03-22 21:23:00 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-03-22 21:23:00 +0000 |
commit | e3f0e22a52e1766bbbcca69a637bc58e0a5f994d (patch) | |
tree | 4ae7fc3c344cc2edb96baf6e279c84603f2001c5 /usr.sbin | |
parent | 0483b134133ba4d8bc055eade2a074de92f1dd2a (diff) |
Don't assume all-numeric names are id's, look up as a name in
passwd first. Noted by Solar Designer <solar@FALSE.COM>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/edquota/edquota.8 | 9 | ||||
-rw-r--r-- | usr.sbin/edquota/edquota.c | 24 |
2 files changed, 19 insertions, 14 deletions
diff --git a/usr.sbin/edquota/edquota.8 b/usr.sbin/edquota/edquota.8 index 2887986155a..1a3e2c922dc 100644 --- a/usr.sbin/edquota/edquota.8 +++ b/usr.sbin/edquota/edquota.8 @@ -33,7 +33,7 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)edquota.8 8.1 (Berkeley) 6/6/93 -.\" $Id: edquota.8,v 1.1 1995/10/18 08:47:33 deraadt Exp $ +.\" $Id: edquota.8,v 1.2 1998/03/22 21:22:57 millert Exp $ .\" .Dd June 6, 1993 .Dt EDQUOTA 8 @@ -45,11 +45,11 @@ .Nm edquota .Op Fl u .Op Fl p Ar proto-username -.Ar username ... +.Ar username | uid ... .Nm edquota .Fl g .Op Fl p Ar proto-groupname -.Ar groupname ... +.Ar groupname | gid ... .Nm edquota .Fl t .Op Fl u @@ -63,6 +63,9 @@ By default, or if the .Fl u flag is specified, one or more users may be specified on the command line. +If a numeric id is given instead of a name that uid/gid +will be used even if there is not a corresponding id in +the passwd or group files. For each user a temporary file is created with an ASCII representation of the current disk quotas for that user. diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 53f93b58b60..4cb91bc272e 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -42,7 +42,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)edquota.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: edquota.c,v 1.17 1997/08/20 05:32:17 millert Exp $"; +static char *rcsid = "$Id: edquota.c,v 1.18 1998/03/22 21:22:59 millert Exp $"; #endif /* not lint */ /* @@ -82,7 +82,6 @@ struct quotause { void putprivs __P((long, int, struct quotause *)); void freeprivs __P((struct quotause *)); -int getentry __P((char *, int)); int writetimes __P((struct quotause *, int, int)); int editit __P((char *)); int readtimes __P((struct quotause *, int)); @@ -91,6 +90,7 @@ int alldigits __P((char *s)); int readprivs __P((struct quotause *, int)); int hasquota __P((struct fstab *, int, char **)); int cvtatos __P((time_t, char *, time_t *)); +u_int getentry __P((char *, int)); void usage() @@ -108,8 +108,6 @@ main(argc, argv) int argc; { register struct quotause *qup, *protoprivs, *curprivs; - extern char *optarg; - extern int optind; register u_int id, protoid; register int quotatype, tmpfd; char *protoname = NULL; @@ -191,25 +189,32 @@ main(argc, argv) * an identifier. This routine must agree with the kernel routine * getinoquota as to the interpretation of quota types. */ -int +u_int getentry(name, quotatype) char *name; int quotatype; { struct passwd *pw; struct group *gr; + u_long id; - if (alldigits(name)) - return(atoi(name)); switch(quotatype) { case USRQUOTA: if ((pw = getpwnam(name))) return(pw->pw_uid); + else if (alldigits(name)) { + if ((id = strtoul(name, NULL, 10)) <= UID_MAX) + return((uid_t)id); + } warnx("%s: no such user", name); break; case GRPQUOTA: if ((gr = getgrnam(name))) return(gr->gr_gid); + else if (alldigits(name)) { + if ((id = strtoul(name, NULL, 10)) <= GID_MAX) + return((gid_t)id); + } warnx("%s: no such group", name); break; default: @@ -234,7 +239,6 @@ getprivs(id, quotatype) int qcmd, qupsize, fd; char *qfpathname; static int warned = 0; - extern int errno; setfsent(); quphead = (struct quotause *)0; @@ -357,8 +361,6 @@ editit(tmpfile) omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); top: if ((pid = fork()) < 0) { - extern errno; - if (errno == EPROCLIM) { warnx("you have too many processes"); free(p); @@ -712,7 +714,7 @@ int alldigits(s) register char *s; { - register c; + register int c; c = *s++; do { |