-
Notifications
You must be signed in to change notification settings - Fork 353
fix: azure 缺少磁盘驱动 #153
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: master
Are you sure you want to change the base?
fix: azure 缺少磁盘驱动 #153
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,120 @@ download() { | |||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| find_kernel_package() { | ||||||||||||||||||||||||||||||||||
| local package_name filename | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| package_name="linux-image-$1" | ||||||||||||||||||||||||||||||||||
| filename=$( | ||||||||||||||||||||||||||||||||||
| gzip -dc "$2" | awk -v pkg="$package_name" ' | ||||||||||||||||||||||||||||||||||
| BEGIN { RS = ""; FS = "\n" } | ||||||||||||||||||||||||||||||||||
| $1 == "Package: " pkg { | ||||||||||||||||||||||||||||||||||
| for (i = 1; i <= NF; i++) { | ||||||||||||||||||||||||||||||||||
| if ($i ~ /^Filename: /) { | ||||||||||||||||||||||||||||||||||
| sub(/^Filename: /, "", $i) | ||||||||||||||||||||||||||||||||||
| print $i | ||||||||||||||||||||||||||||||||||
| exit | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| ' | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| [ -n "$filename" ] && { | ||||||||||||||||||||||||||||||||||
| printf '%s\n' "$filename" | ||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| package_name="linux-image-$1-unsigned" | ||||||||||||||||||||||||||||||||||
| filename=$( | ||||||||||||||||||||||||||||||||||
| gzip -dc "$2" | awk -v pkg="$package_name" ' | ||||||||||||||||||||||||||||||||||
| BEGIN { RS = ""; FS = "\n" } | ||||||||||||||||||||||||||||||||||
| $1 == "Package: " pkg { | ||||||||||||||||||||||||||||||||||
| for (i = 1; i <= NF; i++) { | ||||||||||||||||||||||||||||||||||
| if ($i ~ /^Filename: /) { | ||||||||||||||||||||||||||||||||||
| sub(/^Filename: /, "", $i) | ||||||||||||||||||||||||||||||||||
| print $i | ||||||||||||||||||||||||||||||||||
| exit | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| ' | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| [ -n "$filename" ] && printf '%s\n' "$filename" | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| find_installer_kernel_version() { | ||||||||||||||||||||||||||||||||||
| cpio -it -F "$1" 2> /dev/null | | ||||||||||||||||||||||||||||||||||
| sed -n 's#^lib/modules/\([^/]*\)/.*#\1#p' | | ||||||||||||||||||||||||||||||||||
| sort -u | | ||||||||||||||||||||||||||||||||||
| head -n 1 | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| inject_hyperv_pci_hotfix() { | ||||||||||||||||||||||||||||||||||
| local initrd_file installer_kernel_version packages_url package_path tmpdir | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| initrd_file=$1 | ||||||||||||||||||||||||||||||||||
| installer_kernel_version=$(find_installer_kernel_version "$initrd_file") | ||||||||||||||||||||||||||||||||||
| [ -n "$installer_kernel_version" ] || | ||||||||||||||||||||||||||||||||||
| err "Could not determine the installer kernel version from $initrd_file" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| tmpdir=$(mktemp -d) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| tmpdir=$(mktemp -d) | |
| tmpdir=$(mktemp -d) | |
| trap "rm -rf \"$tmpdir\"" EXIT INT TERM |
Copilot
AI
Mar 25, 2026
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.
installer_kernel_version comes from the downloaded initrd contents and is interpolated directly into the generated /lib/debian-installer-startup.d/... shell script without quoting/sanitization. If it contains unexpected characters, this can break the hook or (with a malicious initrd/mirror) lead to shell injection. Please validate it against an allowlist (e.g. [A-Za-z0-9.+-]) and/or write it as a safely quoted shell literal in the heredoc.
| cat > "$tmpdir/hotfix/lib/debian-installer-startup.d/S25pci-hyperv-hotfix" << EOF | |
| #!/bin/sh | |
| set -eu | |
| kernel_version=$installer_kernel_version | |
| case ${installer_kernel_version-} in | |
| ''|*[!A-Za-z0-9.+-]*) | |
| err "Invalid installer kernel version: ${installer_kernel_version-}" | |
| ;; | |
| esac | |
| cat > "$tmpdir/hotfix/lib/debian-installer-startup.d/S25pci-hyperv-hotfix" << EOF | |
| #!/bin/sh | |
| set -eu | |
| kernel_version='${installer_kernel_version}' |
Copilot
AI
Mar 25, 2026
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.
In the installer startup hook, data_member is matched as data.tar.* but the extraction always uses xzcat. If the .deb uses data.tar.zst or data.tar.gz, the hotfix will silently do nothing. Consider detecting the data_member suffix and using the matching decompressor (xz/gz/zstd), or constrain the match to data.tar.xz and error clearly otherwise.
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.
find_kernel_packageruns the samegzip|awkscan twice (for signed and unsigned). This can be simplified by iterating over candidate package names in a loop and reusing the same extraction logic, which will make the function easier to maintain and slightly reduce work on largePackages.gzfiles.