aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.ci/check-shell.sh60
-rw-r--r--.ci/exception-list.txt4
-rw-r--r--.ci/functions.sh91
-rw-r--r--.ci/script-list.txt2
-rw-r--r--.travis.yml7
-rw-r--r--Makefile4
-rw-r--r--doc/sysconfig.txt9
-rw-r--r--etc/rc.d/init.d/functions14
-rw-r--r--etc/rwtab5
-rw-r--r--initscripts.spec31
-rwxr-xr-xnetwork-scripts/ifup8
-rwxr-xr-xnetwork-scripts/ifup-aliases2
-rwxr-xr-xnetwork-scripts/ifup-ctc2
-rwxr-xr-xnetwork-scripts/ifup-eth14
-rwxr-xr-xnetwork-scripts/ifup-ippp16
-rwxr-xr-xnetwork-scripts/ifup-plip2
-rwxr-xr-xnetwork-scripts/ifup-plusb2
-rwxr-xr-xnetwork-scripts/ifup-tunnel2
-rw-r--r--network-scripts/network-functions50
-rw-r--r--network-scripts/network-functions-ipv610
-rw-r--r--po/cs.po5
-rw-r--r--src/rename_device.c14
-rwxr-xr-xusr/sbin/service20
23 files changed, 273 insertions, 101 deletions
diff --git a/.ci/check-shell.sh b/.ci/check-shell.sh
index a4ea3c52..6fef7dd1 100755
--- a/.ci/check-shell.sh
+++ b/.ci/check-shell.sh
@@ -1,5 +1,6 @@
#!/bin/bash
+# Path is wrong because of travis
. ./.ci/functions.sh
# ------------ #
@@ -8,63 +9,84 @@
# https://medium.com/@joey_9999/how-to-only-lint-files-a-git-pull-request-modifies-3f02254ec5e0
# get names of files from PR (excluding deleted files)
-# TRAVIS_COMMIT_RANGE - HEAD of destination branch ... HEAD of PR branch
git diff --name-only --diff-filter=db "${TRAVIS_COMMIT_RANGE}" > ../pr-changes.txt
# Find modified shell scripts
-readarray list_of_changes < <(grep "^[^#]" ../pr-changes.txt)
+list_of_changes=()
+file_to_array "../pr-changes.txt" "list_of_changes" 0
+list_of_scripts=()
+file_to_array "./.ci/script-list.txt" "list_of_scripts" 1
+
+# Create list of scripts for testing
list_of_changed_scripts=()
for file in "${list_of_changes[@]}"; do
- # https://stackoverflow.com/questions/19345872/how-to-remove-a-newline-from-a-string-in-bash
- # Remove new line and add ./ at the beginning
- is_it_script "$file" && list_of_changed_scripts+=("./${file//[$'\t\r\n ']}")
+ is_it_script "$file" "${list_of_scripts[@]}" && list_of_changed_scripts+=("./${file}") && continue
+ check_extension "$file" && list_of_changed_scripts+=("./${file}") && continue
+ check_shebang "$file" && list_of_changed_scripts+=("./${file}")
done
-echo "Changed shell scripts:"
+# Get list of exceptions
+list_of_exceptions=()
+file_to_array "./.ci/exception-list.txt" "list_of_exceptions" 1
+string_of_exceptions=$(join_by , "${list_of_exceptions[@]}")
+
+echo -e "\n"
+echo ":::::::::::::::::::::"
+echo -e "::: ${WHITE}Shellcheck CI${NOCOLOR} :::"
+echo ":::::::::::::::::::::"
+echo -e "\n"
+
+echo -e "${WHITE}Changed shell scripts:${NOCOLOR}"
echo "${list_of_changed_scripts[@]}"
-echo "------------"
+echo -e "${WHITE}List of shellcheck exceptions:${NOCOLOR}"
+echo "${string_of_exceptions}"
+echo -e "\n"
# ------------ #
# SHELLCHECK #
# ------------ #
# sed part is to edit shellcheck output so csdiff/csgrep knows it is shellcheck output (--format=gcc)
-shellcheck --format=gcc "${list_of_changed_scripts[@]}" | sed -e 's|$| <--[shellcheck]|' > ../pr-br-shellcheck.err
+shellcheck --format=gcc --exclude="${string_of_exceptions}" "${list_of_changed_scripts[@]}" 2> /dev/null | sed -e 's|$| <--[shellcheck]|' > ../pr-br-shellcheck.err
# make destination branch
-[[ ${TRAVIS_COMMIT_RANGE} =~ ^([0-9|a-f]*?)\. ]] && git checkout -b ci_br_dest "${BASH_REMATCH[1]}"
+[[ ${TRAVIS_COMMIT_RANGE} =~ ^([0-9|a-f]*?)\. ]] && git checkout -q -b ci_br_dest "${BASH_REMATCH[1]}"
-shellcheck --format=gcc "${list_of_changed_scripts[@]}" | sed -e 's|$| <--[shellcheck]|' > ../dest-br-shellcheck.err
+shellcheck --format=gcc --exclude="${string_of_exceptions}" "${list_of_changed_scripts[@]}" 2> /dev/null | sed -e 's|$| <--[shellcheck]|' > ../dest-br-shellcheck.err
# ------------ #
# VALIDATION #
# ------------ #
exitstatus=0
+echo ":::::::::::::::::::::::::"
+echo -e "::: ${WHITE}Validation Output${NOCOLOR} :::"
+echo ":::::::::::::::::::::::::"
+echo -e "\n"
# Check output for Fixes
csdiff --fixed "../dest-br-shellcheck.err" "../pr-br-shellcheck.err" > ../fixes.log
if [ "$(cat ../fixes.log | wc -l)" -ne 0 ]; then
- echo "Fixed bugs:"
+ echo -e "${GREEN}Fixed bugs:${NOCOLOR}"
csgrep ../fixes.log
- echo "------------"
+ echo "---------------------"
else
- echo "No Fixes!"
- echo "------------"
+ echo -e "${YELLOW}No Fixes!${NOCOLOR}"
+ echo "---------------------"
fi
+echo -e "\n"
# Check output for added bugs
csdiff --fixed "../pr-br-shellcheck.err" "../dest-br-shellcheck.err" > ../bugs.log
if [ "$(cat ../bugs.log | wc -l)" -ne 0 ]; then
- echo "Added bugs, NEED INSPECTION:"
+ echo -e "${RED}Added bugs, NEED INSPECTION:${NOCOLOR}"
csgrep ../bugs.log
- echo "------------"
+ echo "---------------------"
exitstatus=1
else
- echo "No bugs added Yay!"
- echo "------------"
+ echo -e "${GREEN}No bugs added Yay!${NOCOLOR}"
+ echo "---------------------"
exitstatus=0
fi
exit $exitstatus
-
diff --git a/.ci/exception-list.txt b/.ci/exception-list.txt
new file mode 100644
index 00000000..5b093820
--- /dev/null
+++ b/.ci/exception-list.txt
@@ -0,0 +1,4 @@
+# List of Shelcheck codes which should be excluded from ci output
+# Avoid spaces in list since they are counted as comment
+SC1090 # Ignore when shellcheck can't follow non-constant source e.g. ``. "${path}"``
+SC2148 # Ignore missing shebang
diff --git a/.ci/functions.sh b/.ci/functions.sh
index 300f92df..cbe00874 100644
--- a/.ci/functions.sh
+++ b/.ci/functions.sh
@@ -1,9 +1,92 @@
# Function to check whether input param is on list of shell scripts
# $1 - <string> absolute path to file
+# $@ - <array of strings> list of strings to compare with
+# $? - return value - 0 when succes
is_it_script () {
- [ $# -eq 0 ] && return 1
-
- readarray list_of_scripts < ./.ci/script-list.txt
- echo "${list_of_scripts[@]}" | grep --silent "$1" && return 0
+ [ $# -le 1 ] && return 1
+ local file="$1"
+ shift
+ local scripts=("$@")
+
+ [[ " ${scripts[*]} " =~ " ${file} " ]] && return 0 || return 2
+}
+
+# Function to check if given file has .sh extension
+# https://stackoverflow.com/a/407229
+# $1 - <string> absolute path to file
+# $? - return value - 0 when succes
+check_extension () {
+ [ $# -le 0 ] && return 1
+ local file="$1"
+
+ [ "${file: -3}" == ".sh" ] && return 0 || return 2
+}
+
+# Function to check if given file contain shell shebang (bash or sh)
+# https://unix.stackexchange.com/a/406939
+# $1 - <string> absolute path to file
+# $? - return value - 0 when succes
+check_shebang () {
+ [ $# -le 0 ] && return 1
+ local file="$1"
+
+ if IFS= read -r line < "./${file}" ; then
+ case $line in
+ "#!/bin/bash") return 0;;
+ "#!/bin/sh") return 0;;
+ *) return 1
+ esac
+ fi
+}
+
+# Function to prepare string from array of strings where first argument specify one character separator
+# https://stackoverflow.com/a/17841619
+# $1 - <char> Character used to join elements of array
+# $@ - <array of string> list of strings
+# return value - string
+join_by () {
+ local IFS="$1"
+ shift
+ echo "$*"
+}
+
+# Function to get rid of comments represented by '#'
+# $1 - file path
+# $2 - name of variable where will be stored result array
+# $3 - value 1|0 - does file content inline comments?
+# $? - return value - 0 when succes
+file_to_array () {
+ [ $# -le 2 ] && return 1
+ local output=()
+
+ [ "$3" -eq 0 ] && readarray output < <(grep -v "^#.*" "$1") # fetch array with lines from file while excluding '#' comments
+ [ "$3" -eq 1 ] && readarray output < <(cut -d ' ' -f 1 < <(grep -v "^#.*" "$1")) # fetch array with lines from file while excluding '#' comments
+ clean_array "$2" "${output[@]}" && return 0
+}
+
+# Function to get rid of spaces and new lines from array elements
+# https://stackoverflow.com/a/9715377
+# https://stackoverflow.com/a/19347380
+# https://unix.stackexchange.com/a/225517
+# $1 - name of variable where will be stored result array
+# $@ - source array
+# $? - return value - 0 when succes
+clean_array () {
+ [ $# -le 2 ] && return 1
+ local output="$1"
+ shift
+ local input=("$@")
+
+ for i in "${input[@]}"; do
+ eval $output+=\("${i//[$'\t\r\n ']}"\)
+ done
}
+# Color aliases use echo -e to use them
+NOCOLOR='\033[0m'
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+ORANGE='\033[0;33m'
+BLUE='\033[0;34m'
+YELLOW='\033[1;33m'
+WHITE='\033[1;37m'
diff --git a/.ci/script-list.txt b/.ci/script-list.txt
index 7323ceb7..053672df 100644
--- a/.ci/script-list.txt
+++ b/.ci/script-list.txt
@@ -1,4 +1,6 @@
# Tracker of all shell scripts in this repository
+# Every new script should be added in order to test it with ci
+# Avoid spaces in list since they are counted as comment
etc/rc.d/init.d/functions
etc/rc.d/init.d/network
network-scripts/ifdown-bnep
diff --git a/.travis.yml b/.travis.yml
index ee431240..afb755d7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
-# Run in fast container-based environment:
-sudo: false
+os: linux
dist: trusty
+language: c
git:
depth: 2
@@ -23,7 +23,7 @@ addons:
packages:
libpopt-dev
-matrix:
+jobs:
include:
- language: shell
script:
@@ -33,4 +33,3 @@ matrix:
notifications:
email: false
-
diff --git a/Makefile b/Makefile
index 01a21223..4d77e363 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ localstatedir = /var
sharedstatedir = $(localstatedir)/lib
VERSION := $(shell gawk '/Version:/ { print $$2 }' initscripts.spec)
-NEXT_VERSION := $(shell gawk '/Version:/ { print $$2 + 0.01}' initscripts.spec)
+NEXT_VERSION := $(shell gawk '/Version:/ { print $$2 + 0.01 }' initscripts.spec)
all: make-binaries make-translations
@@ -108,7 +108,7 @@ tag:
release-commit:
@git log --decorate=no --format="- %s" $(VERSION)..HEAD > .changelog.tmp
- @rpmdev-bumpspec -n $(NEXT_VERSION) -f .changelog.tmp initscripts.spec
+ @rpmdev-bumpspec -D -n $(NEXT_VERSION) -f .changelog.tmp initscripts.spec
@rm -f .changelog.tmp
@git add initscripts.spec
@git commit --message="$(NEXT_VERSION)"
diff --git a/doc/sysconfig.txt b/doc/sysconfig.txt
index b16338a9..16da2d97 100644
--- a/doc/sysconfig.txt
+++ b/doc/sysconfig.txt
@@ -151,6 +151,11 @@ Generic options:
Example: WAIT_UNTIL_REACHABLE=8.8.8.8
Default: (not set)
+ RES_OPTIONS=<list of resolv.conf options>
+ RES_OPTIONS contains space-separated list of resolver options as explained in resolv.conf(5).
+ Example: RES_OPTIONS="rotate timeout:1 retries:1" this will be presented in /etc/resolv.conf like
+ "options rotate timeout:1 retries:1"
+
IFDOWN_ON_SHUTDOWN=yes|no
If yes, do bring interfaces down during system shutdown. If no, leave them
in their current state (this is only supported on hosts using systemd).
@@ -475,6 +480,10 @@ Files in /etc/sysconfig/network-scripts/
NOZEROCONF=
Set this to not set a route for dynamic link-local addresses
over this device.
+ LINKSTATUS=up|down
+ Setting LINKSTATUS to down prevents network-scripts from bringing up interface.
+ This prevents issues with interfaces like Open vSwitch bridges which uses
+ userspace datapaths. If not set defaults to up.
PERSISTENT_DHCLIENT=yes|no|1|0
Without this option, or if it is 'no'/'0', and BOOTPROTO=dhcp,
dhclient is run for the interface in "one-shot" mode; if the
diff --git a/etc/rc.d/init.d/functions b/etc/rc.d/init.d/functions
index 9e33ee06..5ede6c76 100644
--- a/etc/rc.d/init.d/functions
+++ b/etc/rc.d/init.d/functions
@@ -86,7 +86,7 @@ if [ -z "${BOOTUP:-}" ]; then
# NOTE: /dev/ttyS* is serial console. "not a tty" is such as
# /dev/null associated when executed under systemd service units.
- if LANG=C tty | grep --quiet -e '\(/dev/ttyS\|not a tty\)'; then
+ if LANG=C tty | grep -q -e '\(/dev/ttyS\|not a tty\)'; then
BOOTUP=serial
MOVE_TO_COL=
SETCOLOR_SUCCESS=
@@ -311,7 +311,7 @@ killproc() {
RC=0; delay=3; try=0
# Test syntax.
if [ "$#" -eq 0 ]; then
- echo $"Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"
+ echo $"Usage: killproc [-p {pidfile} [-b {binary}]] [-d {delay}] {program} [-signal]"
return 1
fi
if [ "$1" = "-p" ]; then
@@ -321,7 +321,7 @@ killproc() {
if [ "$1" = "-b" ]; then
if [ -z $pid_file ]; then
echo $"-b option can be used only with -p"
- echo $"Usage: killproc -p pidfile -b binary program"
+ echo $"Usage: killproc [-p {pidfile} [-b {binary}]] [-d {delay}] {program} [-signal]"
return 1
fi
binary=$2
@@ -330,7 +330,7 @@ killproc() {
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]"
+ echo $"Usage: killproc [-p {pidfile} [-b {binary}]] [-d {delay}] {program} [-signal]"
return 1
fi
shift 2
@@ -408,7 +408,7 @@ pidofproc() {
# Test syntax.
if [ "$#" = 0 ]; then
- echo $"Usage: pidofproc [-p pidfile] {program}"
+ echo $"Usage: pidofproc [-p {pidfile}] {program}"
return 1
fi
if [ "$1" = "-p" ]; then
@@ -434,7 +434,7 @@ status() {
# Test syntax.
if [ "$#" = 0 ] ; then
- echo $"Usage: status [-p pidfile] {program}"
+ echo $"Usage: status [-p {pidfile}] [-l {lockfile}] [-b {binary}] {program}"
return 1
fi
if [ "$1" = "-p" ]; then
@@ -448,7 +448,7 @@ status() {
if [ "$1" = "-b" ]; then
if [ -z $pid_file ]; then
echo $"-b option can be used only with -p"
- echo $"Usage: status -p pidfile -b binary program"
+ echo $"Usage: status [-p {pidfile}] [-l {lockfile}] [-b {binary}] {program}"
return 1
fi
binary=$2
diff --git a/etc/rwtab b/etc/rwtab
index ef574664..d084823b 100644
--- a/etc/rwtab
+++ b/etc/rwtab
@@ -4,6 +4,8 @@ dirs /var/lib/xkb
dirs /var/log
dirs /var/lib/puppet
dirs /var/lib/dbus
+dirs /var/lib/mlocate
+dirs /var/lib/systemd/rfkill
empty /tmp
empty /var/cache/foomatic
@@ -20,6 +22,7 @@ empty /var/lib/php
empty /var/lib/pulse
empty /var/lib/systemd/timers
empty /var/lib/ups
+empty /var/lib/chrony
empty /var/tmp
files /etc/adjtime
@@ -41,5 +44,5 @@ files /var/empty/sshd/etc/localtime
files /var/lib/systemd/random-seed
files /var/spool
files /var/lib/samba
-files /var/log/audit/audit.log
+files /var/log/audit/audit.log
files /var/lib/nfs
diff --git a/initscripts.spec b/initscripts.spec
index fe42f491..2250dc3a 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -18,7 +18,7 @@ Requires: gawk \
Name: initscripts
Summary: Basic support for legacy System V init scripts
-Version: 10.03
+Version: 10.06
Release: 1%{?dist}
License: GPLv2
@@ -175,6 +175,9 @@ Obsoletes: %{name} < 9.82-2
This package provides script & configuration file for setting up read-only root
support. Additional configuration is required after installation.
+Please note that readonly-root package is considered deprecated with limited support.
+Please use systemd-volatile-root functionality instead, if possible.
+
# === BUILD INSTRUCTIONS ======================================================
%prep
@@ -347,6 +350,30 @@ fi
# =============================================================================
%changelog
+* Fri Nov 13 2020 Jan Macku <jamacku@redhat.com> - 10.06-1
+- service: catch unsupported action keywords
+- makefile: Use rpmdev-bumpspec's legacy date option
+
+* Fri Nov 06 2020 Jan Macku <jamacku@redhat.com> - 10.05-1
+- service: Prevent variables from globbing
+- init.d/functions: Make usage msgs more clear
+- network-scripts: Use net_log() instead of logger
+- Allow updating rfkill switch status while in readonly root mode
+- Add info into specfile about readonly-root deprecation
+- Allow updating mlocate.db while in readonly root mode
+- rc.d/functions: replace grep's --quiet with -q
+- Add warning to warn user when ETHTOOL_OPTS is set and ethtool binary is missing - Olav Vitters
+- Fix spacing in Makefile
+- Add optional 'dev' keyword
+
+* Tue Jul 14 2020 Jan Macku <jamacku@redhat.com> - 10.04-1
+- Maintain permisision to set umask
+- rwtab: Add support for chrony
+- Correct spelling, IP, …
+- Fix spelling, for more info
+- Fix spelling of SELinux
+- Translations update from Weblate
+
* Tue Mar 24 2020 Jan Macku <jamacku@redhat.com> - 10.03-1
- Replace grep -EL with subshell since -L changed behaviour
- Wait for scope link addresses as well as for scope global addresses
@@ -691,7 +718,7 @@ ng
* Tue Jan 14 2014 Lukáš Nykrýn <lnykryn@redhat.com> 9.51-1
- readonly-root: bind-mount only necessary subset of entries in rwtab
- readonly-root: Add /var/log/audit/audit.log to rwtab
-- readonly-root: restore selinux context after bind mount
+- readonly-root: restore SELinux context after bind mount
- rename_device: remove comments and trailing whitespaces
- service: suggest using systemctl if unknown action is used
- ifup-eth: fix typo in error message
diff --git a/network-scripts/ifup b/network-scripts/ifup
index 5aac4c9f..a0530779 100755
--- a/network-scripts/ifup
+++ b/network-scripts/ifup
@@ -122,7 +122,7 @@ if is_true "${VLAN}" && is_false "$ISALIAS" && [ -n "$DEVICE" ]; then
}
# Link on Physical device needs to be up but no ip required
- check_device_down ${PHYSDEV} && { ip -o link set dev ${PHYSDEV} up; }
+ check_device_down ${PHYSDEV} && set_link_up ${PHYSDEV}
if [ ! -f /proc/net/vlan/${DEVICE} ]; then
if is_false "${REORDER_HDR}"; then
@@ -134,13 +134,11 @@ if is_true "${VLAN}" && is_false "$ISALIAS" && [ -n "$DEVICE" ]; then
fi
ip link add dev ${DEVICE} link ${PHYSDEV} type vlan id ${VID} ${FLAG_REORDER_HDR} ${FLAG_GVRP} || {
- (/usr/bin/logger -p daemon.info -t ifup \
- $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" &) &
- net_log $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}"
+ net_log $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" info ifup
exit 1
}
- [ -n "${VLAN_EGRESS_PRIORITY_MAP}" ] && ip link set ${DEVICE} type vlan egress ${VLAN_EGRESS_PRIORITY_MAP}
+ [ -n "${VLAN_EGRESS_PRIORITY_MAP}" ] && ip link set dev ${DEVICE} type vlan egress ${VLAN_EGRESS_PRIORITY_MAP}
fi
fi
diff --git a/network-scripts/ifup-aliases b/network-scripts/ifup-aliases
index 8020f407..971ce208 100755
--- a/network-scripts/ifup-aliases
+++ b/network-scripts/ifup-aliases
@@ -266,7 +266,7 @@ function new_interface ()
if [ "${parent_device}" != "lo" ] && ! is_false "${ARPCHECK}" && \
is_available ${parent_device} && \
( grep -qswi "up" /sys/class/net/${parent_device}/operstate || grep -qswi "1" /sys/class/net/${parent_device}/carrier ) ; then
- echo $"Determining if ip address ${IPADDR} is already in use for device ${parent_device}..."
+ echo $"Determining if IP address ${IPADDR} is already in use for device ${parent_device}…"
ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${parent_device} ${IPADDR})
if [ $? = 1 ]; then
ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p')
diff --git a/network-scripts/ifup-ctc b/network-scripts/ifup-ctc
index 83f754a0..89f50a09 100755
--- a/network-scripts/ifup-ctc
+++ b/network-scripts/ifup-ctc
@@ -26,7 +26,7 @@ fi
[ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
ip addr add ${IPADDR} peer ${GATEWAY}/${PREFIX} dev ${DEVICE}
-ip link set up dev ${DEVICE}
+set_link_up ${DEVICE}
# Wait for the device to come up - the chandev'ified ctc driver can take
# quite a while...
timeout=0
diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth
index 178b5173..730e08fd 100755
--- a/network-scripts/ifup-eth
+++ b/network-scripts/ifup-eth
@@ -60,7 +60,7 @@ if [ "${TYPE}" = "Bridge" ]; then
if [ ! -d /sys/class/net/${DEVICE}/bridge ]; then
ip link add ${DEVICE} type bridge $bridge_opts || exit 1
elif [ -n "${bridge_opts}" ]; then
- ip link set ${DEVICE} type bridge $bridge_opts || exit 1
+ ip link set dev ${DEVICE} type bridge $bridge_opts || exit 1
fi
unset bridge_opts
@@ -76,7 +76,7 @@ if [ "${TYPE}" = "Bridge" ]; then
# set LINKDELAY (used as timeout when calling check_link_down())
# to at least (${DELAY} * 2) + 7 if STP is enabled. This is the
# minimum time required for /sys/class/net/$REALDEVICE/carrier to
- # become 1 after "ip link set dev $DEVICE up" is called.
+ # become 1 after "set_link_up $DEVICE" is called.
if is_true "${STP}"; then
if [ -n "${DELAY}" ]; then
forward_delay="${DELAY}"
@@ -164,7 +164,7 @@ fi
# so it can actually get an IP.
if is_false "$ISALIAS" && is_bonding_device ${DEVICE}; then
install_bonding_driver ${DEVICE}
- /sbin/ip link set dev ${DEVICE} up
+ set_link_up ${DEVICE}
for device in $(LANG=C grep -l "^[[:space:]]*MASTER=['\"]\?${DEVICE}['\"]\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do
is_ignored_file "$device" && continue
/sbin/ifup ${device##*/} || net_log "Unable to start slave device ${device##*/} for master ${DEVICE}." warning
@@ -188,10 +188,10 @@ if [ -n "${BRIDGE}" ]; then
ip link add ${BRIDGE} type bridge 2>/dev/null
fi
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null
- /sbin/ip link set dev ${DEVICE} up
+ set_link_up ${DEVICE}
ethtool_set
[ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
- ip link set ${DEVICE} master ${BRIDGE}
+ ip link set dev ${DEVICE} master ${BRIDGE}
# add the bits to setup driver parameters here
for arg in $BRIDGING_OPTS ; do
key=${arg%%=*};
@@ -243,7 +243,7 @@ if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then
else
if [ -z "${IPADDR}" -a -z "${IPADDR0}" -a -z "${IPADDR1}" -a -z "${IPADDR2}" ]; then
# enable device without IP, useful for e.g. PPPoE
- ip link set dev ${REALDEVICE} up
+ set_link_up ${REALDEVICE}
ethtool_set
[ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
else
@@ -253,7 +253,7 @@ else
[ -n "${ARP}" ] && \
ip link set dev ${REALDEVICE} $(toggle_value arp $ARP)
- if ! ip link set dev ${REALDEVICE} up ; then
+ if ! set_link_up ${REALDEVICE} ; then
net_log $"Failed to bring up ${DEVICE}."
exit 1
fi
diff --git a/network-scripts/ifup-ippp b/network-scripts/ifup-ippp
index b8df7c07..a19c12e0 100755
--- a/network-scripts/ifup-ippp
+++ b/network-scripts/ifup-ippp
@@ -30,20 +30,20 @@ fi
# check that ipppd is available for syncppp
if [ "$ENCAP" = "syncppp" ]; then
if [ ! -x /sbin/ipppd ] && [ ! -x /usr/sbin/ipppd ] ; then
- /usr/bin/logger -p daemon.info -t ifup-ippp "ipppd does not exist or is not executable"
+ net_log $"ipppd does not exist or is not executable" info ifup-ippp
exit 1
fi
fi
# check that isdnctrl is available
if [ ! -x /sbin/isdnctrl ] && [ ! -x /usr/sbin/isdnctrl ] ; then
- /usr/bin/logger -p daemon.info -t ifup-ippp "isdnctrl does not exist or is not executable"
+ net_log $"isdnctrl does not exist or is not executable" info ifup-ippp
exit 1
fi
# check all ISDN devices
if ! isdnctrl list all >/dev/null 2>&1 ; then
- /usr/bin/logger -p daemon.info -t ifup-ippp "cannot list ISDN devices"
+ net_log $"cannot list ISDN devices" info ifup-ippp
exit 1
fi
@@ -52,12 +52,12 @@ isdnctrl list $DEVICE >/dev/null 2>&1 && exit 0
function log_echo()
{
- /usr/bin/logger -p daemon.info -t ifup-ippp $"$*"
+ net_log $"$*" info ifup-ippp
}
function log_isdnctrl()
{
- /usr/bin/logger -p daemon.info -t ifup-ippp isdnctrl $*
+ net_log $"$*" info ifup-ippp
isdnctrl $* >/dev/null 2>&1 || exit 1
}
@@ -340,13 +340,13 @@ function addprovider()
pfx=${val##PREFIX=}
}
# activate ISDN device
- /usr/bin/logger -p daemon.info -t ifup-ippp "ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE"
+ net_log $"ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE" info ifup-ippp
ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE
- ip link set dev $DEVICE up
+ set_link_up ${DEVICE}
if [ "$ENCAP" = "syncppp" ]; then
# start ipppd daemon
- /usr/bin/logger -p daemon.info -t ifup-ippp "ipppd $options $netmask"
+ net_log $"ipppd $options $netmask" info ifup-ippp
ipppd $options $netmask >/dev/null 2>&1
# start ibod daemon
diff --git a/network-scripts/ifup-plip b/network-scripts/ifup-plip
index 2cea68b4..3524b261 100755
--- a/network-scripts/ifup-plip
+++ b/network-scripts/ifup-plip
@@ -12,7 +12,7 @@ fi
[ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} dev ${DEVICE}
-ip link set up dev ${DEVICE}
+set_link_up ${DEVICE}
ip route add ${NETWORK} dev ${DEVICE}
. /etc/sysconfig/network
diff --git a/network-scripts/ifup-plusb b/network-scripts/ifup-plusb
index 1b29afeb..2b2c2c5c 100755
--- a/network-scripts/ifup-plusb
+++ b/network-scripts/ifup-plusb
@@ -29,7 +29,7 @@ if [ ${BROADCAST} != "" ] ; then
else
ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} dev ${DEVICE}
fi
-ip link set up dev ${DEVICE}
+set_link_up ${DEVICE}
. /etc/sysconfig/network
diff --git a/network-scripts/ifup-tunnel b/network-scripts/ifup-tunnel
index ea85df52..f20048a3 100755
--- a/network-scripts/ifup-tunnel
+++ b/network-scripts/ifup-tunnel
@@ -91,7 +91,7 @@ fi
/sbin/ip addr add "$MY_INNER_IPADDR" dev "$DEVICE" \
${PEER_INNER_IPADDR:+peer "$PEER_INNER_IPADDR"}
-/sbin/ip link set dev "$DEVICE" up
+set_link_up "${DEVICE}"
# IPv6 initialisation?
/etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG}
diff --git a/network-scripts/network-functions b/network-scripts/network-functions
index 99096bd8..c80467ab 100644
--- a/network-scripts/network-functions
+++ b/network-scripts/network-functions
@@ -195,25 +195,29 @@ nm_con_load () {
array:string:"/etc/sysconfig/network-scripts/${1}" >/dev/null 2>&1
}
-ethtool_set()
+ethtool_set ()
{
- oldifs=$IFS;
- IFS=';';
- if [ -n "${ETHTOOL_DELAY}" ]; then
- # Convert microseconds to seconds:
- local ETHTOOL_DELAY_SEC=$(convert2sec ${ETHTOOL_DELAY} micro)
- sleep ${ETHTOOL_DELAY_SEC}
- fi
- for opts in $ETHTOOL_OPTS ; do
- IFS=$oldifs;
- if [[ "${opts}" =~ [[:space:]]*- ]]; then
- /sbin/ethtool $opts
- else
- /sbin/ethtool -s ${REALDEVICE} $opts
- fi
+ if [ -n "${ETHTOOL_OPTS}" ] && [ ! -x /sbin/ethtool ] ; then
+ net_log "ethtool does not exist or is not executable." warning
+ else
+ oldifs=$IFS;
IFS=';';
- done
- IFS=$oldifs;
+ if [ -n "${ETHTOOL_DELAY}" ] ; then
+ # Convert microseconds to seconds:
+ local ETHTOOL_DELAY_SEC=$(convert2sec ${ETHTOOL_DELAY} micro)
+ sleep ${ETHTOOL_DELAY_SEC}
+ fi
+ for opts in $ETHTOOL_OPTS ; do
+ IFS=$oldifs;
+ if [[ "${opts}" =~ [[:space:]]*- ]] ; then
+ /sbin/ethtool $opts
+ else
+ /sbin/ethtool -s ${REALDEVICE} $opts
+ fi
+ IFS=';';
+ done
+ IFS=$oldifs;
+ fi
}
expand_config ()
@@ -453,11 +457,16 @@ check_device_down ()
fi
}
-check_link_down ()
+set_link_up ()
{
- if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q ",UP" ; then
+ if [ "$LINKSTATUS" != up ]; then
ip link set dev $1 up >/dev/null 2>&1
fi
+}
+
+check_link_down ()
+{
+ set_link_up $1
timeout=0
delay=10
[ -n "$LINKDELAY" ] && delay=$(($LINKDELAY * 2))
@@ -622,6 +631,8 @@ is_bonding_device ()
# Invoke this when /etc/resolv.conf has changed:
change_resolv_conf ()
{
+ oldumask=$(umask)
+ umask 022
s=$(/bin/grep '^[\ \ ]*option' /etc/resolv.conf 2>/dev/null)
if [ $# -gt 1 ]; then
if [ "x$s" != "x" ]; then
@@ -657,6 +668,7 @@ change_resolv_conf ()
/usr/bin/logger -p local7.notice -t "NET" -i "$0 : updated /etc/resolv.conf"
[ -e /run/nscd/socket ] && /usr/sbin/nscd -i hosts # invalidate cache
fi
+ umask "$oldumask"
return $r
}
diff --git a/network-scripts/network-functions-ipv6 b/network-scripts/network-functions-ipv6
index 2f7b19b8..a85a776d 100644
--- a/network-scripts/network-functions-ipv6
+++ b/network-scripts/network-functions-ipv6
@@ -10,6 +10,8 @@
#
#
+# Source network-functions due to need of set_link_up()
+. ./network-functions
##### Test for IPv6 capabilities
# $1: (optional) testflag: currently supported: "testonly" (do not load a module)
@@ -108,7 +110,7 @@ ipv6_enable_autotunnel() {
true
else
# bring up basic tunnel device
- /sbin/ip link set sit0 up
+ set_link_up sit0
if ! ipv6_test_device_status sit0; then
net_log $"Tunnel device 'sit0' enabling didn't work" err $fn
@@ -159,7 +161,7 @@ ipv6_add_addr_on_device() {
net_log $"Device '$device' doesn't exist" err $fn
return 3
else
- /sbin/ip link set $device up
+ set_link_up $device
if ! ipv6_test_device_status $device; then
net_log $"Device '$device' enabling didn't work" err $fn
@@ -604,7 +606,7 @@ ipv6_add_tunnel_device() {
return 3
fi
- /sbin/ip link set $device up
+ set_link_up $device
if ! ipv6_test_device_status $device; then
net_log $"Tunnel device '$device' bringing up didn't work" err $fn
@@ -1077,7 +1079,7 @@ ipv6_wait_tentative() {
if [ -n "$ip_output" ]; then
net_log $"Some IPv6 address(es) of ${device} remain still in 'tentative' state" warning $fn
- net_log $"Run 'ip -6 addr show dev ${device} tentative' to see more" warning $fn
+ net_log $"Run 'ip -6 addr show dev ${device} tentative' for more info" warning $fn
fi
return 0
diff --git a/po/cs.po b/po/cs.po
index 7980e943..0f69f21a 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -265,8 +265,8 @@ msgstr "Zadaná IPv4 adresa '$ipv4addr' není globálně použitelná"
#: ../network-scripts/ifup-ipv6:222
msgid ""
-"IPv6to4 configuration needs an IPv4 address on related interface or "
-"otherwise specified"
+"Determining if ip address ${IPADDR} is already in use for device "
+"${parent_device}..."
msgstr ""
"Nastavení IPv6to4 potřebuje IPv4 adresu buď na příslušném zařízení nebo "
"zadanou jinak"
@@ -514,7 +514,6 @@ msgstr ""
#: ../network-scripts/network-functions-ipv6:895
msgid "Given IPv6 default device '$device' requires an explicit nexthop"
msgstr ""
-"Zadané implicitní zařízení IPv6 '$device' vyžaduje explicitní další skok"
#: ../network-scripts/network-functions-ipv6:898
msgid "Given IPv6 default device '$device' doesn't exist or isn't up"
diff --git a/src/rename_device.c b/src/rename_device.c
index c39f447d..b4ed69eb 100644
--- a/src/rename_device.c
+++ b/src/rename_device.c
@@ -278,6 +278,14 @@ char *get_config_by_hwaddr(char *hwaddr, char *current) {
return first;
}
+int pid_exist(int pid)
+{
+ char proc_dir[32];
+ sprintf(proc_dir, "/proc/%d/", pid);
+ return !access(proc_dir, F_OK);
+}
+
+
void take_lock() {
int count = 0;
int lockfd;
@@ -309,7 +317,11 @@ void take_lock() {
close(fd);
pid = atoi(buf);
if (pid && pid != 1) {
- kill(pid,SIGKILL);
+ if (pid_exist(pid))
+ kill(pid,SIGKILL);
+ else
+ if (unlink(LOCKFILE) != 0)
+ break;
}
}
usleep(100000);
diff --git a/usr/sbin/service b/usr/sbin/service
index b178d915..4e82bad1 100755
--- a/usr/sbin/service
+++ b/usr/sbin/service
@@ -74,9 +74,9 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
# LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
# lets reap them before next start
if [ "${ACTION}" = 'start' ] && \
- [ "$(systemctl show -p ActiveState ${SERVICE}.service --value)" = 'active' ] && \
- [ "$(systemctl show -p SubState ${SERVICE}.service --value)" = 'exited' ]; then
- /bin/systemctl stop ${SERVICE}.service
+ [ "$(systemctl show -p ActiveState "${SERVICE}".service --value)" = 'active' ] && \
+ [ "$(systemctl show -p SubState "${SERVICE}".service --value)" = 'exited' ]; then
+ /bin/systemctl stop "${SERVICE}".service
fi
# Workaround to be able to "stop" network.service when it's in inactive state using service instead of systemctl
@@ -87,14 +87,14 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; then
export SYSTEMCTL_SKIP_REDIRECT=1
fi
- env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS}
+ env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES="${SYSTEMCTL_IGNORE_DEPENDENCIES}" SYSTEMCTL_SKIP_REDIRECT="${SYSTEMCTL_SKIP_REDIRECT}" "${SERVICEDIR}/${SERVICE}" "${ACTION}" ${OPTIONS}
elif [ -n "${ACTION}" ] && [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" ]; then
- env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS}
-elif [[ $ACTION =~ start|stop|restart|try-restart|reload|force-reload|status|condrestart ]]; then
- SERVICE_MANGLED=$(/usr/bin/systemd-escape --mangle ${SERVICE})
- echo $"Redirecting to /bin/systemctl ${ACTION}${OPTIONS:+ }${OPTIONS} ${SERVICE_MANGLED}" >&2
- exec /bin/systemctl ${ACTION} ${OPTIONS} ${SERVICE_MANGLED}
+ env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES="${SYSTEMCTL_IGNORE_DEPENDENCIES}" SYSTEMCTL_SKIP_REDIRECT="${SYSTEMCTL_SKIP_REDIRECT}" "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS}
+elif [[ $ACTION =~ ^(start|stop|restart|try-restart|reload|reload-or-restart|try-reload-or-restart|force-reload|status|condrestart)$ ]]; then
+ SERVICE_MANGLED=$(/usr/bin/systemd-escape --mangle "${SERVICE}")
+ echo $"Redirecting to /bin/systemctl ${ACTION} ${SERVICE_MANGLED}${OPTIONS:+ }${OPTIONS}" >&2
+ exec /bin/systemctl "${ACTION}" "${SERVICE_MANGLED}" ${OPTIONS}
else
- echo $"The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl." >&2
+ echo $"The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, reload-or-restart, try-reload-or-restart, force-reload, status, condrestart). For other actions, please try to use systemctl." >&2
exit 2
fi