C function to test existence of a login


 
Thread Tools Search this Thread
Top Forums Programming C function to test existence of a login
# 1  
Old 03-01-2008
Data C function to test existence of a login

Hi everybody,

I need to check in C program whether a given login is known on the system. Is there any system function that could do this ?

So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by other means (PAM, Kerberos, ...).

I am surprised not to have found anything on that topic, because any shell is able to resolve a user's HOME while doing the tilde expansion, but how is it done? I had a look at the shell C sources, but I am a bit lost. Also, I don't have a system with network authentication handy, so I can't ktrace /bin/sh while doing a tilde expansion to see what function is called...

Thanks in advance, any help much appreciated.

Xavier
# 2  
Old 03-04-2008
Did you check man wtmp or man wtmpx?
# 3  
Old 03-04-2008
Hi, the discussion has moved here, indeed:

https://www.unix.com/unix-advanced-ex...xistence+login

X.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test function not working

i am writing the following snippet and cannot figure out why the variable measType remains 0. it should be 1 I also tried "\#analog" and '\#analog' in the test statement and it still doesn't work. What is going on? bash$ measType=0 bash$ read line < 2iconfig.ini bash$ echo $line #analog... (4 Replies)
Discussion started by: oahmad
4 Replies

2. Shell Programming and Scripting

explanation of test function

I have found a code some where, which looks like if (test $value) then <do something> fi I am not understanding what is test doing here. I have seen test with !,-eq, -e etc. But, the above appears to be a new one to me. Can anyone please expalin me. (4 Replies)
Discussion started by: mady135
4 Replies

3. Shell Programming and Scripting

test for existence of files with same extension

Hi, I am checking for existence of files with the same extensions #! /usr/bin/ksh txtfiles = '*.txt' if then cp ${dirpath}/${txtfiles} ${dir2path} fi I am getting the following error line 5: [: too many arguments for the if check condition (4 Replies)
Discussion started by: chen.sara
4 Replies

4. Solaris

How to test the existence of trailer record

SunOS 5.10 Generic_142900-15 sun4v sparc SUNW,T5240 I have a script that needs to test a file for the existence of a trailer record. Is there a command and is a header and trailer differect record type? Thanks in advance (1 Reply)
Discussion started by: Harleyrci
1 Replies

5. Shell Programming and Scripting

Test for existence of files

Hello, Can you please help me to see if log files exist in a directory? I need to scan logs in different directories, so I am using an array to change dynamically. I need help in the if test statement dir=/logs/MSD dir=/logs/UPD countA=1 while (( countA <= ${#dir } )) do cd ${dir}... (1 Reply)
Discussion started by: drbiloukos
1 Replies

6. Shell Programming and Scripting

Test File for Existence with Whitespaces in Path

Hi Everyone! I'm quite new to shell scripting so this might be trivial, though 3 days of struggle and search didn't help to solve the problem: I want to look for files called '*HUN*' in a huge amount of directories most of their names contain whitespaces and print the path of the directory if... (8 Replies)
Discussion started by: sumi76
8 Replies

7. Shell Programming and Scripting

Test for a file existence

deleted (1 Reply)
Discussion started by: ust
1 Replies

8. UNIX for Advanced & Expert Users

test for function name?

Hi, I found this: https://www.unix.com/unix-advanced-expert-users/27318-how-see-function-shell.html which indicates I can use typeset -f to list the functions. But it also lists the contents of the functions. Is there a lighter weight way to see what is defined? Is there an internal... (5 Replies)
Discussion started by: duderonomy
5 Replies

9. UNIX for Advanced & Expert Users

Check existence of a login

Hi everybody, I need to check in C program wether a given login is known on the system. Is there any system function that could do this ? So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by... (10 Replies)
Discussion started by: xavier054
10 Replies

10. Shell Programming and Scripting

how to test for file existence using file size?

ok im doing this in a normal shell. i need to check the file in the script. how should i write the if else statment? if the filesize contains 0kb then it will echo out file contains nothing else if the script contains more than 0kb then it will echo out file exist. any one care to help?... (3 Replies)
Discussion started by: forevercalz
3 Replies
Login or Register to Ask a Question