D-Bus 1.15.12
dbus-sysdeps-unix.h
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/* dbus-sysdeps-unix.h UNIX-specific wrappers around system/libc features (internal to D-Bus implementation)
3 *
4 * Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
5 * Copyright (C) 2003 CodeFactory AB
6 *
7 * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
8 *
9 * Licensed under the Academic Free License version 2.1
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 */
26
27#ifndef DBUS_SYSDEPS_UNIX_H
28#define DBUS_SYSDEPS_UNIX_H
29
30#include <dbus/dbus-sysdeps.h>
31
32#ifdef DBUS_WIN
33#error "Don't include this on Windows"
34#endif
35
37
45DBUS_PRIVATE_EXPORT
46dbus_bool_t
47_dbus_close (int fd,
48 DBusError *error);
49DBUS_PRIVATE_EXPORT
50int _dbus_dup (int fd,
51 DBusError *error);
52DBUS_PRIVATE_EXPORT
53int
54_dbus_read (int fd,
55 DBusString *buffer,
56 int count);
57int
58_dbus_write (int fd,
59 const DBusString *buffer,
60 int start,
61 int len);
62int
63_dbus_write_two (int fd,
64 const DBusString *buffer1,
65 int start1,
66 int len1,
67 const DBusString *buffer2,
68 int start2,
69 int len2);
70
72 DBusError *error);
73
74dbus_bool_t _dbus_read_credentials (int client_fd,
75 DBusCredentials *credentials,
76 DBusError *error);
77dbus_bool_t _dbus_send_credentials (int server_fd,
78 DBusError *error);
79
80dbus_bool_t _dbus_lookup_launchd_socket (DBusString *socket_path,
81 const char *launchd_env_var,
82 DBusError *error);
83
88
102
112
113dbus_bool_t _dbus_user_info_fill (DBusUserInfo *info,
114 const DBusString *username,
115 DBusError *error);
116dbus_bool_t _dbus_user_info_fill_uid (DBusUserInfo *info,
117 dbus_uid_t uid,
118 DBusError *error);
120
121dbus_bool_t _dbus_group_info_fill (DBusGroupInfo *info,
122 const DBusString *groupname,
123 DBusError *error);
125 dbus_gid_t gid,
126 DBusError *error);
128
129DBUS_PRIVATE_EXPORT
131
132DBUS_PRIVATE_EXPORT
133void _dbus_close_all (void);
134DBUS_PRIVATE_EXPORT
136DBUS_PRIVATE_EXPORT
137void _dbus_fd_clear_close_on_exec (int fd);
138
140 DBusString *address,
141 DBusError *error);
142
143DBUS_PRIVATE_EXPORT
144void _dbus_fd_set_close_on_exec (int fd);
145
146typedef enum
147{
148 DBUS_FORCE_STDIN_NULL = (1 << 0),
149 DBUS_FORCE_STDOUT_NULL = (1 << 1),
150 DBUS_FORCE_STDERR_NULL = (1 << 2)
151} DBusEnsureStandardFdsFlags;
152
153DBUS_PRIVATE_EXPORT
154dbus_bool_t _dbus_ensure_standard_fds (DBusEnsureStandardFdsFlags flags,
155 const char **error_str_p);
156
158typedef void (* DBusSignalHandler) (int sig);
159
160void _dbus_set_signal_handler (int sig,
161 DBusSignalHandler handler);
162
163dbus_bool_t _dbus_reset_oom_score_adj (const char **error_str_p);
164
168
169#endif /* DBUS_SYSDEPS_UNIX_H */
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
Definition dbus-macros.h:36
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.
Definition dbus-macros.h:37
DBUS_PRIVATE_EXPORT void _dbus_fd_clear_close_on_exec(int fd)
Sets the file descriptor to not be close-on-exec.
dbus_bool_t _dbus_reset_oom_score_adj(const char **error_str_p)
If the current process has been protected from the Linux OOM killer (the oom_score_adj process parame...
dbus_bool_t _dbus_group_info_fill(DBusGroupInfo *info, const DBusString *groupname, DBusError *error)
Initializes the given DBusGroupInfo struct with information about the given group name.
DBUS_PRIVATE_EXPORT void _dbus_fd_set_all_close_on_exec(void)
Sets all file descriptors except the first three (i.e.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_close(int fd, DBusError *error)
Closes a file descriptor.
int _dbus_write(int fd, const DBusString *buffer, int start, int len)
Thin wrapper around the write() system call that writes a part of a DBusString and handles EINTR for ...
void(* DBusSignalHandler)(int sig)
A UNIX signal handler.
void _dbus_set_signal_handler(int sig, DBusSignalHandler handler)
Installs a UNIX signal handler.
int _dbus_write_two(int fd, const DBusString *buffer1, int start1, int len1, const DBusString *buffer2, int start2, int len2)
Like _dbus_write() but will use writev() if possible to write both buffers in sequence.
dbus_bool_t _dbus_lookup_launchd_socket(DBusString *socket_path, const char *launchd_env_var, DBusError *error)
quries launchd for a specific env var which holds the socket path.
int _dbus_listen_systemd_sockets(DBusSocket **fd, DBusError *error)
Acquires one or more sockets passed in from systemd.
dbus_bool_t _dbus_append_address_from_socket(DBusSocket fd, DBusString *address, DBusError *error)
Read the address from the socket and append it to the string.
dbus_bool_t _dbus_user_info_fill(DBusUserInfo *info, const DBusString *username, DBusError *error)
Gets user info for the given username.
void _dbus_user_info_free(DBusUserInfo *info)
Frees the members of info (but not info itself)
void _dbus_group_info_free(DBusGroupInfo *info)
Frees the members of info (but not info itself).
DBUS_PRIVATE_EXPORT void _dbus_close_all(void)
Closes all file descriptors except the first three (i.e.
dbus_bool_t _dbus_group_info_fill_gid(DBusGroupInfo *info, dbus_gid_t gid, DBusError *error)
Initializes the given DBusGroupInfo struct with information about the given group ID.
DBUS_PRIVATE_EXPORT int _dbus_dup(int fd, DBusError *error)
Duplicates a file descriptor.
DBUS_PRIVATE_EXPORT void _dbus_fd_set_close_on_exec(int fd)
Sets the file descriptor to be close on exec.
DBUS_PRIVATE_EXPORT int _dbus_read(int fd, DBusString *buffer, int count)
Thin wrapper around the read() system call that appends the data it reads to the DBusString buffer.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_ensure_standard_fds(DBusEnsureStandardFdsFlags flags, const char **error_str_p)
Ensure that the standard file descriptors stdin, stdout and stderr are open, by opening /dev/null if ...
DBUS_PRIVATE_EXPORT dbus_uid_t _dbus_geteuid(void)
Gets our effective UID.
dbus_bool_t _dbus_user_info_fill_uid(DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
Gets user info for the given user ID.
unsigned long dbus_uid_t
A user ID.
unsigned long dbus_gid_t
A group ID.
Object representing an exception.
Definition dbus-errors.h:51
Information about a UNIX group.
dbus_gid_t gid
GID.
char * groupname
Group name.
size_t refcount
Reference count.
Socket interface.
Information about a UNIX user.
int n_group_ids
Size of group IDs array.
dbus_uid_t uid
UID.
char * homedir
Home directory.
dbus_gid_t * group_ids
Groups IDs, including above primary group.
size_t refcount
Reference count.
char * username
Username.
dbus_gid_t primary_gid
GID.