diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-10-26 23:29:03 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-27 17:34:36 +0100 |
commit | e039e689e3c4baefb4b62703429aaf86eef1bd99 (patch) | |
tree | 41d75770e7e1bb36a2662fa9c273ab4c806dc3c3 | |
parent | a48308701a4d89d7cc0d0557cfabaec94a0bb3b0 (diff) | |
download | busybox-w32-e039e689e3c4baefb4b62703429aaf86eef1bd99.tar.gz busybox-w32-e039e689e3c4baefb4b62703429aaf86eef1bd99.tar.bz2 busybox-w32-e039e689e3c4baefb4b62703429aaf86eef1bd99.zip |
wall: new applet
text data bss dec hex filename
81 0 0 81 51 miscutils/wall.o
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/applets.h | 1 | ||||
-rw-r--r-- | include/usage.h | 8 | ||||
-rw-r--r-- | miscutils/Config.in | 6 | ||||
-rw-r--r-- | miscutils/Kbuild | 1 | ||||
-rw-r--r-- | miscutils/wall.c | 36 | ||||
-rw-r--r-- | scripts/defconfig | 1 |
6 files changed, 53 insertions, 0 deletions
diff --git a/include/applets.h b/include/applets.h index 134f21e2f..9683f1ec8 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -417,6 +417,7 @@ IF_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_DROP)) | |||
417 | IF_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_DROP)) | 417 | IF_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_DROP)) |
418 | IF_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 418 | IF_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) |
419 | IF_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 419 | IF_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_DROP)) |
420 | IF_WALL(APPLET(wall, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | ||
420 | IF_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_DROP)) | 421 | IF_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_DROP)) |
421 | IF_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_DROP)) | 422 | IF_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_DROP)) |
422 | IF_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 423 | IF_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) |
diff --git a/include/usage.h b/include/usage.h index 93eb2f6ba..72b6acc47 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -4950,6 +4950,14 @@ | |||
4950 | #define volname_full_usage "\n\n" \ | 4950 | #define volname_full_usage "\n\n" \ |
4951 | "Show CD volume name of the DEVICE (default /dev/cdrom)" | 4951 | "Show CD volume name of the DEVICE (default /dev/cdrom)" |
4952 | 4952 | ||
4953 | #define wall_trivial_usage \ | ||
4954 | "[file]" | ||
4955 | #define wall_full_usage "\n\n" \ | ||
4956 | "Write content of file or standard-input to all logged-in users" | ||
4957 | #define wall_sample_usage \ | ||
4958 | "echo foo | wall\n" \ | ||
4959 | "wall ./mymessage" | ||
4960 | |||
4953 | #define watch_trivial_usage \ | 4961 | #define watch_trivial_usage \ |
4954 | "[-n seconds] [-t] PROG [ARGS]" | 4962 | "[-n seconds] [-t] PROG [ARGS]" |
4955 | #define watch_full_usage "\n\n" \ | 4963 | #define watch_full_usage "\n\n" \ |
diff --git a/miscutils/Config.in b/miscutils/Config.in index 9b804889b..842f7f9d2 100644 --- a/miscutils/Config.in +++ b/miscutils/Config.in | |||
@@ -612,6 +612,12 @@ config VOLNAME | |||
612 | help | 612 | help |
613 | Prints a CD-ROM volume name. | 613 | Prints a CD-ROM volume name. |
614 | 614 | ||
615 | config WALL | ||
616 | bool "wall" | ||
617 | default n | ||
618 | help | ||
619 | Write a message to all users that are logged in. | ||
620 | |||
615 | config WATCHDOG | 621 | config WATCHDOG |
616 | bool "watchdog" | 622 | bool "watchdog" |
617 | default n | 623 | default n |
diff --git a/miscutils/Kbuild b/miscutils/Kbuild index d88cb39ac..22a9adb34 100644 --- a/miscutils/Kbuild +++ b/miscutils/Kbuild | |||
@@ -42,4 +42,5 @@ lib-$(CONFIG_TIME) += time.o | |||
42 | lib-$(CONFIG_TIMEOUT) += timeout.o | 42 | lib-$(CONFIG_TIMEOUT) += timeout.o |
43 | lib-$(CONFIG_TTYSIZE) += ttysize.o | 43 | lib-$(CONFIG_TTYSIZE) += ttysize.o |
44 | lib-$(CONFIG_VOLNAME) += volname.o | 44 | lib-$(CONFIG_VOLNAME) += volname.o |
45 | lib-$(CONFIG_WALL) += wall.o | ||
45 | lib-$(CONFIG_WATCHDOG) += watchdog.o | 46 | lib-$(CONFIG_WATCHDOG) += watchdog.o |
diff --git a/miscutils/wall.c b/miscutils/wall.c new file mode 100644 index 000000000..2dbab60b4 --- /dev/null +++ b/miscutils/wall.c | |||
@@ -0,0 +1,36 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * wall - write a message to all logged-in users | ||
4 | * Copyright (c) 2009 Bernhard Reutner-Fischer | ||
5 | * | ||
6 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
7 | */ | ||
8 | |||
9 | #include "libbb.h" | ||
10 | #include <utmp.h> | ||
11 | |||
12 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
13 | int wall_main(int argc UNUSED_PARAM, char **argv) | ||
14 | { | ||
15 | struct utmp *ut; | ||
16 | char *msg; | ||
17 | int fd = argv[1] ? xopen(argv[1], O_RDONLY) : STDIN_FILENO; | ||
18 | |||
19 | msg = xmalloc_read(fd, NULL); | ||
20 | if (ENABLE_FEATURE_CLEAN_UP && argv[1]) | ||
21 | close(fd); | ||
22 | setutent(); | ||
23 | while ((ut = getutent()) != NULL) { | ||
24 | char *line; | ||
25 | if (ut->ut_type != USER_PROCESS) | ||
26 | continue; | ||
27 | line = concat_path_file("/dev", ut->ut_line); | ||
28 | xopen_xwrite_close(line, msg); | ||
29 | free(line); | ||
30 | } | ||
31 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
32 | endutent(); | ||
33 | free(msg); | ||
34 | } | ||
35 | return EXIT_SUCCESS; | ||
36 | } | ||
diff --git a/scripts/defconfig b/scripts/defconfig index 797f275d1..f8a92d4c3 100644 --- a/scripts/defconfig +++ b/scripts/defconfig | |||
@@ -638,6 +638,7 @@ CONFIG_TIME=y | |||
638 | CONFIG_TIMEOUT=y | 638 | CONFIG_TIMEOUT=y |
639 | CONFIG_TTYSIZE=y | 639 | CONFIG_TTYSIZE=y |
640 | CONFIG_VOLNAME=y | 640 | CONFIG_VOLNAME=y |
641 | CONFIG_WALL=y | ||
641 | CONFIG_WATCHDOG=y | 642 | CONFIG_WATCHDOG=y |
642 | 643 | ||
643 | # | 644 | # |