setaudit: Fix handling of numeric UIDs
The usage of strtoul() was incorrect. Reviewed by: csjp MFC after: 2 weeks Sponsored by: Modirum MDPay Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D53671
This commit is contained in:
@@ -45,7 +45,7 @@ Use IPv4.
|
||||
.It Fl 6
|
||||
Use IPv6.
|
||||
.It Fl a Ar auid
|
||||
Audit user ID.
|
||||
Audit user ID or user name.
|
||||
.It Fl m Ar mask
|
||||
String representation of an audit mask.
|
||||
.It Fl s Ar source
|
||||
|
||||
@@ -58,7 +58,7 @@ main(int argc, char *argv [])
|
||||
auditinfo_addr_t aia;
|
||||
struct addrinfo *res;
|
||||
struct passwd *pwd;
|
||||
char *aflag, *mflag, *sflag, *r, *prog;
|
||||
char *aflag, *mflag, *sflag, *prog;
|
||||
int ch, error;
|
||||
|
||||
aflag = mflag = sflag = NULL;
|
||||
@@ -99,8 +99,10 @@ main(int argc, char *argv [])
|
||||
if (aflag) {
|
||||
pwd = getpwnam(aflag);
|
||||
if (pwd == NULL) {
|
||||
char *r;
|
||||
|
||||
aia.ai_auid = strtoul(aflag, &r, 10);
|
||||
if (r != NULL)
|
||||
if (*r != '\0')
|
||||
errx(1, "%s: invalid user", aflag);
|
||||
} else
|
||||
aia.ai_auid = pwd->pw_uid;
|
||||
|
||||
Reference in New Issue
Block a user