11-15-2003
Read paragraph 3 of my first post for comments on getuid(). Hmmm, I see that I said to use getpwnam(). Actually, since we have the uid, we should use getpwuid().
ctermid() is a silly little function that always returns the string "/dev/tty". I will never understand why people write functions to return a constant.
cuserid() was dropped from posix in 1990. It is still available on many systems, but I recommend that it not be used for new code. It first tries the technique I mentioned in the second paragraph of my first post. If that fails, it then uses the getuid() technique that I mentioned in my third paragraph. No information is available to the caller about which technique worked. And it never tries the technique mentioned in my first paragraph which posix seems to promote as the preferred method.
Also there is getlogin() which automates looking up the controlling terminal in utmp.
I have the uneasy feeling that there are more functions that automate some conbination of the 3 techniques that I mentioned. It's dangerous to be sure of a negative, but I'm rather sure that there isn't a 4th technique lurking around.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi all,
kindly let me know the command to get password and user for current user in unix.
thanks in advance.
--Bali Reddy.Y (1 Reply)
Discussion started by: balireddy_77
1 Replies
2. Shell Programming and Scripting
I have crated a file xx wth env redirected into it 5 times n couldnot proceed further
n next we have to create a script that takes 1 argument being a file, in this instance we use the newly created file above xx(xx file contains the env redirected into it 5 times) read the inputted file, in... (1 Reply)
Discussion started by: bobby36
1 Replies
3. Shell Programming and Scripting
When I typed in ps -a I get this:
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim
And to check who is currently logged in, I type who
Felix Whoals
Tada Whoals
Lala Whoals
How can I get the user process for all current users who logged in?? I think I need to combine... (14 Replies)
Discussion started by: felixwhoals
14 Replies
4. UNIX for Dummies Questions & Answers
I'm trying to write a grep command that will be good for the current user of the command but it doesn't work on my server with bash shell. On the server with tcsh I used:
last | grep "$user" and the current user could see how many times they logged on this month. On the other server it doesn't... (11 Replies)
Discussion started by: steveu
11 Replies
5. Shell Programming and Scripting
Ok, so, in order to install some dependencies of a program I made, a script has to be run as root. The thing is that I have to copy some things into the home folder of currently logged in user, but the variable $HOME returns '/root' and the $USER returns 'root' :(
Is there any way to see who is... (7 Replies)
Discussion started by: hakermania
7 Replies
6. Shell Programming and Scripting
Hey guys
I need a script that reads a login name and verifies if that user is currently logged in
i have found few commands like "who" and "users"
but i wonder how can i verify it that login name is logged in or not? (3 Replies)
Discussion started by: nishrestha
3 Replies
7. Shell Programming and Scripting
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. Shell Programming and Scripting
Hi,
'ps -ef' returns output of the following format
UID PID PPID C STIME TTY TIME CMD
root 17573 1 0 Sep12 tty6 00:00:00 /sbin/mingetty tty6
hpsmh 18150 14864 0 Sep12 ? 00:00:00 /opt/hp/hpsmh/sbin/hpsmhd -DSSL -f /opt/hp/hpsmh/conf/smhpd.conf
root ... (3 Replies)
Discussion started by: ysrini
3 Replies
9. UNIX for Dummies Questions & Answers
In any non-root account, whenever I enter mail, it gives me:
/var/spool/mail/root: Permission deniedI am not logged in as root, why is mail accessing root's mailbox ?
I am unable to enter the currently logged in user's mailbox.
Any help is appreciated :) (2 Replies)
Discussion started by: Hijanoqu
2 Replies
10. Shell Programming and Scripting
Hi,
i need to list the processes running only under current logged in user.
EX:
$ whoami
oraaqw
$ ps -ef | grep tnslsnr
oraaqw 11403300 19267592 0 09:14:47 pts/3 0:00 grep tnslsnr
oraaqw 15794208 1 0 Jan 14 - 11:59... (6 Replies)
Discussion started by: aravindadla
6 Replies
LEARN ABOUT SUSE
unix2_chkpwd
UNIX2_CHKPWD(8) Linux-PAM Manual UNIX2_CHKPWD(8)
NAME
unix2_chkpwd - helper binary that verifies the password of the current user
SYNOPSIS
/sbin/unix2_chkpwd servicename username
DESCRIPTION
unix2_chkpwd is a helper program for applications that verifies the password of the current user. It is not intended to be run directly
from the command line and logs a security violation if done so.
It is typically installed setuid root or setgid shadow and called by applications, which only wishes to do an user authentification and
nothing more.
OPTIONS
unix2_pwdchk requires the following arguments:
pam_service
The name of the service using unix2_chkpwd. This is required to be one of the services in /etc/pam.d
username
The name of the user whose password you want to verify.
INPUTS
unix2_pwdchk expects the password via stdin.
RETURN CODES
unix2_chkpwd has the following return codes:
1 unix2_chkpwd was inappropriately called from the command line or the password is incorrect.
0 The password is correct.
HISTORY
Written by Olaf Kirch loosely based on unix_chkpwd by Andrew Morgan
SEE ALSO
pam(8)
AUTHOR
Emily Ratliff.
Linux-PAM 0.76 2003-03-21 UNIX2_CHKPWD(8)