diff --git a/src/suauth.c b/src/suauth.c index ac9af264..9def76c0 100644 --- a/src/suauth.c +++ b/src/suauth.c @@ -13,11 +13,13 @@ #include #include #include +#include #include #include "defines.h" #include "prototypes.h" #include "string/strchr/strrspn.h" +#include "string/strtok/stpsep.h" #ifndef SUAUTHFILE @@ -45,7 +47,7 @@ int check_su_auth (const char *actual_id, const char *wanted_id, bool su_to_root) { - int posn, endline; + int posn; const char field[] = ":"; FILE *authfile_fd; char temp[1024]; @@ -72,23 +74,21 @@ int check_su_auth (const char *actual_id, while (fgets (temp, sizeof (temp), authfile_fd) != NULL) { lines++; - endline = strlen(temp) - 1; - if (temp[0] == '\0' || temp[endline] != '\n') { + if (stpsep(temp, "\n") == NULL) { SYSLOG ((LOG_ERR, "%s, line %d: line too long or missing newline", SUAUTHFILE, lines)); continue; } - stpcpy(strrspn(temp, " \t\n"), ""); + stpcpy(strrspn(temp, " \t"), ""); posn = 0; while (temp[posn] == ' ' || temp[posn] == '\t') posn++; - if (temp[posn] == '\n' || temp[posn] == '#' - || temp[posn] == '\0') { + if (temp[posn] == '#' || temp[posn] == '\0') { continue; } if (!(to_users = strtok (temp + posn, field))