summaryrefslogtreecommitdiffstats
path: root/src/providers/proxy
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-11 12:25:53 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-21 22:17:34 +0100
commit8e5549e453558d4bebdec333a93e215d5d6ffaec (patch)
treea9004b07b800492ecb8bdaeb2019512c3fccb229 /src/providers/proxy
parentccc2af010bbbe6d8a7496fb717216135bc4c1993 (diff)
downloadsssd-8e5549e453558d4bebdec333a93e215d5d6ffaec.tar.gz
sssd-8e5549e453558d4bebdec333a93e215d5d6ffaec.tar.xz
sssd-8e5549e453558d4bebdec333a93e215d5d6ffaec.zip
Introduce be_req_terminate() helper
Call it everywhere instead of directly dereferencing be_req->fn This is in preparation of making be_req opaque.
Diffstat (limited to 'src/providers/proxy')
-rw-r--r--src/providers/proxy/proxy.h4
-rw-r--r--src/providers/proxy/proxy_auth.c12
-rw-r--r--src/providers/proxy/proxy_common.c31
-rw-r--r--src/providers/proxy/proxy_id.c34
-rw-r--r--src/providers/proxy/proxy_init.c4
5 files changed, 25 insertions, 60 deletions
diff --git a/src/providers/proxy/proxy.h b/src/providers/proxy/proxy.h
index 962cb28fc..305cbe978 100644
--- a/src/providers/proxy/proxy.h
+++ b/src/providers/proxy/proxy.h
@@ -142,10 +142,6 @@ struct pc_init_ctx {
#define DEFAULT_BUFSIZE 4096
#define MAX_BUF_SIZE 1024*1024 /* max 1MiB */
-/* From proxy_common.c */
-void proxy_reply(struct be_req *req, int dp_err,
- int error, const char *errstr);
-
/* From proxy_id.c */
void proxy_get_account_info(struct be_req *breq);
diff --git a/src/providers/proxy/proxy_auth.c b/src/providers/proxy/proxy_auth.c
index 02a95fe6d..7b6a26f57 100644
--- a/src/providers/proxy/proxy_auth.c
+++ b/src/providers/proxy/proxy_auth.c
@@ -60,18 +60,18 @@ void proxy_pam_handler(struct be_req *req)
case SSS_PAM_OPEN_SESSION:
case SSS_PAM_CLOSE_SESSION:
pd->pam_status = PAM_SUCCESS;
- proxy_reply(req, DP_ERR_OK, EOK, NULL);
+ be_req_terminate(req, DP_ERR_OK, EOK, NULL);
return;
default:
DEBUG(1, ("Unsupported PAM task.\n"));
pd->pam_status = PAM_MODULE_UNKNOWN;
- proxy_reply(req, DP_ERR_OK, EINVAL, "Unsupported PAM task");
+ be_req_terminate(req, DP_ERR_OK, EINVAL, "Unsupported PAM task");
return;
}
client_ctx = talloc(req, struct proxy_client_ctx);
if (client_ctx == NULL) {
- proxy_reply(req, DP_ERR_FATAL, ENOMEM, NULL);
+ be_req_terminate(req, DP_ERR_FATAL, ENOMEM, NULL);
return;
}
client_ctx->auth_ctx = ctx;
@@ -85,7 +85,7 @@ void proxy_pam_handler(struct be_req *req)
/* Could not queue request
* Return an error
*/
- proxy_reply(req, DP_ERR_FATAL, EINVAL, "Could not queue request\n");
+ be_req_terminate(req, DP_ERR_FATAL, EINVAL, "Could not queue request\n");
return;
}
tevent_req_set_callback(child_req, proxy_child_done, client_ctx);
@@ -740,7 +740,7 @@ static void proxy_child_done(struct tevent_req *req)
if (ret != EOK) {
/* Pam child failed */
- proxy_reply(client_ctx->be_req, DP_ERR_FATAL, ret,
+ be_req_terminate(client_ctx->be_req, DP_ERR_FATAL, ret,
"PAM child failed");
return;
}
@@ -770,7 +770,7 @@ static void proxy_child_done(struct tevent_req *req)
}
done:
- proxy_reply(client_ctx->be_req, DP_ERR_OK, EOK, NULL);
+ be_req_terminate(client_ctx->be_req, DP_ERR_OK, EOK, NULL);
}
static void run_proxy_child_queue(struct tevent_context *ev,
diff --git a/src/providers/proxy/proxy_common.c b/src/providers/proxy/proxy_common.c
deleted file mode 100644
index 6d5c455c2..000000000
--- a/src/providers/proxy/proxy_common.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- SSSD
-
- proxy_common.c
-
- Authors:
- Stephen Gallagher <sgallagh@redhat.com>
-
- Copyright (C) 2010 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/>.
-*/
-
-#include "providers/proxy/proxy.h"
-
-void proxy_reply(struct be_req *req, int dp_err,
- int error, const char *errstr)
-{
- return req->fn(req, dp_err, error, errstr);
-}
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index 33869e5a7..a4f7b19ef 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -1355,12 +1355,12 @@ void proxy_get_account_info(struct be_req *breq)
domain = breq->be_ctx->domain;
if (be_is_offline(breq->be_ctx)) {
- return proxy_reply(breq, DP_ERR_OFFLINE, EAGAIN, "Offline");
+ return be_req_terminate(breq, DP_ERR_OFFLINE, EAGAIN, "Offline");
}
/* for now we support only core attrs */
if (ar->attr_type != BE_ATTR_CORE) {
- return proxy_reply(breq, DP_ERR_FATAL, EINVAL, "Invalid attr type");
+ return be_req_terminate(breq, DP_ERR_FATAL, EINVAL, "Invalid attr type");
}
switch (ar->entry_type & BE_REQ_TYPE_MASK) {
@@ -1377,13 +1377,13 @@ void proxy_get_account_info(struct be_req *breq)
case BE_FILTER_IDNUM:
uid = (uid_t) strtouint32(ar->filter_value, &endptr, 10);
if (errno || *endptr || (ar->filter_value == endptr)) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid attr type");
}
ret = get_pw_uid(breq, ctx, sysdb, domain, uid);
break;
default:
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid filter type");
}
break;
@@ -1399,24 +1399,24 @@ void proxy_get_account_info(struct be_req *breq)
case BE_FILTER_IDNUM:
gid = (gid_t) strtouint32(ar->filter_value, &endptr, 10);
if (errno || *endptr || (ar->filter_value == endptr)) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid attr type");
}
ret = get_gr_gid(breq, ctx, sysdb, domain, gid, 0);
break;
default:
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid filter type");
}
break;
case BE_REQ_INITGROUPS: /* init groups for user */
if (ar->filter_type != BE_FILTER_NAME) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid filter type");
}
if (ctx->ops.initgroups_dyn == NULL) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
ENODEV, "Initgroups call not supported");
}
ret = get_initgr(breq, ctx, sysdb, domain, ar->filter_value);
@@ -1424,12 +1424,12 @@ void proxy_get_account_info(struct be_req *breq)
case BE_REQ_NETGROUP:
if (ar->filter_type != BE_FILTER_NAME) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid filter type");
}
if (ctx->ops.setnetgrent == NULL || ctx->ops.getnetgrent_r == NULL ||
ctx->ops.endnetgrent == NULL) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
ENODEV, "Netgroups are not supported");
}
@@ -1440,7 +1440,7 @@ void proxy_get_account_info(struct be_req *breq)
switch (ar->filter_type) {
case BE_FILTER_NAME:
if (ctx->ops.getservbyname_r == NULL) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
ENODEV, "Services are not supported");
}
ret = get_serv_byname(ctx, sysdb, domain,
@@ -1449,7 +1449,7 @@ void proxy_get_account_info(struct be_req *breq)
break;
case BE_FILTER_IDNUM:
if (ctx->ops.getservbyport_r == NULL) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
ENODEV, "Services are not supported");
}
ret = get_serv_byport(ctx, sysdb, domain,
@@ -1460,19 +1460,19 @@ void proxy_get_account_info(struct be_req *breq)
if (!ctx->ops.setservent
|| !ctx->ops.getservent_r
|| !ctx->ops.endservent) {
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
ENODEV, "Services are not supported");
}
ret = enum_services(ctx, sysdb, domain);
break;
default:
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid filter type");
}
break;
default: /*fail*/
- return proxy_reply(breq, DP_ERR_FATAL,
+ return be_req_terminate(breq, DP_ERR_FATAL,
EINVAL, "Invalid request type");
}
@@ -1481,8 +1481,8 @@ void proxy_get_account_info(struct be_req *breq)
DEBUG(2, ("proxy returned UNAVAIL error, going offline!\n"));
be_mark_offline(breq->be_ctx);
}
- proxy_reply(breq, DP_ERR_FATAL, ret, NULL);
+ be_req_terminate(breq, DP_ERR_FATAL, ret, NULL);
return;
}
- proxy_reply(breq, DP_ERR_OK, EOK, NULL);
+ be_req_terminate(breq, DP_ERR_OK, EOK, NULL);
}
diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c
index de4d7b615..bb071688d 100644
--- a/src/providers/proxy/proxy_init.c
+++ b/src/providers/proxy/proxy_init.c
@@ -43,13 +43,13 @@ struct sbus_interface proxy_interface = {
static void proxy_shutdown(struct be_req *req)
{
/* TODO: Clean up any internal data */
- req->fn(req, DP_ERR_OK, EOK, NULL);
+ be_req_terminate(req, DP_ERR_OK, EOK, NULL);
}
static void proxy_auth_shutdown(struct be_req *req)
{
talloc_free(req->be_ctx->bet_info[BET_AUTH].pvt_bet_data);
- req->fn(req, DP_ERR_OK, EOK, NULL);
+ be_req_terminate(req, DP_ERR_OK, EOK, NULL);
}
struct bet_ops proxy_id_ops = {