1
0
mirror of https://github.com/Yubico/yubico-pam.git synced 2025-02-20 21:54:16 +01:00

Support comments in authfile

Adds support for comments (indicated by lines starting with '#') in
authfiles.
This commit is contained in:
Alex Feinberg 2015-08-04 20:17:51 -07:00
parent 50ce40bbb1
commit 362ca9cb92
2 changed files with 8 additions and 0 deletions

View File

@ -58,7 +58,9 @@ static void test_check_user_token(void) {
assert(fd != -1);
handle = fdopen(fd, "w");
fprintf(handle, "# This is a comment containing foobar:foobar\n");
fprintf(handle, "foobar:hhhvhvhdhbid:hnhbhnhbhnhb:\n");
fprintf(handle, "# This is a comment in the middle\n");
fprintf(handle, "kaka:hdhrhbhjhvhu:hihbhdhrhbhj\n");
fprintf(handle, "bar:hnhbhnhbhnhb\n");
fclose(handle);

6
util.c
View File

@ -147,6 +147,12 @@ check_user_token (const char *authfile,
char *saveptr = NULL;
if (buf[strlen (buf) - 1] == '\n')
buf[strlen (buf) - 1] = '\0';
if (buf[0] == '#') {
/* This is a comment and we may skip it. */
if(verbose)
D (("Skipping comment line: %s", buf));
continue;
}
if(verbose)
D (("Authorization line: %s", buf));
s_user = strtok_r (buf, ":", &saveptr);