Answer the question
In order to leave comments, you need to log in
How to elevate privileges on a system without sudoers?
There is a machine on FreeBSD and there is no way to install the sudo package and, accordingly, get the sudoers file (well, no way).
Is there any way, using the chmod and chown commands, or something else to get the script to be executed as root by a normal user bypassing authorization?
Specifically, it is required to reboot apache2 from a normal user, such as
service apache2 restart
I tried to add this user to the apache group, it crashes when the http 80 socket is raised (<1024 require authorization and rutization)
Answer the question
In order to leave comments, you need to log in
Try the setuid bit chmod u+s <filename>
An executable with the setuid bit set is run as owner, if it is root then as root.
But that's a security hole...
There's also setgid chmod g+s <filename>
to run as a group, which might be a better fit. Or not...
If it doesn't work, then you can remove the bits by replacing "+" with "-":
chmod u-s <filename>
chmod g-s <filename>
PS
Actually, sudo allows you to elevate privileges due to the setuid bit:
~$ which sudo
/usr/bin/sudo
~$ ls -alah /usr/bin/sudo
-rwsr-xr-x 1 root root 163K янв 19 2021 /usr/bin/sudo
~$
Not having root rights - no way.
For a script - no way at all, even with rights, even without them
For a program with rights - through setuid
You can set up a login as root through an ssh key or even a password. For security, disable login as root remotely, only local authorization when you have already logged into the server under your user.
You can fix pam.d to allow su to root without a password
You can do suid on httpd itself, chown root:root but specify the user's apache in the config - Apache will switch itself
Well, there is another tricky option - to launch Apache on an unprivileged port, such as 8080, and in iptables make a redirect from 80 to 8080. Then Apache can be run freely on behalf of the user, and the site will work on both 80 and 8080.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question