Hi,

this patch enables/disables PCRE_DUPNAMES depending on the version of
libprce found at compile time and should solve
https://fedorahosted.org/sssd/ticket/61 . For me is works on SLES10. It
would be nice if someone can confirm that it works on RHEL5 or other
plattforms with libpcre < 7.

bye,
Sumit
>From 3f1b401d673e800b39e8486b4a54faaa3aff0345 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sb...@redhat.com>
Date: Mon, 31 Aug 2009 20:30:46 +0200
Subject: [PATCH] check if libpcre version is above or below 7

PCRE_DUPNAMES is a new feature of libpcre 7. It is used in sssd to
make the splitting of fully qualified user names more flexible.
---
 server/external/libpcre.m4 |    8 +++++++-
 server/man/sssd.conf.5.xml |    7 +++++++
 server/util/usertools.c    |   14 +++++++++++++-
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/server/external/libpcre.m4 b/server/external/libpcre.m4
index bda7a6b..5917c8c 100644
--- a/server/external/libpcre.m4
+++ b/server/external/libpcre.m4
@@ -3,7 +3,13 @@ AC_SUBST(PCRE_OBJ)
 AC_SUBST(PCRE_LIBS)
 AC_SUBST(PCRE_CFLAGS)
 
-PKG_CHECK_MODULES(PCRE, libpcre >= 7)
+PKG_CHECK_MODULES(PCRE, libpcre)
+PKG_CHECK_EXISTS(libpcre >= 7,
+                 [AC_MSG_NOTICE([PCRE version is 7 or higher])],
+                 [AC_MSG_NOTICE([PCRE version is below 7])
+                  AC_DEFINE([HAVE_LIBPCRE_LESSER_THAN_7],
+                            1,
+                            [Define if libpcre version is less than 7])])
 
 AC_CHECK_HEADERS(pcre.h)
 AC_CHECK_LIB(pcre, pcre_compile, [ PCRE_LIBS="-lpcre" ], [AC_MSG_ERROR([PCRE 
is required])])
diff --git a/server/man/sssd.conf.5.xml b/server/man/sssd.conf.5.xml
index 6c6a310..f4cb87a 100644
--- a/server/man/sssd.conf.5.xml
+++ b/server/man/sssd.conf.5.xml
@@ -137,6 +137,13 @@
                             which translates to "the name is everything up to 
the
                             <quote>@</quote> sign, the domain everything after 
that"
                         </para>
+                        <para>
+                            PLEASE NOTE: the support for non-unique named
+                            subpatterns is not available on all plattforms
+                            (e.g. RHEL5 and SLES10). Only plattforms with
+                            libpcre version 7 or higher can support non-unique
+                            named subpatterns.
+                        </para>
                     </listitem>
                 </varlistentry>
                 <varlistentry>
diff --git a/server/util/usertools.c b/server/util/usertools.c
index 220b52c..2134839 100644
--- a/server/util/usertools.c
+++ b/server/util/usertools.c
@@ -29,6 +29,12 @@
 
 #define NAMES_CONFIG "config/names"
 
+#ifdef HAVE_LIBPCRE_LESSER_THAN_7
+#define NAME_DOMAIN_PATTERN_OPTIONS (PCRE_EXTENDED)
+#else
+#define NAME_DOMAIN_PATTERN_OPTIONS (PCRE_DUPNAMES | PCRE_EXTENDED)
+#endif
+
 char *get_username_from_uid(TALLOC_CTX *mem_ctx, uid_t uid)
 {
     char *username;
@@ -63,6 +69,12 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx 
*cdb, struct sss_names
             ret = ENOMEM;
             goto done;
         }
+#ifdef HAVE_LIBPCRE_LESSER_THAN_7
+        DEBUG(2, ("This binary was build with a version of libpcre that does "
+                  "not support non-unique named subpatterns.\n"));
+        DEBUG(2, ("Please make sure that your pattern [%s] only contains "
+                  "subpatterns with a unique name.\n", ctx->re_pattern));
+#endif
     }
 
     ret = confdb_get_string(cdb, ctx, NAMES_CONFIG,
@@ -78,7 +90,7 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx 
*cdb, struct sss_names
     }
 
     ctx->re = pcre_compile2(ctx->re_pattern,
-                            PCRE_DUPNAMES | PCRE_EXTENDED,
+                            NAME_DOMAIN_PATTERN_OPTIONS,
                             &errval, &errstr, &errpos, NULL);
     if (!ctx->re) {
         DEBUG(1, ("Invalid Regular Expression pattern at position %d."
-- 
1.6.2.5

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to