uncommitted - micro-httpd

Ready changes

Summary

Import uploads missing from VCS:

Diff

diff --git a/.pc/.quilt_patches b/.pc/.quilt_patches
new file mode 100644
index 0000000..6857a8d
--- /dev/null
+++ b/.pc/.quilt_patches
@@ -0,0 +1 @@
+debian/patches
diff --git a/.pc/.quilt_series b/.pc/.quilt_series
new file mode 100644
index 0000000..c206706
--- /dev/null
+++ b/.pc/.quilt_series
@@ -0,0 +1 @@
+series
diff --git a/.pc/.version b/.pc/.version
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/.pc/.version
@@ -0,0 +1 @@
+2
diff --git a/.pc/21-micro-httpd.c--swf.patch/micro_httpd.c b/.pc/21-micro-httpd.c--swf.patch/micro_httpd.c
new file mode 100644
index 0000000..ca6abb4
--- /dev/null
+++ b/.pc/21-micro-httpd.c--swf.patch/micro_httpd.c
@@ -0,0 +1,316 @@
+/* micro_httpd - really small HTTP server
+**
+** Copyright � 1999,2005 by Jef Poskanzer <jef@mail.acme.com>.
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+** ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+** SUCH DAMAGE.
+*/
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <ctype.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+
+#define SERVER_NAME "micro_httpd"
+#define SERVER_URL "http://www.acme.com/software/micro_httpd/"
+#define PROTOCOL "HTTP/1.0"
+#define RFC1123FMT "%a, %d %b %Y %H:%M:%S GMT"
+
+
+/* Forwards. */
+static void file_details( char* dir, char* name );
+static void send_error( int status, char* title, char* extra_header, char* text );
+static void send_headers( int status, char* title, char* extra_header, char* mime_type, off_t length, time_t mod );
+static char* get_mime_type( char* name );
+static void strdecode( char* to, char* from );
+static int hexit( char c );
+static void strencode( char* to, size_t tosize, const char* from );
+
+
+int
+main( int argc, char** argv )
+    {
+    char line[10000], method[10000], path[10000], protocol[10000], idx[20000], location[20000];
+    char* file;
+    size_t len;
+    int ich;
+    struct stat sb;
+    FILE* fp;
+    struct dirent **dl;
+    int i, n;
+
+    if ( argc != 2 )
+	send_error( 500, "Internal Error", (char*) 0, "Config error - no dir specified." );
+    if ( chdir( argv[1] ) < 0 )
+	send_error( 500, "Internal Error", (char*) 0, "Config error - couldn't chdir()." );
+    if ( fgets( line, sizeof(line), stdin ) == (char*) 0 )
+	send_error( 400, "Bad Request", (char*) 0, "No request found." );
+    if ( sscanf( line, "%[^ ] %[^ ] %[^ ]", method, path, protocol ) != 3 )
+	send_error( 400, "Bad Request", (char*) 0, "Can't parse request." );
+    while ( fgets( line, sizeof(line), stdin ) != (char*) 0 )
+	{
+	if ( strcmp( line, "\n" ) == 0 || strcmp( line, "\r\n" ) == 0 )
+	    break;
+	}
+    if ( strcasecmp( method, "get" ) != 0 )
+	send_error( 501, "Not Implemented", (char*) 0, "That method is not implemented." );
+    if ( path[0] != '/' )
+	send_error( 400, "Bad Request", (char*) 0, "Bad filename." );
+    file = &(path[1]);
+    strdecode( file, file );
+    if ( file[0] == '\0' )
+	file = "./";
+    len = strlen( file );
+    if ( file[0] == '/' || strcmp( file, ".." ) == 0 || strncmp( file, "../", 3 ) == 0 || strstr( file, "/../" ) != (char*) 0 || strcmp( &(file[len-3]), "/.." ) == 0 )
+	send_error( 400, "Bad Request", (char*) 0, "Illegal filename." );
+    if ( stat( file, &sb ) < 0 )
+	send_error( 404, "Not Found", (char*) 0, "File not found." );
+    if ( S_ISDIR( sb.st_mode ) )
+	{
+	if ( file[len-1] != '/' )
+	    {
+	    (void) snprintf(
+		location, sizeof(location), "Location: %s/", path );
+	    send_error( 302, "Found", location, "Directories must end with a slash." );
+	    }
+	(void) snprintf( idx, sizeof(idx), "%sindex.html", file );
+	if ( stat( idx, &sb ) >= 0 )
+	    {
+	    file = idx;
+	    goto do_file;
+	    }
+	send_headers( 200, "Ok", (char*) 0, "text/html", -1, sb.st_mtime );
+	(void) printf( "\
+<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\
+<html>\n\
+  <head>\n\
+    <meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n\
+    <title>Index of %s</title>\n\
+  </head>\n\
+  <body bgcolor=\"#99cc99\">\n\
+    <h4>Index of %s</h4>\n\
+    <pre>\n", file, file );
+	n = scandir( file, &dl, NULL, alphasort );
+	if ( n < 0 )
+	    perror( "scandir" );
+	else
+	    for ( i = 0; i < n; ++i )
+		file_details( file, dl[i]->d_name );
+	(void) printf( "\
+    </pre>\n\
+    <hr>\n\
+    <address><a href=\"%s\">%s</a></address>\n\
+  </body>\n\
+</html>\n", SERVER_URL, SERVER_NAME );
+	}
+    else
+	{
+	do_file:
+	fp = fopen( file, "r" );
+	if ( fp == (FILE*) 0 )
+	    send_error( 403, "Forbidden", (char*) 0, "File is protected." );
+	send_headers( 200, "Ok", (char*) 0, get_mime_type( file ), sb.st_size, sb.st_mtime );
+	while ( ( ich = getc( fp ) ) != EOF )
+	    putchar( ich );
+	}
+
+    (void) fflush( stdout );
+    exit( 0 );
+    }
+
+
+static void
+file_details( char* dir, char* name )
+    {
+    static char encoded_name[1000];
+    static char path[2000];
+    struct stat sb;
+    char timestr[16];
+
+    strencode( encoded_name, sizeof(encoded_name), name );
+    (void) snprintf( path, sizeof(path), "%s/%s", dir, name );
+    if ( lstat( path, &sb ) < 0 )
+	(void) printf( "<a href=\"%s\">%-32.32s</a>    ???\n", encoded_name, name );
+    else
+	{
+	(void) strftime( timestr, sizeof(timestr), "%d%b%Y %H:%M", localtime( &sb.st_mtime ) );
+	(void) printf( "<a href=\"%s\">%-32.32s</a>    %15s %14lld\n", encoded_name, name, timestr, (long long) sb.st_size );
+	}
+    }
+
+
+static void
+send_error( int status, char* title, char* extra_header, char* text )
+    {
+    send_headers( status, title, extra_header, "text/html", -1, -1 );
+    (void) printf( "\
+<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\
+<html>\n\
+  <head>\n\
+    <meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n\
+    <title>%d %s</title>\n\
+  </head>\n\
+  <body bgcolor=\"#cc9999\">\n\
+    <h4>%d %s</h4>\n", status, title, status, title );
+    (void) printf( "%s\n", text );
+    (void) printf( "\
+    <hr>\n\
+    <address><a href=\"%s\">%s</a></address>\n\
+  </body>\n\
+</html>\n", SERVER_URL, SERVER_NAME );
+    (void) fflush( stdout );
+    exit( 1 );
+    }
+
+
+static void
+send_headers( int status, char* title, char* extra_header, char* mime_type, off_t length, time_t mod )
+    {
+    time_t now;
+    char timebuf[100];
+
+    (void) printf( "%s %d %s\015\012", PROTOCOL, status, title );
+    (void) printf( "Server: %s\015\012", SERVER_NAME );
+    now = time( (time_t*) 0 );
+    (void) strftime( timebuf, sizeof(timebuf), RFC1123FMT, gmtime( &now ) );
+    (void) printf( "Date: %s\015\012", timebuf );
+    if ( extra_header != (char*) 0 )
+	(void) printf( "%s\015\012", extra_header );
+    if ( mime_type != (char*) 0 )
+	(void) printf( "Content-Type: %s\015\012", mime_type );
+    if ( length >= 0 )
+	(void) printf( "Content-Length: %lld\015\012", (long long) length );
+    if ( mod != (time_t) -1 )
+	{
+	(void) strftime( timebuf, sizeof(timebuf), RFC1123FMT, gmtime( &mod ) );
+	(void) printf( "Last-Modified: %s\015\012", timebuf );
+	}
+    (void) printf( "Connection: close\015\012" );
+    (void) printf( "\015\012" );
+    }
+
+
+static char*
+get_mime_type( char* name )
+    {
+    char* dot;
+
+    dot = strrchr( name, '.' );
+    if ( dot == (char*) 0 )
+	return "text/plain; charset=UTF-8";
+    if ( strcmp( dot, ".html" ) == 0 || strcmp( dot, ".htm" ) == 0 )
+	return "text/html; charset=UTF-8";
+    if ( strcmp( dot, ".xhtml" ) == 0 || strcmp( dot, ".xht" ) == 0 )
+	return "application/xhtml+xml; charset=UTF-8";
+    if ( strcmp( dot, ".jpg" ) == 0 || strcmp( dot, ".jpeg" ) == 0 )
+	return "image/jpeg";
+    if ( strcmp( dot, ".gif" ) == 0 )
+	return "image/gif";
+    if ( strcmp( dot, ".png" ) == 0 )
+	return "image/png";
+    if ( strcmp( dot, ".css" ) == 0 )
+	return "text/css";
+    if ( strcmp( dot, ".xml" ) == 0 || strcmp( dot, ".xsl" ) == 0 )
+	return "text/xml; charset=UTF-8";
+    if ( strcmp( dot, ".au" ) == 0 )
+	return "audio/basic";
+    if ( strcmp( dot, ".wav" ) == 0 )
+	return "audio/wav";
+    if ( strcmp( dot, ".avi" ) == 0 )
+	return "video/x-msvideo";
+    if ( strcmp( dot, ".mov" ) == 0 || strcmp( dot, ".qt" ) == 0 )
+	return "video/quicktime";
+    if ( strcmp( dot, ".mpeg" ) == 0 || strcmp( dot, ".mpe" ) == 0 )
+	return "video/mpeg";
+    if ( strcmp( dot, ".vrml" ) == 0 || strcmp( dot, ".wrl" ) == 0 )
+	return "model/vrml";
+    if ( strcmp( dot, ".midi" ) == 0 || strcmp( dot, ".mid" ) == 0 )
+	return "audio/midi";
+    if ( strcmp( dot, ".mp3" ) == 0 )
+	return "audio/mpeg";
+    if ( strcmp( dot, ".ogg" ) == 0 )
+	return "application/ogg";
+    if ( strcmp( dot, ".pac" ) == 0 )
+	return "application/x-ns-proxy-autoconfig";
+    return "text/plain; charset=UTF-8";
+    }
+
+
+static void
+strdecode( char* to, char* from )
+    {
+    for ( ; *from != '\0'; ++to, ++from )
+	{
+	if ( from[0] == '%' && isxdigit( from[1] ) && isxdigit( from[2] ) )
+	    {
+	    *to = hexit( from[1] ) * 16 + hexit( from[2] );
+	    from += 2;
+	    }
+	else
+	    *to = *from;
+	}
+    *to = '\0';
+    }
+
+
+static int
+hexit( char c )
+    {
+    if ( c >= '0' && c <= '9' )
+	return c - '0';
+    if ( c >= 'a' && c <= 'f' )
+	return c - 'a' + 10;
+    if ( c >= 'A' && c <= 'F' )
+	return c - 'A' + 10;
+    return 0;		/* shouldn't happen, we're guarded by isxdigit() */
+    }
+
+
+static void
+strencode( char* to, size_t tosize, const char* from )
+    {
+    int tolen;
+
+    for ( tolen = 0; *from != '\0' && tolen + 4 < tosize; ++from )
+	{
+	if ( isalnum(*from) || strchr( "/_.-~", *from ) != (char*) 0 )
+	    {
+	    *to = *from;
+	    ++to;
+	    ++tolen;
+	    }
+	else
+	    {
+	    (void) sprintf( to, "%%%02x", (int) *from & 0xff );
+	    to += 3;
+	    tolen += 3;
+	    }
+	}
+    *to = '\0';
+    }
diff --git a/.pc/30-makefile-strip-fix.patch/Makefile b/.pc/30-makefile-strip-fix.patch/Makefile
new file mode 100644
index 0000000..090cadc
--- /dev/null
+++ b/.pc/30-makefile-strip-fix.patch/Makefile
@@ -0,0 +1,23 @@
+BINDIR =	/usr/local/sbin
+MANDIR =	/usr/local/man/man8
+CC =		cc
+CFLAGS =	-O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long
+#SYSVLIBS =	-lnsl -lsocket
+LDFLAGS =	-s $(SYSVLIBS)
+
+all:		micro_httpd
+
+micro_httpd:	micro_httpd.o
+	$(CC) micro_httpd.o $(LDFLAGS) -o micro_httpd
+
+micro_httpd.o:	micro_httpd.c
+	$(CC) $(CFLAGS) -c micro_httpd.c
+
+install:	all
+	rm -f $(BINDIR)/micro_httpd
+	cp micro_httpd $(BINDIR)/micro_httpd
+	rm -f $(MANDIR)/micro_httpd.8
+	cp micro_httpd.8 $(MANDIR)/micro_httpd.8
+
+clean:
+	rm -f micro_httpd *.o core core.* *.core
diff --git a/.pc/applied-patches b/.pc/applied-patches
new file mode 100644
index 0000000..1d2358f
--- /dev/null
+++ b/.pc/applied-patches
@@ -0,0 +1,2 @@
+21-micro-httpd.c--swf.patch
+30-makefile-strip-fix.patch
diff --git a/Makefile b/Makefile
index 090cadc..2faa776 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ MANDIR =	/usr/local/man/man8
 CC =		cc
 CFLAGS =	-O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long
 #SYSVLIBS =	-lnsl -lsocket
-LDFLAGS =	-s $(SYSVLIBS)
+LDFLAGS =	$(SYSVLIBS)
 
 all:		micro_httpd
 
diff --git a/debian/NEWS b/debian/NEWS
index 076767a..f50e36e 100644
--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,24 @@
+micro-httpd (20140814-2.1) unstable; urgency=medium
+
+  On hosts booting with systemd, the daemon is configured via systemd units.
+
+  1) To change the document root, type the following line in a command shell:
+
+       sudo systemctl edit micro-httpd@.service
+
+     Then change the second part of ExecStart to a different path.
+
+  2) To change IP address or port, type the following line in a command shell:
+
+       sudo systemctl edit micro-httpd.socket
+  
+     Then change ListenStream to a different IP address and port combination.
+
+  On hosts booting with the traditional BSD init, the daemon in configured via
+  the /etc/inetd.conf (document root) and /etc/services (port) text files.
+
+ -- Martin-Éric Racine <martin-eric.racine@iki.fi>  Thu, 14 Oct 2021 16:53:42 +0300
+
 micro-httpd (20051212-5) unstable; urgency=low
 
   The binary name has changed from micro_httpd to the micro-httpd.
diff --git a/debian/changelog b/debian/changelog
index e5993a4..0e8ef9b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+micro-httpd (20140814-2.1) unstable; urgency=medium
+
+  * Non-Maintainer Upload.
+  * Fixed "cannot configure the root directory if started by systemd
+    instead of inetd" by adding a NEWS item (Closes: #983232).
+  * Fixed "systemd install dependency fails if binding to IP other than
+    0.0.0.0" by adding FreeBind=true to the socket unit (Closes: #991324).
+    Thanks to Ansgar Burchardt for the solution.
+  * Fixed "micro-httpd@.service:6: Special user nobody configured, this is
+    not safe!" by using the canonical www-data user (Closes: #991884).
+  * Ran 'quilt refresh' which defuzzed 30_makefile-strip-fix.dpatch
+
+ -- Martin-Éric Racine <martin-eric.racine@iki.fi>  Thu, 14 Oct 2021 16:02:47 +0300
+
 micro-httpd (20140814-2) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --git a/debian/micro-httpd.socket b/debian/micro-httpd.socket
index 1d2600b..a8fdfe8 100644
--- a/debian/micro-httpd.socket
+++ b/debian/micro-httpd.socket
@@ -5,6 +5,7 @@ Documentation=man:micro-httpd(8)
 [Socket]
 ListenStream=0.0.0.0:80
 Accept=true
+FreeBind=true
 
 [Install]
 WantedBy=sockets.target
diff --git a/debian/micro-httpd@.service b/debian/micro-httpd@.service
index 93052eb..2140304 100644
--- a/debian/micro-httpd@.service
+++ b/debian/micro-httpd@.service
@@ -3,8 +3,7 @@ Description=micro-httpd
 Documentation=man:micro-httpd(8)
 
 [Service]
-User=nobody
+User=www-data
 Group=www-data
 ExecStart=-/usr/sbin/micro-httpd /var/www/html
 StandardInput=socket
-
diff --git a/debian/patches/30-makefile-strip-fix.patch b/debian/patches/30-makefile-strip-fix.patch
index 714ef97..dad4f42 100644
--- a/debian/patches/30-makefile-strip-fix.patch
+++ b/debian/patches/30-makefile-strip-fix.patch
@@ -10,10 +10,10 @@ Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
  Makefile |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
-diff --git a/Makefile b/Makefile
-index 090cadc..2faa776 100644
---- a/Makefile
-+++ b/Makefile
+Index: micro-httpd-20140814/Makefile
+===================================================================
+--- micro-httpd-20140814.orig/Makefile
++++ micro-httpd-20140814/Makefile
 @@ -3,7 +3,7 @@ MANDIR =	/usr/local/man/man8
  CC =		cc
  CFLAGS =	-O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long
@@ -23,6 +23,3 @@ index 090cadc..2faa776 100644
  
  all:		micro_httpd
  
--- 
-1.6.5
-
diff --git a/micro_httpd.c b/micro_httpd.c
index ca6abb4..5e4b34e 100644
--- a/micro_httpd.c
+++ b/micro_httpd.c
@@ -244,6 +244,8 @@ get_mime_type( char* name )
 	return "audio/wav";
     if ( strcmp( dot, ".avi" ) == 0 )
 	return "video/x-msvideo";
+    if ( strcmp( dot, ".swf" ) == 0 )
+	return "application/x-shockwave-flash";
     if ( strcmp( dot, ".mov" ) == 0 || strcmp( dot, ".qt" ) == 0 )
 	return "video/quicktime";
     if ( strcmp( dot, ".mpeg" ) == 0 || strcmp( dot, ".mpe" ) == 0 )

Debdiff

File lists identical (after any substitutions)

No differences were encountered between the control files of package micro-httpd

No differences were encountered between the control files of package micro-httpd-dbgsym

Run locally

More details

Full run details