[K12OSN] Student Process Reaper Script
Dennis Daniels
ddaniels at magic.fr
Sat Sep 4 01:37:33 UTC 2004
Hmm, very nice! I wonder if there might be a GUI for grouping user
access perms to applications... for a couple of my students I don't want
them playing any games at all! :)
great idea Henry!
Dennis
Henry Burroughs wrote:
> I wrote a script this morning to keep the students in my classes from
> playing games/chess/web browsing during my classes (I don't want to
> uninstall games, and that doesn't stop the browsing). Basically, the
> script is an infinite loop (always wanted to have a "while (true)" loop)
> that reads 2 variables from a file that you specify on the command line
> (ctrl-c stops it). It just loops and does a ps list for each user and
> picks the pids of the programs you don't want them to run, and kills
> them... here's the contents from my 1st period file I use:
>
> #1st_period.reap
> #1st Period - no mozilla, no chess, no Maelstrom
> REAP_USERS="cfraser afuller mandrews rladd cpawley"
>
> REAP_PROGS="mozilla-bin gnuchess Maelstrom"
>
>
> So I run ./class_reaper.sh 1st_period.reap
>
>
> You have to run it as root at the moment... DO NOT RUN THIS USING
> SUDO!!!!!!!!!!!
> As you can imagine, a malicious user who has access to run it could
> terminate any users programs, as well as gdm, root, etc!!!! If someone
> wants to make it SUDO safe (ie: protect root, etc... or users under a
> UID # range), and not kill users within specific groups (ie:
> Faculty).... you are quite welcome to.
>
> I've thought about making it interactive... ie: as students finish an
> assignment, I can release them while not having to terminate the script
> and reload the new text file.
>
>
> Henry Burroughs
> Technology Director
> Hilton Head Preparatory School
> www.hhprep.org
> hburroughs at hhprep.org
>
>
> ------------------------------------------------------------------------
>
> # Class/period process reaper
> # Copyright Henry Burroughs
>
> # This program is free software; you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> # the Free Software Foundation; either version 2 of the License, or
> # (at your option) any later version.
>
> # This program is distributed in the hope that it will be useful,
> # but WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> # GNU General Public License for more details.
>
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>
>
> #!/bin/bash
>
> if [ $# -ne 1 ]; then
> echo "Please provide file with REAP_USERS & REAP_PROGS variables";
> exit;
> fi
>
> . $1 #Load info
>
> #BUILD GREPLIST
> for prog in $REAP_PROGS; do
> GREP_LIST="$GREP_LIST -e $prog";
> done
>
> while (true); do
> for user in $REAP_USERS; do
> PROG_LIST=`ps h -u $user 2> /dev/null | grep $GREP_LIST`;
> #echo $PROG_LIST|cut -d" " -f 1;
> kill `echo $PROG_LIST|cut -d" " -f 1` 2> /dev/null;
> done
> done
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
More information about the K12OSN
mailing list