cgi question

Sadhunathan Nadesan sadhu at castandcrew.com
Fri Mar 8 21:05:01 EST 2002


| 
| OK, here's a question.  When darwin mc is running, what is it running AS?
| It can write to files with read/write (everyone), but cannot write to files
| with read only (everyone.)  If I knew what it was running AS, I could put
| that into a group and simplify my life.  When I use the shell command
| whoami, it returns "root."   But that's what the shell commands are run as,
| NOT what the metatalk scripts are run as.  I can get around this by using
| shell commands to write files instead of metatalk commands (open file,
| etc.), but the question remains.  Anyone have the answer?  :)
| 
| :)
| Richard MacLemale

What's darwin mc?  Sorry if I missed an earlier thread here, but it
sounds like you mean, what is the user id of the process when an MC
script is executed as a CGI program??  Would this be on a Unix system
I presume?

Darn, I remember running into that too but I forget what I found out,
it was maybe "nobody" or "httpd" or something like that.  And as I
vaguely recall, that was configurable in  Apache maybe?    I might be
totally wrong here.

However, I suspect there is an easy way to answer your own question
(that's what you really wanted to know, right?).  Can you have your mc
cgi script create a new file somewhere that is read,writable by
everyone (like /tmp) and then, just look at the file permissions?

I did that just now and the answer I got I believe would be specific
to the system where I ran it:  I got

4 -rwxrwxrwx    1 wwwrun   nogroup       498 Mar  8 11:10 formdata.mc.txt


Perhaps the tiny script I used to write this file would be of some
help?  Here it is.  (I call it "debug.mt").  You have to drive it with
an html "form" with a post command, such as:

<form methond="POST" action="/cgi-bin/debug.mt">

and it will spit back your form fields plus save the raw data in
a text file for examination.

Cheers,
Sadhu


#!/usr/local/bin/mc

on startup

  read from stdin until empty
  put it into inputdata
  put urlDecode (inputdata)  into formdata
  put inputdata into url "file:/tmp/formdata.mc.txt" 
  split formdata by "&" and "="
  put keys(formdata) into keywords

  put "Content-Type: text/plain" & cr & cr
  put "I am an MT script - hello world"
  repeat for each line this_item in keywords
    put this_item && "=" && formdata[this_item] & cr
  end repeat

end startup




More information about the metacard mailing list