diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-12-30 21:03:55 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-12-30 23:25:13 +0100 |
commit | 34c71acbc9ae19575aa11a1b0f79b39ba02ba784 (patch) | |
tree | ddfee1da5168fa62170f57c960c693be07175f31 | |
parent | 0a9e994335f5436c0c1e77c8c79e7b322f5da746 (diff) | |
download | hurd-34c71acbc9ae19575aa11a1b0f79b39ba02ba784.tar.gz hurd-34c71acbc9ae19575aa11a1b0f79b39ba02ba784.tar.bz2 hurd-34c71acbc9ae19575aa11a1b0f79b39ba02ba784.zip |
random: Add a trivfs_server_name
glibc uses /dev/urandom for getrandom(), and from version 2.34 malloc
initialization uses it. We need to be able to know whether we are
running the random translator itself, in which case we can't read
ourself.
-rw-r--r-- | libtrivfs/io-version.c | 10 | ||||
-rw-r--r-- | libtrivfs/trivfs.h | 7 | ||||
-rw-r--r-- | trans/random.c | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/libtrivfs/io-version.c b/libtrivfs/io-version.c index e656d5cc..59a0ebef 100644 --- a/libtrivfs/io-version.c +++ b/libtrivfs/io-version.c @@ -27,5 +27,13 @@ trivfs_S_io_server_version (trivfs_protid_t obj, int *min, int *edit) { - return EOPNOTSUPP; + if (!obj) + return EOPNOTSUPP; + + if (!&trivfs_server_name || !&trivfs_server_version) + return EOPNOTSUPP; + + snprintf (name, sizeof (string_t), "%s %s", + trivfs_server_name, trivfs_server_version); + return 0; } diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h index c920b678..1295fe17 100644 --- a/libtrivfs/trivfs.h +++ b/libtrivfs/trivfs.h @@ -74,6 +74,13 @@ struct trivfs_control void *hook; /* for user use */ }; +/* The user may define this variable. Set this to the name of the + filesystem server. */ +extern char *trivfs_server_name __attribute__((weak)); + +/* The user may define this variables. Set this to be the server + version number. */ +extern char *trivfs_server_version __attribute__((weak)); /* The user must define these variables. */ extern int trivfs_fstype; diff --git a/trans/random.c b/trans/random.c index f0b99dd4..b409d39f 100644 --- a/trans/random.c +++ b/trans/random.c @@ -44,6 +44,8 @@ +char *trivfs_server_name = "random"; + /* Entropy pool. We use one of the SHAKE algorithms from the Keccak family. Being a sponge construction, it allows the extraction of arbitrary amounts of pseudorandom data. */ |