Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libstorage-ng for openSUSE:Factory checked in at 2021-06-24 18:22:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libstorage-ng (Old) and /work/SRC/openSUSE:Factory/.libstorage-ng.new.2625 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libstorage-ng" Thu Jun 24 18:22:13 2021 rev:119 rq:901126 version:4.4.15 Changes: -------- --- /work/SRC/openSUSE:Factory/libstorage-ng/libstorage-ng.changes 2021-06-15 16:37:19.313691915 +0200 +++ /work/SRC/openSUSE:Factory/.libstorage-ng.new.2625/libstorage-ng.changes 2021-06-24 18:22:25.368906141 +0200 @@ -1,0 +2,8 @@ +Mon Jun 21 10:33:29 UTC 2021 - aschn...@suse.com + +- merge gh#openSUSE/libstorage-ng#814 +- removed unused code in SystemCmd +- use reference in loop +- 4.4.15 + +-------------------------------------------------------------------- Old: ---- libstorage-ng-4.4.14.tar.xz New: ---- libstorage-ng-4.4.15.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libstorage-ng.spec ++++++ --- /var/tmp/diff_new_pack.szrNqc/_old 2021-06-24 18:22:25.920906753 +0200 +++ /var/tmp/diff_new_pack.szrNqc/_new 2021-06-24 18:22:25.924906758 +0200 @@ -18,7 +18,7 @@ %define libname %{name}1 Name: libstorage-ng -Version: 4.4.14 +Version: 4.4.15 Release: 0 Summary: Library for storage management License: GPL-2.0-only ++++++ libstorage-ng-4.4.14.tar.xz -> libstorage-ng-4.4.15.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.14/VERSION new/libstorage-ng-4.4.15/VERSION --- old/libstorage-ng-4.4.14/VERSION 2021-06-10 12:22:52.000000000 +0200 +++ new/libstorage-ng-4.4.15/VERSION 2021-06-21 12:33:29.000000000 +0200 @@ -1 +1 @@ -4.4.14 +4.4.15 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.14/storage/Utils/SystemCmd.cc new/libstorage-ng-4.4.15/storage/Utils/SystemCmd.cc --- old/libstorage-ng-4.4.14/storage/Utils/SystemCmd.cc 2021-06-10 12:22:52.000000000 +0200 +++ new/libstorage-ng-4.4.15/storage/Utils/SystemCmd.cc 2021-06-21 12:33:29.000000000 +0200 @@ -25,8 +25,6 @@ #include <unistd.h> #include <errno.h> #include <fcntl.h> -#include <ostream> -#include <fstream> #include <sys/wait.h> #include <string> #include <sstream> @@ -62,7 +60,7 @@ SystemCmd::SystemCmd(const Options& options) - : options(options), _combineOutput(false), _execInBackground(false), _cmdRet(0), _cmdPid(0) + : options(options), _cmdRet(0), _cmdPid(0) { y2mil("constructor SystemCmd(\"" << command() << "\")"); @@ -189,7 +187,6 @@ { y2mil("SystemCmd Executing:\"" << command() << "\""); y2mil("timestamp " << timestamp()); - _execInBackground = false; ret = doExecute(); } @@ -203,78 +200,6 @@ int - SystemCmd::executeBackground() - { - y2mil("SystemCmd Executing (Background): \"" << command() << "\""); - _execInBackground = true; - return doExecute(); - } - - - int - SystemCmd::executeRestricted(long unsigned maxTimeSec, long unsigned maxLineOut, - bool& timeExceeded_ret, bool& linesExceeded_ret) - { - y2mil("cmd:" << command() << " MaxTime:" << maxTimeSec << " MaxLines:" << maxLineOut); - timeExceeded_ret = linesExceeded_ret = false; - int ret = executeBackground(); - unsigned long ts = 0; - unsigned long ls = 0; - unsigned long start_time = time(NULL); - while ( !timeExceeded_ret && !linesExceeded_ret && !doWait( false, ret ) ) - { - if ( maxTimeSec>0 ) - { - ts = time(NULL)-start_time; - y2mil( "time used:" << ts ); - } - if ( maxLineOut>0 ) - { - ls = stdout().size() + stderr().size(); - y2mil( "lines out:" << ls ); - } - timeExceeded_ret = maxTimeSec>0 && ts>maxTimeSec; - linesExceeded_ret = maxLineOut>0 && ls>maxLineOut; - sleep( 1 ); - } - if ( timeExceeded_ret || linesExceeded_ret ) - { - int r = kill( _cmdPid, SIGKILL ); - y2mil( "kill pid:" << _cmdPid << " ret:" << r ); - unsigned count=0; - int cmdStatus; - int waitpidRet = -1; - while ( count<5 && waitpidRet<=0 ) - { - waitpidRet = waitpid( _cmdPid, &cmdStatus, WNOHANG ); - y2mil( "waitpid:" << waitpidRet ); - count++; - sleep( 1 ); - } - /* - r = kill( _cmdPid, SIGKILL ); - y2mil( "kill pid:" << _cmdPid << " ret:" << r ); - count=0; - waitDone = false; - while ( count<8 && !waitDone ) - { - y2mil( "doWait:" << count ); - waitDone = doWait( false, ret ); - count++; - sleep( 1 ); - } - */ - _cmdRet = -257; - } - else - _cmdRet = ret; - y2mil("ret:" << ret << " timeExceeded:" << timeExceeded_ret - << " linesExceeded_ret:" << linesExceeded_ret); - return ret; - } - - - int SystemCmd::doExecute() { y2deb("command:" << command()); @@ -298,7 +223,7 @@ SYSCALL_FAILED( "pipe stdout creation failed" ); ok = false; } - if ( !_combineOutput && pipe(serr)<0 ) + if ( pipe(serr)<0 ) { SYSCALL_FAILED( "pipe stderr creation failed" ); ok = false; @@ -315,15 +240,12 @@ { SYSCALL_FAILED( "fcntl O_NONBLOCK failed for stdout" ); } - if ( !_combineOutput ) + _pfds[2].fd = serr[0]; + if ( fcntl( _pfds[2].fd, F_SETFL, O_NONBLOCK )<0 ) { - _pfds[2].fd = serr[0]; - if ( fcntl( _pfds[2].fd, F_SETFL, O_NONBLOCK )<0 ) - { - SYSCALL_FAILED( "fcntl O_NONBLOCK failed for stderr" ); - } + SYSCALL_FAILED( "fcntl O_NONBLOCK failed for stderr" ); } - y2deb("sout:" << _pfds[1].fd << " serr:" << (_combineOutput?-1:_pfds[2].fd)); + y2deb("sout:" << _pfds[1].fd << " serr:" << _pfds[2].fd); const vector<const char*> env = make_env(); @@ -339,11 +261,7 @@ { SYSCALL_FAILED_NOTHROW( "dup2 stdout failed in child process" ); } - if ( !_combineOutput && dup2( serr[1], STDERR_FILENO )<0 ) - { - SYSCALL_FAILED_NOTHROW( "dup2 stderr failed in child process" ); - } - if ( _combineOutput && dup2( STDOUT_FILENO, STDERR_FILENO )<0 ) + if ( dup2( serr[1], STDERR_FILENO )<0 ) { SYSCALL_FAILED_NOTHROW( "dup2 stderr failed in child process" ); } @@ -355,7 +273,7 @@ { SYSCALL_FAILED_NOTHROW( "close( stdout ) failed in child process" ); } - if ( !_combineOutput && close( serr[0] )<0 ) + if ( close( serr[0] )<0 ) { SYSCALL_FAILED_NOTHROW( "close( stderr ) failed in child process" ); } @@ -386,7 +304,7 @@ { SYSCALL_FAILED_NOTHROW( "close( stdout ) in parent failed" ); } - if ( !_combineOutput && close( serr[1] )<0 ) + if ( close( serr[1] )<0 ) { SYSCALL_FAILED_NOTHROW( "close( stderr ) in parent failed" ); } @@ -403,19 +321,15 @@ { SYSCALL_FAILED_NOTHROW( "fdopen( stdout ) failed" ); } - if ( !_combineOutput ) - { - _files[IDX_STDERR] = fdopen( serr[0], "r" ); - if ( _files[IDX_STDERR] == NULL ) - { - SYSCALL_FAILED_NOTHROW( "fdopen( stderr ) failed" ); - } - } - if ( !_execInBackground ) + _files[IDX_STDERR] = fdopen( serr[0], "r" ); + if ( _files[IDX_STDERR] == NULL ) { - doWait( true, _cmdRet ); - y2mil("stopwatch " << stopwatch << " for \"" << command() << "\""); + SYSCALL_FAILED_NOTHROW( "fdopen( stderr ) failed" ); } + + doWait( _cmdRet ); + y2mil("stopwatch " << stopwatch << " for \"" << command() << "\""); + break; } } @@ -436,16 +350,16 @@ bool - SystemCmd::doWait( bool hang, int& cmdRet_ret ) + SystemCmd::doWait( int& cmdRet_ret ) { int waitpidRet; int cmdStatus; do { - y2deb("[0] id:" << _pfds[1].fd << " ev:" << hex << (unsigned)_pfds[1].events << dec << " [1] fs:" << - (_combineOutput?-1:_pfds[2].fd) << " ev:" << hex << (_combineOutput?0:(unsigned)_pfds[2].events)); - int sel = poll( _pfds, _combineOutput?2:3, 1000 ); + y2deb("[1] fd:" << _pfds[1].fd << " ev:" << hex << (unsigned)(_pfds[1].events) << dec << " " + "[2] fd:" << _pfds[2].fd << " ev:" << hex << (unsigned)(_pfds[2].events)); + int sel = poll( _pfds, 3, 1000 ); if (sel < 0) { SYSCALL_FAILED_NOTHROW( "poll() failed" ); @@ -461,7 +375,7 @@ waitpidRet = waitpid( _cmdPid, &cmdStatus, WNOHANG ); y2deb("Wait ret:" << waitpidRet); } - while ( hang && waitpidRet == 0 ); + while ( waitpidRet == 0 ); if ( waitpidRet != 0 ) { @@ -473,11 +387,8 @@ } fclose( _files[IDX_STDOUT] ); _files[IDX_STDOUT] = NULL; - if ( !_combineOutput ) - { - fclose( _files[IDX_STDERR] ); - _files[IDX_STDERR] = NULL; - } + fclose( _files[IDX_STDERR] ); + _files[IDX_STDERR] = NULL; if (WIFEXITED(cmdStatus)) { cmdRet_ret = WEXITSTATUS(cmdStatus); @@ -500,7 +411,7 @@ } y2deb("Wait:" << waitpidRet << " pid:" << _cmdPid << " stat:" << cmdStatus << - " Hang:" << hang << " Ret:" << cmdRet_ret); + " Ret:" << cmdRet_ret); return waitpidRet != 0; } @@ -735,7 +646,7 @@ { string ret; - for (std::vector<string>::const_iterator it = strs.begin(); it != strs.end(); ++it) + for (vector<string>::const_iterator it = strs.begin(); it != strs.end(); ++it) { if (it != strs.begin()) ret.append(" "); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.14/storage/Utils/SystemCmd.h new/libstorage-ng-4.4.15/storage/Utils/SystemCmd.h --- old/libstorage-ng-4.4.14/storage/Utils/SystemCmd.h 2021-06-10 12:22:52.000000000 +0200 +++ new/libstorage-ng-4.4.15/storage/Utils/SystemCmd.h 2021-06-21 12:33:29.000000000 +0200 @@ -58,10 +58,7 @@ struct Options { Options(const string& command, ThrowBehaviour throw_behaviour = NoThrow) - : command(command), throw_behaviour(throw_behaviour), stdin_text(), - mockup_key(), log_line_limit(1000), - verify([](int exit_code){ return exit_code == 0; }), - env({ "LC_ALL=C", "LANGUAGE=C" }) {} + : command(command), throw_behaviour(throw_behaviour) {} /** * The command to be executed. @@ -71,7 +68,7 @@ /** * Should exceptions be thrown or not? */ - ThrowBehaviour throw_behaviour; + ThrowBehaviour throw_behaviour = NoThrow; /** * The stdin text to be sent via pipe to the command. @@ -86,20 +83,20 @@ /** * Limit for logged lines. */ - unsigned int log_line_limit; + unsigned int log_line_limit = 1000; /** * If throw_behaviour is DoThrow this function is used * additionally to verify if the command succeeded and if not an * exception is thrown. */ - std::function<bool(int)> verify; + std::function<bool(int)> verify = [](int exit_code){ return exit_code == 0; }; /** * Environment variables to override existing environment variables. Per * default this includes LC_ALL=C and LANGUAGE=C. */ - vector<string> env; + vector<string> env = { "LC_ALL=C", "LANGUAGE=C" }; }; @@ -122,35 +119,13 @@ */ virtual ~SystemCmd(); - protected: + private: /** * Execute the specified command in the foreground and return its exit code. **/ int execute(); - /** - * Execute the specified command in the background. - * The return value is only meaningful if < 0 (fork() or exec() failed). - */ - int executeBackground(); - - /** - * Execute the specified command in the foreground with some restrictions: - * - * If 'maxTimeSec' is > 0, the command is killed (with SIGKILL) after - * 'maxTimeSec' seconds, and 'timeExceeded_ret' is set to 'true'. - * - * If 'maxLineOut' is > 0, the command is killed (with SIGKILL) if more - * than 'maxLineOut' lines have been collected in both stdout and - * stderr. - * - * This function returns the command's exit code if none of the limits - * was exceeded, and -257 otherwise. - */ - int executeRestricted(unsigned long maxTimeSec, unsigned long maxLineOut, - bool& timeExceeded_ret, bool& linesExceeded_ret); - public: /** @@ -185,7 +160,7 @@ */ static string quote(const vector<string>& strs); - protected: + private: enum OutputStream { IDX_STDOUT, IDX_STDERR }; @@ -194,14 +169,14 @@ void invalidate(); void closeOpenFds() const; int doExecute(); - bool doWait(bool hang, int& cmdRet_ret); + bool doWait(int& cmdRet_ret); void checkOutput(); void sendStdin(); - void getUntilEOF(FILE* file, std::vector<string>& lines, + void getUntilEOF(FILE* file, vector<string>& lines, bool& newLineSeen_ret, bool isStderr) const; void extractNewline(const string& buffer, int count, bool& newLineSeen_ret, - string& text, std::vector<string>& lines) const; - void addLine(const string& text, std::vector<string>& lines) const; + string& text, vector<string>& lines) const; + void addLine(const string& text, vector<string>& lines) const; void logOutput() const; @@ -210,18 +185,12 @@ const string& mockup_key() const { return options.mockup_key.empty() ? options.command : options.mockup_key; } - // - // Data members - // - Options options; FILE* _files[2]; FILE* _childStdin; - std::vector<string> _outputLines[2]; + vector<string> _outputLines[2]; bool _newLineSeen[2]; - bool _combineOutput; - bool _execInBackground; int _cmdRet; int _cmdPid; struct pollfd _pfds[3]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.4.14/testsuite/helpers/TsCmp.cc new/libstorage-ng-4.4.15/testsuite/helpers/TsCmp.cc --- old/libstorage-ng-4.4.14/testsuite/helpers/TsCmp.cc 2021-06-10 12:22:52.000000000 +0200 +++ new/libstorage-ng-4.4.15/testsuite/helpers/TsCmp.cc 2021-06-21 12:33:29.000000000 +0200 @@ -295,7 +295,7 @@ for (const Entry& entry : entries) { - for (const string dep_id : entry.dep_ids) + for (const string& dep_id : entry.dep_ids) { if (ids.find(dep_id) == ids.end()) ST_THROW(Exception("unknown dependency-id"));