-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrap_kpass.c
52 lines (36 loc) · 1.09 KB
/
wrap_kpass.c
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
#include <Python.h>
#include <stdlib.h>
#include "kpass.h"
static char rcsid[] = "$Id: wrap_kpass.c,v 1.2 2007/04/10 03:02:00 shuque Exp $";
static PyObject *KpassError;
static PyObject *
wrap_kpass(PyObject *self, PyObject *args) {
char *username, *password, *service, *host, *kt_pathname;
int rc;
if ( !PyArg_ParseTuple(args, "ssszz",
&username, &password, &service, &host,
&kt_pathname) )
return NULL;
rc = kpass(username, password, service, host, kt_pathname);
if (rc == -1) {
PyErr_SetString(KpassError, obtain_errormsg());
return NULL;
}
return Py_BuildValue("i", rc);
}
static struct PyMethodDef kpass_methods[] = {
{"kpass", wrap_kpass, METH_VARARGS, "Kerberos 5 password verification"},
{NULL, NULL, 0, NULL}
};
/*
* Initialization: called by Python on first import
*/
PyMODINIT_FUNC
init_kpass() {
PyObject *m;
m = Py_InitModule("_kpass", kpass_methods);
KpassError = PyErr_NewException("kpass.KpassError",
PyExc_Exception, NULL);
Py_INCREF(KpassError);
PyModule_AddObject(m, "KpassError", KpassError);
}