steffen: server/perl-kolab/Kolab-Conf Conf.pm,1.8,1.9

cvs at intevation.de cvs at intevation.de
Wed May 19 15:58:47 CEST 2004


Author: steffen

Update of /kolabrepository/server/perl-kolab/Kolab-Conf
In directory doto:/tmp/cvs-serv1500/Kolab-Conf

Modified Files:
	Conf.pm 
Log Message:
ported permission and ownership code from KOLAB_1_0 branch

Index: Conf.pm
===================================================================
RCS file: /kolabrepository/server/perl-kolab/Kolab-Conf/Conf.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Conf.pm	18 May 2004 01:51:14 -0000	1.8
+++ Conf.pm	19 May 2004 13:58:45 -0000	1.9
@@ -56,16 +56,36 @@
 
 our $VERSION = '0.9';
 
+sub fixup {
+   my $file = shift;
+   my $ownership = shift;
+   my $perm = shift;
+
+   (my $owner, my $group) = split(/:/, $ownership, 2);
+   my $uid = (getpwnam($owner))[2];
+   my $gid = (getgrnam($group))[2];
+   if( chmod($perm, $file) != 1 ) {
+     Kolab::log('T', "Unable to change permissions of `$file' to $perm", KOLAB_ERROR);
+     exit(1);
+   }
+   if( chown($uid,$gid,$file) != 1 ) {
+     Kolab::log('T', "Unable to change ownership of `$file' to $uid:$gid", KOLAB_ERROR);
+     exit(1);
+   }
+}
+
 sub build {
     my $tmpl = shift;
     my $cfg = shift;
+    my $owner = shift;
+    my $perm = shift;
     my $oldcfg = $cfg . '.old';
     my $prefix = $Kolab::config{'prefix'};
 
     my $tmpfile = $prefix . '/etc/kolab/.tmp';
     copy($cfg, $oldcfg);
     chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
-    chmod(0600, $oldcfg) if ($oldcfg =~ /openldap/);
+    #chmod(0600, $oldcfg) if ($oldcfg =~ /openldap/);
 
     Kolab::log('T', "Creating new configuration file `$cfg' from template `$tmpl'");
 
@@ -75,7 +95,7 @@
         exit(1);
     }
     my $config;
-    if (!($config = IO::File->new($tmpfile, 'w+'))) {
+    if (!($config = IO::File->new($tmpfile, 'w+', 0600 ))) {
         Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
         exit(1);
     }
@@ -108,8 +128,9 @@
     $config->close;
 
     move($tmpfile, $cfg);
-    chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $cfg);
-    chmod(0600, $cfg) if ($cfg =~ /openldap/);
+    fixup( $cfg, $owner, $perm );
+    #chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $cfg);
+    #chmod(0600, $cfg) if ($cfg =~ /openldap/);
 
     if (-f $oldcfg) {
         my $rc = `diff -q $cfg $oldcfg`;
@@ -362,10 +383,48 @@
         "$prefix/etc/kolab/slapd.conf.template" => "$prefix/etc/openldap/slapd.conf"
     );
 
+    my %permissions = (
+      "$prefix/var/kolab/php/admin/include/session_vars.php" => 0640,
+      "$prefix/etc/postfix/main.cf"                          => 0640,
+      "$prefix/etc/postfix/master.cf"                        => 0640,
+      "$prefix/etc/clamav/clamav.conf"                       => 0640,
+      "$prefix/etc/clamav/freshclam.conf"                    => 0640,
+      "$prefix/etc/amavisd/amavisd.conf"                     => 0640,
+      "$prefix/etc/sasl/saslauthd.conf"                      => 0600,
+      "$prefix/etc/imapd/imapd.conf"                         => 0640,
+      "$prefix/etc/apache/apache.conf"                       => 0640,
+      "$prefix/etc/apache/legacy.conf"                       => 0640,
+      "$prefix/etc/apache/php.ini"                           => 0640,
+      "$prefix/etc/proftpd/proftpd.conf"                     => 0640,
+      "$prefix/etc/openldap/slapd.conf"                      => 0640,
+      "$prefix/etc/postfix/transport"                        => 0640,
+      "$prefix/etc/imapd/cyrus.conf"                         => 0640,
+      "$prefix/etc/imapd/imapd.group"                        => 0640);
+
+    my %ownership = (
+      "$prefix/var/kolab/php/admin/include/session_vars.php" => "kolab:kolab-n",
+      "$prefix/etc/postfix/main.cf"                          => "root:root",
+      "$prefix/etc/postfix/master.cf"                        => "root:root",
+      "$prefix/etc/clamav/clamav.conf"                       => "root:root",
+      "$prefix/etc/clamav/freshclam.conf"                    => "root:root",
+      "$prefix/etc/amavisd/amavisd.conf"                     => "root:root",
+      "$prefix/etc/sasl/saslauthd.conf"                      => "kolab:kolab",
+      "$prefix/etc/imapd/imapd.conf"                         => "kolab:kolab-r",
+      "$prefix/etc/apache/apache.conf"                       => "kolab:kolab-n",
+      "$prefix/etc/apache/legacy.conf"                       => "kolab:kolab-n",
+      "$prefix/etc/apache/php.ini"                           => "kolab:kolab-n",
+      "$prefix/etc/proftpd/proftpd.conf"                     => "kolab:kolab-n",
+      "$prefix/etc/openldap/slapd.conf"                      => "kolab:kolab",
+      "$prefix/etc/postfix/transport"                        => "root:root",
+      "$prefix/etc/imapd/cyrus.conf"                         => "kolab:kolab",
+      "$prefix/etc/imapd/imapd.group"                        => "kolab:kolab-r");
+
+
     Kolab::log('T', 'Regenerating configuration files');
 
     foreach $key (keys %templates) {
-        build($key, $templates{$key});
+      my $tpl = $templates{$key};
+      build($key, $tpl, $ownership{$tpl}, $permissions{$tpl} );
     }
 
     buildPostfixTransportMap;





More information about the commits mailing list