wicd daemon fails to start if /etc/resolv.conf is a relative symlink

Bug #1193856 reported by tommy
This bug report is a duplicate of:  Bug #1132529: Can't start wicd daemon. Edit Remove
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
wicd
New
Undecided
Unassigned

Bug Description

wicd version 1.7.2.4-4, Ubuntu 13.04 amd64

Traceback (most recent call last):
  File "/usr/share/wicd/daemon/wicd-daemon.py", line 1859, in <module>
    main(sys.argv)
  File "/usr/share/wicd/daemon/wicd-daemon.py", line 1708, in main
    os.symlink(dest, backup_location)
OSError: [Errno 17] File exists

I have a fresh install of Ubuntu 13.04, and /etc/resolv.conf is symlinked to "../run/resolvconf/resolv.conf".

When wicd-daemon.py checks if it has backed this file up, it uses "os.path.exists" on the backup location.
os.path.exists returns False for broken symlinks.
The location "../run/resolvconf/resolv.conf" does not exist relative to the backup location.
Thus wicd-daemon.py assumes there is nothing there and tries to write to it, when in fact there is a (correctly backed up, but broken) symlink there.

relevant section of code:
"""
    # back up resolv.conf before we do anything else
    try:
        backup_location = wpath.varlib + 'resolv.conf.orig'
        # don't back up if .orig exists, probably there cause
        # wicd exploded
        print wpath.varlib
        if not os.path.exists(backup_location):
            if os.path.islink('/etc/resolv.conf'):
                dest = os.readlink('/etc/resolv.conf')
                os.symlink(dest, backup_location)
            else:
                shutil.copy2('/etc/resolv.conf', backup_location)
            os.chmod(backup_location, 0644)
    except IOError:
        print 'error backing up resolv.conf'
"""

suggested fix:

- if not os.path.exists(backup_location):
+ if not os.path.exists(backup_location) \
+ and not os.path.islink(backup_location):

or something like that.

Related branches

tommy (mesilliac)
description: updated
description: updated
Revision history for this message
zack knyon (zack-kenyon) wrote :

the suggested fix works for me.

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.