summarylogtreecommitdiffstats
path: root/0001-guest-account-Use-cross-distro-commands.patch
diff options
context:
space:
mode:
Diffstat (limited to '0001-guest-account-Use-cross-distro-commands.patch')
-rw-r--r--0001-guest-account-Use-cross-distro-commands.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/0001-guest-account-Use-cross-distro-commands.patch b/0001-guest-account-Use-cross-distro-commands.patch
new file mode 100644
index 000000000000..d5caff98ef37
--- /dev/null
+++ b/0001-guest-account-Use-cross-distro-commands.patch
@@ -0,0 +1,89 @@
+From f79dcd208c2d0e09425cda9535c6881ecf22125c Mon Sep 17 00:00:00 2001
+From: Xiao-Long Chen <chenxiaolong@cxl.epac.to>
+Date: Sun, 13 Apr 2014 01:01:44 -0400
+Subject: [PATCH 1/2] guest-account: Use cross-distro commands
+
+---
+ debian/guest-account.sh | 41 +++++++++++++++++++++++++++++++++--------
+ 1 file changed, 33 insertions(+), 8 deletions(-)
+
+diff --git a/debian/guest-account.sh b/debian/guest-account.sh
+index 6da5687..0fc3daa 100644
+--- a/debian/guest-account.sh
++++ b/debian/guest-account.sh
+@@ -20,7 +20,12 @@ fi
+
+ add_account ()
+ {
+- HOME=`mktemp -td guest-XXXXXX`
++ NEWHOME=`mktemp -td guest-XXXXXX`
++ # useradd does not accept upper case characters in the username
++ HOME=`echo $NEWHOME | tr '[A-Z]' '[a-z]'`
++ if [ "x$NEWHOME" != "x$HOME" ]; then
++ mv $NEWHOME $HOME
++ fi
+ USER=`echo $HOME | sed 's/\(.*\)guest/guest/'`
+
+ # if $USER already exists, it must be a locked system account with no existing
+@@ -46,7 +51,21 @@ add_account ()
+ fi
+ else
+ # does not exist, so create it
+- adduser --system --no-create-home --home / --gecos $(gettext "Guest") --group --shell /bin/bash $USER || {
++ # Arch Linux modification: Ubuntu/Debian uses their own adduser package,
++ # which works differently from the own provided by the shadow package.
++ # Instead, use useradd, which works in any distro.
++ #
++ # Only the syntax is changed
++ # adduser -> useradd
++ # --system -> --system
++ # --no-create-home -> --no-create-home
++ # --home -> --home-dir
++ # --gecos -> --comment
++ # --group -> --user-group
++ # --shell -> --shell
++ #
++ #adduser --system --no-create-home --home / --gecos $(gettext "Guest") --group --shell /bin/bash $USER || {
++ useradd --system --no-create-home --home-dir / --comment $(gettext "Guest") --user-group --shell /bin/bash $USER || {
+ umount "$HOME"
+ rm -rf "$HOME"
+ exit 1
+@@ -128,7 +147,12 @@ remove_account ()
+ GUEST_UID=`echo "$PWENT" | cut -f3 -d:`
+ GUEST_HOME=`echo "$PWENT" | cut -f6 -d:`
+
+- if [ "$GUEST_UID" -ge 500 ]; then
++ # deluser is provided by the adduser package on Debian/Ubuntu. useradd
++ # doesn't have a '--system' parameter, which causes deluser to only delete
++ # system users, so this will be handled using this script.
++ 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}')"
++ if [ "$GUEST_UID" -lt "$SYS_UID_MIN" ] || [ "$GUEST_UID" -gt "$SYS_UID_MAX" ]; then
+ echo "Error: user $GUEST_USER is not a system user."
+ exit 1
+ fi
+@@ -150,15 +174,16 @@ remove_account ()
+ # remove leftovers in /tmp
+ find /tmp -mindepth 1 -maxdepth 1 -uid "$GUEST_UID" -print0 | xargs -0 rm -rf || true
+
+- # remove possible /media/guest-XXXXXX folder
+- if [ -d /media/"$GUEST_USER" ]; then
+- for dir in $( find /media/"$GUEST_USER" -mindepth 1 -maxdepth 1 ); do
++ # remove possible /run/media/guest-XXXXXX folder
++ if [ -d /run/media/"$GUEST_USER" ]; then
++ for dir in $( find /run/media/"$GUEST_USER" -mindepth 1 -maxdepth 1 ); do
+ umount "$dir" || true
+ done
+- rmdir /media/"$GUEST_USER" || true
++ rmdir /run/media/"$GUEST_USER" || true
+ fi
+
+- deluser --system "$GUEST_USER"
++ #deluser --system "$GUEST_USER"
++ userdel "$GUEST_USER"
+ }
+
+ case "$1" in
+--
+2.3.3
+