rpms/fedora-usermgmt/FC-5 fedora-usermgmt.spec, 1.11, 1.12 fedora-usermgmt-wrapper, 1.2, 1.3
Enrico Scholz (ensc)
fedora-extras-commits at redhat.com
Wed Jun 20 07:15:21 UTC 2007
Author: ensc
Update of /cvs/extras/rpms/fedora-usermgmt/FC-5
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv25059/FC-5
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/FC-5/fedora-usermgmt.spec,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- fedora-usermgmt.spec 25 Apr 2007 07:23:27 -0000 1.11
+++ fedora-usermgmt.spec 20 Jun 2007 07:14:45 -0000 1.12
@@ -9,7 +9,7 @@
Summary: Fedora tools for user management
Name: fedora-usermgmt
Version: 0.8
-Release: %release_func 3
+Release: %release_func 4
License: GPL
BuildArch: noarch
@@ -147,6 +147,9 @@
%changelog
+* Wed Jun 20 2007 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.8-4
+- added basic checks that CLI is used correctly
+
* Thu Mar 8 2007 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.8-3
- fixed and updated the documentation; especially, added the '-r'
option to the fedora-useradd example and mentioned the wiki page.
Index: fedora-usermgmt-wrapper
===================================================================
RCS file: /cvs/extras/rpms/fedora-usermgmt/FC-5/fedora-usermgmt-wrapper,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fedora-usermgmt-wrapper 10 Dec 2005 11:59:30 -0000 1.2
+++ fedora-usermgmt-wrapper 20 Jun 2007 07:14:45 -0000 1.3
@@ -20,25 +20,49 @@
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
BASE_DIR=/etc/fedora/usermgmt
+ARGS=( "$0" "$@" )
+
function invalidateCache {
local rc=0
{
# Enforce some nscd activity
- id root
- id nscd
+ id root || :
+ id nscd || :
# Clear the caches
/usr/sbin/nscd -i group || rc=1
/usr/sbin/nscd -i passwd || rc=1
# Enforce some nscd activity
- id root
- id nscd
+ id root || :
+ id nscd || :
} &>/dev/null
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