1

OS: Linux (Debian 8) Environment details:

  1. We use LXDE and uxterm.
  2. Virtual console form till ctrl +Alt + F6 is disabled.
  3. Total users available user1, user2, user3

the default system is set with auto login with user1 and we trigger user terminal via script (uxterm).

On user pressing special combination in LXDE it invoked a Uxterminal in screen with User2 as login. on login success, user2 console can be used.

We have 3rd user, where his role is very limited and needed for our current scenario of our operation.

To create a BASH profile for the user, we have added info in sudoers with NOPASSWD option.

etc/sudoers

User_Alias PRIVILEGEDUSER = user1,user2
Runas_Alias TARGETUSER = user2,user3
PRIVILEGEDUSER ALL=(TARGETUSER) NOPASSWD: /bin/bash

also we have added env_keep in Defaults

Defaults        env_reset
Defaults        env_keep += "JRE_HOME"
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

With this option when we try switching user, JRE_HOME is not getting set. Also added JRE_HOME in etc/.profile manually for all available users in system for testing purposed, even that did not help

JRE_HOME=/usr/lib/jvm/java-7-openjdk-i386/jre
export JRE_HOME

Need some guidance in setting JRE_HOME during sudo -u switching.

2 Answers 2

0

To set envrionment variables globally there are several approaches and as discussed under How to set environment variable for everyone under my Linux system or How to permanently set environmental variables.

For me placing a .sh file under etc/profile.d worked well.

0

You can set specific environment variables in your /etc/sudoers file for a given user with:

Defaults:myuser-spec env_file=/etc/sudovars_for_myuser

For your example, you may have /etc/sudovars_for_myuser containing:

JRE_HOME=/usr/lib/jvm/java-7-openjdk-i386/jre

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .