Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Jun 2018 22:09:43 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335308 - head/usr.sbin/bsdconfig/usermgmt/share
Message-ID:  <201806172209.w5HM9hQh068718@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Sun Jun 17 22:09:43 2018
New Revision: 335308
URL: https://svnweb.freebsd.org/changeset/base/335308

Log:
  bsdconfig: Fix a bug when editing users
  
  The usermgmt API was stomping on a global ($user_gid to be specific)
  so things would appear to work fine until you tried to make a second
  pass into the API with the now-tainted variable contents.
  
  Fixed by localizing menu-specific contents as to not leak outside API.
  
  PR:		bin/208774
  Reported by:	Martin Waschbuesch <martin@waschbuesch.de>
  MFC after:	1 week
  X-MFC-to:	stable/11, stable/10
  Sponsored by:	Smule, Inc.

Modified:
  head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr

Modified: head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
==============================================================================
--- head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr	Sun Jun 17 21:29:35 2018	(r335307)
+++ head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr	Sun Jun 17 22:09:43 2018	(r335308)
@@ -1020,13 +1020,6 @@ f_dialog_menu_user_add()
 		user_password_expires_on="$user_password_expire"
 	fi
 
-	# Attempt to translate a numeric GID into `number (name)'
-	if f_isinteger "$user_gid"; then
-		local user_group
-		user_group=$( pw groupshow -g "$user_gid" 2> /dev/null ) &&
-			user_gid="$user_gid (${user_group%%:*})"
-	fi
-
 	# Localize potentially hostile variables and escape their values
 	# to the local variable (see f_shell_escape() of `strings.subr')
 	local var
@@ -1038,6 +1031,14 @@ f_dialog_menu_user_add()
 		eval f_shell_escape \"\$user_$var\" _user_$var
 	done
 
+	# Attempt to translate a numeric GID into `number (name)'
+	if f_isinteger "$_user_gid"; then
+		local _user_group
+		_user_group=$( pw groupshow -g "$_user_gid" 2> /dev/null ) &&
+			_user_group="${_user_group%%:*}" &&
+			f_shell_escape "$_user_gid ($_user_group)" _user_gid
+	fi
+
 	menu_list="
 		'X' '$msg_add/$msg_exit'
 		'1' '$msg_login: $_user_name'
@@ -1137,13 +1138,6 @@ f_dialog_menu_user_delete()
 		user_password_expires_on="$user_password_expire"
 	fi
 
-	# Attempt to translate a numeric GID into `number (name)'
-	if f_isinteger "$user_gid"; then
-		local user_group
-		user_group=$( pw groupshow -g "$user_gid" 2> /dev/null ) &&
-			user_gid="$user_gid (${user_group%%:*})"
-	fi
-
 	# Localize potentially hostile variables and escape their values
 	# to the local variable (see f_shell_escape() of `strings.subr')
 	local var
@@ -1155,6 +1149,14 @@ f_dialog_menu_user_delete()
 		eval f_shell_escape \"\$user_$var\" _user_$var
 	done
 
+	# Attempt to translate a numeric GID into `number (name)'
+	if f_isinteger "$_user_gid"; then
+		local _user_group
+		_user_group=$( pw groupshow -g "$_user_gid" 2> /dev/null ) &&
+			_user_group="${_user_group%%:*}" &&
+			f_shell_escape "$_user_gid ($_user_group)" _user_gid
+	fi
+
 	menu_list="
 		'X' '$msg_delete/$msg_exit'
 		'1' '$msg_login: $_user_name'
@@ -1254,13 +1256,6 @@ f_dialog_menu_user_edit()
 		user_password_expires_on="$user_password_expire"
 	fi
 
-	# Attempt to translate a numeric GID into `number (name)'
-	if f_isinteger "$user_gid"; then
-		local user_group
-		user_group=$( pw groupshow -g "$user_gid" 2> /dev/null ) &&
-			user_gid="$user_gid (${user_group%%:*})"
-	fi
-
 	# Localize potentially hostile variables and escape their values
 	# to the local variable (see f_shell_escape() of `strings.subr')
 	local var
@@ -1271,6 +1266,14 @@ f_dialog_menu_user_edit()
 		local _user_$var
 		eval f_shell_escape \"\$user_$var\" _user_$var
 	done
+
+	# Attempt to translate a numeric GID into `number (name)'
+	if f_isinteger "$_user_gid"; then
+		local _user_group
+		_user_group=$( pw groupshow -g "$_user_gid" 2> /dev/null ) &&
+			_user_group="${_user_group%%:*}" &&
+			f_shell_escape "$_user_gid ($_user_group)" _user_gid
+	fi
 
 	menu_list="
 		'X' '$msg_save/$msg_exit'



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806172209.w5HM9hQh068718>