-int
-my_getgrnam(char *name, gid_t *gid)
-{
- return my_getid("/etc/group", name, gid);
-}
-
-const char chown_usage[] = "chown [-R] user-name file [file ...]\n"
-"\n\tThe group list is kept in the file /etc/groups.\n\n"
-"\t-R:\tRecursively change the mode of all files and directories\n"
-"\t\tunder the argument directory.";
-
-int
-parse_user_name(const char * s, struct FileInfo * i)
-{
- char * dot = strchr(s, '.');
- char * end = NULL;
- uid_t id = 0;
-
- if (! dot )
- dot = strchr(s, ':');
-
- if ( dot )
- *dot = '\0';
-
- if ( my_getpwnam(s,&id) == -1 ) {
- id = strtol(s,&end,10);
- if ((*end != '\0') || ( my_getpwuid(&id) == -1 )) {
- fprintf(stderr, "%s: no such user.\n", s);
- return 1;
- }
- }
- i->userID = id;
-
- if ( dot ) {
- if ( my_getgrnam(++dot,&id) == -1 ) {
- id = strtol(dot,&end,10);
- if ((*end != '\0') || ( my_getgrgid(&id) == -1 )) {
- fprintf(stderr, "%s: no such group.\n", dot);
- return 1;
+ /* Find the selected user (if appropriate) */
+ if (whichApp == CHOWN_APP) {
+ uid = strtoul(*argv, &p, 10); /* if numeric ... */
+ if (*argv == p)
+ uid = my_getpwnam(*argv);
+ if (uid == -1) {
+ fatalError( "%s: unknown user name: %s\n",
+ invocationName, *argv);