如何使用 PAM 验证用户身份?

发布于 2024-10-19 05:31:18 字数 346 浏览 1 评论 0原文

我已通读 这个页面,但我有点困惑...

  • pam_start
    • 什么是struct pam_conv以及如何填写?
    • service_name 到底是什么?它的含义是什么?

是否有使用 PAM 登录用户(或至少验证他们提供的凭据)的示例?

I've read through this page, but I'm a little confused...

  • pam_start
    • What is struct pam_conv and how should it be filled in?
    • What on earth is service_name and what does it mean?

Is there an example somewhere of using PAM to log in a user (or at least verify their provided credentials)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹淡然 2024-10-26 05:31:18

下面是一个示例:

#include <stdlib.h> // for NULL
#include <security/pam_appl.h> // for pam_ functions

// compile with 'gcc -lpam filename.c'

int main ( int argc , char * * argv )
{
    //function used to get user input
    int function_conversation ( ) { /* ToDo prompt user for input */ } ;

    const char * local_service = "Example Service" ; // name of the authentication service
    const char * local_user = "Example User" ; //Name of the user
    void * local_app_data = NULL ; // ToDo Make this valid.
    const struct pam_conv local_conversation = { function_conversation , local_app_data } ;
    pam_handle_t * local_auth_handle = NULL ; // this gets set by pam_start
    int local_status = 0 ; // result of each function call

    // local_auth_handle gets set based on the service 
    local_status = pam_start ( local_service , local_user , & local_conversation , & local_auth_handle ) ;

    int local_auth_flags = 0 ; // ToDo Are there any relevent flags?
    // Authenticate the user with the authentication handle set by pam_start
    local_status = pam_athenticate ( local_auth_handle , local_auth_flags ) ;

    // terminate transaction
    local_status = pam_end ( local_auth_handle , local_status ) ;

    return local_status ;
}

参考资料:

http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/pam_start.htm< /a>

http://www.kapet.de/kb/pam_interpose/pam_interpose.c< /a>

http://pubs.opengroup.org/onlinepubs/8329799/pam_start.htm< /a>

Here is an example:

#include <stdlib.h> // for NULL
#include <security/pam_appl.h> // for pam_ functions

// compile with 'gcc -lpam filename.c'

int main ( int argc , char * * argv )
{
    //function used to get user input
    int function_conversation ( ) { /* ToDo prompt user for input */ } ;

    const char * local_service = "Example Service" ; // name of the authentication service
    const char * local_user = "Example User" ; //Name of the user
    void * local_app_data = NULL ; // ToDo Make this valid.
    const struct pam_conv local_conversation = { function_conversation , local_app_data } ;
    pam_handle_t * local_auth_handle = NULL ; // this gets set by pam_start
    int local_status = 0 ; // result of each function call

    // local_auth_handle gets set based on the service 
    local_status = pam_start ( local_service , local_user , & local_conversation , & local_auth_handle ) ;

    int local_auth_flags = 0 ; // ToDo Are there any relevent flags?
    // Authenticate the user with the authentication handle set by pam_start
    local_status = pam_athenticate ( local_auth_handle , local_auth_flags ) ;

    // terminate transaction
    local_status = pam_end ( local_auth_handle , local_status ) ;

    return local_status ;
}

References:

http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/pam_start.htm

http://www.kapet.de/kb/pam_interpose/pam_interpose.c

http://pubs.opengroup.org/onlinepubs/8329799/pam_start.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文