* Add wrappergroup config option, which can be used to cause wrappers
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 14 Nov 2007 14:27:11 +0000 (09:27 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 14 Nov 2007 14:27:11 +0000 (09:27 -0500)
  to be created owned by some group other than the default. Useful
  then there's a shared repository with access controlled by a group,
  to let ikiwiki run setgid to that group.
* ikiwiki-mass-rebuild: Run build with the user in all their groups.

IkiWiki/Wrapper.pm
debian/changelog
doc/usage.mdwn
ikiwiki-mass-rebuild
po/ikiwiki.pot

index 558cdb1cca8c53415358b572664b9a0cca8dad1d..6687cace221afc7cca17c35d99a85c3557fd9223 100644 (file)
@@ -102,14 +102,26 @@ $envsave
 }
 EOF
        close OUT;
-       if (system("gcc", "$wrapper.c", "-o", $wrapper) != 0) {
+       if (system("gcc", "$wrapper.c", "-o", "$wrapper.new") != 0) {
                #translators: The parameter is a C filename.
                error(sprintf(gettext("failed to compile %s"), "$wrapper.c"));
        }
        unlink("$wrapper.c");
+       if (defined $config{wrappergroup}) {
+               my $gid=(getgrnam($config{wrappergroup}))[2];
+               if (! defined $gid) {
+                       error(sprintf("bad wrappergroup"));
+               }
+               if (! chown(-1, $gid, "$wrapper.new")) {
+                       error("chown $wrapper.new: $!");
+               }
+       }
        if (defined $config{wrappermode} &&
-           ! chmod(oct($config{wrappermode}), $wrapper)) {
-               error("chmod $wrapper: $!");
+           ! chmod(oct($config{wrappermode}), "$wrapper.new")) {
+               error("chmod $wrapper.new: $!");
+       }
+       if (! rename("$wrapper.new", $wrapper)) {
+               error("rename $wrapper.new $wrapper: $!");
        }
        #translators: The parameter is a filename.
        printf(gettext("successfully generated %s"), $wrapper);
index 749db67e0f31839456dfe6881aaf6ea41c4b9ed5..3de7ea785ef1891c5466f4502852a8c62c1bf2e0 100644 (file)
@@ -5,8 +5,13 @@ ikiwiki (2.13) UNRELEASED; urgency=low
   * ikiwiki.setup is licensed same as the basewiki, not GPLed.
   * inline: Add timeformat parameter to control how the ctime of
     inlined pages is displayed. Closes: #451019
+  * Add wrappergroup config option, which can be used to cause wrappers
+    to be created owned by some group other than the default. Useful
+    then there's a shared repository with access controlled by a group,
+    to let ikiwiki run setgid to that group.
+  * ikiwiki-mass-rebuild: Run build with the user in all their groups.
 
- -- Joey Hess <joeyh@debian.org>  Tue, 13 Nov 2007 16:11:54 -0500
+ -- Joey Hess <joeyh@debian.org>  Wed, 14 Nov 2007 08:37:03 -0500
 
 ikiwiki (2.12) unstable; urgency=low
 
index 4fb91b89b4a826440b08ede51cc953449a543fce..af3634e13b0aa3a8b02d62494e2614c1d5cb373e 100644 (file)
@@ -125,6 +125,14 @@ configuration options of their own.
 
   Specify a mode to chmod the wrapper to after creating it.
 
+* --wrappergroup group
+
+  Specify what unix group the wrapper should be owned by. This can be
+  useful if the wrapper needs to be owned by a group other than the default.
+  For example, if a project has a repository with multiple committers with
+  access controlled by a group, it makes sense for the ikiwiki wrappers
+  to run setgid to that group.
+
 * --notify, --no-notify
 
   Enable email notification of commits. This should be used when running
index 1ec90b3c0d34e05dd6092e542523e0bf6d81646a..710db4eacffc22baa6e68f7dcf6a9a230b1d8907 100755 (executable)
@@ -2,6 +2,19 @@
 use warnings;
 use strict;
 
+sub supplemental_groups {
+       my $user=shift;
+
+       my @list;
+       while (my @fields=getgrent()) {
+               if (grep { $_ eq $user } split(' ', $fields[3])) {
+                       push @list, $fields[2];
+               }
+       }
+
+       return @list;
+}
+
 sub processline {
        my $user=shift;
        my $setup=shift;
@@ -20,11 +33,15 @@ sub processline {
        defined(my $pid = fork) or die "Can’t fork: $!";
        if (! $pid) {
                my ($uuid, $ugid) = (getpwnam($user))[2, 3];
-               $)="$ugid $ugid";
+               my $grouplist=join(" ", $ugid, $ugid, supplemental_groups($user));
+               $)=$grouplist;
+               if ($!) {
+                       die "failed to set egid $grouplist";
+               }
                $(=$ugid;
                $<=$uuid;
                $>=$uuid;
-               if ($< != $uuid || $> != $uuid || $( != $ugid || $) ne "$ugid $ugid") {
+               if ($< != $uuid || $> != $uuid || $( != $ugid) {
                        die "failed to drop permissions to $user";
                }
                %ENV=(
index 3448cda199c5e67eafdbb16920ecceefbb046bcf..c20db1ac41bc08508faf7eaac073849336a5caf1 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-13 16:14-0500\n"
+"POT-Creation-Date: 2007-11-14 09:23-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -589,7 +589,7 @@ msgid "failed to compile %s"
 msgstr ""
 
 #. translators: The parameter is a filename.
-#: ../IkiWiki/Wrapper.pm:115
+#: ../IkiWiki/Wrapper.pm:127
 #, perl-format
 msgid "successfully generated %s"
 msgstr ""