aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-03-24 11:55:30 +0000
committerRon Yorston <rmy@pobox.com>2021-03-24 12:43:15 +0000
commit355a7a6c1e9626b7afe8758a6095f3cf275c52e1 (patch)
tree6dab679c15b049cab97212e0b43077132eec1fbe /libbb
parent71ecc8033e6989996057b32577e71148fd544596 (diff)
parent889425812b5cda8b3394d73253cbde7355fb1115 (diff)
downloadbusybox-w32-w32_1_26_2.tar.gz
busybox-w32-w32_1_26_2.tar.bz2
busybox-w32-w32_1_26_2.zip
Merge tag '1_26_2' into w32_1_26_2w32_1_26_2
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Config.src2
-rw-r--r--libbb/Kbuild.src8
-rw-r--r--libbb/appletlib.c32
-rw-r--r--libbb/make_directory.c15
-rw-r--r--libbb/update_passwd.c15
-rw-r--r--libbb/xatonum.c19
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
153config FEATURE_USERNAME_COMPLETION 153config 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
135lib-$(CONFIG_TCPSVD) += udp_io.o 135lib-$(CONFIG_TCPSVD) += udp_io.o
136lib-$(CONFIG_UDPSVD) += udp_io.o 136lib-$(CONFIG_UDPSVD) += udp_io.o
137lib-$(CONFIG_TRACEROUTE) += udp_io.o 137lib-$(CONFIG_TRACEROUTE) += udp_io.o
138lib-$(CONFIG_TRACEROUTE6) += udp_io.o
138 139
139lib-$(CONFIG_LOSETUP) += loop.o 140lib-$(CONFIG_LOSETUP) += loop.o
140lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o 141lib-$(CONFIG_FEATURE_MOUNT_LOOP) += loop.o
@@ -144,7 +145,7 @@ lib-$(CONFIG_ADDUSER) += update_passwd.o
144lib-$(CONFIG_DELGROUP) += update_passwd.o 145lib-$(CONFIG_DELGROUP) += update_passwd.o
145lib-$(CONFIG_DELUSER) += update_passwd.o 146lib-$(CONFIG_DELUSER) += update_passwd.o
146 147
147lib-$(CONFIG_FTPD) += correct_password.o 148lib-$(CONFIG_FTPD) += pw_encrypt.o correct_password.o
148lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o 149lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o
149lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o 150lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o
150lib-$(CONFIG_CRYPTPW) += pw_encrypt.o 151lib-$(CONFIG_CRYPTPW) += pw_encrypt.o
@@ -159,6 +160,7 @@ lib-$(CONFIG_FEATURE_FTP_AUTHENTICATION) += pw_encrypt.o
159lib-$(CONFIG_DF) += find_mount_point.o 160lib-$(CONFIG_DF) += find_mount_point.o
160lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o 161lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o
161lib-$(CONFIG_MKFS_EXT2) += find_mount_point.o 162lib-$(CONFIG_MKFS_EXT2) += find_mount_point.o
163lib-$(CONFIG_MKE2FS) += find_mount_point.o
162lib-$(CONFIG_MKFS_REISER) += find_mount_point.o 164lib-$(CONFIG_MKFS_REISER) += find_mount_point.o
163lib-$(CONFIG_FSCK_MINIX) += find_mount_point.o 165lib-$(CONFIG_FSCK_MINIX) += find_mount_point.o
164lib-$(CONFIG_MOUNT) += find_mount_point.o 166lib-$(CONFIG_MOUNT) += find_mount_point.o
@@ -171,11 +173,13 @@ lib-$(CONFIG_MPSTAT) += get_cpu_count.o
171lib-$(CONFIG_POWERTOP) += get_cpu_count.o 173lib-$(CONFIG_POWERTOP) += get_cpu_count.o
172 174
173lib-$(CONFIG_PING) += inet_cksum.o 175lib-$(CONFIG_PING) += inet_cksum.o
176lib-$(CONFIG_PING6) += inet_cksum.o
174lib-$(CONFIG_TRACEROUTE) += inet_cksum.o 177lib-$(CONFIG_TRACEROUTE) += inet_cksum.o
175lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o 178lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o
176lib-$(CONFIG_UDHCPC) += inet_cksum.o 179lib-$(CONFIG_UDHCPC) += inet_cksum.o
177lib-$(CONFIG_UDHCPC6) += inet_cksum.o 180lib-$(CONFIG_UDHCPC6) += inet_cksum.o
178lib-$(CONFIG_UDHCPD) += inet_cksum.o 181lib-$(CONFIG_UDHCPD) += inet_cksum.o
182lib-$(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
184lib-$(CONFIG_AWK) += xregcomp.o 188lib-$(CONFIG_AWK) += xregcomp.o
185lib-$(CONFIG_SED) += xregcomp.o 189lib-$(CONFIG_SED) += xregcomp.o
186lib-$(CONFIG_GREP) += xregcomp.o 190lib-$(CONFIG_GREP) += xregcomp.o
191lib-$(CONFIG_EGREP) += xregcomp.o
192lib-$(CONFIG_FGREP) += xregcomp.o
187lib-$(CONFIG_EXPR) += xregcomp.o 193lib-$(CONFIG_EXPR) += xregcomp.o
188lib-$(CONFIG_MDEV) += xregcomp.o 194lib-$(CONFIG_MDEV) += xregcomp.o
189lib-$(CONFIG_LESS) += xregcomp.o 195lib-$(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
335static bool suid_cfg_readable; 335static bool suid_cfg_readable;
336 336
337/* check if u is member of group g */
338static 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 */
353static char *get_trimmed_slice(char *s, char *e) 338static 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 */
563static 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
577static void check_suid(int applet_no) 577static 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
100const 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};