systems.c (d91d286164db7f10f516a9d0bca0a3527e864714) systems.c (30291ffb15d7e4b02d0e8de225a57dd49f655d4e)
1/*
2 * System configuration routines
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * System configuration routines
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: systems.c,v 1.35.2.10 1998/05/15 23:58:29 brian Exp $
20 * $Id: systems.c,v 1.36 1998/05/21 21:48:33 brian Exp $
21 *
22 * TODO:
23 */
24#include <sys/param.h>
25
26#include <ctype.h>
27#include <pwd.h>
28#include <stdio.h>

--- 209 unchanged lines hidden (view full) ---

238 } else
239 break;
240 }
241 return n;
242}
243
244static int
245ReadSystem(struct bundle *bundle, const char *name, const char *file,
21 *
22 * TODO:
23 */
24#include <sys/param.h>
25
26#include <ctype.h>
27#include <pwd.h>
28#include <stdio.h>

--- 209 unchanged lines hidden (view full) ---

238 } else
239 break;
240 }
241 return n;
242}
243
244static int
245ReadSystem(struct bundle *bundle, const char *name, const char *file,
246 int doexec, struct prompt *prompt)
246 int doexec, struct prompt *prompt, struct datalink *cx)
247{
248 FILE *fp;
249 char *cp, *wp;
250 int n, len;
251 char line[LINE_LEN];
252 char filename[MAXPATHLEN];
253 int linenum;
254 int argc;

--- 24 unchanged lines hidden (view full) ---

279 switch (*cp) {
280 case '\0': /* empty/comment */
281 break;
282
283 case '!':
284 switch (DecodeCtrlCommand(cp+1, arg)) {
285 case CTRL_INCLUDE:
286 log_Printf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
247{
248 FILE *fp;
249 char *cp, *wp;
250 int n, len;
251 char line[LINE_LEN];
252 char filename[MAXPATHLEN];
253 int linenum;
254 int argc;

--- 24 unchanged lines hidden (view full) ---

279 switch (*cp) {
280 case '\0': /* empty/comment */
281 break;
282
283 case '!':
284 switch (DecodeCtrlCommand(cp+1, arg)) {
285 case CTRL_INCLUDE:
286 log_Printf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
287 n = ReadSystem(bundle, name, arg, doexec, prompt);
287 n = ReadSystem(bundle, name, arg, doexec, prompt, cx);
288 log_Printf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
289 if (!n)
290 return 0; /* got it */
291 break;
292 default:
293 log_Printf(LogWARN, "%s: %s: Invalid command\n", filename, cp);
294 break;
295 }

--- 21 unchanged lines hidden (view full) ---

317
318 if (!indent) /* start of next section */
319 break;
320
321 len = strlen(cp);
322 command_Interpret(cp, len, &argc, &argv);
323 allowcmd = argc > 0 && !strcasecmp(*argv, "allow");
324 if ((!doexec && allowcmd) || (doexec && !allowcmd))
288 log_Printf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
289 if (!n)
290 return 0; /* got it */
291 break;
292 default:
293 log_Printf(LogWARN, "%s: %s: Invalid command\n", filename, cp);
294 break;
295 }

--- 21 unchanged lines hidden (view full) ---

317
318 if (!indent) /* start of next section */
319 break;
320
321 len = strlen(cp);
322 command_Interpret(cp, len, &argc, &argv);
323 allowcmd = argc > 0 && !strcasecmp(*argv, "allow");
324 if ((!doexec && allowcmd) || (doexec && !allowcmd))
325 command_Run(bundle, argc, (char const *const *)argv, prompt, name);
325 command_Run(bundle, argc, (char const *const *)argv, prompt,
326 name, cx);
326 }
327
328 fclose(fp); /* everything read - get out */
329 return 0;
330 }
331 break;
332 }
333 }

--- 8 unchanged lines hidden (view full) ---

342 * Note: The ReadSystem() calls only result in calls to the Allow*
343 * functions. arg->bundle will be set to NULL for these commands !
344 */
345 if (ID0realuid() == 0)
346 return userok = modeok = 1;
347 userok = 0;
348 modeok = 1;
349 modereq = mode;
327 }
328
329 fclose(fp); /* everything read - get out */
330 return 0;
331 }
332 break;
333 }
334 }

--- 8 unchanged lines hidden (view full) ---

343 * Note: The ReadSystem() calls only result in calls to the Allow*
344 * functions. arg->bundle will be set to NULL for these commands !
345 */
346 if (ID0realuid() == 0)
347 return userok = modeok = 1;
348 userok = 0;
349 modeok = 1;
350 modereq = mode;
350 ReadSystem(NULL, "default", CONFFILE, 0, prompt);
351 ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL);
351 if (name != NULL)
352 if (name != NULL)
352 ReadSystem(NULL, name, CONFFILE, 0, prompt);
353 ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL);
353 return userok && modeok;
354}
355
356int
357system_Select(struct bundle *bundle, const char *name, const char *file,
354 return userok && modeok;
355}
356
357int
358system_Select(struct bundle *bundle, const char *name, const char *file,
358 struct prompt *prompt)
359 struct prompt *prompt, struct datalink *cx)
359{
360 userok = modeok = 1;
361 modereq = PHYS_ALL;
360{
361 userok = modeok = 1;
362 modereq = PHYS_ALL;
362 return ReadSystem(bundle, name, file, 1, prompt);
363 return ReadSystem(bundle, name, file, 1, prompt, cx);
363}
364}