finalisation decoupage options

This commit is contained in:
2019-01-09 12:08:25 -05:00
parent 950e76d6e8
commit d18504ce2a
6 changed files with 40 additions and 95 deletions
+1 -1
View File
@@ -13,4 +13,4 @@
#include "httpd.h" #include "httpd.h"
#include <sys/stat.h> #include <sys/stat.h>
int mysql_lookup(request_rec *r, struct stat *fperm); int perms_lookup(request_rec *r, struct stat *fperm);
+5 -55
View File
@@ -10,65 +10,15 @@
#include "absec_auto.h" #include "absec_auto.h"
#include <mysql.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "httpd.h" #include "httpd.h"
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// // file system based permission lookup
int mysql_lookup(request_rec *r, struct stat *fperm) int perms_lookup(request_rec *r, struct stat *fperm)
{ {
MYSQL *conn; int status;
MYSQL_RES *res; status = stat(r->filename, fperm);
MYSQL_ROW row;
char *server = "localhost"; return status;
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 -2
View File
@@ -15,8 +15,8 @@
#include "httpd.h" #include "httpd.h"
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// // mysql based permission lookup
int mysql_lookup(request_rec *r, struct stat *fperm) int perms_lookup(request_rec *r, struct stat *fperm)
{ {
MYSQL *conn; MYSQL *conn;
MYSQL_RES *res; MYSQL_RES *res;
+4 -3
View File
@@ -1,8 +1,10 @@
#!/bin/bash #!/bin/bash
ABSEC_AUTHEN_DEP="-lpam -lpam_misc " ABSEC_AUTHEN_DEP="-lpam -lpam_misc "
ABSEC_AUTHEN_FILE="absec_pam.o" ABSEC_AUTHEN_FILE="absec_pam.o"
#could be absec_pam or absec_etc
ABSEC_AUTO_DEP="`mysql_config --cflags --libs` " ABSEC_AUTO_DEP="`mysql_config --cflags --libs` "
ABSEC_AUTO_FILE="absec_mysql.o" ABSEC_AUTO_FILE="absec_mysql.o"
#could be absec_fs or absec_mysql
echo "----------------" echo "----------------"
echo "Cleaning projets" echo "Cleaning projets"
@@ -42,15 +44,14 @@ echo "Running test"
echo "================" echo "================"
echo "Compiling filesystem module" echo "Compiling filesystem module"
gcc absec_fs.c `mysql_config --cflags --libs` -I/usr/include/apache2 -I/usr/include/apr-1.0 -fPIC -c gcc absec_fs.c -I/usr/include/apache2 -I/usr/include/apr-1.0 -fPIC -c
echo "----------------" echo "----------------"
echo "Compiling auto test with filesystem (test_auto -labsec_fs)" echo "Compiling auto test with filesystem (test_auto -labsec_fs)"
gcc test_auto.c absec_mysql.o `mysql_config --cflags --libs` -I/usr/include/apache2 -I/usr/include/apr-1.0 -o test_auto gcc test_auto.c absec_fs.o -I/usr/include/apache2 -I/usr/include/apr-1.0 -o test_auto
echo "Running test" echo "Running test"
./test_auto ./test_auto
echo "================" echo "================"
echo "Compiling absec tools" echo "Compiling absec tools"
echo "- absec_ls" echo "- absec_ls"
+2 -2
View File
@@ -123,8 +123,8 @@ static int absec_handler_first(request_rec *r)
/* should include <sys/stat.h> */ /* should include <sys/stat.h> */
struct stat fperm; struct stat fperm;
int status; int status;
status = stat(r->filename, &fperm); //status = stat(r->filename, &fperm);
//status = mysql_lookup(r, &fperm); status = perms_lookup(r, &fperm);
//ap_rprintf(r, "Result mysql: %d<br/>\r\n", ); //ap_rprintf(r, "Result mysql: %d<br/>\r\n", );
if (status==-1) { if (status==-1) {
ap_rprintf(r, "stat erreur %d", errno); ap_rprintf(r, "stat erreur %d", errno);
+26 -32
View File
@@ -1,8 +1,3 @@
#include "absec_auto.h"
#include <mysql.h>
#include <stdio.h>
///// /////
// //
// File : test_auto.c // File : test_auto.c
@@ -12,39 +7,38 @@
// Description: autorisation method test file // Description: autorisation method test file
// //
#include "absec_auto.h"
#include <stdio.h>
#include <sys/stat.h>
#include "httpd.h"
////////////////////////////////////////////////////////////////
int main() { int main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost"; struct request_rec r;
char *user = "jlcyr"; struct stat fperm;
char *password = "password"; /* set me first */
char *database = "absec";
conn = mysql_init(NULL); char* filename = "/var/www/html/absec/test.php";
r.filename=malloc(strlen(filename));
strcpy(r.filename, filename);
char* uri = "/absec/test.php";
r.uri=malloc(strlen(uri));
strcpy(r.uri, uri);
/* Connect to database */ printf("ABSEC auto perms for file %s or uri %s\r\n", r.filename, r.uri);
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */ perms_lookup(&r, &fperm);
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn); printf("Perms: %o\r\n", fperm.st_mode);
/* output table name */ printf("Test completed\r\n");
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL) return 0;
printf("%s \n", row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
} }
/*
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");
*/