diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-12 13:58:40 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-12 13:58:40 +0200 |
commit | 783d57af7bb2b851c16cf87df848e0365e5052da (patch) | |
tree | 71bb23e51b9cb40eac4a6fb831383134c1fc45a0 /miscutils/wall.c | |
parent | ac47a00e2ec398b04c3141cd3434a6e4b95740b1 (diff) | |
download | busybox-w32-783d57af7bb2b851c16cf87df848e0365e5052da.tar.gz busybox-w32-783d57af7bb2b851c16cf87df848e0365e5052da.tar.bz2 busybox-w32-783d57af7bb2b851c16cf87df848e0365e5052da.zip |
Sort some miscutils/ applets into coreutils or util-linux
No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/wall.c')
-rw-r--r-- | miscutils/wall.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/miscutils/wall.c b/miscutils/wall.c deleted file mode 100644 index 50658f457..000000000 --- a/miscutils/wall.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
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 source tree. | ||
7 | */ | ||
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 | |||
21 | //usage:#define wall_trivial_usage | ||
22 | //usage: "[FILE]" | ||
23 | //usage:#define wall_full_usage "\n\n" | ||
24 | //usage: "Write content of FILE or stdin to all logged-in users" | ||
25 | //usage: | ||
26 | //usage:#define wall_sample_usage | ||
27 | //usage: "echo foo | wall\n" | ||
28 | //usage: "wall ./mymessage" | ||
29 | |||
30 | #include "libbb.h" | ||
31 | |||
32 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
33 | int wall_main(int argc UNUSED_PARAM, char **argv) | ||
34 | { | ||
35 | struct utmpx *ut; | ||
36 | char *msg; | ||
37 | int fd; | ||
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 | fd = xopen_as_uid_gid(argv[1], O_RDONLY, getuid(), getgid()); | ||
45 | } | ||
46 | msg = xmalloc_read(fd, NULL); | ||
47 | if (ENABLE_FEATURE_CLEAN_UP && argv[1]) | ||
48 | close(fd); | ||
49 | setutxent(); | ||
50 | while ((ut = getutxent()) != NULL) { | ||
51 | char *line; | ||
52 | if (ut->ut_type != USER_PROCESS) | ||
53 | continue; | ||
54 | line = concat_path_file("/dev", ut->ut_line); | ||
55 | xopen_xwrite_close(line, msg); | ||
56 | free(line); | ||
57 | } | ||
58 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
59 | endutxent(); | ||
60 | free(msg); | ||
61 | } | ||
62 | return EXIT_SUCCESS; | ||
63 | } | ||