1 diff -Naur a/action.c b/action.c
2 --- a/action.c 2009-11-18 13:15:21.000000000 +0000
3 +++ b/action.c 2009-11-18 13:11:19.000000000 +0000
8 + * Creates a "key=value" string from the given key and value
13 + * Returns: Newly allocated string in "key=value" form
16 +static char* alloc_env(const char *key, const char *value) {
17 + size_t keylen, vallen;
20 + keylen = strlen(key);
21 + vallen = strlen(value) + 1;
23 + combined = xmalloc(keylen + vallen + 1);
24 + memcpy(combined, key, keylen);
25 + combined[keylen] = '=';
26 + memcpy(&combined[keylen + 1], value, vallen);
32 * Choose what action should be taken according to passed settings.
37 void action_perform(struct settings_t *settings, struct uevent_t *event) {
41 + env = xmalloc(sizeof(char *) * event->env_vars_c);
43 + for (i = 0; i < event->env_vars_c; i++) {
44 + env[i] = alloc_env(event->env_vars[i].key, event->env_vars[i].value);
48 - for (i = 0; i < event->env_vars_c; i++)
49 - setenv(event->env_vars[i].key, event->env_vars[i].value, 1);
51 if (settings->dumb == 0) {
52 ruleset_execute(&settings->rules, event, settings);
54 action_dumb(settings, event);
57 - for (i = 0; i < event->env_vars_c; i++)
58 + for (i = 0; i < event->env_vars_c; i++) {
59 unsetenv(event->env_vars[i].key);