mirror of
https://github.com/openvswitch/ovs
synced 2025-10-15 14:17:18 +00:00
lib/daemon: support --user option for all OVS daemon
OVS daemons can now support --user option to run as a non-root user with less privileges. See the manpage patch for more descriptions. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
33
lib/daemon.h
33
lib/daemon.h
@@ -42,14 +42,16 @@
|
||||
OPT_NO_CHDIR, \
|
||||
OPT_OVERWRITE_PIDFILE, \
|
||||
OPT_PIDFILE, \
|
||||
OPT_MONITOR
|
||||
OPT_MONITOR, \
|
||||
OPT_USER_GROUP
|
||||
|
||||
#define DAEMON_LONG_OPTIONS \
|
||||
{"detach", no_argument, NULL, OPT_DETACH}, \
|
||||
{"no-chdir", no_argument, NULL, OPT_NO_CHDIR}, \
|
||||
{"pidfile", optional_argument, NULL, OPT_PIDFILE}, \
|
||||
#define DAEMON_LONG_OPTIONS \
|
||||
{"detach", no_argument, NULL, OPT_DETACH}, \
|
||||
{"no-chdir", no_argument, NULL, OPT_NO_CHDIR}, \
|
||||
{"pidfile", optional_argument, NULL, OPT_PIDFILE}, \
|
||||
{"overwrite-pidfile", no_argument, NULL, OPT_OVERWRITE_PIDFILE}, \
|
||||
{"monitor", no_argument, NULL, OPT_MONITOR}
|
||||
{"monitor", no_argument, NULL, OPT_MONITOR}, \
|
||||
{"user", required_argument, NULL, OPT_USER_GROUP}
|
||||
|
||||
#define DAEMON_OPTION_HANDLERS \
|
||||
case OPT_DETACH: \
|
||||
@@ -70,6 +72,10 @@
|
||||
\
|
||||
case OPT_MONITOR: \
|
||||
daemon_set_monitor(); \
|
||||
break; \
|
||||
\
|
||||
case OPT_USER_GROUP: \
|
||||
daemon_set_new_user(optarg); \
|
||||
break;
|
||||
|
||||
void set_detach(void);
|
||||
@@ -84,7 +90,8 @@ pid_t read_pidfile(const char *name);
|
||||
OPT_PIDFILE, \
|
||||
OPT_PIPE_HANDLE, \
|
||||
OPT_SERVICE, \
|
||||
OPT_SERVICE_MONITOR
|
||||
OPT_SERVICE_MONITOR \
|
||||
OPT_USER_GROUP \
|
||||
|
||||
#define DAEMON_LONG_OPTIONS \
|
||||
{"detach", no_argument, NULL, OPT_DETACH}, \
|
||||
@@ -92,7 +99,8 @@ pid_t read_pidfile(const char *name);
|
||||
{"pidfile", optional_argument, NULL, OPT_PIDFILE}, \
|
||||
{"pipe-handle", required_argument, NULL, OPT_PIPE_HANDLE}, \
|
||||
{"service", no_argument, NULL, OPT_SERVICE}, \
|
||||
{"service-monitor", no_argument, NULL, OPT_SERVICE_MONITOR}
|
||||
{"service-monitor", no_argument, NULL, OPT_SERVICE_MONITOR} \
|
||||
{"user", required_argument, NULL, OPT_USER_GROUP}
|
||||
|
||||
#define DAEMON_OPTION_HANDLERS \
|
||||
case OPT_DETACH: \
|
||||
@@ -113,7 +121,10 @@ pid_t read_pidfile(const char *name);
|
||||
break; \
|
||||
\
|
||||
case OPT_SERVICE_MONITOR: \
|
||||
break;
|
||||
break; \
|
||||
\
|
||||
case OPT_USER_GROUP: \
|
||||
daemon_set_new_user(optarg); \
|
||||
|
||||
void control_handler(DWORD request);
|
||||
void set_pipe_handle(const char *pipe_handle);
|
||||
@@ -122,8 +133,10 @@ void set_pipe_handle(const char *pipe_handle);
|
||||
bool get_detach(void);
|
||||
void daemon_save_fd(int fd);
|
||||
void daemonize(void);
|
||||
void daemonize_start(void);
|
||||
void daemonize_start(bool access_datapath);
|
||||
void daemonize_complete(void);
|
||||
void daemon_set_new_user(const char * user_spec);
|
||||
void daemon_become_new_user(bool access_datapath);
|
||||
void daemon_usage(void);
|
||||
void service_start(int *argcp, char **argvp[]);
|
||||
void service_stop(void);
|
||||
|
Reference in New Issue
Block a user