util  Check-in [a2d840e698]

Overview
Comment:minor tweaks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a2d840e698b77cc40363c40d697aeb454c9c8df49a3ab749fbb0aaf872d6f6bb
User & Date: lexi on 2019-08-16 02:03:51
Other Links: manifest | tags
Context
2019-08-16
03:00
add android support check-in: 8a57f6203c user: lexi tags: trunk
02:03
minor tweaks check-in: a2d840e698 user: lexi tags: trunk
02:00
fix addpw/genpw bugs check-in: 37cc6dd034 user: lexi tags: trunk
Changes

Modified kpw.d/kpw.c from [e965fe4be4] to [de39328fae].

323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
...
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
		case term_clear_line:   write(tty,"\r\x1b[2K",5); break;
		case term_clear_screen: write(tty,"\r\x1b[3J",5); break;
	}
}
void term_bell(int tty) {
	write(tty,"\a",1);
}
#include<stdio.h>
typedef char password[kpw_db_pw_max + 1];
bad pwread(bool obscure, char* dest, size_t* out_len, const char* prompt, const size_t plen) {
	if (isatty(0)) {
		int tty = 1;
		if (!isatty(tty)) tty = open("/dev/tty", O_WRONLY);
		if (tty == -1) return bad_insane;

................................................................................
		alert(a_debug, "attempting to decrypt private key");
		for (size_t i = 0; i < sz(key); ++i) {
			priv[i] = priv_enc[i] ^ key[i];
		}
		hexdump(priv, sz(key));
	} else {
		/* found a key in memory; loading it into *priv */
		alert(a_notice, "using saved key");
		key_priv* saved = shmat(shm, 0, 0);
		if (saved == (void*)-1)
			return bad_shm;
		hexdump((byte*)saved, sizeof(key_priv));
		memcpy(priv, saved, sizeof(key_priv));
		shmdt(saved);
	}
................................................................................
		}

		case chpw:
		case regen:
		case delpw:{ /* kpw -d <acct> */
			if (param == 0) return emit_usage
				  (op==delpw ? " -d <account>\n"          :
				   op==regen ? " -r[lmusp] <account> [<pw len>]" :
				/* op==chpw */ " -c <account> [<new pw>]");

			if (param < 1 || param > (op == delpw ? 1 : 2))
				return bad_syntax;
			const char* target = params[0];
			const char* delta;
			if (param == 2) delta=params[1];
				else delta=NULL;







|







 







|







 







|
|







323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
...
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
		case term_clear_line:   write(tty,"\r\x1b[2K",5); break;
		case term_clear_screen: write(tty,"\r\x1b[3J",5); break;
	}
}
void term_bell(int tty) {
	write(tty,"\a",1);
}

typedef char password[kpw_db_pw_max + 1];
bad pwread(bool obscure, char* dest, size_t* out_len, const char* prompt, const size_t plen) {
	if (isatty(0)) {
		int tty = 1;
		if (!isatty(tty)) tty = open("/dev/tty", O_WRONLY);
		if (tty == -1) return bad_insane;

................................................................................
		alert(a_debug, "attempting to decrypt private key");
		for (size_t i = 0; i < sz(key); ++i) {
			priv[i] = priv_enc[i] ^ key[i];
		}
		hexdump(priv, sz(key));
	} else {
		/* found a key in memory; loading it into *priv */
		alert(a_debug, "using saved key");
		key_priv* saved = shmat(shm, 0, 0);
		if (saved == (void*)-1)
			return bad_shm;
		hexdump((byte*)saved, sizeof(key_priv));
		memcpy(priv, saved, sizeof(key_priv));
		shmdt(saved);
	}
................................................................................
		}

		case chpw:
		case regen:
		case delpw:{ /* kpw -d <acct> */
			if (param == 0) return emit_usage
				  (op==delpw ? " -d <account>\n"          :
				   op==regen ? " -r[lmusp] <account> [<pw len>]\n" :
				/* op==chpw */ " -c <account> [<new pw>]\n");

			if (param < 1 || param > (op == delpw ? 1 : 2))
				return bad_syntax;
			const char* target = params[0];
			const char* delta;
			if (param == 2) delta=params[1];
				else delta=NULL;