Ejemplo n.º 1
0
int login(struct clientinfo* clntinfo, int stage) {
	int ret = 0;

	if (! clntinfo->user && stage >= LOGIN_ST_USER) {
		say(clntinfo->clientsocket, "500 Error logging in\r\n");
		jlog(4, "No user was set - Cannot proceed");
		return CMD_ERROR;
	}

	if ((ret = login_setforward_user(clntinfo)) < 0) {
		/* the error is logged and say()ed */
		return CMD_ERROR;
	}

	if (! clntinfo->destination) {
		say(clntinfo->clientsocket, "500 Error logging in\r\n");
		jlog(4, "No destination was set - Cannot proceed");
		if (config_compare_option("logintime", "connect")) {
			jlog(4, "This may be because of your logintime --> connect setting");
		}
		return CMD_ERROR;
	}

	if (stage >= LOGIN_ST_CONNECTED) {
		ret = login_connect(clntinfo);
		if (ret) { return ret; }
	}
	if (stage >= LOGIN_ST_USER) {
		ret = login_sendauth_user(clntinfo);
		if (ret) { return ret; }
	}
	if (stage >= LOGIN_ST_FULL) {
		ret = login_connect(clntinfo);
		if (ret) { return ret; }
		ret = login_setforward_pass(clntinfo);
		if (ret) { return ret; }
		ret = login_auth(clntinfo);
		if (ret) {
			int ret2;
			if ((ret2 = login_failed(clntinfo)) < 0) {
				return ret2;
			}
			return ret;
		} else {
			config_destroy_sectionconfig();
		}
		ret = login_loggedin_setup(clntinfo);
		if (ret) { return ret; }
	}
	return CMD_HANDLED;
}
Ejemplo n.º 2
0
static void *the_shell_thread_func(void *arg)
{
    int ret;
    char clean_cmd_line[512];
    cur_histotry_cmds_num = 0;
    shell_buf_cur_len=0;

    print_intro();

    if (login_auth()) goto EXIT;
    
    redirect_io(fd_pty_slave);
    print_hint();

    while (!shell_thread_should_exit)
    {
        ret=read_input(0);
        if (ret<0) goto EXIT;
        if (ret==1)
        {
            if (shell_buf_cur_len==0)
                goto CMD_OVER;
            
            update_histotry_cmds(shell_buf);
            shell_buf_cur_len=0;
            str_trim_all(clean_cmd_line, shell_buf);
            //printf_to_fd(ori_std_output, "== ret=%s\n", shell_buf);
            if (strlen(clean_cmd_line)==0)
                goto CMD_OVER;

            if (strcmp(clean_cmd_line,"quit")==0)
                goto EXIT;

            proccess_cmd(clean_cmd_line);
            printf_to_fd(1, "\n");
CMD_OVER:
            print_hint();
        }
    }

EXIT:
    shell_quit_occurred = 1;
    return NULL;
}