Debian パッケージで setuid ビットとファイル所有者を設定できません。

Debian パッケージで setuid ビットとファイル所有者を設定できません。

私は次の構造を持っています:

./inst/opt/test/ls/bin/ls:簡単のためにバイナリのコピーです。

./inst/DEBIAN/changelog:

test (1) unstable; urgency=low

  * test 1

 -- test <[email protected]> April 28, 2020

./inst/DEBIAN/control:

Package: test
Version: 1
Architecture: amd64
Section: unknown
Priority: optional
Maintainer: test <[email protected]>
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.4
Homepage: https://www.test.com/
Depends: libappindicator1
Description: Test

./inst/DEBIAN/compat:

9

今まではそんなに良くなった。

私が達成したいのは、インストール後にsetuidビットをls独自に設定して設定することですroot。これをやろうとしている私の多くの試みの1つは次のとおりです。

./inst/DEBIAN/rules:

#!/usr/bin/make -f

%:
        dh $@

override_dh_fixperms:
        dh_fixperms --exclude ls
        find . -name ls -exec chmod +s {} \;

しかし、このファイルがあるかどうかにかかわらず、結果はまったく変わりません。

次のコマンドを使用して deb パッケージをビルドします。

dpkg-deb --build ~/test/inst/ ~/test/

明らかに何か大きなものを逃した。誰でも私に何を教えてもらえますか?

これはpostinst私にとってオプションではありません。

ベストアンサー1

バイナリパッケージを直接ビルドすると、debian/rulesソースパッケージからビルドしたときにのみ処理されます。

setuidビットを含むファイルを使用してバイナリパッケージをビルドするには(chmod +s固定ビットではなくsetuidビットを設定する)、実行する前にファイルシステムで設定しますdpkg-deb

chmod 4755 inst/opt/test/ls

その後、ファイルがルート所有として保存されていることを確認するには、次の手順をdpkg-deb実行しますfakeroot

fakeroot dpkg-deb -b ~/test/inst ~/test

dpkg-deb -c生成されたパッケージの内容を調べるには表示する必要があります。

-rwsr-xr-x root/root ... ./opt/test/ls

おすすめ記事