From 57969a835f8ab2b64ee6e0afd0ddf5ad31de4a38 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Mon, 9 Aug 2004 21:32:37 +0000 Subject: [PATCH] (Logical change 1.52) git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@160 fd59a12c-fef9-0310-b244-a6a79926bd2f --- exec/main.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/exec/main.c b/exec/main.c index f64767d6..c679e667 100644 --- a/exec/main.c +++ b/exec/main.c @@ -642,6 +642,31 @@ static void aisexec_mlockall (void) }; } +void aisexec_keyread (unsigned char *key) +{ + int fd; + int res; + + fd = open ("/etc/ais/authkey", O_RDONLY); + if (fd == -1) { + log_printf (LOG_LEVEL_ERROR, "Could not open /etc/ais/authkey: %s\n", strerror (errno)); + ais_done (1); + } + res = read (fd, key, 128); + if (res == -1) { + log_printf (LOG_LEVEL_ERROR, "Could not read /etc/ais/authkey: %s\n", strerror (errno)); + ais_done (1); + } + if (res != 128) { + log_printf (LOG_LEVEL_ERROR, "Could only read %d bits of 1024 bits from /etc/ais/authkey.\n", res * 8); + ais_done (1); + } + + close (fd); +} + + + int main (int argc, char **argv) { int libais_server_fd; @@ -649,7 +674,7 @@ int main (int argc, char **argv) struct sockaddr_in sockaddr_in_mcast; struct sockaddr_in sockaddr_in_bindnet; gmi_join_handle handle; - + unsigned char private_key[128]; char *error_string; @@ -685,10 +710,15 @@ int main (int argc, char **argv) aisexec_mlockall (); + aisexec_keyread (private_key); + gmi_log_printf_init (internal_log_printf_checkdebug, - LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_NOTICE, LOG_LEVEL_DEBUG); + LOG_LEVEL_SECURITY, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, + LOG_LEVEL_NOTICE, LOG_LEVEL_DEBUG); gmi_init (&sockaddr_in_mcast, &sockaddr_in_bindnet, - &aisexec_poll_handle, &this_ip); + &aisexec_poll_handle, &this_ip, + private_key, + sizeof (private_key)); /* * Drop root privleges to user 'ais'