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