diff options
Diffstat (limited to 'ax25')
-rw-r--r-- | ax25/axparms.8 | 2 | ||||
-rw-r--r-- | ax25/axparms.c | 27 |
2 files changed, 22 insertions, 7 deletions
diff --git a/ax25/axparms.8 b/ax25/axparms.8 index 3187158..d4b1b7c 100644 --- a/ax25/axparms.8 +++ b/ax25/axparms.8 @@ -21,7 +21,7 @@ and so no generalised command format can be given. The format of this option is: .LP .nf -.B axparms --assoc <callsign> <username> +.B axparms --assoc <callsign> <username|uid> .br .B axparms --assoc <callsign> delete .br diff --git a/ax25/axparms.c b/ax25/axparms.c index a3795e3..5c49e58 100644 --- a/ax25/axparms.c +++ b/ax25/axparms.c @@ -1,3 +1,4 @@ +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -168,9 +169,10 @@ int setifcall(int s, char *ifn, char *name) int associate(int s, int argc, char *argv[]) { - char buffer[80], *u, *c; + char buffer[80], *u, *c, *endp; struct sockaddr_ax25 sax25; struct passwd *pw; + uid_t uid; int opt; FILE *fp; @@ -254,12 +256,25 @@ int associate(int s, int argc, char *argv[]) return 0; } - if ((pw = getpwnam(argv[3])) == NULL) { - fprintf(stderr, "axparms: associate: unknown username %s\n", argv[3]); - return 1; - } + /* + * Tolerate spaces following a UID, it may happen in scripts + */ + errno = 0; + uid = strtol(argv[3], &endp, 0); + if (!errno && (*endp == '\0' || isspace(*endp))) { + sax25.sax25_uid = uid; + } else { + pw = getpwnam(argv[3]); + + if (pw == NULL) { + fprintf(stderr, + "axparms: associate: unknown username %s\n", + argv[3]); + return 1; + } - sax25.sax25_uid = pw->pw_uid; + sax25.sax25_uid = pw->pw_uid; + } if (ioctl(s, SIOCAX25ADDUID, &sax25) == -1) { perror("axparms: SIOCAX25ADDUID"); |