[5826] in Athena Bugs

home help back first fref pref prev next nref lref last post

cron-based program for deactivation

daemon@ATHENA.MIT.EDU (John T Kohl)
Fri Aug 24 11:00:26 1990

Date: Fri, 24 Aug 90 11:00:12 -0400
From: John T Kohl <jtkohl@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU

This might be useful for machines without toehold.

#include <stdio.h>
#include <utmp.h>
#include <sys/file.h>

static char utmpf[]="/etc/utmp";
char deactivate_prog[] = "/etc/athena/deactivate";

int nobody_logged_in()
{
    struct utmp utmp;
    int file;

    if((file = open(utmpf, O_RDONLY, 0)) >= 0) {
	while(read(file, (char *) &utmp, sizeof(utmp)) > 0) {
	    if(*utmp.ut_name) return 0;
	}
    }
    return 1;
}

main()
{
    if (nobody_logged_in()) {
	execlp(deactivate_prog, deactivate_prog, 0);
	fprintf(stderr, "%s not found\n", deactivate_prog);
	exit(1);
    } else
	exit(0);
}

home help back first fref pref prev next nref lref last post