Backing up resolv.conf fails if readlink returns relative path

Bug #1295253 reported by John Chadwick
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wicd
New
Undecided
Unassigned

Bug Description

I had an issue where wicd was unable to start because it was trying to back up resolv.conf, but the symlink path was relative. It appears instead of using os.readlink to find the destination of a link, it's better to use os.path.realpath, which always returns an absolute path. A simple replacement fixed the problem for me.

I also noticed that wicd would fail to start if /var/lib/wicd/resolv.conf.orig was an invalid symlink. This case could occur for other reasons, e.g. the file being removed. I think the code should be changed to account for that possibility.

Revision history for this message
chalom (andrechalom) wrote :

This bug has affected me as well (Ubuntu 13.10, wicd 1.7.2.4 (bzr-r768)). My resolv.conf was a symlink to "../run/resolvconf/resolv.conf".

While trying to debug the issue, I also noticed that the try block is ended by a "except IOError", but the errors that may arise either by the symlink being present but invalid (in which case os.symlink(dest, backup_location) will fail) or created by this session (in which case os.chmod(backup_location, 0644) will fail) are OSError, and not IOError. Maybe this exception class should be added to the except clause?

Revision history for this message
Doug (illusion65) wrote :

Oops, didn't think of "realpath()" function! That is better than my solution. Here's my updated patch... Again, I don't have a clean system to test it, but I believe it's fine. Cheers, Doug

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.