Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 305067
Collapse All | Expand All

(-)Modules/posixmodule.c.orig (-18 / +39 lines)
Lines 1310-1317 Link Here
1310
        PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev));
1310
        PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev));
1311
#endif
1311
#endif
1312
        PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink));
1312
        PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink));
1313
        PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid));
1313
        PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)(int)st->st_uid));
1314
        PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid));
1314
        PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)(int)st->st_gid));
1315
#ifdef HAVE_LARGEFILE_SUPPORT
1315
#ifdef HAVE_LARGEFILE_SUPPORT
1316
        PyStructSequence_SET_ITEM(v, 6,
1316
        PyStructSequence_SET_ITEM(v, 6,
1317
				  PyLong_FromLongLong((PY_LONG_LONG)st->st_size));
1317
				  PyLong_FromLongLong((PY_LONG_LONG)st->st_size));
Lines 1897-1905 Link Here
1897
posix_chown(PyObject *self, PyObject *args)
1897
posix_chown(PyObject *self, PyObject *args)
1898
{
1898
{
1899
	char *path = NULL;
1899
	char *path = NULL;
1900
	long uid, gid;
1900
	int uid, gid;
1901
	int res;
1901
	int res;
1902
	if (!PyArg_ParseTuple(args, "etll:chown",
1902
	if (!PyArg_ParseTuple(args, "etii:chown",
1903
	                      Py_FileSystemDefaultEncoding, &path,
1903
	                      Py_FileSystemDefaultEncoding, &path,
1904
	                      &uid, &gid))
1904
	                      &uid, &gid))
1905
		return NULL;
1905
		return NULL;
Lines 3804-3810 Link Here
3804
static PyObject *
3804
static PyObject *
3805
posix_getegid(PyObject *self, PyObject *noargs)
3805
posix_getegid(PyObject *self, PyObject *noargs)
3806
{
3806
{
3807
	return PyInt_FromLong((long)getegid());
3807
	return PyInt_FromLong((long)(int)getegid());
3808
}
3808
}
3809
#endif
3809
#endif
3810
3810
Lines 3817-3823 Link Here
3817
static PyObject *
3817
static PyObject *
3818
posix_geteuid(PyObject *self, PyObject *noargs)
3818
posix_geteuid(PyObject *self, PyObject *noargs)
3819
{
3819
{
3820
	return PyInt_FromLong((long)geteuid());
3820
	return PyInt_FromLong((long)(int)geteuid());
3821
}
3821
}
3822
#endif
3822
#endif
3823
3823
Lines 3830-3836 Link Here
3830
static PyObject *
3830
static PyObject *
3831
posix_getgid(PyObject *self, PyObject *noargs)
3831
posix_getgid(PyObject *self, PyObject *noargs)
3832
{
3832
{
3833
	return PyInt_FromLong((long)getgid());
3833
	return PyInt_FromLong((long)(int)getgid());
3834
}
3834
}
3835
#endif
3835
#endif
3836
3836
Lines 3851-3856 Link Here
3851
"getgroups() -> list of group IDs\n\n\
3851
"getgroups() -> list of group IDs\n\n\
3852
Return list of supplemental group IDs for the process.");
3852
Return list of supplemental group IDs for the process.");
3853
3853
3854
#include <pwd.h>
3855
int getgrouplist_2(const char *name, gid_t basegid, gid_t **groups);
3856
3854
static PyObject *
3857
static PyObject *
3855
posix_getgroups(PyObject *self, PyObject *noargs)
3858
posix_getgroups(PyObject *self, PyObject *noargs)
3856
{
3859
{
Lines 3862-3879 Link Here
3862
        /* defined to be 16 on Solaris7, so this should be a small number */
3865
        /* defined to be 16 on Solaris7, so this should be a small number */
3863
#define MAX_GROUPS 64
3866
#define MAX_GROUPS 64
3864
#endif
3867
#endif
3865
        gid_t grouplist[MAX_GROUPS];
3868
        gid_t *grouplist = NULL;
3869
        struct passwd *pw;
3866
        int n;
3870
        int n;
3867
3871
3868
        n = getgroups(MAX_GROUPS, grouplist);
3872
        if ((pw = getpwuid(getuid())) == NULL) {
3869
        if (n < 0)
3873
            errno = EINVAL;
3870
            posix_error();
3874
            posix_error();
3871
        else {
3875
            return NULL;
3876
        }
3877
        n = getgrouplist_2(pw->pw_name, pw->pw_gid, &grouplist);
3878
        if (n < 0) {
3879
            errno = EINVAL;
3880
            posix_error();
3881
        } else {
3872
            result = PyList_New(n);
3882
            result = PyList_New(n);
3873
            if (result != NULL) {
3883
            if (result != NULL) {
3874
                int i;
3884
                int i;
3875
                for (i = 0; i < n; ++i) {
3885
                for (i = 0; i < n; ++i) {
3876
                    PyObject *o = PyInt_FromLong((long)grouplist[i]);
3886
                    PyObject *o = PyInt_FromLong((long)(int)grouplist[i]);
3877
                    if (o == NULL) {
3887
                    if (o == NULL) {
3878
                        Py_DECREF(result);
3888
                        Py_DECREF(result);
3879
                        result = NULL;
3889
                        result = NULL;
Lines 3884-3889 Link Here
3884
            }
3894
            }
3885
        }
3895
        }
3886
3896
3897
    if (grouplist) free(grouplist);
3887
    return result;
3898
    return result;
3888
}
3899
}
3889
#endif
3900
#endif
Lines 3994-4000 Link Here
3994
static PyObject *
4005
static PyObject *
3995
posix_getuid(PyObject *self, PyObject *noargs)
4006
posix_getuid(PyObject *self, PyObject *noargs)
3996
{
4007
{
3997
	return PyInt_FromLong((long)getuid());
4008
	return PyInt_FromLong((long)(int)getuid());
3998
}
4009
}
3999
#endif
4010
#endif
4000
4011
Lines 5711-5725 Link Here
5711
posix_setgroups(PyObject *self, PyObject *groups)
5722
posix_setgroups(PyObject *self, PyObject *groups)
5712
{
5723
{
5713
	int i, len;
5724
	int i, len;
5714
        gid_t grouplist[MAX_GROUPS];
5725
        gid_t *grouplist;
5715
5726
5716
	if (!PySequence_Check(groups)) {
5727
	if (!PySequence_Check(groups)) {
5717
		PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
5728
		PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
5718
		return NULL;
5729
		return NULL;
5719
	}
5730
	}
5720
	len = PySequence_Size(groups);
5731
	len = PySequence_Size(groups);
5721
	if (len > MAX_GROUPS) {
5732
	if ((grouplist = (gid_t *)malloc(len * sizeof(gid_t))) == NULL) {
5722
		PyErr_SetString(PyExc_ValueError, "too many groups");
5733
		PyErr_NoMemory();
5723
		return NULL;
5734
		return NULL;
5724
	}
5735
	}
5725
	for(i = 0; i < len; i++) {
5736
	for(i = 0; i < len; i++) {
Lines 5743-5749 Link Here
5743
				}
5754
				}
5744
				grouplist[i] = x;
5755
				grouplist[i] = x;
5745
				/* read back to see if it fits in gid_t */
5756
				/* read back to see if it fits in gid_t */
5746
				if (grouplist[i] != x) {
5757
				if ((int)grouplist[i] != x) {
5747
					PyErr_SetString(PyExc_TypeError,
5758
					PyErr_SetString(PyExc_TypeError,
5748
							"group id too big");
5759
							"group id too big");
5749
					Py_DECREF(elem);
5760
					Py_DECREF(elem);
Lines 5753-5759 Link Here
5753
		} else {
5764
		} else {
5754
			long x  = PyInt_AsLong(elem);
5765
			long x  = PyInt_AsLong(elem);
5755
			grouplist[i] = x;
5766
			grouplist[i] = x;
5756
			if (grouplist[i] != x) {
5767
			if ((int)grouplist[i] != x) {
5757
				PyErr_SetString(PyExc_TypeError,
5768
				PyErr_SetString(PyExc_TypeError,
5758
						"group id too big");
5769
						"group id too big");
5759
				Py_DECREF(elem);
5770
				Py_DECREF(elem);
Lines 5765-5770 Link Here
5765
5776
5766
	if (setgroups(len, grouplist) < 0)
5777
	if (setgroups(len, grouplist) < 0)
5767
		return posix_error();
5778
		return posix_error();
5779
	free(grouplist);
5768
	Py_INCREF(Py_None);
5780
	Py_INCREF(Py_None);
5769
	return Py_None;
5781
	return Py_None;
5770
}
5782
}
Lines 7521-7526 Link Here
7521
#ifdef _MIPS_CS_VENDOR
7533
#ifdef _MIPS_CS_VENDOR
7522
    {"MIPS_CS_VENDOR",	_MIPS_CS_VENDOR},
7534
    {"MIPS_CS_VENDOR",	_MIPS_CS_VENDOR},
7523
#endif
7535
#endif
7536
#ifdef _CS_DARWIN_USER_DIR
7537
    {"CS_DARWIN_USER_DIR", _CS_DARWIN_USER_DIR},
7538
#endif
7539
#ifdef _CS_DARWIN_USER_TEMP_DIR
7540
    {"CS_DARWIN_USER_TEMP_DIR", _CS_DARWIN_USER_TEMP_DIR},
7541
#endif
7542
#ifdef _CS_DARWIN_USER_CACHE_DIR
7543
    {"CS_DARWIN_USER_CACHE_DIR", _CS_DARWIN_USER_CACHE_DIR},
7544
#endif
7524
};
7545
};
7525
7546
7526
static int
7547
static int

Return to bug 305067