diff options
Diffstat (limited to 'src/firejail/env.c')
-rw-r--r-- | src/firejail/env.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/firejail/env.c b/src/firejail/env.c index c54b429c3..b2e4c17f3 100644 --- a/src/firejail/env.c +++ b/src/firejail/env.c | |||
@@ -33,13 +33,13 @@ static Env *envlist = NULL; | |||
33 | 33 | ||
34 | static void env_add(Env *env) { | 34 | static void env_add(Env *env) { |
35 | env->next = NULL; | 35 | env->next = NULL; |
36 | 36 | ||
37 | // add the new entry at the end of the list | 37 | // add the new entry at the end of the list |
38 | if (envlist == NULL) { | 38 | if (envlist == NULL) { |
39 | envlist = env; | 39 | envlist = env; |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | 42 | ||
43 | Env *ptr = envlist; | 43 | Env *ptr = envlist; |
44 | while (1) { | 44 | while (1) { |
45 | if (ptr->next == NULL) { | 45 | if (ptr->next == NULL) { |
@@ -77,7 +77,7 @@ void env_ibus_load(void) { | |||
77 | continue; | 77 | continue; |
78 | if (strlen(ptr) != 6) | 78 | if (strlen(ptr) != 6) |
79 | continue; | 79 | continue; |
80 | 80 | ||
81 | // open the file | 81 | // open the file |
82 | char *fname; | 82 | char *fname; |
83 | if (asprintf(&fname, "%s/%s", dirname, entry->d_name) == -1) | 83 | if (asprintf(&fname, "%s/%s", dirname, entry->d_name) == -1) |
@@ -86,7 +86,7 @@ void env_ibus_load(void) { | |||
86 | free(fname); | 86 | free(fname); |
87 | if (!fp) | 87 | if (!fp) |
88 | continue; | 88 | continue; |
89 | 89 | ||
90 | // read the file | 90 | // read the file |
91 | const int maxline = 4096; | 91 | const int maxline = 4096; |
92 | char buf[maxline]; | 92 | char buf[maxline]; |
@@ -137,24 +137,24 @@ void env_defaults(void) { | |||
137 | if (prompt && strcmp(prompt, "yes") == 0) | 137 | if (prompt && strcmp(prompt, "yes") == 0) |
138 | set_prompt = 1; | 138 | set_prompt = 1; |
139 | } | 139 | } |
140 | 140 | ||
141 | if (set_prompt) { | 141 | if (set_prompt) { |
142 | //export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] ' | 142 | //export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] ' |
143 | if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0) | 143 | if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0) |
144 | errExit("setenv"); | 144 | errExit("setenv"); |
145 | } | 145 | } |
146 | 146 | ||
147 | // set the window title | 147 | // set the window title |
148 | if (!arg_quiet) | 148 | if (!arg_quiet) |
149 | printf("\033]0;firejail %s\007", cfg.window_title); | 149 | printf("\033]0;firejail %s\007", cfg.window_title); |
150 | fflush(0); | 150 | fflush(0); |
151 | } | 151 | } |
152 | 152 | ||
153 | // parse and store the environment setting | 153 | // parse and store the environment setting |
154 | void env_store(const char *str, ENV_OP op) { | 154 | void env_store(const char *str, ENV_OP op) { |
155 | EUID_ASSERT(); | 155 | EUID_ASSERT(); |
156 | assert(str); | 156 | assert(str); |
157 | 157 | ||
158 | // some basic checking | 158 | // some basic checking |
159 | if (*str == '\0') | 159 | if (*str == '\0') |
160 | goto errexit; | 160 | goto errexit; |
@@ -182,11 +182,11 @@ void env_store(const char *str, ENV_OP op) { | |||
182 | env->value = ptr2 + 1; | 182 | env->value = ptr2 + 1; |
183 | } | 183 | } |
184 | env->op = op; | 184 | env->op = op; |
185 | 185 | ||
186 | // add entry to the list | 186 | // add entry to the list |
187 | env_add(env); | 187 | env_add(env); |
188 | return; | 188 | return; |
189 | 189 | ||
190 | errexit: | 190 | errexit: |
191 | fprintf(stderr, "Error: invalid --env setting\n"); | 191 | fprintf(stderr, "Error: invalid --env setting\n"); |
192 | exit(1); | 192 | exit(1); |
@@ -195,7 +195,7 @@ errexit: | |||
195 | // set env variables in the new sandbox process | 195 | // set env variables in the new sandbox process |
196 | void env_apply(void) { | 196 | void env_apply(void) { |
197 | Env *env = envlist; | 197 | Env *env = envlist; |
198 | 198 | ||
199 | while (env) { | 199 | while (env) { |
200 | if (env->op == SETENV) { | 200 | if (env->op == SETENV) { |
201 | if (setenv(env->name, env->value, 1) < 0) | 201 | if (setenv(env->name, env->value, 1) < 0) |