Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 5 commits into
base: ade-singlepass-dev
Choose a base branch
from

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
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..../

VMEncryption/volume-notif-svc/UdevVolNotif.c Show resolved Hide resolved
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.

3 participants