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));
76
syslog(LOG_ERR, "OpenConfigFile: Failed to open %s.", CONFIGFILE);
77
syslog(LOG_ERR, "%s", strerror(errno));
80
80
/* Read in, one line at a time */
81
81
while (!feof(ConfigFile)) {
83
if (NULL == fgets(Confbuf, 2048, ConfigFile))
83
if (NULL == fgets(Confbuf, 2048, ConfigFile))
112
112
/* Ignore empty lines */
113
113
if (strlen(Linebuf) == 0)
116
116
/* Break up on whitespaces */
117
117
if ((Directive = strtok(Linebuf, " \t\n")) == NULL)
120
120
/* Check for a comment line. If found, stop . */
121
121
if (Directive[0] == '#')
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.");
131
Param2 = strtok(NULL, " \t\n");
132
if (NULL == Param2) {
133
syslog(LOG_ERR, "ProcessLine: 'server' missing BDC parameter.");
136
Param3 = strtok(NULL, " \t\n");
137
if (NULL == Param3) {
138
syslog(LOG_ERR, "ProcessLine: 'server' missing domain parameter.");
141
AddServer(Param1, Param2, Param3);
126
Param1 = strtok(NULL, " \t\n");
127
if (NULL == Param1) {
128
syslog(LOG_ERR, "ProcessLine: 'server' missing PDC parameter.");
131
Param2 = strtok(NULL, " \t\n");
132
if (NULL == Param2) {
133
syslog(LOG_ERR, "ProcessLine: 'server' missing BDC parameter.");
136
Param3 = strtok(NULL, " \t\n");
137
if (NULL == Param3) {
138
syslog(LOG_ERR, "ProcessLine: 'server' missing domain parameter.");
141
AddServer(Param1, Param2, Param3);
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");
148
if (NULL == Param1) {
149
syslog(LOG_ERR, "ProcessLine: A 'denyusers' line needs a filename parameter.");
152
memset(Denyuserpath, '\0', MAXPATHLEN);
153
strncpy(Denyuserpath, Param1, MAXPATHLEN - 1);
148
if (NULL == Param1) {
149
syslog(LOG_ERR, "ProcessLine: A 'denyusers' line needs a filename parameter.");
152
memset(Denyuserpath, '\0', MAXPATHLEN);
153
strncpy(Denyuserpath, Param1, MAXPATHLEN - 1);
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");
160
if (NULL == Param1) {
161
syslog(LOG_ERR, "ProcessLine: An 'allowusers' line needs a filename parameter.");
164
memset(Allowuserpath, '\0', MAXPATHLEN);
165
strncpy(Allowuserpath, Param1, MAXPATHLEN - 1);
160
if (NULL == Param1) {
161
syslog(LOG_ERR, "ProcessLine: An 'allowusers' line needs a filename parameter.");
164
memset(Allowuserpath, '\0', MAXPATHLEN);
165
strncpy(Allowuserpath, Param1, MAXPATHLEN - 1);
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)
182
182
if (Serversqueried == MAXSERVERS) {
183
syslog(LOG_ERR, "AddServer: Ignoring '%s' server line; "
184
"too many servers.", ParamPDC);
183
syslog(LOG_ERR, "AddServer: Ignoring '%s' server line; "
184
"too many servers.", ParamPDC);
187
187
if (gethostbyname(ParamPDC) == NULL) {
188
syslog(LOG_ERR, "AddServer: Ignoring host '%s'. "
189
"Cannot resolve its address.", ParamPDC);
188
syslog(LOG_ERR, "AddServer: Ignoring host '%s'. "
189
"Cannot resolve its address.", ParamPDC);
192
192
if (gethostbyname(ParamBDC) == NULL) {
193
syslog(LOG_USER | LOG_ERR, "AddServer: Ignoring host '%s'. "
194
"Cannot resolve its address.", ParamBDC);
193
syslog(LOG_USER | LOG_ERR, "AddServer: Ignoring host '%s'. "
194
"Cannot resolve its address.", ParamBDC);
197
197
/* NOTE: ServerArray is zeroed in OpenConfigFile() */
198
198
assert(Serversqueried < MAXSERVERS);
238
238
result = Valid_User(username, password, ServerArray[x].pdc,
239
ServerArray[x].bdc, ServerArray[x].domain);
239
ServerArray[x].bdc, ServerArray[x].domain);
241
241
switch (result) { /* Write any helpful syslog messages */
245
syslog(LOG_AUTHPRIV | LOG_INFO, "Server error when checking %s.",
245
syslog(LOG_AUTHPRIV | LOG_INFO, "Server error when checking %s.",
249
syslog(LOG_AUTHPRIV | LOG_INFO, "Protocol error when checking %s.",
249
syslog(LOG_AUTHPRIV | LOG_INFO, "Protocol error when checking %s.",
253
syslog(LOG_AUTHPRIV | LOG_INFO, "Authentication failed for %s.",
253
syslog(LOG_AUTHPRIV | LOG_INFO, "Authentication failed for %s.",
261
261
/* Valid_User return codes -
263
263
* 0 - User authenticated successfully.
264
264
* 1 - Server error.
265
265
* 2 - Protocol error.