chown: fix user:group option parsing
Check that either user or group is correctly passed, and adapt documention according to that.
This commit is contained in:
parent
6e7743eb56
commit
a02d66b8fc
14
chown.1
14
chown.1
|
@ -11,15 +11,23 @@
|
||||||
.Fl R
|
.Fl R
|
||||||
.Op Fl H | L | P
|
.Op Fl H | L | P
|
||||||
.Oc
|
.Oc
|
||||||
.Op Ar owner Op Ar :group
|
.Ar owner Ns Op Pf : Op Ar group
|
||||||
|
.Op Ar file ...
|
||||||
|
.Nm
|
||||||
|
.Op Fl h
|
||||||
|
.Oo
|
||||||
|
.Fl R
|
||||||
|
.Op Fl H | L | P
|
||||||
|
.Oc
|
||||||
|
.Pf : Ar group
|
||||||
.Op Ar file ...
|
.Op Ar file ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
sets the user or group id of each
|
sets the user and/or group id of each
|
||||||
.Ar file
|
.Ar file
|
||||||
to the uid of
|
to the uid of
|
||||||
.Ar owner
|
.Ar owner
|
||||||
or the gid of
|
and/or the gid of
|
||||||
.Ar group
|
.Ar group
|
||||||
respectively.
|
respectively.
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
|
|
8
chown.c
8
chown.c
|
@ -40,8 +40,9 @@ chownpwgr(const char *path, struct stat *st, void *data, struct recursor *r)
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-h] [-R [-H | -L | -P]] [owner][:[group]] "
|
eprintf("usage: %s [-h] [-R [-H | -L | -P]] owner[:[group]] file ...\n"
|
||||||
"file ...\n", argv0);
|
" %s [-h] [-R [-H | -L | -P]] :group file ...\n",
|
||||||
|
argv0, argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -99,6 +100,9 @@ main(int argc, char *argv[])
|
||||||
gid = estrtonum(group, 0, UINT_MAX);
|
gid = estrtonum(group, 0, UINT_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (uid == (uid_t)-1 && gid == (gid_t)-1)
|
||||||
|
usage();
|
||||||
|
|
||||||
for (argc--, argv++; *argv; argc--, argv++)
|
for (argc--, argv++; *argv; argc--, argv++)
|
||||||
recurse(*argv, NULL, &r);
|
recurse(*argv, NULL, &r);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user