diff options
author | Samuel Varley <samuel.varley@alliedtelesis.co.nz> | 2015-11-26 11:04:25 +1300 |
---|---|---|
committer | Samuel Varley <samuel.varley@alliedtelesis.co.nz> | 2015-12-10 12:45:13 +1300 |
commit | 8cadbd70f4e8323f7e2901c774d5206cd456643f (patch) | |
tree | 42ab59427ea790517bb401e6e61cf6f695e1b565 /src/pam_radius_auth.c | |
parent | 14664dab2d129a7f975648930a1594bdcc1b374a (diff) | |
download | libpam-radius-auth-8cadbd70f4e8323f7e2901c774d5206cd456643f.tar.gz libpam-radius-auth-8cadbd70f4e8323f7e2901c774d5206cd456643f.zip |
Thread safety: Store the name of conf file in radius_conf_t.
I needed to move the position of the structures
so I could use the CONST macro with the new
member.
Diffstat (limited to 'src/pam_radius_auth.c')
-rw-r--r-- | src/pam_radius_auth.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/pam_radius_auth.c b/src/pam_radius_auth.c index 29b0322..0ee145e 100644 --- a/src/pam_radius_auth.c +++ b/src/pam_radius_auth.c @@ -61,7 +61,6 @@ /* internal data */ static CONST char *pam_module_name = "pam_radius_auth"; -static char conf_file[BUFFER_SIZE]; /* configuration file */ static int opt_debug = FALSE; /* print debug info */ /* logging */ @@ -84,7 +83,7 @@ static int _pam_parse(int argc, CONST char **argv, radius_conf_t *conf) memset(conf, 0, sizeof(radius_conf_t)); /* ensure it's initialized */ - strcpy(conf_file, CONF_FILE); + conf->conf_file = CONF_FILE; /* set the default prompt */ snprintf(conf->prompt, MAXPROMPT, "%s: ", DEFAULT_PROMPT); @@ -101,13 +100,7 @@ static int _pam_parse(int argc, CONST char **argv, radius_conf_t *conf) /* generic options */ if (!strncmp(*argv,"conf=",5)) { - /* protect against buffer overflow */ - if (strlen(*argv+5) >= sizeof(conf_file)) { - _pam_log(LOG_ERR, "conf= argument too long"); - conf_file[0] = 0; - return 0; - } - strcpy(conf_file,*argv+5); + conf->conf_file = *argv+5; } else if (!strcmp(*argv, "use_first_pass")) { ctrl |= PAM_USE_FIRST_PASS; @@ -574,11 +567,11 @@ static int initialize(radius_conf_t *conf, int accounting) char src_ip[MAX_IP_LEN]; /* the first time around, read the configuration file */ - if ((fserver = fopen (conf_file, "r")) == (FILE*)NULL) { + if ((fserver = fopen (conf->conf_file, "r")) == (FILE*)NULL) { char error_string[BUFFER_SIZE]; get_error_string(errno, error_string, sizeof(error_string)); _pam_log(LOG_ERR, "Could not open configuration file %s: %s\n", - conf_file, error_string); + conf->conf_file, error_string); return PAM_ABORT; } @@ -604,7 +597,7 @@ static int initialize(radius_conf_t *conf, int accounting) src_ip[0] = 0; if (sscanf(p, "%s %s %d %s", hostname, secret, &timeout, src_ip) < 2) { _pam_log(LOG_ERR, "ERROR reading %s, line %d: Could not read hostname or secret\n", - conf_file, line); + conf->conf_file, line); continue; /* invalid line */ } else { /* read it in and save the data */ radius_server_t *tmp; @@ -636,7 +629,7 @@ static int initialize(radius_conf_t *conf, int accounting) if (!server) { /* no server found, die a horrible death */ _pam_log(LOG_ERR, "No RADIUS server found in configuration file %s\n", - conf_file); + conf->conf_file); return PAM_AUTHINFO_UNAVAIL; } |