Re: [Web-ftp] problems starting 2.2.1 in OpenBSD 3.9
Status: Beta
Brought to you by:
aball
From: Anthony R. J. B. <an...@su...> - 2006-07-12 19:57:45
|
It probably compiled ok before, those were just warnings. Glad it works now, though. On Wed, Jul 12, 2006 at 08:51:09PM +0200, FTP wrote: > I did some minor 'corrections' (strlcpy and strlcat) and it did compile. Now works fine. Please find it attached. > > Do you think that you could add this version in your distribution? This applies to OpenBSD 3.9 > > Thanks > > George > > On Wed, Jul 12, 2006 at 08:31:41PM +0200, FTP wrote: > > didn't compile. Here are the results: > > > > -------------- > > cc web-ftpc.c -o web-ftpc.cgi > > > > /tmp//ccB26931.o(.text+0xde): In function `main': > > : warning: strcpy() is almost always misused, please use strlcpy() > > /tmp//ccB26931.o(.text+0x423): In function `main': > > : warning: strcat() is almost always misused, please use strlcat() > > > > # gcc web-ftpc.c -o web-ftpc.cgi > > > > /tmp//ccf14518.o(.text+0xde): In function `main': > > : warning: strcpy() is almost always misused, please use strlcpy() > > /tmp//ccf14518.o(.text+0x423): In function `main': > > : warning: strcat() is almost always misused, please use strlcat() > > -------------- > > > > Thanks > > > > George > > > > On Wed, Jul 12, 2006 at 11:35:21AM -0400, Anthony R. J. Ball wrote: > > > > > > Try this one? > > > > > > On Tue, Jul 11, 2006 at 08:31:43PM +0200, FTP wrote: > > > > also gcc gives the following: > > > > > > > > # gcc web-ftpc.c -o web-ftpc.cgi > > > > web-ftpc.c:111:12: missing terminating " character > > > > web-ftpc.c: In function `main': > > > > web-ftpc.c:113: error: `HTML' undeclared (first use in this function) > > > > web-ftpc.c:113: error: (Each undeclared identifier is reported only once > > > > web-ftpc.c:113: error: for each function it appears in.) > > > > web-ftpc.c:113: error: syntax error before '<' token > > > > web-ftpc.c:116: error: stray '\' in program > > > > web-ftpc.c:116:15: missing terminating " character > > > > web-ftpc.c:120: error: stray '\' in program > > > > web-ftpc.c:120:15: missing terminating " character > > > > web-ftpc.c:122: error: stray '\' in program > > > > web-ftpc.c:122:108: missing terminating " character > > > > web-ftpc.c:123:15: missing terminating " character > > > > > > > > The "gcc" I'm using is: > > > > > > > > # which gcc > > > > /usr/bin/gcc > > > > # gcc -v > > > > Reading specs from /usr/lib/gcc-lib/i386-unknown-openbsd3.9/3.3.5/specs > > > > Configured with: > > > > Thread model: single > > > > gcc version 3.3.5 (propolice) > > > > > > > > > > > > Thanks > > > > > > > > George > > > > > > > > On Tue, Jul 11, 2006 at 02:24:01PM -0400, Anthony R. J. Ball wrote: > > > > > > > > > > Do you have gcc? If that doesn't work I think I know what to do. > > > > > > > > > > On Tue, Jul 11, 2006 at 08:21:28PM +0200, FTP wrote: > > > > > > indeed you are right. In the INSTALL doc you refer to the "web-ftp.c" but I think that its the "web-ftpc.c" instead - correct? > > > > > > Now I tried to compile it by running: > > > > > > > > > > > > cc web-ftpc.c -o web-ftpc.cgi > > > > > > > > > > > > and get the following: > > > > > > > > > > > > ------------ > > > > > > web-ftpc.c:111:12: missing terminating " character > > > > > > web-ftpc.c: In function `main': > > > > > > web-ftpc.c:113: error: `HTML' undeclared (first use in this function) > > > > > > web-ftpc.c:113: error: (Each undeclared identifier is reported only once > > > > > > web-ftpc.c:113: error: for each function it appears in.) > > > > > > web-ftpc.c:113: error: syntax error before '<' token > > > > > > web-ftpc.c:116: error: stray '\' in program > > > > > > web-ftpc.c:116:15: missing terminating " character > > > > > > web-ftpc.c:120: error: stray '\' in program > > > > > > web-ftpc.c:120:15: missing terminating " character > > > > > > web-ftpc.c:122: error: stray '\' in program > > > > > > web-ftpc.c:122:108: missing terminating " character > > > > > > web-ftpc.c:123:15: missing terminating " character > > > > > > ------------ > > > > > > > > > > > > Thanks > > > > > > > > > > > > George > > > > > > > > > > > > On Tue, Jul 11, 2006 at 01:52:07PM -0400, Anthony R. J. Ball wrote: > > > > > > > > > > > > > > Hehe.. THAT one is covered in the docs. The web-ftpc.cgi is a > > > > > > > compiled C program, compiled under Linux, you are using BSD you said... > > > > > > > > > > > > > > INSTALL should help... > > > > > > > > > > > > > > Or just change to > > > > > > > MainCGI=web-ftp.cgi > > > > > > > > > > > > > > That just uses pure Perl, no C. slower and more processor intensive, > > > > > > > but should work. > > > > > > > > > > > > > > On Tue, Jul 11, 2006 at 07:06:19PM +0200, FTP wrote: > > > > > > > > ops! Sorry. You were right :-( I forgot to start the FTP server :-( > > > > > > > > > > > > > > > > But now I get another error message. When the user credentials are correct, the browser displays the following: > > > > > > > > > > > > > > > > ------------------ > > > > > > > > Internal Server Error > > > > > > > > The server encountered an internal error or misconfiguration and was unable to complete your request. > > > > > > > > > > > > > > > > Please contact the server administrator, yo...@yo...dress and inform them of the time the error occurred, and anything you might have done that may have caused the error. > > > > > > > > > > > > > > > > More information about this error may be available in the server error log. > > > > > > > > ------------------- > > > > > > > > > > > > > > > > and the error_log: > > > > > > > > > > > > > > > > Premature end of script headers: /var/www/cgi-bin/web-ftpc.cgi > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > George > > > > > > > > > > > > > > > > On Tue, Jul 11, 2006 at 11:52:44AM -0400, Anthony R. J. Ball wrote: > > > > > > > > > > > > > > > > > > So there is definately an FTP server running on the default port of > > > > > > > > > the host you specified? > > > > > > > > > > > > > > > > > > On Tue, Jul 11, 2006 at 05:12:14PM +0200, FTP wrote: > > > > > > > > > > Hi there, > > > > > > > > > > > > > > > > > > > > I did follow the installation procedure as described in 2.2.1 and actually placed all the files in the apache cgi-bin directory. > > > > > > > > > > > > > > > > > > > > Now, when I run: > > > > > > > > > > > > > > > > > > > > https://<my server>/cgi-bin/web-ftp.cgi > > > > > > > > > > > > > > > > > > > > and log-in with an existing UNIX user, I get the following in my browser: > > > > > > > > > > > > > > > > > > > > -------------------- > > > > > > > > > > There has been an error > > > > > > > > > > > > > > > > > > > > Server said: Net::FTP: connect: Connection refused > > > > > > > > > > > > > > > > > > > > Click here to go to the log in screen. > > > > > > > > > > -------------------- > > > > > > > > > > > > > > > > > > > > regardless if I type in a correct or a wrong password. The Apache "error_log" file shows the following: > > > > > > > > > > > > > > > > > > > > Server said: at /var/www/cgi-bin/web-ftp.cgi line 140, <STDIN> line 1. > > > > > > > > > > > > > > > > > > > > Any help is more than welcome in order to troubleshoot the above. > > > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > George > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > Web-ftp-general mailing list > > Web...@li... > > https://lists.sourceforge.net/lists/listinfo/web-ftp-general > /* Copyright 2002 by Anthony Ball an...@we... > * May be used and redistiributed under the > * terms and agreements of the Gnu Public License > * This software comes with absolutely no warranty > */ > #include <sys/types.h> > #include <sys/socket.h> > #include <sys/un.h> > #include <unistd.h> > #include <stdio.h> > #include <stdlib.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <fcntl.h> > /*#include <sys/timeb.h>*/ > > void err(const char *msg) { > perror(msg); > printf("Content-Type: text/html\n\n<HTML><HEAD><TITLE><A HREF=\"http://www.web-ftp.org\">Web-FTP</A> Error</TITLE></HEAD><BODY><H3>Web-FTP: There has been an error:<P><BLOCKQUOTE>%s</BLOCKQUOTE></BODY></HTML>",msg); > } > > int main(int argc, char **argv, char **env) { > int sockfd; > int len; > struct sockaddr_un address; > int result; > int i = 0; > FILE * conf; > int bytes; > char buf[10240]; > char sock[1024]; > char basecgi[1024]; > /* > struct timeb t; > struct timeb t2; > */ > int a,b; > > /*ftime(&t);*/ > sockfd = socket(AF_UNIX, SOCK_STREAM, 0); > /* printf("Content-Type: text/plain\n\n");*/ > address.sun_family = AF_UNIX; > if(!(conf = fopen("webftp/web-ftp.conf","r"))) { > if(!(conf = fopen("web-ftp.conf","r"))) { > err("Cound not find web-ftp.conf"); > exit(1); > } > } > strlcpy(basecgi,"web-ftp.cgi"); > sock[0] = '\0'; > while(fgets(buf,1024,conf)) { > int i = 9; > int j,k; > if(!strncasecmp(buf,"SocketDir",9)) { > i=9; > while(++i < 1023 && (buf[i] == ' ' || buf[i] == '=') > && buf[i] != '\n' && buf[i] != '\r' && buf[i] != '\0'){} > k = j = i; > while(buf[k] != '\n' && ++k < 1023 && buf[k] != '\n') { > if(buf[k] != ' ') > j = k+1; > } > if(j > i) { > strncpy(sock,buf+i,j-i); > sock[j-i] = '\0'; > } > } > if(!strncasecmp(buf,"BaseCGI",7)) { > i=6; > while(++i < 1023 && (buf[i] == ' ' || buf[i] == '=') > && buf[i] != '\n' && buf[i] != '\r' && buf[i] != '\0'){} > k = j = i; > while(buf[k] != '\n' && ++k < 1023 && buf[k] != '\n') { > if(buf[k] != ' ') > j = k+1; > } > if(j > i) { > strncpy(basecgi,buf+i,j-i); > basecgi[j-i] = '\0'; > } > } > } > fclose(conf); > > if(sock[0] == '\0') > strncpy(sock,"/tmp/WebFTP",1000); > strlcat(sock,"/"); > if(!getenv("PATH_INFO")) { > fprintf(stderr, "PATH_INFO not found in environment. May not be running as a cgi\n"); > exit(1); > } > strncat(sock,(char *)getenv("PATH_INFO"),6); > > strncpy(address.sun_path, sock, sizeof(address.sun_path)); > len = sizeof(address); > > result = connect(sockfd, (struct sockaddr *)&address, len); > > if(result == -1) { > char *i; > if(getenv("SCRIPT_NAME")) { > strncpy(buf,(char *)getenv("SCRIPT_NAME"),1000); > } else { > fprintf(stderr, "SCRIPT_NAME not found in environment... may not be running as a cgi"); > exit(1); > } > if((i = rindex(buf,'/')) > 0) > i[1] = '\0'; > strncat(buf,basecgi,1024-strlen(buf)); > perror("Could not connect to socket"); > printf("Content-type: text/html\n\n<HTML><HEAD>\n<SCRIPT LANGUAGE=JAVASCRIPT>\nfunction goToLogin() {\n setTimeout(\"open('%s','_top')\",5000);\n}\n</SCRIPT>\n</HEAD>\n<BODY ONLOAD=\"goToLogin()\">\n<H2>%s</H2>\nSorry, but your session has either timed out, or has aborted due to error, returning you to the <A TARGET=\"_top\" HREF=\"%s\">Login page</A>\n</BODY></HTML>",buf,buf,buf); > exit(1); > } > > while(env[i]) { > write(sockfd,env[i],strlen(env[i])); > write(sockfd,"\n",1); > i++; > } > write(sockfd,"__END_ENV__\n",12); > while(bytes = read(fileno(stdin),buf,1024)) { > write(sockfd,buf,bytes); > } > > write(sockfd,"\n\n",2); > > while((bytes = read(sockfd, &buf, 1024)) > 0) { > buf[bytes] = '\0'; > fwrite(buf,1,bytes,stdout); /* printf was just plain stupid: \0s */ > /* printf("%s", buf);*/ > } > close(sockfd); > /* > ftime(&t2); > a = t2.time - t.time; > b = t2.millitm - t.millitm ; > if(b < 0) { > a--; > b+=999; > } > fprintf(stderr,"C prog took: %d.%03d\n",a,b); > */ > } > > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Web-ftp-general mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/web-ftp-general -- www.suave.net - Anthony Ball - an...@su... OSB - http://rivendell.suave.net/Beer -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= You can't be a figment of my imagination--I'd have done a better job! |