Path: utzoo!utgpu!watmath!uunet!lll-winken!pacbell!att!icus!lenny From: lenny@icus.islp.ny.us (Lenny Tropiano) Newsgroups: unix-pc.sources Subject: Dump entries in /etc/pwcntl Keywords: Quick and dirty ditty... Message-ID: <556@icus.islp.ny.us> Date: 14 Dec 88 01:10:11 GMT Distribution: unix-pc Organization: ICUS Software Systems, Islip, New York Lines: 132 Yes, I whipped this up quick... It does what it supposed to, and no more. Nothing fancy ... :-) -Lenny #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh Makefile <<'END_OF_Makefile' X# X# Makefile to compile look_pwcntl.c (/etc/pwcntl dump program) X# By Lenny Tropiano X# (c)1988 ICUS Computer Group UUCP: ...icus!lenny (lenny@icus.islp.ny.us) X# XCFLAGS=-v -O XLDFLAGS=-s XLIBS=/lib/crt0s.o /lib/shlib.ifile XDEST=/usr/lbin/ X# Xlook_pwcntl: look_pwcntl.o X @echo "Loading ..." X $(LD) $(LDFLAGS) -o look_pwcntl look_pwcntl.o $(LIBS) X# Xlook_pwcntl.o: X $(CC) $(CFLAGS) -c look_pwcntl.c X# X# Need to be root for this X# X$(DEST): X mkdir $(DEST) X# Xinstall: look_pwcntl $(DEST) X cp look_pwcntl ${DEST} X chown root ${DEST}/look_pwcntl X chgrp bin ${DEST}/look_pwcntl X chmod 750 ${DEST}/look_pwcntl X# Xclean: X rm -f look_pwcntl *.o core END_OF_Makefile if test 642 -ne `wc -c look_pwcntl.c <<'END_OF_look_pwcntl.c' X/*************************************************************************** X * look_pwcntl.c X * X * Program to dump out entries of /etc/pwcntl, that is created by the X * stock login(1M) program on the UNIX PC computer. This will print out X * all the entries, and their last login time. It also compares login X * names with the /etc/passwd to check for validity. The login will X * record all entries, correct or not. X * X * ** NOTE ** This is a quick and dirty program, very simple, but someone X * had to do it! :-) X * X * By Lenny Tropiano ICUS Software Systems December 13, 1988 X * X * Permission granted to redistribute without profit in the public domain X * only. This header must remain in-tact as is. This program carries X * no warranties, express or implied, and all consequences resulting from X * the use of this program are the sole responsibility of the user. X * X ***************************************************************************/ X X#include X#include X#include X#include X#include X Xmain() X{ X int fd; X struct passwd *psw; X struct pwcntl { X char login[8]; X int uid; X char expert; X char pad; X time_t laston; X time_t tcreat; X long space; X } pwrec; X X if ((fd = open("/etc/pwcntl",O_RDONLY)) < 0) { X perror("open()"); X exit(1); X } X printf("Login id\tLogin time\t\t\tName\n"); X printf("------------------------------------------------------------------------------\n"); X while (read(fd, &pwrec, sizeof(pwrec)) == sizeof(pwrec)) { X printf("%-12.12s\t%-24.24s", pwrec.login, ctime(&pwrec.laston)); X X if ((psw = (struct passwd *)getpwnam(pwrec.login)) X == (struct passwd *)NULL) X printf("\t* Invalid login *\n"); X else X printf("\t%s\n", psw->pw_gecos); X } X close(fd); X} END_OF_look_pwcntl.c if test 1801 -ne `wc -c