-
Notifications
You must be signed in to change notification settings - Fork 16
Feature: [Ubuntu, no-CVM] CVM machines to not get UEFI and kek certificate updates #356
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
25e0af9
Feature: [Ubuntu, no-CVM] CVM machines to not get UEFI and kek certif…
rane-rajasi 627bb93
Feature: [Ubuntu, no-CVM] Added additional UT coverage and addressed …
rane-rajasi ef8d554
Feature: [Ubuntu, no-CVM] Addressing PR feedback #1
rane-rajasi 6bdead9
Merge branch 'master' into rarane/certupdate/nocvm
kjohn-msft 8c281dd
Feature: [Ubuntu, no-CVM] Moving DetectConfidentialVmShim to external…
rane-rajasi 0751df3
minor changes
rane-rajasi f8c266e
Merge branch 'master' into rarane/certupdate/nocvm
rane-rajasi c079426
Removing old unused code
rane-rajasi 095c0b4
Merge branch 'rarane/certupdate/nocvm' of https://github.com/Azure/Li…
rane-rajasi c10846b
Minor changes
rane-rajasi 54775e0
Merge branch 'master' into rarane/certupdate/nocvm
rane-rajasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/core/src/external_dependencies/DetectConfidentialVMShim.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright 2020 Microsoft Corporation | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
|
kjohn-msft marked this conversation as resolved.
|
||
| # NOTE: This script is used to detect if the VM is running on a confidential VM. | ||
| # It checks for full disk encryption and other artifacts that indicate the presence of confidential computing features. | ||
| # Please reach out to Azure Cloud Security team if you have any questions or concerns about this script. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| HOSTNAME=$(hostname) | ||
|
|
||
| ROOT_SRC=$(findmnt -n -o SOURCE /) | ||
| ROOT_DEV=$(readlink -f "$ROOT_SRC" || echo "$ROOT_SRC") | ||
|
|
||
| FDE="false" | ||
| DETAILS="" | ||
|
|
||
| check_device() { | ||
| local dev="$1" | ||
|
|
||
| if blkid "$dev" 2>/dev/null | grep -qi 'crypto_LUKS'; then | ||
| FDE="true" | ||
| DETAILS="LUKS:$dev" | ||
| return | ||
| fi | ||
|
|
||
| local type | ||
| type=$(lsblk -dn -o TYPE "$dev" 2>/dev/null || true) | ||
|
|
||
| if [[ "$type" == "crypt" ]]; then | ||
| FDE="true" | ||
| DETAILS="CRYPT:$dev" | ||
| return | ||
| fi | ||
| } | ||
|
|
||
| walk_parents() { | ||
| local dev="$1" | ||
|
|
||
| while [[ -n "$dev" ]]; do | ||
| check_device "$dev" | ||
|
|
||
| if [[ "$FDE" == "true" ]]; then | ||
| return | ||
| fi | ||
|
|
||
| local parent | ||
| parent=$(lsblk -ndo PKNAME "$dev" 2>/dev/null | head -1 || true) | ||
|
|
||
| if [[ -z "$parent" ]]; then | ||
| break | ||
| fi | ||
|
|
||
| dev="/dev/$parent" | ||
| done | ||
| } | ||
|
|
||
| walk_parents "$ROOT_DEV" | ||
|
|
||
| if [[ "$FDE" != "true" ]]; then | ||
| while read -r name type; do | ||
| if [[ "$type" == "crypt" ]]; then | ||
| mapper="/dev/mapper/$name" | ||
|
|
||
| if mount | grep -q "^$mapper on / "; then | ||
| FDE="true" | ||
| DETAILS="DMCRYPT_ROOT:$mapper" | ||
| break | ||
| fi | ||
| fi | ||
| done < <(dmsetup ls --target crypt 2>/dev/null || true) | ||
| fi | ||
|
|
||
| if [[ "$FDE" != "true" ]]; then | ||
| if systemctl list-units 2>/dev/null | grep -qi azure; then | ||
| if ls /var/lib/waagent/*Encryption* >/dev/null 2>&1; then | ||
| FDE="true" | ||
| DETAILS="AZURE_ADE_ARTIFACTS" | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| echo "$HOSTNAME,$ROOT_DEV,FDE=$FDE,$DETAILS" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.