diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-29 14:07:18 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-29 14:07:18 +0200 |
| commit | cef7bce317368cce6c87d9bcf9745e43d1866076 (patch) | |
| tree | d5f8c595fbf26f3331781cbc61d5f4b85e81af0e | |
| parent | d5bdbc372f3d6708df787d2f4d26bbd2134f2926 (diff) | |
| download | abrt-cef7bce317368cce6c87d9bcf9745e43d1866076.tar.gz abrt-cef7bce317368cce6c87d9bcf9745e43d1866076.tar.xz abrt-cef7bce317368cce6c87d9bcf9745e43d1866076.zip | |
add support for abrtd autostart
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | lib/Plugins/CCpp.cpp | 79 | ||||
| -rw-r--r-- | src/Daemon/Daemon.cpp | 8 | ||||
| -rw-r--r-- | src/Daemon/Makefile.am | 3 | ||||
| -rw-r--r-- | src/Daemon/com.redhat.abrt.service | 4 | ||||
| -rw-r--r-- | src/Gui/CCDBusBackend.py | 17 |
5 files changed, 76 insertions, 35 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 3276b24..a294941 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -174,10 +174,8 @@ static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktra ExecVP(args, atoi(UID.c_str()), pBacktrace); } -static void GetIndependentBacktrace(const std::string& pBacktrace, std::string& pIndependentBacktrace) +static std::string GetIndependentBacktrace(const std::string& pBacktrace) { - int ii = 0; - std::string line; std::string header; bool in_bracket = false; bool in_quote = false; @@ -188,10 +186,35 @@ static void GetIndependentBacktrace(const std::string& pBacktrace, std::string& bool has_bracket = false; std::set<std::string> set_headers; - while (ii < pBacktrace.length()) - { - if (pBacktrace[ii] == '#' && !in_quote) - { + /* Backtrace example: + #0 0x00007f047e21af70 in __nanosleep_nocancel () from /lib64/libc-2.10.1.so + + Thread 1 (Thread 30750): + #0 0x00007f047e21af70 in __nanosleep_nocancel () from /lib64/libc-2.10.1.so + No symbol table info available. + #1 0x00000000004037bb in rpl_nanosleep (requested_delay=0x7fff8999e400, + remaining_delay=0x0) at nanosleep.c:69 + r = -516 + delay = {tv_sec = 1260, tv_nsec = 0} + t0 = {tv_sec = 12407, tv_nsec = 291505364} + #2 0x000000000040322b in xnanosleep (seconds=<value optimized out>) + at xnanosleep.c:112 + overflow = false + ts_sleep = {tv_sec = 1260, tv_nsec = 0} + __PRETTY_FUNCTION__ = "xnanosleep" + #3 0x0000000000401779 in main (argc=2, argv=0x7fff8999e598) at sleep.c:147 + i = 2 + seconds = 1260 + ok = true + */ + const char *bk = pBacktrace.c_str(); + while (*bk) + { + if (bk[0] == '#' + && bk[1] >= '0' && bk[1] <= '4' + && bk[2] == ' ' /* take only #0...#4 (5 last stack frames) */ + && !in_quote + ) { if (in_header && !has_filename) { header = ""; @@ -200,32 +223,32 @@ static void GetIndependentBacktrace(const std::string& pBacktrace, std::string& } if (in_header) { - if (isdigit(pBacktrace[ii]) && !in_quote && !has_at) + if (isdigit(*bk) && !in_quote && !has_at) { in_digit = true; } - else if (pBacktrace[ii] == '\\' && pBacktrace[ii + 1] == '\"') + else if (bk[0] == '\\' && bk[1] == '\"') { - ii++; + bk++; } - else if (pBacktrace[ii] == '\"') + else if (*bk == '\"') { in_quote = in_quote == true ? false : true; } - else if (pBacktrace[ii] == '(' && !in_quote) + else if (*bk == '(' && !in_quote) { in_bracket = true; in_digit = false; header += '('; } - else if (pBacktrace[ii] == ')' && !in_quote) + else if (*bk == ')' && !in_quote) { in_bracket = false; has_bracket = true; in_digit = false; header += ')'; } - else if (pBacktrace[ii] == '\n' && has_filename) + else if (*bk == '\n' && has_filename) { set_headers.insert(header); in_bracket = false; @@ -237,36 +260,39 @@ static void GetIndependentBacktrace(const std::string& pBacktrace, std::string& has_bracket = false; header = ""; } - else if (pBacktrace[ii] == ',' && !in_quote) + else if (*bk == ',' && !in_quote) { in_digit = false; } - else if (isspace(pBacktrace[ii]) && !in_quote) + else if (isspace(*bk) && !in_quote) { in_digit = false; } - else if (pBacktrace[ii] == 'a' && pBacktrace[ii + 1] == 't' && has_bracket && !in_quote) + else if (bk[0] == 'a' && bk[1] == 't' && has_bracket && !in_quote) { has_at = true; header += 'a'; } - else if (pBacktrace[ii] == ':' && has_at && isdigit(pBacktrace[ii + 1]) && !in_quote) + else if (bk[0] == ':' && has_at && isdigit(bk[1]) && !in_quote) { has_filename = true; } else if (in_header && !in_digit && !in_quote && !in_bracket) { - header += pBacktrace[ii]; + header += *bk; } } - ii++; + bk++; } - pIndependentBacktrace = ""; - std::set<std::string>::iterator it; - for (it = set_headers.begin(); it != set_headers.end(); it++) + + std::string pIndependentBacktrace; + std::set<std::string>::iterator it = set_headers.begin(); + for (; it != set_headers.end(); it++) { pIndependentBacktrace += *it; } + VERB3 log("IndependentBacktrace:'%s'", pIndependentBacktrace.c_str()); + return pIndependentBacktrace; } static void GetIndependentBuildIdPC(const std::string& pBuildIdPC, std::string& pIndependentBuildIdPC) @@ -274,7 +300,7 @@ static void GetIndependentBuildIdPC(const std::string& pBuildIdPC, std::string& int ii = 0; while (ii < pBuildIdPC.length()) { - std::string line = ""; + std::string line; int jj = 0; while (pBuildIdPC[ii] != '\n' && ii < pBuildIdPC.length()) @@ -501,7 +527,6 @@ std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) std::string backtrace; std::string executable; std::string package; - std::string independentBacktrace; { CDebugDump dd; dd.Open(pDebugDumpDir); @@ -509,7 +534,7 @@ std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) dd.LoadText(FILENAME_EXECUTABLE, executable); dd.LoadText(FILENAME_PACKAGE, package); } - GetIndependentBacktrace(backtrace, independentBacktrace); + std::string independentBacktrace = GetIndependentBacktrace(backtrace); return CreateHash(package + executable + independentBacktrace); } @@ -522,7 +547,7 @@ static bool DebuginfoCheckPolkit(int uid) if (child_pid == 0) { - //child + //child setuid(uid); result = polkit_check_authorization(getpid(), "org.fedoraproject.abrt.install-debuginfos"); diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 6445b6c..3b66bdb 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -647,13 +647,16 @@ int main(int argc, char** argv) textdomain(PACKAGE); #endif - while ((opt = getopt(argc, argv, "dv")) != -1) + while ((opt = getopt(argc, argv, "dsv")) != -1) { switch (opt) { case 'd': daemonize = false; break; + case 's': + start_syslog_logging(); + break; case 'v': g_verbose++; break; @@ -662,6 +665,7 @@ int main(int argc, char** argv) "Usage: abrt [-dv]\n" "\nOptions:" "\n\t-d\tDo not daemonize" + "\n\t-s\tLog to syslog even with -d" "\n\t-v\tVerbose" ); } @@ -701,7 +705,7 @@ int main(int argc, char** argv) } /* Child (daemon) continues */ setsid(); /* never fails */ - if (g_verbose == 0) + if (g_verbose == 0 && logmode != LOGMODE_SYSLOG) start_syslog_logging(); } diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index 49898c1..a21eb9c 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -39,6 +39,9 @@ dist_daemonconf_DATA = abrt.conf polkitconfdir = ${datadir}/polkit-1/actions dist_polkitconf_DATA = org.fedoraproject.abrt.policy +comredhatabrtservicedir = /usr/share/dbus-1/system-services +dist_comredhatabrtservice_DATA = com.redhat.abrt.service + man_MANS = abrt.8 abrt.conf.5 EXTRA_DIST = $(man_MANS) diff --git a/src/Daemon/com.redhat.abrt.service b/src/Daemon/com.redhat.abrt.service new file mode 100644 index 0000000..163f276 --- /dev/null +++ b/src/Daemon/com.redhat.abrt.service @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=com.redhat.abrt +Exec=/usr/sbin/abrtd -ds +User=root diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py index 7b952a6..844b371 100644 --- a/src/Gui/CCDBusBackend.py +++ b/src/Gui/CCDBusBackend.py @@ -122,12 +122,15 @@ class DBusManager(gobject.GObject): # self.emit("analyze-complete", dump) pass +# Seems to be not needed at all. Not only that, it is actively harmful +# when abrtd is autostarted by dbus-daemon: connect_to_daemon() would install +# duplicate signal handlers! def owner_changed_cb(self,name, old_owner, new_owner): if(name == CC_NAME and new_owner): - self.proxy = self.connect_to_daemon() + #self.proxy = self.connect_to_daemon() self.emit("daemon-state-changed", "up") if(name == CC_NAME and not(new_owner)): - self.proxy = None + #self.proxy = None self.emit("daemon-state-changed", "down") @@ -138,10 +141,12 @@ class DBusManager(gobject.GObject): self.uniq_name = self.bus.get_unique_name() if not self.bus: raise Exception(_("Can't connect to dbus")) - if self.bus.name_has_owner(CC_NAME): - self.proxy = self.bus.get_object(CC_IFACE, CC_PATH,introspect=False) - else: - raise Exception(_("Please check if abrt daemon is running.")) + self.proxy = self.bus.get_object(CC_IFACE, CC_PATH, introspect=False) + # Can't do this: abrtd may be autostarted by dbus-daemon + #if self.bus.name_has_owner(CC_NAME): + # self.proxy = self.bus.get_object(CC_IFACE, CC_PATH, introspect=False) + #else: + # raise Exception(_("Please check if abrt daemon is running.")) if self.proxy: self.cc = dbus.Interface(self.proxy, dbus_interface=CC_IFACE) |
