motd-news.service scheduled even when /etc/update-motd.d/50-motd-news is not executable

Bug #1803601 reported by Simon Déziel
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
base-files (Ubuntu)
Triaged
Low
Unassigned

Bug Description

update-motd(5) says:

 Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at each
 login, and this information is concatenated in /run/motd.dynamic. The order of script execu‐
 tion is determined by the run-parts(8) --lsbsysinit option (basically alphabetical order, with
 a few caveats).

So sysadmins are used to "chmod -x" motd fragments from /etc/update-motd.d/ to prevent their execution. When doing so for /etc/update-motd.d/50-motd-news, I noticed that motd-news.timer was still trying to execute the motd-news.service unit which then logged a failure:

 systemd[3704]: motd-news.service: Failed to execute command: Permission denied
 systemd[3704]: motd-news.service: Failed at step EXEC spawning /etc/update-motd.d/50-motd-news:
  Permission denied
 systemd[1]: motd-news.service: Main process exited, code=exited, status=203/EXEC
 systemd[1]: motd-news.service: Failed with result 'exit-code'.
 systemd[1]: Failed to start Message of the Day.

The motd-news.service unit looks like this:

$ systemctl cat motd-news.service
# /lib/systemd/system/motd-news.service
[Unit]
Description=Message of the Day
After=network-online.target
Documentation=man:update-motd(8)

[Service]
Type=oneshot
ExecStart=/etc/update-motd.d/50-motd-news --force

This problem was observed on a Bionic system:

$ lsb_release -rd
Description: Ubuntu 18.04.1 LTS
Release: 18.04
$ apt-cache policy base-files
base-files:
  Installed: 10.1ubuntu2.3
  Candidate: 10.1ubuntu2.3
  Version table:
 *** 10.1ubuntu2.3 500
        500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     10.1ubuntu2.2 500
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
     10.1ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages

But the problem also exist in Disco.

Revision history for this message
Simon Déziel (sdeziel) wrote :

A possible fix would be to make the unit execution conditional to the update-motd fragment being executable:

  [Unit]
  ConditionFileIsExecutable=/etc/update-motd.d/50-motd-news

I'm not sure if this should be added to motd-news.service, motd-news.timer or both.

description: updated
Revision history for this message
Tommy (aschenbecher) wrote :

I have the same problem and it looks like this issue brings my server in real trouble. I deactivated this services completly now and hope it helps.

tags: added: bionic bitsize eoan
tags: added: bitesize
removed: bitsize
Changed in base-files (Ubuntu):
importance: Undecided → Low
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

There are many alternatives here. What you describe is one, and you could then also add a systemd override with that exec check. A bit cumbersome, though.

Another one is specific to this service, and that is to set ENABLED=0 in /etc/default/motd-news.

I think fixing this doesn't warrant an SRU, but should be considered for the devel release of ubuntu (groovy at the moment).

Changed in base-files (Ubuntu):
status: New → Triaged
Revision history for this message
Simon Déziel (sdeziel) wrote : Re: [Bug 1803601] Re: motd-news.service scheduled even when /etc/update-motd.d/50-motd-news is not executable

On 2020-05-06 2:49 p.m., Andreas Hasenack wrote:
> There are many alternatives here.

IIRC, `chmod -x` snippets from /etc/update-motd.d/ was the way to go a
few releases ago when it was consumed by run-parts.

> I think fixing this doesn't warrant an SRU, but should be considered for
> the devel release of ubuntu (groovy at the moment).

It's merely to avoid harmless surprise and keep the old sysadmins happy,
certainly not worth a SRU.

Thanks,
Simon

Revision history for this message
wontfix (wontfix) wrote :

"Another one is specific to this service, and that is to set ENABLED=0 in /etc/default/motd-news."

This file no longer exists by default in Ubuntu 22.04 Jammy. The language in the fix in many places including https://ubuntu.com/legal/motd is to change a number in a file that isn't there.

As you know, systemd services that are disabled can still be enabled.

Revision history for this message
Tired Sysadmin (wearyofallthiscrap) wrote :

Simon Déziel (sdeziel) wrote:
> IIRC, `chmod -x` snippets from /etc/update-motd.d/ was the way to go a
> few releases ago when it was consumed by run-parts.

In 22.04 it's still handled by run-parts, and the man page documents it as such. Specifically by

$ strings /lib/x86_64-linux-gnu/security/pam_motd.so | grep run-parts
/usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d > /run/motd.dynamic.new

in its primary use case. The "fetch new ads on boot" motd-news.service for this bug report runs one of the scripts directly, but the directory is still a run-parts input.

We could disable scripts by renaming them to something that won't be found by the '--lsbsysinit' file patterns, but that would only solve the problem for "at login" updates, not the "at boot" updates through systemd.

> It's merely to avoid harmless surprise and keep the old sysadmins happy,

Service errors is hardly a "surprise", and you don't need to be condescending about it.

wontfix (wontfix) wrote:
> and that is to set ENABLED=0 in /etc/default/motd-news."
>
> This file no longer exists by default in Ubuntu 22.04 Jammy.

$ grep VERSION /etc/os-release
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
$ dpkg -S /etc/default/motd-news
motd-news-config: /etc/default/motd-news
$ apt show motd-news-config
Package: motd-news-config
Priority: optional
Source: base-files
Task: cloud-image, ubuntu-wsl, server, ubuntu-server-raspi
APT-Manual-Installed: no
[several header elided]

It certainly existed by default from the beginning of the server installation I'm working with. However, it's "priority: optional" so perhaps that's what you mean by "not default"; it likely wouldn't be there for a standard desktop installation.

Revision history for this message
Tired Sysadmin (wearyofallthiscrap) wrote :

I should also have mentioned that 'ubuntu-server' has a hard dependency on 'motd-news-config', so anybody wanting a standard server-type installation will automatically get the advert updater and /etc/default/motd-news.

wontfix (wontfix)
tags: added: jammy kinetic lunar
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.