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

Image Customizer: Remove "sudo" calls. #10803

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func addEquivalencyRules(selinuxMode imagecustomizerapi.SELinuxMode,

for _, overlay := range overlays {
err = imageChroot.UnsafeRun(func() error {
return shell.ExecuteLiveWithErr(1, "sudo", "semanage", "fcontext", "-a", "-e", overlay.MountPoint, overlay.UpperDir)
return shell.ExecuteLiveWithErr(1, "semanage", "fcontext", "-a", "-e", overlay.MountPoint, overlay.UpperDir)
})
if err != nil {
return fmt.Errorf("failed to add equivalency rule between %s and %s:\n%w", overlay.MountPoint, overlay.UpperDir, err)
Expand Down
8 changes: 4 additions & 4 deletions toolkit/tools/pkg/imagecustomizerlib/shrinkfilesystems.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ func shrinkFilesystems(imageLoopDevice string, verityHashPartition *imagecustomi
}

// Check the file system with e2fsck
err = shell.ExecuteLive(true /*squashErrors*/, "sudo", "e2fsck", "-fy", partitionLoopDevice)
err = shell.ExecuteLive(true /*squashErrors*/, "e2fsck", "-fy", partitionLoopDevice)
if err != nil {
return fmt.Errorf("failed to check %s with e2fsck:\n%w", partitionLoopDevice, err)
}

// Shrink the file system with resize2fs -M
stdout, stderr, err := shell.Execute("sudo", "resize2fs", "-M", partitionLoopDevice)
stdout, stderr, err := shell.Execute("resize2fs", "-M", partitionLoopDevice)
if err != nil {
return fmt.Errorf("failed to resize %s with resize2fs:\n%v", partitionLoopDevice, stderr)
}
Expand All @@ -103,7 +103,7 @@ func shrinkFilesystems(imageLoopDevice string, verityHashPartition *imagecustomi
}

// Resize the partition with parted resizepart
_, stderr, err = shell.ExecuteWithStdin("yes" /*stdin*/, "sudo", "parted", "---pretend-input-tty",
_, stderr, err = shell.ExecuteWithStdin("yes" /*stdin*/, "parted", "---pretend-input-tty",
imageLoopDevice, "resizepart", strconv.Itoa(partitionNumber), end)
if err != nil {
return fmt.Errorf("failed to resizepart %s with parted:\n%v", partitionLoopDevice, stderr)
Expand All @@ -121,7 +121,7 @@ func shrinkFilesystems(imageLoopDevice string, verityHashPartition *imagecustomi
// Get the start sectors of all partitions.
// Ideally, we would use 'lsblk --output START' here. But that is only available in util-linux v2.38+.
func getStartSectors(imageLoopDevice string, partitionCount int) (partitionStarts map[string]int, err error) {
stdout, stderr, err := shell.Execute("sudo", "fdisk", "--list", imageLoopDevice)
stdout, stderr, err := shell.Execute("fdisk", "--list", imageLoopDevice)
if err != nil {
return nil, fmt.Errorf("fdisk failed to list partitions:\n%v", stderr)
}
Expand Down
Loading