diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-07-11 16:19:17 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-07-11 16:19:17 +0000 |
commit | 6166bb40b91e0fb0f4ae59c572df0dd00858892f (patch) | |
tree | 6afc009d439dc7174f008ccd531f2452e26a833c | |
parent | 5c1a4bd0a2cd584faf216be049509dace663f162 (diff) | |
download | busybox-w32-6166bb40b91e0fb0f4ae59c572df0dd00858892f.tar.gz busybox-w32-6166bb40b91e0fb0f4ae59c572df0dd00858892f.tar.bz2 busybox-w32-6166bb40b91e0fb0f4ae59c572df0dd00858892f.zip |
Patch from Tito to remove pwd_to_spwd (which we don't actually need), with
some #ifdef removal from me.
git-svn-id: svn://busybox.net/trunk/busybox@15685 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | include/libbb.h | 6 | ||||
-rw-r--r-- | libbb/Makefile.in | 1 | ||||
-rw-r--r-- | libbb/pwd2spwd.c | 74 | ||||
-rw-r--r-- | loginutils/passwd.c | 21 |
4 files changed, 7 insertions, 95 deletions
diff --git a/include/libbb.h b/include/libbb.h index af45511d4..0a52b6421 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -38,12 +38,7 @@ | |||
38 | 38 | ||
39 | #include "pwd_.h" | 39 | #include "pwd_.h" |
40 | #include "grp_.h" | 40 | #include "grp_.h" |
41 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS | ||
42 | #include "shadow_.h" | 41 | #include "shadow_.h" |
43 | #endif | ||
44 | #ifdef CONFIG_FEATURE_SHA1_PASSWORDS | ||
45 | # include "sha1.h" | ||
46 | #endif | ||
47 | 42 | ||
48 | /* Try to pull in PATH_MAX */ | 43 | /* Try to pull in PATH_MAX */ |
49 | #include <limits.h> | 44 | #include <limits.h> |
@@ -467,7 +462,6 @@ extern int restricted_shell ( const char *shell ); | |||
467 | extern void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ); | 462 | extern void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ); |
468 | extern int correct_password ( const struct passwd *pw ); | 463 | extern int correct_password ( const struct passwd *pw ); |
469 | extern char *pw_encrypt(const char *clear, const char *salt); | 464 | extern char *pw_encrypt(const char *clear, const char *salt); |
470 | extern struct spwd *pwd_to_spwd(const struct passwd *pw); | ||
471 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); | 465 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); |
472 | 466 | ||
473 | extern int bb_xopen(const char *pathname, int flags); | 467 | extern int bb_xopen(const char *pathname, int flags); |
diff --git a/libbb/Makefile.in b/libbb/Makefile.in index 0324ec041..cae7f99ed 100644 --- a/libbb/Makefile.in +++ b/libbb/Makefile.in | |||
@@ -38,7 +38,6 @@ LIBBB-y:= \ | |||
38 | bb_do_delay.c | 38 | bb_do_delay.c |
39 | 39 | ||
40 | # conditionally compiled objects: | 40 | # conditionally compiled objects: |
41 | LIBBB-$(CONFIG_FEATURE_SHADOWPASSWDS)+=pwd2spwd.c | ||
42 | LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c | 41 | LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c |
43 | LIBBB-$(CONFIG_LOSETUP)+= loop.c | 42 | LIBBB-$(CONFIG_LOSETUP)+= loop.c |
44 | LIBBB-$(CONFIG_FEATURE_MTAB_SUPPORT)+= mtab.c | 43 | LIBBB-$(CONFIG_FEATURE_MTAB_SUPPORT)+= mtab.c |
diff --git a/libbb/pwd2spwd.c b/libbb/pwd2spwd.c deleted file mode 100644 index 3dd625b27..000000000 --- a/libbb/pwd2spwd.c +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Copyright 1989 - 1994, Julianne Frances Haugh <jockgrrl@austin.rr.com> | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of Julianne F. Haugh nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <time.h> | ||
32 | #include <sys/types.h> | ||
33 | #include "libbb.h" | ||
34 | #include "shadow_.h" | ||
35 | |||
36 | /* | ||
37 | * pwd_to_spwd - create entries for new spwd structure | ||
38 | * | ||
39 | * pwd_to_spwd() creates a new (struct spwd) containing the | ||
40 | * information in the pointed-to (struct passwd). | ||
41 | */ | ||
42 | #define DAY (24L*3600L) | ||
43 | #define WEEK (7*DAY) | ||
44 | #define SCALE DAY | ||
45 | struct spwd *pwd_to_spwd(const struct passwd *pw) | ||
46 | { | ||
47 | static struct spwd sp; | ||
48 | |||
49 | /* | ||
50 | * Nice, easy parts first. The name and passwd map directly | ||
51 | * from the old password structure to the new one. | ||
52 | */ | ||
53 | sp.sp_namp = pw->pw_name; | ||
54 | sp.sp_pwdp = pw->pw_passwd; | ||
55 | |||
56 | /* | ||
57 | * Defaults used if there is no pw_age information. | ||
58 | */ | ||
59 | sp.sp_min = 0; | ||
60 | sp.sp_max = (10000L * DAY) / SCALE; | ||
61 | sp.sp_lstchg = time((time_t *) 0) / SCALE; | ||
62 | |||
63 | /* | ||
64 | * These fields have no corresponding information in the password | ||
65 | * file. They are set to uninitialized values. | ||
66 | */ | ||
67 | sp.sp_warn = -1; | ||
68 | sp.sp_expire = -1; | ||
69 | sp.sp_inact = -1; | ||
70 | sp.sp_flag = -1; | ||
71 | |||
72 | return &sp; | ||
73 | } | ||
74 | |||
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index a1ad02bf0..607e8fd65 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -146,9 +146,6 @@ int passwd_main(int argc, char **argv) | |||
146 | int dflg = 0; /* -d - delete password */ | 146 | int dflg = 0; /* -d - delete password */ |
147 | const struct passwd *pw; | 147 | const struct passwd *pw; |
148 | 148 | ||
149 | #if ENABLE_FEATURE_SHADOWPASSWDS | ||
150 | const struct spwd *sp; | ||
151 | #endif | ||
152 | amroot = (getuid() == 0); | 149 | amroot = (getuid() == 0); |
153 | openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); | 150 | openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); |
154 | while ((flag = getopt(argc, argv, "a:dlu")) != EOF) { | 151 | while ((flag = getopt(argc, argv, "a:dlu")) != EOF) { |
@@ -187,18 +184,13 @@ int passwd_main(int argc, char **argv) | |||
187 | syslog(LOG_WARNING, "can't change pwd for `%s'", name); | 184 | syslog(LOG_WARNING, "can't change pwd for `%s'", name); |
188 | bb_error_msg_and_die("Permission denied.\n"); | 185 | bb_error_msg_and_die("Permission denied.\n"); |
189 | } | 186 | } |
190 | #if ENABLE_FEATURE_SHADOWPASSWDS | 187 | if (ENABLE_FEATURE_SHADOWPASSWDS) { |
191 | sp = getspnam(name); | 188 | struct spwd *sp = getspnam(name); |
192 | if (!sp) { | 189 | if (!sp) bb_error_msg_and_die("Unknown user %s", name); |
193 | sp = (struct spwd *) pwd_to_spwd(pw); | 190 | cp = sp->sp_pwdp; |
194 | } | 191 | } else cp = pw->pw_passwd; |
195 | cp = sp->sp_pwdp; | ||
196 | np = sp->sp_namp; | ||
197 | #else | ||
198 | cp = pw->pw_passwd; | ||
199 | np = name; | ||
200 | #endif | ||
201 | 192 | ||
193 | np = name; | ||
202 | safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); | 194 | safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); |
203 | if (!(dflg || lflg || uflg)) { | 195 | if (!(dflg || lflg || uflg)) { |
204 | if (!amroot) { | 196 | if (!amroot) { |
@@ -243,6 +235,7 @@ int passwd_main(int argc, char **argv) | |||
243 | syslog(LOG_WARNING, "an error occurred updating the password file"); | 235 | syslog(LOG_WARNING, "an error occurred updating the password file"); |
244 | bb_error_msg_and_die("An error occurred updating the password file.\n"); | 236 | bb_error_msg_and_die("An error occurred updating the password file.\n"); |
245 | } | 237 | } |
238 | if (ENABLE_FEATURE_CLEAN_UP) free(myname); | ||
246 | return (0); | 239 | return (0); |
247 | } | 240 | } |
248 | 241 | ||