Let me ask you a question about suid and shell scripts ~ You can see it.
Source: Internet
Author: User
Let me ask you a question about suid and shell scripts ~ For more information, see Linux general technology-Linux technology and application. For more information, see the following. Recently, I wanted to write a shell script to implement server monitoring. However, if the root permission and apache permission are involved, I decided whether SUID can be used to solve the problem,
The result is a try.
For example, I used the root account to write a script:
Echoname. sh
#! /Bin/bash
Echo $ USER
In this case, run the command as root? Script output root is okay ,? If the permission set by the script is 7755, how can I run it with a normal account nobody? Script output:
Nobody
Why ?? Why is the output not root?
And. If the script is written as follows:
#! /Bin/bash
# Delete a directory that only the administrator can operate on
Rmdir/home/root/test
? The directory configuration permission is 700, and the script configuration permission is 7755. Why do I say that the permission is insufficient when I use the normal user nobody for execution? Isn't it SUID?
I have checked a lot of materials and blogs. one BLOG says that suid cannot be used for shell scripts but binary executable files?
However, several blogs clearly use shell scripts as example programs. However, after I tried it, I couldn't get through ..
Could you tell me this settlement? Why? If it is a shell script, which script can use suid? Can system scripts written in C be used?
Please kindly advise me and thank you.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service