projects
/
onak.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add -c option to specify keyd config file on command line
[onak.git]
/
keyd.c
diff --git
a/keyd.c
b/keyd.c
index d6abd32b8a21c462cb9611334c1c9301ff324b7c..05f9fe9b025742dbad205741d4f881002b446770 100644
(file)
--- a/
keyd.c
+++ b/
keyd.c
@@
-2,14
+2,16
@@
* keyd.c - key retrieval daemon
*
* Jonathan McDowell <noodles@earth.li>
* keyd.c - key retrieval daemon
*
* Jonathan McDowell <noodles@earth.li>
- *
+ *
* Copyright 2004 Project Purple
*/
#include <fcntl.h>
* Copyright 2004 Project Purple
*/
#include <fcntl.h>
+#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
@@
-32,7
+34,7
@@
void iteratefunc(void *ctx, struct openpgp_publickey *key)
struct openpgp_packet_list *list_end = NULL;
struct buffer_ctx storebuf;
int ret = 0;
struct openpgp_packet_list *list_end = NULL;
struct buffer_ctx storebuf;
int ret = 0;
- int
fd = (int
) ctx;
+ int
*fd = (int *
) ctx;
if (key != NULL) {
storebuf.offset = 0;
if (key != NULL) {
storebuf.offset = 0;
@@
-52,10
+54,10
@@
void iteratefunc(void *ctx, struct openpgp_publickey *key)
logthing(LOGTHING_TRACE,
"Sending %d bytes.",
storebuf.offset);
logthing(LOGTHING_TRACE,
"Sending %d bytes.",
storebuf.offset);
- ret = write(fd, &storebuf.offset,
+ ret = write(
*
fd, &storebuf.offset,
sizeof(storebuf.offset));
if (ret != 0) {
sizeof(storebuf.offset));
if (ret != 0) {
- write(fd, storebuf.buffer,
+ write(
*
fd, storebuf.buffer,
storebuf.offset);
}
storebuf.offset);
}
@@
-287,7
+289,7
@@
int sock_do(int fd)
cmd = KEYD_REPLY_OK;
write(fd, &cmd, sizeof(cmd));
config.dbbackend->iterate_keys(iteratefunc,
cmd = KEYD_REPLY_OK;
write(fd, &cmd, sizeof(cmd));
config.dbbackend->iterate_keys(iteratefunc,
-
(void *)
fd);
+
&
fd);
bytes = 0;
write(fd, &bytes, sizeof(bytes));
break;
bytes = 0;
write(fd, &bytes, sizeof(bytes));
break;
@@
-310,7
+312,8
@@
int sock_do(int fd)
int sock_close(int fd)
{
int sock_close(int fd)
{
- return shutdown(fd, SHUT_RDWR);
+ shutdown(fd, SHUT_RDWR);
+ return close(fd);
}
int sock_accept(int fd)
}
int sock_accept(int fd)
@@
-339,8
+342,20
@@
int main(int argc, char *argv[])
int fd = -1;
fd_set rfds;
char sockname[1024];
int fd = -1;
fd_set rfds;
char sockname[1024];
+ char *configfile = NULL;
+ int optchar;
- readconfig(NULL);
+ while ((optchar = getopt(argc, argv, "c:")) != -1 ) {
+ switch (optchar) {
+ case 'c':
+ configfile = strdup(optarg);
+ break;
+ }
+ }
+
+ readconfig(configfile);
+ free(configfile);
+ configfile = NULL;
initlogthing("keyd", config.logfile);
catchsignals();
initlogthing("keyd", config.logfile);
catchsignals();
@@
-367,6
+382,6
@@
int main(int argc, char *argv[])
cleanuplogthing();
cleanupconfig();
cleanuplogthing();
cleanupconfig();
-
+
return(EXIT_SUCCESS);
}
return(EXIT_SUCCESS);
}