Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-release-src > by-pkgid > 931fe3a15cc64baa680c1cb086dd28c6 > files > 5

e4rat-0.2.3-21.mga6.src.rpm

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6de8d2..65aa95d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 
 set(Boost_USE_STATIC_LIBS   ON)
 set(Boost_USE_MULTITHREADED OFF)
-add_definitions(-DBOOST_FILESYSTEM_VERSION=2)
+add_definitions(-DBOOST_FILESYSTEM_VERSION=3)
 find_package(Boost 1.41 COMPONENTS system filesystem regex REQUIRED)
 set(${PROJECT_NAME}_LIBRARIES   ${${PROJECT_NAME}_LIBRARIES}
     ${Boost_LIBRARIES})
diff --git a/doc/e4rat-collect.pod b/doc/e4rat-collect.pod
index f206411..4d602ac 100644
--- a/doc/e4rat-collect.pod
+++ b/doc/e4rat-collect.pod
@@ -127,4 +127,4 @@ Report bugs to Andreas Rid <conso at users.sf.net>.
 
 =head1 SEE ALSO
 
-e4rat-realloc(8), e4rat-preload(8), e4rat.conf(8)
+e4rat-realloc(8), e4rat-preload(8), e4rat.conf(5)
diff --git a/doc/e4rat-preload.pod b/doc/e4rat-preload.pod
index 82e63b4..df74e89 100644
--- a/doc/e4rat-preload.pod
+++ b/doc/e4rat-preload.pod
@@ -82,4 +82,4 @@ Report bugs to Andreas Rid <conso at users.sf.net>.
 
 =head1 SEE ALSO
 
-e4rat-collect(8), e4rat-realloc(8), e4rat.conf(8)
+e4rat-collect(8), e4rat-realloc(8), e4rat.conf(5)
diff --git a/doc/e4rat-realloc.pod b/doc/e4rat-realloc.pod
index b937ca0..8081e37 100644
--- a/doc/e4rat-realloc.pod
+++ b/doc/e4rat-realloc.pod
@@ -89,4 +89,4 @@ Report bugs to Andreas Rid <conso at users.sf.net>.
 
 =head1 SEE ALSO
 
-e4rat-collect(8), e4rat-preload(8), e4rat.conf(8)
+e4rat-collect(8), e4rat-preload(8), e4rat.conf(5)
diff --git a/src/common.cc b/src/common.cc
index 9fba13a..6538e14 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -157,7 +157,7 @@ std::vector<std::string> matchPath( const std::string & filesearch )
         p /= filesearch;
     }
     // Initialize regex filter - use * as default if nothing is given in filesearch
-    std::string f( p.has_filename() ? p.filename() : "*");
+    std::string f( p.has_filename() ? p.filename().string() : "*");
 
     fs::path dir(system_complete(p).parent_path());
     if( is_directory(dir) )
@@ -166,8 +166,8 @@ std::vector<std::string> matchPath( const std::string & filesearch )
              it!=boost::filesystem::directory_iterator();
              ++it )
         {
-            if( boost::regex_match( it->leaf(), path2regex(f) ) )
-                fileset.push_back(it->string());
+            if( boost::regex_match( it->path().filename().string(), path2regex(f) ) )
+                fileset.push_back(it->path().string());
         }
     return fileset;
 }
diff --git a/src/config.cc b/src/config.cc
index 5671fb4..1c851b9 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -29,7 +29,7 @@
 
 DEFINE_SINGLETON(Config);
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-char** get_argv()
+static const char** get_argv()
 {
     char** ptr = environ;
     ptr--;
@@ -37,7 +37,7 @@ char** get_argv()
         // Assumption argument strings does not have a leading '\0' character.
         // Therefore ptr points to argc.
         if(*(unsigned int*)ptr < 0x00FFFFFF)
-            return ++ptr;
+            return (const char**)++ptr;
     return 0;
 }
 #else
@@ -64,14 +64,14 @@ Config::Config()
 
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
     size_t found;
-    char**argv = get_argv();
+    const char**argv = get_argv();
     if(argv == NULL)
     {
         fprintf(stderr, "Cannot get argv arguments\n");
         return;
     }
     
-    tool_name = fs::path(argv[0]).filename();
+    tool_name = fs::path(argv[0]).filename().string();
     found = tool_name.find_last_of("-");
     if(found)
         defaultSection = tool_name.substr(found+1);
diff --git a/src/defrag.cc b/src/defrag.cc
index be08312..d431436 100644
--- a/src/defrag.cc
+++ b/src/defrag.cc
@@ -761,7 +761,7 @@ void Defrag::createDonorFiles_LocalityGroup(Device& device,
          * Restore CPU affinity
          */
         if(ret_get_affinity == 0)
-            if(0 > sched_setaffinity(gettid(), sizeof(new_sched_mask), &new_sched_mask))
+            if(0 > sched_setaffinity(gettid(), sizeof(cur_sched_mask), &cur_sched_mask))
                 warn("Cannot restore process's CPU affinity: %s", strerror(errno));
         
         /*
@@ -826,9 +826,9 @@ void Defrag::createDonorFiles_TLD(Device& device,
                 continue;
             
             interruptionPoint();
-            
+            std::string tmpFile;
             try {
-                std::string tmpFile = createTempFile(tld, 
+                tmpFile = createTempFile(tld, 
                                            odp.blocks * device.getBlockSize());
 
                 // Once we created all donor files we will remove our top level
@@ -837,7 +837,12 @@ void Defrag::createDonorFiles_TLD(Device& device,
             }
             catch(std::runtime_error& e)
             {
-                warn("%s", e.what());
+                if(-1 == remove(tmpFile.c_str()))
+                    if(errno != ENOENT)
+                        error("Cannot remove temp file: %s: %s",
+                              tmpFile.c_str(), strerror(errno));
+                
+                throw;
             }
         }
         
diff --git a/src/device.cc b/src/device.cc
index 4ac6e73..eeb91bd 100644
--- a/src/device.cc
+++ b/src/device.cc
@@ -196,14 +196,14 @@ int Device::getDevNameFromDevfs()
         it != end_itr;
         ++it )
     {
-        if(it->filename() == "root")
+        if(it->path().string() == "/dev/root")
             continue;
-        if(lstat(it->string().c_str(), &st))
+        if(lstat(it->path().string().c_str(), &st))
             continue;
-        if(st.st_rdev == get()->devno)
+        if(st.st_rdev == get()->devno && S_ISBLK(st.st_mode))
         {
-            get()->deviceName = it->filename();
-            get()->devicePath = "/dev/" + get()->deviceName;
+            get()->devicePath = it->path().string();
+            get()->deviceName = it->path().filename().string();
             return 0;
         }
     }
@@ -225,7 +225,7 @@ int Device::getDevNameFromMajorMinor()
             // the minor number of virtual filesystems are allocated dynamically in function set_anon_super() in fs/super.c
             // for convenience set deviceName and devicePath to a common name
             get()->deviceName = "virtual file system";
-            get()->devicePath = get()->mount_point.filename();
+            get()->devicePath = get()->mount_point.filename().string();
             return 0;
         case 2:
             ss << "fd"; 
diff --git a/src/e4rat-collect.cc b/src/e4rat-collect.cc
index 8cc2b81..6125eca 100644
--- a/src/e4rat-collect.cc
+++ b/src/e4rat-collect.cc
@@ -84,8 +84,10 @@ int system_u(const char* user, const char* command)
                     exit(1);
                 }
                 setenv("HOME", pw->pw_dir, 1);
-                setuid(pw->pw_uid);
-                setgid(pw->pw_gid);
+                if(setuid(pw->pw_uid))
+                    error("Cannot set user id %d: %s", pw->pw_uid, strerror(errno));
+                if(setgid(pw->pw_gid))
+                    error("Cannot set group id %d: %s", pw->pw_gid, strerror(errno));
             }
             
             execl("/bin/sh", "/bin/sh", "-c", command, NULL);
@@ -396,7 +398,7 @@ int main(int argc, char* argv[])
          * Parse application list given as arguments
          */
         for ( ; optind < argc; optind++)
-            project.observeApp(fs::path(argv[optind]).filename());
+            project.observeApp(fs::path(argv[optind]).filename().string());
 
         /*
          * Parse application list on stdin
diff --git a/src/listener.cc b/src/listener.cc
index f7f0fa1..4d55fa2 100644
--- a/src/listener.cc
+++ b/src/listener.cc
@@ -624,15 +624,15 @@ bool AuditListener::ignoreDevice(dev_t dev)
         return true;
 
     if(!watch_devices.empty())
-        if(watch_devices.end() != watch_devices.find(dev))
-            return false;
+        if(watch_devices.end() == watch_devices.find(dev))
+            return true;
 
-    if(ext4_only)
+    if(ext4_only && ext4_devices_cache.end() == ext4_devices_cache.find(dev))
     {
         try {
             Device device(dev);
             if(device.getFileSystem() == "ext4")
-                watch_devices.insert(dev);
+                ext4_devices_cache.insert(dev);
             else
             {
                 std::string dev_name = device.getDevicePath();
diff --git a/src/listener.hh b/src/listener.hh
index 3426b70..5785f96 100644
--- a/src/listener.hh
+++ b/src/listener.hh
@@ -109,6 +109,7 @@ class AuditListener : public Interruptible
         std::set<dev_t> exclude_devices;
         std::set<long>  watch_fs_types;
         bool ext4_only;
+        std::set<dev_t> ext4_devices_cache;
 };
 
 /*