2013-09-26 17:14:40 +02:00

38 lines
938 B
Plaintext

$NetBSD: patch-am,v 1.4 2002/12/23 21:23:59 jlam Exp $
--- modules/pam_issue/pam_issue.c.orig Sun Nov 11 21:23:29 2001
+++ modules/pam_issue/pam_issue.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
@@ -244,12 +245,24 @@ char *do_prompt(FILE *fd)
case 'U':
{
int users = 0;
+#if (defined(BSD) && BSD >= 199306)
+ struct utmp ut;
+ FILE *uf;
+
+ if ((uf == fopen(_PATH_UTMP, "r")) != NULL) {
+ while (fread(&ut, sizeof(ut), 1, uf) > 0)
+ if (ut.ut_name[0] != '\0')
+ ++users;
+ (void) fclose(uf);
+ }
+#else
struct utmp *ut;
setutent();
while ((ut = getutent()))
if (ut->ut_type == USER_PROCESS)
users++;
endutent();
+#endif
printf ("%d ", users);
if (c == 'U')
snprintf (buf, 1024, "%s", (users == 1) ?