Edgewall Software
Modify

Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#10044 closed defect (fixed)

Unhelpful error message when config permissions are incorrect for reading

Reported by: verm Owned by: Jun Omae
Priority: normal Milestone: 0.12.3
Component: general Version: 0.12dev
Severity: normal Keywords: config permissions
Cc: verm@…, Thijs Triemstra, Jun Omae Branch:
Release Notes:
API Changes:
Internal Changes:

Description

After a fresh installation using trac-admin initenv I was unable to load the instance from the web with this error message:

TimeoutError: Unable to get database connection within 0 seconds. (TracError: Database "/usr/www/trac/db/trac.db" not found.)

MY backend was set to MySQL (and initenv even populated the database). After much debugging I figured out the problem after discovering it worked successfully using tracd.

The config file was not readable by the webserver, this problem can be reproduced by a chmod 000 conf/trac.ini.

Attachments (1)

t10044-configparser-read-r10853.diff (1.4 KB ) - added by Jun Omae 13 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 by Amar Takhar <verm@…>, 14 years ago

Cc: verm@… added

comment:2 by Remy Blank, 14 years ago

Related to #7378.

comment:3 by Christian Boos, 14 years ago

On Windows, when the file is not readable I get the appropriate "TracError: IOError: [Errno 13] Permission denied: '…'" (trunk). However I get an "TracError: The Trac Environment needs to be upgraded." in case the trac.ini file is missing. Not good either.

This was for the web front-end. For trac-admin, I get Error: Command not found for anything beyond help, since no commands are known.

in reply to:  3 comment:4 by Christian Boos, 14 years ago

Replying to cboos:

On Windows, when the file is not readable I get the appropriate "TracError: IOError: [Errno 13] Permission denied: '…'" (trunk).

… with the patch from #7378 applied, that is.

comment:5 by verm, 14 years ago

I tried the patch from #7378 and got this error message:

Error

TracError: IOError: [Errno 13] Permission denied: '/usr/www/trac/conf/trac.ini'

So I would say that it's fixed, for the case of a missing trac.ini however the message isn't as nice:

Error

TracError: AttributeError: 'Configuration' object has no attribute 'parsed_options'

in reply to:  5 comment:6 by Christian Boos, 14 years ago

Milestone: 0.13

Replying to verm:

for the case of a missing trac.ini however the message isn't as nice:

Error

TracError: AttributeError: 'Configuration' object has no attribute 'parsed_options'

Strange, I don't see that… I will investigate (was that on Linux?)

comment:7 by verm, 14 years ago

FreeBSD 9-CURRENT

comment:8 by Christian Boos, 14 years ago

In addition, we should add group rw perms to trac.ini when creating it (googlegroups:trac-users:afe74b4aa40a2d60).

comment:9 by Remy Blank, 14 years ago

#10098 was closed as a duplicate.

I wonder how come we get more and more of such reports lately. Has anything changed in the way we parse trac.ini?

comment:10 by Thijs Triemstra, 14 years ago

Cc: Thijs Triemstra added

comment:11 by Remy Blank, 14 years ago

#10192 was closed as a duplicate.

comment:12 by duncang@…, 13 years ago

New clue, if you're working on it. This failure is intermittent. I click the resend in firefox and it shows up … maybe yes … maybe no. Happens on any pages … login, help pages , browse source …

trac 0.12.2 ubuntu 11.04 brand new apache, all the mods and pythons …

comment:13 by anonymous, 13 years ago

When I use php5, Apache and Trac I have the same error. The error is sporadic. When disable php5, error disappears.

in reply to:  3 comment:14 by Thijs Triemstra, 13 years ago

Replying to cboos:

On Windows, when the file is not readable I get the appropriate "TracError: IOError: [Errno 13] Permission denied: '…'" (trunk). However I get an "TracError: The Trac Environment needs to be upgraded." in case the trac.ini file is missing. Not good either.

I'm also getting this upgrade message when the permissions for trac.ini are incorrect:

-rw------- 1 root root 528 2011-09-17 00:19 trac.ini

Extremely confusing, and only figured out after many environment upgrade tries..

in reply to:  13 comment:15 by anonymous, 13 years ago

Replying to anonymous:

When I use php5, Apache and Trac I have the same error. The error is sporadic. When disable php5, error disappears.

I'm confirming above. My configuration: RHEL6 apache 2.2.15-5 php-5.3.2 mod_wsgi-3.2-1 postgresql 8.4.7

When Trac is served via mod_wsgi and PHP is enabled then this error appears in about 50% of requests. When I disable PHP, it works OK. Of course, disabling PHP is not acceptable solution in my case. Could someone help?

by Jun Omae, 13 years ago

comment:16 by Jun Omae, 13 years ago

Cc: Jun Omae added

I can reproduce the issue:

  1. Create tracenv with other than sqlite database (e.g. specifies mysql://...)
  2. Drop all permissions of conf/trac.ini. (chmod 0000 conf/trac.ini)
  3. Launch tracd and access using your browser.

Because Trac do not check the return value of ConfigParser.read() and initializes self.config with the default values in this case.

ConfigParser.read() returns list of successfully parsed filenames. http://docs.python.org/library/configparser.html#ConfigParser.RawConfigParser.read.

In my patch, attachment:t10044-configparser-read-r10853.diff, adds checking for .read() and handling the exception for trac-admin.

jun66j5@gotanda:1586$ PYTHONPATH=$PWD python2.4 trac/admin/console.py ~/var/trac/0.12-t10044
Welcome to trac-admin 0.12.3dev-r0
Interactive Trac administration console.
Copyright (C) 2003-2011 Edgewall Software

Type:  '?' or 'help' for help on commands.

Trac [/home/jun66j5/var/trac/0.12-t10044]> wiki list
Error: Error reading trac.ini, make sure it is readable.
Trac [/home/jun66j5/var/trac/0.12-t10044]> help
trac-admin - The Trac Administration Console 0.12.3dev-r0
help     Show documentation
initenv  Create and initialize a new environment
Trac [/home/jun66j5/var/trac/0.12-t10044]> 

comment:17 by Remy Blank, 13 years ago

Looks good. You should mention the full path to the config file in the TracError, as it's not always trac.ini (think [inherit] file).

You could apply this in 0.12-stable.

comment:18 by Jun Omae, 13 years ago

Milestone: 0.130.12.3
Resolution: fixed
Status: newclosed

Thanks, Remy!

The patch with your suggestion is committed in [10856/branches/0.12-stable].

comment:19 by Jun Omae, 13 years ago

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.