diff --git a/doas.h b/doas.h index 4f12e86..938b824 100644 --- a/doas.h +++ b/doas.h @@ -65,3 +65,6 @@ struct passwd *copyenvpw(struct passwd *original); #define SAFE_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" #endif +#ifndef MAX_ENV_LENGTH +#define MAX_ENV_LENGTH 1024 +#endif diff --git a/env.c b/env.c index 689f491..cfa45f3 100644 --- a/env.c +++ b/env.c @@ -117,6 +117,7 @@ createenv(struct rule *rule, struct passwd *original, struct passwd *target) { struct env *env; u_int i; + char *language = NULL; env = malloc(sizeof(*env)); if (!env) @@ -133,6 +134,10 @@ createenv(struct rule *rule, struct passwd *original, struct passwd *target) addnode(env, "PATH", GLOBAL_PATH); addnode(env, "SHELL", target->pw_shell); addnode(env, "USER", target->pw_name); + /* avoid dropping language of original user */ + language = getenv("LANG"); + if (language) + addnode(env, "LANG", language); if (rule->options & KEEPENV) { #ifndef linux @@ -143,7 +148,7 @@ createenv(struct rule *rule, struct passwd *original, struct passwd *target) struct envnode *node; const char *e, *eq; size_t len; - char name[1024]; + char name[MAX_ENV_LENGTH]; e = environ[i];