aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--initscripts.spec8
-rwxr-xr-xrc.d/rc.sysinit15
-rw-r--r--src/ipcalc.13
-rw-r--r--src/shvar.c65
-rw-r--r--src/shvar.h1
-rwxr-xr-xsysconfig/network-scripts/ifdown-post5
-rw-r--r--sysconfig/network-scripts/network-functions31
8 files changed, 102 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index 53ccd58d..0f5f7f6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2000-01-31 Nalin Dahyabhai <nalin@redhat.com>
+ * sysconfig/network-scripts/ifdown-post:
+ attempt to reset the default route in case we dropped it for PPP
+
+ * src/ipcalc.1:
+ document the "--silent" option
+
+ * src/shvar.c:
+ strtok() and other cleanups
+
+ * rc.d/rc.sysinit:
+ make symlinks for System.map and module-info automatically
+
2000-01-31 Bill Nottingham <notting@redhat.com>
* rc.d/init.d/network:
diff --git a/initscripts.spec b/initscripts.spec
index e517219f..cbde688f 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -1,6 +1,6 @@
Summary: The inittab file and the /etc/rc.d scripts.
Name: initscripts
-%define version 4.85
+%define version 4.86
Version: %{version}
Copyright: GPL
Group: System Environment/Base
@@ -227,6 +227,12 @@ rm -rf $RPM_BUILD_ROOT
%ghost %attr(0664,root,utmp) /var/run/utmp
%changelog
+* Mon Jan 31 2000 Nalin Dahyabhai <nalin@redhat.com>
+- attempt to restore default route if PPP takes it over
+- man page fix for ipcalc
+- shvar cleaning
+- automate maintaining /boot/System.map symlinks
+
* Mon Jan 31 2000 Bill Nottingham <notting@redhat.com>
- fix hanging ppp-watch
- fix issues with cleaning of /var/{run,lock}
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
index 844af28d..b08a40c3 100755
--- a/rc.d/rc.sysinit
+++ b/rc.d/rc.sysinit
@@ -518,6 +518,21 @@ if [ "$SMP" != "$OLDSMP" -o "$UP" != "$OLDUP" ]; then
EOF
fi
+# Adjust symlinks as necessary in /boot to keep system services from
+# spewing messages about mismatched System maps and so on.
+if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
+ ln -s -f System.map-`uname -r` /boot/System.map
+fi
+if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
+ ln -s -f System.map-`uname -r` /boot/System.map
+fi
+if [ -L /boot/module-info -a -r /boot/module-info-`uname -r` ] ; then
+ ln -s -f module-info-`uname -r` /boot/module-info
+fi
+if [ ! -e /boot/module-info -a -r /boot/module-info-`uname -r` ] ; then
+ ln -s -f module-info-`uname -r` /boot/module-info
+fi
+
# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
dmesg > /var/log/dmesg
diff --git a/src/ipcalc.1 b/src/ipcalc.1
index 2a72aa3d..c637eb4a 100644
--- a/src/ipcalc.1
+++ b/src/ipcalc.1
@@ -27,6 +27,9 @@ be returned.
.IP \fI--network\fR
Display the network address for the given IP address and netmask.
+.IP \fI--silent\fR
+Don't ever display error messages.
+
.SH AUTHOR
.nf
Erik Troan <ewt@redhat.com>
diff --git a/src/shvar.c b/src/shvar.c
index 5c5233e1..9b1d8f92 100644
--- a/src/shvar.c
+++ b/src/shvar.c
@@ -1,4 +1,3 @@
-/* copied from rp3 -- DO NOT EDIT HERE, ONLY COPY FROM rp3 */
/*
* shvar.c
*
@@ -29,7 +28,6 @@
*
*/
-#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,8 +45,7 @@ svNewFile(char *name)
shvarFile *s = NULL;
int closefd = 0;
- s = calloc(sizeof(shvarFile), 1);
- if (!s) return NULL;
+ s = g_malloc0(sizeof(shvarFile));
s->fd = open(name, O_RDWR); /* NOT O_CREAT */
if (s->fd == -1) {
@@ -56,24 +53,21 @@ svNewFile(char *name)
s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
if (s->fd) closefd = 1;
}
- s->fileName = strdup(name);
+ s->fileName = g_strdup(name);
if (s->fd != -1) {
struct stat buf;
- char *tmp;
+ char *p, *q;
if (fstat(s->fd, &buf) < 0) goto bail;
- s->arena = calloc(buf.st_size, 1);
- if (!s->arena) goto bail;
+ s->arena = g_malloc0(buf.st_size + 1);
+
if (read(s->fd, s->arena, buf.st_size) < 0) goto bail;
- /* Yes, I know that strtok is evil, except that this is
- * precisely what it was intended for in the first place...
- */
- tmp = strtok(s->arena, "\n");
- while (tmp) {
- s->lineList = g_list_append(s->lineList, tmp);
- tmp = strtok(NULL, "\n");
+
+ for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) {
+ s->lineList = g_list_append(s->lineList, g_strndup(p, q - p));
}
+
if (closefd) {
close(s->fd);
s->fd = -1;
@@ -84,9 +78,9 @@ svNewFile(char *name)
bail:
if (s->fd != -1) close(s->fd);
- if (s->arena) free (s->arena);
- if (s->fileName) free (s->fileName);
- free (s);
+ if (s->arena) g_free (s->arena);
+ if (s->fileName) g_free (s->fileName);
+ g_free (s);
return NULL;
}
@@ -136,7 +130,7 @@ escape(char *s) {
slen = strlen(s);
newlen = slen + mangle + 3; /* 3 is extra ""\0 */
- new = calloc(newlen, 1);
+ new = g_malloc(newlen);
if (!new) return NULL;
new[0] = '"';
@@ -163,11 +157,10 @@ svGetValue(shvarFile *s, char *key)
char *keyString;
int len;
- assert(s);
- assert(key);
+ g_assert(s);
+ g_assert(key);
- keyString = calloc (strlen(key) + 2, 1);
- if (!keyString) return NULL;
+ keyString = g_malloc0(strlen(key) + 2);
strcpy(keyString, key);
keyString[strlen(key)] = '=';
len = strlen(keyString);
@@ -175,18 +168,18 @@ svGetValue(shvarFile *s, char *key)
for (s->current = s->lineList; s->current; s->current = s->current->next) {
line = s->current->data;
if (!strncmp(keyString, line, len)) {
- value = strdup(line + len);
+ value = g_strdup(line + len);
unescape(value);
break;
}
}
- free(keyString);
+ g_free(keyString);
if (value) {
if (value[0]) {
return value;
} else {
- free (value);
+ g_free(value);
return NULL;
}
}
@@ -217,7 +210,7 @@ svTrueValue(shvarFile *s, char *key, int def)
(!strcasecmp("f", tmp)) ||
(!strcasecmp("n", tmp)) ) returnValue = 0;
- free (tmp);
+ g_free (tmp);
return returnValue;
}
@@ -251,14 +244,12 @@ svSetValue(shvarFile *s, char *key, char *value)
char *val1 = NULL, *val2 = NULL;
char *keyValue;
- assert(s);
- assert(key);
+ g_assert(s);
+ g_assert(key);
/* value may be NULL */
if (value) value = escape(value);
- keyValue = malloc (strlen(key) + (value?strlen(value):0) + 2);
- if (!keyValue) return;
- sprintf(keyValue, "%s=%s", key, value?value:"");
+ keyValue = g_strdup_printf("%s=%s", key, value ? value : "");
val1 = svGetValue(s, key);
if (val1 && value && !strcmp(val1, value)) goto bail;
@@ -361,17 +352,17 @@ int
svCloseFile(shvarFile *s)
{
- assert(s);
+ g_assert(s);
if (s->fd != -1) close(s->fd);
- free(s->arena);
+ g_free(s->arena);
for (s->current = s->freeList; s->current; s->current = s->current->next) {
- free(s->current->data);
+ g_free(s->current->data);
}
- free(s->fileName);
+ g_free(s->fileName);
g_list_free(s->freeList);
g_list_free(s->lineList); /* implicitly frees s->current */
- free(s);
+ g_free(s);
return 0;
}
diff --git a/src/shvar.h b/src/shvar.h
index ee60e12b..482922f2 100644
--- a/src/shvar.h
+++ b/src/shvar.h
@@ -1,4 +1,3 @@
-/* copied from rp3 -- DO NOT EDIT HERE, ONLY COPY FROM rp3 */
/*
* shvar.h
*
diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post
index 460b072c..49dfa5b4 100755
--- a/sysconfig/network-scripts/ifdown-post
+++ b/sysconfig/network-scripts/ifdown-post
@@ -8,6 +8,11 @@ cd /etc/sysconfig/network-scripts
CONFIG=$1
source_config
+# Reset the default route if this interface had a special one
+if ! check_default_route ; then
+ add_default_route
+fi
+
# Notify programs that have requested notification
do_netreport
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index feea9922..93ef3b40 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -59,3 +59,34 @@ check_device_down ()
return $retcode
}
+check_default_route ()
+{
+ return `/sbin/route -n|gawk 'BEGIN{r=1} $3=="0.0.0.1" && $4=="UG" {r=0} END{print r}'`
+}
+
+find_gateway_dev ()
+{
+ . /etc/sysconfig/network
+ if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ] ; then
+ export GATEWAY
+ networks=`/sbin/route -n|awk '{print $1, ENVIRON["GATEWAY"],$3,$8}'|awk '{system("ipcalc --silent --network "$2" "$3" 2>/dev/null")}'|sed s^NETWORK=^^g`
+ for net in $networks; do
+ dev=`/sbin/route -n|grep ^$net|awk '{print $NF}'`
+ if [ "$dev" != "" ] ; then
+ GATEWAYDEV=$dev
+ fi
+ done
+ fi
+}
+
+add_default_route ()
+{
+ . /etc/sysconfig/network
+ find_gateway_dev
+ if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" -a "${GATEWAYDEV}" != "" ] ; then
+ DEVICE=$GATEWAYDEV
+ if ! check_device_down ; then
+ /sbin/route add default gw ${GATEWAY} ${GATEWAYDEV}
+ fi
+ fi
+}