Compare commits

...

2 Commits

Author SHA1 Message Date
8ca44dfab3
Added install rule to Makefile 2025-05-22 11:02:47 +02:00
1b53a9638e
Added dialogue file existence checks 2025-05-22 11:02:31 +02:00
2 changed files with 25 additions and 3 deletions

View File

@ -65,7 +65,7 @@ endif
default: $(TARGETS)
.PHONY: clean icfs_test clean-icfs clean-icfs_dialogue
.PHONY: clean icfs_test clean-icfs clean-icfs_dialogue install uninstall
$(BUILD_DIR)/icfs_dialogue:
make -C $(SOURCES_DIR)/gui TEST=$(TEST) DEBUG=$(shell realpath $(DEBUG)) SOURCES_DIR=$(shell realpath $(SOURCES_DIR)/gui) BUILD_DIR=$(shell realpath $(BUILD_DIR)) TESTS_DIR=$(shell realpath $(TESTS_DIR))
@ -113,3 +113,19 @@ clean-icfs:
clean-icfs_dialogue:
make -C $(SOURCES_DIR)/gui clean SOURCES_DIR=$(shell realpath $(SOURCES_DIR)/gui) BUILD_DIR=$(shell realpath $(BUILD_DIR)) TESTS_DIR=$(shell realpath $(TESTS_DIR))
install: $(BUILD_DIR)/icfs $(BUILD_DIR)/icfs_dialogue
@echo "Install script needs superuser permission to:"
@printf "\t1. Move executables to /usr/bin.\n"
@printf "\t2. Create \"icfs\" user.\n"
@printf "\t3. Set the setuid bit of icfs executable.\n"
sudo cp $(BUILD_DIR)/icfs /usr/bin/icfs && sudo cp $(BUILD_DIR)/icfs_dialogue /usr/bin/icfs_dialogue
id -u icfs &>/dev/null || sudo useradd --system --user-group icfs
sudo chown icfs: /usr/bin/icfs && sudo chmod 4777 /usr/bin/icfs
@read -p "Create /etc/icfs directory for permission databases [y/N]: " permd; if [[ $$permd == "y" ]]; then echo "sudo mkdir /etc/icfs && sudo chown :icfs /etc/icfs && sudo chmod g+rw,o= /etc/icfs;"; sudo mkdir /etc/icfs && sudo chown icfs:icfs /etc/icfs && sudo chmod g+rw,o= /etc/icfs; fi
uninstall:
@echo "Install script needs superuser permission to remove executables in /usr/bin"
sudo rm -f /usr/bin/icfs /usr/bin/icfs_dialogue
@read -p "Remove /etc/icfs directory [y/N]: " permd; if [[ $$permd == "y" ]]; then echo "sudo rm -rf /etc/icfs"; sudo rm -rf /etc/icfs; fi

View File

@ -244,9 +244,15 @@ int interactive_access(const char *filename, struct process_info proc_info,
// the user might specify a different file in the dialogue, so we need to
// check if it is valid
while (source_access(response.filename, F_OK)) {
while (
source_access(response.filename, F_OK) ||
!(strncmp(response.filename, filename, strlen(response.filename)) == 0 &&
((strlen(response.filename) < strlen(filename) &&
response.filename[strlen(response.filename) - 1] == '/') ||
(strlen(response.filename) == strlen(filename))))) {
// if it is invalid, just ask again.
fprintf(stderr, "[ICFS] Filename returned by zenty wasn't correct: %s\n",
fprintf(stderr,
"[ICFS] Filename returned by access dialogue wasn't correct: %s\n",
response.filename);
free(response.filename);
response = ask_access(filename, proc_info);