packages: rc-scripts-user/rc-scripts-user.spec, rc-scripts-user/userscripts...

sparky sparky at pld-linux.org
Tue Feb 1 02:09:20 CET 2011


Author: sparky                       Date: Tue Feb  1 01:09:20 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- updated to: 1.6
-- implemented script limit (by default only 20 scripts for each user)
-- only allow valid shells from /etc/shells (ignore comments, must be
   executable)
-- better service name

---- Files affected:
packages/rc-scripts-user:
   rc-scripts-user.spec (1.7 -> 1.8) , userscripts.init (1.5 -> 1.6) 

---- Diffs:

================================================================
Index: packages/rc-scripts-user/rc-scripts-user.spec
diff -u packages/rc-scripts-user/rc-scripts-user.spec:1.7 packages/rc-scripts-user/rc-scripts-user.spec:1.8
--- packages/rc-scripts-user/rc-scripts-user.spec:1.7	Mon Jan 31 22:06:25 2011
+++ packages/rc-scripts-user/rc-scripts-user.spec	Tue Feb  1 02:09:14 2011
@@ -3,7 +3,7 @@
 Summary:	Run user scripts
 Summary(pl.UTF-8):	Uruchom skrypty użytkownika
 Name:		rc-scripts-user
-Version:	1.5
+Version:	1.6
 Release:	1
 License:	GPL v2+
 Group:		Applications/System
@@ -53,6 +53,9 @@
 # Script priority
 NICE=15
 
+# maximum number of scripts run for every user
+MAX_USER_SCRIPTS=20
+
 # additional arguments for run-fast-or-hide,
 # check: run-fast-or-hide --help for more info
 # RUN_ARGS="-s 50000"
@@ -83,6 +86,13 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.8  2011/02/01 01:09:14  sparky
+- updated to: 1.6
+-- implemented script limit (by default only 20 scripts for each user)
+-- only allow valid shells from /etc/shells (ignore comments, must be
+   executable)
+-- better service name
+
 Revision 1.7  2011/01/31 21:06:25  glen
 - use .init suffix
 

================================================================
Index: packages/rc-scripts-user/userscripts.init
diff -u packages/rc-scripts-user/userscripts.init:1.5 packages/rc-scripts-user/userscripts.init:1.6
--- packages/rc-scripts-user/userscripts.init:1.5	Mon Jan 31 20:34:07 2011
+++ packages/rc-scripts-user/userscripts.init	Tue Feb  1 02:09:14 2011
@@ -14,6 +14,7 @@
 BANNED=""
 STOP_WAIT_TIME=2
 NICE=15
+MAX_USER_SCRIPTS=20
 RUN_ARGS=""
 
 # subdirectory with user scripts
@@ -23,7 +24,16 @@
 	. /etc/sysconfig/userscripts
 fi
 
-VALID_SHELLS=$(cat /etc/shells)
+service_name="User init.d scripts"
+
+VALID_SHELLS=""
+while read shell; do
+	case $shell in
+		/*)
+			[ -x "$shell" ] && VALID_SHELLS="$VALID_SHELLS $shell"
+			;;
+	esac
+done < /etc/shells
 
 is_on_list()
 {
@@ -68,6 +78,7 @@
 			continue
 		fi
 
+		local USER_SCRIPTS=0
 		for script in "$home/$scripts_dir"/*; do
 
 			# skip backups
@@ -77,6 +88,11 @@
 					;;
 			esac
 
+			if [ $((USER_SCRIPTS++)) -ge $MAX_USER_SCRIPTS ]; then
+				nls "Maximum number of scripts run for %s was reached" "$user"
+				break
+			fi
+
 			show "Running %s %s as %s" "$script" "$action" "$user"
 			busy
 
@@ -101,11 +117,11 @@
 start()
 {
 	if [ -f /var/lock/subsys/userscripts ]; then
-		msg_already_running "User scripts"
+		msg_already_running "$service_name"
 		return 1
 	fi
 
-	msg_starting "User scripts"; ok
+	msg_starting "$service_name"; ok
 
 	run_scripts start
 
@@ -115,13 +131,13 @@
 stop()
 {
 	if [ ! -f /var/lock/subsys/userscripts ]; then
-		msg_not_running "User scripts"
+		msg_not_running "$service_name"
 		return 2
 	fi
 
 	run_scripts stop
 
-	msg_stopping "User scripts"; busy
+	msg_stopping "$service_name"; busy
 
 	# give them some time to stop, but don't wait for finish
 	[ "$SCRIPTS_RUN" -gt 0 ] && sleep $STOP_WAIT_TIME
@@ -133,9 +149,9 @@
 status()
 {
 	if [ -f /var/lock/subsys/userscripts ]; then
-		nls "User scripts should be running";
+		nls "$service_name should be running";
 	else
-		nls "User scripts should be stopped";
+		nls "$service_name should be stopped";
 	fi
 }
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/rc-scripts-user/rc-scripts-user.spec?r1=1.7&r2=1.8&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/rc-scripts-user/userscripts.init?r1=1.5&r2=1.6&f=u



More information about the pld-cvs-commit mailing list