diff -urNp quota-tools-orig/edquota.c quota-tools/edquota.c --- quota-tools-orig/edquota.c 2005-06-01 09:21:29.000000000 +0200 +++ quota-tools/edquota.c 2008-07-17 12:20:28.000000000 +0200 @@ -66,16 +66,16 @@ void usage(void) { #if defined(RPC_SETQUOTA) errstr("%s%s%s%s", - _("Usage:\n\tedquota [-r] [-u] [-F formatname] [-p username] [-f filesystem] username ...\n"), - _("\tedquota [-r] -g [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"), - _("\tedquota [-r] [-u|g] [-F formatname] [-f filesystem] -t\n"), - _("\tedquota [-r] [-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n")); + _("Usage:\n edquota [-r] [-u] [-x] [-F formatname] [-p username] [-f filesystem] username ...\n"), + _(" edquota [-r] -g [-x] [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"), + _(" edquota [-r] [-u|g] [-x] [-F formatname] [-f filesystem] -t\n"), + _(" edquota [-r] [-u|g] [-x] [-F formatname] [-f filesystem] -T username|groupname ...\n")); #else errstr("%s%s%s%s", - _("Usage:\n\tedquota [-u] [-F formatname] [-p username] [-f filesystem] username ...\n"), - _("\tedquota -g [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"), - _("\tedquota [-u|g] [-F formatname] [-f filesystem] -t\n"), - _("\tedquota [-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n")); + _("Usage:\n edquota [-u] [-x] [-F formatname] [-p username] [-f filesystem] username ...\n"), + _(" edquota -g [-x] [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"), + _(" edquota [-u|g] [-x] [-F formatname] [-f filesystem] -t\n"), + _(" edquota [-u|g] [-x] [-F formatname] [-f filesystem] -T username|groupname ...\n")); #endif fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL); exit(1); @@ -87,7 +87,7 @@ int main(int argc, char **argv) long id, protoid; int quotatype, tmpfd, ret; char *protoname = NULL; - int tflag = 0, Tflag = 0, pflag = 0, rflag = 0, fmt = -1; + int tflag = 0, Tflag = 0, pflag = 0, rflag = 0, nflag =0, fmt = -1; struct quota_handle **handles; char *tmpfil, *tmpdir = NULL; @@ -100,9 +100,9 @@ int main(int argc, char **argv) dirname = NULL; quotatype = USRQUOTA; #if defined(RPC_SETQUOTA) - while ((ret = getopt(argc, argv, "ugrntTVp:F:f:")) != -1) { + while ((ret = getopt(argc, argv, "ugrntxTVp:F:f:")) != -1) { #else - while ((ret = getopt(argc, argv, "ugtTVp:F:f:")) != -1) { + while ((ret = getopt(argc, argv, "ugtxTVp:F:f:")) != -1) { #endif switch (ret) { case 'p': @@ -134,6 +134,9 @@ int main(int argc, char **argv) case 'f': dirname = optarg; break; + case 'x': + nflag++; + break; case 'V': version(); exit(0); @@ -156,10 +159,10 @@ int main(int argc, char **argv) } if (pflag) { ret = 0; - protoid = name2id(protoname, quotatype, NULL); + protoid = name2id(protoname, quotatype, !!(nflag), NULL); protoprivs = getprivs(protoid, handles, 0); while (argc-- > 0) { - id = name2id(*argv++, quotatype, NULL); + id = name2id(*argv++, quotatype, !!(nflag), NULL); curprivs = getprivs(id, handles, 0); for (pprivs = protoprivs, cprivs = curprivs; pprivs && cprivs; @@ -215,7 +218,7 @@ int main(int argc, char **argv) } else if (Tflag) { for (; argc > 0; argc--, argv++) { - id = name2id(*argv, quotatype, NULL); + id = name2id(*argv, quotatype, !!(nflag), NULL); curprivs = getprivs(id, handles, 0); if (writeindividualtimes(curprivs, tmpfd, *argv, quotatype) < 0) { errstr(_("Can't write individual grace times to file.\n")); @@ -239,7 +242,7 @@ int main(int argc, char **argv) } else { for (; argc > 0; argc--, argv++) { - id = name2id(*argv, quotatype, NULL); + id = name2id(*argv, quotatype, !!(nflag), NULL); curprivs = getprivs(id, handles, 0); if (writeprivs(curprivs, tmpfd, *argv, quotatype) < 0) { errstr(_("Can't write quotas to file.\n")); diff -urNp quota-tools-orig/quota.c quota-tools/quota.c --- quota-tools-orig/quota.c 2004-04-20 21:33:05.000000000 +0200 +++ quota-tools/quota.c 2008-07-17 12:14:29.000000000 +0200 @@ -68,6 +68,7 @@ #define FL_LOCALONLY 32 #define FL_QUIETREFUSE 64 #define FL_NOAUTOFS 128 +#define FL_ALWAYSRESOLVE 256 int flags, fmt = -1; char *progname; @@ -85,7 +86,7 @@ int main(int argc, char **argv) gettexton(); progname = basename(argv[0]); - while ((ret = getopt(argc, argv, "guqvsVliQF:")) != -1) { + while ((ret = getopt(argc, argv, "guqvxsVliQF:")) != -1) { switch (ret) { case 'g': flags |= FL_GROUP; @@ -115,6 +116,9 @@ int main(int argc, char **argv) case 'i': flags |= FL_NOAUTOFS; break; + case 'x': + flags |= FL_ALWAYSRESOLVE; + break; case 'V': version(); exit(0); @@ -156,19 +160,19 @@ int main(int argc, char **argv) if (flags & FL_USER) for (; argc > 0; argc--, argv++) - ret |= showquotas(USRQUOTA, user2uid(*argv, NULL)); + ret |= showquotas(USRQUOTA, user2uid(*argv, !!(flags & FL_ALWAYSRESOLVE), NULL)); else if (flags & FL_GROUP) for (; argc > 0; argc--, argv++) - ret |= showquotas(GRPQUOTA, group2gid(*argv, NULL)); + ret |= showquotas(GRPQUOTA, group2gid(*argv, !!(flags & FL_ALWAYSRESOLVE), NULL)); return ret; } void usage(void) { errstr( "%s%s%s", - _("Usage: quota [-guqvs] [-l | -Q] [-i] [-F quotaformat]\n"), - _("\tquota [-qvs] [-l | -Q] [-i] [-F quotaformat] -u username ...\n"), - _("\tquota [-qvs] [-l | -Q] [-i] [-F quotaformat] -g groupname ...\n")); + _("Usage: quota [-guqxvs] [-l | -Q] [-i] [-F quotaformat]\n"), + _("\tquota [-qxvs] [-l | -Q] [-i] [-F quotaformat] -u username ...\n"), + _("\tquota [-qxvs] [-l | -Q] [-i] [-F quotaformat] -g groupname ...\n")); fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL); exit(1); } diff -urNp quota-tools-orig/quotaops.c quota-tools/quotaops.c --- quota-tools-orig/quotaops.c 2008-07-17 11:58:13.000000000 +0200 +++ quota-tools/quotaops.c 2008-07-17 12:33:42.000000000 +0200 @@ -256,7 +256,7 @@ int writeprivs(struct dquot *qlist, int #if defined(ALT_FORMAT) fprintf(fd, _("Disk quotas for %s %s (%cid %d):\n"), - type2name(quotatype), name, *type2name(quotatype), name2id(name, quotatype, NULL)); + type2name(quotatype), name, *type2name(quotatype), name2id(name, quotatype, 0, NULL)); fprintf(fd, _(" Filesystem blocks soft hard inodes soft hard\n")); @@ -440,7 +440,7 @@ int writeindividualtimes(struct dquot *q die(1, _("Can't duplicate descriptor of file to write to: %s\n"), strerror(errno)); fprintf(fd, _("Times to enforce softlimit for %s %s (%cid %d):\n"), - type2name(quotatype), name, *type2name(quotatype), name2id(name, quotatype, NULL)); + type2name(quotatype), name, *type2name(quotatype), name2id(name, quotatype, 0, NULL)); fprintf(fd, _("Time units may be: days, hours, minutes, or seconds\n")); fprintf(fd, _(" Filesystem block grace inode grace\n")); diff -urNp quota-tools-orig/quotasys.c quota-tools/quotasys.c --- quota-tools-orig/quotasys.c 2005-06-24 14:12:16.000000000 +0200 +++ quota-tools/quotasys.c 2008-07-17 12:30:24.000000000 +0200 @@ -89,7 +89,7 @@ char *type2name(int type) /* * Convert name to uid */ -uid_t user2uid(char *name, int *err) +uid_t user2uid(char *name, int flag, int *err) { struct passwd *entry; uid_t ret; @@ -97,9 +97,11 @@ uid_t user2uid(char *name, int *err) if (err) *err = 0; - ret = strtol(name, &errch, 0); - if (!*errch) /* Is name number - we got directly uid? */ - return ret; + if (!flag) { + ret = strtol(name, &errch, 0); + if (!*errch) /* Is name number - we got directly uid? */ + return ret; + } if (!(entry = getpwnam(name))) { if (!err) { errstr(_("User %s doesn't exist.\n"), name); @@ -116,7 +118,7 @@ uid_t user2uid(char *name, int *err) /* * Convert group name to gid */ -gid_t group2gid(char *name, int *err) +gid_t group2gid(char *name, int flag, int *err) { struct group *entry; gid_t ret; @@ -124,9 +126,11 @@ gid_t group2gid(char *name, int *err) if (err) *err = 0; - ret = strtol(name, &errch, 0); - if (!*errch) /* Is name number - we got directly gid? */ - return ret; + if (!flag) { + ret = strtol(name, &errch, 0); + if (!*errch) /* Is name number - we got directly gid? */ + return ret; + } if (!(entry = getgrnam(name))) { if (!err) { errstr(_("Group %s doesn't exist.\n"), name); @@ -143,12 +147,12 @@ gid_t group2gid(char *name, int *err) /* * Convert name to id */ -int name2id(char *name, int qtype, int *err) +int name2id(char *name, int qtype, int flag, int *err) { if (qtype == USRQUOTA) - return user2uid(name, err); + return user2uid(name, flag, err); else - return group2gid(name, err); + return group2gid(name, flag, err); } /* diff -urNp quota-tools-orig/quotasys.h quota-tools/quotasys.h --- quota-tools-orig/quotasys.h 2005-06-01 09:21:30.000000000 +0200 +++ quota-tools/quotasys.h 2008-07-17 12:31:29.000000000 +0200 @@ -46,13 +46,13 @@ int nfs_fstype(char *); char *type2name(int); /* Convert username to uid */ -uid_t user2uid(char *, int *err); +uid_t user2uid(char *, int flag, int *err); /* Convert groupname to gid */ -gid_t group2gid(char *, int *err); +gid_t group2gid(char *, int flag, int *err); /* Convert user/groupname to id */ -int name2id(char *name, int qtype, int *err); +int name2id(char *name, int qtype, int flag, int *err); /* Convert uid to username */ int uid2user(uid_t, char *); diff -urNp quota-tools-orig/edquota.8 quota-tools/edquota.8 --- quota-tools-orig/edquota.8 2005-06-01 09:21:28.000000000 +0200 +++ quota-tools/edquota.8 2008-07-17 14:01:03.000000000 +0200 @@ -12,6 +12,8 @@ edquota \- edit user quotas ] [ .B \-r ] [ +.B \-x +] [ .B \-F .I format-name ] [ @@ -25,6 +27,8 @@ edquota \- edit user quotas .BR \-u \ | .B \-g ] [ +.B \-x +] [ .B \-F .I format-name ] [ @@ -38,6 +42,8 @@ edquota \- edit user quotas .BR \-u \ | .B \-g ] [ +.B \-x +] [ .B \-F .I format-name ] [ @@ -101,6 +107,9 @@ Edit the user quota. This is the default .B \-g Edit the group quota. .TP +.B \-x +Always try to translate name to id, even if it is composed of only digits. +.TP .B \-p \f2protoname\f1 Duplicate the quotas of the prototypical user specified for each user specified. This is the normal diff -urNp quota-tools-orig/quota.1 quota-tools/quota.1 --- quota-tools-orig/quota.1 2004-04-20 21:30:54.000000000 +0200 +++ quota-tools/quota.1 2008-07-17 12:11:30.000000000 +0200 @@ -7,7 +7,7 @@ quota \- display disk usage and limits .B -F .I format-name ] [ -.BR -guvsil \ | +.BR -guvxsil \ | .B q ] .br @@ -16,7 +16,7 @@ quota \- display disk usage and limits .B -F .I format-name ] [ -.BR -uvsil \ | +.BR -uvxsil \ | .B q ] .IR user ... @@ -26,7 +26,7 @@ quota \- display disk usage and limits .B -F .I format-name ] [ -.BR -gvsil \ | +.BR -gvxsil \ | .B q ] .IR group ... @@ -84,6 +84,9 @@ Print a more terse message, containing only information on filesystems where usage is over quota. .TP +.B \-x +Always try to translate name to id, even if it is composed of only digits. +.TP .B \-Q Do not print error message if connection to rpc.rquotad is refused (usually this happens when rpc.rquotad is not running on the server). diff -urNp quota-tools-orig/setquota.8 quota-tools/setquota.8 --- quota-tools-orig/setquota.8 2004-10-20 12:33:11.000000000 +0200 +++ quota-tools/setquota.8 2008-07-17 14:03:15.000000000 +0200 @@ -12,6 +12,9 @@ setquota \- set disk quotas .B \-g ] [ +.B \-x +] +[ .B \-F .I quotaformat ] @@ -34,6 +37,9 @@ setquota \- set disk quotas .B \-g ] [ +.B \-x +] +[ .B \-F .I quotaformat ] @@ -57,6 +63,9 @@ setquota \- set disk quotas .B \-g ] [ +.B \-x +] +[ .B \-F .I quotaformat ] @@ -72,6 +81,9 @@ setquota \- set disk quotas .B \-g ] [ +.B \-x +] +[ .B \-F .I quotaformat ] @@ -89,6 +101,9 @@ setquota \- set disk quotas .B \-g ] [ +.B \-x +] +[ .B \-F .I quotaformat ] @@ -134,6 +149,9 @@ Set user quotas for named user. This is .B -g Set group quotas for named group. .TP +.B \-x +Always try to translate name to id, even if it is composed of only digits. +.TP .B -p \f2protoname\f1 Use quota settings of user or group .I protoname diff -urNp quota-tools-orig/setquota.c quota-tools/setquota.c --- quota-tools-orig/setquota.c 2004-07-13 13:19:49.000000000 +0200 +++ quota-tools/setquota.c 2008-07-17 12:25:31.000000000 +0200 @@ -29,6 +29,7 @@ #define FL_GRACE 32 #define FL_INDIVIDUAL_GRACE 64 #define FL_BATCH 128 +#define FL_ALWAYSRESOLVE 256 int flags, fmt = -1; char **mnt; @@ -42,20 +43,20 @@ static void usage(void) { #if defined(RPC_SETQUOTA) errstr(_("Usage:\n" - " setquota [-u|-g] [-r] [-F quotaformat] <user|group>\n" + " setquota [-u|-g] [-x] [-r] [-F quotaformat] <user|group>\n" "\t<block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> -a|<filesystem>...\n" - " setquota [-u|-g] [-r] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n" - " setquota [-u|-g] [-r] [-F quotaformat] -b -a|<filesystem>...\n" - " setquota [-u|-g] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n" - " setquota [-u|-g] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n")); + " setquota [-u|-g] [-x] [-r] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n" + " setquota [-u|-g] [-x] [-r] [-F quotaformat] -b -a|<filesystem>...\n" + " setquota [-u|-g] [-x] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n" + " setquota [-u|-g] [-x] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n")); #else errstr(_("Usage:\n" - " setquota [-u|-g] [-F quotaformat] <user|group>\n" + " setquota [-u|-g] [-x] [-F quotaformat] <user|group>\n" "\t<block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> -a|<filesystem>...\n" - " setquota [-u|-g] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n" - " setquota [-u|-g] [-F quotaformat] -b -a|<filesystem>...\n" - " setquota [-u|-g] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n" - " setquota [-u|-g] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n")); + " setquota [-u|-g] [-x] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n" + " setquota [-u|-g] [-x] [-F quotaformat] -b -a|<filesystem>...\n" + " setquota [-u|-g] [-x] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n" + " setquota [-u|-g] [-x] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n")); #endif fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL); exit(1); @@ -91,9 +92,9 @@ static void parse_options(int argcnt, ch char *protoname = NULL; #ifdef RPC_SETQUOTA - char *opts = "igp:urVF:taTb"; + char *opts = "igp:urxVF:taTb"; #else - char *opts = "igp:uVF:taTb"; + char *opts = "igp:uxVF:taTb"; #endif while ((ret = getopt(argcnt, argstr, opts)) != -1) { @@ -126,6 +127,9 @@ static void parse_options(int argcnt, ch case 'T': flags |= FL_INDIVIDUAL_GRACE; break; + case 'x': + flags |= FL_ALWAYSRESOLVE; + break; case 'F': if ((fmt = name2fmt(optarg)) == QF_ERROR) exit(1); @@ -173,7 +177,7 @@ static void parse_options(int argcnt, ch if (!(flags & (FL_USER | FL_GROUP))) flags |= FL_USER; if (!(flags & (FL_GRACE | FL_BATCH))) { - id = name2id(argstr[optind++], flag2type(flags), NULL); + id = name2id(argstr[optind++], flag2type(flags), !!(flags & FL_ALWAYSRESOLVE), NULL); if (!(flags & (FL_GRACE | FL_INDIVIDUAL_GRACE | FL_PROTO))) { toset.dqb_bsoftlimit = parse_num(argstr[optind++], _("block softlimit")); toset.dqb_bhardlimit = parse_num(argstr[optind++], _("block hardlimit")); @@ -181,7 +185,7 @@ static void parse_options(int argcnt, ch toset.dqb_ihardlimit = parse_num(argstr[optind++], _("inode hardlimit")); } else if (flags & FL_PROTO) - protoid = name2id(protoname, flag2type(flags), NULL); + protoid = name2id(protoname, flag2type(flags), !!(flags & FL_ALWAYSRESOLVE), NULL); } if (flags & FL_GRACE) { toset.dqb_btime = parse_num(argstr[optind++], _("block grace time")); @@ -265,7 +269,7 @@ static int read_entry(qid_t *id, qsize_t if (ret != 5) die(1, _("Cannot parse input line %d.\n"), line); ret = 0; - *id = name2id(name, flag2type(flags), &ret); + *id = name2id(name, flag2type(flags), !!(flags & FL_ALWAYSRESOLVE), &ret); if (ret) errstr(_("Unable to get name '%s'.\n"), name); } while (ret);