summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--modules/pam_access/pam_access.c13
-rw-r--r--modules/pam_cracklib/pam_cracklib.c11
-rw-r--r--modules/pam_ftp/pam_ftp.c8
-rw-r--r--modules/pam_unix/pam_unix_passwd.c20
5 files changed, 41 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 451b6117..e4ead3a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-03-29 Tomas Mraz <t8m@centrum.cz>
+
+ * modules/pam_access/pam_access.c (login_access, list_match):
+ Replace strtok with strtok_r.
+ * modules/pam_cracklib/pam_cracklib.c (check_old_password):
+ Likewise.
+ * modules/pam_ftp/pam_ftp.c (lookup, pam_authenticate):
+ Likewise.
+ * modules/pam_unix/pam_unix_passwd.c (check_old_password,
+ save_old_password): Likewise.
+
2007-03-12 Thorsten Kukuk <kukuk@thkukuk.de>
* po/ar.po: New translation.
diff --git a/modules/pam_access/pam_access.c b/modules/pam_access/pam_access.c
index 80d94cc9..34ee56bd 100644
--- a/modules/pam_access/pam_access.c
+++ b/modules/pam_access/pam_access.c
@@ -321,6 +321,7 @@ login_access (pam_handle_t *pamh, struct login_info *item)
int match = NO;
int end;
int lineno = 0; /* for diagnostics */
+ char *sptr;
if (pam_access_debug)
pam_syslog (pamh, LOG_DEBUG,
@@ -354,9 +355,9 @@ login_access (pam_handle_t *pamh, struct login_info *item)
continue;
/* Allow field seperator in last field of froms */
- if (!(perm = strtok(line, fs))
- || !(users = strtok((char *) 0, fs))
- || !(froms = strtok((char *) 0, "\n"))) {
+ if (!(perm = strtok_r(line, fs, &sptr))
+ || !(users = strtok_r(NULL, fs, &sptr))
+ || !(froms = strtok_r(NULL, "\n", &sptr))) {
pam_syslog(pamh, LOG_ERR, "%s: line %d: bad field count",
item->config_file, lineno);
continue;
@@ -398,6 +399,7 @@ static int list_match(pam_handle_t *pamh,
{
char *tok;
int match = NO;
+ char *sptr;
/*
* Process tokens one at a time. We have exhausted all possible matches
@@ -406,7 +408,8 @@ static int list_match(pam_handle_t *pamh,
* the match is affected by any exceptions.
*/
- for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) {
+ for (tok = strtok_r(list, sep, &sptr); tok != 0;
+ tok = strtok_r(NULL, sep, &sptr)) {
if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
break;
if ((match = (*match_fn) (pamh, tok, item))) /* YES */
@@ -415,7 +418,7 @@ static int list_match(pam_handle_t *pamh,
/* Process exceptions to matches. */
if (match != NO) {
- while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT"))
+ while ((tok = strtok_r(NULL, sep, &sptr)) && strcasecmp(tok, "EXCEPT"))
/* VOID */ ;
if (tok == 0 || list_match(pamh, (char *) 0, item, match_fn) == NO)
return (match);
diff --git a/modules/pam_cracklib/pam_cracklib.c b/modules/pam_cracklib/pam_cracklib.c
index 9b496202..d2831345 100644
--- a/modules/pam_cracklib/pam_cracklib.c
+++ b/modules/pam_cracklib/pam_cracklib.c
@@ -426,17 +426,18 @@ static const char * check_old_password(const char *forwho, const char *newpass)
while (fgets(buf, 16380, opwfile)) {
if (!strncmp(buf, forwho, strlen(forwho))) {
+ char *sptr;
buf[strlen(buf)-1] = '\0';
- s_luser = strtok(buf, ":,");
- s_uid = strtok(NULL, ":,");
- s_npas = strtok(NULL, ":,");
- s_pas = strtok(NULL, ":,");
+ s_luser = strtok_r(buf, ":,", &sptr);
+ s_uid = strtok_r(NULL, ":,", &sptr);
+ s_npas = strtok_r(NULL, ":,", &sptr);
+ s_pas = strtok_r(NULL, ":,", &sptr);
while (s_pas != NULL) {
if (!strcmp(crypt(newpass, s_pas), s_pas)) {
msg = _("has been already used");
break;
}
- s_pas = strtok(NULL, ":,");
+ s_pas = strtok_r(NULL, ":,", &sptr);
}
break;
}
diff --git a/modules/pam_ftp/pam_ftp.c b/modules/pam_ftp/pam_ftp.c
index 4f4231c2..11cdf590 100644
--- a/modules/pam_ftp/pam_ftp.c
+++ b/modules/pam_ftp/pam_ftp.c
@@ -79,10 +79,11 @@ static int lookup(const char *name, const char *list, const char **_user)
if (list && *list) {
const char *l;
char *list_copy, *x;
+ char *sptr;
list_copy = x_strdup(list);
x = list_copy;
- while (list_copy && (l = strtok(x, ","))) {
+ while (list_copy && (l = strtok_r(x, ",", &sptr))) {
x = NULL;
if (!strcmp(name, l)) {
*_user = list;
@@ -170,11 +171,12 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED,
/* XXX: Some effort should be made to verify this email address! */
if (!(ctrl & PAM_IGNORE_EMAIL)) {
- token = strtok(resp, "@");
+ char *sptr;
+ token = strtok_r(resp, "@", &sptr);
retval = pam_set_item(pamh, PAM_RUSER, token);
if ((token) && (retval == PAM_SUCCESS)) {
- token = strtok(NULL, "@");
+ token = strtok_r(NULL, "@", &sptr);
retval = pam_set_item(pamh, PAM_RHOST, token);
}
}
diff --git a/modules/pam_unix/pam_unix_passwd.c b/modules/pam_unix/pam_unix_passwd.c
index bec856f4..c8ee5492 100644
--- a/modules/pam_unix/pam_unix_passwd.c
+++ b/modules/pam_unix/pam_unix_passwd.c
@@ -330,11 +330,12 @@ static int check_old_password(const char *forwho, const char *newpass)
while (fgets(buf, 16380, opwfile)) {
if (!strncmp(buf, forwho, strlen(forwho))) {
+ char *sptr;
buf[strlen(buf) - 1] = '\0';
- s_luser = strtok(buf, ":,");
- s_uid = strtok(NULL, ":,");
- s_npas = strtok(NULL, ":,");
- s_pas = strtok(NULL, ":,");
+ s_luser = strtok_r(buf, ":,", &sptr);
+ s_uid = strtok_r(NULL, ":,", &sptr);
+ s_npas = strtok_r(NULL, ":,", &sptr);
+ s_pas = strtok_r(NULL, ":,", &sptr);
while (s_pas != NULL) {
char *md5pass = Goodcrypt_md5(newpass, s_pas);
if (!strcmp(md5pass, s_pas)) {
@@ -342,7 +343,7 @@ static int check_old_password(const char *forwho, const char *newpass)
retval = PAM_AUTHTOK_ERR;
break;
}
- s_pas = strtok(NULL, ":,");
+ s_pas = strtok_r(NULL, ":,", &sptr);
_pam_delete(md5pass);
}
break;
@@ -432,11 +433,12 @@ static int save_old_password(pam_handle_t *pamh,
while (fgets(buf, 16380, opwfile)) {
if (!strncmp(buf, forwho, strlen(forwho))) {
+ char *sptr;
buf[strlen(buf) - 1] = '\0';
- s_luser = strtok(buf, ":");
- s_uid = strtok(NULL, ":");
- s_npas = strtok(NULL, ":");
- s_pas = strtok(NULL, ":");
+ s_luser = strtok_r(buf, ":", &sptr);
+ s_uid = strtok_r(NULL, ":", &sptr);
+ s_npas = strtok_r(NULL, ":", &sptr);
+ s_pas = strtok_r(NULL, ":", &sptr);
npas = strtol(s_npas, NULL, 10) + 1;
while (npas > howmany) {
s_pas = strpbrk(s_pas, ",");