forked from duosecurity/duo_unix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support additional GECOS field username parsing
- Loading branch information
Matt Schwager
committed
Jun 19, 2017
1 parent
355f2d9
commit 5f5d0ee
Showing
9 changed files
with
158 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
#include "util.h" | ||
|
||
int success() | ||
{ | ||
printf("OK\n"); | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
int failure() | ||
{ | ||
printf("FAIL\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
if (argc != 5) { | ||
printf("Format: %s <string|NULL> <delimiter> <position> <expected|NULL>\n", argv[0]); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
char *s = argv[1]; | ||
char *delimiter = argv[2]; | ||
int position = atoi(argv[3]); | ||
char *expected = argv[4]; | ||
|
||
if (strcmp(s, "NULL") == 0) { | ||
s = NULL; | ||
} | ||
|
||
char *result = duo_split_at(s, *delimiter, position); | ||
|
||
if ((result == NULL && strcmp(expected, "NULL") == 0) || | ||
(result != NULL && strcmp(result, expected) == 0)) { | ||
return success(); | ||
} | ||
|
||
return failure(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
util.{c,h} unit tests | ||
|
||
$ cd ${BUILDDIR}/lib | ||
|
||
duo_split_at: basic | ||
$ ./testutil_duo_split_at foo/bar/baz / 1 bar | ||
OK | ||
|
||
duo_split_at: first | ||
$ ./testutil_duo_split_at foo/bar/baz / 0 foo | ||
OK | ||
|
||
duo_split_at: last | ||
$ ./testutil_duo_split_at foo/bar/baz / 2 baz | ||
OK | ||
|
||
duo_split_at: too many | ||
$ ./testutil_duo_split_at foo/bar/baz / 100 NULL | ||
OK | ||
|
||
duo_split_at: no delimiter | ||
$ ./testutil_duo_split_at foo / 1 NULL | ||
OK | ||
|
||
duo_split_at: starts with delimiter | ||
$ ./testutil_duo_split_at /foo/bar/baz / 0 "" | ||
OK | ||
|
||
duo_split_at: ends with delimiter | ||
$ ./testutil_duo_split_at foo/bar/baz/ / 3 "" | ||
OK | ||
|
||
duo_split_at: empty | ||
$ ./testutil_duo_split_at "" / 0 "" | ||
OK |