From 65821e8e792a253e5baa1d3633ff115702769b84 Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Mon, 8 Jun 2015 12:59:39 +0200 Subject: [PATCH] ccpp: don't save the system logs by default Saving the system logs if uid equals 0 was a bad idea because we are not sure who really owns the problem directory. It could be reintroduced when we rewrite those shell script lines in Python/C or better we should store the system logs in a private element (#989). This patch also removes the support for /var/log/messages because it was making the whole post-create event unnecessarily complex and we can count on the fact that all currently supported systems use systemd-journald. Related: rhbz#1212868 Signed-off-by: Jakub Filak --- src/plugins/ccpp_event.conf | 46 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/plugins/ccpp_event.conf b/src/plugins/ccpp_event.conf index 809c3b7..227776d 100644 --- a/src/plugins/ccpp_event.conf +++ b/src/plugins/ccpp_event.conf @@ -29,34 +29,24 @@ EVENT=post-create analyzer=CCpp # Can't do it as analyzer step, non-root can't read log. executable=`cat executable` && base_executable=${executable##*/} && - # Test if the current version of journalctl has --system switch - journalctl --system -n1 >/dev/null - if [ $? -ne 0 ]; - then - # Remove the exit below if you don't mind sharing data from the - # system logs with unprivileged users -> bugzilla.redhat.com/1212868 - exit 0 - # It's not an error if /var/log/messages isn't readable: - test -f /var/log/messages || exit 0 - test -r /var/log/messages || exit 0 - log=`grep -F -e "$base_executable" /var/log/messages | tail -99` - else - uid=`cat uid` && - ( - # Remove the line below if you don't mind sharing data from the - # system logs with unprivileged users -> bugzilla.redhat.com/1212868 - [ "$uid" -ne 0 ] && exit 0 - log="[System Logs]:\n" && - log=$log`journalctl -b --since=-3m --system -n 99 _COMM="$base_executable"` - ) && - log=$log"\n[User Logs]:\n" && - log=$log`journalctl -b --since=-3m -n 99 _COMM="$base_executable" _UID="$uid"` && - log=`echo -e "$log"` - fi - if test -n "$log"; then - printf "%s\n" "$log" >var_log_messages - # echo "Element 'var_log_messages' saved" - fi + uid=`cat $DUMP_DIR/uid` && + { + user_log=`journalctl -b --since=-3m -n 99 _COMM="$base_executable" _UID="$uid"` && + test -n "$user_log" && printf "User logs:\n%s\n" "$user_log" >$DUMP_DIR/var_log_messages + # Do not use '&&' here because if $user_log is the empty string + # then the script does not continue to get the system logs + { + # Remove the line below if you don't mind sharing data from the + # system logs with unprivileged users -> bugzilla.redhat.com/1212868 + false && + system_log=$log`journalctl -b --since=-3m --system -n 99 _COMM="$base_executable"` && + test -n "$system_log" && printf "System logs:\n%s\n" "$system_log" >>$DUMP_DIR/var_log_messages + # Always exit with true here, because the false at + # the beginning would cause the post-create hook to remove + # the current problem directory. + true + } + } ) EVENT=collect_xsession_errors analyzer=CCpp dso_list~=.*/libX11.* -- 2.1.0