Adapt to rc.conf file format.

This commit is contained in:
Jordan K. Hubbard 1997-04-28 10:31:14 +00:00
parent 2056a6faec
commit 3de5b08eda
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25251
14 changed files with 100 additions and 70 deletions

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: config.c,v 1.87 1997/04/20 16:46:25 jkh Exp $
* $Id: config.c,v 1.88 1997/04/28 06:15:48 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -300,9 +300,9 @@ readConfig(char *config, char **lines, int max)
#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
/* Load the environment from a sysconfig file */
/* Load the environment from an rc.conf file */
void
configEnvironmentSysconfig(char *config)
configEnvironmentRC_conf(char *config)
{
char *lines[MAX_LINES], *cp, *cp2;
int i, j, nlines;
@ -320,10 +320,10 @@ configEnvironmentSysconfig(char *config)
*cp++ = '\0';
(void)string_prune(lines[i]);
cp = string_skipwhite(string_prune(cp));
if ((cp2 = index(cp, '"'))) /* Eliminate leading quote if it's quoted */
if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) /* Eliminate leading quote if it's quoted */
cp = cp2 + 1;
j = strlen(cp) - 1;
if (cp[j] == '"') /* And trailing one */
if (cp2 && cp[j] == *cp2) /* And trailing one */
cp[j] = '\0';
if (strlen(cp))
variable_set2(lines[i], cp);
@ -356,11 +356,11 @@ configEnvironmentResolv(char *config)
}
/*
* This sucks in /etc/sysconfig, substitutes anything needing substitution, then
* This sucks in /etc/rc.conf, substitutes anything needing substitution, then
* writes it all back out. It's pretty gross and needs re-writing at some point.
*/
void
configSysconfig(char *config)
configRC_conf(char *config)
{
FILE *fp;
char *lines[MAX_LINES], *cp;
@ -383,9 +383,19 @@ configSysconfig(char *config)
continue;
sstrncpy(line, lines[i], cp - lines[i]);
if (!strcmp(line, v->name)) {
char *cp3, *comment = NULL;
/* If trailing comment, try and preserve it */
if ((cp3 = index(lines[i], '#')) != NULL) {
comment = alloca(strlen(cp3) + 1);
strcpy(comment, cp3);
}
free(lines[i]);
lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + 5);
sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value);
lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? 0 : strlen(comment)) + 10);
if (comment)
sprintf(lines[i], "%s=\"%s\"\t\t%s\n", v->name, v->value, comment);
else
sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value);
}
}
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.180 1997/04/02 12:07:32 jkh Exp $
* $Id: install.c,v 1.181 1997/04/03 13:44:58 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -565,7 +565,7 @@ installNovice(dialogMenuItem *self)
}
/* Now would be a good time to checkpoint the configuration data */
configSysconfig("/etc/sysconfig");
configRC_conf("/etc/rc.conf");
sync();
if (directory_exists("/usr/X11R6")) {
@ -994,8 +994,8 @@ installVarDefaults(dialogMenuItem *self)
void
installEnvironment(void)
{
if (file_readable("/etc/sysconfig"))
configEnvironmentSysconfig("/etc/sysconfig");
if (file_readable("/etc/rc.conf"))
configEnvironmentRC_conf("/etc/rc.conf");
if (file_readable("/etc/resolv.conf"))
configEnvironmentResolv("/etc/resolv.conf");
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: installUpgrade.c,v 1.46 1997/03/11 09:29:17 jkh Exp $
* $Id: installUpgrade.c,v 1.47 1997/04/02 12:07:37 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -99,6 +99,7 @@ static HitList etc_files [] = {
{ JUST_COPY, "protocols", TRUE, NULL },
{ JUST_COPY, "pwd.db", TRUE, NULL },
{ JUST_COPY, "rc.local", TRUE, NULL },
{ JUST_COPY, "rc.conf", FALSE, NULL },
{ JUST_COPY, "remote", TRUE, NULL },
{ JUST_COPY, "resolv.conf", TRUE, NULL },
{ JUST_COPY, "rmt", TRUE, NULL },
@ -109,7 +110,6 @@ static HitList etc_files [] = {
{ JUST_COPY, "skeykeys", TRUE, NULL },
{ JUST_COPY, "spwd.db", TRUE, NULL },
{ JUST_COPY, "supfile", TRUE, NULL },
{ JUST_COPY, "sysconfig", FALSE, NULL },
{ JUST_COPY, "syslog.conf", TRUE, NULL },
{ JUST_COPY, "termcap", TRUE, NULL },
{ JUST_COPY, "ttys", TRUE, NULL },

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.123 1997/04/02 12:07:39 jkh Exp $
* $Id: sysinstall.h,v 1.124 1997/04/20 16:46:36 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -180,7 +180,7 @@ typedef struct _dmenu {
dialogMenuItem items[0]; /* Array of menu items */
} DMenu;
/* A sysconfig variable */
/* An rc.conf variable */
typedef struct _variable {
struct _variable *next;
char *name;
@ -406,9 +406,9 @@ extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
extern int configFstab(void);
extern void configEnvironmentSysconfig(char *config);
extern void configEnvironmentRC_conf(char *config);
extern void configEnvironmentResolv(char *config);
extern void configSysconfig(char *config);
extern void configRC_conf(char *config);
extern int configRegister(dialogMenuItem *self);
extern void configResolv(void);
extern int configPackages(dialogMenuItem *self);
@ -421,7 +421,7 @@ extern int configRouter(dialogMenuItem *self);
extern int configSamba(dialogMenuItem *self);
extern int configPCNFSD(dialogMenuItem *self);
extern int configNFSServer(dialogMenuItem *self);
extern int configWriteSysconfig(dialogMenuItem *self);
extern int configWriteRC_conf(dialogMenuItem *self);
#ifdef NETCON_EXTENTIONS
extern int configNovell(dialogMenuItem *self);
#endif

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: system.c,v 1.78 1997/04/28 06:15:49 jkh Exp $
* $Id: system.c,v 1.79 1997/04/28 09:35:59 jkh Exp $
*
* Jordan Hubbard
*
@ -118,9 +118,9 @@ systemShutdown(int status)
if (status >=0 && mediaDevice)
mediaDevice->shutdown(mediaDevice);
/* write out any changes to sysconfig .. */
if (!status)
configSysconfig("/etc/sysconfig");
/* write out any changes to rc.conf .. */
if (status)
configRC_conf("/etc/rc.conf");
/* Shut down the dialog library */
if (DialogActive) {

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: config.c,v 1.87 1997/04/20 16:46:25 jkh Exp $
* $Id: config.c,v 1.88 1997/04/28 06:15:48 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -300,9 +300,9 @@ readConfig(char *config, char **lines, int max)
#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
/* Load the environment from a sysconfig file */
/* Load the environment from an rc.conf file */
void
configEnvironmentSysconfig(char *config)
configEnvironmentRC_conf(char *config)
{
char *lines[MAX_LINES], *cp, *cp2;
int i, j, nlines;
@ -320,10 +320,10 @@ configEnvironmentSysconfig(char *config)
*cp++ = '\0';
(void)string_prune(lines[i]);
cp = string_skipwhite(string_prune(cp));
if ((cp2 = index(cp, '"'))) /* Eliminate leading quote if it's quoted */
if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) /* Eliminate leading quote if it's quoted */
cp = cp2 + 1;
j = strlen(cp) - 1;
if (cp[j] == '"') /* And trailing one */
if (cp2 && cp[j] == *cp2) /* And trailing one */
cp[j] = '\0';
if (strlen(cp))
variable_set2(lines[i], cp);
@ -356,11 +356,11 @@ configEnvironmentResolv(char *config)
}
/*
* This sucks in /etc/sysconfig, substitutes anything needing substitution, then
* This sucks in /etc/rc.conf, substitutes anything needing substitution, then
* writes it all back out. It's pretty gross and needs re-writing at some point.
*/
void
configSysconfig(char *config)
configRC_conf(char *config)
{
FILE *fp;
char *lines[MAX_LINES], *cp;
@ -383,9 +383,19 @@ configSysconfig(char *config)
continue;
sstrncpy(line, lines[i], cp - lines[i]);
if (!strcmp(line, v->name)) {
char *cp3, *comment = NULL;
/* If trailing comment, try and preserve it */
if ((cp3 = index(lines[i], '#')) != NULL) {
comment = alloca(strlen(cp3) + 1);
strcpy(comment, cp3);
}
free(lines[i]);
lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + 5);
sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value);
lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? 0 : strlen(comment)) + 10);
if (comment)
sprintf(lines[i], "%s=\"%s\"\t\t%s\n", v->name, v->value, comment);
else
sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value);
}
}
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.180 1997/04/02 12:07:32 jkh Exp $
* $Id: install.c,v 1.181 1997/04/03 13:44:58 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -565,7 +565,7 @@ installNovice(dialogMenuItem *self)
}
/* Now would be a good time to checkpoint the configuration data */
configSysconfig("/etc/sysconfig");
configRC_conf("/etc/rc.conf");
sync();
if (directory_exists("/usr/X11R6")) {
@ -994,8 +994,8 @@ installVarDefaults(dialogMenuItem *self)
void
installEnvironment(void)
{
if (file_readable("/etc/sysconfig"))
configEnvironmentSysconfig("/etc/sysconfig");
if (file_readable("/etc/rc.conf"))
configEnvironmentRC_conf("/etc/rc.conf");
if (file_readable("/etc/resolv.conf"))
configEnvironmentResolv("/etc/resolv.conf");
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.123 1997/04/02 12:07:39 jkh Exp $
* $Id: sysinstall.h,v 1.124 1997/04/20 16:46:36 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -180,7 +180,7 @@ typedef struct _dmenu {
dialogMenuItem items[0]; /* Array of menu items */
} DMenu;
/* A sysconfig variable */
/* An rc.conf variable */
typedef struct _variable {
struct _variable *next;
char *name;
@ -406,9 +406,9 @@ extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
extern int configFstab(void);
extern void configEnvironmentSysconfig(char *config);
extern void configEnvironmentRC_conf(char *config);
extern void configEnvironmentResolv(char *config);
extern void configSysconfig(char *config);
extern void configRC_conf(char *config);
extern int configRegister(dialogMenuItem *self);
extern void configResolv(void);
extern int configPackages(dialogMenuItem *self);
@ -421,7 +421,7 @@ extern int configRouter(dialogMenuItem *self);
extern int configSamba(dialogMenuItem *self);
extern int configPCNFSD(dialogMenuItem *self);
extern int configNFSServer(dialogMenuItem *self);
extern int configWriteSysconfig(dialogMenuItem *self);
extern int configWriteRC_conf(dialogMenuItem *self);
#ifdef NETCON_EXTENTIONS
extern int configNovell(dialogMenuItem *self);
#endif

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: system.c,v 1.78 1997/04/28 06:15:49 jkh Exp $
* $Id: system.c,v 1.79 1997/04/28 09:35:59 jkh Exp $
*
* Jordan Hubbard
*
@ -118,9 +118,9 @@ systemShutdown(int status)
if (status >=0 && mediaDevice)
mediaDevice->shutdown(mediaDevice);
/* write out any changes to sysconfig .. */
if (!status)
configSysconfig("/etc/sysconfig");
/* write out any changes to rc.conf .. */
if (status)
configRC_conf("/etc/rc.conf");
/* Shut down the dialog library */
if (DialogActive) {

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: config.c,v 1.87 1997/04/20 16:46:25 jkh Exp $
* $Id: config.c,v 1.88 1997/04/28 06:15:48 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -300,9 +300,9 @@ readConfig(char *config, char **lines, int max)
#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
/* Load the environment from a sysconfig file */
/* Load the environment from an rc.conf file */
void
configEnvironmentSysconfig(char *config)
configEnvironmentRC_conf(char *config)
{
char *lines[MAX_LINES], *cp, *cp2;
int i, j, nlines;
@ -320,10 +320,10 @@ configEnvironmentSysconfig(char *config)
*cp++ = '\0';
(void)string_prune(lines[i]);
cp = string_skipwhite(string_prune(cp));
if ((cp2 = index(cp, '"'))) /* Eliminate leading quote if it's quoted */
if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) /* Eliminate leading quote if it's quoted */
cp = cp2 + 1;
j = strlen(cp) - 1;
if (cp[j] == '"') /* And trailing one */
if (cp2 && cp[j] == *cp2) /* And trailing one */
cp[j] = '\0';
if (strlen(cp))
variable_set2(lines[i], cp);
@ -356,11 +356,11 @@ configEnvironmentResolv(char *config)
}
/*
* This sucks in /etc/sysconfig, substitutes anything needing substitution, then
* This sucks in /etc/rc.conf, substitutes anything needing substitution, then
* writes it all back out. It's pretty gross and needs re-writing at some point.
*/
void
configSysconfig(char *config)
configRC_conf(char *config)
{
FILE *fp;
char *lines[MAX_LINES], *cp;
@ -383,9 +383,19 @@ configSysconfig(char *config)
continue;
sstrncpy(line, lines[i], cp - lines[i]);
if (!strcmp(line, v->name)) {
char *cp3, *comment = NULL;
/* If trailing comment, try and preserve it */
if ((cp3 = index(lines[i], '#')) != NULL) {
comment = alloca(strlen(cp3) + 1);
strcpy(comment, cp3);
}
free(lines[i]);
lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + 5);
sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value);
lines[i] = (char *)malloc(strlen(v->name) + strlen(v->value) + (comment ? 0 : strlen(comment)) + 10);
if (comment)
sprintf(lines[i], "%s=\"%s\"\t\t%s\n", v->name, v->value, comment);
else
sprintf(lines[i], "%s=\"%s\"\n", v->name, v->value);
}
}
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.180 1997/04/02 12:07:32 jkh Exp $
* $Id: install.c,v 1.181 1997/04/03 13:44:58 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -565,7 +565,7 @@ installNovice(dialogMenuItem *self)
}
/* Now would be a good time to checkpoint the configuration data */
configSysconfig("/etc/sysconfig");
configRC_conf("/etc/rc.conf");
sync();
if (directory_exists("/usr/X11R6")) {
@ -994,8 +994,8 @@ installVarDefaults(dialogMenuItem *self)
void
installEnvironment(void)
{
if (file_readable("/etc/sysconfig"))
configEnvironmentSysconfig("/etc/sysconfig");
if (file_readable("/etc/rc.conf"))
configEnvironmentRC_conf("/etc/rc.conf");
if (file_readable("/etc/resolv.conf"))
configEnvironmentResolv("/etc/resolv.conf");
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: installUpgrade.c,v 1.46 1997/03/11 09:29:17 jkh Exp $
* $Id: installUpgrade.c,v 1.47 1997/04/02 12:07:37 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -99,6 +99,7 @@ static HitList etc_files [] = {
{ JUST_COPY, "protocols", TRUE, NULL },
{ JUST_COPY, "pwd.db", TRUE, NULL },
{ JUST_COPY, "rc.local", TRUE, NULL },
{ JUST_COPY, "rc.conf", FALSE, NULL },
{ JUST_COPY, "remote", TRUE, NULL },
{ JUST_COPY, "resolv.conf", TRUE, NULL },
{ JUST_COPY, "rmt", TRUE, NULL },
@ -109,7 +110,6 @@ static HitList etc_files [] = {
{ JUST_COPY, "skeykeys", TRUE, NULL },
{ JUST_COPY, "spwd.db", TRUE, NULL },
{ JUST_COPY, "supfile", TRUE, NULL },
{ JUST_COPY, "sysconfig", FALSE, NULL },
{ JUST_COPY, "syslog.conf", TRUE, NULL },
{ JUST_COPY, "termcap", TRUE, NULL },
{ JUST_COPY, "ttys", TRUE, NULL },

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.123 1997/04/02 12:07:39 jkh Exp $
* $Id: sysinstall.h,v 1.124 1997/04/20 16:46:36 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -180,7 +180,7 @@ typedef struct _dmenu {
dialogMenuItem items[0]; /* Array of menu items */
} DMenu;
/* A sysconfig variable */
/* An rc.conf variable */
typedef struct _variable {
struct _variable *next;
char *name;
@ -406,9 +406,9 @@ extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
extern int configFstab(void);
extern void configEnvironmentSysconfig(char *config);
extern void configEnvironmentRC_conf(char *config);
extern void configEnvironmentResolv(char *config);
extern void configSysconfig(char *config);
extern void configRC_conf(char *config);
extern int configRegister(dialogMenuItem *self);
extern void configResolv(void);
extern int configPackages(dialogMenuItem *self);
@ -421,7 +421,7 @@ extern int configRouter(dialogMenuItem *self);
extern int configSamba(dialogMenuItem *self);
extern int configPCNFSD(dialogMenuItem *self);
extern int configNFSServer(dialogMenuItem *self);
extern int configWriteSysconfig(dialogMenuItem *self);
extern int configWriteRC_conf(dialogMenuItem *self);
#ifdef NETCON_EXTENTIONS
extern int configNovell(dialogMenuItem *self);
#endif

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: system.c,v 1.78 1997/04/28 06:15:49 jkh Exp $
* $Id: system.c,v 1.79 1997/04/28 09:35:59 jkh Exp $
*
* Jordan Hubbard
*
@ -118,9 +118,9 @@ systemShutdown(int status)
if (status >=0 && mediaDevice)
mediaDevice->shutdown(mediaDevice);
/* write out any changes to sysconfig .. */
if (!status)
configSysconfig("/etc/sysconfig");
/* write out any changes to rc.conf .. */
if (status)
configRC_conf("/etc/rc.conf");
/* Shut down the dialog library */
if (DialogActive) {