finalisation decoupage options
This commit is contained in:
+1
-1
@@ -13,4 +13,4 @@
|
||||
#include "httpd.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
@@ -10,65 +10,15 @@
|
||||
|
||||
#include "absec_auto.h"
|
||||
|
||||
#include <mysql.h>
|
||||
#include <sys/stat.h>
|
||||
#include "httpd.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
int mysql_lookup(request_rec *r, struct stat *fperm)
|
||||
// file system based permission lookup
|
||||
int perms_lookup(request_rec *r, struct stat *fperm)
|
||||
{
|
||||
MYSQL *conn;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
int status;
|
||||
status = stat(r->filename, fperm);
|
||||
|
||||
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);
|
||||
return status;
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@
|
||||
#include "httpd.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
int mysql_lookup(request_rec *r, struct stat *fperm)
|
||||
// mysql based permission lookup
|
||||
int perms_lookup(request_rec *r, struct stat *fperm)
|
||||
{
|
||||
MYSQL *conn;
|
||||
MYSQL_RES *res;
|
||||
|
||||
+4
-3
@@ -1,8 +1,10 @@
|
||||
#!/bin/bash
|
||||
ABSEC_AUTHEN_DEP="-lpam -lpam_misc "
|
||||
ABSEC_AUTHEN_FILE="absec_pam.o"
|
||||
#could be absec_pam or absec_etc
|
||||
ABSEC_AUTO_DEP="`mysql_config --cflags --libs` "
|
||||
ABSEC_AUTO_FILE="absec_mysql.o"
|
||||
#could be absec_fs or absec_mysql
|
||||
|
||||
echo "----------------"
|
||||
echo "Cleaning projets"
|
||||
@@ -42,15 +44,14 @@ echo "Running test"
|
||||
|
||||
echo "================"
|
||||
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 "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"
|
||||
./test_auto
|
||||
|
||||
|
||||
echo "================"
|
||||
echo "Compiling absec tools"
|
||||
echo "- absec_ls"
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ static int absec_handler_first(request_rec *r)
|
||||
/* should include <sys/stat.h> */
|
||||
struct stat fperm;
|
||||
int status;
|
||||
status = stat(r->filename, &fperm);
|
||||
//status = mysql_lookup(r, &fperm);
|
||||
//status = stat(r->filename, &fperm);
|
||||
status = perms_lookup(r, &fperm);
|
||||
//ap_rprintf(r, "Result mysql: %d<br/>\r\n", );
|
||||
if (status==-1) {
|
||||
ap_rprintf(r, "stat erreur %d", errno);
|
||||
|
||||
+26
-32
@@ -1,8 +1,3 @@
|
||||
|
||||
|
||||
#include "absec_auto.h"
|
||||
#include <mysql.h>
|
||||
#include <stdio.h>
|
||||
/////
|
||||
//
|
||||
// File : test_auto.c
|
||||
@@ -12,39 +7,38 @@
|
||||
// Description: autorisation method test file
|
||||
//
|
||||
|
||||
#include "absec_auto.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include "httpd.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
int main() {
|
||||
MYSQL *conn;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
char *server = "localhost";
|
||||
char *user = "jlcyr";
|
||||
char *password = "password"; /* set me first */
|
||||
char *database = "absec";
|
||||
struct request_rec r;
|
||||
struct stat fperm;
|
||||
|
||||
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 */
|
||||
if (!mysql_real_connect(conn, server,
|
||||
user, password, database, 0, NULL, 0)) {
|
||||
fprintf(stderr, "%s\n", mysql_error(conn));
|
||||
exit(1);
|
||||
}
|
||||
printf("ABSEC auto perms for file %s or uri %s\r\n", r.filename, r.uri);
|
||||
|
||||
/* send SQL query */
|
||||
if (mysql_query(conn, "show tables")) {
|
||||
fprintf(stderr, "%s\n", mysql_error(conn));
|
||||
exit(1);
|
||||
}
|
||||
perms_lookup(&r, &fperm);
|
||||
|
||||
res = mysql_use_result(conn);
|
||||
printf("Perms: %o\r\n", fperm.st_mode);
|
||||
|
||||
/* output table name */
|
||||
printf("MySQL Tables in mysql database:\n");
|
||||
while ((row = mysql_fetch_row(res)) != NULL)
|
||||
printf("%s \n", row[0]);
|
||||
printf("Test completed\r\n");
|
||||
|
||||
return 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");
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user