他のユーザーでコマンドを実行する[閉じる]

他のユーザーでコマンドを実行する[閉じる]

intelmqというプログラムを実行する権限を持つユーザーを作成しましたintelmqctl。その後、実行apacheしたいユーザーを作成しましたapache。ファイルに次の行を追加しました。intelmqctlintelmqsudoers

Defaults:apache !requiretty
apache ALL=(intelmq) NOPASSWD: /usr/bin/intelmqctl

ただし、ユーザーとして次のコマンドを実行しようとするたびに、apache次のものが返されます。

注文する:sudo -u apache sudo -u intelmq /usr/bin/intelmqctl --type json stop abusech-ip-parser

出力:

Sorry, user apache is not allowed to execute '/bin/sudo -u intelmq /usr/bin/intelmqctl --type json stop abusech-ip-parser' as apache on localhost.localdomain.

CentOS 7を使用しています。

以下は、インストールするために実行した手順intelmqctlと問題自体のより良い説明です。おそらくインストールプロセス中に失敗した可能性があります。https://github.com/certtools/intelmq/issues/981

sudo -iu apacheasを実行しようとするとrootuserに変更され、apacheコマンドを実行すると機能sudo -u intelmq /usr/bin/intelmqctlし、実行するすべてのオプションが表示されますintelmqctl

ただし、ユーザーとしてコマンドを実行すると、次のものが返されますsudo -iu apacheapacheSorry, user apache is not allowed to execute '/bin/bash' as apache on localhost.localdomain.

ベストアンサー1

バイナリに setuid 権限を追加し、所有権を intelmq に変更できます。

chmod u+s /usr/bin/intelmqctl
chown intelmq /usr/bin/intelmqctl

その後、intelmqのプロセス所有権を使用してこの実行可能ファイルを実行できます。

おすすめ記事