Skip to content

Commit 4b5cb0d

Browse files
committed
5-5 C3
1 parent c9f7185 commit 4b5cb0d

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

contrib/win32/ssh-pubkey/pubkeyfd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "atomicio.h"
5656
#include "misc.h"
5757
#include "ssherr.h"
58+
#include "pubkeyfd.h"
5859

5960
#define MAX_AGENT_IDENTITIES 2048 /* Max keys in agent reply */
6061
#define MAX_AGENT_REPLY_LEN (256 * 1024) /* Max bytes in agent reply */
@@ -66,7 +67,16 @@
6667
(x == SSH2_AGENT_FAILURE))
6768

6869

69-
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment) {
70+
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password) {
71+
struct sshbuf *msg;
72+
int r;
73+
74+
if ((msg = sshbuf_new()) == NULL)
75+
return SSH_ERR_ALLOC_FAIL;
76+
77+
if ((r = sshbuf_put_cstring(msg, PK_REQUEST_ADD)) != 0 )
78+
79+
7080
return 0;
7181
}
7282

contrib/win32/ssh-pubkey/pubkeyfd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PK_REQUEST_REMOVE_ALL "removeall"
99
#define PK_REQUEST_REMOVE_BY_FP "removebyfp"
1010

11-
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment);
11+
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password);
1212
int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp);
1313
int ssh_remove_pubkey(int sock, struct sshkey *key);
1414
int ssh_remove_pubkey_by_fp(int sock, const char *fingerprint);

contrib/win32/ssh-pubkey/ssh-pubkey.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static int
143143
do_file(int agent_fd, int deleting, char *filename)
144144
{
145145
struct sshkey *public;
146-
char *comment = NULL;
146+
char *comment = NULL, *password = NULL;
147147
int r, ret = -1;
148148

149149
if ((r = sshkey_load_public(filename, &public, &comment)) != 0) {
@@ -161,7 +161,13 @@ do_file(int agent_fd, int deleting, char *filename)
161161
filename, ssh_err(r));
162162
}
163163
else {
164-
if ((r = ssh_add_pubkey(agent_fd, public, comment)) == 0) {
164+
if ((password = read_passphrase("Enter your password: ",
165+
RP_ALLOW_STDIN)) == NULL) {
166+
ret = ENOMEM;
167+
goto out;
168+
}
169+
170+
if ((r = ssh_add_pubkey(agent_fd, public, comment, password)) == 0) {
165171
fprintf(stderr, "Public key added: %s (%s)\n", filename, comment);
166172
ret = 0;
167173
}

0 commit comments

Comments
 (0)