summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-04-21 20:39:57 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-04-21 20:39:57 +0300
commit38e7700cc2472aa66591f255915bc85e5351cb7d (patch)
treef0ebeda6461526a7439e14711d18afecfb8933be
parent265d2886f8012e84860bbe66f299073ebefe7553 (diff)
downloadfileserv-38e7700cc2472aa66591f255915bc85e5351cb7d.tar.gz
fileserv-38e7700cc2472aa66591f255915bc85e5351cb7d.tar.bz2
Minor changes
* src/Makefile.am: Install fileserv to sbin. * src/fileserv.8: Update. * src/fileserv.c: New option -V
-rw-r--r--src/Makefile.am2
-rw-r--r--src/fileserv.85
-rw-r--r--src/fileserv.c57
3 files changed, 44 insertions, 20 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d871c86..e943d6c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
1bin_PROGRAMS=fileserv 1sbin_PROGRAMS=fileserv
2fileserv_SOURCES=fileserv.c runas.c fileserv.h logger.c pidfile.c\ 2fileserv_SOURCES=fileserv.c runas.c fileserv.h logger.c pidfile.c\
3 wordsplit.c wordsplit.h catfile.c config.c idx.c defidx.h\ 3 wordsplit.c wordsplit.h catfile.c config.c idx.c defidx.h\
4 mem.c remoteip.c icon.c dirls.c dirls.h lang.c httperr.c 4 mem.c remoteip.c icon.c dirls.c dirls.h lang.c httperr.c
diff --git a/src/fileserv.8 b/src/fileserv.8
index a0204a3..11129f0 100644
--- a/src/fileserv.8
+++ b/src/fileserv.8
@@ -13,7 +13,7 @@
13.\" 13.\"
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
15.\" along with fileserv. If not, see <http://www.gnu.org/licenses/>. 15.\" along with fileserv. If not, see <http://www.gnu.org/licenses/>.
16.TH FILESERV 8 "April 20, 2018" "FILESERV" "User Commands" 16.TH FILESERV 8 "April 21, 2018" "FILESERV" "User Commands"
17.SH NAME 17.SH NAME
18fileserv \- simple http server for static files 18fileserv \- simple http server for static files
19.SH SYNOPSIS 19.SH SYNOPSIS
@@ -84,6 +84,9 @@ This option overrides the \fBuser\fR configuration setting.
84.TP 84.TP
85.B \-v 85.B \-v
86Increase verbosity level. Multiple options accumulate. 86Increase verbosity level. Multiple options accumulate.
87.TP
88.B \-V
89Show program version, license and copyright information.
87.SH CONFIGURATION FILE 90.SH CONFIGURATION FILE
88The server reads most of its settings from the configuration file 91The server reads most of its settings from the configuration file
89\fB/etc/fileserv.conf\fR (the default location can be overridden using 92\fB/etc/fileserv.conf\fR (the default location can be overridden using
diff --git a/src/fileserv.c b/src/fileserv.c
index fb9811d..58262c3 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -35,7 +35,7 @@
35#endif 35#endif
36 36
37char const *progname; 37char const *progname;
38int verbose; /* reserved for future use */ 38int verbose; /* increase diagnostic verbosity */
39char *address = DEFAULT_ADDRESS; 39char *address = DEFAULT_ADDRESS;
40char *forwarded_header = "X-Forwarded-For"; 40char *forwarded_header = "X-Forwarded-For";
41char *index_css; 41char *index_css;
@@ -43,7 +43,40 @@ char *tmpdir;
43char *user; 43char *user;
44char *group; 44char *group;
45char *mime_types_file; 45char *mime_types_file;
46
47void
48usage(void)
49{
50 printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname);
51 printf("Simple HTTP server.\n");
52 printf("OPTIONS are:\n\n");
53 printf(" -a [IP]:PORT listen on this IP and PORT\n");
54 printf(" -c FILE read configuration from FILE\n");
55 printf(" -f remain in the foreground\n");
56 printf(" -g GROUP run with this group privileges\n");
57 printf(" -h show this help summary\n");
58 printf(" -s don't start sentinel process\n");
59 printf(" -u USER run with this user privileges\n");
60 printf(" -v increase verbosity\n");
61 printf(" -V show program version\n");
62 printf("\n");
63}
46 64
65const char version_copyright[] = "Copyright (C) 2017-2018 Sergey Poznyakoff";
66const char gplv3[] = "\
67License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
68This is free software: you are free to change and redistribute it.\n\
69There is NO WARRANTY, to the extent permitted by law.\
70";
71
72static void
73show_version(void)
74{
75 printf("%s\n", PACKAGE_STRING);
76 printf("%s\n", version_copyright);
77 printf("\n%s\n\n", gplv3);
78}
79
47static void 80static void
48fileserv_panic(void *cls, const char *file, unsigned int line, 81fileserv_panic(void *cls, const char *file, unsigned int line,
49 const char *reason) 82 const char *reason)
@@ -84,22 +117,7 @@ errno_to_http_code(int ec)
84 return MHD_HTTP_FORBIDDEN; 117 return MHD_HTTP_FORBIDDEN;
85 } 118 }
86} 119}
87 120
88void
89usage(void)
90{
91 printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname);
92 printf("OPTIONS are:\n\n");
93 printf(" -a [IP]:PORT listen on this IP and PORT\n");
94 printf(" -c FILE read configuration from FILE\n");
95 printf(" -f remain in the foreground\n");
96 printf(" -g GROUP run with this group privileges\n");
97 printf(" -h show this help summary\n");
98 printf(" -s don't start sentinel process\n");
99 printf(" -u USER run with this user privileges\n");
100 printf(" -v increase verbosity\n");
101}
102
103int 121int
104open_node(char const *node, char const *serv, struct sockaddr **saddr) 122open_node(char const *node, char const *serv, struct sockaddr **saddr)
105{ 123{
@@ -781,7 +799,7 @@ main(int argc, char **argv)
781 if (!tmpdir) 799 if (!tmpdir)
782 tmpdir = "/tmp"; 800 tmpdir = "/tmp";
783 801
784 while ((c = getopt(argc, argv, "a:c:fg:hsu:v")) != EOF) { 802 while ((c = getopt(argc, argv, "a:c:fg:hsu:vV")) != EOF) {
785 switch (c) { 803 switch (c) {
786 case 'a': 804 case 'a':
787 opt_address = optarg; 805 opt_address = optarg;
@@ -807,6 +825,9 @@ main(int argc, char **argv)
807 case 'v': 825 case 'v':
808 verbose++; 826 verbose++;
809 break; 827 break;
828 case 'V':
829 show_version();
830 exit(0);
810 default: 831 default:
811 exit(1); 832 exit(1);
812 } 833 }

Return to:

Send suggestions and report system problems to the System administrator.