Пример #1
0
static Fnew (lua_State *L) {
struct memory_zone bf;
char* name = luaL_checkstring(L, 1);
luaL_argcheck(L, (strlen(name) >=2)&&(strlen(name <=8)),1, "bad name size");
luaL_argcheck(L, name[0] == 'L' && name[1] == 'F',1,"name must begin with LF");
luaL_argcheck(L, search_mem_zone(1,name,&bf)==-1,1,"file do already exist");
int size = luaL_checkint(L, 2);
int size2 = size;
static const char *const opts[] ={"char","uchar","int","float"};
int option = luaL_checkoption(L, 3, "float", opts);
switch (option) { case 0: case 1: break;
                  case 2: size2*=2; break;
                  case 3: size2*=4;
                }
luaL_argcheck(L, (size2>0)&&(size>0),2,"bad size");
filedata *f = (filedata *)lua_newuserdata(L,sizeof(filedata));
luaL_getmetatable(L, "ramfile");
lua_setmetatable(L, -2);
globalrefresh++;
if (create_mem_zone(1,name,(unsigned int)size2 + 24,CREATE_ZONE)<0 ) luaL_error(L,"not enough memory for file");
search_mem_zone(1,name,&(f->bf));
f->taillezone = size;
f->debut = MK_FP(f->bf.segment+1, f->bf.offset+5);
f->refreshnum = globalrefresh;
f->close =0;
f->option = option;
change_password(&(f->bf),"LUAF");
return 1;
}
Пример #2
0
int main() {

	char *installationChoice = (char *) malloc(sizeof(installationChoice));

	int choice;
	
	printf("### Subuntu Login Menu ###\n");
	printf("### 1. Unlock System ###\n");
	printf("### 2. Add New User ###\n");
	printf("### 3. Delete User ###\n");
	printf("### 4. Change Password ###\n");
	printf("### 5. Exit ###\n");
	
	printf("Please enter your choice: ");
	scanf("%d", &choice);

	if(choice == 1) {
		login_diffuser();
	} else if(choice == 2) {
		add_user();
	} else if(choice == 3) {
		delete_user();
	} else if(choice == 4) {
		change_password();
	} else if(choice == 5) {
		exit(0);
	} else {
		printf("Invalid Option!\n");
		printf("Please enter your choice: ");
		scanf("%d", &choice);
	}
}
Пример #3
0
int main(int argc, char **argv) {
  int i;
  FILE *password_file;
  int digits[16] = {0};
  char password[64];
  char new_password[64];
  char confirm_password[64];

  generate_hex_table();

  password_file = fopen(password_file_path, "r");
  if (password_file == NULL) {
    perror("fopen");
    return 1;
  }
  read_password(password_file, password, sizeof(password));
  fclose(password_file);

  printf("New password: "******"Invalid character: %c\n", new_password[i]);
      exit(1);
    }
    digits[index] = 1;
  }

  for (i = 0; i <= 16; ++i) {
    if (digits[i] == 0) {
      printf("Password is not complex enough: %d\n", i);
      return 1;
    }
  }

  printf("Confirm old password: "******"Old password is incorrect.\n");
    return 1;
  }

  change_password(new_password);
  printf("Password changed!\n");
  return 0;
}
Пример #4
0
//Allows user to change their password
void Bank::change_password() {
	string line, old_password, new_password1, new_password2;
	int customer_id;
	cout << "--Password Change Menu--" << endl << endl;
	cout << "This menu will allow you to change your password." << endl << endl;
	cout << "To make sure this is you, please enter your customer ID again: "; cin >> customer_id;
	cout << "Please enter your old password: "******" " + old_password;
	if (credential_validation(customer_id, old_password)) {
		cout << "Please enter your new password: "******"Please enter your new password again for verification: "; cin >> new_password2;
		if (new_password1 == new_password2) {
			ifstream in("login_information.txt");
			if (!in.is_open()) {
				cout << "Input file failed to open \n";
			}
			ofstream out("outfile.txt");
			while (getline(in, line)) {
				if (line != delete_line) {
					out << line << endl;
				}
			}
			in.close();
			out.close();
			//Delete original file
			remove("login_information.txt");
			//Rename old to new
			rename("outfile.txt", "login_information.txt");
			//Adds new password to login file
			fstream newPassword;
			newPassword.open("login_information.txt", std::fstream::in | std::fstream::out | std::fstream::app);
			newPassword << customer_id << " " << new_password1;
			newPassword.close();
			cout << "--Successfully Changed Password--" << endl << endl;
		}
		else {
			cout << "The password you entered to not match your first password entry. Please try again." << endl;
			change_password();
		}
	}
	else {
Пример #5
0
//Main Menu allows user to select different menu options
void Bank::main_menu() {
	cout << "--Main Menu--" << endl;
	cout << "Enter 1 to view your monthly statement." << endl;
	cout << "Enter 2 to view total of an account." << endl;
	cout << "Enter 3 to make a payment on your loan." << endl;
	cout << "Enter 4 to change your password." << endl;
	cout << "Enter 0 to exit application." << endl;
	int option = get_input();
	switch (option) {
	case 0:
		exit(0);
	case 1:
		print_customer_statements();
	case 2:
		customer_total();
	case 3:
		customer_payment();
	case 4:
		change_password();
	}

}
Пример #6
0
void chat_interface(int new_fd)
{
    clear();
    refresh();
    
    int flag = 3;

    int ch;

    WINDOW *new_window1, *new_window2, *new_window5;

    setlocale(LC_ALL, "");
    //initscr();

    //keypad(ch_window4, 1);

    new_window1 = newwin(3, 91,0,22);
    ch_window2 = newwin(13, 68,4,23);
    new_window5 = newwin(15, 70,3,22);
    ch_window3 = newwin(6, 70,18,22);
    ch_window4 = newwin(21, 21,3,92);
    ch_window5 = newwin(6, 20,0,2);
    ch_window1 = newwin(18, 20,6,2);

    box(new_window1, 0, 0);
    box(ch_window4, 0, 0);
    box(ch_window5, 0, 0);
    box(new_window5, 0, 0);
    box(ch_window1, 0, 0);
    box(ch_window2, ' ', ' ');
    box(ch_window3, 0, 0);

    mvwaddstr(ch_window1, 1, 5, "ONLINE-USER");
    mvwaddstr(ch_window1, 2, 5, "===========");

    mvwaddstr(ch_window5, 2, 7, msg1.name);
    mvwaddstr(ch_window5, 3, 6, msg1.id);
    
    mvwaddstr(ch_window4, 1, 6, "FUNCTION");
    mvwaddstr(ch_window4, 2, 5, "===========");
    mvwaddstr(ch_window4, 3, 5, "私聊");
    mvwaddstr(ch_window4, 4, 5, "群聊");
    mvwaddstr(ch_window4, 5, 5, "发送表情");
    mvwaddstr(ch_window4, 6, 5, "查看聊天记录");
    mvwaddstr(ch_window4, 7, 5, "删除聊天记录");
    mvwaddstr(ch_window4, 8, 5, "发送文件");
    mvwaddstr(ch_window4, 9, 5, "修改昵称");
    mvwaddstr(ch_window4, 10, 5, "修改密码");
    mvwaddstr(ch_window4, 11, 5, "切换用户");

    wrefresh(new_window1);
    wrefresh(ch_window3);
    wrefresh(ch_window5);
    wrefresh(new_window5);
    wrefresh(ch_window1);
    wrefresh(ch_window2);
    wrefresh(ch_window4);
 
    mvwaddstr(ch_window4, flag, 3, "=>");
    wrefresh(ch_window4);

    keypad(ch_window4,true);

    cbreak();

    while(1)
    {
        if(filesend == FILE_SEND)
	{
	    file_receive(new_fd);

	    filesend = 0;
	}

        curs_set(0);
        
        /*mvwaddstr(ch_window4, flag, 3, "  ");
	
	flag = 3;

        mvwaddstr(ch_window4, flag, 3, "=>");
	wrefresh(ch_window4);*/

        noecho();
        while((ch = wgetch(ch_window4)) != '\n')
	{
	    if(ch == KEY_UP)
	    {
		mvwaddstr(ch_window4, flag, 3, "  ");

	        if(flag == 3)
		{
		    flag = 11;
		}
		else
		{
		    flag--;
		}

		mvwaddstr(ch_window4, flag, 3, "=>");
	    }
	    if(ch == KEY_DOWN)
	    {
		mvwaddstr(ch_window4, flag, 3, "  ");
                 
	        if(flag == 11)
		{
		    flag = 3;
		}
		else
		{
		    flag++;
		}

		mvwaddstr(ch_window4, flag, 3, "=>");
	        
	    }

	    wrefresh(ch_window4);
	}

	switch(flag)
	{
	    case 3:
	    {
	        private_chat(new_fd);
                break;
	    }
	    case 4:
	    {
	        group_chat(new_fd);
	        break;
	    }
	    case 5:
	    {   
	        send_face(new_fd);
	        break;
	    }
	    case 6:
	    {
	        check_history(new_fd);
	        break;
	    }
	    case 7:
	    {
	        delete_history(new_fd);
	        break;
	    }
	    case 8:
	    {
	        file_send(new_fd);
	        break;
	    }
	    case 9:
	    {
	        change_name(new_fd);
	        break;
	    }
	    case 10:
	    {
 
	        change_password(new_fd);

    box(new_window1, 0, 0);
    box(ch_window4, 0, 0);
    box(ch_window5, 0, 0);
    box(new_window5, 0, 0);
    box(ch_window1, 0, 0);
    box(ch_window2, ' ', ' ');
    box(ch_window3, 0, 0);

    mvwaddstr(ch_window1, 1, 5, "ONLINE-USER");
    mvwaddstr(ch_window1, 2, 5, "===========");

    mvwaddstr(ch_window5, 2, 7, msg1.name);
    mvwaddstr(ch_window5, 3, 6, msg1.id);
    
    mvwaddstr(ch_window4, 1, 6, "FUNCTION");
    mvwaddstr(ch_window4, 2, 5, "===========");
    mvwaddstr(ch_window4, 3, 5, "私聊");
    mvwaddstr(ch_window4, 4, 5, "群聊");
    mvwaddstr(ch_window4, 5, 5, "发送表情");
    mvwaddstr(ch_window4, 6, 5, "查看聊天记录");
    mvwaddstr(ch_window4, 7, 5, "删除聊天记录");
    mvwaddstr(ch_window4, 8, 5, "发送文件");
    mvwaddstr(ch_window4, 9, 5, "修改昵称");
    mvwaddstr(ch_window4, 10, 5, "修改密码");
    mvwaddstr(ch_window4, 11, 5, "切换用户");

    wrefresh(new_window1);
    wrefresh(ch_window3);
    wrefresh(ch_window5);
    wrefresh(new_window5);
    wrefresh(ch_window1);
    wrefresh(ch_window2);
    wrefresh(ch_window4);
 
    mvwaddstr(ch_window4, flag, 3, "=>");
    wrefresh(ch_window4);


                     break;

	    }
	    case 11:
	    {
                clear();
                refresh();
                new_window2 = newwin(13, 50, 5, 30);
                box(new_window2, 0, 0);
                mvwaddstr(new_window2, 3, 22, "GOODBYE");
                mvwaddstr(new_window2, 5, 22, msg1.name);
		wrefresh(new_window2);

		msg1.action = QUIT;
		write(new_fd, &msg1, sizeof(Node));

	        goto EXIT_CHATINTERFACE;
	        break;
	    }
	}
    }

    EXIT_CHATINTERFACE:

    curs_set(1);
    wgetch(new_window1);

}
Пример #7
0
int main()
{
	string username;
	string password;
	string command;
	string subcommand;
	string temp_path;
	char t;
	load_user();
	init();
	save();
	while (1)
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
		cout << "welcome to system" << endl;
		cout << "please login" << endl;
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
		while (1)
		{
			username = "";
			password = "";
			cout << "username:"******"password:"******"username or password error" << endl;
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
			}
		}
		system("cls");
		getline(cin, command);
		while (1)
		{
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
			cout << username;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED);
			cout << "@filesystem ";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
			if (path.size() == 1)
				cout << "/";
			else
			{
				for (auto p : path)
				{
					if (p == 0)
						continue;
					cout << "/" << catalog[p].info.name;
				}
			}
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
			cout << endl << ">";
			getline(cin, command);
			stringstream command_stream(command);
			command_stream >> subcommand;
			if (subcommand == "")
			{

			}
			else if (subcommand == "cd")
			{
				change_path(command);
			}
			else if (subcommand == "ls")
			{
				show_folder(command);
			}
			else if (subcommand == "create")
			{
				create(command);
			}
			else if (subcommand == "mkdir")
			{
				create_folder(command);
			}
			else if (subcommand == "delete")
			{
				delete_file(command);
			}
			else if (subcommand == "edit")
			{
				edit(command);
			}
			else if (subcommand == "search")
			{
				search_file(command);
			}
			else if (subcommand == "open")
			{
				open_file(command);
			}
			else if (subcommand == "close")
			{
				close_file(command);
			}
			else if (subcommand == "cp")
			{
				copy(command);
			}
			else if (subcommand == "mv")
			{
				move(command);
			}
			else if (subcommand == "bs"){
				backstage();
			}
			else if (subcommand == "l"){
				l();
			}
			else if (subcommand == "info"){
				info();
			}
			else if (subcommand == "format")
			{
				char c;
				cout << "Are you sure you want to format the disk?(y/N)";
				c = _getch();
				if (c == 'n' || c == 'N' || c == '\r')
				{
					cout << c << endl;
					continue;
				}
				else if (c == 'y' || c == 'Y')
				{
					remove("disk.txt");
					remove("diskdata.txt");
					init();
					cout << c << "\nformat complete" << endl;
				}
			}
			else if (subcommand == "useradd")
			{
				add_user(command);
			}
			else if (subcommand == "userdelete")
			{
				delete_user(command);
			}
			else if (subcommand == "passwd")
			{
				change_password(command);
			}
			else if (subcommand == "clear")
			{
				system("cls");
			}
			else if (subcommand == "exit")
			{
				system("cls");
				break;
			}
			else
			{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
				cout << "command not found" << endl;
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
			}
			cout << endl;
			save();
			command = "";
			subcommand = "";
		}
	}
}
int main(){

    HWND hwnd = GetConsoleWindow();
	ShowWindow(hwnd,SW_MAXIMIZE);
    console_settings();
    console_resize(3);
    login=fopen("save\\logins.dat","rb");
    if(login==NULL)
        admin_settings_signup();
    else
        admin_settings_signin();

    main_menu();
    start_socket();
    start_server();

    handleAccept = (HANDLE) _beginthread(thd_accept_connections,0,0);
    handleMessages = (HANDLE) _beginthread(thd_program_messages,0,0);
    //clientHandle = (HANDLE) _beginthread( thd_receive_data,0,0);

    while(1){  // The interface part
      switch(getch()){
        case '1':
                if(flag_menu==0)
                   requests();
                else if(flag_menu==2)
                    services();
                else if(flag_menu==21)
                    add_services();
                else if(flag_menu==22)
                    setcost();
                else if(flag_menu==24)
                    change_password();
                break;
            case '2':
                if(flag_menu==0)
                    settings();
                else if(flag_menu==2)
                    cost();
                else if(flag_menu==22)
                    viewcost();
                else if(flag_menu==21)
                    view_services();
                break;
            case '3':
                if(flag_menu==0){
                    saveMessagesToFile();
                    exit(0);
                }
                else if(flag_menu==2)
                    member_settings_signup();
                else if(flag_menu==21)
                    edit_services();
                break;
            case '4':
                if(flag_menu==21)
                    search_services();
                else if(flag_menu==2)
                    admin_settings();
                break;
            case '5':
                if(flag_menu==21)
                    delete_services();
                         break;
            case 'r':
                if(flag_menu == 0)
                    flag_reset = true;
                    main_menu();
                    break;

            case 27:
                if(flag_menu==2 || flag_menu==1 )
                    main_menu();
                else if(flag_menu==21)
                     settings();
                else if( flag_menu==22)
                     settings();
                else if(flag_menu==23)
                     settings();
                else if(flag_menu==24)
                     settings();
                else if(flag_menu==211)
                     services();
                else if(flag_menu==212)
                     services();
                else if(flag_menu==213)
                     services();
                else if(flag_menu==214)
                     services();
                else if(flag_menu==215)
                     services();
                else if(flag_menu==221 || flag_menu==222)
                     cost();
                break;
            default:
                break;
            }
        }
return 0;
}
Пример #9
0
int
main (int argc, char **argv)
{
    krb5_error_code ret;
    krb5_context context;
    krb5_principal principal;
    krb5_get_init_creds_opt *opt;
    krb5_ccache id = NULL;
    int exit_value;
    int optidx = 0;

    setprogname(argv[0]);

    if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx))
	usage(1, args, sizeof(args) / sizeof(args[0]));
    if (help_flag)
	usage(0, args, sizeof(args) / sizeof(args[0]));
    if (version_flag) {
	print_version(NULL);
	return 0;
    }
    argc -= optidx;
    argv += optidx;

    ret = krb5_init_context (&context);
    if (ret)
	errx (1, "krb5_init_context failed: %d", ret);

    ret = krb5_get_init_creds_opt_alloc (context, &opt);
    if (ret)
	krb5_err(context, 1, ret, "krb5_get_init_creds_opt_alloc");

    krb5_get_init_creds_opt_set_tkt_life (opt, 300);
    krb5_get_init_creds_opt_set_forwardable (opt, FALSE);
    krb5_get_init_creds_opt_set_proxiable (opt, FALSE);

    if (cred_cache_str) {
	ret = krb5_cc_resolve(context, cred_cache_str, &id);
	if (ret)
	    krb5_err (context, 1, ret, "krb5_cc_resolve");
    } else {
	ret = krb5_cc_new_unique(context, krb5_cc_type_memory, NULL, &id);
	if (ret)
	    krb5_err (context, 1, ret, "krb5_cc_new_unique");
    }

    if (cred_cache_str == NULL) {
	krb5_principal admin_principal = NULL;
	krb5_creds cred;

	if (admin_principal_str) {
	    ret = krb5_parse_name (context, admin_principal_str,
				   &admin_principal);
	    if (ret)
		krb5_err (context, 1, ret, "krb5_parse_name");
	} else if (argc == 1) {
	    ret = krb5_parse_name (context, argv[0], &admin_principal);
	    if (ret)
		krb5_err (context, 1, ret, "krb5_parse_name");
	} else {
	    ret = krb5_get_default_principal (context, &admin_principal);
	    if (ret)
		krb5_err (context, 1, ret, "krb5_get_default_principal");
	}

	ret = krb5_get_init_creds_password (context,
					    &cred,
					    admin_principal,
					    NULL,
					    krb5_prompter_posix,
					    NULL,
					    0,
					    "kadmin/changepw",
					    opt);
	switch (ret) {
	case 0:
	    break;
	case KRB5_LIBOS_PWDINTR :
	    return 1;
	case KRB5KRB_AP_ERR_BAD_INTEGRITY :
	case KRB5KRB_AP_ERR_MODIFIED :
	    krb5_errx(context, 1, "Password incorrect");
	    break;
	default:
	    krb5_err(context, 1, ret, "krb5_get_init_creds");
	}

	krb5_get_init_creds_opt_free(context, opt);

	ret = krb5_cc_initialize(context, id, admin_principal);
	krb5_free_principal(context, admin_principal);
	if (ret)
	    krb5_err(context, 1, ret, "krb5_cc_initialize");

	ret = krb5_cc_store_cred(context, id, &cred);
	if (ret)
	    krb5_err(context, 1, ret, "krb5_cc_store_cred");

	krb5_free_cred_contents (context, &cred);
    }

    if (argc == 0) {
	exit_value = change_password(context, NULL, id);
    } else {
	exit_value = 0;

	while (argc-- > 0) {

	    ret = krb5_parse_name (context, argv[0], &principal);
	    if (ret)
		krb5_err (context, 1, ret, "krb5_parse_name");

	    ret = change_password(context, principal, id);
	    if (ret)
		exit_value = 1;
	    krb5_free_principal(context, principal);
	    argv++;
	}
    }

    if (cred_cache_str == NULL) {
	ret = krb5_cc_destroy(context, id);
	if (ret)
	    krb5_err (context, 1, ret, "krb5_cc_destroy");
    } else {
	ret = krb5_cc_close(context, id);
	if (ret)
	    krb5_err (context, 1, ret, "krb5_cc_close");
    }

    krb5_free_context (context);
    return exit_value;
}
Пример #10
0
krb5_error_code KRB5_LIB_FUNCTION
krb5_get_init_creds_password(krb5_context context,
			     krb5_creds *creds,
			     krb5_principal client,
			     const char *password,
			     krb5_prompter_fct prompter,
			     void *data,
			     krb5_deltat start_time,
			     const char *in_tkt_service,
			     krb5_get_init_creds_opt *options)
{
    krb5_init_creds_context ctx;
    char buf[BUFSIZ];
    krb5_error_code ret;
    int chpw = 0;

 again:
    ret = krb5_init_creds_init(context, client, prompter, data, start_time, options, &ctx);
    if (ret)
	goto out;

    ret = krb5_init_creds_set_service(context, ctx, in_tkt_service);
    if (ret)
	goto out;

    if (prompter != NULL && ctx->password == NULL && password == NULL) {
	krb5_prompt prompt;
	krb5_data password_data;
	char *p, *q;

	krb5_unparse_name (context, client, &p);
	asprintf (&q, "%s's Password: "******"kadmin/changepw") == 0)
	   goto out;

	/* don't try to change password where then where none */
	if (prompter == NULL)
	    goto out;

	ret = change_password (context,
			       client,
			       ctx->password,
			       buf,
			       sizeof(buf),
			       prompter,
			       data,
			       options);
	if (ret)
	    goto out;
	chpw = 1;
	krb5_init_creds_free(context, ctx);
	goto again;
    }

 out:
    if (ret == 0)
	krb5_init_creds_get_creds(context, ctx, creds);

    if (ctx)
	krb5_init_creds_free(context, ctx);

    memset(buf, 0, sizeof(buf));
    return ret;
}
Пример #11
0
//模块的主体函数
void main_change_password()
{
	show_change_password();
	change_password();
}