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

ImageCustomizer: Add Support for Configuring User Sudoers File #11196

Draft
wants to merge 1 commit into
base: 3.0-dev
Choose a base branch
from

Conversation

elainezhao96
Copy link
Contributor

@elainezhao96 elainezhao96 commented Nov 22, 2024

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • Ready to merge

Summary

What does the PR accomplish, why was it needed?

Change Log
Does this affect the toolchain?

NO

Associated issues
  • #xxxx
Test Methodology
  • Pipeline build id: xxxx

return nil
}

func UpdateSudoAccess(installChroot safechroot.ChrootInterface, username string, enableSudo bool) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to put this function inside userutils.py but will create cyclic dependency issue.

@@ -20,6 +20,7 @@ type User struct {
SecondaryGroups []string `yaml:"secondaryGroups"`
StartupCommand string `yaml:"startupCommand"`
HomeDirectory string `yaml:"homeDirectory"`
Sudo bool `yaml:"sudo"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this setting specifically enabling no-password sudo? If that's the case, then could we make the setting name appropriately specific to that? Given that this is a security-impacting setting, I think we should be as clear as we can about what the image owner is opening up.

},
}

err := CopyAdditionalFiles(sudoersFile, additionalFiles, installChroot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use CopyAdditionalFiles. Just write to the file using file.Write. (You can use installChroot .RootDir() to get the rootfs directory.)

@@ -17,8 +17,8 @@ const (
defaultFilePermissions = 0o755
)

func copyAdditionalFiles(baseConfigPath string, additionalFiles imagecustomizerapi.AdditionalFileList,
imageChroot *safechroot.Chroot,
func CopyAdditionalFiles(baseConfigPath string, additionalFiles imagecustomizerapi.AdditionalFileList,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to make a function public if you are accessing it from the same package/directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants