47 int passwordDialog(const char *msg, char *buf, size_t length, void *this0)
48 {
49 PyObject *result;
50 PyObject *arglist;
51 CryptSetupObject *self = (CryptSetupObject *)this0;
52 char *res = NULL;
53 int ok;
54
55 if(self->passwordDialogCB){
56 arglist = Py_BuildValue("(s)", msg);
when treating unknown void * from pycryptsetup/cryptsetup.c:48 as non-NULL
when treating unknown struct PyObject * from pycryptsetup/cryptsetup.c:56 as non-NULL
taking True path
57 if(!arglist) return 0;
when Py_BuildValue() succeeds
58 result = PyEval_CallObject(self->passwordDialogCB, arglist);
taking False path
59 Py_DECREF(arglist);
when treating unknown struct PyObject * from pycryptsetup/cryptsetup.c:59 as non-NULL
when PyEval_CallObjectWithKeywords() succeeds
new ref from call to PyEval_CallObjectWithKeywords allocated at: result = PyEval_CallObject(self->passwordDialogCB, arglist);
ob_refcnt is now refs: 1 + N where N >= 0
60
when taking True path
61 if (result == NULL) return 0;
62
taking False path
63 ok = PyArg_Parse(result, "z", &res);
64 fprintf(stderr, "Parsing passw from callback result [%p]: %d %s [%p]\n", result, ok, res, res);
when PyArg_Parse() fails
65
66 if(!ok){
67 return 0;
taking True path
68 }
69
70 // copy the password
71 strncpy(buf, res, length-1);
72 Py_DECREF(result);
73 fprintf(stderr, "Passphrase received: %s [%d]\n", buf, strlen(buf));
74
75 return strlen(buf);
76 }
77 else return 0;
78 }
79