comparison svr-agentfwd.c @ 579:8c737cd7c1af

merge of '48fdaa8706d1acda35e9d564adc9a1fbc96c18c8' and '658fd03abd21e0da7c4c89b9fff9dc693c72daae'
author Matt Johnston <matt@ucc.asn.au>
date Sat, 27 Feb 2010 11:53:18 +0000
parents 52d7301e46bd
children a98a2138364a
comparison
equal deleted inserted replaced
577:69e98c45db7c 579:8c737cd7c1af
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;
179 m_free(chansess->agentdir); 183 m_free(chansess->agentdir);
180 } 184 }
181 185
182 } 186 }
183 187
184 static const struct ChanType chan_agent = { 188 static const struct ChanType chan_svr_agent = {
185 0, /* sepfds */ 189 0, /* sepfds */
186 "[email protected]", 190 "[email protected]",
187 NULL, 191 NULL,
188 NULL, 192 NULL,
189 NULL, 193 NULL,
192 196
193 197
194 /* helper for accepting an agent request */ 198 /* helper for accepting an agent request */
195 static int send_msg_channel_open_agent(int fd) { 199 static int send_msg_channel_open_agent(int fd) {
196 200
197 if (send_msg_channel_open_init(fd, &chan_agent) == DROPBEAR_SUCCESS) { 201 if (send_msg_channel_open_init(fd, &chan_svr_agent) == DROPBEAR_SUCCESS) {
198 encrypt_packet(); 202 encrypt_packet();
199 return DROPBEAR_SUCCESS; 203 return DROPBEAR_SUCCESS;
200 } else { 204 } else {
201 return DROPBEAR_FAILURE; 205 return DROPBEAR_FAILURE;
202 } 206 }