vhost: allow adding vhosts after server init
authorBablooos <beetle@gambler.ru>
Tue, 29 Nov 2016 23:05:13 +0000 (07:05 +0800)
committerAndy Green <andy@warmcat.com>
Fri, 16 Dec 2016 14:08:13 +0000 (22:08 +0800)
commit6e436dca390216c11b6d9860f83aee69a85643b4
tree5876a8de77a7d55ec38b17baefa4707956950c1e
parentfded366ea0fd4180ae55825fd9d8cac02f8fef40
vhost: allow adding vhosts after server init

This should allow adding vhosts "late", ie, after the server is up and
running with its initial vhost(s).  The necessary housekeeping is folded
into lws_create_vhost() itself so it should be transparent.

Notice though that at the point the server starts to do service after it
starts initially, if it was requested that the UID / GID change, that
is performed at that point and is not reversible.

So vhosts added "late" find themselves running under the unprivileged
UID / GID from the very start, whereas vhosts added "early" initially
run under the UID / GID the process started with.  If protocols the
vhost uses want to, eg, open privileged files at init and then use
them unprivileged, that will fail if the vhost is added late because
the initial privs are already gone.

AG: also deal with lws_protocol_init() on late vhost init (does the
callbacks for per vh protocol creation), add comments
lib/context.c
lib/libuv.c
lib/private-libwebsockets.h
lib/server.c