- updated the getgrouplist patch

- fixed a few undeclared functions (and int to pointer conversions)
This commit is contained in:
Tomas Janousek 2007-09-25 09:17:00 +00:00
parent f238fc76b8
commit 6a71b6b700
5 changed files with 451 additions and 87 deletions

View File

@ -1,84 +0,0 @@
diff -Naur cyrus-imapd-2.3.8.orig/configure.in cyrus-imapd-2.3.8/configure.in
--- cyrus-imapd-2.3.8.orig/configure.in Thu Nov 30 18:11:16 2006
+++ cyrus-imapd-2.3.8/configure.in Tue Jun 12 15:40:12 2007
@@ -119,7 +119,7 @@
AC_CHECK_HEADERS(unistd.h sys/select.h sys/param.h stdarg.h)
AC_REPLACE_FUNCS(memmove strcasecmp ftruncate strerror)
-AC_CHECK_FUNCS(strlcat strlcpy)
+AC_CHECK_FUNCS(strlcat strlcpy getgrouplist)
AC_HEADER_DIRENT
dnl do this before Berkeley DB/IPv6 detection
diff -Naur cyrus-imapd-2.3.8.orig/lib/auth_unix.c cyrus-imapd-2.3.8/lib/auth_unix.c
--- cyrus-imapd-2.3.8.orig/lib/auth_unix.c Thu Nov 30 18:11:22 2006
+++ cyrus-imapd-2.3.8/lib/auth_unix.c Tue Jun 12 15:42:22 2007
@@ -224,6 +224,12 @@
struct passwd *pwd;
struct group *grp;
char **mem;
+#ifdef HAVE_GETGROUPLIST
+ gid_t gid;
+ int ret, ngroups;
+ gid_t *groupids = 0;
+ int i;
+#endif
identifier = mycanonifyid(identifier, 0);
if (!identifier) return 0;
@@ -239,7 +245,45 @@
return newstate;
pwd = getpwnam(identifier);
-
+#ifdef HAVE_GETGROUPLIST
+ gid = pwd ? pwd->pw_gid : (gid_t) -1;
+
+ // get number of groups user is member of into newstate->ngroups
+ getgrouplist(identifier, gid, NULL, &(newstate->ngroups));
+ // get the actual group ids.
+ do {
+ if (groupids)
+ free(groupids);
+ groupids = (gid_t *)xmalloc(newstate->ngroups * sizeof(gid_t));
+
+ ngroups = newstate->ngroups;
+ ret = getgrouplist(identifier, gid, groupids, &(newstate->ngroups));
+ /*
+ * This is tricky. We do this as long as getgrouplist tells us to
+ * realloc _and_ the number of groups changes. It tells us to realloc
+ * also in the case of failure...
+ */
+ } while (ret != -1 && ngroups != newstate->ngroups);
+
+ if (ret == -1) {
+ newstate->ngroups = 0;
+ newstate->group = NULL;
+ goto err;
+ }
+
+ newstate->group = (char **)xmalloc(newstate->ngroups * sizeof(char *));
+ for (i = 0; i < newstate->ngroups; ++i ) {
+ struct group *group;
+
+ if (pwd || groupids[i] != gid) {
+ if ((group = getgrgid(groupids[i])))
+ newstate->group[i] = xstrdup(group->gr_name);
+ }
+ }
+
+err:
+ free( groupids );
+#else
setgrent();
while ((grp = getgrent())) {
for (mem = grp->gr_mem; *mem; mem++) {
@@ -254,6 +298,8 @@
}
}
endgrent();
+#endif
+
return newstate;
}

View File

@ -0,0 +1,81 @@
--- cyrus/lib/auth_unix.c 2007/02/13 16:42:49 1.41
+++ cyrus/lib/auth_unix.c 2007/09/17 14:36:40 1.45
@@ -41,7 +41,7 @@
*/
/*
- * $Id: auth_unix.c,v 1.41 2007/02/13 16:42:49 murch Exp $
+ * $Id: auth_unix.c,v 1.45 2007/09/17 14:36:40 murch Exp $
*/
#include <config.h>
@@ -224,6 +224,10 @@ static struct auth_state *mynewstate(con
struct passwd *pwd;
struct group *grp;
char **mem;
+#ifdef HAVE_GETGROUPLIST
+ gid_t gid, *groupids = NULL;
+ int ret, ngroups = 0;
+#endif
identifier = mycanonifyid(identifier, 0);
if (!identifier) return 0;
@@ -239,7 +243,48 @@ static struct auth_state *mynewstate(con
return newstate;
pwd = getpwnam(identifier);
-
+
+#ifdef HAVE_GETGROUPLIST
+ gid = pwd ? pwd->pw_gid : (gid_t) -1;
+
+ /* get number of groups user is member of into ngroups */
+ getgrouplist(identifier, gid, NULL, &ngroups);
+
+ /* get the actual group ids */
+ do {
+ groupids = (gid_t *)xrealloc((gid_t *)groupids,
+ ngroups * sizeof(gid_t));
+
+ newstate->ngroups = ngroups; /* copy of ngroups for comparision */
+ ret = getgrouplist(identifier, gid, groupids, &ngroups);
+ /*
+ * This is tricky. We do this as long as getgrouplist tells us to
+ * realloc _and_ the number of groups changes. It tells us to realloc
+ * also in the case of failure...
+ */
+ } while (ret != -1 && ngroups != newstate->ngroups);
+
+ if (ret == -1) {
+ newstate->ngroups = 0;
+ newstate->group = NULL;
+ goto err;
+ }
+
+ newstate->ngroups = 0;
+ newstate->group = (char **)xmalloc(ngroups * sizeof(char *));
+ while (ngroups--) {
+ if (pwd || groupids[ngroups] != gid) {
+ if ((grp = getgrgid(groupids[ngroups]))) {
+ newstate->ngroups++;
+ newstate->group[newstate->ngroups-1] = xstrdup(grp->gr_name);
+ }
+ }
+ }
+
+err:
+ if (groupids) free(groupids);
+
+#else /* !HAVE_GETGROUPLIST */
setgrent();
while ((grp = getgrent())) {
for (mem = grp->gr_mem; *mem; mem++) {
@@ -254,6 +299,8 @@ static struct auth_state *mynewstate(con
}
}
endgrent();
+#endif /* HAVE_GETGROUPLIST */
+
return newstate;
}

View File

@ -0,0 +1,282 @@
--- cyrus-imapd-2.3.9/imap/tls_prune.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/tls_prune.c 2007-09-18 15:48:46.000000000 +0200
@@ -49,6 +49,7 @@
#include "exitcodes.h"
#include "global.h"
+#include "util.h"
#include "tls.h"
#include "xmalloc.h"
--- cyrus-imapd-2.3.9/imap/sync_client.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/sync_client.c 2007-09-18 15:39:44.000000000 +0200
@@ -69,6 +69,8 @@
#include "mailbox.h"
#include "quota.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "acl.h"
#include "seen.h"
#include "mboxname.h"
--- cyrus-imapd-2.3.9/imap/protocol.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/protocol.c 2007-09-18 15:39:09.000000000 +0200
@@ -49,6 +49,8 @@
#include "protocol.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
static char *imap_parsemechlist(const char *str, struct protocol_t *prot)
{
--- cyrus-imapd-2.3.9/imap/ipurge.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/ipurge.c 2007-09-18 15:48:26.000000000 +0200
@@ -61,6 +61,7 @@
/* cyrus includes */
#include "global.h"
+#include "util.h"
#include "sysexits.h"
#include "exitcodes.h"
#include "imap_err.h"
--- cyrus-imapd-2.3.9/imap/cyrdump.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/cyrdump.c 2007-09-18 15:48:30.000000000 +0200
@@ -54,6 +54,7 @@
#include "assert.h"
#include "exitcodes.h"
#include "global.h"
+#include "util.h"
#include "imapd.h"
#include "imap_err.h"
#include "imapurl.h"
--- cyrus-imapd-2.3.9/imap/fetchnews.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/fetchnews.c 2007-09-18 15:48:50.000000000 +0200
@@ -60,10 +60,13 @@
#include "cyrusdb.h"
#include "exitcodes.h"
#include "global.h"
+#include "util.h"
#include "gmtoff.h"
#include "lock.h"
#include "prot.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
/* global state */
const int config_need_data = 0;
--- cyrus-imapd-2.3.9/imap/sync_server.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/sync_server.c 2007-09-18 15:40:02.000000000 +0200
@@ -94,6 +94,8 @@
#include "util.h"
#include "version.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "sync_support.h"
#include "sync_commit.h"
--- cyrus-imapd-2.3.9/imap/ctl_mboxlist.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/ctl_mboxlist.c 2007-09-18 15:48:35.000000000 +0200
@@ -77,6 +77,7 @@
#include "exitcodes.h"
#include "imap_err.h"
#include "global.h"
+#include "util.h"
#include "libcyr_cfg.h"
#include "mboxlist.h"
#include "mupdate.h"
--- cyrus-imapd-2.3.9/imap/sync_support.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/sync_support.c 2007-09-18 15:39:55.000000000 +0200
@@ -71,6 +71,8 @@
#include "mailbox.h"
#include "quota.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "acl.h"
#include "seen.h"
#include "mboxname.h"
--- cyrus-imapd-2.3.9/imap/squatter.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/squatter.c 2007-09-18 15:48:39.000000000 +0200
@@ -84,6 +84,7 @@
#include "assert.h"
#include "mboxlist.h"
#include "global.h"
+#include "util.h"
#include "exitcodes.h"
#include "imap_err.h"
#include "mailbox.h"
--- cyrus-imapd-2.3.9/imap/autosieve.c.implicitdecl 2007-09-18 15:42:01.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/autosieve.c 2007-09-18 15:39:14.000000000 +0200
@@ -19,6 +19,9 @@
#include "global.h"
#include "util.h"
+#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "mailbox.h"
#include "imap_err.h"
#include "sieve_interface.h"
--- cyrus-imapd-2.3.9/imap/arbitron.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/arbitron.c 2007-09-18 15:48:43.000000000 +0200
@@ -59,6 +59,7 @@
#include "assert.h"
#include "global.h"
+#include "util.h"
#include "exitcodes.h"
#include "hash.h"
#include "imap_err.h"
--- cyrus-imapd-2.3.9/imap/mupdate.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/mupdate.c 2007-09-18 15:39:34.000000000 +0200
@@ -87,6 +87,8 @@
#include "util.h"
#include "version.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
/* Sent to clients that we can't accept a connection for. */
static const char SERVER_UNABLE_STRING[] = "* BYE \"Server Unable\"\r\n";
--- cyrus-imapd-2.3.9/imap/make_md5.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/make_md5.c 2007-09-18 15:48:54.000000000 +0200
@@ -16,6 +16,7 @@
#include <signal.h>
#include "global.h"
+#include "util.h"
#include "assert.h"
#include "mboxlist.h"
#include "exitcodes.h"
--- cyrus-imapd-2.3.9/imap/sync_commit.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/sync_commit.c 2007-09-18 15:40:08.000000000 +0200
@@ -69,6 +69,8 @@
#include "mailbox.h"
#include "quota.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "acl.h"
#include "seen.h"
#include "mboxname.h"
--- cyrus-imapd-2.3.9/imap/compile_sieve.c.implicitdecl 2007-09-18 15:27:37.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/compile_sieve.c 2007-09-18 15:27:48.000000000 +0200
@@ -20,6 +20,7 @@
#include "global.h"
#include "util.h"
+#include "xmalloc.h"
#include "mailbox.h"
#include "imap_err.h"
#include "sieve_interface.h"
--- cyrus-imapd-2.3.9/timsieved/timsieved.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/timsieved/timsieved.c 2007-09-18 15:40:35.000000000 +0200
@@ -73,6 +73,8 @@
#include "prot.h"
#include "libconfig.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "exitcodes.h"
#include "iptostring.h"
#include "global.h"
--- cyrus-imapd-2.3.9/timsieved/actions.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/timsieved/actions.c 2007-09-18 15:40:25.000000000 +0200
@@ -69,6 +69,8 @@
#include "global.h"
#include "libconfig.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "sieve_interface.h"
#include "codes.h"
--- cyrus-imapd-2.3.9/timsieved/parser.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/timsieved/parser.c 2007-09-18 15:40:41.000000000 +0200
@@ -64,6 +64,8 @@
#include "mboxname.h"
#include "mboxlist.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "prot.h"
#include "tls.h"
#include "lex.h"
--- cyrus-imapd-2.3.9/master/cyrusMasterMIB.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/master/cyrusMasterMIB.c 2007-09-18 15:39:06.000000000 +0200
@@ -52,6 +52,8 @@
#include "master.h"
#include "../imap/version.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
/*
* cyrusMasterMIB_variables_oid:
--- cyrus-imapd-2.3.9/sieve/interp.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/sieve/interp.c 2007-09-18 15:38:40.000000000 +0200
@@ -33,6 +33,8 @@
#include <string.h>
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#include "sieve_interface.h"
#include "interp.h"
--- cyrus-imapd-2.3.9/sieve/addr.y.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/sieve/addr.y 2007-09-18 15:38:45.000000000 +0200
@@ -37,6 +37,8 @@
#include "addr.h"
#include "script.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
int yyerror(char *msg);
extern int yylex(void);
--- cyrus-imapd-2.3.9/imtest/imtest.c.implicitdecl 2007-09-18 15:36:52.000000000 +0200
+++ cyrus-imapd-2.3.9/imtest/imtest.c 2007-09-18 15:40:14.000000000 +0200
@@ -82,6 +82,8 @@
#include "imparse.h"
#include "iptostring.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
#ifdef HAVE_SSL
#include <openssl/ssl.h>
--- cyrus-imapd-2.3.9/ptclient/ptexpire.c.implicitdecl 2007-09-18 15:47:55.000000000 +0200
+++ cyrus-imapd-2.3.9/ptclient/ptexpire.c 2007-09-18 15:48:57.000000000 +0200
@@ -65,6 +65,7 @@
#include "cyrusdb.h"
#include "exitcodes.h"
#include "global.h"
+#include "util.h"
#include "libconfig.h"
#include "lock.h"
#include "xmalloc.h"
--- cyrus-imapd-2.3.9/ptclient/ldap.c.implicitdecl 2007-09-18 15:49:48.000000000 +0200
+++ cyrus-imapd-2.3.9/ptclient/ldap.c 2007-09-18 15:40:19.000000000 +0200
@@ -61,6 +61,9 @@
#include <sys/un.h>
#include <sys/uio.h>
+/* Functions like ldap_bind() have been deprecated in OpenLDAP 2.3 */
+#define LDAP_DEPRECATED 1
+
#include <ldap.h>
#include <lber.h>
@@ -74,6 +77,8 @@
#include "auth_pts.h"
#include "strhash.h"
#include "xmalloc.h"
+#include "xstrlcpy.h"
+#include "xstrlcat.h"
/* xxx this just uses the UNIX canonicalization semantics, which is
* most likely wrong */

View File

@ -0,0 +1,76 @@
--- cyrus-imapd-2.3.9/imap/compile_sieve.c.myfatal 2007-09-23 16:13:29.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/compile_sieve.c 2007-09-23 16:54:54.000000000 +0200
@@ -37,7 +37,7 @@
static int is_script_parsable(FILE *stream, char **errstr, sieve_script_t **ret);
-static void fatal(const char *s, int code)
+static void my_fatal(const char *s, int code)
{
printf("Fatal error: %s (%d)\r\n", s, code);
@@ -68,7 +68,7 @@
extern char *optarg;
char sieve_tmpname[MAX_MAILBOX_NAME+1];
- if (geteuid() == 0) fatal("must run as the Cyrus user", EC_USAGE);
+ if (geteuid() == 0) my_fatal("must run as the Cyrus user", EC_USAGE);
while((opt = getopt(argc, argv, "C:i:o:")) != EOF) {
switch (opt) {
@@ -218,7 +218,7 @@
/* to make larry's stupid functions happy :) */
static void foo(void)
{
- fatal("stub function called", 0);
+ my_fatal("stub function called", 0);
}
extern sieve_vacation_t vacation2;/* = {
@@ -234,7 +234,7 @@
void *message_context __attribute__((unused)),
const char **errmsg __attribute__((unused)))
{
- fatal("stub function called", 0);
+ my_fatal("stub function called", 0);
return SIEVE_FAIL;
}
--- cyrus-imapd-2.3.9/imap/autosieve.c.myfatal 2007-09-23 16:13:29.000000000 +0200
+++ cyrus-imapd-2.3.9/imap/autosieve.c 2007-09-23 16:37:27.000000000 +0200
@@ -35,7 +35,7 @@
static int get_script_dir(char *sieve_script_dir, size_t buflen, char *userid, const char *sieve_dir);
int autoadd_sieve(char *userid, const char *source_script);
-static void fatal(const char *s, int code);
+static void my_fatal(const char *s, int code);
static void foo(void);
static int sieve_notify(void *ac __attribute__((unused)),
void *interp_context __attribute__((unused)),
@@ -441,7 +441,7 @@
return 0;
}
-static void fatal(const char *s, int code)
+static void my_fatal(const char *s, int code)
{
printf("Fatal error: %s (%d)\r\n", s, code);
exit(1);
@@ -450,7 +450,7 @@
/* to make larry's stupid functions happy :) */
static void foo(void)
{
- fatal("stub function called", 0);
+ my_fatal("stub function called", 0);
}
static int sieve_notify(void *ac __attribute__((unused)),
@@ -459,7 +459,7 @@
void *message_context __attribute__((unused)),
const char **errmsg __attribute__((unused)))
{
- fatal("stub function called", 0);
+ my_fatal("stub function called", 0);
return SIEVE_FAIL;
}

View File

@ -1,7 +1,7 @@
%define upstream_ver 2.3.9
Name: cyrus-imapd
Version: 2.3.9
Release: 6%{?dist}
Release: 7%{?dist}
# ********************** BUILD TIME OPTIONS START **********************
@ -147,11 +147,13 @@ Patch15: cyrus-imapd-2.3.1-make_md5_defaults.patch
Patch16: cyrus-imapd-2.3.7-db4.5.patch
Patch17: cyrus-imapd-2.3.7-makeinstallfix.patch
Patch18: cyrus-imapd-2.3.7-krb4.patch
Patch20: cyrus-imapd-2.3.8-getgrouplist.patch
Patch19: cyrus-imapd-2.3.9-implicitdecl.patch
Patch20: cyrus-imapd-2.3.9-myfatal.patch
# Patches >= 100 are / will be fixed in CVS
Patch100: cyrus-imapd-2.3.1-make_md5.patch
Patch101: cyrus-imapd-2.3.1-backend_sigsegv.patch
Patch102: cyrus-imapd-2.3.1-replication_policycheck.patch
Patch103: cyrus-imapd-2.3.9-getgrouplist.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: autoconf >= 2.59
BuildRequires: cyrus-sasl-devel >= 2.1.15-1, perl, perl-devel, tcp_wrappers
@ -256,7 +258,9 @@ one running the server.
#%patch16 -p1 -b .db4.5
#%patch17 -p1 -b .makeinstallfix
%patch18 -p1 -b .krb4
%patch20 -p1 -b .getgrouplist
%patch19 -p1 -b .implicitdecl
%patch20 -p1 -b .myfatal
%patch103 -p1 -b .getgrouplist
# fixed upstream
#%patch100 -p1 -b .make_md5
# fixed upstream
@ -272,6 +276,7 @@ autoheader
autoconf -f
%build
#export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Werror-implicit-function-declaration"
CPPFLAGS="-I%{_includedir}/et"; export CPPFLAGS
CFLAGS="$RPM_OPT_FLAGS -fPIC"; export CFLAGS
if pkg-config openssl; then
@ -798,6 +803,10 @@ fi
%{_mandir}/man1/*
%changelog
* Sun Sep 23 2007 Tomas Janousek <tjanouse@redhat.com> - 2.3.9-7
- updated the getgrouplist patch
- fixed a few undeclared functions (and int to pointer conversions)
* Wed Aug 22 2007 Tomas Janousek <tjanouse@redhat.com> - 2.3.9-6
- update to latest upstream
- updated all patches from uoa and reenabled rmquota+deletemailbox