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
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.
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
34 int Uerrors
= 0; /* error count */
36 /* This unusual include (#include "permission.c") is done because
37 * uucheck wants to use the global static variable in permission.c
41 #include "permission.c"
44 /* These are here because uucpdefs.c is not used, and
45 * some routines are referenced (never called within uucheck execution)
49 #define USAGE "[-v] [-xNUM]"
52 int mkdirs(){ return (0); }
53 int canPath(){ return (0); }
54 char RemSpool
[] = SPOOL
; /* this is a dummy for chkpth() -- never used here */
56 char *Pubdir
= PUBDIR
;
58 char Progname
[NAMESIZE
];
59 /* used for READANY and READSOME macros */
62 /* This is stuff for uucheck */
71 "CORRUPT", CORRUPTDIR
,
79 "PERMISSIONS", PERMISSIONS
,
82 "DIALCODES", DIALCODES
,
85 "USRSPOOLLOCKS", "/var/spool/locks",
88 "NOSTRANGERS", NOSTRANGERS
,
90 "LIMITS", LIMITS
, /* if not defined we'll stat NULL, it's not a bug */
92 "WORKSPACE", WORKSPACE
,
93 "admin directory", ADMIN
,
97 extern char *nextarg();
98 int verbose
= 0; /* fsck-like verbosity */
109 (void) strcpy(Progname
, "uucheck");
110 while ((i
= getopt(argc
, argv
, "vx:")) != EOF
) {
118 Debug
= atoi(optarg
);
123 "WARNING: uucheck built with SMALL flag defined -- no debug info available\n");
128 (void) fprintf(stderr
, "\tusage: %s %s\n",
133 if (argc
!= optind
) {
134 (void) fprintf(stderr
, "\tusage: %s %s\n", Progname
, USAGE
);
138 if (verbose
) printf("*** uucheck: Check Required Files and Directories\n");
139 for (tabptr
= tab
; tabptr
->name
!= NULL
; tabptr
++) {
140 if (stat(tabptr
->value
, &statbuf
) < 0) {
141 fprintf(stderr
, "%s - ", tabptr
->name
);
142 perror(tabptr
->value
);
147 if (verbose
) printf("*** uucheck: Directories Check Complete\n\n");
149 /* check the permissions file */
151 if (verbose
) printf("*** uucheck: Check %s file\n", PERMISSIONS
);
152 Uerrors
+= checkPerm();
153 if (verbose
) printf("*** uucheck: %s Check Complete\n\n", PERMISSIONS
);
163 char defaults
[BUFSIZ
];
165 for (type
=0; type
<2; type
++) {
166 /* type = 0 for LOGNAME, 1 for MACHINE */
168 if (verbose
) printf("** %s \n\n",
170 ?"MACHINE PHASE (when we call or execute their uux requests)"
171 :"LOGNAME PHASE (when they call us)" );
173 Fp
= fopen(PERMISSIONS
, "r");
175 if (verbose
) printf("can't open %s\n", PERMISSIONS
);
180 if (parse_tokens(_Flds
, NULL
) != 0) {
184 if (_Flds
[type
] == NULL
)
187 /* XXX - need to reset defaults here */
189 /* if no ReadPath set num to 1--Path already set */
190 fillList(U_READPATH
, _RPaths
);
191 fillList(U_WRITEPATH
, _WPaths
);
192 fillList(U_NOREADPATH
, _NoRPaths
);
193 fillList(U_NOWRITEPATH
, _NoWPaths
);
194 if (_Flds
[U_COMMANDS
] == NULL
) {
195 strcpy(defaults
, DEFAULTCMDS
);
196 _Flds
[U_COMMANDS
] = defaults
;
198 fillList(U_COMMANDS
, _Commands
);
199 error
+= outLine(type
);
201 if (verbose
) printf("\n");
212 char *arg
, cmd
[BUFSIZ
];
214 char myname
[MAXBASENAME
+1];
216 if (_Flds
[type
][0] == 0)
219 if (type
== U_LOGNAME
) { /* for LOGNAME */
220 p
= _Flds
[U_LOGNAME
];
221 if (verbose
) printf("When a system logs in as: ");
223 p
= nextarg(p
, &arg
);
224 if (verbose
) printf("(%s) ", arg
);
226 if (verbose
) printf("\n");
229 if (verbose
) printf("\tWe will call them back.\n\n");
234 p
= _Flds
[U_MACHINE
];
235 if (verbose
) printf("When we call system(s): ");
237 p
= nextarg(p
, &arg
);
238 if (verbose
) printf("(%s) ", arg
);
240 if (verbose
) printf("\n");
244 if (verbose
) printf("\tWe %s allow them to request files.\n",
245 requestOK()? "DO" : "DO NOT");
247 if (type
== U_LOGNAME
) {
248 if (verbose
) printf("\tWe %s send files queued for them on this call.\n",
249 switchRole()? "WILL" : "WILL NOT");
252 if (verbose
) printf("\tThey can send files to\n");
253 if (_Flds
[U_WRITEPATH
] == NULL
) {
254 if (verbose
) printf("\t %s (DEFAULT)\n", Pubdir
);
257 for (i
=0; _WPaths
[i
] != NULL
; i
++)
258 if (verbose
) printf("\t %s\n", _WPaths
[i
]);
261 if (_Flds
[U_NOWRITEPATH
] != NULL
) {
262 if (verbose
) printf("\tExcept\n");
263 for (i
=0; _NoWPaths
[i
] != NULL
; i
++)
264 if (verbose
) printf("\t %s\n", _NoWPaths
[i
]);
269 (void) printf("\tSent files will be created directly in the target directory.\n");
271 (void) printf("\tSent files will be created in %s\n", SPOOL
);
272 (void) printf("\t before they are copied to the target directory.\n");
277 if (verbose
) printf("\tThey can request files from\n");
278 if (_Flds
[U_READPATH
] == NULL
) {
279 if (verbose
) printf("\t %s (DEFAULT)\n", Pubdir
);
282 for (i
=0; _RPaths
[i
] != NULL
; i
++)
283 if (verbose
) printf("\t %s\n", _RPaths
[i
]);
286 if (_Flds
[U_NOREADPATH
] != NULL
) {
287 if (verbose
) printf("\tExcept\n");
288 for (i
=0; _NoRPaths
[i
] != NULL
; i
++)
289 if (verbose
) printf("\t %s\n", _NoRPaths
[i
]);
294 if (verbose
) printf("\tMyname for the conversation will be %s.\n",
296 if (verbose
) printf("\tPUBDIR for the conversation will be %s.\n",
299 if (verbose
) printf("\n");
301 if (type
== U_MACHINE
) {
302 if (verbose
) printf("Machine(s): ");
303 p
= _Flds
[U_MACHINE
];
305 p
= nextarg(p
, &arg
);
306 if (verbose
) printf("(%s) ", arg
);
308 if (verbose
) printf("\nCAN execute the following commands:\n");
309 for (i
=0; _Commands
[i
] != NULL
; i
++) {
310 if (cmdOK(BASENAME(_Commands
[i
], '/'), cmd
) == FALSE
) {
311 if (verbose
) printf("Software Error in permission.c\n");
314 if (verbose
) printf("command (%s), fullname (%s)\n",
315 BASENAME(_Commands
[i
], '/'), cmd
);
317 if (verbose
) printf("\n");