rpms/fedora-usermgmt/F-7 fedora-usermgmt.spec, 1.14, 1.15 fedora-usermgmt-wrapper, 1.3, 1.4

Enrico Scholz (ensc) fedora-extras-commits at redhat.com
Wed Jun 20 07:15:26 UTC 2007


Author: ensc

Update of /cvs/extras/rpms/fedora-usermgmt/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv25059/F-7

Modified Files:
	fedora-usermgmt.spec fedora-usermgmt-wrapper 
Log Message:
added basic checks that CLI is used correctly



Index: fedora-usermgmt.spec
===================================================================
RCS file: /cvs/extras/rpms/fedora-usermgmt/F-7/fedora-usermgmt.spec,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- fedora-usermgmt.spec	25 Apr 2007 07:24:50 -0000	1.14
+++ fedora-usermgmt.spec	20 Jun 2007 07:14:51 -0000	1.15
@@ -8,8 +8,8 @@
 
 Summary:	Fedora tools for user management
 Name:		fedora-usermgmt
-Version:	0.9
-Release:	%release_func 2
+Version:	0.10
+Release:	%release_func 1
 
 License:	GPL
 BuildArch:	noarch
@@ -188,6 +188,9 @@
 
 
 %changelog
+* Wed Jun 20 2007 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.10-1
+- added basic checks that CLI is used correctly
+
 * Wed Apr 25 2007 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.9-2
 - fixed version in the Provides/Obsoletes of -default-fedora-setup (bz
   #237457)


Index: fedora-usermgmt-wrapper
===================================================================
RCS file: /cvs/extras/rpms/fedora-usermgmt/F-7/fedora-usermgmt-wrapper,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- fedora-usermgmt-wrapper	15 Sep 2006 06:25:42 -0000	1.3
+++ fedora-usermgmt-wrapper	20 Jun 2007 07:14:51 -0000	1.4
@@ -20,6 +20,8 @@
 PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
 BASE_DIR=/etc/fedora/usermgmt
 
+ARGS=( "$0" "$@" )
+
 function invalidateCache {
     local rc=0
     {
@@ -39,6 +41,28 @@
     return $rc
 }
 
+function panic {
+    echo "$*; aborting" >&2
+    logger -p auth.err -t "fedora-usermgmt[$$]" "$@"
+    logger -p auth.err -t "fedora-usermgmt[$$]" "cmd: [${ARGS[*]}]"
+    exit 1
+}
+
+# Usage: validateHint <result-var> <offset> <hint>
+function validateHint {
+    local tmp
+
+    let tmp="${3}"1
+    test $tmp -ne 0 || \
+	panic $"Hint '$3' is not a numeric value"
+
+    let tmp="$2"+"$3"
+    test $tmp -ge 0 || \
+	panic $"Hint '$3' evaluates to a negative value ($tmp)"
+
+    eval $1=\$tmp
+}
+
 test -r "$BASE_DIR/baseuid" && BASE_UID=`cat "$BASE_DIR/baseuid"` || BASE_UID=300
 test -r "$BASE_DIR/basegid" && BASE_GID=`cat "$BASE_DIR/basegid"` || BASE_GID=$BASE_UID
 
@@ -57,12 +81,10 @@
 	    exit 0
 	}
 
-	test "$#" -ge 2 || {
-	    echo $"Missing argument; use '--help' for more information";
-	    exit 1
-	}
+	test "$#" -ge 2 || \
+	    panic $"Missing argument; use '--help' for more information";
 
-	v=$[ BASE_UID + $1 ]
+	validateHint v "$BASE_UID" "$1"
 	shift
 	set -- "$v" "$@"
 	;;
@@ -72,12 +94,10 @@
 	    exit 0
 	}
 
-	test "$#" -ge 2 || {
-	    echo $"Missing argument; use '--help' for more information";
-	    exit 1
-	}
+	test "$#" -ge 2 || \
+	    panic $"Missing argument; use '--help' for more information";
 
-	v=$[ BASE_GID + $1 ]
+	validateHint v "$BASE_GID" "$1"
 	shift
 	set -- "$v" "$@"
 	;;
@@ -91,10 +111,8 @@
     exec 2>>"$BASE_DIR/log"
 fi
 
-test -n "$exec_name" || {
-    echo $"Wrapper could not be found; aborting" >&2
-    exit 1
-}
+test -n "$exec_name" || \
+    panic $"Wrapper could not be found"
 
 invalidateCache
 "$exec_name" "$@"




More information about the fedora-extras-commits mailing list