Skip to content

Commit

Permalink
- djm@cvs.openbsd.org 2004/06/24 19:30:54
Browse files Browse the repository at this point in the history
     [servconf.c servconf.h sshd.c]
     re-exec sshd on accept(); initial work, final debugging and ok markus@
  • Loading branch information
daztucker committed Jun 25, 2004
1 parent b5bc1a6 commit 645ab75
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 32 deletions.
8 changes: 7 additions & 1 deletion ChangeLog
@@ -1,3 +1,9 @@
20040625
- (dtucker) OpenBSD CVS Sync
- djm@cvs.openbsd.org 2004/06/24 19:30:54
[servconf.c servconf.h sshd.c]
re-exec sshd on accept(); initial work, final debugging and ok markus@

20040623
- (dtucker) [auth1.c] Ensure do_pam_account is called for Protocol 1
connections with empty passwords. Patch from davidwu at nbttech.com,
Expand Down Expand Up @@ -1399,4 +1405,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu

$Id: ChangeLog,v 1.3443 2004/06/23 14:34:53 dtucker Exp $
$Id: ChangeLog,v 1.3444 2004/06/25 03:33:20 dtucker Exp $
48 changes: 36 additions & 12 deletions servconf.c
Expand Up @@ -10,7 +10,7 @@
*/

#include "includes.h"
RCSID("$OpenBSD: servconf.c,v 1.133 2004/05/23 23:59:53 dtucker Exp $");
RCSID("$OpenBSD: servconf.c,v 1.134 2004/06/24 19:30:54 djm Exp $");

#include "ssh.h"
#include "log.h"
Expand Down Expand Up @@ -942,26 +942,50 @@ process_server_config_line(ServerOptions *options, char *line,
/* Reads the server configuration file. */

void
read_server_config(ServerOptions *options, const char *filename)
load_server_config(const char *filename, Buffer *conf)
{
int linenum, bad_options = 0;
char line[1024];
char line[1024], *cp;
FILE *f;

debug2("read_server_config: filename %s", filename);
f = fopen(filename, "r");
if (!f) {
debug2("%s: filename %s", __func__, filename);
if ((f = fopen(filename, "r")) == NULL) {
perror(filename);
exit(1);
}
linenum = 0;
buffer_clear(conf);
while (fgets(line, sizeof(line), f)) {
/* Update line number counter. */
linenum++;
if (process_server_config_line(options, line, filename, linenum) != 0)
bad_options++;
/*
* Trim out comments and strip whitespace
* NB - preserve newlines, they are needed to reproduce
* line numbers later for error messages
*/
if ((cp = strchr(line, '#')) != NULL)
memcpy(cp, "\n", 2);
cp = line + strspn(line, " \t\r");

buffer_append(conf, cp, strlen(cp));
}
buffer_append(conf, "\0", 1);
fclose(f);
debug2("%s: done config len = %d", __func__, buffer_len(conf));
}

void
parse_server_config(ServerOptions *options, const char *filename, Buffer *conf)
{
int linenum, bad_options = 0;
char *cp, *cbuf;

debug2("%s: config %s len %d", __func__, filename, buffer_len(conf));

cbuf = xstrdup(buffer_ptr(conf));
linenum = 0;
while((cp = strsep(&cbuf, "\n")) != NULL) {
if (process_server_config_line(options, cp, filename,
linenum++) != 0)
bad_options++;
}
free(cbuf);
if (bad_options > 0)
fatal("%s: terminating, %d bad configuration options",
filename, bad_options);
Expand Down
8 changes: 5 additions & 3 deletions servconf.h
@@ -1,4 +1,4 @@
/* $OpenBSD: servconf.h,v 1.69 2004/05/23 23:59:53 dtucker Exp $ */
/* $OpenBSD: servconf.h,v 1.70 2004/06/24 19:30:54 djm Exp $ */

/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
Expand All @@ -16,6 +16,8 @@
#ifndef SERVCONF_H
#define SERVCONF_H

#include "buffer.h"

#define MAX_PORTS 256 /* Max # ports. */

#define MAX_ALLOW_USERS 256 /* Max # users on allow list. */
Expand Down Expand Up @@ -134,9 +136,9 @@ typedef struct {
} ServerOptions;

void initialize_server_options(ServerOptions *);
void read_server_config(ServerOptions *, const char *);
void fill_default_server_options(ServerOptions *);
int process_server_config_line(ServerOptions *, char *, const char *, int);

void load_server_config(const char *, Buffer *);
void parse_server_config(ServerOptions *, const char *, Buffer *);

#endif /* SERVCONF_H */

0 comments on commit 645ab75

Please sign in to comment.