Skip to content

Commit 49ab319

Browse files
committed
Outline sycl user creation into a separate script; Make it require password for sudo
1 parent 1ea04f5 commit 49ab319

File tree

5 files changed

+38
-47
lines changed

5 files changed

+38
-47
lines changed

devops/containers/ubuntu2204_base.Dockerfile

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,8 @@ USER root
88
COPY scripts/install_build_tools.sh /install.sh
99
RUN /install.sh
1010

11-
# By default Ubuntu sets an arbitrary UID value, that is different from host
12-
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
13-
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
14-
# 1001, that is used as default by GitHub Actions.
15-
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
16-
# Add sycl user to video/irc groups so that it can access GPU
17-
RUN usermod -aG video sycl
18-
RUN usermod -aG irc sycl
19-
20-
# group 109 is required for sycl user to access PVC card.
21-
RUN groupadd -g 109 render
22-
RUN usermod -aG render sycl
23-
24-
# Allow sycl user to run as sudo
25-
RUN echo "sycl ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
11+
COPY scripts/setup-sycl-user.sh /user-setup.sh
12+
RUN /user-setup.sh
2613

2714
COPY actions/cached_checkout /actions/cached_checkout
2815
COPY actions/cleanup /actions/cleanup

devops/containers/ubuntu2204_build.Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,8 @@ RUN apt update && apt install -yqq rocm-dev && \
3030
apt-get clean && \
3131
rm -rf /var/lib/apt/lists/*
3232

33-
# By default Ubuntu sets an arbitrary UID value, that is different from host
34-
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
35-
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
36-
# 1001, that is used as default by GitHub Actions.
37-
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
38-
# Add sycl user to video/irc groups so that it can access GPU
39-
RUN usermod -aG video sycl
40-
RUN usermod -aG irc sycl
33+
COPY scripts/setup-sycl-user.sh /user-setup.sh
34+
RUN /user-setup.sh
4135

4236
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
4337

devops/containers/ubuntu2204_preinstalled.Dockerfile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@ ARG base_image=ghcr.io/intel/llvm/ubuntu2204_intel_drivers
33

44
FROM $base_image:$base_tag
55

6+
USER ROOT
7+
68
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
79
RUN mkdir -p /opt/sycl
810
ADD sycl_linux.tar.gz /opt/sycl/
911

1012
ENV PATH /opt/sycl/bin:$PATH
1113
ENV LD_LIBRARY_PATH /opt/sycl/lib:$LD_LIBRARY_PATH
1214

13-
# By default Ubuntu sets an arbitrary UID value, that is different from host
14-
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
15-
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
16-
# 1001, that is used as default by GitHub Actions.
17-
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
18-
# Add sycl user to video/irc groups so that it can access GPU
19-
RUN usermod -aG video sycl
20-
RUN usermod -aG irc sycl
21-
2215
USER sycl
2316

2417
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]

devops/containers/ubuntu2404_base.Dockerfile

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,8 @@ USER root
88
COPY scripts/install_build_tools.sh /install.sh
99
RUN /install.sh
1010

11-
# By default Ubuntu sets an arbitrary UID value, that is different from host
12-
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
13-
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
14-
# 1001, that is used as default by GitHub Actions.
15-
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
16-
# Add sycl user to video/irc groups so that it can access GPU
17-
RUN usermod -aG video sycl
18-
RUN usermod -aG irc sycl
19-
20-
# group 109 is required for sycl user to access PVC card.
21-
RUN groupadd -g 109 render
22-
RUN usermod -aG render sycl
23-
24-
# Allow sycl user to run as sudo
25-
RUN echo "sycl ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
11+
COPY scripts/create-sycl-user.sh /user-setup.sh
12+
RUN /user-setup.sh
2613

2714
COPY actions/cached_checkout /actions/cached_checkout
2815
COPY actions/cleanup /actions/cleanup

devops/scripts/create-sycl-user.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# By default Ubuntu sets an arbitrary UID value, that is different from host
4+
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
5+
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
6+
# 1001, that is used as default by GitHub Actions.
7+
groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
8+
# Add sycl user to video/irc groups so that it can access GPU
9+
usermod -aG video sycl
10+
usermod -aG irc sycl
11+
12+
# group 109 is required for sycl user to access PVC card.
13+
groupadd -g 109 render
14+
usermod -aG render sycl
15+
16+
if [[ -f /run/secrets/sycl_passwd ]]; then
17+
# When running in our CI environment, we restrict access to root.
18+
19+
# Set password for sycl user
20+
cat /run/secrets/sycl_passwd | passwd -s sycl
21+
22+
# Allow sycl user to run as sudo, but only with password
23+
echo "sycl ALL=(root) PASSWD:ALL" >> /etc/sudoers
24+
else
25+
# Otherwise, we allow password-less root to simplify building other
26+
# containers on top.
27+
28+
# Allow sycl user to run as sudo passwrod-less
29+
echo "sycl ALL=(root) NOPASSWD:ALL" >> /etc/sudoers
30+
fi

0 commit comments

Comments
 (0)