Edgewall Software
Modify

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#10044 closed defect (fixed)

Unhelpful error message when config permissions are incorrect for reading

Reported by: verm Owned by: jomae
Priority: normal Milestone: 0.12.3
Component: general Version: 0.12dev
Severity: normal Keywords: config permissions
Cc: verm@…, thijstriemstra, jomae
Release Notes:
API 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 jomae 3 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 4 years ago by Amar Takhar <verm@…>

  • Cc verm@… added

comment:2 Changed 4 years ago by rblank

Related to #7378.

comment:3 follow-ups: Changed 4 years ago by 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.

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.

comment:4 in reply to: ↑ 3 Changed 4 years ago by cboos

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 follow-up: Changed 4 years ago by verm

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'

comment:6 in reply to: ↑ 5 Changed 4 years ago by cboos

  • Milestone set to 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 Changed 4 years ago by verm

FreeBSD 9-CURRENT

comment:8 Changed 4 years ago by cboos

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

comment:9 Changed 4 years ago by rblank

#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 Changed 4 years ago by thijstriemstra

  • Cc thijstriemstra added

comment:11 Changed 4 years ago by rblank

#10192 was closed as a duplicate.

comment:12 Changed 3 years ago by duncang@…

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 follow-up: Changed 3 years ago by anonymous

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

comment:14 in reply to: ↑ 3 Changed 3 years ago by thijstriemstra

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..

comment:15 in reply to: ↑ 13 Changed 3 years ago by anonymous

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?

Changed 3 years ago by jomae

comment:16 Changed 3 years ago by jomae

  • Cc jomae 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 Changed 3 years ago by rblank

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 Changed 3 years ago by jomae

  • Milestone changed from 0.13 to 0.12.3
  • Resolution set to fixed
  • Status changed from new to closed

Thanks, Remy!

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

comment:19 Changed 3 years ago by jomae

  • Owner set to jomae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain jomae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from jomae 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.