Author: mvidner
Date: Thu Aug 13 09:14:51 2009
New Revision: 58332
URL: http://svn.opensuse.org/viewcvs/yast?rev=58332&view=rev
Log:
Applied the following fixes from Factory (bnc#530260):
- avoid y2log in both signal handler and forked children (bnc#493152)
- Resurrected logging in the signal handler, into
/var/log/YaST2/signal (or ./y2signal.log) (bnc#493152#c33).
- /var/log/YaST2/signal: do not make it executable
- 2.17.30
(and deleted ****ing wrong svn:mergeinfo from the subtree)
Modified:
branches/SuSE-Code-11-Branch/core/ (props changed)
branches/SuSE-Code-11-Branch/core/VERSION
branches/SuSE-Code-11-Branch/core/agent-any/doc/ag_anyagent.html (props changed)
branches/SuSE-Code-11-Branch/core/agent-dummy/doc/ag_dummy.html (props changed)
branches/SuSE-Code-11-Branch/core/agent-ini/doc/ag_ini.html (props changed)
branches/SuSE-Code-11-Branch/core/agent-modules/doc/ag_modules.html (props changed)
branches/SuSE-Code-11-Branch/core/agent-process/doc/ag_process.html (props changed)
branches/SuSE-Code-11-Branch/core/agent-resolver/doc/ag_resolver.html (props changed)
branches/SuSE-Code-11-Branch/core/agent-system/src/ShellCommand.cc
branches/SuSE-Code-11-Branch/core/agents-perl/doc/ag_modinfo.html (props changed)
branches/SuSE-Code-11-Branch/core/agents-perl/doc/ag_yp_makefile.html (props changed)
branches/SuSE-Code-11-Branch/core/dbus/SCR_service/ (props changed)
branches/SuSE-Code-11-Branch/core/liby2/src/Y2ProgramComponent.cc
branches/SuSE-Code-11-Branch/core/liby2/src/genericfrontend.cc
branches/SuSE-Code-11-Branch/core/liby2dbus/ (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/DBusConn.cc (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/DBusConn.h (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/DBusMsg.cc (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/DBusMsg.h (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/Makefile.am (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/PolKit.cc (props changed)
branches/SuSE-Code-11-Branch/core/liby2dbus/src/PolKit.h (props changed)
branches/SuSE-Code-11-Branch/core/liby2util-r/src/y2log.cc
branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
Modified: branches/SuSE-Code-11-Branch/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/VERSION?rev=58332&r1=58331&r2=58332&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/VERSION (original)
+++ branches/SuSE-Code-11-Branch/core/VERSION Thu Aug 13 09:14:51 2009
@@ -1 +1 @@
-2.17.29
+2.17.30
Modified: branches/SuSE-Code-11-Branch/core/agent-system/src/ShellCommand.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-system/src/ShellCommand.cc?rev=58332&r1=58331&r2=58332&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-system/src/ShellCommand.cc (original)
+++ branches/SuSE-Code-11-Branch/core/agent-system/src/ShellCommand.cc Thu Aug 13 09:14:51 2009
@@ -117,7 +117,7 @@
FILE *stream2 = fdopen (pipe2[0], "r");
if (stream2 == 0)
{
- y2error ("stream2 fdopen error");
+ y2error ("stream2 fdopen error");
_exit (1);
}
close (pipe2[1]);
@@ -126,7 +126,8 @@
{
if (out)
fputs (s2, out);
- y2debug ("%s", s2);
+ //bnc#493152#c24
+ //y2debug ("%s", s2);
}
fclose (stream2);
@@ -154,7 +155,7 @@
else
ret = WTERMSIG (ret) + 128;
- y2debug ("Exit status is %d", ret);
+ //y2debug ("Exit status is %d", ret);
if (!tempdir.empty ())
{
Modified: branches/SuSE-Code-11-Branch/core/liby2/src/Y2ProgramComponent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/liby2/src/Y2ProgramComponent.cc?rev=58332&r1=58331&r2=58332&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/liby2/src/Y2ProgramComponent.cc (original)
+++ branches/SuSE-Code-11-Branch/core/liby2/src/Y2ProgramComponent.cc Thu Aug 13 09:14:51 2009
@@ -291,13 +291,14 @@
// Call chroot if desired.
if (chroot_path == "" || chroot_path == "/") {
- y2debug ("Going to execute %s", bin_file.c_str ());
+ //bnc#493152#c24
+ //y2debug ("Going to execute %s", bin_file.c_str ());
} else {
- y2debug ("Going to execute %s with chroot %s", bin_file.c_str (),
- chroot_path.c_str ());
+ /*y2debug ("Going to execute %s with chroot %s", bin_file.c_str (),
+ chroot_path.c_str ());*/
if (chroot (chroot_path.c_str ()) != 0) {
- y2error ("Cannot chroot to %s: %s", chroot_path.c_str (),
- strerror (errno));
+ /*y2error ("Cannot chroot to %s: %s", chroot_path.c_str (),
+ strerror (errno));*/
_exit (5);
}
@@ -307,7 +308,7 @@
execv (bin_file.c_str (), argv); // execute program
// this code is only reached if exec failed
- y2error ("Cannot execute external program %s", bin_file.c_str ());
+ //y2error ("Cannot execute external program %s", bin_file.c_str ());
_exit (5); // No sense in returning! I am forked away!!
}
Modified: branches/SuSE-Code-11-Branch/core/liby2/src/genericfrontend.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/liby2/src/genericfrontend.cc?rev=58332&r1=58331&r2=58332&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/liby2/src/genericfrontend.cc (original)
+++ branches/SuSE-Code-11-Branch/core/liby2/src/genericfrontend.cc Thu Aug 13 09:14:51 2009
@@ -69,9 +69,9 @@
#include
#include
#include
+#include
#include <sstream>
#include <iomanip>
-#include
#include <string>
#include
@@ -103,99 +103,139 @@
static void print_help ();
static void print_error (const char*, ...) __attribute__ ((format (printf, 1, 2)));
static bool has_parens (const char* arg);
-string demangle( const char * mangled );
+
+int signal_log_fd; // fd to use for logging in signal handler
+
+static
+void
+signal_log_to_fd (int fd, const char * cs)
+{
+ ssize_t n = strlen (cs);
+ while (true) {
+ ssize_t w = write(fd, cs, n);
+ if (w == n)
+ break; // success
+ else if (w == -1) {
+ if (errno == EINTR) {
+ // perror("gotcha"); // bnc#470645
+ }
+ else {
+ perror("write"); // other cases
+ break;
+ }
+ }
+ else {
+ errno = 0;
+ cs += w;
+ n -= w;
+ }
+ }
+
+}
+
+static
+void
+signal_log (const char * cs)
+{
+ signal_log_to_fd (signal_log_fd, cs);
+}
static
bool
-log_blanik (const string & s)
+signal_log_ss (const string & s)
{
- y2lograw (s.c_str ());
+ signal_log (s.c_str ());
return true;
}
+
+static
+void
+signal_log_timestamp ()
+{
+ char buffer[200];
+ time_t time_time;
+ struct tm tm_time;
+
+ time_time = time(NULL);
+ localtime_r (&time_time, &tm_time);
+
+ if (strftime(buffer, sizeof(buffer), "=== %F %T %z ===\n", &tm_time) != 0)
+ {
+ signal_log (buffer);
+ }
+}
+
// fate#302166 "cache yast debugging logs in case of failure"
static
-void log_stored_debug ()
+void signal_log_stored_debug ()
{
- y2error ("Liberating suppressed debugging messages:");
- blanik.for_each (log_blanik);
- y2error ("End of suppressed debugging messages");
+ signal_log ("Liberating suppressed debugging messages:\n");
+ blanik.for_each (signal_log_ss);
+ signal_log ("End of suppressed debugging messages\n");
}
// FATE 302167, info '(libc) Backtraces'
void
-log_backtrace ()
+signal_log_backtrace ()
{
static const int N = 100;
void *frames[N];
size_t size = backtrace (frames, N);
- char ** strings = backtrace_symbols (frames, size);
+ // demangling is not signal safe
+ signal_log ("Backtrace: (use c++filt to demangle)\n");
+ backtrace_symbols_fd (frames, size, signal_log_fd);
+}
- std::stringstream backtrace;
+void
+signal_log_open ()
+{
+ signal_log_fd = -1;
+
+ const char * logfns[] = {
+ "/var/log/YaST2/signal",
+ "y2signal.log",
+ NULL, // sentinel
+ };
- for (size_t i = 0; i < size; ++i)
+ for (const char ** logfn_p = &logfns[0]; *logfn_p != NULL; ++logfn_p)
{
- backtrace << " Frame "
- << std::setw( 2 ) << i << ": "
- << demangle( strings[i] ) << "\n";
+ signal_log_fd = open (*logfn_p, O_WRONLY | O_CREAT | O_APPEND, 0600);
+ if (signal_log_fd != -1)
+ break;
}
-
- y2error( "Back trace:\n\n%s\n== End of back trace ===\n",
- backtrace.str().c_str() );
-
- free (strings);
}
-
-
-string demangle( const char * mangled )
+void
+signal_handler (int sig)
{
- const char * func_begin = strchr( mangled, '(' );
-
- if ( ! func_begin )
- return string( mangled );
-
- func_begin++; // skip '('
-
- string func( func_begin );
- std::size_t func_end = func.find_first_of( ")+" );
-
- if ( func_end != string::npos )
- func.erase( func_end );
+ signal (sig, SIG_IGN);
- int status = 0;
- char * demangled_name =
- abi::__cxa_demangle( func.c_str(),
- 0, // output buffer
- 0, // length
- & status );
+ // bnc#493152#c19 only signal-safe functions are allowed
+ char buffer[200];
+ int n = snprintf (buffer, sizeof(buffer),
+ "YaST got signal %d at YCP file %s:%d\n",
+ sig, ee.filename ().c_str (), ee.linenumber ());
+ if (n >= (int)sizeof(buffer) || n < 0)
+ strcpy (buffer, "YaST got a signal.\n");
+ signal_log_to_fd (STDERR_FILENO, buffer);
- if ( status == 0 && demangled_name )
+ signal_log_open ();
+ if (signal_log_fd == -1)
{
- func = string( demangled_name );
- free( demangled_name ); // abi::__cxa_demangle uses malloc()
-
- string lib_name = string( mangled, func_begin - mangled -1 );
-
- return lib_name + " " + func;
+ signal_log_to_fd (STDERR_FILENO, "Could not open log file.\n");
}
else
{
- return string( mangled );
- }
-}
+ signal_log_timestamp ();
+ signal_log (buffer);
+ signal_log_stored_debug ();
+ signal_log_backtrace ();
+ if (close (signal_log_fd) == -1)
+ perror ("log close");
+ }
-void
-signal_handler (int sig)
-{
- signal (sig, SIG_IGN);
- fprintf (stderr, "YaST got signal %d at YCP file %s:%d\n",
- sig, ee.filename ().c_str (), ee.linenumber ());
- y2error ("got signal %d at YCP file %s:%d",
- sig, ee.filename ().c_str (), ee.linenumber ());
- log_stored_debug ();
- log_backtrace ();
// bye
signal (sig, SIG_DFL);
kill ( getpid (), sig);
Modified: branches/SuSE-Code-11-Branch/core/liby2util-r/src/y2log.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/liby2util-r/src/y2log.cc?rev=58332&r1=58331&r2=58332&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/liby2util-r/src/y2log.cc (original)
+++ branches/SuSE-Code-11-Branch/core/liby2util-r/src/y2log.cc Thu Aug 13 09:14:51 2009
@@ -119,7 +119,10 @@
FILE * newstderr = fdopen( dupstderr, "a" );
if ( newstderr == NULL ) {
- fprintf( Y2LOG_STDERR, "y2log: Can't fdopen new stderr: %s.\n", strerror (errno) );
+ char buf[100];
+ //bnc#493152#c22
+ strerror_r(errno, buf, sizeof(buf)-1);
+ fprintf( Y2LOG_STDERR, "y2log: Can't fdopen new stderr: %s.\n", buf);
}
else {
fcntl (fileno (newstderr), F_SETFD, fcntl (fileno (newstderr), F_GETFD) | FD_CLOEXEC);
@@ -127,7 +130,9 @@
}
}
else {
- fprintf( Y2LOG_STDERR, "y2log: Can't dup stderr: %s.\n", strerror (errno) );
+ char buf[100];
+ strerror_r(errno, buf, sizeof(buf)-1);
+ fprintf( Y2LOG_STDERR, "y2log: Can't dup stderr: %s.\n", buf );
}
return 1;
}
@@ -145,8 +150,10 @@
logfile = fopen (logname, "a");
}
if (!logfile && !log_simple) {
+ char buf[100];
+ strerror_r(errno, buf, sizeof(buf)-1);
fprintf (Y2LOG_STDERR, "y2log: Error opening logfile '%s': %s.\n",
- logname, strerror (errno));
+ logname, buf);
return NULL;
}
}
@@ -244,17 +251,19 @@
#if 1
// just 1 second precision
time_t timestamp = time (NULL);
- struct tm *brokentime = localtime (×tamp);
+ struct tm brokentime;
+ localtime_r (×tamp, &brokentime);
char date[50]; // that's big enough
- strftime (date, sizeof (date), Y2LOG_DATE, brokentime);
+ strftime (date, sizeof (date), Y2LOG_DATE, &brokentime);
#else
// 1 millisecond precision (use only for testing)
timeval time;
gettimeofday (&time, NULL);
time_t timestamp = time.tv_sec;
- struct tm *brokentime = localtime (×tamp);
+ struct tm brokentime;
+ localtime_r (×tamp, &brokentime);
char tmp1[50], date[50]; // that's big enough
- strftime (tmp1, sizeof (tmp1), Y2LOG_DATE, brokentime);
+ strftime (tmp1, sizeof (tmp1), Y2LOG_DATE, &brokentime);
snprintf (date, sizeof (date), "%s.%03ld", tmp1, time.tv_usec / 1000);
#endif
Modified: branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/package/yast2-core.changes?rev=58332&r1=58331&r2=58332&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/package/yast2-core.changes (original)
+++ branches/SuSE-Code-11-Branch/core/package/yast2-core.changes Thu Aug 13 09:14:51 2009
@@ -1,4 +1,14 @@
-------------------------------------------------------------------
+Thu Aug 13 09:06:06 CEST 2009 - mvidner@suse.cz
+
+- Applied the following fixes from Factory (bnc#530260):
+- avoid y2log in both signal handler and forked children (bnc#493152)
+- Resurrected logging in the signal handler, into
+ /var/log/YaST2/signal (or ./y2signal.log) (bnc#493152#c33).
+- /var/log/YaST2/signal: do not make it executable
+- 2.17.30
+
+-------------------------------------------------------------------
Mon Feb 9 13:33:48 CET 2009 - lslezak@suse.cz
- SCR DBus service - improved reading DBus messages, it decreases
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org