summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--ax25/axparms.82
-rw-r--r--ax25/axparms.c27
3 files changed, 23 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 89b1a46..7caf16e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@ ax25-tools (0.0.10)
* Fix build issues with modern autoconf, automake and GCC.
* For the tarball release Regenerate generates files with most
recent autoconf and automake.
+ * axparms --assoc now also accepts a numeric user id.
-- Ralf Baechle DL5RB <ralf@linux-mips.org> Sat, 6 Jun 2015 14:29:07 +0200
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");