Dump entries in /etc/pwcntl
Lenny Tropiano
lenny at icus.islp.ny.us
Wed Dec 14 11:10:11 AEST 1988
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 <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: Makefile look_pwcntl.c
# Wrapped by lenny at icus on Tue Dec 13 20:08:35 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(642 characters\)
sed "s/^X//" >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 at 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 <Makefile`; then
echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f look_pwcntl.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"look_pwcntl.c\"
else
echo shar: Extracting \"look_pwcntl.c\" \(1801 characters\)
sed "s/^X//" >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 <stdio.h>
X#include <sys/types.h>
X#include <pwd.h>
X#include <fcntl.h>
X#include <time.h>
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 <look_pwcntl.c`; then
echo shar: \"look_pwcntl.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
--
Lenny Tropiano ICUS Software Systems [w] +1 (516) 582-5525
lenny at icus.islp.ny.us Telex; 154232428 ICUS [h] +1 (516) 968-8576
{talcott,decuac,boulder,hombre,pacbell,sbcs}!icus!lenny attmail!icus!lenny
ICUS Software Systems -- PO Box 1; Islip Terrace, NY 11752
More information about the Unix-pc.sources
mailing list