Solved

Verifying a user's password

Posted on 1998-05-31
4
376 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

805 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