How To Execute Shell Scripts As Some User
Nov 18, 2007
I'm trying to write some scripts that automate the installation of a website with a content management system. This includes creating domains, installing databases etc via plesk API.
Now we have it creating the domains and databases via plesk, this is not the issue. It's permission problems issuing commands on the server.
I need to have the script install the cms and this requires writing files to a folder on the server owned by a user which is created with the domain.
e.g.
user creates timsdomain.com with ftp user name tim
Plesk makes directory on webserver called ~/vhosts/timsdomain.com/
inside this directory is a folder called httpdocs.
All the files within this folder are owned by tim.
Now my script (running as 'apache' in a folder owned by 'admin') needs to write/edit files to this directory as the user tim (or whatever user was created when the domain was set up).
How can I do this from a php script?
My idea would be to log in as the new user and then start issuing commands but I don't know how to login a user from a script.
I've tried exec, exec_shell etc
trying to log in via script as the new user using sudo/su/suid etc but they all ask for a password (for obvious reasons) but I cannot see a way to send the password to the command with the script. Ssh?
Here's some pseudocode that demonstrates what I'm trying to do, if you can think of a better way I'm all ears.
Code:
//User Fills in CMS/Domain information which becomes Form_Data
//uses plesk to create blank domain, create email addresses and empty database
Make_Domain(Form_Data) {
Plesk = Get_Plesk_Object();
Plesk.Create_Domain();
Plesk.Create_Database();
Build_CMS(Form_Data);
}
//HERE IS WHERE I AM HAVING TROUBLE: I can't figure out how to change the user so I can install files to a
// different directory other than the current user's directory (admin)
Build_CMS(Form_Data) {
change_to_user(Form_Data.ftp_username, FormData.ftp_password);
unpack_CMS_archive_into(user_directory); //eg unpack cms.tar into 'timsdomain.com' (if the above command didn't switch the current directory to users home directory)
//initialises CMS config files and installs CMS data to database
Run_Install_Scripts_On_Server(Form_Data);
//albeit complex, most important part of script
Confirm_Tim_Is_Awesome();
}
Confirm_Tim_Is_Awesome() {
while (getTim().has_moustache()) {
echo "<em>You're still awesome. </em>";
}
View 14 Replies
ADVERTISEMENT
Nov 15, 2007
I'm trying to write some scripts that automate the installation of a website with a content management system. This includes creating domains, installing databases etc via plesk API.
Now we have it creating the domains and databases via plesk, this is not the issue. It's permission problems issuing commands on the server.
I need to have the script install the cms and this requires writing files to a folder on the server owned by a user which is created with the domain.
e.g.
user creates timsdomain.com with ftp user name tim
Plesk makes directory on webserver called ~/vhosts/timsdomain.com/
inside this directory is a folder called httpdocs.
All the files within this folder are owned by tim.
Now my script (running as 'apache' in a folder owned by 'admin') needs to write/edit files to this directory as the user tim (or whatever user was created when the domain was set up).
How can I do this from a php script?
My idea would be to log in as the new user and then start issuing commands but I don't know how to login a user from a script.
I've tried exec, exec_shell etc
trying to log in via script as the new user using sudo/su/suid etc but they all ask for a password (for obvious reasons) but I cannot see a way to send the password to the command with the script. Ssh?
I don't know. Help
Here's some pseudocode that demonstrates what I'm trying to do, if you can think of a better way I'm all ears.
Code:
//User Fills in CMS/Domain information which becomes Form_Data
//uses plesk to create blank domain, create email addresses and empty database
Make_Domain(Form_Data) {
Plesk = Get_Plesk_Object();
Plesk.Create_Domain();
Plesk.Create_Database();
Build_CMS(Form_Data);
}
//HERE IS WHERE I AM HAVING TROUBLE: I can't figure out how to change the user so I can install files to a
// different directory other than the current user's directory (admin)
Build_CMS(Form_Data) {
change_to_user(Form_Data.ftp_username, FormData.ftp_password);
unpack_CMS_archive_into(user_directory); //eg unpack cms.tar into 'timsdomain.com' (if the above command didn't switch the current directory to users home directory)
//initialises CMS config files and installs CMS data to database
Run_Install_Scripts_On_Server(Form_Data);
//albeit complex, most important part of script
Confirm_Tim_Is_Awesome();
}
Confirm_Tim_Is_Awesome() {
while (getTim().has_moustache()) {
echo "<em>You're still awesome. </em>";
}
}
View 2 Replies
View Related
Jun 8, 2005
Anyone know the commands to change a MySQL user's password via ssh?
I found stuff for changing the root password, and tried to adapt it for the user, but it didn't work.
View 12 Replies
View Related
Apr 15, 2007
Is there any way to totally block php shell scripts on users accounts, i don't mean like the java shell in cPanel i mean a php shell script like the kind frequently used by hackers...
View 11 Replies
View Related
Jul 1, 2015
Is it possible to set the subscription shell option of an subscription via xml api? I see it is possible via cmd "/usr/local/psa/bin/subscription -u {subscription} -shell /usr/local/psa/bin/chrootsh" But how is it possible via xml api?
View 1 Replies
View Related
Jul 8, 2008
Do any1 know how to change jail shell to normal shell?
View 14 Replies
View Related
Feb 2, 2008
I'm trying to get a Movable Type installation working. Centos under HyperVM and Lxadmin...
Correct Perl version is installed. Cgi script in MT calls correct Perl install.
Perhaps it's an issue that I'm running through Lxadmin?
I run through the install - no problem. But when trying to access my install, I get a 500 error.
I'm not getting anything in the logs. Absolutely nothing on the Six Apart side.
SElinux in not running. I've tried forcing with .htaccess:
<Directory /path-to-movabletype>
Options Indexes ExecCGI
</Directory>
Has anyone been through this... or perhaps just some feedback.
It's a common problem - but the solution isn't typical apparently (for me that is).
[url]
View 1 Replies
View Related
Aug 30, 2013
If any GET request are coming on Apache I want execute my "try.pl". I used "Script" directive for execute script "Script GET /cgi-bin/try.pl ....
View 2 Replies
View Related
May 9, 2013
I am migrating to apache httpd 2.4 on windows xp. The current server currently has exe programs that execute as cgi programs. When I try to use one of these links, apache just servers the programs as files for download. How do I configure my httpd.conf to run these instead of download them?
View 1 Replies
View Related
Feb 19, 2015
My OS is CentOS 5.8.
Plesk is 11.0.9.
Having problems with failed daily domain backups. All databases that have been created by Plesk cannot be backed up, thus backup fails with the following message:
<?xml version="1.0" encoding="UTF-8"?>
<execution-result status="error" log-location="/usr/local/psa/PMM/sessions/2015-02-19-044701.875/migration.result">
[Code]...
View 4 Replies
View Related
Jan 24, 2014
I am 3 days new to figuring out how to get Perl scripts to run on my Windows XP box. I downloaded and installed the Apache installation file "httpd-2.0.65-win32-x86-openssl-0.9.8y.msi" and the "strawberry-perl-5.18.2.1-32bit.msi" from the perl.org site in hopes that I could get a feedback form to work for a web site that I am working on.
Out of the many pages that I have viewed online of how to configure the Apache Server, nothing has given any favorable results with their explanations.
My last attempt was [URL] ..... where I could not get the example to work. I did the changes to the Apache file "Edit the Apache httpd.conf Configuration File" fairly easily but I must be having problems with the test.pl because I can't get it to work.
I used a different version of Perl (Strawbery from perl.org because it installed without giving me an error pop up after installation) and after copy pasting the script, in an attempt to get it working, I ended up changing it in hopes that I could get it working, shown below.
#!/strawberry/bin/perl.exe
print "Content-type: text/html; charset=iso-8859-1
";
print "<phtml>";
print "<body>";
print "Test Page";
print "</body>";
print "</html>";
This is what the site says to create the program with:
#!/perl/bin/perl
print "Content-type: text/html; charset=iso-8859-1
";
print "<phtml>";
print "<body>";
print "Test Page";
print "</body>";
print "</html>";
where I assumed that "#!" meant the "C:" drive and substituted the first "/perl" with the folder the Strawbery Perl had installed itself to and left the second "/perl" in the first line thinking that it was referring to the executable in the "C:strawberryperlbin" folder.
This is the error I get when trying to get the script to run when typing "localhost/test.pl" in the address bar.
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
........"
Know how I can change the title of this post to read "Configuring Apache HTTP Server 2.0 to run Perl in Windows"?
View 1 Replies
View Related
Apr 6, 2015
I'm not been able to start plesk although web and mail services are running.I'm getting the error unable to execute php_handlers_control.I've patched and updated plesk with command line and bootstrap repair and I'm getting this errors:
==> Checking for: mail_responder_restore... fail
/usr/lib64/plesk-9.0/mail_restore: line 820: 17063 Illegal instruction /usr/local/psa//admin/sbin/mailmng-service --restart-service
Errors occured in mail restore procedure
Some utilities have exited with errors:
/usr/lib64/plesk-9.0/mail_auth_dump
/usr/lib64/plesk-9.0/mail_responder_restore
I get Illegal Instruction When I run :
# /usr/local/psa/admin/sbin/mailmng-service --restart-service
Illegal instruction
Also I switched from postfix to qmail and back using the command line with no luck.
/usr/local/psa/admin/bin/mailmng --features
runs without problems.....
/usr/local/psa/admin/logs/panel.log:
[06-Apr-2015 12:47:25 America/New_York] PleskUtilException: '/usr/local/psa/admin/bin/php_handlers_control' '--list-json' failed with code 4.
[code]....
View 8 Replies
View Related
May 7, 2007
I thought I knew enough about my .htaccess stuff to do this, but I can't seem to work it out. What I want to do is if a user visits domain.com/folder, we check to see if the folder exists. If so, show as normal (IE domain.com/support)
If a user visits domain.com/dynamicusername (dynamicusername is not a physical folder), redirect to dynamicusername.domain.com
View 3 Replies
View Related
Jan 3, 2014
when I find the subscription from the admin side of PPA, if I select "Login as user" I've noticed that it is different from actually logging in as the user - for example - "add domain alias" is missing when I login as a customer - but not as an admin... I need my customers to add their own aliases and manage them - how do I add that feature to the client login side?
View 9 Replies
View Related
Sep 30, 2007
my server in under attack of shell
how can i find shell code in my server? (c99 ...)
is any anti virus or open source tools to find it
how can i disable shell function?
View 4 Replies
View Related
May 10, 2007
I have spare dedicated machine.
I want to allow user to run few processes on machine (debian etch).
I configurated limits at /etc/security/limits.conf for group "shell".
When I attached user to group shell, limits work well, but he still can look
everywhere on system. (he can do cat /home/somefile.txt, even owned by root).
Is there any method, software to limit user to acces only their home directories?
View 2 Replies
View Related
Jun 7, 2009
For security reason I have these php functiosn disabled:
show_source, system, shell_exec, exec, popen, proc_open, procopen, passthru
Can anyone please tell me whether if it will prevent shell scripts from working?
They can still upload the shells but cant read/write/execute commands in 777 directories?
View 6 Replies
View Related
Apr 16, 2005
I'm having a problem connecting to SSH/Shell on my server. I get the Login Prompt, but when i enter the User/Pass i just get "SSH-2.0-OpenSSH_3.6.1p2", everything under that is blank.
I've restarted the SSH Server and made sure the account i was using was set to use Normal Shell (not jailed). What could be the problem?
View 3 Replies
View Related
Oct 8, 2006
I was wondering if it were possible to chmod a directory that is set to a low number to 777 using a shell or command and if so can anyone point me in the right direction as to how to go about doing so ??? I am trying to learn a little and i pefer using my browser to edit files rather then a ftp client.
View 9 Replies
View Related
Jun 9, 2007
I was just wondering if anyone is aware of Linux VPS or shell account providers with servers that are physically located in Pennsylvania. The only two I've come across so far are Nocster and VPS Village.
View 2 Replies
View Related
Oct 8, 2009
I keep seeing web hosts where it says that there is/isn't shell access, etc. What's shell access and what do you do with it in/with a web host?
View 14 Replies
View Related
May 27, 2008
Is there a such thing? I use shell mainly for whois info, tracing, telnet for email issues, etc etc. Is there a 'toolkit' for such things?
View 6 Replies
View Related
Nov 6, 2005
I have a script that needs to be run from shell access, but I've never done this before. How do you access a script through shell? Is there software I need to download? Not even sure where to begin.
View 5 Replies
View Related
Dec 16, 2007
One of our customers uploaded C99Shell script on my server, and he can access to another accounts,
I upgraded php to 5 but he can access with this script to another accounts yet, what should I do to disable this script or other one?
View 14 Replies
View Related
Oct 11, 2006
I'm trying to program a very simple shell script that does 2-3 things.
1) checks for the number of a script running say, "ps aux | grep php | wc -l" returns that number.
2) deletes temp files folders "cd /to/that/directory/; rm -fr *&" every 90 seconds IF that number in check #1 is below say 50....
and then have this shell script launched in shell every so often, not sure on the frequency but first is how to program in shell is a TIME DELAY....
View 7 Replies
View Related