summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* add support for timerfd_{set,get}timeValentin Gatien-Baron2021-03-301-5/+72
|
* Merge pull request #318 from jimklimov/date-prog-sunWolfgang Hommel2021-03-281-1/+1
|\ | | | | faketime.c: default to GNU date as "gdate" on Sun-related OSes
| * faketime.c: default to GNU date as "gdate" on Sun-related OSesJim Klimov2021-03-281-1/+1
| |
* | Merge pull request #317 from jimklimov/date-prog-argWolfgang Hommel2021-03-281-0/+17
|\ \ | | | | | | faketime.c: allow user to select their implementation of GNU date
| * | faketime.c: allow user to select their implementation of GNU dateJim Klimov2021-03-281-0/+17
| |/
* | src/sunos_endian.h: No newline at end of fileJim Klimov2021-03-281-1/+1
|/ | | | | For pedantic compilers this is actually a fatal error, since per (older?) C standards the file should end with an EOL.
* Centralize assumptions about variadic argument re-packingDaniel Kahn Gillmor2021-03-053-16/+46
| | | | | By stating these assumptions in src/faketime_common.h, we can reuse them in the tests as well as in the code.
* Promote syscall passthrough arguments to long instead of int (#310)Wolfgang Hommel2021-03-041-1/+1
|
* Pass through syscall(__NR_clock_gettime) if FAKERANDOM is unsetDaniel Kahn Gillmor2021-03-021-1/+1
| | | | | | | | | | | If FAKERANDOM is unset, we were still intercepting syscall() and passing it through to clock_gettime, rather than letting it fall through to real_syscall. That would have the effect of diverting syscall(__NR_clock_gettime,…) into the libc invocation of clock_gettime(…) (via real_clock_gettime). While that probably does the same thing, it's probably a mistake to do such a diversion when FAKETIME is unset.
* Merge pull request #309 from dkg/faketime-pidWolfgang Hommel2021-02-261-0/+17
|\ | | | | faketime: add -p option to wrapper for setting PID
| * faketime: add -p option to wrapper for setting PIDDaniel Kahn Gillmor2021-02-251-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I had to decide what to do if FAKE_PID wasn't defined during the build. I decided that since the wrapper can't be sure it is preloading the same library that it was built with (someone could somehow mix and match the library and the wrapper tool), it should just warn and pass along the value anyway. This reserves the option space, but shouldn't annoy people too much if they are running it on a system that doesn't have FAKE_PID enabled. I note that this happens regardless of whether it is a "direct" invocation or not. I don't fully understand all the tradeoffs here, so I would appreciate another set of eyes reviewing this choice. Closes: #308
* | Handle when another library uses a syscall in a constructorDaniel Kahn Gillmor2021-02-251-0/+2
|/ | | | | Without this fix, the test_library_constructors test was failing on use_lib_syscall.
* divert syscall() to clock_gettime() (#176 #302)Wolfgang Hommel2021-02-251-0/+10
|
* Use real_getpid instead of getpid in ft_shm_create() under FAKE_PIDDaniel Kahn Gillmor2021-02-251-2/+8
| | | | This addresses part of the concerns raised in #297
* Merge pull request #304 from dkg/cover-getentropyWolfgang Hommel2021-02-251-4/+20
|\ | | | | better testing for interception of randomness from the kernel, including getentropy()
| * if FAKE_RANDOM is present, try to intercept getentropy as well.Daniel Kahn Gillmor2021-02-241-4/+20
| | | | | | | | Closes: #303
* | Intercept syscallDaniel Kahn Gillmor2021-02-242-0/+59
|/ | | | | | | | | | | | | | | | | | | | | | This is an attempt at an implementation to address #301. Some things worth noting: - I am not particularly confident in my reverse of the variadic C ABI. While the code appears to work for me on x86_64, I could imagine some variations between platforms that I'm not understanding. - This works to intercept the invocation of syscall as seen in test/syscalltest.sh, as long as it was compiled with -DFAKE_RANDOM - defining -DINTERCEPT_SYSCALL on non-Linux platforms should result in a compile-time error. - This does *not* work to intercept the syscall sent by `openssl rand`, for some reason I don't yet understand. Perhaps openssl has some platform-specific syscall mechanism that doesn't route them through libc's syscall() shim?
* Merge pull request #298 from dkg/fakepidWolfgang Hommel2021-02-242-0/+26
|\ | | | | Enable intercepting getpid()
| * Enable intercepting getpid()Daniel Kahn Gillmor2021-02-232-0/+26
| | | | | | | | | | | | | | I went with the runtime environment variable being FAKETIME_FAKEPID since it seems less likely to collide with anything else. Closes: #297
* | Ensure that real_getrandom is initialized properlyDaniel Kahn Gillmor2021-02-231-0/+4
|/ | | | | | | | | 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
* Version bump to v0.9.9v0.9.9Wolfgang Hommel2021-02-213-4/+4
|
* Handle EINTR during sem_wait() in selected functions (addresses #291)Wolfgang Hommel2021-02-091-8/+36
|
* Merge pull request #285 from dkg/fix-clobberWolfgang Hommel2021-02-041-1/+1
|\ | | | | Try to fix warning about clobbering under optimization (Closes #284)
| * Try to fix warning about clobbering under optimization (Closes #284)Daniel Kahn Gillmor2021-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | fix embedded version numberDaniel Kahn Gillmor2021-02-021-1/+1
|/
* faketime: Prefix error messages with faketimeOxan van Leeuwen2020-12-081-12/+12
|
* Preliminary support to intercept getrandom() #275Wolfgang Hommel2020-11-152-1/+52
|
* Some fixes and improvements for utime functions.Wayne Davison2020-07-282-19/+144
| | | | | | | | | | | | | | | | | | - 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.
* Merge pull request #248 from sdettmer/fix_settime_when_using_rcfileWolfgang Hommel2020-04-091-0/+1
|\ | | | | Fixes #247, FAKE_SETTIME has effect even if rcfile is present
| * Fixes #247, FAKE_SETTIME has effect even if rcfile is presentSteffen Dettmer2020-04-091-0/+1
| |
* | settime functions support FAKETIME_UPDATE_TIMESTAMP_FILE (for #239).Steffen Dettmer2020-04-091-0/+36
|/ | | | | | | | 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.
* Merge pull request #246 from sdettmer/dev/sde/pthread_cond_init_232_lazy_initWolfgang Hommel2020-04-081-0/+11
|\ | | | | Add lazy ftpl_init() to pthread_cond_init_232(), fixes #245.
| * Add lazy ftpl_init() to pthread_cond_init_232(), fixes #245.Steffen Dettmer2020-04-081-0/+11
| |
* | Added support for FAKETIME_LINK_FLAGS for #243.Steffen Dettmer2020-04-081-1/+1
|/
* Unskip file parsing on improper initialization #240Wolfgang Hommel2020-03-261-28/+45
|
* replace global state struct with local state struct holding a pointer to the ↵Mathis Beer2020-03-161-7/+7
| | | | | | | | global mutex variable this fixes the `{ 0 }` initializer not compiling on some platforms fix issue 231 fix issue 235
* fix threading issue: don't assign to the global lock state struct until ↵Mathis Beer2020-03-121-3/+5
| | | | | | | we're safely inside the mutex. Otherwise, we might be overwriting the global lock state from two different threads at once.
* Unlock faketime lock on all return paths from libfaketime.c.Mathis Beer2020-03-121-6/+18
| | | | | | | | | | | | | | | | 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.
* use pthread_sigmask instead of sigprocmaskMathis Beer2020-03-121-3/+2
| | | | pthread_sigmask is the one meant for threaded programs.
* Fix deadlock issues with signals: block all signals while inside mutex.Mathis Beer2020-03-031-5/+26
|
* fake_clock_gettime: avoid placing large buffers on the stackMathis Beer2020-02-201-3/+3
|
* Merge pull request #227 from wolfcw/developWolfgang Hommel2020-02-141-8/+27
|\ | | | | | | Refresh the monotonic faketime setting envvar when cache expires.
| * Refresh the monotonic faketime setting envar when cache expires.thowse2020-02-141-8/+27
| |
* | time multiplication overflow fixAbhishek Sunkum Rammurthy2019-12-171-3/+3
| | | | | | | | | | In 32 bit platforms, timespecmul2() macro function, overflow occurs during multiplication. Size of `long` type in 32 bit platform is 4 bytes, but the size of `long` type in 64 bit platform is 8 bytes.
* | Use -DFAKE_FILE_TIMESTAMPS to intercept utime[s](), by @speq, #183Wolfgang Hommel2019-12-141-0/+75
| |
* | fix #ifndef for timermul, @speq, #183Wolfgang Hommel2019-12-141-1/+1
|/
* wrap nanosec ops in #ifndef, patch by @paul-j-lucas, #219Wolfgang Hommel2019-12-141-0/+12
|
* Revert "Automake branch"revert-178-automake-branchWolfgang Hommel2019-11-306-82/+220
|
* Merge pull request #178 from manchicken/automake-branchWolfgang Hommel2019-11-306-220/+82
|\ | | | | Automake branch
| * Merged master in and cleaned up.Michael D. Stemle, Jr2019-11-272-28/+659
| |\ | | | | | | We no longer need the OSX-specific test. Tests are passing, too.