refresh shadow password using shadow.h

refresh shadow password using shadow.h

Post by Abili » Sat, 02 Jun 2001 02:46:14



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();

Quote:}

Im Waiting for any help!
--
 
 
 

refresh shadow password using shadow.h

Post by Nate Eldredg » Sat, 02 Jun 2001 03:44:47



> 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

You can't use the getsp* functions to change /etc/shadow.  Your
program will have to rewrite it manually.

--

Nate Eldredge


 
 
 

refresh shadow password using shadow.h

Post by Nithyanandha » Sat, 02 Jun 2001 04:23:40




> > 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

> You can't use the getsp* functions to change /etc/shadow.

Correct this....Is getsp* for changing the sp entries ?

--Nithyanand.
  Siemens, Bangalore, India.

 
 
 

refresh shadow password using shadow.h

Post by Nate Eldredg » Sat, 02 Jun 2001 04:46:22




> > You can't use the getsp* functions to change /etc/shadow.

> Correct this....Is getsp* for changing the sp entries ?

I don't understand what you're asking.

--

Nate Eldredge

 
 
 

1. ERROR: KDE shadow password error although no shadow passwords used

Hi Folks,

I get the following error message from Setting up Screensaver:

*********************************************************
Warning: You wont be able to lock the screen

Your system uses shadow passwords.
Please contact your system administrator.
Tell him that you need suid for the kcheckpass program!
*********************************************************

--
Cu Andy


// URL: http://homepages.munich.netsurf.de/Andreas.Reuter \\

2. 16K colors running MetroX

3. Shadow password files vs. non-shadowed passwords

4. Standard Monitor And GXT800P

5. Shadow package from sunsite (shadow'd passwords)

6. Galeon 1.0.3

7. Question about using Shadow Passwords

8. grabbing stdout,stderr

9. centralize shadow password using NIS

10. Anyone using S/Key with shadow passwords?

11. determiniting if a system is actually using shadow passwords

12. centralize shadow password using NIS

13. Using shadow password option for POP mail