[interchange-cvs] interchange - jon modified SPECS/interchange-cron

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Dec 4 09:51:24 EST 2003


User:      jon
Date:      2003-12-04 14:51:24 GMT
Modified:  SPECS    interchange-cron
Log:
Allow symlinks when removing empty directories too.
Use login shell for su to avoid cwd and shell init problems.
Explain things a little better.

Revision  Changes    Path
2.2       +10 -3     interchange/SPECS/interchange-cron


rev 2.2, prev_rev 2.1
Index: interchange-cron
===================================================================
RCS file: /var/cvs/interchange/SPECS/interchange-cron,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -u -r2.1 -r2.2
--- interchange-cron	3 Dec 2003 19:39:12 -0000	2.1
+++ interchange-cron	4 Dec 2003 14:51:24 -0000	2.2
@@ -1,11 +1,16 @@
 #!/bin/sh
 
-# purge expired Interchange session and tmp files
+# Script to purge expired Interchange session and tmp files
+#
+# Before anything else we assure that we run only as the 'interch' user
+# because we allow 'find' to follow symlinks (e.g. to handle session
+# directories put on a RAM disk or NFS mount), which could be a
+# security risk if run as another user.
 
 icuser=interch
 myuid=`id -u`
 if [ "$myuid" = 0 ]; then
-	exec su -c "$0" $icuser
+	exec su -c "$0" - $icuser
 elif [ "$myuid" -ne "`id -u $icuser`" ]; then
 	echo "Aborting Interchange session/tmp file purge" >&2
 	echo "Must run as root or user '$icuser', not user '`id -u -n`'" >&2
@@ -16,5 +21,7 @@
 do
 	[ -d $i ] || continue
 	find $i -type f -follow -mtime +1 | xargs -r rm -f
-	find $i -type d -empty -depth -mindepth 1 | xargs -r rmdir --ignore-fail-on-non-empty
+	find $i -type d -follow -empty -depth -mindepth 1 | xargs -r rmdir --ignore-fail-on-non-empty
 done
+
+exit 0








More information about the interchange-cvs mailing list