Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ install-vm: install-both
$(INSTALL_DATA) receiver/qubes-video-companion.rules $(DESTDIR)/usr/lib/udev/rules.d/80-qubes-video-companion.rules
$(INSTALL_DATA) receiver/qubes-video-companion.modprobe $(DESTDIR)/usr/lib/modprobe.d/qubes-video-companion.conf
$(INSTALL_DATA) receiver/qubes-video-companion.sudoers $(DESTDIR)/etc/sudoers.d/qubes-video-companion
$(INSTALL_DIR) $(DESTDIR)/etc/privleap/conf.d
$(INSTALL_DATA) receiver/qubes-video-companion.privleap $(DESTDIR)/etc/privleap/conf.d/qubes-video-companion.conf
$(INSTALL_DIR) $(DESTDIR)$(SYSCONFDIR)/qubes/rpc-config
echo 'wait-for-session=1' > $(DESTDIR)$(SYSCONFDIR)/qubes/rpc-config/qvc.Webcam
echo 'wait-for-session=1' > $(DESTDIR)$(SYSCONFDIR)/qubes/rpc-config/qvc.ScreenShare
Expand Down
3 changes: 3 additions & 0 deletions receiver/qubes-video-companion.privleap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[action:qvc-modprobe-v4l2loopback]
Command=modprobe v4l2loopback
AuthorizedGroups=sudo,privleap,qubes
31 changes: 28 additions & 3 deletions receiver/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import fcntl
import subprocess
import shutil

# see v4l2loopback.h:
# __s32 output_nr;
Expand Down Expand Up @@ -91,16 +92,40 @@ def register_device(name):
os.close(ctrl_fd)


def try_esc_exec(exe, cmdline):
if shutil.which(exe) is not None:
try:
subprocess.check_call([exe, *cmdline])
except Exception:
return False
else:
return False
return True


def main(argv):
name = None
if len(argv) == 2:
name = f"QVC - {argv[1]}"
elif len(argv) != 1:
raise RuntimeError("Invalid arguments - usage: setup.py [name]")
if not os.path.exists("/dev/v4l2loopback"):
subprocess.check_call(
["sudo", "--non-interactive", "modprobe", "v4l2loopback"]
)
if (
not try_esc_exec(
"sudo",
[
"--non-interactive",
"modprobe",
"v4l2loopback",
],
)
and not try_esc_exec(
"leaprun", ["qvc-modprobe-v4l2loopback"]
)
):
raise RuntimeError(
"Cannot escalate privileges to modprobe v4l2loopback"
)
# wait for udev to apply permission
subprocess.check_call(
["udevadm", "wait", "--settle", "/dev/v4l2loopback"]
Expand Down
1 change: 1 addition & 0 deletions rpm_spec/qubes-video-companion.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ This package contains the video-receiving portion of Qubes Video Companion.
/usr/lib/udev/rules.d/80-qubes-video-companion.rules
/usr/lib/modprobe.d/qubes-video-companion.conf
/etc/sudoers.d/qubes-video-companion
/etc/privleap/conf.d/qubes-video-companion.conf

%package docs
Summary: Documentation for qubes-video-companion
Expand Down