CGI works as program, not as FORM ACTION?!?!

CGI works as program, not as FORM ACTION?!?!

Post by Chris » Mon, 12 May 1997 04:00:00



This is a multi-part message in MIME format.

--------------5E7A00402463F03613E08A7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I've got a CGI program I wrote in "C".  It's not very good,
but it works for our purposes.  Anyway, when we run it
as a stand-alone compiled application it runs just fine and
produces the desired results (mail gets transported over to
where it's supposed to go, with the correct info in it).

However, when we slap this program into the Action field of
a webpage (see http://paradigm.uor.edu/socal-raves/crank.html )
and run it that way, no mail ever gets sent, yet the program
runs normally (kicking up the desired response page).

The source code is attached, though I don't know if that's
where the problem is...

If anyone can help, it would be greatly appreciated!

- Chris

--
----------------------------------------------------------------
"Master Linus...  Is the dark side stronger?"
"No!  no... quicker, easier... more seductive."

--------------5E7A00402463F03613E08A7
Content-Type: text/plain; charset=us-ascii; name="mail.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="mail.c"

#include <stdio.h>
#include <string.h>
#include <unistd.h>

void main()
{
        FILE *mailfile;

        char input[800];        // The data input from the form.
        char pid[10], filename[20]="tmpMailCGI.";
        double my_pid;

        gets(input);            // Read from STDIN (the POST method)
        my_pid = getpid();      // find out what process # we are (used later)

        for(int i=0; i<=strlen(input);i++)   // Convert simple forms
        {                                       // into slighntly more
                switch(input[i])                // readable text
                {
                   case '&':  
                        input[i] = '\n';
                        break;
                   case '+':
                        input[i] = ' ';
                        break;
                   default:
                        ;
                }
        }
        sprintf(pid, "%.2f", my_pid); // Convert number (my_pid_ to string    
        strcat(filename, pid);          // And add the PID to the filename
                                        // (assures unique filenames in
                                        // multiuser environment)

        mailfile=fopen(filename, "w");        // Store the input into a file

        fprintf(mailfile, "%s", input);
        fprintf(mailfile, "\n\nBy sending this email message I agree to the following statement:\n\n");
        fprintf(mailfile, "I am not a member of a law enforcement agency, nor am I working with any members of any law enforcment agency. None of the information I obtain at the socal-raves website hosted on paradigm.uor.edu will be passed along to any law enforcement agency.");

        fclose(mailfile);

        strcat(system_call, filename);  // Setup the system call to mail it

        system(system_call);            // Mail the file to the maintainer
        remove(filename);               // delete the file (no longer needed)

        printf("Content-type: text/html\n\n");
        printf("<html>\n<head><title>Thanks!</title></head>\n");
        printf("<body bgcolor=#ffffff text=#000000><b>");
        printf("Thanks!  Your information has been sent to the proper ");
        printf("persons; you should see confirmation in your mailbox in ");
        printf("next day or so...");

        printf("<p><a href=/socal-raves>Return to the Socal Raves page</a>");

Quote:}

--------------5E7A00402463F03613E08A7--
 
 
 

CGI works as program, not as FORM ACTION?!?!

Post by Martin Edlma » Thu, 15 May 1997 04:00:00



> I've got a CGI program I wrote in "C".  It's not very good,
> but it works for our purposes.  Anyway, when we run it
> as a stand-alone compiled application it runs just fine and
> produces the desired results (mail gets transported over to
> where it's supposed to go, with the correct info in it).

The possible problem is that when you run it standalone you run it as
under your userID. As the source code shows, it makes some output to the
file. You have the permission to write to this directory, ok?

Quote:> However, when we slap this program into the Action field of
> a webpage (see http://paradigm.uor.edu/socal-raves/crank.html )
> and run it that way, no mail ever gets sent, yet the program
> runs normally (kicking up the desired response page).

Now when you run it from WEB you run it as user nobody which probably
has not permissions to write to this directory. So no file is generated
and after your source emty mail is generated, is that true?

Quote:> The source code is attached, though I don't know if that's
> where the problem is...

If this is the problem possible solution is to make some directory with
rwx permission for nobody and create files in this directory.
                                                                Edas

--
Martin Edlman, system administrator
Czech On Line a.s., Rybna 14, Burzovni palac, 110 00 Praha 1, Czech Rep.


 
 
 

1. Apache, cgi forms, cgi programs - issues - restart resolves issue??

This is a very strange occurance.

Running Apache 1.3.26 or other versions (tried several)
Sun Ultra 2 w/1536 meg
Solaris 8

Same issue on other machines running similar configs

We are running several web servers on this box.
Maybe about 25 total. We also use a shopping cart program
written in cgi. Our email form scripts are written in cgi.
Ok, here is the weird and strange happenings we are running into.

Error log reports malformed headers when a form is submitted
while this is happening.

Every so often the shopping cart program will not allow
you to "view the next 25 items". Clicking that button just brings them
back to the shopping carts home page.
When this happens with the cgi forms, submitting the form
returns an error as if their is a field missing and there are not any
missing or empty fields.

Now if I "./apachectl restart", both of the above seems to work fine.
Then a couple hours, sometimes a day, sometimes a few days or even a week later
it happens again. We never know unless a client calls about the form
not working.

I'm thinking there may be some sort of process that gets killed.
Any ideas on what that process would be?
Any way to monitor the system to find out what process that would
be or what is happening to it?

I am lost with this issue.
Any help is greatly appreciated.

Thanks

2. Apache responding very slowly to http requests

3. Apache, cgi forms, cgi programs - Issues and problems

4. solaris 10 iso dvd image

5. Apache: FORM ACTION POST fails, GET WORKS...Why?

6. LSI U320 HBA, Linux 2.4: how to set TCQ depth?

7. passing arguments from cgi forms to shell program

8. SCO compatability with Gateway or Micron machines

9. Perl CGI not working although shell script CGI's do

10. Apache 1.3.3 - CGI scripts - form varibles not passed

11. Error handling/ErrorDocument not working with AddType/Action

12. Sub: Why does not the button reset in my form working?

13. /cgi-bin/phf /cgi-bin/test-cgi /cgi-bin/handler