Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.6.9

Doc Bug #14645 Document how to specify a homedir (prevent Uncaught Exceptions)
Submitted: 2008-09-13 11:48 UTC
From: ywirasin Assigned: gauthierm
Status: Closed Package: Crypt_GPG (version 0.6.0)
PHP Version: 5.2.5 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2008-09-13 11:48 UTC] ywirasin (Marco Wirasinghe)
Description: ------------ Running a simple test script of Crypt_GPG on Hostgator (which installed it successfully server wide) yields a fatal error. I've tried both the encrypt and getKeys functions and both fail. This isn't a problem with our server, as I simply logged in via SSH, and did echo ''411111111111' | gpg --encrypt --armor --recipient 'support@namechangeexpress.com' and it yielded the encrypted string properly. So, it makes me believe there is something either in the code or configuration that is causing the failure. Can you please help us figure out what is happening? I wish I could provide a debug report, but I don't know how to turn it on appropriately. Please advise. Test script: --------------- <?php require_once 'Crypt/GPG.php'; $card_number = '411111111111'; $gpg = Crypt_GPG::factory(); echo "successful "; $encrypted = $gpg->encrypt('support@namechangeexpress.com',$card_number); echo "successful 2"; echo $card_number; ?> Expected result: ---------------- Should just be successful successful 2 and the card number. ideally, my next step is to echo $encrypted. However, this is all pointless as we're finding it crashes. Actual result: -------------- successful Fatal error: Uncaught <table border="1" cellspacing="0"> <tr><td colspan="3" bgcolor="#ff9999"> <b>Crypt_GPG_Exception</b>: Unknown error encrypting data. in <b>/home/ywirasin/public_html/test.php</b> on line <b>9</b></td></tr> <tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr> <tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td><td align="center" bgcolor="#cccccc"><b>Function</b></td><td align="center" bgcolor="#cccccc"><b>Location</b></td></tr> <tr><td align="center">0</td><td>Crypt_GPG_Driver_Php->encrypt('support@namechan…', '411111111111')</td><td>/home/ywirasin/public_html/test.php:9</td></tr> <tr><td align="center">1</td><td>{main}</td><td> </td></tr> </table> thrown in /usr/local/lib/php/Crypt/GPG/Driver/Php.php on line 890

Comments

 [2008-09-13 17:53 UTC] gauthierm (Michael Gauthier)
Your test script looks like it should run fine. To turn on debug mode, replace $gpg = Crypt_GPG::factory(); with $gpg = Crypt_GPG::factory('php', array('debug' => true)); Please run the test again after than and paste the results here.
 [2008-09-14 00:00 UTC] ywirasin (Marco Wirasinghe)
Thanks for the guidance on the debug flag. Here are the results. Appreciate you folks helping us figure out why this is not working - hostgator (our host) used PEAR to install it onto to the server, and I believe no other additional configurations were made. Looking at results, it seems like there might be some permission isssues for some type of directory. Thoughts or guidance? thanks, -marco successful Crypt_GPG DEBUG: Opening subprocess with the following command: Crypt_GPG DEBUG: /usr/bin/gpg --no-secmem-warning --no-permission-warning --no-tty --trust-model always --status-fd '3' --recipient 'support@namechangeexpress.com' --armor --encrypt Crypt_GPG DEBUG: Subprocess returned an unexpected exit code: 2 Crypt_GPG DEBUG: Error text is: Crypt_GPG DEBUG: gpg: failed to create temporary file `~/.gnupg/.#lk0xb7fe71b0.gator556.hostgator.com.18270': No such file or directory Crypt_GPG DEBUG: gpg: fatal: ~/.gnupg: can't create directory: No such file or directory Crypt_GPG DEBUG: secmem usage: 0/0 bytes in 0/0 blocks of pool 0/32768 Crypt_GPG DEBUG: Crypt_GPG DEBUG: Status text is: Crypt_GPG DEBUG: Fatal error: Uncaught <table border="1" cellspacing="0"> <tr><td colspan="3" bgcolor="#ff9999"> <b>Crypt_GPG_Exception</b>: Unknown error encrypting data. in <b>/home/ywirasin/public_html/test.php</b> on line <b>9</b></td></tr> <tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr> <tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td><td align="center" bgcolor="#cccccc"><b>Function</b></td><td align="center" bgcolor="#cccccc"><b>Location</b></td></tr> <tr><td align="center">0</td><td>Crypt_GPG_Driver_Php->encrypt('support@namechan…', '411111111111')</td><td>/home/ywirasin/public_html/test.php:9</td></tr> <tr><td align="center">1</td><td>{main}</td><td> </td></tr> </table> thrown in /usr/local/lib/php/Crypt/GPG/Driver/Php.php on line 890
 [2008-09-14 02:48 UTC] gauthierm (Michael Gauthier)
Because the gpg subprocess runs as the apache user, keychains set up for other users will not be found by default. You cn instruct Crypt_GPG to use a specific keychain with the 'homedir' option. For example, if the keychain has been set up for the user 'foo' on the server, try: Crypt_GPG::factory('php', array('homedir' => '/home/foo/.gnupg', 'debug' => true)); If the above change (or something similar) works, the 'unknown' error message needs to be made friendlier and I will fix it.
 [2008-09-14 04:33 UTC] ywirasin (Marco Wirasinghe)
Mike, great news! It worked brilliantly! Many thanks for the support. From my googling of the error, it seems many people have similary issues. I'm with you that the error message should be made more descriptive. Additionally, I think it would be very helpful if you could include the test code (with debug) with the debug flag and description in the code to allow people to know what to do with the error. That, or maybe put a little blurb about it on the Crypt documentation on the page. Anyway, just my 2 cents. My sincerest thanks and really appreciate the support!
 [2008-09-18 18:38 UTC] gauthierm (Michael Gauthier)
The first part of this is fixed. A more descriptive error message is used: throw new Crypt_GPG_FileException('The \'homedir\' "' . $this->_homedir . '" does not exist and cannot be ' . 'created. This can happen if \'homedir\' is not ' . 'specified in the Crypt_GPG options, Crypt_GPG is run as ' . 'the web user, and the web user has no home directory.', 0, $this->_homedir); The second part, better hints on how to use debug mode, is still to come.
 [2008-09-18 18:54 UTC] ywirasin (Marco Wirasinghe)
Thanks! Given your write up, could we specify somewhere in the documentation, example, or error message for users an example, such as the one provided by your guys? Specifically, how to use the option to set a homedir. Crypt_GPG::factory('php', array('homedir' => '/home/foo/.gnupg', 'debug' => true)); Just my thoughts as a user. thanks! -m
 [2008-09-18 20:12 UTC] gauthierm (Michael Gauthier)
I'll add that to the end user documentation after the next release.
 [2009-01-16 16:25 UTC] gauthierm (Michael Gauthier)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. A section has been added to the docbook sources describing setting the homedir option. It will appear after the next build of the PEAR manual (currently suspended pending deployment of new build system).