summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-04-20 20:03:32 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-04-20 20:03:32 (GMT)
commite36b8e6c014df07a0973d56d1135c8bdde55aac3 (patch) (side-by-side diff)
tree6e89ce2dd8df9513a5510701519bd35cbda9faf5
parentcebe7290369abc0dfbe8040ef89cca443715ab39 (diff)
downloadfileserv-e36b8e6c014df07a0973d56d1135c8bdde55aac3.tar.gz
fileserv-e36b8e6c014df07a0973d56d1135c8bdde55aac3.tar.bz2
Restore the -a, -u, and -g options.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/fileserv.828
-rw-r--r--src/fileserv.c33
2 files changed, 54 insertions, 7 deletions
diff --git a/src/fileserv.8 b/src/fileserv.8
index 6014fad..a0204a3 100644
--- a/src/fileserv.8
+++ b/src/fileserv.8
@@ -19,7 +19,10 @@ fileserv \- simple http server for static files
.SH SYNOPSIS
\fBfileserv\fR\
[\fB\-fhsv\fR]\
+ [\fB\-a\fR [\fIIP\fR][\fB:\fIPORT\fR]]\
[\fB\-c\fR \fIFILE\fR]\
+ [\fB\-g\fR \fIGROUP\fR]\
+ [\fB\-u\fR \fIUSER\fR]\
[\fIHOST\fB:\fR]\fIURL\fB:\fIDIR\fR ...
.SH DESCRIPTION
A simple and lightweight HTTP server. It serves static files from one
@@ -45,18 +48,39 @@ Depending on the configuration settings, the directory listing can be
produced.
.SH OPTIONS
.TP
+\fB\-a [\fIIP\fR][\fB:\fIPORT\fR]
+Listen on the given IP address and port. Either \fIIP\fR or \fIPORT\fR (but
+not both) can be omitted. If \fIIP\fR is omitted, the colon must be
+retained.
+.sp
+This option overrides the \fBlisten\fRv configuration setting.
+.TP
\fB\-c \fIFILE\fB
Read configuration from \fIFILE\fR, instead of \fB/etc/fileserv.conf\fR.
.TP
.B \-f
Run in foreground.
.TP
+.BI \-g " GROUP"
+Run with this primary group privileges. \fIGROUP\fR must be either the
+name of a group listed in the user database, or a numeric GID prefixed
+with a plus sign.
+.sp
+This option overrides the \fBgroup\fR configuration setting.
+.TP
+.B \-h
+Display a terse command line summary and exit.
+.TP
.B \-s
Run in single-process mode. In this mode, \fBfileserv\fR does not
start a sentinel process.
.TP
-.B \-h
-Display a terse command line summary and exit.
+.BI \-u " USER"
+Run with this user privileges. \fIUSER\fR must be either the
+name of a user listed in the system user database, or a numeric UID
+prefixed with a plus sign.
+.sp
+This option overrides the \fBuser\fR configuration setting.
.TP
.B \-v
Increase verbosity level. Multiple options accumulate.
diff --git a/src/fileserv.c b/src/fileserv.c
index b760a9a..dbe2eb2 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -90,9 +90,13 @@ usage(void)
{
printf("usage: %s [OPTIONS] [HOST:]URL:DIR...\n", progname);
printf("OPTIONS are:\n\n");
+ printf(" -a [IP]:PORT listen on this IP and PORT\n");
printf(" -c FILE read configuration from FILE\n");
printf(" -f remain in the foreground\n");
+ printf(" -g GROUP run with this group privileges\n");
printf(" -h show this help summary\n");
+ printf(" -s don't start sentinel process\n");
+ printf(" -u USER run with this user privileges\n");
printf(" -v increase verbosity\n");
}
@@ -767,7 +771,10 @@ main(int argc, char **argv)
struct sockaddr *server_addr;
int foreground = 0;
int single_process = 0;
-
+ char *opt_address = NULL;
+ char *opt_user = NULL;
+ char *opt_group = NULL;
+
progname = basename(argv[0]);
mimetypes_error_printer = fileserv_error_printer;
@@ -775,20 +782,29 @@ main(int argc, char **argv)
if (!tmpdir)
tmpdir = "/tmp";
- while ((c = getopt(argc, argv, "c:fshv")) != EOF) {
+ while ((c = getopt(argc, argv, "a:c:fg:hsu:v")) != EOF) {
switch (c) {
+ case 'a':
+ opt_address = optarg;
+ break;
case 'c':
config_file = optarg;
break;
case 'f':
foreground = 1;
break;
- case 's':
- single_process = 1;
+ case 'g':
+ opt_group = optarg;
break;
case 'h':
usage();
exit(0);
+ case 's':
+ single_process = 1;
+ break;
+ case 'u':
+ opt_user = optarg;
+ break;
case 'v':
verbose++;
break;
@@ -799,10 +815,17 @@ main(int argc, char **argv)
readconfig();
+ if (opt_address)
+ address = xstrdup(opt_address);
+ if (opt_user)
+ user = xstrdup(opt_user);
+ if (opt_group)
+ group = xstrdup(opt_group);
+
pidfile_check();
if (mime_types_file) {
- mimetypes_parse (mime_types_file); //FIXME: diag
+ mimetypes_parse(mime_types_file); //FIXME: diag
}
fd = open_listener(address, &server_addr);

Return to:

Send suggestions and report system problems to the System administrator.