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