Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: third_party/xdg-utils/scripts/xdg-su.in

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-su ('k') | third_party/xdg-utils/scripts/xdg-terminal » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/sh
2 #---------------------------------------------
3 # xdg-su
4 #
5 # Utility script to run a command as an alternate user, generally
6 # the root user, with a graphical prompt for the root
7 # password if needed
8 #
9 # Refer to the usage() function below for usage.
10 #
11 # Copyright 2006, Jeremy White <jwhite@codeweavers.com>
12 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
13 #
14 # LICENSE:
15 #
16 #---------------------------------------------
17
18 manualpage()
19 {
20 cat << _MANUALPAGE
21 _MANUALPAGE
22 }
23
24 usage()
25 {
26 cat << _USAGE
27 _USAGE
28 }
29
30 #@xdg-utils-common@
31
32 su_kde()
33 {
34 if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
35 KDESU=`kde4-config --locate kdesu --path exe 2>/dev/null`
36 else
37 KDESU=`which kdesu 2>/dev/null`
38 fi
39 if [ $? -eq 0 ] ; then
40 if [ -z "$user" ] ; then
41 $KDESU -c "$cmd"
42 else
43 $KDESU -u "$user" -c "$cmd"
44 fi
45
46 if [ $? -eq 0 ]; then
47 exit_success
48 else
49 exit_failure_operation_failed
50 fi
51 else
52 su_generic
53 fi
54 }
55
56 su_gnome()
57 {
58 GSU=`which gnomesu 2>/dev/null`
59 if [ $? -ne 0 ] ; then
60 GSU=`which xsu 2>/dev/null`
61 fi
62 if [ $? -eq 0 ] ; then
63 if [ -z "$user" ] ; then
64 $GSU -c "$cmd"
65 else
66 $GSU -u "$user" -c "$cmd"
67 fi
68
69 if [ $? -eq 0 ]; then
70 exit_success
71 else
72 exit_failure_operation_failed
73 fi
74 else
75 su_generic
76 fi
77 }
78
79 su_generic()
80 {
81 if [ -z "$user" ] ; then
82 xterm -geom 60x5 -T "xdg-su: $cmd" -e su -c "$cmd"
83 else
84 xterm -geom 60x5 -T "xdg-su: $cmd" -e su -u "$user" -c "$cmd"
85 fi
86
87 if [ $? -eq 0 ]; then
88 exit_success
89 else
90 exit_failure_operation_failed
91 fi
92 }
93
94 [ x"$1" != x"" ] || exit_failure_syntax
95
96 user=
97 cmd=
98 while [ $# -gt 0 ] ; do
99 parm="$1"
100 shift
101
102 case "$parm" in
103 -u)
104 if [ -z "$1" ] ; then
105 exit_failure_syntax "user argument missing for -u"
106 fi
107 user="$1"
108 shift
109 ;;
110
111 -c)
112 if [ -z "$1" ] ; then
113 exit_failure_syntax "command argument missing for -c"
114 fi
115 cmd="$1"
116 shift
117 ;;
118
119 -*)
120 exit_failure_syntax "unexpected option '$parm'"
121 ;;
122
123 *)
124 exit_failure_syntax "unexpected argument '$parm'"
125 ;;
126 esac
127 done
128
129 if [ -z "${cmd}" ] ; then
130 exit_failure_syntax "command missing"
131 fi
132
133 detectDE
134
135 if [ x"$DE" = x"" ]; then
136 XSU=`which xsu 2>/dev/null`
137 if [ $? -eq 0 ] ; then
138 DE=generic
139 fi
140 fi
141
142 case "$DE" in
143 kde)
144 su_kde
145 ;;
146
147 gnome)
148 su_gnome
149 ;;
150
151 generic)
152 su_generic
153 ;;
154
155 *)
156 [ x"$user" = x"" ] && user=root
157 exit_failure_operation_impossible "no graphical method available for invokin g '$cmd' as '$user'"
158 ;;
159 esac
OLDNEW
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-su ('k') | third_party/xdg-utils/scripts/xdg-terminal » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698