View | Details | Raw Unified | Return to bug 1138
Collapse All | Expand All

(-)authfile.c (-1 / +1 lines)
Lines 507-513 key_load_private_pem(int fd, int type, c Link Here
507
	return prv;
507
	return prv;
508
}
508
}
509
509
510
static int
510
int
511
key_perm_ok(int fd, const char *filename)
511
key_perm_ok(int fd, const char *filename)
512
{
512
{
513
	struct stat st;
513
	struct stat st;
(-)authfile.h (+1 lines)
Lines 21-25 Key *key_load_public_type(int, const cha Link Here
21
Key	*key_load_private(const char *, const char *, char **);
21
Key	*key_load_private(const char *, const char *, char **);
22
Key	*key_load_private_type(int, const char *, const char *, char **);
22
Key	*key_load_private_type(int, const char *, const char *, char **);
23
Key	*key_load_private_pem(int, int, const char *, char **);
23
Key	*key_load_private_pem(int, int, const char *, char **);
24
int	 key_perm_ok(int, const char *);
24
25
25
#endif
26
#endif
(-)ssh-add.c (-3 / +12 lines)
Lines 124-139 delete_all(AuthenticationConnection *ac) Link Here
124
static int
124
static int
125
add_file(AuthenticationConnection *ac, const char *filename)
125
add_file(AuthenticationConnection *ac, const char *filename)
126
{
126
{
127
	struct stat st;
128
	Key *private;
127
	Key *private;
129
	char *comment = NULL;
128
	char *comment = NULL;
130
	char msg[1024];
129
	char msg[1024];
131
	int ret = -1;
130
	int fd, perms_ok, ret = -1;
132
131
133
	if (stat(filename, &st) < 0) {
132
	if ((fd = open(filename, 0)) < 0) {
134
		perror(filename);
133
		perror(filename);
135
		return -1;
134
		return -1;
136
	}
135
	}
136
137
	/*
138
	 * Since we'll try to load a keyfile multiple times, permission errors
139
	 * will occur multiple times, so check perms first and bail if wrong.
140
	 */
141
	perms_ok = key_perm_ok(fd, filename);
142
	close(fd);
143
	if (!perms_ok)
144
		return -1;
145
137
	/* At first, try empty passphrase */
146
	/* At first, try empty passphrase */
138
	private = key_load_private(filename, "", &comment);
147
	private = key_load_private(filename, "", &comment);
139
	if (comment == NULL)
148
	if (comment == NULL)

Return to bug 1138