History

Updates to Unix based UserInfo implementation.

ritchiecarroll committed 12 years ago

Commit bf22ae21 parent 2ab4c339 files · +284 −43Browse files

Showing the changes to Source/Tools/UnixTools/GSF.POSIX.c (1 of 9 files). Show all

Unified · Split

Source/Tools/UnixTools/GSF.POSIX.c+15−18
@@ -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// Compiling for Linux:26// Compiling for Linux:
25//27//
26// Get PAM development libraries, e.g., for Ubuntu: apt-get install libpam0g-dev28// Get PAM development libraries, e.g., for Ubuntu: apt-get install libpam0g-dev
27//29//
30// To compile to an object library
28// gcc -c -Wall -Werror -fpic GSF.POSIX.c31// gcc -c -Wall -Werror -fpic GSF.POSIX.c
29// gcc -shared -o GSF.POSIX.so GSF.POSIX.o -lpam -lpam_misc32//
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#include <security/pam_appl.h>41#include <security/pam_appl.h>
33#include <security/pam_misc.h>42#include <security/pam_misc.h>
34#include <sys/types.h>43#include <sys/types.h>
@@ -39,26 +48,14 @@ · 4 unmodified lines
39#include <grp.h>48#include <grp.h>
40#include <shadow.h>49#include <shadow.h>
41#include <crypt.h>50#include <crypt.h>
42 51#include "GSF.POSIX.h"
43// Structure used to return key spwd information
44struct 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};
55 52
56// Define custom PAM conversation function for authentication53// Define custom PAM conversation function for authentication
57int AuthenticateConveration(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr)54int AuthenticateConveration(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr)
58{55{
59 const struct pam_message* message = *msg;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 // Provide password for the PAM conversation response that was passed into appdata_ptr60 // Provide password for the PAM conversation response that was passed into appdata_ptr
64 struct pam_response* reply = (struct pam_response*)malloc(sizeof(struct pam_response));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 pam_handle_t* pamh; 136 pam_handle_t* pamh;
140 int retval;137 int retval;
141 138
142 // Start PAM - just associate with something simple like the "whoami" command139 // Start PAM - just associate with something simple like the "passwd" command
143 retval = pam_start("whoami", userName, &pamc, &pamh);140 retval = pam_start("gsf", userName, &pamc, &pamh);
144 141
145 if (retval == PAM_SUCCESS)142 if (retval == PAM_SUCCESS)
146 {143 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t