mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
Refer to ZED's scripts as ZEDLETs
The executables invoked by the ZED in response to a given zevent have been generically referred to as "scripts". By convention, these scripts have aimed to be /bin/sh compatible for reasons of portability and comprehensibility. However, the ZED only requires they be executable and (ideally) capable of reading environment variables. As such, these scripts are now referred to as ZEDLETs (ZFS Event Daemon Linkage for Executable Tasks). Signed-off-by: Chris Dunlap <cdunlap@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #2735
This commit is contained in:
parent
8cb8cf91df
commit
dcca723ace
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Log all environment variables to ZED_DEBUG_LOG.
|
# Log all environment variables to ZED_DEBUG_LOG.
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
# Override the default umask to restrict access to a newly-created logfile.
|
# Override the default umask to restrict access to a newly-created logfile.
|
||||||
umask 077
|
umask 077
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Log the zevent via syslog.
|
# Log the zevent via syslog.
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
logger -t "${ZED_SYSLOG_TAG:=zed}" -p "${ZED_SYSLOG_PRIORITY:=daemon.notice}" \
|
logger -t "${ZED_SYSLOG_TAG:=zed}" -p "${ZED_SYSLOG_PRIORITY:=daemon.notice}" \
|
||||||
eid="${ZEVENT_EID}" class="${ZEVENT_SUBCLASS}" \
|
eid="${ZEVENT_EID}" class="${ZEVENT_SUBCLASS}" \
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# State File Format:
|
# State File Format:
|
||||||
# POOL;TIME_OF_LAST_EMAIL
|
# POOL;TIME_OF_LAST_EMAIL
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
test -n "${ZEVENT_POOL}" || exit 5
|
test -n "${ZEVENT_POOL}" || exit 5
|
||||||
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# 2: email suppressed
|
# 2: email suppressed
|
||||||
# 3: missing executable
|
# 3: missing executable
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
# Only send email if ZED_EMAIL has been configured.
|
# Only send email if ZED_EMAIL has been configured.
|
||||||
test -n "${ZED_EMAIL}" || exit 2
|
test -n "${ZED_EMAIL}" || exit 2
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# State File Format:
|
# State File Format:
|
||||||
# POOL;VDEV_PATH;TIME_OF_LAST_EMAIL
|
# POOL;VDEV_PATH;TIME_OF_LAST_EMAIL
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
test -n "${ZEVENT_POOL}" || exit 5
|
test -n "${ZEVENT_POOL}" || exit 5
|
||||||
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
# 4: unsupported event class
|
# 4: unsupported event class
|
||||||
# 5: internal error
|
# 5: internal error
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
test -n "${ZEVENT_POOL}" || exit 5
|
test -n "${ZEVENT_POOL}" || exit 5
|
||||||
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# 4: unsupported event class
|
# 4: unsupported event class
|
||||||
# 5: internal error
|
# 5: internal error
|
||||||
#
|
#
|
||||||
test -f "${ZED_SCRIPT_DIR}/zed.rc" && . "${ZED_SCRIPT_DIR}/zed.rc"
|
test -f "${ZED_ZEDLET_DIR}/zed.rc" && . "${ZED_ZEDLET_DIR}/zed.rc"
|
||||||
|
|
||||||
test -n "${ZEVENT_POOL}" || exit 5
|
test -n "${ZEVENT_POOL}" || exit 5
|
||||||
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
test -n "${ZEVENT_SUBCLASS}" || exit 5
|
||||||
|
@ -43,9 +43,9 @@
|
|||||||
#define ZED_STATE_FILE RUNSTATEDIR "/zed.state"
|
#define ZED_STATE_FILE RUNSTATEDIR "/zed.state"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Absolute path for the default zed script directory.
|
* Absolute path for the default zed zedlet directory.
|
||||||
*/
|
*/
|
||||||
#define ZED_SCRIPT_DIR SYSCONFDIR "/zfs/zed.d"
|
#define ZED_ZEDLET_DIR SYSCONFDIR "/zfs/zed.d"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reserved for future use.
|
* Reserved for future use.
|
||||||
|
@ -58,7 +58,7 @@ zed_conf_create(void)
|
|||||||
zcp->syslog_facility = LOG_DAEMON;
|
zcp->syslog_facility = LOG_DAEMON;
|
||||||
zcp->min_events = ZED_MIN_EVENTS;
|
zcp->min_events = ZED_MIN_EVENTS;
|
||||||
zcp->max_events = ZED_MAX_EVENTS;
|
zcp->max_events = ZED_MAX_EVENTS;
|
||||||
zcp->scripts = NULL; /* created via zed_conf_scan_dir() */
|
zcp->zedlets = NULL; /* created via zed_conf_scan_dir() */
|
||||||
zcp->state_fd = -1; /* opened via zed_conf_open_state() */
|
zcp->state_fd = -1; /* opened via zed_conf_open_state() */
|
||||||
zcp->zfs_hdl = NULL; /* opened via zed_event_init() */
|
zcp->zfs_hdl = NULL; /* opened via zed_event_init() */
|
||||||
zcp->zevent_fd = -1; /* opened via zed_event_init() */
|
zcp->zevent_fd = -1; /* opened via zed_event_init() */
|
||||||
@ -69,7 +69,7 @@ zed_conf_create(void)
|
|||||||
if (!(zcp->pid_file = strdup(ZED_PID_FILE)))
|
if (!(zcp->pid_file = strdup(ZED_PID_FILE)))
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
|
||||||
if (!(zcp->script_dir = strdup(ZED_SCRIPT_DIR)))
|
if (!(zcp->zedlet_dir = strdup(ZED_ZEDLET_DIR)))
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
|
||||||
if (!(zcp->state_file = strdup(ZED_STATE_FILE)))
|
if (!(zcp->state_file = strdup(ZED_STATE_FILE)))
|
||||||
@ -111,14 +111,14 @@ zed_conf_destroy(struct zed_conf *zcp)
|
|||||||
if (zcp->pid_file)
|
if (zcp->pid_file)
|
||||||
free(zcp->pid_file);
|
free(zcp->pid_file);
|
||||||
|
|
||||||
if (zcp->script_dir)
|
if (zcp->zedlet_dir)
|
||||||
free(zcp->script_dir);
|
free(zcp->zedlet_dir);
|
||||||
|
|
||||||
if (zcp->state_file)
|
if (zcp->state_file)
|
||||||
free(zcp->state_file);
|
free(zcp->state_file);
|
||||||
|
|
||||||
if (zcp->scripts)
|
if (zcp->zedlets)
|
||||||
zed_strings_destroy(zcp->scripts);
|
zed_strings_destroy(zcp->zedlets);
|
||||||
|
|
||||||
free(zcp);
|
free(zcp);
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ _zed_conf_display_help(const char *prog, int got_err)
|
|||||||
"Read configuration from FILE.", ZED_CONF_FILE);
|
"Read configuration from FILE.", ZED_CONF_FILE);
|
||||||
#endif
|
#endif
|
||||||
fprintf(fp, "%*c%*s %s [%s]\n", w1, 0x20, -w2, "-d DIR",
|
fprintf(fp, "%*c%*s %s [%s]\n", w1, 0x20, -w2, "-d DIR",
|
||||||
"Read enabled scripts from DIR.", ZED_SCRIPT_DIR);
|
"Read enabled ZEDLETs from DIR.", ZED_ZEDLET_DIR);
|
||||||
fprintf(fp, "%*c%*s %s [%s]\n", w1, 0x20, -w2, "-p FILE",
|
fprintf(fp, "%*c%*s %s [%s]\n", w1, 0x20, -w2, "-p FILE",
|
||||||
"Write daemon's PID to FILE.", ZED_PID_FILE);
|
"Write daemon's PID to FILE.", ZED_PID_FILE);
|
||||||
fprintf(fp, "%*c%*s %s [%s]\n", w1, 0x20, -w2, "-s FILE",
|
fprintf(fp, "%*c%*s %s [%s]\n", w1, 0x20, -w2, "-s FILE",
|
||||||
@ -269,7 +269,7 @@ zed_conf_parse_opts(struct zed_conf *zcp, int argc, char **argv)
|
|||||||
_zed_conf_parse_path(&zcp->conf_file, optarg);
|
_zed_conf_parse_path(&zcp->conf_file, optarg);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
_zed_conf_parse_path(&zcp->script_dir, optarg);
|
_zed_conf_parse_path(&zcp->zedlet_dir, optarg);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
_zed_conf_parse_path(&zcp->pid_file, optarg);
|
_zed_conf_parse_path(&zcp->pid_file, optarg);
|
||||||
@ -318,19 +318,19 @@ zed_conf_parse_file(struct zed_conf *zcp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan the [zcp] script_dir for files to exec based on the event class.
|
* Scan the [zcp] zedlet_dir for files to exec based on the event class.
|
||||||
* Files must be executable by user, but not writable by group or other.
|
* Files must be executable by user, but not writable by group or other.
|
||||||
* Dotfiles are ignored.
|
* Dotfiles are ignored.
|
||||||
*
|
*
|
||||||
* Return 0 on success with an updated set of scripts,
|
* Return 0 on success with an updated set of zedlets,
|
||||||
* or -1 on error with errno set.
|
* or -1 on error with errno set.
|
||||||
*
|
*
|
||||||
* FIXME: Check if script_dir and all parent dirs are secure.
|
* FIXME: Check if zedlet_dir and all parent dirs are secure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
zed_conf_scan_dir(struct zed_conf *zcp)
|
zed_conf_scan_dir(struct zed_conf *zcp)
|
||||||
{
|
{
|
||||||
zed_strings_t *scripts;
|
zed_strings_t *zedlets;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *direntp;
|
struct dirent *direntp;
|
||||||
char pathname[PATH_MAX];
|
char pathname[PATH_MAX];
|
||||||
@ -339,23 +339,23 @@ zed_conf_scan_dir(struct zed_conf *zcp)
|
|||||||
|
|
||||||
if (!zcp) {
|
if (!zcp) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
zed_log_msg(LOG_ERR, "Failed to scan script dir: %s",
|
zed_log_msg(LOG_ERR, "Failed to scan zedlet dir: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
scripts = zed_strings_create();
|
zedlets = zed_strings_create();
|
||||||
if (!scripts) {
|
if (!zedlets) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
zed_log_msg(LOG_WARNING, "Failed to scan dir \"%s\": %s",
|
zed_log_msg(LOG_WARNING, "Failed to scan dir \"%s\": %s",
|
||||||
zcp->script_dir, strerror(errno));
|
zcp->zedlet_dir, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
dirp = opendir(zcp->script_dir);
|
dirp = opendir(zcp->zedlet_dir);
|
||||||
if (!dirp) {
|
if (!dirp) {
|
||||||
int errno_bak = errno;
|
int errno_bak = errno;
|
||||||
zed_log_msg(LOG_WARNING, "Failed to open dir \"%s\": %s",
|
zed_log_msg(LOG_WARNING, "Failed to open dir \"%s\": %s",
|
||||||
zcp->script_dir, strerror(errno));
|
zcp->zedlet_dir, strerror(errno));
|
||||||
zed_strings_destroy(scripts);
|
zed_strings_destroy(zedlets);
|
||||||
errno = errno_bak;
|
errno = errno_bak;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ zed_conf_scan_dir(struct zed_conf *zcp)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
n = snprintf(pathname, sizeof (pathname),
|
n = snprintf(pathname, sizeof (pathname),
|
||||||
"%s/%s", zcp->script_dir, direntp->d_name);
|
"%s/%s", zcp->zedlet_dir, direntp->d_name);
|
||||||
if ((n < 0) || (n >= sizeof (pathname))) {
|
if ((n < 0) || (n >= sizeof (pathname))) {
|
||||||
zed_log_msg(LOG_WARNING, "Failed to stat \"%s\": %s",
|
zed_log_msg(LOG_WARNING, "Failed to stat \"%s\": %s",
|
||||||
direntp->d_name, strerror(ENAMETOOLONG));
|
direntp->d_name, strerror(ENAMETOOLONG));
|
||||||
@ -405,7 +405,7 @@ zed_conf_scan_dir(struct zed_conf *zcp)
|
|||||||
direntp->d_name);
|
direntp->d_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (zed_strings_add(scripts, direntp->d_name) < 0) {
|
if (zed_strings_add(zedlets, direntp->d_name) < 0) {
|
||||||
zed_log_msg(LOG_WARNING,
|
zed_log_msg(LOG_WARNING,
|
||||||
"Failed to register \"%s\": %s",
|
"Failed to register \"%s\": %s",
|
||||||
direntp->d_name, strerror(errno));
|
direntp->d_name, strerror(errno));
|
||||||
@ -413,20 +413,20 @@ zed_conf_scan_dir(struct zed_conf *zcp)
|
|||||||
}
|
}
|
||||||
if (zcp->do_verbose)
|
if (zcp->do_verbose)
|
||||||
zed_log_msg(LOG_INFO,
|
zed_log_msg(LOG_INFO,
|
||||||
"Registered script \"%s\"", direntp->d_name);
|
"Registered zedlet \"%s\"", direntp->d_name);
|
||||||
}
|
}
|
||||||
if (closedir(dirp) < 0) {
|
if (closedir(dirp) < 0) {
|
||||||
int errno_bak = errno;
|
int errno_bak = errno;
|
||||||
zed_log_msg(LOG_WARNING, "Failed to close dir \"%s\": %s",
|
zed_log_msg(LOG_WARNING, "Failed to close dir \"%s\": %s",
|
||||||
zcp->script_dir, strerror(errno));
|
zcp->zedlet_dir, strerror(errno));
|
||||||
zed_strings_destroy(scripts);
|
zed_strings_destroy(zedlets);
|
||||||
errno = errno_bak;
|
errno = errno_bak;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (zcp->scripts)
|
if (zcp->zedlets)
|
||||||
zed_strings_destroy(zcp->scripts);
|
zed_strings_destroy(zcp->zedlets);
|
||||||
|
|
||||||
zcp->scripts = scripts;
|
zcp->zedlets = zedlets;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ struct zed_conf {
|
|||||||
int max_events; /* RESERVED FOR FUTURE USE */
|
int max_events; /* RESERVED FOR FUTURE USE */
|
||||||
char *conf_file; /* abs path to config file */
|
char *conf_file; /* abs path to config file */
|
||||||
char *pid_file; /* abs path to pid file */
|
char *pid_file; /* abs path to pid file */
|
||||||
char *script_dir; /* abs path to script dir */
|
char *zedlet_dir; /* abs path to zedlet dir */
|
||||||
zed_strings_t *scripts; /* names of enabled scripts */
|
zed_strings_t *zedlets; /* names of enabled zedlets */
|
||||||
char *state_file; /* abs path to state file */
|
char *state_file; /* abs path to state file */
|
||||||
int state_fd; /* fd to state file */
|
int state_fd; /* fd to state file */
|
||||||
libzfs_handle_t *zfs_hdl; /* handle to libzfs */
|
libzfs_handle_t *zfs_hdl; /* handle to libzfs */
|
||||||
|
@ -814,7 +814,7 @@ zed_event_service(struct zed_conf *zcp)
|
|||||||
_zed_event_add_var(eid, zsp, "%s%s=%d",
|
_zed_event_add_var(eid, zsp, "%s%s=%d",
|
||||||
ZED_VAR_PREFIX, "PID", (int) getpid());
|
ZED_VAR_PREFIX, "PID", (int) getpid());
|
||||||
_zed_event_add_var(eid, zsp, "%s%s=%s",
|
_zed_event_add_var(eid, zsp, "%s%s=%s",
|
||||||
ZED_VAR_PREFIX, "SCRIPT_DIR", zcp->script_dir);
|
ZED_VAR_PREFIX, "ZEDLET_DIR", zcp->zedlet_dir);
|
||||||
|
|
||||||
subclass = _zed_event_get_subclass(class);
|
subclass = _zed_event_get_subclass(class);
|
||||||
_zed_event_add_var(eid, zsp, "%s%s=%s",
|
_zed_event_add_var(eid, zsp, "%s%s=%s",
|
||||||
@ -823,7 +823,7 @@ zed_event_service(struct zed_conf *zcp)
|
|||||||
_zed_event_add_time_strings(eid, zsp, etime);
|
_zed_event_add_time_strings(eid, zsp, etime);
|
||||||
|
|
||||||
zed_exec_process(eid, class, subclass,
|
zed_exec_process(eid, class, subclass,
|
||||||
zcp->script_dir, zcp->scripts, zsp, zcp->zevent_fd);
|
zcp->zedlet_dir, zcp->zedlets, zsp, zcp->zevent_fd);
|
||||||
|
|
||||||
zed_conf_write_state(zcp, eid, etime);
|
zed_conf_write_state(zcp, eid, etime);
|
||||||
|
|
||||||
|
@ -156,13 +156,13 @@ restart:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process the event [eid] by synchronously invoking all scripts with a
|
* Process the event [eid] by synchronously invoking all zedlets with a
|
||||||
* matching class prefix.
|
* matching class prefix.
|
||||||
*
|
*
|
||||||
* Each executable in [scripts] from the directory [dir] is matched against
|
* Each executable in [zedlets] from the directory [dir] is matched against
|
||||||
* the event's [class], [subclass], and the "all" class (which matches
|
* the event's [class], [subclass], and the "all" class (which matches
|
||||||
* all events). Every script with a matching class prefix is invoked.
|
* all events). Every zedlet with a matching class prefix is invoked.
|
||||||
* The NAME=VALUE strings in [envs] will be passed to the script as
|
* The NAME=VALUE strings in [envs] will be passed to the zedlet as
|
||||||
* environment variables.
|
* environment variables.
|
||||||
*
|
*
|
||||||
* The file descriptor [zfd] is the zevent_fd used to track the
|
* The file descriptor [zfd] is the zevent_fd used to track the
|
||||||
@ -172,16 +172,16 @@ restart:
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
zed_exec_process(uint64_t eid, const char *class, const char *subclass,
|
zed_exec_process(uint64_t eid, const char *class, const char *subclass,
|
||||||
const char *dir, zed_strings_t *scripts, zed_strings_t *envs, int zfd)
|
const char *dir, zed_strings_t *zedlets, zed_strings_t *envs, int zfd)
|
||||||
{
|
{
|
||||||
const char *class_strings[4];
|
const char *class_strings[4];
|
||||||
const char *allclass = "all";
|
const char *allclass = "all";
|
||||||
const char **csp;
|
const char **csp;
|
||||||
const char *s;
|
const char *z;
|
||||||
char **e;
|
char **e;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (!dir || !scripts || !envs || zfd < 0)
|
if (!dir || !zedlets || !envs || zfd < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
csp = class_strings;
|
csp = class_strings;
|
||||||
@ -199,11 +199,11 @@ zed_exec_process(uint64_t eid, const char *class, const char *subclass,
|
|||||||
|
|
||||||
e = _zed_exec_create_env(envs);
|
e = _zed_exec_create_env(envs);
|
||||||
|
|
||||||
for (s = zed_strings_first(scripts); s; s = zed_strings_next(scripts)) {
|
for (z = zed_strings_first(zedlets); z; z = zed_strings_next(zedlets)) {
|
||||||
for (csp = class_strings; *csp; csp++) {
|
for (csp = class_strings; *csp; csp++) {
|
||||||
n = strlen(*csp);
|
n = strlen(*csp);
|
||||||
if ((strncmp(s, *csp, n) == 0) && !isalpha(s[n]))
|
if ((strncmp(z, *csp, n) == 0) && !isalpha(z[n]))
|
||||||
_zed_exec_fork_child(eid, dir, s, e, zfd);
|
_zed_exec_fork_child(eid, dir, z, e, zfd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(e);
|
free(e);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
int zed_exec_process(uint64_t eid, const char *class, const char *subclass,
|
int zed_exec_process(uint64_t eid, const char *class, const char *subclass,
|
||||||
const char *dir, zed_strings_t *scripts, zed_strings_t *envs,
|
const char *dir, zed_strings_t *zedlets, zed_strings_t *envs,
|
||||||
int zevent_fd);
|
int zevent_fd);
|
||||||
|
|
||||||
#endif /* !ZED_EXEC_H */
|
#endif /* !ZED_EXEC_H */
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
.TH ZED 8 "Octember 1, 2013" "ZFS on Linux" "System Administration Commands"
|
.TH ZED 8 "Octember 1, 2013" "ZFS on Linux" "System Administration Commands"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
zed \- ZFS Event Daemon
|
ZED \- ZFS Event Daemon
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.HP
|
.HP
|
||||||
.B zed
|
.B zed
|
||||||
.\" [\fB\-c\fR \fIconfigfile\fR]
|
.\" [\fB\-c\fR \fIconfigfile\fR]
|
||||||
[\fB\-d\fR \fIscriptdir\fR]
|
[\fB\-d\fR \fIzedletdir\fR]
|
||||||
[\fB\-f\fR]
|
[\fB\-f\fR]
|
||||||
[\fB\-F\fR]
|
[\fB\-F\fR]
|
||||||
[\fB\-h\fR]
|
[\fB\-h\fR]
|
||||||
@ -44,9 +44,10 @@ zed \- ZFS Event Daemon
|
|||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
\fBzed\fR (ZFS Event Daemon) monitors events generated by the ZFS kernel
|
\fBZED\fR (ZFS Event Daemon) monitors events generated by the ZFS kernel
|
||||||
module. When a ZFS event (zevent) is posted, \fBzed\fR will run any scripts
|
module. When a zevent (ZFS Event) is posted, \fBZED\fR will run any ZEDLETs
|
||||||
that have been enabled for the corresponding zevent class.
|
(ZFS Event Daemon Linkage for Executable Tasks) that have been enabled for the
|
||||||
|
corresponding zevent class.
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
@ -81,8 +82,8 @@ to be reprocessed.
|
|||||||
.\" .BI \-c\ configfile
|
.\" .BI \-c\ configfile
|
||||||
.\" Read the configuration from the specified file.
|
.\" Read the configuration from the specified file.
|
||||||
.TP
|
.TP
|
||||||
.BI \-d\ scriptdir
|
.BI \-d\ zedletdir
|
||||||
Read the enabled scripts from the specified directory.
|
Read the enabled ZEDLETs from the specified directory.
|
||||||
.TP
|
.TP
|
||||||
.BI \-p\ pidfile
|
.BI \-p\ pidfile
|
||||||
Write the daemon's process ID to the specified file.
|
Write the daemon's process ID to the specified file.
|
||||||
@ -92,7 +93,7 @@ Write the daemon's state to the specified file.
|
|||||||
|
|
||||||
.SH ZEVENTS
|
.SH ZEVENTS
|
||||||
.PP
|
.PP
|
||||||
A zevent is comprised of a list of name/value pairs (nvpairs). Each zevent
|
A zevent is comprised of a list of nvpairs (name/value pairs). Each zevent
|
||||||
contains an EID (Event IDentifier) that uniquely identifies it throughout
|
contains an EID (Event IDentifier) that uniquely identifies it throughout
|
||||||
the lifetime of the loaded ZFS kernel module; this EID is a monotonically
|
the lifetime of the loaded ZFS kernel module; this EID is a monotonically
|
||||||
increasing integer that resets to 1 each time the kernel module is loaded.
|
increasing integer that resets to 1 each time the kernel module is loaded.
|
||||||
@ -105,29 +106,29 @@ their associated lists of nvpairs) using the "\fBzpool events \-v\fR" command.
|
|||||||
|
|
||||||
.SH CONFIGURATION
|
.SH CONFIGURATION
|
||||||
.PP
|
.PP
|
||||||
The scripts to be invoked in response to zevents are located in the
|
ZEDLETs to be invoked in response to zevents are located in the
|
||||||
enabled-scripts directory. These can be symlinked or copied from the
|
\fIenabled-zedlets\fR directory. These can be symlinked or copied from the
|
||||||
installed-scripts directory; symlinks allow for automatic updates from the
|
\fIinstalled-zedlets\fR directory; symlinks allow for automatic updates
|
||||||
installed scripts, whereas copies preserve local modifications. As a security
|
from the installed ZEDLETs, whereas copies preserve local modifications.
|
||||||
measure, scripts must be owned by root. They must have execute permissions
|
As a security measure, ZEDLETs must be owned by root. They must have
|
||||||
for the user, but they must not have write permissions for group or other.
|
execute permissions for the user, but they must not have write permissions
|
||||||
Dotfiles are ignored.
|
for group or other. Dotfiles are ignored.
|
||||||
.PP
|
.PP
|
||||||
Scripts are named after the zevent class for which they should be invoked.
|
ZEDLETs are named after the zevent class for which they should be invoked.
|
||||||
In particular, a script will be invoked for a given zevent if either its
|
In particular, a ZEDLET will be invoked for a given zevent if either its
|
||||||
class or subclass string is a prefix of its filename (and is followed by
|
class or subclass string is a prefix of its filename (and is followed by
|
||||||
a non-alphabetic character). As a special case, the prefix "all" matches
|
a non-alphabetic character). As a special case, the prefix "all" matches
|
||||||
all zevents. Multiple scripts may be invoked for a given zevent.
|
all zevents. Multiple ZEDLETs may be invoked for a given zevent.
|
||||||
|
|
||||||
.SH SCRIPTS
|
.SH ZEDLETS
|
||||||
.PP
|
.PP
|
||||||
Scripts should be written under the presumption they can be invoked
|
ZEDLETs are executables invoked by the ZED in response to a given zevent.
|
||||||
concurrently, and they should use appropriate locking to access any shared
|
They should be written under the presumption they can be invoked concurrently,
|
||||||
resources. Common variables used by the scripts can be stored in the default
|
and they should use appropriate locking to access any shared resources.
|
||||||
rc file which is sourced by the scripts; these variables should be prefixed
|
Common variables used by ZEDLETs can be stored in the default rc file which
|
||||||
with "ZED_".
|
is sourced by scripts; these variables should be prefixed with "ZED_".
|
||||||
.PP
|
.PP
|
||||||
The zevent nvpairs are passed to the scripts as environment variables.
|
The zevent nvpairs are passed to ZEDLETs as environment variables.
|
||||||
Each nvpair name is converted to an environment variable in the following
|
Each nvpair name is converted to an environment variable in the following
|
||||||
manner: 1) it is prefixed with "ZEVENT_", 2) it is converted to uppercase,
|
manner: 1) it is prefixed with "ZEVENT_", 2) it is converted to uppercase,
|
||||||
and 3) each non-alphanumeric character is converted to an underscore.
|
and 3) each non-alphanumeric character is converted to an underscore.
|
||||||
@ -171,12 +172,12 @@ ZED_PID
|
|||||||
The daemon's process ID.
|
The daemon's process ID.
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
ZED_SCRIPT_DIR
|
ZED_ZEDLET_DIR
|
||||||
The daemon's current enabled-scripts directory.
|
The daemon's current \fIenabled-zedlets\fR directory.
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
ZFS_ALIAS
|
ZFS_ALIAS
|
||||||
The ZFS alias (name-ver-rel) string used to build the daemon.
|
The ZFS alias (\fIname-version-release\fR) string used to build the daemon.
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
ZFS_VERSION
|
ZFS_VERSION
|
||||||
@ -186,10 +187,10 @@ The ZFS version used to build the daemon.
|
|||||||
ZFS_RELEASE
|
ZFS_RELEASE
|
||||||
The ZFS release used to build the daemon.
|
The ZFS release used to build the daemon.
|
||||||
.PP
|
.PP
|
||||||
Scripts may need to call other ZFS commands. The installation paths of
|
ZEDLETs may need to call other ZFS commands. The installation paths of
|
||||||
the following executables are defined: \fBZDB\fR, \fBZED\fR, \fBZFS\fR,
|
the following executables are defined: \fBZDB\fR, \fBZED\fR, \fBZFS\fR,
|
||||||
\fBZINJECT\fR, and \fBZPOOL\fR. These variables can be overridden in the
|
\fBZINJECT\fR, and \fBZPOOL\fR. These variables can be overridden in the
|
||||||
zed.rc if needed.
|
rc file if needed.
|
||||||
|
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.\" .TP
|
.\" .TP
|
||||||
@ -197,13 +198,13 @@ zed.rc if needed.
|
|||||||
.\" The default configuration file for the daemon.
|
.\" The default configuration file for the daemon.
|
||||||
.TP
|
.TP
|
||||||
.I @sysconfdir@/zfs/zed.d
|
.I @sysconfdir@/zfs/zed.d
|
||||||
The default directory for enabled scripts.
|
The default directory for enabled ZEDLETs.
|
||||||
.TP
|
.TP
|
||||||
.I @sysconfdir@/zfs/zed.d/zed.rc
|
.I @sysconfdir@/zfs/zed.d/zed.rc
|
||||||
The default rc file for common variables used by the scripts.
|
The default rc file for common variables used by ZEDLETs.
|
||||||
.TP
|
.TP
|
||||||
.I @libexecdir@/zfs/zed.d
|
.I @libexecdir@/zfs/zed.d
|
||||||
The default directory for installed scripts.
|
The default directory for installed ZEDLETs.
|
||||||
.TP
|
.TP
|
||||||
.I @runstatedir@/zed.pid
|
.I @runstatedir@/zed.pid
|
||||||
The default file containing the daemon's process ID.
|
The default file containing the daemon's process ID.
|
||||||
@ -214,14 +215,14 @@ The default file containing the daemon's state.
|
|||||||
.SH SIGNALS
|
.SH SIGNALS
|
||||||
.TP
|
.TP
|
||||||
.B HUP
|
.B HUP
|
||||||
Reconfigure the daemon and rescan the directory for enabled scripts.
|
Reconfigure the daemon and rescan the directory for enabled ZEDLETs.
|
||||||
.TP
|
.TP
|
||||||
.B TERM
|
.B TERM
|
||||||
Terminate the daemon.
|
Terminate the daemon.
|
||||||
|
|
||||||
.SH NOTES
|
.SH NOTES
|
||||||
.PP
|
.PP
|
||||||
\fBzed\fR requires root privileges.
|
\fBZED\fR requires root privileges.
|
||||||
.\" Do not taunt zed.
|
.\" Do not taunt zed.
|
||||||
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
@ -229,16 +230,16 @@ Terminate the daemon.
|
|||||||
Events are processed synchronously by a single thread. This can delay the
|
Events are processed synchronously by a single thread. This can delay the
|
||||||
processing of simultaneous zevents.
|
processing of simultaneous zevents.
|
||||||
.PP
|
.PP
|
||||||
There is no maximum timeout for script execution. Consequently, a misbehaving
|
There is no maximum timeout for ZEDLET execution. Consequently, a misbehaving
|
||||||
script can delay the processing of subsequent zevents.
|
ZEDLET can delay the processing of subsequent zevents.
|
||||||
.PP
|
.PP
|
||||||
The ownership and permissions of the enabled-scripts directory (along
|
The ownership and permissions of the \fIenabled-zedlets\fR directory (along
|
||||||
with all parent directories) are not checked. If any of these directories
|
with all parent directories) are not checked. If any of these directories
|
||||||
are improperly owned or permissioned, an unprivileged user could insert a
|
are improperly owned or permissioned, an unprivileged user could insert a
|
||||||
script to be executed as root. The requirement that scripts be owned by
|
ZEDLET to be executed as root. The requirement that ZEDLETs be owned by
|
||||||
root mitigates this to some extent.
|
root mitigates this to some extent.
|
||||||
.PP
|
.PP
|
||||||
Scripts are unable to return state/status information to the kernel.
|
ZEDLETs are unable to return state/status information to the kernel.
|
||||||
.PP
|
.PP
|
||||||
Some zevent nvpair types are not handled. These are denoted by zevent
|
Some zevent nvpair types are not handled. These are denoted by zevent
|
||||||
environment variables having a "_NOT_IMPLEMENTED_" value.
|
environment variables having a "_NOT_IMPLEMENTED_" value.
|
||||||
@ -257,7 +258,7 @@ Copyright (C) 2013\-2014 Lawrence Livermore National Security, LLC.
|
|||||||
|
|
||||||
.SH LICENSE
|
.SH LICENSE
|
||||||
.PP
|
.PP
|
||||||
\fBzed\fR (ZFS Event Daemon) is distributed under the terms of the
|
\fBZED\fR (ZFS Event Daemon) is distributed under the terms of the
|
||||||
Common Development and Distribution License (CDDL\-1.0).
|
Common Development and Distribution License (CDDL\-1.0).
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
|
Loading…
Reference in New Issue
Block a user