diff options
author | Damien Goutte-Gattat <dgouttegattat@incenp.org> | 2017-01-18 18:52:12 +0100 |
---|---|---|
committer | Justus Winter <justus@g10code.com> | 2017-01-19 10:39:06 +0100 |
commit | 3daeef702b2e6a42f0f396b828f86ffc3f33fc88 (patch) | |
tree | fc12a159c0920a7cc991853e1543baa04719f30a /g10 | |
parent | common: Clarify use of vars in buffer copy code. (diff) | |
download | gnupg2-3daeef702b2e6a42f0f396b828f86ffc3f33fc88.tar.xz gnupg2-3daeef702b2e6a42f0f396b828f86ffc3f33fc88.zip |
gpg: Allow to freeze faked system time.
* g10/gpg.c (main): If the parameter for --faked-system-time
ends with a '!', freeze time at the specified point.
* common/gettime.c (gnupg_set_time): Allow to freeze the time
at an arbitrary time instead of only the current time.
* doc/gpg.texi: Update documentation for --faked-system-time.
--
This patch allows the user to modify the behavior of the
--faked-system-time option: by appending a '!' to the parameter,
time in GnuPG will be frozen at the specified time, instead of
advancing normally from that time onward.
Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Diffstat (limited to 'g10')
-rw-r--r-- | g10/gpg.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -3493,10 +3493,20 @@ main (int argc, char **argv) case oFakedSystemTime: { - time_t faked_time = isotime2epoch (pargs.r.ret_str); + size_t len = strlen (pargs.r.ret_str); + int freeze = 0; + time_t faked_time; + + if (len > 0 && pargs.r.ret_str[len-1] == '!') + { + freeze = 1; + pargs.r.ret_str[len-1] = '\0'; + } + + faked_time = isotime2epoch (pargs.r.ret_str); if (faked_time == (time_t)(-1)) faked_time = (time_t)strtoul (pargs.r.ret_str, NULL, 10); - gnupg_set_time (faked_time, 0); + gnupg_set_time (faked_time, freeze); } break; |