first pass cleanup code
This commit is contained in:
+22
-45
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
** mod_absec.c -- Apache sample absec module
|
||||
** [Autogenerated via ``apxs -n absec -g'']
|
||||
** mod_absec.c -- Apache absec module
|
||||
** [base Autogenerated via ``apxs -n absec -g'']
|
||||
**
|
||||
** To play with this sample module first compile it into a
|
||||
** DSO file and install it into Apache's modules directory
|
||||
** by running:
|
||||
**
|
||||
** $ apxs -c -i mod_absec.c
|
||||
** $ apxs -lpam -lpam_misc -c -i mod_absec.c
|
||||
**
|
||||
** Then activate it in Apache's httpd.conf file for instance
|
||||
** for the URL /absec in as follows:
|
||||
@@ -21,25 +21,11 @@
|
||||
**
|
||||
** $ apachectl restart
|
||||
**
|
||||
** you immediately can request the URL /absec and watch for the
|
||||
** output of this module. This can be achieved for instance via:
|
||||
**
|
||||
** $ lynx -mime_header http://localhost/absec
|
||||
**
|
||||
** The output should be similar to the following one:
|
||||
**
|
||||
** HTTP/1.1 200 OK
|
||||
** Date: Tue, 31 Mar 1998 14:42:22 GMT
|
||||
** Server: Apache/1.3.4 (Unix)
|
||||
** Connection: close
|
||||
** Content-Type: text/html
|
||||
**
|
||||
** The sample page from mod_absec.c
|
||||
*/
|
||||
|
||||
/*
|
||||
TEST URL
|
||||
http://10.211.55.15/absec?joe=blow
|
||||
http://10.211.55.15/absec/<fichier>
|
||||
|
||||
INFORMATION SOURCES
|
||||
|
||||
@@ -89,21 +75,19 @@ static int check_autorization(request_rec *r)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//int function_conversation ( ) {
|
||||
/* ToDo prompt user for input */
|
||||
//};
|
||||
//struct pam_conv conv = { function_conversation, 0 };
|
||||
|
||||
// Global var for passing fake response to PAM callback
|
||||
struct pam_response *reply;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// PAM response callback function
|
||||
int converse(int n, const struct pam_message **msg,
|
||||
struct pam_response **resp, void *data)
|
||||
{
|
||||
// Return globally set response
|
||||
*resp = reply;
|
||||
return PAM_SUCCESS;
|
||||
|
||||
|
||||
// Real code for responding and asking user values
|
||||
struct pam_response *aresp;
|
||||
char buf[PAM_MAX_RESP_SIZE];
|
||||
int i;
|
||||
@@ -118,17 +102,17 @@ int converse(int n, const struct pam_message **msg,
|
||||
aresp[i].resp = NULL;
|
||||
switch (msg[i]->msg_style) {
|
||||
case PAM_PROMPT_ECHO_OFF:
|
||||
aresp[i].resp = strdup("jlcyrpass01!");
|
||||
//aresp[i].resp = strdup(getpass(msg[i]->msg));
|
||||
//aresp[i].resp = strdup("jlcyrpass01!");
|
||||
aresp[i].resp = strdup(getpass(msg[i]->msg));
|
||||
if (aresp[i].resp == NULL)
|
||||
goto fail;
|
||||
break;
|
||||
case PAM_PROMPT_ECHO_ON:
|
||||
fputs(msg[i]->msg, stderr);
|
||||
//if (fgets(buf, sizeof buf, stdin) == NULL)
|
||||
// goto fail;
|
||||
//aresp[i].resp = strdup(buf);
|
||||
aresp[i].resp = strdup("jlcyrpass01!");
|
||||
if (fgets(buf, sizeof buf, stdin) == NULL)
|
||||
goto fail;
|
||||
aresp[i].resp = strdup(buf);
|
||||
//aresp[i].resp = strdup("jlcyrpass01!");
|
||||
if (aresp[i].resp == NULL)
|
||||
goto fail;
|
||||
break;
|
||||
@@ -162,10 +146,12 @@ int converse(int n, const struct pam_message **msg,
|
||||
return (PAM_CONV_ERR);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// define PAM callback function
|
||||
struct pam_conv conv = { converse, 0 };
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
/* Main routine */
|
||||
/* Main routine - called after request processing */
|
||||
static int absec_handler_last(request_rec *r)
|
||||
{
|
||||
// Is this module really called?
|
||||
@@ -179,7 +165,7 @@ static int absec_handler_last(request_rec *r)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
/* Main routine */
|
||||
/* Main routine - called before request processing */
|
||||
static int absec_handler_first(request_rec *r)
|
||||
{
|
||||
// Is this module really called?
|
||||
@@ -314,6 +300,7 @@ static int absec_handler_first(request_rec *r)
|
||||
return HTTP_UNAUTHORIZED;
|
||||
}*/
|
||||
|
||||
// Connect to PAM to auth user
|
||||
pam_handle_t * pamh = NULL;
|
||||
int rret;
|
||||
|
||||
@@ -322,18 +309,12 @@ static int absec_handler_first(request_rec *r)
|
||||
printf("Pam start failed\n");
|
||||
exit(0);
|
||||
}
|
||||
/* if((rret = pam_set_item( pamh, PAM_AUTHTOK, &pass)) == PAM_BUF_ERR) {
|
||||
return HTTP_BAD_REQUEST;
|
||||
}
|
||||
*/
|
||||
|
||||
// Set the PAM callback function response (would call for password)
|
||||
reply = (struct pam_response *)malloc(sizeof(struct pam_response));
|
||||
|
||||
// *** Get the password by any method, or maybe it was passed into this function.
|
||||
reply[0].resp = strdup(pass);
|
||||
reply[0].resp = strdup(pass); // password received in basic auth
|
||||
reply[0].resp_retcode = 0;
|
||||
|
||||
|
||||
if((rret = pam_authenticate(pamh, 0)) != PAM_SUCCESS) {
|
||||
return HTTP_UNAUTHORIZED;
|
||||
printf("User auth failed\n");
|
||||
@@ -349,7 +330,6 @@ static int absec_handler_first(request_rec *r)
|
||||
|
||||
////////
|
||||
/* Encrypt and compare shadow password */
|
||||
|
||||
// TODO : Valider qu'on a un user
|
||||
// TODO : Valider qu'il y a un password (pas * ! rien)
|
||||
/* char *encrypted;
|
||||
@@ -382,9 +362,6 @@ static int absec_handler_first(request_rec *r)
|
||||
}
|
||||
return HTTP_OK;
|
||||
|
||||
|
||||
|
||||
|
||||
////////
|
||||
/* Check supplemental groups */
|
||||
/* Should include <grp.h> */
|
||||
|
||||
Reference in New Issue
Block a user