On Sun, May 22, 2011 at 05:21:23PM -0400, Stephen Gallagher wrote: > > > On May 22, 2011, at 12:37 PM, Jakub Hrozek <jhro...@redhat.com> wrote: > > > On 05/20/2011 09:44 AM, Sumit Bose wrote: > >> On Fri, May 20, 2011 at 09:34:06AM +0200, Jakub Hrozek wrote: > >>> On 05/19/2011 05:12 PM, Sumit Bose wrote: > >>>> Hi, > >>>> > >>>> there are a couple of places where we set _GNU_SOURCE in the source > >>>> files to enable glibc specific extensions. If by chance > >>>> '-D_GNU_SOURCE=1' is set on the gcc command line, e.g. by using the > >>>> CFLAGS from a pkg-config output (yes, there are examples :-), we get > >>>> '"_GNU_SOURCE" redefined' message during compilation. With the attached > >>>> patch _GNU_SOURCE is only defined in the sources if not already set. > >>>> > >>>> An alternative fix would be to remove all defines of _GNU_SOURCE from > >>>> the source code and add AC_USE_SYSTEM_EXTENSIONS/AC_GNU_SOURCE to > >>>> configure.ac . I'm not sure if there is a recommended way how to handle > >>>> _GNU_SOURCE and friends. > >>>> > >>>> bye, > >>>> Sumit > >>>> > >>>> > >>> > >>> This patch works fine. > >>> > >>> I think I would prefer to use something like > >>> AC_USE_SYSTEM_EXTENSIONS/AC_GNU_SOURCE simply because it would rule out > >>> the possibility of forgetting to ifdef _GNU_SOURCE. > >>> > >>> But the problem seems to be that AC_GNU_SOURCE is obsolete in newer > >>> versions of autoconf (and also throws an error on F14). At the same > >>> time, AC_USE_SYSTEM_EXTENSIONS requires autoconf>= 2.60 while RHEL5 is > >>> still on 2.59 > >>> > >> > >> To solve this I have found the following: > >> > >> m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], > >> [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], > >> [AC_REQUIRE([AC_GNU_SOURCE])]) > >> > >> Shall I prepare a patch with this in configure.ac? > >> > > > > To me this seems like a more systematic solution. So unless anyone > > objects, I vote for this little autoconf trickery. > > > > I concur
ok, this new version set _GNU_SOURCE safely in config.h. I had to add or move some #include "config.h" and came across a 'shadows global' warning I hadn't see before. Additionally I added a patch to remove some AC_DEFUN from configure.ac which were not used anywhere in our code. bye, Sumit
From df84d23467f30f09ef725fce23bf9b3fa4fb0eec Mon Sep 17 00:00:00 2001 From: Sumit Bose <sb...@redhat.com> Date: Thu, 19 May 2011 09:58:09 +0200 Subject: [PATCH 1/2] Set _GNU_SOURCE globally --- configure.ac | 4 ++++ src/confdb/confdb.c | 3 +-- src/external/platform.m4 | 3 +-- src/krb5_plugin/sssd_krb5_locator_plugin.c | 4 +++- src/monitor/monitor.c | 1 - src/responder/common/responder_common.c | 4 +--- src/sss_client/common.c | 4 +--- src/sss_client/pam_sss.c | 4 ---- src/tools/selinux.c | 1 - src/util/crypto/libcrypto/crypto_sha512crypt.c | 1 - src/util/crypto/nss/nss_obfuscate.c | 4 ++-- src/util/crypto/nss/nss_sha512crypt.c | 3 ++- src/util/debug.c | 3 ++- src/util/server.c | 1 - 14 files changed, 17 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index b96c42a..a31f97d 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,10 @@ AC_INIT([sssd], VERSION_NUMBER, [sssd-devel@lists.fedorahosted.org]) +m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], + [AC_USE_SYSTEM_EXTENSIONS], + [AC_GNU_SOURCE]) + CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE" AC_CONFIG_SRCDIR([BUILD.txt]) diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c index 87d33f9..3f668dd 100644 --- a/src/confdb/confdb.c +++ b/src/confdb/confdb.c @@ -19,10 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define _GNU_SOURCE +#include "config.h" #include <ctype.h> -#include "config.h" #include "util/util.h" #include "confdb/confdb.h" #include "confdb/confdb_private.h" diff --git a/src/external/platform.m4 b/src/external/platform.m4 index 051fe07..c67e081 100644 --- a/src/external/platform.m4 +++ b/src/external/platform.m4 @@ -37,8 +37,7 @@ AM_CONDITIONAL([HAVE_DEBIAN], [test x"$osname" = xdebian]) AM_CONDITIONAL([HAVE_GENTOO], [test x"$osname" = xgentoo]) AC_CHECK_MEMBERS([struct ucred.pid, struct ucred.uid, struct ucred.gid], , , - [[#define _GNU_SOURCE - #include <sys/socket.h>]]) + [[#include <sys/socket.h>]]) if test x"$ac_cv_member_struct_ucred_pid" = xyes -a \ x"$ac_cv_member_struct_ucred_uid" = xyes -a \ diff --git a/src/krb5_plugin/sssd_krb5_locator_plugin.c b/src/krb5_plugin/sssd_krb5_locator_plugin.c index a4dc31c..d6e90a7 100644 --- a/src/krb5_plugin/sssd_krb5_locator_plugin.c +++ b/src/krb5_plugin/sssd_krb5_locator_plugin.c @@ -17,7 +17,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define _GNU_SOURCE + +#include "config.h" + #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 59ffeb3..5559bd9 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define _GNU_SOURCE #include <sys/types.h> #include <sys/wait.h> #include <sys/time.h> diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 37761ae..c8647e0 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -19,8 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* for struct ucred */ -#define _GNU_SOURCE +#include "config.h" #include <stdio.h> #include <unistd.h> @@ -33,7 +32,6 @@ #include <sys/time.h> #include <errno.h> #include <popt.h> -#include "config.h" #include "util/util.h" #include "db/sysdb.h" #include "confdb/confdb.h" diff --git a/src/sss_client/common.c b/src/sss_client/common.c index c8a9515..b603305 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -23,8 +23,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* for struct ucred */ -#define _GNU_SOURCE +#include "config.h" #include <nss.h> #include <security/pam_modules.h> @@ -43,7 +42,6 @@ #include <libintl.h> #define _(STRING) dgettext (PACKAGE, STRING) -#include "config.h" #include "sss_cli.h" #if HAVE_PTHREAD diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c index 66de232..d54c025 100644 --- a/src/sss_client/pam_sss.c +++ b/src/sss_client/pam_sss.c @@ -24,10 +24,6 @@ #define PAM_SM_SESSION #define PAM_SM_PASSWORD -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - #include <sys/types.h> #include <unistd.h> #include <stdlib.h> diff --git a/src/tools/selinux.c b/src/tools/selinux.c index 647fc17..45672d1 100644 --- a/src/tools/selinux.c +++ b/src/tools/selinux.c @@ -21,7 +21,6 @@ #include "config.h" -#define _GNU_SOURCE #include <stdio.h> #ifdef HAVE_SELINUX diff --git a/src/util/crypto/libcrypto/crypto_sha512crypt.c b/src/util/crypto/libcrypto/crypto_sha512crypt.c index 29900cc..5073431 100644 --- a/src/util/crypto/libcrypto/crypto_sha512crypt.c +++ b/src/util/crypto/libcrypto/crypto_sha512crypt.c @@ -10,7 +10,6 @@ /* SHA512-based Unix crypt implementation. Released into the Public Domain by Ulrich Drepper <drep...@redhat.com>. */ -#define _GNU_SOURCE #include <endian.h> #include <errno.h> #include <limits.h> diff --git a/src/util/crypto/nss/nss_obfuscate.c b/src/util/crypto/nss/nss_obfuscate.c index bd8688e..cbd8984 100644 --- a/src/util/crypto/nss/nss_obfuscate.c +++ b/src/util/crypto/nss/nss_obfuscate.c @@ -183,13 +183,13 @@ done: static int nss_encrypt_decrypt_init(TALLOC_CTX *mem_ctx, struct crypto_mech_data *mech_props, - bool encrypt, + bool do_encrypt, struct sss_nss_crypto_ctx *cctx) { CK_ATTRIBUTE_TYPE op; int ret; - op = encrypt ? CKA_ENCRYPT : CKA_DECRYPT; + op = do_encrypt ? CKA_ENCRYPT : CKA_DECRYPT; /* turn the raw key into a key object */ cctx->keyobj = PK11_ImportSymKey(cctx->slot, mech_props->cipher, diff --git a/src/util/crypto/nss/nss_sha512crypt.c b/src/util/crypto/nss/nss_sha512crypt.c index 514e4d9..76eb8a6 100644 --- a/src/util/crypto/nss/nss_sha512crypt.c +++ b/src/util/crypto/nss/nss_sha512crypt.c @@ -8,7 +8,8 @@ /* SHA512-based Unix crypt implementation. Released into the Public Domain by Ulrich Drepper <drep...@redhat.com>. */ -#define _GNU_SOURCE +#include "config.h" + #include <endian.h> #include <errno.h> #include <limits.h> diff --git a/src/util/debug.c b/src/util/debug.c index dbd54c1..18bfda4 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -19,7 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define _GNU_SOURCE +#include "config.h" + #include <stdio.h> #include <stdarg.h> #include <stdlib.h> diff --git a/src/util/server.c b/src/util/server.c index e126237..d33c5cb 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define _GNU_SOURCE #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -- 1.7.5.1
From 07986ee6b6909118afe54ebf7e724a78f87aad4a Mon Sep 17 00:00:00 2001 From: Sumit Bose <sb...@redhat.com> Date: Mon, 23 May 2011 15:25:52 +0200 Subject: [PATCH 2/2] Remove unused defines from configure.ac --- configure.ac | 12 ------------ 1 files changed, 0 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index a31f97d..972c24c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,16 +1,4 @@ AC_PREREQ(2.59) -AC_DEFUN([AC_CHECK_LIB_EXT], [ - AC_CHECK_LIB([$1],[$3],[$4],[$5],[$7]) - ac_cv_lib_ext_$1_$3=$ac_cv_lib_$1_$3 -]) -AC_DEFUN([AC_CHECK_FUNC_EXT], [ - AC_CHECK_FUNC([$1],[$3],[$4]) - ac_cv_func_ext_$1=$ac_cv_func_$1 -]) -AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) -AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) -AC_DEFUN([SMB_EXT_LIB], [echo -n ""]) -AC_DEFUN([SMB_ENABLE], [echo -n ""]) m4_include([version.m4]) AC_INIT([sssd], -- 1.7.5.1
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel