Commit ce69c980 authored by Arie Peterson's avatar Arie Peterson 🐚
Browse files

Run notification hook on startup

parent 4caaf4d1
......@@ -28,11 +28,26 @@ int main(int argc, char ** argv)
y_init_logs("cryptops-api", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG,
NULL, "Starting cryptops-api");
y_log_message(Y_LOG_LEVEL_DEBUG, "root_device: %s", config.root_device);
y_log_message(Y_LOG_LEVEL_DEBUG, "info_partition_device: %s", config.info_partition_device);
y_log_message(Y_LOG_LEVEL_DEBUG, "data_partition_device: %s", config.data_partition_device);
y_log_message(Y_LOG_LEVEL_DEBUG, "mapped_device_name: %s", config.mapped_device_name);
y_log_message(Y_LOG_LEVEL_DEBUG, "mapped_device_path: %s", config.mapped_device_path);
y_log_message(Y_LOG_LEVEL_DEBUG, "root_device: %s",
config.root_device);
y_log_message(Y_LOG_LEVEL_DEBUG, "info_partition_device: %s",
config.info_partition_device);
y_log_message(Y_LOG_LEVEL_DEBUG, "data_partition_device: %s",
config.data_partition_device);
y_log_message(Y_LOG_LEVEL_DEBUG, "mapped_device_name: %s",
config.mapped_device_name);
y_log_message(Y_LOG_LEVEL_DEBUG, "mapped_device_path: %s",
config.mapped_device_path);
y_log_message(Y_LOG_LEVEL_DEBUG, "notify_command: %s",
config.notify_command);
// Check if the root device is encrypted, and if so, use the supplied
// command to notify the user.
if (path_exists(config.data_partition_device) &&
is_encrypted_device(config.data_partition_device))
{
system(config.notify_command);
}
// Set address to bind to.
struct sockaddr_in address;
......@@ -144,8 +159,6 @@ int main(int argc, char ** argv)
// send their response to the client.
sleep(1);
y_close_logs();
ulfius_stop_framework(&instance);
ulfius_clean_instance(&instance);
......@@ -163,5 +176,7 @@ int main(int argc, char ** argv)
reboot_initrd(false);
}
y_close_logs();
return 0;
}
......@@ -6,20 +6,23 @@ struct config
char * mapped_device_name;
char * mapped_device_path;
char * tmp_data_location;
char * notify_command;
};
extern struct config config;
struct config config;
void set_config_from_arguments(int argc, char ** argv)
{
if (argc < 3)
if (argc < 4)
{
printf("Not enough arguments. Usage:\n cryptops-api ROOTDEV CRYPTNAME\n");
printf("Not enough arguments. Usage:\n");
printf(" cryptops-api ROOTDEV CRYPTNAME NOTIFY_COMMAND\n");
exit(1);
}
config.root_device = argv[1];
config.mapped_device_name = argv[2];
config.notify_command = argv[3];
asprintf(&config.info_partition_device, "%s1", config.root_device);
asprintf(&config.data_partition_device, "%s2", config.root_device);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment