[fpc-pascal]Password changing

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Jun 6 22:44:44 CEST 2002

On Thu, 6 Jun 2002, Helio Cavichiolo Jr wrote:

> Thank you Vassilis, but I thought fpc had a function to do that.
> I'm currently using...
> shell('echo "',user,':',pass,'" | chpasswd');
> ...but would prefer something system independent.

The correct way is to use get(s)pwnam()/put(s)pwnam() from the libc library.

TPasswordRecord = record
  pw_name : pchar;
  pw_passwd : pchar;
  pw_uid : pchar;
  pw_gid : pchar;
  pw_gecos : pchar;
  pw_dir : pchar;
  pw_shell : pchar;
PPasswordRecord = ^TPasswordRecord;

getpwnam (UserName : Pchar) : PPasswordRecord;cdecl;external 'c' name getpwnam;

and similar for putpwnam.

Do a man getpwent and you should get all possible info.

Take care that systems with shadow passwords use getspwnam().


More information about the fpc-pascal mailing list