3 @@ -31,6 +31,30 @@ static void action_dumb(const struct set
7 + * Creates a "key=value" string from the given key and value
12 + * Returns: Newly allocated string in "key=value" form
15 +static char* alloc_env(const char *key, const char *value) {
16 + size_t keylen, vallen;
19 + keylen = strlen(key);
20 + vallen = strlen(value) + 1;
22 + combined = xmalloc(keylen + vallen + 1);
23 + memcpy(combined, key, keylen);
24 + combined[keylen] = '=';
25 + memcpy(&combined[keylen + 1], value, vallen);
31 * Choose what action should be taken according to passed settings.
34 @@ -41,16 +65,25 @@ static void action_dumb(const struct set
36 void action_perform(struct settings_t *settings, struct uevent_t *event) {
40 + env = xmalloc(sizeof(char *) * event->env_vars_c);
42 + for (i = 0; i < event->env_vars_c; i++) {
43 + env[i] = alloc_env(event->env_vars[i].key, event->env_vars[i].value);
47 - for (i = 0; i < event->env_vars_c; i++)
48 - setenv(event->env_vars[i].key, event->env_vars[i].value, 1);
50 if (settings->dumb == 0) {
51 ruleset_execute(&settings->rules, event, settings);
53 action_dumb(settings, event);
56 - for (i = 0; i < event->env_vars_c; i++)
57 + for (i = 0; i < event->env_vars_c; i++) {
58 unsetenv(event->env_vars[i].key);