diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-15 18:35:34 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-15 18:35:34 +0000 |
| commit | b4c5bf615e0cd0da41222b853627ce2c893cba5c (patch) | |
| tree | 6a631fbd817d16dce6f0d16ed7381ee54cfd7b71 | |
| parent | 5703c22a51a154db17e6a7f6426a95232542cc9e (diff) | |
| download | busybox-w32-b4c5bf615e0cd0da41222b853627ce2c893cba5c.tar.gz busybox-w32-b4c5bf615e0cd0da41222b853627ce2c893cba5c.tar.bz2 busybox-w32-b4c5bf615e0cd0da41222b853627ce2c893cba5c.zip | |
Specially for Bernhard Fischer introduce USE_BB_CRYPT
which selects between libc/custom crypt routines.
| -rw-r--r-- | include/libbb.h | 3 | ||||
| -rw-r--r-- | libbb/pw_encrypt.c | 17 | ||||
| -rw-r--r-- | loginutils/Config.in | 89 |
3 files changed, 75 insertions, 34 deletions
diff --git a/include/libbb.h b/include/libbb.h index 655ca01a5..e92dbc4c0 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -1032,6 +1032,9 @@ extern int restricted_shell(const char *shell); | |||
| 1032 | extern void setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw); | 1032 | extern void setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw); |
| 1033 | extern int correct_password(const struct passwd *pw); | 1033 | extern int correct_password(const struct passwd *pw); |
| 1034 | /* Returns a malloced string */ | 1034 | /* Returns a malloced string */ |
| 1035 | #if !ENABLE_USE_BB_CRYPT | ||
| 1036 | #define pw_encrypt(clear, salt, cleanup) pw_encrypt(clear, salt) | ||
| 1037 | #endif | ||
| 1035 | extern char *pw_encrypt(const char *clear, const char *salt, int cleanup); | 1038 | extern char *pw_encrypt(const char *clear, const char *salt, int cleanup); |
| 1036 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); | 1039 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); |
| 1037 | /* rnd is additional random input. New one is returned. | 1040 | /* rnd is additional random input. New one is returned. |
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index 762cbab27..c1e927e23 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | 9 | ||
| 10 | #include "libbb.h" | 10 | #include "libbb.h" |
| 11 | 11 | ||
| 12 | #if ENABLE_USE_BB_CRYPT | ||
| 13 | |||
| 12 | /* | 14 | /* |
| 13 | * DES and MD5 crypt implementations are taken from uclibc. | 15 | * DES and MD5 crypt implementations are taken from uclibc. |
| 14 | * They were modified to not use static buffers. | 16 | * They were modified to not use static buffers. |
| @@ -69,3 +71,18 @@ char *pw_encrypt(const char *clear, const char *salt, int cleanup) | |||
| 69 | 71 | ||
| 70 | return encrypted; | 72 | return encrypted; |
| 71 | } | 73 | } |
| 74 | |||
| 75 | #else /* if !ENABLE_USE_BB_CRYPT */ | ||
| 76 | |||
| 77 | char *pw_encrypt(const char *clear, const char *salt, int cleanup) | ||
| 78 | { | ||
| 79 | #if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */ | ||
| 80 | if (strncmp(salt, "$2$", 3) == 0) { | ||
| 81 | return xstrdup(sha1_crypt(clear)); | ||
| 82 | } | ||
| 83 | #endif | ||
| 84 | |||
| 85 | return xstrdup(crypt(clear, salt)); | ||
| 86 | } | ||
| 87 | |||
| 88 | #endif | ||
diff --git a/loginutils/Config.in b/loginutils/Config.in index c57d9976e..e39fb6f79 100644 --- a/loginutils/Config.in +++ b/loginutils/Config.in | |||
| @@ -13,45 +13,67 @@ config FEATURE_SHADOWPASSWDS | |||
| 13 | readable by root and thus the encrypted passwords are no longer | 13 | readable by root and thus the encrypted passwords are no longer |
| 14 | publicly readable. | 14 | publicly readable. |
| 15 | 15 | ||
| 16 | config USE_BB_PWD_GRP | ||
| 17 | bool "Use internal password and group functions rather than system functions" | ||
| 18 | default n | ||
| 19 | help | ||
| 20 | If you leave this disabled, busybox will use the system's password | ||
| 21 | and group functions. And if you are using the GNU C library | ||
| 22 | (glibc), you will then need to install the /etc/nsswitch.conf | ||
| 23 | configuration file and the required /lib/libnss_* libraries in | ||
| 24 | order for the password and group functions to work. This generally | ||
| 25 | makes your embedded system quite a bit larger. | ||
| 26 | |||
| 27 | Enabling this option will cause busybox to directly access the | ||
| 28 | system's /etc/password, /etc/group files (and your system will be | ||
| 29 | smaller, and I will get fewer emails asking about how glibc NSS | ||
| 30 | works). When this option is enabled, you will not be able to use | ||
| 31 | PAM to access remote LDAP password servers and whatnot. And if you | ||
| 32 | want hostname resolution to work with glibc, you still need the | ||
| 33 | /lib/libnss_* libraries. | ||
| 34 | |||
| 35 | If you need to use glibc's nsswitch.conf mechanism | ||
| 36 | (e.g. if user/group database is NOT stored in /etc/passwd etc), | ||
| 37 | you must NOT use this option. | ||
| 38 | |||
| 39 | If you enable this option, it will add about 1.5k to busybox. | ||
| 40 | |||
| 16 | config USE_BB_SHADOW | 41 | config USE_BB_SHADOW |
| 17 | bool "Use busybox shadow password functions" | 42 | bool "Use busybox shadow password functions" |
| 18 | default y | 43 | default y |
| 19 | depends on USE_BB_PWD_GRP && FEATURE_SHADOWPASSWDS | 44 | depends on USE_BB_PWD_GRP && FEATURE_SHADOWPASSWDS |
| 20 | help | 45 | help |
| 21 | If you leave this disabled, busybox will use the system's shadow | 46 | If you leave this disabled, busybox will use the system's shadow |
| 22 | password handling functions. And if you are using the GNU C library | 47 | password handling functions. And if you are using the GNU C library |
| 23 | (glibc), you will then need to install the /etc/nsswitch.conf | 48 | (glibc), you will then need to install the /etc/nsswitch.conf |
| 24 | configuration file and the required /lib/libnss_* libraries in | 49 | configuration file and the required /lib/libnss_* libraries in |
| 25 | order for the shadow password functions to work. This generally | 50 | order for the shadow password functions to work. This generally |
| 26 | makes your embedded system quite a bit larger. | 51 | makes your embedded system quite a bit larger. |
| 27 | 52 | ||
| 28 | Enabling this option will cause busybox to directly access the | 53 | Enabling this option will cause busybox to directly access the |
| 29 | system's /etc/shadow file when handling shadow passwords. This | 54 | system's /etc/shadow file when handling shadow passwords. This |
| 30 | makes your system smaller and I will get fewer emails asking about | 55 | makes your system smaller and I will get fewer emails asking about |
| 31 | how glibc NSS works). When this option is enabled, you will not be | 56 | how glibc NSS works). When this option is enabled, you will not be |
| 32 | able to use PAM to access shadow passwords from remote LDAP | 57 | able to use PAM to access shadow passwords from remote LDAP |
| 33 | password servers and whatnot. | 58 | password servers and whatnot. |
| 34 | 59 | ||
| 35 | config USE_BB_PWD_GRP | 60 | config USE_BB_CRYPT |
| 36 | bool "Use internal password and group functions rather than system functions" | 61 | bool "Use internal DES and MD5 crypt functions rather than system functions" |
| 37 | default n | 62 | default y |
| 38 | help | 63 | help |
| 39 | If you leave this disabled, busybox will use the system's password | 64 | If you leave this disabled, busybox will use the system's password |
| 40 | and group functions. And if you are using the GNU C library | 65 | and group functions. Most C libraries use large (~70k) |
| 41 | (glibc), you will then need to install the /etc/nsswitch.conf | 66 | static buffers in these functions, and also combine them |
| 42 | configuration file and the required /lib/libnss_* libraries in | 67 | with more general DES encryption/decryption routines. |
| 43 | order for the password and group functions to work. This generally | 68 | For busybox, having large static buffers is undesirable, |
| 44 | makes your embedded system quite a bit larger. | 69 | especially so on NOMMU machines. |
| 45 | 70 | ||
| 46 | Enabling this option will cause busybox to directly access the | 71 | These functions produce results which are identical |
| 47 | system's /etc/password, /etc/group files (and your system will be | 72 | to corresponding C library functions. |
| 48 | smaller, and I will get fewer emails asking about how glibc NSS | 73 | |
| 49 | works). When this option is enabled, you will not be able to use | 74 | If you enable this option, it will add about 4.8k to busybox |
| 50 | PAM to access remote LDAP password servers and whatnot. And if you | 75 | if you are building dynamically linked executable. |
| 51 | want hostname resolution to work with glibc, you still need the | 76 | In static build, it makes executable _smaller_ by about 1.2k. |
| 52 | /lib/libnss_* libraries. | ||
| 53 | |||
| 54 | If you enable this option, it will add about 1.5k to busybox. | ||
| 55 | 77 | ||
| 56 | config ADDGROUP | 78 | config ADDGROUP |
| 57 | bool "addgroup" | 79 | bool "addgroup" |
| @@ -255,4 +277,3 @@ config VLOCK | |||
| 255 | work properly. | 277 | work properly. |
| 256 | 278 | ||
| 257 | endmenu | 279 | endmenu |
| 258 | |||
