Mailinglist Archive: zypp-commit (233 mails)

< Previous Next >
[zypp-commit] <libzypp> master : CheckAccessDeleted: Per default do not collect deleted files outside bin and lib dirs (bnc #554480)
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Wed, 11 Nov 2009 14:08:04 +0100
  • Message-id: <E1N8Cvt-0004Pj-B7@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 27c38805648170fce72924ddb0196b9d75e5c413
Author: Michael Andres <ma@xxxxxxx>
Date: Wed Nov 11 14:08:04 2009 +0100

CheckAccessDeleted: Per default do not collect deleted files outside bin
and lib dirs (bnc #554480)
---
tools/zypp-CheckAccessDeleted.cc | 2 +-
zypp/misc/CheckAccessDeleted.cc | 16 ++++++++++------
zypp/misc/CheckAccessDeleted.h | 10 +++++++++-
3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/tools/zypp-CheckAccessDeleted.cc b/tools/zypp-CheckAccessDeleted.cc
index 716c5ba..ebdcd1e 100644
--- a/tools/zypp-CheckAccessDeleted.cc
+++ b/tools/zypp-CheckAccessDeleted.cc
@@ -120,7 +120,7 @@ int main( int argc, char * argv[] )

zypp::CheckAccessDeleted checker(false); // wait for explicit call to check()
try {
- checker.check();
+ checker.check( /*verbose*/true );
}
catch( const zypp::Exception & err )
{
diff --git a/zypp/misc/CheckAccessDeleted.cc b/zypp/misc/CheckAccessDeleted.cc
index baeafe3..6af5a01 100644
--- a/zypp/misc/CheckAccessDeleted.cc
+++ b/zypp/misc/CheckAccessDeleted.cc
@@ -96,7 +96,7 @@ namespace zypp
* - The type \c (t) is set to \c REG or \c DEL
* - The filedescriptor \c (f) is set to \c txt, \c mem or \c DEL
*/
- inline void addCacheIf( CheckAccessDeleted::ProcInfo & cache_r, const
std::string & line_r )
+ inline void addCacheIf( CheckAccessDeleted::ProcInfo & cache_r, const
std::string & line_r, bool verbose_r )
{
const char * f = 0;
const char * t = 0;
@@ -137,11 +137,15 @@ namespace zypp
|| ( *f == 'l' && *(f+1) == 't' && *(f+2) == 'x' && *(f+3) ==
'\0' ) ) )
return; // wrong filedescriptor type

- std::string name( n );
-
if ( str::contains( n, "(stat: Permission denied)" ) )
return; // Avoid reporting false positive due to insufficient
permission.

+ if ( ! verbose_r )
+ {
+ if ( ! ( str::contains( n, "/lib" ) || str::contains( n, "bin/" ) ) )
+ return; // Try to avoid reporting false positive unless verbose.
+ }
+
if ( *f == 'm' || *f == 'D' ) // skip some wellknown nonlibrary
memorymapped files
{
static const char * black[] = {
@@ -156,7 +160,7 @@ namespace zypp
}
}

- if ( std::find( cache_r.files.begin(), cache_r.files.end(), name ) ==
cache_r.files.end() )
+ if ( std::find( cache_r.files.begin(), cache_r.files.end(), n ) ==
cache_r.files.end() )
{
// Add if no duplicate
cache_r.files.push_back( n );
@@ -166,7 +170,7 @@ namespace zypp
} // namespace
///////////////////////////////////////////////////////////////////

- CheckAccessDeleted::size_type CheckAccessDeleted::check()
+ CheckAccessDeleted::size_type CheckAccessDeleted::check( bool verbose_r )
{
_data.clear();
std::vector<ProcInfo> data;
@@ -187,7 +191,7 @@ namespace zypp
}
else
{
- addCacheIf( cache, line );
+ addCacheIf( cache, line, verbose_r );
}
}
addDataIf( data, cache );
diff --git a/zypp/misc/CheckAccessDeleted.h b/zypp/misc/CheckAccessDeleted.h
index cb8b545..92c0190 100644
--- a/zypp/misc/CheckAccessDeleted.h
+++ b/zypp/misc/CheckAccessDeleted.h
@@ -70,10 +70,18 @@ namespace zypp

public:
/** Check for running processes which access deleted executables or
libraries.
+ *
+ * Per default \ref check will try guess and collect executables and
+ * libraries only by looking at the files path and name. (e.g named
+ * \c lib* or located in \c *bin/).
+ *
+ * A verbose check will omit this test and collect all processes uning
+ * any deleted file.
+ *
* \return the number of processes found.
* \throws Exception On error collecting the data (e.g. no lsof
installed)
*/
- size_type check();
+ size_type check( bool verbose_r = false );

bool empty() const { return _data.empty(); }
size_type size() const { return _data.size(); }
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages