Ahhh... this clarifies your first posting
considerably
The short answer... I don't know if that can be
done but if it could, it would seem like a
security hole. Since the passwd program should not
accept input from anything other than an actual
"tty" attached to stdin. Having said that, a C
program run as root can pretty much do anything.
You may consider writing your own C program
to do it or look around (maybe as part of a
root kit or somthing but I woun't recommend
those
) for some code fragments.