Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/init/mesg.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/init/mesg.c
r821 r1770 8 8 */ 9 9 10 #include "busybox.h" 11 #include <unistd.h> 12 #include <stdlib.h> 10 #include "libbb.h" 13 11 14 12 #ifdef USE_TTY_GROUP … … 18 16 #endif 19 17 20 int mesg_main(int argc, char *argv[]) 18 int mesg_main(int argc, char **argv); 19 int mesg_main(int argc, char **argv) 21 20 { 22 21 struct stat sb; 23 c har *tty;22 const char *tty; 24 23 char c = 0; 25 24 26 if ((--argc == 0) 27 || ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) { 28 if ((tty = ttyname(STDERR_FILENO)) == NULL) { 25 if (--argc == 0 26 || (argc == 1 && ((c = **++argv) == 'y' || c == 'n')) 27 ) { 28 tty = ttyname(STDERR_FILENO); 29 if (tty == NULL) { 29 30 tty = "ttyname"; 30 31 } else if (stat(tty, &sb) == 0) { 32 mode_t m; 31 33 if (argc == 0) { 32 puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) == 33 0) ? "is n" : "is y"); 34 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); 34 35 return EXIT_SUCCESS; 35 36 } 36 if (chmod 37 (tty, 38 (c == 39 'y') ? sb.st_mode | (S_IWGRP_OR_S_IWOTH) : sb. 40 st_mode & ~(S_IWGRP | S_IWOTH)) == 0) { 37 m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH 38 : sb.st_mode & ~(S_IWGRP|S_IWOTH); 39 if (chmod(tty, m) == 0) { 41 40 return EXIT_SUCCESS; 42 41 }
Note:
See TracChangeset
for help on using the changeset viewer.