D-Bus 1.12.4

dbus-userdb.c
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/* dbus-userdb.c User database abstraction
3 *
4 * Copyright (C) 2003, 2004 Red Hat, Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * 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#include <config.h>
24#define DBUS_USERDB_INCLUDES_PRIVATE 1
25#include "dbus-userdb.h"
26#include "dbus-hash.h"
27#include "dbus-test.h"
28#include "dbus-internals.h"
29#include "dbus-protocol.h"
30#include "dbus-credentials.h"
31#include <string.h>
32
44 void
45_dbus_user_info_free_allocated (DBusUserInfo *info)
46{
47 if (info == NULL) /* hash table will pass NULL */
48 return;
49
50 _dbus_user_info_free (info);
51 dbus_free (info);
52}
53
60 void
61_dbus_group_info_free_allocated (DBusGroupInfo *info)
62{
63 if (info == NULL) /* hash table will pass NULL */
64 return;
65
66 _dbus_group_info_free (info);
67 dbus_free (info);
68}
69
75 void
76_dbus_user_info_free (DBusUserInfo *info)
77{
78 dbus_free (info->group_ids);
79 dbus_free (info->username);
80 dbus_free (info->homedir);
81}
82
88 void
89_dbus_group_info_free (DBusGroupInfo *info)
90{
91 dbus_free (info->groupname);
92}
93
102 dbus_bool_t
103_dbus_is_a_number (const DBusString *str,
104 unsigned long *num)
105{
106 int end;
107
108 if (_dbus_string_parse_uint (str, 0, num, &end) &&
109 end == _dbus_string_get_length (str))
110 return TRUE;
111 else
112 return FALSE;
113}
114
127 DBusUserInfo*
128_dbus_user_database_lookup (DBusUserDatabase *db,
129 dbus_uid_t uid,
130 const DBusString *username,
131 DBusError *error)
132{
133 DBusUserInfo *info;
134
135 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
136 _dbus_assert (uid != DBUS_UID_UNSET || username != NULL);
137
138 /* See if the username is really a number */
139 if (uid == DBUS_UID_UNSET)
140 {
141 unsigned long n;
142
143 if (_dbus_is_a_number (username, &n))
144 uid = n;
145 }
146
147 if (uid != DBUS_UID_UNSET)
148 info = _dbus_hash_table_lookup_uintptr (db->users, uid);
149 else
150 info = _dbus_hash_table_lookup_string (db->users_by_name, _dbus_string_get_const_data (username));
151
152 if (info)
153 {
154 _dbus_verbose ("Using cache for UID "DBUS_UID_FORMAT" information\n",
155 info->uid);
156 return info;
157 }
158 else
159 {
160 if (uid != DBUS_UID_UNSET)
161 _dbus_verbose ("No cache for UID "DBUS_UID_FORMAT"\n",
162 uid);
163 else
164 _dbus_verbose ("No cache for user \"%s\"\n",
165 _dbus_string_get_const_data (username));
166
167 info = dbus_new0 (DBusUserInfo, 1);
168 if (info == NULL)
169 {
170 dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
171 return NULL;
172 }
173
174 if (uid != DBUS_UID_UNSET)
175 {
176 if (!_dbus_user_info_fill_uid (info, uid, error))
177 {
178 _DBUS_ASSERT_ERROR_IS_SET (error);
179 _dbus_user_info_free_allocated (info);
180 return NULL;
181 }
182 }
183 else
184 {
185 if (!_dbus_user_info_fill (info, username, error))
186 {
187 _DBUS_ASSERT_ERROR_IS_SET (error);
188 _dbus_user_info_free_allocated (info);
189 return NULL;
190 }
191 }
192
193 /* be sure we don't use these after here */
194 uid = DBUS_UID_UNSET;
195 username = NULL;
196
197 /* insert into hash */
198 if (!_dbus_hash_table_insert_uintptr (db->users, info->uid, info))
199 {
200 dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
201 _dbus_user_info_free_allocated (info);
202 return NULL;
203 }
204
205 if (!_dbus_hash_table_insert_string (db->users_by_name,
206 info->username,
207 info))
208 {
209 _dbus_hash_table_remove_uintptr (db->users, info->uid);
210 dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
211 return NULL;
212 }
213
214 return info;
215 }
216}
217
218 static dbus_bool_t database_locked = FALSE;
219 static DBusUserDatabase *system_db = NULL;
220 static DBusString process_username;
221 static DBusString process_homedir;
222
223 static void
224shutdown_system_db (void *data)
225{
226 if (system_db != NULL)
227 _dbus_user_database_unref (system_db);
228 system_db = NULL;
229 _dbus_string_free (&process_username);
230 _dbus_string_free (&process_homedir);
231}
232
233 static dbus_bool_t
234init_system_db (void)
235{
236 _dbus_assert (database_locked);
237
238 if (system_db == NULL)
239 {
240 DBusError error = DBUS_ERROR_INIT;
241 const DBusUserInfo *info;
242
243 system_db = _dbus_user_database_new ();
244 if (system_db == NULL)
245 return FALSE;
246
247 if (!_dbus_user_database_get_uid (system_db,
248 _dbus_getuid (),
249 &info,
250 &error))
251 {
252 _dbus_user_database_unref (system_db);
253 system_db = NULL;
254
255 if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
256 {
257 dbus_error_free (&error);
258 return FALSE;
259 }
260 else
261 {
262 /* This really should not happen. */
263 _dbus_warn ("Could not get password database information for UID of current process: %s",
264 error.message);
265 dbus_error_free (&error);
266 return FALSE;
267 }
268 }
269
270 if (!_dbus_string_init (&process_username))
271 {
272 _dbus_user_database_unref (system_db);
273 system_db = NULL;
274 return FALSE;
275 }
276
277 if (!_dbus_string_init (&process_homedir))
278 {
279 _dbus_string_free (&process_username);
280 _dbus_user_database_unref (system_db);
281 system_db = NULL;
282 return FALSE;
283 }
284
285 if (!_dbus_string_append (&process_username,
286 info->username) ||
287 !_dbus_string_append (&process_homedir,
288 info->homedir) ||
289 !_dbus_register_shutdown_func (shutdown_system_db, NULL))
290 {
291 _dbus_string_free (&process_username);
292 _dbus_string_free (&process_homedir);
293 _dbus_user_database_unref (system_db);
294 system_db = NULL;
295 return FALSE;
296 }
297 }
298
299 return TRUE;
300}
301
305 dbus_bool_t
306_dbus_user_database_lock_system (void)
307{
308 if (_DBUS_LOCK (system_users))
309 {
310 database_locked = TRUE;
311 return TRUE;
312 }
313 else
314 {
315 return FALSE;
316 }
317}
318
322 void
323_dbus_user_database_unlock_system (void)
324{
325 database_locked = FALSE;
326 _DBUS_UNLOCK (system_users);
327}
328
335DBusUserDatabase*
336_dbus_user_database_get_system (void)
337{
338 _dbus_assert (database_locked);
339
340 init_system_db ();
341
342 return system_db;
343}
344
348 void
349_dbus_user_database_flush_system (void)
350{
351 if (!_dbus_user_database_lock_system ())
352 {
353 /* nothing to flush */
354 return;
355 }
356
357 if (system_db != NULL)
358 _dbus_user_database_flush (system_db);
359
360 _dbus_user_database_unlock_system ();
361}
362
370 dbus_bool_t
371_dbus_username_from_current_process (const DBusString **username)
372{
373 if (!_dbus_user_database_lock_system ())
374 return FALSE;
375
376 if (!init_system_db ())
377 {
378 _dbus_user_database_unlock_system ();
379 return FALSE;
380 }
381 *username = &process_username;
382 _dbus_user_database_unlock_system ();
383
384 return TRUE;
385}
386
394 dbus_bool_t
395_dbus_homedir_from_current_process (const DBusString **homedir)
396{
397 if (!_dbus_user_database_lock_system ())
398 return FALSE;
399
400 if (!init_system_db ())
401 {
402 _dbus_user_database_unlock_system ();
403 return FALSE;
404 }
405 *homedir = &process_homedir;
406 _dbus_user_database_unlock_system ();
407
408 return TRUE;
409}
410
418 dbus_bool_t
419_dbus_homedir_from_username (const DBusString *username,
420 DBusString *homedir)
421{
422 DBusUserDatabase *db;
423 const DBusUserInfo *info;
424
425 /* FIXME: this can't distinguish ENOMEM from other errors */
426 if (!_dbus_user_database_lock_system ())
427 return FALSE;
428
429 db = _dbus_user_database_get_system ();
430 if (db == NULL)
431 {
432 _dbus_user_database_unlock_system ();
433 return FALSE;
434 }
435
436 if (!_dbus_user_database_get_username (db, username,
437 &info, NULL))
438 {
439 _dbus_user_database_unlock_system ();
440 return FALSE;
441 }
442
443 if (!_dbus_string_append (homedir, info->homedir))
444 {
445 _dbus_user_database_unlock_system ();
446 return FALSE;
447 }
448
449 _dbus_user_database_unlock_system ();
450 return TRUE;
451}
452
460 dbus_bool_t
461_dbus_homedir_from_uid (dbus_uid_t uid,
462 DBusString *homedir)
463{
464 DBusUserDatabase *db;
465 const DBusUserInfo *info;
466
467 if (uid == _dbus_getuid () && uid == _dbus_geteuid ())
468 {
469 const char *from_environment;
470
471 from_environment = _dbus_getenv ("HOME");
472
473 if (from_environment != NULL)
474 return _dbus_string_append (homedir, from_environment);
475 }
476
477 /* FIXME: this can't distinguish ENOMEM from other errors */
478 if (!_dbus_user_database_lock_system ())
479 return FALSE;
480
481 db = _dbus_user_database_get_system ();
482 if (db == NULL)
483 {
484 _dbus_user_database_unlock_system ();
485 return FALSE;
486 }
487
488 if (!_dbus_user_database_get_uid (db, uid,
489 &info, NULL))
490 {
491 _dbus_user_database_unlock_system ();
492 return FALSE;
493 }
494
495 if (!_dbus_string_append (homedir, info->homedir))
496 {
497 _dbus_user_database_unlock_system ();
498 return FALSE;
499 }
500
501 _dbus_user_database_unlock_system ();
502 return TRUE;
503}
504
519 dbus_bool_t
520_dbus_credentials_add_from_user (DBusCredentials *credentials,
521 const DBusString *username)
522{
523 DBusUserDatabase *db;
524 const DBusUserInfo *info;
525
526 /* FIXME: this can't distinguish ENOMEM from other errors */
527 if (!_dbus_user_database_lock_system ())
528 return FALSE;
529
530 db = _dbus_user_database_get_system ();
531 if (db == NULL)
532 {
533 _dbus_user_database_unlock_system ();
534 return FALSE;
535 }
536
537 if (!_dbus_user_database_get_username (db, username,
538 &info, NULL))
539 {
540 _dbus_user_database_unlock_system ();
541 return FALSE;
542 }
543
544 if (!_dbus_credentials_add_unix_uid(credentials, info->uid))
545 {
546 _dbus_user_database_unlock_system ();
547 return FALSE;
548 }
549
550 _dbus_user_database_unlock_system ();
551 return TRUE;
552}
553
559DBusUserDatabase*
560_dbus_user_database_new (void)
561{
562 DBusUserDatabase *db;
563
564 db = dbus_new0 (DBusUserDatabase, 1);
565 if (db == NULL)
566 return NULL;
567
568 db->refcount = 1;
569
570 db->users = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
571 NULL, (DBusFreeFunction) _dbus_user_info_free_allocated);
572
573 if (db->users == NULL)
574 goto failed;
575
576 db->groups = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
577 NULL, (DBusFreeFunction) _dbus_group_info_free_allocated);
578
579 if (db->groups == NULL)
580 goto failed;
581
582 db->users_by_name = _dbus_hash_table_new (DBUS_HASH_STRING,
583 NULL, NULL);
584 if (db->users_by_name == NULL)
585 goto failed;
586
587 db->groups_by_name = _dbus_hash_table_new (DBUS_HASH_STRING,
588 NULL, NULL);
589 if (db->groups_by_name == NULL)
590 goto failed;
591
592 return db;
593
594 failed:
595 _dbus_user_database_unref (db);
596 return NULL;
597}
598
602 void
603_dbus_user_database_flush (DBusUserDatabase *db)
604{
605 _dbus_hash_table_remove_all(db->users_by_name);
606 _dbus_hash_table_remove_all(db->groups_by_name);
607 _dbus_hash_table_remove_all(db->users);
608 _dbus_hash_table_remove_all(db->groups);
609}
610
611#ifdef DBUS_ENABLE_EMBEDDED_TESTS
617DBusUserDatabase *
618_dbus_user_database_ref (DBusUserDatabase *db)
619{
620 _dbus_assert (db->refcount > 0);
621
622 db->refcount += 1;
623
624 return db;
625}
626#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
627
632 void
633_dbus_user_database_unref (DBusUserDatabase *db)
634{
635 _dbus_assert (db->refcount > 0);
636
637 db->refcount -= 1;
638 if (db->refcount == 0)
639 {
640 if (db->users)
641 _dbus_hash_table_unref (db->users);
642
643 if (db->groups)
644 _dbus_hash_table_unref (db->groups);
645
646 if (db->users_by_name)
647 _dbus_hash_table_unref (db->users_by_name);
648
649 if (db->groups_by_name)
650 _dbus_hash_table_unref (db->groups_by_name);
651
652 dbus_free (db);
653 }
654}
655
666 dbus_bool_t
667_dbus_user_database_get_uid (DBusUserDatabase *db,
668 dbus_uid_t uid,
669 const DBusUserInfo **info,
670 DBusError *error)
671{
672 *info = _dbus_user_database_lookup (db, uid, NULL, error);
673 return *info != NULL;
674}
675
685 dbus_bool_t
686_dbus_user_database_get_username (DBusUserDatabase *db,
687 const DBusString *username,
688 const DBusUserInfo **info,
689 DBusError *error)
690{
691 *info = _dbus_user_database_lookup (db, DBUS_UID_UNSET, username, error);
692 return *info != NULL;
693}
694
697/* Tests in dbus-userdb-util.c */
_dbus_credentials_add_unix_uid
dbus_bool_t _dbus_credentials_add_unix_uid(DBusCredentials *credentials, dbus_uid_t uid)
Add a UNIX user ID to the credentials.
Definition: dbus-credentials.c:167
DBUS_ERROR_INIT
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack.
Definition: dbus-errors.h:62
dbus_error_has_name
dbus_bool_t dbus_error_has_name(const DBusError *error, const char *name)
Checks whether the error is set and has the given name.
Definition: dbus-errors.c:302
dbus_set_error
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
Definition: dbus-errors.c:354
dbus_error_free
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
Definition: dbus-errors.c:211
_dbus_hash_table_remove_uintptr
dbus_bool_t _dbus_hash_table_remove_uintptr(DBusHashTable *table, uintptr_t key)
Removes the hash entry for the given key.
Definition: dbus-hash.c:1189
_dbus_hash_table_insert_string
dbus_bool_t _dbus_hash_table_insert_string(DBusHashTable *table, char *key, void *value)
Creates a hash entry with the given key and value.
Definition: dbus-hash.c:1224
_dbus_hash_table_lookup_uintptr
void * _dbus_hash_table_lookup_uintptr(DBusHashTable *table, uintptr_t key)
Looks up the value for a given integer in a hash table of type DBUS_HASH_UINTPTR.
Definition: dbus-hash.c:1109
_dbus_hash_table_unref
void _dbus_hash_table_unref(DBusHashTable *table)
Decrements the reference count for a hash table, freeing the hash table if the count reaches zero.
Definition: dbus-hash.c:361
_dbus_hash_table_new
DBusHashTable * _dbus_hash_table_new(DBusHashType type, DBusFreeFunction key_free_function, DBusFreeFunction value_free_function)
Constructs a new hash table.
Definition: dbus-hash.c:285
_dbus_hash_table_lookup_string
void * _dbus_hash_table_lookup_string(DBusHashTable *table, const char *key)
Looks up the value for a given string in a hash table of type DBUS_HASH_STRING.
Definition: dbus-hash.c:1059
_dbus_hash_table_remove_all
void _dbus_hash_table_remove_all(DBusHashTable *table)
Removed all entries from a hash table.
Definition: dbus-hash.c:418
_dbus_hash_table_insert_uintptr
dbus_bool_t _dbus_hash_table_insert_uintptr(DBusHashTable *table, uintptr_t key, void *value)
Creates a hash entry with the given key and value.
Definition: dbus-hash.c:1299
DBUS_HASH_UINTPTR
@ DBUS_HASH_UINTPTR
Hash keys are integer capable to hold a pointer.
Definition: dbus-hash.h:71
DBUS_HASH_STRING
@ DBUS_HASH_STRING
Hash keys are strings.
Definition: dbus-hash.h:69
_dbus_assert
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Definition: dbus-internals.h:152
_dbus_user_database_lock_system
dbus_bool_t _dbus_user_database_lock_system(void)
Locks global system user database.
Definition: dbus-userdb.c:306
_dbus_homedir_from_current_process
dbus_bool_t _dbus_homedir_from_current_process(const DBusString **homedir)
Gets homedir of user owning current process.
Definition: dbus-userdb.c:395
_DBUS_UNLOCK
#define _DBUS_UNLOCK(name)
Unlocks a global lock.
Definition: dbus-internals.h:373
_dbus_user_database_new
DBusUserDatabase * _dbus_user_database_new(void)
Creates a new user database object used to look up and cache user information.
Definition: dbus-userdb.c:560
_DBUS_LOCK
#define _DBUS_LOCK(name)
Locks a global lock, initializing it first if necessary.
Definition: dbus-internals.h:372
_dbus_user_database_unlock_system
void _dbus_user_database_unlock_system(void)
Unlocks global system user database.
Definition: dbus-userdb.c:323
_dbus_user_database_unref
void _dbus_user_database_unref(DBusUserDatabase *db)
Decrements refcount of user database.
Definition: dbus-userdb.c:633
_dbus_user_database_get_uid
dbus_bool_t _dbus_user_database_get_uid(DBusUserDatabase *db, dbus_uid_t uid, const DBusUserInfo **info, DBusError *error)
Gets the user information for the given UID, returned user info should not be freed.
Definition: dbus-userdb.c:667
_dbus_user_database_flush_system
void _dbus_user_database_flush_system(void)
Flushes the system global user database;.
Definition: dbus-userdb.c:349
_dbus_user_database_lookup
DBusUserInfo * _dbus_user_database_lookup(DBusUserDatabase *db, dbus_uid_t uid, const DBusString *username, DBusError *error)
Looks up a uid or username in the user database.
Definition: dbus-userdb.c:128
_dbus_homedir_from_username
dbus_bool_t _dbus_homedir_from_username(const DBusString *username, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:419
_dbus_username_from_current_process
dbus_bool_t _dbus_username_from_current_process(const DBusString **username)
Gets username of user owning current process.
Definition: dbus-userdb.c:371
_dbus_user_info_free
void _dbus_user_info_free(DBusUserInfo *info)
Frees the members of info (but not info itself)
Definition: dbus-userdb.c:76
_dbus_user_database_flush
void _dbus_user_database_flush(DBusUserDatabase *db)
Flush all information out of the user database.
Definition: dbus-userdb.c:603
_dbus_group_info_free_allocated
void _dbus_group_info_free_allocated(DBusGroupInfo *info)
Frees the given DBusGroupInfo's members with _dbus_group_info_free() and also calls dbus_free() on th...
Definition: dbus-userdb.c:61
_dbus_homedir_from_uid
dbus_bool_t _dbus_homedir_from_uid(dbus_uid_t uid, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:461
_dbus_warn
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
Definition: dbus-internals.c:230
_dbus_group_info_free
void _dbus_group_info_free(DBusGroupInfo *info)
Frees the members of info (but not info itself).
Definition: dbus-userdb.c:89
_dbus_user_database_get_username
dbus_bool_t _dbus_user_database_get_username(DBusUserDatabase *db, const DBusString *username, const DBusUserInfo **info, DBusError *error)
Gets the user information for the given username.
Definition: dbus-userdb.c:686
_dbus_credentials_add_from_user
dbus_bool_t _dbus_credentials_add_from_user(DBusCredentials *credentials, const DBusString *username)
Adds the credentials corresponding to the given username.
Definition: dbus-userdb.c:520
_dbus_is_a_number
dbus_bool_t _dbus_is_a_number(const DBusString *str, unsigned long *num)
Checks if a given string is actually a number and converts it if it is.
Definition: dbus-userdb.c:103
_dbus_user_database_get_system
DBusUserDatabase * _dbus_user_database_get_system(void)
Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system(...
Definition: dbus-userdb.c:336
_dbus_user_info_free_allocated
void _dbus_user_info_free_allocated(DBusUserInfo *info)
Frees the given DBusUserInfo's members with _dbus_user_info_free() and also calls dbus_free() on the ...
Definition: dbus-userdb.c:45
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
TRUE
#define TRUE
Expands to "1".
FALSE
#define FALSE
Expands to "0".
_dbus_register_shutdown_func
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_register_shutdown_func(DBusShutdownFunction function, void *data)
Register a cleanup function to be called exactly once the next time dbus_shutdown() is called.
Definition: dbus-memory.c:811
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition: dbus-memory.h:64
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:702
dbus_new0
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition: dbus-memory.h:59
DBUS_ERROR_NO_MEMORY
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
Definition: dbus-protocol.h:357
_dbus_string_append
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
Definition: dbus-string.c:935
_dbus_string_init
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition: dbus-string.c:175
_dbus_string_free
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
Definition: dbus-string.c:259
_dbus_string_parse_uint
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_string_parse_uint(const DBusString *str, int start, unsigned long *value_return, int *end_return)
Parses an unsigned integer contained in a DBusString.
Definition: dbus-sysdeps.c:476
_dbus_user_info_fill
dbus_bool_t _dbus_user_info_fill(DBusUserInfo *info, const DBusString *username, DBusError *error)
Gets user info for the given username.
Definition: dbus-sysdeps-unix.c:2589
_dbus_geteuid
dbus_uid_t _dbus_geteuid(void)
Gets our effective UID.
Definition: dbus-sysdeps-unix.c:2681
_dbus_user_info_fill_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.
Definition: dbus-sysdeps-unix.c:2606
dbus_uid_t
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:108
DBUS_UID_UNSET
#define DBUS_UID_UNSET
an invalid UID used to represent an uninitialized dbus_uid_t field
Definition: dbus-sysdeps.h:115
_dbus_getenv
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Definition: dbus-sysdeps.c:187
_dbus_getuid
dbus_uid_t _dbus_getuid(void)
Gets our UID.
Definition: dbus-sysdeps-unix.c:2672
DBUS_UID_FORMAT
#define DBUS_UID_FORMAT
an appropriate printf format for dbus_uid_t
Definition: dbus-sysdeps.h:122
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
DBusCredentials
Definition: dbus-credentials.c:48
DBusError
Object representing an exception.
Definition: dbus-errors.h:49
DBusError::message
const char * message
public error message field
Definition: dbus-errors.h:51
DBusGroupInfo
Information about a UNIX group.
Definition: dbus-sysdeps-unix.h:120
DBusGroupInfo::groupname
char * groupname
Group name.
Definition: dbus-sysdeps-unix.h:122
DBusString
Definition: dbus-string.h:43
DBusUserInfo
Information about a UNIX user.
Definition: dbus-sysdeps-unix.h:107
DBusUserInfo::uid
dbus_uid_t uid
UID.
Definition: dbus-sysdeps-unix.h:108
DBusUserInfo::homedir
char * homedir
Home directory.
Definition: dbus-sysdeps-unix.h:113
DBusUserInfo::group_ids
dbus_gid_t * group_ids
Groups IDs, including above primary group.
Definition: dbus-sysdeps-unix.h:110
DBusUserInfo::username
char * username
Username.
Definition: dbus-sysdeps-unix.h:112