comparison svr-agentfwd.c @ 560:52d7301e46bd agent-client

Agent forwarding works
author Matt Johnston <matt@ucc.asn.au>
date Thu, 30 Jul 2009 15:14:33 +0000
parents d588e3ea557a
children a98a2138364a
comparison
equal deleted inserted replaced
559:7f66b8e40f2d 560:52d7301e46bd
47 static int bindagent(int fd, struct ChanSess * chansess); 47 static int bindagent(int fd, struct ChanSess * chansess);
48 static void agentaccept(struct Listener * listener, int sock); 48 static void agentaccept(struct Listener * listener, int sock);
49 49
50 /* Handles client requests to start agent forwarding, sets up listening socket. 50 /* Handles client requests to start agent forwarding, sets up listening socket.
51 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 51 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
52 int agentreq(struct ChanSess * chansess) { 52 int svr_agentreq(struct ChanSess * chansess) {
53 53
54 int fd; 54 int fd;
55
56 TRACE(("enter svr_agentreq"))
55 57
56 if (!svr_pubkey_allows_agentfwd()) { 58 if (!svr_pubkey_allows_agentfwd()) {
57 return DROPBEAR_FAILURE; 59 return DROPBEAR_FAILURE;
58 } 60 }
59 61
87 if (chansess->agentlistener == NULL) { 89 if (chansess->agentlistener == NULL) {
88 goto fail; 90 goto fail;
89 } 91 }
90 92
91 return DROPBEAR_SUCCESS; 93 return DROPBEAR_SUCCESS;
94 TRACE(("success"))
92 95
93 fail: 96 fail:
97 TRACE(("fail"))
94 /* cleanup */ 98 /* cleanup */
95 agentcleanup(chansess); 99 svr_agentcleanup(chansess);
96 100
97 return DROPBEAR_FAILURE; 101 return DROPBEAR_FAILURE;
98 } 102 }
99 103
100 /* accepts a connection on the forwarded socket and opens a new channel for it 104 /* accepts a connection on the forwarded socket and opens a new channel for it
116 120
117 } 121 }
118 122
119 /* set up the environment variable pointing to the socket. This is called 123 /* set up the environment variable pointing to the socket. This is called
120 * just before command/shell execution, after dropping priveleges */ 124 * just before command/shell execution, after dropping priveleges */
121 void agentset(struct ChanSess * chansess) { 125 void svr_agentset(struct ChanSess * chansess) {
122 126
123 char *path = NULL; 127 char *path = NULL;
124 int len; 128 int len;
125 129
126 if (chansess->agentlistener == NULL) { 130 if (chansess->agentlistener == NULL) {
135 addnewvar("SSH_AUTH_SOCK", path); 139 addnewvar("SSH_AUTH_SOCK", path);
136 m_free(path); 140 m_free(path);
137 } 141 }
138 142
139 /* close the socket, remove the socket-file */ 143 /* close the socket, remove the socket-file */
140 void agentcleanup(struct ChanSess * chansess) { 144 void svr_agentcleanup(struct ChanSess * chansess) {
141 145
142 char *path = NULL; 146 char *path = NULL;
143 uid_t uid; 147 uid_t uid;
144 gid_t gid; 148 gid_t gid;
145 int len; 149 int len;