[Bug 2019089] [NEW] shutdown-scripts service is restarted on package upgrade - causing any configured shutdown scripts to be run

Philip Roche 2019089 at bugs.launchpad.net
Wed May 10 08:39:23 UTC 2023


Public bug reported:

Initially reported @ https://github.com/GoogleCloudPlatform/guest-
agent/issues/119

It is only relevant for Ubuntu 22.04 and later.

The previous logic https://git.launchpad.net/ubuntu/+source/google-
guest-agent/tree/debian/rules#n20 in the package works fine in 20.04 and
18.04 but not in 22.04+.

Basically anytime the google-guest-agent package is updated, these
services are restarted which means the customer scripts are run at a
time they are not supposed to be. This caused an outage for one customer
who had some logic in their shutdown script that basically turned off
their services.

The issue is most certainly in the autogenerated preinst script which
should not be there. Stopping the shutdown service will invoke the
shutdown script. This wasn't there in previous Ubuntu versions.

Ubuntu 22.04 preinst script
```
#!/bin/sh
set -e
# Automatically added by dh_installdeb/13.6ubuntu1
dpkg-maintscript-helper rm_conffile /etc/defaults/instance_configs.cfg 20200617.00-0ubuntu2\~ -- "$@"
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = upgrade ] && [ -d /run/systemd/system ] ; then
deb-systemd-invoke stop 'google-shutdown-scripts.service' 'google-startup-scripts.service' >/dev/null || true
fi
# End automatically added section
```

Ubuntu 20.04 preinst script

```
root at ubu2004:/tmp/DEBIAN# cat preinst
#!/bin/sh
set -e
# Automatically added by dh_installdeb/12.10ubuntu1
dpkg-maintscript-helper rm_conffile /etc/defaults/instance_configs.cfg 20200617.00-0ubuntu2\~ -- "$@"
# End automatically added section
```

One reason this issue was of concern as the latest google-guest-agent
update was a rebuild promoted by golang-1.18 being updated to address
CVEs prompting a rebuild of all packages dependant on golang-1.18 and
publication of those rebuilds to the -security pocket. unattended-
upgrades then upgraded google-guest-agent in the background which
restarted the shutdown-scripts.

** Affects: google-guest-agent (Ubuntu)
     Importance: Undecided
     Assignee: Philip Roche (philroche)
         Status: In Progress

** Attachment added: "Reproducer and test script"
   https://bugs.launchpad.net/bugs/2019089/+attachment/5672115/+files/reproducer-and-test.sh

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to google-guest-agent in Ubuntu.
https://bugs.launchpad.net/bugs/2019089

Title:
  shutdown-scripts service is restarted on package upgrade - causing any
  configured shutdown scripts to be run

Status in google-guest-agent package in Ubuntu:
  In Progress

Bug description:
  Initially reported @ https://github.com/GoogleCloudPlatform/guest-
  agent/issues/119

  It is only relevant for Ubuntu 22.04 and later.

  The previous logic https://git.launchpad.net/ubuntu/+source/google-
  guest-agent/tree/debian/rules#n20 in the package works fine in 20.04
  and 18.04 but not in 22.04+.

  Basically anytime the google-guest-agent package is updated, these
  services are restarted which means the customer scripts are run at a
  time they are not supposed to be. This caused an outage for one
  customer who had some logic in their shutdown script that basically
  turned off their services.

  The issue is most certainly in the autogenerated preinst script which
  should not be there. Stopping the shutdown service will invoke the
  shutdown script. This wasn't there in previous Ubuntu versions.

  Ubuntu 22.04 preinst script
  ```
  #!/bin/sh
  set -e
  # Automatically added by dh_installdeb/13.6ubuntu1
  dpkg-maintscript-helper rm_conffile /etc/defaults/instance_configs.cfg 20200617.00-0ubuntu2\~ -- "$@"
  # End automatically added section
  # Automatically added by dh_installsystemd/13.6ubuntu1
  if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = upgrade ] && [ -d /run/systemd/system ] ; then
  deb-systemd-invoke stop 'google-shutdown-scripts.service' 'google-startup-scripts.service' >/dev/null || true
  fi
  # End automatically added section
  ```

  Ubuntu 20.04 preinst script

  ```
  root at ubu2004:/tmp/DEBIAN# cat preinst
  #!/bin/sh
  set -e
  # Automatically added by dh_installdeb/12.10ubuntu1
  dpkg-maintscript-helper rm_conffile /etc/defaults/instance_configs.cfg 20200617.00-0ubuntu2\~ -- "$@"
  # End automatically added section
  ```

  One reason this issue was of concern as the latest google-guest-agent
  update was a rebuild promoted by golang-1.18 being updated to address
  CVEs prompting a rebuild of all packages dependant on golang-1.18 and
  publication of those rebuilds to the -security pocket. unattended-
  upgrades then upgraded google-guest-agent in the background which
  restarted the shutdown-scripts.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/google-guest-agent/+bug/2019089/+subscriptions




More information about the foundations-bugs mailing list