[Pkg-nx-commits] r34 - in freenx/trunk: . debian

Stefan Lippers-Hollmann slh-guest at costa.debian.org
Sun Aug 7 00:19:29 UTC 2005


Author: slh-guest
Date: 2005-08-07 00:19:28 +0000 (Sun, 07 Aug 2005)
New Revision: 34

Modified:
   freenx/trunk/ChangeLog
   freenx/trunk/debian/changelog
   freenx/trunk/debian/postinst
   freenx/trunk/debian/postrm
   freenx/trunk/debian/prerm
   freenx/trunk/node.conf.sample
   freenx/trunk/nxloadconfig
   freenx/trunk/nxnode
   freenx/trunk/nxserver
   freenx/trunk/nxsetup
Log:
freenx: update to new upstream version 0.4.4.
freenx: use #!/bin/bash for maintainer scripts until they're completely POSIX compatible (TODO).


Modified: freenx/trunk/ChangeLog
===================================================================
--- freenx/trunk/ChangeLog	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/ChangeLog	2005-08-07 00:19:28 UTC (rev 34)
@@ -1,3 +1,24 @@
+06.08.2005 FreeNX 0.4.4 "UKUUG Enterprise Edition"
+	* Added ENABLE_1_5_0_BACKEND configuration directive:
+		* Fixed fullscreen support in nxdesktop (still feels more like
+		  'Available Area', but with Ctrl-Alt-F you can get "real"
+		  fullscreen)
+	* Added COMMAND_MD5SUM directive
+	* Security: $USER_FAKE_HOME/.nx now gets 0700
+	* Fixed support for CUPS forwarding.
+	* Added secure re-transmitting to client.
+	* Removed grep from getent to not search through the whole database.
+	  (Suggestion by "Matthew S. Harris" <mharris at google.com>,
+	                 "Ed Warnicke"       <eaw at cisco.com>)
+	* Set sleeps to 60 instead of 10 seconds, removed one wrong trap.
+	  (Suggestion by "Sunil" <funtoos at yahoo.com>)
+	* Made automatic timeout configurable.
+	  (Patch by "Ed Warnicke" <eaw at cisco.com>)
+	* Made nxsetup more enterprise friendly. Added --localuser
+	  (RedHat only) and --gid. 
+	  (Based on a patch by "Ed Warnicke" <eaw at cisco.com>)
+	* Fixed resume of multiple sessions.
+
 28.07.2005 FreeNX 0.4.3 "NoMachine 1.5.0 Edition"
 	* Fixed reconnection problems with !M 1.5.0 client.
 	* Fixed reconnection problems with !M 1.5.0 backend.

Modified: freenx/trunk/debian/changelog
===================================================================
--- freenx/trunk/debian/changelog	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/debian/changelog	2005-08-07 00:19:28 UTC (rev 34)
@@ -1,3 +1,11 @@
+freenx (0.4.4-1) UNRELEASED; urgency=low
+
+  * (NOT RELEASED YET) New upstream release
+  * use #!/bin/bash for maintainer scripts until they're properly POSIX
+    compatible.
+
+ -- Stefan Lippers-Hollmann <s.l-h at gmx.de>  Sun,  7 Aug 2005 02:14:45 +0200
+
 freenx (0.4.3-0) UNRELEASED; urgency=low
 
   * (NOT RELEASED YET) New upstream release:

Modified: freenx/trunk/debian/postinst
===================================================================
--- freenx/trunk/debian/postinst	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/debian/postinst	2005-08-07 00:19:28 UTC (rev 34)
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 # postinst script for freenx
 #
 # see: dh_installdeb(1)

Modified: freenx/trunk/debian/postrm
===================================================================
--- freenx/trunk/debian/postrm	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/debian/postrm	2005-08-07 00:19:28 UTC (rev 34)
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 # postrm script for freenx
 #
 # see: dh_installdeb(1)

Modified: freenx/trunk/debian/prerm
===================================================================
--- freenx/trunk/debian/prerm	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/debian/prerm	2005-08-07 00:19:28 UTC (rev 34)
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 # prerm script for freenx
 #
 # see: dh_installdeb(1)

Modified: freenx/trunk/node.conf.sample
===================================================================
--- freenx/trunk/node.conf.sample	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/node.conf.sample	2005-08-07 00:19:28 UTC (rev 34)
@@ -37,7 +37,7 @@
 #
 #           https://mail.kde.org/mailman/listinfo/freenx-knx
 #
-# CVS: $Id: node.conf.sample,v 1.32 2005/07/27 16:10:41 fabianx Exp $
+# CVS: $Id: node.conf.sample,v 1.35 2005/08/02 15:39:32 fabianx Exp $
 
 #########################################################################
 # General FreeNX directives
@@ -60,7 +60,6 @@
 # This adds the usermode to the possible authentication methods
 # Usermode means that a user can start the nxserver as his shell
 # and connect directly to the right server via a custom client.
-
 #ENABLE_USERMODE_AUTHENTICATION="0"
 
 # This adds the passdb to the possible authentication methods
@@ -310,6 +309,9 @@
 # The key that contains the name of the complete path of the 'cupsd' command.
 #COMMAND_CUPSD=/usr/sbin/cupsd
 
+# The tool to generate md5sums with
+#COMMAND_MD5SUM=md5sum
+
 #########################################################################
 # Misc directives
 #########################################################################
@@ -350,6 +352,10 @@
 #AGENT_EXTRA_OPTIONS_RDP=""
 #AGENT_EXTRA_OPTIONS_X=""
 
+# The number of seconds we wait for the nxagent to start before
+# deciding startup has failed
+#AGENT_STARTUP_TIMEOUT="60"
+
 # The font server the agent will use. If set to "" no font server is used.
 # For this to do any good, the client has to have the same font server set
 # in /etc/X11/XF86Config

Modified: freenx/trunk/nxloadconfig
===================================================================
--- freenx/trunk/nxloadconfig	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/nxloadconfig	2005-08-07 00:19:28 UTC (rev 34)
@@ -5,7 +5,7 @@
 #
 # License: GPL, version 2
 #
-# CVS: $Id: nxloadconfig,v 1.40 2005/07/27 16:10:41 fabianx Exp $
+# CVS: $Id: nxloadconfig,v 1.43 2005/08/02 15:39:32 fabianx Exp $
 #
 # ========================================================================
 
@@ -49,7 +49,7 @@
 # DO NOT TOUCH unless you REALLY know what you are doing
 #########################################################################
 
-NX_VERSION=1.4.0-04
+NX_VERSION=1.4.0-44
 NX_LICENSE="OS (GPL)"
 
 # Where can different nx components be found
@@ -157,6 +157,7 @@
 COMMAND_SSH=ssh
 COMMAND_SSH_KEYGEN=ssh-keygen
 COMMAND_CUPSD=/usr/sbin/cupsd
+COMMAND_MD5SUM=md5sum
 
 
 # Misc directives
@@ -173,6 +174,7 @@
 AGENT_EXTRA_OPTIONS_RFB=""
 AGENT_EXTRA_OPTIONS_RDP=""
 AGENT_EXTRA_OPTIONS_X=""
+AGENT_STARTUP_TIMEOUT="60"
 AGENT_FONT_SERVER=""
 PROXY_TCP_NODELAY="0"
 PROXY_EXTRA_OPTIONS=""
@@ -190,6 +192,7 @@
 		COMMAND_XTERM=/usr/openwin/bin/xterm
 		COMMAND_XAUTH=/usr/openwin/bin/xauth
 		COMMAND_CUPSD=/opt/sfw/cups/sbin/cupsd
+		COMMAND_MD5SUM=gmd5sum
 		PATH=/usr/xpg4/bin:/usr/openwin/bin:$PATH
 		export PATH
 		;;
@@ -324,16 +327,16 @@
 	if [ "$ENABLE_PERSISTENT_SESSION" != "all" ]
 	then
 		for USERNAME in $ENABLE_PERSISTENT_SESSION; do
-			[ "${USERNAME:0:1}" != "@" ] && [ -z $(getent passwd | egrep "^$USERNAME:") ] && \
+			[ "${USERNAME:0:1}" != "@" ] && [ -z $(getent passwd $USERNAME) ] && \
 				ERROR="yes" && echo "Error: Invalid value \"ENABLE_PERSISTENT_SESSION=$ENABLE_PERSISTENT_SESSION\"" && break ;
-			[ "${USERNAME:0:1}" = "@" ] && [ -z $(getent group | egrep "^${USERNAME:1}:") ] && \
+			[ "${USERNAME:0:1}" = "@" ] && [ -z $(getent group ${USERNAME:1}) ] && \
 				ERROR="yes" && echo "Error: Invalid value \"ENABLE_PERSISTENT_SESSION=$ENABLE_PERSISTENT_SESSION\"" && break ;
 		done
 	fi
 	for USERNAME in $DISABLE_PERSISTENT_SESSION; do
-		[ "${USERNAME:0:1}" != "@" ] && [ -z $(getent passwd | egrep "^$USERNAME:") ] && \
+		[ "${USERNAME:0:1}" != "@" ] && [ -z $(getent passwd $USERNAME) ] && \
 			ERROR="yes" && echo "Error: Invalid value \"DISABLE_PERSISTENT_SESSION=$DISABLE_PERSISTENT_SESSION\"" && break ;
-		[ "${USERNAME:0:1}" = "@" ] && [ -z $(getent group | egrep "^${USERNAME:1}:") ] && \
+		[ "${USERNAME:0:1}" = "@" ] && [ -z $(getent group ${USERNAME:1}) ] && \
 			ERROR="yes" && echo "Error: Invalid value \"DISABLE_PERSISTENT_SESSION=$DISABLE_PERSISTENT_SESSION\"" && break ;
 	done
 	IFS=$OLD_IFS
@@ -444,6 +447,8 @@
 	! which "$COMMAND_CUPSD" >/dev/null 2>&1 && \
 		WARNING="yes" && echo "Warning: Invalid value \"COMMAND_CUPSD=$COMMAND_CUPSD\"" \
 					  && echo "         Users will not be able to enable printing."
+	! which "$COMMAND_MD5SUM" >/dev/null 2>&1 && \
+		ERROR="yes" && echo "Warning: Invalid value \"COMMAND_MD5SUM=$COMMAND_MD5SUM\""
 
 	# Misc directives
 	

Modified: freenx/trunk/nxnode
===================================================================
--- freenx/trunk/nxnode	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/nxnode	2005-08-07 00:19:28 UTC (rev 34)
@@ -13,7 +13,7 @@
 #
 # License: GNU GPL, version 2
 #
-# CVS: $Id: nxnode,v 1.72 2005/07/27 12:50:54 fabianx Exp $
+# CVS: $Id: nxnode,v 1.77 2005/08/02 15:20:18 fabianx Exp $
 #
 # 21.06.2004: - Full reconnection support
 
@@ -236,6 +236,7 @@
 	[ "$virtualdesktop" = "0" ] && R="-R"
 	vncfullscreen=""
 	[ "$geometry" = "fullscreen" -a "$type" = "vnc" ] && vncfullscreen="-fullscreen" && G=""
+	[ "$geometry" = "fullscreen" -a "$type" = "windows" -a "$ENABLE_1_5_0_BACKEND" = "1" ] && G="-geometry `echo $screeninfo | cut -d"x" -f1,2`"
 
 	if [ "$type" = "windows" ]
 	then
@@ -243,9 +244,11 @@
 		[ "$SET_LD_LIBRARY_PATH" = "1" ] && export LD_LIBRARY_PATH="$AGENT_LIBRARY_PATH:$LD_LIBRARY_PATH"
 		U=""
 		P=""
+		D=""
 		[ -n "$agent_user" ] && U="-u $agent_user"
 		[ -n "$agent_password" ] && P="-p -"
-		echo "$agent_password" | $PATH_BIN/nxdesktop -name "NX - $user@$SERVER_NAME:$display - $session (GPL Edition)" -option "$USER_FAKE_HOME/.nx/C-$sess_id/options" $K $G $U $P $agent_server $AGENT_EXTRA_OPTIONS_RDP 2>>$USER_FAKE_HOME/.nx/C-$sess_id/session &
+		[ -n "$agent_domain" ] && D="-d $agent_domain"
+		echo "$agent_password" | $PATH_BIN/nxdesktop -name "NX - $user@$SERVER_NAME:$display - $session (GPL Edition)" -option "$USER_FAKE_HOME/.nx/C-$sess_id/options" $K $G $U $P $D $agent_server $AGENT_EXTRA_OPTIONS_RDP 2>>$USER_FAKE_HOME/.nx/C-$sess_id/session &
 	elif [ "$type" = "vnc" ]
 	then
 		# nxviewer session (VNC RFP)
@@ -424,9 +427,9 @@
 		if stringinstring "Info: tail -f running with pid" "$line"
 		then
 			TAIL_PID=$(echo $line | cut -d"'" -f2)
-			# now set a timeout of 10 seconds ...
+			# now set a timeout of 60 seconds ...
 			( 
-                          sleep 10
+                          sleep 60
 			  if [ -d "$HOME/.nx/C-$sess_id/" ]
 			  then
 		          	echo "NX> 1004 Error: nxagent failed to start. Session timed out."
@@ -626,9 +629,12 @@
 	mediahelper=$(getparam mediahelper)
 	sync=$(getparam sync)
 	samba=$(getparam samba)
+	cups=$(getparam cups)
 	agent_server=$(getparam agent_server)
 	agent_user=$(getparam agent_user)
 	agent_password=$(getparam agent_password)
+	agent_domain=$(getparam agent_domain)
+	screeninfo=$(getparam screeninfo)
 
 	if [ "$ENABLE_1_5_0_BACKEND" = "1" ]
 	then
@@ -640,6 +646,9 @@
 	
 	clientproto=$(getparam clientproto)
 
+	fullscreen=""
+	[ "$geometry" = "fullscreen" -a "$ENABLE_1_5_0_BACKEND" = "1" ] && fullscreen="1"
+
 	[ "$EXPORT_USERIP" = "1" ] && export NXUSERIP="$userip"
 
 	ssl_tunnel=$(getparam encryption)
@@ -652,7 +661,12 @@
 	sess_id="$SERVER_NAME-$display-$uniqueid"
 	[ "$EXPORT_SESSIONID" = "1" ] && export NXSESSIONID="$sess_id"
 	
+	OLD_UMASK=$(umask)
+	umask 0022
+	mkdir -p $USER_FAKE_HOME
+	umask 0077
 	mkdir -p $USER_FAKE_HOME/.nx/C-$sess_id
+	umask $OLD_UMASK
 	
 	# cache=8M,images=32M,pack=nopack,link=lan,type=unix-kde,cleanup=0,accept=192.168.1.66,cookie=E38A94A77F975443AF04EC911881B120,id=Knoppix-1000-6A8269CC467264EAEF6349D062689755,samba=1,render=1:1000
 	
@@ -663,7 +677,7 @@
 	[ "$imagecompressionmethod" = "1" ] && PACK="pack=16m-jpeg-$imagecompressionlevel,"
 	[ "$imagecompressionmethod" = "2" ] && PACK="pack=16m-png-9,"
 	
-	proxy_cookie=$(echo $[$RANDOM*$RANDOM] | md5sum | cut -d" " -f1)
+	proxy_cookie=$(echo $[$RANDOM*$RANDOM] | $COMMAND_MD5SUM | cut -d" " -f1)
 
 	if [ "$ENABLE_1_5_0_BACKEND" = "1" -a "$clientproto" = "1.5.0" ]
 	then
@@ -687,7 +701,7 @@
 	umask 0077
 
 cat << EOF > $USER_FAKE_HOME/.nx/C-$sess_id/options
-${kbtype:+kbtype=$kbtype,}${CACHE}${IMAGES}${PACK}link=$link,type=$type,cleanup=0,${ACCEPT}cookie=$proxy_cookie,id=$sess_id,samba=$samba,media=$media${sync:+,sync=$sync}${cups:+,cups=$cups}${rdpcolors:+,rdpcolors=$rdpcolors}${rdpcache:+,rdpcache=$rdpcache}:$display
+${kbtype:+kbtype=$kbtype,}${CACHE}${IMAGES}${PACK}link=$link,type=$type,cleanup=0,${ACCEPT}cookie=$proxy_cookie,id=$sess_id,samba=$samba,media=$media${sync:+,sync=$sync}${cups:+,cups=$cups}${rdpcolors:+,rdpcolors=$rdpcolors}${rdpcache:+,rdpcache=$rdpcache}${fullscreen:+,fullscreen=1}:$display
 EOF
 	umask $OLD_UMASK
 #samba=$samba,

Modified: freenx/trunk/nxserver
===================================================================
--- freenx/trunk/nxserver	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/nxserver	2005-08-07 00:19:28 UTC (rev 34)
@@ -11,7 +11,7 @@
 #
 # License: GNU GPL, version 2
 #
-# CVS: $Id: nxserver,v 1.69 2005/07/27 16:10:41 fabianx Exp $
+# CVS: $Id: nxserver,v 1.75 2005/08/05 16:38:44 fabianx Exp $
 #
 
 # Read the config file
@@ -46,7 +46,7 @@
 
 passdb_get_crypt_pass()
 {
-	echo "$@" | md5sum | cut -d" " -f1
+	echo "$@" | $COMMAND_MD5SUM | cut -d" " -f1
 }
 
 passdb_get_pass()
@@ -249,7 +249,7 @@
 			then
 				available="Yes"
 			fi
-			printf "%-7s %-16s %32s %8s %5s %-14s %-11s %s" "$(getparam display)" "$(getparam type)" "$(getparam sessionId)" "$options" "$depth" "$geom" "$available" "$(getparam sessionName)" >> $TMPFILE
+			printf "%-7s %-16s %32s %8s %5s %-14s %-11s %s\n" "$(getparam display)" "$(getparam type)" "$(getparam sessionId)" "$options" "$depth" "$geom" "$available" "$(getparam sessionName)" >> $TMPFILE
 		fi
 		egrep -q "^userName=$1$" $i && let SESSION_COUNT_USER=$SESSION_COUNT_USER+1
 	done
@@ -421,13 +421,18 @@
 
 # Log in a way that is secure for passwords / cookies / ...
 
+echo_secure()
+{
+	echo "$@ " | perl -pi -e 's/--cookie=".+?"/--cookie="******"/g; s/--agent_password=".+?"/agent_password="******"/g; s/--password=".+?"/password="******"/g; s/cookie=.+?&/cookie=******&/g; s/agent_password=.+?&/agent_password=******&/g; s/password=.+?&/password=******&/g;'
+}
+
 log_secure()
 {
 	if [ "$NX_LOG_SECURE" = "0" ]
 	then
 		log "$@"
 	else
-		[ "$NX_LOG_LEVEL" -ge "$1" -a -w "$NX_LOGFILE" ] && shift && echo "$@ " | perl -pi -e 's/--cookie=".+?"/--cookie="******"/g; s/--agent_password=".+?"/agent_password="******"/g; s/--password=".+?"/password="******"/g; s/cookie=.+?&/cookie=******&/g; s/agent_password=.+?&/agent_password=******&/g; s/password=.+?&/password=******&/g;' >> "$NX_LOGFILE"
+		[ "$NX_LOG_LEVEL" -ge "$1" -a -w "$NX_LOGFILE" ] && shift && echo_secure "$@" >> "$NX_LOGFILE"
 	fi
 }
 
@@ -679,7 +684,8 @@
 {
 	server_add_usession
 
-	trap server_nxnode_exit_func EXIT
+	# Trap did fire unnecessarily according to Sunil, so removed it again.
+	#trap server_nxnode_exit_func EXIT
 	
 	SERVER_CHANNEL=1
 	KILL_WAIT_PID=1
@@ -848,7 +854,7 @@
 			return
 		fi
 	
-		uniqueid=$(echo $[$RANDOM*$RANDOM] | md5sum | cut -d" " -f1 | tr "[a-z]" "[A-Z]")
+		uniqueid=$(echo $[$RANDOM*$RANDOM] | $COMMAND_MD5SUM | cut -d" " -f1 | tr "[a-z]" "[A-Z]")
 		FULL_PARAMS="$PARAMS&user=$USER&userip=$USERIP&uniqueid=$uniqueid&display=$SESS_DISPLAY"
 		log_secure "6" "$FULL_PARAMS"
 
@@ -866,7 +872,7 @@
 	fi
 
 	# now start the node
-	(sleep 10; exit 1) &
+	(sleep $AGENT_STARTUP_TIMEOUT; exit 1) &
 	SERVER_WAIT_PID=$!
 	server_nxnode_start_wait --"$ACTION"session $USER "$FULL_PARAMS" &
 	SERVER_PID=$!
@@ -876,7 +882,7 @@
 	if [ $? -eq 1 ]
 	then
 		# Something went wrong ...
-		session_fail $uniqueid
+		[ "$ACTION" = "start" ] && session_fail $uniqueid
 		# FIXME: Need correct error code.
 		echo_x "NX> 1004 Error: Session did not start."
 		echo_x "NX> 504 Session startup failed."
@@ -895,14 +901,14 @@
 	# FIXME?
 	[ "$CMD" = "" ] && CMD="quit"
 	
-	echo "$CMD"
-	
 	# Logging 
 	case "$CMD" in
 		startsession*|restoresession*|addmount*|addprinter*)
+			echo_secure "$CMD"
 			log_secure "4" "$CMD"
 		;;
 		*)
+			echo "$CMD"
 			log "4" "$CMD"
 		;;
 	esac
@@ -1127,7 +1133,7 @@
 	
 	[ ${#CMD_CHUSER} -ge 32 ] && cmd_abort "Error: User $CMD_CHUSER must be shorter than 32 characters."
 	egrep -q "^$CMD_CHUSER:" $NX_ETC_DIR/passwords && cmd_abort "Error: User $CMD_CHUSER already in database."
-	getent passwd | egrep -q "^$CMD_CHUSER:" || cmd_abort "Error: User $CMD_CHUSER not existing on local system. Can't add."
+	getent passwd "$CMD_CHUSER" >/dev/null || cmd_abort "Error: User $CMD_CHUSER not existing on local system. Can't add."
 	passdb_add_user "$CMD_CHUSER"
 }
 

Modified: freenx/trunk/nxsetup
===================================================================
--- freenx/trunk/nxsetup	2005-08-07 00:10:01 UTC (rev 33)
+++ freenx/trunk/nxsetup	2005-08-07 00:19:28 UTC (rev 34)
@@ -5,13 +5,18 @@
 #
 # License: GNU GPL, version 2
 #
-# CVS: $Id: nxsetup,v 1.29 2005/07/16 15:45:37 fabianx Exp $ 
+# CVS: $Id: nxsetup,v 1.31 2005/08/02 17:29:59 fabianx Exp $ 
 #
 
 HELP="no"
 INSTALL="no"
 SETUP_NOMACHINE_KEY="no"
 SETUP_UID=""
+SETUP_GID=""
+LOCAL_USER_OPTION=""
+# luseradd / luserdel are only available on RedHat
+[ -f /etc/redhat-release ] && LOCAL_USER_OPTION="yes"
+SETUP_LOCAL_USER="no"
 CLEAN="no"
 UNINSTALL="no"
 PURGE="no"
@@ -27,6 +32,8 @@
 		--ssh2) SETUP_SSH2_KEY="yes"; shift;;
 		--dont-build-known-hosts) BUILD_KNOWN_HOSTS="no"; shift;;
 		--uid) SETUP_UID=$2; shift 2 ;;
+		--gid) SETUP_GID=$2; shift 2 ;;
+		--localuser) SETUP_LOCAL_USER="yes"; shift;;
 		--clean) CLEAN="yes"; shift ;;
 		--uninstall) UNINSTALL="yes"; shift ;;
 		--purge) PURGE="yes"; shift ;;
@@ -36,6 +43,7 @@
 done
 
 #Check for invalid combinations:
+[ "$SETUP_LOCAL_USER" = "yes" -a -z "$LOCAL_USER_OPTION" ] && HELP="yes"
 [ "$INSTALL" = "yes" -a "$UNINSTALL" = "yes" ] && HELP="yes"
 [ "$INSTALL" = "no" -a "$UNINSTALL" = "no" ] && HELP="yes"
 [ "$INSTALL" = "yes" -a "$CLEAN" = "no" -a "$PURGE" = "yes" ] && HELP="yes"
@@ -59,6 +67,8 @@
 	echo "  --ssh2		       Additionally create commercial pubkey-support, beware"
 	echo "			       own _commercial_ ssh2-key is not supported!."
 	echo "  --uid <number>         The nx user will be given the uid <number>."
+	echo "  --gid <number>         The nx user will be given the gid <number>."
+	[ -n "$LOCAL_USER_OPTION" ] && echo "  --localuser            The nx user will be created locally using luseradd, for use in NIS and NISplus environments."
 	echo "  --clean                Performs an uninstall prior to the installation"
 	echo "  --uninstall            Remove log and session files, as well as the nx user"
 	echo "  --purge                Uninstall will remove extra configuration files and ssh"
@@ -80,28 +90,52 @@
 # Read the config file
 . $(PATH=$(cd $(dirname $0) && pwd):$PATH which nxloadconfig) --
 
+nx_user_exists()
+{
+	if [ "$SETUP_LOCAL_USER" = "yes" ]
+	then
+		egrep "^nx:" /etc/passwd >/dev/null
+	else
+		getent passwd nx >/dev/null
+	fi
+}	
+
 # Tries to add a system user
 useradd_nx()
 {
 	# In any case create the basedir of the HOME directory before, 
 	# because useradd will fail to make more than one directory
 	mkdir -p $(dirname "$NX_HOME_DIR")
-	
-	# Are uid specified
-	if [ -n "$SETUP_UID" ]
-	then
-		useradd -u $SETUP_UID -d $NX_HOME_DIR -s $PATH_BIN/nxserver nx
+
 	# Is it a debian?
-	elif [ -f /etc/debian_version ]
+	if [ -f /etc/debian_version -a -z "$SETUP_UID" ]
 	then
-		adduser --system --home $NX_HOME_DIR --shell $PATH_BIN/nxserver nx
-	# or is it a SuSE?
-	elif [ -f /etc/SuSE-release ]
-	then
-		useradd -r -d $NX_HOME_DIR -s $PATH_BIN/nxserver nx
-	# we don't know the system, fallback
+		USERADD_OPTIONS="--system --home $NX_HOME_DIR --shell $PATH_BIN/nxserver"
+		[ -n "$SETUP_GID" ] && USERADD_OPTIONS="--gid $SETUP_GID $USERADD_OPTIONS"
+		adduser $USERADD_OPTIONS nx
+	# no, its a "normal" useradd
 	else
-		useradd -d $NX_HOME_DIR -s $PATH_BIN/nxserver nx
+		USERADD_OPTIONS="-d $NX_HOME_DIR -s $PATH_BIN/nxserver"
+		[ -n $SETUP_GID ] && USERADD_OPTIONS="-g $SETUP_GID $USERADD_OPTIONS"
+		# uid specified?
+		if [ -n "$SETUP_UID" ]
+		then
+			USERADD_OPTIONS="-u $SETUP_UID $USERADD_OPTIONS"
+		# Is it a SuSE?
+		elif [ -f /etc/SuSE-release ]
+		then
+			USERADD_OPTIONS="-r $USERADD_OPTIONS"
+		fi
+
+		if [ "$SETUP_LOCAL_USER" = "yes" ]
+		then
+			[ -n "$SETUP_GID" ] && /usr/sbin/lgroupadd -g $SETUP_GID nx
+			luseradd $USERADD_OPTIONS nx
+		else
+			useradd $USERADD_OPTIONS nx
+		fi
+
+		
 	fi
 }
 
@@ -142,7 +176,7 @@
 	chmod 600 "$NX_LOGFILE"
 	echo "done"
 	
-	if ! { getent passwd | egrep -q "^nx:"; }
+	if ! nx_user_exists
 	then
 		echo -n "Setting up user nx ..."
 		useradd_nx
@@ -226,10 +260,17 @@
 
 uninstall_nx() 
 {
-	if { getent passwd | egrep -q "^nx:"; }
+	if nx_user_exists
 	then
 		echo -n "Removing user nx ..."
-		userdel nx
+		
+		if [ "$SETUP_LOCAL_USER" = "yes" ]
+		then
+			luserdel nx
+		else
+			userdel nx
+		fi
+			
 		echo "done"
 	fi
 	




More information about the Pkg-nx-commits mailing list