note 68933 added to function.exec

From: Date: Wed, 16 Aug 2006 14:10:37 +0000
Subject: note 68933 added to function.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-115975@lists.php.net to get a copy of this message
Recently I had to do some "root" stuff via PHP - I could do it through cronjob based on the database, but since I was too lazy with doing that, I just wrote a shell script to create all the IMAP stuff, chown properly all the Maildirs and provision the user on the local system. Executing that command as another user from inside of PHP was like this... <code> @exec("echo 'apache' | /usr/bin/sudo -u mail -S /var/www/html/mailset.sh $name"); </code> "Advantage" is that you can run in this way commands as any sudoer on your system which can be fine-tuned and pretty useful. But again - password is echoed in cleartext and option "-S" tells sudo to take password from stdin which he does of course. Major security risk - do it only if you really need to run some commands as different users (nologin users) and if you are really lazy :) Now, my solution is a cronjob which runs every 5 mins and gets datasets from the MySQL table and does the work without exploiting any exec() from within PHP - which is the right way to do it. ---- Server IP: 192.35.244.50 Probable Submitter: 212.17.113.8 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.exec.php Edit -- https://master.php.net/note/edit/68933 Del: integrated -- https://master.php.net/note/delete/68933/integrated Del: useless -- https://master.php.net/note/delete/68933/useless Del: bad code -- https://master.php.net/note/delete/68933/bad+code Del: spam -- https://master.php.net/note/delete/68933/spam Del: non-english -- https://master.php.net/note/delete/68933/non-english Del: in docs -- https://master.php.net/note/delete/68933/in+docs Del: other reasons-- https://master.php.net/note/delete/68933 Reject -- https://master.php.net/note/reject/68933 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115975) next »