diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/Config.src | 2 | ||||
-rw-r--r-- | libbb/Kbuild.src | 8 | ||||
-rw-r--r-- | libbb/appletlib.c | 32 | ||||
-rw-r--r-- | libbb/make_directory.c | 15 | ||||
-rw-r--r-- | libbb/update_passwd.c | 15 | ||||
-rw-r--r-- | libbb/xatonum.c | 19 |
6 files changed, 70 insertions, 21 deletions
diff --git a/libbb/Config.src b/libbb/Config.src index 00804e31e..172fbcc0e 100644 --- a/libbb/Config.src +++ b/libbb/Config.src | |||
@@ -152,7 +152,7 @@ config FEATURE_TAB_COMPLETION | |||
152 | 152 | ||
153 | config FEATURE_USERNAME_COMPLETION | 153 | config FEATURE_USERNAME_COMPLETION |
154 | bool "Username completion" | 154 | bool "Username completion" |
155 | default n | 155 | default y |
156 | depends on FEATURE_TAB_COMPLETION | 156 | depends on FEATURE_TAB_COMPLETION |
157 | help | 157 | help |
158 | Enable username completion. | 158 | Enable username completion. |
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 39d9d907d..fc9371db1 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src | |||
@@ -135,6 +135,7 @@ lib-$(CONFIG_TFTPD) += udp_io.o | |||
135 | lib-$(CONFIG_TCPSVD) += udp_io.o | 135 | lib-$(CONFIG_TCPSVD) += udp_io.o |
136 | lib-$(CONFIG_UDPSVD) += udp_io.o | 136 | lib-$(CONFIG_UDPSVD) += udp_io.o |
137 | lib-$(CONFIG_TRACEROUTE) += udp_io.o | 137 | lib-$(CONFIG_TRACEROUTE) += udp_io.o |
138 | lib-$(CONFIG_TRACEROUTE6) += udp_io.o | ||
138 | 139 | ||
139 | lib-$(CONFIG_LOSETUP) += loop.o | 140 | lib-$(CONFIG_LOSETUP) += loop.o |
140 | lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o | 141 | lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o |
@@ -144,7 +145,7 @@ lib-$(CONFIG_ADDUSER) += update_passwd.o | |||
144 | lib-$(CONFIG_DELGROUP) += update_passwd.o | 145 | lib-$(CONFIG_DELGROUP) += update_passwd.o |
145 | lib-$(CONFIG_DELUSER) += update_passwd.o | 146 | lib-$(CONFIG_DELUSER) += update_passwd.o |
146 | 147 | ||
147 | lib-$(CONFIG_FTPD) += correct_password.o | 148 | lib-$(CONFIG_FTPD) += pw_encrypt.o correct_password.o |
148 | lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o | 149 | lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o |
149 | lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o | 150 | lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o |
150 | lib-$(CONFIG_CRYPTPW) += pw_encrypt.o | 151 | lib-$(CONFIG_CRYPTPW) += pw_encrypt.o |
@@ -159,6 +160,7 @@ lib-$(CONFIG_FEATURE_FTP_AUTHENTICATION) += pw_encrypt.o | |||
159 | lib-$(CONFIG_DF) += find_mount_point.o | 160 | lib-$(CONFIG_DF) += find_mount_point.o |
160 | lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o | 161 | lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o |
161 | lib-$(CONFIG_MKFS_EXT2) += find_mount_point.o | 162 | lib-$(CONFIG_MKFS_EXT2) += find_mount_point.o |
163 | lib-$(CONFIG_MKE2FS) += find_mount_point.o | ||
162 | lib-$(CONFIG_MKFS_REISER) += find_mount_point.o | 164 | lib-$(CONFIG_MKFS_REISER) += find_mount_point.o |
163 | lib-$(CONFIG_FSCK_MINIX) += find_mount_point.o | 165 | lib-$(CONFIG_FSCK_MINIX) += find_mount_point.o |
164 | lib-$(CONFIG_MOUNT) += find_mount_point.o | 166 | lib-$(CONFIG_MOUNT) += find_mount_point.o |
@@ -171,11 +173,13 @@ lib-$(CONFIG_MPSTAT) += get_cpu_count.o | |||
171 | lib-$(CONFIG_POWERTOP) += get_cpu_count.o | 173 | lib-$(CONFIG_POWERTOP) += get_cpu_count.o |
172 | 174 | ||
173 | lib-$(CONFIG_PING) += inet_cksum.o | 175 | lib-$(CONFIG_PING) += inet_cksum.o |
176 | lib-$(CONFIG_PING6) += inet_cksum.o | ||
174 | lib-$(CONFIG_TRACEROUTE) += inet_cksum.o | 177 | lib-$(CONFIG_TRACEROUTE) += inet_cksum.o |
175 | lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o | 178 | lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o |
176 | lib-$(CONFIG_UDHCPC) += inet_cksum.o | 179 | lib-$(CONFIG_UDHCPC) += inet_cksum.o |
177 | lib-$(CONFIG_UDHCPC6) += inet_cksum.o | 180 | lib-$(CONFIG_UDHCPC6) += inet_cksum.o |
178 | lib-$(CONFIG_UDHCPD) += inet_cksum.o | 181 | lib-$(CONFIG_UDHCPD) += inet_cksum.o |
182 | lib-$(CONFIG_DHCPRELAY) += inet_cksum.o | ||
179 | 183 | ||
180 | # We shouldn't build xregcomp.c if we don't need it - this ensures we don't | 184 | # We shouldn't build xregcomp.c if we don't need it - this ensures we don't |
181 | # require regex.h to be in the include dir even if we don't need it thereby | 185 | # require regex.h to be in the include dir even if we don't need it thereby |
@@ -184,6 +188,8 @@ lib-$(CONFIG_UDHCPD) += inet_cksum.o | |||
184 | lib-$(CONFIG_AWK) += xregcomp.o | 188 | lib-$(CONFIG_AWK) += xregcomp.o |
185 | lib-$(CONFIG_SED) += xregcomp.o | 189 | lib-$(CONFIG_SED) += xregcomp.o |
186 | lib-$(CONFIG_GREP) += xregcomp.o | 190 | lib-$(CONFIG_GREP) += xregcomp.o |
191 | lib-$(CONFIG_EGREP) += xregcomp.o | ||
192 | lib-$(CONFIG_FGREP) += xregcomp.o | ||
187 | lib-$(CONFIG_EXPR) += xregcomp.o | 193 | lib-$(CONFIG_EXPR) += xregcomp.o |
188 | lib-$(CONFIG_MDEV) += xregcomp.o | 194 | lib-$(CONFIG_MDEV) += xregcomp.o |
189 | lib-$(CONFIG_LESS) += xregcomp.o | 195 | lib-$(CONFIG_LESS) += xregcomp.o |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 1fe0eb44f..ac3e414f5 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -334,21 +334,6 @@ static struct suid_config_t { | |||
334 | 334 | ||
335 | static bool suid_cfg_readable; | 335 | static bool suid_cfg_readable; |
336 | 336 | ||
337 | /* check if u is member of group g */ | ||
338 | static int ingroup(uid_t u, gid_t g) | ||
339 | { | ||
340 | struct group *grp = getgrgid(g); | ||
341 | if (grp) { | ||
342 | char **mem; | ||
343 | for (mem = grp->gr_mem; *mem; mem++) { | ||
344 | struct passwd *pwd = getpwnam(*mem); | ||
345 | if (pwd && (pwd->pw_uid == u)) | ||
346 | return 1; | ||
347 | } | ||
348 | } | ||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | /* libbb candidate */ | 337 | /* libbb candidate */ |
353 | static char *get_trimmed_slice(char *s, char *e) | 338 | static char *get_trimmed_slice(char *s, char *e) |
354 | { | 339 | { |
@@ -573,7 +558,22 @@ static inline void parse_config_file(void) | |||
573 | # endif /* FEATURE_SUID_CONFIG */ | 558 | # endif /* FEATURE_SUID_CONFIG */ |
574 | 559 | ||
575 | 560 | ||
576 | # if ENABLE_FEATURE_SUID | 561 | # if ENABLE_FEATURE_SUID && NUM_APPLETS > 0 |
562 | /* check if u is member of group g */ | ||
563 | static int ingroup(uid_t u, gid_t g) | ||
564 | { | ||
565 | struct group *grp = getgrgid(g); | ||
566 | if (grp) { | ||
567 | char **mem; | ||
568 | for (mem = grp->gr_mem; *mem; mem++) { | ||
569 | struct passwd *pwd = getpwnam(*mem); | ||
570 | if (pwd && (pwd->pw_uid == u)) | ||
571 | return 1; | ||
572 | } | ||
573 | } | ||
574 | return 0; | ||
575 | } | ||
576 | |||
577 | static void check_suid(int applet_no) | 577 | static void check_suid(int applet_no) |
578 | { | 578 | { |
579 | gid_t rgid; /* real gid */ | 579 | gid_t rgid; /* real gid */ |
diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 3980376ec..840c525b0 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c | |||
@@ -35,9 +35,20 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags) | |||
35 | char c; | 35 | char c; |
36 | struct stat st; | 36 | struct stat st; |
37 | 37 | ||
38 | /* Happens on bb_make_directory(dirname("no_slashes"),...) */ | 38 | /* "path" can be a result of dirname(). |
39 | if (LONE_CHAR(path, '.')) | 39 | * dirname("no_slashes") returns ".", possibly read-only. |
40 | * musl dirname() can return read-only "/" too. | ||
41 | * We need writable string. And for "/", "." (and ".."?) | ||
42 | * nothing needs to be created anyway. | ||
43 | */ | ||
44 | if (LONE_CHAR(path, '/')) | ||
40 | return 0; | 45 | return 0; |
46 | if (path[0] == '.') { | ||
47 | if (path[1] == '\0') | ||
48 | return 0; /* "." */ | ||
49 | // if (path[1] == '.' && path[2] == '\0') | ||
50 | // return 0; /* ".." */ | ||
51 | } | ||
41 | 52 | ||
42 | org_mask = cur_mask = (mode_t)-1L; | 53 | org_mask = cur_mask = (mode_t)-1L; |
43 | s = path; | 54 | s = path; |
diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index a2004f480..95423d19b 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c | |||
@@ -30,7 +30,18 @@ static void check_selinux_update_passwd(const char *username) | |||
30 | if (!seuser) | 30 | if (!seuser) |
31 | bb_error_msg_and_die("invalid context '%s'", context); | 31 | bb_error_msg_and_die("invalid context '%s'", context); |
32 | if (strcmp(seuser, username) != 0) { | 32 | if (strcmp(seuser, username) != 0) { |
33 | if (checkPasswdAccess(PASSWD__PASSWD) != 0) | 33 | security_class_t tclass; |
34 | access_vector_t av; | ||
35 | |||
36 | tclass = string_to_security_class("passwd"); | ||
37 | if (tclass == 0) | ||
38 | goto die; | ||
39 | av = string_to_av_perm(tclass, "passwd"); | ||
40 | if (av == 0) | ||
41 | goto die; | ||
42 | |||
43 | if (selinux_check_passwd_access(av) != 0) | ||
44 | die: | ||
34 | bb_error_msg_and_die("SELinux: access denied"); | 45 | bb_error_msg_and_die("SELinux: access denied"); |
35 | } | 46 | } |
36 | if (ENABLE_FEATURE_CLEAN_UP) | 47 | if (ENABLE_FEATURE_CLEAN_UP) |
@@ -169,6 +180,7 @@ int FAST_FUNC update_passwd(const char *filename, | |||
169 | if (!line) /* EOF/error */ | 180 | if (!line) /* EOF/error */ |
170 | break; | 181 | break; |
171 | 182 | ||
183 | #if ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP | ||
172 | if (!name && member) { | 184 | if (!name && member) { |
173 | /* Delete member from all groups */ | 185 | /* Delete member from all groups */ |
174 | /* line is "GROUP:PASSWD:[member1[,member2]...]" */ | 186 | /* line is "GROUP:PASSWD:[member1[,member2]...]" */ |
@@ -198,6 +210,7 @@ int FAST_FUNC update_passwd(const char *filename, | |||
198 | fprintf(new_fp, "%s\n", line); | 210 | fprintf(new_fp, "%s\n", line); |
199 | goto next; | 211 | goto next; |
200 | } | 212 | } |
213 | #endif | ||
201 | 214 | ||
202 | cp = is_prefixed_with(line, name_colon); | 215 | cp = is_prefixed_with(line, name_colon); |
203 | if (!cp) { | 216 | if (!cp) { |
diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 9dd5c3e7e..b63b7f54d 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c | |||
@@ -96,3 +96,22 @@ const struct suffix_mult cwbkMG_suffixes[] = { | |||
96 | /* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */ | 96 | /* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */ |
97 | { "", 0 } | 97 | { "", 0 } |
98 | }; | 98 | }; |
99 | |||
100 | const struct suffix_mult kmg_i_suffixes[] = { | ||
101 | { "KiB", 1024 }, | ||
102 | { "kiB", 1024 }, | ||
103 | { "K", 1024 }, | ||
104 | { "k", 1024 }, | ||
105 | { "MiB", 1048576 }, | ||
106 | { "miB", 1048576 }, | ||
107 | { "M", 1048576 }, | ||
108 | { "m", 1048576 }, | ||
109 | { "GiB", 1073741824 }, | ||
110 | { "giB", 1073741824 }, | ||
111 | { "G", 1073741824 }, | ||
112 | { "g", 1073741824 }, | ||
113 | { "KB", 1000 }, | ||
114 | { "MB", 1000000 }, | ||
115 | { "GB", 1000000000 }, | ||
116 | { "", 0 } | ||
117 | }; | ||