summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-07-28 16:33:45 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-07-28 16:33:45 (GMT)
commit0cec0ffc787ee969b4003d04c031d38e2c523715 (patch)
treecc896af4474d199540e76940133779e70bf400c7 /Modules/posixmodule.c
parentddc6f4748e827ba655816987215394afbf811810 (diff)
downloadcpython-0cec0ffc787ee969b4003d04c031d38e2c523715.zip
cpython-0cec0ffc787ee969b4003d04c031d38e2c523715.tar.gz
cpython-0cec0ffc787ee969b4003d04c031d38e2c523715.tar.bz2
Patch #573770: Implement lchown.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 47bea6f..6100067 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -930,6 +930,33 @@ posix_chown(PyObject *self, PyObject *args)
}
#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
PyDoc_STRVAR(posix_getcwd__doc__,
@@ -6225,6 +6252,9 @@ static PyMethodDef posix_methods[] = {
#ifdef HAVE_CHOWN
{"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__},
#endif