updated on Sun Jan 22 04:03:10 UTC 2012
[aur-mirror.git] / gpa / server.patch
blobe4547bd21463fd07a9bc9b642768455a36ede63f
1 --- ./src/server.c.orig 2009-05-13 03:11:11.000000000 -0400
2 +++ ./src/server.c 2010-06-22 05:31:57.000000000 -0400
3 @@ -568,7 +568,7 @@
4 the last command. A RESET command undoes the effect of this
5 command.
6 */
7 -static int
8 +static gpg_error_t
9 cmd_session (assuan_context_t ctx, char *line)
11 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
12 @@ -594,7 +594,7 @@
13 validity right away; if it does not (as here) all recipients are
14 checked at the time of the ENCRYPT command. All RECIPIENT commands
15 are cumulative until a RESET or an successful ENCRYPT command. */
16 -static int
17 +static gpg_error_t
18 cmd_recipient (assuan_context_t ctx, char *line)
20 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
21 @@ -615,7 +615,7 @@
22 Set the file descriptor to read a message which is used with
23 detached signatures.
25 -static int
26 +static gpg_error_t
27 cmd_message (assuan_context_t ctx, char *line)
29 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
30 @@ -659,7 +659,7 @@
32 Encrypt the data received on INPUT to OUTPUT.
34 -static int
35 +static gpg_error_t
36 cmd_encrypt (assuan_context_t ctx, char *line)
38 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
39 @@ -755,7 +755,7 @@
41 Dummy encryption command used to check whether the given recipients
42 are all valid and to tell the client the preferred protocol. */
43 -static int
44 +static gpg_error_t
45 cmd_prep_encrypt (assuan_context_t ctx, char *line)
47 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
48 @@ -814,7 +814,7 @@
49 @code{RESET} command. A second command overrides the effect of
50 the first one; if EMAIL is not given the server shall use the
51 default signing key. */
52 -static int
53 +static gpg_error_t
54 cmd_sender (assuan_context_t ctx, char *line)
56 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
57 @@ -867,7 +867,7 @@
59 Sign the data received on INPUT to OUTPUT.
61 -static int
62 +static gpg_error_t
63 cmd_sign (assuan_context_t ctx, char *line)
65 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
66 @@ -943,7 +943,7 @@
67 If the option --no-verify is given, the server should not try to
68 verify a signature, in case the input data is an OpenPGP combined
69 message. */
70 -static int
71 +static gpg_error_t
72 cmd_decrypt (assuan_context_t ctx, char *line)
74 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
75 @@ -1058,7 +1058,7 @@
77 The DISPLAYSTRING is a percent-and-plus-encoded string with a short
78 human readable description of the status. */
79 -static int
80 +static gpg_error_t
81 cmd_verify (assuan_context_t ctx, char *line)
83 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
84 @@ -1143,7 +1143,7 @@
85 manager is brought into the foregound and that this command
86 immediatley returns.
88 -static int
89 +static gpg_error_t
90 cmd_start_keymanager (assuan_context_t ctx, char *line)
92 gpa_open_key_manager (NULL, NULL);
93 @@ -1157,7 +1157,7 @@
94 manager is brought into the foregound and that this command
95 immediatley returns.
97 -static int
98 +static gpg_error_t
99 cmd_start_cardmanager (assuan_context_t ctx, char *line)
101 gpa_open_cardmanager (NULL, NULL);
102 @@ -1172,7 +1172,7 @@
103 manager is brought into the foregound and that this command
104 immediatley returns.
106 -static int
107 +static gpg_error_t
108 cmd_start_confdialog (assuan_context_t ctx, char *line)
110 gpa_open_settings_dialog (NULL, NULL);
111 @@ -1191,7 +1191,7 @@
112 version - Return the version of the program.
113 pid - Return the process id of the server.
115 -static int
116 +static gpg_error_t
117 cmd_getinfo (assuan_context_t ctx, char *line)
119 gpg_error_t err;
120 @@ -1295,7 +1295,7 @@
122 Set the files on which to operate.
124 -static int
125 +static gpg_error_t
126 cmd_file (assuan_context_t ctx, char *line)
128 gpg_error_t err = 0;
129 @@ -1366,7 +1366,7 @@
132 /* ENCRYPT_FILES --nohup */
133 -static int
134 +static gpg_error_t
135 cmd_encrypt_files (assuan_context_t ctx, char *line)
137 gpg_error_t err;
138 @@ -1389,7 +1389,7 @@
141 /* SIGN_FILES --nohup */
142 -static int
143 +static gpg_error_t
144 cmd_sign_files (assuan_context_t ctx, char *line)
146 gpg_error_t err;
147 @@ -1412,7 +1412,7 @@
150 /* ENCRYPT_SIGN_FILES --nohup */
151 -static int
152 +static gpg_error_t
153 cmd_encrypt_sign_files (assuan_context_t ctx, char *line)
155 gpg_error_t err;
156 @@ -1474,7 +1474,7 @@
159 /* DECRYPT_FILES --nohup */
160 -static int
161 +static gpg_error_t
162 cmd_decrypt_files (assuan_context_t ctx, char *line)
164 gpg_error_t err;
165 @@ -1497,7 +1497,7 @@
168 /* VERIFY_FILES --nohup */
169 -static int
170 +static gpg_error_t
171 cmd_verify_files (assuan_context_t ctx, char *line)
173 gpg_error_t err;
174 @@ -1520,7 +1520,7 @@
177 /* DECRYPT_VERIFY_FILES --nohup */
178 -static int
179 +static gpg_error_t
180 cmd_decrypt_verify_files (assuan_context_t ctx, char *line)
182 gpg_error_t err;
183 @@ -1543,7 +1543,7 @@
186 /* IMPORT_FILES --nohup */
187 -static int
188 +static gpg_error_t
189 cmd_import_files (assuan_context_t ctx, char *line)
191 gpg_error_t err;
192 @@ -1567,7 +1567,7 @@
195 /* CHECKSUM_CREATE_FILES --nohup */
196 -static int
197 +static gpg_error_t
198 cmd_checksum_create_files (assuan_context_t ctx, char *line)
200 gpg_error_t err;
201 @@ -1591,7 +1591,7 @@
204 /* CHECKSUM_VERIFY_FILES --nohup */
205 -static int
206 +static gpg_error_t
207 cmd_checksum_verify_files (assuan_context_t ctx, char *line)
209 gpg_error_t err;
210 @@ -1614,8 +1614,8 @@
214 -static void
215 -reset_notify (assuan_context_t ctx)
216 +static gpg_error_t
217 +reset_notify (assuan_context_t ctx, char *line)
219 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
221 @@ -1639,6 +1639,7 @@
222 ctrl->session_number = 0;
223 xfree (ctrl->session_title);
224 ctrl->session_title = NULL;
225 + return 0;
229 @@ -1648,7 +1649,7 @@
231 static struct {
232 const char *name;
233 - int (*handler)(assuan_context_t, char *line);
234 + assuan_handler_t handler;
235 } table[] = {
236 { "SESSION", cmd_session },
237 { "RECIPIENT", cmd_recipient },
238 @@ -1681,7 +1682,8 @@
240 for (i=0; table[i].name; i++)
242 - rc = assuan_register_command (ctx, table[i].name, table[i].handler);
243 + rc = assuan_register_command (ctx, table[i].name, table[i].handler,
244 + NULL);
245 if (rc)
246 return rc;
248 @@ -1692,7 +1694,7 @@
250 /* Prepare for a new connection on descriptor FD. */
251 static assuan_context_t
252 -connection_startup (int fd)
253 +connection_startup (assuan_fd_t fd)
255 gpg_error_t err;
256 assuan_context_t ctx;
257 @@ -1700,7 +1702,16 @@
259 /* Get an Assuan context for the already accepted file descriptor
260 FD. Allow descriptor passing. */
261 - err = assuan_init_socket_server_ext (&ctx, ASSUAN_INT2FD(fd), 1|2);
262 + err = assuan_new (&ctx);
263 + if (err)
265 + g_debug ("failed to initialize the new connection: %s",
266 + gpg_strerror (err));
267 + return NULL;
270 + err = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_FDPASSING
271 + | ASSUAN_SOCKET_SERVER_ACCEPTED);
272 if (err)
274 g_debug ("failed to initialize the new connection: %s",
275 @@ -1712,7 +1723,7 @@
277 g_debug ("failed to register commands with Assuan: %s",
278 gpg_strerror (err));
279 - assuan_deinit_server (ctx);
280 + assuan_release (ctx);
281 return NULL;
284 @@ -1736,8 +1747,8 @@
286 conn_ctrl_t ctrl = assuan_get_pointer (ctx);
288 - reset_notify (ctx);
289 - assuan_deinit_server (ctx);
290 + reset_notify (ctx, NULL);
291 + assuan_release (ctx);
292 g_free (ctrl);
293 connection_counter--;
294 if (!connection_counter && shutdown_pending)
295 @@ -1805,14 +1816,23 @@
297 else
299 + int done = 0;
300 ctrl->in_command++;
301 - err = assuan_process_next (ctx);
302 + err = assuan_process_next (ctx, &done);
303 ctrl->in_command--;
304 - g_debug ("assuan_process_next returned: %s",
305 - err == -1? "EOF": gpg_strerror (err));
306 + if (err)
308 + g_debug ("assuan_process_next returned: %s <%s>",
309 + gpg_strerror (err), gpg_strsource (err));
311 + else
313 + g_debug ("assuan_process_next returned: %s",
314 + done ? "done" : "success");
316 if (gpg_err_code (err) == GPG_ERR_EAGAIN)
317 ; /* Ignore. */
318 - else if (gpg_err_code (err) == GPG_ERR_EOF || err == -1)
319 + else if (!err && done)
321 if (ctrl->cont_cmd)
322 ctrl->client_died = 1; /* Need to delay the cleanup. */
323 @@ -1868,14 +1888,14 @@
324 g_debug ("error accepting connection: %s", strerror (errno));
325 goto leave;
327 - if (assuan_sock_check_nonce (ASSUAN_INT2FD(fd), &socket_nonce))
328 + if (assuan_sock_check_nonce ((assuan_fd_t) fd, &socket_nonce))
330 g_debug ("new connection at fd %d refused", fd);
331 goto leave;
334 g_debug ("new connection at fd %d", fd);
335 - ctx = connection_startup (fd);
336 + ctx = connection_startup ((assuan_fd_t) fd);
337 if (!ctx)
338 goto leave;
340 @@ -1911,7 +1931,7 @@
342 leave:
343 if (fd != -1)
344 - assuan_sock_close (ASSUAN_INT2FD (fd));
345 + assuan_sock_close ((assuan_fd_t) fd);
346 return TRUE; /* Keep the listen_fd in the event loop. */
349 @@ -1929,7 +1949,7 @@
350 GIOChannel *channel;
351 unsigned int source_id;
353 - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
354 + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
356 socket_name = g_build_filename (gnupg_homedir, "S.uiserver", NULL);
357 if (strlen (socket_name)+1 >= sizeof serv_addr.sun_path )
358 @@ -1974,14 +1994,14 @@
359 g_free (socket_name);
360 socket_name = NULL;
362 - if (listen (ASSUAN_FD2INT (fd), 5) == -1)
363 + if (listen ((int) fd, 5) == -1)
365 g_debug ("listen() failed: %s\n", strerror (errno));
366 assuan_sock_close (fd);
367 return;
369 #ifdef HAVE_W32_SYSTEM
370 - channel = g_io_channel_win32_new_socket (ASSUAN_FD2INT(fd));
371 + channel = g_io_channel_win32_new_socket ((int) fd);
372 #else
373 channel = g_io_channel_unix_new (fd);
374 #endif