[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[desktop] graphical su-to-root (was: Re: [desktop] foomatic-gui is born)



Em Wed, 27 Nov 2002 10:13:22 -0200, Gustavo Noronha Silva <kov@debian.org>
escreveu:

> I'm willing to work towards this, and I think it would be good to
> create some policy for that, probably modify the su-to-root script
> to use a "graphical su" alternative if $DISPLAY is set... 

Something like the patch that is attached... do you people think
this is a good idea?

[]s!

-- 
kov@debian.org: Gustavo Noronha <http://people.debian.org/~kov>
Debian: <http://www.debian.org>  *  <http://www.debian-br.org>
Dúvidas sobre o Debian? Visite o Rau-Tu: http://rautu.cipsga.org.br
--- /usr/sbin/su-to-root	2002-09-30 13:53:26.000000000 -0300
+++ /home/kov/scripts/su-to-root	2002-11-27 21:48:43.000000000 -0200
@@ -2,7 +2,7 @@
 
 PRIV=root
 COMMAND=
-
+XSU=/usr/bin/gksu
 
 eusername () {
    getent passwd | grep "^[^:]*:[^:]*:$1:"|cut -f1 -d:
@@ -23,7 +23,8 @@
 for i in "$@"; do
    case "$prev" in
      -p)
-       PRIV="$i";;
+       PRIV="$i"
+       XSU="$XSU -u $i";;
      -c)
        COMMAND="$i";;
    esac
@@ -38,15 +39,21 @@
 if test $eus = "root" -o $eus = $PRIV; then
   $COMMAND
 else
-  echo About to execute $COMMAND. 
-  echo This command needs $PRIV privileges to be executed.
-  echo enter $PRIV passwd:
-  while ! su $PRIV -c "$COMMAND"; do
-    echo -n 'Incorrect password. Try again? (y/n)'
-    read ans
-    if test "$ans" != "y" -a "$ans" != "Y"; then
-      exit 1
-    fi
-  done  
+  if [ "$DISPLAY" != "" ]; then
+    $XSU -t "About to execute $COMMAND" \
+      -m "This command needs $PRIV privileges to be executed." \
+      "$COMMAND"
+  else
+    echo About to execute $COMMAND. 
+    echo This command needs $PRIV privileges to be executed.
+    echo enter $PRIV passwd:
+    while ! su $PRIV -c "$COMMAND"; do
+      echo -n 'Incorrect password. Try again? (y/n)'
+      read ans
+      if test "$ans" != "y" -a "$ans" != "Y"; then
+        exit 1
+      fi
+    done  
+  fi
 fi
     

Reply to: