Skip to content

Commit

Permalink
change asserts to simple checks
Browse files Browse the repository at this point in the history
we don't want the daemon to exit out due to bad client output,
just to not go on and choke on it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
hallyn committed Nov 29, 2013
1 parent 6501684 commit 1359b58
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cgmanager.c
Expand Up @@ -63,11 +63,13 @@ int cgmanager_create (void *data, NihDBusMessage *message,
const char *controller, char *cgroup)
{
int fd = 0, ret;
nih_assert (message != NULL);
struct ucred ucred;
socklen_t len;
char rcgpath[MAXPATHLEN], path[MAXPATHLEN], *copy, *fnam, *dnam;

if (message == NULL)
return -1;

if (!dbus_connection_get_socket(message->connection, &fd)) {
nih_dbus_error_raise_printf (DBUS_ERROR_INVALID_ARGS,
"Could not get client socket.");
Expand Down Expand Up @@ -161,11 +163,13 @@ int cgmanager_get_my_cgroup (void *data, NihDBusMessage *message,
const char *controller, char **value)
{
int fd = 0;
nih_assert (message != NULL);
struct ucred ucred;
socklen_t len;
char path[MAXPATHLEN];

if (message == NULL)
return -1;

const char *controller_path = get_controller_path(controller);
if (!controller_path)
return -1;
Expand Down Expand Up @@ -202,11 +206,13 @@ int cgmanager_get_value (void *data, NihDBusMessage *message,

{
int fd = 0;
nih_assert (message != NULL);
struct ucred ucred;
socklen_t len;
char path[MAXPATHLEN], *fullpath;

if (message == NULL)
return -1;

if (!dbus_connection_get_socket(message->connection, &fd)) {
nih_dbus_error_raise_printf (DBUS_ERROR_INVALID_ARGS,
"Could not get client socket.");
Expand Down Expand Up @@ -263,8 +269,8 @@ static dbus_bool_t allow_user(DBusConnection *connection, unsigned long uid, voi
static int
client_connect (DBusServer *server, DBusConnection *conn)
{
nih_assert (server != NULL);
nih_assert (conn != NULL);
if (server == NULL || conn == NULL)
return FALSE;

dbus_connection_set_unix_user_function(conn, allow_user, NULL, NULL);

Expand All @@ -280,7 +286,8 @@ client_connect (DBusServer *server, DBusConnection *conn)
static void
client_disconnect (DBusConnection *conn)
{
nih_assert (conn != NULL);
if (conn == NULL)
return;

nih_info (_("Disconnected from private client"));
}
Expand Down

0 comments on commit 1359b58

Please sign in to comment.