#12000 closed defect (fixed)
Symbolic link for trac.ini overwritten when saving Configuration object
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.6 |
Component: | general | Version: | |
Severity: | normal | Keywords: | config |
Cc: | Branch: | ||
Release Notes: |
Fixed: symbolic link at |
||
API Changes: |
|
||
Internal Changes: |
Description (last modified by )
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.
Using os.path.realpath
seems to be the proper solution:
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): 129 129 when the file has changed. 130 130 """ 131 131 def __init__(self, filename, params={}): 132 self.filename = filename132 self.filename = os.path.realpath(filename) # follow any symlinks 133 133 self.parser = UnicodeParser() 134 134 self._parsed_sections = {} 135 135 self.parents = []
Inherited files and files defined in PathOption
s 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.
Attachments (0)
Change History (5)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Replying to rjollos:
Inherited files and files defined in
PathOption
s are resolved relative to the location of trac.ini. Before the patch this is always the Environmentconf
directory. I think the behaviour is better after the patch.
I've reconsidered based on comment:1. It will probably be better to store all files relative to the conf
directory, rather than relative to trac.ini
. We can just symlink all files in conf
, if desired.
Proposed changes in log:rjollos.git:t12000. Tested on Ubuntu 14.04 and Windows 7.
comment:3 by , 10 years ago
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:5 by , 10 years ago
Description: | modified (diff) |
---|
Configuration.filename
instance is used withos.path.dirname()
inSeciotn.getpath()
at tags/trac-1.0.5/trac/config.py@:481#L471. Applying the patch would change behavior ofPathOption
, e.g. when$ENV/conf
is a symbolic link.I consider the root cause is that
AtomicFile.commit()
removes a symbolic file. We should modifyAtomicFile
class.trac/util/__init__.py