From 4e71aae00f7adc5cc0f34720056417372c4aa0d5 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Tue, 19 Sep 2023 10:16:47 +0200 Subject: [PATCH 1/2] - use snapper to change config instead of sed --- scripts/pam_snapper_homeconvert.sh | 3 +-- scripts/pam_snapper_pamconfig.sh | 1 - scripts/pam_snapper_useradd.sh | 3 +-- scripts/pam_snapper_userdel.sh | 1 - 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/pam_snapper_homeconvert.sh b/scripts/pam_snapper_homeconvert.sh index ab76e35e8..852a5176b 100755 --- a/scripts/pam_snapper_homeconvert.sh +++ b/scripts/pam_snapper_homeconvert.sh @@ -13,7 +13,6 @@ CMD_BTRFS="/sbin/btrfs" CMD_SNAPPER="/usr/bin/snapper" CMD_EGREP="grep -E" CMD_PAM_CONFIG="/usr/sbin/pam-config" -CMD_SED="sed" CMD_USERADD="useradd -m" CMD_USERDEL="userdel -r" CMD_CHOWN="chown" @@ -137,7 +136,7 @@ function createsnapperconfig () { fi echo "Create snapper configuration for user ${MYUSER}" ${CMD_SNAPPER} -c home_${MYUSER} create-config ${HOMEHOME}/${MYUSER} - ${CMD_SED} -i -e "s/ALLOW_USERS=\"\"/ALLOW_USERS=\"${MYUSER}\"/g" ${SNAPPERCFGDIR}/home_${MYUSER} + ${CMD_SNAPPER} -c home_${MYUSER} set-config ALLOW_USERS=${MYUSER} fi ${CMD_CHMOD} 755 ${HOMEHOME}/${MYUSER}/.snapshots } diff --git a/scripts/pam_snapper_pamconfig.sh b/scripts/pam_snapper_pamconfig.sh index 385c56147..6383a4332 100755 --- a/scripts/pam_snapper_pamconfig.sh +++ b/scripts/pam_snapper_pamconfig.sh @@ -13,7 +13,6 @@ CMD_BTRFS="/sbin/btrfs" CMD_SNAPPER="/usr/bin/snapper" CMD_EGREP="grep -E" CMD_PAM_CONFIG="/usr/sbin/pam-config" -CMD_SED="sed" CMD_USERADD="useradd -m" CMD_USERDEL="userdel -r" CMD_CHOWN="chown" diff --git a/scripts/pam_snapper_useradd.sh b/scripts/pam_snapper_useradd.sh index 6ff50742d..bc9d82e1f 100755 --- a/scripts/pam_snapper_useradd.sh +++ b/scripts/pam_snapper_useradd.sh @@ -13,7 +13,6 @@ CMD_BTRFS="/sbin/btrfs" CMD_SNAPPER="/usr/bin/snapper" CMD_EGREP="grep -E" CMD_PAM_CONFIG="/usr/sbin/pam-config" -CMD_SED="sed" CMD_USERADD="useradd" CMD_USERDEL="userdel -r" CMD_CHOWN="chown" @@ -47,7 +46,7 @@ if [ ${DRYRUN} == 0 ] ; then ${CMD_BTRFS} subvol create ${HOMEHOME}/${MYUSER} # Create snapper config for USER ${CMD_SNAPPER} -c home_${MYUSER} create-config ${HOMEHOME}/${MYUSER} - ${CMD_SED} -i -e "s/ALLOW_USERS=\"\"/ALLOW_USERS=\"${MYUSER}\"/g" ${SNAPPERCFGDIR}/home_${MYUSER} + ${CMD_SNAPPER} -c home_${MYUSER} set-config ALLOW_USERS=${MYUSER} # Create USER ${CMD_USERADD} ${MYUSER} # Give USER skeleton files diff --git a/scripts/pam_snapper_userdel.sh b/scripts/pam_snapper_userdel.sh index 30be9beb6..41bdbfbda 100755 --- a/scripts/pam_snapper_userdel.sh +++ b/scripts/pam_snapper_userdel.sh @@ -13,7 +13,6 @@ CMD_BTRFS="/sbin/btrfs" CMD_SNAPPER="/usr/bin/snapper" CMD_EGREP="grep -E" CMD_PAM_CONFIG="/usr/sbin/pam-config" -CMD_SED="sed" CMD_USERADD="useradd -m" CMD_USERDEL="userdel -r" CMD_CHOWN="chown" From 9b97a8be2373325f925083157a677ef0a8a42a2d Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Tue, 19 Sep 2023 10:20:52 +0200 Subject: [PATCH 2/2] - add option --no-create-home to useradd to avoid warning --- scripts/pam_snapper_useradd.sh | 3 +-- scripts/pam_snapper_userdel.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/pam_snapper_useradd.sh b/scripts/pam_snapper_useradd.sh index bc9d82e1f..fb04c8d81 100755 --- a/scripts/pam_snapper_useradd.sh +++ b/scripts/pam_snapper_useradd.sh @@ -13,8 +13,7 @@ CMD_BTRFS="/sbin/btrfs" CMD_SNAPPER="/usr/bin/snapper" CMD_EGREP="grep -E" CMD_PAM_CONFIG="/usr/sbin/pam-config" -CMD_USERADD="useradd" -CMD_USERDEL="userdel -r" +CMD_USERADD="useradd --no-create-home" CMD_CHOWN="chown" CMD_CHMOD="chmod" CMD_CPA="cp -a" diff --git a/scripts/pam_snapper_userdel.sh b/scripts/pam_snapper_userdel.sh index 41bdbfbda..9ee056195 100755 --- a/scripts/pam_snapper_userdel.sh +++ b/scripts/pam_snapper_userdel.sh @@ -13,8 +13,7 @@ CMD_BTRFS="/sbin/btrfs" CMD_SNAPPER="/usr/bin/snapper" CMD_EGREP="grep -E" CMD_PAM_CONFIG="/usr/sbin/pam-config" -CMD_USERADD="useradd -m" -CMD_USERDEL="userdel -r" +CMD_USERDEL="userdel --remove" CMD_CHOWN="chown" # SNAPPERCFGDIR="/etc/snapper/configs"