[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I want to execute .sh script with root permissions from web.

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 3

File: tp600x-tux.jpg (12KB, 277x275px) Image search: [Google]
tp600x-tux.jpg
12KB, 277x275px
I want to execute .sh script with root permissions from web. I've added this to /etc/sudoers

www-data ALL=NOPASSWD: /usr/share/nginx/html/adduzer.sh
apache ALL=NOPASSWD: /usr/share/nginx/html/adduzer.sh
nginx ALL=NOPASSWD: /usr/share/nginx/html/adduzer.sh

But this constructions don't work anyway for root permissions. Why? Where is the problem?

Also, in php exec('whoami') gives 'apache' user as a result. But I have construction for it.

May be SElinux blocks it? How I can check\disable it?
>>
>>57168169
Gentoo doesn't have this problem.
>>
I have one simple sh script, which adds line to the file. If I execute it from terminal with sudo /usr/share/nginx/html/adduzer.sh I see results in /work/test.txt, but if I execute the same command from php file with shell_exec('sudo /usr/share/nginx/html/adduzer.sh'); or exec('sudo /usr/share/nginx/html/adduzer.sh'); - I have not got new line in the file.

Nginx logs are empty. How I can execute the sh script with root rights for string add?

I've also written not root user to /etc/sudoers construction, like in first message, and I've executed it succesfully like a root. So constructions should to work, but it don't for php...
What I can do here?
>>
File: 1382330525_kava-61027129.jpg (78KB, 900x805px) Image search: [Google]
1382330525_kava-61027129.jpg
78KB, 900x805px
>>57168204
I like gentoo, but have got centos vps, which works little weird, from my point of view. I think, there some SElinux... How I can block selinux or give access to this operations? Any advices?
>>
>>57168224
Are you running apache or nginx?
>>
>>57168252
nginx, but php gives 'apache' as result from echo exec('woami').
Anyway I have constructions for apache, nginx and www-data users in /etc/sudoers

I've add user without root privilegies and add for him one more construction to /etc/sudoers - and it works well from terminal. So something blocks nginx\php for the same operation?
>>
http://stackoverflow.com/questions/24149071/php-shell-exec-and-sudo-commands-for-selinux-administration
>>
File: y_87cbd0fa.jpg (165KB, 538x807px) Image search: [Google]
y_87cbd0fa.jpg
165KB, 538x807px
>>57168447
This awesome url, thank you so much!
I've solved this problem.
you are the best!

Just for note - 4chan helped with this, but a lot of another websites - didn't!
Thread posts: 8
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.