xref: /csrg-svn/usr.bin/xsend/enroll/enroll.c (revision 37916)
111785Ssam #ifndef lint
2*37916Sbostic static char sccsid[] = "@(#)enroll.c	4.3 05/11/89";
311785Ssam #endif
411785Ssam 
5*37916Sbostic #include <sys/types.h>
6*37916Sbostic #include <pwd.h>
711785Ssam #include "xmail.h"
8*37916Sbostic #include "pathnames.h"
9*37916Sbostic 
1011785Ssam MINT *a[42], *x, *b, *one, *c64, *t45, *z, *q, *r, *two, *t15;
1111785Ssam char buf[256];
12*37916Sbostic char maildir[] = _PATH_SECRETMAIL;
1311785Ssam main()
1411785Ssam {
1511785Ssam 	int uid, i;
1611785Ssam 	FILE *fd;
1711785Ssam 	char *myname, fname[128];
1811785Ssam 	uid = getuid();
1912564Sralph 	myname = (char *) getlogin();
2011785Ssam 	if(myname == NULL)
2111785Ssam 		myname = getpwuid(uid)->pw_name;
2211785Ssam 	sprintf(fname, "%s/%s.key", maildir, myname);
2311785Ssam 	comminit();
2411785Ssam 	setup(getpass("Gimme key: "));
2511785Ssam 	mkb();
2611785Ssam 	mkx();
2711785Ssam #ifdef debug
2811785Ssam 	omout(b);
2911785Ssam 	omout(x);
3011785Ssam #endif
3111785Ssam 	mka();
3211785Ssam 	i = creat(fname, 0644);
3311785Ssam 	if(i<0)
3412564Sralph 	{	perror(fname);
3511785Ssam 		exit(1);
3611785Ssam 	}
3711785Ssam 	close(i);
3811785Ssam 	fd = fopen(fname, "w");
3911785Ssam 	for(i=0; i<42; i++)
4011785Ssam 		nout(a[i], fd);
4111785Ssam 	exit(0);
4211785Ssam }
43