Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start process, hide arguments from ps

I have a Python script that interfaces with an API. The script is started from a PHP page. I wrote both scripts, so I can change the code in either as appropriate.

The Python script needs a username and password to interface with the API. My first inclination is to pass them to Python as CLI arguments:

<?php
exec('python someScript.py AzureDiamond hunter2');
?>

However, anybody can then see the credentials via ps:

$ ps | grep someScript
1000     23295  2.0  0.2 116852  9252 pts/0    S+   15:47   0:00 python someScript.py AzureDiamond hunter2

Alternatives that I am considering are to write the data to a text file or sqlite database, then to delete them. Are there any better ideas? A constraint with the sqlite approach is that this needs to run in a rather portable fashion (phpFox Plugin) and most budget webhosts don't support the sqlite3 module.

like image 509
dotancohen Avatar asked Oct 21 '22 18:10

dotancohen


1 Answers

You could use environment variables which you set in PHP and read in the Python script.

like image 175
Bernhard Avatar answered Oct 27 '22 09:10

Bernhard