blob: e48bc7862c002c78680328e6fd163d27ec2e3b4d (
plain)
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
|
#include <bsd/readpassphrase.h>
#include "pam.h"
GMainLoop *loop;
void ready_callback(AstalAuthPam *pam,
GAsyncResult *res,
gpointer user_data) {
GError *error = NULL;
astal_auth_pam_authenticate_finish(res, &error);
if (error == NULL) {
g_print("success\n");
} else {
g_print("failure: %s\n", error->message);
g_error_free(error);
}
g_main_loop_quit(loop);
}
int main(void) {
GMainContext *loopctx = NULL;
loop = g_main_loop_new(loopctx, FALSE);
gchar *passbuf = calloc(1024, sizeof(gchar));
readpassphrase("Password: ", passbuf, 1024, RPP_ECHO_OFF);
astal_auth_pam_authenticate(passbuf,
(GAsyncReadyCallback) ready_callback,
NULL
);
g_free(passbuf);
g_main_loop_run(loop);
exit(EXIT_SUCCESS);
}
|