Page MenuHome GnuPG

gpgme does not find key after setuid()
Closed, InvalidPublic

Description

I have code that sets uid after I start it as root. I have a user A
that owns a key, and I su - to root. Then I do:
./simple-signer <my key name> '<data to sign>' A
In this case, gpgme does not find the key for user A.

However, if I run the following as user A:
./simple-signer <my key name> '<data to sign>'
gpgme finds the key for user A.

I am attaching my code, for reference. My question is : do I need to
do something that will enable gpgme to find the key when I run my code
as root?

Details

Version
1.1.8

Event Timeline

kpgadkari raised the priority of this task from Normal to High.May 2 2009, 6:40 PM
kpgadkari added a project: gpgme.
werner assigned this task to marcus.
werner lowered the priority of this task from High to Normal.
werner removed a project: Bug Report.
werner added a subscriber: marcus.

I looked at the code and it seems that you assume that a setuid(2)
changes more than just the UIDs of the current process. In particular,
you assume that environment variables change - that is not the case:
Like any envvar HOME does not change by calling setuid() or any other
system function. To change the envvars, your code needs to do this.