asrobins
asked on
gpg - failed to create temporary file
I have written a Perl script on CentOS 4.4 to read the contents of a directory and then encrypt the files using gpg. the command is:
gpg -r 'username' --batch --encrypt-files 'filename.ext'
I created the script as root. When I run it interactively from the console, it works just fine. However, if I try to run it from cron or start it from another process (running as root), I receive the following error:
gpg: failed to create temporary file `~/.gnupg/.#lk0x9804868.xx xxxxxxx.31 811': No such file or directory
gpg: fatal: ~/.gnupg: can't create directory: No such file or directory
I've echoed the tilde (~) from within the script and it translates to "/root". The directory "/root/.gnupg" does exist and has proper owner permissions.
Any ideas would be appreciated. Thanks.
gpg -r 'username' --batch --encrypt-files 'filename.ext'
I created the script as root. When I run it interactively from the console, it works just fine. However, if I try to run it from cron or start it from another process (running as root), I receive the following error:
gpg: failed to create temporary file `~/.gnupg/.#lk0x9804868.xx
gpg: fatal: ~/.gnupg: can't create directory: No such file or directory
I've echoed the tilde (~) from within the script and it translates to "/root". The directory "/root/.gnupg" does exist and has proper owner permissions.
Any ideas would be appreciated. Thanks.
ASKER
Yes, that it correct. It works fine from the console as root, but not from cron as root. I've tried changing the permissions on the /root/.gnupg directory to 777, but it still does not work. That leads me to believe that it is not trying to place the file there, but somewhere else. I see nothing in the conf file that would let me change the location of temp files. Thanks.
Is gpg something you created? Is it a shell script?
When you echo ~ in the script, you mean in the gpg script, not your perl script?
When you echo ~ in the script, you mean in the gpg script, not your perl script?
ASKER
no, gpg is the linux command to run gnupg, the encryption program. It came with the CentOS distribution.
/usr/bin/gpg is an executable.
/usr/bin/gpg is an executable.
Is your perl script setuid to make it run as root, or are you actually logging in as root?
ASKER
I am actually logged in as root
Does the perl script change the environment at all before calling system to start gpg?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
system("gpg -r 'username' --batch --encrypt-files 'filename.ext'");