ipa_s2n_exop.c revision ac7a7ee3d1e138818a1ed78758f7dd3c3306a56b
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder/*
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder SSSD
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder IPA Helper routines - external users and groups with s2n plugin
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder Copyright (C) Sumit Bose <sbose@redhat.com> - 2011
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder This program is free software; you can redistribute it and/or modify
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder it under the terms of the GNU General Public License as published by
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder the Free Software Foundation; either version 3 of the License, or
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder (at your option) any later version.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder This program is distributed in the hope that it will be useful,
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder GNU General Public License for more details.
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder You should have received a copy of the GNU General Public License
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder*/
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder#include "util/util.h"
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder#include "util/sss_nss.h"
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder#include "db/sysdb.h"
736fe640b202e3fe7288fad8251d5b210c5d8d87Christian Maeder#include "providers/ldap/sdap_async_private.h"
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder#include "providers/ldap/ldap_common.h"
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maederenum input_types {
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder INP_SID = 1,
e84c877ad38ce9312eab222a79f44da2015572d2Christian Maeder INP_NAME,
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder INP_POSIX_UID,
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder INP_POSIX_GID
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder};
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maederenum request_types {
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder REQ_SIMPLE = 1,
945e82ed7877917f3ab1657f555e71991372546aChristian Maeder REQ_FULL
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder};
c208973c890b8f993297720fd0247bc7481d4304Christian Maeder
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maederenum response_types {
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder RESP_SID = 1,
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder RESP_NAME,
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder RESP_USER,
d97700a22b2585ece83b05f3fff945fdfd0c44b4Christian Maeder RESP_GROUP
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder};
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder
de8eee2014437ec4020be15cd363257f87e79943Christian Maeder/* ==Sid2Name Extended Operation============================================= */
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder#define EXOP_SID2NAME_OID "2.16.840.1.113730.3.8.10.4"
fd94a6f66ccb5cef99aa42069b61e4b8734dbd3fChristian Maeder
fd94a6f66ccb5cef99aa42069b61e4b8734dbd3fChristian Maederstruct ipa_s2n_exop_state {
fd94a6f66ccb5cef99aa42069b61e4b8734dbd3fChristian Maeder struct sdap_handle *sh;
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder struct sdap_op *op;
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder int result;
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder char *retoid;
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder struct berval *retdata;
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder};
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder
473f5af6e4803fbeecc814065952396f2501039bChristian Maederstatic void ipa_s2n_exop_done(struct sdap_op *op,
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder struct sdap_msg *reply,
844c7d2ec3917393e139e53503757098d568713eSimon Ulbricht int error, void *pvt);
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder
04c445e50a1d8b95e667595594e6b551c8b2ff59Simon Ulbrichtstatic struct tevent_req *ipa_s2n_exop_send(TALLOC_CTX *mem_ctx,
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder struct tevent_context *ev,
c99b0eb6632087d502dd4269599c5aa68a148eebSimon Ulbricht struct sdap_handle *sh,
c99b0eb6632087d502dd4269599c5aa68a148eebSimon Ulbricht struct berval *bv)
b99c9606f2faafeabb3fa8c596992143a561c787Simon Ulbricht{
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht struct tevent_req *req = NULL;
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder struct ipa_s2n_exop_state *state;
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder int ret;
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder int msgid;
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder req = tevent_req_create(mem_ctx, &state, struct ipa_s2n_exop_state);
473f5af6e4803fbeecc814065952396f2501039bChristian Maeder if (!req) return NULL;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder state->sh = sh;
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder state->result = LDAP_OPERATIONS_ERROR;
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder state->retoid = NULL;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder state->retdata = NULL;
dae8246f1f55b6a85e946fc1bfb6d32d556395f1Simon Ulbricht
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder DEBUG(SSSDBG_TRACE_FUNC, ("Executing extended operation\n"));
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maeder ret = ldap_extended_operation(state->sh->ldap, EXOP_SID2NAME_OID,
7710f7c3425e45af11af124ff37bec27229d24f7Christian Maeder bv, NULL, NULL, &msgid);
2e2559f894aaa661b199e4fa00609f522bc5482aSimon Ulbricht if (ret == -1 || msgid == -1) {
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder DEBUG(SSSDBG_CRIT_FAILURE, ("ldap_extended_operation failed\n"));
be1ce1c2b2819ef32743136c13101f1927375311Christian Maeder goto fail;
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maeder }
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder DEBUG(SSSDBG_TRACE_INTERNAL, ("ldap_extended_operation sent, msgid = %d\n", msgid));
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder /* FIXME: get timeouts from configuration, for now 10 secs. */
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder ret = sdap_op_add(state, ev, state->sh, msgid, ipa_s2n_exop_done, req, 10,
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder &state->op);
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder if (ret) {
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to set up operation!\n"));
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maeder goto fail;
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maeder }
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maeder
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder return req;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maederfail:
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder tevent_req_error(req, EIO);
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder tevent_req_post(req, ev);
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder return req;
5fb6343a5a2b4bbc67bc83479c84a92d23d30edfChristian Maeder}
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maederstatic void ipa_s2n_exop_done(struct sdap_op *op,
5fb6343a5a2b4bbc67bc83479c84a92d23d30edfChristian Maeder struct sdap_msg *reply,
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder int error, void *pvt)
5fb6343a5a2b4bbc67bc83479c84a92d23d30edfChristian Maeder{
6a6689ad6d4c70af2ce3389f39a50982f20fd939Christian Maeder struct tevent_req *req = talloc_get_type(pvt, struct tevent_req);
d27b1887e61f1dc53d77c37f59dbf5019242a686Christian Maeder struct ipa_s2n_exop_state *state = tevent_req_data(req,
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maeder struct ipa_s2n_exop_state);
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maeder int ret;
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maeder char *errmsg = NULL;
9d50556254571c0811e94b4d948463754812a5aaChristian Maeder char *retoid = NULL;
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maeder struct berval *retdata = NULL;
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maeder
9d50556254571c0811e94b4d948463754812a5aaChristian Maeder if (error) {
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder tevent_req_error(req, error);
5dd895cd3d794ecd2f0035ee3a7b6d6bf2eac5efChristian Maeder return;
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder }
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder
262a0a50e5f72336445bee69630a964660cc8622Christian Maeder ret = ldap_parse_result(state->sh->ldap, reply->msg,
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder &state->result, &errmsg, NULL, NULL,
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder NULL, 0);
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder if (ret != LDAP_SUCCESS) {
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ldap_parse_result failed (%d)\n", state->op->msgid));
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder ret = EIO;
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder goto done;
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder }
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder
232c13ff6847a6f2bac7163392f80ab692cd7774Christian Maeder DEBUG(SSSDBG_TRACE_FUNC, ("ldap_extended_operation result: %s(%d), %s\n",
232c13ff6847a6f2bac7163392f80ab692cd7774Christian Maeder sss_ldap_err2string(state->result), state->result, errmsg));
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder if (state->result != LDAP_SUCCESS) {
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder ret = EIO;
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder goto done;
2f0ca8050a33fbc1a23c0bd2dec0d09c17e3c548Christian Maeder }
f50c9f317ed743022255535248028675a5716d2aSimon Ulbricht
232c13ff6847a6f2bac7163392f80ab692cd7774Christian Maeder ret = ldap_parse_extended_result(state->sh->ldap, reply->msg,
232c13ff6847a6f2bac7163392f80ab692cd7774Christian Maeder &retoid, &retdata, 0);
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder if (ret != LDAP_SUCCESS) {
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ldap_parse_extendend_result failed (%d)\n", ret));
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder ret = EIO;
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder goto done;
63ec46a77d00127c46ec526df43da8d701c30c65Christian Maeder }
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder state->retoid = talloc_strdup(state, retoid);
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder if (state->retoid == NULL) {
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n"));
99b26e2ab8ba89bc9a050c1524137eb6269e2753Christian Maeder ret = ENOMEM;
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder goto done;
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht state->retdata = talloc(state, struct berval);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht if (state->retdata == NULL) {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht DEBUG(SSSDBG_OP_FAILURE, ("talloc failed.\n"));
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = ENOMEM;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht goto done;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht state->retdata->bv_len = retdata->bv_len;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht state->retdata->bv_val = talloc_memdup(state->retdata, retdata->bv_val,
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht retdata->bv_len);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht if (state->retdata->bv_val == NULL) {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht DEBUG(SSSDBG_OP_FAILURE, ("talloc_memdup failed.\n"));
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = ENOMEM;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht goto done;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = EOK;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbrichtdone:
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ldap_memfree(errmsg);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ldap_memfree(retoid);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ber_bvfree(retdata);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht if (ret == EOK) {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht tevent_req_done(req);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht } else {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht tevent_req_error(req, ret);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht}
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbrichtstatic int ipa_s2n_exop_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht enum sdap_result *result, char **retoid,
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht struct berval **retdata)
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht{
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht struct ipa_s2n_exop_state *state = tevent_req_data(req,
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht struct ipa_s2n_exop_state);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht TEVENT_REQ_RETURN_ON_ERROR(req);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht if (state->result == LDAP_SUCCESS) {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht *result = SDAP_SUCCESS;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht *retoid = talloc_steal(mem_ctx, state->retoid);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht *retdata = talloc_steal(mem_ctx, state->retdata);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht } else {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht *result = SDAP_ERROR;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht return EOK;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht}
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbrichtstatic errno_t talloc_ber_flatten(TALLOC_CTX *mem_ctx, BerElement *ber,
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht struct berval **_bv)
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht{
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht int ret;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht struct berval *bv = NULL;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht struct berval *tbv = NULL;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = ber_flatten(ber, &bv);
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht if (ret == -1) {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht ret = EFAULT;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht goto done;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht tbv = talloc_zero(mem_ctx, struct berval);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht if (tbv == NULL) {
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = ENOMEM;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht goto done;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht tbv->bv_len = bv->bv_len;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht tbv->bv_val = talloc_memdup(tbv, bv->bv_val, bv->bv_len);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht if (tbv->bv_val == NULL) {
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = ENOMEM;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht goto done;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = EOK;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbrichtdone:
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ber_bvfree(bv);
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht if (ret == EOK) {
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht *_bv = tbv;
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht } else {
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht talloc_free(tbv);
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht }
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht return ret;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht}
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht/* The extended operation expect the following ASN.1 encoded request data:
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht *
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * ExtdomRequestValue ::= SEQUENCE {
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * inputType ENUMERATED {
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * sid (1),
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * name (2),
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * posix uid (3),
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * posix gid (3)
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * },
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * requestType ENUMERATED {
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * simple (1),
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * full (2)
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * },
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * data InputData
7463a1bf64cfa90917e2afb6a5017ec411d2b3dbSimon Ulbricht * }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht *
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * InputData ::= CHOICE {
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * sid OCTET STRING,
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * name NameDomainData
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * uid PosixUid,
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * gid PosixGid
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * }
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht *
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht * NameDomainData ::= SEQUENCE {
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht * domain_name OCTET STRING,
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * object_name OCTET STRING
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht *
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * PosixUid ::= SEQUENCE {
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * domain_name OCTET STRING,
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * uid INTEGER
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * }
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht *
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht * PosixGid ::= SEQUENCE {
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht * domain_name OCTET STRING,
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht * gid INTEGER
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht *
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht */
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht
2e2559f894aaa661b199e4fa00609f522bc5482aSimon Ulbrichtstatic errno_t s2n_encode_request(TALLOC_CTX *mem_ctx,
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht const char *domain_name,
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht int entry_type,
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht const char *name,
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht uint32_t id,
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht struct berval **_bv)
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht{
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht BerElement *ber = NULL;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht int ret;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ber = ber_alloc_t( LBER_USE_DER );
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht if (ber == NULL) {
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht return ENOMEM;
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht }
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht switch (entry_type) {
2e2559f894aaa661b199e4fa00609f522bc5482aSimon Ulbricht case BE_REQ_USER:
2e2559f894aaa661b199e4fa00609f522bc5482aSimon Ulbricht if (name != NULL) {
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht ret = ber_printf(ber, "{ee{ss}}", INP_NAME, REQ_FULL,
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht domain_name, name);
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht } else {
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht ret = ber_printf(ber, "{ee{si}}", INP_POSIX_UID, REQ_FULL,
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht domain_name, id);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht }
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht break;
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht case BE_REQ_GROUP:
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht if (name != NULL) {
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht ret = ber_printf(ber, "{ee{ss}}", INP_NAME, REQ_FULL,
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht domain_name, name);
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht } else {
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht ret = ber_printf(ber, "{ee{si}}", INP_POSIX_GID, REQ_FULL,
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht domain_name, id);
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht }
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht break;
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht default:
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht ret = EINVAL;
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht goto done;
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht }
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht if (ret == -1) {
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = EFAULT;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht goto done;
562e30787355109feb0133ffea2ad86b6c143c26Simon Ulbricht }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = talloc_ber_flatten(mem_ctx, ber, _bv);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht if (ret == -1) {
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht ret = EFAULT;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht goto done;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht }
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ret = EOK;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
de8eee2014437ec4020be15cd363257f87e79943Christian Maederdone:
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht ber_free(ber, 1);
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht return ret;
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht}
f6a562e28240e4f9107c199ba7a8e500ccfbfa55Simon Ulbricht
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht/* If the extendend operation is successful it returns the following ASN.1
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht * encoded response:
9a5e6e537c43a631facd9d87ce1a6c76f4b0af6dSimon Ulbricht *
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht * ExtdomResponseValue ::= SEQUENCE {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * responseType ENUMERATED {
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * sid (1),
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * name (2),
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder * posix_user (3),
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder * posix_group (4)
1ab66a7e4234c760be9689b05ab4c34ce99dba23Simon Ulbricht * },
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * data OutputData
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * }
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder *
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * OutputData ::= CHOICE {
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * sid OCTET STRING,
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * name NameDomainData,
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * user PosixUser,
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * group PosixGroup
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * }
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder *
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * NameDomainData ::= SEQUENCE {
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * domain_name OCTET STRING,
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * object_name OCTET STRING
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * }
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder *
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * PosixUser ::= SEQUENCE {
0bbc28585c7d42913167ff78a862ef25ea59e85eChristian Maeder * domain_name OCTET STRING,
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * user_name OCTET STRING,
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * uid INTEGER
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * gid INTEGER
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * }
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder *
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * PosixGroup ::= SEQUENCE {
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * domain_name OCTET STRING,
993e01fc242fa58d3dcf1b3272cd411726817eeeSimon Ulbricht * group_name OCTET STRING,
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * gid INTEGER
f3fb0e085030be5bc309d946a6a9c20736dd3e0fSimon Ulbricht * }
f3fb0e085030be5bc309d946a6a9c20736dd3e0fSimon Ulbricht *
f3fb0e085030be5bc309d946a6a9c20736dd3e0fSimon Ulbricht * Since we always request the full data set (REQ_FULL), i.e user/group name,
f3fb0e085030be5bc309d946a6a9c20736dd3e0fSimon Ulbricht * domain name and corresponding unix id, only PosixUser (RESP_USER) and
f3fb0e085030be5bc309d946a6a9c20736dd3e0fSimon Ulbricht * PosixGroup (RESP_GROUP) are handled by s2n_response_to_attrs().
f3fb0e085030be5bc309d946a6a9c20736dd3e0fSimon Ulbricht */
116efc752fbf094a464c4f4940d9a450ab41c6c9Simon Ulbricht
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maederstruct resp_attrs {
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder enum response_types response_type;
31a81edf1285dc338211bfe86ba50a1f4128d9d2Christian Maeder char *domain_name;
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder union {
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder struct passwd user;
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder struct group group;
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder } a;
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder};
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maederstatic errno_t s2n_response_to_attrs(TALLOC_CTX *mem_ctx,
eae0d62755147d991cc3e903f74f98ac31a7cd42Christian Maeder char *retoid,
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder struct berval *retdata,
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder struct resp_attrs **resp_attrs)
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder{
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder BerElement *ber = NULL;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder ber_tag_t tag;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder int ret;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder enum response_types type;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder char *domain_name = NULL;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder char *name = NULL;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder uid_t uid;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder gid_t gid;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder struct resp_attrs *attrs = NULL;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder if (retoid == NULL || retdata == NULL) {
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("Missing OID or data.\n"));
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder return EINVAL;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder }
fd94a6f66ccb5cef99aa42069b61e4b8734dbd3fChristian Maeder
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder if (strcmp(retoid, EXOP_SID2NAME_OID) != 0) {
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder DEBUG(SSSDBG_OP_FAILURE,
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder ("Result has wrong OID, expected [%s], got [%s].\n",
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder EXOP_SID2NAME_OID, retoid));
de8eee2014437ec4020be15cd363257f87e79943Christian Maeder return EINVAL;
de8eee2014437ec4020be15cd363257f87e79943Christian Maeder }
de8eee2014437ec4020be15cd363257f87e79943Christian Maeder
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder ber = ber_init(retdata);
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder if (ber == NULL) {
de8eee2014437ec4020be15cd363257f87e79943Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ber_init failed.\n"));
de8eee2014437ec4020be15cd363257f87e79943Christian Maeder return EINVAL;
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder }
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder tag = ber_scanf(ber, "{e", &type);
5a448e9be8c4482a978b174b744237757335140fChristian Maeder if (tag == LBER_ERROR) {
5a448e9be8c4482a978b174b744237757335140fChristian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ber_scanf failed.\n"));
bd90cf050d470eb42f6e0b79327cc53bd0f80dc9Christian Maeder ret = EINVAL;
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder goto done;
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder }
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder attrs = talloc_zero(mem_ctx, struct resp_attrs);
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder if (attrs == NULL) {
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("talloc_zero failed.\n"));
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder ret = ENOMEM;
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder goto done;
142fd5dd7fcfa170f08b2a0ab232859428f6e3c2Christian Maeder }
142fd5dd7fcfa170f08b2a0ab232859428f6e3c2Christian Maeder
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder switch (type) {
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder case RESP_USER:
3f08b178a44369b618a5e0b5f1fc2207fe043aabChristian Maeder tag = ber_scanf(ber, "{aaii}}", &domain_name, &name, &uid, &gid);
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder if (tag == LBER_ERROR) {
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ber_scanf failed.\n"));
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder ret = EINVAL;
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder goto done;
3e87e1dc85fa76cc6eaeb8eafbc0bea77af939f4Christian Maeder }
3f08b178a44369b618a5e0b5f1fc2207fe043aabChristian Maeder
3f08b178a44369b618a5e0b5f1fc2207fe043aabChristian Maeder /* Winbind is not consistent with the case of the returned user
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder * name. In general all names should be lower case but there are
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder * bug in some version of winbind which might lead to upper case
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder * letters in the name. To be on the safe side we explicitly
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder * lowercase the name. */
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder attrs->a.user.pw_name = sss_tc_utf8_str_tolower(attrs, name);
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder if (attrs->a.user.pw_name == NULL) {
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n"));
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder ret = ENOMEM;
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder goto done;
59fa2ed5a4936e7e56f7164d8a274df68dd4160cSimon Ulbricht }
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder attrs->a.user.pw_uid = uid;
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder attrs->a.user.pw_gid = gid;
ef1c24c8229ade3ac872febebd18c181e32fb9c4Christian Maeder
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder break;
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder case RESP_GROUP:
fd94a6f66ccb5cef99aa42069b61e4b8734dbd3fChristian Maeder tag = ber_scanf(ber, "{aai}}", &domain_name, &name, &gid);
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder if (tag == LBER_ERROR) {
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ber_scanf failed.\n"));
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder ret = EINVAL;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder goto done;
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder }
4ed68712ee368cbebfeaa327968583cb022e3c72Christian Maeder
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder attrs->a.group.gr_name = talloc_strdup(attrs, name);
4d54e7814b18ce142359c92a5868e6dcff9219b5Christian Maeder if (attrs->a.group.gr_name == NULL) {
4d54e7814b18ce142359c92a5868e6dcff9219b5Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n"));
142fd5dd7fcfa170f08b2a0ab232859428f6e3c2Christian Maeder ret = ENOMEM;
4d54e7814b18ce142359c92a5868e6dcff9219b5Christian Maeder goto done;
7be1485dfcaa5decb3586d194ff4b2443668e349Simon Ulbricht }
7be1485dfcaa5decb3586d194ff4b2443668e349Simon Ulbricht
7be1485dfcaa5decb3586d194ff4b2443668e349Simon Ulbricht attrs->a.group.gr_gid = gid;
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder break;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder default:
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder DEBUG(SSSDBG_OP_FAILURE, ("Unexpected response type [%d].\n",
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder type));
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder ret = EINVAL;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder goto done;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder }
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder attrs->response_type = type;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder attrs->domain_name = talloc_strdup(attrs, domain_name);
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder if (attrs->domain_name == NULL) {
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n"));
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder ret = ENOMEM;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder goto done;
7a3e20d1b7fe1b0e47c0b9138716b0bbc8ecf1f6Christian Maeder }
7a3e20d1b7fe1b0e47c0b9138716b0bbc8ecf1f6Christian Maeder
7a3e20d1b7fe1b0e47c0b9138716b0bbc8ecf1f6Christian Maeder ret = EOK;
7a3e20d1b7fe1b0e47c0b9138716b0bbc8ecf1f6Christian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maederdone:
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder ber_memfree(domain_name);
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder ber_memfree(name);
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder ber_free(ber, 1);
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder if (ret == EOK) {
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder *resp_attrs = attrs;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder } else {
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder talloc_free(attrs);
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder }
be9d4ffdd00c0665f9c25a4a905b0a0bf0c90bbfChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder return ret;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder}
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maederstruct ipa_s2n_get_user_state {
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder struct tevent_context *ev;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder struct sdap_options *opts;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder struct sss_domain_info *dom;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder struct sdap_handle *sh;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder const char **expected_attrs;
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder};
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maederstatic void ipa_s2n_get_user_done(struct tevent_req *subreq);
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder
f675b8f0a612e37472640da57b48d795bef4427eChristian Maederstruct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx,
275698320a734a6fd647ea6a461d6ce38862da1dChristian Maeder struct tevent_context *ev,
f675b8f0a612e37472640da57b48d795bef4427eChristian Maeder struct sdap_options *opts,
526e7f36639cb58e3c99a54bea082499a6b04a25Christian Maeder struct sss_domain_info *dom,
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder struct sdap_handle *sh,
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder const char **attrs,
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder int entry_type,
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder const char *name,
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder uint32_t id)
05c714be15ce094d83f1b989cdf5236be78419bfSimon Ulbricht{
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder struct ipa_s2n_get_user_state *state;
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht struct tevent_req *req;
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht struct tevent_req *subreq;
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht struct berval *bv_req = NULL;
7463a1bf64cfa90917e2afb6a5017ec411d2b3dbSimon Ulbricht int ret = EFAULT;
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder if ((name == NULL && id == 0) || (name != NULL && id != 0)) {
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("Either a user name or a uid expected, "
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder "not both or nothing.\n"));
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder return NULL;
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht }
7463a1bf64cfa90917e2afb6a5017ec411d2b3dbSimon Ulbricht
cc9f19b1fe81424205736fe0ae73620395b1bb74Simon Ulbricht req = tevent_req_create(mem_ctx, &state, struct ipa_s2n_get_user_state);
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder if (req == NULL) {
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder return NULL;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht }
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht state->ev = ev;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht state->opts = opts;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht state->dom = dom;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder state->sh = sh;
029d127079d24fa541e0bbba0133bc273268dd4eSimon Ulbricht state->expected_attrs = attrs;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder
d864f0a0e04e61b5f87963496765eafcf646ed7bChristian Maeder ret = s2n_encode_request(state, dom->name, entry_type, name, id, &bv_req);
4d54e7814b18ce142359c92a5868e6dcff9219b5Christian Maeder if (ret != EOK) {
e80bbb632bd22010c079852e652d843a15bb133dChristian Maeder goto fail;
486db0a875bcdd0b80cf0d447d14c9c00a92ae94Simon Ulbricht }
a07a6a1143844a6f061a49aefc550e3bdd28f331Christian Maeder
a07a6a1143844a6f061a49aefc550e3bdd28f331Christian Maeder subreq = ipa_s2n_exop_send(state, state->ev, state->sh, bv_req);
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder if (subreq == NULL) {
ea5ccb1c6e89486a54e1f4bd95840147e96093edChristian Maeder DEBUG(SSSDBG_OP_FAILURE, ("ipa_s2n_exop_send failed.\n"));
029d127079d24fa541e0bbba0133bc273268dd4eSimon Ulbricht ret = ENOMEM;
10eaa95e20c860acbfbecd6cf07e3ae0bf7b55cbSimon Ulbricht goto fail;
10eaa95e20c860acbfbecd6cf07e3ae0bf7b55cbSimon Ulbricht }
04c445e50a1d8b95e667595594e6b551c8b2ff59Simon Ulbricht tevent_req_set_callback(subreq, ipa_s2n_get_user_done, req);
10eaa95e20c860acbfbecd6cf07e3ae0bf7b55cbSimon Ulbricht
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbricht return req;
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbricht
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbrichtfail:
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbricht tevent_req_error(req, ret);
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbricht tevent_req_post(req, ev);
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbricht
e6c31a14c3fe6eb0eb93f376f2224f4023315e55Simon Ulbricht return req;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder}
b0bf54186358372d2be6a95e36ed3ef5fd64b7a3Christian Maeder
7c661ba558707feaa5d8a299365c2191e1afabb2Christian Maederstatic void ipa_s2n_get_user_done(struct tevent_req *subreq)
7c661ba558707feaa5d8a299365c2191e1afabb2Christian Maeder{
7c661ba558707feaa5d8a299365c2191e1afabb2Christian Maeder struct tevent_req *req = tevent_req_callback_data(subreq,
7c661ba558707feaa5d8a299365c2191e1afabb2Christian Maeder struct tevent_req);
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder struct ipa_s2n_get_user_state *state = tevent_req_data(req,
8ca6b0820806f62042d84a1fff11599db55591c4Christian Maeder struct ipa_s2n_get_user_state);
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder int ret;
029d127079d24fa541e0bbba0133bc273268dd4eSimon Ulbricht enum sdap_result result;
029d127079d24fa541e0bbba0133bc273268dd4eSimon Ulbricht char *retoid = NULL;
7c661ba558707feaa5d8a299365c2191e1afabb2Christian Maeder struct berval *retdata = NULL;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder struct resp_attrs *attrs;
5bedf8c26d27eac08962c78379bcb2e5cb529036Christian Maeder time_t now;
5896f38ba2934056542cb7cb3e6359e88a622547Christian Maeder uint64_t timeout = 10*60*60; /* FIXME: find a better timeout ! */
23ee432f8fe96e07f2523ca7c4bda9bcce1ea6f0Simon Ulbricht const char *homedir = NULL;
23ee432f8fe96e07f2523ca7c4bda9bcce1ea6f0Simon Ulbricht struct sysdb_attrs *user_attrs = NULL;
23ee432f8fe96e07f2523ca7c4bda9bcce1ea6f0Simon Ulbricht
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder ret = ipa_s2n_exop_recv(subreq, state, &result, &retoid, &retdata);
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder talloc_zfree(subreq);
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder if (ret != EOK) {
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("s2n exop request failed.\n"));
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder goto done;
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder }
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder ret = s2n_response_to_attrs(state, retoid, retdata, &attrs);
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder if (ret != EOK) {
43d8d7472d3a0a78d9a2c85122815a81deb8689aChristian Maeder DEBUG(SSSDBG_OP_FAILURE, ("s2n_response_to_attrs failed.\n"));
c99b0eb6632087d502dd4269599c5aa68a148eebSimon Ulbricht goto done;
bb9642ff292545658dc11251b83a7b7af3c1fccbChristian Maeder }
be1ce1c2b2819ef32743136c13101f1927375311Christian Maeder
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder if (!(strcasecmp(state->dom->name, attrs->domain_name) == 0 ||
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder (state->dom->flat_name != NULL &&
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder strcasecmp(state->dom->flat_name, attrs->domain_name) == 0))) {
486db0a875bcdd0b80cf0d447d14c9c00a92ae94Simon Ulbricht DEBUG(SSSDBG_OP_FAILURE, ("Unexpected domain name returned, "
486db0a875bcdd0b80cf0d447d14c9c00a92ae94Simon Ulbricht "expected [%s] or [%s], got [%s].\n",
be1ce1c2b2819ef32743136c13101f1927375311Christian Maeder state->dom->name,
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder state->dom->flat_name == NULL ? "" : state->dom->flat_name,
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder attrs->domain_name));
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder ret = EINVAL;
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder goto done;
cdae1f4c0c6e32f5463a7ce9986600e27f8ac253Christian Maeder }
aed438ce70de05d86d51932a078d829a3f6be5c2Christian Maeder
cdae1f4c0c6e32f5463a7ce9986600e27f8ac253Christian Maeder now = time(NULL);
aed438ce70de05d86d51932a078d829a3f6be5c2Christian Maeder
aed438ce70de05d86d51932a078d829a3f6be5c2Christian Maeder switch (attrs->response_type) {
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht case RESP_USER:
aed438ce70de05d86d51932a078d829a3f6be5c2Christian Maeder if (state->dom->subdomain_homedir) {
aed438ce70de05d86d51932a078d829a3f6be5c2Christian Maeder homedir = expand_homedir_template(state,
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder state->dom->subdomain_homedir,
e80bbb632bd22010c079852e652d843a15bb133dChristian Maeder attrs->a.user.pw_name,
92b34c379207fb8752258be174cb8ef4162dc865Simon Ulbricht attrs->a.user.pw_uid,
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder state->dom->name);
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder if (homedir == NULL) {
5727dbcb926ede2e7b05f43685476ce656ce01e4Christian Maeder ret = ENOMEM;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder goto done;
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder }
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder }
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder
18548c6cc2dff13bf9f5f08b3f6cde6ca914df1dChristian Maeder user_attrs = sysdb_new_attrs(state);
df67ddf64192bfcae6ece65255ad796a17cbe532Christian Maeder if (user_attrs == NULL) {
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht DEBUG(SSSDBG_OP_FAILURE, ("sysdb_new_attrs failed.\n"));
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht ret = ENOMEM;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht goto done;
2e76bbbed1c936bb0aee1753837e1c50416847a2Simon Ulbricht }
37c793236d73cd400bb268672e0d0f7f97a89a70Simon Ulbricht
2e2559f894aaa661b199e4fa00609f522bc5482aSimon Ulbricht ret = sysdb_attrs_add_string(user_attrs, SYSDB_NAME_ALIAS,
2e2559f894aaa661b199e4fa00609f522bc5482aSimon Ulbricht attrs->a.user.pw_name);
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht if (ret != EOK) {
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_add_string failed.\n"));
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht goto done;
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht }
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht ret = sysdb_store_domuser(state->dom, attrs->a.user.pw_name, NULL,
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht attrs->a.user.pw_uid,
7cb31cb2104c666b2762976f7ed86da10575a980Simon Ulbricht 0, NULL, /* gecos */
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht homedir, NULL,
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht user_attrs, NULL, timeout, now);
92b34c379207fb8752258be174cb8ef4162dc865Simon Ulbricht break;
92b34c379207fb8752258be174cb8ef4162dc865Simon Ulbricht case RESP_GROUP:
de04c8b0fb11f38a905bdb08a6156f5aa6dc3169Simon Ulbricht ret = sysdb_store_domgroup(state->dom, attrs->a.group.gr_name,
993e01fc242fa58d3dcf1b3272cd411726817eeeSimon Ulbricht attrs->a.group.gr_gid, NULL, timeout,
d5a6311a0badccb57c915d3f7d0657615338e12cSimon Ulbricht now);
37c793236d73cd400bb268672e0d0f7f97a89a70Simon Ulbricht break;
d5a6311a0badccb57c915d3f7d0657615338e12cSimon Ulbricht default:
37c793236d73cd400bb268672e0d0f7f97a89a70Simon Ulbricht DEBUG(SSSDBG_OP_FAILURE, ("Unexpected response type [%d].\n",
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht attrs->response_type));
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht ret = EINVAL;
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht goto done;
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht }
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht
029d127079d24fa541e0bbba0133bc273268dd4eSimon Ulbricht
37c793236d73cd400bb268672e0d0f7f97a89a70Simon Ulbrichtdone:
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht talloc_free(user_attrs);
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht if (ret == EOK) {
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht tevent_req_done(req);
7f81535ccbe97ecc332b8c03d6c137b92e4ac4aaSimon Ulbricht } else {
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht tevent_req_error(req, ret);
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht }
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht return;
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht}
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbrichtint ipa_s2n_get_acct_info_recv(struct tevent_req *req)
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht{
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht TEVENT_REQ_RETURN_ON_ERROR(req);
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht return EOK;
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht}
2b1abe6d680bc23b703f7ffbf6d214be15aa9f1fSimon Ulbricht