[Pkg-privacy-commits] [libgsecuredelete] 129/168: sfill wrapper: Don't require root privileges for FAT

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Jul 7 20:06:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch master
in repository libgsecuredelete.

commit 10466f2d19ac2c7ca76e0accbdb1753c8fe678ad
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Mon Jun 11 23:50:25 2012 +0200

    sfill wrapper: Don't require root privileges for FAT
    
    Some file systems like FAT don't require root privileges to be wiped
    entirely (because they don't support reserved blocks), so don't ask
    for root privileges on those FS.
---
 gsd-sfill-helper.in | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/gsd-sfill-helper.in b/gsd-sfill-helper.in
index 4fe3c7e..b01d968 100644
--- a/gsd-sfill-helper.in
+++ b/gsd-sfill-helper.in
@@ -113,19 +113,29 @@ progress_step() {
 }
 
 
-# become root!
 if [ `whoami` != root ]; then
-  if which pkexec >/dev/null; then
-    pkexec --user root "$0" $OPT_f $OPT_i $OPT_I $OPT_l $OPT_v $OPT_z "$dir"
-    code=$?
-    if [ $code -ne 126 -a $code -ne 127 ]; then
-      # if becoming root succeeded, abort this instance
-      exit $code
-    fi
-  fi
-  
-  echo "Continuing without root privileges, wipe may be incomplete" >&2
-  MISSING_ROOT=1
+  # before trying to become root, check whether the FS on which we will work
+  # actually requires root privileges
+  fstype=$(df -T "$dir" | tail -n1 | tr -s ' ' | cut -d' ' -f 2)
+  case $fstype in
+    msdos|umsdos|vfat) # no need to be root for those FS
+      [ -n $OPT_v ] || echo "File system type is $fstype, no need to be root"
+      ;;
+    
+    *) # guess we better be root for all other FS types, so try to become root!
+      if which pkexec >/dev/null; then
+        pkexec --user root "$0" $OPT_f $OPT_i $OPT_I $OPT_l $OPT_v $OPT_z "$dir"
+        code=$?
+        if [ $code -ne 126 -a $code -ne 127 ]; then
+          # if becoming root succeeded, abort this instance
+          exit $code
+        fi
+      fi
+      
+      echo "Continuing without root privileges, wipe may be incomplete" >&2
+      MISSING_ROOT=1
+      ;;
+  esac
 fi
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libgsecuredelete.git



More information about the Pkg-privacy-commits mailing list