Solved

Unix - getpwuid & getprpwuid

Posted on 1999-01-18
3
372 Views
Last Modified: 2010-08-05
I need a c-program that will detect if the Unix System is trusted host or not and use the appropriate function
getpwuid - none trusted host
getprpwuid - trusted host

How do I do this?

If you know the answer and have sample code, please send it to me.  

I'm creating a cgi script that will authenticate users on a Web Site using the System password DB. This includes encrypting the password using crypt & the SALT and then comparing it to the encrypted System User password.  If they match, your logged in.
*** If you have already done this, please let me know and I'll reward you 500 points. ***

Thanks.
0
Comment
Question by:lerous
3 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1258173
getpwuid's purpose is to retrieve information about known users on a UNIX system, it has nocthig to do with trusted hosts.
Could you please explain your first section?
Where did you find getprpwuid?
0
 
LVL 3

Accepted Solution

by:
mliberi earned 200 total points
ID: 1258174
The following code is not a full CGI, but contains all you need to validate a user password

int userok(char *username; char *password)
/* validate username password */
/* if OK return 0  */
{
    char *p;
    struct passwd *passwd;
#ifdef AIX
  struct userpw *userpw; /* AIX stores password in /etc/security/passwd */
#endif

 if (!(passwd=getpwnam(username))) /* use getpwuid if you have user uid */
   return 1;                                      /* user not present in /etc/passwd */

#ifdef AIX
  if (!(userpw=getuserpw(passwd->pw_name)))
    return 2;
  p=userpw->upw_passwd;
#else
  p=passwd->pw_passwd;
#endif
  if (strcmp(crypt(password,p),p))
    return 3;   /* password mismatch */
  return 0;     /* user validated */
}
0
 

Author Comment

by:lerous
ID: 1258175
If you have an Unix Server, simply type "man getprpwuid" and if you read the documentation, it specifies all functions that are designed for trusted host systems where normally you would use getpwuid.
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

810 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