/* Badpasswd shell for people that have not changed their passwd or have picked
a wrong one. Change the users shell to this to disable them.
	Logging in syslog under auth.debug
Written by Ken Wilcox	<wilcox@kpw104.rh.psu.edu>
									     */

/* Major Includes and safety defines so that is options are not there
   it does not blow beats						*/

#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
#include <syslog.h>
#include <sys/types.h>
#include <unistd.h>
#ifndef MAIL_FLAG
#define MAIL_FLAG sysadmin
#endif
#ifndef ADMIN_FLAG
#define ADMIN_FLAG sysadmin
#endif
#ifndef ROOM_FLAG
#define ROOM_FLAG sysadmin
#endif

/*	Needed Vars	*/
int uid_user; 		    /* user Uid */
struct passwd *get_passwd; /* Passwd structure */
char *t; 		   /* The users tty */

main(){
/* The syslogging */
	t = ttyname(STDIN_FILENO);
	uid_user = getuid();
	get_passwd = getpwuid(uid_user);
	openlog("badpasswd",LOG_PID,LOG_AUTH);
	syslog(LOG_DEBUG, "user %s got the badpasswd msg on %s", get_passwd->pw_name, t); 
	closelog();
/* The Message */
	printf("\n\n\n");
	printf("Your account has been disabled because of a bad passwd. To see about having\n");
	printf("your account re-activated, Pleae send mail ");
	printf(MAIL_FLAG);
	printf(" or stop and\n");
	printf("talk to ");
	printf(ADMIN_FLAG);
	printf(" in room\n");
	printf(ROOM_FLAG);
	printf(". Thank You!!\n\n\n\n");
	printf("Systems Staff\n\n\n\n");
	usleep(15*1000000);
}

