version 1.13, 1999/11/10 23:36:44 |
version 1.14, 1999/11/14 21:45:07 |
|
|
|
|
typedef enum |
typedef enum |
{ |
{ |
|
oBadOption, |
oForwardAgent, oForwardX11, oGatewayPorts, oRhostsAuthentication, |
oForwardAgent, oForwardX11, oGatewayPorts, oRhostsAuthentication, |
oPasswordAuthentication, oRSAAuthentication, oFallBackToRsh, oUseRsh, |
oPasswordAuthentication, oRSAAuthentication, oFallBackToRsh, oUseRsh, |
#ifdef KRB4 |
#ifdef KRB4 |
|
|
if (strcmp(cp, keywords[i].name) == 0) |
if (strcmp(cp, keywords[i].name) == 0) |
return keywords[i].opcode; |
return keywords[i].opcode; |
|
|
fatal("%.200s line %d: Bad configuration option.", |
fprintf(stderr, "%s: line %d: Bad configuration option: %s\n", |
filename, linenum); |
filename, linenum, cp); |
/*NOTREACHED*/ |
return oBadOption; |
return 0; |
|
} |
} |
|
|
/* Processes a single option line as used in the configuration files. |
/* Processes a single option line as used in the configuration files. |
This only sets those values that have not already been set. */ |
This only sets those values that have not already been set. */ |
|
|
void process_config_line(Options *options, const char *host, |
int |
|
process_config_line(Options *options, const char *host, |
char *line, const char *filename, int linenum, |
char *line, const char *filename, int linenum, |
int *activep) |
int *activep) |
{ |
{ |
|
|
/* Skip leading whitespace. */ |
/* Skip leading whitespace. */ |
cp = line + strspn(line, WHITESPACE); |
cp = line + strspn(line, WHITESPACE); |
if (!*cp || *cp == '\n' || *cp == '#') |
if (!*cp || *cp == '\n' || *cp == '#') |
return; |
return 0; |
|
|
/* Get the keyword. (Each line is supposed to begin with a keyword). */ |
/* Get the keyword. (Each line is supposed to begin with a keyword). */ |
cp = strtok(cp, WHITESPACE); |
cp = strtok(cp, WHITESPACE); |
|
|
|
|
switch (opcode) |
switch (opcode) |
{ |
{ |
|
case oBadOption: |
|
return -1; /* don't panic, but count bad options */ |
|
/*NOTREACHED*/ |
case oForwardAgent: |
case oForwardAgent: |
intptr = &options->forward_agent; |
intptr = &options->forward_agent; |
parse_flag: |
parse_flag: |
|
|
*charptr = string; |
*charptr = string; |
else |
else |
xfree(string); |
xfree(string); |
return; |
return 0; |
|
|
case oPort: |
case oPort: |
intptr = &options->port; |
intptr = &options->port; |
|
|
break; |
break; |
} |
} |
/* Avoid garbage check below, as strtok already returned NULL. */ |
/* Avoid garbage check below, as strtok already returned NULL. */ |
return; |
return 0; |
|
|
case oEscapeChar: |
case oEscapeChar: |
intptr = &options->escape_char; |
intptr = &options->escape_char; |
|
|
break; |
break; |
|
|
default: |
default: |
fatal("parse_config_file: Unimplemented opcode %d", opcode); |
fatal("process_config_line: Unimplemented opcode %d", opcode); |
} |
} |
|
|
/* Check that there is no garbage at end of line. */ |
/* Check that there is no garbage at end of line. */ |
if (strtok(NULL, WHITESPACE) != NULL) |
if (strtok(NULL, WHITESPACE) != NULL) |
fatal("%.200s line %d: garbage at end of line.", |
fatal("%.200s line %d: garbage at end of line.", |
filename, linenum); |
filename, linenum); |
|
return 0; |
} |
} |
|
|
|
|
|
|
FILE *f; |
FILE *f; |
char line[1024]; |
char line[1024]; |
int active, linenum; |
int active, linenum; |
|
int bad_options = 0; |
|
|
/* Open the file. */ |
/* Open the file. */ |
f = fopen(filename, "r"); |
f = fopen(filename, "r"); |
|
|
{ |
{ |
/* Update line number counter. */ |
/* Update line number counter. */ |
linenum++; |
linenum++; |
|
if (process_config_line(options, host, line, filename, linenum, &active) != 0) |
process_config_line(options, host, line, filename, linenum, &active); |
bad_options++; |
} |
} |
fclose(f); |
fclose(f); |
|
if (bad_options > 0) |
|
fatal("%s: terminating, %d bad configuration options\n", |
|
filename, bad_options); |
} |
} |
|
|
/* Initializes options to special values that indicate that they have not |
/* Initializes options to special values that indicate that they have not |