Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied: '/media/data/fact_fw_data/87'&& AttributeError: 'str' object has no attribute 'uid' #35

Open
PdxPdx opened this issue Mar 28, 2023 · 4 comments

Comments

@PdxPdx
Copy link

PdxPdx commented Mar 28, 2023

Hello, thank you very much for providing this tool
I completed the tool deployment according to "Usage" and did not report any errors during the deployment process. However, after uploading the firmware, the following error occurred.
The installation process is as follows:
$ docker pull ghcr.io/fkie-cad/fact-core-frontend:4.0.1
$ docker pull ghcr.io/fkie-cad/fact-core-backend:4.0.1
$ docker pull ghcr.io/fkie-cad/fact-core-scripts:4.0.1
$ ./start.py pull
$ ./start.py compose-env
--firmware-file-storage-dir /root/FACT_docker-main/data/
$ eval $(./start.py compose-env --firmware-file-storage-dir /root/FACT_docker-main/data/)
$ export FACT_DOCKER_POSTGRES_PASSWORD=mypassword
$ docker volume create fact_postgres_data
$ docker-compose up -d database

Wait some seconds until the db is ready

$ ./start.py initialize-db
--network fact_docker-main_fact-network
$ docker-compose up

No errors were reported during installation

The error message is as follows:
fact_docker-main-fact-backend-1 | [2023-03-28 02:31:49][fail_safe_file_operations][ERROR]: Could not write file: [Errno 13] Permission denied: '/media/data/fact_fw_data/87'
fact_docker-main-fact-backend-1 | Traceback (most recent call last):
fact_docker-main-fact-backend-1 | File "/usr/local/lib/python3.8/dist-packages/common_helper_files/fail_safe_file_operations.py", line 61, in write_binary_to_file
fact_docker-main-fact-backend-1 | create_dir_for_file(file_path)
fact_docker-main-fact-backend-1 | File "/usr/local/lib/python3.8/dist-packages/common_helper_files/file_functions.py", line 50, in create_dir_for_file
fact_docker-main-fact-backend-1 | Path(file_path).resolve().parent.mkdir(parents=True, exist_ok=True)
fact_docker-main-fact-backend-1 | File "/usr/lib/python3.8/pathlib.py", line 1288, in mkdir
fact_docker-main-fact-backend-1 | self._accessor.mkdir(self, mode)
fact_docker-main-fact-backend-1 | PermissionError: [Errno 13] Permission denied: '/media/data/fact_fw_data/87'
fact_docker-main-fact-frontend-1 | [pid: 24|app: 0|req: 38/188] 172.18.0.1 () {40 vars in 666 bytes} [Tue Mar 28 02:31:49 2023] GET /static/fact_logo_inv.svg => generated 0 bytes in 1 msecs (HTTP/1.1 304) 3 headers in 148 bytes (0 switches on core 1)
fact_docker-main-fact-backend-1 | Process Unpacking-Worker-3:
fact_docker-main-fact-backend-1 | Traceback (most recent call last):
fact_docker-main-fact-backend-1 | File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
fact_docker-main-fact-backend-1 | self.run()
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/helperFunctions/process.py", line 56, in run
fact_docker-main-fact-backend-1 | raise exception
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/helperFunctions/process.py", line 51, in run
fact_docker-main-fact-backend-1 | Process.run(self)
fact_docker-main-fact-backend-1 | File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
fact_docker-main-fact-backend-1 | self._target(*self._args, **self._kwargs)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/scheduler/unpacking_scheduler.py", line 64, in unpack_worker
fact_docker-main-fact-backend-1 | extracted_objects = unpacker.unpack(fo)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/unpacker/unpack.py", line 37, in unpack
fact_docker-main-fact-backend-1 | file_path = self._generate_local_file_path(current_fo)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/unpacker/unpack.py", line 93, in _generate_local_file_path
fact_docker-main-fact-backend-1 | local_path = self.file_storage_system.generate_path(file_object.uid)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/storage/fsorganizer.py", line 30, in generate_path
fact_docker-main-fact-backend-1 | return self.generate_path_from_uid(file_object.uid)
fact_docker-main-fact-backend-1 | AttributeError: 'str' object has no attribute 'uid'
fact_docker-main-fact-backend-1 | [2023-03-28 02:31:53][process][ERROR]: Exception in Unpacking process:
fact_docker-main-fact-backend-1 | Traceback (most recent call last):
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/helperFunctions/process.py", line 51, in run
fact_docker-main-fact-backend-1 | Process.run(self)
fact_docker-main-fact-backend-1 | File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
fact_docker-main-fact-backend-1 | self._target(*self._args, **self._kwargs)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/scheduler/unpacking_scheduler.py", line 64, in unpack_worker
fact_docker-main-fact-backend-1 | extracted_objects = unpacker.unpack(fo)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/unpacker/unpack.py", line 37, in unpack
fact_docker-main-fact-backend-1 | file_path = self._generate_local_file_path(current_fo)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/unpacker/unpack.py", line 93, in _generate_local_file_path
fact_docker-main-fact-backend-1 | local_path = self.file_storage_system.generate_path(file_object.uid)
fact_docker-main-fact-backend-1 | File "/opt/FACT_core/src/storage/fsorganizer.py", line 30, in generate_path
fact_docker-main-fact-backend-1 | return self.generate_path_from_uid(file_object.uid)
fact_docker-main-fact-backend-1 | AttributeError: 'str' object has no attribute 'uid'
fact_docker-main-fact-backend-1 |
fact_docker-main-fact-backend-1 | [2023-03-28 02:31:53][process][WARNING]: restarting Unpacking 3 process

I manually created the "/media/data/fact_fw_data/87" folder and granted read, write, and execute permissions。
At the same time, I manually created the "/tmp/fact docker mount base dir/fact_unpack_e3qdhzga/" folder and the "/media/data/fact_wt_mongodb/" folder and gave them read and write execution permissions

I am using the Kali system, and the system information is as follows:
Linux kali 5.18.0-kali5-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.5-1kali6 (2022-07-07) x86_64 GNU/Lin
The entire installation process is performed using root privileges
Of course, the root user is also added to the docker user group

What is the reason for the error? How on earth should I set it so as not to report errors? Could you please explain it

@PdxPdx
Copy link
Author

PdxPdx commented Mar 29, 2023

At the same time, in the Info>system on the web, the front-end status and back-end status display are normal, but the database status is "unknown". Is there a problem with the database settings?

In addition, after uploading the firmware, an error is prompted:

“ Error! File not found in database: d1df9a9c72504c5a6c78e60b9d3599b2ada99c05d4444dd68a5fb8811ef4bdc1_7279516 ”

@jstucke
Copy link
Collaborator

jstucke commented Mar 29, 2023

Hi, it's hard to say what the reason for the permission problem could be. Please mind though, that /media/data/fact_fw_data/87 is the path inside the docker container. Creating it inside your file system won't help. But it is actually also located in your system: The option --firmware-file-storage-dir sets which directory gets mounted inside the container and you should make sure that it has the appropriate permissions.

You could also try to debug the problem directly by opening a shell inside the running container. After you started FACT_docker, you can use docker container ls to get a list of all running containers and find out what the ID of the "FACT backend" container is. With this ID you can open a shell in the container with docker exec -it <container-ID> bash. Then you can try to navigate to the problematic directory and look at the permissions.

the front-end status and back-end status display are normal, but the database status is "unknown"

This is a side effect of the transition from MongoDB to PostgreSQL and you can ignore it.

“ Error! File not found in database: d1df9a9c72504c5a6c78e60b9d3599b2ada99c05d4444dd68a5fb8811ef4bdc1_7279516 ”

This is likely an aftereffect of the permission problems.

@PdxPdx
Copy link
Author

PdxPdx commented Mar 30, 2023

Thank you for your quick response

"The permission for"/media/data "in the container is" drwxr-xr-x 3 root 4096 Oct 13 10:22 data ", but the backend error message is" Could not write file: [Errno 13] Permission denied: '/media/data/fact "."_ fw_ data/d1'“

I want to know the password of the root user in the fact image, so that I can grant permissions to the file

In addition, what is the problem of AttributeError: 'str' object has no attribute 'uid' reporting an error? How should I resolve it?

@maringuu
Copy link
Collaborator

Manually granting permissions is not a good approach.

While in theory executing as root should not be a problem, could you please try again as a non root user?
(Mind that this user has to be in the docker group)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants