I'm writing an extension to a python program that will need to store passwords and need to access them during non interactive cronjobs (during the user is not logged in).
My first approach was to use seahorse
to store the password. But seahorse
is not accessible when the user is not logged in, is it?
You will probably have to store the password in a file that is only readable by root. crontab jobs run as root so they will have access, but other users of the system won't.
If it is acceptable to require the user to sign on first, you could have the user run a program to transfer the password from the gnome-keyring (seahorse) to a user owned file on a tmpfs file system. In that way it is never stored unencrypted on non-volatile storage.
an other approach:
A daemon start on users first time login collecting passwords from gnome-keyring and providing a private fifo (mode 0600) on which it will wait for requests (e.g. 'PROTOCOL:USER@HOST') and answer with password.