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

[bug]: File read permission denied #2585

Open
1 task done
klein0r opened this issue Jan 16, 2024 · 1 comment
Open
1 task done

[bug]: File read permission denied #2585

klein0r opened this issue Jan 16, 2024 · 1 comment
Labels

Comments

@klein0r
Copy link
Contributor

klein0r commented Jan 16, 2024

No existing issues.

  • There is no existing issue for my problem.

Description

mkleine@iobroker:~$ echo "test" > ~/test.txt
mkleine@iobroker:~$ iobroker file write ~/test.txt 0_userdata.0/test.txt
File "/home/mkleine/test.txt" stored as "test.txt"

Unable to read file:

mkleine@iobroker:~$ iobroker file read 0_userdata.0/test.txt
Error: EACCES: permission denied, open '/home/mkleine/test.txt'
    at Object.openSync (node:fs:581:18)
    at Object.writeFileSync (node:fs:2342:35)
    at Immediate.<anonymous> (/opt/iobroker/node_modules/@iobroker/js-controller-cli/src/lib/setup.ts:2289:32)
    at processImmediate (node:internal/timers:480:21) {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/home/mkleine/test.txt'
}

The problem is, that /opt/iobroker/iobroker runs the command with sudo -H -u iobroker and the user iobroker has no permissions to write in my home dir.

else
sudo -H -u iobroker node /opt/iobroker/node_modules/iobroker.js-controller/iobroker.js "$@"
fi

Reproduction instruction

No response

@foxriver76
Copy link
Collaborator

hm yes.. probably not that easy to fix.

Short recap if coming back later: The behavior of read file is, read file from the database and write it to the current working directory if not specified other.

An alternative would be to let the read file command just write to stdout, then users could pipe stdout to file if needed, but would probably bring up other ugly cases and would also not fix other situations where this might occur.

All in all, this might be really tricky to get a nice behavior here, whole setup is (as desired normally) that everything runs as iobroker but of course has no permissions to user dirs where user might operate. For most scenarios the user will use admin files tab anyway, where files can be downloaded flawlessly.

No idea how to solve besides adding more command exceptions which are not executed by user iobroker or only displaying the file for this specific scenario. Any ideas @Apollon77?

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

No branches or pull requests

2 participants