Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to get a login name of a person who used 'su' and act with different user-name? Post 302286303 by alex_5161 on Tuesday 10th of February 2009 07:57:42 PM
Old 02-10-2009
So, I have resolve my own task, although the main question of this thread is not resolved.

In my situation I knew the log name that is used to start process. And, how it was advised, using the 'ps' though real terminals, I get the acctual log name of the person, who been loged in before 'su'.
I have put it into a function:
Code:
main_log_nm ()
{
    typeset usr       tr        ;  # input user name; related to usr terminals;
    typeset usrs_all usrs_les;  # all users on those terminals; all users, lewss on usr
      # if no user name in input, use name of requester
    [[ -z $1 ]] && usr=$(whoami) || usr=$1;
      # get line of related terminals (backgroung jobs has '?' for TT (terminal);  
    tr=$(ec $(ps -o tty -u $usr|grep -v '^?'|grep -v TT|sort|uniq )|sed 's/ /,/g');
      # now get all users associated with found terminals - originaly a person will have a terminal
    [[ ! -z $tr ]] && {
      usrs_all=$(ps -o user -t $tr | grep -v  USER |sort|uniq);
        # remove from all users the requested user name (as it 'su'id)
      usrs_les=$(ec $usrs_all|sed "s/ *//g; s/$usr//g");
        # if there is any other name than the requested, do not return the requested name
      [[ -z $usrs_les ]] && /usr/bin/echo $usrs_all || /usr/bin/echo $usrs_les
    }  #END of 'if any terminal is found (so, someone is loged in)'
}
#  END of  main_log_nm

(If you see anythink incorrect or should/could be done different - I will appreciate your hints!)
After that it is easy to use 'write' for each returned name

BUT, if the task is to realise who is logged under 'su' - I DO NOT HAVE a solution!

If you see how it could be done in such system as our (where 'su' command is not showed in 'ps' list and represented as a regular log,) show it here.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Login User

Dear all members I've a question basd on an AIX enviroment. In here I've two administrative users, are used for the running application (SAP). Now my problem's, that's not possible to login over the "normal" Loginscreen as such a user. If I try this, the FTP connection will closed at once. It's... (6 Replies)
Discussion started by: olli2002
6 Replies

2. Shell Programming and Scripting

User Login Limit

Gud day :) We have a limited user login so we want to restrict 1 login per user. We have added below script in each user's profile but it is not working :confused: , I displayed the output for COUNT (by inserting echo command) but the value is always 1. Hope you could help me. Thanks ;) ... (3 Replies)
Discussion started by: lancemendioro
3 Replies

3. UNIX for Dummies Questions & Answers

I create user but i cant login the user i created.

I created a user, i login as a root. I add him in the group where he can access and login as a root! I checked it in users' list and in group's list, he is there. My problem is this, I cant login using the username/account I just created! What should i do to use and login the user/account i've just... (5 Replies)
Discussion started by: jerome
5 Replies

4. Shell Programming and Scripting

Running script from other user rather than login user

Hi, My requirement is that i am login from ROOT in a script but when any command is coming which is logging to sqlplus then i have to run it with normal user as only normal user have permission to connect to sqlplus . i tried making a script like this : #! /bin/ksh su -... (3 Replies)
Discussion started by: rawatds
3 Replies

5. Solaris

error message rmclomv ... SC Login Failure for user Please login:

Hello World ~ HW : SUN Fire V240 OS : Solaris 8 Error message prompts 'rmclomv ... SC login failure ...' on terminal. and Error Message prompts continually 'SC Login Failure for user Please login:' on Single Mode(init S) The System is in normal operation, though In case of rain, Can... (1 Reply)
Discussion started by: lifegeek
1 Replies

6. AIX

User login time

I want to set the "logintimes" variable for a user on a server who need access mornings and night how to I set the "logintimes" I want the user to log in from 08:00 to 12:00 and 17:00 to 21:00 is this possible? (1 Reply)
Discussion started by: daveisme
1 Replies

7. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

8. AIX

User Account Login Login on your AIX server

I want to learn AIX. I would like to find someone who would be willing to give me a login to their AIX home lab server. My intent is to poke around and discover the similarities and differences of AIX compared to other *NIXs. I am a UNIX admin so I can think of what some immediate concerns may... (1 Reply)
Discussion started by: perl_in_my_shel
1 Replies

9. Shell Programming and Scripting

Login into another user from user inside script

now i have logged in username : ramesh in unix Now i have to created script file to login into another user and have run a command inside that user and after executing the command i have to exit from that user. Inside script, i have to login into su - ram along with password : haihow and have to... (4 Replies)
Discussion started by: rammm
4 Replies

10. UNIX for Advanced & Expert Users

Prevent user from creating new user from his login

Hi Experts, Need your support Redhat 6.5 I want to create a user with all(read, write, execute) privileges except that user should not be able to create any new user from his login to perform any task. (10 Replies)
Discussion started by: as7951
10 Replies
pam_console(8)						   System Administrator's Manual					    pam_console(8)

NAME
pam_console - control permissions for users at the system console SYNOPSIS
session optional /lib/security/pam_console.so auth required /lib/security/pam_console.so DESCRIPTION
pam_console.so is designed to give users at the physical console (virtual terminals and local xdm-managed X sessions by default, but that is configurable) capabilities that they would not otherwise have, and to take those capabilities away when the are no longer logged in at the console. It provides two main kinds of capabilities: file permissions and authentication. When a user logs in at the console and no other user is currently logged in at the console, pam_console.so will change permissions and own- ership of files as described in the file /etc/security/console.perms. That user may then log in on other terminals that are considered part of the console, and as long as the user is still logged in at any one of those terminals, that user will own those devices. When the user logs out of the last terminal, the console may be taken by the next user to log in. Other users who have logged in at the console during the time that the first user was logged in will not be given ownership of the devices unless they log in on one of the terminals; having done so on any one terminal, the next user will own those devices until he or she has logged out of every terminal that is part of the physical console. Then the race can start for the next user. In practice, this is not a problem; the physical console is not gener- ally in use by many people at the same time, and pam_console.so just tries to do the right thing in weird cases. ARGUMENTS
debug turns on debugging allow_nonroot_tty gain console locks and change permissions even if the TTY's owner is not root. permsfile=filename tells pam_console.so to get its permissions database from a different file than /etc/security/console.perms fstab=filename tells pam_console.so to read the table of configured filesystems from a file other than /etc/fstab when scanning permsfile. This file is used to map directories to device names. FILES
/var/run/console.lock /var/run/console/ /etc/security/console.apps /etc/security/console.perms SEE ALSO
console.perms(5) console.apps(5) /usr/doc/pam*/html/index.html pam_console_apply(8) /usr/doc/pam*/html/index.html BUGS
Let's hope not, but if you find any, please report them via the "Bug Track" link at http://bugzilla.redhat.com/bugzilla/ AUTHOR
Michael K. Johnson <johnsonm@redhat.com> Red Hat 2000/7/11 pam_console(8)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy