--- killer-0.90.orig/debian/rules +++ killer-0.90/debian/rules @@ -0,0 +1,18 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/class/makefile.mk +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/dpatch.mk + +DEB_MAKE_CLEAN_TARGET = clean + +DEB_INSTALL_DOCS_ALL = ChangeLog + +DESTDIR = debian/$(cdbs_curpkg)$(pkgdir) +bindir = /usr/sbin +man1dir = /usr/share/man/man1 + +install/killer:: + install -d $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) + install killer $(DESTDIR)$(bindir) + install -m 644 killer.1 $(DESTDIR)$(man1dir) --- killer-0.90.orig/debian/control +++ killer-0.90/debian/control @@ -0,0 +1,23 @@ +Source: killer +Section: misc +Priority: optional +Maintainer: Debian Edu Developers +Uploaders: Petter Reinholdtsen , José L. Redrejo Rodríguez +Build-Depends: debhelper (>= 5.0.0), cdbs, perl, dpatch +Standards-Version: 3.8.0 +Vcs-Svn: svn://svn.debian.org/svn/debian-edu/trunk/src/killer +Vcs-Browser: http://svn.debian.org/wsvn/debian-edu/trunk/src/killer + +Package: killer +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, exim4 | mail-transport-agent +Description: Background job killer + killer is a perl script that gets rid of background jobs. Background + jobs are defined as processes that belong to users who are not currently + logged into the machine. Jobs can be run in the background (and are + exempt from *killer*'s actions) if their scheduling priority has been + reduced by increasing their nice(1) value or if they are being run + through condor. + . + When the package is installed, a cron job is installed to run killer + once an hour. --- killer-0.90.orig/debian/compat +++ killer-0.90/debian/compat @@ -0,0 +1 @@ +5 --- killer-0.90.orig/debian/copyright +++ killer-0.90/debian/copyright @@ -0,0 +1,15 @@ +This package was debianized by the author Petter Reinholdtsen + on Tue Jan 29 22:00:27 CET 2008. + +It was downloaed from +. + +The killer package is copyright Michael Gerdts . + +These scripts are 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, or (at your option) any +later version. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. --- killer-0.90.orig/debian/changelog +++ killer-0.90/debian/changelog @@ -0,0 +1,85 @@ +killer (0.90-7) unstable; urgency=low + + * Fix linux-ps-longusernames.dpatch to also handle long usernames in + ruser, to avoid killing processes of user with usernames > 8 + characters (Closes: #551753). + + -- Petter Reinholdtsen Mon, 25 Jan 2010 19:03:03 +0100 + +killer (0.90-6) unstable; urgency=low + + * Fix typo in linux-ps-longusernames.dpatch, returning the password + hash instead of the username. + + -- Petter Reinholdtsen Mon, 7 Jul 2008 10:29:42 +0200 + +killer (0.90-5) unstable; urgency=low + + * Rewrite patch x-console to drop code to use uid instead of username + for console users. It was based on a misunderstanding regarding the + source of the uids (Closes: #467499). + * New patch linux-ps-longusernames to look up uids returned from ps to + get the usernames, to work around the misfeature in ps only showing + uids for users with usernames > 8 characters. + * Change kdm console detection code to recognize any X display, not + just :0. + * Updated standards-version from 3.7.3 to 3.8.0. No changes needed. + + -- Petter Reinholdtsen Sun, 6 Jul 2008 12:46:16 +0200 + +killer (0.90-4) unstable; urgency=low + + [ José L. Redrejo Rodríguez ] + * Use getent to get the uid as getpwname does not work correctly with + ldap authenticated users. + + [ Petter Reinholdtsen ] + * Fix typos in the package description (Closes: #470017). + + -- Petter Reinholdtsen Sun, 16 Mar 2008 11:37:35 +0100 + +killer (0.90-3) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Added patch linux-nice-level to deduce nice limit from 20 + (impossible on Linux as 19 is max) to 9. + * Added patch default-email to change default emails from killer@ to + root@. + * Make package group maintained by Debian Edu and add + José L. Redrejo Rodríguez as uploader. + * debian/patches/x-console.dpatch modified to avoid killing the user + logged via gdm/kdm + * Add Vcs-Svn and Vcs-Browse headers to the control file. + + [ José L. Redrejo Rodríguez ] + * Modify how console users idle time is calculated. + * debian/patches/update-valid-users.dpatch to avoid killing daemons + running under the nobody login. + + -- Petter Reinholdtsen Wed, 27 Feb 2008 08:22:07 +0100 + +killer (0.90-2) unstable; urgency=low + + * Split all patches into separate files in debian/patch, to make + them easier to submit upstream. Uses dpatch. + * Added patch to handle kdm and gdm logins better. + * Added patch to implement new option -n to tryrun only (not killing + anything) and -d for debug output. + * Make sure to use LC_ALL=POSIX to avoid different output depending + on locale. + * Add /dev/input/mice to list of devices to check for the console user. + + -- Petter Reinholdtsen Sat, 16 Feb 2008 14:30:41 +0100 + +killer (0.90-1) unstable; urgency=low + + * Initial upload (Closes: #463161). + * Patches relative to upstream: + - Do not kill processes belonging to users with uid below 1000. + - Correct path to the ps command. + - Make sure to work even without the domainname program. + - Fix clean target to remove files generated by pod2html generated. + * Add cron.hourly file to call killer once an hour to kill + background jobs. + + -- Petter Reinholdtsen Wed, 30 Jan 2008 13:59:09 +0100 --- killer-0.90.orig/debian/cron.hourly +++ killer-0.90/debian/cron.hourly @@ -0,0 +1,3 @@ +#!/bin/sh + +[ -x /usr/sbin/killer ] && /usr/sbin/killer --- killer-0.90.orig/debian/patches/00list +++ killer-0.90/debian/patches/00list @@ -0,0 +1,12 @@ +empty-domain +ignore-system-uids +ps-path +x-console +proper-clean +no-kill-opt +posix-locale +console-devs +linux-nice-level +default-email +update-valid-users +linux-ps-longusernames --- killer-0.90.orig/debian/patches/x-console.dpatch +++ killer-0.90/debian/patches/x-console.dpatch @@ -0,0 +1,39 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Detect kdm and gdm logins as console users. +In that case jump over the initializeTty routine. +This is example output from who in this case: + +% who +kdmuser :0 2008-01-22 15:58 +% + +% who +gdmuser tty7 2008-02-14 20:21 (:0) +% + +@DPATCH@ + +--- killer-0.90~/killer 2008-02-26 10:44:58.000000000 +0100 ++++ killer-0.90/killer 2008-02-28 13:52:20.000000000 +0100 +@@ -876,10 +876,16 @@ + while ( ) { + chop; + @parts = split(/[ \t]+/); +- if ( $parts[1] eq 'console' ) { +- $consoleuser = $parts[0]; +- } +- $self->initializeTty($parts[1], stat("/dev/" . $parts[1])); ++ if ( $parts[1] eq 'console' ++ || $parts[1] =~ '^:\d+$' # kdm ++ || $parts[1] =~ '^tty\d$' # gdm ++ ) { ++ $consoleuser = $parts[0]; ++ $tty2idletime{$parts[1]}=0; ++ push (@{$user2ttys{$consoleuser}}, $parts[1]); ++ } else { ++ $self->initializeTty($parts[1], stat("/dev/" . $parts[1])); ++ } + } + close(W); + } --- killer-0.90.orig/debian/patches/linux-ps-longusernames.dpatch +++ killer-0.90/debian/patches/linux-ps-longusernames.dpatch @@ -0,0 +1,23 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Improve handling of long usernames on Linux, where ps will print the +uid if the username is more than 8 characters logn. + - Petter Reinholdtsen 2008-07-06 + +@DPATCH@ +diff -urNad killer~/killer killer/killer +--- killer~/killer 2010-01-25 19:01:46.000000000 +0100 ++++ killer/killer 2010-01-25 19:02:08.000000000 +0100 +@@ -238,7 +238,11 @@ + + ($user, $ruser, $uid, $ruid, $tty, $pid, $ppid, $nice, $comm) + = split( /[ \t]+/, $_, 9 ); +- ++ ++ # Linux ps report uid when username is longer than 8 characters. ++ $user = (getpwuid($user))[0] if ($user =~ m/^\d+/); ++ $ruser = (getpwuid($ruser))[0] if ($ruser =~ m/^\d+/); ++ + $pid2user{$pid} = $user; + $pid2ruser{$pid} = $ruser; + $pid2uid{$pid} = int $uid; --- killer-0.90.orig/debian/patches/console-devs.dpatch +++ killer-0.90/debian/patches/console-devs.dpatch @@ -0,0 +1,16 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Check relevant devices for console access. + +@DPATCH@ +--- killer-0.90.orig/killer ++++ killer-0.90/killer +@@ -963,7 +963,7 @@ + if ( $consoleuser eq $user ) { + my (@statparts, $device); + foreach $device ( '/dev/ps2mouse', '/dev/ps2kbd', '/dev/mouse', +- '/dev/kbd' ) { ++ '/dev/kbd', '/dev/input/mice' ) { + @statparts = stat($device); + next unless defined($statparts[8]); + --- killer-0.90.orig/debian/patches/ignore-system-uids.dpatch +++ killer-0.90/debian/patches/ignore-system-uids.dpatch @@ -0,0 +1,47 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Make sure to not kill processes for system users (uid < 1000). + +@DPATCH@ +--- killer-0.90.orig/killer ++++ killer-0.90/killer +@@ -1085,6 +1086,14 @@ + + my @validusers = ( 'condor', 'root', 'daemon' ); + ++=item $minuid ++ ++Do not kill processes of users with uid lower than this value. ++ ++=cut ++ ++my $minuid = 1000; ++ + =item $maxidletime + + The maximum number of seconds that a user can be idle without being +@@ -1123,6 +1132,7 @@ + my @ttys; + my @users; + my $user; ++my $uid; + + =head2 gatherInfo + +@@ -1205,6 +1215,16 @@ + + =item * + ++Removes all processes of users with uid lower than the $minuid value. ++ ++=cut ++ ++ foreach $uid ( 0 .. $minuid-1 ) { ++ $ptable->removeProcesses('uid', $uid); ++ } ++ ++=item * ++ + Finally, the process table and terminal objects are returned. + + =back --- killer-0.90.orig/debian/patches/proper-clean.dpatch +++ killer-0.90/debian/patches/proper-clean.dpatch @@ -0,0 +1,16 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Remove generated files. + +@DPATCH@ +--- killer-0.90.orig/Makefile ++++ killer-0.90/Makefile +@@ -19,7 +19,7 @@ + pod2text $(SCRIPTNAME) > $(SCRIPTNAME).txt + + clean: +- -rm -f $(TARGETS) pod2html-*cache ++ -rm -f $(TARGETS) pod2html-*cache pod2htm*.tmp + + install: + @echo "You probably want to customize the script then copy it into place yourself." 1>&2 --- killer-0.90.orig/debian/patches/posix-locale.dpatch +++ killer-0.90/debian/patches/posix-locale.dpatch @@ -0,0 +1,17 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Make sure all processes have a well defined locale. + +@DPATCH@ +diff -urNad killer-0.90~/killer killer-0.90/killer +--- killer-0.90~/killer 2008-02-16 12:42:01.000000000 +0100 ++++ killer-0.90/killer 2008-02-16 12:42:01.000000000 +0100 +@@ -1125,6 +1125,8 @@ + # End of (intended) configuration options. + # ######## + ++$ENV{LC_ALL} = 'POSIX'; ++ + =back + + If I am a user really trying to avoid a background job killer, I would --- killer-0.90.orig/debian/patches/update-valid-users.dpatch +++ killer-0.90/debian/patches/update-valid-users.dpatch @@ -0,0 +1,19 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Added nobody as a valid user whose processes won't be killed. +There are several daemons that run under that login + - José L. Redrejo Rodríguez 2008-02-26 + +@DPATCH@ + +--- killer-0.90~/killer 2008-02-26 10:44:58.000000000 +0100 ++++ killer-0.90/killer 2008-02-26 12:24:11.000000000 +0100 +@@ -1083,7 +1083,7 @@ + + =cut + +-my @validusers = ( 'condor', 'root', 'daemon' ); ++my @validusers = ( 'condor', 'root', 'daemon', 'nobody' ); + + =item $maxidletime + --- killer-0.90.orig/debian/patches/ps-path.dpatch +++ killer-0.90/debian/patches/ps-path.dpatch @@ -0,0 +1,17 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Fix path to ps. + +@DPATCH@ +diff -urNad killer-0.90~/killer killer-0.90/killer +--- killer-0.90~/killer 2008-02-16 12:42:19.000000000 +0100 ++++ killer-0.90/killer 2008-02-16 12:42:19.000000000 +0100 +@@ -132,7 +132,7 @@ + =cut + + # On HP-UX be sure that env var UNIX95 is defined for ps -o to work! +-my $pscmd = '/usr/bin/ps -e -o "user ruser uid ruid tty pid ppid nice comm"'; ++my $pscmd = '/bin/ps -e -o "user ruser uid ruid tty pid ppid nice comm"'; + + my $errmsg; + --- killer-0.90.orig/debian/patches/no-kill-opt.dpatch +++ killer-0.90/debian/patches/no-kill-opt.dpatch @@ -0,0 +1,121 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +New option -n to not kill, just print out what would be killed. + +@DPATCH@ +diff -urNad killer-0.90~/killer killer-0.90/killer +--- killer-0.90~/killer 2008-02-16 13:25:28.000000000 +0100 ++++ killer-0.90/killer 2008-02-16 13:27:50.000000000 +0100 +@@ -36,7 +36,7 @@ + + =head1 SYNOPSIS + +-killer [B<-h>] [B<-V>] ++killer [B<-h>] [B<-V>] [B<-n>] [B<-d>] + + =head1 DESCRIPTION + +@@ -66,6 +66,14 @@ + + Display version number + ++=item -n ++ ++Do not kill, just print what would be killed ++ ++=item -d ++ ++Enable debug output ++ + =back + + =cut +@@ -145,6 +153,8 @@ + my %pid2nice = (); # nice value + my %pid2comm = (); # Command name being executed + my %remainingprocs = (); # The processes that have not been eliminated ++my $noop = 0; ++my $debug = 0; + + =head2 new + +@@ -220,7 +230,7 @@ + # skip the first line of input + ; + while () { +- #print "\t$_"; ++ print "\t$_" if $debug; + chop; + + # strip leading white space +@@ -805,11 +815,16 @@ + my $killcount = 0; + + foreach my $pid ( keys %remainingprocs ) { +- if ( kill($signum, $pid) > 0 ) { +- $killcount ++; +- syslog('info', "kill($signum, $pid) user=%s command=%s nice=%d", ++ my $msg = sprintf("kill($signum, $pid) user=%s command=%s nice=%d", + $pid2ruser{$pid}, $pid2comm{$pid}, + $pid2nice{$pid}); ++ if ($noop) { ++ print "$msg\n"; ++ } else { ++ if ( kill($signum, $pid) > 0 ) { ++ $killcount ++; ++ syslog('info', "%s", $msg); ++ } + } + } + return $killcount; +@@ -1014,6 +1029,14 @@ + print STDERR "Type \"perldoc $0\" for lots of help.\n"; + next; + }; ++ $opt eq '-n' && do { ++ $noop = 1; ++ next; ++ }; ++ $opt eq '-d' && do { ++ $debug = 1; ++ next; ++ }; + $opt eq '-V' && do { + print STDERR "killer version $version\n"; + next; +@@ -1021,7 +1044,7 @@ + print STDERR "killer: option \"$opt\" not recognized\n"; + print STDERR "Type \"perldoc $0\" for lots of help.\n"; + } +- exit(1); ++ exit(1) unless ($noop || $debug); + } + + =head1 PACKAGE main +@@ -1269,7 +1269,7 @@ + print $outfile "Attempt 1: Nicely killing the following processes\n"; + $ptable->printRemainingProcesses($outfile); + $ptable->killAll(15); +-sleep(30); ++sleep(30) unless $noop; + $ptable->killAll(9); + + # ######### +@@ -1279,7 +1279,7 @@ + # be spawned. This should catch fork() bombs as well + # ########## + +-sleep(5); ++sleep(5) unless $noop; + ($ptable, $term) = gatherInfo(); + ( @remaining ) = $ptable->getRemainingProcesses(); + if ( $#remaining == -1 ) { +@@ -1301,7 +1301,7 @@ + # the processes. Let's just whine through email. + # ######## + +-sleep(5); ++sleep(5) unless $noop; + ($ptable, $term) = gatherInfo(); + ( @remaining ) = $ptable->getRemainingProcesses(); + if ( $#remaining == -1 ) { --- killer-0.90.orig/debian/patches/linux-nice-level.dpatch +++ killer-0.90/debian/patches/linux-nice-level.dpatch @@ -0,0 +1,30 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Reduce nice limit from 20 (impossible on Linux as 19 is max) to 9. +Using nice with no arguments set nice level to 10, and those should +be allowed to live, I believe. + - Petter Reinholdtsen 2008-02-20 + +@DPATCH@ +--- killer-0.90.orig/killer ++++ killer-0.90/killer +@@ -655,8 +655,8 @@ + + =head2 removeNiceJobs + +-This function removes all jobs that have a nice value greater than 20. +-That is, they have a lower sceduling priority than the default. ++This function removes all jobs that have a nice value greater than 9. ++That is, they have a lower sceduling priority than the default (0). + + Example: + +@@ -674,7 +674,7 @@ + # Get rid of things not in the "default" scheduling class + next unless ($val =~ /^[0-9]+$/); + +- if ( int($val) > 20 ) { ++ if ( int($val) > 9 ) { + $self->removeProcessId($key); + } + } --- killer-0.90.orig/debian/patches/empty-domain.dpatch +++ killer-0.90/debian/patches/empty-domain.dpatch @@ -0,0 +1,19 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Use 'localhost' as domain if it is currently unset. + +@DPATCH@ +diff -u killer-0.90/killer killer-0.90/killer +--- killer-0.90/killer ++++ killer-0.90/killer +@@ -1042,8 +1042,9 @@ + # Configuration options: + # ######## + ++my $domainname = `domainname 2>/dev/null || true`; +-my $domainname = `domainname`; + chop $domainname; ++$domainname = "localhost" unless ($domainname); + + =item $forkadmin + --- killer-0.90.orig/debian/patches/default-email.dpatch +++ killer-0.90/debian/patches/default-email.dpatch @@ -0,0 +1,34 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run + +Change default email to use when reporting problems. + +@DPATCH@ +--- killer-0.90.orig/killer ++++ killer-0.90/killer +@@ -1051,7 +1053,7 @@ + + =cut + +-my $forkadmin = "killer\@$domainname"; ++my $forkadmin = "root\@$domainname"; + + =item $killadmin + +@@ -1059,7 +1061,7 @@ + + =cut + +-my $killadmin = "killer\@$domainname"; ++my $killadmin = "root\@$domainname"; + + =item $fromaddr + +@@ -1075,7 +1077,7 @@ + + =cut + +-my $stubbornadmin = "killer\@$domainname"; ++my $stubbornadmin = "root\@$domainname"; + + =item @validusers +