sbus_client.c revision 9a592ee3fc195f20732c6b1f90894a0be25ccc19
fdbad18e66c0e293f94694458d47df305f050c71Christian Maeder/*
fdbad18e66c0e293f94694458d47df305f050c71Christian Maeder SSSD
fdbad18e66c0e293f94694458d47df305f050c71Christian Maeder
fdbad18e66c0e293f94694458d47df305f050c71Christian Maeder Data Provider Helpers
5214cf3742dc626a7efc5ec851db09bf0ff1f579Christian Maeder
5214cf3742dc626a7efc5ec851db09bf0ff1f579Christian Maeder Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
b96b500ba4430269d97a08f07de87838278e9c5dChristian Maeder
b96b500ba4430269d97a08f07de87838278e9c5dChristian Maeder This program is free software; you can redistribute it and/or modify
5214cf3742dc626a7efc5ec851db09bf0ff1f579Christian Maeder it under the terms of the GNU General Public License as published by
5214cf3742dc626a7efc5ec851db09bf0ff1f579Christian Maeder the Free Software Foundation; either version 3 of the License, or
5214cf3742dc626a7efc5ec851db09bf0ff1f579Christian Maeder (at your option) any later version.
5214cf3742dc626a7efc5ec851db09bf0ff1f579Christian Maeder
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 <talloc.h>
#include "util/util.h"
#include "sbus_client.h"
int sbus_client_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const char *server_address,
struct sbus_connection **_conn)
{
struct sbus_connection *conn = NULL;
int ret;
char *filename;
/* Validate input */
if (server_address == NULL) {
return EINVAL;
}
filename = strchr(server_address, '/');
if (filename == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Unexpected dbus address [%s].\n", server_address);
return EIO;
}
ret = check_file(filename,
0, 0, S_IFSOCK|S_IRUSR|S_IWUSR, 0, NULL, true);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "check_file failed for [%s].\n", filename);
return EIO;
}
ret = sbus_new_connection(mem_ctx, ev, server_address, &conn);
if (ret != EOK) {
goto fail;
}
*_conn = conn;
return EOK;
fail:
talloc_free(conn);
return ret;
}