新的 Fedora 包管理器是否允许未经授权的安装?

信息安全 linux 特权升级 须藤 安装
2021-08-21 12:50:16

我刚刚升级到Fedora 22与之前版本最大的变化是yum包管理器现在被替换为dnf. 我注意到的一个变化是,如果您尝试执行来自尚未安装的通用软件包的命令,终端将提示您安装该软件包。例如:

[wbarlow@wbarlow-thinkpad src]$ ar
bash: ar: command not found...
Install package 'binutils' to provide command 'ar'? [N/y] y


 * Waiting in queue... 
 * Waiting in queue... 
 * Waiting for authentication... 
 * Waiting in queue... 
 * Downloading packages... 
 * Requesting data... 
 * Testing changes... 
 * Installing packages... 
Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...
       ar -M [<mri-script]
 commands:
  d            - delete file(s) from the archive
  m[ab]        - move file(s) in the archive
  p            - print file(s) found in the archive
  q[f]         - quick append file(s) to the archive
  r[ab][f][u]  - replace existing or insert new file(s) into the archive
  s            - act as ranlib
  t            - display contents of archive
  x[o]         - extract file(s) from the archive
 command specific modifiers:
  [a]          - put file(s) after [member-name]
  [b]          - put file(s) before [member-name] (same as [i])
  [D]          - use zero for timestamps and uids/gids (default)
  [U]          - use actual timestamps and uids/gids
  [N]          - use instance [count] of name
  [f]          - truncate inserted file names
  [P]          - use full path names when matching
  [o]          - preserve original dates
  [u]          - only replace files that are newer than current archive contents
 generic modifiers:
  [c]          - do not warn if the library had to be created
  [s]          - create an archive index (cf. ranlib)
  [S]          - do not build a symbol table
  [T]          - make a thin archive
  [v]          - be verbose
  [V]          - display the version number
  @<file>      - read options from <file>
  --target=BFDNAME - specify the target object format as BFDNAME
 optional:
  --plugin <p> - load the specified plugin
 emulation options: 
  No emulation specific options
ar: supported targets: elf64-x86-64 elf32-i386 elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex

在整个过程中,我从未被要求输入密码,但我必须使用提升的帐户才能运行dnf install binutils. 上面的安装和一个dnf install安装有什么区别为什么一个需要提升权限而另一个不需要?这是一个安全漏洞吗?

4个回答

我建议你尝试重现这一点。很可能,您已经有一个经过身份验证的会话,并且您的系统由于密钥环而记住了它。重新启动后立即进行测试是一种很好的方法。

aditya@20:54:20:~$ nano
bash: nano: command not found...
Install package 'nano' to provide command 'nano'? [N/y] y


 * Waiting in queue... 
 * Loading list of packages.... 
 * Downloading details about the software sources.... 
 * Loading list of packages.... 
 * Waiting in queue... 
 * Waiting for authentication... Failed to install packages: Failed to obtain authentication.

免责声明:我是 Fedora 用户和贡献者。

创建第一个用户(Fedora 安装)时,您可以选择设置一个特殊的复选框(“admin”或类似的)。如果设置,创建的用户会被一些 polkit-rules (man polkit) 赋予一些特殊的权限。

我认为这是通过简单地将用户添加到“wheel”组来完成的。因此,如果您想改变这种行为,请尝试“system-config-users”并添加/删除组“wheel”。

这个问题继续得到偶尔的访问和投票,我看到一些答案包含真实答案的一部分,所以我正在创建一个将它们拼接在一起的 wiki 答案。此后在 Unix.SE上提出并回答了类似的问题。

根据RH# 1225788,这是预期行为:

按照设计,管理员用户(在 wheel 组中)无需输入密码即可安装软件。有关背景信息,请参阅 https://pagure.io/fesco/issue/1115#comment-27002和票证中的讨论。

可以通过注释掉以下行来更改此行为/usr/share/polkit-1/rules.d/org.freedesktop.packagekit.rules

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.packagekit.package-install" &&
        subject.active == true && subject.local == true &&
        subject.isInGroup("wheel")) {
            return polkit.Result.YES;
    }
});

我遇到了同样的问题,并寻找了很长时间的解决方案。最后我解决了;解决方案是这个问题的答案Unauthorized Installations in dnf after enter a command that's not found

我不得不注释掉一些行

/usr/share/polkit-1/rules.d/org.freedesktop.packagekit.rules

一旦我这样做了,bash 就被迫在身份验证阶段显示一个对话框。