]>
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>
20 #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
);
48 * Check to see if the username provided by Squid appears in the denied
49 * user list. Returns 0 if the user was not found, and 1 if they were.
53 Check_ifuserdenied(char *ConnectingUser
)
55 /* If user string is empty, deny */
56 if (ConnectingUser
[0] == '\0')
59 /* If denied user list is empty, allow */
60 if (DenyUsers
.Inuse
== 0)
63 return Check_userlist(&DenyUsers
, ConnectingUser
);
67 * Decides if a user is denied or allowed.
68 * If they have been denied, or not allowed, return 1.
73 Check_user(char *ConnectingUser
)
75 if (Check_ifuserdenied(ConnectingUser
) == 1)
78 if (Check_ifuserallowed(ConnectingUser
) == 0)
85 * Checks the denied and allowed user files for change.
86 * This function is invoked when a SIGHUP signal is received.
87 * It is also run after every 60 seconds, at the next request.
91 Check_forchange(int signal
)
93 Check_fordenychange();
94 Check_forallowchange();
98 * Checks the timer. If longer than 1 minute has passed since the last
99 * time someone has accessed the proxy, then check for changes in the
100 * denied user file. If longer than one minute hasn't passed, return.
106 static time_t Lasttime
; /* The last time the timer was checked */
107 static time_t Currenttime
; /* The current time */
109 Currenttime
= time(NULL
);
111 /* If timeout has expired, check the denied user file, else return */
112 if (difftime(Currenttime
, Lasttime
) < 60)
116 Lasttime
= Currenttime
;