I'm currently using KeePass2 2.26 on Debian with Mono 3.0.6. So far everything works great, except that I get a crash when trying to create triggers. I go to Tools -> Triggers, click Add, click the Actions tab, click Add, then when I click on the grey box next to File/URL, the keepass window goes away and I get the following message in the console:
~~~~~~
System.ObjectDisposedException: The object was used after being disposed.
at System.Windows.Forms.Control.CreateHandle () [0x00000] in <filename unknown="">:0
at System.Windows.Forms.TextBoxBase.CreateHandle () [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.CreateControl () [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.SetVisibleCore (Boolean value) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.set_Visible (Boolean value) [0x00000] in <filename unknown="">:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:set_Visible (bool)
at System.Windows.Forms.DataGridView.BeginEdit (Boolean selectAll) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore (Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.DataGridView.OnMouseDown (System.Windows.Forms.MouseEventArgs e) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.WmLButtonDown (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.DataGridView.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown="">:0
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00000] in <filename unknown="">:0
~~~~~~~</filename></filename></filename></filename></filename></filename></filename></filename></filename></filename></filename></filename></filename></filename>
This is a bug in Mono; the bug report is here:
https://bugzilla.xamarin.com/show_bug.cgi?id=9653
Best regards,
Dominik
Ah, okay. I wish there were a better workaround, but for now I can at least edit the parameters in KeePass.config.xml manually once I add the trigger entries.
That bug has been a "lowest" priority bug in Mono for over a year, with no sign of work being done on it yet ... sad :).
I have managed to add the trigger I wanted (to backup my keepass data when I save it), but I have no idea how to edit the XML to specify the action (run a shell script that does this ... I am on Ubuntu 14.04).
If the shell script were for example "/home/paul/backup_keepass", then what changes would I make to the action for this trigger, which currently shows:
I know almost nothing about mono ... but the following report suggests to me that this is NOT a mono but, but rather a misuse of mono resources by keepass that doesn't happen to show up on Windows or older Linux Mono versions.
http://stackoverflow.com/questions/10830651/monodroid-objectdisposedexception-when-loading-xdocument-for-rss
See for example the reply that begins with the words "The ObjectDisposedException made me think of it. ..."
I've modified your trigger to match your request, hopefully. I've used the event "Saved database file", called it "Backup Database on Save" and added arguments to your script which can be replaced by an empty Parameter place holder.
cheers, Paul
Thanks. That helped. I didn't require any arguments, and I couldn't see why I would need to pass a final parameter of True, so I reduced the <parameters> to just:</parameters>
Perhaps I messed something up by doing this. For now, just invoking keepass2, entering my Master Password, and then selecting "Exit" from the "File" pull down menu (having done nothing useful ... just fire it up and exit immediately) results in an exception:
Last edit: Paul Jackson 2014-08-14
Leave both parameters in and try again. The "True" parameter is to wait for exit. Set it to false if you don't want to wait.
cheers, Paul
Last edit: Paul 2014-08-15
The other Paul suggested:
Thanks for getting back to me. I tried both what you suggested above, with three Parameter arguments (the 2nd empty and the 3rd True), and also a variation with the 3rd Parameter set to False.
I could see one difference between these two experiments. When the third parameter was True, there was a delay on exit, equal to the time my backup_keepass program requires to run. When the third parameter was False, there was no such delay, and the backup ran asynchronously. Given your explanation of the third parameter, this is exactly as expected.
However, unfortunately, in either case, the program then crashed with the same Unhandled Exception as I recently reported above.
Last edit: Paul Jackson 2014-08-16
Then set up a Cron job to run a script that checks if the database has been modified, if so run a backup.
cheers, Paul
The other Paul wrote:
True - I can do that. Or I could use inotify (Linux), FileSystemWatcher, FindFirstChangeNotification or others (Windows), or fsevents (OS X).
===
However, I will confess that I am finding it unfortunate that KeePass on Linux depends on the Linux port of Mono. I see from scanning this SourceForge bug database that the use of Mono results in quite a few unresolveable bugs in the KeePass port to Linux (such as this one). It also presents what seems to me to be a less than slick gui interface on Linux desktops, and it brings in a substantial stack of gui library that I otherwise had little use for.
Granted, I am a long standing Linux (and Unix, since the days of getting 9-track tapes from Ken Thompson, back in the 1970's) expert, with an almost as long standing anti-DOS, anti-Windows, anti-Microsoft bias, so Mono would have a steep up hill climb to gain my support. If I were more expert in gui programming, and had more free time on my hands, I'd be tempted to try porting KeePass to a more Linux friendly and native graphical user interface ... but alas such is not the case.
If someone does try such a port ... let me know and there's a fair chance I can be enticed to try it out.
===
Thank-you, other Paul, for your responsive and supportive attention to this report.
Isn't that what KeePassX was supposed to be?
T. Bug Reporter wrote:
Indeed it is!
I just now realized that there are quite a few alternative ports of KeePass to different operating environments, including KeePassX on Qt (for OS X and Linux), KeePassC on curses and Python, ... See http://en.wikipedia.org/wiki/KeePass for a list of such alternatives.
Having realized this, I returned to this old bug, to suggest that died in the wool old Linux hackers like me would likely prefer Qt based KeePassX, or perhaps one of the other C, Perl or Python variants, over the Mono (.net) based KeePass, and found your note here.
Good - thanks.
Last edit: Paul Jackson 2014-08-19
A list of ports can also be found on
http://keepass.info/download.html
Best regards,
Dominik