aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2012-10-08 12:47:23 +0200
committerLukas Nykryn <lnykryn@redhat.com>2012-10-08 12:48:22 +0200
commite182e58e886c6e5cb105055b76646113f2c3bc2d (patch)
treecaeed2d3c67dd118bc78f4d8e34f7364e1dda552
parent30483d5b4a4763e03dcc2462a4621b76568ab1b3 (diff)
downloadinitscripts-e182e58e886c6e5cb105055b76646113f2c3bc2d.tar
initscripts-e182e58e886c6e5cb105055b76646113f2c3bc2d.tar.gz
initscripts-e182e58e886c6e5cb105055b76646113f2c3bc2d.tar.bz2
initscripts-e182e58e886c6e5cb105055b76646113f2c3bc2d.tar.xz
initscripts-e182e58e886c6e5cb105055b76646113f2c3bc2d.zip
Revert patches which should not be in 6.4
Revert "Process rule6-* for sit devices (#840009)" This reverts commit f082f9e64eadbf68ef9bb67744c97c0974af9115. Revert "securetty: check if the device is in the file before attempting to write to it" This reverts commit 10c72ce532c1d4f6d0b17fdc9448c9bd2d0b5ef5. Revert "Killproc -d should parse same values as sleep" This reverts commit 763b7dcf6bf9e47d90546be1aabf1f724dd527f8. Revert "Make killproc more granular when delay is passed. (#428029, <xjakub@fi.muni.cz>)" This reverts commit 6e62c51f3162081cc05ef546929aa98b8448b1cb. Revert "Allow dhclient configuration files for DHCPv6 as well. (#815676)" This reverts commit 9987361e94ec6f26e557053b27af6e43a9ee13e1.
-rw-r--r--rc.d/init.d/functions26
-rw-r--r--src/securetty.c58
-rwxr-xr-xsysconfig/network-scripts/ifdown-sit3
-rwxr-xr-xsysconfig/network-scripts/ifup-eth13
-rwxr-xr-xsysconfig/network-scripts/ifup-sit8
-rw-r--r--sysconfig/network-scripts/network-functions11
6 files changed, 45 insertions, 74 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index ce6df4c7..f1fff775 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -269,9 +269,9 @@ daemon() {
# A function to stop a program.
killproc() {
- local RC killlevel= base pid pid_file= delay try
+ local RC killlevel= base pid pid_file= delay
- RC=0; delay=3; try=0
+ RC=0; delay=3
# Test syntax.
if [ "$#" -eq 0 ]; then
echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
@@ -282,11 +282,7 @@ killproc() {
shift 2
fi
if [ "$1" = "-d" ]; then
- delay=$(echo $2 | awk -v RS=' ' -v IGNORECASE=1 '{if($1!~/^[0-9.]+[smhd]?$/) exit 1;d=$1~/s$|^[0-9.]*$/?1:$1~/m$/?60:$1~/h$/?60*60:$1~/d$/?24*60*60:-1;if(d==-1) exit 1;delay+=d*$1} END {printf("%d",delay+0.5)}')
- if [ "$?" -eq 1 ]; then
- echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
- return 1
- fi
+ delay=$2
shift 2
fi
@@ -316,17 +312,11 @@ killproc() {
# TERM first, then KILL if not dead
kill -TERM $pid >/dev/null 2>&1
usleep 100000
- if checkpid $pid ; then
- try=0
- while [ $try -lt $delay ] ; do
- checkpid $pid || break
- sleep 1
- let try+=1
- done
- if checkpid $pid ; then
- kill -KILL $pid >/dev/null 2>&1
- usleep 100000
- fi
+ if checkpid $pid && sleep 1 &&
+ checkpid $pid && sleep $delay &&
+ checkpid $pid ; then
+ kill -KILL $pid >/dev/null 2>&1
+ usleep 100000
fi
fi
checkpid $pid
diff --git a/src/securetty.c b/src/securetty.c
index a4768e35..9ec8e7ef 100644
--- a/src/securetty.c
+++ b/src/securetty.c
@@ -18,7 +18,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -26,7 +25,6 @@
#include <syslog.h>
#include <unistd.h>
-#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -68,50 +66,39 @@ int open_and_lock_securetty() {
int rewrite_securetty(char *terminal) {
int fd;
+ char *buf, *pos;
+ struct stat sbuf;
fd = open_and_lock_securetty();
if (fd == -1)
return 1;
- if (lseek(fd, 0, SEEK_END) == -1) {
+ if (fstat(fd, &sbuf) == -1) {
close(fd);
- syslog(LOG_ERR, "Couldn't seek to end of /etc/securetty: %s",strerror(errno));
+ syslog(LOG_ERR, "Couldn't stat /etc/securetty: %s",strerror(errno));
return 1;
}
- write(fd, terminal, strlen(terminal));
- write(fd, "\n", 1);
- close(fd);
- return 0;
-}
-
-int check_securetty(char *terminal) {
- int fd, rc = 1;
- char *buf, term[PATH_MAX];
- struct stat sb;
-
- fd = open("/etc/securetty", O_RDONLY);
- if (fd == -1)
- goto out;
- fstat(fd, &sb);
- buf = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (buf == ((caddr_t) -1)) {
+ buf = malloc(sbuf.st_size + 1);
+ if (read(fd, buf, sbuf.st_size) != sbuf.st_size) {
close(fd);
+ syslog(LOG_ERR, "Couldn't read /etc/securetty: %s",strerror(errno));
return 1;
}
- snprintf(term,PATH_MAX,"%s\n",terminal);
- if (!strncmp(buf,term,strlen(term))) {
- rc = 0;
- goto out_unmap;
+ if (!strncmp(buf,terminal,strlen(terminal)) && buf[strlen(terminal)] == '\n')
+ goto out_ok;
+ if ((pos = strstr(buf, terminal))) {
+ if (pos[strlen(terminal)] == '\n' && *(pos-1) == '\n')
+ goto out_ok;
}
- snprintf(term,PATH_MAX,"\n%s\n",terminal);
- if (strstr(buf,term)) {
- rc = 0;
- goto out_unmap;
+ if (lseek(fd, 0, SEEK_END) == -1) {
+ close(fd);
+ syslog(LOG_ERR, "Couldn't seek to end of /etc/securetty: %s",strerror(errno));
+ return 1;
}
-out_unmap:
- munmap(buf, sb.st_size);
-out:
+ write(fd, terminal, strlen(terminal));
+ write(fd, "\n", 1);
+out_ok:
close(fd);
- return rc;
+ return 0;
}
int main(int argc, char **argv) {
@@ -120,8 +107,5 @@ int main(int argc, char **argv) {
exit(1);
}
openlog("securetty", LOG_CONS, LOG_DAEMON);
- if (check_securetty(argv[1]))
- return rewrite_securetty(argv[1]);
- else
- return 0;
+ return rewrite_securetty(argv[1]);
}
diff --git a/sysconfig/network-scripts/ifdown-sit b/sysconfig/network-scripts/ifdown-sit
index 7d6951f2..68b2002f 100755
--- a/sysconfig/network-scripts/ifdown-sit
+++ b/sysconfig/network-scripts/ifdown-sit
@@ -51,8 +51,5 @@ if [ $? != 0 -a $? != 11 ]; then
exit 0
fi
-# Cleanup additional static routes
-/etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE}
-
# Cleanup and shut down IPv6-in-IPv4 tunnel device
ipv6_del_tunnel_device $DEVICE
diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth
index ea9de5f6..d3adb143 100755
--- a/sysconfig/network-scripts/ifup-eth
+++ b/sysconfig/network-scripts/ifup-eth
@@ -176,7 +176,15 @@ if [ -n "${DYNCONFIG}" -a -x /sbin/dhclient ]; then
else
ONESHOT="-1";
fi;
- generate_config_file_name
+ # allow users to use generic '/etc/dhclient.conf' (as documented in manpage!)
+ # if per-device file doesn't exist or is empty
+ if [ -s /etc/dhcp/dhclient-${DEVICE}.conf ]; then
+ DHCLIENTCONF="-cf /etc/dhcp/dhclient-${DEVICE}.conf";
+ elif [ -s /etc/dhclient-${DEVICE}.conf ]; then
+ DHCLIENTCONF="-cf /etc/dhclient-${DEVICE}.conf";
+ else
+ DHCLIENTCONF='';
+ fi;
# copy any lease obtained by the initrd
for file in /dev/.dhclient-${DEVICE}.leases /dev/.initramfs/net.${DEVICE}.lease ; do
if [ -f "${file}" ]; then
@@ -291,8 +299,7 @@ fi
# IPv6 initialisation?
/etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG}
if [[ "${DHCPV6C}" = [Yy1]* ]] && [ -x /sbin/dhclient ]; then
- generate_config_file_name 6
- /sbin/dhclient -6 -1 ${DHCPV6C_OPTIONS} ${DHCLIENTCONF} -lf /var/lib/dhclient/dhclient6-${DEVICE}.leases -pf /var/run/dhclient6-${DEVICE}.pid ${DHCP_HOSTNAME:+-H $DHCP_HOSTNAME} ${DEVICE}
+ /sbin/dhclient -6 -1 ${DHCPV6C_OPTIONS} -lf /var/lib/dhclient/dhclient6-${DEVICE}.leases -pf /var/run/dhclient6-${DEVICE}.pid ${DHCP_HOSTNAME:+-H $DHCP_HOSTNAME} ${DEVICE}
fi
exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG} ${2}
diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit
index 330118a8..3b24985c 100755
--- a/sysconfig/network-scripts/ifup-sit
+++ b/sysconfig/network-scripts/ifup-sit
@@ -104,5 +104,9 @@ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
done
fi
-# Setup static routes
-/etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE}
+# Setup additional static IPv6 routes (newer config style)
+if [ -f "/etc/sysconfig/network-scripts/route6-$REALDEVICE" ]; then
+ cat "/etc/sysconfig/network-scripts/route6-$REALDEVICE" | sed 's/#.*//g' | grep -v '^[[:space:]]*$' | while read line; do
+ /sbin/ip -6 route add $line
+ done
+fi
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index a3833463..e0d5018c 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -59,17 +59,6 @@ get_uuid_by_config ()
dbus-send --system --print-reply --dest=com.redhat.ifcfgrh1 /com/redhat/ifcfgrh1 com.redhat.ifcfgrh1.GetIfcfgDetails string:"/etc/sysconfig/network-scripts/$1" 2>/dev/null | awk -F '"' '/string / { print $2 }'
}
-generate_config_file_name () {
- local ver=$1
- if [ -s /etc/dhcp/dhclient$ver-${DEVICE}.conf ]; then
- DHCLIENTCONF="-cf /etc/dhcp/dhclient$ver-${DEVICE}.conf";
- elif [ -s /etc/dhclient$ver-${DEVICE}.conf ]; then
- DHCLIENTCONF="-cf /etc/dhclient$ver-${DEVICE}.conf";
- else
- DHCLIENTCONF='';
- fi
-}
-
need_config ()
{
local nconfig