D
D
DenPolosin2016-09-28 10:24:25
linux
DenPolosin, 2016-09-28 10:24:25

(*.sh;*.php) How to make the script itself request administrator rights?

I want to make a script that will add information to files that only the administrator is allowed to write to. So I want to know what command is there through sh or through php in order to automatically receive administrator rights, or at least so that the script itself asks for the administrator password and does not have to run it on behalf of the administrator. (OS: Debian 8)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Smithson, 2016-09-28
@DenPolosin

the sudo command will save you.

N
Nikolai Romanovich, 2016-09-28
@MikalaiR

if [ $EUID != 0 ]; then
  exec sudo $0 "[email protected]"
  exit 0
fi

R
romy4, 2016-09-28
@romy4

sudo+expect. but not secure, as well as disabling the administrator password.

V
Victor Taran, 2016-09-28
@shambler81

Your site does not have the right to manage the root in any way, it is strictly prohibited.
If you still want to manage it, raise the daemon on the port and knock on it using php.
And the demon, in turn, will control. BUT in no case should Apache be able to log in as root.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question