Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/miscutils/wall.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/miscutils/wall.c
r3232 r3621 6 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 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 8 20 9 21 //usage:#define wall_trivial_usage … … 21 33 int wall_main(int argc UNUSED_PARAM, char **argv) 22 34 { 23 struct utmp *ut;35 struct utmpx *ut; 24 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 fd = xopen_as_uid_gid(argv[1], O_RDONLY, getuid(), getgid()); 45 } 27 46 msg = xmalloc_read(fd, NULL); 28 47 if (ENABLE_FEATURE_CLEAN_UP && argv[1]) 29 48 close(fd); 30 setut ent();31 while ((ut = getut ent()) != NULL) {49 setutxent(); 50 while ((ut = getutxent()) != NULL) { 32 51 char *line; 33 52 if (ut->ut_type != USER_PROCESS) … … 38 57 } 39 58 if (ENABLE_FEATURE_CLEAN_UP) { 40 endut ent();59 endutxent(); 41 60 free(msg); 42 61 }
Note:
See TracChangeset
for help on using the changeset viewer.