From 4a6688a61b92aa8dfbcfc166241e98c8caa680dc Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 17:19:28 +0200 Subject: [PATCH 01/10] Added nweb and enabled it by default --- src/.config | 3 +- src/README | 2 + src/minimal_overlay/bundles/nweb/bundle.sh | 33 +++ src/minimal_overlay/bundles/nweb/client.c | 50 +++++ src/minimal_overlay/bundles/nweb/favicon.ico | Bin 0 -> 1334 bytes src/minimal_overlay/bundles/nweb/index.html | 13 ++ src/minimal_overlay/bundles/nweb/nweb.8 | 25 +++ src/minimal_overlay/bundles/nweb/nweb23.c | 204 +++++++++++++++++++ 8 files changed, 329 insertions(+), 1 deletion(-) create mode 100755 src/minimal_overlay/bundles/nweb/bundle.sh create mode 100644 src/minimal_overlay/bundles/nweb/client.c create mode 100644 src/minimal_overlay/bundles/nweb/favicon.ico create mode 100644 src/minimal_overlay/bundles/nweb/index.html create mode 100644 src/minimal_overlay/bundles/nweb/nweb.8 create mode 100644 src/minimal_overlay/bundles/nweb/nweb23.c diff --git a/src/.config b/src/.config index d9d62ed13..bf00fa412 100644 --- a/src/.config +++ b/src/.config @@ -86,7 +86,6 @@ STATIC_GET_SOURCE_URL=http://s.minos.io/s # CLOUD_FOUNDRY_CLI_URL=http://cli.run.pivotal.io/stable?release=linux64-binary&source=github - #################################################### # # # This section contains configuration properties # @@ -171,11 +170,13 @@ COPY_SOURCE_ISO=true # lua - scripting language # static_get - portable binaries for Linux (http://s.minos.io) # cf_cli - CLoud Foundry CLI (command line interface) +# nweb - simple mini http server # # Refer to the README file for more information. # #OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix,mll_utils,lua,static_get,cf_cli #OVERLAY_BUNDLES=cf_cli +OVERLY_BUNDLES=nweb # This property enables the standard penguin boot logo in the upper left corner # of the screen. The property is used in 'xx_build_kernel.sh'. The default value diff --git a/src/README b/src/README index f0f32fbf8..0968a783f 100644 --- a/src/README +++ b/src/README @@ -63,6 +63,8 @@ Currently available overlay bundles: * Lua - The Lua Scripting Language 5.3. Requires ~ 800kb additional space. Use the "lua" command to run an interactive lua interpreter +* nweb - nweb is a very small and easy to use webserver + ### ### ### I only provide the build scripts. It's entirely up to you to configure and diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh new file mode 100755 index 000000000..def88ed6b --- /dev/null +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -0,0 +1,33 @@ +#!/bin/sh +SRC_DIR=$(pwd) + +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +cd $MAIN_SRC_DIR/work/overlay/nweb + +# nweb +cc -O2 $(SRC_DIR)/nweb23.c -o nweb + +# client +#cc -O2 $(SRC_DIR)/client.c -o client + +echo "nweb has been build." + +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr" +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin" +install -m755 nweb "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/nweb" +#install -m755 client "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/client" +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS compliant location +install -m022 "$(SRC_DIR)/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/index.html" +install -m022 "$(SRC_DIR)/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/favicon.ico" +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share" +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man" +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8" +install -m022 "$(SRC_DIR)/nweb.8" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8/nweb.8" + +echo "nweb has been installed." +echo "type 'man nweb' to see what it can do on your mimial system" + diff --git a/src/minimal_overlay/bundles/nweb/client.c b/src/minimal_overlay/bundles/nweb/client.c new file mode 100644 index 000000000..55887f9a9 --- /dev/null +++ b/src/minimal_overlay/bundles/nweb/client.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +/* YOU WILL HAVE TO CHANGE THESE TWO LINES TO MATCH YOUR CONFIG */ +#define PORT 8181 /* Port number as an integer - web server default is 80 */ +#define IP_ADDRESS "192.168.0.8" /* IP Address as a string */ + +char *command = "GET /index.html HTTP/1.0 \r\n\r\n" ; +/* Note: spaces are delimiters and VERY important */ + +#define BUFSIZE 8196 + +pexit(char * msg) +{ + perror(msg); + exit(1); +} + +main() +{ +int i,sockfd; +char buffer[BUFSIZE]; +static struct sockaddr_in serv_addr; + + printf("client trying to connect to %s and port %d\n",IP_ADDRESS,PORT); + if((sockfd = socket(AF_INET, SOCK_STREAM,0)) <0) + pexit("socket() failed"); + + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = inet_addr(IP_ADDRESS); + serv_addr.sin_port = htons(PORT); + + /* Connect tot he socket offered by the web server */ + if(connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) <0) + pexit("connect() failed"); + + /* Now the sockfd can be used to communicate to the server the GET request */ + printf("Send bytes=%d %s\n",strlen(command), command); + write(sockfd, command, strlen(command)); + + /* This displays the raw HTML file (if index.html) as received by the browser */ + while( (i=read(sockfd,buffer,BUFSIZE)) > 0) + write(1,buffer,i); +} diff --git a/src/minimal_overlay/bundles/nweb/favicon.ico b/src/minimal_overlay/bundles/nweb/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c7a2123c162b1cca07532e1607f5fdced7eb0f62 GIT binary patch literal 1334 zcmajdv2ET!42EGENPv_Xfn_FeO{C8b9OWB@MUXjIdxjJ&UAj-9yb}NXF<`*f>Cs0? z2T6Cj?>`L4JGLR4ojoIJL zOQb+TC^Tl5LOB^o2!+P%GHE9R38B!KYYAzb3?zg?W2_l}n?i%i^URKG zx8pb~(9TO7p5JW8^TD-)0L87H)$Z4oSNC7{xw_nYp3mNA{HxA + +nweb + + +

nweb test page

+
+

It works!

+

All rights go to the original author of nweb Nigel Griffiths nag@uk.ibm.com

+

Feedback is welcome to Nigel Griffiths nag@uk.ibm.com

+

+ + diff --git a/src/minimal_overlay/bundles/nweb/nweb.8 b/src/minimal_overlay/bundles/nweb/nweb.8 new file mode 100644 index 000000000..047e0763c --- /dev/null +++ b/src/minimal_overlay/bundles/nweb/nweb.8 @@ -0,0 +1,25 @@ +.TH NWEB 8 "June 19, 2017" +.SH NAME +nweb \- small and very safe mini web server +.SH SYNPOSIS +.B nweb +[\fIport\fR] +[\fItopdir\fR] +.SH DESCRIPTION +nweb only servers out file/web pages with extensions named below and only from the named directory or its sub-directories. + +There is no fancy features = safe and secure. + +Only Supports: gif jpg jpeg png ico zip gz tar htm html + +Not Supported: URLs including "..", Java, Javascript, CGI + +Not Supported: directories / /etc /bin /lib /tmp /usr /dev /sbin + +No warranty given or implied + +Nigel Griffiths nag@uk.ibm.com +.SH EXAMPLES + "nweb 8181 /srv/www &" + +Runs nweb on port 8181 serving files in /srv/www diff --git a/src/minimal_overlay/bundles/nweb/nweb23.c b/src/minimal_overlay/bundles/nweb/nweb23.c new file mode 100644 index 000000000..da5a6d3b1 --- /dev/null +++ b/src/minimal_overlay/bundles/nweb/nweb23.c @@ -0,0 +1,204 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define VERSION 23 +#define BUFSIZE 8096 +#define ERROR 42 +#define LOG 44 +#define FORBIDDEN 403 +#define NOTFOUND 404 + +#ifndef SIGCLD +# define SIGCLD SIGCHLD +#endif + +struct { + char *ext; + char *filetype; +} extensions [] = { + {"gif", "image/gif" }, + {"jpg", "image/jpg" }, + {"jpeg","image/jpeg"}, + {"png", "image/png" }, + {"ico", "image/ico" }, + {"zip", "image/zip" }, + {"gz", "image/gz" }, + {"tar", "image/tar" }, + {"htm", "text/html" }, + {"html","text/html" }, + {0,0} }; + +void logger(int type, char *s1, char *s2, int socket_fd) +{ + int fd ; + char logbuffer[BUFSIZE*2]; + + switch (type) { + case ERROR: (void)sprintf(logbuffer,"ERROR: %s:%s Errno=%d exiting pid=%d",s1, s2, errno,getpid()); + break; + case FORBIDDEN: + (void)write(socket_fd, "HTTP/1.1 403 Forbidden\nContent-Length: 185\nConnection: close\nContent-Type: text/html\n\n\n403 Forbidden\n\n

Forbidden

\nThe requested URL, file type or operation is not allowed on this simple static file webserver.\n\n",271); + (void)sprintf(logbuffer,"FORBIDDEN: %s:%s",s1, s2); + break; + case NOTFOUND: + (void)write(socket_fd, "HTTP/1.1 404 Not Found\nContent-Length: 136\nConnection: close\nContent-Type: text/html\n\n\n404 Not Found\n\n

Not Found

\nThe requested URL was not found on this server.\n\n",224); + (void)sprintf(logbuffer,"NOT FOUND: %s:%s",s1, s2); + break; + case LOG: (void)sprintf(logbuffer," INFO: %s:%s:%d",s1, s2,socket_fd); break; + } + /* No checks here, nothing can be done with a failure anyway */ + if((fd = open("nweb.log", O_CREAT| O_WRONLY | O_APPEND,0644)) >= 0) { + (void)write(fd,logbuffer,strlen(logbuffer)); + (void)write(fd,"\n",1); + (void)close(fd); + } + if(type == ERROR || type == NOTFOUND || type == FORBIDDEN) exit(3); +} + +/* this is a child web server process, so we can exit on errors */ +void web(int fd, int hit) +{ + int j, file_fd, buflen; + long i, ret, len; + char * fstr; + static char buffer[BUFSIZE+1]; /* static so zero filled */ + + ret =read(fd,buffer,BUFSIZE); /* read Web request in one go */ + if(ret == 0 || ret == -1) { /* read failure stop now */ + logger(FORBIDDEN,"failed to read browser request","",fd); + } + if(ret > 0 && ret < BUFSIZE) /* return code is valid chars */ + buffer[ret]=0; /* terminate the buffer */ + else buffer[0]=0; + for(i=0;i 0 ) { + (void)write(fd,buffer,ret); + } + sleep(1); /* allow socket to drain before signalling the socket is closed */ + close(fd); + exit(1); +} + +int main(int argc, char **argv) +{ + int i, port, pid, listenfd, socketfd, hit; + socklen_t length; + static struct sockaddr_in cli_addr; /* static = initialised to zeros */ + static struct sockaddr_in serv_addr; /* static = initialised to zeros */ + + if( argc < 3 || argc > 3 || !strcmp(argv[1], "-?") ) { + (void)printf("hint: nweb Port-Number Top-Directory\t\tversion %d\n\n" + "\tnweb is a small and very safe mini web server\n" + "\tnweb only servers out file/web pages with extensions named below\n" + "\t and only from the named directory or its sub-directories.\n" + "\tThere is no fancy features = safe and secure.\n\n" + "\tExample: nweb 8181 /home/nwebdir &\n\n" + "\tOnly Supports:", VERSION); + for(i=0;extensions[i].ext != 0;i++) + (void)printf(" %s",extensions[i].ext); + + (void)printf("\n\tNot Supported: URLs including \"..\", Java, Javascript, CGI\n" + "\tNot Supported: directories / /etc /bin /lib /tmp /usr /dev /sbin \n" + "\tNo warranty given or implied\n\tNigel Griffiths nag@uk.ibm.com\n" ); + exit(0); + } + if( !strncmp(argv[2],"/" ,2 ) || !strncmp(argv[2],"/etc", 5 ) || + !strncmp(argv[2],"/bin",5 ) || !strncmp(argv[2],"/lib", 5 ) || + !strncmp(argv[2],"/tmp",5 ) || !strncmp(argv[2],"/usr", 5 ) || + !strncmp(argv[2],"/dev",5 ) || !strncmp(argv[2],"/sbin",6) ){ + (void)printf("ERROR: Bad top directory %s, see nweb -?\n",argv[2]); + exit(3); + } + if(chdir(argv[2]) == -1){ + (void)printf("ERROR: Can't Change to directory %s\n",argv[2]); + exit(4); + } + /* Become deamon + unstopable and no zombies children (= no wait()) */ + if(fork() != 0) + return 0; /* parent returns OK to shell */ + (void)signal(SIGCLD, SIG_IGN); /* ignore child death */ + (void)signal(SIGHUP, SIG_IGN); /* ignore terminal hangups */ + for(i=0;i<32;i++) + (void)close(i); /* close open files */ + (void)setpgrp(); /* break away from process group */ + logger(LOG,"nweb starting",argv[1],getpid()); + /* setup the network socket */ + if((listenfd = socket(AF_INET, SOCK_STREAM,0)) <0) + logger(ERROR, "system call","socket",0); + port = atoi(argv[1]); + if(port < 0 || port >60000) + logger(ERROR,"Invalid port number (try 1->60000)",argv[1],0); + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); + serv_addr.sin_port = htons(port); + if(bind(listenfd, (struct sockaddr *)&serv_addr,sizeof(serv_addr)) <0) + logger(ERROR,"system call","bind",0); + if( listen(listenfd,64) <0) + logger(ERROR,"system call","listen",0); + for(hit=1; ;hit++) { + length = sizeof(cli_addr); + if((socketfd = accept(listenfd, (struct sockaddr *)&cli_addr, &length)) < 0) + logger(ERROR,"system call","accept",0); + if((pid = fork()) < 0) { + logger(ERROR,"system call","fork",0); + } + else { + if(pid == 0) { /* child */ + (void)close(listenfd); + web(socketfd,hit); /* never returns */ + } else { /* parent */ + (void)close(socketfd); + } + } + } +} From 75f053a9ceebada85c9b90aa4a8b7d7d0a5bd8df Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 17:26:42 +0200 Subject: [PATCH 02/10] Fixed mixed Makefile and bash syntax in nweb --- src/minimal_overlay/bundles/nweb/bundle.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index def88ed6b..b75ea5e4d 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -6,13 +6,16 @@ cd ../../.. MAIN_SRC_DIR=$(pwd) cd $SRC_DIR +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + cd $MAIN_SRC_DIR/work/overlay/nweb # nweb -cc -O2 $(SRC_DIR)/nweb23.c -o nweb +cc $CFLAGS $SRC_DIR/nweb23.c -o nweb # client -#cc -O2 $(SRC_DIR)/client.c -o client +#cc $CFLAGS $SRC_DIR/client.c -o client echo "nweb has been build." @@ -21,13 +24,12 @@ install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin" install -m755 nweb "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/nweb" #install -m755 client "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/client" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS compliant location -install -m022 "$(SRC_DIR)/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/index.html" -install -m022 "$(SRC_DIR)/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/favicon.ico" +install -m022 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/index.html" +install -m022 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/favicon.ico" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8" -install -m022 "$(SRC_DIR)/nweb.8" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8/nweb.8" +install -m022 "$SRC_DIR/nweb.8" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8/nweb.8" echo "nweb has been installed." echo "type 'man nweb' to see what it can do on your mimial system" - From 018a94c481ae25cee8a88f0934c1163eb667c980 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 17:41:02 +0200 Subject: [PATCH 03/10] Fixed nweb --- src/minimal_overlay/bundles/nweb/bundle.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index b75ea5e4d..2fa3dc146 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -9,6 +9,9 @@ cd $SRC_DIR # Read the 'CFLAGS' property from '.config' CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" +echo "removing previous work area" +rm -rf $MAIN_SRC_DIR/work/overlay/nweb +mkdir -p $MAIN_SRC_DIR/work/overlay/nweb cd $MAIN_SRC_DIR/work/overlay/nweb # nweb @@ -24,12 +27,12 @@ install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin" install -m755 nweb "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/nweb" #install -m755 client "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/client" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS compliant location -install -m022 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/index.html" -install -m022 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/svc/www/favicon.ico" +install -m644 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/index.html" +install -m644 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/favicon.ico" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8" -install -m022 "$SRC_DIR/nweb.8" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8/nweb.8" +install -m644 "$SRC_DIR/nweb.8" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8/nweb.8" echo "nweb has been installed." echo "type 'man nweb' to see what it can do on your mimial system" From 8ba5c56fdbe950ffbb6829153300c24d38b645d1 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 17:50:47 +0200 Subject: [PATCH 04/10] Removed man page for nweb --- src/minimal_overlay/bundles/nweb/bundle.sh | 6 +----- src/minimal_overlay/bundles/nweb/nweb.8 | 25 ---------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 src/minimal_overlay/bundles/nweb/nweb.8 diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index 2fa3dc146..d653e2fd5 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -29,10 +29,6 @@ install -m755 nweb "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/nweb" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS compliant location install -m644 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/index.html" install -m644 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/favicon.ico" -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share" -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man" -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8" -install -m644 "$SRC_DIR/nweb.8" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/share/man/man8/nweb.8" echo "nweb has been installed." -echo "type 'man nweb' to see what it can do on your mimial system" +echo "run 'nweb 80 /srv/www &' on your minimal system to run it" diff --git a/src/minimal_overlay/bundles/nweb/nweb.8 b/src/minimal_overlay/bundles/nweb/nweb.8 deleted file mode 100644 index 047e0763c..000000000 --- a/src/minimal_overlay/bundles/nweb/nweb.8 +++ /dev/null @@ -1,25 +0,0 @@ -.TH NWEB 8 "June 19, 2017" -.SH NAME -nweb \- small and very safe mini web server -.SH SYNPOSIS -.B nweb -[\fIport\fR] -[\fItopdir\fR] -.SH DESCRIPTION -nweb only servers out file/web pages with extensions named below and only from the named directory or its sub-directories. - -There is no fancy features = safe and secure. - -Only Supports: gif jpg jpeg png ico zip gz tar htm html - -Not Supported: URLs including "..", Java, Javascript, CGI - -Not Supported: directories / /etc /bin /lib /tmp /usr /dev /sbin - -No warranty given or implied - -Nigel Griffiths nag@uk.ibm.com -.SH EXAMPLES - "nweb 8181 /srv/www &" - -Runs nweb on port 8181 serving files in /srv/www From f1bcda53e7a24eb0fdac10b9160f29e3c0f1239f Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 18:00:49 +0200 Subject: [PATCH 05/10] Added note about port-forwarding the guest machine --- src/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/README b/src/README index 0968a783f..fa86b7699 100644 --- a/src/README +++ b/src/README @@ -64,6 +64,10 @@ Currently available overlay bundles: space. Use the "lua" command to run an interactive lua interpreter * nweb - nweb is a very small and easy to use webserver + run it using 'nweb 80 /srv/www' + to portforward port 8080 on the host to port 80 on the guest (minimal) + add '-net nic,model=e1000 -net user,hostfwd=tcp::8080-:80' to the cmd in + qemu64.sh and qemu32.sh ### ### ### From faa36e15c8ccff7260138596b75ee60c7585b706 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 18:39:53 +0200 Subject: [PATCH 06/10] Added nweb to /etc/autostart --- src/minimal_overlay/bundles/nweb/bundle.sh | 4 +++- src/minimal_overlay/bundles/nweb/index.html | 3 ++- src/minimal_overlay/bundles/nweb/nweb.sh | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/minimal_overlay/bundles/nweb/nweb.sh diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index d653e2fd5..d2349039c 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -29,6 +29,8 @@ install -m755 nweb "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/nweb" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS compliant location install -m644 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/index.html" install -m644 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/favicon.ico" +install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc" +install -m755 "$SRC_DIR/nweb.sh" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc/nweb.sh" echo "nweb has been installed." -echo "run 'nweb 80 /srv/www &' on your minimal system to run it" +echo "it will be autostarted on boot" diff --git a/src/minimal_overlay/bundles/nweb/index.html b/src/minimal_overlay/bundles/nweb/index.html index d99085b24..19920ae66 100644 --- a/src/minimal_overlay/bundles/nweb/index.html +++ b/src/minimal_overlay/bundles/nweb/index.html @@ -3,9 +3,10 @@ nweb -

nweb test page

+

nweb test page


It works!

+

You can edit this file in /srv/www/index.html

All rights go to the original author of nweb Nigel Griffiths nag@uk.ibm.com

Feedback is welcome to Nigel Griffiths nag@uk.ibm.com

diff --git a/src/minimal_overlay/bundles/nweb/nweb.sh b/src/minimal_overlay/bundles/nweb/nweb.sh new file mode 100644 index 000000000..ac5389dcf --- /dev/null +++ b/src/minimal_overlay/bundles/nweb/nweb.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo "starting nweb on port 80 serving /srv/www" +nweb 80 /srv/www From ad1c8f90ccc36daf4d38fd6928a0b3a889a5ce0f Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 19:25:39 +0200 Subject: [PATCH 07/10] Fixed 2 typos --- src/.config | 2 +- src/minimal_overlay/bundles/nweb/bundle.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.config b/src/.config index bf00fa412..df674bdc3 100644 --- a/src/.config +++ b/src/.config @@ -176,7 +176,7 @@ COPY_SOURCE_ISO=true # #OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix,mll_utils,lua,static_get,cf_cli #OVERLAY_BUNDLES=cf_cli -OVERLY_BUNDLES=nweb +OVERLAY_BUNDLES=nweb # This property enables the standard penguin boot logo in the upper left corner # of the screen. The property is used in 'xx_build_kernel.sh'. The default value diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index d2349039c..1eb14a467 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -30,7 +30,7 @@ install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS c install -m644 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/index.html" install -m644 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/favicon.ico" install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc" -install -m755 "$SRC_DIR/nweb.sh" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc/nweb.sh" +install -m755 "$SRC_DIR/nweb.sh" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc/autorun/90_nweb.sh" echo "nweb has been installed." echo "it will be autostarted on boot" From b7a0182ac3f807d8fcb2875a9691820fdc286d1c Mon Sep 17 00:00:00 2001 From: bauen1 Date: Mon, 19 Jun 2017 19:27:54 +0200 Subject: [PATCH 08/10] Made the bundle.sh of the nweb overlay better to read --- src/minimal_overlay/bundles/nweb/bundle.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index 1eb14a467..1ea6d676b 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -22,15 +22,18 @@ cc $CFLAGS $SRC_DIR/nweb23.c -o nweb echo "nweb has been build." -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr" -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin" -install -m755 nweb "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/nweb" -#install -m755 client "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/bin/client" -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www" # FHS compliant location -install -m644 "$SRC_DIR/index.html" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/index.html" -install -m644 "$SRC_DIR/favicon.ico" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/srv/www/favicon.ico" -install -d -m755 "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc" -install -m755 "$SRC_DIR/nweb.sh" "$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/etc/autorun/90_nweb.sh" +DESTDIR="$MAIN_SRC_DIR/work/src/minimal_overlay/rootfs" + +install -d -m755 "$DESTDIR/usr" +install -d -m755 "$DESTDIR/usr/bin" +install -m755 nweb "$DESTDIR/usr/bin/nweb" +#install -m755 client "$DESTDIR/usr/bin/client" +install -d -m755 "$DESTDIR/srv/www" # FHS compliant location +install -m644 "$SRC_DIR/index.html" "$DESTDIR/srv/www/index.html" +install -m644 "$SRC_DIR/favicon.ico" "$DESTDIR/srv/www/favicon.ico" +install -d -m755 "$DESTDIR/etc" +install -d -m755 "$DESTDIR/etc/autorun" +install -m755 "$SRC_DIR/nweb.sh" "$DESTDIR/etc/autorun/90_nweb.sh" echo "nweb has been installed." echo "it will be autostarted on boot" From c12c6dcf575cfcbd47790116267d41b00ff12ecf Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Tue, 20 Jun 2017 00:15:59 +0300 Subject: [PATCH 09/10] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5da949d51..b375a8a20 100644 --- a/README.md +++ b/README.md @@ -96,14 +96,16 @@ dd if=minimal_linux_live.iso of=/dev/xxx * [Minimal Linux Script](https://github.com/ivandavidov/minimal-linux-script) - very simplified and minimalistic version of MLL. Recommended for 100% noobs. -* [Boot2Minc](https://github.com/mhiramat/boot2minc) - this fork adds [Mincs](https://github.com/mhiramat/mincs) and as result you can run Linux containers. One interesting Mincs feature - it provides tools which allow you to reuse alredy existing Docker containers. +* [Boot2Minc](https://github.com/mhiramat/boot2minc) - this fork adds [Mincs](https://github.com/mhiramat/mincs) and as result you can run Linux containers inside MLL. One interesting Mincs feature - it provides tools which allow you to reuse alredy existing Docker containers. * [K1773R's MLL](https://github.com/K1773R/minimal) - PowerPC version of Minimal Linux Live with [memtester](http://pyropus.ca/software/memtester) as additional software. Impressive work! -* [Ladiko's MLL](https://github.com/ladiko/minimal) - This fork automatically downloads and uses the latest available Kernel and BusyBox sources. By default there is NTFS and SquashFS support. The fork also provides an installer which can be used to put MLL on USB flash device. +* [Ladiko's MLL](https://github.com/ladiko/minimal) - this fork automatically downloads and uses the latest available Kernel and BusyBox sources. By default there is NTFS and SquashFS support. The fork also provides an installer which can be used to put MLL on USB flash device. * [AwlsomeLinux](https://github.com/AwlsomeAlex/AwlsomeLinux) - MLL fork which provides additional overlay bundles (ncurses and Nano). +* [StarLinux](https://github.com/AwlsomeAlex/StarLinux) - the successor of [AwlsomeLinux](https://github.com/AwlsomeAlex/AwlsomeLinux). StarLinux aims at making the build process user friendly. + * [prologic's MLL](https://github.com/prologic/minimal) - this fork adds Python support to the MLL runtime environment. * [KernelISO](https://github.com/rleon/kerneliso) - extended version of MLL. From 67d59d38d5a65d7e1708784cb5a4e830a627668b Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Tue, 20 Jun 2017 00:19:35 +0300 Subject: [PATCH 10/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b375a8a20..15632693a 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ dd if=minimal_linux_live.iso of=/dev/xxx ## Projects based on Minimal Linux Live: -* [Minimal Linux Script](https://github.com/ivandavidov/minimal-linux-script) - very simplified and minimalistic version of MLL. Recommended for 100% noobs. +* [Minimal Linux Script](https://github.com/ivandavidov/minimal-linux-script) - very simplified and minimalistic version of MLL. This project is recommended as a starting point for beginners. * [Boot2Minc](https://github.com/mhiramat/boot2minc) - this fork adds [Mincs](https://github.com/mhiramat/mincs) and as result you can run Linux containers inside MLL. One interesting Mincs feature - it provides tools which allow you to reuse alredy existing Docker containers.