authorSergey Poznyakoff <>2018-04-20 20:03:32 (GMT)
committer Sergey Poznyakoff <>2018-04-20 20:03:32 (GMT)
commite36b8e6c014df07a0973d56d1135c8bdde55aac3 (patch) (side-by-side diff)
parentcebe7290369abc0dfbe8040ef89cca443715ab39 (diff)
Restore the -a, -u, and -g options.
Diffstat (more/less context) (ignore whitespace changes)
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
+ [\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 ...
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
+\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
+This option overrides the \fBlisten\fRv configuration setting.
\fB\-c \fIFILE\fB
Read configuration from \fIFILE\fR, instead of \fB/etc/fileserv.conf\fR.
.B \-f
Run in foreground.
+.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.
+This option overrides the \fBgroup\fR configuration setting.
+.B \-h
+Display a terse command line summary and exit.
.B \-s
Run in single-process mode. In this mode, \fBfileserv\fR does not
start a sentinel process.
-.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.
+This option overrides the \fBuser\fR configuration setting.
.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;
case 'f':
foreground = 1;
- case 's':
- single_process = 1;
+ case 'g':
+ opt_group = optarg;
case 'h':
+ case 's':
+ single_process = 1;
+ break;
+ case 'u':
+ opt_user = optarg;
+ break;
case 'v':
@@ -799,10 +815,17 @@ main(int argc, char **argv)
+ if (opt_address)
+ address = xstrdup(opt_address);
+ if (opt_user)
+ user = xstrdup(opt_user);
+ if (opt_group)
+ group = xstrdup(opt_group);
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.