Skip to content

Conversation

@canfikret
Copy link
Member

Linux VM disk encryption: add a systemd service for detecting arrived/changed volumes.

@canfikret canfikret changed the title Fican/volume notif svc Linux VM disk encryption: add a systemd service for detecting arrived/changed volumes Jan 25, 2023
@canfikret canfikret requested review from pankajosh and vimish January 25, 2023 23:23
static char log_file_path[1024];

void custom_log(const char *format, ...) {
FILE *log_file = fopen(log_file_path, "a");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to rotate the log after certain size

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what I am thinking is to do syslog instead of files. File could be used for debugging purposes.

dev = udev_monitor_receive_device(mon);
custom_log("A new udev monitoring event is received!");

const char *action = udev_device_get_action(dev);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null pointer checks needed for all the char* pointers which are returned before using them

fd = udev_monitor_get_fd(mon);
if (fd < 0) {
custom_log("ERROR: Can't get udev monitor fd (error no=%d)\n", errno);
exit(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using exit should be avoided and better to terminate gracefully

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and if we do via return we should close all handles etc

custom_log("Device node: %s", devnode);
int is_initialized = udev_device_get_is_initialized(dev);
custom_log("is_initialized: %d", is_initialized);
const char *fsType = udev_device_get_property_value(dev, "ID_FS_TYPE");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic string can be a literal

// system("");
}
custom_log("Processing udev monitoring event is done!\n");
udev_device_unref(dev);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple unref s making difficult to prove correctness better to do:
takeref and allocate resources
callfoo() new funtion
deref and deallocate resources

TimeoutSec=30
IgnoreSIGPIPE=no
KillMode=control-group
ExecStart=/opt/microsoft/azure-diskencryption/bin/ade-volume-notif-svc -d
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be %s and during ADE installation, replace it with /var/lib/waagent/Azure.Security..../

@pankajosh pankajosh force-pushed the fican/VolumeNotifSvc branch from 13883df to 4c9b33d Compare May 11, 2023 13:52
cryptedDevices.push_back(it);
}
}
//remove previously add crypted devices, which are mounted now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errata: "which are unlocked now",
assuming status change from add->change for crypted device is inferring ADE unlock to those devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants