habitat icon indicating copy to clipboard operation
habitat copied to clipboard

hab pkg build fails if license accepted via sudo

Open themightychris opened this issue 4 years ago • 4 comments

If you accept the Habitat license under a sudo'd command, you get /hab/accepted-licenses/habitat while if you do it under an unpriveledged user you get ~/.hab/accepted-licenses/habitat

If you start out a new system with a su-did license acceptance, you can't also accept it under your user directory and hab pkg build fails with 3 license prompts and quits without offering any interaction.

If you delete the global license, hab pkg build then prompts for license acceptance normally and works:

$ hab --version
hab 1.6.39/20200527162613

$ sudo hab license accept

Accepting 1 product license...
✓  1 product license accepted.

+---------------------------------------------+

$ ls -l /hab
total 44
drwxr-xr-x  2 root root 4096 Jun  4 21:48 accepted-licenses
drwxr-xr-x  5 root root 4096 Jun 28  2016 cache
drwxr-xr-x  4 root root 4096 May 19 23:39 pkgs

$ ls -l ~/.hab
total 8
drwxrwxr-x 5 chris chris 4096 Jun  4 21:35 cache
drwxrwxr-x 2 chris chris 4096 Jun  4 21:34 etc

$ hab pkg build habitat-plans/nodemon
   hab-studio: Destroying Studio at /hab/studios/home--chris--Repositories ()
   hab-studio: Creating Studio at /hab/studios/home--chris--Repositories (default)
   hab-studio: Importing 'chris' secret origin key
+---------------------------------------------+

            Chef License Acceptance


Before you can continue, 1 product license must be accepted.
View the license at https://www.chef.io/end-user-license-agreement

License that needs accepting:

  * Habitat

Do you accept the 1 product license? [yes/No/quit] Do you accept the 1 product license? [yes/No/quit] 
If you do not accept this license you will not be able to use Chef products.

Do you accept the 1 product license? [yes/No/quit] 
+---------------------------------------------+

✗✗✗
✗✗✗ License agreement not accepted
✗✗✗

$ sudo rm /hab/accepted-licenses/habitat 

$ hab pkg build habitat-plans/nodemon
+---------------------------------------------+

            Chef License Acceptance


Before you can continue, 1 product license must be accepted.
View the license at https://www.chef.io/end-user-license-agreement

License that needs accepting:

  * Habitat

Do you accept the 1 product license? [yes/No/quit] yes

Accepting 1 product license...
✓  1 product license accepted.

+---------------------------------------------+

   hab-studio: Destroying Studio at /hab/studios/home--chris--Repositories ()
   hab-studio: Creating Studio at /hab/studios/home--chris--Repositories (default)
   hab-studio: Importing 'chris' secret origin key
» Importing origin key from standard input
★ Imported secret origin key chris-20200605013411.
   hab-studio: Importing 'chris' public origin key
» Importing origin key from standard input
★ Imported public origin key chris-20200605013411.
» Installing core/hab-backline/1.6.39/20200527164610
☛ Verifying core/hab-backline/1.6.39/20200527164610
↓ Downloading core-20180119235000 public origin key

themightychris avatar Jun 05 '20 01:06 themightychris

Based on what we do with other Chef tools, we should treat the license as accepted if it has globally as root/superuser, or if has been accepted locally as that user. So we should search the global location (/hab on linux) as well as the local location ~/.hab.

Our Ruby based apps search both: https://github.com/chef/license-acceptance/blob/master/components/ruby/lib/license_acceptance/config.rb#L22

I think we need to extend our hab code to do the same: https://github.com/habitat-sh/habitat/blob/master/components/hab/src/license.rs#L145

markan avatar Jul 07 '20 18:07 markan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] avatar Jul 24 '21 22:07 stale[bot]

still an issue

themightychris avatar Jul 25 '21 12:07 themightychris

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] avatar Jul 31 '22 10:07 stale[bot]

└─# hab studio enter hab-studio: Creating Studio at /hab/studios/hab--accepted-licenses (default) hab-studio: Importing 'test' secret origin key +---------------------------------------------+

        Chef License Acceptance

Before you can continue, 1 product license must be accepted. View the license at https://www.chef.io/end-user-license-agreement

License that needs accepting:

  • Habitat

Do you accept the 1 product license? [yes/No/quit] Do you accept the 1 product license? [yes/No/quit] If you do not accept this license you will not be able to use Chef products.

Do you accept the 1 product license? [yes/No/quit] +---------------------------------------------+

✗✗✗ ✗✗✗ License agreement not accepted ✗✗✗

I am still facing this issue

golakiyaalice avatar Jul 02 '23 08:07 golakiyaalice