summaryrefslogtreecommitdiff
path: root/security/PAM/patches/patch-al
blob: ab79d039881c1560207b4a07901016d42434f65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$NetBSD: patch-al,v 1.2 2002/01/29 17:10:11 jlam Exp $

--- modules/pam_issue/pam_issue.c.orig	Wed Feb 21 23:49:45 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 <time.h>
 #include <fcntl.h>
@@ -215,12 +216,24 @@
 	      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) ?