|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79481 - in trunk/libs/filesystem: doc src test
From: bdawes_at_[hidden]
Date: 2012-07-13 15:43:34
Author: bemandawes
Date: 2012-07-13 15:43:33 EDT (Fri, 13 Jul 2012)
New Revision: 79481
URL: http://svn.boost.org/trac/boost/changeset/79481
Log:
Fix a Linux fchmodat problem affecting symlink permissions reported during discussion of 6659. Patch supplied by Duncan Exon Smith. Does not fix the original problem.
Text files modified:
trunk/libs/filesystem/doc/release_history.html | 4 +++-
trunk/libs/filesystem/src/operations.cpp | 11 ++++++++++-
trunk/libs/filesystem/test/operations_test.cpp | 17 ++++++++++++++++-
3 files changed, 29 insertions(+), 3 deletions(-)
Modified: trunk/libs/filesystem/doc/release_history.html
==============================================================================
--- trunk/libs/filesystem/doc/release_history.html (original)
+++ trunk/libs/filesystem/doc/release_history.html 2012-07-13 15:43:33 EDT (Fri, 13 Jul 2012)
@@ -47,6 +47,8 @@
<li>Add range_begin() and range_end() non-member functions for directory_iterator and
recursive_directory_iterator so that
<a href="http://www.boost.org/libs/foreach/">BOOST_FOREACH</a> works.</li>
+ <li>Fix a Linux fchmodat problem affecting symlink permissions reported during
+ discussion of #6659.</li>
</ul>
<h2>1.50.0</h2>
@@ -176,7 +178,7 @@
</ul>
<hr>
<p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->12 July, 2012<!--webbot bot="Timestamp" endspan i-checksum="21089" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->13 July, 2012<!--webbot bot="Timestamp" endspan i-checksum="21091" --></p>
<p>© Copyright Beman Dawes, 2011</p>
<p> Use, modification, and distribution are subject to the Boost Software
License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">
Modified: trunk/libs/filesystem/src/operations.cpp
==============================================================================
--- trunk/libs/filesystem/src/operations.cpp (original)
+++ trunk/libs/filesystem/src/operations.cpp 2012-07-13 15:43:33 EDT (Fri, 13 Jul 2012)
@@ -1396,8 +1396,17 @@
prms = current_status.permissions() & ~prms;
// Mac OS X Lion and some other platforms don't support fchmodat()
+ // Linux does not support permissions on symbolic links and has no plans to
+ // support them in the future. The chmod() code is thus more practical,
+ // rather than always hitting ENOTSUP when sending in AT_SYMLINK_NO_FOLLOW.
+ // - See the 3rd paragraph of
+ // "Symbolic link ownership, permissions, and timestamps" at:
+ // "http://man7.org/linux/man-pages/man7/symlink.7.html"
+ // - See the fchmodat() Linux man page:
+ // "http://man7.org/linux/man-pages/man2/fchmodat.2.html"
# if defined(AT_FDCWD) && defined(AT_SYMLINK_NOFOLLOW) \
- && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5100)
+ && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5100) \
+ && !(defined(linux) || defined(__linux) || defined(__linux__))
if (::fchmodat(AT_FDCWD, p.c_str(), mode_cast(prms),
!(prms & symlink_perms) ? 0 : AT_SYMLINK_NOFOLLOW))
# else // fallback if fchmodat() not supported
Modified: trunk/libs/filesystem/test/operations_test.cpp
==============================================================================
--- trunk/libs/filesystem/test/operations_test.cpp (original)
+++ trunk/libs/filesystem/test/operations_test.cpp 2012-07-13 15:43:33 EDT (Fri, 13 Jul 2012)
@@ -115,7 +115,7 @@
unsigned short language_id; // 0 except for Windows
- const char* temp_dir_name = "v3_operations_test";
+ const char* temp_dir_name = "operations_test";
void create_file(const fs::path & ph, const std::string & contents = std::string())
{
@@ -848,6 +848,21 @@
for (fs::directory_iterator itr(dir); itr != fs::directory_iterator(); ++itr)
if (itr->path().filename() == fs::path("permissions.txt"))
BOOST_TEST(itr->status().permissions() == fs::owner_all);
+
+ if (create_symlink_ok) // only if symlinks supported
+ {
+ BOOST_TEST(fs::status(p).permissions() == fs::owner_all);
+ fs::path p2(dir / "permissions-symlink.txt");
+ fs::create_symlink(p, p2);
+ cout << std::oct;
+ cout << " status(p).permissions() " << fs::status(p).permissions() << endl;
+ cout << " status(p2).permissions() " << fs::status(p).permissions() << endl;
+ fs::permissions(p2, fs::add_perms | fs::others_read);
+ cout << " status(p).permissions(): " << fs::status(p).permissions() << endl;
+ cout << " status(p2).permissions(): " << fs::status(p2).permissions() << endl;
+ cout << std::dec;
+ }
+
}
else // Windows
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk