[PATCH] wbinfo: Dump user info for pam-logon -v
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Jun 9 14:10:43 MDT 2015
Hi!
A patch from my attic: A customer using wbinfo for checking
creds in a custom application wanted to know the user's real
name at login time. This makes wbinfo --pam-logon -v print
what we know about the user from libwbclient.
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 8b8f40ec22263b38f59d4e4e9f5bc778f253bf0b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 8 Apr 2015 11:17:51 +0200
Subject: [PATCH] wbinfo: Dump user info for pam-logon -v
Signed-off-by: Volker Lendecke <vl at samba.org>
---
nsswitch/wbinfo.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 3 deletions(-)
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index bde0d43..f45d7b5 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -1778,10 +1778,11 @@ static bool wbinfo_auth_crap(char *username, bool use_ntlmv2, bool use_lanman)
/* Authenticate a user with a plaintext password */
-static bool wbinfo_pam_logon(char *username)
+static bool wbinfo_pam_logon(char *username, bool verbose)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcLogonUserParams params;
+ struct wbcLogonUserInfo *info = NULL;
struct wbcAuthErrorInfo *error = NULL;
char *s = NULL;
char *p = NULL;
@@ -1826,7 +1827,45 @@ static bool wbinfo_pam_logon(char *username)
return false;
}
- wbc_status = wbcLogonUser(¶ms, NULL, &error, NULL);
+ wbc_status = wbcLogonUser(¶ms, &info, &error, NULL);
+
+ if (verbose && (info != NULL)) {
+ struct wbcAuthUserInfo *i = info->info;
+
+ if (i->account_name != NULL) {
+ d_printf("account_name: %s\n", i->account_name);
+ }
+ if (i->user_principal != NULL) {
+ d_printf("user_principal: %s\n", i->user_principal);
+ }
+ if (i->full_name != NULL) {
+ d_printf("full_name: %s\n", i->full_name);
+ }
+ if (i->domain_name != NULL) {
+ d_printf("domain_name: %s\n", i->domain_name);
+ }
+ if (i->dns_domain_name != NULL) {
+ d_printf("dns_domain_name: %s\n", i->dns_domain_name);
+ }
+ if (i->logon_server != NULL) {
+ d_printf("logon_server: %s\n", i->logon_server);
+ }
+ if (i->logon_script != NULL) {
+ d_printf("logon_script: %s\n", i->logon_script);
+ }
+ if (i->profile_path != NULL) {
+ d_printf("profile_path: %s\n", i->profile_path);
+ }
+ if (i->home_directory != NULL) {
+ d_printf("home_directory: %s\n", i->home_directory);
+ }
+ if (i->home_drive != NULL) {
+ d_printf("home_drive: %s\n", i->home_drive);
+ }
+
+ wbcFreeMemory(info);
+ info = NULL;
+ }
wbcFreeMemory(params.blobs);
@@ -2566,7 +2605,7 @@ int main(int argc, const char **argv, char **envp)
break;
}
case OPT_PAM_LOGON:
- if (!wbinfo_pam_logon(string_arg)) {
+ if (!wbinfo_pam_logon(string_arg, verbose)) {
d_fprintf(stderr, "pam_logon failed for %s\n",
string_arg);
goto done;
--
1.7.9.5
More information about the samba-technical
mailing list