From 141aafc5ca69b711c3532d1037a4d5b57622fdaf Mon Sep 17 00:00:00 2001 From: Jean-Luc Cyr Date: Thu, 2 Aug 2018 13:00:31 -0400 Subject: [PATCH] test dev mysql et script compile --- compile.sh | 2 ++ mod_absec.c | 8 ++++++++ test_mysql.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100755 compile.sh create mode 100644 test_mysql.c diff --git a/compile.sh b/compile.sh new file mode 100755 index 0000000..69376fc --- /dev/null +++ b/compile.sh @@ -0,0 +1,2 @@ +/home/jlcyr/apache2/bin/apxs -lpam -lpam_misc -c -i mod_absec.c +/home/jlcyr/apache2/bin/apachectl restart diff --git a/mod_absec.c b/mod_absec.c index dd6b14a..e2f1ccd 100644 --- a/mod_absec.c +++ b/mod_absec.c @@ -142,6 +142,10 @@ static int absec_handler_first(request_rec *r) struct stat fperm; int status; status = stat(r->filename, &fperm); + if (status==-1) { + ap_rprintf(r, "stat erreur %d", errno); + return (OK); + } //ap_rprintf(r, "File perms %o, owner %d, group %d (status %d)
\r\n", fperm.st_mode, fperm.st_uid, fperm.st_gid, status); /* check if any permission (ogw) match method (get r, put/post w, delete x) */ @@ -297,6 +301,10 @@ static void absec_register_hooks(apr_pool_t *p) //ap_hook_handler(absec_handler, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(absec_handler_last, NULL, NULL, APR_HOOK_LAST); ap_hook_handler(absec_handler_first, NULL, NULL, APR_HOOK_FIRST); + + // should use HOOK FIXUP + + // should use FILTER } //////////////////////////////////////////////////////////////// diff --git a/test_mysql.c b/test_mysql.c new file mode 100644 index 0000000..fad2db3 --- /dev/null +++ b/test_mysql.c @@ -0,0 +1,39 @@ +#include +#include + +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"; + + conn = mysql_init(NULL); + + /* Connect to database */ + if (!mysql_real_connect(conn, server, + user, password, database, 0, NULL, 0)) { + fprintf(stderr, "%s\n", mysql_error(conn)); + exit(1); + } + + /* send SQL query */ + if (mysql_query(conn, "show tables")) { + fprintf(stderr, "%s\n", mysql_error(conn)); + exit(1); + } + + res = mysql_use_result(conn); + + /* output table name */ + printf("MySQL Tables in mysql database:\n"); + while ((row = mysql_fetch_row(res)) != NULL) + printf("%s \n", row[0]); + + /* close connection */ + mysql_free_result(res); + mysql_close(conn); +}