Best way to check for system user and password in C


 
Thread Tools Search this Thread
Top Forums Programming Best way to check for system user and password in C
# 1  
Old 12-29-2009
Best way to check for system user and password in C

Hello,

I'm implementing a very simple FTP client, and to do the login I would like to check against system users instead of using my own database, so that I can give the proper permissions to the newly created process that I spawn with fork. What's the best way for doing this in C?

I've read about the getpwnam function, that returns a struct passwd that has the field pw_passwd to compare against (using the crypt function), but I'm not sure if this is quite standard, is there any other way to do this?

Thanks, Roger.
# 2  
Old 01-03-2010
I would suggest to use PAM , instead of reinventing the wheel .


The pam_authenticate function is used to authenticate the current user.

#include <security/pam_appl.h>
int pam_authenticate (pam_handle_t *pamh, int flags);

Google for
Linux-PAM Application Developers' Guide
# 3  
Old 01-03-2010
Thanks, I've already got a code sample from CryptNoMore
# 4  
Old 01-03-2010
OK , but if you want it portable among Unixes , PAM is the way.
# 5  
Old 01-03-2010
Yes, CryptNoMore shows examples about how to use OpenDirectory, PAM and Crypt. I've used the PAM part of the code, which runs fine on both Mac OS X and Linux at least.

Thanks for the reply.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Oracle Database - How to check if user roles and system roles are separated?

I have these two table. How do I see if user roles and system roles are seperated? SQL> desc DBA_ROLES; Name Null? Type ----------------------------------------- -------- ---------------------------- ROLE NOT NULL... (1 Reply)
Discussion started by: alvinoo
1 Replies

2. HP-UX

How to check password expiration date of particular user?

Hi Guys, I am new to HP-UX and want to find expiration date of particular user please also note i don't have root access on that server. for e.g. i have user abc on my HP box and want to know when its password going to expire and also when its password changed last time. I also try to... (7 Replies)
Discussion started by: Yasin Rakhangi
7 Replies

3. Shell Programming and Scripting

How to scp File from root user in one server to say crt user in another server and avoid password?

Can someone help in writing some script through which I can transfer file (scp) from root user in abc server to crt user in hfg server and can give the crt user password in script itself so that it doesn't prompt me every time for password (4 Replies)
Discussion started by: Moon1234
4 Replies

4. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

5. UNIX for Dummies Questions & Answers

Check password strength

For moderator: I made a new thread in a proper part of the forum now https://www.unix.com/homework-coursework-questions/137119-user-processes.html But now i wan't to make something which isn't related to a homework, so i hope you won't close this one. Thanks to those two answers, you helped me!... (9 Replies)
Discussion started by: petel1
9 Replies

6. Cybersecurity

Periodic check of user password strength

I need to periodically run a check on the passwords of the users (Redhat 5.0) to verify that all passwords meet minimal standards. I remember seeing a script years ago that grabbed the encrypted passwords from the file and checked if they matched any of the encrypted strings in another file, plus... (1 Reply)
Discussion started by: tlynnch
1 Replies

7. UNIX for Advanced & Expert Users

password verification verify password of a user for only first 8 characters

Helo , I m using linux pam library for user and its password authentication. I m creating new user and giving its password.I m giving password of 10 characters.now when I login in as that newly created user its ask me $ su - ram Password: You are required to change your password immediately... (12 Replies)
Discussion started by: amitpansuria
12 Replies

8. Solaris

How to check the last login user were doing in the system

Hi, I'm new to solaris/ Unix and would like to know how to check in the system what was the last login user were doing. Is there any way to check this? Thanks in advanced. (1 Reply)
Discussion started by: raziayub
1 Replies

9. UNIX for Dummies Questions & Answers

password check

Hi While using Pipe concept ,if a user enters a "login name" and "paswword" ,then how does a child process check for user password is correct or not and give notification to parent process. (1 Reply)
Discussion started by: riya
1 Replies
Login or Register to Ask a Question