Page MenuHome GnuPG

Unable to set expiry when using --faked-system-time
Open, LowPublic

Description

I'm unable to set the expiry time when using using --faked-system-time.
Consider the following transcript:

us@chu:/tmp$ mktemp -d
/tmp/tmp.OBz461l17Y
us@chu:/tmp$ cd /tmp/tmp.OBz461l17Y
us@chu:/tmp/tmp.OBz461l17Y$ export GNUPGHOME=pwd
us@chu:/tmp/tmp.OBz461l17Y$ gpg --faked-system-time $(date -d '20170201
00:00:00' '+%s') --quick-gen-key '<test@test.com>'
...
us@chu:/tmp/tmp.OBz461l17Y$ gpg --faked-system-time $(date -d '20170201
00:00:01' '+%s') --edit-key '<test@test.com>'
gpg (GnuPG) 2.1.19-beta39; Copyright (C) 2017 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: WARNING: running with faked system time: 2017-01-31 23:00:01
gpg: key FA87F12A13277CBD was created 1 second in the future (time warp or clock
problem)
gpg: key FA87F12A13277CBD was created 1 second in the future (time warp or clock
problem)
Secret key is available.

sec rsa2048/FA87F12A13277CBD

created: 2017-01-31  expires: never       usage: SCEA
trust: ultimate      validity: ultimate

ssb rsa2048/A980349FD959518B

created: 2017-01-31  expires: never       usage:

[ultimate] (1). <test@test.com>

gpg> key 1

sec rsa2048/FA87F12A13277CBD

created: 2017-01-31  expires: never       usage: SCEA
trust: ultimate      validity: ultimate

ssb* rsa2048/A980349FD959518B

created: 2017-01-31  expires: never       usage:

[ultimate] (1). <test@test.com>

gpg> expire
Changing expiration time for a subkey.
Please specify how long the key should be valid.

   0 = key does not expire
<n>  = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years

Key is valid for? (0) 1d
Key expires at Thu 02 Feb 2017 12:00:08 AM CET
Is this correct? (y/N) y

sec rsa2048/FA87F12A13277CBD

created: 2017-01-31  expires: 2019-01-31  usage: SC  
trust: ultimate      validity: ultimate

ssb* rsa2048/A980349FD959518B

created: 2017-01-31  expires: never       usage: E

[ultimate] (1). <test@test.com>

gpg>

In this example, I set the time to be 1 second after the creation time, but
using a later time (specifically, I tried 1 month later) also doesn't work.

Event Timeline

neal renamed this task from Unable to set expiry to Unable to set expiry when using --faked-system-time.Feb 8 2017, 10:57 AM
neal removed gnupg-hackers as the assignee of this task.
neal added a project: Bug Report.
neal added subscribers: gnupg-hackers, neal.
neal removed a subscriber: neal.

--faked-system-time is debug hack, so I degrade this to a minor-bug.

werner lowered the priority of this task from Normal to Low.Feb 13 2017, 3:47 PM
werner added a project: gnupg.

Unfortunately, it is also used in the test suite to deal with expiration times.