-
Notifications
You must be signed in to change notification settings - Fork 263
Linux VM disk encryption: add a systemd service for detecting arrived/changed volumes #1666
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
base: ade-singlepass-dev
Are you sure you want to change the base?
Conversation
| static char log_file_path[1024]; | ||
|
|
||
| void custom_log(const char *format, ...) { | ||
| FILE *log_file = fopen(log_file_path, "a"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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..../
13883df to
4c9b33d
Compare
| cryptedDevices.push_back(it); | ||
| } | ||
| } | ||
| //remove previously add crypted devices, which are mounted now. |
There was a problem hiding this comment.
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.
Linux VM disk encryption: add a systemd service for detecting arrived/changed volumes.