aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/e_auth.c
blob: 00b0e5d843e7cf71cadfdb23ad2bedd8027bfa26 (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
#include "e.h"

E_API int
e_auth_begin(char *passwd)
{
   char buf[PATH_MAX], *p;
   Ecore_Exe *exe = NULL;
   int ret = 0;

   if (strlen(passwd) == 0) goto out;

   snprintf(buf, sizeof(buf), "%s/enlightenment/utils/enlightenment_ckpasswd",
            e_prefix_lib_get());

   exe = ecore_exe_pipe_run(buf, ECORE_EXE_PIPE_WRITE, NULL);
   if (ecore_exe_send(exe, passwd, strlen(passwd)) != EINA_TRUE) goto out;
   ecore_exe_close_stdin(exe);

   ret = ecore_exe_pid_get(exe);
   if (ret == -1)
     {
        ret = 0;
        goto out;
     }

   exe = NULL;
out:
   if (exe) ecore_exe_free(exe);

   /* security - null out passwd string once we are done with it */
   for (p = passwd; *p; p++) *p = 0;
   if (passwd[0] || passwd[3]) fprintf(stderr, "ACK!\n");

   return ret;
}