LCOV - code coverage report
Current view: top level - providers/data_provider - dp.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 48 0.0 %
Date: 2016-06-29 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :     Authors:
       3             :         Pavel Březina <pbrezina@redhat.com>
       4             : 
       5             :     Copyright (C) 2016 Red Hat
       6             : 
       7             :     This program is free software; you can redistribute it and/or modify
       8             :     it under the terms of the GNU General Public License as published by
       9             :     the Free Software Foundation; either version 3 of the License, or
      10             :     (at your option) any later version.
      11             : 
      12             :     This program is distributed in the hope that it will be useful,
      13             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :     GNU General Public License for more details.
      16             : 
      17             :     You should have received a copy of the GNU General Public License
      18             :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include <talloc.h>
      22             : 
      23             : #include "config.h"
      24             : #include "providers/data_provider/dp.h"
      25             : #include "providers/data_provider/dp_private.h"
      26             : #include "providers/backend.h"
      27             : #include "util/util.h"
      28             : 
      29           0 : static errno_t dp_init_dbus_server(struct data_provider *provider)
      30             : {
      31             :     const char *domain;
      32             :     char *sbus_address;
      33             :     errno_t ret;
      34             : 
      35           0 :     domain = provider->be_ctx->domain->name;
      36           0 :     ret = dp_get_sbus_address(NULL, &sbus_address, domain);
      37           0 :     if (ret != EOK) {
      38           0 :         DEBUG(SSSDBG_FATAL_FAILURE, "Could not get sbus backend address.\n");
      39           0 :         return ret;
      40             :     }
      41             : 
      42           0 :     ret = sbus_new_server(provider, provider->ev, sbus_address,
      43             :                           provider->uid, provider->gid, true,
      44             :                           &provider->srv_conn,
      45             :                           dp_client_init, provider);
      46           0 :     talloc_free(sbus_address);
      47           0 :     if (ret != EOK) {
      48           0 :         DEBUG(SSSDBG_FATAL_FAILURE, "Could not set up sbus server.\n");
      49           0 :         return ret;
      50             :     }
      51             : 
      52           0 :     return EOK;
      53             : }
      54             : 
      55           0 : static int dp_destructor(struct data_provider *provider)
      56             : {
      57             :     enum dp_clients client;
      58             : 
      59           0 :     provider->terminating = true;
      60             : 
      61           0 :     dp_terminate_active_requests(provider);
      62             : 
      63           0 :     for (client = 0; client != DP_CLIENT_SENTINEL; client++) {
      64           0 :         talloc_zfree(provider->clients[client]);
      65             :     }
      66             : 
      67           0 :     return 0;
      68             : }
      69             : 
      70           0 : errno_t dp_init(struct tevent_context *ev,
      71             :                 struct be_ctx *be_ctx,
      72             :                 uid_t uid,
      73             :                 gid_t gid)
      74             : {
      75             :     struct data_provider *provider;
      76             : 
      77             :     errno_t ret;
      78             : 
      79           0 :     provider = talloc_zero(be_ctx, struct data_provider);
      80           0 :     if (provider == NULL) {
      81           0 :         return ENOMEM;
      82             :     }
      83             : 
      84           0 :     provider->ev = ev;
      85           0 :     provider->uid = uid;
      86           0 :     provider->gid = gid;
      87           0 :     provider->be_ctx = be_ctx;
      88             : 
      89           0 :     ret = dp_req_table_init(provider, &provider->requests.reply_table);
      90           0 :     if (ret != EOK) {
      91           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize request table "
      92             :               "[%d]: %s\n", ret, sss_strerror(ret));
      93           0 :         goto done;
      94             :     }
      95             : 
      96           0 :     ret = dp_init_modules(provider, &provider->modules);
      97           0 :     if (ret != EOK) {
      98           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP modules "
      99             :               "[%d]: %s\n", ret, sss_strerror(ret));
     100           0 :         goto done;
     101             :     }
     102             : 
     103           0 :     ret = dp_init_targets(provider, be_ctx, provider, provider->modules);
     104           0 :     if (ret != EOK) {
     105           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP targets "
     106             :               "[%d]: %s\n", ret, sss_strerror(ret));
     107           0 :         goto done;
     108             :     }
     109             : 
     110           0 :     talloc_set_destructor(provider, dp_destructor);
     111             : 
     112           0 :     ret = dp_init_dbus_server(provider);
     113           0 :     if (ret != EOK) {
     114           0 :         DEBUG(SSSDBG_FATAL_FAILURE, "Unable to setup service bus [%d]: %s\n",
     115             :               ret, sss_strerror(ret));
     116           0 :         goto done;
     117             :     }
     118             : 
     119           0 :     be_ctx->provider = provider;
     120             : 
     121           0 :     ret = EOK;
     122             : 
     123             : done:
     124           0 :     if (ret != EOK) {
     125           0 :         talloc_free(provider);
     126             :     }
     127             : 
     128           0 :     return ret;
     129             : }

Generated by: LCOV version 1.10