Solved

gpg - failed to create temporary file

Posted on 2008-10-21
8
1,246 Views
Last Modified: 2012-08-13
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.xxxxxxxxx.31811': 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.
0
Comment
Question by:asrobins
  • 4
  • 4
8 Comments
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
So your perl script does:
    system("gpg -r 'username' --batch --encrypt-files 'filename.ext'");

0
 
LVL 1

Author Comment

by:asrobins
Comment Utility
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.
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
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?
0
 
LVL 1

Author Comment

by:asrobins
Comment Utility
no, gpg is the linux command to run gnupg, the encryption program.  It came with the CentOS distribution.
/usr/bin/gpg is an executable.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 39

Expert Comment

by:Adam314
Comment Utility
Is your perl script setuid to make it run as root, or are you actually logging in as root?
0
 
LVL 1

Author Comment

by:asrobins
Comment Utility
I am actually logged in as root
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
Does the perl script change the environment at all before calling system to start gpg?
0
 
LVL 1

Accepted Solution

by:
asrobins earned 0 total points
Comment Utility
Problem has been independently resolved.

Solution was to add parameter:  --homedir '/root/.gnupg' to the gpg command line.

Thanks for trying.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

#SSL #TLS #Citrix #HTTPS #PKI #Compliance #Certificate #Encryption #StoreFront #Web Interface #Citrix XenApp
Healthcare providers, insurance companies and other covered entities trust eFax Corporate to transmit their most sensitive documents. eFax Corporate can help your organization implement a HIPAA compliant cloud faxing solution.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now