mod_python generates a message "user root needs read _and_ write access ..."

1 view
Skip to first unread message

Jackson

unread,
Nov 17, 2006, 6:58:22 PM11/17/06
to Trac Users
I was given a machine runnig SuSE Enterprise Linux 10 and told to set
up Trac and Subversion accessed via Apache. So, I have tried to do
that. Now, I am trying to configure auhorization. When I try to access
the Trac environment, I get the above message.
Apache is running as 'root' (bad idea, I know ...). So this makes no
sense. I solved the problem by "chmod -R 777 /var/trac", which seems
rather drastic. Information suggests the error is caused by SE Linux,
but this installation has SE Linux disabled. I suspect I need to
disable something in the Apache build configuration, but I do not know
what. Any help?

solo turn

unread,
Nov 18, 2006, 9:20:03 AM11/18/06
to trac-...@googlegroups.com
i'd go for a "chown -R <your-apache-user> /var/trac.

Matt Good

unread,
Nov 18, 2006, 8:24:23 PM11/18/06
to Trac Users
Jackson wrote:
> I was given a machine runnig SuSE Enterprise Linux 10 and told to set
> up Trac and Subversion accessed via Apache. So, I have tried to do
> that. Now, I am trying to configure auhorization. When I try to access
> the Trac environment, I get the above message.
> Apache is running as 'root' (bad idea, I know ...). So this makes no
> sense. I solved the problem by "chmod -R 777 /var/trac", which seems
> rather drastic.

If that chmod worked, it suggests that Apache may not really be running
as root. I've seen that before where the username reported in the
error message is "root" although Apache is not really running as root.
When they drop permissions the $USER environment variable may still be
set to "root" which is being picked up by Trac in that message.

Set your permissions back to something sane:
chmod -R 644 /var/trac
find /var/trac -type d | xargs chmod 755

Then apply this patch which I think should give you the right username
in that error message:

Index: trac/db/sqlite_backend.py
===================================================================
--- trac/db/sqlite_backend.py (revision 4297)
+++ trac/db/sqlite_backend.py (working copy)
@@ -146,11 +146,12 @@
dbdir = os.path.dirname(path)
if not os.access(path, os.R_OK + os.W_OK) or \
not os.access(dbdir, os.R_OK + os.W_OK):
- from getpass import getuser
+ import pwd
+ username = pwd.getpwuid(os.getuid())[0]
raise TracError('The user %s requires read _and_ write
' \
'permission to the database file %s
and the ' \
'directory it is located in.' \
- % (getuser(), path))
+ % (username, path))

if have_pysqlite == 2:
self._active_cursors = weakref.WeakKeyDictionary()


If that works I'll update Trac to use the "pwd" module instead of
"getpass" when possible (it's not available on Windows). Then you
should be able to just make sure the Apache user owns the files in the
Trac projects:

chown -R www-data /var/trac

Replacing www-data with the right user name.

-- Matt Good

stoKes

unread,
Jan 11, 2007, 4:12:31 PM1/11/07
to Trac Users

I tried your patch, however, still receiving error :

[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch\n result = object(req)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", line
87, in handler\n gateway.run(dispatch_request)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/web/wsgi.py", line 87, in run\n
response = application(self.environ, self._start_response)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/web/main.py", line 377, in
dispatch_request\n env = _open_environment(env_path,
run_once=run_once)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/web/main.py", line 58, in
_open_environment\n env_cache[env_path] = open_environment(env_path)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/env.py", line 435, in
open_environment\n if env.needs_upgrade():
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/env.py", line 313, in
needs_upgrade\n db = self.get_db_cnx()
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/env.py", line 182, in
get_db_cnx\n return DatabaseManager(self).get_connection()
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/db/api.py", line 75, in
get_connection\n return self._cnx_pool.get_cnx(self.timeout or None)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/db/pool.py", line 101, in
get_cnx\n cnx = self._connector.get_connection(**self._kwargs)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 113,
in get_connection\n return SQLiteConnection(path, params)
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: File
"/usr/lib/python2.3/site-packages/trac/db/sqlite_backend.py", line 150,
in __init__\n raise TracError('The user %s requires read _and_ write
' \\
[Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
trac.web.modpython_frontend: TracError: The user apache requires read


_and_ write permission to the database file

/opt/trac/gsstoolbox/db/trac.db and the directory it is located in.


However, the perms are :
ll /opt/trac/gsstoolbox/db/trac.db
-rw-rw-r-- 1 apache apache 445440 Jan 11 16:58
/opt/trac/gsstoolbox/db/trac.db

So not sure what other workarounds to try at this point

Thanks
adam

Noah Kantrowitz

unread,
Jan 12, 2007, 12:49:09 AM1/12/07
to trac-...@googlegroups.com
stoKes wrote:
[snip]

> [Thu Jan 11 17:12:00 2007] [error] [client 172.16.59.147] PythonHandler
> trac.web.modpython_frontend: TracError: The user apache requires read
> _and_ write permission to the database file
> /opt/trac/gsstoolbox/db/trac.db and the directory it is located in.
>
>
> However, the perms are :
> ll /opt/trac/gsstoolbox/db/trac.db
> -rw-rw-r-- 1 apache apache 445440 Jan 11 16:58
> /opt/trac/gsstoolbox/db/trac.db

What about "ll /opt/trac/gsstoolbox" and look at the db folder?

--Noah

Reply all
Reply to author
Forward
0 new messages