I am trying to write a cgi in C to let our user changing their password
through browser. But some questions arised:
1. I referenced several source packages and it seems that my program
must create a new master.passwd file. Is this the only way or there
are system call to help me update user's password?
2. If I created a new master.passwd file, I have to run pwd_mkdb to update
my password database. What function call is available to do this?
3. If I want my program portable to linux or solaris, Is it true that all I have
to do is update shadow file directly?
any help would be greatly appreciated.
---
Vincent Chen
vcb...@ms1.hinet.net
Taipei,Taiwan
R.O.C.
If you implement your CGI script in Tcl, you can probably cut and paste a lot of
this code directly.
(see /usr/ports/lang/expect)
Hope this is a machine not open to the Internet, or at least is using SSL. I'd
be concerned about others seeing plaintext passwords flying around ;-)
Good Luck,
Jerry Hicks
wgh...@bellsouth.net
On Sun, 29 Nov 1998, Vincent Chen wrote:
> Date: Sun, 29 Nov 1998 15:35:05 GMT
> From: Vincent Chen <vcb...@ms1.hinet.net>
> Newsgroups: comp.unix.bsd.freebsd.misc
> Subject: c program to change user's password?
> I am trying to write a cgi in C to let our user changing their password
>through browser. But some questions arised:
I'd suggest that you use expect or an expect like C program to
use /usr/bin/passwd to change the person's password from within
the CGI script. That way you know that it will be easy to port
to other OSs and you don't need to know anything about how their
password file works... Expect is in ports and packages.
David.
For best portability accross Solaris, FreeBSD, etc, I'd exec()
the 'passwd' command to change the password. However, there is a
trick to doing this. It seems that /bin/passwd does not read
from 'stdin'. Instead, /bin/passwd opens /dev/tty to read
input. /dev/tty is a synonym in the kernel for a processes
controlling tty so a pipe(), fork(), exec() will not work.
I ran into exactly this problem awhile back and solved it using
a pseudo tty for interprocess commnunication in place of a
pipe(). A pseudo tty can be made to be a processes controlling
terminal. For the programming model to use, code snippets, etc,
see Stevens "UNIX Network Programming", ISBN 0-13-949876-1,
beginning on page 600.
regards
--
John J. Rushford
j...@sapphire.alisa.org
j...@cs.du.edu
http://www.cs.du.edu/~jjr