|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T t
Length: 1746 (0x6d2) Types: TextFile Names: »ttysbr.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Uip/rcvalert/ttysbr.c«
/* ttysbr.c: */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Uip/rcvalert/RCS/ttysbr.c,v 5.0 90/09/20 16:33:56 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Uip/rcvalert/RCS/ttysbr.c,v 5.0 90/09/20 16:33:56 pp Exp Locker: pp $ * * $Log: ttysbr.c,v $ * Revision 5.0 90/09/20 16:33:56 pp * rcsforce : 5.0 public release * */ #include <stdio.h> #include <isode/manifest.h> #include <utmp.h> #include <sys/file.h> #include <sys/stat.h> #ifndef UTMP_FILE #define UTMP_FILE "/etc/utmp" #endif #define OKTONOTIFY 020 /* group write perm */ #ifdef nonuser #define NONUSER(x) nonuser(x) #else #define NONUSER(x) ((x).ut_name[0] == 0) #endif int notify_normal (str, username) char *str; char *username; { FILE *fp; int done = NOTOK; struct utmp utmp; if ((fp = fopen (UTMP_FILE, "r")) == NULL) return NOTOK; while (fread ((char *)&utmp, sizeof utmp, 1, fp) > 0) { if (NONUSER (utmp)) continue; if (strncmp (utmp.ut_name, username, sizeof (utmp.ut_name)) == 0) if (notify_user (&utmp, str) == OK) done = OK; } (void) fclose (fp); return done; } notify_user (ut, str) struct utmp *ut; char *str; { char device[BUFSIZ]; struct stat st; int pid; int fd; (void) sprintf (device, "/dev/%.*s", sizeof (ut -> ut_line), ut -> ut_line); if (stat (device, &st) == NOTOK) return NOTOK; if ((st.st_mode & OKTONOTIFY) == 0) return NOTOK; if ((pid = fork ()) == NOTOK) return NOTOK; if (pid) return OK; if ((fd = open (device, O_WRONLY, 0)) == NOTOK) _exit(1); (void) write (fd, "\r\n\007", 3); (void) write (fd, str, strlen (str)); (void) write (fd, "\r\n\007", 3); (void) close (fd); _exit (0); return NOTOK; }