Umaks incorrect in systemd unit
Description:
The umask 177 from the systemd unit causes an error with the cache directory creation /var/cache/reflector/Reflector
. The directory gets created with rw- permissions and therefore the service fails to properly use this directory as the x permission is missing. Setting the x permission manually fixes this error.
Dec 03 17:07:21 PC-001 systemd[1]: Starting Refresh Pacman mirrorlist with Reflector....
░░ Subject: A start job for unit reflector.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit reflector.service has begun execution.
░░
░░ The job identifier is 23251.
Dec 03 17:07:21 PC-001 reflector[1988981]: Traceback (most recent call last):
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/bin/reflector", line 4, in <module>
Dec 03 17:07:21 PC-001 reflector[1988981]: sys.exit(Reflector.run_main(configure_logging=True))
Dec 03 17:07:21 PC-001 reflector[1988981]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 1159, in run_main
Dec 03 17:07:21 PC-001 reflector[1988981]: main(args, **kwargs)
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 1127, in main
Dec 03 17:07:21 PC-001 reflector[1988981]: mirrorstatus, mirrors = process_options(options)
Dec 03 17:07:21 PC-001 reflector[1988981]: ^^^^^^^^^^^^^^^^^^^^^^^^
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 1056, in process_options
Dec 03 17:07:21 PC-001 reflector[1988981]: mirrors = mirrorstatus.get_mirrors()
Dec 03 17:07:21 PC-001 reflector[1988981]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 711, in get_mirrors
Dec 03 17:07:21 PC-001 reflector[1988981]: obj = self.get_obj()
Dec 03 17:07:21 PC-001 reflector[1988981]: ^^^^^^^^^^^^^^
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 704, in get_obj
Dec 03 17:07:21 PC-001 reflector[1988981]: self.retrieve()
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 692, in retrieve
Dec 03 17:07:21 PC-001 reflector[1988981]: self.mirror_status, self.ms_mtime = get_mirrorstatus(
Dec 03 17:07:21 PC-001 reflector[1988981]: ^^^^^^^^^^^^^^^^^
Dec 03 17:07:21 PC-001 reflector[1988981]: File "/usr/lib/python3.11/site-packages/Reflector.py", line 113, in get_mirrorstatus
Dec 03 17:07:21 PC-001 reflector[1988981]: mtime = os.path.getmtime(cache_path)
Dec 03 17:07:21 PC-001 reflector[1988981]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 03 17:07:21 PC-001 reflector[1988981]: File "<frozen genericpath>", line 55, in getmtime
Dec 03 17:07:21 PC-001 reflector[1988981]: PermissionError: [Errno 13] Permission denied: '/var/cache/reflector/Reflector/aHR0cHM6Ly93d3cuYXJjaGxpbnV4Lm9yZy9taXJyb3JzL3N0YXR1cy9qc29uLw==.json'
Dec 03 17:07:21 PC-001 systemd[1]: reflector.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ An ExecStart= process belonging to unit reflector.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Dec 03 17:07:21 PC-001 systemd[1]: reflector.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit reflector.service has entered the 'failed' state with result 'exit-code'.
Dec 03 17:07:21 PC-001 systemd[1]: Failed to start Refresh Pacman mirrorlist with Reflector..
░░ Subject: A start job for unit reflector.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit reflector.service has finished with a failure.
░░
░░ The job identifier is 23251 and the job result is failed.
Additional info:
- package version(s): 2023-1
- config and/or log files etc.
- link to upstream bug report, if any
Steps to reproduce:
- Freshly install reflector
- Start the systemd unig
systemctl start reflector.service
- Look at unit status or journal
journalctl -xeu reflector.service
The actual conflicting code is the set umask and the makedirs within the python code:
umask 177
python -c 'import os; os.makedirs("/tmp/test3", exist_ok=True)'
Edited by Klaus Frank