Commit Graph

450 Commits

Author SHA1 Message Date
Daniel Kahn Gillmor
00d6edf90c Test repeated invocations of getrandom()
A single program that invokes getrandom() repeatedly should end up
with the same stream of bytes, regardless of how it chunks up the
reading from the entropy source.

This test already passses.  I'm including it because it seems
like a useful confirmation.
2021-02-24 15:24:45 -05:00
Wolfgang Hommel
a8283c646d Merge pull request #300 from dkg/improve-tests
Test getpid() against a library that invokes getpid() in its constructor
2021-02-24 17:54:30 +01:00
Daniel Kahn Gillmor
2ca0b719e3 test getpid() against library with constructor that calls it
This is an attempt to ensure that an external library invocation of
getpid doesn't trigger a crash (e.g. #295) or an infinite loop
(e.g. #297).
2021-02-24 11:15:31 -05:00
Daniel Kahn Gillmor
f6ddc32695 Genericize build rules for testing external libraries with constructor
This paves the way for testing other interceptions like getpid() with
shared objects that do devious things in their consturctors.
2021-02-24 11:15:01 -05:00
Daniel Kahn Gillmor
8de66f799f randomtest.sh requires librandom.so to be present
In some configurations, GNU make might treat librandom.so as an
ephemeral/intermediate build artifact and destroy it before
randomtest.sh is run.  This ensures the shared object is present when
needed.
2021-02-24 11:14:37 -05:00
Wolfgang Hommel
63fe6f0be5 Merge pull request #298 from dkg/fakepid
Enable intercepting getpid()
2021-02-24 13:53:45 +01:00
Wolfgang Hommel
062abac575 Merge pull request #299 from dkg/fix-getrandom
Ensure that real_getrandom is initialized properly
2021-02-24 06:34:46 +01:00
Daniel Kahn Gillmor
004222585e Enable intercepting getpid()
I went with the runtime environment variable being FAKETIME_FAKEPID
since it seems less likely to collide with anything else.

Closes: #297
2021-02-23 22:19:08 -05:00
Daniel Kahn Gillmor
9c59e24d33 Ensure that real_getrandom is initialized properly
This avoids potential failure if another library calls getrandom()
within its constructor before we are loaded.

For me, it lets "make randomtest" succeed in tests/

Closes: #295
2021-02-23 22:15:24 -05:00
Wolfgang Hommel
46dc625642 Merge pull request #296 from dkg/test-getrandom-library-init
test getrandom() in library initialization without FAKERANDOM_SEED
2021-02-23 22:08:43 +01:00
Daniel Kahn Gillmor
8f2c856d8e test getrandom() in library initialization without FAKERANDOM_SEED
Running "make randomtest" should demonstrates the segfault described
in https://github.com/wolfcw/libfaketime/issues/295
2021-02-23 11:14:37 -05:00
Wolfgang Hommel
b4a822cd6a Merge pull request #294 from dkg/improve-FAKE_RANDOM-tests
Improve tests for FAKE_RANDOM
2021-02-23 06:24:57 +01:00
Daniel Kahn Gillmor
54994ceb0d Improve tests for FAKE_RANDOM
Previously, we had failed to test code with getrandom() against
LD_PRELOAD when FAKERANDOM_SEED was unset.

We also want to try calling getrandom twice in a single process to
make sure that works OK.
2021-02-22 22:49:05 -05:00
Wolfgang Hommel
3c0b101a84 Version bump to v0.9.9 v0.9.9 2021-02-21 18:27:02 +01:00
Wolfgang Hommel
44a6d1f0fa Set FORCE_MONOTONIC_FIX for GitHub CI 2021-02-12 17:04:28 +01:00
Wolfgang Hommel
772d9523a7 Do not fail due to timer overrun counter mismatch on GNU/Hurd for now (#287) 2021-02-12 16:59:42 +01:00
Wolfgang Hommel
8b5519d496 Handle EINTR during sem_wait() in selected functions (addresses #291) 2021-02-09 20:16:08 +01:00
Wolfgang Hommel
3ba66842aa Make randomtest.sh use FAKETIME_TESTLIB like the rest of the test cases 2021-02-04 21:40:55 +01:00
Wolfgang Hommel
4359458c7c Merge pull request #289 from dkg/getrandom_test-cleanup
Ease build of getrandom_test
2021-02-04 21:39:02 +01:00
Wolfgang Hommel
726c4657fc Merge branch 'master' of github.com:wolfcw/libfaketime 2021-02-04 21:32:22 +01:00
Wolfgang Hommel
8853afb509 Added optional FAKETIME_TESTLIB environment variable for make test (#288) 2021-02-04 21:30:01 +01:00
Wolfgang Hommel
48f280ac86 Merge pull request #285 from dkg/fix-clobber
Try to fix warning about clobbering under optimization (Closes #284)
2021-02-04 20:07:56 +01:00
Wolfgang Hommel
47e6f5f33d Merge pull request #283 from dkg/update-version-number
fix embedded version number
2021-02-03 19:53:49 +01:00
Wolfgang Hommel
e4e5ea6211 Merge pull request #286 from dkg/speling
Fix spelling
2021-02-03 19:51:19 +01:00
Daniel Kahn Gillmor
206ae9ea80 Ease build of getrandom_test
In trying to test the experimental getrandom features, I found a few
minor problems.  These changes should make it easier to test.

After building, the developer can now just do:

    make -C test randomtest

This will do a basic verfication that the feature works as expected.

I haven't tried to integrate this with the overall "make test".  To do
that right, it should condition the test on the definition of
FAKE_RANDOM.
2021-02-03 13:12:32 -05:00
Daniel Kahn Gillmor
cce377b371 Fix spelling 2021-02-03 11:55:28 -05:00
Daniel Kahn Gillmor
5e6ed4cd2c Try to fix warning about clobbering under optimization (Closes #284)
Without this fix, when compiling with `-O1` or more, we see:

```
libfaketime.c: In function ‘fake_clock_gettime’:
libfaketime.c:2843:7: error: variable ‘ret’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
 2843 |   int ret = INT_MAX;
      |       ^~~
cc1: all warnings being treated as errors
```

This error doesn't happen when using `-O0`.

The warning appears to happen when the compiler optimizes `ret`
because it is the return value for the function call (meaning maybe
preserved in a register, or some other more risky placement that might
break during the `goto` error cases?).  Explicitly marking it as
volatile should keep the compiler from optimizing that way, regardless
of the level of optimization the user asks for.

I got the idea to use `volatile` here from the rather confused
discussion in
https://cboard.cprogramming.com/c-programming/147829-help-me-warning-argument-fmtstring-might-clobbered-longjmp-vfork.html

I admit I don't fully understand what's going on here, and would be
grateful for review by someone who understands the machinery here at a
deeper level than I do.
2021-02-02 20:14:37 -05:00
Daniel Kahn Gillmor
55e634a6ca fix embedded version number 2021-02-02 19:23:13 -05:00
Wolfgang Hommel
532816864e Merge pull request #278 from oxan/prefix-error-messages
faketime: Prefix error messages with faketime
2020-12-08 19:14:47 +01:00
Oxan van Leeuwen
4564afb924 faketime: Prefix error messages with faketime 2020-12-08 17:27:06 +01:00
Wolfgang Hommel
5b8673df54 Updated macOS-specific documentation, especially regarding SIP issues 2020-11-16 17:05:17 +01:00
Wolfgang Hommel
e00ba47ca9 Preliminary documentation related to #275 changes 2020-11-16 16:56:47 +01:00
Wolfgang Hommel
ca2f3fefa1 Preliminary support to intercept getrandom() #275 2020-11-15 21:57:10 +01:00
Wolfgang Hommel
dacc5866a7 Merge pull request #270 from sanjaymsh/ppc64le
Travis-ci: added support for ppc64le
2020-10-07 19:52:48 +02:00
sanjay-cpu
b35e7c8ca6 Travis-ci: added support for ppc64le 2020-10-07 08:28:41 +00:00
Wolfgang Hommel
25a60d0292 Merge pull request #261 from WayneD/master
Some fixes and improvements for utime functions.
2020-07-29 08:11:58 +02:00
Wayne Davison
d90c8c26d3 Some fixes and improvements for utime functions.
- Fix the utime() and utimes() functions to work with a NULL arg
  (which is a request for "now").
- Add missing utimensat() & futimens() functions.
- Add support for a FAKE_UTIME define and enable it by default.  This
  is like defining FAKE_FILE_TIMESTAMPS except that the code defaults
  to NO utime faking unless FAKE_UTIME environment var enables it.
- When utime values are not being faked, the use of a NULL arg or a
  UTIME_NOW nsec value gives the user NOW translated into their fake
  current time.  This is because the caller's fake times are otherwise
  being preserved, so we should help their NOW request also be handled
  as a fake time.
- Mention FAKE_FILE_TIMESTAMPS & FAKE_UTIME in the src/Makefile.
- Move a sanity check in fake_clock_gettime() to where it is actually
  prior to all the pointer dereferences it should protect.
- Get rid of an errant tab in the src/Makefile's comments.
2020-07-28 18:04:11 -07:00
Wolfgang Hommel
c683c81417 Merge pull request #257 from robinlinden/deprecated-func-warning
Fix make test build failure on gcc 9.3
2020-05-29 06:35:51 +02:00
Robin Linden
f19d68ea32 Fix make test build failure on gcc 9.3
On Ubuntu 20.04 using gcc 9.3, make test fails due to a deprecated
function (ftime) warning in combination with -Werror in timetest.c.
Since the warning is from a test testing that the deprecated function
can be replaced using LD_PRELOAD, I think it's reasonable to just
silence the warning in that case.
2020-05-28 23:26:25 +02:00
Wolfgang Hommel
c36674c27f remote automake branch workflow until work on it continues 2020-05-10 13:28:30 +02:00
Wolfgang Hommel
112809f986 Merge branch 'master' of github.com:wolfcw/libfaketime 2020-04-10 13:28:05 +02:00
Wolfgang Hommel
9498b2cacc add ./configure step to action for automake branch 2020-04-10 13:27:51 +02:00
Wolfgang Hommel
c9a3b1bace Merge pull request #248 from sdettmer/fix_settime_when_using_rcfile
Fixes #247, FAKE_SETTIME has effect even if rcfile is present
2020-04-09 19:53:06 +02:00
Wolfgang Hommel
834953480e Merge pull request #249 from sdettmer/settime_update_timestamp_file
settime functions support FAKETIME_UPDATE_TIMESTAMP_FILE (for #239).
2020-04-09 19:47:06 +02:00
Steffen Dettmer
c1d10321a7 settime functions support FAKETIME_UPDATE_TIMESTAMP_FILE (for #239).
When the environment variable FAKETIME_TIMESTAMP_FILE is set, points to
a writeable (creatable) custom config file and the environment variable
FAKETIME_UPDATE_TIMESTAMP_FILE is "1", then the file also is updated on
each call. By this, a common "virtual time" can be shared by several
processes, where each can adjust the time for all.
2020-04-09 16:06:32 +02:00
Steffen Dettmer
58ccfb6c27 Fixes #247, FAKE_SETTIME has effect even if rcfile is present 2020-04-09 13:04:40 +02:00
Wolfgang Hommel
1e25e1f042 fix for github action for automake branch 2020-04-09 11:41:01 +02:00
Wolfgang Hommel
690ed3f158 github action for automake branch 2020-04-09 06:41:10 +02:00
Wolfgang Hommel
d2f0daf092 Merge pull request #246 from sdettmer/dev/sde/pthread_cond_init_232_lazy_init
Add lazy ftpl_init() to pthread_cond_init_232(), fixes #245.
2020-04-08 20:11:57 +02:00
Steffen Dettmer
c5b5d0b56e Add lazy ftpl_init() to pthread_cond_init_232(), fixes #245. 2020-04-08 19:57:14 +02:00