[SRU] motion fails to start after install: Permission denied creating log file
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
motion (Debian) |
New
|
Unknown
|
|||
motion (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Undecided
|
Unassigned | ||
Mantic |
Fix Released
|
Undecided
|
Unassigned | ||
Noble |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[ Impact ]
motion will fail to start after installing with the error:
motion[4536]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/
Also, service status will show:
$ systemctl status motion.service
○ motion.service - Motion detection video capture daemon
Loaded: loaded (/usr/lib/
Active: inactive (dead) since Tue 2024-03-05 21:47:35 GMT; 1min 16s ago
Duration: 91ms
Docs: man:motion(1)
Process: 4536 ExecStart=
Main PID: 4536 (code=exited, status=0/SUCCESS)
CPU: 49ms
Mar 05 21:47:34 sudip-pc-i440fx-7-2 systemd[1]: Started motion.service - Motion detection video capture daemon.
Mar 05 21:47:34 sudip-pc-i440fx-7-2 motion[4536]: [0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/
Mar 05 21:47:34 sudip-pc-i440fx-7-2 motion[4536]: [0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/
Mar 05 21:47:34 sudip-pc-i440fx-7-2 motion[4536]: [0:motion] [ERR] [ALL] mycreate_path: Problem creating directory /var/log/motion: Permission denied
Mar 05 21:47:34 sudip-pc-i440fx-7-2 motion[4536]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/
Mar 05 21:47:34 sudip-pc-i440fx-7-2 motion[4536]: [0:motion] [ERR] [ALL] mycreate_path: Problem creating directory /var/log/motion: Permission denied
Mar 05 21:47:34 sudip-pc-i440fx-7-2 motion[4536]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/
Mar 05 21:47:35 sudip-pc-i440fx-7-2 systemd[1]: motion.service: Deactivated successfully.
Any attempt to start or restart the service will still fail.
$ sudo systemctl start motion.service
Broadcast message from systemd-
motion[4621]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/
The problem will be there until the /var/log/motion directory is created. A non-technical user will see "motion" is not working.
[ Test Plan ]
1. Install motion
2. Check motion service status and confirm its started
With the fixed package, motion service status will shows it has started.
[ Where problems could occur ]
It does not change any part of the code, only change is in the postinst script to create the log folder if it does not exist. There should not be any regression in the software for this change.
[ Other Info ]
The log folder creation was part of the init scripts at https:/
I guess it was missed while updating the package to use systemd services.
The error will not be seen by users upgrading from Focal.
[ Original Bug Description ]
I installed motion for the first time on a reasonably fresh Kubuntu 21.04 release. I installed this system in April 2021. It immediately fails and spams "emergency" log messages all over my terminals. (See dpkg log below)
The problem seems to be that the default config /etc/motion/
log_file /var/log/
but there is nothing to create that directory. I'm not sure whether this should be a job for postinst, or a systemd ExecStartPre, but I would argue that not logging to a file at all and letting systemd-journald hoover up the stderr/syslog messages would be better.
Indeed, if I remove the log_file line from /etc/motion/
Thanks,
Bruce
Dpkg log:
Setting up motion (4.3.2-1) ...
Adding group `motion' (GID 134) ...
Done.
Warning: The home dir /var/lib/motion you specified already exists.
Adding system user `motion' (UID 127) ...
Adding new user `motion' (UID 127) with group `motion' ...
The home directory `/var/lib/motion' already exists. Not copying from `/etc/skel'.
adduser: Warning: The home directory `/var/lib/motion' does not belong to the user you are currently creating.
Adding user `motion' to group `video' ...
Adding user motion to group video
Done.
Created symlink /etc/systemd/
Processing triggers for man-db (2.9.4-2) ...
Broadcast message from systemd-
motion[1372993]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/
Changed in motion (Ubuntu Jammy): | |
status: | New → Confirmed |
Changed in motion (Ubuntu Mantic): | |
status: | New → Confirmed |
Changed in motion (Ubuntu Jammy): | |
assignee: | nobody → Sudip Mukherjee (sudipmuk) |
Changed in motion (Ubuntu Mantic): | |
assignee: | nobody → Sudip Mukherjee (sudipmuk) |
Changed in motion (Ubuntu Noble): | |
assignee: | nobody → Sudip Mukherjee (sudipmuk) |
Changed in motion (Ubuntu Jammy): | |
status: | Confirmed → In Progress |
Changed in motion (Ubuntu Mantic): | |
status: | Confirmed → In Progress |
Changed in motion (Ubuntu Noble): | |
status: | Confirmed → In Progress |
Changed in motion (Debian): | |
status: | Unknown → New |
Same here with 22.04. I just did this to get it to start:
mkdir /var/log/motion
chown motion: /var/log/motion/
systemctl start motion