1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* System configuration routines
|
|
|
|
*
|
|
|
|
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
* by the Internet Initiative Japan, Inc. The name of the
|
|
|
|
* IIJ may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1995-01-31 06:29:58 +00:00
|
|
|
* TODO:
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <pwd.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-05-08 11:07:56 +00:00
|
|
|
#include <termios.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
1998-06-15 19:06:25 +00:00
|
|
|
#include "defs.h"
|
1997-11-22 03:37:54 +00:00
|
|
|
#include "command.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "log.h"
|
1997-11-09 06:22:49 +00:00
|
|
|
#include "id.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "systems.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
#define issep(ch) ((ch) == ' ' || (ch) == '\t')
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
FILE *
|
1997-11-22 03:37:54 +00:00
|
|
|
OpenSecret(const char *file)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
char line[100];
|
|
|
|
|
1997-11-09 06:22:49 +00:00
|
|
|
snprintf(line, sizeof line, "%s/%s", _PATH_PPP, file);
|
|
|
|
fp = ID0fopen(line, "r");
|
|
|
|
if (fp == NULL)
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogWARN, "OpenSecret: Can't open %s.\n", line);
|
1997-08-25 00:29:32 +00:00
|
|
|
return (fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-05-09 20:02:29 +00:00
|
|
|
CloseSecret(FILE *fp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
/* Move string from ``from'' to ``to'', interpreting ``~'' and $.... */
|
1999-12-20 20:30:25 +00:00
|
|
|
static const char *
|
|
|
|
InterpretArg(const char *from, char *to)
|
1997-11-09 17:51:27 +00:00
|
|
|
{
|
|
|
|
const char *env;
|
|
|
|
char *ptr, *startto, *endto;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
startto = to;
|
|
|
|
endto = to + LINE_LEN - 1;
|
|
|
|
|
|
|
|
while(issep(*from))
|
|
|
|
from++;
|
1999-12-20 20:30:25 +00:00
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
if (*from == '~') {
|
1999-12-20 20:30:47 +00:00
|
|
|
struct passwd *pwd;
|
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
ptr = strchr(++from, '/');
|
|
|
|
len = ptr ? ptr - from : strlen(from);
|
|
|
|
if (len == 0) {
|
1999-12-20 20:30:47 +00:00
|
|
|
pwd = getpwuid(getuid());
|
1997-11-09 17:51:27 +00:00
|
|
|
} else {
|
|
|
|
strncpy(to, from, len);
|
|
|
|
to[len] = '\0';
|
|
|
|
pwd = getpwnam(to);
|
|
|
|
}
|
1999-12-20 20:30:47 +00:00
|
|
|
strncpy(to, pwd ? pwd->pw_dir : _PATH_PPP, endto - to);
|
|
|
|
endpwent();
|
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
*endto = '\0';
|
|
|
|
to += strlen(to);
|
|
|
|
from += len;
|
|
|
|
}
|
|
|
|
|
1999-12-20 20:30:25 +00:00
|
|
|
while (to < endto && !issep(*from) && *from != '#' && *from != '\0') {
|
1997-11-09 17:51:27 +00:00
|
|
|
if (*from == '$') {
|
|
|
|
if (from[1] == '$') {
|
|
|
|
*to = '\0'; /* For an empty var name below */
|
|
|
|
from += 2;
|
|
|
|
} else if (from[1] == '{') {
|
|
|
|
ptr = strchr(from+2, '}');
|
|
|
|
if (ptr) {
|
|
|
|
len = ptr - from - 2;
|
|
|
|
if (endto - to < len )
|
|
|
|
len = endto - to;
|
|
|
|
if (len) {
|
|
|
|
strncpy(to, from+2, len);
|
|
|
|
to[len] = '\0';
|
|
|
|
from = ptr+1;
|
|
|
|
} else {
|
|
|
|
*to++ = *from++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*to++ = *from++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ptr = to;
|
|
|
|
for (from++; (isalnum(*from) || *from == '_') && ptr < endto; from++)
|
|
|
|
*ptr++ = *from;
|
|
|
|
*ptr = '\0';
|
|
|
|
}
|
|
|
|
if (*to == '\0')
|
|
|
|
*to++ = '$';
|
|
|
|
else if ((env = getenv(to)) != NULL) {
|
|
|
|
strncpy(to, env, endto - to);
|
|
|
|
*endto = '\0';
|
|
|
|
to += strlen(to);
|
|
|
|
}
|
1999-12-20 20:30:25 +00:00
|
|
|
} else {
|
|
|
|
if (*from == '\\')
|
|
|
|
from++;
|
1997-11-09 17:51:27 +00:00
|
|
|
*to++ = *from++;
|
1999-12-20 20:30:25 +00:00
|
|
|
}
|
1997-11-09 17:51:27 +00:00
|
|
|
}
|
1999-12-20 20:30:25 +00:00
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
while (to > startto) {
|
|
|
|
to--;
|
|
|
|
if (!issep(*to)) {
|
|
|
|
to++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*to = '\0';
|
1999-12-20 20:30:25 +00:00
|
|
|
|
|
|
|
while (issep(*from))
|
|
|
|
from++;
|
|
|
|
|
|
|
|
return from;
|
1997-11-09 17:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CTRL_UNKNOWN (0)
|
|
|
|
#define CTRL_INCLUDE (1)
|
|
|
|
|
|
|
|
static int
|
|
|
|
DecodeCtrlCommand(char *line, char *arg)
|
|
|
|
{
|
1999-12-20 20:30:25 +00:00
|
|
|
const char *end;
|
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
if (!strncasecmp(line, "include", 7) && issep(line[7])) {
|
1999-12-20 20:30:25 +00:00
|
|
|
end = InterpretArg(line+8, arg);
|
|
|
|
if (*end && *end != '#')
|
|
|
|
log_Printf(LogWARN, "Usage: !include filename\n");
|
|
|
|
else
|
|
|
|
return CTRL_INCLUDE;
|
1997-11-09 17:51:27 +00:00
|
|
|
}
|
|
|
|
return CTRL_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
1998-10-31 17:38:47 +00:00
|
|
|
/*
|
|
|
|
* Initialised in system_IsValid(), set in ReadSystem(),
|
|
|
|
* used by system_IsValid()
|
|
|
|
*/
|
1998-04-10 13:19:23 +00:00
|
|
|
static int modeok;
|
1997-11-11 22:58:14 +00:00
|
|
|
static int userok;
|
1998-04-10 13:19:23 +00:00
|
|
|
static int modereq;
|
1997-11-11 22:58:14 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
int
|
1997-11-22 03:37:54 +00:00
|
|
|
AllowUsers(struct cmdargs const *arg)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
/* arg->bundle may be NULL (see system_IsValid()) ! */
|
1997-11-11 22:58:14 +00:00
|
|
|
int f;
|
1999-12-20 20:30:40 +00:00
|
|
|
struct passwd *pwd;
|
1997-11-11 22:58:14 +00:00
|
|
|
|
|
|
|
userok = 0;
|
1999-12-20 20:30:40 +00:00
|
|
|
pwd = getpwuid(getuid());
|
|
|
|
if (pwd != NULL)
|
1998-04-14 23:17:24 +00:00
|
|
|
for (f = arg->argn; f < arg->argc; f++)
|
1999-12-20 20:30:40 +00:00
|
|
|
if (!strcmp("*", arg->argv[f]) || !strcmp(pwd->pw_name, arg->argv[f])) {
|
1997-11-11 22:58:14 +00:00
|
|
|
userok = 1;
|
|
|
|
break;
|
|
|
|
}
|
1999-12-20 20:30:40 +00:00
|
|
|
endpwent();
|
1997-11-11 22:58:14 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-11-22 03:37:54 +00:00
|
|
|
AllowModes(struct cmdargs const *arg)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
/* arg->bundle may be NULL (see system_IsValid()) ! */
|
1998-05-15 23:58:30 +00:00
|
|
|
int f, mode, allowed;
|
1997-11-11 22:58:14 +00:00
|
|
|
|
|
|
|
allowed = 0;
|
1998-04-14 23:17:24 +00:00
|
|
|
for (f = arg->argn; f < arg->argc; f++) {
|
1998-05-15 23:58:30 +00:00
|
|
|
mode = Nam2mode(arg->argv[f]);
|
|
|
|
if (mode == PHYS_NONE || mode == PHYS_ALL)
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogWARN, "allow modes: %s: Invalid mode\n", arg->argv[f]);
|
1998-05-15 23:58:30 +00:00
|
|
|
else
|
|
|
|
allowed |= mode;
|
1997-11-11 22:58:14 +00:00
|
|
|
}
|
|
|
|
|
1998-04-10 13:19:23 +00:00
|
|
|
modeok = modereq & allowed ? 1 : 0;
|
1997-11-11 22:58:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-02-04 01:03:36 +00:00
|
|
|
static char *
|
|
|
|
strip(char *line)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = strlen(line);
|
|
|
|
while (len && (line[len-1] == '\n' || line[len-1] == '\r' ||
|
|
|
|
issep(line[len-1])))
|
|
|
|
line[--len] = '\0';
|
|
|
|
|
|
|
|
while (issep(*line))
|
|
|
|
line++;
|
|
|
|
|
|
|
|
if (*line == '#')
|
|
|
|
*line = '\0';
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xgets(char *buf, int buflen, FILE *fp)
|
|
|
|
{
|
|
|
|
int len, n;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
while (fgets(buf, buflen-1, fp)) {
|
|
|
|
n++;
|
|
|
|
buf[buflen-1] = '\0';
|
|
|
|
len = strlen(buf);
|
|
|
|
while (len && (buf[len-1] == '\n' || buf[len-1] == '\r'))
|
|
|
|
buf[--len] = '\0';
|
|
|
|
if (len && buf[len-1] == '\\') {
|
|
|
|
buf += len - 1;
|
|
|
|
buflen -= len - 1;
|
|
|
|
if (!buflen) /* No buffer space */
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
1999-02-02 09:35:30 +00:00
|
|
|
/* Values for ``how'' in ReadSystem */
|
|
|
|
#define SYSTEM_EXISTS 1
|
|
|
|
#define SYSTEM_VALIDATE 2
|
|
|
|
#define SYSTEM_EXEC 3
|
|
|
|
|
1999-12-23 21:43:00 +00:00
|
|
|
static char *
|
|
|
|
GetLabel(char *line, const char *filename, int linenum)
|
|
|
|
{
|
1999-12-27 11:43:31 +00:00
|
|
|
char *argv[MAXARGS];
|
|
|
|
int argc, len;
|
|
|
|
|
|
|
|
argc = MakeArgs(line, argv, MAXARGS, PARSE_REDUCE);
|
|
|
|
|
|
|
|
if (argc == 2 && !strcmp(argv[1], ":"))
|
|
|
|
return argv[0];
|
|
|
|
|
|
|
|
if (argc != 1 || (len = strlen(argv[0])) < 2 || argv[0][len-1] != ':') {
|
|
|
|
log_Printf(LogWARN, "Bad label in %s (line %d) - missing colon\n",
|
1999-12-23 21:43:00 +00:00
|
|
|
filename, linenum);
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-12-27 11:43:31 +00:00
|
|
|
argv[0][len-1] = '\0'; /* Lose the ':' */
|
1999-12-23 21:43:00 +00:00
|
|
|
|
1999-12-27 11:43:31 +00:00
|
|
|
return argv[0];
|
1999-12-23 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 20:39:03 +00:00
|
|
|
/* Returns -2 for ``file not found'' and -1 for ``label not found'' */
|
|
|
|
|
1997-11-11 22:58:14 +00:00
|
|
|
static int
|
1998-02-02 19:32:16 +00:00
|
|
|
ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
1999-02-02 09:35:30 +00:00
|
|
|
struct prompt *prompt, struct datalink *cx, int how)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
FILE *fp;
|
1999-12-23 21:43:00 +00:00
|
|
|
char *cp;
|
1997-11-04 01:17:05 +00:00
|
|
|
int n, len;
|
1997-11-09 14:18:55 +00:00
|
|
|
char line[LINE_LEN];
|
1997-12-17 21:22:01 +00:00
|
|
|
char filename[MAXPATHLEN];
|
1997-05-10 01:22:19 +00:00
|
|
|
int linenum;
|
1997-11-11 22:58:14 +00:00
|
|
|
int argc;
|
1998-06-15 19:06:25 +00:00
|
|
|
char *argv[MAXARGS];
|
1997-11-11 22:58:14 +00:00
|
|
|
int allowcmd;
|
1998-02-04 01:03:36 +00:00
|
|
|
int indent;
|
|
|
|
char arg[LINE_LEN];
|
1999-09-06 08:16:33 +00:00
|
|
|
struct prompt *op;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1997-11-09 17:51:27 +00:00
|
|
|
if (*file == '/')
|
|
|
|
snprintf(filename, sizeof filename, "%s", file);
|
|
|
|
else
|
|
|
|
snprintf(filename, sizeof filename, "%s/%s", _PATH_PPP, file);
|
1997-11-09 06:22:49 +00:00
|
|
|
fp = ID0fopen(filename, "r");
|
1995-01-31 06:29:58 +00:00
|
|
|
if (fp == NULL) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogDEBUG, "ReadSystem: Can't open %s.\n", filename);
|
1999-03-09 20:39:03 +00:00
|
|
|
return -2;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename);
|
1997-05-10 01:22:19 +00:00
|
|
|
|
|
|
|
linenum = 0;
|
1998-02-04 01:03:36 +00:00
|
|
|
while ((n = xgets(line, sizeof line, fp))) {
|
|
|
|
linenum += n;
|
|
|
|
if (issep(*line))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cp = strip(line);
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
switch (*cp) {
|
1998-02-04 01:03:36 +00:00
|
|
|
case '\0': /* empty/comment */
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
1998-02-04 01:03:36 +00:00
|
|
|
|
|
|
|
case '!':
|
|
|
|
switch (DecodeCtrlCommand(cp+1, arg)) {
|
|
|
|
case CTRL_INCLUDE:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
|
1999-02-02 09:35:30 +00:00
|
|
|
n = ReadSystem(bundle, name, arg, prompt, cx, how);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
|
1998-02-04 01:03:36 +00:00
|
|
|
if (!n)
|
|
|
|
return 0; /* got it */
|
|
|
|
break;
|
|
|
|
default:
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogWARN, "%s: %s: Invalid command\n", filename, cp);
|
1998-02-04 01:03:36 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
break;
|
1998-02-04 01:03:36 +00:00
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
default:
|
1999-12-23 21:43:00 +00:00
|
|
|
if ((cp = GetLabel(cp, filename, linenum)) == NULL)
|
|
|
|
continue;
|
1998-02-04 01:03:36 +00:00
|
|
|
|
|
|
|
if (strcmp(cp, name) == 0) {
|
|
|
|
/* We're in business */
|
1999-02-02 09:35:30 +00:00
|
|
|
if (how == SYSTEM_EXISTS)
|
|
|
|
return 0;
|
1998-02-04 01:03:36 +00:00
|
|
|
while ((n = xgets(line, sizeof line, fp))) {
|
|
|
|
linenum += n;
|
|
|
|
indent = issep(*line);
|
|
|
|
cp = strip(line);
|
|
|
|
|
1999-12-23 21:43:00 +00:00
|
|
|
if (*cp == '\0') /* empty / comment */
|
1998-02-04 01:03:36 +00:00
|
|
|
continue;
|
|
|
|
|
1999-12-23 21:43:00 +00:00
|
|
|
if (!indent) { /* start of next section */
|
|
|
|
if (*cp != '!' && how == SYSTEM_EXEC)
|
1999-12-27 11:43:31 +00:00
|
|
|
cp = GetLabel(cp, filename, linenum);
|
1998-02-04 01:03:36 +00:00
|
|
|
break;
|
1998-10-17 12:28:03 +00:00
|
|
|
}
|
1998-02-04 01:03:36 +00:00
|
|
|
|
|
|
|
len = strlen(cp);
|
1999-12-20 20:30:02 +00:00
|
|
|
if ((argc = command_Interpret(cp, len, argv)) < 0)
|
|
|
|
log_Printf(LogWARN, "%s: %d: Syntax error\n", filename, linenum);
|
|
|
|
else {
|
|
|
|
allowcmd = argc > 0 && !strcasecmp(argv[0], "allow");
|
1999-12-20 20:30:30 +00:00
|
|
|
if ((how != SYSTEM_EXEC && allowcmd) ||
|
|
|
|
(how == SYSTEM_EXEC && !allowcmd)) {
|
1999-12-20 20:30:02 +00:00
|
|
|
/*
|
|
|
|
* Disable any context so that warnings are given to everyone,
|
|
|
|
* including syslog.
|
|
|
|
*/
|
|
|
|
op = log_PromptContext;
|
|
|
|
log_PromptContext = NULL;
|
|
|
|
command_Run(bundle, argc, (char const *const *)argv, prompt,
|
|
|
|
name, cx);
|
|
|
|
log_PromptContext = op;
|
|
|
|
}
|
1999-09-06 08:16:33 +00:00
|
|
|
}
|
1997-11-09 17:51:27 +00:00
|
|
|
}
|
1998-02-04 01:03:36 +00:00
|
|
|
|
|
|
|
fclose(fp); /* everything read - get out */
|
|
|
|
return 0;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
1997-06-09 03:27:43 +00:00
|
|
|
return -1;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1998-10-31 17:38:47 +00:00
|
|
|
const char *
|
1998-05-01 19:26:12 +00:00
|
|
|
system_IsValid(const char *name, struct prompt *prompt, int mode)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
1998-02-02 19:32:16 +00:00
|
|
|
/*
|
|
|
|
* Note: The ReadSystem() calls only result in calls to the Allow*
|
|
|
|
* functions. arg->bundle will be set to NULL for these commands !
|
|
|
|
*/
|
1999-03-09 20:39:03 +00:00
|
|
|
int def, how, rs;
|
1998-10-31 17:38:47 +00:00
|
|
|
|
|
|
|
def = !strcmp(name, "default");
|
1999-02-02 09:35:30 +00:00
|
|
|
how = ID0realuid() == 0 ? SYSTEM_EXISTS : SYSTEM_VALIDATE;
|
1997-11-11 22:58:14 +00:00
|
|
|
userok = 0;
|
|
|
|
modeok = 1;
|
1998-04-10 13:19:23 +00:00
|
|
|
modereq = mode;
|
1998-10-31 17:38:47 +00:00
|
|
|
|
1999-03-09 20:39:03 +00:00
|
|
|
rs = ReadSystem(NULL, "default", CONFFILE, prompt, NULL, how);
|
|
|
|
|
|
|
|
if (!def) {
|
|
|
|
if (rs == -1)
|
|
|
|
rs = 0; /* we don't care that ``default'' doesn't exist */
|
|
|
|
|
|
|
|
if (rs == 0)
|
|
|
|
rs = ReadSystem(NULL, name, CONFFILE, prompt, NULL, how);
|
1999-02-02 09:35:30 +00:00
|
|
|
|
1999-03-09 20:39:03 +00:00
|
|
|
if (rs == -1)
|
|
|
|
return "Configuration label not found";
|
|
|
|
|
|
|
|
if (rs == -2)
|
|
|
|
return _PATH_PPP "/" CONFFILE ": File not found";
|
|
|
|
}
|
1998-10-31 17:38:47 +00:00
|
|
|
|
1999-02-02 09:35:30 +00:00
|
|
|
if (how == SYSTEM_EXISTS)
|
|
|
|
userok = modeok = 1;
|
1998-10-31 17:38:47 +00:00
|
|
|
|
|
|
|
if (!userok)
|
1999-02-02 09:35:30 +00:00
|
|
|
return "User access denied";
|
1998-10-31 17:38:47 +00:00
|
|
|
|
|
|
|
if (!modeok)
|
1999-02-02 09:35:30 +00:00
|
|
|
return "Mode denied for this label";
|
1998-10-31 17:38:47 +00:00
|
|
|
|
|
|
|
return NULL;
|
1997-11-11 22:58:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-05-01 19:26:12 +00:00
|
|
|
system_Select(struct bundle *bundle, const char *name, const char *file,
|
1998-06-15 19:05:51 +00:00
|
|
|
struct prompt *prompt, struct datalink *cx)
|
1997-11-11 22:58:14 +00:00
|
|
|
{
|
|
|
|
userok = modeok = 1;
|
1998-04-10 13:19:23 +00:00
|
|
|
modereq = PHYS_ALL;
|
1999-02-02 09:35:30 +00:00
|
|
|
return ReadSystem(bundle, name, file, prompt, cx, SYSTEM_EXEC);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|