大网数据广告活动
服务器运维问答

Unattended-Upgrades override Allowed-Origins

· 52CE 我爱测

I am trying to set the Unattended-Upgrade::Allowed-Origins so that it only is allowed for security updates. I would like to do this in a later config in the apt.conf.d leaving the default 50unattended-upgrades config as the defau…

问题原文

原帖链接 · patrickdavey · CC BY-SA 4.0

I am trying to set the Unattended-Upgrade::Allowed-Origins so that it only is allowed for security updates. I would like to do this in a later config in the apt.conf.d leaving the default 50unattended-upgrades config as the default and just overriding.

In my 99-unattended-upgrades I am setting the following:

// Only allow security origin
Unattended-Upgrade::Allowed-Origins {
  "${distro_id}:${distro_codename}-security";
};

However, this seems to be merged with the existing config (rather than just nuking it completely) as when I do an apt-config dump I can see the default settings in there.

I also tried setting it with the following:

Unattended-Upgrade::Allowed-Origins "${distro_id}:${distro_codename}-security";

Also did not work.

I could simply comment out the lines in 50unattended-updates, but, I'd really like to leave the original files pristine if I can.

已采纳解答

原帖链接 · silmaril · CC BY-SA 4.0

After a bit of digging in apt source code and then in apt-conf manual page it turns out that there is a way

[...]#clear is used to erase a part of the configuration tree. The specified element and all its descendants are erased. (Note that these lines also need to end with a semicolon.)

The #clear command is the only way to delete a list or a complete scope. Reopening a scope (or using the syntax described below with an appended ::) will not override previously written entries. Options can only be overridden by addressing a new value to them - lists and scopes can't be overridden, only cleared.

So this would get you what you want:

#clear Unattended-Upgrade::Allowed-Origins;
// Only allow security origin
Unattended-Upgrade::Allowed-Origins {
  "${distro_id}:${distro_codename}-security";
};

https://manpages.debian.org/testing/apt/apt.conf.5.en.html

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-08-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。