diff options
| author | Robert Mustacchi <rm@joyent.com> | 2015-06-02 17:12:04 +0000 |
|---|---|---|
| committer | Robert Mustacchi <rm@joyent.com> | 2015-06-03 21:27:23 +0000 |
| commit | 1fda1f6b6719377f14028786198a066b33bbc60b (patch) | |
| tree | 20e3d8100386598c46f916f9cb2d54ce1827f1cf /usr/src/cmd/varpd | |
| parent | eeaafcb1f11a17ed049a53804c911d362a06ee5a (diff) | |
| download | illumos-joyent-1fda1f6b6719377f14028786198a066b33bbc60b.tar.gz | |
OS-4370 varpd should support getting an include path from SMF
OS-4203 varpd stayed in carbonite after signal delivery
OS-4373 varpd plugins should not link against libvarpd
OS-4374 libc mutexes break kernel writers hearts
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Diffstat (limited to 'usr/src/cmd/varpd')
| -rw-r--r-- | usr/src/cmd/varpd/Makefile | 2 | ||||
| -rw-r--r-- | usr/src/cmd/varpd/svc-varpd | 5 | ||||
| -rw-r--r-- | usr/src/cmd/varpd/varpd.c | 51 | ||||
| -rw-r--r-- | usr/src/cmd/varpd/varpd.xml | 8 |
4 files changed, 58 insertions, 8 deletions
diff --git a/usr/src/cmd/varpd/Makefile b/usr/src/cmd/varpd/Makefile index cff0f49f9d..215f23d29e 100644 --- a/usr/src/cmd/varpd/Makefile +++ b/usr/src/cmd/varpd/Makefile @@ -30,7 +30,7 @@ ROOTMANIFESTDIR= $(ROOTSVCNETWORK) CLEANFILES += $(OBJS) CPPFLAGS += -D_REENTRANT CFLAGS += $(CCVERBOSE) -LDLIBS += -lvarpd -lumem +LDLIBS += -lvarpd -lumem -lscf $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG # diff --git a/usr/src/cmd/varpd/svc-varpd b/usr/src/cmd/varpd/svc-varpd index ace611c8de..c7483a033e 100644 --- a/usr/src/cmd/varpd/svc-varpd +++ b/usr/src/cmd/varpd/svc-varpd @@ -24,10 +24,7 @@ # add_drv overlay 2>/dev/null -# -# This should be a service property. -# -/usr/lib/varpd/varpd -i /usr/lib/varpd +/usr/lib/varpd/varpd if [ $? = 0 ]; then exit $SMF_EXIT_OK else diff --git a/usr/src/cmd/varpd/varpd.c b/usr/src/cmd/varpd/varpd.c index fd1dfaa5c8..8131604537 100644 --- a/usr/src/cmd/varpd/varpd.c +++ b/usr/src/cmd/varpd/varpd.c @@ -58,6 +58,7 @@ #include <unistd.h> #include <thread.h> #include <priv.h> +#include <libscf.h> #define VARPD_EXIT_REQUESTED 0 #define VARPD_EXIT_FATAL 1 @@ -66,6 +67,9 @@ #define VARPD_RUNDIR "/var/run/varpd" #define VARPD_DEFAULT_DOOR "/var/run/varpd/varpd.door" +#define VARPD_PG "varpd" +#define VARPD_PROP_INC "include_path" + static varpd_handle_t *varpd_handle; static const char *varpd_pname; static volatile boolean_t varpd_exit = B_FALSE; @@ -328,6 +332,38 @@ varpd_cleanup(void) } /* + * Load default information from SMF and apply any of if necessary. We recognize + * the following properties: + * + * varpd/include_path Treat these as a series of -i options. + * + * If we're not under SMF, just move on. + */ +static void +varpd_load_smf(int dfd) +{ + char *fmri, *inc; + scf_simple_prop_t *prop; + + if ((fmri = getenv("SMF_FMRI")) == NULL) + return; + + if ((prop = scf_simple_prop_get(NULL, fmri, VARPD_PG, + VARPD_PROP_INC)) == NULL) + return; + + while ((inc = scf_simple_prop_next_astring(prop)) != NULL) { + int err = libvarpd_plugin_load(varpd_handle, inc); + if (err != 0) { + varpd_dfatal(dfd, "failed to load from %s: %s\n", + inc, strerror(err)); + } + } + + scf_simple_prop_free(prop); +} + +/* * There are a bunch of things we need to do to be a proper daemon here. * * o Ensure that /var/run/varpd exists or create it @@ -408,12 +444,13 @@ main(int argc, char *argv[]) for (i = 0; i < nextincpath; i++) { err = libvarpd_plugin_load(varpd_handle, incpath[i]); if (err != 0) { - (void) fprintf(stderr, "failed to load from %s: %s\n", - optarg, strerror(err)); - return (1); + varpd_dfatal(dfd, "failed to load from %s: %s\n", + incpath[i], strerror(err)); } } + varpd_load_smf(dfd); + if ((err = libvarpd_persist_enable(varpd_handle, VARPD_RUNDIR)) != 0) varpd_dfatal(dfd, "failed to enable varpd persistence: %s\n", strerror(err)); @@ -455,12 +492,20 @@ main(int argc, char *argv[]) act.sa_flags = 0; if (sigaction(SIGHUP, &act, NULL) != 0) varpd_dfatal(dfd, "failed to register HUP handler"); + if (sigdelset(&set, SIGHUP) != 0) + varpd_dfatal(dfd, "failed to remove HUP from mask"); if (sigaction(SIGQUIT, &act, NULL) != 0) varpd_dfatal(dfd, "failed to register QUIT handler"); + if (sigdelset(&set, SIGQUIT) != 0) + varpd_dfatal(dfd, "failed to remove QUIT from mask"); if (sigaction(SIGINT, &act, NULL) != 0) varpd_dfatal(dfd, "failed to register INT handler"); + if (sigdelset(&set, SIGINT) != 0) + varpd_dfatal(dfd, "failed to remove INT from mask"); if (sigaction(SIGTERM, &act, NULL) != 0) varpd_dfatal(dfd, "failed to register TERM handler"); + if (sigdelset(&set, SIGTERM) != 0) + varpd_dfatal(dfd, "failed to remove TERM from mask"); err = 0; (void) write(dfd, &err, sizeof (err)); diff --git a/usr/src/cmd/varpd/varpd.xml b/usr/src/cmd/varpd/varpd.xml index 7b01ab7253..8ea855b438 100644 --- a/usr/src/cmd/varpd/varpd.xml +++ b/usr/src/cmd/varpd/varpd.xml @@ -40,6 +40,14 @@ Copyright 2015, Joyent, Inc. exec=":kill" timeout_seconds="10" /> + <property_group name='varpd' type='application'> + <property name='include_path' type='astring'> + <astring_list> + <value_node value='/usr/lib/varpd'/> + </astring_list> + </property> + </property_group> + <stability value='Unstable' /> <template> |
