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

Be more liberal in our license acceptance checking. #6574

Merged
merged 3 commits into from May 20, 2019

Conversation

raskchanky
Copy link
Contributor

Now if you're running hab commands as a non-privileged user and
a privileged user has already accepted the license, it won't prompt you
twice.

Signed-off-by: Josh Black raskchanky@gmail.com

Now if you're running hab commands as a non-privileged user and
a privileged user has already accepted the license, it won't prompt you
twice.

Signed-off-by: Josh Black <raskchanky@gmail.com>
@chef-expeditor
Copy link
Contributor

Hello raskchanky! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

fn superuser_license_root() -> PathBuf { PathBuf::from(&*FS_ROOT_PATH).join("hab") }

fn user_license_root() -> PathBuf {
if let Some(home) = dirs::home_dir() {
home.join(".hab")
} else {
panic!("No home directory available. Unable to find a suitable place to write a license \
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question on whether panic is what we want here.. I realize its code thats not specifically for this change but it seems odd to have a panic in that path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the panic is intentional. If we hit that code path, something is super wrong because it means that hab is being run by a user that doesn't have a home directory. Users without home directories tend to be ones that are reserved for running services and as such, wouldn't be appropriate for accepting a license, since there's no sensible place to persist the license acceptance file.

Copy link
Contributor

@chefsalim chefsalim left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Josh Black <raskchanky@gmail.com>
Copy link
Contributor

@christophermaier christophermaier left a comment

Choose a reason for hiding this comment

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

I left a suggestion, but this looks good overall.
tenor-202210935

pub fn license_exists() -> bool { license_file().is_file() }
pub fn license_exists() -> bool {
license_file(&license_path(&superuser_license_root())).is_file()
|| license_file(&license_path(&user_license_root())).is_file()
Copy link
Contributor

Choose a reason for hiding this comment

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

Though I doubt it ends up making a huge difference, it seems like we should check the user license first, then the superuser license, since that's going from more specific to more general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, why not

Signed-off-by: Josh Black <raskchanky@gmail.com>
@raskchanky raskchanky merged commit cadf97b into master May 20, 2019
@raskchanky raskchanky deleted the jb/improve-license-acceptance-ux branch May 20, 2019 19:16
chef-ci added a commit that referenced this pull request May 20, 2019
Obvious fix; these changes are the result of automation not creative thinking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants