From 548620c18b1f0988dbeab1009788daf9f002e927 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 8 Dec 2016 12:24:48 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- include/libbb.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index bdafcf5a6..a42a2fba8 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1191,8 +1191,16 @@ int bb_cat(char** argv); /* If shell needs them, they exist even if not enabled as applets */ int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); -int test_main(int argc, char **argv) IF_TEST(MAIN_EXTERNALLY_VISIBLE); -int kill_main(int argc, char **argv) IF_KILL(MAIN_EXTERNALLY_VISIBLE); +int test_main(int argc, char **argv) +#if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2 + MAIN_EXTERNALLY_VISIBLE +#endif +; +int kill_main(int argc, char **argv) +#if ENABLE_KILL || ENABLE_KILLALL || ENABLE_KILLALL5 + MAIN_EXTERNALLY_VISIBLE +#endif +; /* Similar, but used by chgrp, not shell */ int chown_main(int argc, char **argv) IF_CHOWN(MAIN_EXTERNALLY_VISIBLE); /* Used by ftpd */ -- cgit v1.2.3-55-g6feb From c6f35241b38ea0c9581409efcd83716b74918903 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 9 Dec 2016 18:30:30 -0500 Subject: selinux: drop deprecated headers The selinux guys want you to get class values at runtime by converting textual names into constants. Drop the deprecated headers and switch to the new format. This API has been around for years, so there shouldn't be an issue with backwards compatibility. Signed-off-by: Mike Frysinger --- include/libbb.h | 2 -- libbb/update_passwd.c | 13 ++++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index a42a2fba8..2e9ea46e2 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -81,8 +81,6 @@ #if ENABLE_SELINUX # include # include -# include -# include #endif #if ENABLE_FEATURE_UTMP # if defined __UCLIBC__ && ( \ diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index a2004f480..6255af492 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c @@ -30,7 +30,18 @@ static void check_selinux_update_passwd(const char *username) if (!seuser) bb_error_msg_and_die("invalid context '%s'", context); if (strcmp(seuser, username) != 0) { - if (checkPasswdAccess(PASSWD__PASSWD) != 0) + security_class_t tclass; + access_vector_t av; + + tclass = string_to_security_class("passwd"); + if (tclass == 0) + goto die; + av = string_to_av_perm(tclass, "passwd"); + if (av == 0) + goto die; + + if (selinux_check_passwd_access(av) != 0) + die: bb_error_msg_and_die("SELinux: access denied"); } if (ENABLE_FEATURE_CLEAN_UP) -- cgit v1.2.3-55-g6feb From 4f13a7050787aadb402c9c47aae0ff778dbc2c8b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 16:29:32 +0100 Subject: suppress glibc "use sysmacros.h for major" warning Signed-off-by: Denys Vlasenko --- include/libbb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index 2e9ea46e2..b1fec0157 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -45,7 +45,7 @@ #include #include #include -#ifndef major +#if !defined(major) || defined(__GLIBC__) # include #endif #include -- cgit v1.2.3-55-g6feb From e184a883567ee3fd735644416e4bd683f1894ac5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 12 Dec 2016 19:56:31 +0100 Subject: df: implement -B n and -B formats of -B option Signed-off-by: Denys Vlasenko --- coreutils/df.c | 20 ++++++++++++++++++-- include/libbb.h | 1 + libbb/xatonum.c | 19 +++++++++++++++++++ util-linux/fstrim.c | 25 +++---------------------- 4 files changed, 41 insertions(+), 24 deletions(-) (limited to 'include/libbb.h') diff --git a/coreutils/df.c b/coreutils/df.c index fdcdae675..79e4c4670 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -129,8 +129,19 @@ int df_main(int argc UNUSED_PARAM, char **argv) if (opt & OPT_MEGA) df_disp_hr = 1024*1024; - if (opt & OPT_BSIZE) - df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */ + if (opt & OPT_BSIZE) { + /* GNU coreutils 8.25 accepts "-BMiB" form too */ + int i; + for (i = 0; kmg_i_suffixes[i].suffix[0]; i++) { + if (strcmp(kmg_i_suffixes[i].suffix, chp) == 0) { + df_disp_hr = kmg_i_suffixes[i].mult; + goto got_it; + } + } + /* Range used to disallow 0 */ + df_disp_hr = xatoul_range_sfx(chp, 1, ULONG_MAX, kmg_i_suffixes); + got_it: ; + } /* From the manpage of df from coreutils-6.10: * Disk space is shown in 1K blocks by default, unless the environment @@ -203,6 +214,11 @@ int df_main(int argc UNUSED_PARAM, char **argv) bb_simple_perror_msg(mount_point); goto set_error; } + /* Some uclibc versions were seen to lose f_frsize + * (kernel does return it, but then uclibc does not copy it) + */ + if (s.f_frsize == 0) + s.f_frsize = s.f_bsize; if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) { if (opt & OPT_INODE) { diff --git a/include/libbb.h b/include/libbb.h index b1fec0157..abdc8c2b8 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -923,6 +923,7 @@ extern const struct suffix_mult bkm_suffixes[]; #define km_suffixes (bkm_suffixes + 1) extern const struct suffix_mult cwbkMG_suffixes[]; #define kMG_suffixes (cwbkMG_suffixes + 3) +extern const struct suffix_mult kmg_i_suffixes[]; #include "xatonum.h" /* Specialized: */ 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[] = { /* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */ { "", 0 } }; + +const struct suffix_mult kmg_i_suffixes[] = { + { "KiB", 1024 }, + { "kiB", 1024 }, + { "K", 1024 }, + { "k", 1024 }, + { "MiB", 1048576 }, + { "miB", 1048576 }, + { "M", 1048576 }, + { "m", 1048576 }, + { "GiB", 1073741824 }, + { "giB", 1073741824 }, + { "G", 1073741824 }, + { "g", 1073741824 }, + { "KB", 1000 }, + { "MB", 1000000 }, + { "GB", 1000000000 }, + { "", 0 } +}; diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c index 51400ef0b..fc51878b6 100644 --- a/util-linux/fstrim.c +++ b/util-linux/fstrim.c @@ -47,25 +47,6 @@ struct fstrim_range { #define FITRIM _IOWR('X', 121, struct fstrim_range) #endif -static const struct suffix_mult fstrim_sfx[] = { - { "KiB", 1024 }, - { "kiB", 1024 }, - { "K", 1024 }, - { "k", 1024 }, - { "MiB", 1048576 }, - { "miB", 1048576 }, - { "M", 1048576 }, - { "m", 1048576 }, - { "GiB", 1073741824 }, - { "giB", 1073741824 }, - { "G", 1073741824 }, - { "g", 1073741824 }, - { "KB", 1000 }, - { "MB", 1000000 }, - { "GB", 1000000000 }, - { "", 0 } -}; - int fstrim_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int fstrim_main(int argc UNUSED_PARAM, char **argv) { @@ -98,11 +79,11 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv) range.len = ULLONG_MAX; if (opts & OPT_o) - range.start = xatoull_sfx(arg_o, fstrim_sfx); + range.start = xatoull_sfx(arg_o, kmg_i_suffixes); if (opts & OPT_l) - range.len = xatoull_sfx(arg_l, fstrim_sfx); + range.len = xatoull_sfx(arg_l, kmg_i_suffixes); if (opts & OPT_m) - range.minlen = xatoull_sfx(arg_m, fstrim_sfx); + range.minlen = xatoull_sfx(arg_m, kmg_i_suffixes); mp = argv[optind]; if (find_block_device(mp)) { -- cgit v1.2.3-55-g6feb