-
Notifications
You must be signed in to change notification settings - Fork 0
/
c.go
46 lines (42 loc) · 898 Bytes
/
c.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
/*
#define PAM_SM_AUTH
#include <security/pam_appl.h>
#include <security/pam_ext.h>
#include <string.h>
#include <stdio.h>
char *get_user(pam_handle_t *pamh) {
if (!pamh) {
return NULL;
}
int err = 0;
const char *user;
if ((err = pam_get_item(pamh, PAM_USER, (const void**)&user)) != PAM_SUCCESS) {
return NULL;
}
return strdup(user);
}
char *get_service(pam_handle_t *pamh) {
if (!pamh) {
return NULL;
}
int err = 0;
const char *service;
if ((err = pam_get_item(pamh, PAM_SERVICE, (const void**)&service)) != PAM_SUCCESS) {
return NULL;
}
return strdup(service);
}
char *get_secret(pam_handle_t *pamh) {
if (!pamh) {
return NULL;
}
int err = 0;
const char *secret;
if ((err = pam_get_authtok(pamh, PAM_AUTHTOK, (const char **)&secret, NULL)) != PAM_SUCCESS) {
return NULL;
}
return strdup(secret);
}
*/
import "C"