version 1.16, 2016/10/10 21:29:23 |
version 1.17, 2017/01/24 20:15:32 |
|
|
free(envent); |
free(envent); |
} |
} |
|
|
/* |
/* Copy variables from a destination into a source * environment. */ |
* Copy a space-separated list of variables from a destination into a source |
|
* environment. |
|
*/ |
|
void |
void |
environ_update(const char *vars, struct environ *srcenv, |
environ_update(struct options *oo, struct environ *src, struct environ *dst) |
struct environ *dstenv) |
|
{ |
{ |
struct environ_entry *envent; |
struct environ_entry *envent; |
char *copyvars, *var, *next; |
struct options_entry *o; |
|
u_int size, idx; |
|
const char *value; |
|
|
copyvars = next = xstrdup(vars); |
o = options_get(oo, "update-environment"); |
while ((var = strsep(&next, " ")) != NULL) { |
if (o == NULL || options_array_size(o, &size) == -1) |
if ((envent = environ_find(srcenv, var)) == NULL) |
return; |
environ_clear(dstenv, var); |
for (idx = 0; idx < size; idx++) { |
|
value = options_array_get(o, idx); |
|
if (value == NULL) |
|
continue; |
|
if ((envent = environ_find(src, value)) == NULL) |
|
environ_clear(dst, value); |
else |
else |
environ_set(dstenv, envent->name, "%s", envent->value); |
environ_set(dst, envent->name, "%s", envent->value); |
} |
} |
free(copyvars); |
|
} |
} |
|
|
/* Push environment into the real environment - use after fork(). */ |
/* Push environment into the real environment - use after fork(). */ |