~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Modules/posixmodule.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1923
1923
static PyObject *
1924
1924
posix_fchown(PyObject *self, PyObject *args)
1925
1925
{
1926
 
        int fd, uid, gid;
 
1926
        int fd;
 
1927
        long uid, gid;
1927
1928
        int res;
1928
 
        if (!PyArg_ParseTuple(args, "iii:chown", &fd, &uid, &gid))
 
1929
        if (!PyArg_ParseTuple(args, "ill:chown", &fd, &uid, &gid))
1929
1930
                return NULL;
1930
1931
        Py_BEGIN_ALLOW_THREADS
1931
1932
        res = fchown(fd, (uid_t) uid, (gid_t) gid);
1946
1947
posix_lchown(PyObject *self, PyObject *args)
1947
1948
{
1948
1949
        char *path = NULL;
1949
 
        int uid, gid;
 
1950
        long uid, gid;
1950
1951
        int res;
1951
 
        if (!PyArg_ParseTuple(args, "etii:lchown",
 
1952
        if (!PyArg_ParseTuple(args, "etll:lchown",
1952
1953
                              Py_FileSystemDefaultEncoding, &path,
1953
1954
                              &uid, &gid))
1954
1955
                return NULL;
3631
3632
posix_fork1(PyObject *self, PyObject *noargs)
3632
3633
{
3633
3634
        pid_t pid;
3634
 
        int result;
 
3635
        int result = 0;
3635
3636
        _PyImport_AcquireLock();
3636
3637
        pid = fork1();
3637
 
        result = _PyImport_ReleaseLock();
 
3638
        if (pid == 0) {
 
3639
                /* child: this clobbers and resets the import lock. */
 
3640
                PyOS_AfterFork();
 
3641
        } else {
 
3642
                /* parent: release the import lock. */
 
3643
                result = _PyImport_ReleaseLock();
 
3644
        }
3638
3645
        if (pid == -1)
3639
3646
                return posix_error();
3640
 
        if (pid == 0)
3641
 
                PyOS_AfterFork();
3642
3647
        if (result < 0) {
3643
3648
                /* Don't clobber the OSError if the fork failed. */
3644
3649
                PyErr_SetString(PyExc_RuntimeError,
3660
3665
posix_fork(PyObject *self, PyObject *noargs)
3661
3666
{
3662
3667
        pid_t pid;
3663
 
        int result;
 
3668
        int result = 0;
3664
3669
        _PyImport_AcquireLock();
3665
3670
        pid = fork();
3666
 
        result = _PyImport_ReleaseLock();
 
3671
        if (pid == 0) {
 
3672
                /* child: this clobbers and resets the import lock. */
 
3673
                PyOS_AfterFork();
 
3674
        } else {
 
3675
                /* parent: release the import lock. */
 
3676
                result = _PyImport_ReleaseLock();
 
3677
        }
3667
3678
        if (pid == -1)
3668
3679
                return posix_error();
3669
 
        if (pid == 0)
3670
 
                PyOS_AfterFork();
3671
3680
        if (result < 0) {
3672
3681
                /* Don't clobber the OSError if the fork failed. */
3673
3682
                PyErr_SetString(PyExc_RuntimeError,
3776
3785
static PyObject *
3777
3786
posix_forkpty(PyObject *self, PyObject *noargs)
3778
3787
{
3779
 
        int master_fd = -1, result;
 
3788
        int master_fd = -1, result = 0;
3780
3789
        pid_t pid;
3781
3790
 
3782
3791
        _PyImport_AcquireLock();
3783
3792
        pid = forkpty(&master_fd, NULL, NULL, NULL);
3784
 
        result = _PyImport_ReleaseLock();
 
3793
        if (pid == 0) {
 
3794
                /* child: this clobbers and resets the import lock. */
 
3795
                PyOS_AfterFork();
 
3796
        } else {
 
3797
                /* parent: release the import lock. */
 
3798
                result = _PyImport_ReleaseLock();
 
3799
        }
3785
3800
        if (pid == -1)
3786
3801
                return posix_error();
3787
 
        if (pid == 0)
3788
 
                PyOS_AfterFork();
3789
3802
        if (result < 0) {
3790
3803
                /* Don't clobber the OSError if the fork failed. */
3791
3804
                PyErr_SetString(PyExc_RuntimeError,
5636
5649
        uid_t ruid, euid;
5637
5650
        if (!PyArg_ParseTuple(args, "ll", &ruid_arg, &euid_arg))
5638
5651
                return NULL;
5639
 
        ruid = ruid_arg;
5640
 
        euid = euid_arg;
5641
 
        if (euid != euid_arg || ruid != ruid_arg) {
 
5652
        if (ruid_arg == -1)
 
5653
                ruid = (uid_t)-1;  /* let the compiler choose how -1 fits */
 
5654
        else
 
5655
                ruid = ruid_arg;  /* otherwise, assign from our long */
 
5656
        if (euid_arg == -1)
 
5657
                euid = (uid_t)-1;
 
5658
        else
 
5659
                euid = euid_arg;
 
5660
        if ((euid_arg != -1 && euid != euid_arg) || 
 
5661
            (ruid_arg != -1 && ruid != ruid_arg)) {
5642
5662
                PyErr_SetString(PyExc_OverflowError, "user id too big");
5643
5663
                return NULL;
5644
5664
        }
5663
5683
        gid_t rgid, egid;
5664
5684
        if (!PyArg_ParseTuple(args, "ll", &rgid_arg, &egid_arg))
5665
5685
                return NULL;
5666
 
        rgid = rgid_arg;
5667
 
        egid = egid_arg;
5668
 
        if (egid != egid_arg || rgid != rgid_arg) {
 
5686
        if (rgid_arg == -1)
 
5687
                rgid = (gid_t)-1;  /* let the compiler choose how -1 fits */
 
5688
        else
 
5689
                rgid = rgid_arg;  /* otherwise, assign from our long */
 
5690
        if (egid_arg == -1)
 
5691
                egid = (gid_t)-1;
 
5692
        else
 
5693
                egid = egid_arg;
 
5694
        if ((egid_arg != -1 && egid != egid_arg) || 
 
5695
            (rgid_arg != -1 && rgid != rgid_arg)) {
5669
5696
                PyErr_SetString(PyExc_OverflowError, "group id too big");
5670
5697
                return NULL;
5671
5698
        }