Hi

I have a patch for adduser to support the option "-S: Create a system 
user", which is presently accepted but ignored.

Also I changed the range for normal users to start at 1000 instead of 
500, which is what most current distributions do.

As a side note:
It is not possible to create users with group 0. The code seems to 
create a new group with same and same number as the new user.
Why would that be useful?
Also, I think it is possible that this implementation results in 
duplicate user ids:
The first loop, "while (!fgetpwent_r(..." find a free user id.
The second loop, "while (getgrgid(p->pw_uid)) p->pw_uid++;" increments 
uid until it finds an unused group id.
It is possible that this incremented uid is in use as a user id.

Regards
Ralf Friedl

Index: loginutils/adduser.c
===================================================================
--- loginutils/adduser.c
+++ loginutils/adduser.c
@@ -11,6 +11,7 @@
 #include "libbb.h"

 #define OPT_DONT_SET_PASS  (1 << 4)
+#define OPT_SYSTEM_ACCOUNT (1 << 5)
 #define OPT_DONT_MAKE_HOME (1 << 6)


@@ -18,14 +19,24 @@
 /* EDR recoded such that the uid may be passed in *p */
 static int passwd_study(const char *filename, struct passwd *p)
 {
-       enum { min = 500, max = 65000 };
        FILE *passwd;
        /* We are using reentrant fgetpwent_r() in order to avoid
         * pulling in static buffers from libc (think static build here) */
        char buffer[256];
        struct passwd pw;
        struct passwd *result;
+       int min, max;

+        if (option_mask32 & OPT_SYSTEM_ACCOUNT) {
+               min = 1;
+               max = 999;
+       }
+       else {
+               min = 1000;
+               max = 65000;
+       }
+
+
        passwd = xfopen(filename, "r");

        /* EDR if uid is out of bounds, set to min */
Index: include/usage.h
===================================================================
--- include/usage.h
+++ include/usage.h
@@ -27,7 +27,7 @@
        "       -g GECOS        GECOS field\n" \
        "       -s SHELL        Login shell\n" \
        "       -G GROUP        Add user to existing group\n" \
-       "       -S              Create a system user (ignored)\n" \
+       "       -S              Create a system user\n" \
        "       -D              Do not assign a password\n" \
        "       -H              Do not create home directory"

_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to