rdiff-backup-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Rdiff-backup-commits] Changes to rdiff-backup/rdiff_backup/cmodule.c


From: Ben Escoto
Subject: [Rdiff-backup-commits] Changes to rdiff-backup/rdiff_backup/cmodule.c
Date: Wed, 10 Aug 2005 23:34:04 -0400

Index: rdiff-backup/rdiff_backup/cmodule.c
diff -u rdiff-backup/rdiff_backup/cmodule.c:1.20 
rdiff-backup/rdiff_backup/cmodule.c:1.21
--- rdiff-backup/rdiff_backup/cmodule.c:1.20    Tue Aug 26 22:38:58 2003
+++ rdiff-backup/rdiff_backup/cmodule.c Thu Aug 11 03:34:03 2005
@@ -368,6 +368,36 @@
   return Py_BuildValue("s", unquote(s));
 }
 
+/* ------------- lchown taken from Python's posixmodule.c -------------- */
+/* duplicate here to avoid v2.3 requirement */
+
+static PyObject *
+posix_error_with_allocated_filename(char* name)
+{
+       PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
+       PyMem_Free(name);
+       return rc;
+}
+
+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;
+}
 
 /* ------------- Python export lists -------------------------------- */
 
@@ -381,6 +411,8 @@
    "Quote string, escaping non-printables"},
   {"acl_unquote", acl_unquote, METH_VARARGS,
    "Unquote string, producing original input to quote"},
+  {"lchown", posix_lchown, METH_VARARGS,
+   "Like chown, but don't follow symlinks"},
   {NULL, NULL, 0, NULL}
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]