Ejemplo n.º 1
0
static char *do_get_passwd(void)
{
    static char pwd[LINE_MAX];
    char pwd2[LINE_MAX];    
    int tries = MAX_PASSWD_CHANGE_TRIES;
       
    *pwd = 0;
    *pwd2 = 0;
    
    again:
    printf("Password: "******"\nEnter it again: ");
    fflush(stdout);
    disable_echo();
    if (fgets(pwd2, (int) (sizeof pwd2 - 1U), stdin) == NULL) {
        enable_echo();
        return NULL;
    }
    strip_lf(pwd2);
    puts("");
    if (strcmp(pwd, pwd2) != 0) {
        if (*pwd2 != 0) {
            memset(pwd2, 0, strlen(pwd2));
        }
        if (*pwd != 0) {
            memset(pwd, 0, strlen(pwd));
        }
        puts("You didn't enter the same password");
        if (--tries > 0) {
            goto again;
        }
        enable_echo();
        
        return NULL;
    }
    if (*pwd2 != 0) {
        memset(pwd2, 0, strlen(pwd2));
    }
    enable_echo();
    
    return pwd;
}
Ejemplo n.º 2
0
void console_init() {
    int i, j = 0;

    for (; j < 1; j++) {
        for (i = 0; i < cols; i++) {
            setCharAtOff(j, i, ' ');
            setAttrAtOff(j, i, 0x2E);
        }
    }

    for (; j < rows-1; j++) {
        for (i = 0; i < cols; i++) {
            setCharAtOff(j, i, ' ');
            setAttrAtOff(j, i, 0x1F);
        }
    }


    for (; j < rows; j++) {
        for (i = 0; i < cols; i++) {
            setCharAtOff(j, i, ' ');
            setAttrAtOff(j, i, 0x70);
        }
    }
    disable_echo();
    disable_buf();
    console_update();
}
Ejemplo n.º 3
0
int
get_password(char *pwd, size_t max_len, const char *prompt)
{
    int ret;

    disable_echo();
    ret = get_line(pwd, max_len, prompt);
    enable_echo();

    return ret;
}
Ejemplo n.º 4
0
char *git_terminal_prompt(const char *prompt, int echo)
{
	static struct strbuf buf = STRBUF_INIT;
	int r;
	FILE *input_fh, *output_fh;

#ifdef GIT_WINDOWS_NATIVE

	/* try shell_prompt first, fall back to CONIN/OUT if bash is missing */
	char *result = shell_prompt(prompt, echo);
	if (result)
		return result;

	if (echo && set_echo(1))
		return NULL;
#endif

	input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
	if (!input_fh)
		return NULL;

	output_fh = fopen(OUTPUT_PATH, "w" FORCE_TEXT);
	if (!output_fh) {
		fclose(input_fh);
		return NULL;
	}

	if (!echo && disable_echo()) {
		fclose(input_fh);
		fclose(output_fh);
		return NULL;
	}

	fputs(prompt, output_fh);
	fflush(output_fh);

	r = strbuf_getline_lf(&buf, input_fh);
	if (!echo) {
		putc('\n', output_fh);
		fflush(output_fh);
	}

	restore_term();
	fclose(input_fh);
	fclose(output_fh);

	if (r == EOF)
		return NULL;
	return buf.buf;
}
Ejemplo n.º 5
0
char *git_terminal_prompt(const char *prompt, int echo)
{
	static struct strbuf buf = STRBUF_INIT;
	int r;
	FILE *input_fh, *output_fh;
#ifdef GIT_WINDOWS_NATIVE
	const char *term = getenv("TERM");

	if (term && starts_with(term, "xterm"))
		return xterm_prompt(prompt, echo);
#endif

	input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
	if (!input_fh)
		return NULL;

	output_fh = fopen(OUTPUT_PATH, "w" FORCE_TEXT);
	if (!output_fh) {
		fclose(input_fh);
		return NULL;
	}

	if (!echo && disable_echo()) {
		fclose(input_fh);
		fclose(output_fh);
		return NULL;
	}

	fputs(prompt, output_fh);
	fflush(output_fh);

	r = strbuf_getline(&buf, input_fh, '\n');
	if (!echo) {
		putc('\n', output_fh);
		fflush(output_fh);
	}

	restore_term();
	fclose(input_fh);
	fclose(output_fh);

	if (r == EOF)
		return NULL;
	return buf.buf;
}
Ejemplo n.º 6
0
void mg_init(void) {
uint8_t i;
	
	MG301_HALT();
	sleep(1);
	MG301_PWON();
	sleep(5);
	disable_echo();
	for(i=0; i<60; i++) {
		if(is_rcv_nwtime()) {
			debug("update time from NWTIME\r\n");
			update_time();
			usart2_buf_clr();
			break;
		}
		sleep(1);
	}
}
Ejemplo n.º 7
0
void init_graphics(){
  char *PATH_TO_FRAMEBUFFER = "/dev/fb0";
  unsigned int yres;
  unsigned int length;

  struct fb_var_screeninfo virtual_resolution_info;
  struct fb_fix_screeninfo bit_depth_info;

  fd = open(PATH_TO_FRAMEBUFFER, O_RDWR);

  ioctl(fd, FBIOGET_VSCREENINFO, &virtual_resolution_info);
  ioctl(fd, FBIOGET_FSCREENINFO, &bit_depth_info);

  map_size = virtual_resolution_info.yres_virtual * bit_depth_info.line_length;

  addr = mmap(NULL, map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

  disable_echo();
  fcntl(0, F_SETFL, O_NONBLOCK);
}
Ejemplo n.º 8
0
int main (int argc, char **argv)
{
	int master_fd;
	int c;
	int ignore_eof;
	int interactive;
	int quiet;
	int err_flag;
	pid_t pid;
	char *driver;
	struct termios old_termios;
	struct winsize tty_winsize;

	ignore_eof = 0;
	interactive = isatty (STDIN_FILENO);
	quiet = 0;
	driver = NULL;
	err_flag = 0;
	opterr = 0;

	while ((c = getopt (argc, argv, "d:eiq")) != EOF) {
		switch (c) {
			case 'd':
				driver = optarg;
				break;

			case 'e':
				ignore_eof++;
				break;

			case 'i':
				interactive = 0;
				break;

			case 'q':
				quiet++;
				break;

			default:
				err_flag++;
				break;
		}
	}

	if ((err_flag) || (optind >= argc))
		err_quit ("Usage: pty [-d driver] [eiq] command [arg ...]");

	if (interactive) {
		if (tcgetattr (STDIN_FILENO, &old_termios) == -1)
			err_msg ("tcgetattr failed");

		if (ioctl (STDIN_FILENO, TIOCGWINSZ, &tty_winsize) == -1)
			err_msg ("TIOCGWINSZ failed");

		pid = pty_fork (&master_fd, &old_termios, &tty_winsize);
	}
	else
		pid = pty_fork (&master_fd, NULL, NULL);

	if (pid == -1)
		err_msg ("pty_fork failed");

	if (pid == 0) {
		if (quiet)
			disable_echo (STDIN_FILENO);

		if (execvp (argv [optind], &argv [optind]) == -1)
			err_msg ("pty: %s", argv [optind]);
	}

	if ((interactive) && (driver == NULL)) {
		if (tty_raw (STDIN_FILENO) == -1)
			err_msg ("tty_raw failed");
		if (atexit (tty_atexit) == -1)
			err_msg ("tty_atexit failed");
	}

	if (driver)
		run_driver (driver);

	loop (master_fd, ignore_eof);

	return (0);
}