Merge lp:~asmund-liseth/do-plugins/run-as-root into lp:do-plugins

Proposed by Asmund Liseth
Status: Needs review
Proposed branch: lp:~asmund-liseth/do-plugins/run-as-root
Merge into: lp:do-plugins
Diff against target: 207 lines (+157/-0)
6 files modified
Makefile.am (+1/-0)
Root/Makefile.am (+15/-0)
Root/Resources/Root.addin.xml.in (+27/-0)
Root/Root.mdp (+28/-0)
Root/src/Root.cs (+84/-0)
configure.ac (+2/-0)
To merge this branch: bzr merge lp:~asmund-liseth/do-plugins/run-as-root
Reviewer Review Type Date Requested Status
Do Plugins Team Pending
Review via email: mp+15933@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

675. By Asmund Liseth <asmund@asmund-laptop>

Added a simple plugin to run applicatioins as root

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2009-11-08 23:58:01 +0000
3+++ Makefile.am 2009-12-10 11:49:09 +0000
4@@ -56,6 +56,7 @@
5 RequestTracker \
6 Rhythmbox \
7 Riptide \
8+ Root \
9 RSS \
10 Shelf \
11 Skype \
12
13=== added directory 'Root'
14=== added file 'Root/Makefile.am'
15--- Root/Makefile.am 1970-01-01 00:00:00 +0000
16+++ Root/Makefile.am 2009-12-10 11:49:09 +0000
17@@ -0,0 +1,15 @@
18+include $(top_srcdir)/build.rules.mk
19+
20+ASSEMBLY=Root
21+
22+FILES = \
23+ src/Root.cs
24+
25+RESOURCES = \
26+ Resources/Root.addin.xml
27+
28+REFERENCES = \
29+ System \
30+ System.Core \
31+ $(DO_PLATFORM_LIBS) \
32+ $(DO_UNIVERSE_LIBS)
33
34=== added directory 'Root/Resources'
35=== added file 'Root/Resources/Root.addin.xml.in'
36--- Root/Resources/Root.addin.xml.in 1970-01-01 00:00:00 +0000
37+++ Root/Resources/Root.addin.xml.in 2009-12-10 11:49:09 +0000
38@@ -0,0 +1,27 @@
39+<Addin
40+ id="Root"
41+ namespace="Do"
42+ version="1.0"
43+ name="Run as root"
44+ description="Run applications as root"
45+ author="Asmund Liseth"
46+ category="Community"
47+ defaultEnabled="false"
48+ url="http://do.davebsd.com/wiki/Root_Plugin"
49+ >
50+
51+ <Runtime>
52+ <Import assembly="Root.dll"/>
53+ </Runtime>
54+
55+ <Localizer type="Gettext" catalog="gnome-do-plugins" location="@expanded_datadir@/locale" />
56+
57+ <Dependencies>
58+ <Addin id="Universe" version="1.0" />
59+ </Dependencies>
60+
61+ <Extension path="/Do/Action">
62+ <Action type="Root.RootAction" />
63+ </Extension>
64+
65+</Addin>
66
67=== added file 'Root/Root.mdp'
68--- Root/Root.mdp 1970-01-01 00:00:00 +0000
69+++ Root/Root.mdp 2009-12-10 11:49:09 +0000
70@@ -0,0 +1,28 @@
71+<Project name="Root" fileversion="2.0" language="C#" targetFramework="2.0" ctype="DotNetProject">
72+ <Configurations active="Debug">
73+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
74+ <Output directory="bin/Debug" assembly="Root" />
75+ <Build debugmode="True" target="Exe" />
76+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
77+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
78+ </Configuration>
79+ <Configuration name="Release" ctype="DotNetProjectConfiguration">
80+ <Output directory="bin/Release" assembly="Root" />
81+ <Build debugmode="False" target="Exe" />
82+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
83+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
84+ </Configuration>
85+ </Configurations>
86+ <Contents>
87+ <File name="src" subtype="Directory" buildaction="Compile" />
88+ <File name="src/Root.cs" subtype="Code" buildaction="Compile" />
89+ </Contents>
90+ <References>
91+ <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.9.0.0, Culture=neutral" />
92+ <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.9.0.0, Culture=neutral" />
93+ <ProjectReference type="Gac" localcopy="True" refto="Do.Platform.Linux, Version=0.9.0.0, Culture=neutral" />
94+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
95+ <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
96+ <ProjectReference type="Gac" localcopy="True" refto="Do.Interface.Linux, Version=0.9.0.0, Culture=neutral" />
97+ </References>
98+</Project>
99\ No newline at end of file
100
101=== added file 'Root/Root.pidb'
102Binary files Root/Root.pidb 1970-01-01 00:00:00 +0000 and Root/Root.pidb 2009-12-10 11:49:09 +0000 differ
103=== added directory 'Root/bin'
104=== added directory 'Root/bin/Debug'
105=== added directory 'Root/bin/Release'
106=== added directory 'Root/src'
107=== added file 'Root/src/Root.cs'
108--- Root/src/Root.cs 1970-01-01 00:00:00 +0000
109+++ Root/src/Root.cs 2009-12-10 11:49:09 +0000
110@@ -0,0 +1,84 @@
111+/* Root.cs
112+ *
113+ * GNOME Do is the legal property of its developers. Please refer to the
114+ * COPYRIGHT file distributed with this source distribution.
115+ *
116+ * This program is free software: you can redistribute it and/or modify
117+ * it under the terms of the GNU General Public License as published by
118+ * the Free Software Foundation, either version 3 of the License, or
119+ * (at your option) any later version.
120+ *
121+ * This program is distributed in the hope that it will be useful,
122+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
123+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124+ * GNU General Public License for more details.
125+ *
126+ * You should have received a copy of the GNU General Public License
127+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
128+ */
129+
130+using System;
131+using System.Collections.Generic;
132+using Do.Platform;
133+using Do.Universe;
134+
135+namespace Root {
136+
137+ public class RootAction : Act {
138+
139+ public override string Name {
140+ get { return "Run as root"; }
141+ }
142+
143+ public override string Description {
144+ get { return "Run application as root"; }
145+ }
146+
147+ public override string Icon {
148+ get { return "gnome-run"; }
149+ }
150+
151+ public override IEnumerable<Type> SupportedItemTypes
152+ {
153+ get {
154+ yield return typeof (IApplicationItem);
155+ // Files can be run if they're executable.
156+ yield return typeof (IFileItem);
157+ // ITextItems canbe run if they're valid command lines.
158+ yield return typeof (ITextItem);
159+ }
160+ }
161+
162+ public override bool SupportsItem (Item item)
163+ {
164+ string command = "";
165+ if (item is IApplicationItem) return true;
166+ if (item is IFileItem)
167+ command = (item as IFileItem).Path;
168+ else if (item is ITextItem)
169+ command = (item as ITextItem).Text;
170+
171+ return Services.Environment.IsExecutable (command);
172+ }
173+
174+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
175+ {
176+ string command = "" ;
177+ foreach (Item item in items) {
178+ if (item is IApplicationItem) {
179+ command = (item as IApplicationItem).Exec;
180+ } else if (item is IFileItem) {
181+ command = (item as IFileItem).Path;
182+ } else if (item is ITextItem) {
183+ command = (item as ITextItem).Text;
184+ }
185+ if (command.Substring(command.Length-2, 2) == "%U")
186+ command = command.Substring(0, command.Length-2);
187+ //I want to get "sudo" command from user configuration
188+ //in the future. For now, I hardcoded gksudo.
189+ Services.Environment.Execute ("gksudo " + command);
190+ }
191+ return null;
192+ }
193+ }
194+}
195
196=== modified file 'configure.ac'
197--- configure.ac 2009-11-08 23:58:01 +0000
198+++ configure.ac 2009-12-10 11:49:09 +0000
199@@ -344,6 +344,8 @@
200 Rhythmbox/Resources/Rhythmbox.addin.xml
201 Riptide/Makefile
202 Riptide/Resources/Riptide.addin.xml
203+Root/Makefile
204+Root/Resources/Root.addin.xml
205 RSS/Makefile
206 RSS/Resources/RSS.addin.xml
207 Shelf/Makefile

Subscribers

People subscribed via source and target branches