Showing the changes to Source/Tools/UnixTools/GSF.POSIX.c (1 of 9 files). Show all
Unified · Split
| @@ -21,14 +21,23 @@ · 20 unmodified lines | ||
| 21 | 21 | // |
| 22 | 22 | //****************************************************************************************************** |
| 23 | 23 | |
| 24 | +// This will create a shared object for needed GSF functions | |
| 25 | + | |
| 24 | 26 | // Compiling for Linux: |
| 25 | 27 | // |
| 26 | −// Get PAM development libraries, e.g., for Ubuntu: apt-get install libpam0g-dev | |
| 28 | +// Get PAM development libraries, e.g., for Ubuntu: apt-get install libpam0g-dev | |
| 27 | 29 | // |
| 30 | +// To compile to an object library | |
| 28 | 31 | // gcc -c -Wall -Werror -fpic GSF.POSIX.c |
| 29 | −// gcc -shared -o GSF.POSIX.so GSF.POSIX.o -lpam -lpam_misc | |
| 32 | +// | |
| 33 | +// To compile as a shared object | |
| 34 | +// gcc -shared -o GSF.POSIX.so GSF.POSIX.o -lpam -lpam_misc -lcrypt | |
| 35 | +// | |
| 36 | +// To deploy, copy to user libraries folder | |
| 37 | +// sudo cp GSF.POSIX.so /usr/lib/ | |
| 30 | 38 | // |
| 31 | 39 | |
| 40 | +#include <stdlib.h> | |
| 32 | 41 | #include <security/pam_appl.h> |
| 33 | 42 | #include <security/pam_misc.h> |
| 34 | 43 | #include <sys/types.h> |
| @@ -39,26 +48,14 @@ · 4 unmodified lines | ||
| 39 | 48 | #include <grp.h> |
| 40 | 49 | #include <shadow.h> |
| 41 | 50 | #include <crypt.h> |
| 42 | − | |
| 43 | −// Structure used to return key spwd information | |
| 44 | −struct UserPasswordInformation | |
| 45 | −{ | |
| 46 | − // Do not include any pointer types in this structure | |
| 47 | − // to keep marshaling into .NET simple | |
| 48 | − long lastChangeDate; | |
| 49 | − long minDaysForChange; | |
| 50 | − long maxDaysForChange; | |
| 51 | − long warningDays; | |
| 52 | − long inactivityDays; | |
| 53 | − long accountExpirationDate; | |
| 54 | −}; | |
| 51 | +#include "GSF.POSIX.h" | |
| 55 | 52 | |
| 56 | 53 | // Define custom PAM conversation function for authentication |
| 57 | 54 | int AuthenticateConveration(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr) |
| 58 | 55 | { |
| 59 | 56 | const struct pam_message* message = *msg; |
| 60 | 57 | |
| 61 | − if (num_msg == 1 && message->msg != NULL && message->msg_style == PAM_PROMPT_ECHO_ON) | |
| 58 | + if (num_msg == 1 && message->msg != NULL && message->msg_style == PAM_PROMPT_ECHO_OFF) | |
| 62 | 59 | { |
| 63 | 60 | // Provide password for the PAM conversation response that was passed into appdata_ptr |
| 64 | 61 | struct pam_response* reply = (struct pam_response*)malloc(sizeof(struct pam_response)); |
| @@ -139,8 +136,8 @@ int AuthenticateUser(const char* userName, const char* password) · 74 unmodified lines | ||
| 139 | 136 | pam_handle_t* pamh; |
| 140 | 137 | int retval; |
| 141 | 138 | |
| 142 | − // Start PAM - just associate with something simple like the "whoami" command | |
| 143 | − retval = pam_start("whoami", userName, &pamc, &pamh); | |
| 139 | + // Start PAM - just associate with something simple like the "passwd" command | |
| 140 | + retval = pam_start("gsf", userName, &pamc, &pamh); | |
| 144 | 141 | |
| 145 | 142 | if (retval == PAM_SUCCESS) |
| 146 | 143 | { |