Skip to content

Commit 0964ce8

Browse files
committed
Differentiate password-less sycl vs sycl-ci user
1 parent 6d88ec7 commit 0964ce8

8 files changed

+54
-31
lines changed

devops/containers/ubuntu2204_base.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ COPY actions/cleanup /actions/cleanup
1616
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
1717
COPY scripts/install_drivers.sh /opt/install_drivers.sh
1818

19-
USER sycl
19+
USER sycl_ci
2020

2121
ENTRYPOINT ["/docker_entrypoint.sh"]

devops/containers/ubuntu2204_build.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RUN --mount=type=secret,id=sycl_passwd /user-setup.sh
3535

3636
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
3737

38-
USER sycl
38+
USER sycl_ci
3939

4040
ENTRYPOINT ["/docker_entrypoint.sh"]
4141

devops/containers/ubuntu2204_intel_drivers.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN --mount=type=secret,id=github_token \
2727

2828
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2929

30-
USER sycl
30+
USER sycl_ci
3131

3232
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
3333

devops/containers/ubuntu2204_preinstalled.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ADD sycl_linux.tar.gz /opt/sycl/
1212
ENV PATH /opt/sycl/bin:$PATH
1313
ENV LD_LIBRARY_PATH /opt/sycl/lib:$LD_LIBRARY_PATH
1414

15+
# For preinstalled containers we create a different user which has
16+
# password-less sudo access
17+
RUN /user-setup.sh --regular
1518
USER sycl
1619

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

devops/containers/ubuntu2404_base.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ COPY actions/cleanup /actions/cleanup
1616
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
1717
COPY scripts/install_drivers.sh /opt/install_drivers.sh
1818

19-
USER sycl
19+
USER sycl_ci
2020

2121
ENTRYPOINT ["/docker_entrypoint.sh"]

devops/containers/ubuntu2404_intel_drivers.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN --mount=type=secret,id=github_token \
2727

2828
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2929

30-
USER sycl
30+
USER sycl_ci
3131

3232
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
3333

devops/containers/ubuntu2404_intel_drivers_igc_dev.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN --mount=type=secret,id=github_token \
2222

2323
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2424

25-
USER sycl
25+
USER sycl_ci
2626

2727
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2828

devops/scripts/create-sycl-user.sh

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
#!/bin/bash
22

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
3+
set -e
4+
5+
if [[ $# -eq 0 ]]; then
6+
# When launched without arguments, we assume that it was launched as part of
7+
# CI workflow and therefore a different kind of user is created
8+
USER_NAME=sycl_ci
9+
SET_PASSWD=true
10+
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+
USER_ID=1001
2416
else
25-
# Otherwise, we allow password-less root to simplify building other
26-
# containers on top.
17+
if [[ "${1:-}" != "--regular" ]]; then
18+
echo "The only supported argument is --regular!"
19+
exit 1
20+
fi
21+
USER_NAME=sycl
22+
SET_PASSWD=false
23+
24+
# Some user id which is different from the one assigned to sycl_ci user
25+
USER_ID=1234
26+
fi
27+
28+
groupadd -g $USER_ID $USER_NAME && useradd $USER_NAME -u $USER_ID -g $USER_ID -m -s /bin/bash
29+
# Add user to video/irc groups so that it can access GPU
30+
usermod -aG video $USER_NAME
31+
usermod -aG irc $USER_NAME
2732

28-
# Allow sycl user to run as sudo passwrod-less
29-
echo "sycl ALL=(root) NOPASSWD:ALL" >> /etc/sudoers
33+
# group 109 is required for user to access PVC card.
34+
groupadd -f -g 109 render
35+
usermod -aG render $USER_NAME
36+
37+
if [[ $SET_PASSWD == true ]]; then
38+
if [[ ! -f /run/secrets/sycl_ci_passwd ]]; then
39+
echo "Password is requested, but /run/secrtes/sycl_ci_passwd doesn't exists!"
40+
exit 2
41+
fi
42+
43+
# Set password for user
44+
echo "$USER_NAME:$(cat /run/secrets/sycl_ci_passwd)" | chpasswd
45+
46+
# Allow user to run as sudo, but only with password
47+
echo "$USER_NAME ALL=(ALL) PASSWD:ALL" >> /etc/sudoers
48+
else
49+
echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
3050
fi

0 commit comments

Comments
 (0)