~ubuntu-branches/ubuntu/maverick/dbus/maverick-security

« back to all changes in this revision

Viewing changes to dbus/dbus-sysdeps.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-27 13:06:32 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20100927130632-bqs145trvchd2lmf
Tags: 1.4.0-0ubuntu1
* New upstream release
 - Fixes https://bugs.freedesktop.org/show_bug.cgi?id=17754 Race condition in protected_change_timeout
 - Requested by various upstream KDE developers http://lists.kde.org/?t=128514970000004&r=1&w=2

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#ifndef DBUS_SYSDEPS_H
26
26
#define DBUS_SYSDEPS_H
27
27
 
28
 
#include <config.h>
 
28
#include "config.h"
 
29
 
 
30
#ifdef HAVE_STDINT_H
 
31
#include <stdint.h>
 
32
#endif
29
33
 
30
34
#include <dbus/dbus-errors.h>
 
35
#include <dbus/dbus-file.h>
 
36
#include <dbus/dbus-string.h>
31
37
 
32
38
/* this is perhaps bogus, but strcmp() etc. are faster if we use the
33
39
 * stuff straight out of string.h, so have this here for now.
35
41
#include <string.h>
36
42
#include <stdarg.h>
37
43
 
38
 
 
39
44
/* AIX sys/poll.h does #define events reqevents, and other
40
45
 * wonderousness, so must include sys/poll before declaring
41
46
 * DBusPollFD
44
49
#include <sys/poll.h>
45
50
#endif
46
51
 
 
52
#ifdef DBUS_WINCE
 
53
/* Windows CE lacks some system functions (such as errno and clock).
 
54
   We bring them in here.  */
 
55
#include "dbus-sysdeps-wince-glue.h"
 
56
#endif
 
57
 
47
58
DBUS_BEGIN_DECLS
48
59
 
49
60
#ifdef DBUS_WIN
54
65
 
55
66
/* Forward declarations */
56
67
 
57
 
/** An opaque string type */
58
 
typedef struct DBusString DBusString;
59
68
 
60
69
/** An opaque list type */
61
70
typedef struct DBusList DBusList;
63
72
/** Object that contains a list of credentials such as UNIX or Windows user ID */
64
73
typedef struct DBusCredentials DBusCredentials;
65
74
 
 
75
/** A wrapper around a pipe descriptor or handle */
 
76
typedef struct DBusPipe DBusPipe;
 
77
 
66
78
/**
67
79
 * @addtogroup DBusSysdeps
68
80
 *
69
81
 * @{
70
82
 */
71
83
 
72
 
/* The idea of this file is to encapsulate everywhere that we're
73
 
 * relying on external libc features, for ease of security
74
 
 * auditing. The idea is from vsftpd. This also gives us a chance to
75
 
 * make things more convenient to use, e.g.  by reading into a
76
 
 * DBusString. Operating system headers aren't intended to be used
77
 
 * outside of this file and a limited number of others (such as
78
 
 * dbus-memory.c)
79
 
 */
80
 
 
81
 
#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
82
 
#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )    \
83
 
  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
84
 
#define _DBUS_GNUC_NORETURN                         \
85
 
  __attribute__((__noreturn__))
86
 
#else   /* !__GNUC__ */
87
 
#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )
88
 
#define _DBUS_GNUC_NORETURN
89
 
#endif  /* !__GNUC__ */
90
 
 
91
 
/** @def _DBUS_GNUC_PRINTF
92
 
 * used to tell gcc about printf format strings
93
 
 */
94
 
/** @def _DBUS_GNUC_NORETURN
95
 
 * used to tell gcc about functions that never return, such as _dbus_abort()
96
 
 */
97
 
 
98
84
void _dbus_abort (void) _DBUS_GNUC_NORETURN;
99
85
 
100
86
const char* _dbus_getenv (const char *varname);
153
139
                                    const DBusString *buffer2,
154
140
                                    int               start2,
155
141
                                    int               len2);
 
142
 
 
143
int _dbus_read_socket_with_unix_fds      (int               fd,
 
144
                                          DBusString       *buffer,
 
145
                                          int               count,
 
146
                                          int              *fds,
 
147
                                          int              *n_fds);
 
148
int _dbus_write_socket_with_unix_fds     (int               fd,
 
149
                                          const DBusString *buffer,
 
150
                                          int               start,
 
151
                                          int               len,
 
152
                                          const int        *fds,
 
153
                                          int               n_fds);
 
154
int _dbus_write_socket_with_unix_fds_two (int               fd,
 
155
                                          const DBusString *buffer1,
 
156
                                          int               start1,
 
157
                                          int               len1,
 
158
                                          const DBusString *buffer2,
 
159
                                          int               start2,
 
160
                                          int               len2,
 
161
                                          const int        *fds,
 
162
                                          int               n_fds);
 
163
 
 
164
dbus_bool_t _dbus_socket_is_invalid (int              fd);
 
165
 
156
166
int _dbus_connect_tcp_socket  (const char     *host,
157
167
                               const char     *port,
158
168
                               const char     *family,
159
169
                               DBusError      *error);
 
170
int _dbus_connect_tcp_socket_with_nonce  (const char     *host,
 
171
                                          const char     *port,
 
172
                                          const char     *family,
 
173
                                          const char     *noncefile,
 
174
                                          DBusError      *error);
160
175
int _dbus_listen_tcp_socket   (const char     *host,
161
176
                               const char     *port,
162
177
                               const char     *family,
192
207
dbus_bool_t _dbus_append_keyring_directory_for_credentials (DBusString      *directory,
193
208
                                                            DBusCredentials *credentials);
194
209
 
 
210
void _dbus_daemon_publish_session_bus_address (const char* address);
 
211
 
 
212
void _dbus_daemon_unpublish_session_bus_address (void);
 
213
 
 
214
dbus_bool_t _dbus_socket_can_pass_unix_fd(int fd);
 
215
 
195
216
/** Opaque type representing an atomically-modifiable integer
196
217
 * that can be used from multiple threads.
197
218
 */
286
307
                             long *tv_usec);
287
308
 
288
309
/**
289
 
 * File/directory interface
 
310
 * directory interface
290
311
 */
291
 
dbus_bool_t _dbus_file_exists         (const char       *file);
292
 
dbus_bool_t _dbus_file_get_contents   (DBusString       *str,
293
 
                                       const DBusString *filename,
294
 
                                       DBusError        *error);
295
 
dbus_bool_t _dbus_string_save_to_file (const DBusString *str,
296
 
                                       const DBusString *filename,
297
 
                                       DBusError        *error);
298
 
 
299
 
dbus_bool_t _dbus_make_file_world_readable   (const DBusString *filename,
300
 
                                              DBusError *error);
301
 
 
302
 
dbus_bool_t    _dbus_create_file_exclusively (const DBusString *filename,
303
 
                                              DBusError        *error);
304
 
dbus_bool_t    _dbus_delete_file             (const DBusString *filename,
305
 
                                              DBusError        *error);
306
312
dbus_bool_t    _dbus_create_directory        (const DBusString *filename,
307
313
                                              DBusError        *error);
308
314
dbus_bool_t    _dbus_delete_directory        (const DBusString *filename,
320
326
dbus_bool_t _dbus_append_system_config_file  (DBusString *str);
321
327
dbus_bool_t _dbus_append_session_config_file (DBusString *str);
322
328
 
323
 
typedef struct {
324
 
  int fd_or_handle;
325
 
} DBusPipe;
326
 
 
327
 
void        _dbus_pipe_init                (DBusPipe         *pipe,
328
 
                                            int               fd);
329
 
void        _dbus_pipe_init_stdout         (DBusPipe         *pipe);
330
 
int         _dbus_pipe_write               (DBusPipe         *pipe,
331
 
                                            const DBusString *buffer,
332
 
                                            int               start,
333
 
                                            int               len,
334
 
                                            DBusError        *error);
335
 
int         _dbus_pipe_close               (DBusPipe         *pipe,
336
 
                                            DBusError        *error);
337
 
dbus_bool_t _dbus_pipe_is_valid            (DBusPipe         *pipe);
338
 
void        _dbus_pipe_invalidate          (DBusPipe         *pipe);
339
 
dbus_bool_t _dbus_pipe_is_stdout_or_stderr (DBusPipe         *pipe);
340
 
 
341
 
 
342
329
/** Opaque type for reading a directory listing */
343
330
typedef struct DBusDirIter DBusDirIter;
344
331
 
352
339
dbus_bool_t  _dbus_check_dir_is_private_to_user    (DBusString *dir,
353
340
                                                    DBusError *error);
354
341
 
355
 
void _dbus_fd_set_close_on_exec (int fd);
 
342
void _dbus_fd_set_close_on_exec (intptr_t fd);
356
343
 
357
344
const char* _dbus_get_tmpdir      (void);
358
345
 
369
356
                                                int         n_bytes);
370
357
 
371
358
const char* _dbus_error_from_errno (int error_number);
 
359
const char* _dbus_error_from_system_errno (void);
372
360
 
373
361
void        _dbus_set_errno_to_zero                  (void);
374
362
dbus_bool_t _dbus_get_is_errno_nonzero               (void);
418
406
                                   dbus_bool_t       keep_umask);
419
407
 
420
408
dbus_bool_t _dbus_verify_daemon_user    (const char *user);
 
409
dbus_bool_t _dbus_change_to_daemon_user (const char *user,
 
410
                                         DBusError  *error);
421
411
 
422
412
dbus_bool_t _dbus_write_pid_to_file_and_pipe (const DBusString *pidfile,
423
413
                                              DBusPipe         *print_pid_pipe,
524
514
 
525
515
void _dbus_flush_caches (void);
526
516
 
 
517
/*
 
518
 * replaces the term DBUS_PREFIX in configure_time_path by the
 
519
 * current dbus installation directory. On unix this function is a noop
 
520
 *
 
521
 * @param configure_time_path
 
522
 * @return real path
 
523
 */
 
524
const char *
 
525
_dbus_replace_install_prefix (const char *configure_time_path);
 
526
 
527
527
/** @} */
528
528
 
529
529
DBUS_END_DECLS