andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Andre Lucas. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * 3. All advertising materials mentioning features or use of this software |
| 13 | * must display the following acknowledgement: |
| 14 | * This product includes software developed by Markus Friedl. |
| 15 | * 4. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 30 | /** |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 31 | ** logintest.c: simple test driver for platform-independent login recording |
| 32 | ** and lastlog retrieval |
| 33 | **/ |
| 34 | |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 35 | #include "includes.h" |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 36 | |
| 37 | #include <sys/types.h> |
| 38 | #include <sys/wait.h> |
| 39 | #include <unistd.h> |
| 40 | #include <stdlib.h> |
| 41 | #include <stdio.h> |
| 42 | #include <string.h> |
| 43 | #include <pwd.h> |
| 44 | #include <netdb.h> |
| 45 | #ifdef HAVE_TIME_H |
| 46 | #include <time.h> |
| 47 | #endif |
| 48 | |
| 49 | #include "loginrec.h" |
| 50 | |
Kevin Steves | ff8b495 | 2001-04-05 23:05:22 +0000 | [diff] [blame] | 51 | RCSID("$Id: logintest.c,v 1.8 2001/04/05 23:05:22 stevesk Exp $"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 52 | |
Kevin Steves | ff8b495 | 2001-04-05 23:05:22 +0000 | [diff] [blame] | 53 | #ifdef HAVE___PROGNAME |
| 54 | extern char *__progname; |
| 55 | #else |
| 56 | char *__progname; |
| 57 | #endif |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 58 | |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 59 | #define PAUSE_BEFORE_LOGOUT 3 |
| 60 | |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 61 | int nologtest = 0; |
| 62 | int compile_opts_only = 0; |
| 63 | int be_verbose = 0; |
| 64 | |
| 65 | |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 66 | /* Dump a logininfo to stdout. Assumes a tab size of 8 chars. */ |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 67 | void |
| 68 | dump_logininfo(struct logininfo *li, char *descname) |
andre | 61e6725 | 2000-06-04 17:07:49 +0000 | [diff] [blame] | 69 | { |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 70 | /* yes I know how nasty this is */ |
| 71 | printf("struct logininfo %s = {\n\t" |
| 72 | "progname\t'%s'\n\ttype\t\t%d\n\t" |
| 73 | "pid\t\t%d\n\tuid\t\t%d\n\t" |
| 74 | "line\t\t'%s'\n\tusername\t'%s'\n\t" |
| 75 | "hostname\t'%s'\n\texit\t\t%d\n\ttermination\t%d\n\t" |
| 76 | "tv_sec\t%d\n\ttv_usec\t%d\n\t" |
| 77 | "struct login_netinfo hostaddr {\n\t\t" |
| 78 | "struct sockaddr sa {\n" |
| 79 | "\t\t\tfamily\t%d\n\t\t}\n" |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 80 | "\t}\n" |
| 81 | "}\n", |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 82 | descname, li->progname, li->type, |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 83 | li->pid, li->uid, li->line, |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 84 | li->username, li->hostname, li->exit, |
| 85 | li->termination, li->tv_sec, li->tv_usec, |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 86 | li->hostaddr.sa.sa_family); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 90 | int |
| 91 | testAPI() |
andre | 61e6725 | 2000-06-04 17:07:49 +0000 | [diff] [blame] | 92 | { |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 93 | struct logininfo *li1; |
| 94 | struct passwd *pw; |
| 95 | struct hostent *he; |
| 96 | struct sockaddr_in sa_in4; |
| 97 | char cmdstring[256], stripline[8]; |
| 98 | char username[32]; |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 99 | #ifdef HAVE_TIME_H |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 100 | time_t t0, t1, t2, logintime, logouttime; |
| 101 | char s_t0[64],s_t1[64],s_t2[64]; |
| 102 | char s_logintime[64], s_logouttime[64]; /* ctime() strings */ |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 103 | #endif |
| 104 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 105 | printf("**\n** Testing the API...\n**\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 106 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 107 | pw = getpwuid(getuid()); |
| 108 | strlcpy(username, pw->pw_name, sizeof(username)); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 109 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 110 | /* gethostname(hostname, sizeof(hostname)); */ |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 111 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 112 | printf("login_alloc_entry test (no host info):\n"); |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 113 | |
| 114 | /* FIXME fake tty more effectively - this could upset some platforms */ |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 115 | li1 = login_alloc_entry((int)getpid(), username, NULL, ttyname(0)); |
| 116 | strlcpy(li1->progname, "OpenSSH-logintest", sizeof(li1->progname)); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 117 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 118 | if (be_verbose) |
| 119 | dump_logininfo(li1, "li1"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 120 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 121 | printf("Setting host address info for 'localhost' (may call out):\n"); |
| 122 | if (! (he = gethostbyname("localhost"))) { |
| 123 | printf("Couldn't set hostname(lookup failed)\n"); |
| 124 | } else { |
| 125 | /* NOTE: this is messy, but typically a program wouldn't have to set |
| 126 | * any of this, a sockaddr_in* would be already prepared */ |
| 127 | memcpy((void *)&(sa_in4.sin_addr), (void *)&(he->h_addr_list[0][0]), |
| 128 | sizeof(struct in_addr)); |
| 129 | login_set_addr(li1, (struct sockaddr *) &sa_in4, sizeof(sa_in4)); |
| 130 | strlcpy(li1->hostname, "localhost", sizeof(li1->hostname)); |
| 131 | } |
| 132 | if (be_verbose) |
| 133 | dump_logininfo(li1, "li1"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 134 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 135 | if ((int)geteuid() != 0) { |
| 136 | printf("NOT RUNNING LOGIN TESTS - you are not root!\n"); |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 137 | return 1; |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 138 | } |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 139 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 140 | if (nologtest) |
| 141 | return 1; |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 142 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 143 | line_stripname(stripline, li1->line, sizeof(stripline)); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 144 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 145 | printf("Performing an invalid login attempt (no type field)\n--\n"); |
| 146 | login_write(li1); |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 147 | printf("--\n(Should have written errors to stderr)\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 148 | |
| 149 | #ifdef HAVE_TIME_H |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 150 | (void)time(&t0); |
| 151 | strlcpy(s_t0, ctime(&t0), sizeof(s_t0)); |
| 152 | t1 = login_get_lastlog_time(getuid()); |
| 153 | strlcpy(s_t1, ctime(&t1), sizeof(s_t1)); |
| 154 | printf("Before logging in:\n\tcurrent time is %d - %s\t" |
| 155 | "lastlog time is %d - %s\n", |
| 156 | (int)t0, s_t0, (int)t1, s_t1); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 157 | #endif |
| 158 | |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 159 | printf("Performing a login on line %s ", stripline); |
| 160 | #ifdef HAVE_TIME_H |
| 161 | (void)time(&logintime); |
| 162 | strlcpy(s_logintime, ctime(&logintime), sizeof(s_logintime)); |
| 163 | printf("at %d - %s", (int)logintime, s_logintime); |
| 164 | #endif |
| 165 | printf("--\n"); |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 166 | login_login(li1); |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 167 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 168 | snprintf(cmdstring, sizeof(cmdstring), "who | grep '%s '", |
| 169 | stripline); |
| 170 | system(cmdstring); |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 171 | |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 172 | printf("--\nPausing for %d second(s)...\n", PAUSE_BEFORE_LOGOUT); |
| 173 | sleep(PAUSE_BEFORE_LOGOUT); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 174 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 175 | printf("Performing a logout "); |
| 176 | #ifdef HAVE_TIME_H |
| 177 | (void)time(&logouttime); |
| 178 | strlcpy(s_logouttime, ctime(&logouttime), sizeof(s_logouttime)); |
| 179 | printf("at %d - %s", (int)logouttime, s_logouttime); |
| 180 | #endif |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 181 | printf("\nThe root login shown above should be gone.\n" |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 182 | "If the root login hasn't gone, but another user on the same\n" |
| 183 | "pty has, this is OK - we're hacking it here, and there\n" |
| 184 | "shouldn't be two users on one pty in reality...\n" |
| 185 | "-- ('who' output follows)\n"); |
| 186 | login_logout(li1); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 187 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 188 | system(cmdstring); |
| 189 | printf("-- ('who' output ends)\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 190 | |
| 191 | #ifdef HAVE_TIME_H |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 192 | t2 = login_get_lastlog_time(getuid()); |
| 193 | strlcpy(s_t2, ctime(&t2), sizeof(s_t2)); |
| 194 | printf("After logging in, lastlog time is %d - %s\n", (int)t2, s_t2); |
| 195 | if (t1 == t2) |
| 196 | printf("The lastlog times before and after logging in are the " |
| 197 | "same.\nThis indicates that lastlog is ** NOT WORKING " |
| 198 | "CORRECTLY **\n"); |
| 199 | else if (t0 != t2) |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 200 | /* We can be off by a second or so, even when recording works fine. |
| 201 | * I'm not 100% sure why, but it's true. */ |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 202 | printf("** The login time and the lastlog time differ.\n" |
| 203 | "** This indicates that lastlog is either recording the " |
andre | b4db42f | 2000-06-19 08:25:36 +0000 | [diff] [blame] | 204 | "wrong time,\n** or retrieving the wrong entry.\n" |
| 205 | "If it's off by less than %d second(s) " |
| 206 | "run the test again.\n", PAUSE_BEFORE_LOGOUT); |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 207 | else |
| 208 | printf("lastlog agrees with the login time. This is a good thing.\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 209 | |
| 210 | #endif |
| 211 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 212 | printf("--\nThe output of 'last' shown next should have " |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 213 | "an entry for root \n on %s for the time shown above:\n--\n", |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 214 | stripline); |
| 215 | snprintf(cmdstring, sizeof(cmdstring), "last | grep '%s ' | head -3", |
| 216 | stripline); |
| 217 | system(cmdstring); |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 218 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 219 | printf("--\nEnd of login test.\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 220 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 221 | login_free_entry(li1); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 222 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 223 | return 1; |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 224 | } /* testAPI() */ |
| 225 | |
| 226 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 227 | void |
| 228 | testLineName(char *line) |
andre | 61e6725 | 2000-06-04 17:07:49 +0000 | [diff] [blame] | 229 | { |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 230 | /* have to null-terminate - these functions are designed for |
| 231 | * structures with fixed-length char arrays, and don't null-term.*/ |
| 232 | char full[17], strip[9], abbrev[5]; |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 233 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 234 | memset(full, '\0', sizeof(full)); |
| 235 | memset(strip, '\0', sizeof(strip)); |
| 236 | memset(abbrev, '\0', sizeof(abbrev)); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 237 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 238 | line_fullname(full, line, sizeof(full)-1); |
| 239 | line_stripname(strip, full, sizeof(strip)-1); |
| 240 | line_abbrevname(abbrev, full, sizeof(abbrev)-1); |
| 241 | printf("%s: %s, %s, %s\n", line, full, strip, abbrev); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 242 | |
| 243 | } /* testLineName() */ |
| 244 | |
| 245 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 246 | int |
| 247 | testOutput() |
| 248 | { |
| 249 | printf("**\n** Testing linename functions\n**\n"); |
| 250 | testLineName("/dev/pts/1"); |
| 251 | testLineName("pts/1"); |
| 252 | testLineName("pts/999"); |
| 253 | testLineName("/dev/ttyp00"); |
| 254 | testLineName("ttyp00"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 255 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 256 | return 1; |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 257 | } /* testOutput() */ |
| 258 | |
| 259 | |
| 260 | /* show which options got compiled in */ |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 261 | void |
| 262 | showOptions(void) |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 263 | { |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 264 | printf("**\n** Compile-time options\n**\n"); |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 265 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 266 | printf("login recording methods selected:\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 267 | #ifdef USE_LOGIN |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 268 | printf("\tUSE_LOGIN\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 269 | #endif |
| 270 | #ifdef USE_UTMP |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 271 | printf("\tUSE_UTMP (UTMP_FILE=%s)\n", UTMP_FILE); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 272 | #endif |
| 273 | #ifdef USE_UTMPX |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 274 | printf("\tUSE_UTMPX (UTMPX_FILE=%s)\n", UTMPX_FILE); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 275 | #endif |
| 276 | #ifdef USE_WTMP |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 277 | printf("\tUSE_WTMP (WTMP_FILE=%s)\n", WTMP_FILE); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 278 | #endif |
| 279 | #ifdef USE_WTMPX |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 280 | printf("\tUSE_WTMPX (WTMPX_FILE=%s)\n", WTMPX_FILE); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 281 | #endif |
| 282 | #ifdef USE_LASTLOG |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 283 | printf("\tUSE_LASTLOG (LASTLOG_FILE=%s)\n", LASTLOG_FILE); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 284 | #endif |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 285 | printf("\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 286 | |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 287 | } /* showOptions() */ |
| 288 | |
| 289 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 290 | int |
| 291 | main(int argc, char *argv[]) |
andre | 61e6725 | 2000-06-04 17:07:49 +0000 | [diff] [blame] | 292 | { |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 293 | printf("Platform-independent login recording test driver\n"); |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 294 | |
Kevin Steves | ff8b495 | 2001-04-05 23:05:22 +0000 | [diff] [blame] | 295 | __progname = get_progname(argv[0]); |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 296 | if (argc == 2) { |
| 297 | if (strncmp(argv[1], "-i", 3) == 0) |
| 298 | compile_opts_only = 1; |
| 299 | else if (strncmp(argv[1], "-v", 3) == 0) |
| 300 | be_verbose=1; |
| 301 | } |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 302 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 303 | if (!compile_opts_only) { |
| 304 | if (be_verbose && !testOutput()) |
| 305 | return 1; |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 306 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 307 | if (!testAPI()) |
| 308 | return 1; |
| 309 | } |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 310 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 311 | showOptions(); |
Kevin Steves | ef4eea9 | 2001-02-05 12:42:17 +0000 | [diff] [blame] | 312 | |
andre | 6e5d347 | 2000-06-13 00:43:47 +0000 | [diff] [blame] | 313 | return 0; |
andre | 2ff7b5d | 2000-06-03 14:57:40 +0000 | [diff] [blame] | 314 | } /* main() */ |
| 315 | |