5 |
* Written for SLIND (from passwd.c) by Alexander Shishkin <virtuoso@slind.org> |
* Written for SLIND (from passwd.c) by Alexander Shishkin <virtuoso@slind.org> |
6 |
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
7 |
*/ |
*/ |
|
|
|
8 |
#include "libbb.h" |
#include "libbb.h" |
9 |
|
|
10 |
#if ENABLE_GETOPT_LONG |
#if ENABLE_LONG_OPTS |
11 |
static const char chpasswd_longopts[] ALIGN1 = |
static const char chpasswd_longopts[] ALIGN1 = |
12 |
"encrypted\0" No_argument "e" |
"encrypted\0" No_argument "e" |
13 |
"md5\0" No_argument "m" |
"md5\0" No_argument "m" |
29 |
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
30 |
|
|
31 |
opt_complementary = "m--e:e--m"; |
opt_complementary = "m--e:e--m"; |
32 |
USE_GETOPT_LONG(applet_long_options = chpasswd_longopts;) |
IF_LONG_OPTS(applet_long_options = chpasswd_longopts;) |
33 |
opt = getopt32(argv, "em"); |
opt = getopt32(argv, "em"); |
34 |
|
|
35 |
while ((name = xmalloc_fgetline(stdin)) != NULL) { |
while ((name = xmalloc_fgetline(stdin)) != NULL) { |
52 |
/* This is rather complex: if user is not found in /etc/shadow, |
/* This is rather complex: if user is not found in /etc/shadow, |
53 |
* we try to find & change his passwd in /etc/passwd */ |
* we try to find & change his passwd in /etc/passwd */ |
54 |
#if ENABLE_FEATURE_SHADOWPASSWDS |
#if ENABLE_FEATURE_SHADOWPASSWDS |
55 |
rc = update_passwd(bb_path_shadow_file, name, pass); |
rc = update_passwd(bb_path_shadow_file, name, pass, NULL); |
56 |
if (rc == 0) /* no lines updated, no errors detected */ |
if (rc == 0) /* no lines updated, no errors detected */ |
57 |
#endif |
#endif |
58 |
rc = update_passwd(bb_path_passwd_file, name, pass); |
rc = update_passwd(bb_path_passwd_file, name, pass, NULL); |
59 |
/* LOGMODE_BOTH logs to syslog also */ |
/* LOGMODE_BOTH logs to syslog also */ |
60 |
logmode = LOGMODE_BOTH; |
logmode = LOGMODE_BOTH; |
61 |
if (rc < 0) |
if (rc < 0) |