Detaching program from controlling terminal

Ihsan Junaidi Ibrahim ihsan at synthexp.net
Mon Jun 14 22:45:22 PDT 2004


Hi all,

I'm somehow stuck in the loop now and am hoping some of you can give me 
pointers on how to proceed. Due to a customer requirement, I need to 
build a simple web-based (via cgi or php) script to change the system 
password. They found that sshing to the server and typing passwd to 
change the password is wee too involving hence the need to use a much 
friendlier interface. Letting the sysadmins change the user's password 
is not a good idea, as the sysadmins are outsourced and the users value 
their privacy. FYI, all the users has a /sbin/nologin shell set. I'm 
running FreeBSD 5.2.1.

I understand there are two primary way to change a user's password, 
either via passwd or pw. Since pw is a root-only program, that doesn't 
seem the best way to do it over the web so I'm left with passwd.

Since passwd gets its input from the controlling terminal, I simply 
cannot get an environment variable passed via stdin. Reading over 
daemon(8) I finally got it that I need to detach passwd from the 
controlling terminal and run it as a daemon.

This is where I entered the loop and never seem to get out of it. I 
couldn't get passwd to run properly because once it entered daemon mode, 
it locked up the whole terminal and subsequent tries also suffered the 
same fate.

If there's something that I have missed or there's better alternatives, 
please point it out. :)

Thanks,
Ihsan


More information about the freebsd-questions mailing list