pwman

Check-in [29163ef9b2]
Login

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

Overview
Comment:Remove file that isn't used anyway Just never knew that until moved away from autohell
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | manualheaven
Files: files | file ages | folders
SHA3-256: 29163ef9b207bcdec2cfd7e8ad597ff27ece0df7ae6257596181b201752f9492
User & Date: base@atomicules.co.uk 2014-05-15 22:18:43
Context
2014-05-15
22:23
Merge branch 'manualheaven' into tweaks Leaf check-in: 91957153ef user: base@atomicules.co.uk tags: origin/tweaks, trunk
22:18
Remove file that isn't used anyway Just never knew that until moved away from autohell Leaf check-in: 29163ef9b2 user: base@atomicules.co.uk tags: trunk, manualheaven
22:16
Needs reference to a definition of NULL now using new Makefile I'm not sure how it got away with it before? check-in: 10c900ef1d user: base@atomicules.co.uk tags: trunk, manualheaven
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Makefile.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# PWman - An obsolete password manager for the console

include config.mk

SRC_PWMAN = actions.c filter.c gnupg.c gnupg.h help.h launch.c misc.c options.c pwgen.c pwlist.c pwman.c pwman.h search.c ui.c ui.h uilist.c
SRC_CONVERT_PWDB = convert_pwdb.c
SRC_PWDB2CSV = pwdb2csv.c
# This one isn't currently used: import_export.c
OBJ_PWMAN = ${SRC_PWMAN:.c=.o}
OBJ_CONVERT_PWDB = ${SRC_CONVERT_PWDB:.c=.o}
OBJ_PWDB2CSV = ${SRC_PWDB2CSV:.c=.o}

all: options pwman convert_pwdb pwdb2csv

options:







<







1
2
3
4
5
6
7

8
9
10
11
12
13
14
# PWman - An obsolete password manager for the console

include config.mk

SRC_PWMAN = actions.c filter.c gnupg.c gnupg.h help.h launch.c misc.c options.c pwgen.c pwlist.c pwman.c pwman.h search.c ui.c ui.h uilist.c
SRC_CONVERT_PWDB = convert_pwdb.c
SRC_PWDB2CSV = pwdb2csv.c

OBJ_PWMAN = ${SRC_PWMAN:.c=.o}
OBJ_CONVERT_PWDB = ${SRC_CONVERT_PWDB:.c=.o}
OBJ_PWDB2CSV = ${SRC_PWDB2CSV:.c=.o}

all: options pwman convert_pwdb pwdb2csv

options:

Deleted import_export.c.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 *  PWMan - password application manager
 *
 *  Copyright (C) 2002  Ivan Kelly <ivan@ivankelly.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <pwman.h>
#include <ui.h>
#include <stdlib.h>
#include <libxml/tree.h>
#include <libxml/parser.h>

int
export_passwd(Pw *pw)
{
	char vers[5];
	char id[STRING_LONG], file[STRING_LONG];
	
	xmlDocPtr doc;
	xmlNodePtr root;

	if(check_gnupg() != 0){
		debug("export_passwd: gnupg not found");
		return -1;
	}
	if(!pw){
		debug("export_passwd: bad password");
		statusline_msg("Bad password");
		return -1;
	}

	get_gnupg_id(id);
	if(id[0] == 0){
		debug("export_passwd: cancel because id is blank");
		return -1;
	}
	
	get_filename(file, 'w');

	debug("export_passwd: construct xml doc");
	snprintf(vers, 5, "%d", FF_VERSION);
	doc = xmlNewDoc((xmlChar*)"1.0");
	
	root = xmlNewDocNode(doc, NULL, (xmlChar*)"PWMan_Export", NULL);

	xmlSetProp(root, "version", vers);
	
	write_password_node(root, pw);

	xmlDocSetRootElement(doc, root);

	gnupg_write(doc, id, file);
	
	xmlFreeDoc(doc);
	return 0;
}

int
export_passwd_list(PWList *pwlist)
{
	char vers[5];
	char id[STRING_LONG], file[STRING_LONG];
	
	xmlDocPtr doc;
	xmlNodePtr root;

	if(check_gnupg() != 0){
		debug("export_passwd_list: gnupg not found");
		return -1;
	}
	if(!pwlist){
		debug("export_passwd_list: bad password");
		statusline_msg("Bad password");
		return -1;
	}

	get_gnupg_id(id);
	if(id[0] == 0){
		debug("export_passwd_list: cancel because id is blank");
		return -1;
	}
	
	get_filename(file, 'w');

	debug("export_passwd_list: construct xml doc");
	snprintf(vers, 5, "%d", FF_VERSION);
	doc = xmlNewDoc((xmlChar*)"1.0");
	
	root = xmlNewDocNode(doc, NULL, (xmlChar*)"PWMan_Export", NULL);

	xmlSetProp(root, "version", vers);
	
	write_pwlist(root, pwlist);

	xmlDocSetRootElement(doc, root);

	gnupg_write(doc, id, file);
	
	xmlFreeDoc(doc);
	return 0;
}

int
import_passwd()
{
	char file[STRING_LONG], *buf, *cmd, *s, *text;
	int i = 0;
	xmlNodePtr node, root;
	xmlDocPtr doc;

	get_filename(file, 'r');

	gnupg_read(file, &doc);	
	
	if(!doc){
		debug("import_passwd: bad data");
		return -1;
	}
	root = xmlDocGetRootElement(doc);
	if(!root || !root->name	|| (strcmp((char*)root->name, "PWMan_Export") != 0) ){
		statusline_msg("Badly Formed password data");
		return -1;
	}
	if( buf = xmlGetProp(root, (xmlChar*)"version") ){
		i = atoi( buf );
	} else {
		i = 0;
	}
	if(i < FF_VERSION){
		statusline_msg("Password Export File in older format, use convert_pwdb");
		return -1;
	}
	
	for(node = root->children; node != NULL; node = node->next){
		if(strcmp(node->name, "PwList") == 0){
			read_pwlist(node, current_pw_sublist);
			break;
		} else if(strcmp(node->name, "PwItem") == 0){
			read_password_node(node, current_pw_sublist);
			break;
		}
	}
	xmlFreeDoc(doc);
	return 0;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<