Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c2d02009
Kaydet (Commit)
c2d02009
authored
Şub 10, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #4591: Uid and gid values larger than 2**31 are supported now.
üst
d80b16db
7cf55993
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
18 deletions
+84
-18
test_posix.py
Lib/test/test_posix.py
+23
-6
Makefile.pre.in
Makefile.pre.in
+8
-0
NEWS
Misc/NEWS
+2
-0
grpmodule.c
Modules/grpmodule.c
+12
-5
posixmodule.c
Modules/posixmodule.c
+0
-0
posixmodule.h
Modules/posixmodule.h
+25
-0
pwdmodule.c
Modules/pwdmodule.c
+10
-6
signalmodule.c
Modules/signalmodule.c
+4
-1
No files found.
Lib/test/test_posix.py
Dosyayı görüntüle @
c2d02009
...
@@ -404,10 +404,20 @@ class PosixTester(unittest.TestCase):
...
@@ -404,10 +404,20 @@ class PosixTester(unittest.TestCase):
else
:
else
:
self
.
assertTrue
(
stat
.
S_ISFIFO
(
posix
.
stat
(
support
.
TESTFN
)
.
st_mode
))
self
.
assertTrue
(
stat
.
S_ISFIFO
(
posix
.
stat
(
support
.
TESTFN
)
.
st_mode
))
def
_test_all_chown_common
(
self
,
chown_func
,
first_param
):
def
_test_all_chown_common
(
self
,
chown_func
,
first_param
,
stat_func
):
"""Common code for chown, fchown and lchown tests."""
"""Common code for chown, fchown and lchown tests."""
def
check_stat
():
if
stat_func
is
not
None
:
stat
=
stat_func
(
first_param
)
self
.
assertEqual
(
stat
.
st_uid
,
os
.
getuid
())
self
.
assertEqual
(
stat
.
st_gid
,
os
.
getgid
())
# test a successful chown call
# test a successful chown call
chown_func
(
first_param
,
os
.
getuid
(),
os
.
getgid
())
chown_func
(
first_param
,
os
.
getuid
(),
os
.
getgid
())
check_stat
()
chown_func
(
first_param
,
-
1
,
os
.
getgid
())
check_stat
()
chown_func
(
first_param
,
os
.
getuid
(),
-
1
)
check_stat
()
if
os
.
getuid
()
==
0
:
if
os
.
getuid
()
==
0
:
try
:
try
:
...
@@ -427,8 +437,12 @@ class PosixTester(unittest.TestCase):
...
@@ -427,8 +437,12 @@ class PosixTester(unittest.TestCase):
"behavior"
)
"behavior"
)
else
:
else
:
# non-root cannot chown to root, raises OSError
# non-root cannot chown to root, raises OSError
self
.
assertRaises
(
OSError
,
chown_func
,
self
.
assertRaises
(
OSError
,
chown_func
,
first_param
,
0
,
0
)
first_param
,
0
,
0
)
check_stat
()
self
.
assertRaises
(
OSError
,
chown_func
,
first_param
,
-
1
,
0
)
check_stat
()
self
.
assertRaises
(
OSError
,
chown_func
,
first_param
,
0
,
-
1
)
check_stat
()
@unittest.skipUnless
(
hasattr
(
posix
,
'chown'
),
"test needs os.chown()"
)
@unittest.skipUnless
(
hasattr
(
posix
,
'chown'
),
"test needs os.chown()"
)
def
test_chown
(
self
):
def
test_chown
(
self
):
...
@@ -438,7 +452,8 @@ class PosixTester(unittest.TestCase):
...
@@ -438,7 +452,8 @@ class PosixTester(unittest.TestCase):
# re-create the file
# re-create the file
support
.
create_empty_file
(
support
.
TESTFN
)
support
.
create_empty_file
(
support
.
TESTFN
)
self
.
_test_all_chown_common
(
posix
.
chown
,
support
.
TESTFN
)
self
.
_test_all_chown_common
(
posix
.
chown
,
support
.
TESTFN
,
getattr
(
posix
,
'stat'
,
None
))
@unittest.skipUnless
(
hasattr
(
posix
,
'fchown'
),
"test needs os.fchown()"
)
@unittest.skipUnless
(
hasattr
(
posix
,
'fchown'
),
"test needs os.fchown()"
)
def
test_fchown
(
self
):
def
test_fchown
(
self
):
...
@@ -448,7 +463,8 @@ class PosixTester(unittest.TestCase):
...
@@ -448,7 +463,8 @@ class PosixTester(unittest.TestCase):
test_file
=
open
(
support
.
TESTFN
,
'w'
)
test_file
=
open
(
support
.
TESTFN
,
'w'
)
try
:
try
:
fd
=
test_file
.
fileno
()
fd
=
test_file
.
fileno
()
self
.
_test_all_chown_common
(
posix
.
fchown
,
fd
)
self
.
_test_all_chown_common
(
posix
.
fchown
,
fd
,
getattr
(
posix
,
'fstat'
,
None
))
finally
:
finally
:
test_file
.
close
()
test_file
.
close
()
...
@@ -457,7 +473,8 @@ class PosixTester(unittest.TestCase):
...
@@ -457,7 +473,8 @@ class PosixTester(unittest.TestCase):
os
.
unlink
(
support
.
TESTFN
)
os
.
unlink
(
support
.
TESTFN
)
# create a symlink
# create a symlink
os
.
symlink
(
_DUMMY_SYMLINK
,
support
.
TESTFN
)
os
.
symlink
(
_DUMMY_SYMLINK
,
support
.
TESTFN
)
self
.
_test_all_chown_common
(
posix
.
lchown
,
support
.
TESTFN
)
self
.
_test_all_chown_common
(
posix
.
lchown
,
support
.
TESTFN
,
getattr
(
posix
,
'lstat'
,
None
))
def
test_chdir
(
self
):
def
test_chdir
(
self
):
if
hasattr
(
posix
,
'chdir'
):
if
hasattr
(
posix
,
'chdir'
):
...
...
Makefile.pre.in
Dosyayı görüntüle @
c2d02009
...
@@ -639,6 +639,14 @@ Modules/python.o: $(srcdir)/Modules/python.c
...
@@ -639,6 +639,14 @@ Modules/python.o: $(srcdir)/Modules/python.c
Modules/_testembed.o
:
$(srcdir)/Modules/_testembed.c
Modules/_testembed.o
:
$(srcdir)/Modules/_testembed.c
$(MAINCC)
-c
$(PY_CORE_CFLAGS)
-o
$@
$(srcdir)
/Modules/_testembed.c
$(MAINCC)
-c
$(PY_CORE_CFLAGS)
-o
$@
$(srcdir)
/Modules/_testembed.c
Modules/posixmodule.o
:
$(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h
Modules/grpmodule.o
:
$(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h
Modules/pwdmodule.o
:
$(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
Modules/signalmodule.o
:
$(srcdir)/Modules/signalmodule.c $(srcdir)/Modules/posixmodule.h
Python/dynload_shlib.o
:
$(srcdir)/Python/dynload_shlib.c Makefile
Python/dynload_shlib.o
:
$(srcdir)/Python/dynload_shlib.c Makefile
$(CC)
-c
$(PY_CORE_CFLAGS)
\
$(CC)
-c
$(PY_CORE_CFLAGS)
\
-DSOABI
=
'"
$(SOABI)
"'
\
-DSOABI
=
'"
$(SOABI)
"'
\
...
...
Misc/NEWS
Dosyayı görüntüle @
c2d02009
...
@@ -250,6 +250,8 @@ Core and Builtins
...
@@ -250,6 +250,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
4591
:
Uid
and
gid
values
larger
than
2
**
31
are
supported
now
.
-
Issue
#
17141
:
random
.
vonmisesvariate
()
no
more
hangs
for
large
kappas
.
-
Issue
#
17141
:
random
.
vonmisesvariate
()
no
more
hangs
for
large
kappas
.
-
Issue
#
17149
:
Fix
random
.
vonmisesvariate
to
always
return
results
in
-
Issue
#
17149
:
Fix
random
.
vonmisesvariate
to
always
return
results
in
...
...
Modules/grpmodule.c
Dosyayı görüntüle @
c2d02009
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
/* UNIX group file access module */
/* UNIX group file access module */
#include "Python.h"
#include "Python.h"
#include "posixmodule.h"
#include <sys/types.h>
#include <grp.h>
#include <grp.h>
static
PyStructSequence_Field
struct_group_type_fields
[]
=
{
static
PyStructSequence_Field
struct_group_type_fields
[]
=
{
...
@@ -69,7 +69,7 @@ mkgrent(struct group *p)
...
@@ -69,7 +69,7 @@ mkgrent(struct group *p)
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
}
}
#endif
#endif
SET
(
setIndex
++
,
PyLong_FromLong
((
long
)
p
->
gr_gid
));
SET
(
setIndex
++
,
_PyLong_FromGid
(
p
->
gr_gid
));
SET
(
setIndex
++
,
w
);
SET
(
setIndex
++
,
w
);
#undef SET
#undef SET
...
@@ -85,17 +85,24 @@ static PyObject *
...
@@ -85,17 +85,24 @@ static PyObject *
grp_getgrgid
(
PyObject
*
self
,
PyObject
*
pyo_id
)
grp_getgrgid
(
PyObject
*
self
,
PyObject
*
pyo_id
)
{
{
PyObject
*
py_int_id
;
PyObject
*
py_int_id
;
unsigned
in
t
gid
;
gid_
t
gid
;
struct
group
*
p
;
struct
group
*
p
;
py_int_id
=
PyNumber_Long
(
pyo_id
);
py_int_id
=
PyNumber_Long
(
pyo_id
);
if
(
!
py_int_id
)
if
(
!
py_int_id
)
return
NULL
;
return
NULL
;
gid
=
PyLong_AS_LONG
(
py_int_id
);
if
(
!
_Py_Gid_Converter
(
py_int_id
,
&
gid
))
{
Py_DECREF
(
py_int_id
);
return
NULL
;
}
Py_DECREF
(
py_int_id
);
Py_DECREF
(
py_int_id
);
if
((
p
=
getgrgid
(
gid
))
==
NULL
)
{
if
((
p
=
getgrgid
(
gid
))
==
NULL
)
{
PyErr_Format
(
PyExc_KeyError
,
"getgrgid(): gid not found: %d"
,
gid
);
PyObject
*
gid_obj
=
_PyLong_FromGid
(
gid
);
if
(
gid_obj
==
NULL
)
return
NULL
;
PyErr_Format
(
PyExc_KeyError
,
"getgrgid(): gid not found: %S"
,
gid_obj
);
Py_DECREF
(
gid_obj
);
return
NULL
;
return
NULL
;
}
}
return
mkgrent
(
p
);
return
mkgrent
(
p
);
...
...
Modules/posixmodule.c
Dosyayı görüntüle @
c2d02009
This diff is collapsed.
Click to expand it.
Modules/posixmodule.h
0 → 100644
Dosyayı görüntüle @
c2d02009
/* Declarations shared between the different POSIX-related modules */
#ifndef Py_POSIXMODULE_H
#define Py_POSIXMODULE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifndef Py_LIMITED_API
#ifndef MS_WINDOWS
PyAPI_FUNC
(
PyObject
*
)
_PyLong_FromUid
(
uid_t
);
PyAPI_FUNC
(
PyObject
*
)
_PyLong_FromGid
(
gid_t
);
PyAPI_FUNC
(
int
)
_Py_Uid_Converter
(
PyObject
*
,
void
*
);
PyAPI_FUNC
(
int
)
_Py_Gid_Converter
(
PyObject
*
,
void
*
);
#endif
/* MS_WINDOWS */
#endif
#ifdef __cplusplus
}
#endif
#endif
/* !Py_POSIXMODULE_H */
Modules/pwdmodule.c
Dosyayı görüntüle @
c2d02009
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
/* UNIX password file access module */
/* UNIX password file access module */
#include "Python.h"
#include "Python.h"
#include "posixmodule.h"
#include <sys/types.h>
#include <pwd.h>
#include <pwd.h>
static
PyStructSequence_Field
struct_pwd_type_fields
[]
=
{
static
PyStructSequence_Field
struct_pwd_type_fields
[]
=
{
...
@@ -74,8 +74,8 @@ mkpwent(struct passwd *p)
...
@@ -74,8 +74,8 @@ mkpwent(struct passwd *p)
#else
#else
SETS
(
setIndex
++
,
p
->
pw_passwd
);
SETS
(
setIndex
++
,
p
->
pw_passwd
);
#endif
#endif
SETI
(
setIndex
++
,
p
->
pw_uid
);
PyStructSequence_SET_ITEM
(
v
,
setIndex
++
,
_PyLong_FromUid
(
p
->
pw_uid
)
);
SETI
(
setIndex
++
,
p
->
pw_gid
);
PyStructSequence_SET_ITEM
(
v
,
setIndex
++
,
_PyLong_FromGid
(
p
->
pw_gid
)
);
#ifdef __VMS
#ifdef __VMS
SETS
(
setIndex
++
,
""
);
SETS
(
setIndex
++
,
""
);
#else
#else
...
@@ -104,13 +104,17 @@ See help(pwd) for more on password database entries.");
...
@@ -104,13 +104,17 @@ See help(pwd) for more on password database entries.");
static
PyObject
*
static
PyObject
*
pwd_getpwuid
(
PyObject
*
self
,
PyObject
*
args
)
pwd_getpwuid
(
PyObject
*
self
,
PyObject
*
args
)
{
{
u
nsigned
in
t
uid
;
u
id_
t
uid
;
struct
passwd
*
p
;
struct
passwd
*
p
;
if
(
!
PyArg_ParseTuple
(
args
,
"
I:getpwuid"
,
&
uid
))
if
(
!
PyArg_ParseTuple
(
args
,
"
O&:getpwuid"
,
_Py_Uid_Converter
,
&
uid
))
return
NULL
;
return
NULL
;
if
((
p
=
getpwuid
(
uid
))
==
NULL
)
{
if
((
p
=
getpwuid
(
uid
))
==
NULL
)
{
PyObject
*
uid_obj
=
_PyLong_FromUid
(
uid
);
if
(
uid_obj
==
NULL
)
return
NULL
;
PyErr_Format
(
PyExc_KeyError
,
PyErr_Format
(
PyExc_KeyError
,
"getpwuid(): uid not found: %d"
,
uid
);
"getpwuid(): uid not found: %S"
,
uid_obj
);
Py_DECREF
(
uid_obj
);
return
NULL
;
return
NULL
;
}
}
return
mkpwent
(
p
);
return
mkpwent
(
p
);
...
...
Modules/signalmodule.c
Dosyayı görüntüle @
c2d02009
...
@@ -4,6 +4,9 @@
...
@@ -4,6 +4,9 @@
/* XXX Signals should be recorded per thread, now we have thread state. */
/* XXX Signals should be recorded per thread, now we have thread state. */
#include "Python.h"
#include "Python.h"
#ifndef MS_WINDOWS
#include "posixmodule.h"
#endif
#ifdef MS_WINDOWS
#ifdef MS_WINDOWS
#include <Windows.h>
#include <Windows.h>
...
@@ -723,7 +726,7 @@ fill_siginfo(siginfo_t *si)
...
@@ -723,7 +726,7 @@ fill_siginfo(siginfo_t *si)
PyStructSequence_SET_ITEM
(
result
,
1
,
PyLong_FromLong
((
long
)(
si
->
si_code
)));
PyStructSequence_SET_ITEM
(
result
,
1
,
PyLong_FromLong
((
long
)(
si
->
si_code
)));
PyStructSequence_SET_ITEM
(
result
,
2
,
PyLong_FromLong
((
long
)(
si
->
si_errno
)));
PyStructSequence_SET_ITEM
(
result
,
2
,
PyLong_FromLong
((
long
)(
si
->
si_errno
)));
PyStructSequence_SET_ITEM
(
result
,
3
,
PyLong_FromPid
(
si
->
si_pid
));
PyStructSequence_SET_ITEM
(
result
,
3
,
PyLong_FromPid
(
si
->
si_pid
));
PyStructSequence_SET_ITEM
(
result
,
4
,
PyLong_FromLong
((
long
)(
si
->
si_uid
)
));
PyStructSequence_SET_ITEM
(
result
,
4
,
_PyLong_FromUid
(
si
->
si_uid
));
PyStructSequence_SET_ITEM
(
result
,
5
,
PyStructSequence_SET_ITEM
(
result
,
5
,
PyLong_FromLong
((
long
)(
si
->
si_status
)));
PyLong_FromLong
((
long
)(
si
->
si_status
)));
PyStructSequence_SET_ITEM
(
result
,
6
,
PyLong_FromLong
(
si
->
si_band
));
PyStructSequence_SET_ITEM
(
result
,
6
,
PyLong_FromLong
(
si
->
si_band
));
...
...
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