Search code examples
linuxgnupgopenwrtgpg-signature

When does GPG load its keys?


On an OpenWRT installation, I have an update script that downloads a file and checks its GPG signature.

If I run this script at boot in rc.d at priority 99 (it's the last one), I get a "gpg: Can't check signature: public key not found" error. If I run it via Cron or manually, everything works.

I also tried to add a 60 second sleep before running the script.

Is there a way to know when GPG finished its init?


Solution

  • Turns out, scripts in rc.d are not run as root, or the root home is not specified yet (?), so the home directory where GPG is looking for signatures is different (it's looking at //.gnupg/ instead of /root/.gnupg/). Adding the homedir parameter to GPG allows to specify the directory; this works:

    gpg --homedir /root/.gnupg/ --verify update.gpg