diff options
author | stefan0xC | 2020-07-23 01:16:01 +0200 |
---|---|---|
committer | stefan0xC | 2020-07-23 01:16:01 +0200 |
commit | ed544aafc002334975bbe3ee4fb3c8645a6b5e5f (patch) | |
tree | 730a82d06dbace172574a89716d5d6fc86bfcc8b /guest-account.sh | |
parent | b24e39bbf36799cfec81ac0e71f9a5ea9d6c01f0 (diff) | |
download | aur-ed544aafc002334975bbe3ee4fb3c8645a6b5e5f.tar.gz |
revert to upstream version
Diffstat (limited to 'guest-account.sh')
-rw-r--r-- | guest-account.sh | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/guest-account.sh b/guest-account.sh index 0321723288db..6708de2fb071 100644 --- a/guest-account.sh +++ b/guest-account.sh @@ -3,25 +3,24 @@ # Author: Martin Pitt <martin.pitt@ubuntu.com> # License: GPL v2 or later # modified by David D Lowe and Thomas Detoux -# adapted for Arch Linux by Stefan Melmuk # # Setup user and temporary home directory for guest session. # If this succeeds, this script needs to print the username as the last line to # stdout. -export TEXTDOMAINDIR=/usr/share/locale +export TEXTDOMAINDIR=/usr/share/locale-langpack export TEXTDOMAIN=lightdm # set the system wide locale for gettext calls -if [ -f /etc/locale.conf ]; then - . /etc/locale.conf +if [ -f /etc/default/locale ]; then + . /etc/default/locale LANGUAGE= export LANG LANGUAGE fi is_system_user () { - UID_MIN=$(cat /etc/login.defs | grep '^UID_MIN' | awk '{print $2}') + UID_MIN=$(cat /etc/login.defs | grep UID_MIN | awk '{print $2}') SYS_UID_MIN=$(cat /etc/login.defs | grep SYS_UID_MIN | awk '{print $2}') SYS_UID_MAX=$(cat /etc/login.defs | grep SYS_UID_MAX | awk '{print $2}') @@ -46,7 +45,7 @@ add_account () # if ${GUEST_USER} already exists, it must be a locked system account with no existing # home directory - if PWSTAT=$(passwd -S ${GUEST_USER} 2>/dev/null); then + if PWSTAT=$(passwd -S ${GUEST_USER}) 2>/dev/null; then if [ $(echo ${PWSTAT} | cut -f2 -d' ') != L ]; then echo "User account ${GUEST_USER} already exists and is not locked" exit 1 @@ -72,17 +71,13 @@ add_account () fi else # does not exist, so create it - useradd --system \ - --home-dir ${GUEST_HOME} \ - --comment $(gettext "Guest") \ - --user-group -G autologin \ - --shell /bin/bash \ - ${GUEST_USER} || { + useradd --system --home-dir ${GUEST_HOME} --comment $(gettext "Guest") --user-group --shell /bin/bash ${GUEST_USER} || { rm -rf ${GUEST_HOME} exit 1 } fi + dist_gs=/usr/share/lightdm/guest-session site_gs=/etc/guest-session # create temporary home directory @@ -92,17 +87,59 @@ add_account () } if [ -d ${site_gs}/skel ] && [ "$(ls -A ${site_gs}/skel)" ]; then - cp -rT ${site_gs}/skel/ ${GUEST_HOME} - chown -R ${GUEST_USER}:${GUEST_USER} ${GUEST_HOME} + # Only perform union-mounting if BindFS is available + if [ -x /usr/bin/bindfs ]; then + bindfs_mount=true + + # Try OverlayFS first + if modinfo -n overlay >/dev/null 2>&1; then + mkdir ${GUEST_HOME}/upper ${GUEST_HOME}/work + chown ${GUEST_USER}:${GUEST_USER} ${GUEST_HOME}/upper ${GUEST_HOME}/work + + mount -t overlay -o lowerdir=${dist_gs}/skel:${site_gs}/skel,upperdir=${GUEST_HOME}/upper,workdir=${GUEST_HOME}/work overlay ${GUEST_HOME} || { + umount ${GUEST_HOME} + rm -rf ${GUEST_HOME} + exit 1 + } + # If OverlayFS is not available, try AuFS + elif [ -x /sbin/mount.aufs ]; then + mount -t aufs -o br=${GUEST_HOME}:${dist_gs}/skel:${site_gs}/skel none ${GUEST_HOME} || { + umount ${GUEST_HOME} + rm -rf ${GUEST_HOME} + exit 1 + } + # If none of them is available, fall back to copy over + else + cp -rT ${site_gs}/skel/ ${GUEST_HOME} + cp -rT ${dist_gs}/skel/ ${GUEST_HOME} + chown -R ${GUEST_USER}:${GUEST_USER} ${GUEST_HOME} + bindfs_mount=false + fi + + if ${bindfs_mount}; then + # Wrap ${GUEST_HOME} in a BindFS mount, so that + # ${GUEST_USER} will be seen as the owner of ${GUEST_HOME}'s contents. + bindfs -u ${GUEST_USER} -g ${GUEST_USER} ${GUEST_HOME} ${GUEST_HOME} || { + umount ${GUEST_HOME} # union mount + umount ${GUEST_HOME} # tmpfs mount + rm -rf ${GUEST_HOME} + exit 1 + } + fi + # If BindFS is not available, just fall back to copy over + else + cp -rT ${site_gs}/skel/ ${GUEST_HOME} + cp -rT ${dist_gs}/skel/ ${GUEST_HOME} + chown -R ${GUEST_USER}:${GUEST_USER} ${GUEST_HOME} + fi else cp -rT /etc/skel/ ${GUEST_HOME} + cp -rT ${dist_gs}/skel/ ${GUEST_HOME} chown -R ${GUEST_USER}:${GUEST_USER} ${GUEST_HOME} fi # setup session - if [ -f ${site_gs}/setup.sh ]; then - su ${GUEST_USER} -c "env HOME=${GUEST_HOME} site_gs=${site_gs} ${site_gs}/setup.sh" - fi + su ${GUEST_USER} -c "env HOME=${GUEST_HOME} site_gs=${site_gs} ${dist_gs}/setup.sh" # set possible local guest session preferences source_local_prefs() { @@ -150,6 +187,8 @@ remove_account () if [ ${GUEST_HOME} = ${GUEST_HOME#/tmp/} ]; then echo "Warning: home directory ${GUEST_HOME} is not in /tmp/. It won't be removed." else + umount ${GUEST_HOME} || umount -l ${GUEST_HOME} || true # BindFS mount + umount ${GUEST_HOME} || umount -l ${GUEST_HOME} || true # union mount umount ${GUEST_HOME} || umount -l ${GUEST_HOME} || true # tmpfs mount rm -rf ${GUEST_HOME} fi |