为什么apt install后的文件权限和dpkg -c不一样

为什么apt install后的文件权限和dpkg -c不一样

我只是好奇是什么决定了所安装文件的文件权限apt

运行apt download transmission然后dpkg -c transmission-daemon_2.94-2ubuntu3_amd64.deb显示所有文件属于root

drwxr-xr-x root/root         0 2020-03-26 01:56 ./
drwxr-xr-x root/root         0 2020-03-26 01:56 ./etc/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./etc/default/
-rw-r--r-- root/root       562 2019-01-02 12:50 ./etc/default/transmission-daemon
drwxr-xr-x root/root         0 2020-03-26 01:56 ./etc/init/
-rw-r--r-- root/root       654 2019-01-02 12:50 ./etc/init/transmission-daemon.conf
drwxr-xr-x root/root         0 2020-03-26 01:56 ./etc/init.d/
-rwxr-xr-x root/root      1975 2019-01-02 12:50 ./etc/init.d/transmission-daemon
drwxr-xr-x root/root         0 2020-03-26 01:56 ./etc/transmission-daemon/
-rw-r--r-- root/root       303 2019-01-02 12:50 ./etc/transmission-daemon/README.json
-rw-r--r-- root/root       523 2019-01-02 12:50 ./etc/transmission-daemon/settings.json
drwxr-xr-x root/root         0 2020-03-26 01:56 ./lib/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./lib/systemd/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./lib/systemd/system/
-rw-r--r-- root/root       284 2020-03-26 01:56 ./lib/systemd/system/transmission-daemon.service
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/bin/
-rwxr-xr-x root/root    543528 2020-03-26 01:56 ./usr/bin/transmission-daemon
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/share/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/share/bug/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/share/bug/transmission-daemon/
-rw-r--r-- root/root        95 2019-01-02 12:50 ./usr/share/bug/transmission-daemon/presubj
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/share/doc/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/share/man/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./usr/share/man/man1/
-rw-r--r-- root/root      1992 2020-03-26 01:56 ./usr/share/man/man1/transmission-daemon.1.gz
drwxr-xr-x root/root         0 2020-03-26 01:56 ./var/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./var/lib/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./var/lib/transmission-daemon/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./var/lib/transmission-daemon/.config/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./var/lib/transmission-daemon/.config/transmission-daemon/
drwxr-xr-x root/root         0 2020-03-26 01:56 ./var/lib/transmission-daemon/downloads/
lrwxrwxrwx root/root         0 2020-03-26 01:56 ./usr/share/doc/transmission-daemon -> transmission-common
lrwxrwxrwx root/root         0 2020-03-26 01:56 ./var/lib/transmission-daemon/.config/transmission-daemon/settings.json -> /etc/transmission-daemon/settings.json
lrwxrwxrwx root/root         0 2020-03-26 01:56 ./var/lib/transmission-daemon/info -> .config/transmission-daemon

但随后运行ls -lha /etc/transmission-daemon显示apt install transmission-daemon有些文件不属于 root:

total 16K
drwxrwsr-x   2 root                debian-transmission 4.0K Jun 20 19:10 .
drwxr-xr-x 106 root                root                4.0K Jun 20 19:10 ..
-rw-r--r--   1 root                root                 303 Jan  2  2019 README.json
-rw-rw----   1 debian-transmission debian-transmission  523 Jan  2  2019 settings.json

答案1

为了查看 transmission-daemon 使用的 posi-install 脚本,请运行:
apt download transmission-daemon

传输-daemon_3.00-2ubuntu2_amd64.deb将被下载。
(您的版本号可能略有不同)

  • 现在使用你最喜欢的存档提取器提取 .deb 包,或者右键单击 deb 文件,然后摘录自此处使用您的文件管理器。

  • 在解压的目录中,您应该看到:“control.tar.zst”、“data.tar.zst”、“debian-binary”

  • 现在提取控制文件

  • 您应该查看脚本。(我们对preinst&感兴趣postinst

  • 请随意看一下preinst脚本。(只有几行)

  • 完成后,打开postinst脚本并查看该chperms()函数及其用法。

相关内容