]>
git.ipfire.org Git - thirdparty/squid.git/blob - helpers/basic_auth/MSNT/denyusers.cc
5 * (C) 2000 Antonino Iannella, Stellar-X Pty Ltd
6 * Released under GPL, see COPYING-2.0 for details.
8 * These routines are to block users attempting to use the proxy which
9 * have been explicitly denied by the system administrator.
10 * Routines at the bottom also use the allowed user functions.
16 #include <sys/types.h>
17 #include <sys/param.h>
19 #include "usersfile.h"
22 static usersfile DenyUsers
;
26 char Denyuserpath
[MAXPATHLEN
]; /* MAXPATHLEN defined in param.h */
32 memset(&DenyUsers
, '\0', sizeof(DenyUsers
));
36 return Read_usersfile(Denyuserpath
, &DenyUsers
);
42 Check_fordenychange(void)
44 Check_forfilechange(&DenyUsers
);
49 * Check to see if the username provided by Squid appears in the denied
50 * user list. Returns 0 if the user was not found, and 1 if they were.
54 Check_ifuserdenied(char *ConnectingUser
)
56 /* If user string is empty, deny */
57 if (ConnectingUser
[0] == '\0')
60 /* If denied user list is empty, allow */
61 if (DenyUsers
.Inuse
== 0)
64 return Check_userlist(&DenyUsers
, ConnectingUser
);
68 * Decides if a user is denied or allowed.
69 * If they have been denied, or not allowed, return 1.
74 Check_user(char *ConnectingUser
)
76 if (Check_ifuserdenied(ConnectingUser
) == 1)
79 if (Check_ifuserallowed(ConnectingUser
) == 0)
86 * Checks the denied and allowed user files for change.
87 * This function is invoked when a SIGHUP signal is received.
88 * It is also run after every 60 seconds, at the next request.
92 Check_forchange(int signal
)
94 Check_fordenychange();
95 Check_forallowchange();
99 * Checks the timer. If longer than 1 minute has passed since the last
100 * time someone has accessed the proxy, then check for changes in the
101 * denied user file. If longer than one minute hasn't passed, return.
107 static time_t Lasttime
; /* The last time the timer was checked */
108 static time_t Currenttime
; /* The current time */
110 Currenttime
= time(NULL
);
112 /* If timeout has expired, check the denied user file, else return */
113 if (difftime(Currenttime
, Lasttime
) < 60)
117 Lasttime
= Currenttime
;