[arch-projects] [INITSCRIPTS][PATCH 1/4] localtime copy fix in to rc.conf man page
set_timezone function currently respect user choice of symlink to timezone file or copy it. man page doesn't explain this subtlety which let think that TIMEZONE parameter in rc.conf doesn't ensure anything. Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- 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 c4087d0..4b452fc 100644 --- a/rc.conf.5.txt +++ b/rc.conf.5.txt @@ -25,7 +25,7 @@ LOCALIZATION[[L]] *TIMEZONE=* Specifies the timezone. The setting takes effect on boot by ensuring that /etc/localtime is a symlink -to the correct zoneinfo file. Possible timezones are the relative path to a zoneinfo file starting +to, or a copy of, the correct zoneinfo file. Possible timezones are the relative path to a zoneinfo file starting from the directory /usr/share/zoneinfo. For example, a German timezone would be Europe/Berlin, which refers to the file /usr/share/zoneinfo/Europe/Berlin. -- Sebastien "Seblu" Luttringer
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 <seblu@seblu.net> --- 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 -- Sebastien "Seblu" Luttringer
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
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
Makes sense in principle. Do you know if any packages yet ship with sysctl files (systemd does, but that doesn't count ;-) )? If so they could call this in post_install, so that makes sense to me. -t
On Mon, Mar 12, 2012 at 11:19 PM, Tom Gundersen <teg@jklm.no> wrote:
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
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
Makes sense in principle. Do you know if any packages yet ship with sysctl files (systemd does, but that doesn't count ;-) )? If so they could call this in post_install, so that makes sense to me.
I don't know if package ship sysctl files, but there is few case where this should be done. It's more an admin facility to tweak a system and be compatible with other distro. Idea behind this commit, is to have the same behaviour in initscripts plugin. If package want trigger it, he can do it with the initscripts binary, calling /usr/lib/initscripts/arch-sysctl. But it's initscripts oriented and not really compatible with systemd and should directly call "sysctl -p hisfile.conf" instead. -- Sébastien Luttringer www.seblu.net
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 <seblu@seblu.net> --- 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 -- Sebastien "Seblu" Luttringer
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
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 <seblu@seblu.net>
I'm not necessarily opposed to this, but could you point to some usecases? I assume this will allow us to remove some code from some packages and have them ship a config file instead? Some examples like this would be nice. -t
On Mon, Mar 12, 2012 at 11:12 PM, Tom Gundersen <teg@jklm.no> wrote:
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
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 <seblu@seblu.net>
I'm not necessarily opposed to this, but could you point to some usecases? I assume this will allow us to remove some code from some packages and have them ship a config file instead? Some examples like this would be nice. Do you want this examples added in commit message or in a manpages[1]?
You can test this feature by droping a file wine.conf in /etc/binfmt.d with the following content: # Start WINE on Windows executables :DOSWin:M::MZ::/usr/bin/wine: After a reboot, or a succeful run of /usr/lib/initscripts/arch-binfmt, you can run ./toto.exe and it will be lauched automagically with wine as interpreter. You can read more detail on this linux feature in the kernel documentation[2]. I don't believe package currently use this feature. There is a wiki page with example for java[3] where the job is done in rc.local. This patch will allow to do it by initscripts config. [1] http://linuxmanpages.net/manpages/fedora15/man5/binfmt.d.5.html [2] http://www.kernel.org/doc/Documentation/binfmt_misc.txt [3] https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java -- Sébastien Luttringer www.seblu.net
This patch revert patch 042d197b4d989ec64. Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- 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 -- Sebastien "Seblu" Luttringer
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
This patch revert patch 042d197b4d989ec64.
Signed-off-by: Sébastien Luttringer <seblu@seblu.net>
This was discussed a lot back and forth. Could you give a summary in the commit message of the pros and cons, and why this is the right thing to do? -t
On Mon, Mar 12, 2012 at 11:13 PM, Tom Gundersen <teg@jklm.no> wrote:
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
This patch revert patch 042d197b4d989ec64.
Signed-off-by: Sébastien Luttringer <seblu@seblu.net>
This was discussed a lot back and forth. Could you give a summary in the commit message of the pros and cons, and why this is the right thing to do?
https://github.com/seblu/arch-initscripts/commit/9f75591c8a56ba7ec1ea20cfe16... Better? -- Sébastien Luttringer www.seblu.net
On Mon, Mar 12, 2012 at 10:54 PM, Sébastien Luttringer <seblu@seblu.net> wrote:
set_timezone function currently respect user choice of symlink to timezone file or copy it. man page doesn't explain this subtlety which let think that TIMEZONE parameter in rc.conf doesn't ensure anything.
IMHO the manpage should stay the same, and we should rather change rc.sysinit to always ensure the symlink (the only point of doing the copy is in case /usr is not mounted, but we don't support that any more). -t
participants (3)
-
Seblu
-
Sébastien Luttringer
-
Tom Gundersen