Find a file
Zbigniew Jędrzejewski-Szmek f0d09059bd basic/random-util: do not fall back to /dev/urandom if getrandom() returns short
During early boot, we'd call getrandom(), and immediately fall back to
reading from /dev/urandom unless we got the full requested number of bytes.
Those two sources are the same, so the most likely result is /dev/urandom
producing some pseudorandom numbers for us, complaining widely on the way.

Let's change our behaviour to be more conservative:
- if the numbers are only used to initialize a hash table, a short read is OK,
  we don't really care if we get the first part of the seed truly random and
  then some pseudorandom bytes. So just do that and return "success".

- if getrandom() returns -EAGAIN, fall back to rand() instead of querying
  /dev/urandom again.

  The idea with those two changes is to avoid generating a warning about
  reading from an /dev/urandom when the kernel doesn't have enough entropy.

- only in the cases where we really need to make the best effort possible
  (sd_id128_randomize and firstboot password hashing), fall back to
  /dev/urandom.

When calling getrandom(), drop the checks whether the argument fits in an int —
getrandom() should do that for us already, and we call it with small arguments
only anyway.

Note that this does not really change the (relatively high) number of random
bytes we request from the kernel. On my laptop, during boot, PID 1 and all
other processes using this code through libsystemd request:
  74780 bytes with high_quality_required == false
    464 bytes with high_quality_required == true
and it does not eliminate reads from /dev/urandom completely. If the kernel was
short on entropy and getrandom() would fail, we would fall back to /dev/urandom
for those 464 bytes.

When falling back to /dev/urandom, don't lose the short read we already got,
and just read the remaining bytes.

If getrandom() syscall is not available, we fall back to /dev/urandom same
as before.

Fixes #4167 (possibly partially, let's see).
2017-06-28 10:32:02 -04:00
.github github: how to report bugs for older distribution versions (#6146) 2017-06-20 20:20:25 +02:00
.mkosi Merge pull request #6176 from poettering/timer-boottime-monotonic 2017-06-22 21:34:39 -04:00
catalog meson: reindent all files with 8 spaces 2017-04-23 21:47:29 -04:00
coccinelle tree-wide: drop NULL sentinel from strjoin 2016-10-23 11:43:27 -04:00
docs meson: use booleans for conf.set and drop unecessary conditionals 2017-05-02 16:29:11 -04:00
factory/etc factory: remove broken pam_limits 2014-07-30 15:21:54 +02:00
hwdb meson: increase timeout for parse_hwdb.py test to 90 s 2017-06-24 19:24:20 -04:00
m4 build-sys: Perform flag tests in context to existing flags 2016-02-06 14:57:46 +01:00
man Merge pull request #5600 from fbuihuu/make-logind-restartable 2017-06-24 18:58:36 -04:00
network meson: use booleans for conf.set and drop unecessary conditionals 2017-05-02 16:29:11 -04:00
po Added slovak translation (#6191) 2017-06-25 13:19:10 -04:00
rules rules: watch metadata changes in mmcblk devices (#6050) 2017-05-30 15:19:03 +02:00
shell-completion zsh: add completion for add-wants and add-requires (#6082) 2017-06-06 21:32:15 -04:00
src basic/random-util: do not fall back to /dev/urandom if getrandom() returns short 2017-06-28 10:32:02 -04:00
sysctl.d meson: use booleans for conf.set and drop unecessary conditionals 2017-05-02 16:29:11 -04:00
system-preset units: make enablement of s-n-wait-online.service follow systemd-networkd.service (#5635) 2017-03-27 12:55:55 +02:00
sysusers.d meson: do not use path separator for target name (#6177) 2017-06-22 21:27:07 -04:00
test test: ensure 'InaccessiblePaths=/proc' option works (#6017) 2017-05-25 07:47:08 +03:00
tmpfiles.d meson: do not use path separator for target name (#6177) 2017-06-22 21:27:07 -04:00
tools Mark python scripts executable 2017-05-07 20:16:47 -04:00
units Merge pull request #5600 from fbuihuu/make-logind-restartable 2017-06-24 18:58:36 -04:00
xorg login: support user-bus on dbus1 2015-08-31 18:12:37 +02:00
.dir-locals.el meson: also indent scripts with 8 spaces 2017-04-25 08:49:16 -04:00
.editorconfig editors: only extend line width to 119 for C and XML files 2016-02-10 12:29:32 +01:00
.gitattributes git: indicate that tabs are never OK in the systemd tree 2013-10-30 02:25:38 +01:00
.gitignore test-timesync: add first test for timesyncd conf parsing 2017-05-25 10:59:35 -04:00
.mailmap mailmap: add entries for recent commits from github 2017-05-30 21:36:27 -04:00
.travis.yml remove gudev and gtk-doc 2015-06-03 00:22:53 +02:00
.vimrc vimrc: fix indentation logic for our docbook xml files 2016-04-29 12:23:34 +02:00
.ycm_extra_conf.py ycm: update flag blacklist 2014-06-04 15:41:10 -04:00
autogen.sh build-sys/autogen: don't use bashisms (#4489) 2016-10-25 19:39:48 -04:00
CODING_STYLE tree-wide: set SA_RESTART for signal handlers we install 2016-12-01 12:41:17 +01:00
configure.ac make nss-systemd support conditional (#6155) 2017-06-24 13:30:26 -04:00
DISTRO_PORTING It's now ok to use Google NTP servers (#5311) 2017-02-12 00:30:40 -05:00
ENVIRONMENT.md Rename $TEST_DIR to $SYSTEMD_TEST_DATA, document it 2017-02-16 21:36:31 +01:00
HACKING HACKING: update qemu-kvm instructions (#6138) 2017-06-20 23:16:16 +02:00
LICENSE.GPL2 relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
LICENSE.LGPL2.1 licence: remove references to old FSF address 2012-12-17 11:41:31 +01:00
Makefile-man.am make nss-systemd support conditional (#6155) 2017-06-24 13:30:26 -04:00
Makefile.am make nss-systemd support conditional (#6155) 2017-06-24 13:30:26 -04:00
meson.build make nss-systemd support conditional (#6155) 2017-06-24 13:30:26 -04:00
meson_options.txt make nss-systemd support conditional (#6155) 2017-06-24 13:30:26 -04:00
mkosi.build mkosi.build: set encoding 2017-05-05 21:19:04 -04:00
mkosi.default mkosi: create .mkosi directory 2016-10-06 11:53:58 -04:00
NEWS kernel-install: support the case /etc/machine-id is missing or empty (#5975) 2017-05-30 09:45:10 -04:00
README Merge pull request #5928 from keszybz/libidn2 2017-05-12 12:01:40 +02:00
README.md README: include small graphs of open issues and pull requests (#5576) 2017-03-13 08:10:04 +01:00
TODO update TODO 2017-04-24 18:48:10 +02:00

systemd - System and Service Manager

Count of open issues over time Count of open pull requests over time Build Status
Coverity Scan Status

Details

General information about systemd can be found in the systemd Wiki.

Information about build requirements are provided in the README file.

Consult our NEWS file for information about what's new in the most recent systemd versions.

Please see the HACKING file for information how to hack on systemd and test your modifications.

Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.

When preparing patches for systemd, please follow our Coding Style Guidelines.

If you are looking for support, please contact our mailing list or join our IRC channel.