mirror of
https://github.com/slicer69/doas
synced 2024-09-30 05:03:36 +00:00
Make sure LANG environment variable is copied over to the target
user from the original, if it is defined. Avoids switching languages on the original user by surprise.
This commit is contained in:
parent
ab3ae5ad41
commit
2299d4967d
3
doas.h
3
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
|
||||
|
|
7
env.c
7
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];
|
||||
|
||||
|
|
Loading…
Reference in a new issue