summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-03-14 09:44:41 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-04-02 17:01:08 +0200
commit53b58615fbc13eddcd6e2f28066b67cb5f16b6d3 (patch)
treee5ca489842778a4e6adba28e085bb75701db89de /src
parent755aee449c6311518200c2f11c1aae329a19b038 (diff)
downloadsssd-53b58615fbc13eddcd6e2f28066b67cb5f16b6d3.tar.gz
sssd-53b58615fbc13eddcd6e2f28066b67cb5f16b6d3.tar.xz
sssd-53b58615fbc13eddcd6e2f28066b67cb5f16b6d3.zip
Reusing create_pam_data() on the other places.
Function create_pam_data() should be only one way how to create new struct pam_data, because it also initialize destructor to created object.
Diffstat (limited to 'src')
-rw-r--r--src/providers/data_provider.h12
-rw-r--r--src/providers/krb5/krb5_child.c2
-rw-r--r--src/responder/pam/pamsrv_cmd.c2
-rw-r--r--src/tests/krb5_child-test.c2
-rw-r--r--src/tests/krb5_utils-tests.c2
5 files changed, 16 insertions, 4 deletions
diff --git a/src/providers/data_provider.h b/src/providers/data_provider.h
index 8e475d229..2ce16e859 100644
--- a/src/providers/data_provider.h
+++ b/src/providers/data_provider.h
@@ -202,6 +202,18 @@ struct pam_data {
#define SSS_KRB5_INFO_TGT_LIFETIME (SSS_SERVER_INFO|SSS_KRB5_INFO|0x01)
#define SSS_KRB5_INFO_UPN (SSS_SERVER_INFO|SSS_KRB5_INFO|0x02)
+/**
+ * @brief Create new zero initialized struct pam_data.
+ *
+ * @param mem_ctx A memory context use to allocate the internal data
+ * @return A pointer to new struct pam_data
+ * NULL on error
+ *
+ * NOTE: This function should be the only way, how to create new empty
+ * struct pam_data, because this function automatically initialize sub
+ * structures and set destructor to created object.
+ */
+struct pam_data *create_pam_data(TALLOC_CTX *mem_ctx);
errno_t copy_pam_data(TALLOC_CTX *mem_ctx, struct pam_data *old_pd,
struct pam_data **new_pd);
void pam_print_data(int l, struct pam_data *pd);
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
index 656853335..52127b39a 100644
--- a/src/providers/krb5/krb5_child.c
+++ b/src/providers/krb5/krb5_child.c
@@ -1556,7 +1556,7 @@ static errno_t unpack_buffer(uint8_t *buf, size_t size,
if (!offline || !kr) return EINVAL;
- pd = talloc_zero(kr, struct pam_data);
+ pd = create_pam_data(kr);
if (pd == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_zero failed.\n"));
return ENOMEM;
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index 647f82762..fa6cf23cd 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -758,7 +758,7 @@ static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd)
}
preq->cctx = cctx;
- preq->pd = talloc_zero(preq, struct pam_data);
+ preq->pd = create_pam_data(preq);
if (!preq->pd) {
talloc_free(preq);
return ENOMEM;
diff --git a/src/tests/krb5_child-test.c b/src/tests/krb5_child-test.c
index f6ddcaad2..302cf3c8e 100644
--- a/src/tests/krb5_child-test.c
+++ b/src/tests/krb5_child-test.c
@@ -169,7 +169,7 @@ create_dummy_pam_data(TALLOC_CTX *mem_ctx, const char *user,
size_t authtok_len;
errno_t ret;
- pd = talloc_zero(mem_ctx, struct pam_data);
+ pd = create_pam_data(mem_ctx);
if (!pd) goto fail;
pd->cmd = SSS_PAM_AUTHENTICATE;
diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c
index aa2f4ed4b..fdfe00ac2 100644
--- a/src/tests/krb5_utils-tests.c
+++ b/src/tests/krb5_utils-tests.c
@@ -425,7 +425,7 @@ void setup_talloc_context(void)
kr = talloc_zero(tmp_ctx, struct krb5child_req);
fail_unless(kr != NULL, "Cannot create krb5child_req structure.");
- pd = talloc_zero(tmp_ctx, struct pam_data);
+ pd = create_pam_data(tmp_ctx);
fail_unless(pd != NULL, "Cannot create pam_data structure.");
krb5_ctx = talloc_zero(tmp_ctx, struct krb5_ctx);