Go to the documentation of this file.
37 #include <sys/socket.h>
40 #include <netinet/in.h>
43 #include <arpa/inet.h>
62 #define DICT_BUFFER_SIZE 8196
94 current_entry = first_entry;
96 unsigned int lineCount = 0;
97 while (fgets(line,
sizeof(line), FH) !=
nullptr) {
104 if ((cp = strchr (line,
'\n')) !=
nullptr) {
108 if (strtok(line,
"\t ") !=
nullptr) {
113 if ((
username = strtok(
nullptr,
"\t ")) ==
nullptr) {
114 debug(
"Missing username on line %u of dictionary file\n", lineCount);
119 if ((cp = strtok (line,
"/")) !=
nullptr) {
122 cp = strtok (
nullptr,
"/");
125 current_entry->
netmask = (inet_addr(cp));
127 (((inet_addr (tmpbuf))) & current_entry->
netmask);
130 current_entry->
address = (inet_addr(tmpbuf));
131 current_entry->
netmask = (inet_addr(
"255.255.255.255"));
136 (
char*)calloc(strlen(
username) + 1,
sizeof(char));
162 while (current_entry && current_entry->
username) {
163 debug(
"user: %s\naddr: %lu\nmask: %lu\n\n",
167 if ((inet_addr (
address) & (
unsigned long) current_entry->
171 if ((strchr (current_entry->
username,
'@')) ==
nullptr) {
189 if ((strcmp(dict_username,
username)) == 0) {
192 if ((strcmp(dict_username,
"ALL")) == 0) {
207 g = getgrnam(dict_group);
208 if (!g || !g->gr_mem) {
209 debug(
"Group does not exist or has no members '%s'\n", dict_group);
213 for (
char *
const *m = g->gr_mem; *m; ++m) {
214 if (strcmp(*m, username) == 0)
223 fprintf (stderr,
"Usage:\n%s [-d] -f <configuration file>\n",
230 char *filename =
nullptr;
233 char *username, *address;
238 setvbuf (stdout,
nullptr, _IOLBF, 0);
239 while ((ch =
getopt(argc, argv,
"df:h")) != -1) {
251 fprintf(stderr,
"%s: FATAL: Unknown parameter option '%c'",
program_name, ch);
256 if (filename ==
nullptr) {
257 fprintf(stderr,
"%s: FATAL: No Filename configured.",
program_name);
261 FILE *FH = fopen(filename,
"r");
264 fprintf(stderr,
"%s: FATAL: Unable to open file '%s': %s",
program_name, filename,
xstrerr(xerrno));
270 if ((cp = strchr (line,
'\n')) ==
nullptr) {
272 fprintf(stderr,
"%s: ERROR: Input Too Large: %s\n",
program_name, line);
273 while (fgets(line,
sizeof(line), stdin)) {
274 fprintf(stderr,
"%s: ERROR: Input Too Large..: %s\n",
program_name, line);
275 if (strchr(line,
'\n') !=
nullptr)
const char * xstrerr(int error)
void * xcalloc(size_t n, size_t sz)
void debug(const char *format,...)
int match_group(char *, char *)
int match_user(char *, char *)
int getopt(int nargc, char *const *nargv, const char *ostr)
int main(int argc, char *argv[])
void rfc1738_unescape(char *url)
struct ip_user_dict * load_dict(FILE *)
int dict_lookup(struct ip_user_dict *, char *, char *)
struct ip_user_dict * next_entry
#define HELPER_INPUT_BUFFER
squidaio_request_t * head
static void free_dict(struct ip_user_dict *head)
static void usage(const char *program_name)