SET(LIBZYPP_MAJOR "6")
SET(LIBZYPP_COMPATMINOR "11")
SET(LIBZYPP_MINOR "13")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_PATCH "2")
#
-# LAST RELEASED: 6.13.1 (11)
+# LAST RELEASED: 6.13.2 (11)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
#=======
-------------------------------------------------------------------
+Wed Aug 26 15:55:22 CEST 2009 - ma@suse.de
+
+- Tune CheckAccessDeleted to focus on libraries and executables.
+- version 6.13.2 (11)
+
+-------------------------------------------------------------------
Thu Aug 6 18:18:21 CEST 2009 - ma@suse.de
- Provide class CheckAccessDeleted and command zypp-CheckAccessDeleted
{
std::cout << "Usage: " << progname << " [--help]" << std::endl;
std::cout << "List information about all running processe" << std::endl;
- std::cout << "which access deleted files or libraries." << std::endl;
+ std::cout << "which access deleted executables or libraries." << std::endl;
std::cout << " PID " << "process ID" << std::endl;
std::cout << " PPID " << "parent process ID" << std::endl;
std::cout << " UID " << "process user ID" << std::endl;
std::cout << " LOGIN " << "process login name" << std::endl;
std::cout << " COMMAND " << "process command name" << std::endl;
std::cout << " SERVICE " << "/etc/init.d/ script that might be used to restart the command (guessed)" << std::endl;
- std::cout << " FILES " << "list of deleted files or libraries accessed" << std::endl;
+ std::cout << " FILES " << "list of deleted executables or libraries accessed" << std::endl;
return 0;
}
std::cerr << progname << ": unexpected argument '" << argv[1] << "'" << std::endl;
MIL << " Take " << pinfo << endl;
}
- /** Add line to cache if it refers to a deleted file.
- * Either the link count \c(k) os \c 0, or if no link cout is present,
- * the filedescriptor/type \c (ft) is set to \c DEL.
+ /** Add line to cache if it refers to a deleted executable or library file:
+ * - Either the link count \c(k) os \c 0, or no link cout is present.
+ * - 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 )
{
- bool takeLine = false;
- const char * name = "";
+ const char * k = ".";
+ const char * f = ".";
+ const char * t = ".";
+ const char * n = ".";
- for_( ch, line_r.begin(), line_r.end() )
+ for_( ch, line_r.c_str(), ch+line_r.size() )
{
switch ( *ch )
{
case 'k':
- if ( ! takeLine && *(ch+1) == '0' && *(ch+2) == '\0' )
- takeLine = true;
- break;
+ if ( *(ch+1) != '0' ) // skip non-zero link counts
+ return;
+ k = ch+1;
+ break;
case 'f':
+ f = ch+1;
+ break;
case 't':
- if ( ! takeLine && *(ch+1) == 'D' && *(ch+2) == 'E' && *(ch+3) == 'L' && *(ch+4) == '\0' )
- takeLine = true;
+ t = ch+1;
break;
case 'n':
- name = &*(ch+1);
- break;
+ n = ch+1;
+ break;
}
if ( *ch == '\n' ) break; // end of data
do { ++ch; } while ( *ch != '\0' ); // skip to next field
}
- if ( takeLine )
- cache_r.files.push_back( name );
+
+ if ( !t || !f || !n )
+ return; // wrong filedescriptor/type/name
+
+ if ( !( ( *t == 'R' && *(t+1) == 'E' && *(t+2) == 'G' && *(t+3) == '\0' )
+ || ( *t == 'D' && *(t+1) == 'E' && *(t+2) == 'L' && *(t+3) == '\0' ) ) )
+ return; // wrong type
+
+ if ( !( ( *f == 'm' && *(f+1) == 'e' && *(f+2) == 'm' && *(f+3) == '\0' )
+ || ( *f == 't' && *(f+1) == 'x' && *(f+2) == 't' && *(f+3) == '\0' )
+ || ( *f == 'D' && *(f+1) == 'E' && *(f+2) == 'L' && *(f+3) == '\0' )
+ || ( *f == 'l' && *(f+1) == 't' && *(f+2) == 'x' && *(f+3) == '\0' ) ) )
+ return; // wrong filedescriptor type
+
+ std::string name( n );
+
+ if ( *f == 'm' || *f == 'D' ) // skip some wellknown nonlibrary memorymapped files
+ {
+ static const char * black[] = {
+ "/SYSV",
+ "/var/run/"
+ };
+ for_( it, arrayBegin( black ), arrayEnd( black ) )
+ {
+ if ( str::hasPrefix( n, *it ) )
+ return;
+ }
+ }
+
+ if ( std::find( cache_r.files.begin(), cache_r.files.end(), name ) == cache_r.files.end() )
+ {
+ // Add if no duplicate
+ cache_r.files.push_back( n );
+ }
}
/////////////////////////////////////////////////////////////////
} // namespace
{ /////////////////////////////////////////////////////////////////
/**
- * Check for running processes which access deleted files or libraries.
+ * Check for running processes which access deleted executables or libraries.
*
* Executed after commit, this gives a hint which processes/services
* need to be restarted.
*/
class CheckAccessDeleted
{
+
public:
/**
* Data about one running process accessing deleted files.
std::string puid; //!< process user ID
std::string login; //!< process login name
std::string command; //!< process command name
- std::vector<std::string> files; //!< list of deleted files or libraries accessed
+ std::vector<std::string> files; //!< list of deleted executables or libraries accessed
/** Guess if command was started by an \c /etc/init.d/ script.
* The name of an \c /etc/init.d/ script that might be used to restart the
{ if ( doCheck_r ) check(); }
public:
- /** Check for running processes which access deleted files or libraries.
+ /** Check for running processes which access deleted executables or libraries.
* \return the number of processes found.
* \throws Exception On error collecting the data (e.g. no lsof installed)
*/