From 47d9bdf77552ccb18d65657196247ca20f02599c Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 11 Dec 2017 12:19:21 +0100 Subject: [PATCH] Add switch-passwd Add Source for /sbin/switch-passwd and switch-passwd.service. The script switch-passwd changes /etc/passwd into a symlink to passwd.mariux (which is disted) and removes "nis" as a passwd source from /etc/nsswitch.conf. These changes are not done, if already done or if gdm is running. On systems with gdm (workstations) which can't upgrade immediately, the service switch-passwd.service is used to do the switch on the next boot. /etc/passwd and /etc/nsswitch.conf are temporarily disabled from pdist on the Distmaster to allow a rolling upgrade. After these files are distributed, all system should execute /sbin/switch-passwd # attempt immediate switch systemctl enable switch-passwd.service After all systems have upgraded (immediate or after reboot) we can re-enable /etc/passwd and /etc/nsswitch.conf in the Distfile and remove these switch-passwd files. --- install.sh | 2 ++ switch-passwd/switch-passwd | 11 +++++++++++ switch-passwd/switch-passwd.service | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100755 switch-passwd/switch-passwd create mode 100644 switch-passwd/switch-passwd.service diff --git a/install.sh b/install.sh index 0cf242d..980bae8 100755 --- a/install.sh +++ b/install.sh @@ -88,5 +88,7 @@ install_exec pdist/pdist "$DESTDIR$usrlocal_bindir/pdis install_exec pmirror/pmirror "$DESTDIR$usrlocal_bindir/pmirror" install_exec prun/prun "$DESTDIR$usr_bindir/prun" install_exec put_websafe/put_websafe "$DESTDIR$usrlocal_bindir/put_websafe" +install_exec switch-passwd/switch-passwd "$DESTDIR$root_sbindir/switch-passwd" +install_data switch-passwd/switch-passwd.service "$DESTDIR$systemdunitdir/switch-passwd.service" exit diff --git a/switch-passwd/switch-passwd b/switch-passwd/switch-passwd new file mode 100755 index 0000000..0b147f8 --- /dev/null +++ b/switch-passwd/switch-passwd @@ -0,0 +1,11 @@ +#! /bin/sh +test -L /etc/passwd && exit +systemctl status gdm.service >/dev/null && exit + +set -e + +sed -e 's/passwd: files students nis/passwd: files students/' < /etc/nsswitch.conf > /etc/nsswitch.conf.new +ln -sf passwd.mariux /etc/passwd.new + +mv /etc/passwd.new /etc/passwd +mv /etc/nsswitch.conf.new /etc/nsswitch.conf diff --git a/switch-passwd/switch-passwd.service b/switch-passwd/switch-passwd.service new file mode 100644 index 0000000..7885a26 --- /dev/null +++ b/switch-passwd/switch-passwd.service @@ -0,0 +1,9 @@ +[Unit] +Before=gdm.service + +[Install] +WantedBy=basic.target + +[Service] +Type=oneshot +ExecStart=/sbin/switch-passwd