[glib] Use lchmod instead of stat + chown if available
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Use lchmod instead of stat + chown if available
- Date: Tue, 1 Sep 2009 20:17:55 +0000 (UTC)
commit 3826963e65d8c4c68bcd3e4066505f63ef734b95
Author: Benjamin Otte <otte gnome org>
Date: Tue Sep 1 21:53:35 2009 +0200
Use lchmod instead of stat + chown if available
Fallout of the NOFLOOW_SYMLINKS fix from bug 593406
configure.in | 2 +-
gio/glocalfileinfo.c | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/configure.in b/configure.in
index 7bda924..e2a33b5 100644
--- a/configure.in
+++ b/configure.in
@@ -952,7 +952,7 @@ AC_MSG_RESULT(unsigned $glib_size_type)
# Check for some functions
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink fdwalk)
-AC_CHECK_FUNCS(chown lchown fchmod fchown link statvfs statfs utimes getgrgid getpwuid)
+AC_CHECK_FUNCS(chown lchmod lchown fchmod fchown link statvfs statfs utimes getgrgid getpwuid)
AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getmntinfo)
# Check for high-resolution sleep functions
AC_CHECK_FUNCS(nanosleep nsleep)
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 7182ec5..a61cc55 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1881,6 +1881,9 @@ set_unix_mode (char *filename,
#ifdef HAVE_SYMLINK
if (flags & G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS) {
+#ifdef HAVE_LCHMOD
+ res = lchmod (filename, val);
+#else
struct stat statbuf;
/* Calling chmod on a symlink changes permissions on the symlink.
* We don't want to do this, so we need to check for a symlink */
@@ -1892,10 +1895,11 @@ set_unix_mode (char *filename,
_("Cannot set permissions on symlinks"));
return FALSE;
}
- }
+ else if (res == 0)
+ res = g_chmod (filename, val);
+#endif
+ } else
#endif
-
- if (res == 0)
res = g_chmod (filename, val);
if (res == -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]