Ran into a file permission problem whilst trying to setup Trac (0.12.3) on
a Linux box (Ubuntu Lucid 10.04) with TracGit plugin to run under uWSGI
(1.0.4), with the Git repo's managed by Gitolite. Gitolite runs under
git:git, uWSGI/Trac runs under trac:trac. The trac user is a member of the
git group, and I've verified that I can read the Git control-files as the
trac user (after a 'su - trac').

When running the Trac code under uWSGI, TracGit complains that it cannot
read the repo control files. Running the same code under tracd (in HTTP
mode), it works. I added some trace in PyGit.py, and found that when run
under uWSGI, the uid/gid is set correctly but the supplementary group list
is empty. I eventually found this was caused by the call in utils.c:577 to
setgroups(0, NULL), after the call to setgid().

After some Googling I found the correct solution is calling initgroups(3)
instead of calling setgroups(2) - see links below for details.

   - http://www.gnu.org/software/libc/manual/html_node/Setting-Groups.html
   - http://stackoverflow.com/questions/1489579/linux-id-no-squash-root
   - http://www.palecrow.com/chroot-jail-paper.html
   -
   http://code.google.com/p/modwsgi/source/browse/mod_wsgi/mod_wsgi.c#10197

Note: There are calls to setgroups() in both utils.c and emperor.c. I only
tested this in utils.c.

Testing was done on my Ubuntu 10.04 box, and results in the correct
supplementary groups being available (and TracGit works).

Regards,

Sigurd

diff -p:
*** utils.c 2012-02-13 18:26:37.000000000 +0100
--- ../utils.c 2012-03-06 17:09:05.222275998 +0100
*************** void uwsgi_as_root() {
*** 573,580 ****
  uwsgi_error("setgid()");
  exit(1);
  }
! if (setgroups(0, NULL)) {
! uwsgi_error("setgroups()");
  exit(1);
  }
  }
--- 573,580 ----
  uwsgi_error("setgid()");
  exit(1);
  }
! if (initgroups(uwsgi.uidname, uwsgi.gid)) {
! uwsgi_error("initgroups()");
  exit(1);
  }
  }
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to