Category Archives: New (to me)

New Gee Whiz stuff I find

Mounting a Windows Drive on Ubuntu

We have a development system that is separate from our regular corporate system. Unfortunately, that means that any off-site backups aren’t happening. In order to allow for a backup of data we need to keep, I needed to mount a Windows drive to a Linux box, to copy the files over to the corporate system for backup.

I tried for half a day to accomplish this, using both NFS and CIFS mounts. The first thing I discovered was that the drive I was trying to mount to was not a physical drive on the box I was trying to access. Apparently, that’s not acceptable for NFS. And, to my chagrin, CIFS would allow it, but I could never write to the drive. Next issue I found was that the mount didn’t like network logins; I needed to use a login from that machine, and I needed to make sure the drive had write permission for that user. Perhaps that’s why I couldn’t write to the non-local drive.

So, with a local login, and a local drive to the Windows box, I was able to accomplish my task.

On the Windows box, I did a simple share. And I made sure the drive had write permissions for the local user I would use. On the Ubuntu box, I used the following in the fstab file:

//server/share /ubuntu/mountpoint cifs user=windowslocaluser,password=userpw,defaults 0 0

Cyrus Upgrade Error on Ubuntu

For several months now, I’ve been getting an error every time I tried to do an upgrade of my ubuntu system:


 Converting from /var/lib/cyrus/deliver.db (berkeley-nosync) to /tmp/deliver.db.cOT3kOvz (skiplist)
 fatal error: can't open old database
 dpkg: error processing cyrus-common-2.4 (--configure):
 subprocess installed post-installation script returned error exit status 75
 dpkg: dependency problems prevent configuration of cyrus-pop3d-2.4:
 cyrus-pop3d-2.4 depends on cyrus-common-2.4 (= 2.4.12-2); however:
 Package cyrus-common-2.4 is not configured yet.
 dpkg: error processing cyrus-pop3d-2.4 (--configure):
 dependency problems - leaving unconfigured
 dpkg: dependency problems prevent configuration of cyrus-pop3d:
 cyrus-pop3d depends on cyrus-pop3d-2.4; however:
 Package cyrus-pop3d-2.4 is not configured yet.
 dpkg: error processing cyrus-pop3d (--configure):
 dependency problems - leaving unconfigured
 

I tried removing cyrus altogether. But there were so many inter-dependencies that it wasn’t an option.

I finally found a clue as to how to fix it here, but I had to modify it a bit for my own situation.

I moved the deliver.db and tls_sessions.db files, then ran the upgrade command and voila! everything worked!


 sudo su -
 cd /var/lib/cyrus
 mv deliver.db deliver.db.old
 mv tls_sessions.db tls_sessions.db.old
 

Once the upgrades are done, the ‘old’ files can be removed. Yes, you might be able to get away with just deleting those files in the first place. But I like to play it safe.

Note: does this mean that there may be local mail not delivered? It could. But my local mail is only used for notifications, so it wasn’t a big deal to me.

XPath and C#

Our C# application needs to retrieve data from a Java SOAP source. And, anyone who has dealt with SOAP for any time knows that standards aren’t. In our case, the null dates in the data were being passed back with a date that the Java system, I supposed, considered ‘null’: 1899-01-01 00:00:00. But our C# system parsed the incoming XML and saw a ‘Date Format Exception’.

This all happened when we used Visual Studio’s automagic object creator (Add Service Reference/Advanced/Add Web Reference). When we switched to used the ‘standard’ Add Service Reference, this error disappeared. But we then saw a Number Format Exception error. We couldn’t figure out where this one was coming from, so we started seeking other options.

The Java SOAP services are being created using Axis 2, which permits the user to also make REST calls. So I changed my code to use an XPathDocument to make a REST call for the data. The data returned is still in XML format. But this allows me to walk through the elements myself and either ignore the elements if I don’t need them, or handle a single element’s value if it causes issues.

I found about 5 different ways of accomplishing this exercise before settling on the XPathDocument method I found in Using Returned XML with C#. The one ‘gotcha’ that I had to contend with was remembering to use the XMLNamespaceManager once I created it. Using it is optional when searching for nodes.

The one ‘gotcha’ I ran into was remembering to include *all* the namespaces used within the document, and to use the optional namespace argument when searching for nodes. Without it, I ran into expected – and unexpected – errors:

1) The obvious one – it complained about the fact I was using ‘:’ within the node name but not declaring namespaces.
2) I ran into one error – I can’t reproduce it now – but it complained about the ‘:’ and only told me that was an illegal character to use within a node name, without telling me why.
3) I put one namespace in, but not both that were used in the document and ran into problems with that as well.