Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Upstream-Status: Inappropriate [OE specific] |
| 2 | |
| 3 | Allow for setting password in clear text. |
| 4 | |
| 5 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
| 6 | --- |
| 7 | src/Makefile.am | 8 ++++---- |
| 8 | src/groupadd.c | 8 +++++++- |
| 9 | src/groupmod.c | 8 +++++++- |
| 10 | src/useradd.c | 9 +++++++-- |
| 11 | src/usermod.c | 8 +++++++- |
| 12 | 5 files changed, 32 insertions(+), 9 deletions(-) |
| 13 | |
| 14 | diff --git a/src/Makefile.am b/src/Makefile.am |
| 15 | index 25e288d..856b087 100644 |
| 16 | --- a/src/Makefile.am |
| 17 | +++ b/src/Makefile.am |
| 18 | @@ -88,10 +88,10 @@ chgpasswd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBSELINUX) $(LIBCRYPT) |
| 19 | chsh_LDADD = $(LDADD) $(LIBPAM) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) |
| 20 | chpasswd_LDADD = $(LDADD) $(LIBPAM) $(LIBSELINUX) $(LIBCRYPT) |
| 21 | gpasswd_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) |
| 22 | -groupadd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) |
| 23 | +groupadd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) |
| 24 | groupdel_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) |
| 25 | groupmems_LDADD = $(LDADD) $(LIBPAM) $(LIBSELINUX) |
| 26 | -groupmod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) |
| 27 | +groupmod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) |
| 28 | grpck_LDADD = $(LDADD) $(LIBSELINUX) |
| 29 | grpconv_LDADD = $(LDADD) $(LIBSELINUX) |
| 30 | grpunconv_LDADD = $(LDADD) $(LIBSELINUX) |
| 31 | @@ -111,9 +111,9 @@ su_SOURCES = \ |
| 32 | suauth.c |
| 33 | su_LDADD = $(LDADD) $(LIBPAM) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) |
| 34 | sulogin_LDADD = $(LDADD) $(LIBCRYPT) |
| 35 | -useradd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) |
| 36 | +useradd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) $(LIBCRYPT) |
| 37 | userdel_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) |
| 38 | -usermod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) |
| 39 | +usermod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) $(LIBCRYPT) |
| 40 | vipw_LDADD = $(LDADD) $(LIBSELINUX) |
| 41 | |
| 42 | install-am: all-am |
| 43 | diff --git a/src/groupadd.c b/src/groupadd.c |
| 44 | index f716f57..4e28c26 100644 |
| 45 | --- a/src/groupadd.c |
| 46 | +++ b/src/groupadd.c |
| 47 | @@ -124,6 +124,7 @@ static /*@noreturn@*/void usage (int status) |
| 48 | (void) fputs (_(" -o, --non-unique allow to create groups with duplicate\n" |
| 49 | " (non-unique) GID\n"), usageout); |
| 50 | (void) fputs (_(" -p, --password PASSWORD use this encrypted password for the new group\n"), usageout); |
| 51 | + (void) fputs (_(" -P, --clear-password PASSWORD use this clear password for the new group\n"), usageout); |
| 52 | (void) fputs (_(" -r, --system create a system account\n"), usageout); |
| 53 | (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); |
| 54 | (void) fputs ("\n", usageout); |
| 55 | @@ -387,12 +388,13 @@ static void process_flags (int argc, char **argv) |
| 56 | {"key", required_argument, NULL, 'K'}, |
| 57 | {"non-unique", no_argument, NULL, 'o'}, |
| 58 | {"password", required_argument, NULL, 'p'}, |
| 59 | + {"clear-password", required_argument, NULL, 'P'}, |
| 60 | {"system", no_argument, NULL, 'r'}, |
| 61 | {"root", required_argument, NULL, 'R'}, |
| 62 | {NULL, 0, NULL, '\0'} |
| 63 | }; |
| 64 | |
| 65 | - while ((c = getopt_long (argc, argv, "fg:hK:op:rR:", |
| 66 | + while ((c = getopt_long (argc, argv, "fg:hK:op:P:rR:", |
| 67 | long_options, NULL)) != -1) { |
| 68 | switch (c) { |
| 69 | case 'f': |
| 70 | @@ -444,6 +446,10 @@ static void process_flags (int argc, char **argv) |
| 71 | pflg = true; |
| 72 | group_passwd = optarg; |
| 73 | break; |
| 74 | + case 'P': |
| 75 | + pflg = true; |
| 76 | + group_passwd = pw_encrypt (optarg, crypt_make_salt (NULL, NULL)); |
| 77 | + break; |
| 78 | case 'r': |
| 79 | rflg = true; |
| 80 | break; |
| 81 | diff --git a/src/groupmod.c b/src/groupmod.c |
| 82 | index d9d3807..68f49d1 100644 |
| 83 | --- a/src/groupmod.c |
| 84 | +++ b/src/groupmod.c |
| 85 | @@ -127,6 +127,7 @@ static void usage (int status) |
| 86 | (void) fputs (_(" -o, --non-unique allow to use a duplicate (non-unique) GID\n"), usageout); |
| 87 | (void) fputs (_(" -p, --password PASSWORD change the password to this (encrypted)\n" |
| 88 | " PASSWORD\n"), usageout); |
| 89 | + (void) fputs (_(" -P, --clear-password PASSWORD change the password to this clear PASSWORD\n"), usageout); |
| 90 | (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); |
| 91 | (void) fputs ("\n", usageout); |
| 92 | exit (status); |
| 93 | @@ -375,10 +376,11 @@ static void process_flags (int argc, char **argv) |
| 94 | {"new-name", required_argument, NULL, 'n'}, |
| 95 | {"non-unique", no_argument, NULL, 'o'}, |
| 96 | {"password", required_argument, NULL, 'p'}, |
| 97 | + {"clear-password", required_argument, NULL, 'P'}, |
| 98 | {"root", required_argument, NULL, 'R'}, |
| 99 | {NULL, 0, NULL, '\0'} |
| 100 | }; |
| 101 | - while ((c = getopt_long (argc, argv, "g:hn:op:R:", |
| 102 | + while ((c = getopt_long (argc, argv, "g:hn:op:P:R:", |
| 103 | long_options, NULL)) != -1) { |
| 104 | switch (c) { |
| 105 | case 'g': |
| 106 | @@ -405,6 +407,10 @@ static void process_flags (int argc, char **argv) |
| 107 | group_passwd = optarg; |
| 108 | pflg = true; |
| 109 | break; |
| 110 | + case 'P': |
| 111 | + group_passwd = pw_encrypt (optarg, crypt_make_salt (NULL, NULL)); |
| 112 | + pflg = true; |
| 113 | + break; |
| 114 | case 'R': /* no-op, handled in process_root_flag () */ |
| 115 | break; |
| 116 | default: |
| 117 | diff --git a/src/useradd.c b/src/useradd.c |
| 118 | index b3bd451..4416f90 100644 |
| 119 | --- a/src/useradd.c |
| 120 | +++ b/src/useradd.c |
| 121 | @@ -773,6 +773,7 @@ static void usage (int status) |
| 122 | (void) fputs (_(" -o, --non-unique allow to create users with duplicate\n" |
| 123 | " (non-unique) UID\n"), usageout); |
| 124 | (void) fputs (_(" -p, --password PASSWORD encrypted password of the new account\n"), usageout); |
| 125 | + (void) fputs (_(" -P, --clear-password PASSWORD clear password of the new account\n"), usageout); |
| 126 | (void) fputs (_(" -r, --system create a system account\n"), usageout); |
| 127 | (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); |
| 128 | (void) fputs (_(" -s, --shell SHELL login shell of the new account\n"), usageout); |
| 129 | @@ -1047,6 +1048,7 @@ static void process_flags (int argc, char **argv) |
| 130 | {"no-user-group", no_argument, NULL, 'N'}, |
| 131 | {"non-unique", no_argument, NULL, 'o'}, |
| 132 | {"password", required_argument, NULL, 'p'}, |
| 133 | + {"clear-password", required_argument, NULL, 'P'}, |
| 134 | {"system", no_argument, NULL, 'r'}, |
| 135 | {"root", required_argument, NULL, 'R'}, |
| 136 | {"shell", required_argument, NULL, 's'}, |
| 137 | @@ -1059,9 +1061,9 @@ static void process_flags (int argc, char **argv) |
| 138 | }; |
| 139 | while ((c = getopt_long (argc, argv, |
| 140 | #ifdef WITH_SELINUX |
| 141 | - "b:c:d:De:f:g:G:hk:K:lmMNop:rR:s:u:UZ:", |
| 142 | + "b:c:d:De:f:g:G:hk:K:lmMNop:P:rR:s:u:UZ:", |
| 143 | #else /* !WITH_SELINUX */ |
| 144 | - "b:c:d:De:f:g:G:hk:K:lmMNop:rR:s:u:U", |
| 145 | + "b:c:d:De:f:g:G:hk:K:lmMNop:P:rR:s:u:U", |
| 146 | #endif /* !WITH_SELINUX */ |
| 147 | long_options, NULL)) != -1) { |
| 148 | switch (c) { |
| 149 | @@ -1227,6 +1229,9 @@ static void process_flags (int argc, char **argv) |
| 150 | } |
| 151 | user_pass = optarg; |
| 152 | break; |
| 153 | + case 'P': /* set clear text password */ |
| 154 | + user_pass = pw_encrypt (optarg, crypt_make_salt (NULL, NULL)); |
| 155 | + break; |
| 156 | case 'r': |
| 157 | rflg = true; |
| 158 | break; |
| 159 | diff --git a/src/usermod.c b/src/usermod.c |
| 160 | index e7d4351..b79f7a3 100644 |
| 161 | --- a/src/usermod.c |
| 162 | +++ b/src/usermod.c |
| 163 | @@ -419,6 +419,7 @@ static /*@noreturn@*/void usage (int status) |
| 164 | " new location (use only with -d)\n"), usageout); |
| 165 | (void) fputs (_(" -o, --non-unique allow using duplicate (non-unique) UID\n"), usageout); |
| 166 | (void) fputs (_(" -p, --password PASSWORD use encrypted password for the new password\n"), usageout); |
| 167 | + (void) fputs (_(" -P, --clear-password PASSWORD use clear password for the new password\n"), usageout); |
| 168 | (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); |
| 169 | (void) fputs (_(" -s, --shell SHELL new login shell for the user account\n"), usageout); |
| 170 | (void) fputs (_(" -u, --uid UID new UID for the user account\n"), usageout); |
| 171 | @@ -996,6 +997,7 @@ static void process_flags (int argc, char **argv) |
| 172 | {"move-home", no_argument, NULL, 'm'}, |
| 173 | {"non-unique", no_argument, NULL, 'o'}, |
| 174 | {"password", required_argument, NULL, 'p'}, |
| 175 | + {"clear-password", required_argument, NULL, 'P'}, |
| 176 | {"root", required_argument, NULL, 'R'}, |
| 177 | {"shell", required_argument, NULL, 's'}, |
| 178 | {"uid", required_argument, NULL, 'u'}, |
| 179 | @@ -1012,7 +1014,7 @@ static void process_flags (int argc, char **argv) |
| 180 | {NULL, 0, NULL, '\0'} |
| 181 | }; |
| 182 | while ((c = getopt_long (argc, argv, |
| 183 | - "ac:d:e:f:g:G:hl:Lmop:R:s:u:U" |
| 184 | + "ac:d:e:f:g:G:hl:Lmop:P:R:s:u:U" |
| 185 | #ifdef ENABLE_SUBIDS |
| 186 | "v:w:V:W:" |
| 187 | #endif /* ENABLE_SUBIDS */ |
| 188 | @@ -1112,6 +1114,10 @@ static void process_flags (int argc, char **argv) |
| 189 | user_pass = optarg; |
| 190 | pflg = true; |
| 191 | break; |
| 192 | + case 'P': |
| 193 | + user_pass = pw_encrypt (optarg, crypt_make_salt (NULL, NULL)); |
| 194 | + pflg = true; |
| 195 | + break; |
| 196 | case 'R': /* no-op, handled in process_root_flag () */ |
| 197 | break; |
| 198 | case 's': |
| 199 | -- |
| 200 | 1.7.9.5 |
| 201 | |