[17.04] systemd-udevd. Scripts started by a rule won't write to /var/log

Bug #1685193 reported by flux242 on 2017-04-21
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)

Bug Description

this is rather weird problem but after upgrading to the 17.04 the pm-powersave script I start by a udev rule stopped working. After debuggin a bit I found a place that causes the error. In the /usr/lib/pm-utils/pm-functions there's the init_logfile function that called exec to redirect script's output to the /var/log/pm-powersave.log. And it fails to do so because root (under which the script is started) has no permission to write to anything under the /var/log/

Inside of that functions I added additional logging to prove that
1. the script is started under root
2. the file /var/log/pm-powersave.log exist and it has 644 permissions
3. the root can read from /var/log/*
4. /var permissions are 755, /var/log permissions are 775

If the script is started with 'sudo /usr/sbin/pm-powersave true' then it works!

So what could this be? Could the apparmor prevent udevd to write to /var/log ?

Temporary solution is to write to /tmp/pm-powersave.log

How to reproduce:
1. add the following rule to /etc/udev/rules.d/test.rules
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/sbin/testudev true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/sbin/testudev false"
2. create /usr/sbin/testudev script and make it executable
#!/usr/bin/env bash

logger "testudev: I'm: $(whoami)"
echo test >> /var/log/testudev.log

3. Plug and unplug the power plug. Check the syslog:
Apr 21 13:17:06 chrome root: testudev: I'm: root
Apr 21 13:17:06 chrome systemd-udevd[23333]: Process '/usr/sbin/testudev false' failed with exit code 1.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers