[ABRT PATCH] do not store potentially big data in /tmp

Jakub Filak jfilak at redhat.com
Thu Aug 1 16:45:26 UTC 2013


Related to rhbz#990208

Signed-off-by: Jakub Filak <jfilak at redhat.com>
---
 configure.ac                                 |  6 ++
 src/daemon/Makefile.am                       |  2 +-
 src/daemon/abrt-handle-upload                | 90 ----------------------------
 src/daemon/abrt-handle-upload.in             | 90 ++++++++++++++++++++++++++++
 src/plugins/Makefile.am                      |  1 +
 src/plugins/abrt-action-analyze-vmcore.in    |  5 +-
 src/plugins/abrt-action-install-debuginfo.in |  7 ++-
 src/plugins/abrt-retrace-client.c            | 10 ++--
 8 files changed, 110 insertions(+), 101 deletions(-)
 delete mode 100755 src/daemon/abrt-handle-upload
 create mode 100755 src/daemon/abrt-handle-upload.in

diff --git a/configure.ac b/configure.ac
index d54c715..70fafe1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,6 +118,11 @@ AC_ARG_WITH([dbusinterfacedir],
         [], [with_dbusinterfacedir=${datadir}/dbus-1/interfaces])
 AC_SUBST([dbusinterfacedir], [$with_dbusinterfacedir])
 
+AC_ARG_WITH(largedatatmpdir,
+            [AS_HELP_STRING([--with-largedatatmpdir=DIR],
+                           [Directory where potentially large data are created (default: /var/tmp)])],
+            [], [with_largedatatmpdir="/var/tmp"])
+AC_SUBST([LARGE_DATA_TMP_DIR], [$with_largedatatmpdir])
 
 AC_CHECK_HEADER([sys/inotify.h], [],
    [AC_MSG_ERROR([sys/inotify.h is needed to build abrt])])
@@ -227,6 +232,7 @@ AC_CONFIG_FILES([
 	src/plugins/Makefile
 	src/Makefile
 	src/daemon/Makefile
+	src/daemon/abrt-handle-upload
 	src/hooks/Makefile
 	src/applet/Makefile
 	src/cli/Makefile
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index bb8a5f6..33eec63 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -84,7 +84,7 @@ dist_daemonconf_DATA = \
     abrt-action-save-package-data.conf \
     gpg_keys
 
-EXTRA_DIST = abrt-handle-upload
+EXTRA_DIST = abrt-handle-upload.in
 
 DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
 
diff --git a/src/daemon/abrt-handle-upload b/src/daemon/abrt-handle-upload
deleted file mode 100755
index 85123d2..0000000
--- a/src/daemon/abrt-handle-upload
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/sh
-# Called by abrtd when a new file is noticed in upload directory.
-# The task of this script is to unpack the file and move
-# problem data found in it to abrtd spool directory.
-#
-# Usage: abrt-handle-upload [-d] ABRT_SPOOL_DIR UPLOAD_DIR FILENAME
-#
-#   -d             - deletes an uploaded archive
-#   ABRT_SPOOL_DIR - a directory where valid uploaded archives are unpacked to
-#   UPLOAD_DIR     - a directory where uploaded archives are stored in
-#   FILENAME       - an uploaded archive file name
-
-#echo "Started: $0 $*"
-
-print_clean_and_die()
-{
-    printf "%s\n" "$*"
-    #echo delete_on_exit="$delete_on_exit"
-    test "$delete_on_exit" && rm -rf -- $delete_on_exit
-    exit $die_exitcode
-}
-
-die_exitcode=1
-delete_on_exit=""
-
-delete_archive=false
-if test x"$1" == x"-d"; then delete_archive=true; shift; fi
-
-abrt_dir="$1"
-upload_dir="$2"
-archive="$3"
-
-test -d "$abrt_dir" || print_clean_and_die "Not a directory: '$abrt_dir'"
-test -d "$upload_dir" || print_clean_and_die "Not a directory: '$upload_dir'"
-test x"${archive#/}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (starts with slash)"
-test x"${archive#.}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (starts with dot)"
-test x"${archive#*..}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains ..)"
-test x"${archive#* }" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains space)"
-# Note: next line has a tab!
-test x"${archive#*	}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains tab)"
-
-cd -- "$upload_dir" || print_clean_and_die "Can't chdir to '$upload_dir'"
-
-unpacker=""
-test x"${archive%.tar.gz}" != x"$archive" && unpacker="gunzip"
-test x"${archive%.tar.bz2}" != x"$archive" && unpacker="bunzip2"
-test x"${archive%.tar.xz}" != x"$archive" && unpacker="unxz"
-
-test "$unpacker" || print_clean_and_die "Unknown file type: '$archive'"
-
-workingdir=`mktemp -d "abrt_handle_upload.XXXXXXXXXX" --tmpdir=/tmp` || print_clean_and_die "Can't create working directory"
-delete_on_exit="$workingdir"
-
-tempdir="$workingdir/remote.`date +%Y-%m-%d-%H:%M:%S.%N`.$$"
-working_archive="$workingdir/$archive"
-
-if $delete_archive; then
-    mv -- "$archive" "$working_archive" || print_clean_and_die "Can't move '$archive' to '$working_archive'"
-else
-    cp -- "$archive" "$working_archive" || print_clean_and_die "Can't copy '$archive' to '$working_archive'"
-fi
-
-$unpacker -t -- "$working_archive" || print_clean_and_die "Verification error on '$archive'"
-
-echo "Unpacking '$archive'"
-mkdir "$tempdir" || print_clean_and_die "Can't create '$tempdir' directory"
-$unpacker <"$working_archive" | tar xf - -C "$tempdir" || print_clean_and_die "Can't unpack '$archive'"
-
-# The archive can contain either plain dump files
-# or one or more complete problem data directories.
-# Checking second possibility first.
-if test -f "$tempdir/analyzer" && test -f "$tempdir/time" && test -f "$tempdir/uid"; then
-    printf "1" >"$tempdir/remote"
-    mv -- "$tempdir" "$abrt_dir"
-else
-    (
-    cd -- "$tempdir" || exit
-    for d in *; do
-        test -d "$d" || continue
-        printf "1" >"$d/remote"
-        dst="$abrt_dir/$d"
-        test -e "$dst" && dst="$abrt_dir/$d.$$"
-        test -e "$dst" && continue
-        mv -- "$d" "$dst"
-    done
-    )
-fi
-
-die_exitcode=0
-print_clean_and_die "'$archive' processed successfully"
diff --git a/src/daemon/abrt-handle-upload.in b/src/daemon/abrt-handle-upload.in
new file mode 100755
index 0000000..e727db6
--- /dev/null
+++ b/src/daemon/abrt-handle-upload.in
@@ -0,0 +1,90 @@
+#!/bin/sh
+# Called by abrtd when a new file is noticed in upload directory.
+# The task of this script is to unpack the file and move
+# problem data found in it to abrtd spool directory.
+#
+# Usage: abrt-handle-upload [-d] ABRT_SPOOL_DIR UPLOAD_DIR FILENAME
+#
+#   -d             - deletes an uploaded archive
+#   ABRT_SPOOL_DIR - a directory where valid uploaded archives are unpacked to
+#   UPLOAD_DIR     - a directory where uploaded archives are stored in
+#   FILENAME       - an uploaded archive file name
+
+#echo "Started: $0 $*"
+
+print_clean_and_die()
+{
+    printf "%s\n" "$*"
+    #echo delete_on_exit="$delete_on_exit"
+    test "$delete_on_exit" && rm -rf -- $delete_on_exit
+    exit $die_exitcode
+}
+
+die_exitcode=1
+delete_on_exit=""
+
+delete_archive=false
+if test x"$1" == x"-d"; then delete_archive=true; shift; fi
+
+abrt_dir="$1"
+upload_dir="$2"
+archive="$3"
+
+test -d "$abrt_dir" || print_clean_and_die "Not a directory: '$abrt_dir'"
+test -d "$upload_dir" || print_clean_and_die "Not a directory: '$upload_dir'"
+test x"${archive#/}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (starts with slash)"
+test x"${archive#.}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (starts with dot)"
+test x"${archive#*..}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains ..)"
+test x"${archive#* }" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains space)"
+# Note: next line has a tab!
+test x"${archive#*	}" != x"$archive" && print_clean_and_die "Skipping: '$archive' (contains tab)"
+
+cd -- "$upload_dir" || print_clean_and_die "Can't chdir to '$upload_dir'"
+
+unpacker=""
+test x"${archive%.tar.gz}" != x"$archive" && unpacker="gunzip"
+test x"${archive%.tar.bz2}" != x"$archive" && unpacker="bunzip2"
+test x"${archive%.tar.xz}" != x"$archive" && unpacker="unxz"
+
+test "$unpacker" || print_clean_and_die "Unknown file type: '$archive'"
+
+workingdir=`mktemp -d "abrt_handle_upload.XXXXXXXXXX" --tmpdir=@LARGE_DATA_TMP_DIR@` || print_clean_and_die "Can't create working directory"
+delete_on_exit="$workingdir"
+
+tempdir="$workingdir/remote.`date +%Y-%m-%d-%H:%M:%S.%N`.$$"
+working_archive="$workingdir/$archive"
+
+if $delete_archive; then
+    mv -- "$archive" "$working_archive" || print_clean_and_die "Can't move '$archive' to '$working_archive'"
+else
+    cp -- "$archive" "$working_archive" || print_clean_and_die "Can't copy '$archive' to '$working_archive'"
+fi
+
+$unpacker -t -- "$working_archive" || print_clean_and_die "Verification error on '$archive'"
+
+echo "Unpacking '$archive'"
+mkdir "$tempdir" || print_clean_and_die "Can't create '$tempdir' directory"
+$unpacker <"$working_archive" | tar xf - -C "$tempdir" || print_clean_and_die "Can't unpack '$archive'"
+
+# The archive can contain either plain dump files
+# or one or more complete problem data directories.
+# Checking second possibility first.
+if test -f "$tempdir/analyzer" && test -f "$tempdir/time" && test -f "$tempdir/uid"; then
+    printf "1" >"$tempdir/remote"
+    mv -- "$tempdir" "$abrt_dir"
+else
+    (
+    cd -- "$tempdir" || exit
+    for d in *; do
+        test -d "$d" || continue
+        printf "1" >"$d/remote"
+        dst="$abrt_dir/$d"
+        test -e "$dst" && dst="$abrt_dir/$d.$$"
+        test -e "$dst" && continue
+        mv -- "$d" "$dst"
+    done
+    )
+fi
+
+die_exitcode=0
+print_clean_and_die "'$archive' processed successfully"
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 2638b0f..c0c0745 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -270,6 +270,7 @@ abrt_retrace_client_SOURCES = \
      $(GLIB_CFLAGS) \
      -D_GNU_SOURCE \
      -DDEFAULT_DUMP_DIR_MODE=$(DEFAULT_DUMP_DIR_MODE) \
+     -DLARGE_DATA_TMP_DIR=\"$(LARGE_DATA_TMP_DIR)\" \
      $(LIBREPORT_CFLAGS)
  abrt_retrace_client_LDADD = \
      $(LIBREPORT_LIBS) \
diff --git a/src/plugins/abrt-action-analyze-vmcore.in b/src/plugins/abrt-action-analyze-vmcore.in
index 9475137..6c27e9a 100644
--- a/src/plugins/abrt-action-analyze-vmcore.in
+++ b/src/plugins/abrt-action-analyze-vmcore.in
@@ -85,8 +85,9 @@ if __name__ == "__main__":
 
     if not tmpdir:
         # security people prefer temp subdirs in app's private dir, like /var/run/abrt
-        # for now, we use /tmp...
-        tmpdir = "/tmp/abrt-tmp-debuginfo-%s.%u" % (time.strftime("%Y-%m-%d-%H:%M:%S"), os.getpid())
+        # and we switched to /tmp but Fedora feature tmp-on-tmpfs appeared, hence we must
+        # not use /tmp for potential big data anymore
+        tmpdir = "@LARGE_DATA_TMP_DIR@/abrt-tmp-debuginfo-%s.%u" % (time.strftime("%Y-%m-%d-%H:%M:%S"), os.getpid())
 
     crash = Popen(["crash", "--osrelease", vmcore], stdout=PIPE, bufsize = -1)
     ver, err = crash.communicate()
diff --git a/src/plugins/abrt-action-install-debuginfo.in b/src/plugins/abrt-action-install-debuginfo.in
index ef98250..4ecb58c 100644
--- a/src/plugins/abrt-action-install-debuginfo.in
+++ b/src/plugins/abrt-action-install-debuginfo.in
@@ -94,7 +94,7 @@ if __name__ == "__main__":
             "    -v          Be verbose\n"
             "    -y          Noninteractive, assume 'Yes' to all questions\n"
             "    --ids       Default: build_ids\n"
-            "    --tmpdir    Default: /tmp/abrt-tmp-debuginfo-RANDOM_SUFFIX\n"
+            "    --tmpdir    Default: @LARGE_DATA_TMP_DIR@/abrt-tmp-debuginfo-RANDOM_SUFFIX\n"
             "    --cache     Default: /var/cache/abrt-di\n"
             "    --size_mb   Default: 4096\n"
             "    -e,--exact  Download only specified files\n"
@@ -157,8 +157,9 @@ if __name__ == "__main__":
             cachedirs = ["/var/cache/abrt-di"]
     if not tmpdir:
         # security people prefer temp subdirs in app's private dir, like /var/run/abrt
-        # for now, we use /tmp...
-        tmpdir = "/tmp/abrt-tmp-debuginfo-%s.%u" % (time.strftime("%Y-%m-%d-%H:%M:%S"), os.getpid())
+        # and we switched to /tmp but Fedora feature tmp-on-tmpfs appeared, hence we must
+        # not use /tmp for potential big data anymore
+        tmpdir = "@LARGE_DATA_TMP_DIR@/abrt-tmp-debuginfo-%s.%u" % (time.strftime("%Y-%m-%d-%H:%M:%S"), os.getpid())
 
 
     if missing == None:
diff --git a/src/plugins/abrt-retrace-client.c b/src/plugins/abrt-retrace-client.c
index 9c2c551..940939b 100644
--- a/src/plugins/abrt-retrace-client.c
+++ b/src/plugins/abrt-retrace-client.c
@@ -95,10 +95,10 @@ static int create_archive(bool unlink_temp)
         return -1;
 
     /* Open a temporary file. */
-    char *filename = xstrdup("/tmp/abrt-retrace-client-archive-XXXXXX.tar.xz");
+    char *filename = xstrdup(LARGE_DATA_TMP_DIR"/abrt-retrace-client-archive-XXXXXX.tar.xz");
     int tempfd = mkstemps(filename, /*suffixlen:*/7);
     if (tempfd == -1)
-        perror_msg_and_die(_("Can't create temporary file in /tmp"));
+        perror_msg_and_die(_("Can't create temporary file in "LARGE_DATA_TMP_DIR));
     if (unlink_temp)
         xunlink(filename);
     free(filename);
@@ -177,11 +177,11 @@ static int create_archive(bool unlink_temp)
         /* Hopefully, by this time child emitted more meaningful
          * error message. But just in case it didn't:
          */
-        error_msg_and_die(_("Can't create temporary file in /tmp"));
+        error_msg_and_die(_("Can't create temporary file in "LARGE_DATA_TMP_DIR));
     VERB1 log_msg("Waiting for xz...");
     safe_waitpid(xz_child, &status, 0);
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
-        error_msg_and_die(_("Can't create temporary file in /tmp"));
+        error_msg_and_die(_("Can't create temporary file in "LARGE_DATA_TMP_DIR));
     VERB1 log_msg("Done...");
 
     xlseek(tempfd, 0, SEEK_SET);
@@ -1160,7 +1160,7 @@ int main(int argc, char **argv)
                     _("Delay for polling operations")),
         OPT_BOOL(0, "no-unlink", NULL,
                  _("(debug) do not delete temporary archive created"
-                   " from dump dir in /tmp")),
+                   " from dump dir in "LARGE_DATA_TMP_DIR)),
         OPT_GROUP(_("For status, backtrace, and log operations")),
         OPT_STRING('t', "task", &task_id, "ID",
                    _("id of your task on server")),
-- 
1.8.3.1



More information about the Crash-catcher mailing list