[Python-checkins] python/dist/src/Modules posixmodule.c,2.244,2.245

loewis@users.sourceforge.net loewis@users.sourceforge.net
Sun, 28 Jul 2002 09:33:47 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv3899/Modules

Modified Files:
	posixmodule.c 
Log Message:
Patch #573770: Implement lchown.


Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.244
retrieving revision 2.245
diff -C2 -d -r2.244 -r2.245
*** posixmodule.c	15 Jul 2002 16:10:55 -0000	2.244
--- posixmodule.c	28 Jul 2002 16:33:45 -0000	2.245
***************
*** 931,934 ****
--- 931,961 ----
  #endif /* HAVE_CHOWN */
  
+ #ifdef HAVE_LCHOWN
+ PyDoc_STRVAR(posix_lchown__doc__,
+ "lchown(path, uid, gid)\n\n\
+ Change the owner and group id of path to the numeric uid and gid.\n\
+ This function will not follow symbolic links.");
+ 
+ static PyObject *
+ posix_lchown(PyObject *self, PyObject *args)
+ {
+ 	char *path = NULL;
+ 	int uid, gid;
+ 	int res;
+ 	if (!PyArg_ParseTuple(args, "etii:lchown",
+ 	                      Py_FileSystemDefaultEncoding, &path,
+ 	                      &uid, &gid))
+ 		return NULL;
+ 	Py_BEGIN_ALLOW_THREADS
+ 	res = lchown(path, (uid_t) uid, (gid_t) gid);
+ 	Py_END_ALLOW_THREADS
+ 	if (res < 0)
+ 		return posix_error_with_allocated_filename(path);
+ 	PyMem_Free(path);
+ 	Py_INCREF(Py_None);
+ 	return Py_None;
+ }
+ #endif /* HAVE_LCHOWN */
+ 
  
  #ifdef HAVE_GETCWD
***************
*** 6226,6229 ****
--- 6253,6259 ----
  	{"chown",	posix_chown, METH_VARARGS, posix_chown__doc__},
  #endif /* HAVE_CHOWN */
+ #ifdef HAVE_LCHOWN
+ 	{"lchown",	posix_lchown, METH_VARARGS, posix_lchown__doc__},
+ #endif /* HAVE_LCHOWN */
  #ifdef HAVE_CHROOT
  	{"chroot",	posix_chroot, METH_VARARGS, posix_chroot__doc__},