From 05d1c04cf9e5916de8550115dc578e91d29651cd Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 3 Feb 2012 11:39:27 +0100 Subject: Fix indentation Indent code using tabs (instead of spaces) in all source files. Signed-off-by: Lukas Fleischer --- arch-sysctl | 2 +- rc.sysinit | 2 +- zsh-completion | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch-sysctl b/arch-sysctl index 4856df6..4c54217 100755 --- a/arch-sysctl +++ b/arch-sysctl @@ -19,7 +19,7 @@ declare -A fragments # files declared later in the sysctl_d array will override earlier # Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. for path in "${sysctl_d[@]}"; do - [[ -f $path ]] && fragments[${path##*/}]=$path + [[ -f $path ]] && fragments[${path##*/}]=$path done for path in "${fragments[@]}"; do diff --git a/rc.sysinit b/rc.sysinit index fbb1894..27ad124 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -36,7 +36,7 @@ run_hook sysinit_start bootlogd -p /run/bootlogd.pid if [[ ! -a /usr/lib ]] ; then - printf "${C_FAIL}/usr is not mounted. This is not supported.${C_OTHER}\n" + printf "${C_FAIL}/usr is not mounted. This is not supported.${C_OTHER}\n" fi if [[ ! $(grep devtmpfs /proc/filesystems) ]] ; then diff --git a/zsh-completion b/zsh-completion index 58fdfab..d860e51 100644 --- a/zsh-completion +++ b/zsh-completion @@ -28,7 +28,7 @@ _rc.d () { ;; esac ;; - esac + esac } _rc.d "$@" -- cgit v1.2.3 From e88c1e1781f453db2de6ea46cc574c237c042a6a Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 3 Feb 2012 13:50:35 +0100 Subject: Small style cleanup * Add whitespace to arithmetic expressions. * Use boolean logic for semantically boolean variables. Signed-off-by: Lukas Fleischer --- functions | 2 +- network | 4 ++-- rc.d | 8 ++++---- rc.sysinit | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/functions b/functions index 24da795..833711b 100644 --- a/functions +++ b/functions @@ -662,7 +662,7 @@ need_root() { # Quit script if it's not running by root # This can be disabled in scripts sourcing functions by setting NEED_ROOT=0 # A local call to need_root can be done to ensure part of script need root privilege -(( ${NEED_ROOT:-0} == 1 )) && need_root +(( NEED_ROOT )) && need_root # End of file # vim: set ts=2 sw=2 noet: diff --git a/network b/network index d22b5dd..faaac78 100755 --- a/network +++ b/network @@ -260,7 +260,7 @@ case "$1" in else network_up fi - if ((error == 0)); then + if (( ! error )); then add_daemon network stat_done else @@ -296,7 +296,7 @@ case "$1" in else network_down fi - if ((error == 0)); then + if (( ! error )); then stat_done else stat_fail diff --git a/rc.d b/rc.d index aed2e42..115dc05 100755 --- a/rc.d +++ b/rc.d @@ -41,10 +41,10 @@ not exist or is not executable.${C_CLEAR}\n" >&2 exit 2 fi # check filter - ((${filter[started]} == 1)) && ck_daemon "$daemon" && continue - ((${filter[stopped]} == 1)) && ! ck_daemon "$daemon" && continue - ((${filter[auto]} == 1)) && ck_autostart "$daemon" && continue - ((${filter[noauto]} == 1)) && ! ck_autostart "$daemon" && continue + (( ${filter[started]} )) && ck_daemon "$daemon" && continue + (( ${filter[stopped]} )) && ! ck_daemon "$daemon" && continue + (( ${filter[auto]} )) && ck_autostart "$daemon" && continue + (( ${filter[noauto]} )) && ! ck_autostart "$daemon" && continue new_daemons+=("$daemon") done daemons=("${new_daemons[@]}") diff --git a/rc.sysinit b/rc.sysinit index 27ad124..458239e 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -169,7 +169,7 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then crypto_unlocked=0 read_crypttab do_unlock && stat_done || stat_fail # Maybe someone has LVM on an encrypted block device - (( crypto_unlocked == 1 )) && activate_vgs + (( crypto_unlocked )) && activate_vgs fi # Check filesystems -- cgit v1.2.3 From 6f171422cbb1c48da3f1f440148e163af2e2e635 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 3 Feb 2012 11:33:07 +0100 Subject: rc.sysinit: Remove redundant command substitution Invoke `grep -q` and check its return value instead of checking whether grep(1) produces non-empty output. Signed-off-by: Lukas Fleischer --- rc.sysinit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.sysinit b/rc.sysinit index 458239e..88c72a0 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -39,7 +39,7 @@ if [[ ! -a /usr/lib ]] ; then printf "${C_FAIL}/usr is not mounted. This is not supported.${C_OTHER}\n" fi -if [[ ! $(grep devtmpfs /proc/filesystems) ]] ; then +if ! grep -q devtmpfs /proc/filesystems; then printf "${C_FAIL}Your kernel does not have devtmpfs support. This is not supported.${C_OTHER}\n" fi -- cgit v1.2.3 From 248c6f1679343f9e75647bf3b2fefc53c12ba058 Mon Sep 17 00:00:00 2001 From: Jonathan Frazier Date: Mon, 13 Feb 2012 03:48:54 -0500 Subject: Update the rc.conf manpage for kmod kmod has a modprobe.d man page not modprobe.conf Signed-off-by: Jonathan Frazier --- rc.conf.5.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.conf.5.txt b/rc.conf.5.txt index 099e69f..c4087d0 100644 --- a/rc.conf.5.txt +++ b/rc.conf.5.txt @@ -102,7 +102,7 @@ HARDWARE[[H]] ------------- *MODULES=* -Modules to load at boot-up. To blacklist modules, see "man modprobe.conf". +Modules to load at boot-up. To blacklist modules, see "man modprobe.d". Default: (). -- cgit v1.2.3 From fd54cc63cd6853b839d8a0d15ff7c8506743ac5a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Fri, 24 Feb 2012 21:38:26 +0100 Subject: deal with both valid return codes of mount -a Signed-off-by: Tom Gundersen --- functions | 1 + 1 file changed, 1 insertion(+) diff --git a/functions b/functions index 833711b..9f2078d 100644 --- a/functions +++ b/functions @@ -477,6 +477,7 @@ fsck_reboot() { mount_all() { mount -a -t "nosysfs,no${NETFS//,/,no}" -O no_netdev + return $(($? & ~64)) # ignore return code 64: some mounts succeeded } umount_all() { -- cgit v1.2.3 From 7f42e7e621369aa6eaab446dc4c1bc3f04c4b266 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Fri, 24 Feb 2012 22:36:33 +0100 Subject: Revert "deal with both valid return codes of mount -a" This reverts commit fd54cc63cd6853b839d8a0d15ff7c8506743ac5a. The correct return codes of "mount -a" are: 0 all mounts succeeded 64 some mounts succeeded and some failed 32 all mounts failed We want to show "FAILED" on all return codes except for 0. There is a bug in the new mount where "ignored" is taken to be "failed", which gives some false negative. This will be fixed in util-linux. --- functions | 1 - 1 file changed, 1 deletion(-) diff --git a/functions b/functions index 9f2078d..833711b 100644 --- a/functions +++ b/functions @@ -477,7 +477,6 @@ fsck_reboot() { mount_all() { mount -a -t "nosysfs,no${NETFS//,/,no}" -O no_netdev - return $(($? & ~64)) # ignore return code 64: some mounts succeeded } umount_all() { -- cgit v1.2.3 From ecd99c311b3e5a7bbc7bf19029acad2c2a65178e Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 24 Feb 2012 15:20:28 -0500 Subject: rc.sysinit: avoid exporting empty TIMEZONE as TZ fixes FS#28458 Signed-off-by: Dave Reisner --- rc.sysinit | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rc.sysinit b/rc.sysinit index 88c72a0..b38d350 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -64,7 +64,9 @@ if [[ $HWCLOCK_PARAMS ]]; then # is used. If HARDWARECLOCK is not set in rc.conf, the value in # /var/lib/hwclock/adjfile is used (in this case /var can not be a separate # partition). - TZ=$TIMEZONE hwclock $HWCLOCK_PARAMS && stat_done || stat_fail + [[ $TIMEZONE ]] && export TZ=$TIMEZONE + hwclock $HWCLOCK_PARAMS && stat_done || stat_fail + unset TZ fi # Start/trigger UDev, load MODULES and settle UDev -- cgit v1.2.3 From d033692df18c1ba6385b20871e8fe5fa5a1e3514 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 4 Mar 2012 22:51:15 -0500 Subject: functions: check for length before using array This avoids passing an empty array to umount Signed-off-by: Dave Reisner --- functions | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions b/functions index 833711b..a3c2660 100644 --- a/functions +++ b/functions @@ -505,7 +505,9 @@ umount_all() { mounts=("$target" "${mounts[@]}") done < <(findmnt -mrunRo TARGET,FSTYPE,OPTIONS /) - umount -r "${mounts[@]}" + if (( ${#mounts[*]} )); then + umount -r "${mounts[@]}" + fi } -- cgit v1.2.3 From ea3f8c5761d7f1cdf693746bc3322d9482b349ce Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 4 Mar 2012 22:51:54 -0500 Subject: network: pass -q to dhcpcd on shutdown Avoid unnecessary output about sending a SIGTERM to the active PID. Signed-off-by: Dave Reisner --- network | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network b/network index faaac78..2439dba 100755 --- a/network +++ b/network @@ -52,7 +52,7 @@ network_down() { have_interface "$interface" || return 1 if [[ -f /run/dhcpcd-$interface.pid ]]; then - dhcpcd -k $interface || return 1 + dhcpcd -qk $interface || return 1 else ip addr flush dev $interface || return 1 fi -- cgit v1.2.3 From bdad979a6f062228c318f0903f3d11c6865c5ff1 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 5 Mar 2012 20:16:38 +0100 Subject: netfs: force umounts in order to avoid hanging on NFS This should hopefully fix problems with umount hanging on shutdown. FWIW, this is also what systemd does. Signed-off-by: Tom Gundersen --- netfs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netfs b/netfs index ea7e4eb..bd459ef 100755 --- a/netfs +++ b/netfs @@ -16,9 +16,9 @@ case "$1" in ;; stop) stat_busy "Unmounting Network Filesystems" - umount -a -O _netdev + umount -a -f -O _netdev rc=$? - umount -a -t "$NETFS" + umount -a -f -t "$NETFS" (( rc || $? )) && stat_die rm_daemon netfs stat_done -- cgit v1.2.3 From 11ac21c1cf74a428017c6335b7c74cf3cfedeb11 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 9 Mar 2012 13:26:49 -0500 Subject: arch-tmpfiles: allow passing specific config files Modify our path collection loop to accept the remaining argv as paths to config files. This overrides the default lookup for config files in /etc, /lib, and /run so that single config files can be parsed at a time (e.g. during package installation). Signed-off-by: Dave Reisner --- arch-tmpfiles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch-tmpfiles b/arch-tmpfiles index 3b94885..4b12841 100755 --- a/arch-tmpfiles +++ b/arch-tmpfiles @@ -235,7 +235,7 @@ fi # directories declared later in the tmpfiles_d array will override earlier # directories, on a per file basis. # Example: `/etc/tmpfiles.d/foo.conf' supersedes `/usr/lib/tmpfiles.d/foo.conf'. -for path in "${tmpfiles_d[@]}"; do +for path in "${@:-${tmpfiles_d[@]}}"; do [[ -f $path ]] && fragments[${path##*/}]=${path%/*} done -- cgit v1.2.3 From 9fefe217d5e6dff9415e47e35f855740c11138f9 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 11 Mar 2012 13:12:28 -0400 Subject: arch-tmpfiles: don't try to resolve numeric UIDs/GIDs The whole point of using numeric IDs is to avoid resolution in the passwd/group databases. If we encounter an ID which is simply numeric, leave it alone. Looks like I broke this in a4558c4c trying to be a bit too clever. Signed-off-by: Dave Reisner --- arch-tmpfiles | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch-tmpfiles b/arch-tmpfiles index 4b12841..8d927de 100755 --- a/arch-tmpfiles +++ b/arch-tmpfiles @@ -25,13 +25,19 @@ checkparams() { fi # uid must be numeric or a valid user name - if [[ $uid ]] && ! getent passwd "$uid" >/dev/null; then - return 1 + # don't try to resolve numeric IDs in case they don't exist + if [[ $uid ]]; then + if [[ $uid != +([0-9]) ]] && ! getent passwd "$uid" >/dev/null; then + return 1 + fi fi # gid must be numeric or a valid group name - if [[ $gid ]] && ! getent group "$gid" >/dev/null; then - return 1 + # don't try to resolve numeric IDs in case they don't exist + if [[ $gid ]]; then + if [[ $gid != +([0-9]) ]] && ! getent group "$gid" >/dev/null; then + return 1 + fi fi return 0 -- cgit v1.2.3 From 523e05098af3b9233d286a0f31afe7e879bcd6a8 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 12 Mar 2012 14:45:52 +0100 Subject: Makefile: Mark phony targets Most targets used in our Makefile don't refer to files. Use the ".PHONY" special target to mark these. Doing this prevents us from file name conflicts and improves performance a bit. Signed-off-by: Lukas Fleischer --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 3e83e58..1081730 100644 --- a/Makefile +++ b/Makefile @@ -62,3 +62,5 @@ tar: release: tar scp initscripts-$(VER).tar.xz gerolde.archlinux.org:/srv/ftp/other/initscripts/ scp initscripts-$(VER).tar.xz pkgbuild.com:~/svn-packages/initscripts/trunk/ + +.PHONY: all installdirs install doc clean tar release -- cgit v1.2.3 From 1b653d6986714848a848b421c50dafe2868829e6 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 12 Mar 2012 14:36:45 +0100 Subject: Makefile: Rework man page handling * Move the list of man page files to a variable to avoid code duplication. Also, use generic code in the install target and extract man pages from the newly introduced variable. * Use generic (wildcard) rules for man page generation instead of having one rule per source/target file. * Use "$(DESTDIR)" instead of "${DESTDIR}" everywhere. Signed-off-by: Lukas Fleischer --- Makefile | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 1081730..a429ddd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ VER := $(shell git describe) + DIRS := \ /etc/rc.d \ /etc/conf.d \ @@ -16,6 +17,13 @@ DIRS := \ /usr/share/man/man5 \ /usr/share/man/man8 +MAN_PAGES := \ + rc.d.8 \ + rc.conf.5 \ + locale.conf.5 \ + vconsole.conf.5 \ + hostname.5 + all: doc installdirs: @@ -29,32 +37,23 @@ install: installdirs doc install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/etc/profile.d locale.sh install -m755 -t $(DESTDIR)/usr/sbin rc.d - install -m644 -t ${DESTDIR}/usr/share/man/man8 rc.d.8 - install -m644 -t ${DESTDIR}/usr/share/man/man5 rc.conf.5 locale.conf.5 vconsole.conf.5 hostname.5 + install -m644 -t $(DESTDIR)/usr/share/man/man5 $(filter %.5, $(MAN_PAGES)) + install -m644 -t $(DESTDIR)/usr/share/man/man8 $(filter %.8, $(MAN_PAGES)) install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d -rc.d.8: rc.d.8.txt - a2x -d manpage -f manpage rc.d.8.txt - -rc.conf.5: rc.conf.5.txt - a2x -d manpage -f manpage rc.conf.5.txt - -locale.conf.5: locale.conf.5.txt - a2x -d manpage -f manpage locale.conf.5.txt - -vconsole.conf.5: vconsole.conf.5.txt - a2x -d manpage -f manpage vconsole.conf.5.txt +%.5: %.5.txt + a2x -d manpage -f manpage $< -hostname.5: hostname.5.txt - a2x -d manpage -f manpage hostname.5.txt +%.8: %.8.txt + a2x -d manpage -f manpage $< -doc: rc.d.8 rc.conf.5 locale.conf.5 vconsole.conf.5 hostname.5 +doc: $(MAN_PAGES) clean: - rm -f rc.d.8 rc.conf.5 locale.conf.5 vconsole.conf.5 hostname.5 + rm -f $(MAN_PAGES) tar: git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz -- cgit v1.2.3 From cb18be3f401a2c693d66a9417e479ed74e17c2f0 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 12 Mar 2012 23:26:15 +0100 Subject: timezone: always symlink to zoneinfo rather than copying MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Behave as described in the manpage. This makes sure that we don't need to write to /etc unnecessarily in case of updates to zoneinfo. The reason for keeping a copy in /etc was if /usr was on a separate unmounted partition, but this is no longer supported. Reported-by: Sébastien Luttringer Signed-off-by: Tom Gundersen --- functions | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/functions b/functions index a3c2660..3593892 100644 --- a/functions +++ b/functions @@ -417,13 +417,8 @@ set_timezone() { if [[ -L /etc/localtime && /etc/localtime -ef $zonefile ]]; then return 0 - fi - - # respect the user's decision to symlink or copy - if [[ -L /etc/localtime ]]; then - ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime else - cp --remove-destination "/usr/share/zoneinfo/$tz" /etc/localtime + ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime fi } -- cgit v1.2.3 From 299c22ad5c124cb62e1ba35447440947fe4afb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Mon, 12 Mar 2012 22:08:57 +0100 Subject: arch-sysctl: allow passing specific config files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify our path collection loop to accept the remaining argv as paths to config files. This overrides the default lookup for config files in /etc, /lib, and /run so that single config files can be parsed at a time Credits to Dave Reisner in 11ac21c1cf74 Signed-off-by: Sébastien Luttringer --- arch-sysctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch-sysctl b/arch-sysctl index 4c54217..e27369d 100755 --- a/arch-sysctl +++ b/arch-sysctl @@ -18,7 +18,7 @@ declare -A fragments # files declared later in the sysctl_d array will override earlier # Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. -for path in "${sysctl_d[@]}"; do +for path in "${@:-${sysctl_d[@]}}"; do [[ -f $path ]] && fragments[${path##*/}]=$path done -- cgit v1.2.3 From 788daea5db4445f02fc156132f00829e1107dc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Mon, 12 Mar 2012 22:41:11 +0100 Subject: Support additional binary formats at boot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch mount kernel binfmt_misc filesystem at boot and allow loading of a default configuration inspired from systemd binfmt.d way. Signed-off-by: Sébastien Luttringer --- Makefile | 4 +++- arch-binfmt | 36 ++++++++++++++++++++++++++++++++++++ rc.multi | 3 +++ rc.sysinit | 5 ++++- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 arch-binfmt diff --git a/Makefile b/Makefile index 3e83e58..2cc6867 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ DIRS := \ /usr/sbin \ /etc/tmpfiles.d \ /usr/lib/tmpfiles.d \ + /etc/binfmt.d \ + /usr/lib/binfmt.d \ /etc/sysctl.d \ /usr/lib/sysctl.d \ /usr/lib/initscripts \ @@ -31,7 +33,7 @@ install: installdirs doc install -m755 -t $(DESTDIR)/usr/sbin rc.d install -m644 -t ${DESTDIR}/usr/share/man/man8 rc.d.8 install -m644 -t ${DESTDIR}/usr/share/man/man5 rc.conf.5 locale.conf.5 vconsole.conf.5 hostname.5 - install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl + install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl arch-binfmt install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d diff --git a/arch-binfmt b/arch-binfmt new file mode 100755 index 0000000..6931843 --- /dev/null +++ b/arch-binfmt @@ -0,0 +1,36 @@ +#!/bin/bash +# +# /usr/lib/initscripts/arch-binfmt +# +# Configure additional binary formats at boot +# + +shopt -s nullglob + +declare -a binfmt_d=( + /usr/lib/binfmt.d/*.conf + /etc/binfmt.d/*.conf + /run/binfmt.d/*.conf +) +declare -A fragments + +# check binfmt_misc filesystem is mounted +mountpoint -q /proc/sys/fs/binfmt_misc || + { echo "/proc/sys/fs/binfmt_misc is not mounted"; exit 1;} + +# files declared later in the sysctl_d array will override earlier +# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. +for path in "${@:-${binfmt_d[@]}}"; do + [[ -f $path ]] && fragments[${path##*/}]=$path +done + +for path in "${fragments[@]}"; do + while read -r line; do + [[ ${line:0:1} == '#' ]] && continue + printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register + done < "$path" +done + +: + +# vim: set ts=2 sw=2 noet: diff --git a/rc.multi b/rc.multi index 19623d8..20ed9bc 100755 --- a/rc.multi +++ b/rc.multi @@ -11,6 +11,9 @@ run_hook multi_start # Load sysctl config files [[ -x /usr/lib/initscripts/arch-sysctl ]] && /usr/lib/initscripts/arch-sysctl +# Load additional binary formats +[[ -x /usr/lib/initscripts/arch-binfmt ]] && /usr/lib/initscripts/arch-binfmt + # Start daemons for daemon in "${DAEMONS[@]}"; do case ${daemon:0:1} in diff --git a/rc.sysinit b/rc.sysinit index b38d350..9880995 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -11,8 +11,11 @@ printhl "Arch Linux\n" printhl "${C_H2}http://www.archlinux.org" printsep -# mount /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm (the api filesystems) +# mount the api filesystems +# /proc, /proc/sys/fs/binfmt_misc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev +mountpoint -q /proc/sys/fs/binfmt_misc || + mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid -- cgit v1.2.3 From 9f75591c8a56ba7ec1ea20cfe16dd10a83c65503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Mon, 12 Mar 2012 22:50:42 +0100 Subject: Remove NEED_ROOT crap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch revert patch 042d197b4d989ec64. NEED_ROOT was introduced to fix bug FS#24095. But in fact it doesn't solve it because nobody use it. The idea was to allow initscripts developper to have a check runned by every scripts which tell if scripts need to be run as root (most of them) or not (and the script check itself which part of him have to be run as root). All this to display a cute error message. I think this complexity is superfluous and let part of initscript will fail if rights are not enough. I must confess that we should have marked this bug as wontfix rather than do that. Signed-off-by: Sébastien Luttringer --- functions | 10 ---------- rc.d | 1 - 2 files changed, 11 deletions(-) diff --git a/functions b/functions index a3c2660..25861d0 100644 --- a/functions +++ b/functions @@ -656,15 +656,5 @@ for f in /etc/rc.d/functions.d/*; do [[ -e $f ]] && . "$f" done -# Exit current shell if user is not root -need_root() { - (( EUID )) && printf 'You need to be root.\n' && exit 1 -} - -# Quit script if it's not running by root -# This can be disabled in scripts sourcing functions by setting NEED_ROOT=0 -# A local call to need_root can be done to ensure part of script need root privilege -(( NEED_ROOT )) && need_root - # End of file # vim: set ts=2 sw=2 noet: diff --git a/rc.d b/rc.d index 115dc05..0cfbdaf 100755 --- a/rc.d +++ b/rc.d @@ -1,6 +1,5 @@ #!/bin/bash -NEED_ROOT=0 # this script can be run without be root . /etc/rc.conf . /etc/rc.d/functions -- cgit v1.2.3 From e10b98ba9374c145df0719bb2e9c7fe0d4b614ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Tue, 13 Mar 2012 23:43:45 +0100 Subject: arch-binfmt: move api filesytem mounting from rc.sysinit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this will avoid filesytem to be mounted at every startup if not binfmt is used Signed-off-by: Sébastien Luttringer --- arch-binfmt | 31 ++++++++++++++++++++----------- rc.sysinit | 4 +--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/arch-binfmt b/arch-binfmt index 6931843..91468ef 100755 --- a/arch-binfmt +++ b/arch-binfmt @@ -7,20 +7,29 @@ shopt -s nullglob -declare -a binfmt_d=( - /usr/lib/binfmt.d/*.conf - /etc/binfmt.d/*.conf - /run/binfmt.d/*.conf -) -declare -A fragments +declare -a binfmt_d +# files given has argv supersede config files +if (( $# > 0 )); then + for arg; do [[ -r "$arg" ]] && binfmt_d+=("$arg"); done +else + binfmt_d=( + /usr/lib/binfmt.d/*.conf + /etc/binfmt.d/*.conf + /run/binfmt.d/*.conf + ) +fi + +# check there is file to load +(( ${#binfmt_d[@]} > 0 )) || exit 1 -# check binfmt_misc filesystem is mounted +# mount binfmt_misc if api filesystem is missing mountpoint -q /proc/sys/fs/binfmt_misc || - { echo "/proc/sys/fs/binfmt_misc is not mounted"; exit 1;} + mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc -# files declared later in the sysctl_d array will override earlier -# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. -for path in "${@:-${binfmt_d[@]}}"; do +# files declared later in the binfmt_d array will override earlier +# Example: `/etc/binfmt.d/foo.conf' supersedes `/usr/lib/binfmt.d/foo.conf'. +declare -A fragments +for path in "${binfmt_d[@]}"; do [[ -f $path ]] && fragments[${path##*/}]=$path done diff --git a/rc.sysinit b/rc.sysinit index 9880995..ff0b6d2 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -12,10 +12,8 @@ printhl "${C_H2}http://www.archlinux.org" printsep # mount the api filesystems -# /proc, /proc/sys/fs/binfmt_misc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm +# /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev -mountpoint -q /proc/sys/fs/binfmt_misc || - mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid -- cgit v1.2.3 From ddb6048878ca329a23ee9a0f10919a03d41b4a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Wed, 14 Mar 2012 00:58:23 +0100 Subject: arch-binfmt: add manpage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Luttringer --- Makefile | 3 ++- binfmt.d.5.txt | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 binfmt.d.5.txt diff --git a/Makefile b/Makefile index 46ce5b0..b232e9f 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ MAN_PAGES := \ rc.conf.5 \ locale.conf.5 \ vconsole.conf.5 \ - hostname.5 + hostname.5 \ + binfmt.d.5 all: doc diff --git a/binfmt.d.5.txt b/binfmt.d.5.txt new file mode 100644 index 0000000..2925256 --- /dev/null +++ b/binfmt.d.5.txt @@ -0,0 +1,57 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +binfmt.d(5) +=========== + +NAME +---- +binfmt.d - Configure additional binary formats at boot + +SYNOPSIS +-------- +/usr/lib/binfmt.d/*.conf + +/etc/binfmt.d/*.conf + +/run/binfmt.d/*.conf + +DESCRIPTION +----------- +*initscripts* uses files from the above directories to configure additional +binary formats to register during boot in the kernel. + +CONFIGURATION FORMAT +-------------------- +Each file contains a list of binfmt_misc kernel binary format rules. +Consult *binfmt_misc.txt*[1] for more information on registration of +additional binary formats and how to write rules. + +Empty lines and lines beginning with ; and # are ignored. Note that this +means you may not use ; and # as delimiter in binary format rules. + +Each configuration file is named in the style of .conf. Files in +/etc/ overwrite files with the same name in /usr/lib/. Files in /run +overwrite files with the same name in /etc/ and /usr/lib/. Packages +should install their configuration files in /usr/lib/, files in /etc/ are +reserved for the local administration, which possibly decides to +overwrite the configurations installed from packages. All files are +sorted by filename in alphabetical order, regardless in which of the +directories they reside, to ensure that a specific configuration file +takes precedence over another file with an alphabetically later name. + +EXAMPLE +------- +*Example 1. /etc/binfmt.d/wine.conf example:* + + # Start WINE on Windows executables + :DOSWin:M::MZ::/usr/bin/wine: + +NOTES +----- +*1. binfmt_misc.txt:* + http://www.kernel.org/doc/Documentation/binfmt_misc.txt + +AUTHORS +------- +Original by Lennart Poettering, adapted to Arch Linux by Sébastien Luttringer. -- cgit v1.2.3 From e3050bd87ec873bc4ac1dc21c42c7abd02c3b408 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 16 Mar 2012 19:16:47 -0400 Subject: reorder fsck opts, explicitly set end of options marker Fixes FS#28947. Signed-off-by: Dave Reisner --- functions | 2 +- rc.sysinit | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions b/functions index f8a7acd..0b7fd8d 100644 --- a/functions +++ b/functions @@ -432,7 +432,7 @@ fsck_all() { IGNORE_MOUNTED="-M" fi - fsck -A -T -C${FSCK_FD} -a -t no${NETFS//,/,no},noopts=_netdev ${FORCEFSCK} ${IGNORE_MOUNTED} + fsck -A -T -C${FSCK_FD} -a -t no${NETFS//,/,no},noopts=_netdev ${IGNORE_MOUNTED} -- ${FORCEFSCK} } # Single-user login and/or automatic reboot after fsck (if needed) diff --git a/rc.sysinit b/rc.sysinit index ff0b6d2..8fa4270 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -176,7 +176,7 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then fi # Check filesystems -[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f" +[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-f" declare -r FORCEFSCK if [[ -n $FORCEFSCK ]] || { [[ ! -f /fastboot ]] && ! in_array fastboot $(< /proc/cmdline); }; then -- cgit v1.2.3 From 28ec5b76ca5cbb53ec9d5de73749dbe76db7611a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 17 Mar 2012 11:12:55 +0100 Subject: fsck: move FORCEFSCK/FASTBOOT logic to fsck_all Avoid global variables, and make things clearer. Signed-off-by: Tom Gundersen --- functions | 6 ++++++ rc.sysinit | 29 ++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/functions b/functions index 0b7fd8d..747e42d 100644 --- a/functions +++ b/functions @@ -428,6 +428,12 @@ NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.g # Check local filesystems fsck_all() { + [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-f" + + if [[ ! -n $FORCEFSCK ]] && { [[ -f /fastboot ]] || in_array fastboot $(< /proc/cmdline); }; then + return + fi + if [[ -e /run/initramfs/root-fsck ]]; then IGNORE_MOUNTED="-M" fi diff --git a/rc.sysinit b/rc.sysinit index 8fa4270..0876d05 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -176,24 +176,19 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then fi # Check filesystems -[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-f" -declare -r FORCEFSCK - -if [[ -n $FORCEFSCK ]] || { [[ ! -f /fastboot ]] && ! in_array fastboot $(< /proc/cmdline); }; then - run_hook sysinit_prefsck - if [[ -x $(type -P fsck) ]]; then - stat_busy "Checking Filesystems" - fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}" - declare -r fsckret=$? - (( fsckret <= 1 )) && stat_done || stat_fail - else - declare -r fsckret=0 - fi - run_hook sysinit_postfsck - - # Single-user login and/or automatic reboot if needed - fsck_reboot $fsckret +run_hook sysinit_prefsck +if [[ -x $(type -P fsck) ]]; then + stat_busy "Checking Filesystems" + fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}" + declare -r fsckret=$? + (( fsckret <= 1 )) && stat_done || stat_fail +else + declare -r fsckret=0 fi +run_hook sysinit_postfsck + +# Single-user login and/or automatic reboot if needed +fsck_reboot $fsckret status "Remounting Root" \ mount -o remount / -- cgit v1.2.3 From cb1ddfc15431f2e6498c93cd4da53e14f1147659 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 19 Feb 2012 20:06:26 -0500 Subject: sysinit: remove cryptsetup compat We haven't had the static binary in nearly 2 years, so simply call this without a PATH lookup. Signed-off-by: Dave Reisner --- functions | 11 ----------- rc.sysinit | 14 +++++++------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/functions b/functions index 747e42d..129b3d4 100644 --- a/functions +++ b/functions @@ -379,17 +379,6 @@ activate_vgs() { (( $? == 0 )) && stat_done || stat_fail } -# Arch cryptsetup packages traditionally contained the binaries -# /usr/sbin/cryptsetup -# /sbin/cryptsetup.static -# By default, initscripts used the /sbin/cryptsetup.static. -# Newer packages will only have /sbin/cryptsetup and no static binary -# This ensures maximal compatibility with the old and new layout -for CS in /sbin/cryptsetup /usr/sbin/cryptsetup \ - /sbin/cryptsetup.static ''; do - [[ -x $CS ]] && break -done - read_crypttab() { # $1 = function to call with the split out line from the crypttab local line nspo failed=0 diff --git a/rc.sysinit b/rc.sysinit index 0876d05..ddac829 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -89,7 +89,7 @@ udevd_modprobe sysinit activate_vgs # Set up non-root encrypted partition mappings -if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then +if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then stat_busy "Unlocking encrypted volumes:" modprobe -q dm-crypt 2>/dev/null do_unlock() { @@ -102,7 +102,7 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then # Ordering of options is different if you are using LUKS vs. not. # Use ugly swizzling to deal with it. # isLuks only gives an exit code but no output to stdout or stderr. - if $CS isLuks "$2" 2>/dev/null; then + if cryptsetup isLuks "$2" 2>/dev/null; then open=luksOpen a=$2 b=$1 @@ -125,13 +125,13 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then fi if (( _overwriteokay == 0 )); then false - elif $CS -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then + elif cryptsetup -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then stat_append "creating swapspace.." mkswap -f -L $1 /dev/mapper/$1 >/dev/null fi;; ASK) printf "\nOpening '$1' volume:\n" - $CS $4 $open "$a" "$b" < /dev/console;; + cryptsetup $4 $open "$a" "$b" < /dev/console;; /dev*) local ckdev=${3%%:*} local cka=${3#*:} @@ -153,13 +153,13 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then # cka is numeric: cka=offset, ckb=length dd if=${ckdev} of=${ckfile} bs=1 skip=${cka} count=${ckb} >/dev/null 2>&1;; esac - $CS -d ${ckfile} $4 $open "$a" "$b" >/dev/null + cryptsetup -d ${ckfile} $4 $open "$a" "$b" >/dev/null dd if=/dev/urandom of=${ckfile} bs=1 count=$(stat -c %s ${ckfile}) conv=notrunc >/dev/null 2>&1 rm ${ckfile};; /*) - $CS -d "$3" $4 $open "$a" "$b" >/dev/null;; + cryptsetup -d "$3" $4 $open "$a" "$b" >/dev/null;; *) - echo "$3" | $CS $4 $open "$a" "$b" >/dev/null;; + echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;; esac if (( $? )); then failed=1 -- cgit v1.2.3 From 4c6aba5ab3812523e65806c2876035b4498aad2e Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 17 Mar 2012 11:30:25 +0100 Subject: sysinit: do not unconditionally modprobe any more dm-mod and dm-crypt will be autoloaded when needed (at least on kernels newer than 2.6.36). The rtc modules should be compiled in, as they have been in the official kernels for some time. Signed-off-by: Tom Gundersen --- functions | 2 -- rc.sysinit | 3 --- 2 files changed, 5 deletions(-) diff --git a/functions b/functions index 129b3d4..f5da93c 100644 --- a/functions +++ b/functions @@ -372,9 +372,7 @@ udevd_modprobe() { activate_vgs() { [[ $USELVM = [yY][eE][sS] && -x $(type -P lvm) && -d /sys/block ]] || return 0 - # Kernel 2.6.x, LVM2 groups stat_busy "Activating LVM2 groups" - modprobe -q dm-mod 2>/dev/null vgchange --sysinit -a y >/dev/null (( $? == 0 )) && stat_done || stat_fail } diff --git a/rc.sysinit b/rc.sysinit index ddac829..06b4bda 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -54,8 +54,6 @@ esac if [[ $HWCLOCK_PARAMS ]]; then stat_busy "Adjusting system time and setting kernel timezone" - # enable rtc access - modprobe -q -a rtc-cmos rtc genrtc # Adjust the system time for timezone offset if rtc is not in UTC # 1. Make creation time on device nodes sane (FS#8665) @@ -91,7 +89,6 @@ activate_vgs # Set up non-root encrypted partition mappings if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then stat_busy "Unlocking encrypted volumes:" - modprobe -q dm-crypt 2>/dev/null do_unlock() { # $1 = requested name # $2 = source device -- cgit v1.2.3 From e57e4ebe4aee02b175f3d4d13a0fa1838769b3f2 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 17 Mar 2012 11:38:14 +0100 Subject: crypto: move function from sysinit to functions No functional change, just improve readability. Signed-off-by: Tom Gundersen --- functions | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rc.sysinit | 77 ------------------------------------------------------------- 2 files changed, 78 insertions(+), 77 deletions(-) diff --git a/functions b/functions index f5da93c..11ab11f 100644 --- a/functions +++ b/functions @@ -377,6 +377,84 @@ activate_vgs() { (( $? == 0 )) && stat_done || stat_fail } +do_unlock() { + # $1 = requested name + # $2 = source device + # $3 = password + # $4 = options + stat_append "${1}.." + local open=create a=$1 b=$2 failed=0 + # Ordering of options is different if you are using LUKS vs. not. + # Use ugly swizzling to deal with it. + # isLuks only gives an exit code but no output to stdout or stderr. + if cryptsetup isLuks "$2" 2>/dev/null; then + open=luksOpen + a=$2 + b=$1 + fi + case $3 in + SWAP) + local _overwriteokay=0 + if [[ -b $2 && -r $2 ]]; then + # This is DANGEROUS! If there is any known file system, + # partition table, RAID or LVM volume on the device + # we don't overwrite it. + # + # 'blkid' returns 2 if no valid signature has been found. + # Only in this case we should allow overwriting the device. + # + # This sanity check _should_ be sufficient, but it might not. + # This may cause dataloss if it is not used carefully. + blkid -p "$2" &>/dev/null + (( $? == 2 )) && _overwriteokay=1 + fi + if (( _overwriteokay == 0 )); then + false + elif cryptsetup -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then + stat_append "creating swapspace.." + mkswap -f -L $1 /dev/mapper/$1 >/dev/null + fi;; + ASK) + printf "\nOpening '$1' volume:\n" + cryptsetup $4 $open "$a" "$b" < /dev/console;; + /dev*) + local ckdev=${3%%:*} + local cka=${3#*:} + local ckb=${cka#*:} + local cka=${cka%:*} + local ckfile=/dev/ckfile + local ckdir=/dev/ckdir + case ${cka} in + *[!0-9]*) + # Use a file on the device + # cka is not numeric: cka=filesystem, ckb=path + mkdir ${ckdir} + mount -r -t ${cka} ${ckdev} ${ckdir} + dd if=${ckdir}/${ckb} of=${ckfile} >/dev/null 2>&1 + umount ${ckdir} + rmdir ${ckdir};; + *) + # Read raw data from the block device + # cka is numeric: cka=offset, ckb=length + dd if=${ckdev} of=${ckfile} bs=1 skip=${cka} count=${ckb} >/dev/null 2>&1;; + esac + cryptsetup -d ${ckfile} $4 $open "$a" "$b" >/dev/null + dd if=/dev/urandom of=${ckfile} bs=1 count=$(stat -c %s ${ckfile}) conv=notrunc >/dev/null 2>&1 + rm ${ckfile};; + /*) + cryptsetup -d "$3" $4 $open "$a" "$b" >/dev/null;; + *) + echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;; + esac + if (( $? )); then + failed=1 + stat_append "failed " + else + stat_append "ok " + fi + return $failed +} + read_crypttab() { # $1 = function to call with the split out line from the crypttab local line nspo failed=0 diff --git a/rc.sysinit b/rc.sysinit index 06b4bda..3528bb2 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -89,83 +89,6 @@ activate_vgs # Set up non-root encrypted partition mappings if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then stat_busy "Unlocking encrypted volumes:" - do_unlock() { - # $1 = requested name - # $2 = source device - # $3 = password - # $4 = options - stat_append "${1}.." - local open=create a=$1 b=$2 failed=0 - # Ordering of options is different if you are using LUKS vs. not. - # Use ugly swizzling to deal with it. - # isLuks only gives an exit code but no output to stdout or stderr. - if cryptsetup isLuks "$2" 2>/dev/null; then - open=luksOpen - a=$2 - b=$1 - fi - case $3 in - SWAP) - local _overwriteokay=0 - if [[ -b $2 && -r $2 ]]; then - # This is DANGEROUS! If there is any known file system, - # partition table, RAID or LVM volume on the device - # we don't overwrite it. - # - # 'blkid' returns 2 if no valid signature has been found. - # Only in this case we should allow overwriting the device. - # - # This sanity check _should_ be sufficient, but it might not. - # This may cause dataloss if it is not used carefully. - blkid -p "$2" &>/dev/null - (( $? == 2 )) && _overwriteokay=1 - fi - if (( _overwriteokay == 0 )); then - false - elif cryptsetup -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then - stat_append "creating swapspace.." - mkswap -f -L $1 /dev/mapper/$1 >/dev/null - fi;; - ASK) - printf "\nOpening '$1' volume:\n" - cryptsetup $4 $open "$a" "$b" < /dev/console;; - /dev*) - local ckdev=${3%%:*} - local cka=${3#*:} - local ckb=${cka#*:} - local cka=${cka%:*} - local ckfile=/dev/ckfile - local ckdir=/dev/ckdir - case ${cka} in - *[!0-9]*) - # Use a file on the device - # cka is not numeric: cka=filesystem, ckb=path - mkdir ${ckdir} - mount -r -t ${cka} ${ckdev} ${ckdir} - dd if=${ckdir}/${ckb} of=${ckfile} >/dev/null 2>&1 - umount ${ckdir} - rmdir ${ckdir};; - *) - # Read raw data from the block device - # cka is numeric: cka=offset, ckb=length - dd if=${ckdev} of=${ckfile} bs=1 skip=${cka} count=${ckb} >/dev/null 2>&1;; - esac - cryptsetup -d ${ckfile} $4 $open "$a" "$b" >/dev/null - dd if=/dev/urandom of=${ckfile} bs=1 count=$(stat -c %s ${ckfile}) conv=notrunc >/dev/null 2>&1 - rm ${ckfile};; - /*) - cryptsetup -d "$3" $4 $open "$a" "$b" >/dev/null;; - *) - echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;; - esac - if (( $? )); then - failed=1 - stat_append "failed " - else - stat_append "ok " - fi - return $failed - } crypto_unlocked=0 read_crypttab do_unlock && stat_done || stat_fail # Maybe someone has LVM on an encrypted block device -- cgit v1.2.3 From 807d8f9c858d2adf5285a3ba27aec6ed226d14d7 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 17 Mar 2012 13:46:12 +0100 Subject: crypttab: warn if using passphrase in /etc/crypttab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no reason not to use a keyfile, and allowing literal passphrases in crypttab has caused issues with the parsing in the past. Furthermore, it is not supported by any other crypttab implementation (to the best of my knowledge). The use of keyfiles have been the recomendation in /etc/crypttab for as long as I can remember. We are looking at refactoring the encryption support, and I think it makes sense to drop support for this when we move to the new implementation. Cc: Thomas Bächler Cc: Matthew Monaco Cc: Dave Reisner Signed-off-by: Tom Gundersen --- functions | 1 + 1 file changed, 1 insertion(+) diff --git a/functions b/functions index 11ab11f..04b7ec4 100644 --- a/functions +++ b/functions @@ -444,6 +444,7 @@ do_unlock() { /*) cryptsetup -d "$3" $4 $open "$a" "$b" >/dev/null;; *) + printf "${C_FAIL}crypttab contains a literal encryption key. This will stop working in the future.${C_OTHER}\n" echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;; esac if (( $? )); then -- cgit v1.2.3 From a8691173ac04321f444b949ec041d94c83ad02af Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 21 Mar 2012 11:29:41 +0100 Subject: rc.d: movebash completions to /usr/share This is the standard location with the new bash-completinos package. Signed-off-by: Tom Gundersen --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b232e9f..b5c1da4 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ DIRS := \ /etc/sysctl.d \ /usr/lib/sysctl.d \ /usr/lib/initscripts \ - /etc/bash_completion.d \ + /usr/share/bash-completion/completions \ /usr/share/zsh/site-functions \ /usr/share/man/man5 \ /usr/share/man/man8 @@ -44,7 +44,7 @@ install: installdirs doc install -m644 -t $(DESTDIR)/usr/share/man/man8 $(filter %.8, $(MAN_PAGES)) install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl arch-binfmt install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf - install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d + install -m644 -T bash-completion $(DESTDIR)/usr/share/bash-completion/completions/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d %.5: %.5.txt -- cgit v1.2.3 From e980b8e52b52c176fa1f3fa80d62b5231b4395f4 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 21 Mar 2012 12:39:27 +0100 Subject: man: don't ship manpage for binfmt for now This will be enabled in the next release once we can coordinate with systemd. I'd also like to document the other formats (tmpfiles, sysctl) at the same time. Signed-off-by: Tom Gundersen --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b5c1da4..598417f 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,7 @@ MAN_PAGES := \ rc.conf.5 \ locale.conf.5 \ vconsole.conf.5 \ - hostname.5 \ - binfmt.d.5 + hostname.5 all: doc -- cgit v1.2.3 From 650aa0db2bb92b6751461baf71df169dfd107cab Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 21 Mar 2012 13:06:29 +0100 Subject: fsck: add return value Reported-by: Lukas Fleischer Signed-off-by: Tom Gundersen --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 04b7ec4..f59f9dd 100644 --- a/functions +++ b/functions @@ -497,7 +497,7 @@ fsck_all() { [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-f" if [[ ! -n $FORCEFSCK ]] && { [[ -f /fastboot ]] || in_array fastboot $(< /proc/cmdline); }; then - return + return 0 fi if [[ -e /run/initramfs/root-fsck ]]; then -- cgit v1.2.3 From 2f313dea7e7f4be58bb911596b3c85dcf0e09381 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 25 Mar 2012 20:28:06 +0200 Subject: rc.shutdown: fix tearing down of encrypted devices This should have been done together with cb1ddfc15431f2e6498c93cd4da53e14f1147659. Mea culpa. Signed-off-by: Tom Gundersen --- rc.shutdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 54a1e9a..ec30d56 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -65,14 +65,14 @@ status "Unmounting Non-API Filesystems" umount_all run_hook shutdown_postumount # Kill non-root encrypted partition mappings -if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then +if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then stat_busy "Deactivating encrypted volumes:" # Maybe someone has LVM on an encrypted block device # executing an extra vgchange is errorless [[ $USELVM = [Yy][Ee][Ss] ]] && vgchange --sysinit -a n &>/dev/null do_lock() { stat_append "${1}.." - if $CS remove "$1" &>/dev/null; then + if cryptsetup remove "$1" &>/dev/null; then stat_append "ok " else stat_append "failed " -- cgit v1.2.3 From 0fa2a47e78d318673039f08b6dc77e6abcf7b8ad Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 1 Apr 2012 23:13:48 +0200 Subject: udev: change to new location Both the old and the new location works at the moment, but we want to remove the symlink, so change to the new location. Signed-off-by: Tom Gundersen --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index f59f9dd..3096aaa 100644 --- a/functions +++ b/functions @@ -348,7 +348,7 @@ kill_all() { udevd_modprobe() { # $1 = where we are being called from. # This is used to determine which hooks to run. - status "Starting UDev Daemon" /lib/udev/udevd --daemon + status "Starting UDev Daemon" /usr/lib/udev/udevd --daemon run_hook "$1_udevlaunched" -- cgit v1.2.3 From fa168b92773d44cb97cff05a47c53ed899315120 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 6 Apr 2012 12:15:53 -0400 Subject: functions: use a pipe for umount_all instead of a PE We don't care about the side effects of the subshell created by the pipe since everything is localized within this function. Use the more "canonical" syntax. This should stop the recurring bug reports that we seem to get from people who think they understand Bash syntax, e.g. FS#27203 FS#28331 FS#29145 FS#28582 FS#27098 FS#29496 Signed-off-by: Dave Reisner --- functions | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/functions b/functions index 3096aaa..7516345 100644 --- a/functions +++ b/functions @@ -549,32 +549,31 @@ mount_all() { umount_all() { # $1: restrict to fstype - local mounts + findmnt -mrunRo TARGET,FSTYPE,OPTIONS / | { + while read -r target fstype options; do + # match only targetted fstypes + if [[ $1 && $1 != "$fstype" ]]; then + continue + fi - while read -r target fstype options; do + # don't unmount API filesystems + if [[ $target = /@(proc|sys|run|dev|dev/pts) ]]; then + continue + fi - # match only targetted fstypes - if [[ $1 && $1 != "$fstype" ]]; then - continue - fi + # avoid networked devices + IFS=, read -ra opts <<< "$options" + if in_array _netdev "${opts[@]}"; then + continue + fi - # don't unmount API filesystems - if [[ $target = /@(proc|sys|run|dev|dev/pts) ]]; then - continue - fi + mounts=("$target" "${mounts[@]}") + done - # avoid networked devices - IFS=, read -ra opts <<< "$options" - if in_array _netdev "${opts[@]}"; then - continue + if (( ${#mounts[*]} )); then + umount -r "${mounts[@]}" fi - - mounts=("$target" "${mounts[@]}") - done < <(findmnt -mrunRo TARGET,FSTYPE,OPTIONS /) - - if (( ${#mounts[*]} )); then - umount -r "${mounts[@]}" - fi + } } -- cgit v1.2.3 From 4d6178953060b79af0b2aa14d36c972989662d35 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 28 Apr 2012 20:10:01 -0400 Subject: locale.sh: try harder to ensure locale is set If LANG is never set by /etc/locale.conf or /etc/rc.conf, ensure that we fall back on LANG=C. Signed-off-by: Dave Reisner --- locale.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/locale.sh b/locale.sh index fe82378..c465f6f 100644 --- a/locale.sh +++ b/locale.sh @@ -4,16 +4,12 @@ if [ -s /etc/locale.conf ]; then . /etc/locale.conf fi -if [ -n "$LANG" ]; then - export LANG -else - if [ -s /etc/rc.conf ]; then - export LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE") - else - export LANG="C" - fi +if [ -z "$LANG" ] && [ -s /etc/rc.conf ]; then + LANG=$(. /etc/rc.conf 2>/dev/null; echo "$LOCALE") fi +export LANG=${LANG:-C} + if [ -n "$LC_CTYPE" ]; then export LC_CTYPE else -- cgit v1.2.3 From 0c85927201b22e907c579b3959633a546804a849 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 30 Apr 2012 13:02:11 +0200 Subject: network: fix deprecation message We should point to the manpage rather than rc.conf. Fixes: FS#29494 Reported-by: Jason St. John Signed-off-by: Tom Gundersen --- network | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network b/network index 2439dba..322082c 100755 --- a/network +++ b/network @@ -19,7 +19,7 @@ need_legacy() { deprecated() { printf "${C_FAIL}Warning:${C_CLEAR} Your network settings are deprecated.\n" - printf " Please refer to /etc/rc.conf on how to define a single wired\n" + printf " Please refer to 'man 5 rc.conf' on how to define a single wired\n" printf " connection, or use a utility such as netcfg.\n" } -- cgit v1.2.3 From 956884005eb831f80853c1e6cfea5c2974a5be2b Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 30 Apr 2012 13:06:05 +0200 Subject: man: deprecate NETOWRKS This is deprecated by netcfg, so no need to keep documenting it. It stil works as before, but we don't want to encourage its use. Requested-by: Jouke Witteveen Signed-off-by: Tom Gundersen --- rc.conf.5.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/rc.conf.5.txt b/rc.conf.5.txt index c4087d0..b979f45 100644 --- a/rc.conf.5.txt +++ b/rc.conf.5.txt @@ -200,16 +200,7 @@ Default: "no" *NETWORKS=* -Enable these netcfg profiles at boot-up. These replace the network -configuration above and are useful if you happen to need more advanced -network features than the simple network service supports, -such as multiple network configurations (ie, laptop users). - - set to 'menu' to present a menu during boot-up (dialog package required) - - prefix an entry with a ! to disable it - -Network profiles are found in /etc/network.d -There is a template file included there that can be used to create -new profiles. This requires the netcfg package. +This functionality is deprecated, please refer to the 'netcfg' documentation. DAEMONS[[D]] ------------ -- cgit v1.2.3 From 222cefd41344f82a88dbf2b4a9480c966884d0e7 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 30 Apr 2012 13:12:47 +0200 Subject: vconsole: configure the console as early as possible This makes sure the correct keymap is set before asking users for input and it avoids (to the extent possible) fonts getting garbled when the font is set. Fixes: FS#29646 and FS#25599 Reported-by: Mathieu Pasquet Reported-by: Signed-off-by: Tom Gundersen --- rc.sysinit | 74 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 3528bb2..f91190c 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -36,6 +36,43 @@ run_hook sysinit_start # log all console messages bootlogd -p /run/bootlogd.pid +if [[ -s /etc/locale.conf ]]; then + parse_envfile /etc/locale.conf "LANG" + [[ $LANG ]] && LOCALE=$LANG +fi +if [[ ${LOCALE,,} =~ utf ]]; then + stat_busy "Setting Consoles to UTF-8 mode" + # UTF-8 consoles are default since 2.6.24 kernel + # this code is needed not only for older kernels, + # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. + for i in /dev/tty[0-9]*; do + kbd_mode -u < ${i} + printf "\e%%G" > ${i} + done + echo 1 >| /sys/module/vt/parameters/default_utf8 + stat_done +else + stat_busy "Setting Consoles to legacy mode" + # make non-UTF-8 consoles work on 2.6.24 and newer kernels + for i in /dev/tty[0-9]*; do + kbd_mode -a < ${i} + printf "\e%%@" > ${i} + done + echo 0 >| /sys/module/vt/parameters/default_utf8 + stat_done +fi + +if [[ -s /etc/vconsole.conf ]]; then + parse_envfile /etc/vconsole.conf "${vconsolevars[@]}" + [[ $FONT ]] && CONSOLEFONT=$FONT + [[ $FONT_MAP ]] && CONSOLEMAP=$FONT_MAP +fi +[[ $KEYMAP ]] && + status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP + +# Set console font if required +set_consolefont + if [[ ! -a /usr/lib ]] ; then printf "${C_FAIL}/usr is not mounted. This is not supported.${C_OTHER}\n" fi @@ -144,43 +181,6 @@ if [[ $HOSTNAME ]]; then echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail fi -if [[ -s /etc/locale.conf ]]; then - parse_envfile /etc/locale.conf "LANG" - [[ $LANG ]] && LOCALE=$LANG -fi -if [[ ${LOCALE,,} =~ utf ]]; then - stat_busy "Setting Consoles to UTF-8 mode" - # UTF-8 consoles are default since 2.6.24 kernel - # this code is needed not only for older kernels, - # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. - for i in /dev/tty[0-9]*; do - kbd_mode -u < ${i} - printf "\e%%G" > ${i} - done - echo 1 >| /sys/module/vt/parameters/default_utf8 - stat_done -else - stat_busy "Setting Consoles to legacy mode" - # make non-UTF-8 consoles work on 2.6.24 and newer kernels - for i in /dev/tty[0-9]*; do - kbd_mode -a < ${i} - printf "\e%%@" > ${i} - done - echo 0 >| /sys/module/vt/parameters/default_utf8 - stat_done -fi - -if [[ -s /etc/vconsole.conf ]]; then - parse_envfile /etc/vconsole.conf "${vconsolevars[@]}" - [[ $FONT ]] && CONSOLEFONT=$FONT - [[ $FONT_MAP ]] && CONSOLEMAP=$FONT_MAP -fi -[[ $KEYMAP ]] && - status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP - -# Set console font if required -set_consolefont - stat_busy "Saving dmesg Log" if [[ -e /proc/sys/kernel/dmesg_restrict ]] && (( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then -- cgit v1.2.3 From acfbe4b8e05959079a807dcc1df7650946cd0924 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 30 Apr 2012 13:29:31 +0200 Subject: tmpfiles: use 'root' rather than '0' as the default user/group This avoids hangs due to '0' not being found and the system attempting to look it up over ldap. Suggested-by: Laurent Rahuel Signed-off-by: Tom Gundersen --- arch-tmpfiles | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch-tmpfiles b/arch-tmpfiles index 8d927de..9355fdc 100755 --- a/arch-tmpfiles +++ b/arch-tmpfiles @@ -285,8 +285,8 @@ while read -d '' fragment; do d|D) line[2]=0755 ;; esac fi - [[ ${line[3]} = '-' ]] && line[3]=0 - [[ ${line[4]} = '-' ]] && line[4]=0 + [[ ${line[3]} = '-' ]] && line[3]='root' + [[ ${line[4]} = '-' ]] && line[4]='root' "_${line[@]}" done <"$FILE" -- cgit v1.2.3 From c18d4a38d33a231bf2f39c47909a79c4227f7ca3 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 30 Apr 2012 14:07:45 +0200 Subject: release: put tarball in correct dir on buildserver Signed-off-by: Tom Gundersen --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 598417f..a2e5e04 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,6 @@ tar: release: tar scp initscripts-$(VER).tar.xz gerolde.archlinux.org:/srv/ftp/other/initscripts/ - scp initscripts-$(VER).tar.xz pkgbuild.com:~/svn-packages/initscripts/trunk/ + scp initscripts-$(VER).tar.xz pkgbuild.com:~/packages/initscripts/trunk/ .PHONY: all installdirs install doc clean tar release -- cgit v1.2.3 From 3d261ea4f9cf59a75326d4771a6c23b0c76e4aa4 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 30 Apr 2012 14:08:17 +0200 Subject: deps: require up-to-date udev due to change of direcotry Signed-off-by: Tom Gundersen --- PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 7511b43..3130e5e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,7 +10,7 @@ conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) makedepends=('asciidoc') -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=177' 'iproute2' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=182' 'iproute2' 'ncurses' 'kbd' 'findutils' 'sysvinit') optdepends=('net-tools: legacy networking support' 'bridge-utils: Network bridging support' -- cgit v1.2.3 From 86b2cb99028d81a6cb608f09e1a31bc7744a991c Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 5 May 2012 16:06:53 +0200 Subject: sysctl: fix compatibility with procps-ng The interface changed slightly, from "-p " to "-p", compared with procps. Reported-by: Boris Suggested-by: Eric Belanger Signed-off-by: Tom Gundersen --- arch-sysctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch-sysctl b/arch-sysctl index e27369d..f73f1f0 100755 --- a/arch-sysctl +++ b/arch-sysctl @@ -23,7 +23,7 @@ for path in "${@:-${sysctl_d[@]}}"; do done for path in "${fragments[@]}"; do - sysctl -q -p "$path" + sysctl -q -p"$path" done # vim: set ts=2 sw=2 noet: -- cgit v1.2.3