summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abrt-ccpp.init91
-rw-r--r--abrt.spec.in1
-rw-r--r--src/hooks/Makefile.am5
-rwxr-xr-xsrc/hooks/abrt-install-ccpp-hook97
4 files changed, 111 insertions, 83 deletions
diff --git a/abrt-ccpp.init b/abrt-ccpp.init
index 7f236237..8935378b 100644
--- a/abrt-ccpp.init
+++ b/abrt-ccpp.init
@@ -15,38 +15,8 @@
# Source function library.
. /etc/rc.d/init.d/functions
-# For debugging
-dry_run=false
-verbose=false
-
-# We don't have pid files, therefore have to use
-# a flag file in /var/lock/subsys to enable GUI service tools
-# to figure out our status
LOCK="/var/lock/subsys/abrt-ccpp"
-
-PATTERN_FILE="/proc/sys/kernel/core_pattern"
-SAVED_PATTERN_DIR="/var/run/abrt"
-SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern"
-HOOK_BIN="/usr/libexec/abrt-hook-ccpp"
-# Must match percent_specifiers[] order in abrt-hook-ccpp.c:
-PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %e"
-# Same, but with bogus "executable name" parameter
-PATTERN1="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t e"
-
-# core_pipe_limit specifies how many dump_helpers can run at the same time
-# 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing
-# process will be available for dump_helper.
-# 4 - means that 4 dump_helpers can run at the same time (the rest will also
-# run, but they will fail to read /proc/<pid>).
-#
-# This should be enough for ABRT, we can miss some crashes, but what are
-# the odds that more processes crash at the same time? And moreover,
-# do people want to save EVERY ONE of the crashes when they have
-# a crash storm? I don't think so.
-# The value of 4 has been recommended by nhorman.
-#
-CORE_PIPE_LIMIT_FILE="/proc/sys/kernel/core_pipe_limit"
-CORE_PIPE_LIMIT="4"
+INSTALL_HOOK="/usr/sbin/abrt-install-ccpp-hook"
RETVAL=0
@@ -58,46 +28,18 @@ check() {
start() {
check
- cur=`cat "$PATTERN_FILE"`
- cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
-
- # Is there a %e (executable name) in old pattern anywhere?
- if test x"${cur#.*%e}" = x"${cur}"; then
- # No. Can use PATTERN with less risk of overflow
- # on expansion (executable names can be LONG).
- # Overflow would cause kernel to abort coredump. BAD.
- PATTERN="$PATTERN1"
- fi
-
- $verbose && printf "cur:'%s'\n" "$cur"
- # Is it already installed?
- if test x"$cur_first" != x"|$HOOK_BIN"; then # no
- # It is not installed
- mkdir -p -- "$SAVED_PATTERN_DIR"
- printf "%s\n" "$cur" >"$SAVED_PATTERN_FILE"
- # Install new handler
- $verbose && printf "Installing to %s:'%s'\n" "$PATTERN_FILE" "$PATTERN"
- $dry_run || echo "$PATTERN" >"$PATTERN_FILE"
- $dry_run || touch -- "$LOCK"
-
- # Check core_pipe_limit and change it if it's 0,
- # otherwise the abrt-hook-ccpp won't be able to read /proc/<pid>
- # of the crashing process
- if test x"`cat "$CORE_PIPE_LIMIT_FILE"`" = x"0"; then
- echo "$CORE_PIPE_LIMIT" >"$CORE_PIPE_LIMIT_FILE"
- fi
- fi
+ $INSTALL_HOOK install
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch -- "$LOCK"
return $RETVAL
}
stop() {
check
- if test -f "$SAVED_PATTERN_FILE"; then
- $verbose && printf "Restoring to %s:'%s'\n" "$PATTERN_FILE" "`cat "$SAVED_PATTERN_FILE"`"
- $dry_run || cat "$SAVED_PATTERN_FILE" >"$PATTERN_FILE"
- fi
- $dry_run || rm -f -- "$LOCK"
+ $INSTALL_HOOK uninstall
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && rm -f -- "$LOCK"
return $RETVAL
}
@@ -128,25 +70,10 @@ restart)
restart
;;
condrestart)
- cur=`cat "$PATTERN_FILE"`
- cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
- # Is it already installed?
- if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
- $verbose && printf "Installed, re-installing\n"
- restart
- fi
+ $INSTALL_HOOK is-installed && restart
;;
status)
- cur=`cat "$PATTERN_FILE"`
- cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
- # Is it already installed?
- if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
- $verbose && printf "Installed\n"
- RETVAL=0
- else
- $verbose && printf "Not installed\n"
- RETVAL=3 # "stopped normally"
- fi
+ $INSTALL_HOOK is-installed && RETVAL=0 || RETVAL=3
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
diff --git a/abrt.spec.in b/abrt.spec.in
index 8b622429..3d9dd0d0 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -442,6 +442,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_bindir}/abrt-action-generate-backtrace
%{_bindir}/abrt-action-analyze-backtrace
%{_bindir}/abrt-action-list-dsos.py*
+%{_sbindir}/abrt-install-ccpp-hook
%{_sysconfdir}/%{name}/events.d/ccpp_events.conf
%{_sysconfdir}/%{name}/events/analyze_LocalGDB.xml
%{_sysconfdir}/%{name}/events/analyze_RetraceServer.xml
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index 3fdc59ec..49eddcf3 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -3,6 +3,9 @@ pluginsconfdir = $(PLUGINS_CONF_DIR)
dist_pluginsconf_DATA = \
CCpp.conf
+sbin_SCRIPTS = \
+ abrt-install-ccpp-hook
+
libexec_PROGRAMS = abrt-hook-ccpp
# abrt-hook-ccpp
@@ -24,7 +27,7 @@ abrt_hook_ccpp_LDADD = \
$(LIBREPORT_LIBS)
python_PYTHON = abrt.pth abrt_exception_handler.py
-EXTRA_DIST = abrt_exception_handler.py.in $(man_MANS)
+EXTRA_DIST = abrt_exception_handler.py.in abrt-install-ccpp-hook $(man_MANS)
CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc))
diff --git a/src/hooks/abrt-install-ccpp-hook b/src/hooks/abrt-install-ccpp-hook
new file mode 100755
index 00000000..12a443f0
--- /dev/null
+++ b/src/hooks/abrt-install-ccpp-hook
@@ -0,0 +1,97 @@
+#!/bin/bash
+# Install coredump handler which saves segfault data
+
+# For debugging
+
+dry_run=false
+verbose=false
+
+PATTERN_FILE="/proc/sys/kernel/core_pattern"
+SAVED_PATTERN_DIR="/var/run/abrt"
+SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern"
+HOOK_BIN="/usr/libexec/abrt-hook-ccpp"
+# Must match percent_specifiers[] order in abrt-hook-ccpp.c:
+PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %e"
+# Same, but with bogus "executable name" parameter
+PATTERN1="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t e"
+
+# core_pipe_limit specifies how many dump_helpers can run at the same time
+# 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing
+# process will be available for dump_helper.
+# 4 - means that 4 dump_helpers can run at the same time (the rest will also
+# run, but they will fail to read /proc/<pid>).
+#
+# This should be enough for ABRT, we can miss some crashes, but what are
+# the odds that more processes crash at the same time? And moreover,
+# do people want to save EVERY ONE of the crashes when they have
+# a crash storm? I don't think so.
+# The value of 4 has been recommended by nhorman.
+#
+CORE_PIPE_LIMIT_FILE="/proc/sys/kernel/core_pipe_limit"
+CORE_PIPE_LIMIT="4"
+
+start() {
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+
+ # Is there a %e (executable name) in old pattern anywhere?
+ if test x"${cur#.*%e}" = x"${cur}"; then
+ # No. Can use PATTERN with less risk of overflow
+ # on expansion (executable names can be LONG).
+ # Overflow would cause kernel to abort coredump. BAD.
+ PATTERN="$PATTERN1"
+ fi
+
+ $verbose && printf "cur:'%s'\n" "$cur"
+ # Is it already installed?
+ if test x"$cur_first" != x"|$HOOK_BIN"; then # no
+ # It is not installed
+ mkdir -p -- "$SAVED_PATTERN_DIR"
+ printf "%s\n" "$cur" >"$SAVED_PATTERN_FILE"
+ # Install new handler
+ $verbose && printf "Installing to %s:'%s'\n" "$PATTERN_FILE" "$PATTERN"
+ $dry_run || echo "$PATTERN" >"$PATTERN_FILE"
+
+ # Check core_pipe_limit and change it if it's 0,
+ # otherwise the abrt-hook-ccpp won't be able to read /proc/<pid>
+ # of the crashing process
+ if test x"`cat "$CORE_PIPE_LIMIT_FILE"`" = x"0"; then
+ echo "$CORE_PIPE_LIMIT" >"$CORE_PIPE_LIMIT_FILE"
+ fi
+ fi
+}
+
+stop() {
+ if test -f "$SAVED_PATTERN_FILE"; then
+ $verbose && printf "Restoring to %s:'%s'\n" "$PATTERN_FILE" "`cat "$SAVED_PATTERN_FILE"`"
+ $dry_run || cat "$SAVED_PATTERN_FILE" >"$PATTERN_FILE"
+ fi
+}
+
+status() {
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+ # Is it already installed?
+ if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
+ $verbose && printf "Installed\n"
+ return 0
+ else
+ $verbose && printf "Not installed\n"
+ return 1
+ fi
+}
+
+case "$1" in
+install)
+ start
+ ;;
+uninstall)
+ stop
+ ;;
+is-installed)
+ status
+ ;;
+*)
+ echo $"Usage: $0 {install|uninstall|is-installed}"
+ return 2
+esac