|
|
@@ -40,6 +40,8 @@
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
+#define KEYFILE SYSCONFDIR "/ais/authkey"
|
|
|
+
|
|
|
int main (void) {
|
|
|
int authkey_fd;
|
|
|
int random_fd;
|
|
|
@@ -51,7 +53,7 @@ int main (void) {
|
|
|
printf ("Error: Authorization key must be generated as root user.\n");
|
|
|
exit (1);
|
|
|
}
|
|
|
- mkdir ("/etc/ais", 0700);
|
|
|
+ mkdir (SYSCONFDIR "/ais", 0700);
|
|
|
|
|
|
printf ("Gathering %lu bits for key from /dev/random.\n", (unsigned long)(sizeof (key) * 8));
|
|
|
random_fd = open ("/dev/random", O_RDONLY);
|
|
|
@@ -72,9 +74,9 @@ int main (void) {
|
|
|
/*
|
|
|
* Open key
|
|
|
*/
|
|
|
- authkey_fd = open ("/etc/ais/authkey", O_CREAT|O_WRONLY, 600);
|
|
|
+ authkey_fd = open (KEYFILE, O_CREAT|O_WRONLY, 600);
|
|
|
if (authkey_fd == -1) {
|
|
|
- perror ("Could not create /etc/ais/authkey");
|
|
|
+ perror ("Could not create " KEYFILE);
|
|
|
exit (1);
|
|
|
}
|
|
|
/*
|
|
|
@@ -83,14 +85,14 @@ int main (void) {
|
|
|
fchown (authkey_fd, 0, 0);
|
|
|
fchmod (authkey_fd, 0400);
|
|
|
|
|
|
- printf ("Writing corosync key to /etc/ais/authkey.\n");
|
|
|
+ printf ("Writing corosync key to " KEYFILE ".\n");
|
|
|
|
|
|
/*
|
|
|
* Write key
|
|
|
*/
|
|
|
res = write (authkey_fd, key, sizeof (key));
|
|
|
if (res == -1) {
|
|
|
- perror ("Could not write /etc/ais/authkey");
|
|
|
+ perror ("Could not write " KEYFILE);
|
|
|
exit (1);
|
|
|
}
|
|
|
|