File: test_getpassword.c

package info (click to toggle)
fetchmail 6.6.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,888 kB
  • sloc: ansic: 19,454; sh: 7,111; python: 2,395; perl: 564; yacc: 447; lex: 286; makefile: 261; awk: 124; lisp: 84; exp: 43; sed: 17
file content (31 lines) | stat: -rw-r--r-- 699 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "fetchmail.h"
#include "sdump.h"

#include <errno.h>
#include <stdio.h>
#include <string.h>

const char *program_name = __FILE__;
volatile int lastsig;

int main(void)
{
	const char *pw = fm_getpassword("TEST MODE - enter password: ");
	if (!pw) {
		fprintf(stderr, "fm_getpassword failed! %s\n", strerror(errno));
		return EXIT_FAILURE;
	} else {
		char *pwdump;

		pwdump = sdump_c(pw);
		printf("password received:       <%zu> \"%s\"\n", strlen(pw), pwdump);
		xzerofree(pwdump);

		fm_clearpassword();
		pwdump = sdump_c(pw);
		printf("cleared password buffer: <%zu> \"%s\"\n", strlen(pw), pwdump);
		xzerofree(pwdump);
		if (strlen(pw)) return EXIT_FAILURE;
	}
	return EXIT_SUCCESS;
}