diff options
author | Harald Hoyer <harald@redhat.com> | 2007-04-26 22:52:20 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2007-04-26 22:52:20 +0200 |
commit | 1343a9524f9d2145dfbf2ba479eb859faf6a1e95 (patch) | |
tree | b5160986162c72a36167469f2add6483e6251533 /udevd.c | |
parent | 01ad1ef5f367f1e3e777d03f08b78a1fc37a8f05 (diff) |
udevcontrol: allow to set global variables in udevd
The initial patch is from Harald, possible new bugs are from me.
Diffstat (limited to 'udevd.c')
-rw-r--r-- | udevd.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -667,6 +667,7 @@ static void get_ctrl_msg(void) struct ucred *cred; char cred_msg[CMSG_SPACE(sizeof(struct ucred))]; int *intval; + char *pos; memset(&ctrl_msg, 0x00, sizeof(struct udevd_ctrl_msg)); iov.iov_base = &ctrl_msg; @@ -703,6 +704,21 @@ static void get_ctrl_msg(void) } switch (ctrl_msg.type) { + case UDEVD_CTRL_ENV: + pos = strchr(ctrl_msg.buf, '='); + if (pos == NULL) { + err("wrong key format '%s'", ctrl_msg.buf); + break; + } + pos[0] = '\0'; + if (pos[1] == '\0') { + info("udevd message (ENV) received, unset '%s'", ctrl_msg.buf); + unsetenv(ctrl_msg.buf); + } else { + info("udevd message (ENV) received, set '%s=%s'", ctrl_msg.buf, &pos[1]); + setenv(ctrl_msg.buf, &pos[1], 1); + } + break; case UDEVD_CTRL_STOP_EXEC_QUEUE: info("udevd message (STOP_EXEC_QUEUE) received"); stop_exec_q = 1; |