Fix Podman container to run as non-root user
- Add sudo package installation in containers - Create backport-user account in containers - Set proper ownership of workspace directory - Configure sudo access for backport-user - Run ostree-backport.sh as non-root user - This fixes the 'should not be run as root' safety check - Maintains all safety features while allowing proper execution
This commit is contained in:
parent
fc05ffcbb9
commit
c6b363974e
3 changed files with 12 additions and 4 deletions
|
|
@ -69,14 +69,18 @@ run_in_podman() {
|
|||
bash -c "
|
||||
echo '=== Setting up container environment ==='
|
||||
apt update -y
|
||||
apt install -y git curl wget
|
||||
apt install -y git curl wget sudo
|
||||
git clone https://git.raines.xyz/robojerk/libostree-dev.git /tmp/libostree-dev
|
||||
cp -r /tmp/libostree-dev/* /workspace/
|
||||
cp -r /tmp/libostree-dev/.* /workspace/ 2>/dev/null || true
|
||||
chmod +x /workspace/*.sh
|
||||
echo '=== Container ready, running backport ==='
|
||||
cd /workspace
|
||||
./ostree-backport.sh noble
|
||||
# Create a non-root user for running the script
|
||||
useradd -m -s /bin/bash backport-user
|
||||
chown -R backport-user:backport-user /workspace
|
||||
echo 'backport-user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
su - backport-user -c 'cd /workspace && ./ostree-backport.sh noble'
|
||||
"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,14 +69,18 @@ run_in_podman() {
|
|||
bash -c "
|
||||
echo '=== Setting up container environment ==='
|
||||
apt update -y
|
||||
apt install -y git curl wget
|
||||
apt install -y git curl wget sudo
|
||||
git clone https://git.raines.xyz/robojerk/libostree-dev.git /tmp/libostree-dev
|
||||
cp -r /tmp/libostree-dev/* /workspace/
|
||||
cp -r /tmp/libostree-dev/.* /workspace/ 2>/dev/null || true
|
||||
chmod +x /workspace/*.sh
|
||||
echo '=== Container ready, running backport ==='
|
||||
cd /workspace
|
||||
./ostree-backport.sh trixie
|
||||
# Create a non-root user for running the script
|
||||
useradd -m -s /bin/bash backport-user
|
||||
chown -R backport-user:backport-user /workspace
|
||||
echo 'backport-user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||
su - backport-user -c 'cd /workspace && ./ostree-backport.sh trixie'
|
||||
"
|
||||
}
|
||||
|
||||
|
|
|
|||
0
libostree-dev_noble_backport.sh
Normal file → Executable file
0
libostree-dev_noble_backport.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue