]> granicus.if.org Git - python/commitdiff
Patch #573770: Implement lchown.
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 28 Jul 2002 16:33:45 +0000 (16:33 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 28 Jul 2002 16:33:45 +0000 (16:33 +0000)
Doc/lib/libos.tex
Misc/NEWS
Modules/posixmodule.c
configure
configure.in
pyconfig.h.in

index 7a6389039b6e32a25746d150e892f4b20f89dacc..d5f9a34ae0346446abfe14ce6f12ffa43f1553fc 100644 (file)
@@ -641,6 +641,13 @@ and \var{gid}.
 Availability: \UNIX.
 \end{funcdesc}
 
+\begin{funcdesc}{lchown}{path, uid, gid}
+Change the owner and group id of \var{path} to the numeric \var{uid}
+and gid. This function will not follow symbolic links.
+Availability: \UNIX.
+\versionadded{2.3}
+\end{funcdesc}
+
 \begin{funcdesc}{link}{src, dst}
 Create a hard link pointing to \var{src} named \var{dst}.
 Availability: \UNIX.
index f8f3b7f5d22269048484451dd56461609cd34146..f7a0bcd42b54949415582e69c082f25a4bb9d2a3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -162,8 +162,8 @@ Extension modules
   This will create a temporary in-memory bsddb that won't be
   written to disk.
 
-- posix.killpg, posix.mknod, and posix.getpgid have been added where
-  available.
+- posix.lchown, posix.killpg, posix.mknod, and posix.getpgid have been
+  added where available.
 
 - The locale module now exposes the C library's gettext interface.
 
@@ -339,7 +339,7 @@ Build
   to require editing the core to teach the trashcan mechanism about the
   new type.
 
-- Accoring to Annex F of the current C standard,
+- According to Annex F of the current C standard,
 
     The Standard C macro HUGE_VAL and its float and long double analogs,
     HUGE_VALF and HUGE_VALL, expand to expressions whose values are
index 47bea6f9f92d85ce37b9e5d3089194975ce4f220..61000673f4240b8a0383a9843b623769a6c62554 100644 (file)
@@ -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
index 7fc3bfd1276cd22a27a34b150f60576a311247cf..9024bcb718f1d480240195c815e46a06760c9221 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.334 .
+# From configure.in Revision: 1.335 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53.
 #
@@ -11436,13 +11436,14 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6
 
 
 
+
 
 
 for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \
  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
  gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
- hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \
- nice pathconf pause plock poll pthread_init \
+ hstrerror inet_pton kill killpg lchown link lstat mkfifo mknod mktime \
mremap nice pathconf pause plock poll pthread_init \
  putenv readlink \
  select setegid seteuid setgid setgroups \
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
index 98d54d1a479058c5033f9cb488f467218c8befef..88a285f48716781e0a16d100ac2e753d0d992d53 100644 (file)
@@ -1619,8 +1619,8 @@ AC_MSG_RESULT(MACHDEP_OBJS)
 AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
  gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
- hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \
- nice pathconf pause plock poll pthread_init \
+ hstrerror inet_pton kill killpg lchown link lstat mkfifo mknod mktime \
mremap nice pathconf pause plock poll pthread_init \
  putenv readlink \
  select setegid seteuid setgid setgroups \
  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
index 8a9a1ada50aac8e0012391dae06f75a3f39e2b99..05a355b06bfcebcd3d32981a76c150e2cce537e5 100644 (file)
    Solaris and Linux, the necessary defines are already defined.) */
 #undef HAVE_LARGEFILE_SUPPORT
 
+/* Define to 1 if you have the `lchown' function. */
+#undef HAVE_LCHOWN
+
 /* Define to 1 if you have the `dl' library (-ldl). */
 #undef HAVE_LIBDL