Blame SOURCES/0030-nss-idmap-add-timeout-version-of-old-sss_nss_-calls.patch

9f2ebf
From a12e6ac8001025174cf201bcaa2143edb1b0c017 Mon Sep 17 00:00:00 2001
9f2ebf
From: Sumit Bose <sbose@redhat.com>
9f2ebf
Date: Thu, 2 Nov 2017 10:32:41 +0100
9f2ebf
Subject: [PATCH 30/31] nss-idmap: add timeout version of old sss_nss_* calls
9f2ebf
9f2ebf
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
9f2ebf
(cherry picked from commit e54db68cbb9c12d8a6867f2c7766fb2115ab0997)
9f2ebf
---
9f2ebf
 Makefile.am                                   |   2 +-
9f2ebf
 src/sss_client/idmap/sss_nss_idmap.c          | 126 ++++++++++++++++++--------
9f2ebf
 src/sss_client/idmap/sss_nss_idmap.exports    |   7 ++
9f2ebf
 src/sss_client/idmap/sss_nss_idmap.h          | 124 +++++++++++++++++++++++++
9f2ebf
 src/sss_client/idmap/sss_nss_idmap.unit_tests |   2 +-
9f2ebf
 src/tests/cmocka/sss_nss_idmap-tests.c        |  13 +--
9f2ebf
 6 files changed, 229 insertions(+), 45 deletions(-)
9f2ebf
9f2ebf
diff --git a/Makefile.am b/Makefile.am
9f2ebf
index dd25d1f7ea1be66388aa1b393bac290c4d7501a2..286ba47e3c421864362717be5258de960efca9f2 100644
9f2ebf
--- a/Makefile.am
9f2ebf
+++ b/Makefile.am
9f2ebf
@@ -2974,7 +2974,6 @@ test_sysdb_domain_resolution_order_LDADD = \
9f2ebf
 
9f2ebf
 test_wbc_calls_SOURCES = \
9f2ebf
     src/tests/cmocka/test_wbc_calls.c \
9f2ebf
-    src/sss_client/idmap/sss_nss_idmap.c \
9f2ebf
     src/sss_client/libwbclient/wbc_sid_sssd.c \
9f2ebf
     src/sss_client/libwbclient/wbclient_common.c \
9f2ebf
     src/sss_client/libwbclient/wbc_sid_common.c \
9f2ebf
@@ -2993,6 +2992,7 @@ test_wbc_calls_LDADD = \
9f2ebf
     $(TALLOC_LIBS) \
9f2ebf
     $(SSSD_INTERNAL_LTLIBS) \
9f2ebf
     libsss_test_common.la \
9f2ebf
+    libsss_nss_idmap.la \
9f2ebf
     $(NULL)
9f2ebf
 
9f2ebf
 test_be_ptask_SOURCES = \
9f2ebf
diff --git a/src/sss_client/idmap/sss_nss_idmap.c b/src/sss_client/idmap/sss_nss_idmap.c
9f2ebf
index 6f3af267a1e763e7dce77e3862be377ae2bfe984..6e7685d2b1d80956b6a6668e9bbb146abd9e86ed 100644
9f2ebf
--- a/src/sss_client/idmap/sss_nss_idmap.c
9f2ebf
+++ b/src/sss_client/idmap/sss_nss_idmap.c
9f2ebf
@@ -28,10 +28,13 @@
9f2ebf
 
9f2ebf
 #include "sss_client/sss_cli.h"
9f2ebf
 #include "sss_client/idmap/sss_nss_idmap.h"
9f2ebf
+#include "sss_client/idmap/sss_nss_idmap_private.h"
9f2ebf
 #include "util/strtonum.h"
9f2ebf
 
9f2ebf
 #define DATA_START (3 * sizeof(uint32_t))
9f2ebf
 #define LIST_START (2 * sizeof(uint32_t))
9f2ebf
+#define NO_TIMEOUT ((unsigned int) -1)
9f2ebf
+
9f2ebf
 union input {
9f2ebf
     const char *str;
9f2ebf
     uint32_t id;
9f2ebf
@@ -198,8 +201,8 @@ done:
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
-static int sss_nss_getyyybyxxx(union input inp, enum sss_cli_command cmd ,
9f2ebf
-                               struct output *out)
9f2ebf
+static int sss_nss_getyyybyxxx(union input inp, enum sss_cli_command cmd,
9f2ebf
+                               unsigned int timeout, struct output *out)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     size_t inp_len;
9f2ebf
@@ -215,6 +218,7 @@ static int sss_nss_getyyybyxxx(union input inp, enum sss_cli_command cmd ,
9f2ebf
     struct sss_nss_kv *kv_list;
9f2ebf
     char **names;
9f2ebf
     enum sss_id_type *types;
9f2ebf
+    int time_left = SSS_CLI_SOCKET_TIMEOUT;
9f2ebf
 
9f2ebf
     switch (cmd) {
9f2ebf
     case SSS_NSS_GETSIDBYNAME:
9f2ebf
@@ -250,9 +254,14 @@ static int sss_nss_getyyybyxxx(union input inp, enum sss_cli_command cmd ,
9f2ebf
         return EINVAL;
9f2ebf
     }
9f2ebf
 
9f2ebf
-    sss_nss_lock();
9f2ebf
+    if (timeout == NO_TIMEOUT) {
9f2ebf
+        sss_nss_lock();
9f2ebf
+    } else {
9f2ebf
+        sss_nss_timedlock(timeout, &time_left);
9f2ebf
+    }
9f2ebf
 
9f2ebf
-    nret = sss_nss_make_request(cmd, &rd, &repbuf, &replen, &errnop);
9f2ebf
+    nret = sss_nss_make_request_timeout(cmd, &rd, time_left, &repbuf, &replen,
9f2ebf
+                                        &errnop);
9f2ebf
     if (nret != NSS_STATUS_SUCCESS) {
9f2ebf
         ret = nss_status_to_errno(nret);
9f2ebf
         goto done;
9f2ebf
@@ -347,8 +356,8 @@ done:
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
-int sss_nss_getsidbyname(const char *fq_name, char **sid,
9f2ebf
-                         enum sss_id_type *type)
9f2ebf
+int sss_nss_getsidbyname_timeout(const char *fq_name, unsigned int timeout,
9f2ebf
+                                 char **sid, enum sss_id_type *type)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     union input inp;
9f2ebf
@@ -360,7 +369,7 @@ int sss_nss_getsidbyname(const char *fq_name, char **sid,
9f2ebf
 
9f2ebf
     inp.str = fq_name;
9f2ebf
 
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETSIDBYNAME, &out;;
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETSIDBYNAME, timeout, &out;;
9f2ebf
     if (ret == EOK) {
9f2ebf
         *sid = out.d.str;
9f2ebf
         *type = out.type;
9f2ebf
@@ -369,7 +378,14 @@ int sss_nss_getsidbyname(const char *fq_name, char **sid,
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
-int sss_nss_getsidbyid(uint32_t id, char **sid, enum sss_id_type *type)
9f2ebf
+int sss_nss_getsidbyname(const char *fq_name, char **sid,
9f2ebf
+                         enum sss_id_type *type)
9f2ebf
+{
9f2ebf
+    return sss_nss_getsidbyname_timeout(fq_name, NO_TIMEOUT, sid, type);
9f2ebf
+}
9f2ebf
+
9f2ebf
+int sss_nss_getsidbyid_timeout(uint32_t id, unsigned int timeout,
9f2ebf
+                               char **sid, enum sss_id_type *type)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     union input inp;
9f2ebf
@@ -381,7 +397,7 @@ int sss_nss_getsidbyid(uint32_t id, char **sid, enum sss_id_type *type)
9f2ebf
 
9f2ebf
     inp.id = id;
9f2ebf
 
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETSIDBYID, &out;;
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETSIDBYID, timeout, &out;;
9f2ebf
     if (ret == EOK) {
9f2ebf
         *sid = out.d.str;
9f2ebf
         *type = out.type;
9f2ebf
@@ -390,8 +406,13 @@ int sss_nss_getsidbyid(uint32_t id, char **sid, enum sss_id_type *type)
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
-int sss_nss_getnamebysid(const char *sid, char **fq_name,
9f2ebf
-                         enum sss_id_type *type)
9f2ebf
+int sss_nss_getsidbyid(uint32_t id, char **sid, enum sss_id_type *type)
9f2ebf
+{
9f2ebf
+    return sss_nss_getsidbyid_timeout(id, NO_TIMEOUT, sid, type);
9f2ebf
+}
9f2ebf
+
9f2ebf
+int sss_nss_getnamebysid_timeout(const char *sid, unsigned int timeout,
9f2ebf
+                                 char **fq_name, enum sss_id_type *type)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     union input inp;
9f2ebf
@@ -403,7 +424,7 @@ int sss_nss_getnamebysid(const char *sid, char **fq_name,
9f2ebf
 
9f2ebf
     inp.str = sid;
9f2ebf
 
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETNAMEBYSID, &out;;
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETNAMEBYSID, timeout, &out;;
9f2ebf
     if (ret == EOK) {
9f2ebf
         *fq_name = out.d.str;
9f2ebf
         *type = out.type;
9f2ebf
@@ -412,7 +433,14 @@ int sss_nss_getnamebysid(const char *sid, char **fq_name,
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
-int sss_nss_getidbysid(const char *sid, uint32_t *id, enum sss_id_type *id_type)
9f2ebf
+int sss_nss_getnamebysid(const char *sid, char **fq_name,
9f2ebf
+                         enum sss_id_type *type)
9f2ebf
+{
9f2ebf
+    return sss_nss_getnamebysid_timeout(sid, NO_TIMEOUT, fq_name, type);
9f2ebf
+}
9f2ebf
+
9f2ebf
+int sss_nss_getidbysid_timeout(const char *sid, unsigned int timeout,
9f2ebf
+                               uint32_t *id, enum sss_id_type *id_type)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     union input inp;
9f2ebf
@@ -424,7 +452,7 @@ int sss_nss_getidbysid(const char *sid, uint32_t *id, enum sss_id_type *id_type)
9f2ebf
 
9f2ebf
     inp.str = sid;
9f2ebf
 
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETIDBYSID, &out;;
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETIDBYSID, timeout, &out;;
9f2ebf
     if (ret == EOK) {
9f2ebf
         *id = out.d.id;
9f2ebf
         *id_type = out.type;
9f2ebf
@@ -433,8 +461,14 @@ int sss_nss_getidbysid(const char *sid, uint32_t *id, enum sss_id_type *id_type)
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
-int sss_nss_getorigbyname(const char *fq_name, struct sss_nss_kv **kv_list,
9f2ebf
-                         enum sss_id_type *type)
9f2ebf
+int sss_nss_getidbysid(const char *sid, uint32_t *id, enum sss_id_type *id_type)
9f2ebf
+{
9f2ebf
+    return sss_nss_getidbysid_timeout(sid, NO_TIMEOUT, id, id_type);
9f2ebf
+}
9f2ebf
+
9f2ebf
+int sss_nss_getorigbyname_timeout(const char *fq_name, unsigned int timeout,
9f2ebf
+                                  struct sss_nss_kv **kv_list,
9f2ebf
+                                  enum sss_id_type *type)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     union input inp;
9f2ebf
@@ -446,7 +480,7 @@ int sss_nss_getorigbyname(const char *fq_name, struct sss_nss_kv **kv_list,
9f2ebf
 
9f2ebf
     inp.str = fq_name;
9f2ebf
 
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETORIGBYNAME, &out;;
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETORIGBYNAME, timeout, &out;;
9f2ebf
     if (ret == EOK) {
9f2ebf
         *kv_list = out.d.kv_list;
9f2ebf
         *type = out.type;
9f2ebf
@@ -455,30 +489,42 @@ int sss_nss_getorigbyname(const char *fq_name, struct sss_nss_kv **kv_list,
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
 
9f2ebf
+int sss_nss_getorigbyname(const char *fq_name, struct sss_nss_kv **kv_list,
9f2ebf
+                          enum sss_id_type *type)
9f2ebf
+{
9f2ebf
+    return sss_nss_getorigbyname_timeout(fq_name, NO_TIMEOUT, kv_list, type);
9f2ebf
+}
9f2ebf
+
9f2ebf
+int sss_nss_getnamebycert_timeout(const char *cert, unsigned int timeout,
9f2ebf
+                                  char **fq_name, enum sss_id_type *type)
9f2ebf
+{
9f2ebf
+    int ret;
9f2ebf
+    union input inp;
9f2ebf
+    struct output out;
9f2ebf
+
9f2ebf
+    if (fq_name == NULL || cert == NULL || *cert == '\0') {
9f2ebf
+        return EINVAL;
9f2ebf
+    }
9f2ebf
+
9f2ebf
+    inp.str = cert;
9f2ebf
+
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETNAMEBYCERT, timeout, &out;;
9f2ebf
+    if (ret == EOK) {
9f2ebf
+        *fq_name = out.d.str;
9f2ebf
+        *type = out.type;
9f2ebf
+    }
9f2ebf
+
9f2ebf
+    return ret;
9f2ebf
+}
9f2ebf
+
9f2ebf
 int sss_nss_getnamebycert(const char *cert, char **fq_name,
9f2ebf
                           enum sss_id_type *type)
9f2ebf
 {
9f2ebf
-    int ret;
9f2ebf
-    union input inp;
9f2ebf
-    struct output out;
9f2ebf
-
9f2ebf
-    if (fq_name == NULL || cert == NULL || *cert == '\0') {
9f2ebf
-        return EINVAL;
9f2ebf
-    }
9f2ebf
-
9f2ebf
-    inp.str = cert;
9f2ebf
-
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETNAMEBYCERT, &out;;
9f2ebf
-    if (ret == EOK) {
9f2ebf
-        *fq_name = out.d.str;
9f2ebf
-        *type = out.type;
9f2ebf
-    }
9f2ebf
-
9f2ebf
-    return ret;
9f2ebf
+    return sss_nss_getnamebycert_timeout(cert, NO_TIMEOUT, fq_name, type);
9f2ebf
 }
9f2ebf
 
9f2ebf
-int sss_nss_getlistbycert(const char *cert, char ***fq_name,
9f2ebf
-                          enum sss_id_type **type)
9f2ebf
+int sss_nss_getlistbycert_timeout(const char *cert, unsigned int timeout,
9f2ebf
+                                  char ***fq_name, enum sss_id_type **type)
9f2ebf
 {
9f2ebf
     int ret;
9f2ebf
     union input inp;
9f2ebf
@@ -490,7 +536,7 @@ int sss_nss_getlistbycert(const char *cert, char ***fq_name,
9f2ebf
 
9f2ebf
     inp.str = cert;
9f2ebf
 
9f2ebf
-    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETLISTBYCERT, &out;;
9f2ebf
+    ret = sss_nss_getyyybyxxx(inp, SSS_NSS_GETLISTBYCERT, timeout, &out;;
9f2ebf
     if (ret == EOK) {
9f2ebf
         *fq_name = out.d.names;
9f2ebf
         *type = out.types;
9f2ebf
@@ -498,3 +544,9 @@ int sss_nss_getlistbycert(const char *cert, char ***fq_name,
9f2ebf
 
9f2ebf
     return ret;
9f2ebf
 }
9f2ebf
+
9f2ebf
+int sss_nss_getlistbycert(const char *cert, char ***fq_name,
9f2ebf
+                          enum sss_id_type **type)
9f2ebf
+{
9f2ebf
+    return sss_nss_getlistbycert_timeout(cert, NO_TIMEOUT, fq_name, type);
9f2ebf
+}
9f2ebf
diff --git a/src/sss_client/idmap/sss_nss_idmap.exports b/src/sss_client/idmap/sss_nss_idmap.exports
9f2ebf
index 788d05ecc3bd56fa88e68a98b9c8096cf7140a09..8d0a24f42aa3fb3dd9c2ed125bf79e2c7792993f 100644
9f2ebf
--- a/src/sss_client/idmap/sss_nss_idmap.exports
9f2ebf
+++ b/src/sss_client/idmap/sss_nss_idmap.exports
9f2ebf
@@ -40,4 +40,11 @@ SSS_NSS_IDMAP_0.4.0 {
9f2ebf
         sss_nss_getgrnam_timeout;
9f2ebf
         sss_nss_getgrgid_timeout;
9f2ebf
         sss_nss_getgrouplist_timeout;
9f2ebf
+        sss_nss_getsidbyname_timeout;
9f2ebf
+        sss_nss_getsidbyid_timeout;
9f2ebf
+        sss_nss_getnamebysid_timeout;
9f2ebf
+        sss_nss_getidbysid_timeout;
9f2ebf
+        sss_nss_getorigbyname_timeout;
9f2ebf
+        sss_nss_getnamebycert_timeout;
9f2ebf
+        sss_nss_getlistbycert_timeout;
9f2ebf
 } SSS_NSS_IDMAP_0.3.0;
9f2ebf
diff --git a/src/sss_client/idmap/sss_nss_idmap.h b/src/sss_client/idmap/sss_nss_idmap.h
9f2ebf
index 3755643312f05a31d1cf1aa76dfc22848ef1e3ec..125e72a6486f5916f90d37f27e1743d181bfa3e5 100644
9f2ebf
--- a/src/sss_client/idmap/sss_nss_idmap.h
9f2ebf
+++ b/src/sss_client/idmap/sss_nss_idmap.h
9f2ebf
@@ -303,5 +303,129 @@ int sss_nss_getgrgid_timeout(gid_t gid, struct group *grp,
9f2ebf
 int sss_nss_getgrouplist_timeout(const char *name, gid_t group,
9f2ebf
                                  gid_t *groups, int *ngroups,
9f2ebf
                                  uint32_t flags, unsigned int timeout);
9f2ebf
+/**
9f2ebf
+ * @brief Find SID by fully qualified name with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] fq_name  Fully qualified name of a user or a group
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] sid     String representation of the SID of the requested user
9f2ebf
+ *                     or group, must be freed by the caller
9f2ebf
+ * @param[out] type    Type of the object related to the given name
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - 0 (EOK): success, sid contains the requested SID
9f2ebf
+ *  - ENOENT: requested object was not found in the domain extracted from the given name
9f2ebf
+ *  - ENETUNREACH: SSSD does not know how to handle the domain extracted from the given name
9f2ebf
+ *  - ENOSYS: this call is not supported by the configured provider
9f2ebf
+ *  - EINVAL: input cannot be parsed
9f2ebf
+ *  - EIO: remote servers cannot be reached
9f2ebf
+ *  - EFAULT: any other error
9f2ebf
+ *  - ETIME:     request timed out but was send to SSSD
9f2ebf
+ *  - ETIMEDOUT: request timed out but was not send to SSSD
9f2ebf
+ */
9f2ebf
+int sss_nss_getsidbyname_timeout(const char *fq_name, unsigned int timeout,
9f2ebf
+                                 char **sid, enum sss_id_type *type);
9f2ebf
+
9f2ebf
+/**
9f2ebf
+ * @brief Find SID by a POSIX UID or GID with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] id       POSIX UID or GID
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] sid     String representation of the SID of the requested user
9f2ebf
+ *                     or group, must be freed by the caller
9f2ebf
+ * @param[out] type    Type of the object related to the given ID
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - see #sss_nss_getsidbyname_timeout
9f2ebf
+ */
9f2ebf
+int sss_nss_getsidbyid_timeout(uint32_t id, unsigned int timeout,
9f2ebf
+                               char **sid, enum sss_id_type *type);
9f2ebf
+
9f2ebf
+/**
9f2ebf
+ * @brief Return the fully qualified name for the given SID with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] sid      String representation of the SID
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] fq_name Fully qualified name of a user or a group,
9f2ebf
+ *                     must be freed by the caller
9f2ebf
+ * @param[out] type    Type of the object related to the SID
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - see #sss_nss_getsidbyname_timeout
9f2ebf
+ */
9f2ebf
+int sss_nss_getnamebysid_timeout(const char *sid, unsigned int timeout,
9f2ebf
+                                 char **fq_name, enum sss_id_type *type);
9f2ebf
+
9f2ebf
+/**
9f2ebf
+ * @brief Return the POSIX ID for the given SID with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] sid      String representation of the SID
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] id      POSIX ID related to the SID
9f2ebf
+ * @param[out] id_type Type of the object related to the SID
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - see #sss_nss_getsidbyname_timeout
9f2ebf
+ */
9f2ebf
+int sss_nss_getidbysid_timeout(const char *sid, unsigned int timeout,
9f2ebf
+                               uint32_t *id, enum sss_id_type *id_type);
9f2ebf
+
9f2ebf
+/**
9f2ebf
+ * @brief Find original data by fully qualified name with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] fq_name  Fully qualified name of a user or a group
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] kv_list A NULL terminate list of key-value pairs where the key
9f2ebf
+ *                     is the attribute name in the cache of SSSD,
9f2ebf
+ *                     must be freed by the caller with sss_nss_free_kv()
9f2ebf
+ * @param[out] type    Type of the object related to the given name
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - 0 (EOK): success, sid contains the requested SID
9f2ebf
+ *  - ENOENT: requested object was not found in the domain extracted from the given name
9f2ebf
+ *  - ENETUNREACH: SSSD does not know how to handle the domain extracted from the given name
9f2ebf
+ *  - ENOSYS: this call is not supported by the configured provider
9f2ebf
+ *  - EINVAL: input cannot be parsed
9f2ebf
+ *  - EIO: remote servers cannot be reached
9f2ebf
+ *  - EFAULT: any other error
9f2ebf
+ *  - ETIME:     request timed out but was send to SSSD
9f2ebf
+ *  - ETIMEDOUT: request timed out but was not send to SSSD
9f2ebf
+ */
9f2ebf
+int sss_nss_getorigbyname_timeout(const char *fq_name, unsigned int timeout,
9f2ebf
+                                  struct sss_nss_kv **kv_list,
9f2ebf
+                                  enum sss_id_type *type);
9f2ebf
+
9f2ebf
+/**
9f2ebf
+ * @brief Return the fully qualified name for the given base64 encoded
9f2ebf
+ * X.509 certificate in DER format with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] cert     base64 encoded certificate
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] fq_name Fully qualified name of a user or a group,
9f2ebf
+ *                     must be freed by the caller
9f2ebf
+ * @param[out] type    Type of the object related to the cert
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - see #sss_nss_getsidbyname_timeout
9f2ebf
+ */
9f2ebf
+int sss_nss_getnamebycert_timeout(const char *cert, unsigned int timeout,
9f2ebf
+                                  char **fq_name, enum sss_id_type *type);
9f2ebf
+
9f2ebf
+/**
9f2ebf
+ * @brief Return a list of fully qualified names for the given base64 encoded
9f2ebf
+ * X.509 certificate in DER format with timeout
9f2ebf
+ *
9f2ebf
+ * @param[in] cert     base64 encoded certificate
9f2ebf
+ * @param[in] timeout  timeout in milliseconds
9f2ebf
+ * @param[out] fq_name List of fully qualified name of users or groups,
9f2ebf
+ *                     must be freed by the caller
9f2ebf
+ * @param[out] type    List of types of the objects related to the cert
9f2ebf
+ *
9f2ebf
+ * @return
9f2ebf
+ *  - see #sss_nss_getsidbyname_timeout
9f2ebf
+ */
9f2ebf
+int sss_nss_getlistbycert_timeout(const char *cert, unsigned int timeout,
9f2ebf
+                                  char ***fq_name, enum sss_id_type **type);
9f2ebf
+
9f2ebf
 #endif /* IPA_389DS_PLUGIN_HELPER_CALLS */
9f2ebf
 #endif /* SSS_NSS_IDMAP_H_ */
9f2ebf
diff --git a/src/sss_client/idmap/sss_nss_idmap.unit_tests b/src/sss_client/idmap/sss_nss_idmap.unit_tests
9f2ebf
index 361cc3b134ead52cf458afe27c055739d6728441..05c474f008e1d59aae5976acfd81613c3c3e6540 100644
9f2ebf
--- a/src/sss_client/idmap/sss_nss_idmap.unit_tests
9f2ebf
+++ b/src/sss_client/idmap/sss_nss_idmap.unit_tests
9f2ebf
@@ -2,5 +2,5 @@
9f2ebf
 UNIT_TEST_ONLY {
9f2ebf
     # should not be part of installed library
9f2ebf
     global:
9f2ebf
-        sss_nss_make_request;
9f2ebf
+        sss_nss_make_request_timeout;
9f2ebf
 };
9f2ebf
diff --git a/src/tests/cmocka/sss_nss_idmap-tests.c b/src/tests/cmocka/sss_nss_idmap-tests.c
9f2ebf
index 8807eca619d7b07d919168e5629042cf38f654ac..2e37040d2d3523bea157804706685fa0b36df16a 100644
9f2ebf
--- a/src/tests/cmocka/sss_nss_idmap-tests.c
9f2ebf
+++ b/src/tests/cmocka/sss_nss_idmap-tests.c
9f2ebf
@@ -61,10 +61,11 @@ uint8_t buf_orig1[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0
9f2ebf
  #error "unknow endianess"
9f2ebf
 #endif
9f2ebf
 
9f2ebf
-enum nss_status sss_nss_make_request(enum sss_cli_command cmd,
9f2ebf
-                      struct sss_cli_req_data *rd,
9f2ebf
-                      uint8_t **repbuf, size_t *replen,
9f2ebf
-                      int *errnop)
9f2ebf
+enum nss_status sss_nss_make_request_timeout(enum sss_cli_command cmd,
9f2ebf
+                                             struct sss_cli_req_data *rd,
9f2ebf
+                                             int timeout,
9f2ebf
+                                             uint8_t **repbuf, size_t *replen,
9f2ebf
+                                             int *errnop)
9f2ebf
 {
9f2ebf
     struct sss_nss_make_request_test_data *d;
9f2ebf
 
9f2ebf
@@ -114,7 +115,7 @@ void test_getsidbyname(void **state)
9f2ebf
     sid = NULL;
9f2ebf
 
9f2ebf
     for (c = 0; d[c].d.repbuf != NULL; c++) {
9f2ebf
-        will_return(sss_nss_make_request, &d[0].d);
9f2ebf
+        will_return(sss_nss_make_request_timeout, &d[0].d);
9f2ebf
 
9f2ebf
         ret = sss_nss_getsidbyname("test", &sid, &type);
9f2ebf
         assert_int_equal(ret, d[0].ret);
9f2ebf
@@ -134,7 +135,7 @@ void test_getorigbyname(void **state)
9f2ebf
     enum sss_id_type type;
9f2ebf
     struct sss_nss_make_request_test_data d = {buf_orig1, sizeof(buf_orig1), 0, NSS_STATUS_SUCCESS};
9f2ebf
 
9f2ebf
-    will_return(sss_nss_make_request, &d);
9f2ebf
+    will_return(sss_nss_make_request_timeout, &d);
9f2ebf
     ret = sss_nss_getorigbyname("test", &kv_list, &type);
9f2ebf
     assert_int_equal(ret, EOK);
9f2ebf
     assert_int_equal(type, SSS_ID_TYPE_UID);
9f2ebf
-- 
9f2ebf
2.13.6
9f2ebf