Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#9538 closed defect (fixed)

Trac-admin only recognises Environment when run using sudo

Reported by: hankaspank@… Owned by: Remy Blank
Priority: normal Milestone: 0.12.1
Component: admin/console Version: 0.12-stable
Severity: normal Keywords:
Cc: leho@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Remy Blank)

After upgrading to trac 0.12 and trying to use explicit synchronization I have realised that the trac-admin tool only works when run using sudo. This is an issue when trying to use explicit sync using svn hooks as the svn hook scripts are run as the apache user.

I have tried removing trac 0.12 installation files(trac-admin files and .egg) and reinstalling using easy_install but it hasn't made a difference.

Couldn't find a similar issue.

Example

andrew@li189-190:/etc/apache2/sites-available$ trac-admin /var/projects/trac/monkey/
Welcome to trac-admin 0.12
Interactive Trac administration console.
Copyright (c) 2003-2010 Edgewall Software

Type:  '?' or 'help' for help on commands.
        
Trac [/var/projects/trac/monkey]> ?
trac-admin - The Trac Administration Console 0.12
help     Show documentation
initenv  Create and initialize a new environment
Trac [/var/projects/trac/monkey]> exit

andrew@li189-190:/etc/apache2/sites-available$ sudo trac-admin /var/projects/trac/monkey/
Welcome to trac-admin 0.12
Interactive Trac administration console.
Copyright (c) 2003-2010 Edgewall Software

Type:  '?' or 'help' for help on commands.
        
Trac [/var/projects/trac/monkey]> ?
trac-admin - The Trac Administration Console 0.12
help                 Show documentation
initenv              Create and initialize a new environment
attachment add       Attach a file to a resource
attachment export    Export an attachment from a resource to a file or stdout
attachment list      List attachments of a resource
attachment remove    Remove an attachment from a resource
changeset added      Notify trac about changesets added to a repository
changeset modified   Notify trac about changesets modified in a repository
component add        Add a new component
component chown      Change component ownership
component list       Show available components
component remove     Remove/uninstall a component
component rename     Rename a component
config get           Get the value of the given option in "trac.ini"
config remove        Remove the specified option from "trac.ini"
config set           Set the value for the given option in "trac.ini"
deploy               Extract static resources from Trac and all plugins
hotcopy              Make a hot backup copy of an environment
milestone add        Add milestone
milestone completed  Set milestone complete date
milestone due        Set milestone due date
milestone list       Show milestones
milestone remove     Remove milestone
milestone rename     Rename milestone
permission add       Add a new permission rule
permission list      List permission rules

System Information

OS ubuntu 10.04LTS
Trac 	0.12
Genshi 	0.6
mod_python 	3.3.1
pysqlite 	2.4.1
Python 	2.6.5 (r265:79063, Apr 16 2010, 13:28:26) [GCC 4.4.3]
setuptools 	0.6
SQLite 	3.6.22
Subversion 	1.6.6 (r40053)
jQuery:	1.4.2

Installed Plugins

TracAccountManager 	0.2.1dev 	/usr/lib/pymodules/python2.6
TracDoxygen 	0.11.0.2 	/usr/local/lib/python2.6/dist-packages/TracDoxygen-0.11.0.2-py2.6.egg

Attachments (0)

Change History (12)

comment:1 by hankaspank@…, 12 years ago

Further example run as sudo

Trac [/var/projects/trac/monkey]> changeset added default 307
Trac [/var/projects/trac/monkey]> 

run as user

Trac [/var/projects/trac/stockmonkey]> changeset added default 307
Error: Command not found

comment:2 by Remy Blank, 12 years ago

Description: modified (diff)
Milestone: 0.12.1
Owner: set to Remy Blank

Of course, the user running trac-admin must have write permission to the whole environment. In the standard configuration (both SVN and Trac served via HTTP by Apache), this is usually the case, as the apache user has write access to both the SVN repository and the Trac environment. But if you access the repository e.g. through svn+ssh, you will have to set up sudo.

But in your case, you say that the apache user doesn't have write access to the Trac environment? I thought mod_python would run under the web server's user, isn't that the case?

This is pretty much an InstallationIssue, but we should add a note about su TracRepositoryAdmin. I'll do that.

comment:3 by hankaspank@…, 12 years ago

My users do have permissions write to the whole environment(checked that a few times too hehe) and so does the apache user.

Just noticing even though the trac-admin command using sudo doesn't return an error it doesn't update the timeline? Any links to how to re install trac keeping the wiki and tickets

in reply to:  3 comment:4 by Remy Blank, 12 years ago

Note about sudo added in TracRepositoryAdmin@9.

Replying to hankaspank@…:

Just noticing even though the trac-admin command using sudo doesn't return an error it doesn't update the timeline?

You should either use "(default)" for the default repository (with the quotes), or the absolute path to the repository:

trac-admin /path/to/env changeset added /path/to/repos 307

comment:5 by Remy Blank, 12 years ago

Resolution: fixed
Status: newclosed

comment:6 by hankaspank@…, 12 years ago

Found the problem. trac.db didn't have execute permissions. Adding execute permissions to it fixed the issue

comment:7 by ssomers@…, 12 years ago

In my case, the problem was the user executing trac-admin didn't have write permission on trac's log file (as was configured in the [logging] section of trac.ini)

comment:8 by lkraav <leho@…>, 11 years ago

Cc: leho@… added

just ran into this and spent an embarrasingly long time missing some random +w attribute on some random logfile. rblank basically says patchwelcome for trac telling you somehow (i.e. stderr) that it wants to write some file but can't, so i'm putting this on my list.

comment:9 by anonymous, 11 years ago

Same here - thanks for the note! I do not have root access to the server, so I temporarily stopped logging, ran the sync command, and enable logging..

comment:10 by mizraith, 11 years ago

Seems like a while since this has been touched (closed) , but I'm struggling with this similar issue on a svn/trac server (OS X 10.6.7).

In this case, I'm trying to run trac-admin $evn changeset added $repo $rev

When I run the command with sudo, it works fine. When I run the command as the nominal "_www" user (typical per svn post-commit hook), nothing happens. Returns normally, but nothing is done to the db.

I have checked, re-checked permissions, ownerships, write ability and tried the execute flag. Nothing seems to help. Scouring the web … nothing. Any thoughts?

comment:11 by Tobias Johansson <tobias.johansson@…>, 11 years ago

Same problem here.

All files in the environment have group set to 'dev' and they all have group read and write permissions. My user is in group 'dev' I get:

aa@arcdev:/var/trac$ trac-admin /var/trac/studio help
trac-admin - The Trac Administration Console 0.12

Usage: trac-admin </path/to/projenv> [command [subcommand] [option ...]]

Invoking trac-admin without command starts interactive mode.

help     Show documentation
initenv  Create and initialize a new environment
aa@arcdev:/var/trac$

If I run trac-admin with sudo everything works fine and it lists all commands etc.

If I give write permission to others on all files, trac-admin commands starts working without the need to sudo.

Am I missing something here?

comment:12 by Remy Blank, 11 years ago

Those are all permission issues. Make sure the user running trac-admin has write permission to all files and directories in the environment, and that the directories have execute permission.

We should find a way to report such errors more precisely, by indicating the file on which an operation failed.

Modify Ticket

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