blob: 2fb8cbf285a9eab99ad24987e2f26e7c9a2156ea (
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-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) ?
|