[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.151,2.152

A.M. Kuchling python-dev@python.org
2000年7月12日 18:27:00 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv3810/Modules
Modified Files:
	posixmodule.c 
Log Message:
From Sam Rushing's Medusa, via SF patch #100858: add & document
os.seteuid(), os.setegid(), os.setreuid(), os.setregid().
Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.151
retrieving revision 2.152
diff -C2 -r2.151 -r2.152
*** posixmodule.c	2000年07月12日 13:05:33	2.151
--- posixmodule.c	2000年07月13日 01:26:58	2.152
***************
*** 2619,2622 ****
--- 2619,2698 ----
 
 
+ #ifdef HAVE_SETEUID
+ static char posix_seteuid__doc__[] =
+ "seteuid(uid) -> None\n\
+ Set the current process's effective user id.";
+ static PyObject *
+ posix_seteuid (PyObject *self, PyObject *args)
+ {
+ 	int euid;
+ 	if (!PyArg_ParseTuple(args, "i", &euid)) {
+ 		return NULL;
+ 	} else if (seteuid(euid) < 0) {
+ 		return posix_error();
+ 	} else {
+ 		Py_INCREF(Py_None);
+ 		return Py_None;
+ 	}
+ }
+ #endif /* HAVE_SETEUID */
+ 
+ #ifdef HAVE_SETEGID
+ static char posix_setegid__doc__[] =
+ "setegid(gid) -> None\n\
+ Set the current process's effective group id.";
+ static PyObject *
+ posix_setegid (PyObject *self, PyObject *args)
+ {
+ 	int egid;
+ 	if (!PyArg_ParseTuple(args, "i", &egid)) {
+ 		return NULL;
+ 	} else if (setegid(egid) < 0) {
+ 		return posix_error();
+ 	} else {
+ 		Py_INCREF(Py_None);
+ 		return Py_None;
+ 	}
+ }
+ #endif /* HAVE_SETEGID */
+ 
+ #ifdef HAVE_SETREUID
+ static char posix_setreuid__doc__[] =
+ "seteuid(ruid, euid) -> None\n\
+ Set the current process's real and effective user ids.";
+ static PyObject *
+ posix_setreuid (PyObject *self, PyObject *args)
+ {
+ 	int ruid, euid;
+ 	if (!PyArg_ParseTuple(args, "ii", &ruid, &euid)) {
+ 		return NULL;
+ 	} else if (setreuid(ruid, euid) < 0) {
+ 		return posix_error();
+ 	} else {
+ 		Py_INCREF(Py_None);
+ 		return Py_None;
+ 	}
+ }
+ #endif /* HAVE_SETREUID */
+ 
+ #ifdef HAVE_SETREGID
+ static char posix_setregid__doc__[] =
+ "setegid(rgid, egid) -> None\n\
+ Set the current process's real and effective group ids.";
+ static PyObject *
+ posix_setregid (PyObject *self, PyObject *args)
+ {
+ 	int rgid, egid;
+ 	if (!PyArg_ParseTuple(args, "ii", &rgid, &egid)) {
+ 		return NULL;
+ 	} else if (setregid(rgid, egid) < 0) {
+ 		return posix_error();
+ 	} else {
+ 		Py_INCREF(Py_None);
+ 		return Py_None;
+ 	}
+ }
+ #endif /* HAVE_SETREGID */
+ 
 #ifdef HAVE_SETGID
 static char posix_setgid__doc__[] =
***************
*** 4899,4902 ****
--- 4975,4990 ----
 	{"setuid",	posix_setuid, METH_VARARGS, posix_setuid__doc__},
 #endif /* HAVE_SETUID */
+ #ifdef HAVE_SETEUID
+ 	{"seteuid",	posix_seteuid, METH_VARARGS, posix_seteuid__doc__},
+ #endif /* HAVE_SETEUID */
+ #ifdef HAVE_SETEGID
+ 	{"setegid",	posix_setegid, METH_VARARGS, posix_setegid__doc__},
+ #endif /* HAVE_SETEGID */
+ #ifdef HAVE_SETREUID
+ 	{"setreuid",	posix_setreuid, METH_VARARGS, posix_setreuid__doc__},
+ #endif /* HAVE_SETREUID */
+ #ifdef HAVE_SETREGID
+ 	{"setregid",	posix_setregid,	METH_VARARGS, posix_setregid__doc__},
+ #endif /* HAVE_SETREGID */
 #ifdef HAVE_SETGID
 	{"setgid",	posix_setgid, METH_VARARGS, posix_setgid__doc__},

AltStyle によって変換されたページ (->オリジナル) /