Solved

Unix - getpwuid & getprpwuid

Posted on 1999-01-18
3
374 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Picking random number 8 178
My eclipse editor won't start ? 4 162
C#, VS15, StructLayout 1 135
Autosar OS Multicore Share Resources confusion ? 2 72
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

829 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