version 1.1, 2016/06/16 17:40:30 |
version 1.2, 2016/06/19 19:29:43 |
|
|
*/ |
*/ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
#include <sys/tree.h> |
|
|
#include <string.h> |
#include <string.h> |
#include <stdio.h> |
#include <stdio.h> |
|
|
|
|
#include "doas.h" |
#include "doas.h" |
|
|
|
struct envnode { |
|
RB_ENTRY(envnode) node; |
|
const char *key; |
|
const char *value; |
|
}; |
|
|
|
struct env { |
|
RB_HEAD(envtree, envnode) root; |
|
u_int count; |
|
}; |
|
|
int |
int |
envcmp(struct envnode *a, struct envnode *b) |
envcmp(struct envnode *a, struct envnode *b) |
{ |
{ |
return strcmp(a->key, b->key); |
return strcmp(a->key, b->key); |
} |
} |
RB_GENERATE(envtree, envnode, node, envcmp) |
RB_GENERATE_STATIC(envtree, envnode, node, envcmp) |
|
|
|
struct env *createenv(char **); |
|
struct env *filterenv(struct env *, struct rule *); |
|
char **flattenenv(struct env *); |
|
|
struct env * |
struct env * |
createenv(char **envp) |
createenv(char **envp) |
{ |
{ |
|
|
copyenv(orig, copy, safeset); |
copyenv(orig, copy, safeset); |
|
|
return copy; |
return copy; |
|
} |
|
|
|
char ** |
|
prepenv(struct rule *rule) |
|
{ |
|
extern char **environ; |
|
struct env *env; |
|
|
|
env = createenv(environ); |
|
env = filterenv(env, rule); |
|
return flattenenv(env); |
} |
} |