Skip to content

Commit

Permalink
apt-hook: only run apt upgrade hook when run as root
Browse files Browse the repository at this point in the history
LP: #2084677
  • Loading branch information
orndorffgrant committed Oct 16, 2024
1 parent 547601a commit 93fcfbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apt-hook/20apt-esm-hook.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ APT::Update::Pre-Invoke {
};

binary::apt::AptCli::Hooks::Upgrade {
"[ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook 2>> /var/log/ubuntu-advantage-apt-hook.log || true";
"[ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || [ $(id -u) -ne 0 ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook 2>> /var/log/ubuntu-advantage-apt-hook.log || true";
};
16 changes: 16 additions & 0 deletions features/apt_messages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,22 @@ Feature: APT Messages
# | oracular | lxd-container | jammy | libcurl4t64 | 8.8.0-3ubuntu3 |
| noble | lxd-container | jammy | libcurl4t64 | 8.5.0-2ubuntu10 |

Scenario Outline: APT Hook does not error when run as non-root
Given a `<release>` `<machine_type>` machine with ubuntu-advantage-tools installed
When I run `apt upgrade --simulate` as non-root
Then I will see the following on stderr
"""
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
"""

Examples: ubuntu release
| release | machine_type |
| xenial | lxd-container |
| bionic | lxd-container |
| focal | lxd-container |
| jammy | lxd-container |
| noble | lxd-container |

@uses.config.contract_token
Scenario Outline: APT Hook do not advertises esm-apps on upgrade for interim releases
Given a `<release>` `<machine_type>` machine with ubuntu-advantage-tools installed
Expand Down

0 comments on commit 93fcfbe

Please sign in to comment.