Download pakken aix.tools hos
http://freeware.bull.net de har lavet et program i C, der kan gøre det. Her er source koden:
/*
chpass - change a user\'s password from a script
Copyright (C) 1996, 1997 GROUPE BULL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Use the following command to compile:
# cc -o chpass chpass.c -ls
*/
#include <userpw.h>
#include <sys/types.h>
#include <pwd.h>
#include <usersec.h>
#include <errno.h>
#define KEYCRYPTLEN 2
void usage (){
printf(\"Usage: chpass user passwd\\n\");
exit(1);
}
main (int argc,char *argv[]){
int id;
struct userpw *p;
char user[PW_NAMELEN], pass[PW_PASSLEN], pass2[KEYCRYPTLEN];
char *nwpass;
struct userpw newpw; /* passwd structure if getuserpw fails */
if (argc != 3) usage();
/* calcul du passwd crypte ... */
strcpy(user,argv[1]);
strcpy(pass,argv[2]);
strncpy(pass2,pass,2);
nwpass=(pass,pass2);
/* infos DEBUG
printf(\"passwd crypti : %s\\n\",nwpass);
printf(\"Avant modif : \\n\");
printf(\"------------- \\n\");
*/
/* open data bases for read and write */
setpwdb (S_READ|S_WRITE);
setuserdb (S_READ|S_WRITE);
p=getuserpw(user);
/* On verifie si le user existe ... */
/* Check if the user exists */
if (getuserattr(user,S_ID,&id,SEC_INT))
{
printf(\"\\nuser %s inconnu ...\\n\\n\",user);
return(-1);
exit(ENOENT);
}
if (!(p=getuserpw(user))){
printf(\"structure passwd vide %s ...\\n\\n\",user);
printf(\"%s : user\\n\",user);
/* initialize new userpw struct */
strcpy(newpw.upw_name,user);
newpw.upw_passwd = nwpass;
newpw.upw_lastupdate = time ((long *) 0);
newpw.upw_flags =0;
printf(\"Nom : %s\\n\",user);
printf(\"Password : %s\\n\",newpw.upw_passwd);
printf(\"LastUpdate : %u\\n\",newpw.upw_lastupdate);
printf(\"Flags : %u\\n\\n\\n\",newpw.upw_flags);
putuserpwhist(&newpw);
putuserattr(user,S_PWD,\"!\",SEC_CHAR);
putuserattr(user,NULL,NULL,SEC_COMMIT);
p=getuserpw(user);
/*putuserpw(p); */
}
/* infos DEBUG
printf(\"Nom : %s\\n\",p->upw_name);
printf(\"Password : %s\\n\",p->upw_passwd);
printf(\"LastUpdate : %u\\n\",p->upw_lastupdate);
printf(\"Flags : %u\\n\\n\\n\",p->upw_flags);
*/
/* on met a jour la structure memoire ... */
strcpy(p->upw_passwd,crypt((const *)pass,(const *)pass2));
/* infos DEBUG
printf(\"Apres modif MEMOIRE : \\n\");
printf(\"------------- \\n\");
printf(\"Nom : %s\\n\",p->upw_name);
printf(\"Password : %s\\n\",p->upw_passwd);
printf(\"LastUpdate : %u\\n\",p->upw_lastupdate);
printf(\"Flags : %u\\n\\n\\n\",p->upw_flags);
*/
/* ----------------------------- MAJ du passwd dans la base */
setpwdb(S_WRITE);
putuserpw(p);
endpwdb();
}