Solved

Unix - getpwuid & getprpwuid

Posted on 1999-01-18
3
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

730 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