692 Commits

Author SHA1 Message Date
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
Wolfgang Hommel
f8a0ad2496 Merge pull request #244 from sdettmer/dev/sde/faketime_link_flags
Added support for FAKETIME_LINK_FLAGS for #243.
2020-04-08 19:47:46 +02:00
Steffen Dettmer
0e3269efdc Added support for FAKETIME_LINK_FLAGS for #243. 2020-04-08 19:40:31 +02:00
Wolfgang Hommel
04e78e67bf Unskip file parsing on improper initialization #240 2020-03-26 20:07:24 +01:00
Wolfgang Hommel
0e798503a4 Merge pull request #237 from FeepingCreature/fix/use-pthread-mutex-initializer-again
replace global state struct with local state struct holding a pointer to the global mutex variable
2020-03-16 13:45:37 +01:00
Mathis Beer
a7f7a54e1d replace global state struct with local state struct holding a pointer to the global mutex variable
this fixes the `{ 0 }` initializer not compiling on some platforms
fix issue 231
fix issue 235
2020-03-16 07:57:07 +01:00
Wolfgang Hommel
8075c2e250 Merge pull request #234 from FeepingCreature/fix/use-appropriate-mask-function
Fix timing issue with multiple threads
2020-03-12 21:39:17 +01:00
Mathis Beer
a12ca58dfa fix threading issue: don't assign to the global lock state struct until we're safely inside the mutex.
Otherwise, we might be overwriting the global lock state from two different
threads at once.
2020-03-12 06:49:29 +01:00
Mathis Beer
b4dea2ef9b Unlock faketime lock on all return paths from libfaketime.c.
These gymnastics are necessary because pthread_cleanup_push
and pthread_cleanup_pop must match exactly 1:1 and appear at
the same level of indentation.

This is because pthread_cleanup_push/pop are implemented in
such a way that pthread_cleanup_push opens a scope and
pthread_cleanup_pop closes it.

They're macros with unbalanced brackets.
C, ladies and gentlemen.

So instead of returning, we have to set a field indicating our
intent to return and then jump to the unlock site.
2020-03-12 06:45:43 +01:00