ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am attempting to make bash scripts that are independent from the user who uses them. In order to do this I need to use the $HOME variables in my scripts. I want the scripts to be owned by the root user so that those running them can run them but not view the code itself.
The scripts would be run from the custom commands module in usermin and the $HOME variable should recognize that the usermin user is the one using the script, thereby making the $HOME varibale = /home/username. However this is not the case. It seems to think that the home directory for the webmin user is always /root, which it is not.
This might be due to the fact that the scripts are owned by Root but I have given read write and execute permissions to everyone, (chmod 777) and the scripts are placed in the /bin directory so that they can be run from anywhere. Is there anyway I can make it so that the scirpts cannot be viewed by the users, but can be run by them and have the $HOME variable be successfully recognized as the correct home directory path? ANY help appreciated.
**FYI: I have also tried using the ~/ instead of $HOME but to no effect.
> In order to do this I need to use the $HOME variables in my scripts.
Yup. That's normal.
> I want the scripts to be owned by the root user so that those running
> them can run them but not view the code itself.
You don't want the users to be able to *view* the code? To run
a script, the user has to be able to "read" the code (that is,
the Python/Perl/Bash interpreter has to read the file).
BTW, what's the output of `ls -l your_script`? That might help.
Sorry, what I mean was that I do not want to allow the person access to the code of the script, but since they are using usermin this isn't a problem, sorry you can ignore that part.
As for the ls -l it is as follows:
Code:
-rwxrwxrwx 1 root root 34 Feb 25 18:59 pgw
I think the problem is not within the script itself but somewhere between usermin telling the script what user is running it and that the script is owned by root thereby usermin thinks that $HOME = /root
Don't feel dumb. What you were missing was not some fundamental GNU/Linux feature that everyone needs to know, but an arbitrary feature of some program called "usermin". Personally, I've never heard of this "usermin". I think webmin is a web-based admin tool, but I've never used it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.