Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C または C++ では、ファイルのファイル システム権限を変更する場合、標準ライブラリ関数 (chmod) を使用できます。これは、UNIX プロンプトから実行できるユーティリティに非常に似ています。
ファイルの selinux コンテキストを設定する同様に簡単な方法はありますか? その場合、どのライブラリにリンクする必要があり、どのヘッダー ファイルを含める必要がありますか? コマンド ライン ユーティリティ chcon と同じように簡単に使用できるものが理想的です。
#include <selinux/selinux.h> typedef char *security_context_t; int setfilecon(const char *path, security_context_t con);
おそらくあなたが探している機能です。libselinux にリンクする必要があります。