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/cryptpw.c

    r3232 r3621  
    1010 * Licensed under GPLv2, see file LICENSE in this source tree.
    1111 */
     12//config:config CRYPTPW
     13//config:   bool "cryptpw"
     14//config:   default y
     15//config:   help
     16//config:     Encrypts the given password with the crypt(3) libc function
     17//config:     using the given salt.
     18//config:
     19//config:config MKPASSWD
     20//config:   bool "mkpasswd"
     21//config:   default y
     22//config:   help
     23//config:     Encrypts the given password with the crypt(3) libc function
     24//config:     using the given salt. Debian has this utility under mkpasswd
     25//config:     name. Busybox provides mkpasswd as an alias for cryptpw.
     26
     27//applet:IF_CRYPTPW(APPLET(cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP))
     28//                   APPLET_ODDNAME:name      main     location        suid_type     help
     29//applet:IF_MKPASSWD(APPLET_ODDNAME(mkpasswd, cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP, cryptpw))
     30
     31//kbuild:lib-$(CONFIG_CRYPTPW) += cryptpw.o
     32//kbuild:lib-$(CONFIG_MKPASSWD) += cryptpw.o
    1233
    1334//usage:#define cryptpw_trivial_usage
     
    1536/* We do support -s, we just don't mention it */
    1637//usage:#define cryptpw_full_usage "\n\n"
    17 //usage:       "Crypt PASSWORD using crypt(3)\n"
    18 //usage:    IF_LONG_OPTS(
    19 //usage:     "\n    -P,--password-fd=N  Read password from fd N"
    20 /* //usage:  "\n    -s,--stdin      Use stdin; like -P0" */
    21 //usage:     "\n    -m,--method=TYPE    Encryption method"
    22 //usage:     "\n    -S,--salt=SALT"
    23 //usage:    )
    24 //usage:    IF_NOT_LONG_OPTS(
    25 //usage:     "\n    -P N    Read password from fd N"
    26 /* //usage:  "\n    -s  Use stdin; like -P0" */
    27 //usage:     "\n    -m TYPE Encryption method TYPE"
    28 //usage:     "\n    -S SALT"
    29 //usage:    )
    30 
    31 /* mkpasswd is an alias to cryptpw */
    32 //usage:#define mkpasswd_trivial_usage
    33 //usage:       "[OPTIONS] [PASSWORD] [SALT]"
    34 /* We do support -s, we just don't mention it */
    35 //usage:#define mkpasswd_full_usage "\n\n"
    3638//usage:       "Crypt PASSWORD using crypt(3)\n"
    3739//usage:    IF_LONG_OPTS(
     
    9395    char salt[MAX_PW_SALT_LEN];
    9496    char *salt_ptr;
     97    char *password;
    9598    const char *opt_m, *opt_S;
    9699    int fd;
     
    124127    xmove_fd(fd, STDIN_FILENO);
    125128
    126     puts(pw_encrypt(
    127         argv[0] ? argv[0] : (
    128             /* Only mkpasswd, and only from tty, prompts.
    129             * Otherwise it is a plain read. */
    130             (isatty(STDIN_FILENO) && applet_name[0] == 'm')
     129    password = argv[0];
     130    if (!password) {
     131        /* Only mkpasswd, and only from tty, prompts.
     132        * Otherwise it is a plain read. */
     133        password = (ENABLE_MKPASSWD && isatty(STDIN_FILENO) && applet_name[0] == 'm')
    131134            ? bb_ask_stdin("Password: ")
    132135            : xmalloc_fgetline(stdin)
    133         ),
    134         salt, 1));
     136        ;
     137        /* may still be NULL on EOF/error */
     138    }
     139
     140    if (password)
     141        puts(pw_encrypt(password, salt, 1));
    135142
    136143    return EXIT_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.