summaryrefslogtreecommitdiffstats
path: root/src/havegecmd.h
diff options
context:
space:
mode:
authorWerner Fink <werner@suse.de>2018-07-19 14:13:26 +0200
committerWerner Fink <werner@suse.de>2018-07-26 13:57:05 +0200
commita2496c5de9af7e3ac3ef82a2257d14d8a0ac37fb (patch)
tree65e81d5db947143628dcd5e687b19100de5f97e5 /src/havegecmd.h
parentInitial commit based on haveged-1.9.2.tar.gz from http://www.issihosts.com/ha... (diff)
downloadhaveged-a2496c5de9af7e3ac3ef82a2257d14d8a0ac37fb.tar.xz
haveged-a2496c5de9af7e3ac3ef82a2257d14d8a0ac37fb.zip
Implement a command mode and use it for chroot
the current only known command is root=<new_root> which enforce an already running haveged to switch by using chroot(2) to new root file system and to an execv(3) there to become rebased. This allows haveged to survive the switch root within initrd and hold the entropy at high level. Signed-off-by: Werner Fink <werner@suse.de>
Diffstat (limited to 'src/havegecmd.h')
-rw-r--r--src/havegecmd.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/havegecmd.h b/src/havegecmd.h
new file mode 100644
index 0000000..0bc74fd
--- /dev/null
+++ b/src/havegecmd.h
@@ -0,0 +1,77 @@
+/**
+ ** Provide HAVEGE socket communication API
+ **
+ ** Copyright 2018 Werner Fink <werner@suse.de>
+ **
+ ** This program is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** This program is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **
+ */
+
+#ifndef HAVEGECMD_H
+#define HAVEGECMD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "havege.h"
+#include "haveged.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#define HAVEGED_SOCKET_PATH "\0/sys/entropy/haveged"
+#define MAGIC_CHROOT 'R'
+
+/**
+ * Open and listen on a UNIX socket to get command from there
+ */
+int cmd_listen(struct pparams *);
+
+/**
+ * Open and connect on a UNIX socket to send command over this
+ */
+int cmd_connect(struct pparams *);
+
+/**
+ * Handle arguments in command mode
+ */
+int getcmd(char *);
+
+/**
+ * Handle incomming messages from socket
+ */
+int socket_handler(int, const volatile char *, char *const [], struct pparams *);
+
+/**
+ * Receive incomming messages from socket
+ */
+ssize_t safein(int, void *, size_t);
+
+/**
+ * Send outgoing messages to socket
+ */
+void safeout(int, const void *, size_t);
+
+/**
+ * Socket file descriptor used for communication
+ */
+
+extern int socket_fd;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif