誰かがこれについて教えてもらえますか.../etc/pam.dのログインモジュールに似たpamモジュールを作成したい
3 に答える
ログイン中に pam ベースの顔認証を探している場合は、それを行うモジュールを作成し、それを /etc/pam.d/login のログイン構成ファイルにプラグインする必要があります。
これに直接入る前に、フロー、PAM の動作、および構成ファイルを理解するための簡単なモジュールを作成することをお勧めします。たとえば、sshd pam 構成ファイルで遊んで、使用可能なサンプル pam モジュールをプラグインしてみてください。これらの記事は非常に役に立ちました。
http://aplawrence.com/Basics/understandingpam.html
https://www.packtpub.com/article/development-with-pluggable-authentication-modules-pam
参考までに: Rohan Anil は、code.google.com/p/pam-face-authentication/ でホストされている opensuse の下で GSOC08 中に pam-face-authentication を開発しました。
答えをここに書くには長すぎるので、私の PAM チュートリアルをリンクします: Linux PAM モジュールを書くおよび Linux PAM 構成チュートリアル
モジュールの作成を開始する前に、構成チュートリアルを最初に読むことをお勧めします。構成チュートリアルでは、モジュールの機能を学習できます。
要約すると、モジュールは、アプリケーションが認証を必要とするときに PAM によってロードされる共有オブジェクトです。アプリケーションが「ステージ」(認証、アカウント、セッション、パスワード) をトリガーするたびに、対応する関数がモジュールで呼び出されます。したがって、モジュールは次の機能を提供する必要があります。
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *handle, int flags, int argc, const char **argv){
/* In this function we will ask the username and the password with pam_get_user()
* and pam_get_authtok(). We will then decide if the user is authenticated */
}
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) {
/* In this function we check that the user is allowed in the system. We already know
* that he's authenticated, but we could apply restrictions based on time of the day,
* resources in the system etc. */
}
PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv) {
/* We could have many more information of the user other then password and username.
* These are the credentials. For example, a kerberos ticket. Here we establish those
* and make them visible to the application */
}
PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
/* When the application wants to open a session, this function is called. Here we should
* build the user environment (setting environment variables, mounting directories etc) */
}
PAM_EXTERN int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) {
/* Here we destroy the environment we have created above */
}
PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv){
/* This function is called to change the authentication token. Here we should,
* for example, change the user password with the new password */
}
この関数では、PAM 関数を使用して、アプリケーションからユーザー名とパスワードを取得します。これは、アプリケーションで定義する必要がある会話関数を通じて行われます (このチュートリアルを参照してください)。すべての関数の最後に、結果を決定する PAM リターン コードを返さなければなりません (PAM エラー コードについては、これと一般的なモジュール作成者のドキュメントを参照してください)。
pam モジュールを作成するための最良のリソースの 1 つは、ドキュメント自体です。
http://www.linux-pam.org/Linux-PAM-html/Linux-PAM_MWG.html
ただし、最初に PAM がどのように機能するかを確実に理解するという点で@GGに同意します。