Skip to content

Commit 047bea7

Browse files
committed
Remove acl-restore.sh and do setfacl via udev instead
1 parent f7044e7 commit 047bea7

7 files changed

Lines changed: 14 additions & 64 deletions

File tree

.github/workflows/presubmit.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,6 @@ jobs:
520520
containers-storage:localhost/cuttlefish-orchestration:latest
521521
- name: Run cvd e2e test for podcvd
522522
run: |
523-
# Grant permission on devices as it's hard to grant on test env
524-
sudo chmod 666 /dev/kvm /dev/vhost-net /dev/vhost-vsock
525523
cd e2etests
526524
bazel test \
527525
//cvd/cvd_powerwash_tests \

container/debian/cuttlefish-podcvd.cuttlefish-podcvd.init

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ podcvd_cidr=${podcvd_cidr:-192.168.112.0/20}
3434
podcvd_ifname="podcvd"
3535

3636
start() {
37+
modprobe vhost_net || true
38+
modprobe vhost_vsock || true
39+
3740
ip link add "${podcvd_ifname}" type dummy
3841
ip link set "${podcvd_ifname}" up
3942
ip route add local "${podcvd_cidr}" dev "${podcvd_ifname}"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
src/podcvd/podcvd /usr/lib/cuttlefish-podcvd/bin/
22
debian/podcvd-setup /usr/lib/cuttlefish-podcvd/bin/
3-
debian/restore-acls.sh /usr/lib/cuttlefish-podcvd/bin/
43
debian/podcvd.users /etc/
54
src/podcvd/skill /usr/lib/cuttlefish-podcvd/

container/debian/cuttlefish-podcvd.podcvd-acl-restore.service

Lines changed: 0 additions & 12 deletions
This file was deleted.

container/debian/podcvd-setup

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@ echo "${username}:${assigned_range}" | sudo tee -a "$USER_CONFIG" > /dev/null
9999

100100
echo "Successfully allocated range $assigned_range to user '$username'."
101101

102-
# 5. Apply ACLs immediately (requires sudo)
103-
echo "Configuring device permissions..."
104-
sudo setfacl -m "u:$username:rw" /dev/kvm
105-
sudo setfacl -m "u:$username:rw" /dev/vhost-net
106-
sudo setfacl -m "u:$username:rw" /dev/vhost-vsock
102+
# 5. Add udev rule for applying ACLs and triggers immediately. (requires sudo)
103+
echo "Configuring custom udev rules for applying ACLs for user '$username'..."
104+
cat <<EOF | sudo tee /etc/udev/rules.d/99-podcvd-acls-$username.rules > /dev/null
105+
KERNEL=="kvm", RUN+="/usr/bin/setfacl -m u:$username:rw /dev/%k"
106+
KERNEL=="vhost-net", RUN+="/usr/bin/setfacl -m u:$username:rw /dev/%k"
107+
KERNEL=="vhost-vsock", RUN+="/usr/bin/setfacl -m u:$username:rw /dev/%k"
108+
EOF
109+
sudo udevadm control --reload-rules
110+
sudo udevadm trigger --action=change /dev/kvm
111+
sudo udevadm trigger --action=change /dev/vhost-net
112+
sudo udevadm trigger --action=change /dev/vhost-vsock
107113

108114
# 6. Enable rootless podman socket for the user (runs as unprivileged user)
109115
echo "Starting Podman user service..."

container/debian/restore-acls.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

container/debian/rules

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ override_dh_installinit:
3535

3636
.PHONY: override_dh_installsystemd
3737
override_dh_installsystemd:
38-
dh_installsystemd --name=podcvd-acl-restore
3938
dh_installsystemd --name=cuttlefish-podcvd
4039
dh_installsystemd
4140

0 commit comments

Comments
 (0)