home *** CD-ROM | disk | FTP | other *** search
- MS-DOS passwd library
- Stephen C. Trier
-
- In the process of porting UNIX software to MS-DOS, especially news and
- mail packages, I've run into a need for the UNIX-style password file
- functions. This time I couldn't find a different way out, so I whipped up
- these functions. They aren't secure, and they aren't intended to be. Instead,
- they are meant to access the second function of the UNIX passwd file, which is
- to contain information about various users. This they should do well. Please
- note again: THESE FUNCTIONS ARE NOT INTENDED TO BE USED TO PROVIDE SECURITY TO
- AN MS-DOS SYSTEM. However, they _are_ intended to simplify the task of porting
- UNIX applications to the MS-DOS environment.
-
- The most significant difference between these functions and the UNIX
- version is the format of the /etc/passwd file. Because home directory
- specifications should really include a drive letter, and the drive name
- requires a colon, these routines expect the file to have its fields separated
- by semicolons. This should not change the functionality of these routines,
- because the delimiter is never seen by the application program.
-
- Where will the password file be found? The library looks for a shell
- variable named PASSWD to determine the location of the file. If that variable
- has not been defined, the library uses a UNIX-style path of /etc/passwd. Your
- program can override these choices, however, by calling the function pw_open()
- with a filename as an argument. Calling pw_open with NULL as the argument
- tells it to use the shell-variable and default name to find the file.
-
- I cannot guarantee that these functions are a wonderfully exact clone of
- the UNIX versions; there may even be some big differences. This is because I
- have no real documentation available about the UNIX versions. However, that
- also means that I am free to place my version in the public domain. Use it as
- you wish, and I would be quite interested in hearing of any changes or
- improvements you make.
-
- There is a simple makefile included, but it is not capable of building
- more than one library at a time. That's a bit beyond my makefile-writing
- ability, so if you want a fully-automated, whiz-bang makefile, you'll have to
- write it yourself. (I'd be rather interested in such a beast, to tell the
- truth.)
-
- Hope these are useful to you.
-
- Stephen
-
-
-
- How to reach me by email:
- sct%seldon@scl.cwru.edu will work until May 1990, and (maybe) later.
- sct@po.cwru.edu will work throughout the scholastic year.
- sct@seldon.UUCP will work once I find another feed and get a map entry.
-
- Sample output from the test program:
-
- ---------- cut here ----------
- Name: user1 Password: password1 User Num: 1 Group Num: 11
- Full Name: Joe User Home Dir: \homes\user1 Shell: sh1
-
- Name: user2 Password: password2 User Num: 2 Group Num: 12
- Full Name: Joe User Jr. Home Dir: \homes\user2 Shell: sh2
-
- Name: user3 Password: password3 User Num: 3 Group Num: 13
- Full Name: Joe User III Home Dir: \homes\user3 Shell: sh3
-
- setpwent returns 0
- Name: user1 Password: password1 User Num: 1 Group Num: 11
- Full Name: Joe User Home Dir: \homes\user1 Shell: sh1
-
- Name: user2 Password: password2 User Num: 2 Group Num: 12
- Full Name: Joe User Jr. Home Dir: \homes\user2 Shell: sh2
-
- Name: user3 Password: password3 User Num: 3 Group Num: 13
- Full Name: Joe User III Home Dir: \homes\user3 Shell: sh3
-
- setpwent returns 0
- Finding user3: user3
- Finding user1: user1
- Finding user2: user2
- Finding user4: NULL (Should be NULL)
-
- Finding user id 2: user2
- Finding user id 1: user1
- Finding user id 3: user3
- Finding user id 4: NULL (Should be NULL)
-
- endpwent returns 0
- --------- cut here ---------
-
- Remember that in order to get this output, one of the following must be true:
- (1) the included "passwd" file is in \etc\passwd, or (2) the $PASSWD
- environment variable must point to its location. (set PASSWD=passwd is
- probably sufficient for testing purposes.)