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
=== modified file 'Makefile.am'
--- Makefile.am 2009-11-08 23:58:01 +0000
+++ Makefile.am 2009-12-10 11:49:09 +0000
@@ -56,6 +56,7 @@
56 RequestTracker \56 RequestTracker \
57 Rhythmbox \57 Rhythmbox \
58 Riptide \58 Riptide \
59 Root \
59 RSS \60 RSS \
60 Shelf \61 Shelf \
61 Skype \62 Skype \
6263
=== added directory 'Root'
=== added file 'Root/Makefile.am'
--- Root/Makefile.am 1970-01-01 00:00:00 +0000
+++ Root/Makefile.am 2009-12-10 11:49:09 +0000
@@ -0,0 +1,15 @@
1include $(top_srcdir)/build.rules.mk
2
3ASSEMBLY=Root
4
5FILES = \
6 src/Root.cs
7
8RESOURCES = \
9 Resources/Root.addin.xml
10
11REFERENCES = \
12 System \
13 System.Core \
14 $(DO_PLATFORM_LIBS) \
15 $(DO_UNIVERSE_LIBS)
016
=== added directory 'Root/Resources'
=== added file 'Root/Resources/Root.addin.xml.in'
--- Root/Resources/Root.addin.xml.in 1970-01-01 00:00:00 +0000
+++ Root/Resources/Root.addin.xml.in 2009-12-10 11:49:09 +0000
@@ -0,0 +1,27 @@
1<Addin
2 id="Root"
3 namespace="Do"
4 version="1.0"
5 name="Run as root"
6 description="Run applications as root"
7 author="Asmund Liseth"
8 category="Community"
9 defaultEnabled="false"
10 url="http://do.davebsd.com/wiki/Root_Plugin"
11 >
12
13 <Runtime>
14 <Import assembly="Root.dll"/>
15 </Runtime>
16
17 <Localizer type="Gettext" catalog="gnome-do-plugins" location="@expanded_datadir@/locale" />
18
19 <Dependencies>
20 <Addin id="Universe" version="1.0" />
21 </Dependencies>
22
23 <Extension path="/Do/Action">
24 <Action type="Root.RootAction" />
25 </Extension>
26
27</Addin>
028
=== added file 'Root/Root.mdp'
--- Root/Root.mdp 1970-01-01 00:00:00 +0000
+++ Root/Root.mdp 2009-12-10 11:49:09 +0000
@@ -0,0 +1,28 @@
1<Project name="Root" fileversion="2.0" language="C#" targetFramework="2.0" ctype="DotNetProject">
2 <Configurations active="Debug">
3 <Configuration name="Debug" ctype="DotNetProjectConfiguration">
4 <Output directory="bin/Debug" assembly="Root" />
5 <Build debugmode="True" target="Exe" />
6 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
7 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
8 </Configuration>
9 <Configuration name="Release" ctype="DotNetProjectConfiguration">
10 <Output directory="bin/Release" assembly="Root" />
11 <Build debugmode="False" target="Exe" />
12 <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
13 <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
14 </Configuration>
15 </Configurations>
16 <Contents>
17 <File name="src" subtype="Directory" buildaction="Compile" />
18 <File name="src/Root.cs" subtype="Code" buildaction="Compile" />
19 </Contents>
20 <References>
21 <ProjectReference type="Gac" localcopy="True" refto="Do.Universe, Version=0.9.0.0, Culture=neutral" />
22 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform, Version=0.9.0.0, Culture=neutral" />
23 <ProjectReference type="Gac" localcopy="True" refto="Do.Platform.Linux, Version=0.9.0.0, Culture=neutral" />
24 <ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
25 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
26 <ProjectReference type="Gac" localcopy="True" refto="Do.Interface.Linux, Version=0.9.0.0, Culture=neutral" />
27 </References>
28</Project>
0\ No newline at end of file29\ No newline at end of file
130
=== added file 'Root/Root.pidb'
2Binary files Root/Root.pidb 1970-01-01 00:00:00 +0000 and Root/Root.pidb 2009-12-10 11:49:09 +0000 differ31Binary files Root/Root.pidb 1970-01-01 00:00:00 +0000 and Root/Root.pidb 2009-12-10 11:49:09 +0000 differ
=== added directory 'Root/bin'
=== added directory 'Root/bin/Debug'
=== added directory 'Root/bin/Release'
=== added directory 'Root/src'
=== added file 'Root/src/Root.cs'
--- Root/src/Root.cs 1970-01-01 00:00:00 +0000
+++ Root/src/Root.cs 2009-12-10 11:49:09 +0000
@@ -0,0 +1,84 @@
1/* Root.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this source distribution.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20using System;
21using System.Collections.Generic;
22using Do.Platform;
23using Do.Universe;
24
25namespace Root {
26
27 public class RootAction : Act {
28
29 public override string Name {
30 get { return "Run as root"; }
31 }
32
33 public override string Description {
34 get { return "Run application as root"; }
35 }
36
37 public override string Icon {
38 get { return "gnome-run"; }
39 }
40
41 public override IEnumerable<Type> SupportedItemTypes
42 {
43 get {
44 yield return typeof (IApplicationItem);
45 // Files can be run if they're executable.
46 yield return typeof (IFileItem);
47 // ITextItems canbe run if they're valid command lines.
48 yield return typeof (ITextItem);
49 }
50 }
51
52 public override bool SupportsItem (Item item)
53 {
54 string command = "";
55 if (item is IApplicationItem) return true;
56 if (item is IFileItem)
57 command = (item as IFileItem).Path;
58 else if (item is ITextItem)
59 command = (item as ITextItem).Text;
60
61 return Services.Environment.IsExecutable (command);
62 }
63
64 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
65 {
66 string command = "" ;
67 foreach (Item item in items) {
68 if (item is IApplicationItem) {
69 command = (item as IApplicationItem).Exec;
70 } else if (item is IFileItem) {
71 command = (item as IFileItem).Path;
72 } else if (item is ITextItem) {
73 command = (item as ITextItem).Text;
74 }
75 if (command.Substring(command.Length-2, 2) == "%U")
76 command = command.Substring(0, command.Length-2);
77 //I want to get "sudo" command from user configuration
78 //in the future. For now, I hardcoded gksudo.
79 Services.Environment.Execute ("gksudo " + command);
80 }
81 return null;
82 }
83 }
84}
085
=== modified file 'configure.ac'
--- configure.ac 2009-11-08 23:58:01 +0000
+++ configure.ac 2009-12-10 11:49:09 +0000
@@ -344,6 +344,8 @@
344Rhythmbox/Resources/Rhythmbox.addin.xml344Rhythmbox/Resources/Rhythmbox.addin.xml
345Riptide/Makefile345Riptide/Makefile
346Riptide/Resources/Riptide.addin.xml346Riptide/Resources/Riptide.addin.xml
347Root/Makefile
348Root/Resources/Root.addin.xml
347RSS/Makefile349RSS/Makefile
348RSS/Resources/RSS.addin.xml350RSS/Resources/RSS.addin.xml
349Shelf/Makefile351Shelf/Makefile

Subscribers

People subscribed via source and target branches