diff --git a/src/api/encryption_get.c b/src/api/encryption_get.c index dcd5ae1d460e6b8aecc74eded1dbd20871ab5646..009dd05f64562eb7115f505431c88ba6b5d2c8cb 100644 --- a/src/api/encryption_get.c +++ b/src/api/encryption_get.c @@ -33,7 +33,7 @@ int callback_encryption_get(const struct _u_request * request, FILESYSTEM_TYPE); if (r != 0) { - y_log_message(Y_LOG_LEVEL_ERROR, "mounting root device failed: return code %d\n", r); + y_log_message(Y_LOG_LEVEL_ERROR, "mounting root device failed: return code %d", r); return send_simple_response(response, 500, "error", "mounting root device failed"); } diff --git a/src/api/encryption_init_post.c b/src/api/encryption_init_post.c index 1dec2f90f6dec26b8b06688d546c715ba1e124ad..25b0b408d67729c1417d45e1aa095626c730fad5 100644 --- a/src/api/encryption_init_post.c +++ b/src/api/encryption_init_post.c @@ -58,7 +58,7 @@ int callback_encryption_init_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "mounting root device failed: return code %d\n", r); + "mounting root device failed: return code %d", r); return send_simple_response(response, 500, "error", "mounting root device failed"); } @@ -75,7 +75,7 @@ int callback_encryption_init_post(const struct _u_request * request, // Copy device contents to temporary filesystem. y_log_message(Y_LOG_LEVEL_DEBUG, - "copying existing root device contents to memory\n"); + "copying existing root device contents to memory"); char * command = NULL; asprintf(&command, "rsync -a %s/ %s", UNENCRYPTED_TMP_MOUNTPOINT, TMP_LOCATION); @@ -83,7 +83,7 @@ int callback_encryption_init_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "copying root device contents into memory failed: return code %d\n", + "copying root device contents into memory failed: return code %d", r); return send_simple_response(response, 500, "error", "copying root device contents into memory failed"); @@ -91,13 +91,13 @@ int callback_encryption_init_post(const struct _u_request * request, // Unmount unencrypted device. y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting unencrypted device at %s\n", + "unmounting unencrypted device at %s", UNENCRYPTED_TMP_MOUNTPOINT); r = umount(UNENCRYPTED_TMP_MOUNTPOINT); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting encrypted device failed: return code %d\n", r); + "unmounting encrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "unmounting unencrypted device failed"); } @@ -110,33 +110,33 @@ int callback_encryption_init_post(const struct _u_request * request, if (stat(authorized_keys_path, &st) == -1) { y_log_message(Y_LOG_LEVEL_ERROR, - "authorized_keys not found on root device at %s\n", + "authorized_keys not found on root device at %s", authorized_keys_path); return send_simple_response(response, 500, "error", "authorized_keys not found on root device"); } // Re-partition device. - y_log_message(Y_LOG_LEVEL_ERROR, "repartitioning device %s\n", ROOT_DEVICE); + y_log_message(Y_LOG_LEVEL_ERROR, "repartitioning device %s", ROOT_DEVICE); command = NULL; asprintf(&command, "sgdisk -a 8192 -n 1:0:48M -N 2 %s", ROOT_DEVICE); r = system(command); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "partitioning root device failed: return code %d\n", r); + "partitioning root device failed: return code %d", r); return send_simple_response(response, 500, "error", "partitioning root device failed"); } // Inform kernel of partitioning changes. - y_log_message(Y_LOG_LEVEL_DEBUG, "running partprobe\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "running partprobe"); command = NULL; asprintf(&command, "partprobe"); r = system(command); if (r != 0) { - y_log_message(Y_LOG_LEVEL_ERROR, "partprobe failed: return code %d\n", + y_log_message(Y_LOG_LEVEL_ERROR, "partprobe failed: return code %d", r); return send_simple_response(response, 500, "error", "partprobe failed"); @@ -144,38 +144,38 @@ int callback_encryption_init_post(const struct _u_request * request, // Sleep for a little while. // This seems necessary for the newly created partitions to appear as // devices. - y_log_message(Y_LOG_LEVEL_DEBUG, "waiting a bit...\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "waiting a bit..."); sleep(2); // Create filesystem on the info partition. - y_log_message(Y_LOG_LEVEL_DEBUG, "creating filesystem on info partition\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "creating filesystem on info partition"); command = NULL; asprintf(&command, "mkfs -t %s %s", FILESYSTEM_TYPE, INFO_PARTITION_DEVICE); - y_log_message(Y_LOG_LEVEL_DEBUG, "command: %s\n", command); + y_log_message(Y_LOG_LEVEL_DEBUG, "command: %s", command); r = system(command); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "creating filesystem failed: return code %d\n", r); + "creating filesystem failed: return code %d", r); return send_simple_response(response, 500, "error", "creating filesystem inside encrypted container failed"); } // Mount the info partition. - y_log_message(Y_LOG_LEVEL_DEBUG, "mounting info partition\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "mounting info partition"); r = temporary_mount(INFO_PARTITION_DEVICE, INFO_TMP_MOUNTPOINT, FILESYSTEM_TYPE); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "mounting encrypted device failed: return code %d\n", r); + "mounting encrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "mounting encrypted root device failed"); } // Create some directories in the info partition. - y_log_message(Y_LOG_LEVEL_DEBUG, "creating directories in info partition\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "creating directories in info partition"); command = NULL; asprintf(&command, "mkdir -p %s%s %s%s", INFO_TMP_MOUNTPOINT, AUTHORIZED_KEYS_DIR, INFO_TMP_MOUNTPOINT, SSH_HOST_KEY_DIR); @@ -183,13 +183,13 @@ int callback_encryption_init_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "creating directories failed: return code %d\n", r); + "creating directories failed: return code %d", r); return send_simple_response(response, 500, "error", "creating directories in info partition failed"); } // Copy authorized_keys file to the info partition. - y_log_message(Y_LOG_LEVEL_DEBUG, "copying authorized_keys to info partition\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "copying authorized_keys to info partition"); command = NULL; asprintf(&command, "cp %s %s%s", AUTHORIZED_KEYS_PATH, INFO_TMP_MOUNTPOINT, AUTHORIZED_KEYS_PATH); @@ -197,13 +197,13 @@ int callback_encryption_init_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "copying authorized_keys failed: return code %d\n", r); + "copying authorized_keys failed: return code %d", r); return send_simple_response(response, 500, "error", "copying authorized_keys failed"); } // Copy dropbear ssh host keys from the initrd to the info partition. - y_log_message(Y_LOG_LEVEL_DEBUG, "copying dropbear ssh host keys\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "copying dropbear ssh host keys"); command = NULL; asprintf(&command, "cp /etc/dropbear/* %s%s/", INFO_TMP_MOUNTPOINT, SSH_HOST_KEY_DIR); @@ -211,75 +211,75 @@ int callback_encryption_init_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_DEBUG, - "copying dropbear ssh host keys failed: return code %d\n", r); + "copying dropbear ssh host keys failed: return code %d", r); return send_simple_response(response, 500, "error", "copying dropbear ssh host keys failed"); } // Unmount info partition. y_log_message(Y_LOG_LEVEL_DEBUG, - "unmounting info partition at %s\n", INFO_TMP_MOUNTPOINT); + "unmounting info partition at %s", INFO_TMP_MOUNTPOINT); r = umount(INFO_TMP_MOUNTPOINT); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting failed: return code %d\n", r); + "unmounting failed: return code %d", r); return send_simple_response(response, 500, "error", "unmounting configuration partition failed"); } // Initialise encrypted container on data partition. y_log_message(Y_LOG_LEVEL_DEBUG, - "creating encrypted container at %s\n", DATA_PARTITION_DEVICE); + "creating encrypted container at %s", DATA_PARTITION_DEVICE); r = create_encrypted_device(DATA_PARTITION_DEVICE, password); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "creating encrypted container failed: return code %d\n", r); + "creating encrypted container failed: return code %d", r); return send_simple_response(response, 500, "error", "creating encryption container failed"); } // Unlock the new container. - y_log_message(Y_LOG_LEVEL_DEBUG, "unlocking encrypted device\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "unlocking encrypted device"); r = encryption_unlock(DATA_PARTITION_DEVICE, MAPPED_DEVICE_NAME, password); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unlocking encrypted container failed: return code %d\n", r); + "unlocking encrypted container failed: return code %d", r); return send_simple_response(response, 500, "error", "unlocking new encryption container failed"); } // Create filesystem in the new container. - y_log_message(Y_LOG_LEVEL_DEBUG, "creating filesystem in new container\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "creating filesystem in new container"); command = NULL; asprintf(&command, "mkfs -t %s %s", FILESYSTEM_TYPE, MAPPED_DEVICE_PATH); r = system(command); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "creating filesystem failed: return code %d\n", r); + "creating filesystem failed: return code %d", r); return send_simple_response(response, 500, "error", "creating filesystem inside encrypted container failed"); } // Mount the unlocked container. - y_log_message(Y_LOG_LEVEL_DEBUG, "mounting new filesystem\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "mounting new filesystem"); r = temporary_mount(MAPPED_DEVICE_PATH, DATA_TMP_MOUNTPOINT, FILESYSTEM_TYPE); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "mounting encrypted device failed: return code %d\n", r); + "mounting encrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "mounting encrypted root device failed"); } // Copy device contents from temporary filesystem to encrypted container. y_log_message(Y_LOG_LEVEL_DEBUG, - "copying root device contents from memory\n"); + "copying root device contents from memory"); command = NULL; asprintf(&command, "rsync -a %s/ %s", TMP_LOCATION, DATA_TMP_MOUNTPOINT); r = system(command); @@ -294,23 +294,23 @@ int callback_encryption_init_post(const struct _u_request * request, // Unmount filesystem on encrypted data partition. y_log_message(Y_LOG_LEVEL_DEBUG, - "unmounting encrypted device at %s\n", DATA_TMP_MOUNTPOINT); + "unmounting encrypted device at %s", DATA_TMP_MOUNTPOINT); r = umount(DATA_TMP_MOUNTPOINT); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting encrypted device failed: return code %d\n", r); + "unmounting encrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "unmounting encrypted device failed"); } // Lock the container. - y_log_message(Y_LOG_LEVEL_DEBUG, "locking encrypted device\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "locking encrypted device"); r = encryption_lock(MAPPED_DEVICE_NAME); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "locking encrypted container failed: return code %d\n", r); + "locking encrypted container failed: return code %d", r); return send_simple_response(response, 500, "error", "locking container failed"); } diff --git a/src/api/encryption_keys_get.c b/src/api/encryption_keys_get.c index 6f6d5c1c17778426e2df7b6903290a347475b09e..6783e4ced94d21cd17f17375c33bb5d95407ec1c 100644 --- a/src/api/encryption_keys_get.c +++ b/src/api/encryption_keys_get.c @@ -24,7 +24,7 @@ int callback_encryption_keys_get(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "container_initialise failed with status %d\n", r); + "container_initialise failed with status %d", r); return send_simple_response(response, 500, "error", "initialising encrypted container failed"); } diff --git a/src/api/encryption_keys_put.c b/src/api/encryption_keys_put.c index 6634d8ae5ca8452c3d0c62aaa76d6a9d589f0d33..eb36b809d58631b61c9d06e1175d65927fdf9636 100644 --- a/src/api/encryption_keys_put.c +++ b/src/api/encryption_keys_put.c @@ -43,7 +43,7 @@ int callback_encryption_keys_put(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_WARNING, - "invalid url parameter `slot`: %s\n", keyslot_string); + "invalid url parameter `slot`: %s", keyslot_string); return send_simple_response(response, 400, "error", "invalid url parameter `slot`"); } @@ -58,7 +58,7 @@ int callback_encryption_keys_put(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "container_initialise failed with status %d\n", r); + "container_initialise failed with status %d", r); return send_simple_response(response, 500, "error", "initialising encrypted container failed"); } @@ -78,7 +78,7 @@ int callback_encryption_keys_put(const struct _u_request * request, { // Something else went wrong. y_log_message(Y_LOG_LEVEL_ERROR, - "crypt_keyslot_add_by_passphrase failed with status %d\n", r); + "crypt_keyslot_add_by_passphrase failed with status %d", r); return send_simple_response(response, 500, "error", "error changing password"); } diff --git a/src/api/encryption_remove_post.c b/src/api/encryption_remove_post.c index 1a878fffe4faaa261a49bd819034538221f81549..5ab0a4b2d3eae920bb5c8c63f17e79b04151a690 100644 --- a/src/api/encryption_remove_post.c +++ b/src/api/encryption_remove_post.c @@ -46,7 +46,7 @@ int callback_encryption_remove_post(const struct _u_request * request, } // Unlock the container. - y_log_message(Y_LOG_LEVEL_INFO, "unlocking encrypted device\n"); + y_log_message(Y_LOG_LEVEL_INFO, "unlocking encrypted device"); r = encryption_unlock(DATA_PARTITION_DEVICE, MAPPED_DEVICE_NAME, password); if (r == -1) @@ -58,7 +58,7 @@ int callback_encryption_remove_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unlocking encrypted container failed: return code %d\n", r); + "unlocking encrypted container failed: return code %d", r); return send_simple_response(response, 500, "error", "unlocking encrypted container failed"); } @@ -69,7 +69,7 @@ int callback_encryption_remove_post(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "mounting root device failed: return code %d\n", r); + "mounting root device failed: return code %d", r); return send_simple_response(response, 500, "error", "mounting root device failed"); } @@ -85,14 +85,14 @@ int callback_encryption_remove_post(const struct _u_request * request, // Copy device contents to temporary filesystem. y_log_message(Y_LOG_LEVEL_DEBUG, - "copying existing root device contents to memory\n"); + "copying existing root device contents to memory"); char * command = NULL; asprintf(&command, "rsync -a %s/ %s", DATA_TMP_MOUNTPOINT, TMP_LOCATION); r = system(command); if(r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "copying root device contents into memory failed: return code %d\n", + "copying root device contents into memory failed: return code %d", r); return send_simple_response(response, 500, "error", "copying root device contents into memory failed"); @@ -100,23 +100,23 @@ int callback_encryption_remove_post(const struct _u_request * request, // Unmount encrypted data partition. y_log_message(Y_LOG_LEVEL_DEBUG, - "unmounting encrypted device at %s\n", DATA_TMP_MOUNTPOINT); + "unmounting encrypted device at %s", DATA_TMP_MOUNTPOINT); r = umount(DATA_TMP_MOUNTPOINT); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting encrypted device failed: return code %d\n", r); + "unmounting encrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "unmounting encrypted device failed"); } // Lock the container. - y_log_message(Y_LOG_LEVEL_DEBUG, "locking encrypted device\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "locking encrypted device"); r = encryption_lock(MAPPED_DEVICE_NAME); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "locking encrypted container failed: return code %d\n", r); + "locking encrypted container failed: return code %d", r); return send_simple_response(response, 500, "error", "locking encrypted container failed"); } @@ -125,59 +125,59 @@ int callback_encryption_remove_post(const struct _u_request * request, // We didn't mount this in cryptops-api, but it was mounted by the initrd // scripts for use by dropbear. y_log_message(Y_LOG_LEVEL_DEBUG, - "unmounting info partition at %s\n", INFO_MOUNTPOINT); + "unmounting info partition at %s", INFO_MOUNTPOINT); r = umount(INFO_MOUNTPOINT); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting info partition failed: return code %d\n", r); + "unmounting info partition failed: return code %d", r); return send_simple_response(response, 500, "error", "unmounting info partition failed"); } // Remove all partitions from the device. y_log_message(Y_LOG_LEVEL_DEBUG, - "removing partitions from device %s\n", ROOT_DEVICE); + "removing partitions from device %s", ROOT_DEVICE); command = NULL; asprintf(&command, "sgdisk -Z %s", ROOT_DEVICE); r = system(command); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "removing partitions failed: return code %d\n", r); + "removing partitions failed: return code %d", r); return send_simple_response(response, 500, "error", "removing partitions failed"); } // Create filesystem on the unencrypted device. y_log_message(Y_LOG_LEVEL_DEBUG, - "creating filesystem on unencrypted device\n"); + "creating filesystem on unencrypted device"); command = NULL; asprintf(&command, "mkfs -t %s %s", FILESYSTEM_TYPE, ROOT_DEVICE); r = system(command); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "creating filesystem failed: return code %d\n", r); + "creating filesystem failed: return code %d", r); return send_simple_response(response, 500, "error", "creating filesystem on unencrypted device failed"); } // Mount the new filesystem. - y_log_message(Y_LOG_LEVEL_DEBUG, "mounting new filesystem\n"); + y_log_message(Y_LOG_LEVEL_DEBUG, "mounting new filesystem"); r = temporary_mount(ROOT_DEVICE, UNENCRYPTED_TMP_MOUNTPOINT, FILESYSTEM_TYPE); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "mounting unencrypted device failed: return code %d\n", r); + "mounting unencrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "mounting unencrypted root device failed"); } // Copy device contents from memory to the unencrypted device. y_log_message(Y_LOG_LEVEL_DEBUG, - "copying root device contents from memory\n"); + "copying root device contents from memory"); command = NULL; asprintf(&command, "rsync -a %s/ %s", TMP_LOCATION, UNENCRYPTED_TMP_MOUNTPOINT); @@ -193,12 +193,12 @@ int callback_encryption_remove_post(const struct _u_request * request, // Unmount filesystem on unencrypted device. y_log_message(Y_LOG_LEVEL_DEBUG, - "unmounting unencrypted device at %s\n", UNENCRYPTED_TMP_MOUNTPOINT); + "unmounting unencrypted device at %s", UNENCRYPTED_TMP_MOUNTPOINT); r = umount(UNENCRYPTED_TMP_MOUNTPOINT); if (r != 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "unmounting unencrypted device failed: return code %d\n", r); + "unmounting unencrypted device failed: return code %d", r); return send_simple_response(response, 500, "error", "unmounting unencrypted device failed"); } diff --git a/src/api/encryption_unlock_post.c b/src/api/encryption_unlock_post.c index a5fbbabebb73cbfaf2ede0b120d1e6a4c34d6474..b8dba343c3fe517664775fbe027fb4be09677008 100644 --- a/src/api/encryption_unlock_post.c +++ b/src/api/encryption_unlock_post.c @@ -32,7 +32,7 @@ int callback_encryption_unlock_post(const struct _u_request * request, { // Something else went wrong with unlocking. y_log_message(Y_LOG_LEVEL_ERROR, - "encryption_unlock failed with status %d\n", unlock_status); + "encryption_unlock failed with status %d", unlock_status); return send_simple_response(response, 500, "error", "error during unlocking"); } diff --git a/src/api/ssh_keys_delete.c b/src/api/ssh_keys_delete.c index 849b9a14ea63bd7656935bc85ff87468a87e468b..e7e16496785678b5ff570166f6d3da4e36c1a735 100644 --- a/src/api/ssh_keys_delete.c +++ b/src/api/ssh_keys_delete.c @@ -24,7 +24,7 @@ int callback_ssh_keys_delete(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_WARNING, - "invalid url parameter `id`: %s\n", id_string); + "invalid url parameter `id`: %s", id_string); return send_simple_response(response, 400, "error", "invalid url parameter `id`"); } diff --git a/src/api/ssh_keys_get.c b/src/api/ssh_keys_get.c index 6f967c8256654d254fae43e6300762acb69cbca7..e333a5c0c11b100e5004da417ef21edc2cf88a0a 100644 --- a/src/api/ssh_keys_get.c +++ b/src/api/ssh_keys_get.c @@ -70,7 +70,7 @@ int callback_ssh_keys_get(const struct _u_request * request, if (keys == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, - "Could not open authorized_keys file\n"); + "Could not open authorized_keys file"); return send_simple_response(response, 500, "error", "error reading authorized_keys"); } diff --git a/src/api/ssh_keys_post.c b/src/api/ssh_keys_post.c index cf9d7c8f0e0aaf6cac88546cee4baae624cbdd9a..766cf86b116a35e047305a08080a6b192116d7f1 100644 --- a/src/api/ssh_keys_post.c +++ b/src/api/ssh_keys_post.c @@ -26,7 +26,7 @@ int callback_ssh_keys_post(const struct _u_request * request, if (authorized_keys == NULL) { y_log_message(Y_LOG_LEVEL_ERROR, - "Could not open authorized_keys file for writing\n"); + "Could not open authorized_keys file for writing"); return send_simple_response(response, 500, "error", "error opening authorized_keys"); } diff --git a/src/api/ssh_keys_put.c b/src/api/ssh_keys_put.c index 3a2c434b44f895dd65a086fe814acb115040cf85..1ffdf00019345a1f2b422c09d9f1b8b4861a8e42 100644 --- a/src/api/ssh_keys_put.c +++ b/src/api/ssh_keys_put.c @@ -24,7 +24,7 @@ int callback_ssh_keys_put(const struct _u_request * request, if (r != 0) { y_log_message(Y_LOG_LEVEL_WARNING, - "invalid url parameter `id`: %s\n", id_string); + "invalid url parameter `id`: %s", id_string); return send_simple_response(response, 400, "error", "invalid url parameter `id`"); } diff --git a/src/auxiliary.c b/src/auxiliary.c index af64b5878f22cd97123d09a2881072f15acdeed9..b9622e4767c58a997fb74f1616965f4f4b32bf8d 100644 --- a/src/auxiliary.c +++ b/src/auxiliary.c @@ -3,7 +3,7 @@ */ void stop_server() { - y_log_message(Y_LOG_LEVEL_INFO, "Stopping cryptops-api server...\n"); + y_log_message(Y_LOG_LEVEL_INFO, "Stopping cryptops-api server..."); int fifo; char fifo_path[] = FIFO_PATH; fifo = open(fifo_path, O_WRONLY); @@ -33,7 +33,8 @@ char * read_from_file(FILE * file) temp = realloc(str, size + strlength); if (temp == NULL) { - y_log_message(Y_LOG_LEVEL_ERROR, "Could not allocate memory for file reading\n"); + y_log_message(Y_LOG_LEVEL_ERROR, + "Could not allocate memory for file reading"); return NULL; } else @@ -95,7 +96,8 @@ unsigned long device_size(char * device_path) fd = open(device_path, O_RDONLY); ioctl(fd, BLKGETSIZE, &numblocks); close(fd); - y_log_message(Y_LOG_LEVEL_DEBUG, "Number of blocks: %lu, this makes %.3f GB\n", + y_log_message(Y_LOG_LEVEL_DEBUG, + "Number of blocks: %lu, this makes %.3f GB", numblocks, (double)numblocks * 512.0 / (1024 * 1024 * 1024)); return (numblocks * 512); } @@ -110,7 +112,7 @@ unsigned long available_memory() unsigned long free_bytes; sysinfo(&myinfo); free_bytes = myinfo.mem_unit * myinfo.freeram; - y_log_message(Y_LOG_LEVEL_DEBUG, "Free memory: %lu B, %lu MB\n", + y_log_message(Y_LOG_LEVEL_DEBUG, "Free memory: %lu B, %lu MB", free_bytes, free_bytes / 1024 / 1024); return free_bytes; } @@ -146,16 +148,19 @@ bool filesystem_fits_in_memory(const char * path, double safety_margin) { // Something went wrong in determining the filesystem usage. // Return false as a precaution. - y_log_message(Y_LOG_LEVEL_ERROR, "Determining file system usage failed (size: %lu)\n", size); + y_log_message(Y_LOG_LEVEL_ERROR, + "Determining file system usage failed (size: %lu)", size); return false; } - y_log_message(Y_LOG_LEVEL_DEBUG, "file system usage: %lu bytes\n", size); + y_log_message(Y_LOG_LEVEL_DEBUG, + "file system usage: %lu bytes", size); // Determine the available memory. unsigned long memory = available_memory(); double projected_usage = (double)size / (double)memory; - y_log_message(Y_LOG_LEVEL_DEBUG, "projected memory usage: %.3f\n", projected_usage); + y_log_message(Y_LOG_LEVEL_DEBUG, "projected memory usage: %.3f", + projected_usage); return (projected_usage <= safety_margin); } @@ -234,7 +239,8 @@ int replace_ssh_key(int id, const char * ssh_key) // Check if that succeeded. if (authorized_keys_in == NULL) { - y_log_message(Y_LOG_LEVEL_ERROR, "Could not open authorized_keys file for reading\n"); + y_log_message(Y_LOG_LEVEL_ERROR, + "Could not open authorized_keys file for reading"); return -1; } @@ -247,7 +253,8 @@ int replace_ssh_key(int id, const char * ssh_key) // Check if that succeeded. if (authorized_keys_out == NULL) { - y_log_message(Y_LOG_LEVEL_ERROR, "Could not open authorized_keys tmp file for writing\n"); + y_log_message(Y_LOG_LEVEL_ERROR, + "Could not open authorized_keys tmp file for writing"); return -2; } diff --git a/src/encryption_functions.c b/src/encryption_functions.c index 1bef923b15dfae30a1a5aa7c4d43f7c0c7423931..08569ad3db73f27f13a5edbc675a17a0b2eabc33 100644 --- a/src/encryption_functions.c +++ b/src/encryption_functions.c @@ -13,7 +13,7 @@ static int container_initialise(struct crypt_device ** cd, const char * path, // Check if the device exists. if (! path_exists(path)) { - y_log_message(Y_LOG_LEVEL_ERROR, "device does not exist: %s.\n", path); + y_log_message(Y_LOG_LEVEL_ERROR, "device does not exist: %s.", path); return 1; } @@ -24,7 +24,7 @@ static int container_initialise(struct crypt_device ** cd, const char * path, if (debug) { y_log_message(Y_LOG_LEVEL_ERROR, - "crypt_init() failed for '%s', status: %d.\n", path, r); + "crypt_init() failed for '%s', status: %d.", path, r); } return r; } @@ -36,7 +36,7 @@ static int container_initialise(struct crypt_device ** cd, const char * path, if (debug) { y_log_message(Y_LOG_LEVEL_ERROR, - "crypt_load() failed on device %s.\n", + "crypt_load() failed on device %s.", crypt_get_device_name(*cd)); } } @@ -86,18 +86,18 @@ static int encryption_unlock(const char * path, const char * device_name, if (r < 0) { y_log_message(Y_LOG_LEVEL_ERROR, - "Device %s activation failed.\n", device_name); + "Device %s activation failed.", device_name); crypt_free(cd); return r; } y_log_message(Y_LOG_LEVEL_DEBUG, - "LUKS device %s/%s is active.\n", crypt_get_dir(), device_name); - y_log_message(Y_LOG_LEVEL_DEBUG, "\tcipher used: %s\n", + "LUKS device %s/%s is active.", crypt_get_dir(), device_name); + y_log_message(Y_LOG_LEVEL_DEBUG, "\tcipher used: %s", crypt_get_cipher(cd)); - y_log_message(Y_LOG_LEVEL_DEBUG, "\tcipher mode: %s\n", + y_log_message(Y_LOG_LEVEL_DEBUG, "\tcipher mode: %s", crypt_get_cipher_mode(cd)); - y_log_message(Y_LOG_LEVEL_DEBUG, "\tdevice UUID: %s\n", + y_log_message(Y_LOG_LEVEL_DEBUG, "\tdevice UUID: %s", crypt_get_uuid(cd)); crypt_free(cd); @@ -117,17 +117,17 @@ static int encryption_lock(const char * device_name) r = crypt_init_by_name(&cd, device_name); if (r < 0) { - y_log_message(Y_LOG_LEVEL_ERROR, "crypt_init_by_name() failed for %s.\n", device_name); + y_log_message(Y_LOG_LEVEL_ERROR, "crypt_init_by_name() failed for %s.", device_name); return r; } if (crypt_status(cd, device_name) == CRYPT_ACTIVE) { - y_log_message(Y_LOG_LEVEL_ERROR, "Device %s is still active.\n", device_name); + y_log_message(Y_LOG_LEVEL_ERROR, "Device %s is still active.", device_name); } else { - y_log_message(Y_LOG_LEVEL_ERROR, "Something failed perhaps, device %s is not active.\n", + y_log_message(Y_LOG_LEVEL_ERROR, "Something failed perhaps, device %s is not active.", device_name); crypt_free(cd); return -1; @@ -136,12 +136,12 @@ static int encryption_lock(const char * device_name) r = crypt_deactivate(cd, device_name); if (r < 0) { - y_log_message(Y_LOG_LEVEL_ERROR, "crypt_deactivate() failed.\n"); + y_log_message(Y_LOG_LEVEL_ERROR, "crypt_deactivate() failed."); crypt_free(cd); return r; } - y_log_message(Y_LOG_LEVEL_ERROR, "Device %s is now deactivated.\n", device_name); + y_log_message(Y_LOG_LEVEL_ERROR, "Device %s is now deactivated.", device_name); crypt_free(cd); return 0; } @@ -162,11 +162,11 @@ static int create_encrypted_device(const char * path, const char * password) r = crypt_init(&cd, path); if (r < 0 ) { - y_log_message(Y_LOG_LEVEL_ERROR, "crypt_init() failed for %s.\n", path); + y_log_message(Y_LOG_LEVEL_ERROR, "crypt_init() failed for %s.", path); return r; } - y_log_message(Y_LOG_LEVEL_ERROR, "Context is attached to block device %s.\n", + y_log_message(Y_LOG_LEVEL_ERROR, "Context is attached to block device %s.", crypt_get_device_name(cd)); params.hash = "sha1"; @@ -177,7 +177,7 @@ static int create_encrypted_device(const char * path, const char * password) if (r < 0) { - y_log_message(Y_LOG_LEVEL_ERROR, "crypt_format() failed on device %s\n", + y_log_message(Y_LOG_LEVEL_ERROR, "crypt_format() failed on device %s", crypt_get_device_name(cd)); crypt_free(cd); return r; @@ -187,11 +187,11 @@ static int create_encrypted_device(const char * path, const char * password) strlen(password)); if (r < 0) { - y_log_message(Y_LOG_LEVEL_ERROR, "Adding keyslot failed.\n"); + y_log_message(Y_LOG_LEVEL_ERROR, "Adding keyslot failed."); crypt_free(cd); return r; } - y_log_message(Y_LOG_LEVEL_ERROR, "The first keyslot is initialized.\n"); + y_log_message(Y_LOG_LEVEL_ERROR, "The first keyslot is initialized."); crypt_free(cd); return 0;