Edgewall Software

Opened 9 years ago

Last modified 9 years ago

#12000 closed defect

Symbolic link for trac.ini overwritten when saving Configuration object — at Initial Version

Reported by: Ryan J Ollos Owned by:
Priority: normal Milestone: 1.0.6
Component: general Version:
Severity: normal Keywords: config
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I tried storing trac.ini in a version-controlled directory outside of the Environment, using a symbolic link in the Environment conf directory. The symbolic link is not followed when saving the Configuration object.

Investigation revealed the following:

user@ubuntu:~/Workspace$ touch file
user@ubuntu:~/Workspace$ ln -s file link
user@ubuntu:~/Workspace$ ls -al file link
-rw-rw-r-- 1 user user 0 Mar 25 21:17 file
lrwxrwxrwx 1 user user 4 Mar 25 21:17 link -> file
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath('/home/user/Workspace/link')
'/home/user/Workspace/file'

The following patch appears to work.

  • trac/config.py

    diff --git a/trac/config.py b/trac/config.py
    index d407da1..43ecd81 100644
    a b class Configuration(object):  
    129129    when the file has changed.
    130130    """
    131131    def __init__(self, filename, params={}):
    132         self.filename = filename
     132        self.filename = os.path.realpath(filename)  # follow any symlinks
    133133        self.parser = UnicodeParser()
    134134        self._parsed_sections = {}
    135135        self.parents = []

Inherited files and files defined in PathOptions are resolved relative to the location of trac.ini. Before the patch this is always the Environment conf directory. I think the behaviour is better after the patch.

Change History (0)

Note: See TracTickets for help on using tickets.