check_include_file(syslog.h HAVE_SYSLOG_H)
check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H)
+check_include_file(sys/random.h HAVE_SYS_RANDOM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_symbol_exists(SCM_RIGHTS "sys/types.h;sys/socket.h;sys/un.h" HAVE_UNIX_FD_PASSING)
check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL)
check_symbol_exists(raise "signal.h" HAVE_RAISE)
+check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM)
check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT)
check_symbol_exists(prlimit "sys/resource.h;sys/time.h" HAVE_PRLIMIT)
check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT)
#cmakedefine HAVE_SYS_EVENTS_H 1
#cmakedefine HAVE_SYS_INOTIFY_H 1
#cmakedefine HAVE_SYS_PRCTL_H 1
+#cmakedefine HAVE_SYS_RANDOM_H 1
#cmakedefine HAVE_SYS_RESOURCE_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_DDFD 1
#cmakedefine HAVE_INOTIFY_INIT1 1
+#cmakedefine HAVE_GETRANDOM 1
#cmakedefine HAVE_GETRLIMIT 1
#cmakedefine HAVE_PRCTL 1
#cmakedefine HAVE_PRLIMIT 1
getgrouplist
getpeereid
getpeerucred
+getrandom
getresuid
getrlimit
inotify_init1
signal.h
stdint.h
sys/prctl.h
+sys/random.h
sys/resource.h
sys/syslimits.h
sys/time.h
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
+#ifdef HAVE_SYS_RANDOM_H
+#include <sys/random.h>
+#endif
#ifdef HAVE_ADT
#include <bsm/adt.h>
int n_bytes,
DBusError *error)
{
- int old_len;
+ int old_len = _dbus_string_get_length (str);
int fd;
int result;
+#ifdef HAVE_GETRANDOM
+ char *buffer;
+
+ if (!_dbus_string_lengthen (str, n_bytes))
+ {
+ _DBUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ buffer = _dbus_string_get_data_len (str, old_len, n_bytes);
+ result = getrandom (buffer, n_bytes, GRND_NONBLOCK);
- old_len = _dbus_string_get_length (str);
- fd = -1;
+ if (result == n_bytes)
+ return TRUE;
+
+ _dbus_string_set_length (str, old_len);
+#endif
/* note, urandom on linux will fall back to pseudorandom */
fd = open ("/dev/urandom", O_RDONLY);
# armel, is one architecture that really
# doesn't have them)
set "$@" dbus_cv_sync_sub_and_fetch=no
+ # Disable getrandom syscall
+ set "$@" ac_cv_func_getrandom=no
# No epoll, kqueue or poll (we will fall back
# to select, even on Unix where we would
# usually at least have poll)