Hi,

I've made some additions to cryus imapd (current imapd-2.1.13-20030609):

1. have the spec file built managesieve.pm, acap.pm and
    install it together with the sieveshell (good testing tool !)

2. my feeling is the perl "make install" calls should be made 
   later during the %install section, not within the %build section

3. I have made a groufile patch, that should let imapd look
first into $prefix/etc/imapd/imapd.group and then, if that doesn't
exist, into /etc/group. Note that the patch is optional via the switch 
with_groupfile_hack. I think we need a patch here and cannot
cope with subst etc.

The reason for the 3rd point is that IMHO it's a slight design 
break that cyrus imapd on the one hand doesn't require mail
users to exist locally - which is nice - on the other hand it supports
groups only on top of /etc/group, _if I'm right_.
I'll get into contact with the cyrus people about this.

See if you like the attached patch.

Regards, 

Tassilo

FYI, the kolab server uses the switches witch_vhost_hack and 
with_groupfile_hack. 
--- groupfile.patch.orig	2003-05-20 10:43:39.000000000 +0200
+++ groupfile.patch	2003-05-20 12:44:24.000000000 +0200
@@ -0,0 +1,92 @@
+--- lib/auth_unix.c	Thu Oct 10 16:38:26 2002
++++ lib/auth_unix.c	Thu Oct 10 17:48:04 2002
+@@ -48,6 +48,7 @@
+ #include <stdlib.h>
+ #include <pwd.h>
+ #include <grp.h>
++#include <stdio.h>
+ #include <ctype.h>
+ #include <string.h>
+ 
+@@ -143,6 +144,26 @@
+     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ 
++
++static struct group* fgetgrnam(const char* name)
++{
++    struct group *grp;
++    FILE *groupfile;
++
++    groupfile = fopen("/etc/imapd.group","r");
++    if (!groupfile) groupfile = fopen("/etc/group", "r");
++    if (groupfile) {
++       while ((grp = fgetgrent(groupfile))) {
++         if (strcmp(grp->gr_name, name) == 0) {
++           fclose(groupfile);
++           return grp;
++         }
++       }
++    } 
++    if (groupfile) fclose(groupfile);
++    return NULL;
++} 
++
+ /*
+  * Convert 'identifier' into canonical form.
+  * Returns a pointer to a static buffer containing the canonical form
+@@ -185,7 +206,7 @@
+      */
+     
+     if (!strncmp(retbuf, "group:", 6)) {
+-	grp = getgrnam(retbuf+6);
++	grp = fgetgrnam(retbuf+6);
+ 	if (!grp) return 0;
+ 	strcpy(retbuf+6, grp->gr_name);
+ 	return retbuf;
+@@ -228,6 +249,7 @@
+     struct passwd *pwd;
+     struct group *grp;
+     char **mem;
++    FILE *groupfile;
+ 
+     identifier = auth_canonifyid(identifier, 0);
+     if (!identifier) return 0;
+@@ -241,20 +263,23 @@
+     newstate->ngroups = 0;
+     newstate->group = (char **) 0;
+ 
+-    setgrent();
+-    while ((grp = getgrent())) {
+-	for (mem = grp->gr_mem; *mem; mem++) {
+-	    if (!strcmp(*mem, identifier)) break;
+-	}
+-
+-	if (*mem || (pwd && pwd->pw_gid == grp->gr_gid)) {
+-	    newstate->ngroups++;
+-	    newstate->group = (char **)xrealloc((char *)newstate->group,
+-						newstate->ngroups * sizeof(char *));
+-	    newstate->group[newstate->ngroups-1] = xstrdup(grp->gr_name);
+-	}
+-    }
+-    endgrent();
++    groupfile = fopen("/etc/imapd.group", "r");
++    if (!groupfile) groupfile = fopen("/etc/group","r");
++    if (groupfile) {
++       while ((grp = fgetgrent(groupfile))) {
++         for (mem = grp->gr_mem; *mem; mem++) {
++            if (!strcmp(*mem, identifier)) break;
++         }
++
++         if (*mem || (pwd && pwd->pw_gid == grp->gr_gid)) {
++            newstate->ngroups++;
++            newstate->group = (char **)xrealloc((char *)newstate->group,
++                                                newstate->ngroups * sizeof(char *));
++            newstate->group[newstate->ngroups-1] = xstrdup(grp->gr_name);
++         }
++       }
++       fclose(groupfile);
++    } 
+     return newstate;
+ }
+ 
--- imapd.spec.orig	2003-05-30 21:42:25.000000000 +0200
+++ imapd.spec	2003-06-06 18:04:24.000000000 +0200
@@ -37,6 +37,7 @@
 
 #   package options
 %option       with_vhost_hack  no
+%option       with_groupfile_hack no
 
 #   list of sources
 Source0:      ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-imapd-%{version}.tar.gz
@@ -46,6 +47,7 @@
 Source4:      fsl.imapd
 Patch0:       imapd.patch
 Patch1:       vhosthack.patch
+Patch2:       groupfile.patch
 
 #   build information
 Prefix:       %{l_prefix}
@@ -66,7 +68,9 @@
 
 %prep
     %setup -q -n cyrus-imapd-%{version}
-    %patch -p0
+%if "%{with_groupfile_hack}" == "yes"
+    %patch2 -p0
+%endif
     %{l_shtool} subst \
         -e 's;db-4.1;db;g' \
         configure
@@ -141,6 +145,13 @@
     #   redirect the hard-coded file paths
     %{l_shtool} subst -e "s;/etc/\(.*\).conf;%{l_prefix}/etc/imapd/\\1.conf;" \
         imap/*.c imap/*.h master/*.c master/*.h
+    %{l_shtool} subst -e "s;/etc/mail/cyrusmap\.db;%{l_prefix}/var/imapd/cyrusmap\.db;" \
+	imap/sendmail-map.c
+%if "%{with_groupfile_hack}" == "yes"
+    %{l_shtool} subst -e "s;/etc/imapd.group;%{l_prefix}/halole/etc/imapd/imapd.group;" \
+        lib/auth_unix.c	
+%endif
+
     %{l_make} %{l_mflags}
 
     #   build (and install) Perl-based administration stuff
@@ -149,8 +160,23 @@
       export SASL_INC="%{l_cppflags}"
       export SASL_LIB="%{l_ldflags} -lsasl2"
       export OPENSSL_INC="%{l_cppflags}"
-      export OPENSSL_LIB="%{l_ldflags} -lssl -lcrypto"
-      %{l_prefix}/bin/perl-openpkg install )
+      export OPENSSL_LIB="%{l_ldflags} -lssl -lcrypto" )
+   
+    ( cd perl/sieve && make )
+
+    %{l_prefix}/bin/perl-openpkg prolog
+    ( cd perl/sieve/managesieve
+      export SASL_INC="%{l_cppflags}"
+      export SASL_LIB="%{l_ldflags} -lsasl2"
+      export OPENSSL_INC="%{l_cppflags}"
+      export OPENSSL_LIB="%{l_ldflags} -lssl -lcrypto" )
+
+    %{l_prefix}/bin/perl-openpkg prolog
+    ( cd perl/sieve/acap
+      export SASL_INC="%{l_cppflags}"
+      export SASL_LIB="%{l_ldflags} -lsasl2"
+      export OPENSSL_INC="%{l_cppflags}"
+      export OPENSSL_LIB="%{l_ldflags} -lssl -lcrypto" ) 
 
 %install
 #   FIXME: clean up disabled due to 'perl-openpkg install'
@@ -165,6 +191,13 @@
         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl \
         $RPM_BUILD_ROOT%{l_prefix}/var/imapd/spool \
         $RPM_BUILD_ROOT%{l_prefix}/bin
+    %{l_shtool} install -c -m 755 \
+        perl/sieve/scripts/sieveshell.pl \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/sieveshell
+
+    ( cd perl/imap && %{l_prefix}/bin/perl-openpkg install )
+    ( cd perl/sieve/managesieve && %{l_prefix}/bin/perl-openpkg install )
+    ( cd perl/sieve/acap && %{l_prefix}/bin/perl-openpkg install )
 
     #   offer a sane configuration
 

Reply via email to