aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-10-06 15:14:25 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-10-06 15:14:25 +0200
commitcd256e1c407aa70dfefb7178ed2c0e4201f1aaf7 (patch)
treefefa7b99ae531051123281cc5673e0022940de5c
parent3eab2b7675fc7e2889cd69285a2a31980a4bf504 (diff)
downloadbusybox-w32-cd256e1c407aa70dfefb7178ed2c0e4201f1aaf7.tar.gz
busybox-w32-cd256e1c407aa70dfefb7178ed2c0e4201f1aaf7.tar.bz2
busybox-w32-cd256e1c407aa70dfefb7178ed2c0e4201f1aaf7.zip
wall: access FILE under real user's credentials
While at it, move applet/config/kbuild bits into wall.c. (This way, it's more visible that applet is suid'ed). function old new delta wall_main 87 138 +51 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/applets.src.h2
-rw-r--r--miscutils/Config.src7
-rw-r--r--miscutils/Kbuild.src1
-rw-r--r--miscutils/wall.c25
4 files changed, 24 insertions, 11 deletions
diff --git a/include/applets.src.h b/include/applets.src.h
index aa319bbc9..3a47e15b9 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -407,8 +407,6 @@ IF_VCONFIG(APPLET(vconfig, BB_DIR_SBIN, BB_SUID_DROP))
407/* Needs to be run by root or be suid root - needs to change uid and gid: */ 407/* Needs to be run by root or be suid root - needs to change uid and gid: */
408IF_VLOCK(APPLET(vlock, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) 408IF_VLOCK(APPLET(vlock, BB_DIR_USR_BIN, BB_SUID_REQUIRE))
409IF_VOLNAME(APPLET(volname, BB_DIR_USR_BIN, BB_SUID_DROP)) 409IF_VOLNAME(APPLET(volname, BB_DIR_USR_BIN, BB_SUID_DROP))
410/* Needs to be run by root or be suid root - needs to write to /dev/TTY: */
411IF_WALL(APPLET(wall, BB_DIR_USR_BIN, BB_SUID_REQUIRE))
412IF_WATCH(APPLET(watch, BB_DIR_BIN, BB_SUID_DROP)) 410IF_WATCH(APPLET(watch, BB_DIR_BIN, BB_SUID_DROP))
413IF_WATCHDOG(APPLET(watchdog, BB_DIR_SBIN, BB_SUID_DROP)) 411IF_WATCHDOG(APPLET(watchdog, BB_DIR_SBIN, BB_SUID_DROP))
414IF_WC(APPLET(wc, BB_DIR_USR_BIN, BB_SUID_DROP)) 412IF_WC(APPLET(wc, BB_DIR_USR_BIN, BB_SUID_DROP))
diff --git a/miscutils/Config.src b/miscutils/Config.src
index b9fc196d8..117ec7739 100644
--- a/miscutils/Config.src
+++ b/miscutils/Config.src
@@ -591,13 +591,6 @@ config VOLNAME
591 help 591 help
592 Prints a CD-ROM volume name. 592 Prints a CD-ROM volume name.
593 593
594config WALL
595 bool "wall"
596 default y
597 depends on FEATURE_UTMP
598 help
599 Write a message to all users that are logged in.
600
601config WATCHDOG 594config WATCHDOG
602 bool "watchdog" 595 bool "watchdog"
603 default y 596 default y
diff --git a/miscutils/Kbuild.src b/miscutils/Kbuild.src
index 8c498643b..f3954f407 100644
--- a/miscutils/Kbuild.src
+++ b/miscutils/Kbuild.src
@@ -46,5 +46,4 @@ lib-$(CONFIG_TIME) += time.o
46lib-$(CONFIG_TIMEOUT) += timeout.o 46lib-$(CONFIG_TIMEOUT) += timeout.o
47lib-$(CONFIG_TTYSIZE) += ttysize.o 47lib-$(CONFIG_TTYSIZE) += ttysize.o
48lib-$(CONFIG_VOLNAME) += volname.o 48lib-$(CONFIG_VOLNAME) += volname.o
49lib-$(CONFIG_WALL) += wall.o
50lib-$(CONFIG_WATCHDOG) += watchdog.o 49lib-$(CONFIG_WATCHDOG) += watchdog.o
diff --git a/miscutils/wall.c b/miscutils/wall.c
index 762f53b72..c74f4f27b 100644
--- a/miscutils/wall.c
+++ b/miscutils/wall.c
@@ -6,6 +6,18 @@
6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8 8
9//config:config WALL
10//config: bool "wall"
11//config: default y
12//config: depends on FEATURE_UTMP
13//config: help
14//config: Write a message to all users that are logged in.
15
16/* Needs to be run by root or be suid root - needs to write to /dev/TTY: */
17//applet:IF_WALL(APPLET(wall, BB_DIR_USR_BIN, BB_SUID_REQUIRE))
18
19//kbuild:lib-$(CONFIG_WALL) += wall.o
20
9//usage:#define wall_trivial_usage 21//usage:#define wall_trivial_usage
10//usage: "[FILE]" 22//usage: "[FILE]"
11//usage:#define wall_full_usage "\n\n" 23//usage:#define wall_full_usage "\n\n"
@@ -22,8 +34,19 @@ int wall_main(int argc UNUSED_PARAM, char **argv)
22{ 34{
23 struct utmp *ut; 35 struct utmp *ut;
24 char *msg; 36 char *msg;
25 int fd = argv[1] ? xopen(argv[1], O_RDONLY) : STDIN_FILENO; 37 int fd;
26 38
39 fd = STDIN_FILENO;
40 if (argv[1]) {
41 /* The applet is setuid.
42 * Access to the file must be under user's uid/gid.
43 */
44 setfsuid(getuid());
45 setfsgid(getgid());
46 fd = xopen(argv[1], O_RDONLY);
47 setfsuid(geteuid());
48 setfsgid(getegid());
49 }
27 msg = xmalloc_read(fd, NULL); 50 msg = xmalloc_read(fd, NULL);
28 if (ENABLE_FEATURE_CLEAN_UP && argv[1]) 51 if (ENABLE_FEATURE_CLEAN_UP && argv[1])
29 close(fd); 52 close(fd);