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

update install-worker.sh to chmod under more restrictive uname configurations #1717

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Mar 8, 2024

  1. update install-worker.sh to chmod under more restrictive configurations

    when running under a more restrictive umask, the chmod +x
    wouldn't set the r-x bits for the 'other' group. make the chmod more
    explicit.
    
    for example chmod +x under a more restrictive umask ends up without
    execute pemissions which is likely not what was intended:
    
    [jo.diaz@\ ~]$ umask 0027
    [jo.diaz@\ ~]$ touch testfile
    [jo.diaz@\ ~]$ chmod +x testfile
    [jo.diaz@\ ~]$ ls -l testfile
    -rwxr-x--- 1 jo.diaz jo.diaz 0 Mar  8 11:39 testfile
    
    where under a more typical umask things look more familiar:
    
    [jo.diaz@\ ~]$ umask 0002
    [jo.diaz@\ ~]$ touch permissive
    [jo.diaz@\ ~]$ chmod +x permissive
    [jo.diaz@\ ~]$ ls -l permissive
    -rwxrwxr-x 1 jo.diaz jo.diaz 0 Mar  8 11:40 permissive
    
    so, when using a base AMI with more restrictive umask, update the chmod
    +x's to be more explicit about what is intended.
    
    without these changes, we have seen things error out during the build
    
    2024-03-08T12:02:27-05:00: ==> amazon-ebs: Provisioning with shell
    script:
    /home/jo.diaz/projects/amazon-eks-ami/templates/al2/../shared/provisioners/generate-version-info.sh
    2024-03-08T12:02:28-05:00:     amazon-ebs:
    /home/ec2-user/script_2147.sh: line 19: /usr/bin/kubelet: Permission
    denied
    2024-03-08T12:02:28-05:00: ==> amazon-ebs: Provisioning step had errors:
    Running the cleanup provisioner, if present...
    joelddiaz committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    af1e91e View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2024

  1. update installation of aws cli for restrictive umask

    the zip file aws installation script relies on some assumptions about
    the umask set in the environment that the script runs with.
    
    running with a restrictive umask like 0027 results in a setup where the
    installed aws cli isn't usable by regular users:
    
    [ec2-user@ip-172-31-8-141 ~]$ ls -al /bin/aws
    lrwxrwxrwx. 1 root root 37 Mar 11 22:43 /bin/aws -> /usr/local/aws-cli/v2/current/bin/aws
    
    [ec2-user@ip-172-31-8-141 ~]$ ls -al /usr/local/aws-cli/
    ls: cannot open directory /usr/local/aws-cli/: Permission denied
    
    [ec2-user@ip-172-31-8-141 ~]$ ls -al /usr/local/ | grep aws
    drwxr-x---.  3 root root  16 Mar 11 22:43 aws-cli
    
    so wrap the running of the aws cli installer script with a umask that
    will leave things with a working aws cli for non-root users.
    
    with this change the permissions on the directories/files leave the aws
    cli in a working state.
    
    $ ls -l /usr/local/aws-cli/v2/2.15.29/dist/aws
    -rwxr-xr-x. 1 root root 6714680 Mar 14 15:35
    /usr/local/aws-cli/v2/2.15.29/dist/aws
    joelddiaz committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    10daaa5 View commit details
    Browse the repository at this point in the history