X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydctl.c;h=8712f6361d00978817f42f717989e3f545ebb18d;hb=41b7047c909cb5d8243901080db4931ebf165acf;hp=11e5e8f3ae4fdfe0aaba40a8f20afab618a31cc5;hpb=4c00c60025f3da30824b2df0fb5f25c0207245e3;p=onak.git
diff --git a/keydctl.c b/keydctl.c
index 11e5e8f..8712f63 100644
--- a/keydctl.c
+++ b/keydctl.c
@@ -13,8 +13,7 @@
* more details.
*
* You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program. If not, see .
*/
#include
@@ -27,12 +26,10 @@
#include
#include
+#include "build-config.h"
+
#include "keyd.h"
#include "onak-conf.h"
-#include "version.h"
-
-/* HACK: We need to stop onak-conf.o requiring this. */
-void *DBFUNCS = NULL;
static int keyd_fd = -1;
static int verbose = 0;
@@ -99,7 +96,7 @@ static void keyd_connect(void)
sock.sun_family = AF_UNIX;
snprintf(sock.sun_path, sizeof(sock.sun_path) - 1, "%s/%s",
- config.db_dir,
+ config.sock_dir,
KEYD_SOCKET);
if (connect(keyd_fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
if (verbose >= 0) {
@@ -154,23 +151,37 @@ static void keyd_status(void)
uint32_t reply;
struct keyd_stats stats;
- keyd_do_command(KEYD_CMD_VERSION, &reply, sizeof(reply));
+ if (keyd_do_command(KEYD_CMD_VERSION, &reply, sizeof(reply)) == -1) {
+ printf("Got failure asking for keyd version.\n");
+ return;
+ }
printf("Using keyd protocol version %d.\n", reply);
- keyd_do_command(KEYD_CMD_STATS, &stats, sizeof(stats));
+ if (keyd_do_command(KEYD_CMD_STATS, &stats, sizeof(stats)) == -1) {
+ printf("Got failure asking for keyd statistics.\n");
+ return;
+ }
+
printf("keyd running since %s", ctime(&stats.started));
printf("%d client connections received\n", stats.connects);
printf("Command statistics:\n");
printf(" Version: %d\n",
stats.command_stats[KEYD_CMD_VERSION]);
- printf(" Get key: %d\n", stats.command_stats[KEYD_CMD_GET]);
+ printf(" Get key by ID: %d\n",
+ stats.command_stats[KEYD_CMD_GET_ID]);
+ printf(" Get key by FP: %d\n",
+ stats.command_stats[KEYD_CMD_GET_FP]);
+ printf(" Get key by hash: %d\n",
+ stats.command_stats[KEYD_CMD_GET_SKSHASH]);
printf(" Store key: %d\n",
stats.command_stats[KEYD_CMD_STORE]);
printf(" Delete key: %d\n",
stats.command_stats[KEYD_CMD_DELETE]);
+ printf(" Update key: %d\n",
+ stats.command_stats[KEYD_CMD_UPDATE]);
printf(" Search key: %d\n",
- stats.command_stats[KEYD_CMD_GETTEXT]);
+ stats.command_stats[KEYD_CMD_GET_TEXT]);
printf(" Get full keyid: %d\n",
stats.command_stats[KEYD_CMD_GETFULLKEYID]);
printf(" Iterate all keys: %d\n",
@@ -220,6 +231,7 @@ int main(int argc, char *argv[])
configfile = NULL;
if ((argc - optind) < 1) {
+ cleanupconfig();
usage();
} else if (!strcmp("check", argv[optind])) {
/* Just do the connect and close quietly */
@@ -235,9 +247,11 @@ int main(int argc, char *argv[])
keyd_do_command(KEYD_CMD_QUIT, NULL, 0);
keyd_close();
} else {
+ cleanupconfig();
usage();
}
+ cleanupconfig();
exit(EXIT_SUCCESS);
}