Compare commits

...

12 commits
1.5 ... master

Author SHA1 Message Date
Jason Pell c87d167ca0 minor fixes to paths and also make note of what packages required to get this to compile on ubuntu 2019-03-21 02:16:33 +11:00
Clark Rawlins 812394b9df Configure source format
Define the source format as 3.0 (git)

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 12:17:44 -08:00
Clark Rawlins ef953698c5 Fix lintian errors in debian/changelog
Lintian complians about a NMU version number.
Modify the changelog to use a standard version number.

Modify the changelog version to use the last 9 digits
of the sha1 hash for the git commit.

Add the build-arch and build-indep targets to the debian/rules
file.

Source init-functions in init script

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 12:13:54 -08:00
Clark Rawlins 6ff7b56a42 Add ${misc:Depends} to binary dependencies
Packages built with debhelper may introduce additional
binary package dependencies to a package that uses its
functions.  Adding ${misc:Depends} allows debhelper to
add any required dependencies to the package.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 10:43:28 -08:00
Clark Rawlins cde92985ae Switch from dh_clean -k to dh_prep
dh_clean -k is deprecated. Switch to the supported dh_clean
instead.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 10:35:22 -08:00
Clark Rawlins af2d3b48c6 Use a temp to convert ut_time to time_t
The localtime function takes a time_t* argument.  Passing
the ut_time member of the utmp struct as this argument
doesn't work on 64 bit systems because the lengths of the
arguments don't agree.  So use a temproary variable to
store the ut_time value in a time_t variable and pass
the address of the time_t variable to localtime.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 10:29:17 -08:00
Clark Rawlins 4f37273c60 Ignore warnings on unused return values
Modify the Makefile to silence warnings about unused
return values in the source code.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 09:53:14 -08:00
Clark Rawlins 957c5aefad Update debian/compat to version 5
To support recent versions of deb-buildpackage
increment debian/compat to version 5 (from version 4)

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 09:51:05 -08:00
Clark Rawlins ff3a5d11a1 Update debian/changelog with recent local changes
Update the debian changelog with recent changes to the package.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 09:50:37 -08:00
Clark Rawlins 73dd70fdf8 Ignore files generated by building debian package
Configure git to ignore files generated by the
build process and by the debian package build
process.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 09:21:27 -08:00
Clark Rawlins 119d66d4c1 Update debian/control Standards-Version:
Update debian/control Standards-Version to the
current value: 3.9.5.

Signed-off-by: Clark Rawlins <clark@bit63.org>
2014-12-14 09:09:20 -08:00
Clark Rawlins f8a3bc0509 To resolve the symbol XOpenDisplay link with libX11
When building the timeoutd binary the linker was not
finding the XOpenDisplay symbol.  By linking with
libX11 the missing symbol is found

Signed-off-by: Clark Rawlins <clark@defiant.bit63.org>
2014-12-14 09:05:09 -08:00
12 changed files with 75 additions and 90 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
timeoutd
*.o

View file

@ -1,11 +1,12 @@
CFLAGS=-fomit-frame-pointer -O2 -s -g -Wall CFLAGS=-fomit-frame-pointer -O2 -s -g -Wall -Wno-unused-result
timeoutd: timeoutd.c Makefile timeoutd: timeoutd.c Makefile
#$(CC) $(CFLAGS) -o timeoutd timeoutd.c #$(CC) $(CFLAGS) -o timeoutd timeoutd.c
$(CC) $(CFLAGS) -o timeoutd.o -c timeoutd.c -DTIMEOUTDX11 $(CC) $(CFLAGS) -o timeoutd.o -c timeoutd.c -DTIMEOUTDX11
$(CC) $(CFLAGS) -o timeoutd -L/usr/X11R6/lib timeoutd.o -lXss -lXext $(CC) $(CFLAGS) -o timeoutd -L/usr/X11R6/lib timeoutd.o -lXss -lXext -lX11
install: install:
install -o root -g system -m 2111 timeoutd /usr/etc/timeoutd install -o root -g adm -m 2111 timeoutd /usr/sbin
install -o man -g info -m 444 timeoutd.8 /usr/man/man8 install -o root -g adm -m 2111 timeoutd.service /lib/systemd/system
install -o man -g info -m 444 timeouts.5 /usr/man/man5 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

17
README
View file

@ -12,20 +12,24 @@ each tty on your system:
To build timeoutd, you should make any changes to the makefile for To build timeoutd, you should make any changes to the makefile for
your preferred compilation options, then simply: your preferred compilation options, then simply:
Note for Ubuntu, you need to install:
sudo apt-get install libxss-dev libx11-dev
make 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 parameters for each line/user/group combination. You can use
the sample file provided in the distribution as a starting point the sample file provided in the distribution as a starting point
after reading the timeoutd.8 and timeouts.5 man pages. 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 make install
to install the timeoutd binaries and man pages. 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 to add a line to your /etc/rc or /etc/rc.local (or whatever) to run
timeoutd at boot time. 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 Another (albeit less certain) way of doing this is to put the following
line in /etc/profile near the top of the file: 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: Please sends bugs, comments, suggestions to:
shanea@bigpond.net.au (Shane Alderton) shanea@bigpond.net.au (Shane Alderton)
To build the debian package you need to run:
debuild -uc -us

7
debian/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
files
timeoutd.debhelper.log
timeoutd.postinst.debhelper
timeoutd.postrm.debhelper
timeoutd.prerm.debhelper
timeoutd.substvars
timeoutd

16
debian/changelog vendored
View file

@ -1,11 +1,17 @@
timeoutd (1.5-10.1ubuntu1~1.gbp45a983) UNRELEASED; urgency=low timeoutd (1.5-10.3) unstable; urgency=low
* Non-maintainer upload
* Update to support gnome 3 only
** SNAPSHOT build @45a9836343ec6efa904b51360713c52fb623d6d8 ** -- Jason Pell <jason@pellcorp.com> Wed, 20 Mar 2019 09:28:59 +1000
* UNRELEASED timeoutd (1.5-10.2) unstable; urgency=low
* Fixed local X session handling * Non-maintainer upload
* Resolve the missing symbol XOpenDisplay by linking with libX11
* Update debian/control Standards-Version: 3.9.5
* Ignore files generated by building debian package
* Update debian/compat to version 5
-- Shawn Willden <shawn@kahlan.willden.org> Sun, 04 Jan 2009 23:17:57 -0700 -- Clark Rawlins <clark@bit63.org> Sun, 14 Dec 2014 09:28:59 -0800
timeoutd (1.5-10.1) unstable; urgency=low timeoutd (1.5-10.1) unstable; urgency=low

2
debian/compat vendored
View file

@ -1 +1 @@
4 9

4
debian/control vendored
View file

@ -2,12 +2,12 @@ Source: timeoutd
Section: admin Section: admin
Priority: extra Priority: extra
Maintainer: Dennis Stampfer <seppy@debian.org> Maintainer: Dennis Stampfer <seppy@debian.org>
Standards-Version: 3.6.2 Standards-Version: 3.9.5
Build-Depends: debhelper (>= 4), libx11-dev, libxss-dev Build-Depends: debhelper (>= 4), libx11-dev, libxss-dev
Package: timeoutd Package: timeoutd
Architecture: any Architecture: any
Depends: ${shlibs:Depends} Depends: ${shlibs:Depends}, ${misc:Depends}, gxmessage
Conflicts: suidmanager (<< 0.50) Conflicts: suidmanager (<< 0.50)
Description: Flexible user timeout daemon with X11 support Description: Flexible user timeout daemon with X11 support
timeoutd enforces the time restrictions specified for each or all users. timeoutd enforces the time restrictions specified for each or all users.

7
debian/rules vendored
View file

@ -4,6 +4,9 @@
# Uncomment this to turn on verbose mode. # Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1 #export DH_VERBOSE=1
build-arch: build
build-indep: build
build: build:
$(MAKE) timeoutd $(MAKE) timeoutd
@ -20,7 +23,7 @@ clean:
install: build install: build
dh_testdir dh_testdir
dh_testroot dh_testroot
dh_clean -k dh_prep
dh_installdirs dh_installdirs
# Add here commands to install the package into debian/<packagename> # Add here commands to install the package into debian/<packagename>
@ -43,7 +46,7 @@ binary-arch: build install
# dh_installemacsen # dh_installemacsen
# dh_installpam # dh_installpam
# dh_installmime # dh_installmime
dh_installinit dh_installsystemd
# dh_installcron # dh_installcron
# dh_installinfo # dh_installinfo
# dh_undocumented # dh_undocumented

1
debian/source/format vendored Normal file
View file

@ -0,0 +1 @@
3.0 (git)

View file

@ -1,51 +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 <miquels@cistron.nl>.
DAEMON=/usr/sbin/timeoutd
NAME=timeoutd
DESC="user timeout daemon"
test -x $DAEMON || exit 0
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

11
debian/timeoutd.service vendored Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=Timeoutd service
[Service]
Restart=always
Type=forking
ExecStart=/usr/sbin/timeoutd
[Install]
WantedBy=multi-user.target

View file

@ -126,7 +126,7 @@ struct utmp *getutent() /* returns next utmp file entry */
#define DAYMSG 2 #define DAYMSG 2
#define NOLOGINMSG 3 #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"}; char *limit_names[] = {"idle", "session", "daily", "nologin"};
@ -398,6 +398,7 @@ void read_wtmp()
FILE *fp; FILE *fp;
struct utmp ut; struct utmp ut;
struct tm *tm; struct tm *tm;
time_t time;
#ifdef DEBUG #ifdef DEBUG
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
@ -418,10 +419,18 @@ void read_wtmp()
while (fread(&ut, sizeof(struct utmp), 1, fp) == 1) while (fread(&ut, sizeof(struct utmp), 1, fp) == 1)
{ {
tm = localtime(&ut.ut_time); /* On 64 bit systems time_t is a 64 bit integer
while ut_time is a 32 bit (unsigned) integer.
Copy the value to a time_t value so the pointer
types agree in the call to localtime.
*/
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; break;
*/
#ifndef SUNOS #ifndef SUNOS
if (ut.ut_type == USER_PROCESS || if (ut.ut_type == USER_PROCESS ||
@ -863,7 +872,7 @@ char *host;
/* then send the message using xmessage */ /* then send the message using xmessage */
/* well, this is not really clean: */ /* 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); system(cmdbuf);
/*#ifdef DEBUG*/ /*#ifdef DEBUG*/
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
@ -1440,7 +1449,7 @@ char *host, *user;
/* then send the message using xmessage */ /* then send the message using xmessage */
/* well, this is not really clean: */ /* 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); system(cmdbuf);
#ifdef DEBUG #ifdef DEBUG
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
@ -1451,19 +1460,8 @@ char *host, *user;
#ifndef DEBUG #ifndef DEBUG
/* kill pid here */ sprintf(cmdbuf, "su %s -c \"gnome-session-quit --no-prompt\"", user, host, msgbuf);
kill(pid, SIGTERM); /* otherwise, X crashes */ system(cmdbuf);
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();
}
}
#else #else
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
syslog(LOG_ERR, "Would normally logoff user %s running X (kill PID %d)", user, pid); syslog(LOG_ERR, "Would normally logoff user %s running X (kill PID %d)", user, pid);