Operating System - HP-UX
1753618 Members
5719 Online
108797 Solutions
New Discussion юеВ

Environment variables of another user

 
CLEMENT Steven
New Member

Environment variables of another user

We have a simple unix account (a standard user), and we want to see the content of some environment variables of another user (like $BIN, $ETC, $LOG, ...).

Take into account that we don't have the root password, nor the password of the user of which we want to know the variables.

Is this easily to do ??
8 REPLIES 8
Radhakrishnan Venkatara
Trusted Contributor

Re: Environment variables of another user

these environment variables are sent in user profiles.

let say if u can see it.then it becomes the security risk.

High a potential security threat to the systems.

radhakrishnan
Negative thinking is a highest form of Intelligence
T G Manikandan
Honored Contributor

Re: Environment variables of another user

find his home dir and shell
$cat /etc/passwd|grep

$cd
$ls -la .profile .cshrc .login

.profile -->ksh or sh
.login and .cshrc--->csh
If you have read access you can open these files and find out the value for the variables

Revert
Steve Steel
Honored Contributor

Re: Environment variables of another user

Hi


As well answered already these are user specific variables and you can only see them if the user will give them to you.

The user needs to agree and do set or env
to a file and give you file access

To be able to take them would make you very insecure systemwise.


/etc/profile $HOME/.profile and .dtprofile all make a difference plus any env files like
.kshrc


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Bill Hassell
Honored Contributor

Re: Environment variables of another user

Environment variables only exist when a user logs in and they are setup by the various commands in the login profiles. It is not possiblle to see an existing login environment without being at that user's keyboard since manual changes may have been made. As mentioned before, the only way to see what a specific user will get when they login is to actually login as that user. If the user ihasd a standard shell (/usr/bin/sh or /usr/bin/ksh) then type the command: set and you'll see all variables. Use the command: env and you'll the only the exported variables.


Bill Hassell, sysadmin
CLEMENT Steven
New Member

Re: Environment variables of another user

Conclusion: when we don't have the user password (or the root password), it's not possible to see these variables ?
Steve Steel
Honored Contributor

Re: Environment variables of another user

Hi


Indeed .

You need to be able to login as the user or need to have read/execute access to the users .profile and thus to extrapolate the values.

If you have access to any scripts use dby the user you could always put
set > /tmp/$LOGNAME".env"

In it and then wait.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
john korterman
Honored Contributor

Re: Environment variables of another user

Hi,
even having the root password would only allow seeing how the user's setup is immediately after login. If the user has shell access, he/she can change the environment variables of his/her own shell at any time after login.
As already stated: you have to get the information from the user him/herself.

regards,
John K.
it would be nice if you always got a second chance
Bill Hassell
Honored Contributor

Re: Environment variables of another user

Environment variables are set in three places:

1. global login profiles such as /etc/profile for POSIX shells like /usr/bin/sh, ksh and bash and /etc/csh.login for csh users,

2. local profiles such as .profile and perhaps .kshrc

3. Changes made to the user's local enviroment by sourcing scripts or typing shell commands.

So you can see the environment a specific user might have setup by running the same profiles that the user has. This requires that the user's local profiles are readable by your login.

Other than logging in as the user or using su - user-name to truly login, there is no way to accurately see what a specific users environment might be. Why don't you ask the user to login and print these two commands:

set (all variables)
env (exported variables)

(this assumes the user has a POSIX type shell)


Bill Hassell, sysadmin