Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
57a34e80
Commit
57a34e80
authored
Feb 04, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1422385: Changes to nis module to support multiple NIS domains
parent
faa26dfd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
26 deletions
+101
-26
Doc/lib/libnis.tex
Doc/lib/libnis.tex
+18
-3
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/nismodule.c
Modules/nismodule.c
+79
-23
No files found.
Doc/lib/libnis.tex
View file @
57a34e80
...
...
@@ -15,7 +15,7 @@ only available for \UNIX.
The
\module
{
nis
}
module defines the following functions:
\begin{funcdesc}
{
match
}{
key, mapname
}
\begin{funcdesc}
{
match
}{
key, mapname
[, domain=default
_
domain]
}
Return the match for
\var
{
key
}
in map
\var
{
mapname
}
, or raise an
error (
\exception
{
nis.error
}
) if there is none.
Both should be strings,
\var
{
key
}
is 8-bit clean.
...
...
@@ -24,9 +24,13 @@ and other joys).
Note that
\var
{
mapname
}
is first checked if it is an alias to another
name.
\versionchanged
[The
\var
{
domain
}
argument allows to override
the NIS domain used for the lookup. If unspecified, lookup is in the
default NIS domain]
{
2.5
}
\end{funcdesc}
\begin{funcdesc}
{
cat
}{
mapname
}
\begin{funcdesc}
{
cat
}{
mapname
[, domain=default
_
domain]
}
Return a dictionary mapping
\var
{
key
}
to
\var
{
value
}
such that
\code
{
match(
\var
{
key
}
,
\var
{
mapname
}
)==
\var
{
value
}}
.
Note that both keys and values of the dictionary are arbitrary
...
...
@@ -34,12 +38,23 @@ arrays of bytes.
Note that
\var
{
mapname
}
is first checked if it is an alias to another
name.
\versionchanged
[The
\var
{
domain
}
argument allows to override
the NIS domain used for the lookup. If unspecified, lookup is in the
default NIS domain]
{
2.5
}
\end{funcdesc}
\begin{funcdesc}
{
maps
}{
}
\begin{funcdesc}
{
maps
}{
[domain=default
_
domain]
}
Return a list of all valid maps.
\versionchanged
[The
\var
{
domain
}
argument allows to override
the NIS domain used for the lookup. If unspecified, lookup is in the
default NIS domain]
{
2.5
}
\end{funcdesc}
\begin{funcdesc}
{
get
_
default
_
domain
}{}
Return the system default NIS domain.
\versionadded
{
2.5
}
\end{funcdesc}
The
\module
{
nis
}
module defines the following exception:
...
...
Misc/ACKS
View file @
57a34e80
...
...
@@ -47,6 +47,7 @@ Neal Becker
Robin Becker
Bill Bedford
Reimer Behrends
Ben Bell
Thomas Bellman
Juan M. Bello Rivas
Alexander Belopolsky
...
...
Misc/NEWS
View file @
57a34e80
...
...
@@ -216,6 +216,9 @@ Core and builtins
Extension
Modules
-----------------
-
Patch
#
1422385
:
The
nis
module
now
supports
access
to
domains
other
than
the
system
default
domain
.
-
Use
Win32
API
to
implement
os
.
stat
/
fstat
.
As
a
result
,
subsecond
timestamps
are
reported
,
the
limit
on
path
name
lengths
is
removed
,
and
stat
reports
WindowsError
now
(
instead
of
OSError
).
...
...
Modules/nismodule.c
View file @
57a34e80
...
...
@@ -23,6 +23,27 @@
extern
int
yp_get_default_domain
(
char
**
);
#endif
PyDoc_STRVAR
(
get_default_domain__doc__
,
"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
"
);
static
PyObject
*
NisError
;
static
PyObject
*
...
...
@@ -116,19 +137,36 @@ nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
}
static
PyObject
*
nis_
match
(
PyObject
*
self
,
PyObject
*
args
)
nis_
get_default_domain
(
PyObject
*
self
)
{
char
*
match
;
char
*
domain
;
int
err
;
PyObject
*
res
;
if
((
err
=
yp_get_default_domain
(
&
domain
))
!=
0
)
return
nis_error
(
err
);
res
=
PyString_FromStringAndSize
(
domain
,
strlen
(
domain
));
return
res
;
}
static
PyObject
*
nis_match
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwdict
)
{
char
*
match
;
char
*
domain
=
NULL
;
int
keylen
,
len
;
char
*
key
,
*
map
;
int
err
;
PyObject
*
res
;
int
fix
;
static
const
char
*
kwlist
[]
=
{
"key"
,
"map"
,
"domain"
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"t#s:match"
,
&
key
,
&
keylen
,
&
map
))
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdict
,
"t#s|s:match"
,
kwlist
,
&
key
,
&
keylen
,
&
map
,
&
domain
))
return
NULL
;
if
(
(
err
=
yp_get_default_domain
(
&
domain
))
!=
0
)
if
(
!
domain
&&
((
err
=
yp_get_default_domain
(
&
domain
))
!=
0
)
)
return
nis_error
(
err
);
map
=
nis_mapname
(
map
,
&
fix
);
if
(
fix
)
...
...
@@ -146,18 +184,20 @@ nis_match (PyObject *self, PyObject *args)
}
static
PyObject
*
nis_cat
(
PyObject
*
self
,
PyObject
*
args
)
nis_cat
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwdict
)
{
char
*
domain
;
char
*
domain
=
NULL
;
char
*
map
;
struct
ypall_callback
cb
;
struct
ypcallback_data
data
;
PyObject
*
dict
;
int
err
;
static
const
char
*
kwlist
[]
=
{
"map"
,
"domain"
,
NULL
};
if
(
!
PyArg_ParseTuple
(
args
,
"s:cat"
,
&
map
))
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdict
,
"s|s:cat"
,
kwlist
,
&
map
,
&
domain
))
return
NULL
;
if
(
(
err
=
yp_get_default_domain
(
&
domain
))
!=
0
)
if
(
!
domain
&&
((
err
=
yp_get_default_domain
(
&
domain
))
!=
0
)
)
return
nis_error
(
err
);
dict
=
PyDict_New
();
if
(
dict
==
NULL
)
...
...
@@ -301,19 +341,12 @@ nisproc_maplist_2(domainname *argp, CLIENT *clnt)
static
nismaplist
*
nis_maplist
(
void
)
nis_maplist
(
char
*
dom
)
{
nisresp_maplist
*
list
;
char
*
dom
;
CLIENT
*
cl
;
char
*
server
=
NULL
;
int
mapi
=
0
;
int
err
;
if
((
err
=
yp_get_default_domain
(
&
dom
))
!=
0
)
{
nis_error
(
err
);
return
NULL
;
}
while
(
!
server
&&
aliases
[
mapi
].
map
!=
0L
)
{
yp_master
(
dom
,
aliases
[
mapi
].
map
,
&
server
);
...
...
@@ -344,12 +377,23 @@ nis_maplist (void)
}
static
PyObject
*
nis_maps
(
PyObject
*
self
)
nis_maps
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwdict
)
{
char
*
domain
=
NULL
;
nismaplist
*
maps
;
PyObject
*
list
;
int
err
;
static
const
char
*
kwlist
[]
=
{
"domain"
,
NULL
};
if
((
maps
=
nis_maplist
())
==
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
;
...
...
@@ -368,17 +412,29 @@ nis_maps (PyObject *self)
}
static
PyMethodDef
nis_methods
[]
=
{
{
"match"
,
nis_match
,
METH_VARARGS
},
{
"cat"
,
nis_cat
,
METH_VARARGS
},
{
"maps"
,
(
PyCFunction
)
nis_maps
,
METH_NOARGS
},
{
NULL
,
NULL
}
/* Sentinel */
{
"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 */
};
PyDoc_STRVAR
(
nis__doc__
,
"This module contains functions for accessing NIS maps.
\n
"
);
void
initnis
(
void
)
{
PyObject
*
m
,
*
d
;
m
=
Py_InitModule
(
"nis"
,
nis_methods
);
m
=
Py_InitModule
3
(
"nis"
,
nis_methods
,
nis__doc__
);
if
(
m
==
NULL
)
return
;
d
=
PyModule_GetDict
(
m
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment