/*
SSSD
Service monitor - D-BUS features
Copyright (C) Stephen Gallagher 2008
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 <tevent.h>
#include <limits.h>
#include "sbus/sssd_dbus.h"
#include "sbus/sssd_dbus_private.h"
static int sbus_server_destructor(void *ctx);
struct new_connection_data {
void *client_destructor_data;
};
/*
* new_connection_callback
* Actions to be run upon each new client connection
* Must either perform dbus_connection_ref() on the
* new connection or else close the connection with
* dbus_connection_close()
*/
void *data)
{
int ret;
if (!ncd) {
return;
}
if (ret != 0) {
return;
}
/*
* Initialize connection-specific features
* This function (or its callbacks) should also
* set up connection-specific methods.
*/
}
}
const char *
{
if (!use_symlink) {
}
return talloc_asprintf(mem_ctx,
}
static errno_t
{
errno = 0;
/* Perhaps cruft after a previous server? */
errno = 0;
if (ret != 0) {
"Cannot remove old symlink '%s': [%d][%s].\n",
return EIO;
}
errno = 0;
}
if (ret != 0) {
return EIO;
}
return EOK;
}
static errno_t
{
errno = 0;
if (numread < 0) {
return ret;
}
/* We can only remove the symlink if it points to a socket with
* the same PID */
symlink_name, (unsigned long) getpid());
if (ret < 0) {
return EIO;
return EIO;
}
"Will not remove symlink, seems to be owned by "
"another process\n");
return EOK;
}
if (ret != 0) {
"unlink failed to remove [%s] [%d]: %s\n",
return ret;
}
return EOK;
}
/*
* dbus_new_server
* Set up a D-BUS server, integrate with the event loop
* for handling file descriptor and timed events
*/
struct tevent_context *ev,
const char *address,
bool use_symlink,
struct sbus_connection **_server,
void *init_pvt_data,
void *client_destructor_data)
{
char *tmp;
char *filename;
const char *socket_address;
if (!socket_address) {
goto done;
}
/* Set up D-BUS server */
if (!dbus_server) {
"dbus_server_listen failed! (name=%s, message=%s)\n",
goto done;
}
"Unexpected dbus address [%s].\n", socket_address);
goto done;
}
if (use_symlink) {
if (symlink_filename == NULL) {
"Unexpected dbus address [%s].\n", address);
goto done;
}
goto done;
}
}
/* Both check_file and chmod can handle both the symlink and
* the socket */
goto done;
}
sss_strerror(ret));
goto done;
}
}
sss_strerror(ret));
goto done;
}
}
if (!server) {
goto done;
}
if (use_symlink) {
goto done;
}
}
/* This structure must be alive while server is alive. That's the
* reason for using server as its talloc context.
*/
if (!ncd) {
goto done;
}
/* Set up D-BUS new connection handler */
/* Set up DBusWatch functions */
if (!dbret) {
"Error setting up D-BUS server watch functions\n");
goto done;
}
/* Set up DBusTimeout functions */
if (!dbret) {
"Error setting up D-BUS server timeout functions\n");
goto done;
}
done:
/* non-fatal failure */
"Failed to remove symbolic link '%s': %d [%s]!\n",
}
}
return ret;
}
{
"Could not remove the server symlink\n");
}
}
return 0;
}