Gentlemen,
Im writing a program that read all user in /etc/shadow, and for each user,
him generate a ramdom number, set this number as password and then, will to
send a email (calling perl::system()) to this user with the password
generated.
Its alright, except which i need record the new password in shadow
The source follow below:
#include <unistd.h>
#include <stdio.h>
#include <shadow.h>
int main(int argc,char * argv[])
{
char *cpw, *login, *senha;
char buf[200];
struct spwd *shad;
setspent();
shad = getspnam(argv[1]);
login = (char *)shad->sp_namp;
senha = (char *)shad->sp_pwdp;
// Below im trying set the password returned by crypt function
// to struct of shadow.( i think that here im missing)
shad->sp_pwdp = (char *)crypt(argv[2],argv[2]);
// The two lines below, are my debug :-)
sprintf(buf, "Login: %s\nSenha: %s\n", login, senha);
printf("%s",buf);
endspent();
Im Waiting for any help!Quote:}
--