- printf("**\n** Testing the API...\n**\n");
-
- pw = getpwuid(getuid());
- strlcpy(username, pw->pw_name, sizeof(username));
-
- /* gethostname(hostname, sizeof(hostname)); */
-
- printf("login_alloc_entry test (no host info):\n");
- /* !!! fake tty more effectively */
- li1 = login_alloc_entry((int)getpid(), username, NULL, ttyname(0));
- login_set_progname(li1, "testlogin");
-
- if (be_verbose)
- dump_logininfo(li1, "li1");
-
- printf("Setting IPv4 host info for 'localhost' (may call out):\n");
- if (! (he = gethostbyname("localhost"))) {
- printf("Couldn't set hostname(lookup failed)\n");
- } else {
- /* NOTE: this is messy, but typically a program wouldn't have to set
- * any of this, a sockaddr_in* would be already prepared */
- memcpy((void *)&(sa_in4.sin_addr), (void *)&(he->h_addr_list[0][0]),
- sizeof(struct in_addr));
- login_set_ip4(li1, &sa_in4);
- login_set_hostname(li1, "localhost");
- }
- if (be_verbose)
- dump_logininfo(li1, "li1");
-
- if ((int)geteuid() != 0) {
- printf("NOT RUNNING LOGIN TESTS - you are not root!\n");
- return 1; /* this isn't necessarily an error */
- }
-
- if (nologtest)
- return 1;
-
- line_stripname(stripline, li1->line, sizeof(stripline));
-
- printf("Performing an invalid login attempt (no type field)\n--\n");
- login_write(li1);
- printf("--\n(Should have written an error to stderr)\n");
+ printf("Performing a login on line %s ", stripline);
+#ifdef HAVE_TIME_H
+ (void)time(&logintime);
+ strlcpy(s_logintime, ctime(&logintime), sizeof(s_logintime));
+ printf("at %d - %s", (int)logintime, s_logintime);
+#endif
+ printf("--\n");
+ login_login(li1);