Make mapping a config option again to save space, turn off file locking, do we really need it ?

This commit is contained in:
Glenn L McGrath 2002-12-06 08:35:55 +00:00
parent 9227371b71
commit cdbe5e5d4c
2 changed files with 28 additions and 12 deletions

View File

@ -85,6 +85,14 @@ config CONFIG_FEATURE_IFUPDOWN_IPX
help help
Please submit a patch to add help text for this item. Please submit a patch to add help text for this item.
config CONFIG_FEATURE_IFUPDOWN_MAPPING
bool " Enable mapping support"
default n
depends on CONFIG_IFUPDOWN
help
This enables support for the "mapping" stanza, unless you have
a weird network setup you dont need it.
config CONFIG_IP config CONFIG_IP
bool "ip" bool "ip"
default n default n

View File

@ -680,7 +680,9 @@ static interfaces_file *read_interfaces(char *filename)
{ {
interface_defn *currif = NULL; interface_defn *currif = NULL;
interfaces_file *defn; interfaces_file *defn;
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
mapping_defn *currmap = NULL; mapping_defn *currmap = NULL;
#endif
FILE *f; FILE *f;
char firstword[80]; char firstword[80];
char *buf = NULL; char *buf = NULL;
@ -708,6 +710,7 @@ static interfaces_file *read_interfaces(char *filename)
} }
if (strcmp(firstword, "mapping") == 0) { if (strcmp(firstword, "mapping") == 0) {
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
currmap = xmalloc(sizeof(mapping_defn)); currmap = xmalloc(sizeof(mapping_defn));
currmap->max_matches = 0; currmap->max_matches = 0;
currmap->n_matches = 0; currmap->n_matches = 0;
@ -733,6 +736,7 @@ static interfaces_file *read_interfaces(char *filename)
*where = currmap; *where = currmap;
currmap->next = NULL; currmap->next = NULL;
} }
#endif
currently_processing = MAPPING; currently_processing = MAPPING;
} else if (strcmp(firstword, "iface") == 0) { } else if (strcmp(firstword, "iface") == 0) {
{ {
@ -871,6 +875,7 @@ static interfaces_file *read_interfaces(char *filename)
currif->n_options++; currif->n_options++;
break; break;
case MAPPING: case MAPPING:
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
if (strcmp(firstword, "script") == 0) { if (strcmp(firstword, "script") == 0) {
if (currmap->script != NULL) { if (currmap->script != NULL) {
error_msg("%s:%d: duplicate script in mapping", filename, line); error_msg("%s:%d: duplicate script in mapping", filename, line);
@ -889,6 +894,7 @@ static interfaces_file *read_interfaces(char *filename)
error_msg("%s:%d: misplaced option", filename, line); error_msg("%s:%d: misplaced option", filename, line);
return NULL; return NULL;
} }
#endif
break; break;
case NONE: case NONE:
default: default:
@ -1064,6 +1070,7 @@ static int iface_down(interface_defn *iface)
return (1); return (1);
} }
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
static int popen2(FILE **in, FILE **out, char *command, ...) static int popen2(FILE **in, FILE **out, char *command, ...)
{ {
va_list ap; va_list ap;
@ -1145,7 +1152,7 @@ static int run_mapping(char *physical, char *logical, int len, mapping_defn * ma
return 1; return 1;
} }
#endif /* CONFIG_FEATURE_IFUPDOWN_IPV6 */
static int lookfor_iface(char **ifaces, int n_ifaces, char *iface) static int lookfor_iface(char **ifaces, int n_ifaces, char *iface)
{ {
@ -1198,7 +1205,11 @@ extern int ifupdown_main(int argc, char **argv)
cmds = iface_down; cmds = iface_down;
} }
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
while ((i = getopt(argc, argv, "i:hvnamf")) != -1) { while ((i = getopt(argc, argv, "i:hvnamf")) != -1) {
#else
while ((i = getopt(argc, argv, "i:hvnaf")) != -1) {
#endif
switch (i) { switch (i) {
case 'i': /* interfaces */ case 'i': /* interfaces */
interfaces = xstrdup(optarg); interfaces = xstrdup(optarg);
@ -1212,9 +1223,11 @@ extern int ifupdown_main(int argc, char **argv)
case 'n': /* no-act */ case 'n': /* no-act */
no_act = 1; no_act = 1;
break; break;
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
case 'm': /* no-mappings */ case 'm': /* no-mappings */
run_mappings = 0; run_mappings = 0;
break; break;
#endif
case 'f': /* force */ case 'f': /* force */
force = 1; force = 1;
break; break;
@ -1247,7 +1260,7 @@ extern int ifupdown_main(int argc, char **argv)
if (state_fp != NULL) { if (state_fp != NULL) {
char buf[80]; char buf[80];
char *p; char *p;
#if 0
if (!no_act) { if (!no_act) {
int flags; int flags;
struct flock lock; struct flock lock;
@ -1267,7 +1280,7 @@ extern int ifupdown_main(int argc, char **argv)
perror_msg_and_die("failed to lock statefile %s", statefile); perror_msg_and_die("failed to lock statefile %s", statefile);
} }
} }
#endif
rewind(state_fp); rewind(state_fp);
while ((p = fgets(buf, sizeof buf, state_fp)) != NULL) { while ((p = fgets(buf, sizeof buf, state_fp)) != NULL) {
char *pch; char *pch;
@ -1338,6 +1351,7 @@ extern int ifupdown_main(int argc, char **argv)
liface[79] = 0; liface[79] = 0;
} }
} }
#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
if ((cmds == iface_up) && run_mappings) { if ((cmds == iface_up) && run_mappings) {
mapping_defn *currmap; mapping_defn *currmap;
@ -1354,6 +1368,7 @@ extern int ifupdown_main(int argc, char **argv)
} }
} }
} }
#endif
for (currif = defn->ifaces; currif; currif = currif->next) { for (currif = defn->ifaces; currif; currif = currif->next) {
if (strcmp(liface, currif->iface) == 0) { if (strcmp(liface, currif->iface) == 0) {
@ -1367,19 +1382,12 @@ extern int ifupdown_main(int argc, char **argv)
error_msg("Configuring interface %s=%s (%s)", iface, liface, currif->address_family->name); error_msg("Configuring interface %s=%s (%s)", iface, liface, currif->address_family->name);
} }
switch (cmds(currif)) { if (cmds(currif) == -1) {
case -1:
printf printf
("Don't seem to be have all the variables for %s/%s.\n", ("Don't seem to be have all the variables for %s/%s.\n",
liface, currif->address_family->name); liface, currif->address_family->name);
break;
case 0:
/* this wasn't entirely successful, should it be added to
* the state file?
*/
case 1:
/* successful */
} }
currif->iface = oldiface; currif->iface = oldiface;
} }
} }