From 66cb44437a5453e0b5eeffa20cf7c5b42f721279 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Wed, 6 Dec 2023 19:54:42 +0100 Subject: libpam: remove format argument for _pam_tokenize It is always the same format. Signed-off-by: Tobias Stoeckmann --- libpam/pam_handlers.c | 8 ++++---- libpam/pam_misc.c | 17 ++++++++--------- libpam/pam_private.h | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'libpam') diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c index 860a1abf..2030dbb8 100644 --- a/libpam/pam_handlers.c +++ b/libpam/pam_handlers.c @@ -85,7 +85,7 @@ static int _pam_parse_conf_file(pam_handle_t *pamh, FILE *f /* No service field: all lines are for the known service. */ this_service = known_service; } else { - this_service = tok = _pam_tokenize(buf, " \n\t", &nexttok); + this_service = tok = _pam_tokenize(buf, &nexttok); } #ifdef PAM_READ_BOTH_CONFS @@ -103,7 +103,7 @@ static int _pam_parse_conf_file(pam_handle_t *pamh, FILE *f /* This is a service we are looking for */ D(("Found PAM config entry for: %s", this_service)); - tok = _pam_tokenize(NULL, " \n\t", &nexttok); + tok = _pam_tokenize(NULL, &nexttok); if (tok == NULL) { /* module type does not exist */ D(("empty module type for %s", this_service)); @@ -150,7 +150,7 @@ static int _pam_parse_conf_file(pam_handle_t *pamh, FILE *f for (i=0; i<_PAM_RETURN_VALUES; actions[i++] = _PAM_ACTION_UNDEF); } - tok = _pam_tokenize(NULL, " \n\t", &nexttok); + tok = _pam_tokenize(NULL, &nexttok); if (tok == NULL) { /* no module name given */ D(("no control flag supplied")); @@ -195,7 +195,7 @@ static int _pam_parse_conf_file(pam_handle_t *pamh, FILE *f _pam_set_default_control(actions, _PAM_ACTION_BAD); } - tok = _pam_tokenize(NULL, " \n\t", &nexttok); + tok = _pam_tokenize(NULL, &nexttok); if (pam_include) { if (substack) { res = _pam_add_handler(pamh, PAM_HT_SUBSTACK, other, diff --git a/libpam/pam_misc.c b/libpam/pam_misc.c index 8cf2214e..88702fcc 100644 --- a/libpam/pam_misc.c +++ b/libpam/pam_misc.c @@ -45,13 +45,14 @@ #include #include -char *_pam_tokenize(char *from, const char *format, char **next) +char *_pam_tokenize(char *from, char **next) /* - * this function is a variant of the standard strtok, it differs in that - * it takes an additional argument and doesn't nul terminate tokens until + * this function is a variant of the standard strtok_r, it differs in that + * it uses a fixed set of delimiters and doesn't nul terminate tokens until * they are actually reached. */ { + const char *format = " \n\t"; char table[256], *end; int i; @@ -71,11 +72,9 @@ char *_pam_tokenize(char *from, const char *format, char **next) if (*from == '[') { /* * special case, "[...]" is considered to be a single - * object. Note, however, if one of the format[] chars is - * '[' this single string will not be read correctly. - * Note, any '[' inside the outer "[...]" pair will survive. - * Note, the first ']' will terminate this string, but - * that "\]" will get compressed into "]". That is: + * object. Note, any '[' inside the outer "[...]" pair will + * survive. Note, the first ']' will terminate this string, + * but that "\]" will get compressed into "]". That is: * * "[..[..\]..]..." --> "..[..].." */ @@ -198,7 +197,7 @@ int _pam_mkargv(const char *s, char ***argv, int *argc) argvbufp = (char *) argvbuf + (l * sizeof(char *)); D(("[%s]",sbuf)); - while ((sbuf = _pam_tokenize(sbuf, " \n\t", &tmp))) { + while ((sbuf = _pam_tokenize(sbuf, &tmp))) { D(("arg #%d",++count)); D(("->[%s]",sbuf)); strcpy(argvbufp, sbuf); diff --git a/libpam/pam_private.h b/libpam/pam_private.h index 1ddb7f9f..da268bdf 100644 --- a/libpam/pam_private.h +++ b/libpam/pam_private.h @@ -266,7 +266,7 @@ struct pam_data { void _pam_free_data(pam_handle_t *pamh, int status); -char *_pam_tokenize(char *from, const char *format, char **next); +char *_pam_tokenize(char *from, char **next); char *_pam_strdup(const char *s); -- cgit v1.2.3