cleanup files

This commit is contained in:
2018-11-13 17:32:12 -05:00
parent 154d770cf3
commit 0c909d5a93
11 changed files with 114 additions and 94 deletions
View File
-10
View File
@@ -1,10 +0,0 @@
#define PAM_OK 0
#define PAM_ERROR_START -1
#define PAM_ERROR_INVALID_CRED -2
#define PAM_ERROR_STOP -3
#define HTTP_UNAUTHORIZED 401
#define OK 200
int check_user(char* user, char* pass);
+66
View File
@@ -0,0 +1,66 @@
#include "absec_auto.h"
#include <mysql.h>
#include <sys/stat.h>
#include "httpd.h"
////////////////////////////////////////////////////////////////
//
int mysql_lookup(request_rec *r, struct stat *fperm)
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "jlcyr";
char *password = "password"; /* set me first */
char *database = "absec";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
printf("%s\n", mysql_error(conn));
return(0);
}
char query[256];
sprintf(query, "select * from urls where url='%s'", r->uri);
/* send SQL query */
//if (mysql_query(conn, "show tables")) {
if (mysql_query(conn, query)) {
printf("%s\n", mysql_error(conn));
return(-1);
}
res = mysql_use_result(conn);
/* output table name */
printf("MySQL data:\n<br/>");
int cnt = 0;
while ((row = mysql_fetch_row(res)) != NULL) {
printf("%s %d %d %o \n<br/>", row[0], atoi(row[1]), atoi(row[2]), atoi(row[3]));
fperm->st_uid = atoi(row[1]);
fperm->st_gid = atoi(row[2]);
fperm->st_mode = atoi(row[3]);
cnt = cnt + 1;
}
if (cnt==0) {
sprintf(query, "insert into urls (url, uid, gid, perms) values ('%s', 0, 0, 0)", r->uri);
if (mysql_query(conn, query)) {
printf("%s\n", mysql_error(conn));
return(0);
}
printf("Aucune donnee\n<br/>");
}
/* close connection */
mysql_free_result(res);
mysql_close(conn);
return(0);
}
+2
View File
@@ -1,5 +1,7 @@
#include "absec_auto.h"
#include <mysql.h>
#include <sys/stat.h>
#include "httpd.h"
-7
View File
@@ -1,7 +0,0 @@
#define PAM_OK 0
#define PAM_ERROR_START -1
#define PAM_ERROR_INVALID_CRED -2
#define PAM_ERROR_STOP -3
int check_user(char* user, char* pass);
+1
View File
@@ -9,6 +9,7 @@ Le projet dépend pour être compilé de
* libapr1-dev
* libaprutil-dev
* apache2-dev
* libmysqlclient-dev
Un script de compilation est disponible
compile.sh
Executable → Regular
+2 -2
View File
@@ -1,7 +1,7 @@
#include <mysql.h>
#include "absec_auto.h"
//#include <mysql.h>
#include <stdio.h>
int main() {
-16
View File
@@ -1,16 +0,0 @@
#include "absec_pam.h"
#include <stdio.h>
void main(int argc, char** argv){
char *user = "jlcyr";
char *pass = "jlcyrpass01!";
printf("ABSEC auth etc for %s identified by %s\r\n", user, pass);
int retval;
retval = check_user(user, pass);
printf("Retval: %d\r\n", retval);
if (retval == PAM_ERROR_START) printf("Error at start\r\n");
if (retval == PAM_ERROR_INVALID_CRED) printf("Invalid user/pass\r\n");
if (retval == PAM_OK) printf("OK\r\n");
printf("Test completed\r\n");
return;
}
-16
View File
@@ -1,16 +0,0 @@
#include "absec_pam.h"
#include "absec_etc.h"
#include <stdio.h>
void main(int argc, char** argv){
char *user = "jlcyr";
char *pass = "jlcyrpass01!";
printf("ABSEC auth pam for %s identified by %s\r\n", user, pass);
int retval = check_user(user, pass);
printf("Retval: %d\r\n", retval);
if (retval == PAM_ERROR_START) printf("Error at start\r\n");
if (retval == PAM_ERROR_INVALID_CRED) printf("Invalid user/pass\r\n");
if (retval == PAM_OK) printf("OK\r\n");
printf("Test completed\r\n");
return;
}