Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/loginutils/adduser.c

    r3232 r3621  
    88 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    99 */
     10//config:config ADDUSER
     11//config:   bool "adduser"
     12//config:   default y
     13//config:   help
     14//config:     Utility for creating a new user account.
     15//config:
     16//config:config FEATURE_ADDUSER_LONG_OPTIONS
     17//config:   bool "Enable long options"
     18//config:   default y
     19//config:   depends on ADDUSER && LONG_OPTS
     20//config:   help
     21//config:     Support long options for the adduser applet.
     22//config:
     23//config:config FEATURE_CHECK_NAMES
     24//config:   bool "Enable sanity check on user/group names in adduser and addgroup"
     25//config:   default n
     26//config:   depends on ADDUSER || ADDGROUP
     27//config:   help
     28//config:     Enable sanity check on user and group names in adduser and addgroup.
     29//config:     To avoid problems, the user or group name should consist only of
     30//config:     letters, digits, underscores, periods, at signs and dashes,
     31//config:     and not start with a dash (as defined by IEEE Std 1003.1-2001).
     32//config:     For compatibility with Samba machine accounts "$" is also supported
     33//config:     at the end of the user or group name.
     34//config:
     35//config:config LAST_ID
     36//config:   int "Last valid uid or gid for adduser and addgroup"
     37//config:   depends on ADDUSER || ADDGROUP
     38//config:   default 60000
     39//config:   help
     40//config:     Last valid uid or gid for adduser and addgroup
     41//config:
     42//config:config FIRST_SYSTEM_ID
     43//config:   int "First valid system uid or gid for adduser and addgroup"
     44//config:   depends on ADDUSER || ADDGROUP
     45//config:   range 0 LAST_ID
     46//config:   default 100
     47//config:   help
     48//config:     First valid system uid or gid for adduser and addgroup
     49//config:
     50//config:config LAST_SYSTEM_ID
     51//config:   int "Last valid system uid or gid for adduser and addgroup"
     52//config:   depends on ADDUSER || ADDGROUP
     53//config:   range FIRST_SYSTEM_ID LAST_ID
     54//config:   default 999
     55//config:   help
     56//config:     Last valid system uid or gid for adduser and addgroup
     57
     58//applet:IF_ADDUSER(APPLET(adduser, BB_DIR_USR_SBIN, BB_SUID_DROP))
     59
     60//kbuild:lib-$(CONFIG_ADDUSER) += adduser.o
    1061
    1162//usage:#define adduser_trivial_usage
     
    2172//usage:     "\n    -H      Don't create home directory"
    2273//usage:     "\n    -u UID      User id"
     74//usage:     "\n    -k SKEL     Skeleton directory (/etc/skel)"
    2375
    2476#include "libbb.h"
     
    2779#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config
    2880#endif
     81#if CONFIG_LAST_ID < CONFIG_LAST_SYSTEM_ID
     82#error Bad LAST_ID or LAST_SYSTEM_ID in .config
     83#endif
     84
    2985
    3086/* #define OPT_HOME           (1 << 0) */ /* unused */
     
    3692#define OPT_DONT_MAKE_HOME (1 << 6)
    3793#define OPT_UID            (1 << 7)
    38 
    39 /* We assume UID_T_MAX == INT_MAX */
     94#define OPT_SKEL           (1 << 8)
     95
    4096/* remix */
    4197/* recoded such that the uid may be passed in *p */
    4298static void passwd_study(struct passwd *p)
    4399{
    44     int max = UINT_MAX;
     100    int max = CONFIG_LAST_ID;
    45101
    46102    if (getpwnam(p->pw_name)) {
     
    55111        } else {
    56112            p->pw_uid = CONFIG_LAST_SYSTEM_ID + 1;
    57             max = 64999;
    58113        }
    59114    }
     
    133188        "no-create-home\0"      No_argument       "H"
    134189        "uid\0"                 Required_argument "u"
     190        "skel\0"                Required_argument "k"
    135191        ;
    136192#endif
     
    148204    char *p;
    149205    unsigned opts;
     206    char *uid;
     207    const char *skel = "/etc/skel";
    150208
    151209#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
     
    163221    pw.pw_dir = NULL;
    164222
    165     /* at most two non-option args */
     223    /* at least one and at most two non-option args */
    166224    /* disable interactive passwd for system accounts */
    167     opt_complementary = "?2:SD:u+";
    168     if (sizeof(pw.pw_uid) == sizeof(int)) {
    169         opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &pw.pw_uid);
    170     } else {
    171         unsigned uid;
    172         opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid);
    173         if (opts & OPT_UID) {
    174             pw.pw_uid = uid;
    175         }
    176     }
     225    opt_complementary = "-1:?2:SD";
     226    opts = getopt32(argv, "h:g:s:G:DSHu:k:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid, &skel);
     227    if (opts & OPT_UID)
     228        pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID);
     229
    177230    argv += optind;
    178231    pw.pw_name = argv[0];
     
    253306            };
    254307            /* Be silent on any errors (like: no /etc/skel) */
    255             logmode = LOGMODE_NONE;
    256             copy_file("/etc/skel", pw.pw_dir, FILEUTILS_RECUR);
     308            if (!(opts & OPT_SKEL))
     309                logmode = LOGMODE_NONE;
     310            copy_file(skel, pw.pw_dir, FILEUTILS_RECUR);
    257311            logmode = LOGMODE_STDIO;
    258312            chown_main(4, (char**)args);
Note: See TracChangeset for help on using the changeset viewer.