xref: /titanic_41/usr/src/cmd/bnu/xqt.c (revision fa9e4066f08beec538e775443c5be79dd423fcab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1988 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include "uucp.h"
34 
35 static void euucico();
36 
37 /*
38  * start up uucico for rmtname
39  * return:
40  *	none
41  */
42 void
43 xuucico(rmtname)
44 char *rmtname;
45 {
46 	/*
47 	 * start uucico for rmtname system
48 	 */
49 	if (fork() == 0) {	/* can't vfork() */
50 		/*
51 		 * hide the uid of the initiator of this job so that he
52 		 * doesn't get notified about things that don't concern him.
53 		 */
54 		(void) setuid(geteuid());
55 		euucico(rmtname);
56 	}
57 	return;
58 }
59 
60 static void
61 euucico(rmtname)
62 char	*rmtname;
63 {
64 	char opt[100];
65 
66 	(void) close(0);
67 	(void) close(1);
68 	(void) close(2);
69 	(void) open("/dev/null", 0);
70 	(void) open("/dev/null", 1);
71 	(void) open("/dev/null", 1);
72 	(void) signal(SIGINT, SIG_IGN);
73 	(void) signal(SIGHUP, SIG_IGN);
74 	(void) signal(SIGQUIT, SIG_IGN);
75 	ucloselog();
76 	if (rmtname[0] != '\0')
77 		(void) sprintf(opt, "-s%s", rmtname);
78 	else
79 		opt[0] = '\0';
80 	(void) execle(UUCICO, "UUCICO", "-r1", opt, (char *) 0, Env);
81 	exit(100);
82 }
83 
84 
85 /*
86  * start up uuxqt
87  * return:
88  *	none
89  */
90 void
91 xuuxqt(rmtname)
92 char	*rmtname;
93 {
94 	char	opt[100];
95 	register int i, maxfiles;
96 
97 	if (rmtname && rmtname[0] != '\0')
98 		(void) sprintf(opt, "-s%s", rmtname);
99 	else
100 		opt[0] = '\0';
101 	/*
102 	 * start uuxqt
103 	 */
104 	if (vfork() == 0) {
105 		(void) close(0);
106 		(void) close(1);
107 		(void) close(2);
108 		(void) open("/dev/null", 2);
109 		(void) open("/dev/null", 2);
110 		(void) open("/dev/null", 2);
111 		(void) signal(SIGINT, SIG_IGN);
112 		(void) signal(SIGHUP, SIG_IGN);
113 		(void) signal(SIGQUIT, SIG_IGN);
114 		ucloselog();
115 #ifdef ATTSVR3
116 		maxfiles = ulimit(4, 0);
117 #else /* !ATTSVR3 */
118 #ifdef BSD4_2
119 		maxfiles = getdtablesize();
120 #else /* BSD4_2 */
121 		maxfiles = NOFILE;
122 #endif /* BSD4_2 */
123 #endif /* ATTSVR3 */
124 		for (i = 3; i < maxfiles; i++)
125 			(void) close(i);
126 		/*
127 		 * hide the uid of the initiator of this job so that he
128 		 * doesn't get notified about things that don't concern him.
129 		 */
130 		(void) setuid(geteuid());
131 		(void) execle(UUXQT, "UUXQT", opt, (char *) 0, Env);
132 		_exit(100);
133 	}
134 	return;
135 }
136