php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58374 Works only in cli-mode
Submitted: 2008-10-11 22:02 UTC Modified: 2021-09-19 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: spam2 at rhsoft dot net Assigned: cmb (profile)
Status: No Feedback Package: gnupg (PECL)
PHP Version: 5.2.5 OS: Fedora 9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: spam2 at rhsoft dot net
New email:
PHP Version: OS:

 

 [2008-10-11 22:02 UTC] spam2 at rhsoft dot net
Description:
------------
I have the same problem as http://pecl.php.net/bugs/bug.php?id=14273 on fedora 8 i386 / fedora 9 x86_64
But on both machines it works in CLI-Scripts

So as workaround i have a job-database and a cronjob running every 5 minutes :-(

I do not understand where is the difference and why this happens - It does also not matter if i use the fedora-packages or rebuilt rpms with "-mtune=native"

Reproduce code:
---------------
private function send_gpg_mail_direct($subject, $mailbody)
  {
   /** Konfiguration einbinden */
   require($this->install_dir . 'mailconfig.inc.php');
   /** Extension initailisieren */
   $gnupg = gnupg_init();
   if(!$gnupg)
   {
    $GLOBALS['cl_api']->log('gnupg_init() failed', 'gpg-mails');
   }
   /** GPG-Key einlesen */
   $keyfile = file_get_contents($mail_gpg_key);
   $key     = gnupg_import($gnupg, $keyfile);
   if(!$key || empty($key['fingerprint']))
   {
    $GLOBALS['cl_api']->log('gnupg_import() failed', 'gpg-mails');
   }
   if(gnupg_addsignkey($gnupg, $key['fingerprint']))
   {
    $signed_body = gnupg_sign($gnupg, $mailbody);
    if(!$signed_body)
    {
     $GLOBALS['cl_api']->log('gnupg_sign() failed', 'gpg-mails');
    }
    $mailer = new phpmailer();
    $mailer->Host               = $mail_host;
    $mailer->Port               = $mail_port;
    $mailer->Helo               = $mail_helo;
    $mailer->SMTPKeepAlive      = 0;
    $mailer->received_from_name = ' (' . @gethostbyaddr($_SERVER['REMOTE_ADDR_TRANSLATED']) . ')';
    $mailer->ErrorsTo           = $mail_errors_to;
    $mailer->SMTPDebug          = true;
    $mailer->From               = $mail_from;
    $mailer->FromName           = $mail_from_name;
    $mailer->Subject            = $subject;
    $mailer->IsHTML(false);
    $mailer->AddAddress($mail_to);
    if(!empty($mail_bcc) && is_array($mail_bcc))
    {
     foreach($mail_bcc as $zsp_cc)
     {
      $mailer->AddBcc($zsp_cc);
     }
    }
    $mailer->IsSMTP();
    $mailer->Body = $signed_body;
    $rw = $mailer->Send();
    $mailer->ClearAllRecipients();
    if($rw)
    {
     $GLOBALS['cl_api']->log('OK: ' . $subject, 'gpg-mails');
     return true;
    }
    else
    {
     $GLOBALS['cl_api']->log('Mail konnte nicht gesendet werden', 'gpg-mails');
     return false;
    }
   }
   else
   {
    $GLOBALS['cl_api']->log('GPG-Key konnte nicht hinzugefuegt werden', 'gpg-mails');
   }
  }

Expected result:
----------------
a signed mail

Actual result:
--------------
[12-Oct-2008 03:43:01] PHP Notice:  Undefined index:  fingerprint in /etc/httpd/conf/panel.thelounge.net/modules/nic.at/library.php on line 260


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-11 23:27 UTC] spam2 at rhsoft dot net
Jesus now it will also not work in cli
Trying rpmbuild says the following
Building some other PECL-Extensions this way on the same machine works :-(

ERROR   0002: file '/usr/lib64/php/modules/gnupg.so' contains an invalid rpath '/usr/include/lib' in [/usr/include/lib]                                                                                                   
Fehler: Fehler-Status beim Beenden von /var/tmp/rpm-tmp.56777 (%install)    

________

[builduser@buildserver:/repo/fc9/x86_64]$ cat /home/builduser/rpmbuild/SPECS/php-pecl-gnupg.spec 
%{!?__pecl:     %{expand: %%global __pecl     %{_bindir}/pecl}}                                  
%{!?php_extdir: %{expand: %%global php_extdir %(php-config --extension-dir)}}                    

%define php_apiver %((echo %{default_apiver}; php -i 2>/dev/null | sed -n 's/^PHP API => //p') | tail -1)
%define pecl_name gnupg                                                                                  

Summary:       wrapper around the gpgme library
Name:          php-pecl-gnupg                  
Version:       1.3.1                           
Release:       3%{?dist}                       
License:       PHP                             
Group:         Development/Languages           
URL:           http://pecl.php.net/package/gnupg
Source:        http://pecl.php.net/get/gnupg-%{version}.tgz
BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: php-devel >= 5.2.0, php-pear,  gpgme-devel >= 1.1.6
Requires(post): %{__pecl}                                         
Requires(postun): %{__pecl}                                       
Provides:      php-pecl(%{pecl_name}) = %{version}                

%if %{?php_zend_api}0
Requires:       php(zend-abi) = %{php_zend_api}
Requires:       php(api) = %{php_core_api}     
%else                                          
Requires:       php-api = %{php_apiver}        
%endif                                         
Requires:       gpgme                          

%description
This extension provides methods to interact with gnupg.
%prep                                                  
%setup -q -c                                           

%build
cd %{pecl_name}-%{version}
%{_bindir}/phpize
%configure
%{__make} %{?_smp_mflags}


%install
pushd %{pecl_name}-%{version}
%{__rm} -rf %{buildroot}
%{__make} install INSTALL_ROOT=%{buildroot}

popd

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%{php_extdir}/gnupg.so

%changelog
* Sun Oct 12 2008 Reindl Harald <h.reindl@thelounge.net>
 [2008-11-02 03:38 UTC] Fedora at famillecollet dot com
I think, config.m4 need to be fixed

If it found gpgme.h in /usr/include, it will add /usr/include/lib in the rpath rather than /usr/lib

See this patch proposal
http://rpms.famillecollet.com/files/php-pecl-gnupg-config.patch

Regards
 [2008-12-30 00:15 UTC] mick at jmmmj dot net
I just compiled:

gnupg-1.3.1     
gnupg-1.4.9     
gpgme-1.1.4     
libgpg-error-1.6 

all compiled and installed perfectly on rhel3 centos.
a subsequent call to class_exists("gnupg") in a php file confirms the extention module has loaded and is in place and phpinfo also confirms:
GPGme Version 1.1.4
Extension Version 1.3.1 
<?php
 ini_set('display_errors',1);
 putenv("GNUPGHOME=/gpg/.gnupg");
 $gpg = new gnupg();
 $gpg->seterrormode(gnupg::ERROR_WARNING); 
 $gpg->addencryptkey("snip key");
 $enc = $gpg->encrypt("just a test");
 echo $enc;
 echo $gpg->geterror();
?>

/gpg/.gnupg and all files under have apache write perms.
This code works perfectly calling the php file on the cli like php -f test.php

... when calling from the webserver, no output occurs and i get 

Warning: gnupg::addencryptkey(): get_key failed
gnupg::encrypt(): no key for encryption set in ...

Any ideas here?
 [2015-01-12 10:32 UTC] anonym at anonym dot com
I had the same problem and it was because this path didnt exist for me:

 putenv("GNUPGHOME=/gpg/.gnupg");


I changed it to

 putenv("GNUPGHOME=/tmp");

and now I dont get the fingerprint error any more and gnupg works fine
 [2021-09-10 12:24 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-09-10 12:24 UTC] cmb@php.net
Is this still an issue with the latest gnupg (1.5.0)?
 [2021-09-19 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC