gpt4 book ai didi

authentication - 如何使用 PAM 对用户进行身份验证?

转载 作者:行者123 更新时间:2023-12-04 03:01:20 25 4
gpt4 key购买 nike

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

  • pam_start
  • 什么是struct pam_conv应该如何填写?
  • 到底是什么service_name这是什么意思?

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

    最佳答案

    这是一个例子:

    #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

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

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

    关于authentication - 如何使用 PAM 对用户进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5125245/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com