diff --git a/Makefile b/Makefile index 4d57469..42ceb68 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,10 @@ timeoutd: timeoutd.c Makefile #$(CC) $(CFLAGS) -o timeoutd timeoutd.c $(CC) $(CFLAGS) -o timeoutd.o -c timeoutd.c -DTIMEOUTDX11 $(CC) $(CFLAGS) -o timeoutd -L/usr/X11R6/lib timeoutd.o -lXss -lXext -lX11 - install: - install -o root -g system -m 2111 timeoutd /usr/etc/timeoutd - install -o man -g info -m 444 timeoutd.8 /usr/man/man8 - install -o man -g info -m 444 timeouts.5 /usr/man/man5 + install -o root -g adm -m 2111 timeoutd /usr/sbin + install -o root -g adm -m 2111 timeoutd.service /lib/systemd/system + install -o man -g man -m 444 timeoutd.8 /usr/share/man/man8 + install -o man -g man -m 445 timeouts.5 /usr/share/man/man5 + diff --git a/README b/README index c17a768..f9bfd05 100644 --- a/README +++ b/README @@ -12,20 +12,24 @@ each tty on your system: To build timeoutd, you should make any changes to the makefile for your preferred compilation options, then simply: +Note for Ubuntu, you need to install: + +sudo apt-get install libxss-dev libx11-dev + make -The next step is to install a timeouts file in /usr/etc specifying +The next step is to install a timeouts file in /etc specifying the parameters for each line/user/group combination. You can use the sample file provided in the distribution as a starting point after reading the timeoutd.8 and timeouts.5 man pages. -Once you have installed the timeouts file in /usr/etc, you can type: +Once you have installed the timeouts file in /etc, you can type: make install to install the timeoutd binaries and man pages. -Then it is just a matter of running /usr/etc/timeoutd. You may want +Then it is just a matter of running /usr/sbin/timeoutd. You may want to add a line to your /etc/rc or /etc/rc.local (or whatever) to run timeoutd at boot time. @@ -37,8 +41,11 @@ Otherwise, users who are not allowed to login will be logged off within Another (albeit less certain) way of doing this is to put the following line in /etc/profile near the top of the file: -/usr/etc/timeoutd `whoami` `basename \`tty\`` || exit - +/usr/sbin/timeoutd `whoami` `basename \`tty\`` || exit Please sends bugs, comments, suggestions to: shanea@bigpond.net.au (Shane Alderton) + +To build the debian package you need to run: + +debuild -uc -us diff --git a/debian/changelog b/debian/changelog index 697da0b..3b566c5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +timeoutd (1.5-10.3) unstable; urgency=low + * Non-maintainer upload + * Update to support gnome 3 only + + -- Jason Pell Wed, 20 Mar 2019 09:28:59 +1000 + timeoutd (1.5-10.2) unstable; urgency=low * Non-maintainer upload * Resolve the missing symbol XOpenDisplay by linking with libX11 diff --git a/debian/compat b/debian/compat index 7ed6ff8..ec63514 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -5 +9 diff --git a/debian/control b/debian/control index 7250687..7a2a3d3 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 4), libx11-dev, libxss-dev Package: timeoutd Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends}, gxmessage Conflicts: suidmanager (<< 0.50) Description: Flexible user timeout daemon with X11 support timeoutd enforces the time restrictions specified for each or all users. diff --git a/debian/rules b/debian/rules index 1c7b12a..d2322f8 100755 --- a/debian/rules +++ b/debian/rules @@ -46,7 +46,7 @@ binary-arch: build install # dh_installemacsen # dh_installpam # dh_installmime - dh_installinit + dh_installsystemd # dh_installcron # dh_installinfo # dh_undocumented diff --git a/debian/timeoutd.init.d b/debian/timeoutd.init.d deleted file mode 100644 index 4b7d283..0000000 --- a/debian/timeoutd.init.d +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: timeoutd -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start and stop the user timeout daemon -### END INIT INFO -# -# Based on skeleton 1.9.1 by Miquel van Smoorenburg . - -DAEMON=/usr/sbin/timeoutd -NAME=timeoutd -DESC="user timeout daemon" - -test -x $DAEMON || exit 0 - -. /lib/lsb/init-functions - -set -e - -case "$1" in - start) - echo -n "Starting $DESC: $NAME" - start-stop-daemon --start --oknodo --quiet --exec $DAEMON - echo "." - ;; - stop) - echo -n "Stopping $DESC: $NAME" - start-stop-daemon --stop --oknodo --quiet --exec $DAEMON - echo "." - ;; - reload|force-reload) - echo -n "Reloading $DESC configuration..." - start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON - echo "done." - ;; - restart) - echo -n "Restarting $DESC: $NAME" - start-stop-daemon --stop --oknodo --quiet --exec $DAEMON - sleep 1 - start-stop-daemon --start --quiet --exec $DAEMON - echo "." - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/timeoutd.service b/debian/timeoutd.service new file mode 100644 index 0000000..e05e535 --- /dev/null +++ b/debian/timeoutd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Timeoutd service + +[Service] +Restart=always +Type=forking +ExecStart=/usr/sbin/timeoutd + +[Install] +WantedBy=multi-user.target + diff --git a/timeoutd.c b/timeoutd.c index ceed658..ccfe09e 100644 --- a/timeoutd.c +++ b/timeoutd.c @@ -126,7 +126,7 @@ struct utmp *getutent() /* returns next utmp file entry */ #define DAYMSG 2 #define NOLOGINMSG 3 -#define KWAIT 5 /* Time to wait after sending a kill signal */ +#define KWAIT 10 /* Time to wait after sending a kill signal */ char *limit_names[] = {"idle", "session", "daily", "nologin"}; @@ -427,8 +427,10 @@ void read_wtmp() time = ut.ut_time; tm = localtime(&time); - if (tm->tm_year != now.tm_year || tm->tm_yday != now.tm_yday) + /* disable this as it breaks logic if user is on near to midnight */ + /*if (tm->tm_year != now.tm_year || tm->tm_yday != now.tm_yday) break; + */ #ifndef SUNOS if (ut.ut_type == USER_PROCESS || @@ -870,7 +872,7 @@ char *host; /* then send the message using xmessage */ /* well, this is not really clean: */ - sprintf(cmdbuf, "su %s -c \"xmessage -display %s -center 'WARNING: You will be logged out in %d minute%s when your %s limit expires.'&\"", user, host, time_remaining, time_remaining==1?"":"s", limit_names[limit_type]); + sprintf(cmdbuf, "su %s -c \"gxmessage -display %s -center 'WARNING: You will be logged out in %d minute%s when your %s limit expires.'&\"", user, host, time_remaining, time_remaining==1?"":"s", limit_names[limit_type]); system(cmdbuf); /*#ifdef DEBUG*/ openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); @@ -1447,7 +1449,7 @@ char *host, *user; /* then send the message using xmessage */ /* well, this is not really clean: */ - sprintf(cmdbuf, "su %s -c \"xmessage -display %s -center '%s'&\"", user, host, msgbuf); + sprintf(cmdbuf, "su %s -c \"gxmessage -display %s -center '%s'&\"", user, host, msgbuf); system(cmdbuf); #ifdef DEBUG openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); @@ -1458,19 +1460,8 @@ char *host, *user; #ifndef DEBUG - /* kill pid here */ - kill(pid, SIGTERM); /* otherwise, X crashes */ - sleep(KWAIT); - if (!kill(pid, 0)) { /* SIGHUP might be ignored */ - kill(pid, SIGKILL); /* then send sure "kill" signal */ - sleep(KWAIT); - if (!kill(pid, 0)) - { - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(LOG_ERR, "Could not log user %s off line %s. (running X)", user, host); - closelog(); - } - } + sprintf(cmdbuf, "su %s -c \"gnome-session-quit --no-prompt\"", user, host, msgbuf); + system(cmdbuf); #else openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); syslog(LOG_ERR, "Would normally logoff user %s running X (kill PID %d)", user, pid);