diff options
| author | Andy Fiddaman <omnios@citrus-it.co.uk> | 2021-03-08 20:24:26 +0000 |
|---|---|---|
| committer | Andy Fiddaman <omnios@citrus-it.co.uk> | 2021-03-16 15:24:36 +0000 |
| commit | 4162633a7c5961f388fdc51bcecb3016104b359f (patch) | |
| tree | c6711300cd978322fa792110a07ef7f125bca084 /usr | |
| parent | 974fceab66899bd599db3037669647d0e261838d (diff) | |
| download | illumos-joyent-4162633a7c5961f388fdc51bcecb3016104b359f.tar.gz | |
3782 ksh93's builtin chown fails with numeric ids
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr')
| -rw-r--r-- | usr/src/contrib/ast/src/lib/libcmd/chgrp.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr/src/contrib/ast/src/lib/libcmd/chgrp.c b/usr/src/contrib/ast/src/lib/libcmd/chgrp.c index 680e46294e..98bd5dde80 100644 --- a/usr/src/contrib/ast/src/lib/libcmd/chgrp.c +++ b/usr/src/contrib/ast/src/lib/libcmd/chgrp.c @@ -134,7 +134,13 @@ typedef struct Map_s /* uid/gid map */ Key_t to; /* map to these */ } Map_t; +/* + * libast's struid() has the peculiar feature that it returns -1 in response + * to not finding a UID for a name on the first call, and -2 for subsequent + * calls for the same string. + */ #define NOID (-1) +#define STILLNOID (-2) #define OPT_CHOWN 0x0001 /* chown */ #define OPT_FORCE 0x0002 /* ignore errors */ @@ -180,7 +186,7 @@ getids(register char* s, char** e, Key_t* key, int options) n = (int)strtol(s, &z, 0); if (*z || !(options & OPT_NUMERIC)) { - if ((m = struid(s)) != NOID) + if ((m = struid(s)) != NOID && m != STILLNOID) n = m; else if (*z) error(ERROR_exit(1), "%s: unknown user", s); @@ -200,7 +206,7 @@ getids(register char* s, char** e, Key_t* key, int options) n = (int)strtol(s, &z, 0); if (*z || !(options & OPT_NUMERIC)) { - if ((m = strgid(s)) != NOID) + if ((m = strgid(s)) != NOID && m != STILLNOID) n = m; else if (*z) error(ERROR_exit(1), "%s: unknown group", s); |
