summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/shadow/files/0002-Allow-for-setting-password-in-clear-text.patch
blob: c6332e4f766e1f113f1727290c7726b2c2b801cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
From a7d995228491ad5255ad86c1f04ba071f6880897 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Sat, 16 Nov 2013 15:27:47 +0800
Subject: [PATCH] Allow for setting password in clear text

Upstream-Status: Inappropriate [OE specific]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>

---
 src/Makefile.am |  8 ++++----
 src/groupadd.c  | 20 +++++++++++++++-----
 src/groupmod.c  | 20 +++++++++++++++-----
 src/useradd.c   | 21 +++++++++++++++------
 src/usermod.c   | 20 +++++++++++++++-----
 5 files changed, 64 insertions(+), 25 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index f31fd7a..4a317a3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -103,10 +103,10 @@ chsh_LDADD     = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM)
 chpasswd_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
 expiry_LDADD = $(LDADD) $(LIBECONF)
 gpasswd_LDADD  = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
-groupadd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
+groupadd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) $(LIBCRYPT)
 groupdel_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
 groupmems_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
-groupmod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
+groupmod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) $(LIBCRYPT)
 grpck_LDADD    = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
 grpconv_LDADD  = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
 grpunconv_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
@@ -127,9 +127,9 @@ su_SOURCES     = \
 	suauth.c
 su_LDADD       = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
 sulogin_LDADD  = $(LDADD) $(LIBCRYPT) $(LIBECONF)
-useradd_LDADD  = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) $(LIBECONF)
+useradd_LDADD  = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) $(LIBECONF) $(LIBCRYPT)
 userdel_LDADD  = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBECONF)
-usermod_LDADD  = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) $(LIBECONF)
+usermod_LDADD  = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBATTR) $(LIBECONF) $(LIBCRYPT)
 vipw_LDADD     = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
 
 install-am: all-am
diff --git a/src/groupadd.c b/src/groupadd.c
index e9c4bb7..d572c00 100644
--- a/src/groupadd.c
+++ b/src/groupadd.c
@@ -127,9 +127,10 @@ static /*@noreturn@*/void usage (int status)
 	(void) fputs (_("  -o, --non-unique              allow to create groups with duplicate\n"
 	                "                                (non-unique) GID\n"), usageout);
 	(void) fputs (_("  -p, --password PASSWORD       use this encrypted password for the new group\n"), usageout);
+	(void) fputs (_("  -P, --clear-password PASSWORD use this clear password for the new group\n"), usageout);
 	(void) fputs (_("  -r, --system                  create a system account\n"), usageout);
 	(void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
-	(void) fputs (_("  -P, --prefix PREFIX_DIR       directory prefix\n"), usageout);
+	(void) fputs (_("  -A, --prefix PREFIX_DIR       directory prefix\n"), usageout);
 	(void) fputs ("\n", usageout);
 	exit (status);
 }
@@ -391,13 +392,14 @@ static void process_flags (int argc, char **argv)
 		{"key",        required_argument, NULL, 'K'},
 		{"non-unique", no_argument,       NULL, 'o'},
 		{"password",   required_argument, NULL, 'p'},
+		{"clear-password", required_argument, NULL, 'P'},
 		{"system",     no_argument,       NULL, 'r'},
 		{"root",       required_argument, NULL, 'R'},
-		{"prefix",     required_argument, NULL, 'P'},
+		{"prefix",     required_argument, NULL, 'A'},
 		{NULL, 0, NULL, '\0'}
 	};
 
-	while ((c = getopt_long (argc, argv, "fg:hK:op:rR:P:",
+	while ((c = getopt_long (argc, argv, "fg:hK:op:P:rR:A:",
 		                 long_options, NULL)) != -1) {
 		switch (c) {
 		case 'f':
@@ -449,12 +451,20 @@ static void process_flags (int argc, char **argv)
 			pflg = true;
 			group_passwd = optarg;
 			break;
+		case 'P':
+			pflg = true;
+			group_passwd = pw_encrypt (optarg, crypt_make_salt (NULL, NULL));
+			break;
 		case 'r':
 			rflg = true;
 			break;
 		case 'R': /* no-op, handled in process_root_flag () */
 			break;
-		case 'P': /* no-op, handled in process_prefix_flag () */
+		case 'A': /* no-op, handled in process_prefix_flag () */
+			fprintf (stderr,
+				 _("%s: -A is deliberately not supported \n"),
+				 Prog);
+			exit (E_BAD_ARG);
 			break;
 		default:
 			usage (E_USAGE);
@@ -588,7 +598,7 @@ int main (int argc, char **argv)
 	(void) textdomain (PACKAGE);
 
 	process_root_flag ("-R", argc, argv);
-	prefix = process_prefix_flag ("-P", argc, argv);
+	prefix = process_prefix_flag ("-A", argc, argv);
 
 	OPENLOG ("groupadd");
 #ifdef WITH_AUDIT
diff --git a/src/groupmod.c b/src/groupmod.c
index bc14438..25ccb44 100644
--- a/src/groupmod.c
+++ b/src/groupmod.c
@@ -138,8 +138,9 @@ static void usage (int status)
 	(void) fputs (_("  -o, --non-unique              allow to use a duplicate (non-unique) GID\n"), usageout);
 	(void) fputs (_("  -p, --password PASSWORD       change the password to this (encrypted)\n"
 	                "                                PASSWORD\n"), usageout);
+	(void) fputs (_("  -P, --clear-password PASSWORD change the password to this clear PASSWORD\n"), usageout);
 	(void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
-	(void) fputs (_("  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files\n"), usageout);
+	(void) fputs (_("  -A, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files\n"), usageout);
 	(void) fputs ("\n", usageout);
 	exit (status);
 }
@@ -387,11 +388,12 @@ static void process_flags (int argc, char **argv)
 		{"new-name",   required_argument, NULL, 'n'},
 		{"non-unique", no_argument,       NULL, 'o'},
 		{"password",   required_argument, NULL, 'p'},
+		{"clear-password", required_argument, NULL, 'P'},
 		{"root",       required_argument, NULL, 'R'},
-		{"prefix",     required_argument, NULL, 'P'},
+		{"prefix",     required_argument, NULL, 'A'},
 		{NULL, 0, NULL, '\0'}
 	};
-	while ((c = getopt_long (argc, argv, "g:hn:op:R:P:",
+	while ((c = getopt_long (argc, argv, "g:hn:op:P:R:A:",
 		                 long_options, NULL)) != -1) {
 		switch (c) {
 		case 'g':
@@ -418,9 +420,17 @@ static void process_flags (int argc, char **argv)
 			group_passwd = optarg;
 			pflg = true;
 			break;
+		case 'P':
+			group_passwd = pw_encrypt (optarg, crypt_make_salt (NULL, NULL));
+			pflg = true;
+			break;
 		case 'R': /* no-op, handled in process_root_flag () */
 			break;
-		case 'P': /* no-op, handled in process_prefix_flag () */
+		case 'A': /* no-op, handled in process_prefix_flag () */
+			fprintf (stderr,
+				 _("%s: -A is deliberately not supported \n"),
+				 Prog);
+			exit (E_BAD_ARG);
 			break;
 		default:
 			usage (E_USAGE);
@@ -761,7 +771,7 @@ int main (int argc, char **argv)
 	(void) textdomain (PACKAGE);
 
 	process_root_flag ("-R", argc, argv);
-	prefix = process_prefix_flag ("-P", argc, argv);
+	prefix = process_prefix_flag ("-A", argc, argv);
 
 	OPENLOG ("groupmod");
 #ifdef WITH_AUDIT
diff --git a/src/useradd.c b/src/useradd.c
index 1b7bf06..44f09e2 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -853,9 +853,10 @@ static void usage (int status)
 	(void) fputs (_("  -o, --non-unique              allow to create users with duplicate\n"
 	                "                                (non-unique) UID\n"), usageout);
 	(void) fputs (_("  -p, --password PASSWORD       encrypted password of the new account\n"), usageout);
+	(void) fputs (_("  -P, --clear-password PASSWORD clear password of the new account\n"), usageout);
 	(void) fputs (_("  -r, --system                  create a system account\n"), usageout);
 	(void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
-	(void) fputs (_("  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files\n"), usageout);
+	(void) fputs (_("  -A, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files\n"), usageout);
 	(void) fputs (_("  -s, --shell SHELL             login shell of the new account\n"), usageout);
 	(void) fputs (_("  -u, --uid UID                 user ID of the new account\n"), usageout);
 	(void) fputs (_("  -U, --user-group              create a group with the same name as the user\n"), usageout);
@@ -1133,9 +1134,10 @@ static void process_flags (int argc, char **argv)
 			{"no-user-group",  no_argument,       NULL, 'N'},
 			{"non-unique",     no_argument,       NULL, 'o'},
 			{"password",       required_argument, NULL, 'p'},
+			{"clear-password", required_argument, NULL, 'P'},
 			{"system",         no_argument,       NULL, 'r'},
 			{"root",           required_argument, NULL, 'R'},
-			{"prefix",         required_argument, NULL, 'P'},
+			{"prefix",         required_argument, NULL, 'A'},
 			{"shell",          required_argument, NULL, 's'},
 			{"uid",            required_argument, NULL, 'u'},
 			{"user-group",     no_argument,       NULL, 'U'},
@@ -1146,9 +1148,9 @@ static void process_flags (int argc, char **argv)
 		};
 		while ((c = getopt_long (argc, argv,
 #ifdef WITH_SELINUX
-		                         "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:UZ:",
+		                         "b:c:d:De:f:g:G:hk:K:lmMNop:P:rR:A:s:u:UZ:",
 #else				/* !WITH_SELINUX */
-		                         "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:U",
+		                         "b:c:d:De:f:g:G:hk:K:lmMNop:P:rR:A:s:u:U",
 #endif				/* !WITH_SELINUX */
 		                         long_options, NULL)) != -1) {
 			switch (c) {
@@ -1320,12 +1322,19 @@ static void process_flags (int argc, char **argv)
 				}
 				user_pass = optarg;
 				break;
+			case 'P': /* set clear text password */
+				user_pass = pw_encrypt (optarg, crypt_make_salt (NULL, NULL));
+				break;
 			case 'r':
 				rflg = true;
 				break;
 			case 'R': /* no-op, handled in process_root_flag () */
 				break;
-			case 'P': /* no-op, handled in process_prefix_flag () */
+			case 'A': /* no-op, handled in process_prefix_flag () */
+				fprintf (stderr,
+					 _("%s: -A is deliberately not supported \n"),
+					 Prog);
+				exit (E_BAD_ARG);
 				break;
 			case 's':
 				if (   ( !VALID (optarg) )
@@ -2257,7 +2266,7 @@ int main (int argc, char **argv)
 
 	process_root_flag ("-R", argc, argv);
 
-	prefix = process_prefix_flag("-P", argc, argv);
+	prefix = process_prefix_flag("-A", argc, argv);
 
 	OPENLOG ("useradd");
 #ifdef WITH_AUDIT
diff --git a/src/usermod.c b/src/usermod.c
index 21c6da9..cffdb3e 100644
--- a/src/usermod.c
+++ b/src/usermod.c
@@ -431,8 +431,9 @@ static /*@noreturn@*/void usage (int status)
 	                "                                new location (use only with -d)\n"), usageout);
 	(void) fputs (_("  -o, --non-unique              allow using duplicate (non-unique) UID\n"), usageout);
 	(void) fputs (_("  -p, --password PASSWORD       use encrypted password for the new password\n"), usageout);
+	(void) fputs (_("  -P, --clear-password PASSWORD use clear password for the new password\n"), usageout);
 	(void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
-	(void) fputs (_("  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files\n"), usageout);
+	(void) fputs (_("  -A, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files\n"), usageout);
 	(void) fputs (_("  -s, --shell SHELL             new login shell for the user account\n"), usageout);
 	(void) fputs (_("  -u, --uid UID                 new UID for the user account\n"), usageout);
 	(void) fputs (_("  -U, --unlock                  unlock the user account\n"), usageout);
@@ -1010,8 +1011,9 @@ static void process_flags (int argc, char **argv)
 			{"move-home",    no_argument,       NULL, 'm'},
 			{"non-unique",   no_argument,       NULL, 'o'},
 			{"password",     required_argument, NULL, 'p'},
+			{"clear-password", required_argument, NULL, 'P'},
 			{"root",         required_argument, NULL, 'R'},
-			{"prefix",       required_argument, NULL, 'P'},
+			{"prefix",       required_argument, NULL, 'A'},
 			{"shell",        required_argument, NULL, 's'},
 			{"uid",          required_argument, NULL, 'u'},
 			{"unlock",       no_argument,       NULL, 'U'},
@@ -1027,7 +1029,7 @@ static void process_flags (int argc, char **argv)
 			{NULL, 0, NULL, '\0'}
 		};
 		while ((c = getopt_long (argc, argv,
-		                         "abc:d:e:f:g:G:hl:Lmop:R:s:u:UP:"
+		                         "abc:d:e:f:g:G:hl:Lmop:P:R:s:u:UA:"
 #ifdef ENABLE_SUBIDS
 		                         "v:w:V:W:"
 #endif				/* ENABLE_SUBIDS */
@@ -1130,9 +1132,17 @@ static void process_flags (int argc, char **argv)
 				user_pass = optarg;
 				pflg = true;
 				break;
+			case 'P':
+				user_pass = pw_encrypt (optarg, crypt_make_salt (NULL, NULL));
+				pflg = true;
+				break;
 			case 'R': /* no-op, handled in process_root_flag () */
 				break;
-			case 'P': /* no-op, handled in process_prefix_flag () */
+			case 'A': /* no-op, handled in process_prefix_flag () */
+				fprintf (stderr,
+					 _("%s: -A is deliberately not supported \n"),
+					 Prog);
+				exit (E_BAD_ARG);
 				break;
 			case 's':
 				if (!VALID (optarg)) {
@@ -2127,7 +2137,7 @@ int main (int argc, char **argv)
 	(void) textdomain (PACKAGE);
 
 	process_root_flag ("-R", argc, argv);
-	prefix = process_prefix_flag ("-P", argc, argv);
+	prefix = process_prefix_flag ("-A", argc, argv);
 
 	OPENLOG ("usermod");
 #ifdef WITH_AUDIT