Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rate Thread Display Modes
Old 06-09-2012, 09:52 AM   #1
tim.vrakas
Prospect
 
Join Date: Jun 2012
Posts: 3
Unhappy Start deamon from web

So, I have this deamon, it works great, catches SIGTERM etc
But sometimes it needs to be reset, and sometimes I'm gone when it needs to be sudo launchctl stoped-started and I cant do it. So I thought I would make a CGI perl script and chmod a+s it. But it dosent work.
(I just realized that the fourm dosent save so I'll have to post again from my computer)
tim.vrakas is offline   Reply With Quote
Old 06-09-2012, 03:33 PM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,940
You can't do it via a web server - or rather you don't want to do it that way since it would entail a huge security hole.

What people usually do is install the watchdog script that will restart the daemon if it detects trouble.

Alternatively, just enable Remote Login and then ssh into the Mac from some remote machine and do what you need to do that way.
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 06-09-2012, 04:43 PM   #3
tim.vrakas
Prospect
 
Join Date: Jun 2012
Posts: 3
@hayne- Yes but if the Perl scripts are only running one command and you .Htaccess the files
then it would be pretty secure. i'm running a gaming server and it wouldn't be a HUGE problem


either way i want to know what i'm doing wrong

start.cgi:

#!/usr/bin/perl
# Set content Type
print "Content-type: text/html\n\n";
print "server stoping\n";
system 'launchctl', 'stop', 'net.minecraft.server';
print "server stoped";


stop.cgi: 
#!/usr/bin/perl
# Set content Type
print "Content-type: text/html\n\n";
print "server starting\n";
system 'launchctl', 'start', 'net.minecraft.server';
print "server started";



and the error log reads:
[Sat Jun 09 16:41:22 2012] [error] [client 127.0.0.1] launch_msg(): Socket is not connected
tim.vrakas is offline   Reply With Quote
Old 06-10-2012, 08:01 AM   #4
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
launchctl usually needs to be called as root, and your script doesn't do that. setuid has been disabled at the OS level for several versions now.

Your choices are:

- set up a watchdog

- learn how to use ssh

- compile something and use that to talk to launchctl. Binary programs will still respond to setuid flags.
(if you really don't care about security, it's possible to compile a one-liner that just calls a specific shell script.)
acme.mail.order is offline   Reply With Quote
Old 06-10-2012, 11:02 AM   #5
tim.vrakas
Prospect
 
Join Date: Jun 2012
Posts: 3
I guess i can just use SSH
Thanks Anyway!!
tim.vrakas is offline   Reply With Quote
Reply

Tags
apache cgi perl launchctl

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 07:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.