[SSSD] [PATCHES] Enable printf format string checking

Lukas Slebodnik lslebodn at redhat.com
Wed Sep 4 16:34:52 UTC 2013


On (03/09/13 00:25), Jakub Hrozek wrote:
>On Wed, Aug 21, 2013 at 03:35:11PM +0200, Lukas Slebodnik wrote:
>> On (21/08/13 13:46), Jakub Hrozek wrote:
>> >Sorry it took so long before we got to another review of the patch. The
>> >ticket is targeted for 1.12 so initially I was thinking of the patchset
>> >as lower priority than the other work.
>> >
>> >On Wed, Jul 24, 2013 at 10:32:29AM +0200, Lukas Slebodnik wrote:
>> >> On (24/07/13 09:41), Ondrej Kos wrote:
>> >> >On 07/23/2013 06:21 PM, Lukas Slebodnik wrote:
>> >> >>ehlo,
>> >> >>
>> >> >>It would be great to have enabled printf format string checking in RHEL7.
>> >> >>Therefore I decided to send pateches for ticket
>> >> >>https://fedorahosted.org/sssd/ticket/1945
>> >> >>
>> >> >>Patch 0001 -- Even if this patch is first, it should be applied in upstream as
>> >> >>          last.
>> >
>> >              ^^^^ Does it matter? I'll apply the whole set anyway..
>> It can make a big noise in case of bisecting.
>> I moved this patch to the end.
>
>Thanks. I'll try to remember to ask someone to double-check before pushing
>:-)
>
>> 
>> >
>> >Some comments below..
>> >
>> >> >>
>> >> >>Patch 0002 - 0006 -- trivial
>> >> >>Patch 0007 -- ssize_t is not defined in ANSI c99, IIRC it is defined in posix
>> >> >>               as a signed type, therefore format should be used "zd"
>> >> >>Patch 0008 -- size_t is defined in ANSI c99 as unzigned type -> "zu"
>> >
>> >btw size_t seems to be part of standard library, not the language
>> >specification per se. Not that it matters for the patch :)
>> size_t can be part of standard library, but ANSI c99 says size_t is unsigned
>> type.
>> 
>> Problem is that sizeof(size_t) is different on 32-bit platform and 64-bit
>> platform
>
>OK
>
>> 
>> >
>> >> >>Patch 0009 -- wrapper for inttypes.h and for future format macros.
>> >> >>Patch 0012 -- formating types defined in stdint.h uint_32_t ...
>> >> >>            -- there are used macros defined in inttypes.h
>> >> >>Patches 0010 - 0015 fix formating for special variables (key_serial_t, rlim_t...)
>> >> >>                     and for some types I created macros in sss_format.h
>> >> >>Patch 0010 -- key_serial_t is typedef of int32_t, but it could be defined
>> >> >>          differently in another (platforms/ implemantations of kerberos)
>> >> >>Patch 0011 -- it seems that rlim_t us the same as uint64_t, but it was defined
>> >> >>            using conditional build an not a typedef of std types.
>> >> >>Patch 0013 -- time_t is defined as "long int" sizeof_i386(time_t) != sizeof_x86_64(time_t)
>> >> >>Patch 0014 -- ber_int and ber_tag are typedef for int and unsigned long
>> >> >>Patch 0015 -- gid_t and uid_t are typedef as unsigned
>> >> >>               (I checked linux 32 bit, linu 64_bit and freebsd 64 bit)
>> >
>> >Actually /usr/include/bits/typesizes.h says:
>> >#define __UID_T_TYPE            __U32_TYPE
>> and you forgot to add:
>> shell$ grep -RniI __U32_TYPE
>> bits/types.h:101:#define __U32_TYPE             unsigned int
>
>I think this is lucky coincidence where unsigned int is 32bits wide.
>
>But to be honest I haven't found any information that would state that
>uid_t or gid_t is guaranteed to be 32bit (even though some places in the
>SSSD rely on uid_t == uint32_t). As far as I can see, POSIX simply says
>that both are opaque numeric types. Too bad the system headers don't
>provide some kind of format specifier..
>
>I wonder if we should check the width during configure and define our
>own specifier based on what we discover?
>
>> 
>> >
>> >(and then defines __UID_T_TYPE to __uid_t which in turn gets typedefed to uid_t)
>> >
>
>[snip]
>
>> >> Subject: [PATCH 10/16] Fix formating of variables with type: key_serial_t
>> >> Subject: [PATCH 11/16] Fix formating of variables with type: rlim_t
>> >> Subject: [PATCH 12/16] Fix formating of variables with type defined in stdint.h
>> >
>> >Nice, I didn't know these existed. But to be honest, these format specifiers
>> >seem ugly to me..wouldn't it be nicer to cast the variables to a larger type
>> >(long or unsigned long) and then use plan C conversion?
>> I agree with Stephen casting is not very portable.
>> Some platforms needn't have defned long long unsigend or there can be another
>> type which is bigger.
>> 
>> uintmax_t/intmax_t could be used as the larget type.
>> In this case modifier "j" should be used
>>     format_fun("%jd %ju\n" (uintmax_t) uint_8_var, (intmax_t)int8_t_var)
>> but it is overkill to cast uint_8_var to 64_vit variable (or in future 128 bit:-)
>> 
>> And last point. I don't like casting of argumets in formating functions.
>> 
>> ------------------
>> "man inttypes.h" is very helpful
>> ------------------
>
>OK, I'm convinced :-)
>
>> 
>> >> Subject: [PATCH 13/16] Fix formating of variables with type: time_t
>> >I think this is OK, my C reference says that time_t can be of "any arithmetic
>> >type" but also states that long is traditionally used.
>> >
>> >> Subject: [PATCH 14/16] Fix formating of variables with ber_ type
>> >ACK
>> >
>> >> Subject: [PATCH 15/16] Fix formating of variables with type: [gu]?id_t
>> >
>> >This is the main point of discussion in the patchset I think. IIRC POSIX
>> >states that IDs are 32bit unsigned integers. That's precisely why we have
>> >casted them up to unsigned (long) long. Did you see warnings with some
>> >strict combination of CFLAGS?
>> >
>> -Wformat is automatically  enabled by -Wall, There is no problem with CFLAGS.
>> You can try to revert this patch (or do not apply this patch)
>> And warnings will appear. clang gives more hints.
>> 
>> But it is possibel to add another macro to header file sss_format.h
>> 
>> >> Subject: [PATCH 16/16] Fix warning: data argument not used by format string
>> >Oof, these are bad. Thank you. ACK.
>> Those fixes are not critical, only unsufficient information will be printed.
>> 
>> Updated patches are attached.
>> 
>> LS
>
>Sorry the review has stalled for a bit. I think that once we resolve the
>uid_t patch, we can push the whole patchset.

I added 3 new macros for formating [ug]?id types: PRIid, PRIgid, PRIuid

BTW: I rebased patches and spot 3 new warnings :-)

LS
-------------- next part --------------
>From 43a7534d0213f1be21ca7556f634cf58350f1ddf Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 13 Jul 2013 15:25:47 +0200
Subject: [PATCH 01/20] Fix formating of variables with type: long

---
 src/krb5_plugin/sssd_krb5_locator_plugin.c | 2 +-
 src/providers/krb5/krb5_child.c            | 2 +-
 src/providers/krb5/krb5_common.c           | 2 +-
 src/providers/ldap/ldap_auth.c             | 7 ++++---
 src/providers/ldap/ldap_common.c           | 5 +++--
 src/providers/ldap/sdap_access.c           | 7 ++++---
 src/util/util.h                            | 4 ++--
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/krb5_plugin/sssd_krb5_locator_plugin.c b/src/krb5_plugin/sssd_krb5_locator_plugin.c
index 402fd03e7e45644c65581c7c6f14fe8d7bf2e894..725687ddcf559e251ee54d1005f862bd6d0af4f8 100644
--- a/src/krb5_plugin/sssd_krb5_locator_plugin.c
+++ b/src/krb5_plugin/sssd_krb5_locator_plugin.c
@@ -171,7 +171,7 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
             }
 
             if (port < 0 || port > 65535) {
-                PLUGIN_DEBUG(("Illegal port number [%d], assuming default.\n",
+                PLUGIN_DEBUG(("Illegal port number [%ld], assuming default.\n",
                             port));
                 port = 0;
             }
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index 842b50e6e23cf9b00f51c0a01cfd960e4156ee21..afd39b854786cb8081f050b85dcc0e9be5f23d1e 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -127,7 +127,7 @@ static void sss_krb5_expire_callback_func(krb5_context context, void *data,
         DEBUG(1, ("Time to expire out of range.\n"));
         return;
     }
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("exp_time: [%d]\n", exp_time));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("exp_time: [%ld]\n", exp_time));
 
     blob = talloc_array(kr->pd, uint32_t, 2);
     if (blob == NULL) {
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index c7ce574d513702132cb7e0c8ca4f1f1b80430f0b..e6fbe99529394be7edcec6500ec7ba33ca2d60ac 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -660,7 +660,7 @@ static errno_t _krb5_servers_init(struct be_ctx *ctx,
                 }
 
                 if (port < 1 || port > 65535) {
-                    DEBUG(SSSDBG_CRIT_FAILURE, ("Illegal port number [%d].\n", port));
+                    DEBUG(SSSDBG_CRIT_FAILURE, ("Illegal port number [%ld].\n", port));
                     ret = EINVAL;
                     goto done;
                 }
diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c
index e5b6365816af6bcf42554da7f6491b98241c5c45..dcaea75c0b7833b8a1eb00232ab92ea09f7a7f00 100644
--- a/src/providers/ldap/ldap_auth.c
+++ b/src/providers/ldap/ldap_auth.c
@@ -115,9 +115,10 @@ static errno_t check_pwexpire_kerberos(const char *expire_date, time_t now,
 
     tzset();
     expire_time -= timezone;
-    DEBUG(9, ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%d] "
-              "daylight [%d] now [%d] expire_time [%d].\n", tzname[0],
-              tzname[1], timezone, daylight, now, expire_time));
+    DEBUG(SSSDBG_TRACE_ALL,
+          ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] "
+           "daylight [%d] now [%d] expire_time [%d].\n", tzname[0],
+           tzname[1], timezone, daylight, now, expire_time));
 
     if (difftime(now, expire_time) > 0.0) {
         DEBUG(4, ("Kerberos password expired.\n"));
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index f7ad71182a4f46a20386e70ffda129347c5e3d87..0df5afe8eab3f68f56dd47b1c01f2692b612c160 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -1578,8 +1578,9 @@ errno_t string_to_shadowpw_days(const char *s, long *d)
     }
 
     if (l < -1) {
-        DEBUG(1, ("Input string contains not allowed negative value [%d].\n",
-                  l));
+        DEBUG(SSSDBG_CRIT_FAILURE,
+              ("Input string contains not allowed negative value [%ld].\n",
+               l));
         return EINVAL;
     }
 
diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c
index 53df7b0eeb3bb2bdbede6c126fb004658dea2656..b381fc40570fb1fabe88255a6543c06453a7d9ce 100644
--- a/src/providers/ldap/sdap_access.c
+++ b/src/providers/ldap/sdap_access.c
@@ -433,9 +433,10 @@ static bool nds_check_expired(const char *exp_time_str)
     tzset();
     expire_time -= timezone;
     now = time(NULL);
-    DEBUG(9, ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%d] "
-              "daylight [%d] now [%d] expire_time [%d].\n", tzname[0],
-              tzname[1], timezone, daylight, now, expire_time));
+    DEBUG(SSSDBG_TRACE_ALL,
+          ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] "
+           "daylight [%d] now [%d] expire_time [%d].\n", tzname[0],
+           tzname[1], timezone, daylight, now, expire_time));
 
     if (difftime(now, expire_time) > 0.0) {
         DEBUG(4, ("NDS account expired.\n"));
diff --git a/src/util/util.h b/src/util/util.h
index 516edc81cab5792a30062b2908a58cc3fc21cef4..74fa2235747efc3490d14a543e18b48067cf3f71 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -128,7 +128,7 @@ errno_t set_debug_file_from_fd(const int fd);
             memcpy(__debug_macro_datetime, ctime(&__debug_macro_tv.tv_sec), 19); \
             __debug_macro_datetime[19] = '\0'; \
             if (debug_microseconds) { \
-                debug_fn("(%s:%.6d %d) [%s] [%s] (%#.4x): ", \
+                debug_fn("(%s:%.6ld %d) [%s] [%s] (%#.4x): ", \
                          __debug_macro_datetime, __debug_macro_tv.tv_usec, \
                          __debug_macro_year, debug_prg_name, \
                          __FUNCTION__, __debug_macro_newlevel); \
@@ -169,7 +169,7 @@ errno_t set_debug_file_from_fd(const int fd);
             memcpy(__debug_macro_datetime, ctime(&__debug_macro_tv.tv_sec), 19); \
             __debug_macro_datetime[19] = '\0'; \
             if (debug_microseconds) { \
-                debug_fn("(%s:%.6d %d) [%s] [%s] (%#.4x): %s\n", \
+                debug_fn("(%s:%.6ld %d) [%s] [%s] (%#.4x): %s\n", \
                          __debug_macro_datetime, __debug_macro_tv.tv_usec, \
                          __debug_macro_year, debug_prg_name, \
                          function, __debug_macro_newlevel, message); \
-- 
1.8.3.1

-------------- next part --------------
>From c499864dca2b060a4c859a96772c854993fa67b7 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 13 Jul 2013 15:40:29 +0200
Subject: [PATCH 02/20] Fix formating of variables with type: unsigned long

---
 src/providers/proxy/proxy_auth.c    | 2 +-
 src/responder/common/responder_dp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/providers/proxy/proxy_auth.c b/src/providers/proxy/proxy_auth.c
index 99b1a76c705975da91594eabd70e6a1a94eb6c18..61fec63aa416315546309035cfbe603d6a527329 100644
--- a/src/providers/proxy/proxy_auth.c
+++ b/src/providers/proxy/proxy_auth.c
@@ -167,7 +167,7 @@ static struct tevent_req *proxy_child_send(TALLOC_CTX *mem_ctx,
 
     value.type = HASH_VALUE_PTR;
     value.ptr = req;
-    DEBUG(8, ("Queueing request [%d]\n", key.ul));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("Queueing request [%lu]\n", key.ul));
     hret = hash_enter(auth_ctx->request_table,
                       &key, &value);
     if (hret != HASH_SUCCESS) {
diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c
index c5e8fc8baecc02a789eba53937d3760c6cb8dde7..e73e1e6b6233ac234bbcb991519fc6842634dde4 100644
--- a/src/responder/common/responder_dp.c
+++ b/src/responder/common/responder_dp.c
@@ -116,7 +116,7 @@ static int sss_dp_req_destructor(void *ptr)
     if (hret != HASH_SUCCESS) {
         /* This should never happen */
         DEBUG(SSSDBG_TRACE_INTERNAL,
-              ("BUG: Could not clear [%d:%d:%s] from request queue: [%s]\n",
+              ("BUG: Could not clear [%d:%lu:%s] from request queue: [%s]\n",
                sdp_req->key->type, sdp_req->key->ul, sdp_req->key->str,
                hash_error_string(hret)));
         return -1;
-- 
1.8.3.1

-------------- next part --------------
>From 6281f38a1cc7e549ce8e2d28e6d8b38b33ac855f Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 13 Jul 2013 15:46:09 +0200
Subject: [PATCH 03/20] Fix formating of variables with type: int

---
 src/providers/ldap/sdap_async_connection.c | 2 +-
 src/providers/ldap/sdap_fd_events.c        | 5 +++--
 src/util/sss_ldap.c                        | 5 +++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index e97bcf15e1f43432520ca85fa18d26c630893c0d..cc3e13d097d33dc7c44e1f1fecccd152ceb6cf67 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -294,7 +294,7 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
                                    &ber_sasl_minssf);
             if (lret != LDAP_OPT_SUCCESS) {
                 DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to set LDAP MIN SSF option "
-                                            "to %lu\n", sasl_minssf));
+                                            "to %d\n", sasl_minssf));
                 goto fail;
             }
         }
diff --git a/src/providers/ldap/sdap_fd_events.c b/src/providers/ldap/sdap_fd_events.c
index 190019471c45c30b88425c606d212616e5681779..5e4ea79b3e39e827ad0ad9db552dd1a0c94af90b 100644
--- a/src/providers/ldap/sdap_fd_events.c
+++ b/src/providers/ldap/sdap_fd_events.c
@@ -301,8 +301,9 @@ errno_t sdap_call_conn_cb(const char *uri,int fd, struct sdap_handle *sh)
     ret = ldap_url_parse(uri, &lud);
     if (ret != 0) {
         ber_sockbuf_free(sb);
-        DEBUG(1, ("ldap_url_parse failed to validate [%s] on fd [%ld].\n",
-                  uri, fd));
+        DEBUG(SSSDBG_CRIT_FAILURE,
+              ("ldap_url_parse failed to validate [%s] on fd [%d].\n",
+               uri, fd));
         return EFAULT;
     }
 
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c
index dea38eaa98e073a6d70918b8b32cd08b4a7eee05..6d7b0907ca2fa48d9cff5257ab6bbba0ae7dd5c6 100644
--- a/src/util/sss_ldap.c
+++ b/src/util/sss_ldap.c
@@ -420,8 +420,9 @@ static void sss_ldap_init_sys_connect_done(struct tevent_req *subreq)
 
     lret = ldap_init_fd(state->sd, LDAP_PROTO_TCP, state->uri, &state->ldap);
     if (lret != LDAP_SUCCESS) {
-        DEBUG(1, ("ldap_init_fd failed: %s. [%ld][%s]\n",
-                  sss_ldap_err2string(lret), state->sd, state->uri));
+        DEBUG(SSSDBG_CRIT_FAILURE,
+              ("ldap_init_fd failed: %s. [%d][%s]\n",
+               sss_ldap_err2string(lret), state->sd, state->uri));
         ret = lret == LDAP_SERVER_DOWN ? ETIMEDOUT : EIO;
         goto fail;
     }
-- 
1.8.3.1

-------------- next part --------------
>From 4d2663d418c4c3d8262c365444af799920722a76 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 13 Jul 2013 16:29:59 +0200
Subject: [PATCH 04/20] Fix pointer formatting

---
 src/sbus/sssd_dbus_connection.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c
index 9077b81c13b826326c616402e9ecfe0f924012de..ccea88e6d72dc78829c368bf46dd374043d9728e 100644
--- a/src/sbus/sssd_dbus_connection.c
+++ b/src/sbus/sssd_dbus_connection.c
@@ -54,7 +54,7 @@ static void sbus_dispatch(struct tevent_context *ev,
     conn = talloc_get_type(data, struct sbus_connection);
 
     dbus_conn = conn->dbus.conn;
-    DEBUG(9, ("dbus conn: %lX\n", dbus_conn));
+    DEBUG(SSSDBG_TRACE_ALL, ("dbus conn: %p\n", dbus_conn));
 
     if (conn->retries > 0) {
         DEBUG(6, ("SBUS is reconnecting. Deferring.\n"));
@@ -162,7 +162,7 @@ int sbus_init_connection(TALLOC_CTX *ctx,
     struct sbus_connection *conn;
     int ret;
 
-    DEBUG(5,("Adding connection %lX\n", dbus_conn));
+    DEBUG(SSSDBG_TRACE_FUNC,("Adding connection %p\n", dbus_conn));
     conn = talloc_zero(ctx, struct sbus_connection);
 
     conn->ev = ev;
@@ -296,7 +296,7 @@ int sbus_default_connection_destructor(void *ctx)
     struct sbus_connection *conn;
     conn = talloc_get_type(ctx, struct sbus_connection);
 
-    DEBUG(5, ("Invoking default destructor on connection %lX\n",
+    DEBUG(SSSDBG_TRACE_FUNC, ("Invoking default destructor on connection %p\n",
               conn->dbus.conn));
     if (conn->connection_type == SBUS_CONN_TYPE_PRIVATE) {
         /* Private connections must be closed explicitly */
@@ -334,7 +334,7 @@ void sbus_disconnect (struct sbus_connection *conn)
         return;
     }
 
-    DEBUG(5,("Disconnecting %lX\n", conn->dbus.conn));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Disconnecting %p\n", conn->dbus.conn));
 
     /*******************************
      *  Referencing conn->dbus.conn */
@@ -374,7 +374,7 @@ void sbus_disconnect (struct sbus_connection *conn)
     /* Unreferenced conn->dbus_conn *
      ******************************/
 
-    DEBUG(5,("Disconnected %lX\n", conn->dbus.conn));
+    DEBUG(SSSDBG_TRACE_FUNC ,("Disconnected %p\n", conn->dbus.conn));
 }
 
 static int sbus_reply_internal_error(DBusMessage *message,
-- 
1.8.3.1

-------------- next part --------------
>From eb6f5fae8e1960640731af7852b81dac6ebd5634 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 13 Jul 2013 15:34:00 +0200
Subject: [PATCH 05/20] Use the same variable type like in struct
 ldb_message_element

struct ldb_message_element.num_values is unsigned
This patch indirectly fixes printf format string warning.
---
 src/providers/ldap/sdap_async_groups.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index a2e5106f00368d00984bc2371ff7be1c1bf130fc..bec27e0a7c7101f5a31c45cc0056b1c9ee2667cf 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -1056,7 +1056,7 @@ done:
 static int
 sdap_process_missing_member_2307bis(struct tevent_req *req,
                                     char *user_dn,
-                                    int num_users)
+                                    unsigned num_users)
 {
     struct sdap_process_group_state *grp_state =
         tevent_req_data(req, struct sdap_process_group_state);
-- 
1.8.3.1

-------------- next part --------------
>From ad4b85cdab9be4a008e821e14aed75ec6543e1da Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 13:00:49 +0200
Subject: [PATCH 06/20] Fix formating of variables with type: ssize_t

---
 src/providers/ipa/ipa_selinux.c         | 4 ++--
 src/providers/krb5/krb5_child_handler.c | 2 +-
 src/providers/krb5/krb5_common.c        | 4 ++--
 src/tools/files.c                       | 2 +-
 src/util/backup_file.c                  | 2 +-
 src/util/child_common.c                 | 3 ++-
 src/util/server.c                       | 4 ++--
 7 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/providers/ipa/ipa_selinux.c b/src/providers/ipa/ipa_selinux.c
index 39bebebfd8f4880c4093dfd922f2dfaa79c38a2e..5f734338b8fb43d6d99ba9adcb25c655f8cb1951 100644
--- a/src/providers/ipa/ipa_selinux.c
+++ b/src/providers/ipa/ipa_selinux.c
@@ -672,7 +672,7 @@ static errno_t write_selinux_login_file(const char *username, char *string)
     char *path = NULL;
     char *tmp_path = NULL;
     ssize_t written;
-    int len;
+    size_t len;
     int fd = -1;
     mode_t oldmask;
     TALLOC_CTX *tmp_ctx;
@@ -743,7 +743,7 @@ static errno_t write_selinux_login_file(const char *username, char *string)
     }
 
     if (written != len) {
-        DEBUG(SSSDBG_OP_FAILURE, ("Expected to write %d bytes, wrote %d",
+        DEBUG(SSSDBG_OP_FAILURE, ("Expected to write %zd bytes, wrote %zu",
                                   written, len));
         ret = EIO;
         goto done;
diff --git a/src/providers/krb5/krb5_child_handler.c b/src/providers/krb5/krb5_child_handler.c
index 8117d1e5db01cfe0684ee4d7f3e4acf8ff1e4768..20b83d1372fdf0026b36a4b9877673d3dce25ddd 100644
--- a/src/providers/krb5/krb5_child_handler.c
+++ b/src/providers/krb5/krb5_child_handler.c
@@ -538,7 +538,7 @@ parse_krb5_child_response(TALLOC_CTX *mem_ctx, uint8_t *buf, ssize_t len,
               msg_status, msg_type, msg_len));
 
         if ((p + msg_len) > len) {
-            DEBUG(SSSDBG_CRIT_FAILURE, ("message format error [%d] > [%d].\n",
+            DEBUG(SSSDBG_CRIT_FAILURE, ("message format error [%d] > [%zd].\n",
                   p+msg_len, len));
             return EINVAL;
         }
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index e6fbe99529394be7edcec6500ec7ba33ca2d60ac..5a43983d157818d8164cdca009e219cf64462e69 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -417,7 +417,7 @@ errno_t write_krb5info_file(const char *realm, const char *server,
     char *krb5info_name = NULL;
     TALLOC_CTX *tmp_ctx = NULL;
     const char *name_tmpl = NULL;
-    int server_len;
+    size_t server_len;
     ssize_t written;
     mode_t old_umask;
 
@@ -478,7 +478,7 @@ errno_t write_krb5info_file(const char *realm, const char *server,
 
     if (written != server_len) {
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("Write error, wrote [%d] bytes, expected [%d]\n",
+              ("Write error, wrote [%zd] bytes, expected [%zu]\n",
                written, server_len));
         ret = EIO;
         goto done;
diff --git a/src/tools/files.c b/src/tools/files.c
index ff04d09f8ba14802098b8177dc7c905fa75f4e80..7fc8422817f0cb4365da6404b7eb15c6e3bfb253 100644
--- a/src/tools/files.c
+++ b/src/tools/files.c
@@ -408,7 +408,7 @@ copy_file(int ifd,
 
         if (written != cnt) {
             DEBUG(SSSDBG_CRIT_FAILURE,
-                  ("Wrote %d bytes, expected %d\n", written, cnt));
+                  ("Wrote %zd bytes, expected %zd\n", written, cnt));
             goto done;
         }
     }
diff --git a/src/util/backup_file.c b/src/util/backup_file.c
index edbf868cb8f68ca534c257a6dfc761dc9fd025f2..316c1cfe8023c90b3ceb4d6a514754999f87c45b 100644
--- a/src/util/backup_file.c
+++ b/src/util/backup_file.c
@@ -103,7 +103,7 @@ int backup_file(const char *src_file, int dbglvl)
         }
 
         if (written != numread) {
-            DEBUG(dbglvl, ("Wrote %d bytes expected %d bytes\n",
+            DEBUG(dbglvl, ("Wrote %zd bytes expected %zd bytes\n",
                   written, numread));
             ret = EIO;
             goto done;
diff --git a/src/util/child_common.c b/src/util/child_common.c
index 2bd2bbc3a557ea61c3bcf517a48b3673bd3d6d4f..28358606b0ba8b5fa6a28450f3111b68f8668fbf 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -484,7 +484,8 @@ static void read_pipe_handler(struct tevent_context *ev,
         return;
 
     } else {
-        DEBUG(1, ("unexpected return value of read [%d].\n", size));
+        DEBUG(SSSDBG_CRIT_FAILURE,
+              ("unexpected return value of read [%zd].\n", size));
         tevent_req_error(req, EINVAL);
         return;
     }
diff --git a/src/util/server.c b/src/util/server.c
index 9d3c9cb04dcac2f823982c31cac832fb473b720c..a33207b3da8a713d90dbd840475ecdb75f1fff0c 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -147,7 +147,7 @@ int pidfile(const char *path, const char *name)
     int fd;
     int ret, err;
     ssize_t len;
-    ssize_t size;
+    size_t size;
     ssize_t written;
     ssize_t pidlen = sizeof(pid_str) - 1;
 
@@ -227,7 +227,7 @@ int pidfile(const char *path, const char *name)
 
     if (written != size) {
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("Wrote %d bytes expected %d\n", written, size));
+              ("Wrote %zd bytes expected %zu\n", written, size));
         close(fd);
         return EIO;
     }
-- 
1.8.3.1

-------------- next part --------------
>From 4e349ba0c369ec16d7bc724d7b3d819530f46fa3 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 12:41:33 +0200
Subject: [PATCH 07/20] Fix formating of variables with type: size_t

---
 src/db/sysdb_autofs.c                         |  2 +-
 src/db/sysdb_ops.c                            |  2 +-
 src/db/sysdb_search.c                         |  2 +-
 src/providers/ad/ad_srv.c                     |  4 ++--
 src/providers/fail_over_srv.c                 |  2 +-
 src/providers/ipa/ipa_config.c                |  2 +-
 src/providers/ipa/ipa_idmap.c                 |  2 +-
 src/providers/ipa/ipa_netgroups.c             |  6 ++++--
 src/providers/ipa/ipa_selinux.c               |  4 ++--
 src/providers/ipa/ipa_selinux_maps.c          |  4 ++--
 src/providers/ipa/ipa_srv.c                   |  2 +-
 src/providers/ipa/ipa_subdomains_ext_groups.c |  2 +-
 src/providers/krb5/krb5_child.c               |  6 +++---
 src/providers/krb5/krb5_child_handler.c       |  2 +-
 src/providers/krb5/krb5_renew_tgt.c           |  3 ++-
 src/providers/ldap/ldap_child.c               |  6 +++---
 src/providers/ldap/ldap_id_cleanup.c          |  4 ++--
 src/providers/ldap/sdap_access.c              |  9 +++++----
 src/providers/ldap/sdap_async_autofs.c        |  8 ++++----
 src/providers/ldap/sdap_async_groups.c        | 19 +++++++++++--------
 src/providers/ldap/sdap_async_groups_ad.c     |  2 +-
 src/providers/ldap/sdap_async_initgroups.c    | 17 ++++++++++-------
 src/providers/ldap/sdap_async_initgroups_ad.c |  2 +-
 src/providers/ldap/sdap_async_nested_groups.c |  2 +-
 src/providers/ldap/sdap_async_netgroups.c     | 10 ++++++----
 src/providers/ldap/sdap_async_services.c      |  8 ++++----
 src/providers/ldap/sdap_async_sudo.c          |  2 +-
 src/providers/ldap/sdap_async_users.c         |  5 +++--
 src/providers/ldap/sdap_child_helpers.c       |  2 +-
 src/providers/simple/simple_access_check.c    |  4 ++--
 src/responder/nss/nsssrv_mmap_cache.c         |  2 +-
 src/responder/pam/pamsrv_cmd.c                |  2 +-
 src/util/child_common.c                       |  2 +-
 33 files changed, 82 insertions(+), 69 deletions(-)

diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
index cc44c350b744fc01f3a081c4a3de57b879a2693a..cb9685623c34ca4330b6e0278a3e7a4300f6b26d 100644
--- a/src/db/sysdb_autofs.c
+++ b/src/db/sysdb_autofs.c
@@ -407,7 +407,7 @@ sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
     *_count = count;
     *_entries = talloc_steal(mem_ctx, msgs);
     ret = EOK;
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("found %d entries for map %s\n",
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("found %zu entries for map %s\n",
                                    count, mapname));
 done:
     talloc_free(tmp_ctx);
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 45f3289b702d0492c3cbddd7063f2845afa3de00..439a0cd55d6ac847efd51e6f6d41a8847ef0e32a 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -175,7 +175,7 @@ int sysdb_delete_recursive(struct sysdb_ctx *sysdb,
         goto done;
     }
 
-    DEBUG(9, ("Found [%d] items to delete.\n", msgs_count));
+    DEBUG(SSSDBG_TRACE_ALL, ("Found [%zu] items to delete.\n", msgs_count));
 
     qsort(msgs, msgs_count,
           sizeof(struct ldb_message *), compare_ldb_dn_comp_num);
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index d70d0cc3eee6fe5fa55bee6a36d4e8382d69c3ab..8dfaf1f2ada22db5e70ebe18bee1ee299e4767dd 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -972,7 +972,7 @@ errno_t sysdb_get_direct_parents(TALLOC_CTX *mem_ctx,
     }
     direct_parents[pi] = NULL;
 
-    DEBUG(7, ("%s is a member of %d sysdb groups\n",
+    DEBUG(SSSDBG_TRACE_LIBS, ("%s is a member of %zu sysdb groups\n",
               name, direct_sysdb_count));
     *_direct_parents = talloc_steal(mem_ctx, direct_parents);
     ret = EOK;
diff --git a/src/providers/ad/ad_srv.c b/src/providers/ad/ad_srv.c
index 4ae91f07bfbaafcb12caf82d3e3847f111cdf9fc..dc310020a4e37d199bd047bfcdeb3e40af2d4d84 100644
--- a/src/providers/ad/ad_srv.c
+++ b/src/providers/ad/ad_srv.c
@@ -113,7 +113,7 @@ static void ad_get_dc_servers_done(struct tevent_req *subreq)
         goto done;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Found %lu domain controllers in domain %s\n",
+    DEBUG(SSSDBG_TRACE_FUNC, ("Found %zu domain controllers in domain %s\n",
                               state->num_servers, domain));
 
 done:
@@ -759,7 +759,7 @@ static void ad_srv_plugin_servers_done(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Got %lu primary and %lu backup servers\n",
+    DEBUG(SSSDBG_TRACE_FUNC, ("Got %zu primary and %zu backup servers\n",
           state->num_primary_servers, state->num_backup_servers));
 
     tevent_req_done(req);
diff --git a/src/providers/fail_over_srv.c b/src/providers/fail_over_srv.c
index 189abf14b87bb9475db2fb2049edcb48fb2f47bc..0523e0fa1ca8d6f7c1ab0c5c9771415a3414a3c7 100644
--- a/src/providers/fail_over_srv.c
+++ b/src/providers/fail_over_srv.c
@@ -110,7 +110,7 @@ static void fo_discover_srv_done(struct tevent_req *subreq)
         state->num_servers++;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Got %lu servers\n", state->num_servers));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Got %zu servers\n", state->num_servers));
 
     state->servers = talloc_array(state, struct fo_server_info,
                                   state->num_servers);
diff --git a/src/providers/ipa/ipa_config.c b/src/providers/ipa/ipa_config.c
index 05231cc763c28c2867688530a6d4c17d2fd30933..0b392f5129ce895af2c0ca88286981a79cc5f4bc 100644
--- a/src/providers/ipa/ipa_config.c
+++ b/src/providers/ipa/ipa_config.c
@@ -125,7 +125,7 @@ static void ipa_get_config_done(struct tevent_req *subreq)
 
     if (reply_count != 1) {
         DEBUG(SSSDBG_OP_FAILURE, ("Unexpected number of results, expected 1, "
-                                  "got %d.\n", reply_count));
+                                  "got %zu.\n", reply_count));
         ret = EINVAL;
         goto done;
     }
diff --git a/src/providers/ipa/ipa_idmap.c b/src/providers/ipa/ipa_idmap.c
index c108ca75b84005c3d5957cd45ca89209d59f59ff..69ab55c92fcd274836b36d68ec08ac3b67b53685 100644
--- a/src/providers/ipa/ipa_idmap.c
+++ b/src/providers/ipa/ipa_idmap.c
@@ -194,7 +194,7 @@ errno_t ipa_idmap_init(TALLOC_CTX *mem_ctx,
     }
 
     DEBUG(SSSDBG_CONF_SETTINGS,
-          ("Initializing [%d] domains for ID-mapping\n", range_count));
+          ("Initializing [%zu] domains for ID-mapping\n", range_count));
 
     for (c = 0; c < range_count; c++) {
 
diff --git a/src/providers/ipa/ipa_netgroups.c b/src/providers/ipa/ipa_netgroups.c
index 0f36fc9f542f7b58ebb45664edc0e964ad2f92ff..0deb3944ef93ae1c1175f9e1c5526274cc849986 100644
--- a/src/providers/ipa/ipa_netgroups.c
+++ b/src/providers/ipa/ipa_netgroups.c
@@ -315,7 +315,8 @@ static void ipa_get_netgroups_process(struct tevent_req *subreq)
         goto done;
     }
 
-    DEBUG(6, ("Search for netgroups, returned %d results.\n", netgroups_count));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Search for netgroups, returned %zu results.\n",
+                              netgroups_count));
 
     if (netgroups_count == 0) {
         /* No netgroups found in this search */
@@ -575,7 +576,8 @@ static void ipa_netgr_members_process(struct tevent_req *subreq)
         goto fail;
     }
 
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("Found %u members in current search base\n", count));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("Found %zu members in current search base\n",
+                                  count));
 
     next_call = NULL;
     /* While processing a batch of entities from one search base,
diff --git a/src/providers/ipa/ipa_selinux.c b/src/providers/ipa/ipa_selinux.c
index 5f734338b8fb43d6d99ba9adcb25c655f8cb1951..c227db937a84228c0f3945dbe11ba904c7ad9744 100644
--- a/src/providers/ipa/ipa_selinux.c
+++ b/src/providers/ipa/ipa_selinux.c
@@ -1163,7 +1163,7 @@ static void ipa_get_selinux_maps_done(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_FUNC,
-         ("Found %d SELinux user maps\n", state->nmaps));
+         ("Found %zu SELinux user maps\n", state->nmaps));
 
     check_hbac = false;
     for (i = 0; i < state->nmaps; i++) {
@@ -1222,7 +1222,7 @@ static void ipa_get_selinux_hbac_done(struct tevent_req *subreq)
     ret = ipa_hbac_rule_info_recv(subreq, state, &state->hbac_rule_count,
                                   &state->hbac_rules);
     DEBUG(SSSDBG_TRACE_INTERNAL,
-          ("Received %d HBAC rules\n", state->hbac_rule_count));
+          ("Received %zu HBAC rules\n", state->hbac_rule_count));
     talloc_free(subreq);
 
     if (ret != EOK) {
diff --git a/src/providers/ipa/ipa_selinux_maps.c b/src/providers/ipa/ipa_selinux_maps.c
index b0a2c8f727be2af0a4eb878f4b5b56a7b0ef11bd..1a210689b17b674158420c48ead7e9011cc35764 100644
--- a/src/providers/ipa/ipa_selinux_maps.c
+++ b/src/providers/ipa/ipa_selinux_maps.c
@@ -165,8 +165,8 @@ static void ipa_selinux_get_maps_done(struct tevent_req *subreq)
     }
 
     if (count > 0) {
-        DEBUG(SSSDBG_TRACE_FUNC, ("Found %d user maps in current search base\n",
-                                  count));
+        DEBUG(SSSDBG_TRACE_FUNC,
+              ("Found %zu user maps in current search base\n", count));
 
         total_count = count + state->map_count;
         state->maps = talloc_realloc(state, state->maps, struct sysdb_attrs *, total_count);
diff --git a/src/providers/ipa/ipa_srv.c b/src/providers/ipa/ipa_srv.c
index d604871a277574c93e2c7adf59cf6fa5065c89b7..aa07cf0542d294118728c7706bbfa50092d43b3b 100644
--- a/src/providers/ipa/ipa_srv.c
+++ b/src/providers/ipa/ipa_srv.c
@@ -173,7 +173,7 @@ static void ipa_srv_plugin_done(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Got %lu primary and %lu backup servers\n",
+    DEBUG(SSSDBG_TRACE_FUNC, ("Got %zu primary and %zu backup servers\n",
           state->num_primary_servers, state->num_backup_servers));
 
     tevent_req_done(req);
diff --git a/src/providers/ipa/ipa_subdomains_ext_groups.c b/src/providers/ipa/ipa_subdomains_ext_groups.c
index 0244fee99a709cabe2ca7ee76206f3c94718400d..cd098cde04c7739a58b4e6a583eaae44be5f49b1 100644
--- a/src/providers/ipa/ipa_subdomains_ext_groups.c
+++ b/src/providers/ipa/ipa_subdomains_ext_groups.c
@@ -594,7 +594,7 @@ static void ipa_get_ext_groups_done(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("[%d] external groups found.\n",
+    DEBUG(SSSDBG_TRACE_FUNC, ("[%zu] external groups found.\n",
                               state->reply_count));
 
     ret = process_ext_groups(state->server_mode->ext_groups,
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index afd39b854786cb8081f050b85dcc0e9be5f23d1e..e69f5e35d517a00c101b3499dae8bee5e75c5bdb 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -887,7 +887,7 @@ static errno_t pack_response_packet(TALLOC_CTX *mem_ctx, errno_t error,
         safealign_memcpy(&buf[p], pdr->data, pdr->len, &p);
     }
 
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("response packet size: [%d]\n", p));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("response packet size: [%zu]\n", p));
 
     *_buf = buf;
     *_len = p;
@@ -941,7 +941,7 @@ static errno_t k5c_send_data(struct krb5_req *kr, int fd, errno_t error)
 
     if (written != len) {
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("Write error, wrote [%d] bytes, expected [%d]\n",
+              ("Write error, wrote [%zu] bytes, expected [%zu]\n",
                written, len));
         return EOK;
     }
@@ -1705,7 +1705,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
     struct pam_data *pd;
     errno_t ret;
 
-    DEBUG(SSSDBG_TRACE_LIBS, ("total buffer size: [%d]\n", size));
+    DEBUG(SSSDBG_TRACE_LIBS, ("total buffer size: [%zu]\n", size));
 
     if (!offline || !kr) return EINVAL;
 
diff --git a/src/providers/krb5/krb5_child_handler.c b/src/providers/krb5/krb5_child_handler.c
index 20b83d1372fdf0026b36a4b9877673d3dce25ddd..9aa5c346acde17e1ea74d7a2ab231a6a9eebdb94 100644
--- a/src/providers/krb5/krb5_child_handler.c
+++ b/src/providers/krb5/krb5_child_handler.c
@@ -538,7 +538,7 @@ parse_krb5_child_response(TALLOC_CTX *mem_ctx, uint8_t *buf, ssize_t len,
               msg_status, msg_type, msg_len));
 
         if ((p + msg_len) > len) {
-            DEBUG(SSSDBG_CRIT_FAILURE, ("message format error [%d] > [%zd].\n",
+            DEBUG(SSSDBG_CRIT_FAILURE, ("message format error [%zu] > [%zd].\n",
                   p+msg_len, len));
             return EINVAL;
         }
diff --git a/src/providers/krb5/krb5_renew_tgt.c b/src/providers/krb5/krb5_renew_tgt.c
index d6cdff8f8c0efc98445363c0a12a7ec19d12477f..9102f8ca37668abbcef99b78e8c042ebab32025f 100644
--- a/src/providers/krb5/krb5_renew_tgt.c
+++ b/src/providers/krb5/krb5_renew_tgt.c
@@ -412,7 +412,8 @@ static errno_t check_ccache_files(struct renew_tgt_ctx *renew_tgt_ctx)
         ret = EOK;
         goto done;
     }
-    DEBUG(9, ("Found [%d] entries with ccache file in cache.\n", msgs_count));
+    DEBUG(SSSDBG_TRACE_ALL,
+          ("Found [%zu] entries with ccache file in cache.\n", msgs_count));
 
     for (c = 0; c < msgs_count; c++) {
         user_name = ldb_msg_find_attr_as_string(msgs[c], SYSDB_NAME, NULL);
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
index 9d82e7cf7c7a556c0e9f124c60a90170e21135b3..19c838dacc10bfa0428d96e2d8497d4b25b07079 100644
--- a/src/providers/ldap/ldap_child.c
+++ b/src/providers/ldap/ldap_child.c
@@ -57,7 +57,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
     size_t p = 0;
     uint32_t len;
 
-    DEBUG(SSSDBG_TRACE_LIBS, ("total buffer size: %d\n", size));
+    DEBUG(SSSDBG_TRACE_LIBS, ("total buffer size: %zu\n", size));
 
     /* realm_str size and length */
     SAFEALIGN_COPY_UINT32_CHECK(&len, buf + p, size, &p);
@@ -112,7 +112,7 @@ static int pack_buffer(struct response *r, int result, krb5_error_code krberr,
     r->size = 2 * sizeof(uint32_t) + sizeof(krb5_error_code) +
               len + sizeof(time_t);
 
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("response size: %d\n",r->size));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("response size: %zu\n",r->size));
 
     r->buf = talloc_array(r, uint8_t, r->size);
     if(!r->buf) {
@@ -540,7 +540,7 @@ int main(int argc, const char *argv[])
     }
 
     if (written != resp->size) {
-        DEBUG(SSSDBG_CRIT_FAILURE, ("Expected to write %d bytes, wrote %d\n",
+        DEBUG(SSSDBG_CRIT_FAILURE, ("Expected to write %zu bytes, wrote %zu\n",
               resp->size, written));
         goto fail;
     }
diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c
index 1fd2ff49fe7e80fc9856eb7fadb9017145fb4b45..c13d1714287645f0e168e25d5ef2e86e3116c7f6 100644
--- a/src/providers/ldap/ldap_id_cleanup.c
+++ b/src/providers/ldap/ldap_id_cleanup.c
@@ -226,7 +226,7 @@ static int cleanup_users(struct sdap_options *opts,
         goto done;
     }
 
-    DEBUG(4, ("Found %d expired user entries!\n", count));
+    DEBUG(SSSDBG_FUNC_DATA, ("Found %zu expired user entries!\n", count));
 
     if (count == 0) {
         ret = EOK;
@@ -348,7 +348,7 @@ static int cleanup_groups(TALLOC_CTX *memctx,
         goto done;
     }
 
-    DEBUG(4, ("Found %d expired group entries!\n", count));
+    DEBUG(SSSDBG_FUNC_DATA, ("Found %zu expired group entries!\n", count));
 
     if (count == 0) {
         ret = EOK;
diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c
index b381fc40570fb1fabe88255a6543c06453a7d9ce..9ea9077551b71d494947c7bfd7477ac8ddf227a2 100644
--- a/src/providers/ldap/sdap_access.c
+++ b/src/providers/ldap/sdap_access.c
@@ -464,8 +464,9 @@ static bool nds_check_time_map(const struct ldb_val *time_map)
     }
 
     if (time_map->length != 42) {
-        DEBUG(4, ("Allowed time map has the wrong size, "
-                  "got [%d], expected 42.\n", time_map->length));
+        DEBUG(SSSDBG_FUNC_DATA,
+              ("Allowed time map has the wrong size, "
+               "got [%zu], expected 42.\n", time_map->length));
         return true;
     }
 
@@ -477,7 +478,7 @@ static bool nds_check_time_map(const struct ldb_val *time_map)
 
     if (map_index > 335) {
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("Unexpected index value [%d] for time map.\n", map_index));
+              ("Unexpected index value [%zu] for time map.\n", map_index));
         return true;
     }
 
@@ -485,7 +486,7 @@ static bool nds_check_time_map(const struct ldb_val *time_map)
 
     if (q.quot > 41 || q.quot < 0 || q.rem > 7 || q.rem < 0) {
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("Unexpected result of div(), [%d][%d][%d].\n",
+              ("Unexpected result of div(), [%zu][%d][%d].\n",
                map_index, q.quot, q.rem));
         return true;
     }
diff --git a/src/providers/ldap/sdap_async_autofs.c b/src/providers/ldap/sdap_async_autofs.c
index ae70e703564acebaa1ca9adfb2395ca1c06fd802..4886150f92ec08ee82f9736a7b0cfd52bea7ff91 100644
--- a/src/providers/ldap/sdap_async_autofs.c
+++ b/src/providers/ldap/sdap_async_autofs.c
@@ -394,7 +394,7 @@ automntmaps_process_members_done(struct tevent_req *subreq)
     DEBUG(SSSDBG_TRACE_INTERNAL, ("No more search bases to try\n"));
 
     DEBUG(SSSDBG_TRACE_FUNC,
-          ("Search for autofs entries, returned %d results.\n",
+          ("Search for autofs entries, returned %zu results.\n",
           state->entries_count));
 
     tevent_req_done(req);
@@ -549,7 +549,7 @@ sdap_get_automntmap_process(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_FUNC,
-          ("Search for autofs maps, returned %d results.\n", state->count));
+          ("Search for autofs maps, returned %zu results.\n", state->count));
 
     if (state->count == 0) {
         /* No maps found in this search */
@@ -801,7 +801,7 @@ sdap_autofs_setautomntent_save(struct tevent_req *req)
     if (!tmp_ctx) return ENOMEM;
 
     DEBUG(SSSDBG_TRACE_LIBS,
-          ("Got %d map entries from LDAP\n", state->entries_count));
+          ("Got %zu map entries from LDAP\n", state->entries_count));
     if (state->entries_count == 0) {
         /* No entries for this map in LDAP.
          * We need to ensure that there are no entries
@@ -866,7 +866,7 @@ sdap_autofs_setautomntent_save(struct tevent_req *req)
         goto done;
     }
 
-    DEBUG(SSSDBG_TRACE_LIBS, ("Got %d map entries from sysdb\n", count));
+    DEBUG(SSSDBG_TRACE_LIBS, ("Got %zu map entries from sysdb\n", count));
     if (count == 0) {
         /* No map members for this map in sysdb currently */
         sysdb_entrylist = NULL;
diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index bec27e0a7c7101f5a31c45cc0056b1c9ee2667cf..2ce1d5dd6020ca7b81ab0d09ddd28412fe6dc555 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -377,7 +377,7 @@ sdap_process_ghost_members(struct sysdb_attrs *attrs,
     ghostel->num_values = gh->num_values;
 
     cnt = ghostel->num_values + memberel->num_values;
-    DEBUG(SSSDBG_TRACE_FUNC, ("Group has %d members\n", cnt));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Group has %zu members\n", cnt));
 
     /* Now process RFC2307bis ghost hash table */
     if (ghosts && cnt > 0) {
@@ -1072,8 +1072,9 @@ sdap_process_missing_member_2307bis(struct tevent_req *req,
     if (grp_state->check_count > GROUPMEMBER_REQ_PARALLEL) {
         DEBUG(7, (" queueing search for: %s\n", user_dn));
         if (!grp_state->queued_members) {
-            DEBUG(7, ("Allocating queue for %d members\n",
-                      num_users - grp_state->check_count));
+            DEBUG(SSSDBG_TRACE_LIBS,
+                  ("Allocating queue for %zu members\n",
+                   num_users - grp_state->check_count));
 
             grp_state->queued_members = talloc_array(grp_state, char *,
                     num_users - grp_state->check_count + 1);
@@ -1349,7 +1350,7 @@ static void sdap_process_group_members(struct tevent_req *subreq)
     uint8_t* name_string;
 
     state->check_count--;
-    DEBUG(9, ("Members remaining: %d\n", state->check_count));
+    DEBUG(SSSDBG_TRACE_ALL, ("Members remaining: %zu\n", state->check_count));
 
     ret = sdap_get_generic_recv(subreq, state, &count, &usr_attrs);
     talloc_zfree(subreq);
@@ -1358,7 +1359,8 @@ static void sdap_process_group_members(struct tevent_req *subreq)
     }
     if (count != 1) {
         ret = EINVAL;
-        DEBUG(7, ("Expected one user entry and got %d\n", count));
+        DEBUG(SSSDBG_TRACE_LIBS,
+              ("Expected one user entry and got %zu\n", count));
         goto next;
     }
     ret = sysdb_attrs_get_el(usr_attrs[0],
@@ -1584,7 +1586,8 @@ static void sdap_get_groups_process(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(6, ("Search for groups, returned %d results.\n", count));
+    DEBUG(SSSDBG_TRACE_FUNC,
+          ("Search for groups, returned %zu results.\n", count));
 
     if (!state->enumeration && count > 1) {
         DEBUG(SSSDBG_MINOR_FAILURE,
@@ -1747,7 +1750,7 @@ static void sdap_get_groups_done(struct tevent_req *subreq)
     }
 
     state->check_count--;
-    DEBUG(9, ("Groups remaining: %d\n", state->check_count));
+    DEBUG(SSSDBG_TRACE_ALL, ("Groups remaining: %zu\n", state->check_count));
 
 
     if (state->check_count == 0) {
@@ -1765,7 +1768,7 @@ static void sdap_get_groups_done(struct tevent_req *subreq)
             tevent_req_error(req, ret);
             return;
         }
-        DEBUG(9, ("Saving %d Groups - Done\n", state->count));
+        DEBUG(SSSDBG_TRACE_ALL, ("Saving %zu Groups - Done\n", state->count));
         sysret = sysdb_transaction_commit(state->sysdb);
         if (sysret != EOK) {
             DEBUG(0, ("Couldn't commit transaction\n"));
diff --git a/src/providers/ldap/sdap_async_groups_ad.c b/src/providers/ldap/sdap_async_groups_ad.c
index 1268f7e7de30849d1948265e50a327501982749d..9b61c697d5789c3ec3467ec52a7171f6a640ce9e 100644
--- a/src/providers/ldap/sdap_async_groups_ad.c
+++ b/src/providers/ldap/sdap_async_groups_ad.c
@@ -189,7 +189,7 @@ sdap_get_ad_match_rule_members_step(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_LIBS,
-          ("Search for users returned %d results\n", count));
+          ("Search for users returned %zu results\n", count));
 
     /* Add this batch of users to the list */
     if (count > 0) {
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index aa0ea4c1b28fa2a69390605d3fff3cfff1642aa1..a0df82ca54c89f1df0e301d4e0bae439c97f20f7 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -954,8 +954,9 @@ static void sdap_initgr_nested_search(struct tevent_req *subreq)
                                                         groups[0]);
         state->groups_cur++;
     } else {
-        DEBUG(2, ("Search for group %s, returned %d results. Skipping\n",
-                  state->group_dns[state->cur], count));
+        DEBUG(SSSDBG_OP_FAILURE,
+              ("Search for group %s, returned %zu results. Skipping\n",
+               state->group_dns[state->cur], count));
     }
 
     state->cur++;
@@ -1619,7 +1620,7 @@ static void sdap_initgr_rfc2307bis_process(struct tevent_req *subreq)
         return;
     }
     DEBUG(SSSDBG_TRACE_LIBS,
-          ("Found %d parent groups for user [%s]\n", count, state->name));
+          ("Found %zu parent groups for user [%s]\n", count, state->name));
 
     /* Add this batch of groups to the list */
     if (count > 0) {
@@ -2128,7 +2129,8 @@ struct tevent_req *rfc2307bis_nested_groups_send(
     struct sdap_rfc2307bis_nested_ctx *state;
 
     DEBUG(SSSDBG_TRACE_INTERNAL,
-          ("About to process %d groups in nesting level %d\n", num_groups, nesting));
+          ("About to process %zu groups in nesting level %zu\n",
+           num_groups, nesting));
 
     req = tevent_req_create(mem_ctx, &state,
                             struct sdap_rfc2307bis_nested_ctx);
@@ -2376,7 +2378,7 @@ static void rfc2307bis_nested_groups_process(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_LIBS,
-          ("Found %d parent groups of [%s]\n", count, state->orig_dn));
+          ("Found %zu parent groups of [%s]\n", count, state->orig_dn));
     ngr = state->processed_groups[state->group_iter];
 
     /* Add this batch of groups to the list */
@@ -2405,7 +2407,7 @@ static void rfc2307bis_nested_groups_process(struct tevent_req *subreq)
 
         ngr->ldap_parents[ngr->parents_count] = NULL;
         DEBUG(SSSDBG_TRACE_INTERNAL,
-              ("Total of %d direct parents after this iteration\n",
+              ("Total of %zu direct parents after this iteration\n",
                ngr->parents_count));
     }
 
@@ -2727,7 +2729,8 @@ static void sdap_get_initgr_user(struct tevent_req *subreq)
             return;
         }
     } else if (count != 1) {
-        DEBUG(2, ("Expected one user entry and got %d\n", count));
+        DEBUG(SSSDBG_OP_FAILURE,
+              ("Expected one user entry and got %zu\n", count));
         tevent_req_error(req, EINVAL);
         return;
     }
diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
index e5649a2b9793253a55c48fba69cd3a902c0dc967..efaa247dd22d2ae100e8881c010dfe26a9a10cca 100644
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
@@ -212,7 +212,7 @@ sdap_get_ad_match_rule_initgroups_step(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_LIBS,
-          ("Search for users returned %d results\n", count));
+          ("Search for users returned %zu results\n", count));
 
     /* Add this batch of groups to the list */
     if (count > 0) {
diff --git a/src/providers/ldap/sdap_async_nested_groups.c b/src/providers/ldap/sdap_async_nested_groups.c
index 0147a607f75302ce1d05c1385d717156c7a3184e..6e7056618d801f84a706c06cefd9a9854b469222 100644
--- a/src/providers/ldap/sdap_async_nested_groups.c
+++ b/src/providers/ldap/sdap_async_nested_groups.c
@@ -2036,7 +2036,7 @@ sdap_nested_group_deref_direct_process(struct tevent_req *subreq)
         goto done;
     }
 
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("Received %d dereference results, "
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("Received %zu dereference results, "
           "about to process them\n", num_entries));
 
     /*
diff --git a/src/providers/ldap/sdap_async_netgroups.c b/src/providers/ldap/sdap_async_netgroups.c
index 265fcf0ea8d3ac3a743433ce234a5faf8a673c61..46ea980677234c682bd48c371b62b90a2666ab87 100644
--- a/src/providers/ldap/sdap_async_netgroups.c
+++ b/src/providers/ldap/sdap_async_netgroups.c
@@ -490,8 +490,9 @@ static void netgr_translate_members_ldap_done(struct tevent_req *subreq)
             }
             break;
         default:
-            DEBUG(1, ("Unexpected number of results [%d] for base search.\n",
-                      count));
+            DEBUG(SSSDBG_CRIT_FAILURE,
+                  ("Unexpected number of results [%zu] for base search.\n",
+                   count));
     }
 
     if (state->dn_item->cn == NULL) {
@@ -659,7 +660,8 @@ static void sdap_get_netgroups_process(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(6, ("Search for netgroups, returned %d results.\n", state->count));
+    DEBUG(SSSDBG_TRACE_FUNC,
+          ("Search for netgroups, returned %zu results.\n", state->count));
 
     if (state->count == 0) {
         /* No netgroups found in this search */
@@ -723,7 +725,7 @@ static void netgr_translate_members_done(struct tevent_req *subreq)
         }
     }
 
-    DEBUG(9, ("Saving %d Netgroups - Done\n", state->count));
+    DEBUG(SSSDBG_TRACE_ALL, ("Saving %zu Netgroups - Done\n", state->count));
 
     tevent_req_done(req);
 }
diff --git a/src/providers/ldap/sdap_async_services.c b/src/providers/ldap/sdap_async_services.c
index d637d22e59a68a0957ce01f92ddb99ee8d111f5f..c4245f0574200bca5d3c5770eeefb5b03445393c 100644
--- a/src/providers/ldap/sdap_async_services.c
+++ b/src/providers/ldap/sdap_async_services.c
@@ -177,7 +177,7 @@ sdap_get_services_process(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_FUNC,
-          ("Search for services, returned %d results.\n",
+          ("Search for services, returned %zu results.\n",
            count));
 
     if (state->enumeration || count == 0) {
@@ -240,7 +240,7 @@ sdap_get_services_process(struct tevent_req *subreq)
     }
 
     DEBUG(SSSDBG_TRACE_INTERNAL,
-          ("Saving %d services - Done\n", state->count));
+          ("Saving %zu services - Done\n", state->count));
 
     tevent_req_done(req);
 }
@@ -292,10 +292,10 @@ sdap_save_services(TALLOC_CTX *mem_ctx,
          * Just report the failure to save and go on */
         if (ret) {
             DEBUG(SSSDBG_MINOR_FAILURE,
-                  ("Failed to store service %d. Ignoring.\n", i));
+                  ("Failed to store service %zu. Ignoring.\n", i));
         } else {
             DEBUG(SSSDBG_TRACE_INTERNAL,
-                  ("Service [%lu/%lu] processed!\n", i, num_services));
+                  ("Service [%zu/%zu] processed!\n", i, num_services));
         }
 
         if (usn_value) {
diff --git a/src/providers/ldap/sdap_async_sudo.c b/src/providers/ldap/sdap_async_sudo.c
index ed4cf75ad5e38df3b955f5fe061a8b188fe89927..0d4882bd119dd4d4d217163f97cad275921adf8d 100644
--- a/src/providers/ldap/sdap_async_sudo.c
+++ b/src/providers/ldap/sdap_async_sudo.c
@@ -477,7 +477,7 @@ static void sdap_sudo_refresh_load_done(struct tevent_req *subreq)
         goto done;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Received %d rules\n", rules_count));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Received %zu rules\n", rules_count));
 
     /* start transaction */
     ret = sysdb_transaction_start(state->sysdb);
diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c
index 353dc3992f4124187daeb90419d010253a00f63f..860e8feaf1bfcc99ce0640be417acc2bbf563887 100644
--- a/src/providers/ldap/sdap_async_users.c
+++ b/src/providers/ldap/sdap_async_users.c
@@ -697,7 +697,8 @@ static void sdap_get_users_process(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(6, ("Search for users, returned %d results.\n", count));
+    DEBUG(SSSDBG_TRACE_FUNC,
+          ("Search for users, returned %zu results.\n", count));
 
     if (state->enumeration || count == 0) {
         /* No users found in this search or enumerating */
@@ -758,7 +759,7 @@ static void sdap_get_users_process(struct tevent_req *subreq)
         return;
     }
 
-    DEBUG(9, ("Saving %d Users - Done\n", state->count));
+    DEBUG(SSSDBG_TRACE_ALL, ("Saving %zu Users - Done\n", state->count));
 
     tevent_req_done(req);
 }
diff --git a/src/providers/ldap/sdap_child_helpers.c b/src/providers/ldap/sdap_child_helpers.c
index e57313442fec1723e3cbcc186d9720b7e9a6ce89..9aaff785b789139dee033ecf73d1f74917d9a94c 100644
--- a/src/providers/ldap/sdap_child_helpers.c
+++ b/src/providers/ldap/sdap_child_helpers.c
@@ -160,7 +160,7 @@ static errno_t create_tgt_req_send_buffer(TALLOC_CTX *mem_ctx,
         buf->size += strlen(keytab_name);
     }
 
-    DEBUG(7, ("buffer size: %d\n", buf->size));
+    DEBUG(SSSDBG_TRACE_FUNC, ("buffer size: %zu\n", buf->size));
 
     buf->data = talloc_size(buf, buf->size);
     if (buf->data == NULL) {
diff --git a/src/providers/simple/simple_access_check.c b/src/providers/simple/simple_access_check.c
index dc5f3676484c3748186cbe69fd4260ee329568a6..7335135ea5dedecdb5ba2be60a57d18eb897a960 100644
--- a/src/providers/simple/simple_access_check.c
+++ b/src/providers/simple/simple_access_check.c
@@ -389,7 +389,7 @@ simple_check_get_groups_send(TALLOC_CTX *mem_ctx,
     }
 
     DEBUG(SSSDBG_TRACE_FUNC,
-          ("User %s is a member of %d supplemental groups\n",
+          ("User %s is a member of %zu supplemental groups\n",
            username, group_count));
 
     /* One extra space for terminator, one extra space for private group */
@@ -435,7 +435,7 @@ simple_check_get_groups_send(TALLOC_CTX *mem_ctx,
         goto done;
     }
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Need to resolve %d groups\n", state->num_gids));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Need to resolve %zu groups\n", state->num_gids));
     state->giter = 0;
     subreq = simple_resolve_group_send(req, state->ev, state->ctx,
                                        state->lookup_gids[state->giter]);
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
index 84570ac204b12a561a337ba9f3fd1ce9d104feaf..2b3dc37eac13cb23fbd9348c0642333d0bba6708 100644
--- a/src/responder/nss/nsssrv_mmap_cache.c
+++ b/src/responder/nss/nsssrv_mmap_cache.c
@@ -1205,7 +1205,7 @@ errno_t sss_mmap_cache_init(TALLOC_CTX *mem_ctx, const char *name,
                              MAP_SHARED, mc_ctx->fd, 0);
     if (mc_ctx->mmap_base == MAP_FAILED) {
         ret = errno;
-        DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to mmap file %s(%ld): %d(%s)\n",
+        DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to mmap file %s(%zu): %d(%s)\n",
                                     mc_ctx->file, mc_ctx->mmap_size,
                                     ret, strerror(ret)));
         goto done;
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index 085bd8869b34de9aa6782618dc76dcaec8e74139..32efc4ba85d0f29dd3a52fc2d217c079ec480b2d 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -610,7 +610,7 @@ static void pam_reply(struct pam_auth_req *preq)
     }
 
     sss_packet_get_body(cctx->creq->out, &body, &blen);
-    DEBUG(4, ("blen: %d\n", blen));
+    DEBUG(SSSDBG_FUNC_DATA, ("blen: %zu\n", blen));
     p = 0;
 
     memcpy(&body[p], &pd->pam_status, sizeof(int32_t));
diff --git a/src/util/child_common.c b/src/util/child_common.c
index 28358606b0ba8b5fa6a28450f3111b68f8668fbf..55b3672f4ec948c9c832b4af0a9b5a61519091eb 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -382,7 +382,7 @@ static void write_pipe_handler(struct tevent_context *ev,
     }
 
     if (state->len != state->written) {
-        DEBUG(SSSDBG_CRIT_FAILURE, ("Wrote %d bytes, expected %d\n",
+        DEBUG(SSSDBG_CRIT_FAILURE, ("Wrote %zu bytes, expected %zu\n",
               state->written, state->len));
         tevent_req_error(req, EIO);
         return;
-- 
1.8.3.1

-------------- next part --------------
>From 80b0a73f4dbdc94f5363f24257235c3edc75b1ec Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 18 Jul 2013 08:52:15 +0200
Subject: [PATCH 08/20] Adding new header for printf formating macros

---
 Makefile.am           |  1 +
 src/util/sss_format.h | 32 ++++++++++++++++++++++++++++++++
 src/util/util.h       |  1 +
 3 files changed, 34 insertions(+)
 create mode 100644 src/util/sss_format.h

diff --git a/Makefile.am b/Makefile.am
index b913a12b895d68f1f3e23c185e493e576641d0e2..67cd575c42443c1d7f9fdbfc919e14a3d5638b08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -395,6 +395,7 @@ dist_noinst_HEADERS = \
     src/util/sss_utf8.h \
     src/util/sss_ssh.h \
     src/util/sss_ini.h \
+    src/util/sss_format.h \
     src/util/refcount.h \
     src/util/find_uid.h \
     src/util/user_info_msg.h \
diff --git a/src/util/sss_format.h b/src/util/sss_format.h
new file mode 100644
index 0000000000000000000000000000000000000000..db1a5051ff99171f84f53f10a1e9bc4726dde843
--- /dev/null
+++ b/src/util/sss_format.h
@@ -0,0 +1,32 @@
+/*
+    SSSD
+
+    sss_format.h
+
+    Authors:
+        Lukas Slebodnik <lslebodn at redhat.com>
+
+    Copyright (C) 2013 Red Hat
+
+
+    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 __SSS_FORMAT_H__
+#define __SSS_FORMAT_H__
+
+#include <inttypes.h>
+
+#endif /* __SSS_FORMAT_H__ */
diff --git a/src/util/util.h b/src/util/util.h
index 74fa2235747efc3490d14a543e18b48067cf3f71..4cd96b1bfa6fa2d1090a3a8e7b2c13c309e5c785 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -47,6 +47,7 @@
 #include "util/atomic_io.h"
 #include "util/util_errors.h"
 #include "util/util_safealign.h"
+#include "util/sss_format.h"
 
 #define _(STRING) gettext (STRING)
 
-- 
1.8.3.1

-------------- next part --------------
>From 40059d8491a0f1d8e165d1a15688397540f97a64 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 16:40:26 +0200
Subject: [PATCH 09/20] Fix formating of variables with type: key_serial_t

---
 src/providers/krb5/krb5_delayed_online_authentication.c | 3 ++-
 src/util/sss_format.h                                   | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/providers/krb5/krb5_delayed_online_authentication.c b/src/providers/krb5/krb5_delayed_online_authentication.c
index 87e0f3c631def0d437aa4268e8a3cfcb439be7e0..533127913bf92f2c2b3f2208ebf94dc30df09029 100644
--- a/src/providers/krb5/krb5_delayed_online_authentication.c
+++ b/src/providers/krb5/krb5_delayed_online_authentication.c
@@ -279,7 +279,8 @@ errno_t add_user_to_delayed_online_authentication(struct krb5_ctx *krb5_ctx,
         talloc_free(new_pd);
         return ret;
     }
-    DEBUG(9, ("Saved authtok of user [%s] with serial [%ld].\n",
+    DEBUG(SSSDBG_TRACE_ALL,
+          ("Saved authtok of user [%s] with serial [%"PRIkey_ser"].\n",
               new_pd->user, new_pd->key_serial));
     sss_authtok_set_empty(new_pd->authtok);
 #endif
diff --git a/src/util/sss_format.h b/src/util/sss_format.h
index db1a5051ff99171f84f53f10a1e9bc4726dde843..c9837a6e9d2f950d6d1f12d7727d43ca4b18f62e 100644
--- a/src/util/sss_format.h
+++ b/src/util/sss_format.h
@@ -29,4 +29,7 @@
 
 #include <inttypes.h>
 
+/* key_serial_t is defined in keyutils.h as typedef int32_t */
+#define PRIkey_ser PRId32
+
 #endif /* __SSS_FORMAT_H__ */
-- 
1.8.3.1

-------------- next part --------------
>From 799d002864fdad6ba5fccda0c69b960aed5b1a53 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 16:18:04 +0200
Subject: [PATCH 10/20] Fix formating of variables with type: rlim_t

---
 src/responder/common/responder_common.c | 10 +++++-----
 src/util/sss_format.h                   |  7 +++++++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 58a92f973114c83a44049fc91f11702bc4e45435..10eb9ae464764c9dd795b8d41ece4f78bcf94420 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -999,7 +999,7 @@ void responder_set_fd_limit(rlim_t fd_limit)
     limret = setrlimit(RLIMIT_NOFILE, &new_limit);
     if (limret == 0) {
         DEBUG(SSSDBG_CONF_SETTINGS,
-              ("Maximum file descriptors set to [%d]\n",
+              ("Maximum file descriptors set to [%"PRIrlim"]\n",
                new_limit.rlim_cur));
         return;
     }
@@ -1012,7 +1012,7 @@ void responder_set_fd_limit(rlim_t fd_limit)
     limret = getrlimit(RLIMIT_NOFILE, &current_limit);
     if (limret == 0) {
         DEBUG(SSSDBG_TRACE_INTERNAL,
-              ("Current fd limit: [%d]\n",
+              ("Current fd limit: [%"PRIrlim"]\n",
                current_limit.rlim_cur));
         /* Choose the lesser of the requested and the hard limit */
         if (current_limit.rlim_max < fd_limit) {
@@ -1025,12 +1025,12 @@ void responder_set_fd_limit(rlim_t fd_limit)
         limret = setrlimit(RLIMIT_NOFILE, &new_limit);
         if (limret == 0) {
             DEBUG(SSSDBG_CONF_SETTINGS,
-                  ("Maximum file descriptors set to [%d]\n",
+                  ("Maximum file descriptors set to [%"PRIrlim"]\n",
                    new_limit.rlim_cur));
         } else {
             DEBUG(SSSDBG_CRIT_FAILURE,
-                  ("Could not set new fd limits. Proceeding with [%d]\n",
-                   current_limit.rlim_cur));
+                  ("Could not set new fd limits. Proceeding with "
+                   "[%"PRIrlim"]\n", current_limit.rlim_cur));
         }
     } else {
         DEBUG(SSSDBG_CRIT_FAILURE,
diff --git a/src/util/sss_format.h b/src/util/sss_format.h
index c9837a6e9d2f950d6d1f12d7727d43ca4b18f62e..67194393be0d4401f3bd2cf1476fedff23b5f727 100644
--- a/src/util/sss_format.h
+++ b/src/util/sss_format.h
@@ -32,4 +32,11 @@
 /* key_serial_t is defined in keyutils.h as typedef int32_t */
 #define PRIkey_ser PRId32
 
+/* rlim_t is defined with conditional build as unsigned type.
+ * It seems that sizeof(rlim_t) is 8. It may be platform dependent, therefore
+ * the same format will be used like with uint64_t.
+ */
+
+#define PRIrlim PRIu64
+
 #endif /* __SSS_FORMAT_H__ */
-- 
1.8.3.1

-------------- next part --------------
>From 61b0ce1246b0688de6488f520f3a7b29d3fffd22 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 14:03:41 +0200
Subject: [PATCH 11/20] Fix formating of variables with type defined in
 stdint.h

---
 src/providers/ldap/sdap_access.c    |  5 +++--
 src/providers/proxy/proxy_child.c   |  4 ++--
 src/providers/proxy/proxy_init.c    |  3 ++-
 src/responder/nss/nsssrv_services.c | 13 +++++++------
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c
index 9ea9077551b71d494947c7bfd7477ac8ddf227a2..a4c6386501d785090a301ae70b9f961bef4b1355 100644
--- a/src/providers/ldap/sdap_access.c
+++ b/src/providers/ldap/sdap_access.c
@@ -338,8 +338,9 @@ static errno_t sdap_account_expired_ad(struct pam_data *pd,
 
     expiration_time = ldb_msg_find_attr_as_uint64(user_entry,
                                                   SYSDB_AD_ACCOUNT_EXPIRES, 0);
-    DEBUG(9, ("Expiration time for user [%s] is [%lld].\n",
-              pd->user, expiration_time));
+    DEBUG(SSSDBG_TRACE_ALL,
+          ("Expiration time for user [%s] is [%"PRIu64"].\n",
+           pd->user, expiration_time));
 
     if (uac & UAC_ACCOUNTDISABLE) {
 
diff --git a/src/providers/proxy/proxy_child.c b/src/providers/proxy/proxy_child.c
index 6f95ede6af78f0286933fc4259dd258ef69f2d37..66afcfb64fde68af2a7f0b820db185d4158aaf48 100644
--- a/src/providers/proxy/proxy_child.c
+++ b/src/providers/proxy/proxy_child.c
@@ -430,8 +430,8 @@ int proxy_child_send_id(struct sbus_connection *conn,
         return ENOMEM;
     }
 
-    DEBUG(4, ("Sending ID to Proxy Backend: (%d,%ld)\n",
-              version, id));
+    DEBUG(SSSDBG_FUNC_DATA, ("Sending ID to Proxy Backend: (%d,%"PRIu32")\n",
+                             version, id));
 
     ret = dbus_message_append_args(msg,
                                    DBUS_TYPE_UINT16, &version,
diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c
index 2b154a0703c686c0c2e5074f20bf1690bc5242cb..ec2b193569baefd4cb2f617ed8e15bdcf547f736 100644
--- a/src/providers/proxy/proxy_init.c
+++ b/src/providers/proxy/proxy_init.c
@@ -22,6 +22,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "util/sss_format.h"
 #include "providers/proxy/proxy.h"
 
 static int client_registration(DBusMessage *message,
@@ -415,7 +416,7 @@ static int client_registration(DBusMessage *message,
         return EIO;
     }
 
-    DEBUG(4, ("Proxy client [%ld] connected\n", cli_id));
+    DEBUG(SSSDBG_FUNC_DATA, ("Proxy client [%"PRIu32"] connected\n", cli_id));
 
     /* Check the hash table */
     key.type = HASH_KEY_ULONG;
diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c
index dccc2f40789ead31b8d76bf9a6c1f0e53334cfbb..79caa7d08cdfff25112eedab98a0419f1b1d154e 100644
--- a/src/responder/nss/nsssrv_services.c
+++ b/src/responder/nss/nsssrv_services.c
@@ -225,7 +225,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
              /* If negatively cached, return we didn't find it */
              if (ret == EEXIST) {
                  DEBUG(SSSDBG_TRACE_FUNC,
-                       ("Service [%lu:%s] does not exist in [%s]! "
+                       ("Service [%"PRIu16":%s] does not exist in [%s]! "
                         "(negative cache)\n",
                         port,
                         SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
@@ -248,7 +248,7 @@ getserv_send(TALLOC_CTX *mem_ctx,
 
              /* Check the cache */
              DEBUG(SSSDBG_TRACE_FUNC,
-                   ("Checking cache for [%lu:%s@%s]\n",
+                   ("Checking cache for [%"PRIu16":%s@%s]\n",
                     port,
                     SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
                     dom->name));
@@ -291,7 +291,8 @@ getserv_send(TALLOC_CTX *mem_ctx,
                           * We'll log an error and continue.
                           */
                          DEBUG(SSSDBG_MINOR_FAILURE,
-                               ("Could not set negative cache for [%lu][%s]\n",
+                               ("Could not set negative cache for "
+                                "[%"PRIu16"][%s]\n",
                                 state->port, SVC_PROTO_CASED));
                      }
                  }
@@ -502,7 +503,7 @@ static void lookup_service_done(struct tevent_req *subreq)
                                   &state->res);
     } else {
         DEBUG(SSSDBG_TRACE_FUNC,
-              ("Re-checking cache for [%lu:%s@%s]\n",
+              ("Re-checking cache for [%"PRIu16":%s@%s]\n",
                state->port,
                SVC_PROTO_CASED ? SVC_PROTO_CASED : "<ANY>",
                dom->name));
@@ -540,7 +541,7 @@ static void lookup_service_done(struct tevent_req *subreq)
                  * We'll log an error and continue.
                  */
                 DEBUG(SSSDBG_MINOR_FAILURE,
-                      ("Could not set negative cache for [%lu][%s]\n",
+                      ("Could not set negative cache for [%"PRIu16"][%s]\n",
                        state->port, SVC_PROTO_CASED));
             }
         }
@@ -1146,7 +1147,7 @@ int nss_cmd_getservbyport(struct cli_ctx *cctx)
     dctx->protocol = service_protocol;
 
     DEBUG(SSSDBG_TRACE_FUNC,
-          ("Requesting info for service on port [%lu/%s]\n",
+          ("Requesting info for service on port [%"PRIu16"/%s]\n",
            port, service_protocol ? service_protocol : "<ANY>"));
 
     /* All port lookups are multidomain searches */
-- 
1.8.3.1

-------------- next part --------------
>From 56c03350a586ea9c6e7c3cee22b546ef27676eb6 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 15:27:20 +0200
Subject: [PATCH 12/20] Fix formating of variables with type: time_t

---
 src/providers/fail_over.c                  | 5 +++--
 src/providers/krb5/krb5_child_handler.c    | 2 +-
 src/providers/ldap/ldap_auth.c             | 2 +-
 src/providers/ldap/sdap_access.c           | 2 +-
 src/providers/ldap/sdap_async_connection.c | 2 +-
 src/providers/ldap/sdap_async_sudo_timer.c | 2 +-
 src/providers/ldap/sdap_sudo.c             | 4 ++--
 7 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c
index 537a9aa95a13a5d35895d7a310aab6ae758ebc39..98c20065989bad86acff2b9984726a9176089c44 100644
--- a/src/providers/fail_over.c
+++ b/src/providers/fail_over.c
@@ -154,8 +154,9 @@ fo_context_init(TALLOC_CTX *mem_ctx, struct fo_options *opts)
     ctx->opts->family_order  = opts->family_order;
     ctx->opts->service_resolv_timeout = opts->service_resolv_timeout;
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Created new fail over context, retry timeout is %d\n",
-                              ctx->opts->retry_timeout));
+    DEBUG(SSSDBG_TRACE_FUNC,
+          ("Created new fail over context, retry timeout is %ld\n",
+           ctx->opts->retry_timeout));
     return ctx;
 }
 
diff --git a/src/providers/krb5/krb5_child_handler.c b/src/providers/krb5/krb5_child_handler.c
index 9aa5c346acde17e1ea74d7a2ab231a6a9eebdb94..aa72c07ce28ef09fa7363d1512742b5c981f435d 100644
--- a/src/providers/krb5/krb5_child_handler.c
+++ b/src/providers/krb5/krb5_child_handler.c
@@ -564,7 +564,7 @@ parse_krb5_child_response(TALLOC_CTX *mem_ctx, uint8_t *buf, ssize_t len,
             tgtt.endtime = int64_to_time_t(time_data);
             SAFEALIGN_COPY_INT64(&time_data, buf+p+3*sizeof(int64_t), NULL);
             tgtt.renew_till = int64_to_time_t(time_data);
-            DEBUG(SSSDBG_TRACE_LIBS, ("TGT times are [%d][%d][%d][%d].\n",
+            DEBUG(SSSDBG_TRACE_LIBS, ("TGT times are [%ld][%ld][%ld][%ld].\n",
                   tgtt.authtime, tgtt.starttime, tgtt.endtime, tgtt.renew_till));
         }
 
diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c
index dcaea75c0b7833b8a1eb00232ab92ea09f7a7f00..f9bab4b2b72a061c88fbf18d3f8401b673f79619 100644
--- a/src/providers/ldap/ldap_auth.c
+++ b/src/providers/ldap/ldap_auth.c
@@ -117,7 +117,7 @@ static errno_t check_pwexpire_kerberos(const char *expire_date, time_t now,
     expire_time -= timezone;
     DEBUG(SSSDBG_TRACE_ALL,
           ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] "
-           "daylight [%d] now [%d] expire_time [%d].\n", tzname[0],
+           "daylight [%d] now [%ld] expire_time [%ld].\n", tzname[0],
            tzname[1], timezone, daylight, now, expire_time));
 
     if (difftime(now, expire_time) > 0.0) {
diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c
index a4c6386501d785090a301ae70b9f961bef4b1355..9d1315fab9b838e3f955e82c38ce88a97cb9cd0a 100644
--- a/src/providers/ldap/sdap_access.c
+++ b/src/providers/ldap/sdap_access.c
@@ -436,7 +436,7 @@ static bool nds_check_expired(const char *exp_time_str)
     now = time(NULL);
     DEBUG(SSSDBG_TRACE_ALL,
           ("Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] "
-           "daylight [%d] now [%d] expire_time [%d].\n", tzname[0],
+           "daylight [%d] now [%ld] expire_time [%ld].\n", tzname[0],
            tzname[1], timezone, daylight, now, expire_time));
 
     if (difftime(now, expire_time) > 0.0) {
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index cc3e13d097d33dc7c44e1f1fecccd152ceb6cf67..17d03c3206b61fa442616c57fbc735f87fa6452f 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -1773,7 +1773,7 @@ static void sdap_cli_auth_step(struct tevent_req *req)
             || (state->sh->expire_time > (now + expire_timeout))) {
         state->sh->expire_time = now + expire_timeout;
         DEBUG(SSSDBG_TRACE_LIBS,
-              ("the connection will expire at %d\n", state->sh->expire_time));
+              ("the connection will expire at %ld\n", state->sh->expire_time));
     }
 
     if (!state->do_auth ||
diff --git a/src/providers/ldap/sdap_async_sudo_timer.c b/src/providers/ldap/sdap_async_sudo_timer.c
index ed32cd901bc145b10f3613366b24f29e9100bc11..27dd41f06e0a20c8a672a466535debc45e9f8ea2 100644
--- a/src/providers/ldap/sdap_async_sudo_timer.c
+++ b/src/providers/ldap/sdap_async_sudo_timer.c
@@ -170,7 +170,7 @@ static void sdap_sudo_timer_timeout(struct tevent_context *ev,
     state = tevent_req_data(req, struct sdap_sudo_timer_state);
 
     DEBUG(SSSDBG_CRIT_FAILURE, ("Request timed out. Is timeout too small?"
-                                " (%ds)!\n", state->timeout));
+                                " (%lds)!\n", state->timeout));
 
     talloc_zfree(state->subreq);
 
diff --git a/src/providers/ldap/sdap_sudo.c b/src/providers/ldap/sdap_sudo.c
index f6fa2347c2cecb3de660f6d8f59e140f76ffa716..b8bc409efd48a6e21f8d4fee2f010c5539b24e32 100644
--- a/src/providers/ldap/sdap_sudo.c
+++ b/src/providers/ldap/sdap_sudo.c
@@ -227,7 +227,7 @@ static int sdap_sudo_setup_periodical_refresh(struct sdap_sudo_ctx *sudo_ctx)
         smart_default = id_ctx->opts->basic[SDAP_SUDO_SMART_REFRESH_INTERVAL].def_val.number;
 
         DEBUG(SSSDBG_MINOR_FAILURE, ("At least one periodical update has to be "
-              "enabled. Setting smart refresh interval to default value (%d).\n",
+              "enabled. Setting smart refresh interval to default value (%ld).\n",
               smart_default));
 
         ret = dp_opt_set_int(id_ctx->opts->basic,
@@ -1072,7 +1072,7 @@ schedule:
         }
 
         DEBUG(SSSDBG_TRACE_FUNC, ("Data provider is offline. "
-              "Scheduling another full refresh in %lld minutes.\n", delay));
+              "Scheduling another full refresh in %ld minutes.\n", delay));
 
         ret = sdap_sudo_schedule_refresh(sudo_ctx, sudo_ctx,
                                          SDAP_SUDO_REFRESH_FULL,
-- 
1.8.3.1

-------------- next part --------------
>From ca0e99f62a94a381a00a9f4ca8272363b6c3ed22 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 16:27:43 +0200
Subject: [PATCH 13/20] Fix formating of variables with ber_ type

---
 src/providers/ldap/sdap_async.c            | 2 +-
 src/providers/ldap/sdap_async_connection.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index bdd3c3c8b2ed4cc7246c008ddbfe531b82d880bc..09275dd65fe87b792df592cad28ae440435475f8 100644
--- a/src/providers/ldap/sdap_async.c
+++ b/src/providers/ldap/sdap_async.c
@@ -1424,7 +1424,7 @@ static void sdap_get_generic_ext_done(struct sdap_op *op,
             tevent_req_error(req, EIO);
             return;
         }
-        DEBUG(7, ("Total count [%lu]\n", total_count));
+        DEBUG(SSSDBG_TRACE_INTERNAL, ("Total count [%d]\n", total_count));
 
         if (cookie.bv_val != NULL && cookie.bv_len > 0) {
             /* Cookie contains data, which means there are more requests
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index 17d03c3206b61fa442616c57fbc735f87fa6452f..0a7746088906346ea60884484e38457d39e7d933 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -1987,8 +1987,9 @@ static int synchronous_tls_setup(LDAP *ldap)
 
     lret = ldap_result(ldap, msgid, 1, NULL, &result);
     if (lret != LDAP_RES_EXTENDED) {
-        DEBUG(2, ("Unexpected ldap_result, expected [%d] got [%d].\n",
-                  LDAP_RES_EXTENDED, lret));
+        DEBUG(SSSDBG_OP_FAILURE,
+              ("Unexpected ldap_result, expected [%lu] got [%d].\n",
+               LDAP_RES_EXTENDED, lret));
         lret = LDAP_PARAM_ERROR;
         goto done;
     }
-- 
1.8.3.1

-------------- next part --------------
>From 650cf70775952458c906ab69cf2a5dfb9623d302 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 17:15:58 +0200
Subject: [PATCH 14/20] Fix warning: data argument not used by format string

---
 src/providers/ldap/sdap_async_groups.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index 2ce1d5dd6020ca7b81ab0d09ddd28412fe6dc555..b111895074710ecff9f85ff7cd48828d357384fe 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -1382,7 +1382,9 @@ static void sdap_process_group_members(struct tevent_req *subreq)
 
 next:
     if (ret) {
-        DEBUG(7, ("Error reading group member. Skipping\n", ret));
+        DEBUG(SSSDBG_TRACE_FUNC,
+              ("Error reading group member[%d]: %s. Skipping\n",
+               ret, strerror(ret)));
         state->count--;
     }
     /* Are there more searches for uncached users to submit ? */
@@ -2064,7 +2066,8 @@ static errno_t sdap_nested_group_populate_users(TALLOC_CTX *mem_ctx,
         ret = sss_filter_sanitize(tmp_ctx, original_dn,
                                   &clean_orig_dn);
         if (ret != EOK) {
-            DEBUG(1, ("Cannot sanitize originalDN\n", i));
+            DEBUG(SSSDBG_CRIT_FAILURE,
+                  ("Cannot sanitize originalDN [%s]\n", original_dn));
             goto done;
         }
 
-- 
1.8.3.1

-------------- next part --------------
>From caaa8337280f654fc3b16476b49950261ea3f992 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 4 Sep 2013 10:16:18 +0200
Subject: [PATCH 15/20] Use right formating to print string

format specifies type 'int' but the argument has type 'const char *'
---
 src/providers/ipa/ipa_subdomains_ext_groups.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/providers/ipa/ipa_subdomains_ext_groups.c b/src/providers/ipa/ipa_subdomains_ext_groups.c
index cd098cde04c7739a58b4e6a583eaae44be5f49b1..6d2cef627d995858878790eca5f99f26ae9f0230 100644
--- a/src/providers/ipa/ipa_subdomains_ext_groups.c
+++ b/src/providers/ipa/ipa_subdomains_ext_groups.c
@@ -204,7 +204,7 @@ static errno_t find_ipa_ext_memberships(TALLOC_CTX *mem_ctx,
     }
 
     if (result->count == 0) {
-        DEBUG(SSSDBG_MINOR_FAILURE, ("User [%d] not found in cache.\n",
+        DEBUG(SSSDBG_MINOR_FAILURE, ("User [%s] not found in cache.\n",
                                      user_name));
         ret = EOK;
         goto done;
-- 
1.8.3.1

-------------- next part --------------
>From 687b81137d759bc3e5bdb5f7fb64e94d3abef6c1 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 17 Jul 2013 16:10:51 +0200
Subject: [PATCH 16/20] Fix formating of variables with type: id_t

---
 src/external/sizes.m4                         |  3 +++
 src/providers/ldap/sdap_async_initgroups_ad.c |  2 +-
 src/providers/ldap/sdap_idmap.c               | 12 +++++++-----
 src/providers/proxy/proxy_init.c              |  2 ++
 src/providers/simple/simple_access_check.c    |  8 ++++----
 src/tests/krb5_child-test.c                   |  2 +-
 src/util/sss_format.h                         | 26 +++++++++++++++++++++++++-
 7 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/src/external/sizes.m4 b/src/external/sizes.m4
index 53df61dedc3ae748c50ca9a3935632087834155d..5fc5fead71feefb8d030ae804b0ad934e4ad5541 100644
--- a/src/external/sizes.m4
+++ b/src/external/sizes.m4
@@ -6,6 +6,9 @@ AC_CHECK_SIZEOF(char)
 AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(uid_t)
+AC_CHECK_SIZEOF(gid_t)
+AC_CHECK_SIZEOF(id_t)
 
 if test $ac_cv_sizeof_long_long -lt 8 ; then
 AC_MSG_ERROR([SSSD requires long long of 64-bits])
diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
index efaa247dd22d2ae100e8881c010dfe26a9a10cca..5f2465ca6d8aef7fc486a033e7d3759050c0dec8 100644
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
@@ -472,7 +472,7 @@ sdap_get_ad_tokengroups_initgroups_lookup_done(struct tevent_req *subreq)
         }
 
         DEBUG(SSSDBG_TRACE_LIBS,
-              ("Processing membership GID [%lu]\n",
+              ("Processing membership GID [%u]\n",
                gid));
 
         /* Check whether this GID already exists in the sysdb */
diff --git a/src/providers/ldap/sdap_idmap.c b/src/providers/ldap/sdap_idmap.c
index 0939c31e45a081a8494f4efa82ac1608314b82a3..0666199f96879bafd40b9be44477edb401ee2901 100644
--- a/src/providers/ldap/sdap_idmap.c
+++ b/src/providers/ldap/sdap_idmap.c
@@ -159,7 +159,8 @@ sdap_idmap_init(TALLOC_CTX *mem_ctx,
             || (idmap_upper-idmap_lower) < rangesize)
     {
         DEBUG(SSSDBG_FATAL_FAILURE,
-              ("Invalid settings for range selection: [%d][%d][%d]\n",
+              ("Invalid settings for range selection: "
+               "[%"PRIid"][%"PRIid"][%"PRIid"]\n",
                idmap_lower, idmap_upper, rangesize));
         ret = EINVAL;
         goto done;
@@ -254,7 +255,8 @@ sdap_idmap_init(TALLOC_CTX *mem_ctx,
                                         sid_str, slice_num);
             if (ret != EOK) {
                 DEBUG(SSSDBG_CRIT_FAILURE,
-                      ("Could not add domain [%s][%s][%u] to ID map: [%s]\n",
+                      ("Could not add domain [%s][%s][%"PRIid"] "
+                       "to ID map: [%s]\n",
                        dom_name, sid_str, slice_num, strerror(ret)));
                 goto done;
             }
@@ -333,13 +335,13 @@ sdap_idmap_add_domain(struct sdap_idmap_ctx *idmap_ctx,
         goto done;
     }
     DEBUG(SSSDBG_TRACE_LIBS,
-          ("Adding domain [%s] as slice [%llu]\n", dom_sid, slice));
+          ("Adding domain [%s] as slice [%"PRIid"]\n", dom_sid, slice));
 
     if (range.max > idmap_upper) {
         /* This should never happen */
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("BUG: Range maximum exceeds the global maximum: %d > %d\n",
-               range.max, idmap_upper));
+              ("BUG: Range maximum exceeds the global maximum: "
+               "%d > %"PRIid"\n", range.max, idmap_upper));
         ret = EINVAL;
         goto done;
     }
diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c
index ec2b193569baefd4cb2f617ed8e15bdcf547f736..491482d8c9022836f8ea891070a7ca3fb780ad15 100644
--- a/src/providers/proxy/proxy_init.c
+++ b/src/providers/proxy/proxy_init.c
@@ -22,6 +22,8 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
+
 #include "util/sss_format.h"
 #include "providers/proxy/proxy.h"
 
diff --git a/src/providers/simple/simple_access_check.c b/src/providers/simple/simple_access_check.c
index 7335135ea5dedecdb5ba2be60a57d18eb897a960..1509c9df40c197376b982d9e0041a7690a44a1ef 100644
--- a/src/providers/simple/simple_access_check.c
+++ b/src/providers/simple/simple_access_check.c
@@ -245,7 +245,7 @@ simple_resolve_group_check(struct simple_resolve_group_state *state)
                                     group_attrs, &group);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE,
-               ("Could not look up group by gid [%lu]: [%d][%s]\n",
+               ("Could not look up group by gid [%u]: [%d][%s]\n",
                state->gid, ret, sss_strerror(ret)));
         return ret;
     }
@@ -470,7 +470,7 @@ static void simple_check_get_groups_next(struct tevent_req *subreq)
     talloc_zfree(subreq);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE,
-              ("Could not resolve name of group with GID %llu\n",
+              ("Could not resolve name of group with GID %u\n",
               state->lookup_gids[state->giter]));
         tevent_req_error(req, ret);
         return;
@@ -545,7 +545,7 @@ simple_check_process_group(struct simple_check_groups_state *state,
 
     /* Non-posix group with a GID. Needs resolving */
     state->lookup_gids[state->num_gids] = gid;
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("Adding GID %llu\n", gid));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("Adding GID %u\n", gid));
     state->num_gids++;
     return EOK;
 }
@@ -564,7 +564,7 @@ simple_check_get_groups_primary(struct simple_check_groups_state *state,
                                     gid, group_attrs, &msg);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE,
-               ("Could not look up primary group [%lu]: [%d][%s]\n",
+               ("Could not look up primary group [%u]: [%d][%s]\n",
                gid, ret, sss_strerror(ret)));
         /* We have to treat this as non-fatal, because the primary
          * group may be local to the machine and not available in
diff --git a/src/tests/krb5_child-test.c b/src/tests/krb5_child-test.c
index 24d077289d64d52488a3419ffc4494f59d6bc5df..f5b8174b20f3c018a0c964187fedb8bbef385c22 100644
--- a/src/tests/krb5_child-test.c
+++ b/src/tests/krb5_child-test.c
@@ -284,7 +284,7 @@ create_dummy_req(TALLOC_CTX *mem_ctx, const char *user,
         kr->krb5_ctx->cc_be = &file_cc;
         break;
     }
-    DEBUG(SSSDBG_FUNC_DATA, ("ccname [%s] uid [%llu] gid [%llu]\n",
+    DEBUG(SSSDBG_FUNC_DATA, ("ccname [%s] uid [%u] gid [%u]\n",
             kr->ccname, kr->uid, kr->gid));
 
     ret = kr->krb5_ctx->cc_be->create(kr->ccname,
diff --git a/src/util/sss_format.h b/src/util/sss_format.h
index 67194393be0d4401f3bd2cf1476fedff23b5f727..2683b203810c3edbed4515f00d90c89eec8098a4 100644
--- a/src/util/sss_format.h
+++ b/src/util/sss_format.h
@@ -36,7 +36,31 @@
  * It seems that sizeof(rlim_t) is 8. It may be platform dependent, therefore
  * the same format will be used like with uint64_t.
  */
-
 #define PRIrlim PRIu64
 
+#if SIZEOF_ID_T == 8
+# define PRIid PRIu64
+#elif SIZEOF_ID_T == 4
+# define PRIid PRIu32
+#else
+# error Unexpected sizeof id_t
+#endif /* SIZEOF_ID_T */
+
+#if SIZEOF_UID_T == 8
+# define PRIuid PRIu64
+#elif SIZEOF_UID_T == 4
+# define PRIuid PRIu32
+#else
+# error Unexpected sizeof uid_t
+#endif /* SIZEOF_UID_T */
+
+#if SIZEOF_GID_T == 8
+# define PRIgid PRIu64
+#elif SIZEOF_GID_T == 4
+# define PRIgid PRIu32
+#else
+# error Unexpected sizeof gid_t
+#endif /* SIZEOF_GID_T */
+
+
 #endif /* __SSS_FORMAT_H__ */
-- 
1.8.3.1

-------------- next part --------------
>From 7e641308bebe591fa400c027cf4c683b7c3cc3c2 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 4 Sep 2013 16:28:06 +0200
Subject: [PATCH 17/20] Fix formating of variables with type: uid_t

---
 src/db/sysdb_ops.c                    |  5 +++--
 src/monitor/monitor.c                 |  3 ++-
 src/monitor/monitor_netlink.c         |  5 +++--
 src/providers/krb5/krb5_become_user.c |  5 +++--
 src/providers/krb5/krb5_child.c       |  3 ++-
 src/providers/krb5/krb5_utils.c       | 12 ++++++------
 src/providers/proxy/proxy_id.c        | 11 +++++++----
 src/responder/common/negcache.c       |  4 ++--
 src/tools/sss_seed.c                  |  5 +++--
 src/tools/tools_util.c                |  3 ++-
 10 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 439a0cd55d6ac847efd51e6f6d41a8847ef0e32a..5b1036ec3280faea9aadc72e6950bd877d0ff073 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1116,8 +1116,9 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
 
     if (domain->id_max != 0 && uid != 0 &&
         (uid < domain->id_min || uid > domain->id_max)) {
-        DEBUG(2, ("Supplied uid [%d] is not in the allowed range [%d-%d].\n",
-                  uid, domain->id_min, domain->id_max));
+        DEBUG(SSSDBG_OP_FAILURE,
+              ("Supplied uid [%"PRIuid"] is not in the allowed range "
+               "[%d-%d].\n", uid, domain->id_min, domain->id_max));
         return ERANGE;
     }
 
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 495f31e3487027884313c3eef87ea8d8a3f15028..b130cf3d999a4e6d6bdd7859a0c4fccdea3bd199 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -2695,7 +2695,8 @@ int main(int argc, const char *argv[])
 
     uid = getuid();
     if (uid != 0) {
-        DEBUG(SSSDBG_FATAL_FAILURE, ("Running under %d, must be root\n", uid));
+        DEBUG(SSSDBG_FATAL_FAILURE,
+              ("Running under %"PRIuid", must be root\n", uid));
         sss_log(SSS_LOG_ALERT, "sssd must be run as root");
         return 8;
     }
diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c
index 932a6bf330a80e8c0f7cd506a0ae50a49e9ce38f..b485ac09afbe6addb59ea51b66279bf5f2ddc8fe 100644
--- a/src/monitor/monitor_netlink.c
+++ b/src/monitor/monitor_netlink.c
@@ -472,8 +472,9 @@ static int event_msg_recv(struct nl_msg *msg, void *arg)
 
     creds = nlmsg_get_creds(msg);
     if (!creds || creds->uid != 0) {
-        DEBUG(9, ("Ignoring netlink message from UID %d",
-                  creds ? creds->uid : -1));
+        DEBUG(SSSDBG_TRACE_ALL,
+              ("Ignoring netlink message from UID %"PRIuid,
+                  creds ? creds->uid : (uid_t)-1));
         return NL_SKIP;
     }
 
diff --git a/src/providers/krb5/krb5_become_user.c b/src/providers/krb5/krb5_become_user.c
index 70bc5630ece21505b58bd1a8795d7ab4b7864460..291d6521df98a7e89f4172fc9b2a315c5ecf84a9 100644
--- a/src/providers/krb5/krb5_become_user.c
+++ b/src/providers/krb5/krb5_become_user.c
@@ -30,12 +30,13 @@ errno_t become_user(uid_t uid, gid_t gid)
     uid_t cuid;
     int ret;
 
-    DEBUG(SSSDBG_FUNC_DATA, ("Trying to become user [%d][%d].\n", uid, gid));
+    DEBUG(SSSDBG_FUNC_DATA,
+          ("Trying to become user [%"PRIuid"][%d].\n", uid, gid));
 
     /* skip call if we already are the requested user */
     cuid = geteuid();
     if (uid == cuid) {
-        DEBUG(SSSDBG_FUNC_DATA, ("Already user [%d].\n", uid));
+        DEBUG(SSSDBG_FUNC_DATA, ("Already user [%"PRIuid"].\n", uid));
         return EOK;
     }
 
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index e69f5e35d517a00c101b3499dae8bee5e75c5bdb..8d916fda216db4ba62410a5a2567641117b81424 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -697,7 +697,8 @@ create_ccdir(const char *dirname, uid_t uid, gid_t gid)
 
             if (statbuf.st_uid != uid || statbuf.st_gid != gid) {
                 DEBUG(SSSDBG_CRIT_FAILURE,
-                      ("The directory %s is owned by %d/%d, expected %d/%d\n",
+                      ("The directory %s is owned by %"PRIuid"/%d, "
+                       "expected %"PRIuid"/%d\n",
                        dirname, statbuf.st_uid, statbuf.st_gid, uid, gid));
                 return EACCES;
             }
diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c
index df7892153d2c16fd3e485ed5013454233d228936..03392dbac6562035031661afbf2f9b2a96c3100f 100644
--- a/src/providers/krb5/krb5_utils.c
+++ b/src/providers/krb5/krb5_utils.c
@@ -252,7 +252,7 @@ char *expand_ccname_template(TALLOC_CTX *mem_ctx, struct krb5child_req *kr,
                               "because uid is invalid.\n"));
                     goto done;
                 }
-                result = talloc_asprintf_append(result, "%s%d", p,
+                result = talloc_asprintf_append(result, "%s%"PRIuid, p,
                                                 kr->uid);
                 if (!file_mode) *private_path = true;
                 break;
@@ -401,7 +401,7 @@ static errno_t check_parent_stat(bool private_path, struct stat *parent_stat,
         if (!((parent_stat->st_uid == 0 && parent_stat->st_gid == 0) ||
                parent_stat->st_uid == uid)) {
             DEBUG(1, ("Private directory can only be created below a "
-                      "directory belonging to root or to [%d][%d].\n",
+                      "directory belonging to root or to [%"PRIuid"][%d].\n",
                       uid, gid));
             return EINVAL;
         }
@@ -920,8 +920,8 @@ cc_residual_is_used(uid_t uid, const char *ccname,
 
     if (stat_buf.st_uid != uid) {
         DEBUG(SSSDBG_OP_FAILURE,
-              ("Cache file [%s] exists, but is owned by [%d] instead of "
-               "[%d].\n", ccname, stat_buf.st_uid, uid));
+              ("Cache file [%s] exists, but is owned by [%"PRIuid"] "
+               "instead of [%"PRIuid"].\n", ccname, stat_buf.st_uid, uid));
         return EINVAL;
     }
 
@@ -953,10 +953,10 @@ cc_residual_is_used(uid_t uid, const char *ccname,
     }
 
     if (!active) {
-        DEBUG(SSSDBG_TRACE_FUNC, ("User [%d] is not active\n", uid));
+        DEBUG(SSSDBG_TRACE_FUNC, ("User [%"PRIuid"] is not active\n", uid));
     } else {
         DEBUG(SSSDBG_TRACE_LIBS,
-              ("User [%d] is still active, reusing ccache [%s].\n",
+              ("User [%"PRIuid"] is still active, reusing ccache [%s].\n",
               uid, ccname));
         *result = true;
     }
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index b5d63ecfd280c65e15714ccc98edcc639d7c852d..7fa456bb6fd23efcc6f020f3a950f2469e48cee9 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -22,6 +22,9 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
+
+#include "util/sss_format.h"
 #include "util/strtonum.h"
 #include "providers/proxy/proxy.h"
 
@@ -166,7 +169,7 @@ handle_getpw_result(enum nss_status status, struct passwd *pwd,
 
     case NSS_STATUS_SUCCESS:
 
-        DEBUG(SSSDBG_TRACE_FUNC, ("User found: (%s, %d, %d)\n",
+        DEBUG(SSSDBG_TRACE_FUNC, ("User found: (%s, %"PRIuid", %d)\n",
               pwd->pw_name, pwd->pw_uid, pwd->pw_gid));
 
         /* uid=0 or gid=0 are invalid values */
@@ -314,7 +317,7 @@ static int get_pw_uid(TALLOC_CTX *mem_ctx,
     bool del_user = false;
     int ret;
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Searching user by uid (%d)\n", uid));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Searching user by uid (%"PRIuid")\n", uid));
 
     tmpctx = talloc_new(NULL);
     if (!tmpctx) {
@@ -354,7 +357,7 @@ done:
     talloc_zfree(tmpctx);
     if (ret) {
         DEBUG(SSSDBG_CRIT_FAILURE,
-              ("proxy -> getpwuid_r failed for '%d' <%d>: %s\n",
+              ("proxy -> getpwuid_r failed for '%"PRIuid"' <%d>: %s\n",
                uid, ret, strerror(ret)));
     }
     return ret;
@@ -453,7 +456,7 @@ static int enum_users(TALLOC_CTX *mem_ctx,
 
             case NSS_STATUS_SUCCESS:
 
-                DEBUG(SSSDBG_TRACE_LIBS, ("User found (%s, %d, %d)\n",
+                DEBUG(SSSDBG_TRACE_LIBS, ("User found (%s, %"PRIuid", %d)\n",
                             pwd->pw_name, pwd->pw_uid, pwd->pw_gid));
 
                 /* uid=0 or gid=0 are invalid values */
diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c
index 769346370b8366a687b63a1a844dde8f083d0154..8a277f057a4db3fd1cf3cde47ec54c3957d4b703 100644
--- a/src/responder/common/negcache.c
+++ b/src/responder/common/negcache.c
@@ -379,7 +379,7 @@ int sss_ncache_check_uid(struct sss_nc_ctx *ctx, int ttl, uid_t uid)
     char *str;
     int ret;
 
-    str = talloc_asprintf(ctx, "%s/%u", NC_UID_PREFIX, uid);
+    str = talloc_asprintf(ctx, "%s/%"PRIuid, NC_UID_PREFIX, uid);
     if (!str) return ENOMEM;
 
     ret = sss_ncache_check_str(ctx, str, ttl);
@@ -510,7 +510,7 @@ int sss_ncache_set_uid(struct sss_nc_ctx *ctx, bool permanent, uid_t uid)
     char *str;
     int ret;
 
-    str = talloc_asprintf(ctx, "%s/%u", NC_UID_PREFIX, uid);
+    str = talloc_asprintf(ctx, "%s/%"PRIuid, NC_UID_PREFIX, uid);
     if (!str) return ENOMEM;
 
     ret = sss_ncache_set_str(ctx, str, permanent);
diff --git a/src/tools/sss_seed.c b/src/tools/sss_seed.c
index 75f7e8c520593a0eeb5133ce8749106f951a98cf..1a6814c3a419aab36091620270d54ccbd93a8dac 100644
--- a/src/tools/sss_seed.c
+++ b/src/tools/sss_seed.c
@@ -166,8 +166,9 @@ static int seed_id_input(const char *req,
             return ret;
         }
         if (*endptr != '\0') {
-            DEBUG(SSSDBG_MINOR_FAILURE, ("extra characters [%s] after "
-                                         "ID [%d]\n", endptr, *_id_input));
+            DEBUG(SSSDBG_MINOR_FAILURE,
+                  ("extra characters [%s] after ID [%"PRIuid"]\n",
+                   endptr, *_id_input));
         }
     } else {
         ret = EINVAL;
diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c
index 6798b6589668b1335a7a5ada59b08cf92a2bbf1f..45c3c81ca4be8939026cafa065edd7cb6a960e05 100644
--- a/src/tools/tools_util.c
+++ b/src/tools/tools_util.c
@@ -360,7 +360,8 @@ static int remove_mail_spool(TALLOC_CTX *mem_ctx,
             case 0:
                 break;
             case -1:
-                DEBUG(3, ("%s not owned by %d, not removing\n",
+                DEBUG(SSSDBG_MINOR_FAILURE,
+                      ("%s not owned by %"PRIuid", not removing\n",
                           spool_file, uid));
                 ret = EACCES;
                 /* FALLTHROUGH */
-- 
1.8.3.1

-------------- next part --------------
>From d57b4c1706026ed8a46ff4c256ba8da317f0dc69 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 4 Sep 2013 16:52:34 +0200
Subject: [PATCH 18/20] Fix formating of variables with type: gid_t

---
 src/db/sysdb_ops.c                            | 10 ++++++----
 src/providers/krb5/krb5_become_user.c         |  2 +-
 src/providers/krb5/krb5_child.c               |  4 ++--
 src/providers/krb5/krb5_utils.c               |  4 ++--
 src/providers/ldap/sdap_async_initgroups_ad.c |  3 +--
 src/providers/proxy/proxy_id.c                | 21 +++++++++++----------
 src/providers/simple/simple_access_check.c    |  8 ++++----
 src/responder/common/negcache.c               |  4 ++--
 8 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 5b1036ec3280faea9aadc72e6950bd877d0ff073..f01580e10cdf7af8d4f938341a2f7bbbbdf724cf 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1124,8 +1124,9 @@ int sysdb_add_user(struct sysdb_ctx *sysdb,
 
     if (domain->id_max != 0 && gid != 0 &&
         (gid < domain->id_min || gid > domain->id_max)) {
-        DEBUG(2, ("Supplied gid [%d] is not in the allowed range [%d-%d].\n",
-                  gid, domain->id_min, domain->id_max));
+        DEBUG(SSSDBG_OP_FAILURE,
+              ("Supplied gid [%"PRIgid"] is not in the allowed range "
+               "[%d-%d].\n", gid, domain->id_min, domain->id_max));
         return ERANGE;
     }
 
@@ -1309,8 +1310,9 @@ int sysdb_add_group(struct sysdb_ctx *sysdb,
 
     if (domain->id_max != 0 && gid != 0 &&
         (gid < domain->id_min || gid > domain->id_max)) {
-        DEBUG(2, ("Supplied gid [%d] is not in the allowed range [%d-%d].\n",
-                  gid, domain->id_min, domain->id_max));
+        DEBUG(SSSDBG_OP_FAILURE,
+              ("Supplied gid [%"PRIgid"] is not in the allowed range "
+               "[%d-%d].\n", gid, domain->id_min, domain->id_max));
         return ERANGE;
     }
 
diff --git a/src/providers/krb5/krb5_become_user.c b/src/providers/krb5/krb5_become_user.c
index 291d6521df98a7e89f4172fc9b2a315c5ecf84a9..5743556992074d35e4f647b1ee498596adb992cf 100644
--- a/src/providers/krb5/krb5_become_user.c
+++ b/src/providers/krb5/krb5_become_user.c
@@ -31,7 +31,7 @@ errno_t become_user(uid_t uid, gid_t gid)
     int ret;
 
     DEBUG(SSSDBG_FUNC_DATA,
-          ("Trying to become user [%"PRIuid"][%d].\n", uid, gid));
+          ("Trying to become user [%"PRIuid"][%"PRIgid"].\n", uid, gid));
 
     /* skip call if we already are the requested user */
     cuid = geteuid();
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index 8d916fda216db4ba62410a5a2567641117b81424..9a28ae9def6b50eb98f261eb8f3477cacfd41504 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -697,8 +697,8 @@ create_ccdir(const char *dirname, uid_t uid, gid_t gid)
 
             if (statbuf.st_uid != uid || statbuf.st_gid != gid) {
                 DEBUG(SSSDBG_CRIT_FAILURE,
-                      ("The directory %s is owned by %"PRIuid"/%d, "
-                       "expected %"PRIuid"/%d\n",
+                      ("The directory %s is owned by %"PRIuid"/%"PRIgid", "
+                       "expected %"PRIuid"/%"PRIgid"\n",
                        dirname, statbuf.st_uid, statbuf.st_gid, uid, gid));
                 return EACCES;
             }
diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c
index 03392dbac6562035031661afbf2f9b2a96c3100f..80a2e86961b141f6273c33bab5233e957362df98 100644
--- a/src/providers/krb5/krb5_utils.c
+++ b/src/providers/krb5/krb5_utils.c
@@ -401,8 +401,8 @@ static errno_t check_parent_stat(bool private_path, struct stat *parent_stat,
         if (!((parent_stat->st_uid == 0 && parent_stat->st_gid == 0) ||
                parent_stat->st_uid == uid)) {
             DEBUG(1, ("Private directory can only be created below a "
-                      "directory belonging to root or to [%"PRIuid"][%d].\n",
-                      uid, gid));
+                      "directory belonging to root or to "
+                      "[%"PRIuid"][%"PRIgid"].\n", uid, gid));
             return EINVAL;
         }
 
diff --git a/src/providers/ldap/sdap_async_initgroups_ad.c b/src/providers/ldap/sdap_async_initgroups_ad.c
index 5f2465ca6d8aef7fc486a033e7d3759050c0dec8..9a2d23370e1f8a38b372ca31b3e86b79f9ca6701 100644
--- a/src/providers/ldap/sdap_async_initgroups_ad.c
+++ b/src/providers/ldap/sdap_async_initgroups_ad.c
@@ -472,8 +472,7 @@ sdap_get_ad_tokengroups_initgroups_lookup_done(struct tevent_req *subreq)
         }
 
         DEBUG(SSSDBG_TRACE_LIBS,
-              ("Processing membership GID [%u]\n",
-               gid));
+              ("Processing membership GID [%"PRIgid"]\n", gid));
 
         /* Check whether this GID already exists in the sysdb */
         ret = sysdb_search_group_by_gid(tmp_ctx, state->sysdb, state->domain,
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index 7fa456bb6fd23efcc6f020f3a950f2469e48cee9..93a6ea0b8a90fbf376d3bd60b7c33c7c8e8e9855 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -169,7 +169,7 @@ handle_getpw_result(enum nss_status status, struct passwd *pwd,
 
     case NSS_STATUS_SUCCESS:
 
-        DEBUG(SSSDBG_TRACE_FUNC, ("User found: (%s, %"PRIuid", %d)\n",
+        DEBUG(SSSDBG_TRACE_FUNC, ("User found: (%s, %"PRIuid", %"PRIgid")\n",
               pwd->pw_name, pwd->pw_uid, pwd->pw_gid));
 
         /* uid=0 or gid=0 are invalid values */
@@ -456,8 +456,9 @@ static int enum_users(TALLOC_CTX *mem_ctx,
 
             case NSS_STATUS_SUCCESS:
 
-                DEBUG(SSSDBG_TRACE_LIBS, ("User found (%s, %"PRIuid", %d)\n",
-                            pwd->pw_name, pwd->pw_uid, pwd->pw_gid));
+                DEBUG(SSSDBG_TRACE_LIBS,
+                      ("User found (%s, %"PRIuid", %"PRIgid")\n",
+                       pwd->pw_name, pwd->pw_uid, pwd->pw_gid));
 
                 /* uid=0 or gid=0 are invalid values */
                 /* also check that the id is in the valid range for this domain
@@ -752,7 +753,7 @@ handle_getgr_result(enum nss_status status, struct group *grp,
         break;
 
     case NSS_STATUS_SUCCESS:
-        DEBUG(SSSDBG_FUNC_DATA, ("Group found: (%s, %d)\n",
+        DEBUG(SSSDBG_FUNC_DATA, ("Group found: (%s, %"PRIgid")\n",
               grp->gr_name, grp->gr_gid));
 
         /* gid=0 is an invalid value */
@@ -922,7 +923,7 @@ static int get_gr_gid(TALLOC_CTX *mem_ctx,
     bool delete_group = false;
     int ret;
 
-    DEBUG(SSSDBG_TRACE_FUNC, ("Searching group by gid (%d)\n", gid));
+    DEBUG(SSSDBG_TRACE_FUNC, ("Searching group by gid (%"PRIgid")\n", gid));
 
     tmpctx = talloc_new(mem_ctx);
     if (!tmpctx) {
@@ -957,8 +958,8 @@ static int get_gr_gid(TALLOC_CTX *mem_ctx,
 
     if (delete_group) {
         DEBUG(SSSDBG_TRACE_FUNC,
-              ("Group %d does not exist (or is invalid) on remote server,"
-               " deleting!\n", gid));
+              ("Group %"PRIgid" does not exist (or is invalid) on remote "
+               "server, deleting!\n", gid));
 
         ret = sysdb_delete_group(sysdb, dom, NULL, gid);
         if (ret == ENOENT) {
@@ -978,7 +979,7 @@ done:
     talloc_zfree(tmpctx);
     if (ret) {
         DEBUG(SSSDBG_OP_FAILURE,
-              ("proxy -> getgrgid_r failed for '%d' <%d>: %s\n",
+              ("proxy -> getgrgid_r failed for '%"PRIgid"' <%d>: %s\n",
                gid, ret, strerror(ret)));
     }
     return ret;
@@ -1077,7 +1078,7 @@ static int enum_groups(TALLOC_CTX *mem_ctx,
 
             case NSS_STATUS_SUCCESS:
 
-                DEBUG(SSSDBG_OP_FAILURE, ("Group found (%s, %d)\n",
+                DEBUG(SSSDBG_OP_FAILURE, ("Group found (%s, %"PRIgid")\n",
                             grp->gr_name, grp->gr_gid));
 
                 /* gid=0 is an invalid value */
@@ -1334,7 +1335,7 @@ static int get_initgr_groups_process(TALLOC_CTX *memctx,
     case NSS_STATUS_NOTFOUND:
         DEBUG(SSSDBG_FUNC_DATA, ("The initgroups call returned 'NOTFOUND'. "
                                  "Assume the user is only member of its "
-                                 "primary group (%d)\n", pwd->pw_gid));
+                                 "primary group (%"PRIgid")\n", pwd->pw_gid));
         /* fall through */
     case NSS_STATUS_SUCCESS:
         DEBUG(SSSDBG_CONF_SETTINGS, ("User [%s] appears to be member of %lu"
diff --git a/src/providers/simple/simple_access_check.c b/src/providers/simple/simple_access_check.c
index 1509c9df40c197376b982d9e0041a7690a44a1ef..97dfe4bd2420a01d13e2a7f1d9e6524e91ea5f7e 100644
--- a/src/providers/simple/simple_access_check.c
+++ b/src/providers/simple/simple_access_check.c
@@ -245,7 +245,7 @@ simple_resolve_group_check(struct simple_resolve_group_state *state)
                                     group_attrs, &group);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE,
-               ("Could not look up group by gid [%u]: [%d][%s]\n",
+               ("Could not look up group by gid [%"PRIgid"]: [%d][%s]\n",
                state->gid, ret, sss_strerror(ret)));
         return ret;
     }
@@ -470,7 +470,7 @@ static void simple_check_get_groups_next(struct tevent_req *subreq)
     talloc_zfree(subreq);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE,
-              ("Could not resolve name of group with GID %u\n",
+              ("Could not resolve name of group with GID %"PRIgid"\n",
               state->lookup_gids[state->giter]));
         tevent_req_error(req, ret);
         return;
@@ -545,7 +545,7 @@ simple_check_process_group(struct simple_check_groups_state *state,
 
     /* Non-posix group with a GID. Needs resolving */
     state->lookup_gids[state->num_gids] = gid;
-    DEBUG(SSSDBG_TRACE_INTERNAL, ("Adding GID %u\n", gid));
+    DEBUG(SSSDBG_TRACE_INTERNAL, ("Adding GID %"PRIgid"\n", gid));
     state->num_gids++;
     return EOK;
 }
@@ -564,7 +564,7 @@ simple_check_get_groups_primary(struct simple_check_groups_state *state,
                                     gid, group_attrs, &msg);
     if (ret != EOK) {
         DEBUG(SSSDBG_OP_FAILURE,
-               ("Could not look up primary group [%u]: [%d][%s]\n",
+               ("Could not look up primary group [%"PRIgid"]: [%d][%s]\n",
                gid, ret, sss_strerror(ret)));
         /* We have to treat this as non-fatal, because the primary
          * group may be local to the machine and not available in
diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c
index 8a277f057a4db3fd1cf3cde47ec54c3957d4b703..385d363f84353a60ad92cb8e2d8150886a2cec28 100644
--- a/src/responder/common/negcache.c
+++ b/src/responder/common/negcache.c
@@ -393,7 +393,7 @@ int sss_ncache_check_gid(struct sss_nc_ctx *ctx, int ttl, gid_t gid)
     char *str;
     int ret;
 
-    str = talloc_asprintf(ctx, "%s/%u", NC_GID_PREFIX, gid);
+    str = talloc_asprintf(ctx, "%s/%"PRIgid, NC_GID_PREFIX, gid);
     if (!str) return ENOMEM;
 
     ret = sss_ncache_check_str(ctx, str, ttl);
@@ -524,7 +524,7 @@ int sss_ncache_set_gid(struct sss_nc_ctx *ctx, bool permanent, gid_t gid)
     char *str;
     int ret;
 
-    str = talloc_asprintf(ctx, "%s/%u", NC_GID_PREFIX, gid);
+    str = talloc_asprintf(ctx, "%s/%"PRIgid, NC_GID_PREFIX, gid);
     if (!str) return ENOMEM;
 
     ret = sss_ncache_set_str(ctx, str, permanent);
-- 
1.8.3.1

-------------- next part --------------
>From f96acb886d4774084e1022807f9b20a2e285d20f Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 23 May 2013 13:14:37 +0200
Subject: [PATCH 19/20] Enable printf format string checking

https://fedorahosted.org/sssd/ticket/1945
---
 configure.ac    | 18 ++++++++++++++++++
 src/util/util.h | 10 ++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 511e8d6c8afbfb0cbf5aca076b460aa4c881e252..759122afdec4a37f784e5d8c8c8e333dc4d73757 100644
--- a/configure.ac
+++ b/configure.ac
@@ -267,6 +267,24 @@ if test x"$sss_client_cv_attribute_destructor" = xyes ; then
              [whether compiler supports __attribute__((destructor))])
 fi
 
+AC_CACHE_CHECK([whether compiler supports __attribute__((format))],
+               sss_cv_attribute_format,
+               [AC_COMPILE_IFELSE(
+                    [AC_LANG_SOURCE(
+                        [void debug_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));]
+                    )],
+                    [sss_cv_attribute_format=yes],
+                    [
+                        AC_MSG_RESULT([no])
+                        AC_MSG_WARN([compiler does NOT support __attribute__((format))])
+                    ])
+               ])
+
+if test x"$sss_cv_attribute_format" = xyes ; then
+   AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_FORMAT, 1,
+             [whether compiler supports __attribute__((format))])
+fi
+
 PKG_CHECK_MODULES([CHECK], [check >= 0.9.5], [have_check=1], [have_check=])
 if test x$have_check = x; then
     AC_MSG_WARN([Without the 'CHECK' libraries, you will be unable to run all tests in the 'make check' suite])
diff --git a/src/util/util.h b/src/util/util.h
index 4cd96b1bfa6fa2d1090a3a8e7b2c13c309e5c785..8ec6639901d04a4a0b9cb23fb3e3b8e65b947919 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -55,13 +55,19 @@
 
 #define CLEAR_MC_FLAG "clear_mc_flag"
 
+#ifdef HAVE_FUNCTION_ATTRIBUTE_FORMAT
+#define SSS_ATTRIBUTE_PRINTF(a1, a2) __attribute__ ((format (printf, a1, a2)))
+#else
+#define SSS_ATTRIBUTE_PRINTF(a1, a2)
+#endif
+
 extern const char *debug_prg_name;
 extern int debug_level;
 extern int debug_timestamps;
 extern int debug_microseconds;
 extern int debug_to_file;
 extern const char *debug_log_file;
-void debug_fn(const char *format, ...);
+void debug_fn(const char *format, ...) SSS_ATTRIBUTE_PRINTF(1, 2);
 int debug_get_level(int old_level);
 int debug_convert_old_level(int old_level);
 errno_t set_debug_file_from_fd(const int fd);
@@ -274,7 +280,7 @@ void talloc_log_fn(const char *msg);
 #define SSS_LOG_INFO    6   /* informational */
 #define SSS_LOG_DEBUG   7   /* debug-level messages */
 
-void sss_log(int priority, const char *format, ...);
+void sss_log(int priority, const char *format, ...) SSS_ATTRIBUTE_PRINTF(2, 3);
 
 /* from server.c */
 struct main_context {
-- 
1.8.3.1



More information about the sssd-devel mailing list