<div class="gmail_quote">On Mon, Aug 2, 2010 at 11:37 AM, Matthew Nuzum <span dir="ltr"><<a href="mailto:newz@bearfruit.org">newz@bearfruit.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><div class="gmail_quote">On Mon, Aug 2, 2010 at 10:38 AM, Daniel A. Ramaley <span dir="ltr"><<a href="mailto:daniel.ramaley@drake.edu" target="_blank">daniel.ramaley@drake.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cool idea. Thanks for offering this service to the community.<br>
<br>
Could you provide ssh access but with a restricted and/or chrooted<br>
shell? From the documentation, rssh seems particularly suited to this,<br>
though i've not used it myself.<br>
<div><div></div><div><br></div></div></blockquote></div><div><br></div></div>I don't think it will solve the problems at hand. What is needed is the able to run the command rake db:migrate or chmod +x cgi-bin/formmail.cgi ;-)<div>
<br></div></blockquote></div><br clear="all">I still need to look into rssh, but here is something I experimented with last night. I'd imagine daemonizing it and run as a user that can chmod files owned by Apache's user.<div>
<br></div><div>Basically, it uses inotify to detect when a cgi script is uploaded and sets the correct permissions. I'd think it could be expanded to run a pre-set number of commands on upload. For example, mod_passenger looks at the timestamp of a specific file and when it changes it reloads itself. I could do the same thing but run rake isntead.</div>
<div><br></div><div>I'd really like some extra eyes, can you look it over and tell me what concerns you'd have?</div><div><br></div><div><br></div><div><div>import os, stat</div><div>from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent</div>
<div><br></div><div>wm = WatchManager()</div><div>mask = EventsCodes.IN_DELETE | EventsCodes.IN_CREATE # watched events</div><div><br></div><div>perm = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH</div><div><br></div><div>
class PTmp(ProcessEvent):</div><div> def process_IN_CREATE(self, event):</div><div> print "Create: %s" % os.path.join(event.path, <a href="http://event.name">event.name</a>)</div><div> os.chmod( os.path.join(event.path, <a href="http://event.name">event.name</a>), perm )</div>
<div><br></div><div>notifier = Notifier(wm, PTmp())</div><div>wdd = wm.add_watch('/srv/railstest/cgi-bin', mask, rec=True)</div><div><br></div><div>while True: # loop forever</div><div> try:</div><div> # process the queue of events as explained above</div>
<div> notifier.process_events()</div><div> if notifier.check_events():</div><div> # read notified events and enqeue them</div><div> notifier.read_events()</div><div> # you can do some tasks here...</div>
<div> except KeyboardInterrupt:</div><div> # destroy the inotify's instance on this interrupt (stop monitoring)</div><div> notifier.stop()</div><div> break</div><div><br>-- <br>Matthew Nuzum<br>
newz2000 on freenode, skype, linkedin, <a href="http://identi.ca">identi.ca</a> and twitter<br><br>"Never stop learning" –Robert Nuzum (My dad)<br>
</div></div>