packages icon indicating copy to clipboard operation
packages copied to clipboard

transmission: Couldn't save temporary file: Permission denied (variant.c:1235)

Open chirunosw opened this issue 4 years ago • 9 comments

Maintainer: @dangowrt Environment: Openwrt 22.03.2 X86

Description: Transmission can't create and save stats.json and dht.dat, but setting.json can be created. Each time I restart transmission the session stats would be cleared, altough it is harmless.

Fri Nov  4 22:35:44 2022 user.notice transmission: Starting with 6394528000 virt mem
Fri Nov  4 22:35:45 2022 daemon.err transmission-daemon[5774]: [2022-11-04 14:35:45.160] Couldn't save temporary file "/Home/transmission/settings.json.tmp.XXXXXX": Permission denied (variant.c:1235)
Fri Nov  4 22:35:45 2022 daemon.err transmission-daemon[5774]: [2022-11-04 14:35:45.160] Couldn't save temporary file "/Home/transmission/dht.dat.tmp.XXXXXX": Permission denied (variant.c:1235)
Fri Nov  4 22:35:45 2022 daemon.err transmission-daemon[5774]: [2022-11-04 14:35:45.160] Couldn't save temporary file "/Home/transmission/stats.json.tmp.XXXXXX": Permission denied (variant.c:1235)
Fri Nov  4 22:35:47 2022 daemon.err transmission-daemon[27732]: [2022-11-04 14:35:47.230] Couldn't save temporary file "/Home/transmission/settings.json.tmp.XXXXXX": Permission denied (variant.c:1235)
Fri Nov  4 22:36:09 2022 daemon.err transmission-daemon[27732]: [2022-11-04 14:36:09.230] Unable to create session lock file (2): No such file or directory (session-id.c:96)
root@OpenWrt:~# ls -l  /Home/transmission
drwxr-xr-x    2 transmis transmis      4096 Oct 31 01:49 blocklists
drwxr-xr-x    2 transmis transmis     12288 Nov  4 22:41 resume
-rw-r--r--    1 transmis transmis      1560 Nov  4 22:35 settings.json
drwxr-xr-x    2 transmis transmis     12288 Nov  3 22:36 torrents

chirunosw avatar Nov 04 '22 14:11 chirunosw

/Home/transmission directory permissions won't allow transmission to create new files (no write permissions).

ghost avatar Nov 21 '22 21:11 ghost

/Home/transmission directory permissions won't allow transmission to create new files (no write permissions).

But the directory owner is transmission and it had permission 0755 already. I also set /Home directory to 0777 but still doesn't matter.

root@OpenWrt:~# ls -l  /Home
drwx------    2 root     root          4096 Nov 11 17:58 adblock-Backup
drwxr-xr-x    2 root     root          4096 Nov  2 19:43 adblock-Report
-rw-r--r--    1 root     root           358 Nov 23 00:50 dhcp.leases
drwxr-xr-x    2 root     root          4096 Nov  1 02:10 nlbwmon
drwxr-xr-x    3 root     root          4096 Oct 31 01:36 rrd
drwxrwxrwx    5 transmis transmis      4096 Nov  4 00:30 transmission

chirunosw avatar Nov 22 '22 17:11 chirunosw

What are the permissions of /Home? ls -ld /Home?

paper42 avatar Nov 22 '22 18:11 paper42

What are the permissions of /Home? ls -ld /Home?

root@OpenWrt:~# ls -ld /Home
drwxrwxrwx    7 root     root          4096 Oct 31 01:49 /Home

So I am confused. Should I set the owner to transmission too?

chirunosw avatar Nov 22 '22 18:11 chirunosw

No, this should work. You could try switching your user to transmission and trying to touch that file.

paper42 avatar Nov 22 '22 18:11 paper42

Could it be some jail / chroot / seccomp issue?

ghost avatar Nov 22 '22 19:11 ghost

No, this should work. You could try switching your user to transmission and trying to touch that file.

How can I switch user on openwrt? I don't know passwd and I changed the main directory of transmission to /Home/transmission but still not work.

chirunosw avatar Nov 22 '22 19:11 chirunosw

Could it be some jail / chroot / seccomp issue?

Idk but I saw others related similar problems to those packages. I'm not familiar with them.

chirunosw avatar Nov 22 '22 20:11 chirunosw

Could it be some jail / chroot / seccomp issue?

This is definitely a jail / chroot / seccomp issue. In the /etc/init.d/transmission there is jail section for the files and directories.

	procd_add_jail_mount "$config_file"
	procd_add_jail_mount_rw "$config_dir/resume"
	procd_add_jail_mount_rw "$config_dir/torrents"
	procd_add_jail_mount_rw "$config_dir/blocklists"
	procd_add_jail_mount_rw "$config_dir/stats.json"
	procd_add_jail_mount_rw "$download_dir"

Since there is no write permission for the $config_dir, no new files can be created in it. Transmission daemon would create several .tmp files here in normal operation. Beside those mentioned above, blocklist.tmp is also created here, during blocklist update. Perhaps there is no need to have such a stringent jail rules for the transmission config dir itself?

Workaround one could use is to add RW permission for the config dir here (in addition to or instead of existing rules)

	procd_add_jail_mount_rw "$config_dir"

shtefko avatar May 15 '25 14:05 shtefko