When you try to build a Plesk module you will come across number of doubts in that some of them are
How to Run a Shell Script or Binary as Root in Plesk Module?
How to use plesk wrapper to get root privilege for scripts?
How to use plesk wrapper from sbin?
What to do with “failed to open stream: Permission denied” in plesk module?
Its very difficult to get help on plesk module development. The tutorial provided by Parallels is really insufficient and incomplete. When I was trying to build a plesk module package, I faced many problems and googling never gave any solution too. After doing so much research I was able to develop a plesk module for my Client. I hope this post will be helpful for many who are trying to build plesk module and wanted root privilege to run a script in it.
Following is one of the methods which I used successfully in plesk 10.4. I hope it will work for all plesk versions.
Imagine you want to build a plesk module and that should have functionality to set ownership of configuration file to root:root or any other ownership. Also need to write in to /etc/passwd or any file which can be edited only with root permission. This functionality is not possible with simple php script like chown, or system functions. It is because, plesk modules runs under psaadm user privilege so it can’t change files which is under root privilege. But there is one solution for this which is provided in plesk i.e. plesk module wrappers. This can be used to get root privilege for some scripts. To achieve this, you can follow below procedure or steps.
Imagine you have a shell script [setperm.sh] which is used to set permission for all files related to your module. To execute this script with root privilege use following steps.
1) Place setperm.sh under “/usr/local/psa/admin/sbin” [don’t forget this path is very important]
2) Create a symbolic link in “/usr/local/psa/admin/bin/modules/<ur-module-foldername>”. By executing
“ln -s /usr/local/psa/admin/sbin/wrapper /usr/local/psa/admin/bin/modules/<ur-module-foldername>/ setperm.sh”
3) You are done with wrapper; now you can use this script in any php file inside your module script and it will execute as root.
4) For example you can call this script like this
<?php
system(/usr/local/psa/admin/bin/modules/<ur-module-foldername>/ setperm.sh, $varout);
?>
5) You can create this symbolic link while building RPM itself.
So this is all about plesk wrapper usage to get root privilege for scripts under plesk module.
Unquestionably believe that which you said.
Your favorite justification appeared to be
on the net the simplest thing to be aware of. I say to you, I definitely get annoyed while people consider worries
that they just do not know about. You managed to hit the nail upon the top as well as defined
out the whole thing without having side effect , people can take a
signal. Will probably be back to get more. Thanks
Heya! I realize this is sort of off-topic however I needed to ask.
Does operating a well-established website such as yours require a
large amount of work? I am completely new to blogging but I do
write in my journal every day. I’d like to start a blog so I will be able to share my personal experience and feelings online. Please let me know if you have any kind of suggestions or tips for new aspiring bloggers. Thankyou!
Regards with thiѕ post, I’m a big fan using this site would opt to go on updated.
My spouse and I stumbled over here from a different page and thought I might as well check things out.
I like what I see so i am just following you. Look forward to looking over your web page repeatedly.