php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9665 .netrc sought only in /root
Submitted: 2001-03-09 19:12 UTC Modified: 2001-03-24 19:26 UTC
From: torben@php.net Assigned:
Status: Not a bug Package: cURL related
PHP Version: 4.0.4pl1 OS: Mandrake 7.0
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: torben@php.net
New email:
PHP Version: OS:

 

 [2001-03-09 19:12 UTC] torben@php.net
cURL works fine in general, but when told to search for a .netrc file, searches
only in /root and not in the httpd user's actual home directory (/home/www).

i.e., the following only works if .netrc is in /root:

<?php
error_reporting(E_ALL);

echo `id`;

$url = 'ftp://www.work.loc';

if (!$curld = curl_init()) {
    echo "Could not initialize cURL session.\n";
    exit;
}

curl_setopt($curld, CURLOPT_NETRC, true);
curl_setopt($curld, CURLOPT_URL, $url);
curl_exec($curld);
echo curl_errno($curld);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-24 19:26 UTC] torben@php.net
(Thanks to Daniel Stenberg for pointing this out.)

This occurs because curl is using the $HOME envvar to locate
the .netrc file, so a putenv() before the call enables you to
set the directory in which to search:

<?php
error_reporting(E_ALL);

putenv('HOME=/path/to/desired/home/dir');
$url = 'ftp://www.work.loc';

 if (!$curld = curl_init()) {
       echo "Could not initialize cURL session.\n";
       exit;
}

curl_setopt($curld, CURLOPT_NETRC, true);
curl_setopt($curld, CURLOPT_URL, $url);
curl_exec($curld);
echo curl_errno($curld);
?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC