[SRU] motion fails to start after install: Permission denied creating log file

Bug #1946521 reported by Bruce Duncan
16
This bug affects 2 people
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/motion/motion.log: Permission denied

Also, service status will show:

$ systemctl status motion.service
○ motion.service - Motion detection video capture daemon
     Loaded: loaded (/usr/lib/systemd/system/motion.service; enabled; preset: enabled)
     Active: inactive (dead) since Tue 2024-03-05 21:47:35 GMT; 1min 16s ago
   Duration: 91ms
       Docs: man:motion(1)
    Process: 4536 ExecStart=/usr/bin/motion (code=exited, status=0/SUCCESS)
   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/motion.conf
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/motion.conf
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/motion/motion.log: Permission denied
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/motion/motion.log: Permission denied
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-journald@sudip-pc-i440fx-7-2 (Tue 2024-03-05 21:49:44 GMT):

motion[4621]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/motion/motion.log: Permission denied

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://git.launchpad.net/ubuntu/+source/motion/tree/debian/motion.init?h=ubuntu/focal#n60
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/motion.conf specifies:

log_file /var/log/motion/motion.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/motion.conf, motion starts and runs perfectly well, and I get log messages in systemctl status.

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/system/multi-user.target.wants/motion.service → /lib/systemd/system/motion.service.
Processing triggers for man-db (2.9.4-2) ...

Broadcast message from systemd-journald@w7700 (Fri 2021-10-08 01:05:54 BST):

motion[1372993]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/motion/motion.log: Permission denied

Revision history for this message
Erik Meitner (eamuwmath) wrote :

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

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in motion (Ubuntu):
status: New → Confirmed
Revision history for this message
Sudip Mukherjee (sudipmuk) wrote :

I have now tested and confirmed that the issue is seen on Jammy, Mantic and Noble.

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
Revision history for this message
Sudip Mukherjee (sudipmuk) wrote :

Debdiff for Noble attached.

summary: - motion fails to start after install: Permission denied creating log file
+ [SRU] motion fails to start after install: Permission denied creating
+ log file
description: updated
description: updated
Revision history for this message
Sudip Mukherjee (sudipmuk) wrote :

Debdiff for Mantic.

Revision history for this message
Sudip Mukherjee (sudipmuk) wrote :

Debdiff for Jammy.

Changed in motion (Ubuntu Jammy):
status: In Progress → Confirmed
Changed in motion (Ubuntu Mantic):
status: In Progress → Confirmed
Changed in motion (Ubuntu Noble):
status: In Progress → Confirmed
Changed in motion (Ubuntu Jammy):
assignee: Sudip Mukherjee (sudipmuk) → nobody
Changed in motion (Ubuntu Mantic):
assignee: Sudip Mukherjee (sudipmuk) → nobody
Changed in motion (Ubuntu Noble):
assignee: Sudip Mukherjee (sudipmuk) → nobody
Changed in motion (Debian):
status: Unknown → New
Revision history for this message
Dave Jones (waveform) wrote :

This looks good, thanks -- sponsoring!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package motion - 4.6.0-1ubuntu1

---------------
motion (4.6.0-1ubuntu1) noble; urgency=medium

  * Create log folder if it does not exist. (LP: #1946521)

 -- Sudip Mukherjee <email address hidden> Mon, 25 Mar 2024 14:12:38 +0000

Changed in motion (Ubuntu Noble):
status: Confirmed → Fix Released
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Bruce, or anyone else affected,

Accepted motion into mantic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/motion/4.5.1-3ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-mantic to verification-done-mantic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-mantic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in motion (Ubuntu Mantic):
status: Confirmed → Fix Committed
tags: added: verification-needed verification-needed-mantic
Changed in motion (Ubuntu Jammy):
status: Confirmed → Fix Committed
tags: added: verification-needed-jammy
Revision history for this message
Timo Aaltonen (tjaalton) wrote :

Hello Bruce, or anyone else affected,

Accepted motion into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/motion/4.3.2-1ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Sudip Mukherjee (sudipmuk) wrote :

I can confirm that motion from mantic-proposed has fixed the bug for me.

Test done:

Install motion on a mantic installation.
confirm that motion service did not start and the issue is seen.

Add mantic-proposed to apt sources
update motion from mantic-proposed
check that the motion.service is running

$ systemctl status motion.service
● motion.service - Motion detection video capture daemon
     Loaded: loaded (/lib/systemd/system/motion.service; enabled; preset: enabled)
     Active: active (running) since Sat 2024-05-04 19:17:27 BST; 14s ago
       Docs: man:motion(1)
   Main PID: 3532 (motion)
      Tasks: 4 (limit: 9443)
     Memory: 16.1M
        CPU: 153ms
     CGroup: /system.slice/motion.service
             └─3532 /usr/bin/motion

Test result: the issue with motion has been fixed.

Package tested:

$ apt-cache policy motion
motion:
  Installed: 4.5.1-3ubuntu0.1
  Candidate: 4.5.1-3ubuntu0.1
  Version table:
 *** 4.5.1-3ubuntu0.1 100
        100 http://us.archive.ubuntu.com/ubuntu mantic-proposed/universe amd64 Packages
        100 /var/lib/dpkg/status
     4.5.1-3build1 500
        500 http://us.archive.ubuntu.com/ubuntu mantic/universe amd64 Packages

Revision history for this message
Sudip Mukherjee (sudipmuk) wrote :

I can confirm that motion from jammy-proposed has fixed the bug for me.

Test done:

Install motion on a jammy installation.
confirm that motion service did not start and the issue is seen.

Add jammy-proposed to apt sources
update motion from jammy-proposed
check that the motion.service is running

$ systemctl status motion.service
● motion.service - Motion detection video capture daemon
     Loaded: loaded (/lib/systemd/system/motion.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2024-05-04 19:20:55 BST; 8s ago
       Docs: man:motion(1)
   Main PID: 3250 (motion)
      Tasks: 4 (limit: 9436)
     Memory: 19.0M
        CPU: 118ms
     CGroup: /system.slice/motion.service
             └─3250 /usr/bin/motion

Test result: the issue with motion has been fixed.

Package tested:

$ apt-cache policy motion
motion:
  Installed: 4.3.2-1ubuntu0.1
  Candidate: 4.3.2-1ubuntu0.1
  Version table:
 *** 4.3.2-1ubuntu0.1 500
        500 http://gb.archive.ubuntu.com/ubuntu jammy-proposed/universe amd64 Packages
        100 /var/lib/dpkg/status
     4.3.2-1 500
        500 http://gb.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

tags: added: verification-done verification-done-jammy verification-done-mantic
removed: verification-needed verification-needed-jammy verification-needed-mantic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package motion - 4.5.1-3ubuntu0.1

---------------
motion (4.5.1-3ubuntu0.1) mantic; urgency=medium

  * Create log folder if it does not exist. (LP: #1946521)

 -- Sudip Mukherjee <email address hidden> Tue, 05 Mar 2024 21:54:40 +0000

Changed in motion (Ubuntu Mantic):
status: Fix Committed → Fix Released
Revision history for this message
Robie Basak (racb) wrote : Update Released

The verification of the Stable Release Update for motion has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package motion - 4.3.2-1ubuntu0.1

---------------
motion (4.3.2-1ubuntu0.1) jammy; urgency=medium

  * Create log folder if it does not exist. (LP: #1946521)

 -- Sudip Mukherjee <email address hidden> Tue, 05 Mar 2024 22:01:47 +0000

Changed in motion (Ubuntu Jammy):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.