Solved

Verifying a user's password

Posted on 1998-05-31
4
381 Views
Last Modified: 2010-04-21
I am writing a UNIX program to verify a user's UNIX user name and password. UNIX includes a structure called passwd that allows programmers to verify fields in the passwd file. Comparing and verifying the user inputted/supplied name can be accomplished using this structure; however, the users inputted/supplied password can not, since it must be encrypted before it can be used. Is there a function that encrypts the user's inputted password? Th objective is to compare it against the field in the passwd file.


ronandersen@hotmail.com
0
Comment
Question by:ronandersen
  • 2
4 Comments
 

Author Comment

by:ronandersen
ID: 2007309
Edited text of question
0
 

Author Comment

by:ronandersen
ID: 2007310
This question should probably go under the topic UNIX programming, although administrators could benefit from the response.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2007311
man 3 crypt

0
 
LVL 1

Accepted Solution

by:
hajek earned 100 total points
ID: 2007312
integer pw_compare(current, check)
char    *current,               /* Current pw (encrypted) */
        *check;                 /* check pw (plain) */
{
        if (!*current)
                return(0);
        return(!strcmp(current, crypt(check, current)));
}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reinstall 1 85
Parsing a file using ksh 10 71
recommend secure & efficient Unix LDAP (equiv of Windows AD) 6 111
mobaxterm not able to change directory 28 207
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question