Re: USB install image for OpenBSD 5.5 - TESTING REQUIRED
On 02/28/14 23:51, Chris Cappuccio wrote: Here are some potential USB installer images for OpenBSD/amd64 5.5 http://www.nmedia.net/chris/install55.fs http://www.nmedia.net/chris/miniroot55.fs The install55.fs contains full installation packages. The miniroot55.fs is a ramdisk-kernel only (for network installation or troubleshooting.) It might be obvious, but since it confused me for a bit, I'd like to correct this an say that miniroot55.fs *contains* a ramdisk kernel only. It is still a complete disk image. /Alexander Please test either on as many amd64 machines as you can with any USB flash and any USB-CF adapters that you have. Report failures and success of each image ASAP. Test as many flash types (USB, CF-USB, old USB, new USB...) as you can. SPECIFICALLY, IF you have a boot failure, I need to see the dmesg output (and the fdisk and disklabel output from the machine if possible to boot it another way). Any error messages displayed from the boot blocks or BIOS are also essential.
Simple static testcgi.c
So I wanted to test out nginx and slowcgi. I started everything up and hit up localhost/cgi-bin/test-cgi. Whoops forgot to move /bin/sh into the chroot. Try again, shit forgot to chmod 555 test-cgi. I was complaining on IRC and tbert suggested I write a simple statically linked testcgi.c so people can easily verify cgi is up and working. That is what is attached. It just prints out the environment like test-cgi and printenv but is statically linked and doesn't require anything to be copied into the chroot. Also it's 555 by default so it just works. Is this so bad? The BINDIR is set since I have no idea where in /usr/src this should live or if this is even anything we want in source but here it is for those who don't want to mess around with moving things into the www chroot and just want to verify cgi (slowcgi in my case) is working. Tested with both nginx + slowcgi and httpd. -- James Turner diff -u -p -N Makefile Makefile --- MakefileWed Dec 31 19:00:00 1969 +++ MakefileSat Mar 1 14:06:39 2014 @@ -0,0 +1,7 @@ +PROG= testcgi +SRCS= testcgi.c +LDSTATIC= -static +NOMAN= 1 +BINDIR=/var/www/cgi-bin + +.include bsd.prog.mk diff -u -p -N testcgi.c testcgi.c --- testcgi.c Wed Dec 31 19:00:00 1969 +++ testcgi.c Sat Mar 1 14:15:25 2014 @@ -0,0 +1,42 @@ +/* + * This is free and unencumbered software released into the public domain. + */ + +#include stdio.h +#include stdlib.h + +static char * +cleanenv(char *name) +{ + char *env; + + if ((env = getenv(name)) == NULL) + return ; + + return env; +} + +int +main(void) +{ + printf(Content-type: text/plain\r\n\r\n); + printf(CGI/1.1 test script report:\n\n); + printf(GATEWAY_INTERFACE = %s\n, cleanenv(GATEWAY_INTERFACE)); + printf(SERVER_SOFTWARE = %s\n, cleanenv(SERVER_SOFTWARE)); + printf(SERVER_PROTOCOL = %s\n, cleanenv(SERVER_PROTOCOL)); + printf(SERVER_NAME = %s\n, cleanenv(SERVER_NAME)); + printf(SERVER_ADDR = %s\n, cleanenv(SERVER_ADDR)); + printf(SERVER_PORT = %s\n, cleanenv(SERVER_PORT)); + printf(REQUEST_METHOD = %s\n, cleanenv(REQUEST_METHOD)); + printf(HTTP_ACCEPT = %s\n, cleanenv(HTTP_ACCEPT)); + printf(SCRIPT_NAME = %s\n, cleanenv(SCRIPT_NAME)); + printf(REQUEST_URI = %s\n, cleanenv(REQUEST_URI)); + printf(PATH_INFO = %s\n, cleanenv(PATH_INFO)); + printf(QUERY_STRING = %s\n, cleanenv(QUERY_STRING)); + printf(REMOTE_ADDR = %s\n, cleanenv(REMOTE_ADDR)); + printf(REMOTE_PORT = %s\n, cleanenv(REMOTE_PORT)); + printf(CONTENT_TYPE = %s\n, cleanenv(CONTENT_TYPE)); + printf(CONTENT_LENGTH = %s\n, cleanenv(CONTENT_LENGTH)); + + return (0); +}
Re: Simple static testcgi.c
Simplified. On Sat, Mar 01, 2014 at 02:27:44PM -0500, James Turner wrote: So I wanted to test out nginx and slowcgi. I started everything up and hit up localhost/cgi-bin/test-cgi. Whoops forgot to move /bin/sh into the chroot. Try again, shit forgot to chmod 555 test-cgi. I was complaining on IRC and tbert suggested I write a simple statically linked testcgi.c so people can easily verify cgi is up and working. That is what is attached. It just prints out the environment like test-cgi and printenv but is statically linked and doesn't require anything to be copied into the chroot. Also it's 555 by default so it just works. Is this so bad? The BINDIR is set since I have no idea where in /usr/src this should live or if this is even anything we want in source but here it is for those who don't want to mess around with moving things into the www chroot and just want to verify cgi (slowcgi in my case) is working. Tested with both nginx + slowcgi and httpd. -- James Turner diff -u -p -N Makefile Makefile --- MakefileWed Dec 31 19:00:00 1969 +++ MakefileSat Mar 1 14:06:39 2014 @@ -0,0 +1,7 @@ +PROG= testcgi +SRCS= testcgi.c +LDSTATIC= -static +NOMAN= 1 +BINDIR=/var/www/cgi-bin + +.include bsd.prog.mk diff -u -p -N testcgi.c testcgi.c --- testcgi.c Wed Dec 31 19:00:00 1969 +++ testcgi.c Sat Mar 1 14:41:15 2014 @@ -0,0 +1,43 @@ +/* + * This is free and unencumbered software released into the public domain. + */ + +#include stdio.h +#include stdlib.h + +static void +printenv(char *name) +{ + char *env; + + if ((env = getenv(name)) == NULL) + env = ; + + printf(%s = %s\n, name, env); +} + +int +main(void) +{ + printf(Content-type: text/plain\r\n\r\n); + printf(CGI/1.1 test script report:\n\n); + + printenv(GATEWAY_INTERFACE); + printenv(SERVER_SOFTWARE); + printenv(SERVER_PROTOCOL); + printenv(SERVER_NAME); + printenv(SERVER_ADDR); + printenv(SERVER_PORT); + printenv(REQUEST_METHOD); + printenv(HTTP_ACCEPT); + printenv(SCRIPT_NAME); + printenv(REQUEST_URI); + printenv(PATH_INFO); + printenv(QUERY_STRING); + printenv(REMOTE_ADDR); + printenv(REMOTE_PORT); + printenv(CONTENT_TYPE); + printenv(CONTENT_LENGTH); + + return (0); +}
Use SCRIPT_FILENAME in slowcgi
The attached diff uses SCRIPT_FILENAME instead of SCRIPT_NAME to determine the path of CGI scripts in slowcgi. It also updates the example in nginx.conf. According to CGI/1.1: The SCRIPT_NAME variable MUST be set to a URL path (not URL-encoded) which could identify the CGI script (rather than the script's output). The syntax is the same as for PATH_INFO (section 4.1.5) If you decided to run a CGI script outside of /cgi-bin/ SCRIPT_NAME no longer matches the path of the CGI script as it is now local to the document root. You would need to set something like the following in nginx.conf to make slowcgi be able to find the CGI script: fastcgi_param SCRIPT_NAME $document_root$fastcgi_script_name; However this now violates the CGI/1.1 spec as SCRIPT_NAME is now an absolute path to the file on disk. By introducing SCRIPT_FILENAME much like PHP does we can then use: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; when using CGI scripts outside of cgi-bin and SCRIPT_NAME still functions as normal. The /cgi-bin/ example doesn't need $document_root so your pretty much setting SCRIPT_FILENAME = SCRIPT_NAME which seems redundant but once you move outside of cgi-bin I believe this is the correct way to go. -- James Turner Index: usr.sbin/slowcgi/slowcgi.c === RCS file: /cvs/src/usr.sbin/slowcgi/slowcgi.c,v retrieving revision 1.27 diff -u -p -u -p -r1.27 slowcgi.c --- usr.sbin/slowcgi/slowcgi.c 19 Jan 2014 00:01:05 - 1.27 +++ usr.sbin/slowcgi/slowcgi.c 1 Mar 2014 21:32:03 - @@ -118,7 +118,7 @@ struct request { struct fcgi_response_head response_head; struct fcgi_stdin_head stdin_head; uint16_tid; - charscript_name[MAXPATHLEN]; + charscript_filename[MAXPATHLEN]; struct env_head env; int env_count; pid_t script_pid; @@ -524,7 +524,7 @@ slowcgi_sig_handler(int sig, short event create_end_record(c); c-script_flags |= SCRIPT_DONE; - ldebug(wait: %s, c-script_name); + ldebug(wait: %s, c-script_filename); } if (pid == -1 errno != ECHILD) lwarn(waitpid); @@ -741,9 +741,9 @@ parse_params(uint8_t *buf, uint16_t n, s env_entry-val[name_len] = '\0'; if (val_len MAXPATHLEN strcmp(env_entry-val, - SCRIPT_NAME) == 0) { - bcopy(buf, c-script_name, val_len); - c-script_name[val_len] = '\0'; + SCRIPT_FILENAME) == 0) { + bcopy(buf, c-script_filename, val_len); + c-script_filename[val_len] = '\0'; } env_entry-val[name_len] = '='; @@ -848,7 +848,7 @@ exec_cgi(struct request *c) lerr(1, socketpair); cgi_inflight--; c-inflight_fds_accounted = 1; - ldebug(fork: %s, c-script_name); + ldebug(fork: %s, c-script_filename); switch (pid = fork()) { case -1: @@ -887,15 +887,15 @@ exec_cgi(struct request *c) close(s_out[1]); close(s_err[1]); - argv[0] = c-script_name; + argv[0] = c-script_filename; argv[1] = NULL; if ((env = calloc(c-env_count + 1, sizeof(char*))) == NULL) _exit(1); SLIST_FOREACH(env_entry, c-env, entry) env[i++] = env_entry-val; env[i++] = NULL; - execve(c-script_name, argv, env); - lwarn(execve %s, c-script_name); + execve(c-script_filename, argv, env); + lwarn(execve %s, c-script_filename); _exit(1); } Index: usr.sbin/nginx/conf/nginx.conf === RCS file: /cvs/src/usr.sbin/nginx/conf/nginx.conf,v retrieving revision 1.16 diff -u -p -u -p -r1.16 nginx.conf --- usr.sbin/nginx/conf/nginx.conf 28 Jan 2014 14:48:53 - 1.16 +++ usr.sbin/nginx/conf/nginx.conf 1 Mar 2014 21:32:03 - @@ -64,6 +64,7 @@ http { #fastcgi_pass unix:run/slowcgi.sock; #fastcgi_split_path_info ^(/cgi-bin/[^/]+)(.*); #fastcgi_param PATH_INFO $fastcgi_path_info; +#fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; #includefastcgi_params; #}