bus.h 9.33 KB
Newer Older
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 3 4 5
/* bus.h  message bus context object
 *
 * Copyright (C) 2003 Red Hat, Inc.
 *
6
 * Licensed under the Academic Free License version 2.1
7
 *
8 9 10 11 12 13 14 15 16
 * 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 2 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.
17
 *
18 19
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 22 23 24 25 26 27 28
 *
 */

#ifndef BUS_BUS_H
#define BUS_BUS_H

#include <dbus/dbus.h>
#include <dbus/dbus-string.h>
29
#include <dbus/dbus-mainloop.h>
30
#include <dbus/dbus-pipe.h>
Colin Walters's avatar
Colin Walters committed
31
#include <dbus/dbus-sysdeps.h>
32

33 34 35 36 37 38 39
typedef struct BusActivation    BusActivation;
typedef struct BusConnections   BusConnections;
typedef struct BusContext       BusContext;
typedef struct BusPolicy        BusPolicy;
typedef struct BusClientPolicy  BusClientPolicy;
typedef struct BusPolicyRule    BusPolicyRule;
typedef struct BusRegistry      BusRegistry;
40
typedef struct BusSELinuxID     BusSELinuxID;
41
typedef struct BusAppArmorConfinement BusAppArmorConfinement;
42
typedef struct BusService       BusService;
43
typedef struct BusOwner		BusOwner;
44
typedef struct BusTransaction   BusTransaction;
45 46
typedef struct BusMatchmaker    BusMatchmaker;
typedef struct BusMatchRule     BusMatchRule;
47 48 49

typedef struct
{
50
  long max_incoming_bytes;          /**< How many incoming message bytes for a single connection */
51
  long max_incoming_unix_fds;       /**< How many incoming message unix fds for a single connection */
52
  long max_outgoing_bytes;          /**< How many outgoing bytes can be queued for a single connection */
53
  long max_outgoing_unix_fds;       /**< How many outgoing unix fds can be queued for a single connection */
54
  long max_message_size;            /**< Max size of a single message in bytes */
55
  long max_message_unix_fds;        /**< Max number of unix fds of a single message*/
56 57
  int activation_timeout;           /**< How long to wait for an activation to time out */
  int auth_timeout;                 /**< How long to wait for an authentication to time out */
58
  int pending_fd_timeout;           /**< How long to wait for a D-Bus message with a fd to time out */
59 60 61
  int max_completed_connections;    /**< Max number of authorized connections */
  int max_incomplete_connections;   /**< Max number of incomplete connections */
  int max_connections_per_user;     /**< Max number of connections auth'd as same user */
62 63
  int max_pending_activations;      /**< Max number of pending activations for the entire bus */
  int max_services_per_connection;  /**< Max number of owned services for a single connection */
64
  int max_match_rules_per_connection; /**< Max number of match rules for a single connection */
65 66
  int max_replies_per_connection;     /**< Max number of replies that can be pending for each connection */
  int reply_timeout;                  /**< How long to wait before timing out a reply */
67 68
} BusLimits;

69 70
typedef enum
{
71 72 73 74 75 76
  BUS_CONTEXT_FLAG_NONE = 0,
  BUS_CONTEXT_FLAG_FORK_ALWAYS = (1 << 1),
  BUS_CONTEXT_FLAG_FORK_NEVER = (1 << 2),
  BUS_CONTEXT_FLAG_WRITE_PID_FILE = (1 << 3),
  BUS_CONTEXT_FLAG_SYSTEMD_ACTIVATION = (1 << 4)
} BusContextFlags;
77

78
BusContext*       bus_context_new                                (const DBusString *config_file,
79
                                                                  BusContextFlags   flags,
80 81
                                                                  DBusPipe         *print_addr_pipe,
                                                                  DBusPipe         *print_pid_pipe,
82
                                                                  const DBusString *address,
83
                                                                  DBusError        *error);
84 85
dbus_bool_t       bus_context_reload_config                      (BusContext       *context,
								  DBusError        *error);
86
void              bus_context_shutdown                           (BusContext       *context);
87
BusContext*       bus_context_ref                                (BusContext       *context);
88
void              bus_context_unref                              (BusContext       *context);
89 90
dbus_bool_t       bus_context_get_id                             (BusContext       *context,
                                                                  DBusString       *uuid);
91 92
const char*       bus_context_get_type                           (BusContext       *context);
const char*       bus_context_get_address                        (BusContext       *context);
93
const char*       bus_context_get_servicehelper                  (BusContext       *context);
94
dbus_bool_t       bus_context_get_systemd_activation             (BusContext       *context);
95 96 97 98 99
BusRegistry*      bus_context_get_registry                       (BusContext       *context);
BusConnections*   bus_context_get_connections                    (BusContext       *context);
BusActivation*    bus_context_get_activation                     (BusContext       *context);
BusMatchmaker*    bus_context_get_matchmaker                     (BusContext       *context);
DBusLoop*         bus_context_get_loop                           (BusContext       *context);
100
dbus_bool_t       bus_context_allow_unix_user                    (BusContext       *context,
101
                                                                  unsigned long     uid);
102 103
dbus_bool_t       bus_context_allow_windows_user                 (BusContext       *context,
                                                                  const char       *windows_sid);
104 105
BusPolicy*        bus_context_get_policy                         (BusContext       *context);

106 107 108 109 110
BusClientPolicy*  bus_context_create_client_policy               (BusContext       *context,
                                                                  DBusConnection   *connection,
                                                                  DBusError        *error);
int               bus_context_get_activation_timeout             (BusContext       *context);
int               bus_context_get_auth_timeout                   (BusContext       *context);
111
int               bus_context_get_pending_fd_timeout             (BusContext       *context);
112 113 114 115 116 117
int               bus_context_get_max_completed_connections      (BusContext       *context);
int               bus_context_get_max_incomplete_connections     (BusContext       *context);
int               bus_context_get_max_connections_per_user       (BusContext       *context);
int               bus_context_get_max_pending_activations        (BusContext       *context);
int               bus_context_get_max_services_per_connection    (BusContext       *context);
int               bus_context_get_max_match_rules_per_connection (BusContext       *context);
118 119
int               bus_context_get_max_replies_per_connection     (BusContext       *context);
int               bus_context_get_reply_timeout                  (BusContext       *context);
120
DBusRLimit *      bus_context_get_initial_fd_limit               (BusContext       *context);
121 122 123
void              bus_context_log                                (BusContext       *context,
                                                                  DBusSystemLogSeverity severity,
                                                                  const char       *msg,
124
                                                                  ...) _DBUS_GNUC_PRINTF (3, 4);
125 126 127
void              bus_context_log_literal                        (BusContext       *context,
                                                                  DBusSystemLogSeverity severity,
                                                                  const char       *msg);
128 129 130 131 132 133
void              bus_context_log_and_set_error                  (BusContext       *context,
                                                                  DBusSystemLogSeverity severity,
                                                                  DBusError        *error,
                                                                  const char       *name,
                                                                  const char       *msg,
                                                                  ...) _DBUS_GNUC_PRINTF (5, 6);
134
dbus_bool_t       bus_context_check_security_policy              (BusContext       *context,
135
                                                                  BusTransaction   *transaction,
136 137 138 139 140
                                                                  DBusConnection   *sender,
                                                                  DBusConnection   *addressed_recipient,
                                                                  DBusConnection   *proposed_recipient,
                                                                  DBusMessage      *message,
                                                                  DBusError        *error);
141
void              bus_context_check_all_watches                  (BusContext       *context);
142

143
#endif /* BUS_BUS_H */