debian/0000755000000000000000000000000011475466250007200 5ustar debian/prerm0000644000000000000000000000016611466674730010257 0ustar #!/bin/sh set -e PATH=/bin:/usr/bin:/usr/sbin #DEBHELPER# rm -rf /var/lib/autolog invoke-rc.d autolog stop exit 0 debian/docs0000644000000000000000000000000711466674730010054 0ustar README debian/copyright0000644000000000000000000000166311466674730011145 0ustar This package was debianized by Christoph Lameter on Sat, 7 Dec 1996 11:16:50 -0800. on Wed Jan 8 14:22:28 PST 2003 It was downloaded from http://metalab.unc.edu/pub/Linux/system/admin/idle/ Copyright, Christoph Lameter License: Copyright 1996 by Christoph Lameter 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. On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2'. debian/postrm0000644000000000000000000000046611475466167010464 0ustar #!/bin/sh set -e #DEBHELPER# if [ "$1" = "purge" ]; then if find /var/log -maxdepth 1 -name autolog.log -o -name autolog.log.[0-9].gz | grep -q var ; then echo -n Removing logfiles... rm -f /var/log/autolog.log /var/log/autolog.log.[0-9].gz echo done. fi update-rc.d autolog remove >/dev/null fi debian/watch0000644000000000000000000000012211466674730010230 0ustar version=3 http://www.ibiblio.org/pub/Linux/system/admin/idle/autolog-(.*)\.tar.gz debian/source/0000755000000000000000000000000011466674730010504 5ustar debian/source/format0000644000000000000000000000001411466674730011712 0ustar 3.0 (quilt) debian/rules0000755000000000000000000000247611466674730010275 0ustar #!/usr/bin/make -f # DH_VERBOSE=1 # policy manual, section 10.1 CFLAGS = -Wall -g ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif package = autolog build: dh_testdir make touch build clean: dh_testdir dh_testroot rm -f build [ ! -f Makefile ] || $(MAKE) clean dh_clean rm -f `find . -name "*~"` binary-indep: build dh_testdir # There are no architecture-independent files to be uploaded # generated by this package. If there were any they would be # made here. binary-arch: build dh_testdir dh_testroot rm -rf debian/$(package) install -d debian/$(package)/etc debian/$(package)/etc/logrotate.d debian/$(package)/etc/init.d make install DESTDIR=`pwd`/debian/$(package) CFLAGS="$(CFLAGS)" install -m644 debian/logrotate debian/$(package)/etc/logrotate.d/autolog install -m644 autolog.init debian/$(package)/etc/init.d/autolog dh_installdirs usr/share/lintian/overrides/ dh_install debian/overrides/autolog usr/share/lintian/overrides/ dh_installdocs -n dh_installexamples dh_installchangelogs CHANGES dh_installcron dh_installman debian/autolog.8 debian/autolog.conf.5 dh_strip dh_compress dh_fixperms dh_installdebconf dh_shlibdeps dh_gencontrol dh_installdeb dh_md5sums dh_builddeb # Below here is fairly generic really binary: binary-indep binary-arch debian/autolog.80000644000000000000000000000513011466674730010746 0ustar .TH AUTOLOG 8 "Administrative Utilities" "Linux" \" -*- nroff -*- .SH NAME autolog \- Log out idle users .SH SYNOPSIS \fBautolog\fP [ \fBoptions\fP ] .br .SH DESCRIPTION The program reads the utmp file, entry by entry. The username for each 'user process' is compared to the entries in the configuration file (see .B autolog.conf(5) ). The first entry to match both the name, the group, and the tty line of the process will be used to conduct the automatic logout. .SH CALL .TP .B /etc/init.d/autolog start .PD 0 .TP or .TP .B autolog to run this program in daemon-mode .PD .TP .B autolog -o to run this program as "ordinary" program. Keep in mind: Also when running as ordinary program, it will stay in memory until all its jobs are done. .SH OPTIONS .TP .B -a (all processes) Print information on ALL utmp entries--not just user processes. .TP .B -d (debug mode) This is helpful in setting up your configuration file. The program runs in foreground rather than forking and it prints out verbose messages about what it is doing. .TP .B -n (nokill) Use this to prevent autolog from actually "killing" anyone. Use \-d and \-n together when setting up a new configuration file. ( This will not affect killing of lost processes. ) .TP .B -o (ordinary) Use this to run this program as ordinary program, not as daemon. Program will end, when its job is done. In this case, some data is kept in "/var/lib/autolog/autolog.data". This is read, when the program is called again. .TP .B -f config_file_name Use this to override the default: "/etc/autolog.conf" .TP .B -l log_file_name Use this to override the default: "/var/log/autolog.log". Note that if this file doesn't exist, no logging will happen. Create the file (with touch) to enable logging. .TP .B -t idle_time Use this to override the internal default idle time (minutes) .TP .B -g grace_period Use this to override the internal default grace period (seconds) .TP .B -m yes/no Use this to override the internal mailing switch. If "yes" the program will send mail to the users right after killing them. .TP .B -c yes/no Use this to override the internal "pre-clear" switch. If "yes" the program will clear the terminal screen before warning the user. .TP .B -w yes/no Do timeouts based on total session time--not idle time. (hard) .TP .B -l yes/no If set to "yes" activities will be written to the logfile if present. .SH AUTHOR Kyle Bateman (autolog 0.35), .PD 0 .TP Carsten Juerges .TP (autolog 0.40) .PD .PP This manual page was modified for \fBDebian\fP by Paul Telford debian/README.debian0000644000000000000000000000104711466674730011307 0ustar Note that if using the '-o' flag, the data will be saved in /var/lib/autolog (to comply with FHS) -- I modified the man page to note this, but left the original README file alone. The autolog daemon will be activated after you install or upgrade it and will log users out after two hours of idle time. If you do not want this then either customize /etc/autolog.conf and /etc/rc.d/autolog according to your needs or uninstall autolog. If you are installing or upgrading remotely, then this might disconnect you when you leave things unattended. debian/control0000644000000000000000000000074611466674730010616 0ustar Source: autolog Build-Depends: debhelper (>= 5) Section: admin Priority: extra Maintainer: Luis Uribe Standards-Version: 3.9.1 Homepage: http://gitorious.org/debian-packages/autolog Package: autolog Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends}, cron (>= 3.0pl1-42) Recommends: exim4|mail-transport-agent Description: Terminates connections for idle users Autolog terminates connections considered to be idle based on a large variety of parameters. debian/logrotate0000644000000000000000000000013711466674730011130 0ustar /var/log/autolog.log { notifempty rotate 4 size 100k weekly compress missingok create } debian/overrides/0000755000000000000000000000000011466674730011206 5ustar debian/overrides/autolog0000644000000000000000000000006411466674730012603 0ustar autolog: extended-description-is-probably-too-short debian/autolog.conf.50000644000000000000000000001005211466674730011666 0ustar .TH autolog.conf 5 "Configuration Files" "Linux" \" -*- nroff -*- .SH NAME autolog.conf \- Configuration file for the autolog command .SH DESCRIPTION The configuration file consists of multiple lines, each of which describes a class of processes subject (or not subject) to a certain auto logout procedure. A line consists of any number of switches. Value switches are of the form: "name=value". Boolean switches are of the form: "name" or "noname". .PP Using these switches, you can define a username, a group, and a tty line. These descriptions can contain wildcard characters (regular expressions). You can also define an idle time, a grace period and a few other options. When reading the configuration file, the program creates a record for each configuration line. A value is assigned to each variable in the record regardless of whether or not you specify one explicitly. Values for missing variables are provided by defaults which are compiled in and can be modified from the command line. .PP If no entries are found matching a given process, that process will be spared from an untimely demise. Therefore, it is a good idea to always have a "cleanup" line at the end of the configuration file to catch anything that might have been missed by the more explicit definitions. Since the default name, group, and line are all ".+", a simple line like: idle=30 will do. Actually, any one switch can be specified on the line and all the others will get the default values. .PP If no configuration file is found, the program will create a single entry which has all values set from the defaults. This entry will match any process on any port (name=.+ line=.+ group=.+). Therefore, the default action is to kill all processes. .SH ENTRYS .TP .B name= A regular expression specifying which username(s) to match. .TP .B group= A regular expression specifying which group(s) to match. .TP .B line= A regular expression specifying which tty line(s) to match. Omit the "/dev/" part of the special name. .TP .B idle= An integer specifying the number of \-\-minutes\-\- of idle (or connect) time to allow before beginning automatic logoff. An idle time of 0 exempts the process from automatic logoff. .TP .B grace= An integer specifying the number of \-\-seconds\-\- from the initial warning to killing the process. .TP .B ban= An integer specifying the number of \-\-minutes\-\- from killing the process to the moment, the user may login again. (after exceeding his session). .TP .B hard A boolean value indicating total connect time will be considered rather than idle time. .TP .B mail A boolean value indicating that mail will be sent to the user explaining that he was killed. .TP .B clear A boolean value indicating that the screen will be cleared before a warning message is sent. .TP .B warn A boolean value indicating that a warning message will be sent at the beginning of the "grace" period. .TP .B log A boolean value indicating that activities will be logged to the logfile (if it exists). .SH FURTHER ENTRYS .PP There is another group of entries, which allows to set some general options. Each of them takes a whole line. Don't mix them with the other entries from before. .TP .B nolostkill A boolean value indicating whether lost processes should be killed. If there is a process with uid between 500 and 60000 and the owner is not logged in, it is assumed as lost and will be killed. .TP .B ps=command on some strange or old systems the ps-command has different parameters. This makes it possible to set a completely different command. It is only important, that this command delivers one heading line and then lines with usernames and process-ids (pid). e.g.: ps=ps aux .SH EXAMPLE name=root line=tty[1-7] idle=0 name=guest idle=5 grace=60 nomail hard warn group=lynx-.* idle=10 grace=60 clear idle=60 grace=30 .SH AUTHOR Kyle Bateman (autolog 0.35), .PD 0 .TP Carsten Juerges .TP (autolog 0.40) .PD .PP This manual page was modified for \fBDebian\fP by Paul Telford debian/changelog0000644000000000000000000002467411475466250011067 0ustar autolog (0.40-13.1) unstable; urgency=low * Non-maintainer upload. * Don't set PATH in postrm (there is no need for that), (Closes: #604208). -- Mehdi Dogguy Wed, 01 Dec 2010 16:40:43 +0100 autolog (0.40-13) unstable; urgency=low * debian/patches - Adding 04_check_ps_output.diff, thanks to Julien Viard de Galbert . (Closes: #553502) * debian/control - Bump Standards-Version: 3.9.1 (No changes) * debian/autolog.conf.5 - Fix spelling-error-in-manpage. Makes lintian happy. * debian/patches/01_Makefile.diff - Change the INIDIR to /etc/init.d -- Luis Uribe Sat, 30 Oct 2010 21:19:38 -0500 autolog (0.40-12) unstable; urgency=low * debian/compat - Dump debhelper to 5 * debian/control - Bump Standards-Version: 3.8.4 (No changes) * debian/[postinst,postrm,preinst,prerm] - Add 'set -e' to check for errors * Add patches for: - Makefile - autolog.8 - autolog.conf.5 - autolog.c - autolog.init * debian/control - Adds ${misc:Depends} to Depends: - Bump debhelper dependent number version. Makes lintian happy. - Add homepage field * debian/copyright - Fix the symlink to GPL-2 * Makefile - Remove installation of autolog.log from Makefile and include it on a postinst script - Fix the path of the manpage installation * Switch to dpkg-source 3.0 (quilt) format. (Closes: #538629) * debian/source.lintian-overrides - Add file to override lintian warnings * debian/rules - Remove quilt references - Clean "clean" target. -- Luis Uribe Sun, 21 Mar 2010 21:58:13 -0500 autolog (0.40-11) unstable; urgency=low * debian/control - Bump standards to 3.8.0 (No changes made) * debian/copyright - Rewrite Copyright notice * Remove the bashism in autolog.init (Closes: #471289) * Remove the bashism in debian/preinst * debian/rules - Move dh_shlibdeps after dh_makeshlibs and before dh_gencontrol, makes lintian happy. - Remove template lines. - Manage patches with quilt. * autolog.8 and autolog.conf.5 - Fix lintian reports (hyphen used as a minus sign). -- Luis Uribe Wed, 09 Apr 2008 20:30:13 -0500 autolog (0.40-10) unstable; urgency=low * New maintainter. (Closes: #385360). * Updated to newest standards version. * Added patch from Martin Godisch to correct the misbehave of the program when there is a small idle time specified (Closes: #206729). * debian/control - Remove debconf from Depends: * debian/rules - Remove debian/substvars file. * debian/watch - Added file * autolog.init - Make the script LSB-Compliant. * Move the debconf note to the README.Debian file, also remove debian/config, debian/templates and debian/po. (Closes: #388826). -- Luis Uribe Mon, 4 Jun 2007 16:42:40 -0500 autolog (0.40-9) unstable; urgency=low * Added debconf-2.0 depends, per Joey Hess * Updated Portugese, Swedish translations (Closes: #330204, #330264) -- Paul Telford Fri, 30 Sep 2005 07:49:28 -0700 autolog (0.40-8) unstable; urgency=low * Updated to newest standards-version * Added man page back in to package -- Paul Telford Mon, 18 Jul 2005 09:50:13 -0700 autolog (0.40-7) unstable; urgency=low * Update German, Vietnamese, Japanese, Czech debconf translations (Closes: #276695, #309466, #227806, #293603) * Remove debhelper dependency (Closes: #276909) -- Paul Telford Mon, 18 Jul 2005 08:24:32 -0700 autolog (0.40-6) unstable; urgency=low * Updated Russian and Dutch debconf translation (Closes: #219264, #215365) -- Paul Telford Mon, 8 Dec 2003 15:21:53 -0800 autolog (0.40-5) unstable; urgency=low * Un-commented two erroneously exlcuded upstream source lines (Closes: #206742) * Updated French and Brazilian Portugese debconf translations (Closes: #207948, #207836, #206965) -- Paul Telford Mon, 1 Sep 2003 18:39:48 -0700 autolog (0.40-4) unstable; urgency=low * Switched to gettext-based debconf templates (Closes: #205771) * Added French translation of gettext debconf template (Closes: #206598) -- Paul Telford Thu, 21 Aug 2003 11:48:41 -0700 autolog (0.40-3) unstable; urgency=low * Use an alternate regex comparison routine to avoid a memory leak. (Closes: #188445) * Fixed typo in warning message (Closes: #192018) -- Paul Telford Fri, 18 Jul 2003 22:28:57 -0700 autolog (0.40-2) unstable; urgency=low * Remove old cron.d entry from prior versions if it exists (Closes: #182043) -- Paul Telford Sat, 22 Feb 2003 09:53:21 -0800 autolog (0.40-1) unstable; urgency=low * New upstream release (Closes: #160003, #132152, #73051, #153575, #86423) * New maintainer (Closes: #174336) * Added fix to catch unknown groups (Closes: #52124) * Added Russian debconf template (Closes: #136922) * Fixed various upstream bugs -- Paul Telford Tue, 04 Feb 2003 08:25:28 -0800 autolog (0.35-10.1) unstable; urgency=low * Non-maintainer upload. * Mark /etc/logrotate.d/autolog as a conffile (closes: #132152). -- Colin Watson Sun, 10 Feb 2002 17:32:59 +0000 autolog (0.35-10) unstable; urgency=low * Sorted out build-depends (closes:Bug#103841,Bug#105083). * Enhanced some error messages. * Included host in the subject and the body of the generated messages (closes:Bug#94910). * Included debconf message translation to Brazilian Portuguese contributed by andrelop@ig.com.br (closes:Bug#107486). -- Nicolás Lichtmaier Sun, 21 Oct 2001 18:52:29 -0300 autolog (0.35-9.1) unstable; urgency=low * NMU * Combine multiple build-depends lines -- Progeny Development Team Sun, 15 Jul 2001 12:24:31 -0500 autolog (0.35-9) unstable; urgency=low * Use select(2) to check if we can write to the tty without blocking. I hope this finally fixes autolog creating countless processes. -- Nicolás Lichtmaier Sun, 1 Apr 2001 03:33:01 -0300 autolog (0.35-8) unstable; urgency=low * Ship with a debian/templates file and don't try to tun debconf-mergetemplates if it doesn't exist. This is to enable people to build this package in potato (Debian 2.1) (closes:Bug#86423). -- Nicolás Lichtmaier Sun, 18 Feb 2001 00:58:41 -0300 autolog (0.35-7) unstable; urgency=low * Added Swedish, German and Dutch translations (closes:Bug#82941,Bug#83546,Bug#83902). -- Nicolás Lichtmaier Sat, 17 Feb 2001 13:09:51 -0300 autolog (0.35-6) unstable; urgency=low * Open tty with open(2) in non-blocking mode. It should fix some hangs. -- Nicolás Lichtmaier Wed, 11 Oct 2000 19:20:52 -0300 autolog (0.35-5) unstable; urgency=low * Added Build-Depends header (closes:Bug#70163). * Uses getopt. Exits if given an illegal option. -- Nicolás Lichtmaier Mon, 28 Aug 2000 00:21:59 -0300 autolog (0.35-4) unstable; urgency=low * If the we get ENOENT opening the tty, we skip it (closes:Bug#66416). * Added dh_clean to debian/rules. * Use debconf to show the note to the user. -- Nicolás Lichtmaier Fri, 28 Jul 2000 22:12:57 -0300 autolog (0.35-3) unstable; urgency=low * Moved docs and manpages under /usr/share. * Updated `Standards-Version' to 3.0.1. * Uses logrotate to handle the logfile rotation. * Remove logfiles when the package is purgued. -- Nicolás Lichtmaier Sun, 12 Sep 1999 17:44:00 -0300 autolog (0.35-2) unstable; urgency=low * Really updated maintainer address. * Commented out sample lines in default autolog.conf. * Minor fixes to manpage. * Removed useless README.debian. * Changed Standards-Version to 2.5.0. -- Nicolás Lichtmaier Sun, 4 Jul 1999 02:40:08 -0300 autolog (0.35-1) unstable; urgency=low * New upstream release (only change: default log filename). * Updated maintainer address. * Removed bashism from debian/rules (closes: Bug#22527). * Uses pristine sources. * Added line-feed before logout message. * It were closing popened files with fclose, now fixed. * Removed all compilation warnings. * Improved message sent to the user, indicating who logged him out (closes: Bug#20326). * Switched to debhelper. * Removed changelog from README and install it as upstream changelog. * Changed default idle time from 1 to 2 hours. Updated postinst message. -- Nicolás Lichtmaier Sun, 27 Jun 1999 01:02:39 -0300 autolog (0.34-5) unstable; urgency=low * Updated FSF address. * Added dependancy on cron. * Preserve files' dates. * Added code to remove the old entry from /etc/crontab. * No longer edits /etc/crontab on postinst, now it adds a conffile in /etc/cron.d, as current policy mandates. * Fixes to the manpages. * Upgraded `Standards-version' to 2.4.0.0. * Fixed md5sums file (#19274). -- Nicolás Lichtmaier Wed, 11 Mar 1998 23:23:06 -0300 autolog (0.34-4) unstable; urgency=low * Changed maintainer address. * Added -Wall to CFLAGS and removed lots of warnings. * Don't try to close logfile if it hasn't been opened, fixes bugs #14156 and #15307. * Building with new debmake fixes bug #12832. * Replaced `/bin/mail' with `/usr/sbin/sendmail' and recommend mail-transport-agent, fixes bug #15342. -- Nicolás Lichtmaier Mon, 1 Dec 1997 22:47:55 -0300 autolog (0.34-3) unstable; urgency=low * Added errno message to error messages. * Uses kill to check if process is alive instead of stat in proc. * Built with libc6. * Corrected crontab entry, fixes #8010. * Updated debstd invocation. * New maintainer. -- Nicolás Lichtmaier Thu, 13 Feb 1997 16:13:42 -0300 autolog (0.34-2) unstable; urgency=low * binary was missing and postinst messages fixed -- Christoph Lameter Sun, 5 Jan 1997 19:47:20 -0800 autolog (0.34-1) unstable; urgency=low * Upstream release after sending patches to author. Plus a fix for a problem with X sessions. -- Christoph Lameter Sat, 7 Dec 1996 14:14:27 -0800 autolog (0.33-1) unstable; urgency=low * Initial Release. -- Christoph Lameter Sat, 7 Dec 1996 11:16:50 -0800 Local variables: mode: debian-changelog End: debian/source.lintian-overrides0000644000000000000000000000005111466674730014060 0ustar autolog: source-contains-prebuilt-binary debian/postrm.debhelper0000644000000000000000000000027511466674730012410 0ustar # Automatically added by dh_installdebconf if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge fi # End automatically added section debian/postinst0000644000000000000000000000155611466674730011021 0ustar #!/bin/sh set -e PATH=/bin:/usr/bin:/usr/sbin:/sbin if [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule fi #DEBHELPER# update-rc.d autolog defaults >/dev/null if [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_get autolog/note || true else cat << EOF The autolog daemon will be activated now and will log users out after two hours of idle time. If you do not want this then either uninstall autolog or customize /etc/autolog.conf and /etc/rc.d/autolog according to your needs. If you are running dselect over a modem line then this might disconnect you when you leave things unattended. EOF fi db_stop touch /var/log/autolog.log chown root:adm /var/log/autolog.log chmod 0644 /var/log/autolog.log if [ -x /usr/sbin/invoke-rc.d ]; then invoke-rc.d autolog restart else /etc/init.d/autolog restart fi debian/patches/0000755000000000000000000000000011466674730010633 5ustar debian/patches/04_check_ps_output.diff0000644000000000000000000000144111466674730015167 0ustar From: Julien Viard de Galbert Description: Patch for fixing ps output when it has more than 256 bytes Bug-Debian: 553502 Index: autolog/autolog.c =================================================================== --- autolog.orig/autolog.c 2010-10-30 21:24:17.000000000 -0500 +++ autolog/autolog.c 2010-10-30 21:24:17.000000000 -0500 @@ -1082,6 +1082,18 @@ } } } + /* Read to the end of line to avoid parsing the rest of the command + * line in next round and getting a segfault as ps_pid will be null!! + */ + i=strlen(iline); + while(iline[i-1] != '\n'){ + if(!fgets(iline, LINELEN, ps)) { + /* end of file, exit*/ + fclose(ps); + return; + } + i=strlen(iline); + } } fclose(ps); } debian/patches/03_autolog.init0000644000000000000000000000524711466674730013504 0ustar From: Luis Uribe Subject: Make the autolog.init script LSB-compliant Index: autolog/autolog.init =================================================================== --- autolog.orig/autolog.init 2010-03-25 20:01:19.000000000 -0500 +++ autolog/autolog.init 2010-04-02 10:04:44.000000000 -0500 @@ -1,44 +1,57 @@ #! /bin/sh -# Copyright (c) 2000 Carsten Juerges, Hannover, Germany. All rights reserved. # -# Author: Carsten Juerges , 2000 +# autolog: Terminates connections for idle users # -# /sbin/init.d/autolog +### BEGIN INIT INFO +# Provides: autolog +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start the autolog daemon firewall at boot time +# Description: Script to start/stop/reload the autolog daemon +### END INIT INFO # +# Copyright (c) 2000 Carsten Juerges, Hannover, Germany. All rights reserved. +# Author: Carsten Juerges , 2000 +# Debian-ized by Paul Telford 01/30/2003 +# Make LSB-compliant on 01/06/2007 by Luis Uribe -. /etc/rc.config - -base=${0##*/} -link=${base#*[SK][0-9][0-9]} - -test $link = $base && START_AUTOLOG=yes -test "$START_AUTOLOG" = yes || exit 0 +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/sbin/autolog +NAME=autolog +DESC="terminates connections for idle users" +SCRIPTNAME=/etc/init.d/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions -export PATH=/bin:/usr/bin:/sbin:/usr/sbin -export HOME=/ +test -x /usr/sbin/autolog || exit 0 -return=$rc_done case "$1" in start) echo -n "Starting autolog daemon" - startproc /usr/sbin/autolog || return=$rc_failed - echo -e "$return" + start-stop-daemon --start --quiet --exec $DAEMON + echo "." ;; stop) echo -n "Shutting down autolog daemon" - killproc -TERM /usr/sbin/autolog || return=$rc_failed - echo -e "$return" - ;; - restart) - $0 stop && $0 start || return=$rc_failed + start-stop-daemon --stop --quiet --exec $DAEMON + echo "." ;; - status) - checkproc /usr/sbin/autolog && echo "autolog up" || echo "No autolog" + force-reload|restart) + echo -n "Restarting autolog daemon" + start-stop-daemon --stop --quiet --exec $DAEMON + start-stop-daemon --start --quiet --exec $DAEMON + echo "." ;; *) - echo "Usage: $0 {start|stop|status|restart}" + echo "Usage: $0 {start|stop|restart|force-reload}" exit 1 esac -test "$return" = "$rc_done" || exit 1 exit 0 debian/patches/series0000644000000000000000000000010611466674730012045 0ustar 01_Makefile.diff 02_autolog.c 03_autolog.init 04_check_ps_output.diff debian/patches/01_Makefile.diff0000644000000000000000000000250311466674730013502 0ustar From: Luis Uribe Subject: Add proper routes to Makefile Index: autolog/Makefile =================================================================== --- autolog.orig/Makefile 2010-04-14 22:00:44.000000000 -0500 +++ autolog/Makefile 2010-04-19 09:48:46.000000000 -0500 @@ -3,23 +3,22 @@ # The -g flag is to include debugging information. It gets # stripped back out in the install command anyway. CC = gcc -CFLAGS = -g -MANDIR = /usr/man -BINDIR = /usr/sbin/ -LOGDIR = /var/log/ -INIDIR = /sbin/init.d/ +CFLAGS += -g +MANDIR = $(DESTDIR)/usr/share/man +BINDIR = $(DESTDIR)/usr/sbin/ +STATEDIR = $(DESTDIR)/var/lib/autolog/ +CONFDIR = $(DESTDIR)/etc/ +INIDIR = $(DESTDIR)/etc/init.d/ # ********************************************************* autolog: autolog.c $(CC) $(CFLAGS) -o autolog autolog.c install: autolog + install -d $(BINDIR) $(INIDIR) $(CONFDIR) $(STATEDIR) $(LOGDIR) $(MANDIR) install -m744 -o 0 -g 0 autolog $(BINDIR) install -m744 -o 0 -g 0 autolog.init $(INIDIR)/autolog - install -m644 -o 0 -g 0 autolog.conf /etc - install -m644 -o 0 -g 0 autolog.log $(LOGDIR) - install -m644 autolog.conf.5.gz $(MANDIR)/man5 - install -m644 autolog.8.gz $(MANDIR)/man8 + install -m644 -o 0 -g 0 autolog.conf $(CONFDIR) clean: - rm autolog + rm -f autolog debian/patches/02_autolog.c0000644000000000000000000002246611466674730012764 0ustar From: Luis Uribe Subject: Patch for autolog.c Index: autolog/autolog.c =================================================================== --- autolog.orig/autolog.c 2010-03-25 20:01:19.000000000 -0500 +++ autolog/autolog.c 2010-04-02 10:04:43.000000000 -0500 @@ -114,7 +114,7 @@ int listall = 0; char *confname = "/etc/autolog.conf"; char *logfname = "/var/log/autolog.log"; -char *datfname = "/tmp/autolog.data"; +char *datfname = "/var/lib/autolog/autolog.data"; int g_idle = D_IDLE; int g_grace = D_GRACE; int g_hard = D_HARD; @@ -202,9 +202,10 @@ load_users(); if (debug){ printf("\n"); - printf("Aus der Datei eingelesen:\n"); - printf("=========================\n"); + printf("From the datafile:\n"); + printf("==================\n"); show_results(); + printf("Done reading datafile\n"); } /* now sit in an infinite loop and work */ @@ -258,6 +259,7 @@ check_utmp(){ /* select utmp entries needing killing */ char dev[STRLEN], name[STRLEN], prname[STRLEN]; char *msg; + char tmp_str[80]; struct stat status; time_t idle, atime; @@ -277,8 +279,9 @@ msg,utmpp->ut_user,utmpp->ut_pid,ctime(&utmpp->ut_time)); return(0); } - if (stat(dev, &status)){ /* if can't get status for port */ - bailout("Can't get status of user's terminal", 1); + if (dev[5] != ':' && stat(dev, &status)){ /* if can't get status for port */ + snprintf(tmp_str, 79, "Can't get status of user's terminal: %s", dev); + bailout(tmp_str, 1); return(0); } @@ -302,7 +305,7 @@ /*.. Get Position of user in userlst. .......................................*/ userpos=userfill; - while ( strcmp(userlst[userpos].Name,name) ) userpos--; + while ( strcmp(userlst[userpos].Name,name) ) userpos--; /*.. if not found -> add user to userlst. ...................................*/ if ( userpos ==0 ) { @@ -436,6 +439,11 @@ ps_cmd = strcpy((char *)malloc(strlen(s)+1),s+3); continue; } + s=strstr(iline,"nolostkill"); + if (s) { + lostkill = 0; + continue; + } set_defs(c_idx); s=strtok(iline,delims); do{ @@ -467,8 +475,6 @@ c_arr[c_idx].warn=lev; else if (!strcmp(s,"log")) c_arr[c_idx].log=lev; - else if (!strcmp(s,"lostkill")) - lostkill=lev; else if (debug) printf("Unknown token in file: %s: %s\n",confname,s); } @@ -477,8 +483,8 @@ idle=c_arr[c_idx].idle; /*.. Maybe it is necessary to reduce the max. sleeptime to shortest session. */ - if (0< c_arr[c_idx].hard && 0hard) @@ -699,7 +708,7 @@ mesg(ANGRY, name, ddev, stime/60, idle, ce); /* angry about user. */ if (debug) printf("I am angry, user returned...\n"); - if (kill_PIDs(name)==1) /* try to kill user, at once */ + if (kill_PIDs(name, dev)==1) /* try to kill user, at once */ mesg(LOGOFF, name, ddev, stime/60, idle, ce); /* mail to user */ else mesg(NOLOGOFF,name, ddev, stime/60, idle, ce); /* couldn't kill */ } @@ -722,13 +731,13 @@ /*----------------------------------------------------------------------------*/ void get_PIDs /* find processes of a given user. */ /*----------------------------------------------------------------------------*/ - (char *u_name) /* name of the user. */ + (char *u_name, char *u_dev) /* name of the user. */ /*----------------------------------------------------------------------------*/ /* this version assumes that ps -au returns one header-line and then */ /* lines with usernames, pids and some other stuff */ { char prname[LINELEN], iline[LINELEN]; char *s; - char *ps_name, *ps_pid; + char *ps_name, *ps_pid, *ps_dev; struct stat status; @@ -746,15 +755,16 @@ ps_name= strtok(iline,delims); /* manual: Never use this function. */ ps_pid = strtok(0,delims); pid = atoi(ps_pid); + for(i=0;i<5;i++) ps_dev = strtok(0,delims); sprintf(prname,"/proc/%d",pid); /* append /proc/ to proclist */ if (stat(prname, &status)) printf("Dead process: \n"); uid = status.st_uid; if (debug) - printf("%-8s -> %5s %5d %5d\n", ps_name, ps_pid, pid,uid); - if ( strcmp(u_name,ps_name)==0 ){ + printf("%-8s/%s -> %5s %5d %5d\n", ps_name, ps_dev,ps_pid, pid,uid); + if ( strcmp(u_name,ps_name)==0 && strcmp(u_dev,ps_dev)==0 ){ if (debug) - printf(" -> ok, Name = %s => kill.\n",u_name); + printf(" -> ok, Name = %s, dev = %s => kill.\n",u_name,u_dev); ids_fill++; if (ids_fill > ids_max) { ids_max = 2*(ids_max); @@ -778,7 +788,7 @@ /*=== The following functions have a murder job. ===*/ /*---------------------------------------------------------------------------*/ -int kill_PIDs(char *u_name){ +int kill_PIDs(char *u_name, char *u_dev){ int i,ok=1; ids_max = 50; @@ -789,7 +799,7 @@ /*.. Tell processes to hang up. .............................................*/ // ids_fill = 0; - get_PIDs(u_name); + get_PIDs(u_name, u_dev); if (do_bite) for (i=1; i<=ids_fill; i++) kill_HUP(ids_lst[i]); sleep(HUP_WAIT); @@ -797,7 +807,7 @@ /*.. Check for processes that still survived and now kill them. .............*/ /*.. This will also kill a user that returns at once. Without warning. :) ...*/ ids_fill = 0; - get_PIDs(u_name); + get_PIDs(u_name, u_dev); if (do_bite) for (i=1; i<=ids_fill; i++) kill_KILL(ids_lst[i]); sleep(KILLWAIT); @@ -921,10 +931,10 @@ } fclose(fp); if (ce->mail){ - sprintf(mbuf, "/bin/mail -s \"++WARNING - LOG-OFF ++\" %s", name); + sprintf(mbuf, "/usr/bin/mail -s \"++WARNING - LOG-OFF ++\" %s", name); /* open pipe to mail program for writing */ if (!(mprog = popen(mbuf, "w")) ){ - bailout("Can't use /bin/mail program", 6); + bailout("Can't use /usr/bin/mail program", 6); return(0); } if (ce->hard){ @@ -934,8 +944,8 @@ fprintf(mprog, " So finish up, please.\n"); } else{ - fprintf(mprog, "Your have been idle for quite a long time.\n"); - fprintf(mprog, " %s: You've idle for %3d min.\n", name, stime); + fprintf(mprog, "You have been idle for quite a long time.\n"); + fprintf(mprog, " %s: You've been idle for %3d min.\n", name, stime); fprintf(mprog, " You'll be logged off in %3d sec.\n",ce->grace); fprintf(mprog, " Please: Type something into a terminal \n"); fprintf(mprog, " or you'll be kicked off.\n"); @@ -946,10 +956,10 @@ if (flag == LOGOFF){ hint="** LOGOFF **"; if (ce->mail){ - sprintf(mbuf, "/bin/mail -s \"Logged off, you were idle\" %s", name); + sprintf(mbuf, "/usr/bin/mail -s \"Logged off, you were idle\" %s", name); /* open pipe to mail program for writing */ if (!(mprog = popen(mbuf, "w")) ){ - bailout("Can't use /bin/mail program", 6); + bailout("Can't use /usr/bin/mail program", 6); return(0); } fprintf(mprog, "Subject: Excess Idle Time\n\n"); @@ -962,9 +972,9 @@ if (flag == NOLOGOFF){ hint="** LOGOFF FAILED **"; if (ce->mail){ - sprintf(mbuf, "/bin/mail -s \"Couldn't log out [%s] \" root",name); + sprintf(mbuf, "/usr/bin/mail -s \"Couldn't log out [%s] \" root",name); if ((mprog = popen(mbuf, "w")) == (FILE *) NULL){ - bailout("Can't use /bin/mail program", 7); + bailout("Can't use /usr/bin/mail program", 7); return(0); } fprintf(mprog, "Subject: Can't logoff %s\n", name); @@ -1001,8 +1011,7 @@ bailout(char *message, int status){ /* Handle error message. */ char msg[100]; /* Try to log the message. */ - sprintf(msg, "%-20s %s %-5s idle:%3d sess:%3d", - "** ERROR **" , message); + sprintf(msg, "** ERROR ** %s", message); log_msg(msg); } debian/preinst0000644000000000000000000000131511466674730010613 0ustar #! /bin/sh set -e PATH=/bin:/usr/bin if grep -q "#-- autolog begin" /etc/crontab; then echo -n Removing old autolog entry from /etc/crontab... cp /etc/crontab /etc/crontab.new sed -e '/#-- autolog begin/,/#-- autolog end/d' /etc/crontab rm /etc/crontab.new echo done. fi if [ "$1" = "upgrade" ]; then if [ -e /etc/cron.d/autolog ] then echo Removing old autolog entry from /etc/cron.d rm -f /etc/cron.d/autolog fi if [ `printf %0.4s "$2"` = "0.35" ]; then cat << EOF Note that autolog runs as a daemon by default starting with version 0.40 rather than the old cron-based method. Please see the man page or docs if you still wish to run it from cron EOF fi fi #DEBHELPER# debian/compat0000644000000000000000000000000211466674730010402 0ustar 5