1992-08-12 11:57:12 -03:00
|
|
|
/***********************************************************
|
|
|
|
Written by:
|
2010-05-09 12:52:27 -03:00
|
|
|
Fred Gansevles <Fred.Gansevles@cs.utwente.nl>
|
|
|
|
B&O group,
|
|
|
|
Faculteit der Informatica,
|
|
|
|
Universiteit Twente,
|
|
|
|
Enschede,
|
|
|
|
the Netherlands.
|
1992-08-12 11:57:12 -03:00
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/* NIS module implementation */
|
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
#include "Python.h"
|
1992-08-12 11:57:12 -03:00
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <rpcsvc/yp_prot.h>
|
1996-08-08 16:11:41 -03:00
|
|
|
#include <rpcsvc/ypclnt.h>
|
1992-08-12 11:57:12 -03:00
|
|
|
|
1996-12-09 14:46:28 -04:00
|
|
|
#ifdef __sgi
|
|
|
|
/* This is missing from rpcsvc/ypclnt.h */
|
2000-07-22 20:57:55 -03:00
|
|
|
extern int yp_get_default_domain(char **);
|
1996-12-09 14:46:28 -04:00
|
|
|
#endif
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
PyDoc_STRVAR(get_default_domain__doc__,
|
2006-02-04 15:12:37 -04:00
|
|
|
"get_default_domain() -> str\n\
|
|
|
|
Corresponds to the C library yp_get_default_domain() call, returning\n\
|
|
|
|
the default NIS domain.\n");
|
|
|
|
|
|
|
|
PyDoc_STRVAR(match__doc__,
|
|
|
|
"match(key, map, domain = defaultdomain)\n\
|
|
|
|
Corresponds to the C library yp_match() call, returning the value of\n\
|
|
|
|
key in the given map. Optionally domain can be specified but it\n\
|
|
|
|
defaults to the system default domain.\n");
|
|
|
|
|
|
|
|
PyDoc_STRVAR(cat__doc__,
|
|
|
|
"cat(map, domain = defaultdomain)\n\
|
|
|
|
Returns the entire map as a dictionary. Optionally domain can be\n\
|
|
|
|
specified but it defaults to the system default domain.\n");
|
|
|
|
|
|
|
|
PyDoc_STRVAR(maps__doc__,
|
|
|
|
"maps(domain = defaultdomain)\n\
|
|
|
|
Returns an array of all available NIS maps within a domain. If domain\n\
|
|
|
|
is not specified it defaults to the system default domain.\n");
|
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
static PyObject *NisError;
|
1992-08-12 12:26:16 -03:00
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
static PyObject *
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_error (int err)
|
1992-08-12 12:26:16 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyErr_SetString(NisError, yperr_string(err));
|
|
|
|
return NULL;
|
1992-08-12 12:26:16 -03:00
|
|
|
}
|
|
|
|
|
1992-08-12 11:57:12 -03:00
|
|
|
static struct nis_map {
|
2010-05-09 12:52:27 -03:00
|
|
|
char *alias;
|
|
|
|
char *map;
|
|
|
|
int fix;
|
1992-08-12 11:57:12 -03:00
|
|
|
} aliases [] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
{"passwd", "passwd.byname", 0},
|
|
|
|
{"group", "group.byname", 0},
|
|
|
|
{"networks", "networks.byaddr", 0},
|
|
|
|
{"hosts", "hosts.byname", 0},
|
|
|
|
{"protocols", "protocols.bynumber", 0},
|
|
|
|
{"services", "services.byname", 0},
|
|
|
|
{"aliases", "mail.aliases", 1}, /* created with 'makedbm -a' */
|
|
|
|
{"ethers", "ethers.byname", 0},
|
|
|
|
{0L, 0L, 0}
|
1992-08-12 11:57:12 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static char *
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_mapname (char *map, int *pfix)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
*pfix = 0;
|
|
|
|
for (i=0; aliases[i].alias != 0L; i++) {
|
|
|
|
if (!strcmp (aliases[i].alias, map)) {
|
|
|
|
*pfix = aliases[i].fix;
|
|
|
|
return aliases[i].map;
|
|
|
|
}
|
|
|
|
if (!strcmp (aliases[i].map, map)) {
|
|
|
|
*pfix = aliases[i].fix;
|
|
|
|
return aliases[i].map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return map;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
2009-07-07 03:51:26 -03:00
|
|
|
#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
2004-07-09 21:57:37 -03:00
|
|
|
typedef int (*foreachfunc)(unsigned long, char *, int, char *, int, void *);
|
|
|
|
#else
|
2000-07-09 00:09:57 -03:00
|
|
|
typedef int (*foreachfunc)(int, char *, int, char *, int, char *);
|
2004-07-09 21:57:37 -03:00
|
|
|
#endif
|
1994-08-01 08:34:53 -03:00
|
|
|
|
2000-02-29 11:52:40 -04:00
|
|
|
struct ypcallback_data {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *dict;
|
|
|
|
int fix;
|
|
|
|
PyThreadState *state;
|
2000-02-29 11:52:40 -04:00
|
|
|
};
|
|
|
|
|
1992-08-12 11:57:12 -03:00
|
|
|
static int
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
|
|
|
|
int invallen, struct ypcallback_data *indata)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (instatus == YP_TRUE) {
|
|
|
|
PyObject *key;
|
|
|
|
PyObject *val;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
PyEval_RestoreThread(indata->state);
|
|
|
|
if (indata->fix) {
|
|
|
|
if (inkeylen > 0 && inkey[inkeylen-1] == '\0')
|
|
|
|
inkeylen--;
|
|
|
|
if (invallen > 0 && inval[invallen-1] == '\0')
|
|
|
|
invallen--;
|
|
|
|
}
|
2010-08-19 06:11:51 -03:00
|
|
|
key = PyUnicode_DecodeFSDefaultAndSize(inkey, inkeylen);
|
|
|
|
val = PyUnicode_DecodeFSDefaultAndSize(inval, invallen);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (key == NULL || val == NULL) {
|
|
|
|
/* XXX error -- don't know how to handle */
|
|
|
|
PyErr_Clear();
|
|
|
|
Py_XDECREF(key);
|
|
|
|
Py_XDECREF(val);
|
2010-08-18 13:12:23 -03:00
|
|
|
indata->state = PyEval_SaveThread();
|
2010-05-09 12:52:27 -03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
err = PyDict_SetItem(indata->dict, key, val);
|
|
|
|
Py_DECREF(key);
|
|
|
|
Py_DECREF(val);
|
|
|
|
if (err != 0)
|
|
|
|
PyErr_Clear();
|
|
|
|
indata->state = PyEval_SaveThread();
|
|
|
|
if (err != 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
static PyObject *
|
2006-02-04 15:12:37 -04:00
|
|
|
nis_get_default_domain (PyObject *self)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
char *domain;
|
|
|
|
int err;
|
|
|
|
PyObject *res;
|
2006-02-04 15:12:37 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
if ((err = yp_get_default_domain(&domain)) != 0)
|
|
|
|
return nis_error(err);
|
2006-02-04 15:12:37 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
res = PyUnicode_FromStringAndSize (domain, strlen(domain));
|
|
|
|
return res;
|
2006-02-04 15:12:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
nis_match (PyObject *self, PyObject *args, PyObject *kwdict)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
char *match;
|
|
|
|
char *domain = NULL;
|
2010-08-19 06:11:51 -03:00
|
|
|
Py_ssize_t keylen;
|
|
|
|
int len;
|
2010-05-09 12:52:27 -03:00
|
|
|
char *key, *map;
|
|
|
|
int err;
|
2010-08-19 06:11:51 -03:00
|
|
|
PyObject *ukey, *bkey, *res;
|
2010-05-09 12:52:27 -03:00
|
|
|
int fix;
|
|
|
|
static char *kwlist[] = {"key", "map", "domain", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwdict,
|
2010-08-19 06:11:51 -03:00
|
|
|
"Us|s:match", kwlist,
|
|
|
|
&ukey, &map, &domain))
|
|
|
|
return NULL;
|
|
|
|
if ((bkey = PyUnicode_EncodeFSDefault(ukey)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
if (PyBytes_AsStringAndSize(bkey, &key, &keylen) == -1) {
|
|
|
|
Py_DECREF(bkey);
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2010-08-19 06:11:51 -03:00
|
|
|
}
|
|
|
|
if (!domain && ((err = yp_get_default_domain(&domain)) != 0)) {
|
|
|
|
Py_DECREF(bkey);
|
2010-05-09 12:52:27 -03:00
|
|
|
return nis_error(err);
|
2010-08-19 06:11:51 -03:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
map = nis_mapname (map, &fix);
|
|
|
|
if (fix)
|
|
|
|
keylen++;
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
err = yp_match (domain, map, key, keylen, &match, &len);
|
|
|
|
Py_END_ALLOW_THREADS
|
2010-08-19 06:11:51 -03:00
|
|
|
Py_DECREF(bkey);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (fix)
|
|
|
|
len--;
|
|
|
|
if (err != 0)
|
|
|
|
return nis_error(err);
|
2010-08-19 06:11:51 -03:00
|
|
|
res = PyUnicode_DecodeFSDefaultAndSize(match, len);
|
2010-05-09 12:52:27 -03:00
|
|
|
free (match);
|
|
|
|
return res;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
static PyObject *
|
2006-02-04 15:12:37 -04:00
|
|
|
nis_cat (PyObject *self, PyObject *args, PyObject *kwdict)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
char *domain = NULL;
|
|
|
|
char *map;
|
|
|
|
struct ypall_callback cb;
|
|
|
|
struct ypcallback_data data;
|
|
|
|
PyObject *dict;
|
|
|
|
int err;
|
|
|
|
static char *kwlist[] = {"map", "domain", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "s|s:cat",
|
|
|
|
kwlist, &map, &domain))
|
|
|
|
return NULL;
|
|
|
|
if (!domain && ((err = yp_get_default_domain(&domain)) != 0))
|
|
|
|
return nis_error(err);
|
|
|
|
dict = PyDict_New ();
|
|
|
|
if (dict == NULL)
|
|
|
|
return NULL;
|
|
|
|
cb.foreach = (foreachfunc)nis_foreach;
|
|
|
|
data.dict = dict;
|
|
|
|
map = nis_mapname (map, &data.fix);
|
|
|
|
cb.data = (char *)&data;
|
|
|
|
data.state = PyEval_SaveThread();
|
|
|
|
err = yp_all (domain, map, &cb);
|
|
|
|
PyEval_RestoreThread(data.state);
|
|
|
|
if (err != 0) {
|
|
|
|
Py_DECREF(dict);
|
|
|
|
return nis_error(err);
|
|
|
|
}
|
|
|
|
return dict;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
1994-08-01 08:34:53 -03:00
|
|
|
/* These should be u_long on Sun h/w but not on 64-bit h/w.
|
|
|
|
This is not portable to machines with 16-bit ints and no prototypes */
|
|
|
|
#ifndef YPPROC_MAPLIST
|
2010-05-09 12:52:27 -03:00
|
|
|
#define YPPROC_MAPLIST 11
|
1994-08-01 08:34:53 -03:00
|
|
|
#endif
|
|
|
|
#ifndef YPPROG
|
2010-05-09 12:52:27 -03:00
|
|
|
#define YPPROG 100004
|
1994-08-01 08:34:53 -03:00
|
|
|
#endif
|
|
|
|
#ifndef YPVERS
|
2010-05-09 12:52:27 -03:00
|
|
|
#define YPVERS 2
|
1994-08-01 08:34:53 -03:00
|
|
|
#endif
|
1992-08-12 11:57:12 -03:00
|
|
|
|
|
|
|
typedef char *domainname;
|
|
|
|
typedef char *mapname;
|
|
|
|
|
|
|
|
enum nisstat {
|
2010-05-09 12:52:27 -03:00
|
|
|
NIS_TRUE = 1,
|
|
|
|
NIS_NOMORE = 2,
|
|
|
|
NIS_FALSE = 0,
|
|
|
|
NIS_NOMAP = -1,
|
|
|
|
NIS_NODOM = -2,
|
|
|
|
NIS_NOKEY = -3,
|
|
|
|
NIS_BADOP = -4,
|
|
|
|
NIS_BADDB = -5,
|
|
|
|
NIS_YPERR = -6,
|
|
|
|
NIS_BADARGS = -7,
|
|
|
|
NIS_VERS = -8
|
1992-08-12 11:57:12 -03:00
|
|
|
};
|
|
|
|
typedef enum nisstat nisstat;
|
|
|
|
|
|
|
|
struct nismaplist {
|
2010-05-09 12:52:27 -03:00
|
|
|
mapname map;
|
|
|
|
struct nismaplist *next;
|
1992-08-12 11:57:12 -03:00
|
|
|
};
|
|
|
|
typedef struct nismaplist nismaplist;
|
|
|
|
|
|
|
|
struct nisresp_maplist {
|
2010-05-09 12:52:27 -03:00
|
|
|
nisstat stat;
|
|
|
|
nismaplist *maps;
|
1992-08-12 11:57:12 -03:00
|
|
|
};
|
|
|
|
typedef struct nisresp_maplist nisresp_maplist;
|
|
|
|
|
|
|
|
static struct timeval TIMEOUT = { 25, 0 };
|
|
|
|
|
|
|
|
static
|
|
|
|
bool_t
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_xdr_domainname(XDR *xdrs, domainname *objp)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!xdr_string(xdrs, objp, YPMAXDOMAIN)) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
bool_t
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_xdr_mapname(XDR *xdrs, mapname *objp)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!xdr_string(xdrs, objp, YPMAXMAP)) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
bool_t
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_xdr_ypmaplist(XDR *xdrs, nismaplist *objp)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!nis_xdr_mapname(xdrs, &objp->map)) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
if (!xdr_pointer(xdrs, (char **)&objp->next,
|
|
|
|
sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist))
|
|
|
|
{
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
bool_t
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_xdr_ypstat(XDR *xdrs, nisstat *objp)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!xdr_enum(xdrs, (enum_t *)objp)) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
bool_t
|
2000-07-10 10:12:27 -03:00
|
|
|
nis_xdr_ypresp_maplist(XDR *xdrs, nisresp_maplist *objp)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!nis_xdr_ypstat(xdrs, &objp->stat)) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
if (!xdr_pointer(xdrs, (char **)&objp->maps,
|
|
|
|
sizeof(nismaplist), (xdrproc_t)nis_xdr_ypmaplist))
|
|
|
|
{
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
nisresp_maplist *
|
2000-07-10 10:12:27 -03:00
|
|
|
nisproc_maplist_2(domainname *argp, CLIENT *clnt)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
static nisresp_maplist res;
|
|
|
|
|
|
|
|
memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, YPPROC_MAPLIST,
|
|
|
|
(xdrproc_t)nis_xdr_domainname, (caddr_t)argp,
|
|
|
|
(xdrproc_t)nis_xdr_ypresp_maplist, (caddr_t)&res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS)
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
return (&res);
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
nismaplist *
|
2006-02-04 15:12:37 -04:00
|
|
|
nis_maplist (char *dom)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
nisresp_maplist *list;
|
|
|
|
CLIENT *cl;
|
|
|
|
char *server = NULL;
|
|
|
|
int mapi = 0;
|
|
|
|
|
|
|
|
while (!server && aliases[mapi].map != 0L) {
|
|
|
|
yp_master (dom, aliases[mapi].map, &server);
|
|
|
|
mapi++;
|
|
|
|
}
|
|
|
|
if (!server) {
|
|
|
|
PyErr_SetString(NisError, "No NIS master found for any map");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cl = clnt_create(server, YPPROG, YPVERS, "tcp");
|
|
|
|
if (cl == NULL) {
|
|
|
|
PyErr_SetString(NisError, clnt_spcreateerror(server));
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
list = nisproc_maplist_2 (&dom, cl);
|
|
|
|
clnt_destroy(cl);
|
|
|
|
if (list == NULL)
|
|
|
|
goto finally;
|
|
|
|
if (list->stat != NIS_TRUE)
|
|
|
|
goto finally;
|
|
|
|
|
|
|
|
free(server);
|
|
|
|
return list->maps;
|
1997-01-09 18:22:05 -04:00
|
|
|
|
|
|
|
finally:
|
2010-05-09 12:52:27 -03:00
|
|
|
free(server);
|
|
|
|
return NULL;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
static PyObject *
|
2006-02-04 15:12:37 -04:00
|
|
|
nis_maps (PyObject *self, PyObject *args, PyObject *kwdict)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
char *domain = NULL;
|
|
|
|
nismaplist *maps;
|
|
|
|
PyObject *list;
|
|
|
|
int err;
|
|
|
|
static char *kwlist[] = {"domain", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwdict,
|
|
|
|
"|s:maps", kwlist, &domain))
|
|
|
|
return NULL;
|
|
|
|
if (!domain && ((err = yp_get_default_domain (&domain)) != 0)) {
|
|
|
|
nis_error(err);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((maps = nis_maplist (domain)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
if ((list = PyList_New(0)) == NULL)
|
|
|
|
return NULL;
|
2011-06-07 00:24:11 -03:00
|
|
|
for (; maps; maps = maps->next) {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *str = PyUnicode_FromString(maps->map);
|
|
|
|
if (!str || PyList_Append(list, str) < 0)
|
|
|
|
{
|
|
|
|
Py_DECREF(list);
|
|
|
|
list = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Py_DECREF(str);
|
|
|
|
}
|
|
|
|
/* XXX Shouldn't we free the list of maps now? */
|
|
|
|
return list;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|
|
|
|
|
1996-12-10 20:15:58 -04:00
|
|
|
static PyMethodDef nis_methods[] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
{"match", (PyCFunction)nis_match,
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
match__doc__},
|
|
|
|
{"cat", (PyCFunction)nis_cat,
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
cat__doc__},
|
|
|
|
{"maps", (PyCFunction)nis_maps,
|
|
|
|
METH_VARARGS | METH_KEYWORDS,
|
|
|
|
maps__doc__},
|
|
|
|
{"get_default_domain", (PyCFunction)nis_get_default_domain,
|
|
|
|
METH_NOARGS,
|
|
|
|
get_default_domain__doc__},
|
|
|
|
{NULL, NULL} /* Sentinel */
|
1992-08-12 11:57:12 -03:00
|
|
|
};
|
|
|
|
|
2006-02-04 15:12:37 -04:00
|
|
|
PyDoc_STRVAR(nis__doc__,
|
|
|
|
"This module contains functions for accessing NIS maps.\n");
|
|
|
|
|
2008-06-11 02:26:20 -03:00
|
|
|
static struct PyModuleDef nismodule = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"nis",
|
|
|
|
nis__doc__,
|
|
|
|
-1,
|
|
|
|
nis_methods,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
2008-06-11 02:26:20 -03:00
|
|
|
};
|
|
|
|
|
2015-03-17 13:48:27 -03:00
|
|
|
PyMODINIT_FUNC
|
|
|
|
PyInit_nis(void)
|
1992-08-12 11:57:12 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *m, *d;
|
|
|
|
m = PyModule_Create(&nismodule);
|
|
|
|
if (m == NULL)
|
|
|
|
return NULL;
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
NisError = PyErr_NewException("nis.error", NULL, NULL);
|
|
|
|
if (NisError != NULL)
|
|
|
|
PyDict_SetItemString(d, "error", NisError);
|
|
|
|
return m;
|
1992-08-12 11:57:12 -03:00
|
|
|
}
|