]> git.sesse.net Git - rdpsrv/blob - Xserver/config/util/chownxterm.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / config / util / chownxterm.c
1 /* $XConsortium: chownxterm.c,v 1.3 94/04/17 20:10:41 gildea Exp $ */
2 /*
3
4 Copyright (c) 1993, 1994  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26
27 */
28
29 /*
30  * chownxterm --- make xterm suid root
31  *
32  * By Stephen Gildea, December 1993
33  */
34
35
36 #define XTERM_PATH "/x11/programs/xterm/xterm"
37
38 #include <stdio.h>
39 #include <errno.h>
40
41 char *prog_name;
42
43 void help()
44 {
45     setgid(getgid());
46     setuid(getuid());
47     printf("chown-xterm makes %s suid root\n", XTERM_PATH);
48     printf("This is necessary on Ultrix for /dev/tty operation.\n");
49     exit(0);
50 }
51
52 void print_error(err_string)
53     char *err_string;
54 {
55     setgid(getgid());
56     setuid(getuid());
57     fprintf(stderr, "%s: \"%s\"", prog_name, err_string);
58     perror(" failed");
59     exit(1);
60 }
61
62 main(argc, argv)
63     int argc;
64     char **argv;
65 {
66     prog_name = argv[0];
67     if (argc >= 2 && strcmp(argv[1], "-help") == 0) {
68         help();
69     } else {
70         if (chown(XTERM_PATH, 0, -1) != 0)
71             print_error("chown root " XTERM_PATH);
72         if (chmod(XTERM_PATH, 04555) != 0)
73             print_error("chmod 4555 " XTERM_PATH);
74     }
75     exit(0);
76 }