* - 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;
|| ( *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[] = {
}
}
- 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 );
} // namespace
///////////////////////////////////////////////////////////////////
- CheckAccessDeleted::size_type CheckAccessDeleted::check()
+ CheckAccessDeleted::size_type CheckAccessDeleted::check( bool verbose_r )
{
_data.clear();
std::vector<ProcInfo> data;
}
else
{
- addCacheIf( cache, line );
+ addCacheIf( cache, line, verbose_r );
}
}
addDataIf( data, cache );
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(); }