[SSSD] [PATCH] Fix broken client in master

Lukas Slebodnik lslebodn at redhat.com
Mon Mar 18 08:47:13 UTC 2013


On (16/03/13 15:46), Simo Sorce wrote:
>On Sat, 2013-03-16 at 15:40 +0100, Lukas Slebodnik wrote:
>> On (16/03/13 14:38), Lukas Slebodnik wrote:
>> >On (15/03/13 21:35), Simo Sorce wrote:
>> >>Fixes https://fedorahosted.org/sssd/ticket/1838
>> >>
>> >>Simo.
>> >>
>> >>-- 
>> >>Simo Sorce * Red Hat, Inc * New York
>> >
>> >I tried to grep sources in src/sss_client directory
>> >(with reverted commit 22d381367c27910fe82f476a76b9f4ede555e35a)
>> >
>> >$ grep -Rn '#include "util/util.h"'
>> >sudo/sss_sudo.c:28:#include "util/util.h"
>> >ssh/sss_ssh_knownhostsproxy.c:33:#include "util/util.h"
>> >ssh/sss_ssh_client.c:33:#include "util/util.h"
>> >ssh/sss_ssh_authorizedkeys.c:25:#include "util/util.h"
>> >autofs/sss_autofs_private.h:22:#include "util/util.h"
>> >autofs/autofs_test_client.c:31:#include "util/util.h"
>> >
>> >Is the difference among pam, nss and others clients?
>> >
>> >LS
>> 
>> Oh,
>> I see the problem. But wouldn't be better solution to add another
>> dependency (src/util/io.c) for libnss_sss instead of code duplication
>> Because there is also another dependency to file src/util/murmurhash3.c,
>> which is outside src/sss_client. Patch attached.
>
>Yes murmurhash is a necessary dependency due to the mmap code.
>
>As for the patch if you want to keep using common code we need to do 2
>things:
>
>1) create a header file just for this file util/io.h for example.
>Include this file in util/util.h and include just io.h in sss_client/
>code.
>
>2) add a comment on top of io.c that this file is also used by
>sss_client so it cannot include things like DEBUG macros and it should
>not include util.h
>
>Simo.
>
>-- 
>Simo Sorce * Red Hat, Inc * New York
>
Thak you very much for explanation in both mails.
Updated patch attached.

LS
-------------- next part --------------
>From fc1b6eb3ebf2486155353e36c54d69ec6152704e Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 16 Mar 2013 15:11:10 +0100
Subject: [PATCH] Fix sss_client breakage.

Adding missing dependencies for linker. Missing dependency was
introduced by commit 22d381367c27910fe82f476a76b9f4ede555e35a
in changed file src/sss_client/nss_mc_common.c

All function declaration for io.c was moved from util.h to separate file io.h,

https://fedorahosted.org/sssd/ticket/1838
---
 Makefile.am                    |  2 ++
 src/sss_client/nss_mc_common.c |  2 +-
 src/util/io.c                  |  8 +++++++-
 src/util/io.h                  | 33 +++++++++++++++++++++++++++++++++
 src/util/murmurhash3.h         |  8 ++++++++
 src/util/util.h                |  4 +---
 6 files changed, 52 insertions(+), 5 deletions(-)
 create mode 100644 src/util/io.h

diff --git a/Makefile.am b/Makefile.am
index 4cb8b64364fb8e6b8e5f1bebc4a420e7f8573126..265da9c7923568c7d422ba80743af3eea0ffcade 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -371,6 +371,7 @@ dist_noinst_HEADERS = \
     src/util/crypto/sss_crypto.h \
     src/util/dlinklist.h \
     src/util/util.h \
+    src/util/io.h \
     src/util/util_errors.h \
     src/util/strtonum.h \
     src/util/sss_nss.h \
@@ -1234,6 +1235,7 @@ libnss_sss_la_SOURCES = \
     src/sss_client/sss_cli.h \
     src/sss_client/nss_compat.h \
     src/sss_client/nss_mc_common.c \
+    src/util/io.c \
     src/util/murmurhash3.c \
     src/sss_client/nss_mc_passwd.c \
     src/sss_client/nss_mc_group.c \
diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c
index 66442b7174c38fa4e486b979e8067b1b4dfe448d..5d36c47ad1aa5cd73c12d97d8f1056cbf23ba049 100644
--- a/src/sss_client/nss_mc_common.c
+++ b/src/sss_client/nss_mc_common.c
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "nss_mc.h"
-#include "util/util.h"
+#include "util/io.h"
 
 /* FIXME: hook up to library destructor to avoid leaks */
 /* FIXME: temporarily open passwd file on our own, later we will probably
diff --git a/src/util/io.c b/src/util/io.c
index e07a18c56b97b41409fed35066a7d6ab70cd753d..4d1f2e74a1607bf7f6a8977ca97455185eba7403 100644
--- a/src/util/io.c
+++ b/src/util/io.c
@@ -24,8 +24,14 @@
 
 #include <unistd.h>
 #include <fcntl.h>
+#include <errno.h>
 
-#include "util/util.h"
+#include "util/io.h"
+
+/* CAUTION:
+ * This file have to be minimalist and cannot include DEBUG macros
+ * or header file util.h.
+ */
 
 int sss_open_cloexec(const char *pathname, int flags, int *ret)
 {
diff --git a/src/util/io.h b/src/util/io.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d10ed9c2c6b66b7488cc0c8c5ced83f40ef434b
--- /dev/null
+++ b/src/util/io.h
@@ -0,0 +1,33 @@
+/*
+   SSSD
+
+   SSSD Utility functions
+
+   Copyright (C) Lukas Slebodnik           2013
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _UTIL_IO_H_
+#define _UTIL_IO_H_
+
+/* CAUTION:
+ * This file is also used in sss_client (pam, nss). Therefore it have to be
+ * minimalist and cannot include DEBUG macros or header file util.h.
+ */
+
+int sss_open_cloexec(const char *pathname, int flags, int *ret);
+int sss_openat_cloexec(int dir_fd, const char *pathname, int flags, int *ret);
+
+#endif /* _UTIL_IO_H_ */
diff --git a/src/util/murmurhash3.h b/src/util/murmurhash3.h
index db7d8a48c4680f5aa21d29f5e4607b0c4618203c..6910e596be10c9adef90177559ad3e6efe9f18de 100644
--- a/src/util/murmurhash3.h
+++ b/src/util/murmurhash3.h
@@ -6,7 +6,15 @@
  * clients can be both 64 or 32 bit at the same time.
  */
 
+#ifndef _UTIL_MURMURHASH3_H_
+#define _UTIL_MURMURHASH3_H_
+
 #include <stdint.h>
 
+/* CAUTION:
+ * This file is also used in sss_client (pam, nss). Therefore it have to be
+ * minimalist and cannot include DEBUG macros or header file util.h.
+ */
 uint32_t murmurhash3(const char *key, int len, uint32_t seed);
 
+#endif /* _UTIL_MURMURHASH3_H_ */
diff --git a/src/util/util.h b/src/util/util.h
index e61a94f7f5548ae2081a579307a38bf8ddcb4daf..33725f63591a4d165a084c1fd361f9651e80e50b 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -584,9 +584,7 @@ errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
 /* from util_lock.c */
 errno_t sss_br_lock_file(int fd, size_t start, size_t len,
                          int num_tries, useconds_t wait);
-/* from io.c */
-int sss_open_cloexec(const char *pathname, int flags, int *ret);
-int sss_openat_cloexec(int dir_fd, const char *pathname, int flags, int *ret);
+#include "io.h"
 
 /* Endianness-compatibility for systems running older versions of glibc */
 
-- 
1.8.1.4



More information about the sssd-devel mailing list