Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 84584 Details for
Bug 129861
app-misc/beagle command line injection (CVE-2006-1865)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
beagle-safe-process-launch.patch
beagle-safe-process-launch.patch (text/plain), 26.97 KB, created by
Sune Kloppenborg Jeppesen (RETIRED)
on 2006-04-13 13:32:47 UTC
(
hide
)
Description:
beagle-safe-process-launch.patch
Filename:
MIME Type:
Creator:
Sune Kloppenborg Jeppesen (RETIRED)
Created:
2006-04-13 13:32:47 UTC
Size:
26.97 KB
patch
obsolete
>Index: Filters/FilterExternal.cs >=================================================================== >RCS file: /cvs/gnome/beagle/Filters/FilterExternal.cs,v >retrieving revision 1.3 >diff -u -p -u -r1.3 FilterExternal.cs >--- Filters/FilterExternal.cs 28 Mar 2006 17:05:07 -0000 1.3 >+++ Filters/FilterExternal.cs 13 Apr 2006 18:30:07 -0000 >@@ -143,29 +143,37 @@ namespace Beagle.Filters { > Error (); > } > >- string args = efi.Arguments.Replace ("%s", String.Format ("\"{0}\"", FileInfo.FullName)); >- >- Process pc = new Process (); >+ // FIXME: Need to deal with quotation marks in the XML file, probably. >+ string[] tmp_argv = efi.Arguments.Split (' '); >+ string[] argv = new string [tmp_argv.Length + 1]; >+ >+ argv [0] = efi.Command; >+ >+ int j = 1; >+ for (int i = 0; i < tmp_argv.Length; i++) { >+ if (tmp_argv [i] == String.Empty) >+ continue; >+ >+ if (tmp_argv [i] == "%s") >+ argv [j] = FileInfo.FullName; >+ else >+ argv [j] = tmp_argv [i]; >+ j++; >+ } > >- pc.StartInfo.FileName = efi.Command; >- pc.StartInfo.Arguments = args; >- pc.StartInfo.RedirectStandardInput = false; >- pc.StartInfo.RedirectStandardOutput = true; >- pc.StartInfo.UseShellExecute = false; >+ SafeProcess pc = new SafeProcess (); >+ pc.Arguments = argv; >+ pc.RedirectStandardOutput = true; > > try { > pc.Start (); >- } catch (System.ComponentModel.Win32Exception ex) { >- Logger.Log.Warn ("Unable to execute {0}: {1}", >- pc.StartInfo.FileName, ex); >+ } catch (SafeProcessException e) { >+ Log.Warn (e.Message); > Error (); > return; > } > >- // Nice the process so that we don't monopolize the CPU >- pc.PriorityClass = ProcessPriorityClass.BelowNormal; >- >- StreamReader pout = pc.StandardOutput; >+ StreamReader pout = new StreamReader (pc.StandardOutput); > > string str; > while ((str = pout.ReadLine ()) != null) { >@@ -174,7 +182,6 @@ namespace Beagle.Filters { > } > > pout.Close (); >- pc.WaitForExit (); > pc.Close (); > Finished (); > } >Index: Filters/FilterMPlayerVideo.cs >=================================================================== >RCS file: /cvs/gnome/beagle/Filters/FilterMPlayerVideo.cs,v >retrieving revision 1.7 >diff -u -p -u -r1.7 FilterMPlayerVideo.cs >--- Filters/FilterMPlayerVideo.cs 2 Apr 2006 19:55:54 -0000 1.7 >+++ Filters/FilterMPlayerVideo.cs 13 Apr 2006 18:30:07 -0000 >@@ -96,24 +96,20 @@ namespace Beagle.Filters { > > protected override void DoPullProperties () > { >- // create new external process >- Process pc = new Process (); >- pc.StartInfo.FileName = "mplayer"; >- pc.StartInfo.Arguments = " -vo null -ao null -frames 0 -identify \"" + FileInfo.FullName+"\""; >- pc.StartInfo.RedirectStandardInput = false; >- pc.StartInfo.RedirectStandardOutput = true; >- pc.StartInfo.RedirectStandardError = true; >- pc.StartInfo.UseShellExecute = false; >- >+ SafeProcess pc = new SafeProcess (); >+ pc.Arguments = new string [] { "mplayer", "-vo", "null", "-ao", "null", "-frames", "0", "-identify", FileInfo.FullName }; >+ pc.RedirectStandardOutput = true; >+ pc.RedirectStandardError = true; >+ > try { > pc.Start (); >- } catch (System.ComponentModel.Win32Exception) { >- Log.Warn ("Error: mplayer not found or unable to run"); >+ } catch (SafeProcessException e) { >+ Log.Warn (e.Message); > Error (); > return; > } > >- StreamReader pout = pc.StandardOutput; >+ StreamReader pout = new StreamReader (pc.StandardOutput); > string str; > string name = ""; > >@@ -197,7 +193,6 @@ namespace Beagle.Filters { > } > > pout.Close (); >- pc.WaitForExit (); > pc.Close (); > > // If an aspect ratio wasn't set in the file then work out the >Index: Filters/FilterPdf.cs >=================================================================== >RCS file: /cvs/gnome/beagle/Filters/FilterPdf.cs,v >retrieving revision 1.16 >diff -u -p -u -r1.16 FilterPdf.cs >--- Filters/FilterPdf.cs 2 Apr 2006 19:55:54 -0000 1.16 >+++ Filters/FilterPdf.cs 13 Apr 2006 18:30:07 -0000 >@@ -30,23 +30,20 @@ namespace Beagle.Filters { > protected override void DoPullProperties () > { > // create new external process >- Process pc = new Process (); >- pc.StartInfo.FileName = "pdfinfo"; >- // FIXME: We probably need to quote special chars in the path >- pc.StartInfo.Arguments = String.Format (" \"{0}\"", FileInfo.FullName); >- pc.StartInfo.RedirectStandardInput = false; >- pc.StartInfo.RedirectStandardOutput = true; >- pc.StartInfo.UseShellExecute = false; >+ SafeProcess pc = new SafeProcess (); >+ pc.Arguments = new string [] { "pdfinfo", FileInfo.FullName }; >+ pc.RedirectStandardOutput = true; >+ > try { > pc.Start (); >- } catch (System.ComponentModel.Win32Exception) { >- Logger.Log.Warn ("Unable to find pdfinfo in path; PDF file not indexed."); >- Finished (); >+ } catch (SafeProcessException e) { >+ Log.Warn (e.Message); >+ Error (); > return; > } >- >+ > // add pdfinfo's output to pool >- StreamReader pout = pc.StandardOutput; >+ StreamReader pout = new StreamReader (pc.StandardOutput); > string str = null; > string[] tokens = null; > string strMetaTag = null; >@@ -87,33 +84,26 @@ namespace Beagle.Filters { > } > } > pout.Close (); >- pc.WaitForExit (); > pc.Close (); > } > > protected override void DoPull () > { > // create new external process >- Process pc = new Process (); >- pc.StartInfo.FileName = "pdftotext"; >- // FIXME: We probably need to quote special chars in the path >- pc.StartInfo.Arguments = String.Format ("-q -nopgbrk -enc UTF-8 \"{0}\" -", FileInfo.FullName); >- pc.StartInfo.RedirectStandardInput = false; >- pc.StartInfo.RedirectStandardOutput = true; >- pc.StartInfo.UseShellExecute = false; >+ SafeProcess pc = new SafeProcess (); >+ pc.Arguments = new string [] { "pdftotext", "-q", "-nopgbrk", "-enc", "UTF-8", FileInfo.FullName, "-" }; >+ pc.RedirectStandardOutput = true; >+ > try { > pc.Start (); >- } catch (System.ComponentModel.Win32Exception) { >- Logger.Log.Warn ("Unable to find pdftotext in path; PDF file not indexed."); >- Finished (); >+ } catch (SafeProcessException e) { >+ Log.Warn (e.Message); >+ Error (); > return; > } > >- // Nice the process so we don't monopolize the CPU as much; we might want to even set this to idle >- pc.PriorityClass = ProcessPriorityClass.BelowNormal; >- > // add pdftotext's output to pool >- StreamReader pout = pc.StandardOutput; >+ StreamReader pout = new StreamReader (pc.StandardOutput); > > // FIXME: I don't think this is really required > // Line by line parsing, however, we have to make >@@ -126,7 +116,6 @@ namespace Beagle.Filters { > break; > } > pout.Close (); >- pc.WaitForExit (); > pc.Close (); > Finished (); > } >Index: Filters/FilterRPM.cs >=================================================================== >RCS file: /cvs/gnome/beagle/Filters/FilterRPM.cs,v >retrieving revision 1.2 >diff -u -p -u -r1.2 FilterRPM.cs >--- Filters/FilterRPM.cs 2 Apr 2006 19:55:54 -0000 1.2 >+++ Filters/FilterRPM.cs 13 Apr 2006 18:30:07 -0000 >@@ -74,32 +74,32 @@ namespace Beagle.Filters { > > protected override void DoPullProperties () > { >- Process pc = new Process (); >- pc.StartInfo.FileName = "rpm"; >- pc.StartInfo.Arguments = " -qp --queryformat '[%{*:xml}\n]' \"" + FileInfo.FullName+"\""; >- pc.StartInfo.RedirectStandardInput = false; >- pc.StartInfo.RedirectStandardOutput = true; >- pc.StartInfo.RedirectStandardError = true; >- pc.StartInfo.UseShellExecute = false; >+ SafeProcess pc = new SafeProcess (); >+ pc.Arguments = new string [] { "rpm", "-qp", "--queryformat", "[%{*:xml}\n]", FileInfo.FullName }; >+ pc.RedirectStandardOutput = true; >+ pc.RedirectStandardError = true; > > try { > pc.Start (); >- } catch (System.ComponentModel.Win32Exception) { >- Log.Warn ("Error: 'rpm' command not found or unable to run"); >+ } catch (SafeProcessException e) { >+ Log.Warn (e.Message); > Error (); > return; > } > >- StreamReader pout = pc.StandardOutput; >- XmlTextReader reader = new XmlTextReader (pout); >+ XmlTextReader reader = new XmlTextReader (new StreamReader (pc.StandardOutput)); > reader.WhitespaceHandling = WhitespaceHandling.None; > > try { > ParseRpmTags (reader); >- } catch (XmlException) { >- Logger.Log.Debug ("FilterRPM: Error parsing output of rpmquery!"); >+ } catch (XmlException e) { >+ Logger.Log.Warn ("FilterRPM: Error parsing output of rpmquery: {0}", e.Message); > Error (); >+ } finally { >+ reader.Close (); >+ pc.Close (); > } >+ > Finished (); > } > >Index: Filters/FilterSpreadsheet.cs >=================================================================== >RCS file: /cvs/gnome/beagle/Filters/FilterSpreadsheet.cs,v >retrieving revision 1.4 >diff -u -p -u -r1.4 FilterSpreadsheet.cs >--- Filters/FilterSpreadsheet.cs 28 Jul 2005 21:17:26 -0000 1.4 >+++ Filters/FilterSpreadsheet.cs 13 Apr 2006 18:30:07 -0000 >@@ -75,39 +75,37 @@ namespace Beagle.Filters { > override protected void DoPull () > { > // create new external process >- Process pc = new Process (); >- pc.StartInfo.FileName = "ssindex"; >+ SafeProcess pc = new SafeProcess (); >+ pc.Arguments = new string [] { "ssindex", "-i", FileInfo.FullName }; >+ pc.RedirectStandardOutput = true; > >- pc.StartInfo.Arguments = String.Format ("-i \"{0}\"", FileInfo.FullName); >- pc.StartInfo.RedirectStandardInput = false; >- pc.StartInfo.RedirectStandardOutput = true; >- pc.StartInfo.UseShellExecute = false; > try { > pc.Start (); >- } catch (System.ComponentModel.Win32Exception) { >- Logger.Log.Warn ("Unable to find ssindex in path; {0} file not indexed.", >- FileInfo.FullName); >- Finished (); >+ } catch (SafeProcessException e) { >+ Log.Warn (e.Message); >+ Error (); > return; > } > > // process ssindex output >- StreamReader pout = pc.StandardOutput; >+ StreamReader pout = new StreamReader (pc.StandardOutput); > if (!ignoredFirst2lines) { > pout.ReadLine (); > pout.ReadLine (); > xmlReader = new XmlTextReader (pout); > ignoredFirst2lines = true; > } >+ > try { > WalkContentNodes (xmlReader); > } catch (Exception e) { > Logger.Log.Debug ("Exception occurred while indexing {0}.", FileInfo.FullName); > Logger.Log.Debug (e); > } >+ > pout.Close (); >- pc.WaitForExit (); > pc.Close (); >+ > Finished (); > } > >Index: Util/Makefile.am >=================================================================== >RCS file: /cvs/gnome/beagle/Util/Makefile.am,v >retrieving revision 1.92 >diff -u -p -u -r1.92 Makefile.am >--- Util/Makefile.am 5 Apr 2006 20:10:07 -0000 1.92 >+++ Util/Makefile.am 13 Apr 2006 18:30:07 -0000 >@@ -73,6 +73,7 @@ UTIL_CSFILES = \ > $(srcdir)/PngHeader.cs \ > $(srcdir)/PullingReader.cs \ > $(srcdir)/ReflectionFu.cs \ >+ $(srcdir)/SafeProcess.cs \ > $(srcdir)/Scheduler.cs \ > $(srcdir)/SmallIntArray.cs \ > $(srcdir)/Stopwatch.cs \ >Index: Util/SafeProcess.cs >=================================================================== >RCS file: Util/SafeProcess.cs >diff -N Util/SafeProcess.cs >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Util/SafeProcess.cs 13 Apr 2006 18:30:07 -0000 >@@ -0,0 +1,143 @@ >+// >+// SafeProcess.cs >+// >+// Copyright (C) 2006 Novell, Inc. >+// >+ >+// >+// Permission is hereby granted, free of charge, to any person obtaining a copy >+// of this software and associated documentation files (the "Software"), to deal >+// in the Software without restriction, including without limitation the rights >+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell >+// copies of the Software, and to permit persons to whom the Software is >+// furnished to do so, subject to the following conditions: >+// >+// The above copyright notice and this permission notice shall be included in all >+// copies or substantial portions of the Software. >+// >+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, >+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE >+// SOFTWARE. >+// >+ >+using System; >+using System.IO; >+using System.Runtime.InteropServices; >+using Mono.Unix; >+using GLib; >+ >+namespace Beagle.Util { >+ >+ public class SafeProcess { >+ >+ private bool redirect_stdin, redirect_stdout, redirect_stderr; >+ private int stdin, stdout, stderr; >+ private string[] args; >+ private UnixStream stdin_stream, stdout_stream, stderr_stream; >+ >+ public string[] Arguments { >+ get { return args; } >+ set { args = value; } >+ } >+ >+ public bool RedirectStandardInput { >+ get { return redirect_stdin; } >+ set { redirect_stdin = value; } >+ } >+ >+ public bool RedirectStandardOutput { >+ get { return redirect_stdout; } >+ set { redirect_stdout = value; } >+ } >+ >+ public bool RedirectStandardError { >+ get { return redirect_stderr; } >+ set { redirect_stderr = value; } >+ } >+ >+ public Stream StandardInput { >+ get { return stdin_stream; } >+ } >+ >+ public Stream StandardOutput { >+ get { return stdout_stream; } >+ } >+ >+ public Stream StandardError { >+ get { return stderr_stream; } >+ } >+ >+ [DllImport ("libglib-2.0.so.0")] >+ static extern bool g_spawn_async_with_pipes (string working_directory, >+ string[] argv, >+ string[] envp, >+ int flags, >+ IntPtr child_setup, >+ IntPtr child_data, >+ IntPtr pid, >+ ref int standard_input, >+ ref int standard_output, >+ ref int standard_error, >+ out IntPtr error); >+ >+ public void Start () >+ { >+ if (args == null) >+ throw new ArgumentException ("Arguments cannot be empty"); >+ >+ IntPtr error; >+ >+ if (args [args.Length - 1] != null) { >+ // Need to null-terminate the array. >+ string[] tmp_args = new string [args.Length + 1]; >+ Array.Copy (args, tmp_args, args.Length); >+ args = tmp_args; >+ } >+ >+ g_spawn_async_with_pipes (null, args, null, >+ 1 << 2, // G_SPAWN_SEARCH_PATH >+ IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, >+ ref stdin, ref stdout, ref stderr, out error); >+ >+ if (error != IntPtr.Zero) >+ throw new SafeProcessException (new GException (error)); >+ >+ if (! RedirectStandardInput) >+ Mono.Unix.Native.Syscall.close (stdin); >+ else >+ stdin_stream = new UnixStream (stdin); >+ >+ if (! RedirectStandardOutput) >+ Mono.Unix.Native.Syscall.close (stdout); >+ else >+ stdout_stream = new UnixStream (stdout); >+ >+ if (! RedirectStandardError) >+ Mono.Unix.Native.Syscall.close (stderr); >+ else >+ stderr_stream = new UnixStream (stderr); >+ } >+ >+ public void Close () >+ { >+ if (stdin_stream != null) >+ stdin_stream.Close (); >+ >+ if (stdout_stream != null) >+ stdout_stream.Close (); >+ >+ if (stderr_stream != null) >+ stderr_stream.Close (); >+ } >+ } >+ >+ public class SafeProcessException : Exception { >+ >+ internal SafeProcessException (GException gexception) : base (gexception.Message) { } >+ } >+ >+} >\ No newline at end of file >Index: search/Tiles/File.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/File.cs,v >retrieving revision 1.15 >diff -u -p -u -r1.15 File.cs >--- search/Tiles/File.cs 31 Mar 2006 16:51:37 -0000 1.15 >+++ search/Tiles/File.cs 13 Apr 2006 18:30:07 -0000 >@@ -2,6 +2,7 @@ using System; > using System.Diagnostics; > using System.Runtime.InteropServices; > using Mono.Unix; >+using Beagle.Util; > > namespace Search.Tiles { > >@@ -68,21 +69,15 @@ namespace Search.Tiles { > { > string path = Hit.FileInfo.DirectoryName; > >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- >- if ((! path.StartsWith ("\"")) && (! path.EndsWith ("\""))) >- path = "\"" + path + "\""; >- > // FIXME: When nautilus implements this, then we should > // also select the file in the folder. > >+ SafeProcess p = new SafeProcess (); >+ > #if ENABLE_DESKTOP_LAUNCH >- p.StartInfo.FileName = "desktop-launch"; >- p.StartInfo.Arguments = path; >+ p.Arguments = new string [] { "desktop-launch", path }; > #else >- p.StartInfo.FileName = "nautilus"; >- p.StartInfo.Arguments = "--no-desktop " + path; >+ p.Arguments = new string [] { "nautilus", "--no-desktop", path }; > #endif > try { > p.Start (); >@@ -93,10 +88,8 @@ namespace Search.Tiles { > > public void Email () > { >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = "evolution"; >- p.StartInfo.Arguments = String.Format ("\"mailto:?attach={0}\"", Hit.FileInfo.FullName); >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string [] { "evolution", String.Format ("mailto:?attach={0}", Hit.FileInfo.FullName) }; > > try { > p.Start () ; >Index: search/Tiles/IMLog.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/IMLog.cs,v >retrieving revision 1.8 >diff -u -p -u -r1.8 IMLog.cs >--- search/Tiles/IMLog.cs 26 Feb 2006 17:27:32 -0000 1.8 >+++ search/Tiles/IMLog.cs 13 Apr 2006 18:30:07 -0000 >@@ -2,6 +2,7 @@ using System; > using System.Diagnostics; > using System.Collections; > using Mono.Unix; >+using Beagle.Util; > > namespace Search.Tiles { > >@@ -102,16 +103,16 @@ namespace Search.Tiles { > > public override void Open () > { >- Process p = new Process (); >- p.StartInfo.UseShellExecute = true; >- p.StartInfo.FileName = "beagle-imlogviewer"; >- p.StartInfo.Arguments = String.Format ("--client \"{0}\" --highlight-search \"{1}\" {2}", >- Hit ["fixme:client"], Query.QuotedText, Hit.Uri.LocalPath); >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string [] { "beagle-imlogviewer", >+ "--client", Hit ["fixme:client"], >+ "--highlight-search", Query.QuotedText, >+ Hit.Uri.LocalPath }; > > try { > p.Start (); > } catch (Exception e) { >- Console.WriteLine ("Unable to run {0}: {1}", p.StartInfo.FileName, e.Message); >+ Console.WriteLine ("Unable to run {0}: {1}", p.Arguments [0], e.Message); > } > } > } >Index: search/Tiles/Image.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/Image.cs,v >retrieving revision 1.13 >diff -u -p -u -r1.13 Image.cs >--- search/Tiles/Image.cs 2 Apr 2006 12:16:22 -0000 1.13 >+++ search/Tiles/Image.cs 13 Apr 2006 18:30:07 -0000 >@@ -100,9 +100,14 @@ namespace Search.Tiles { > if (Hit ["fspot:IsIndexed"] == "true") > return; > >- ProcessStartInfo pi = new ProcessStartInfo ("f-spot"); >- pi.Arguments = String.Format ("--import {0}", Hit.FileInfo.FullName); >- Process.Start (pi); >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string[] { "f-spot", "--import", Hit.FileInfo.FullName }; >+ >+ try { >+ p.Start (); >+ } catch (Exception e) { >+ Console.WriteLine ("Error launching F-Spot: " + e); >+ } > } > #endif > >Index: search/Tiles/MailAttachment.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/MailAttachment.cs,v >retrieving revision 1.3 >diff -u -p -u -r1.3 MailAttachment.cs >--- search/Tiles/MailAttachment.cs 7 Feb 2006 22:01:42 -0000 1.3 >+++ search/Tiles/MailAttachment.cs 13 Apr 2006 18:30:07 -0000 >@@ -1,6 +1,7 @@ > using System; > using System.Diagnostics; > using Mono.Unix; >+using Beagle.Util; > > namespace Search.Tiles { > >@@ -67,28 +68,24 @@ namespace Search.Tiles { > > public override void Open () > { >- string uri_str; >- > if (GetHitProperty (Hit, "fixme:client") != "evolution") { > OpenFromMime (Hit); > return; > } > >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = "evolution"; >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string [2]; >+ p.Arguments [0] = "evolution"; > > if (Hit.ParentUriAsString != null) >- uri_str = Hit.ParentUriAsString; >+ p.Arguments [1] = Hit.ParentUriAsString; > else >- uri_str = Hit.UriAsString; >- >- p.StartInfo.Arguments = "'" + uri_str + "'"; >+ p.Arguments [1] = Hit.UriAsString; > > try { > p.Start (); >- } catch (System.ComponentModel.Win32Exception e) { >- Console.WriteLine ("Unable to run {0}: {1}", p.StartInfo.FileName, e.Message); >+ } catch (SafeProcessException e) { >+ Console.WriteLine ("Unable to run {0}: {1}", p.Arguments [0], e.Message); > } > } > } >Index: search/Tiles/MailMessage.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/MailMessage.cs,v >retrieving revision 1.10 >diff -u -p -u -r1.10 MailMessage.cs >--- search/Tiles/MailMessage.cs 31 Mar 2006 17:51:50 -0000 1.10 >+++ search/Tiles/MailMessage.cs 13 Apr 2006 18:30:07 -0000 >@@ -1,6 +1,7 @@ > using System; > using System.Diagnostics; > using Mono.Unix; >+using Beagle.Util; > > namespace Search.Tiles { > >@@ -97,28 +98,24 @@ namespace Search.Tiles { > > public override void Open () > { >- string uri_str; >- > if (Hit.GetFirstProperty ("fixme:client") != "evolution") { > OpenFromMime (Hit); > return; > } > >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = "evolution"; >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string [2]; >+ p.Arguments [0] = "evolution"; > > if (Hit.ParentUriAsString != null) >- uri_str = Hit.ParentUriAsString; >+ p.Arguments [1] = Hit.ParentUriAsString; > else >- uri_str = Hit.UriAsString; >- >- p.StartInfo.Arguments = "'" + uri_str + "'"; >+ p.Arguments [1] = Hit.UriAsString; > > try { > p.Start (); >- } catch (System.ComponentModel.Win32Exception e) { >- Console.WriteLine ("Unable to run {0}: {1}", p.StartInfo.FileName, e.Message); >+ } catch (SafeProcessException e) { >+ Console.WriteLine ("Unable to run {0}: {1}", p.Arguments [0], e.Message); > } > } > >@@ -127,15 +124,13 @@ namespace Search.Tiles { > if (Hit.GetFirstProperty ("fixme:client") != "evolution") > return; > >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = "evolution"; >- p.StartInfo.Arguments = String.Format ("\"{0};forward=attached\"", Hit.Uri); >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string [] { "evolution", String.Format ("{0};forward=attached", Hit.Uri) }; > > try { > p.Start () ; > } catch (Exception e) { >- Console.WriteLine ("Error launching Evolution composer: " + e); >+ Console.WriteLine ("Error launching Evolution composer: " + e.Message); > } > } > } >Index: search/Tiles/Note.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/Note.cs,v >retrieving revision 1.4 >diff -u -p -u -r1.4 Note.cs >--- search/Tiles/Note.cs 31 Mar 2006 16:51:37 -0000 1.4 >+++ search/Tiles/Note.cs 13 Apr 2006 18:30:07 -0000 >@@ -2,6 +2,7 @@ using System; > using System.Diagnostics; > using System.Runtime.InteropServices; > using Mono.Unix; >+using Beagle.Util; > > namespace Search.Tiles { > >@@ -32,16 +33,14 @@ namespace Search.Tiles { > > public override void Open () > { >+ SafeProcess p = new SafeProcess (); >+ > // This doesn't work very well if you have multiple > // terms that match. Tomboy doesn't seem to have a way > // to specify more than one thing to highlight. >- string args = String.Format ("--open-note {0} --highlight-search \"{1}\"", >- Hit.Uri, Query.QuotedText); >- >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = "tomboy"; >- p.StartInfo.Arguments = args; >+ p.Arguments = new string [] { "tomboy", >+ "--open-note", Hit.UriAsString, >+ "--highlight-search", Query.QuotedText }; > > try { > p.Start (); >Index: search/Tiles/Tile.cs >=================================================================== >RCS file: /cvs/gnome/beagle/search/Tiles/Tile.cs,v >retrieving revision 1.15 >diff -u -p -u -r1.15 Tile.cs >--- search/Tiles/Tile.cs 16 Mar 2006 15:23:00 -0000 1.15 >+++ search/Tiles/Tile.cs 13 Apr 2006 18:30:07 -0000 >@@ -326,20 +326,14 @@ namespace Search.Tiles { > > protected void OpenFromMime (Hit hit) > { >- OpenFromMime (hit, null, null, false); >- } >- >- protected void OpenFromMime (Hit hit, string command_fallback, >- string args_fallback, bool expects_uris_fallback) >- { >- string argument; >- string command = command_fallback; >- bool expects_uris = expects_uris_fallback; >+ string command = null, item; >+ bool expects_uris = false; > > // FIXME: This is evil. Nautilus should be handling > // inode/directory, not just x-directory/normal > if (hit.MimeType == "inode/directory") > hit.MimeType = "x-directory/normal"; >+ > #if ENABLE_DESKTOP_LAUNCH > command = "desktop-launch"; > expects_uris = true; >@@ -356,39 +350,47 @@ namespace Search.Tiles { > return; > } > >- if (args_fallback != null) >- argument = args_fallback; >- else >- argument = ""; >- >- if (expects_uris) { >- argument = String.Format ("{0} '{1}'", argument, >- UriFu.UriToSerializableString(hit.Uri)); >- } else { >- argument = String.Format ("{0} {1}", argument, hit.PathQuoted); >- } >+ if (expects_uris) >+ item = UriFu.UriToSerializableString (hit.Uri); >+ else >+ item = hit.Path; > > // Sometimes the command is 'quoted' > if (command.IndexOf ('\'') == 0 && command.LastIndexOf ('\'') == command.Length - 1) > command = command.Trim ('\''); > > // This won't work if a program really has a space in >- // the filename, but I think other things would break >- // with that too, and in practice it doesn't seem to >+ // the command filename, but I think other things would >+ // break with that too, and in practice it doesn't seem to > // happen. >+ // >+ // A bigger issue is that the arguments are split up by >+ // spaces, so quotation marks used to indicate a single >+ // entry in the argv won't work. This probably should >+ // be fixed. >+ string[] arguments = null; > int idx = command.IndexOf (' '); > if (idx != -1) { >- argument = String.Format ("{0} {1}", command.Substring (idx + 1), argument); >+ arguments = command.Substring (idx + 1).Split (' '); > command = command.Substring (0, idx); > } > >+ string[] argv; >+ if (arguments == null) >+ argv = new string [] { command, item }; >+ else { >+ argv = new string [arguments.Length + 2]; >+ argv [0] = command; >+ argv [argv.Length - 1] = item; >+ Array.Copy (arguments, 0, argv, 1, arguments.Length); >+ } >+ > Console.WriteLine ("Cmd: {0}", command); >- Console.WriteLine ("Arg: {0}", argument); >+ Console.WriteLine ("Arg: {0}", String.Join (" ", argv, 1, argv.Length - 2)); >+ Console.WriteLine ("Itm: {0}", item); > >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = command; >- p.StartInfo.Arguments = argument; >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = argv; > > try { > p.Start (); >@@ -405,10 +407,8 @@ namespace Search.Tiles { > public void OpenFromUri (string uri) > { > #if ENABLE_DESKTOP_LAUNCH >- Process p = new Process (); >- p.StartInfo.UseShellExecute = false; >- p.StartInfo.FileName = "desktop-launch"; >- p.StartInfo.Arguments = uri; >+ SafeProcess p = new SafeProcess (); >+ p.Arguments = new string[] { "desktop-launch", uri }; > > try { > p.Start ();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 129861
: 84584