summaryrefslogtreecommitdiffstats
path: root/CommandLine.c
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2021-10-04 15:08:55 +0200
committerBenBE <BenBE@geshi.org>2021-10-24 04:39:58 +0200
commitdfa62506b7b412eeaea8efe1a5cb68e34fbfa88c (patch)
tree0b74defec6a07f6554f61387d6d17f2b8df8a58a /CommandLine.c
parent731b4003a2d764dadcd0243ce86e4e4cdc23dd5f (diff)
Allow -u UID
Defaults to username, of course, like all POSIX utilities do
Diffstat (limited to 'CommandLine.c')
-rw-r--r--CommandLine.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/CommandLine.c b/CommandLine.c
index a352e4e3..c48572c2 100644
--- a/CommandLine.c
+++ b/CommandLine.c
@@ -11,6 +11,7 @@ in the source distribution for its full text.
#include "CommandLine.h"
#include <assert.h>
+#include <ctype.h>
#include <getopt.h>
#include <locale.h>
#include <stdbool.h>
@@ -178,8 +179,12 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
if (!username) {
flags.userId = geteuid();
} else if (!Action_setUserOnly(username, &(flags.userId))) {
- fprintf(stderr, "Error: invalid user \"%s\".\n", username);
- exit(1);
+ for (const char *itr = username; *itr; ++itr)
+ if (!isdigit((unsigned char)*itr)) {
+ fprintf(stderr, "Error: invalid user \"%s\".\n", username);
+ exit(1);
+ }
+ flags.userId = atol(username);
}
break;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy