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

Bug #1685193 reported by flux242
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Won't Fix
Undecided
Dimitri John Ledkov

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.

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

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

Changed in systemd (Ubuntu):
status: New → Confirmed
Changed in systemd (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Yes, there are no permissions to write to /var/log, that is so far intentional.

Another question is why are you still using pmutils? My understanding is that Ubuntu no longer uses that at all, and uses systemd power management.

Revision history for this message
flux242 (flux242) wrote :

what are the intentions?

systemd power management huh? Which of these problems has already been solved since 15.10 then:

1. System doesn't react on the power supply plugged/unplugged events
2. Lid close events are handled by the systemd by default and not by the xfce4-power-manager
3. System doesn't execute pm-utils hooks on sleep/resume events, i.e when the power cord is unplugged all powertop's tunable should be in GOOD state. Are they?

Revision history for this message
Dan Streetman (ddstreet) wrote :

please reopen if this is still an issue

Changed in systemd (Ubuntu):
status: Confirmed → Won't Fix
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.