php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61378 php -H doesn't work
Submitted: 2012-03-13 19:44 UTC Modified: 2012-03-14 17:02 UTC
From: vrana@php.net Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.4.0 OS: Irrelevant
Private report: No CVE-ID: None
 [2012-03-13 19:44 UTC] vrana@php.net
Description:
------------
`php -H` or `php --hide-args` should hide passed arguments from the running script but it does nothing. I've tried it on Windows and Linux.

I think that this feature can be safely removed because it doesn't work for ages (at least since PHP 5.2.10 but probably longer) and I see only a little value in it. It is also the only undocumented option at http://php.net/features.commandline.options


Test script:
---------------
php -H argv.php a b

argv.php:
<?php
print_r($argv);
?>


Expected result:
----------------
Array
(
)


Actual result:
--------------
Array
(
    [0] => argv.php
    [1] => a
    [2] => b
)


Patches

hide-args.patch (last revision 2012-03-13 19:45 UTC by vrana@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-13 19:45 UTC] vrana@php.net
The following patch has been added/updated:

Patch Name: hide-args.patch
Revision:   1331667921
URL:        https://bugs.php.net/patch-display.php?bug=61378&patch=hide-args.patch&revision=1331667921
 [2012-03-13 20:12 UTC] rk at srsbiz dot pl
This switch works, but does not hide arguments from running script (that would be rather pointless to pass arguments and switch to make them inaccessible) but from other users using same server (using 'ps aux' for example).  

Try for yourself:

test.php:
<?php
var_dump($argv);
sleep(120);
?>

php test.php --mypass=adminadmin

on second terminal:

ps aux | grep adminadmin

expected output: 

root      9627  0.0  0.0   3256   740 pts/2    S+   21:09   0:00  php test.php --mypass=adminadmin

now try running with -H:

php -H test.php --mypass=adminadmin

and on second trerminal you should have no match, while greping only for php, you may find it, without any arguments:

ps aux | grep php

root     10012  0.8  0.8  44524  9156 pts/1    S+   21:10   0:00 php
 [2012-03-14 17:02 UTC] iliaa@php.net
-Status: Open +Status: Not a bug
 [2012-03-14 17:02 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC