Compare commits
No commits in common. "c8f19fe30db28a6e0c5e8f061ec511b445c94360" and "c7ec5819c6527daf22ba6c7f1bab64e8e5d6dda2" have entirely different histories.
c8f19fe30d
...
c7ec5819c6
@ -11,7 +11,6 @@
|
|||||||
See the file LICENSE.
|
See the file LICENSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "process_info.h"
|
|
||||||
#include "real_filename.h"
|
#include "real_filename.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -268,7 +267,8 @@ static int xmp_unlink(const char *path) {
|
|||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
// ask the user for the permission for deleting the file
|
// ask the user for the permission for deleting the file
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
|
|
||||||
@ -315,7 +315,8 @@ static int xmp_rename(const char *from, const char *to, unsigned int flags) {
|
|||||||
struct process_info pi;
|
struct process_info pi;
|
||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
|
|
||||||
@ -345,7 +346,8 @@ static int xmp_link(const char *from, const char *to) {
|
|||||||
struct process_info pi;
|
struct process_info pi;
|
||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
if (!interactive_access(from, pi, 0)) {
|
if (!interactive_access(from, pi, 0)) {
|
||||||
@ -369,7 +371,8 @@ static int xmp_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) {
|
|||||||
struct process_info pi;
|
struct process_info pi;
|
||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
if (!interactive_access(path, pi, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
@ -399,7 +402,8 @@ static int xmp_chown(const char *path, uid_t uid, gid_t gid,
|
|||||||
struct process_info pi;
|
struct process_info pi;
|
||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
if (!interactive_access(path, pi, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
@ -457,7 +461,8 @@ static int xmp_create(const char *path, mode_t mode,
|
|||||||
struct process_info pi;
|
struct process_info pi;
|
||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
|
|
||||||
@ -481,7 +486,8 @@ static int xmp_open(const char *path, struct fuse_file_info *fi) {
|
|||||||
struct process_info pi;
|
struct process_info pi;
|
||||||
struct fuse_context *fc = fuse_get_context();
|
struct fuse_context *fc = fuse_get_context();
|
||||||
|
|
||||||
pi = get_process_info(fc->pid);
|
pi.PID = fc->pid;
|
||||||
|
pi.name = get_process_name_by_pid(pi.PID);
|
||||||
|
|
||||||
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi));
|
||||||
if (!interactive_access(path, pi, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
|
@ -258,7 +258,7 @@ access_t check_perm_access_noparent(const char *filename,
|
|||||||
* false negatives, though.
|
* false negatives, though.
|
||||||
*/
|
*/
|
||||||
access_t check_perm_access(const char *filename, struct process_info pi) {
|
access_t check_perm_access(const char *filename, struct process_info pi) {
|
||||||
if (pi.PID == 0 || pi.name == NULL) {
|
if (pi.PID == 0) {
|
||||||
return NDEF;
|
return NDEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,21 +9,10 @@
|
|||||||
#ifndef PROCESS_INFO_H
|
#ifndef PROCESS_INFO_H
|
||||||
#define PROCESS_INFO_H
|
#define PROCESS_INFO_H
|
||||||
|
|
||||||
#include "proc_operations.h"
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
struct process_info {
|
struct process_info {
|
||||||
pid_t PID;
|
pid_t PID;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct process_info get_process_info(pid_t pid) {
|
|
||||||
struct process_info pi;
|
|
||||||
pi.PID = pid;
|
|
||||||
pi.name = get_process_name_by_pid(pi.PID);
|
|
||||||
if (pi.name == NULL) {
|
|
||||||
pi.PID = 0;
|
|
||||||
}
|
|
||||||
return pi;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // PROCESS_INFO_H
|
#endif // PROCESS_INFO_H
|
||||||
|
@ -35,13 +35,9 @@ struct dialogue_response {
|
|||||||
char *filename;
|
char *filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
FILE *access_log;
|
|
||||||
|
|
||||||
int init_ui_socket(const char *perm_permissions_db_filename) {
|
int init_ui_socket(const char *perm_permissions_db_filename) {
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
|
||||||
access_log = fopen("/etc/icfs-log", "a+");
|
|
||||||
|
|
||||||
if (init_temp_permissions_table()) {
|
if (init_temp_permissions_table()) {
|
||||||
fprintf(stderr, "Could not initialize temporary permissions table.\n");
|
fprintf(stderr, "Could not initialize temporary permissions table.\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -64,7 +60,6 @@ int init_ui_socket(const char *perm_permissions_db_filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void destroy_ui_socket(void) {
|
void destroy_ui_socket(void) {
|
||||||
fclose(access_log);
|
|
||||||
destroy_temp_permissions_table();
|
destroy_temp_permissions_table();
|
||||||
destroy_perm_permissions_table();
|
destroy_perm_permissions_table();
|
||||||
}
|
}
|
||||||
@ -142,8 +137,6 @@ struct dialogue_response ask_access(const char *filename,
|
|||||||
|
|
||||||
// assert(0 == strcmp(response.filename, first(&dialogue_output)));
|
// assert(0 == strcmp(response.filename, first(&dialogue_output)));
|
||||||
cleanup(&dialogue_output);
|
cleanup(&dialogue_output);
|
||||||
time_t now = time(0);
|
|
||||||
fprintf(access_log, "%ld\n", now);
|
|
||||||
|
|
||||||
if (dialogue_exit_code == (DIALOGUE_YES | DIALOGUE_PERM)) {
|
if (dialogue_exit_code == (DIALOGUE_YES | DIALOGUE_PERM)) {
|
||||||
response.decision = ALLOW;
|
response.decision = ALLOW;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user