~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to helpers/basic_auth/MSNT/confload.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * confload.c
4
4
 * (C) 2000 Antonino Iannella, Stellar-X Pty Ltd
5
5
 * Released under GPL, see COPYING-2.0 for details.
6
 
 * 
 
6
 *
7
7
 * These routines load the msntauth configuration file.
8
8
 * It stores the servers to query, sets the denied and
9
 
 * allowed user files, and provides the 
 
9
 * allowed user files, and provides the
10
10
 * authenticating function.
11
11
 */
12
12
 
73
73
 
74
74
    /* Open file */
75
75
    if ((ConfigFile = fopen(CONFIGFILE, "r")) == NULL) {
76
 
        syslog(LOG_ERR, "OpenConfigFile: Failed to open %s.", CONFIGFILE);
77
 
        syslog(LOG_ERR, "%s", strerror(errno));
78
 
        return 1;
 
76
        syslog(LOG_ERR, "OpenConfigFile: Failed to open %s.", CONFIGFILE);
 
77
        syslog(LOG_ERR, "%s", strerror(errno));
 
78
        return 1;
79
79
    }
80
80
    /* Read in, one line at a time */
81
81
    while (!feof(ConfigFile)) {
82
 
        Confbuf[0] = '\0';
83
 
        if (NULL == fgets(Confbuf, 2048, ConfigFile))
84
 
            break;
85
 
        Confbuf[2048] = '\0';
86
 
        ProcessLine(Confbuf);
 
82
        Confbuf[0] = '\0';
 
83
        if (NULL == fgets(Confbuf, 2048, ConfigFile))
 
84
            break;
 
85
        Confbuf[2048] = '\0';
 
86
        ProcessLine(Confbuf);
87
87
    }
88
88
 
89
89
    /*
92
92
     * not set in the confugration file.
93
93
     */
94
94
    if (Serversqueried == 0) {
95
 
        syslog(LOG_ERR, "OpenConfigFile: No servers set in %s. At least one is needed.", CONFIGFILE);
96
 
        return 1;
 
95
        syslog(LOG_ERR, "OpenConfigFile: No servers set in %s. At least one is needed.", CONFIGFILE);
 
96
        return 1;
97
97
    }
98
98
    fclose(ConfigFile);
99
99
    return 0;
111
111
 
112
112
    /* Ignore empty lines */
113
113
    if (strlen(Linebuf) == 0)
114
 
        return;
 
114
        return;
115
115
 
116
116
    /* Break up on whitespaces */
117
117
    if ((Directive = strtok(Linebuf, " \t\n")) == NULL)
118
 
        return;
 
118
        return;
119
119
 
120
120
    /* Check for a comment line. If found, stop . */
121
121
    if (Directive[0] == '#')
122
 
        return;
 
122
        return;
123
123
 
124
124
    /* Check for server line. Check for 3 parameters. */
125
125
    if (strcasecmp(Directive, "server") == 0) {
126
 
        Param1 = strtok(NULL, " \t\n");
127
 
        if (NULL == Param1) {
128
 
            syslog(LOG_ERR, "ProcessLine: 'server' missing PDC parameter.");
129
 
            return;
130
 
        }
131
 
        Param2 = strtok(NULL, " \t\n");
132
 
        if (NULL == Param2) {
133
 
            syslog(LOG_ERR, "ProcessLine: 'server' missing BDC parameter.");
134
 
            return;
135
 
        }
136
 
        Param3 = strtok(NULL, " \t\n");
137
 
        if (NULL == Param3) {
138
 
            syslog(LOG_ERR, "ProcessLine: 'server' missing domain parameter.");
139
 
            return;
140
 
        }
141
 
        AddServer(Param1, Param2, Param3);
142
 
        return;
 
126
        Param1 = strtok(NULL, " \t\n");
 
127
        if (NULL == Param1) {
 
128
            syslog(LOG_ERR, "ProcessLine: 'server' missing PDC parameter.");
 
129
            return;
 
130
        }
 
131
        Param2 = strtok(NULL, " \t\n");
 
132
        if (NULL == Param2) {
 
133
            syslog(LOG_ERR, "ProcessLine: 'server' missing BDC parameter.");
 
134
            return;
 
135
        }
 
136
        Param3 = strtok(NULL, " \t\n");
 
137
        if (NULL == Param3) {
 
138
            syslog(LOG_ERR, "ProcessLine: 'server' missing domain parameter.");
 
139
            return;
 
140
        }
 
141
        AddServer(Param1, Param2, Param3);
 
142
        return;
143
143
    }
144
144
    /* Check for denyusers line */
145
145
    if (strcasecmp(Directive, "denyusers") == 0) {
146
 
        Param1 = strtok(NULL, " \t\n");
 
146
        Param1 = strtok(NULL, " \t\n");
147
147
 
148
 
        if (NULL == Param1) {
149
 
            syslog(LOG_ERR, "ProcessLine: A 'denyusers' line needs a filename parameter.");
150
 
            return;
151
 
        }
152
 
        memset(Denyuserpath, '\0', MAXPATHLEN);
153
 
        strncpy(Denyuserpath, Param1, MAXPATHLEN - 1);
154
 
        return;
 
148
        if (NULL == Param1) {
 
149
            syslog(LOG_ERR, "ProcessLine: A 'denyusers' line needs a filename parameter.");
 
150
            return;
 
151
        }
 
152
        memset(Denyuserpath, '\0', MAXPATHLEN);
 
153
        strncpy(Denyuserpath, Param1, MAXPATHLEN - 1);
 
154
        return;
155
155
    }
156
156
    /* Check for allowusers line */
157
157
    if (strcasecmp(Directive, "allowusers") == 0) {
158
 
        Param1 = strtok(NULL, " \t\n");
 
158
        Param1 = strtok(NULL, " \t\n");
159
159
 
160
 
        if (NULL == Param1) {
161
 
            syslog(LOG_ERR, "ProcessLine: An 'allowusers' line needs a filename parameter.");
162
 
            return;
163
 
        }
164
 
        memset(Allowuserpath, '\0', MAXPATHLEN);
165
 
        strncpy(Allowuserpath, Param1, MAXPATHLEN - 1);
166
 
        return;
 
160
        if (NULL == Param1) {
 
161
            syslog(LOG_ERR, "ProcessLine: An 'allowusers' line needs a filename parameter.");
 
162
            return;
 
163
        }
 
164
        memset(Allowuserpath, '\0', MAXPATHLEN);
 
165
        strncpy(Allowuserpath, Param1, MAXPATHLEN - 1);
 
166
        return;
167
167
    }
168
168
    /* Reports error for unknown line */
169
169
    syslog(LOG_ERR, "ProcessLine: Ignoring '%s' line.", Directive);
180
180
AddServer(char *ParamPDC, char *ParamBDC, char *ParamDomain)
181
181
{
182
182
    if (Serversqueried == MAXSERVERS) {
183
 
        syslog(LOG_ERR, "AddServer: Ignoring '%s' server line; "
184
 
            "too many servers.", ParamPDC);
185
 
        return;
 
183
        syslog(LOG_ERR, "AddServer: Ignoring '%s' server line; "
 
184
               "too many servers.", ParamPDC);
 
185
        return;
186
186
    }
187
187
    if (gethostbyname(ParamPDC) == NULL) {
188
 
        syslog(LOG_ERR, "AddServer: Ignoring host '%s'. "
189
 
            "Cannot resolve its address.", ParamPDC);
190
 
        return;
 
188
        syslog(LOG_ERR, "AddServer: Ignoring host '%s'. "
 
189
               "Cannot resolve its address.", ParamPDC);
 
190
        return;
191
191
    }
192
192
    if (gethostbyname(ParamBDC) == NULL) {
193
 
        syslog(LOG_USER | LOG_ERR, "AddServer: Ignoring host '%s'. "
194
 
            "Cannot resolve its address.", ParamBDC);
195
 
        return;
 
193
        syslog(LOG_USER | LOG_ERR, "AddServer: Ignoring host '%s'. "
 
194
               "Cannot resolve its address.", ParamBDC);
 
195
        return;
196
196
    }
197
197
    /* NOTE: ServerArray is zeroed in OpenConfigFile() */
198
198
    assert(Serversqueried < MAXSERVERS);
213
213
{
214
214
    int i;
215
215
    for (i = 0; i < Serversqueried; i++) {
216
 
        if (0 == QueryServerForUser(i, username, password))
217
 
            return 0;
 
216
        if (0 == QueryServerForUser(i, username, password))
 
217
            return 0;
218
218
    }
219
219
    return 1;
220
220
}
236
236
    int result = 1;
237
237
 
238
238
    result = Valid_User(username, password, ServerArray[x].pdc,
239
 
        ServerArray[x].bdc, ServerArray[x].domain);
 
239
                        ServerArray[x].bdc, ServerArray[x].domain);
240
240
 
241
241
    switch (result) {           /* Write any helpful syslog messages */
242
242
    case 0:
243
 
        break;
 
243
        break;
244
244
    case 1:
245
 
        syslog(LOG_AUTHPRIV | LOG_INFO, "Server error when checking %s.",
246
 
            username);
247
 
        break;
 
245
        syslog(LOG_AUTHPRIV | LOG_INFO, "Server error when checking %s.",
 
246
               username);
 
247
        break;
248
248
    case 2:
249
 
        syslog(LOG_AUTHPRIV | LOG_INFO, "Protocol error when checking %s.",
250
 
            username);
251
 
        break;
 
249
        syslog(LOG_AUTHPRIV | LOG_INFO, "Protocol error when checking %s.",
 
250
               username);
 
251
        break;
252
252
    case 3:
253
 
        syslog(LOG_AUTHPRIV | LOG_INFO, "Authentication failed for %s.",
254
 
            username);
255
 
        break;
 
253
        syslog(LOG_AUTHPRIV | LOG_INFO, "Authentication failed for %s.",
 
254
               username);
 
255
        break;
256
256
    }
257
257
 
258
258
    return result;
259
259
}
260
260
 
261
261
/* Valid_User return codes -
262
 
 * 
 
262
 *
263
263
 * 0 - User authenticated successfully.
264
264
 * 1 - Server error.
265
265
 * 2 - Protocol error.