blob: 23d23fb949261a8e28fa1b5ad8bd31f9f898b97c (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* ISC license. */
#include <string.h>
#include <stdlib.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/strerr.h>
#include <skalibs/stralloc.h>
#include <pamela/pam.h>
#include <pamela/compat.h>
/*
static void freeres (struct pam_response *res, unsigned int n)
{
while (n--) free(res[n].resp) ;
free(res) ;
}
*/
static int getsa (int h, char const *msg, stralloc *sa)
{
/* TODO: complete this */
return 0 ;
}
int misc_conv (int n, struct pam_message const **msg, struct pam_response **resp, void *aux)
{
stralloc sa = STRALLOC_ZERO ;
struct pam_response *res ;
if (n <= 0) return PAM_CONV_ERR ;
res = malloc(n * sizeof(struct pam_response)) ;
if (!res) return PAM_CONV_ERR ;
for (unsigned int i = 0 ; i < n ; i++)
{
switch (msg[i]->msg_style)
{
case PAM_PROMPT_ECHO_OFF :
if (getsa(0, msg[i]->msg, &sa)) goto fail ;
break ;
case PAM_PROMPT_ECHO_ON :
if (getsa(1, msg[i]->msg, &sa)) goto fail ;
break ;
case PAM_ERROR_MSG :
strerr_warnw1x(msg[i]->msg) ;
break ;
case PAM_TEXT_INFO :
{
size_t len = strlen(msg[i]->msg) ;
if (allwrite(1, msg[i]->msg, len) < len) goto fail ;
break ;
}
case PAM_BINARY_PROMPT : /* TODO */
break ;
}
}
return 0 ;
fail: /* TODO: check */
return -1 ;
}
|