#include <grp.h>
#include <pwd.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include "defines.h"
#include "prototypes.h"
#include "string/strchr/strrspn.h"
+#include "string/strtok/stpsep.h"
#ifndef SUAUTHFILE
const char *wanted_id,
bool su_to_root)
{
- int posn, endline;
+ int posn;
const char field[] = ":";
FILE *authfile_fd;
char temp[1024];
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))