systems.c (8c8d43deb7274e9b44c2f76af38d36a7fdf30576) | systems.c (7cf368eb42edc6d7738f431289a1e3e2203421e6) |
---|---|
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.38 1998/06/15 19:06:25 brian Exp $ | 20 * $Id: systems.c,v 1.39 1998/10/17 12:28:03 brian Exp $ |
21 * 22 * TODO: 23 */ 24#include <sys/param.h> 25 26#include <ctype.h> 27#include <pwd.h> 28#include <stdio.h> --- 122 unchanged lines hidden (view full) --- 151{ 152 if (!strncasecmp(line, "include", 7) && issep(line[7])) { 153 InterpretArg(line+8, arg); 154 return CTRL_INCLUDE; 155 } 156 return CTRL_UNKNOWN; 157} 158 | 21 * 22 * TODO: 23 */ 24#include <sys/param.h> 25 26#include <ctype.h> 27#include <pwd.h> 28#include <stdio.h> --- 122 unchanged lines hidden (view full) --- 151{ 152 if (!strncasecmp(line, "include", 7) && issep(line[7])) { 153 InterpretArg(line+8, arg); 154 return CTRL_INCLUDE; 155 } 156 return CTRL_UNKNOWN; 157} 158 |
159/* Initialised in system_IsValid(), set in ReadSystem(), used by system_IsValid() */ | 159/* 160 * Initialised in system_IsValid(), set in ReadSystem(), 161 * used by system_IsValid() 162 */ |
160static int modeok; 161static int userok; 162static int modereq; 163 164int 165AllowUsers(struct cmdargs const *arg) 166{ 167 /* arg->bundle may be NULL (see system_IsValid()) ! */ --- 168 unchanged lines hidden (view full) --- 336 } 337 break; 338 } 339 } 340 fclose(fp); 341 return -1; 342} 343 | 163static int modeok; 164static int userok; 165static int modereq; 166 167int 168AllowUsers(struct cmdargs const *arg) 169{ 170 /* arg->bundle may be NULL (see system_IsValid()) ! */ --- 168 unchanged lines hidden (view full) --- 339 } 340 break; 341 } 342 } 343 fclose(fp); 344 return -1; 345} 346 |
344int | 347const char * |
345system_IsValid(const char *name, struct prompt *prompt, int mode) 346{ 347 /* 348 * Note: The ReadSystem() calls only result in calls to the Allow* 349 * functions. arg->bundle will be set to NULL for these commands ! 350 */ | 348system_IsValid(const char *name, struct prompt *prompt, int mode) 349{ 350 /* 351 * Note: The ReadSystem() calls only result in calls to the Allow* 352 * functions. arg->bundle will be set to NULL for these commands ! 353 */ |
351 if (ID0realuid() == 0) 352 return userok = modeok = 1; | 354 int def; 355 356 if (ID0realuid() == 0) { 357 userok = modeok = 1; 358 return NULL; 359 } 360 361 def = !strcmp(name, "default"); |
353 userok = 0; 354 modeok = 1; 355 modereq = mode; | 362 userok = 0; 363 modeok = 1; 364 modereq = mode; |
356 ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL); 357 if (name != NULL) 358 ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL); 359 return userok && modeok; | 365 366 if (ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL) != 0 && def) 367 return "System not found"; 368 369 if (!def && ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL) != 0) 370 return "System not found"; 371 372 if (!userok) 373 return "Invalid user id"; 374 375 if (!modeok) 376 return "Invalid mode"; 377 378 return NULL; |
360} 361 362int 363system_Select(struct bundle *bundle, const char *name, const char *file, 364 struct prompt *prompt, struct datalink *cx) 365{ 366 userok = modeok = 1; 367 modereq = PHYS_ALL; 368 return ReadSystem(bundle, name, file, 1, prompt, cx); 369} | 379} 380 381int 382system_Select(struct bundle *bundle, const char *name, const char *file, 383 struct prompt *prompt, struct datalink *cx) 384{ 385 userok = modeok = 1; 386 modereq = PHYS_ALL; 387 return ReadSystem(bundle, name, file, 1, prompt, cx); 388} |