diff -u bareftp-0.3.1/debian/control bareftp-0.3.1/debian/control --- bareftp-0.3.1/debian/control +++ bareftp-0.3.1/debian/control @@ -1,7 +1,8 @@ Source: bareftp Section: gnome Priority: optional -Maintainer: Debian CLI Applications Team +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian CLI Applications Team Uploaders: Mirco Bauer , Stefan Ebner Build-Depends: debhelper (>= 7.0.50), cli-common-dev (>= 0.7), diff -u bareftp-0.3.1/debian/changelog bareftp-0.3.1/debian/changelog --- bareftp-0.3.1/debian/changelog +++ bareftp-0.3.1/debian/changelog @@ -1,3 +1,10 @@ +bareftp (0.3.1-1ubuntu1.1) lucid-proposed; urgency=low + + * Fix gnome-keyring-sharp crash and catch an unhandled exception + when trying to access to it (LP: #568840) + + -- Stefan Ebner Sat, 08 May 2010 12:18:57 +0200 + bareftp (0.3.1-1) unstable; urgency=low * New upstream release diff -u bareftp-0.3.1/debian/patches/series bareftp-0.3.1/debian/patches/series --- bareftp-0.3.1/debian/patches/series +++ bareftp-0.3.1/debian/patches/series @@ -1,0 +2 @@ +02_fix_gnome-keyring-sharp_crash only in patch2: unchanged: --- bareftp-0.3.1.orig/debian/patches/02_fix_gnome-keyring-sharp_crash +++ bareftp-0.3.1/debian/patches/02_fix_gnome-keyring-sharp_crash @@ -0,0 +1,380 @@ +--- bareftp-0.3.1.orig/src/bareFTP.Gui.Preferences/BookmarkDialog.cs ++++ bareftp-0.3.1/src/bareFTP.Gui.Preferences/BookmarkDialog.cs +@@ -142,7 +142,14 @@ + ParseStore(iter, doc, xbookmarks); + + doc.AppendChild(xbookmarks); +- b.Save(doc); ++ try ++ { ++ b.Save(doc); ++ } ++ catch(bareFTP.Preferences.KeyringException ex) ++ { ++ Dialog.Dialogs.ErrorDialog(ex.Message); ++ } + } + + private void ParseStore(Gtk.TreeIter _iter, XmlDocument doc, XmlElement xelem) +--- bareftp-0.3.1.orig/src/bareFTP.Gui.Preferences/PreferencesDialog.cs ++++ bareftp-0.3.1/src/bareFTP.Gui.Preferences/PreferencesDialog.cs +@@ -129,7 +129,16 @@ + + protected void on_use_gnome_keyring_toggled(object sender, EventArgs e) + { +- prefs.General_UseGnomeKeyring = cb_use_gnome_keyring.Active; ++ try ++ { ++ prefs.General_UseGnomeKeyring = cb_use_gnome_keyring.Active; ++ } ++ catch(Exception ex) ++ { ++ Console.WriteLine(ex.ToString()); ++ bareFTP.Gui.Dialog.Dialogs.ErrorDialog(Mono.Unix.Catalog.GetString("Communication with GnomeKeyring failed and has been disabled")); ++ cb_use_gnome_keyring.Active = false; ++ } + } + + protected void cb_simultaneous_transfers_toggled(object sender, EventArgs e) +--- bareftp-0.3.1.orig/src/bareFTP.Gui/BookmarkUtils.cs ++++ bareftp-0.3.1/src/bareFTP.Gui/BookmarkUtils.cs +@@ -66,6 +66,19 @@ + } + + Preferences.Bookmarks.Bookmarks b = new Preferences.Bookmarks.Bookmarks(); ++ ++ if(!b.BackendOperational) ++ { ++ Console.WriteLine("BackendOperational: Gnome Keyring not available"); ++ MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, ++ MessageType.Error, ButtonsType.Ok, ++ Mono.Unix.Catalog.GetString("Communication with GnomeKeyring failed and has been disabled.") + ++ Environment.NewLine + Environment.NewLine + ++ Mono.Unix.Catalog.GetString("If the problem persists, you may want to disable it permanently")); ++ md.Run (); ++ md.Destroy(); ++ } ++ + if(b.RootItem != null) + CreateBookmarkItems(b.RootItem, bookmarkitems, bookmarkitems2); + +--- bareftp-0.3.1.orig/src/bareFTP.Preferences/Bookmarks/Bookmarks.cs ++++ bareftp-0.3.1/src/bareFTP.Preferences/Bookmarks/Bookmarks.cs +@@ -26,7 +26,6 @@ + namespace bareFTP.Preferences.Bookmarks + { + +- + public class Bookmarks + { + BookmarkFolder rootItem; +@@ -38,14 +37,24 @@ + + public Bookmarks() + { +- pwdBackend = new PwdBackend(); + this.conf = new Config(string.Empty); + use_keyring = conf.General_UseGnomeKeyring; + ++ pwdBackend = new PwdBackend(); ++ ++ try ++ { ++ pwdBackend.CheckKeyring(); ++ } ++ catch ++ { ++ pwdBackend = null; ++ use_keyring = false; ++ } ++ + string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "bareftp/bookmarks.xml"); + if(System.IO.File.Exists(path)) + { +- + bookmarks = new XmlDocument(); + bookmarks.Load(path); + XmlNode blist = bookmarks.SelectSingleNode("/bookmarks"); +@@ -53,7 +62,6 @@ + rootItem = new BookmarkFolder(string.Empty); + Traverser((XmlElement)blist, rootItem); + } +- + } + + public Bookmarks(string filename) +@@ -74,6 +82,24 @@ + + } + ++ public bool BackendOperational ++ { ++ get ++ { ++ PwdBackend backend = new PwdBackend(); ++ try ++ { ++ if(conf.General_UseGnomeKeyring) ++ backend.CheckKeyring(); ++ return true; ++ } ++ catch ++ { ++ return false; ++ } ++ } ++ } ++ + private void Traverser(XmlElement element, BookmarkFolder folder) + { + IEnumerator iter = element.ChildNodes.GetEnumerator(); +@@ -152,6 +178,9 @@ + + public void Save(XmlDocument doc) + { ++ if(doc == null) ++ return; ++ + SavePasswords(doc); + + string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "bareftp/bookmarks.xml"); +@@ -173,6 +202,24 @@ + + public void SavePasswords(XmlDocument doc) + { ++ if(doc == null) ++ return; ++ ++ if(pwdBackend == null) ++ use_keyring = false; ++ else ++ { ++ try ++ { ++ if(use_keyring) ++ pwdBackend.CheckKeyring(); ++ } ++ catch ++ { ++ use_keyring = false; ++ } ++ } ++ + if(use_keyring) + pwdBackend.CleanUpItems(); + +--- bareftp-0.3.1.orig/src/bareFTP.Preferences/Bookmarks/GnomeKeyring/PwdBackend.cs ++++ bareftp-0.3.1/src/bareFTP.Preferences/Bookmarks/GnomeKeyring/PwdBackend.cs +@@ -1,3 +1,22 @@ ++// PwdBackend.cs ++// ++// Copyright (C) 2009-2010 Christian Eide ++// ++// This program is free software; you can redistribute it and/or modify ++// it under the terms of the GNU General Public License as published by ++// the Free Software Foundation; either version 2 of the License, or ++// (at your option) any later version. ++// ++// This program is distributed in the hope that it will be useful, ++// but WITHOUT ANY WARRANTY; without even the implied warranty of ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++// GNU General Public License for more details. ++// ++// You should have received a copy of the GNU General Public License ++// along with this program; if not, write to the Free Software ++// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++// ++ + using System; + using System.Collections; + using System.Collections.Generic; +@@ -8,15 +27,27 @@ + namespace bareFTP.Preferences + { + +- + public class PwdBackend + { + + const string RootPath = "bareftp"; +- ++ string keyring = string.Empty; + public PwdBackend() + { ++ ++ } ++ ++ public void CheckKeyring() ++ { ++#if HAVE_GNOME_KEYRING ++ if(!Ring.Available) ++ throw new Exception("Gnome Keyring not available"); ++ + ++ keyring = Ring.GetDefaultKeyring(); ++ if(string.IsNullOrEmpty(keyring)) ++ keyring = "login"; ++#endif + } + + public string GetPwd(int keyid) +@@ -29,50 +60,17 @@ + { + try + { +- ItemData item = Ring.GetItemInfo(Ring.GetDefaultKeyring(), keyid); +- //if(item.Attributes["obj"] == "bareftp") +- return item.Secret; ++ ItemData item = Ring.GetItemInfo(keyring, keyid); ++ return item.Secret; + } + catch (KeyringException e) { + return string.Empty; + } + } + return string.Empty; +- /* +- string _protocol = "ftp"; +- if(protocol == 3) +- _protocol = "sftp"; +- +- Hashtable hash = new Hashtable(); +- hash["user"] = user; +- hash["server"] = host; +- hash["protocol"] = _protocol; +- hash["obj"] = "bareftp"; +- if(!string.IsNullOrEmpty(port)) +- hash["port"] = Convert.ToInt32(port); +- +- try { +- ItemData[] datatbl = Ring.Find(ItemType.NetworkPassword, hash); +- if(datatbl != null && datatbl.Length > 0) +- { +- foreach(ItemData d in datatbl) +- { +- if(d.ItemID == keyid) +- return d.Secret; +- } +- return datatbl[0].Secret; +- } +- else +- return string.Empty; +- } catch (KeyringException e) { +- return null; +- } +- */ + #else + return string.Empty; + #endif +- +- + } + + public int SetPwd(string user, string host, int protocol, string port, string passwd, bool isnew) +@@ -99,7 +97,7 @@ + int keyid = -1; + + try { +- keyid = Ring.CreateItem(Ring.GetDefaultKeyring(), ItemType.NetworkPassword, ++ keyid = Ring.CreateItem(keyring, ItemType.NetworkPassword, + "bareftp:" + user + "@" + host, hash, passwd, isnew); + } catch (KeyringException e) { + return -1; +@@ -131,20 +129,19 @@ + if(!Ring.Available) + throw new Exception("Gnome Keyring not available"); + +- Hashtable hash = new Hashtable(); +- hash["obj"] = "bareftp"; +- +- try { +- ItemData[] datatbl = Ring.Find(ItemType.NetworkPassword, hash); +- if(datatbl != null && datatbl.Length > 0) +- { +- foreach(ItemData d in datatbl) +- { +- Ring.DeleteItem(Ring.GetDefaultKeyring(), d.ItemID); +- } +- ++ try ++ { ++ List ids = new List(); ++ ++ foreach (int id in Ring.ListItemIDs (keyring)) { ++ Hashtable tbl = Ring.GetItemAttributes(keyring, id); ++ if(tbl["obj"] != null && tbl["obj"].ToString() == "bareftp") ++ ids.Add(id); + } +- ++ foreach(int id in ids) ++ { ++ Ring.DeleteItem(keyring, id); ++ } + } catch (KeyringException e) { + + } +@@ -156,15 +153,15 @@ + #if HAVE_GNOME_KEYRING + if(!Ring.Available) + throw new Exception("Gnome Keyring not available"); +- ++ + try { +- ItemData data = Ring.GetItemInfo(Ring.GetDefaultKeyring(), keyid); ++ ItemData data = Ring.GetItemInfo(keyring, keyid); + if(data != null) + { + + if(data.ItemID == keyid) + { +- Ring.DeleteItem(Ring.GetDefaultKeyring(), data.ItemID); ++ Ring.DeleteItem(keyring, data.ItemID); + return true; + } + } +@@ -175,7 +172,10 @@ + #endif + return false; + } +- +- ++ } ++ ++ public class KeyringException : Exception ++ { ++ public KeyringException(string msg) : base(msg) {} + } + } +--- bareftp-0.3.1.orig/src/bareFTP.Preferences/Preferences.cs ++++ bareftp-0.3.1/src/bareFTP.Preferences/Preferences.cs +@@ -82,10 +82,26 @@ + } + set + { +- Bookmarks.Bookmarks bm = new Bookmarks.Bookmarks(); +- client.Set(GCONF_APP_PATH + "/general/use_gnome_keyring", value); +- client.SuggestSync(); +- bm.Save(value); ++ try ++ { ++ if(value == General_UseGnomeKeyring) ++ return; ++ ++ Bookmarks.Bookmarks bm = new Bookmarks.Bookmarks(); ++ client.Set(GCONF_APP_PATH + "/general/use_gnome_keyring", value); ++ client.SuggestSync(); ++ bm.Save(value); ++ if(!bm.BackendOperational) ++ { ++ throw new Exception("Gnome Keyring not available"); ++ } ++ } ++ catch(Exception ex) ++ { ++ client.Set(GCONF_APP_PATH + "/general/use_gnome_keyring", false); ++ client.SuggestSync(); ++ throw ex; ++ } + } + } +