Skip to content

Commit

Permalink
src/suauth.c: check_su_auth(): Use pointers to simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar authored and hallyn committed Oct 14, 2024
1 parent fb73136 commit 4a15739
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/suauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "defines.h"
#include "prototypes.h"
#include "string/strchr/stpspn.h"
#include "string/strchr/strrspn.h"
#include "string/strtok/stpsep.h"

Expand Down Expand Up @@ -47,7 +48,6 @@ int check_su_auth (const char *actual_id,
const char *wanted_id,
bool su_to_root)
{
int posn;
const char field[] = ":";
FILE *authfile_fd;
char temp[1024];
Expand All @@ -73,6 +73,8 @@ int check_su_auth (const char *actual_id,
}

while (fgets (temp, sizeof (temp), authfile_fd) != NULL) {
char *p;

lines++;

if (stpsep(temp, "\n") == NULL) {
Expand All @@ -84,12 +86,11 @@ int check_su_auth (const char *actual_id,

stpcpy(strrspn(temp, " \t"), "");

posn = strspn(temp, " \t");

if (temp[posn] == '#' || temp[posn] == '\0') {
p = stpspn(temp, " \t");
if (*p == '#' || *p == '\0')
continue;
}
if (!(to_users = strtok (temp + posn, field))

if (!(to_users = strtok(p, field))
|| !(from_users = strtok (NULL, field))
|| !(action = strtok (NULL, field))
|| strtok (NULL, field)) {
Expand Down

0 comments on commit 4a15739

Please sign in to comment.