/* copy environment buffer and reconstruct envp */
memcpy(msg->envbuf, usend_msg.envbuf, envbuf_size);
bufpos = 0;
- for (i = 0; (bufpos < envbuf_size) && (i < HOTPLUG_NUM_ENVP-1); i++) {
+ for (i = 0; (bufpos < envbuf_size) && (i < HOTPLUG_NUM_ENVP-2); i++) {
int keylen;
char *key;
if (strncmp(key, "SEQNUM=", 7) == 0)
msg->seqnum = strtoull(&key[7], NULL, 10);
}
+ msg->envp[i++] = "MANAGED_EVENT=1";
msg->envp[i] = NULL;
/* if no seqnum is given, we move straight to exec queue */
struct udevsend_msg {
char magic[20];
- char envbuf[HOTPLUG_BUFFER_SIZE];
+ char envbuf[HOTPLUG_BUFFER_SIZE+256];
};
struct hotplug_msg {
char *devpath;
char *subsystem;
unsigned long long seqnum;
- char *envp[HOTPLUG_NUM_ENVP];
+ char *envp[HOTPLUG_NUM_ENVP+1];
char envbuf[];
};
goto exit;
}
+ /* prevent loops in the scripts we execute */
+ if (getenv("MANAGED_EVENT") != NULL) {
+ dbg("seems that the event source is not the kernel, just exit");
+ goto exit;
+ }
+
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (sock == -1) {
dbg("error getting socket");