Article 128757 of comp.os.vms:
Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!bloom-beacon.mit.edu!apollo.hp.com!lf.hp.com!news.dtc.hp.com!col.hp.com!usenet.eel.ufl.edu!news.mathworks.com!newshost.marcam.com!usc!elroy.jpl.nasa.gov!lll-winken.llnl.gov!fnnews.fnal.gov!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
Newsgroups: comp.os.vms
Subject: Re: Set Password from an image?
Date: 7 Sep 1995 10:08:51 GMT
Organization: HST Wide Field/Planetary Camera
Lines: 70
Distribution: world
Message-ID: <42mgbj$7mm@gap.cco.caltech.edu>
References: <810416070snz@gisrss.demon.co.uk>
Reply-To: carl@SOL1.GPS.CALTECH.EDU
NNTP-Posting-Host: sol1.gps.caltech.edu

In article <810416070snz@gisrss.demon.co.uk>, Andy Pennington <adp@gisrss.demon.co.uk> writes:
=
=Is there any code floating around which does a password change from an
=image:
=
=What I am really after is something that could be run from DCL like:
=
=	$ set_pass:==$somewhere:set_pass.exe
=	$ set_pass <username> <old-password> <new-password>
=
=This would have to be installable, and would obviously check the old
=password before changing to the new password.

No problem:

#include descrip
#include UAIDEF
#define ckstat(x) if(((stat = x) & 7) != 1) return stat

main(int nargs, char **args)
{	unsigned long SYS$HASH_PASSWORD(), SYS$SETUAI(), SYS$GETUAI(),
		SYS$EXIT(), STR$UPCASE(), puts(), strlen();
	$DESCRIPTOR(pwd, "");
	$DESCRIPTOR(usrnam, "");
	static unsigned char alg;
	static unsigned short salt;
	static unsigned long hash[2], password[2], stat;
	struct ITEM_LIST_3
	{	unsigned short buflen, itmcod;
		unsigned long bufadr, reslen;
	} itmlst1[] =
	{	{ 1, UAI$_ENCRYPT, (unsigned short) &alg, 0 },
		{ 2, UAI$_SALT, (unsigned short) &salt, 0 },
		{ 8, UAI$_PWD, (unsigned long) password, 0 },
		{ 0, 0, 0, 0 }
	}, itmlst2[] =
	{	{ 8, UAI$_PWD, (unsigned long) password, 0 },
		{ 0, 0, 0, 0 }
	};

	if (nargs != 4)
	{	puts("Usage: SET_PASSWORD username old_password new_password");
		SYS$EXIT(1);
	}
	usrnam.dsc$a_pointer = *++args;
	usrnam.dsc$w_length = strlen(*args);
	pwd.dsc$a_pointer = *++args;
	pwd.dsc$w_length = strlen(*args);
	ckstat(STR$UPCASE(&usrnam, &usrnam));
	ckstat(STR$UPCASE(&pwd, &pwd));	
	ckstat(SYS$GETUAI(0, 0, &usrnam, itmlst1, 0, 0, 0));
	ckstat(SYS$HASH_PASSWORD(&pwd, alg, salt, &usrnam, hash));
	if((hash[0] != password[0]) || (hash[1] != password[1]))
	{	puts("Invalid login information");
		SYS$EXIT(1);
	}
	pwd.dsc$a_pointer = *++args;
	pwd.dsc$w_length = strlen(*args);
	ckstat(STR$UPCASE(&pwd, &pwd));
	ckstat(SYS$HASH_PASSWORD(&pwd, alg, salt, &usrnam, password));
	SYS$EXIT(SYS$SETUAI(0, 0, &usrnam, itmlst2, 0, 0, 0));
}
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.


