View | Details | Raw Unified | Return to bug 158 | Differences between
and this patch

Collapse All | Expand All

(-)ssh-add.c~ (-8 / +13 lines)
Lines 123-129 Link Here
123
}
123
}
124
124
125
static int
125
static int
126
add_file(AuthenticationConnection *ac, const char *filename)
126
add_file(AuthenticationConnection *ac, const char *filename, int defaults)
127
{
127
{
128
	struct stat st;
128
	struct stat st;
129
	Key *private;
129
	Key *private;
Lines 132-139 Link Here
132
	int ret = -1;
132
	int ret = -1;
133
133
134
	if (stat(filename, &st) < 0) {
134
	if (stat(filename, &st) < 0) {
135
		perror(filename);
135
		if (errno == ENOENT && defaults) {
136
		return -1;
136
			return 0;
137
		} else {
138
			perror(filename);
139
			return -1;
140
		}
137
	}
141
	}
138
	/* At first, try empty passphrase */
142
	/* At first, try empty passphrase */
139
	private = key_load_private(filename, "", &comment);
143
	private = key_load_private(filename, "", &comment);
Lines 223-235 Link Here
223
}
227
}
224
228
225
static int
229
static int
226
do_file(AuthenticationConnection *ac, int deleting, char *file)
230
do_file(AuthenticationConnection *ac, int deleting, char *file, int defaults)
227
{
231
{
228
	if (deleting) {
232
	if (deleting) {
229
		if (delete_file(ac, file) == -1)
233
		if (delete_file(ac, file) == -1)
230
			return -1;
234
			return -1;
231
	} else {
235
	} else {
232
		if (add_file(ac, file) == -1)
236
		if (add_file(ac, file, defaults) == -1)
233
			return -1;
237
			return -1;
234
	}
238
	}
235
	return 0;
239
	return 0;
Lines 257-263 Link Here
257
	extern int optind;
261
	extern int optind;
258
	AuthenticationConnection *ac = NULL;
262
	AuthenticationConnection *ac = NULL;
259
	char *sc_reader_id = NULL;
263
	char *sc_reader_id = NULL;
260
	int i, ch, deleting = 0, ret = 0;
264
	int i, ch, deleting = 0, ret = 0, defaults = 0;
261
265
262
	__progname = get_progname(argv[0]);
266
	__progname = get_progname(argv[0]);
263
	init_rng();
267
	init_rng();
Lines 310-315 Link Here
310
	if (argc == 0) {
314
	if (argc == 0) {
311
		char buf[MAXPATHLEN];
315
		char buf[MAXPATHLEN];
312
		struct passwd *pw;
316
		struct passwd *pw;
317
		defaults = 1;
313
318
314
		if ((pw = getpwuid(getuid())) == NULL) {
319
		if ((pw = getpwuid(getuid())) == NULL) {
315
			fprintf(stderr, "No user found with uid %u\n",
320
			fprintf(stderr, "No user found with uid %u\n",
Lines 321-332 Link Here
321
		for(i = 0; default_files[i]; i++) {
326
		for(i = 0; default_files[i]; i++) {
322
			snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, 
327
			snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, 
323
			    default_files[i]);
328
			    default_files[i]);
324
			if (do_file(ac, deleting, buf) == -1)
329
			if (do_file(ac, deleting, buf, defaults) == -1)
325
				ret = 1;
330
				ret = 1;
326
		}
331
		}
327
	} else {
332
	} else {
328
		for(i = 0; i < argc; i++) {
333
		for(i = 0; i < argc; i++) {
329
			if (do_file(ac, deleting, argv[i]) == -1)
334
			if (do_file(ac, deleting, argv[i], defaults) == -1)
330
				ret = 1;
335
				ret = 1;
331
		}
336
		}
332
	}
337
	}

Return to bug 158