Changed to OpenBSD indent and function declaration style

Added display of time when logging out, to try to catch lastlog bugs
This commit is contained in:
andre 2000-06-13 00:43:47 +00:00
parent 55661d99b8
commit 6e5d3475a5

View File

@ -48,7 +48,7 @@
#include "loginrec.h" #include "loginrec.h"
RCSID("$Id: logintest.c,v 1.4 2000/06/13 00:29:34 andre Exp $"); RCSID("$Id: logintest.c,v 1.5 2000/06/13 00:43:47 andre Exp $");
int nologtest = 0; int nologtest = 0;
@ -57,7 +57,8 @@ int be_verbose = 0;
/* Dump a logininfo to stdout. Assumes a tab size of 8 chars. */ /* Dump a logininfo to stdout. Assumes a tab size of 8 chars. */
void dump_logininfo(struct logininfo *li, char *descname) void
dump_logininfo(struct logininfo *li, char *descname)
{ {
/* yes I know how nasty this is */ /* yes I know how nasty this is */
printf("struct logininfo %s = {\n\t" printf("struct logininfo %s = {\n\t"
@ -80,7 +81,8 @@ void dump_logininfo(struct logininfo *li, char *descname)
} }
int testAPI() int
testAPI()
{ {
struct logininfo *li1; struct logininfo *li1;
struct passwd *pw; struct passwd *pw;
@ -89,8 +91,8 @@ int testAPI()
char cmdstring[256], stripline[8]; char cmdstring[256], stripline[8];
char username[32]; char username[32];
#ifdef HAVE_TIME_H #ifdef HAVE_TIME_H
time_t t0, t1, t2; time_t t0, t1, t2, logouttime;
char s_t0[64],s_t1[64],s_t2[64]; /* ctime() strings */ char s_t0[64],s_t1[64],s_t2[64], s_logouttime[64]; /* ctime() strings */
#endif #endif
printf("**\n** Testing the API...\n**\n"); printf("**\n** Testing the API...\n**\n");
@ -156,8 +158,13 @@ int testAPI()
printf("--\nWaiting for a few seconds...\n"); printf("--\nWaiting for a few seconds...\n");
sleep(2); sleep(2);
printf("Performing a logout (the root login " printf("Performing a logout ");
"shown above should be gone)\n" #ifdef HAVE_TIME_H
(void)time(&logouttime);
strlcpy(s_logouttime, ctime(&logouttime), sizeof(s_logouttime));
printf("at %d - %s", (int)logouttime, s_logouttime);
#endif
printf("(the root login shown above should be gone)\n"
"If the root login hasn't gone, but another user on the same\n" "If the root login hasn't gone, but another user on the same\n"
"pty has, this is OK - we're hacking it here, and there\n" "pty has, this is OK - we're hacking it here, and there\n"
"shouldn't be two users on one pty in reality...\n" "shouldn't be two users on one pty in reality...\n"
@ -199,7 +206,8 @@ int testAPI()
} /* testAPI() */ } /* testAPI() */
void testLineName(char *line) void
testLineName(char *line)
{ {
/* have to null-terminate - these functions are designed for /* have to null-terminate - these functions are designed for
* structures with fixed-length char arrays, and don't null-term.*/ * structures with fixed-length char arrays, and don't null-term.*/
@ -217,7 +225,9 @@ void testLineName(char *line)
} /* testLineName() */ } /* testLineName() */
int testOutput() { int
testOutput()
{
printf("**\n** Testing linename functions\n**\n"); printf("**\n** Testing linename functions\n**\n");
testLineName("/dev/pts/1"); testLineName("/dev/pts/1");
testLineName("pts/1"); testLineName("pts/1");
@ -230,7 +240,8 @@ int testOutput() {
/* show which options got compiled in */ /* show which options got compiled in */
void showOptions(void) void
showOptions(void)
{ {
printf("**\n** Compile-time options\n**\n"); printf("**\n** Compile-time options\n**\n");
@ -258,7 +269,8 @@ void showOptions(void)
} /* showOptions() */ } /* showOptions() */
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
printf("Platform-independent login recording test driver\n"); printf("Platform-independent login recording test driver\n");