pwman

Check-in [58b6e98d51]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Work-around for segfault & data corruption when secring is not available A couple of things here: 1) I probably use PWMan in a way that wasn't intended: I only make my secret key available to in temporarily, once authorised I delete the secring.gpg file entirely so it isn't hanging about on a machine. So when it times out I need to remember to copy my key back to the machine before I try to re-authorise. Sometimes I forget and ... 2) It seems that for reasons I don't have the inclination or ability to figure out, PWMan segfaults on exit when the secring.gpg isn't available or is 0 bytes (or, probably, doesn't contain the required secret key). This on it's own isn't a bad thing, but when it does this it also seems to have a nasty habit of corrupting the password database; not always in an immediately obvious manner so I can end up "backing up" this corrupted version. So as a workaround (for my usage circumstances), this fix checks whether the secring file is 0 bytes and if it is waits until it isn't (I.e. I've copied it back to the machine) before asking for re-authorisation. This isn't perfect as it only waits once. I.e. if it recognises the secring is available it'll prompt for the password, but it is possible that in this time I could get distracted and come back after the secring file is removed again (since I remove it automatically) and forget and cause a segfault, but then I've only my stupid self to blame.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/tweaks | trunk
Files: files | file ages | folders
SHA3-256: 58b6e98d51f01c48a09cdc81529b01674ebb3a9232ff1e127aa96bdf9d2ef18a
User & Date: base@atomicules.co.uk 2014-01-06 11:10:08
Context
2014-05-13
20:40
Avoid getting stuck in a loop when moving items I have a habit of hitting m instead of M and then getting stuck in a loop of "Sublist does not exist, try again" because there is no sublist I can move to. Although the code is meant to allow you to break out of this by pressing return (the answer[0] bit) it doesn't work for me (perhaps because of the changes I made on ui_statusline_ask_str that restore values on return?). So instead of running it in a loop, just run it once on keypress - it's not exactly a hassle to run it again if I do actually want to move an item and type it wrong. check-in: 84a89d1e8e user: base@atomicules.co.uk tags: origin/tweaks, trunk
2014-01-06
11:10
Work-around for segfault & data corruption when secring is not available A couple of things here: 1) I probably use PWMan in a way that wasn't intended: I only make my secret key available to in temporarily, once authorised I delete the secring.gpg file entirely so it isn't hanging about on a machine. So when it times out I need to remember to copy my key back to the machine before I try to re-authorise. Sometimes I forget and ... 2) It seems that for reasons I don't have the inclination or ability to figure out, PWMan segfaults on exit when the secring.gpg isn't available or is 0 bytes (or, probably, doesn't contain the required secret key). This on it's own isn't a bad thing, but when it does this it also seems to have a nasty habit of corrupting the password database; not always in an immediately obvious manner so I can end up "backing up" this corrupted version. So as a workaround (for my usage circumstances), this fix checks whether the secring file is 0 bytes and if it is waits until it isn't (I.e. I've copied it back to the machine) before asking for re-authorisation. This isn't perfect as it only waits once. I.e. if it recognises the secring is available it'll prompt for the password, but it is possible that in this time I could get distracted and come back after the secring file is removed again (since I remove it automatically) and forget and cause a segfault, but then I've only my stupid self to blame. check-in: 58b6e98d51 user: base@atomicules.co.uk tags: origin/tweaks, trunk
2014-01-03
22:31
Merge branch 'modernise' into tweaks check-in: 229ff25e0f user: base@atomicules.co.uk tags: origin/tweaks, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/ui.c.

19
20
21
22
23
24
25

26
27
28
29
30
31
32
...
181
182
183
184
185
186
187





188
189
190
191
192
193
194
...
204
205
206
207
208
209
210












211
212
213
214
215

216
217
218
219
220
221
222
 */

#include <pwman.h>
#include <ui.h>
#include <help.h>
#include <time.h>
#include <stdlib.h>


char * statusline_ask_str(char *, char*, int);
Pw *get_highlighted_item();

int should_resize = FALSE;
int can_resize = FALSE;

................................................................................
int
ui_run()
{
	Pw *current_item;
	int ch;
	int i = 0;
	int load_worked = 0;





#ifdef DEBUG
	int debug_i = 0;
#endif
	char msg[80];

	time_base = time(NULL);

................................................................................
		if((time_base < (time(NULL) - (options->passphrase_timeout*60)))
				&& options->passphrase_timeout != 0 && tolower(ch) != 'q'){
			pwlist_write_file();
			pwlist_free_all();

			ui_statusline_msg("Passphrase has timed out and you must enter it again.");
			getch();












			
			load_worked = pwlist_read_file();
			if(load_worked != 0) {
				ui_statusline_msg("Error - unable to re-load the password file!");
				break;

			}

			time_base = time(NULL);
		}
		
		switch(ch){
			case 'Q':







>







 







>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>





>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
 */

#include <pwman.h>
#include <ui.h>
#include <help.h>
#include <time.h>
#include <stdlib.h>
#include <sys/stat.h>

char * statusline_ask_str(char *, char*, int);
Pw *get_highlighted_item();

int should_resize = FALSE;
int can_resize = FALSE;

................................................................................
int
ui_run()
{
	Pw *current_item;
	int ch;
	int i = 0;
	int load_worked = 0;
	int secret_key_message = 0;
	struct stat st;
	char secring[STRING_LONG];
	strcpy(secring, getenv("HOME"));
	strcat(secring, "/.gnupg/secring.gpg");
#ifdef DEBUG
	int debug_i = 0;
#endif
	char msg[80];

	time_base = time(NULL);

................................................................................
		if((time_base < (time(NULL) - (options->passphrase_timeout*60)))
				&& options->passphrase_timeout != 0 && tolower(ch) != 'q'){
			pwlist_write_file();
			pwlist_free_all();

			ui_statusline_msg("Passphrase has timed out and you must enter it again.");
			getch();
			// Try to avoid segfault if secring isn't available
			// Need to check for 0 byte file size since something in pwlist_write_file() "touches" it
			stat(secring, &st);
			while ( st.st_size == 0 ) {
				if (secret_key_message == 0) {
					ui_statusline_msg("Secret key not available... Waiting until it is");
					secret_key_message = 1;
				}
				stat(secring, &st);
				sleep(1);
			}
			secret_key_message = 0;
			
			load_worked = pwlist_read_file();
			if(load_worked != 0) {
				ui_statusline_msg("Error - unable to re-load the password file!");
				break;
				// It segfaults here.
			}

			time_base = time(NULL);
		}
		
		switch(ch){
			case 'Q':