Last change
on this file since 965 was 821, checked in by Bruno Cornec, 18 years ago |
Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)
|
File size:
1014 bytes
|
Line | |
---|
1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * mesg implementation for busybox
|
---|
4 | *
|
---|
5 | * Copyright (c) 2002 Manuel Novoa III <mjn3@codepoet.org>
|
---|
6 | *
|
---|
7 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include "busybox.h"
|
---|
11 | #include <unistd.h>
|
---|
12 | #include <stdlib.h>
|
---|
13 |
|
---|
14 | #ifdef USE_TTY_GROUP
|
---|
15 | #define S_IWGRP_OR_S_IWOTH S_IWGRP
|
---|
16 | #else
|
---|
17 | #define S_IWGRP_OR_S_IWOTH (S_IWGRP | S_IWOTH)
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | int mesg_main(int argc, char *argv[])
|
---|
21 | {
|
---|
22 | struct stat sb;
|
---|
23 | char *tty;
|
---|
24 | char c = 0;
|
---|
25 |
|
---|
26 | if ((--argc == 0)
|
---|
27 | || ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) {
|
---|
28 | if ((tty = ttyname(STDERR_FILENO)) == NULL) {
|
---|
29 | tty = "ttyname";
|
---|
30 | } else if (stat(tty, &sb) == 0) {
|
---|
31 | if (argc == 0) {
|
---|
32 | puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) ==
|
---|
33 | 0) ? "is n" : "is y");
|
---|
34 | return EXIT_SUCCESS;
|
---|
35 | }
|
---|
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) {
|
---|
41 | return EXIT_SUCCESS;
|
---|
42 | }
|
---|
43 | }
|
---|
44 | bb_perror_msg_and_die("%s", tty);
|
---|
45 | }
|
---|
46 | bb_show_usage();
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.