hush/libbb
Daniel Thompson a818777d42 libbb: Enable support for !CONFIG_MULTIUSER
Linux recently gained a new config option, CONFIG_MULTIUSER, that makes
support for non-root users optional. This results in a number of syscalls
being disabled: setuid, setregid, setgid, setreuid, setresuid, getresuid,
setresgid, getresgid, setgroups, getgroups, setfsuid, setfsgid, capget,
capset.

Currently a number of busybox applets, including login, struggle to run
when CONFIG_MULTIUSER is disabled. Even the root user is unable to login:
  login: can't set groups: Functi

This patch adds code to make change_identity() a nop on single user
systems. It works by recognising the signature errno value (ENOSYS, due
to the system calls being disabled) and, to avoid security risks, only
deploys when the current uid and target uid is the same.

After the patch is applied any attempt to switch to a non-root user will
fail. Thus a badly configured userspace (for example, one that tries to
start a daemon as a non-root user when the kernel cannot support this)
will report errors as one would expect.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-12 23:59:57 +02:00
..
appletlib.c special-case {true,false,test} --help 2015-04-21 16:00:41 +02:00
ask_confirmation.c
bb_askpass.c libbb: fix bb_ask() to flush input before prompt, not after. Closes 7190 2014-07-01 13:20:22 +02:00
bb_bswap_64.c
bb_do_delay.c
bb_pwd.c libpwdgrp: rewritten to use malloced implementation 2015-01-02 21:37:59 +01:00
bb_qsort.c
bb_strtod.c
bb_strtonum.c
bbunit.c bbunit: fix WANT_TIMING compilation 2014-11-26 14:04:51 +01:00
change_identity.c libbb: Enable support for !CONFIG_MULTIUSER 2015-05-12 23:59:57 +02:00
chomp.c
compare_string_array.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
concat_path_file.c
concat_subpath_file.c
Config.src
copy_file.c Add conditional support for -v / --verbose 2014-05-19 16:23:50 +02:00
copyfd.c libbb: use sendfile() to copy data between file descriptors 2014-11-27 23:31:58 +01:00
correct_password.c ftpd: add optional support for authentication 2014-08-05 21:57:18 +02:00
crc32.c
default_error_retval.c
device_open.c
die_if_bad_username.c
dump.c
endofname.c
executable.c libbb: rename execable -> executable. No code changes 2014-05-02 17:15:58 +02:00
fclose_nonstdin.c sed: open input files sequentially to avoid EMFILE 2013-11-28 03:14:16 +01:00
fflush_stdout_and_exit.c
fgets_str.c
find_mount_point.c
find_pid_by_name.c
find_root_device.c
full_write.c
get_console.c
get_cpu_count.c
get_last_path_component.c
get_line_from_file.c
get_shell_name.c
get_volsize.c
getopt32.c
getpty.c script: make it work even if fd 0 is closed 2014-03-16 12:34:53 +01:00
hash_md5_sha.c sha3: tweak comments and indentation 2014-07-30 16:26:09 +02:00
hash_md5prime.c
herror_msg.c
human_readable.c Make smart_ulltoa return pointer to end (allows for code shink in callers) 2013-09-06 12:53:14 +02:00
in_ether.c fix failures found by randomconfig builds 2013-12-31 23:22:36 +01:00
inet_cksum.c
inet_common.c libbb: make INET[6]_rresolve use sockaddr2{host,dotted}_noport 2015-02-03 12:07:40 +01:00
info_msg.c
inode_hash.c du, copy_file: fix file matching on cramfs. Closes 5456 2014-02-25 15:27:58 +01:00
isdirectory.c
Kbuild.src randomconfig fixes 2014-12-22 19:37:05 +01:00
kernel_version.c
last_char_is.c
lineedit_ptr_hack.c
lineedit.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
llist.c
logenv.c zcip: Add environment variable for overriding log functionality 2014-11-04 12:19:04 +01:00
login.c
loop.c libbb/loop: don't try to re-use existing loop device 2015-02-07 19:13:57 +01:00
make_directory.c Add conditional support for -v / --verbose 2014-05-19 16:23:50 +02:00
makedev.c
match_fstype.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
messages.c
missing_syscalls.c Bionic lacks tcdrain; provide a workaround 2015-04-26 13:14:50 +02:00
mode_string.c
mtab.c
nuke_str.c fix failures found by randomconfig builds 2013-12-31 23:22:36 +01:00
obscure.c unit-tests: implement the unit-testing framework 2014-06-22 16:30:41 +02:00
parse_config.c
parse_mode.c
percent_decode.c
perror_msg.c
perror_nomsg_and_die.c
perror_nomsg.c
pidfile.c
platform.c Bionic lacks ttyname_r; provide a workaround 2015-04-25 21:32:48 +02:00
print_flags.c
printable_string.c
printable.c
process_escape_sequence.c
procps.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
progress.c
ptr_to_globals.c
pw_encrypt_des.c
pw_encrypt_md5.c fix assorted unused code and wrong format specs found by cppchekc (bug 6716) 2013-11-29 16:43:33 +01:00
pw_encrypt_sha.c
pw_encrypt.c libbb: don't die if crypt() returns NULL 2014-02-09 14:38:03 +01:00
read_key.c
read_printf.c libbb: remove unnecessary argument to nonblock_immune_read 2015-04-20 13:41:32 +02:00
read.c
README
recursive_action.c
remove_file.c Add conditional support for -v / --verbose 2014-05-19 16:23:50 +02:00
replace.c xargs: add support for -I and -i. Closes 493 2014-02-27 11:17:06 +01:00
rtc.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
run_shell.c
safe_gethostname.c
safe_poll.c
safe_strncpy.c
safe_write.c
selinux_common.c
setup_environment.c
signals.c
simplify_path.c
single_argv.c
skip_whitespace.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
speed_table.c libbb: FreeBSD fix for B<num> baud rate constants not fitting into a short. 2014-01-08 15:25:20 +01:00
str_tolower.c
strrstr.c unit-tests: implement the unit-testing framework 2014-06-22 16:30:41 +02:00
sysconf.c libbb: add sanity check in bb_arg_max() 2014-12-24 01:46:29 +01:00
systemd_support.c
time.c libbb: fix parsing of "10101010" date/time form 2014-01-21 07:58:18 +01:00
trim.c
u_signal_names.c
udp_io.c
unicode.c
update_passwd.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
utmp.c *: Switch to POSIX utmpx API 2015-04-02 23:03:46 +02:00
uuencode.c
vdprintf.c
verror_msg.c Fix compile failures 2014-05-02 07:18:55 +02:00
vfork_daemon_rexec.c
warn_ignoring_args.c
wfopen_input.c
wfopen.c
write.c
xatonum_template.c
xatonum.c truncate: new applet 2015-03-22 17:56:38 +01:00
xconnect.c libbb: introduce and use is_prefixed_with() 2015-03-12 17:48:34 +01:00
xfunc_die.c
xfuncs_printf.c libbb: Add xsetegid(), xseteuid(), xopen_as_uid_gid() functions 2013-10-08 14:52:49 +02:00
xfuncs.c less: move "retry-on-EAGAIN" logic closer to read ops 2014-09-22 21:14:02 +02:00
xgetcwd.c
xgethostbyname.c
xreadlink.c libbb: fix a bad check for uclibc >= 0.9.31 2014-03-16 20:53:40 +01:00
xrealloc_vector.c
xregcomp.c

Please see the LICENSE file for copyright information (GPLv2)

libbb is BusyBox's utility library.  All of this stuff used to be stuffed into
a single file named utility.c.  When I split utility.c to create libbb, some of
the very oldest stuff ended up without their original copyright and licensing
information (which is now lost in the mists of time).  If you see something
that you wrote that is mis-attributed, do let me know so we can fix that up.

	Erik Andersen
	<andersen@codepoet.org>