summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin f. krafft <madduck@debian.org>2009-05-05 10:51:37 +0200
committermartin f. krafft <madduck@debian.org>2009-05-05 11:38:16 +0200
commit0bcce4d3bb7c9c2b68f937411d55aa22736f90f5 (patch)
tree27a40f3ad37ec4b41ec8fc5c7b0e22e5bc607a57
parent93eecf12c706c1c01f1d0a8c45c20639ca8afe3f (diff)
Enhance bugscript to optionally run as root
Signed-off-by: martin f. krafft <madduck@debian.org>
-rwxr-xr-xdebian/bugscript47
-rw-r--r--debian/changelog2
-rw-r--r--debian/presubj17
-rwxr-xr-xdebian/rules1
4 files changed, 67 insertions, 0 deletions
diff --git a/debian/bugscript b/debian/bugscript
index 4fb920c2..7ecd2ccc 100755
--- a/debian/bugscript
+++ b/debian/bugscript
@@ -28,6 +28,53 @@ if ! command -v yesno >/dev/null; then
exec 3>&1
fi
+if [ $(id -u) != 0 ]; then
+ if [ -x "$(command -v sudo)" ]; then
+ yesno "Gather system information as root using sudo? (Y/n) " yep
+ if [ "$REPLY" = yep ]; then
+ echo running sudo "$0" "$@"...
+ sudo "$0" "$@" && exit 0
+ echo "sudo invocation failed, trying /bin/su..."
+ fi
+ fi
+
+ yesno "Gather system information as root using su? (Y/n) " yep
+ if [ "$REPLY" = yep ]; then
+ ARGS=
+ for i in "$@"; do ARGS="${ARGS:+$ARGS }'$1'"; shift; done
+ echo "running su root -s '/bin/sh -c $0 $ARGS'..."
+ su root -s /bin/sh -c "$0 $ARGS" && exit 0
+ unset ARGS
+ echo "su invocation failed."
+ fi
+
+ # arrive here only if neither sudo nor su worked:
+ yesno "Will you provide system information in the bug report yourself? (N/y) " nop
+ if [ "$REPLY" = yep ]; then
+ cat <<_eof >&3
+
+IMPORTANT:
+ please do not forget to include all relevant system information with this
+ bug report. You could run
+ /usr/share/bug/mdadm/script 3>&1
+ as root and attach or include the output.
+
+_eof
+ exit 0
+ fi
+
+ # try our best
+ cat <<_eof >&3
+
+WARNING:
+ the following output was not generated by the root user. If you can, please
+ replace the following up until "-- System Information:" with the output of
+ /usr/share/bug/mdadm/script 3>&1
+ run as root. Thanks!
+
+_eof
+fi
+
if [ ! -r /proc/mdstat ]; then
echo "The local system does not have MD (RAID) support: no drivers loaded."
echo "Without MD support, I cannot collect as much information as I'd like."
diff --git a/debian/changelog b/debian/changelog
index 09d6da61..504f0007 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ mdadm (2.6.9-3) unstable; urgency=low
the prerequisites (closes: #526793).
* Change my previous recommendation for postfix over to the new virtual
package default-mta (see #522300 and #508644).
+ * Enhance bugscript, which now asks to run as root (sudo/su) if invoked by
+ a normal user.
-- martin f. krafft <madduck@debian.org> Sun, 03 May 2009 17:29:47 +0200
diff --git a/debian/presubj b/debian/presubj
new file mode 100644
index 00000000..9eb304fb
--- /dev/null
+++ b/debian/presubj
@@ -0,0 +1,17 @@
+Gathering information relevant to mdadm as root
+===============================================
+
+If you are not reporting bugs as root (which you should not), you will be
+prompted to give permission to run a script to collect relevant information
+from your system as the root user. Only the root user has access to some
+information that might be relevant to the bug report you are about to file.
+
+
+** Please give permission to run the script as root when asked momentarily.
+
+
+If you would rather obtain the same information manually, you can run
+ /usr/share/bug/mdadm/script 3>&1
+as root and include or attach the output.
+
+ -- martin f. krafft <madduck@debian.org> Tue, 05 May 2009 11:26:32 +0200
diff --git a/debian/rules b/debian/rules
index 67aacda6..81ed63e0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -74,6 +74,7 @@ install: build
install -m0755 debian/mkconf $(DESTDIR)/usr/share/mdadm
install -m0755 debian/checkarray $(DESTDIR)/usr/share/mdadm
install -m0755 debian/bugscript $(DESTDIR)/usr/share/bug/mdadm/script
+ install -m0544 debian/presubj $(DESTDIR)/usr/share/bug/mdadm
install -m0755 debian/mdadm-startall $(DESTDIR)/sbin