Created
February 3, 2012 21:58
-
-
Save ccammilleri/1732951 to your computer and use it in GitHub Desktop.
OpenVPN auth-pam plugin patch for password concatenation delimiting on rightmost comma (meant to be used with Duo Security's OpenVPN plugin)
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
--- auth-pam.c.bak 2012-01-19 11:39:38.728363546 -0600 | |
+++ auth-pam.c 2012-01-20 14:11:35.718361562 -0600 | |
@@ -548,6 +548,28 @@ | |
int ret = PAM_SUCCESS; | |
*response_array = NULL; | |
+ char *p; | |
+ p = strrchr(up->password, ','); | |
+ | |
+ /* dont process nothing or any string longer then 7 characters */ | |
+ if (p == NULL) | |
+ { | |
+ fprintf(stderr, "ERROR: your 2nd password is null\n"); | |
+ return (PAM_CONV_ERR); | |
+ } else if ((strlen(p)) > 8 ) | |
+ { | |
+ fprintf(stderr, "ERROR: your 2nd password is too long\n"); | |
+ return (PAM_CONV_ERR); | |
+ } | |
+ | |
+ /*fprintf(stderr, "DEBUG: strrchr split: %s\n", p);*/ | |
+ | |
+ /* intentionally leaving newpass 1 byte larger so its null terminated */ | |
+ char newpass[(strlen(up->password)) - (strlen(p)-1)]; | |
+ memset(newpass, 0, sizeof(newpass)); | |
+ strncpy(newpass, up->password, (strlen(up->password)-1)-(strlen(p)-1)); | |
+ memset((void *)up->password, 0, sizeof(up->password)); | |
+ strncpy((void *)up->password, newpass, sizeof(newpass)); | |
if (n <= 0 || n > PAM_MAX_NUM_MSG) | |
return (PAM_CONV_ERR); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment