summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-11-26 22:16:25 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-08 15:05:48 +0100
commita6bd69ae438c78af062bb7020ed1112fb95807ef (patch)
treecb012e6fcd9c96a1cbde48cb67cb2d7f27910228 /src/lib
parenta475178ead4f59fc96fbd0fb954e7c87355d423a (diff)
downloadsssd-a6bd69ae438c78af062bb7020ed1112fb95807ef.tar.gz
sssd-a6bd69ae438c78af062bb7020ed1112fb95807ef.tar.xz
sssd-a6bd69ae438c78af062bb7020ed1112fb95807ef.zip
IDMAP: add sss_idmap_smb_sid_to_unix()
To avoid a conversion on the caller side a new call is added to libsss_idmap which converts a Samba dom_sid structure to a Posix ID.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/idmap/sss_idmap.c22
-rw-r--r--src/lib/idmap/sss_idmap.h17
2 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c
index 3615e9d55..1764b6f4b 100644
--- a/src/lib/idmap/sss_idmap.c
+++ b/src/lib/idmap/sss_idmap.c
@@ -422,6 +422,28 @@ done:
return err;
}
+enum idmap_error_code sss_idmap_smb_sid_to_unix(struct sss_idmap_ctx *ctx,
+ struct dom_sid *smb_sid,
+ uint32_t *id)
+{
+ enum idmap_error_code err;
+ char *sid;
+
+ CHECK_IDMAP_CTX(ctx, IDMAP_CONTEXT_INVALID);
+
+ err = sss_idmap_smb_sid_to_sid(ctx, smb_sid, &sid);
+ if (err != IDMAP_SUCCESS) {
+ goto done;
+ }
+
+ err = sss_idmap_sid_to_unix(ctx, sid, id);
+
+done:
+ ctx->free_func(sid, ctx->alloc_pvt);
+
+ return err;
+}
+
enum idmap_error_code sss_idmap_unix_to_dom_sid(struct sss_idmap_ctx *ctx,
uint32_t id,
struct sss_dom_sid **_dom_sid)
diff --git a/src/lib/idmap/sss_idmap.h b/src/lib/idmap/sss_idmap.h
index 22a4d5484..ced7074a9 100644
--- a/src/lib/idmap/sss_idmap.h
+++ b/src/lib/idmap/sss_idmap.h
@@ -200,6 +200,23 @@ enum idmap_error_code sss_idmap_bin_sid_to_unix(struct sss_idmap_ctx *ctx,
uint32_t *id);
/**
+ * @brief Translate a Samba dom_sid stucture to a unix UID or GID
+ *
+ * @param[in] ctx Idmap context
+ * @param[in] smb_sid Samba dom_sid structure
+ * @param[out] id Returned unix UID or GID
+ *
+ * @return
+ * - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
+ * - #IDMAP_SID_INVALID: Invalid SID provided
+ * - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
+ * idmap context
+ */
+enum idmap_error_code sss_idmap_smb_sid_to_unix(struct sss_idmap_ctx *ctx,
+ struct dom_sid *smb_sid,
+ uint32_t *id);
+
+/**
* @brief Translate unix UID or GID to a SID
*
* @param[in] ctx Idmap context