[英]How can I query sssd via PAM in a C program?
I'm playing around with PAM authentication using a small C program:我正在使用一个小的 C 程序来处理 PAM 身份验证:
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <stdlib.h>
int main()
{
pam_handle_t* pamh;
struct pam_conv pamc;
pamc.conv = &misc_conv;
pamc.appdata_ptr = NULL;
pam_start("su", getenv("USER"), &pamc, &pamh);
if (pam_authenticate(pamh, 0) != PAM_SUCCESS) {
fprintf(stderr, "Auth failed!\n");
} else {
fprintf(stderr, "Auth succeeded!\n");
}
pam_end(pamh, 0);
return 0;
}
Two kinds of users have access on my system, those created in the local shadow db, and those who traverse a configured sssd
process to authenticate with LDAP against a remote active directory.有两种用户可以访问我的系统,一种是在本地影子数据库中创建的用户, sssd
一种是遍历配置的sssd
进程以针对远程活动目录使用 LDAP进行身份验证的用户。
I've configured sssd
to plug into PAM, which I'm able to confirm via a number of logs on the system and debug output from sssd
, but the above program only works for local users.我已将sssd
配置为插入 PAM,我可以通过系统上的大量日志进行确认并调试sssd
输出,但上述程序仅适用于本地用户。 Users that would require authentication against sss
get a PAM_AUTH_ERROR
back from pam_authenticate
whether they enter the correct credentials or not.需要针对sss
进行身份验证的用户会从pam_authenticate
获得PAM_AUTH_ERROR
,无论他们是否输入了正确的凭据。
I'm surely missing something obvious.我肯定错过了一些明显的东西。 How can I access sss
via PAM in a C program?如何在 C 程序中通过 PAM 访问sss
?
According to根据
pam_start("su", getenv("USER"), &pamc, &pamh);
^^^^
you are using the su
PAM service.您正在使用su
PAM 服务。
On a typical default configuration, the su
PAM stack might not be configured to use the pam_sss
responder.在典型的默认配置中, su
PAM 堆栈可能未配置为使用pam_sss
响应程序。
Possible solutions:可能的解决方案:
If using su
is appropriate for your application, update /etc/pam.d/su
to use pam_sss
.如果使用su
适合您的应用程序,请更新/etc/pam.d/su
以使用pam_sss
。
Use a different PAM service that is already configured to use pam_sss
;使用已配置为使用pam_sss
的其他 PAM 服务; login
for example.例如login
。
Create a dedicated PAM service for your app in /etc/pam.d/<service-name>
在/etc/pam.d/<service-name>
为您的应用程序创建专用的 PAM 服务
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.