Re: [Boost-bugs] [Boost C++ Libraries] #6821: recursive_directory_iterator: increment fails with 'access denied'

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6821: recursive_directory_iterator: increment fails with 'access denied'
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-29 03:11:42


#6821: recursive_directory_iterator: increment fails with 'access denied'
-----------------------------------------------+----------------------------
  Reporter: Gary Sanders <lex21@…> | Owner: bemandawes
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------------------+----------------------------

Comment (by Jesse Jarrell <jjarrell@…>):

 The proposed fix only addresses when the first entry is a directory and
 returns an access denied code. The POSIX code handles this situation
 nicely with the iterator being set to EOF. However, if there are more
 entries you get an internal error.

 Here is the test directory structure I used to reproduce this as user
 anonymous:
 {{{

 drwxrwxr-x 5 anonymous anonymous 4096 Aug 28 20:45 ./
 drwxrwxr-x 8 anonymous anonymous 4096 Aug 28 20:14 ../
 drwx------ 2 root root 4096 Aug 28 15:30 root_noaccess/
 drwxrwxr-x 2 root anonymous 4096 Aug 28 15:28 root_subdir/
 drwxrwxr-x 2 anonymous anonymous 4096 Aug 28 20:14 xfiles/

 }}}

 {{{
 #include <boost/config/warning_disable.hpp>
 #include <boost/filesystem.hpp>
 #include <iostream>
 #include <iterator>

 using namespace std;

 int main(int argc, char* argv[]) {
         boost::system::error_code dir_error;

         for ( boost::filesystem::recursive_directory_iterator end,
 dir(".", dir_error); dir != end; dir.increment(dir_error) ) {
                 if (dir_error.value()) {
                         cerr << "Error accessing file: " <<
 dir_error.message() << endl;
                 }else{
                         cout << dir->path() << endl;
                 }
         }
         return 0;
 }
 }}}

 Output:
 {{{
 anonymous_at_ubuntu:~/perm_test$ ./test_perms
 "./root_noaccess"
 Error accessing file: Permission denied
 ***** Internal Program Error - assertion (m_imp.get()) failed in
 boost::filesystem::directory_entry&
 boost::filesystem::directory_iterator::dereference() const:
 /usr/local/include/boost/filesystem/operations.hpp(714): attempt to
 dereference end iterator
 Aborted (core dumped)
 }}}

 The expected outcome would be for the iterator to continue on to
 root_subdir since the program has no access to the directory
 "./root_noaccess".

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6821#comment:3>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC