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
9913b64a
Commit
9913b64a
authored
Dec 11, 1996
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed.
parent
292428a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
23 deletions
+29
-23
Modules/pwdmodule.c
Modules/pwdmodule.c
+29
-23
No files found.
Modules/pwdmodule.c
View file @
9913b64a
...
...
@@ -31,16 +31,16 @@ PERFORMANCE OF THIS SOFTWARE.
/* UNIX password file access module */
#include "allobjects.h"
#include "modsupport.h"
#include "Python.h"
#include <sys/types.h>
#include <pwd.h>
static
object
*
mkpwent
(
p
)
static
PyObject
*
mkpwent
(
p
)
struct
passwd
*
p
;
{
return
mkv
alue
(
"(ssllsss)"
,
return
Py_BuildV
alue
(
"(ssllsss)"
,
p
->
pw_name
,
p
->
pw_passwd
,
#if defined(NeXT) && defined(_POSIX_SOURCE) && defined(__LITTLE_ENDIAN__)
...
...
@@ -57,56 +57,62 @@ static object *mkpwent(p)
p
->
pw_shell
);
}
static
object
*
pwd_getpwuid
(
self
,
args
)
object
*
self
,
*
args
;
static
PyObject
*
pwd_getpwuid
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
{
int
uid
;
struct
passwd
*
p
;
if
(
!
getintarg
(
args
,
&
uid
))
if
(
!
PyArg_Parse
(
args
,
"i"
,
&
uid
))
return
NULL
;
if
((
p
=
getpwuid
(
uid
))
==
NULL
)
{
err_setstr
(
KeyError
,
"getpwuid(): uid not found"
);
PyErr_SetString
(
PyExc_
KeyError
,
"getpwuid(): uid not found"
);
return
NULL
;
}
return
mkpwent
(
p
);
}
static
object
*
pwd_getpwnam
(
self
,
args
)
object
*
self
,
*
args
;
static
PyObject
*
pwd_getpwnam
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
{
char
*
name
;
struct
passwd
*
p
;
if
(
!
getstrarg
(
args
,
&
name
))
if
(
!
PyArg_Parse
(
args
,
"s"
,
&
name
))
return
NULL
;
if
((
p
=
getpwnam
(
name
))
==
NULL
)
{
err_setstr
(
KeyError
,
"getpwnam(): name not found"
);
PyErr_SetString
(
PyExc_
KeyError
,
"getpwnam(): name not found"
);
return
NULL
;
}
return
mkpwent
(
p
);
}
static
object
*
pwd_getpwall
(
self
,
args
)
object
*
self
,
*
args
;
static
PyObject
*
pwd_getpwall
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
{
o
bject
*
d
;
PyO
bject
*
d
;
struct
passwd
*
p
;
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
if
((
d
=
newlistobject
(
0
))
==
NULL
)
if
((
d
=
PyList_New
(
0
))
==
NULL
)
return
NULL
;
setpwent
();
while
((
p
=
getpwent
())
!=
NULL
)
{
o
bject
*
v
=
mkpwent
(
p
);
if
(
v
==
NULL
||
addlistitem
(
d
,
v
)
!=
0
)
{
XDECREF
(
v
);
DECREF
(
d
);
PyO
bject
*
v
=
mkpwent
(
p
);
if
(
v
==
NULL
||
PyList_Append
(
d
,
v
)
!=
0
)
{
Py_
XDECREF
(
v
);
Py_
DECREF
(
d
);
return
NULL
;
}
}
return
d
;
}
static
struct
methodlist
pwd_methods
[]
=
{
static
PyMethodDef
pwd_methods
[]
=
{
{
"getpwuid"
,
pwd_getpwuid
},
{
"getpwnam"
,
pwd_getpwnam
},
{
"getpwall"
,
pwd_getpwall
},
...
...
@@ -116,5 +122,5 @@ static struct methodlist pwd_methods[] = {
void
initpwd
()
{
initm
odule
(
"pwd"
,
pwd_methods
);
Py_InitM
odule
(
"pwd"
,
pwd_methods
);
}
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