databases handling tools chmod, chgrp, chown, ls

This commit is contained in:
2019-01-21 09:13:03 -05:00
parent 2fb12410ea
commit ea59731e1f
6 changed files with 244 additions and 25 deletions
+10 -20
View File
@@ -36,7 +36,7 @@ char* perms_to_string(int perms)
////////////////////////////////////////////////////////////////
// define PAM callback function
int mysql_lookup()//request_rec *r, struct stat *fperm)
int mysql_lookup(char* pattern)//request_rec *r, struct stat *fperm)
{
MYSQL *conn;
MYSQL_RES *res;
@@ -57,37 +57,23 @@ int mysql_lookup()//request_rec *r, struct stat *fperm)
}
char query[256];
sprintf(query, "select * from urls"); // where url='%s'", r->uri);
sprintf(query, "select * from urls where url like '%s'", pattern); // 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));
printf("%s\r\n", mysql_error(conn));
return(-1);
}
res = mysql_use_result(conn);
/* output table name */
printf("ABSEC permissions\n");
printf("ABSEC permissions\r\n");
int cnt = 0;
while ((row = mysql_fetch_row(res)) != NULL) {
printf("%s\t%d\t%d\t%s \n", perms_to_string(atoi(row[3])), atoi(row[1]), atoi(row[2]), row[0] );
/*fperm->st_uid = atoi(row[1]);
fperm->st_gid = atoi(row[2]);
fperm->st_mode = atoi(row[3]);*/
cnt = cnt + 1;
printf("%s\t%d\t%d\t%s \r\n", perms_to_string(atoi(row[3])), atoi(row[1]), atoi(row[2]), row[0] );
}
/*if (cnt==0) {
sprintf(query, "insert into urls (url, uid, gid, perms) values ('%s', 0, 0, 0)", r->uri);
if (mysql_query(conn, query)) {
ap_rprintf(r, "%s\n<br/>", mysql_error(conn));
return(0);
}
ap_rprintf(r, "Aucune donnee\n<br/>");
}*/
/* close connection */
mysql_free_result(res);
mysql_close(conn);
@@ -96,5 +82,9 @@ int mysql_lookup()//request_rec *r, struct stat *fperm)
void main(int argc, char** argv)
{
mysql_lookup();
if (argc>1) {
mysql_lookup(argv[1]);
} else {
mysql_lookup("%");
}
}