PHP: shell_exec a shell script vs. shell_exec a program on linux (permissions) -
i have shell script, when executed, makes folders , copies files them. have node.js "program", shell script does.
when call shell script using php's shell_exec
, permission error, says shell script not have privileges make folders. did googling , turns out i'd have setup passwordless sudo , knows else trickery fix this.
however, made exact same thing node , when run node "program" calling shell_exec
before , seems node "program" has rights whatever.
what reason behind this? why "programs" have privileges when ran, shell scripts not? legitimate way do, example, file system operations (calling made node.js php)? because annoying fiddle permission if try same operations php.
php run apache or similar , run under user www-data or http or that. node server runs under piwwoli user. piwwoli can create directory under /home/piwwoli, www-data can't.
both programs , shellscripts have privileges when run, question running them.
you can create directory writeable both www-data , piwwoli:
mkdir /path/to/dir chmod o+w,g+w /path/to/dir chown piwwoli.www-data /path/to/dir # maybe you'll need sudo work
Comments
Post a Comment