-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add QWT support #181
Add QWT support #181
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a full review yet, but I think I captured main point here already.
rpc/qubes.WinSign.CreateKey
Outdated
set -efo pipefail | ||
|
||
# shellcheck source=SCRIPTDIR/qubes.WinSign.common | ||
. /etc/qubes-rpc/qubes.WinSign.common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better not hardcode the path here. Especially, it's convenient to install the RPC files in /usr/local/etc/qubes-rpc in a specific AppVM.
You can use $(dirname "$0")
to find the directory.
Similar comment to all the other services too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tools/windows/edit-iso.sh
Outdated
|
||
echo "[*] Copying the final iso from '${DISPVM}' to '${OUTPUT}'..." | ||
|
||
shell_call "${DISPVM}" "cat ~/win-build.iso" | cat > "${OUTPUT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why extra cat?
shell_call "${DISPVM}" "cat ~/win-build.iso" | cat > "${OUTPUT}" | |
shell_call "${DISPVM}" "cat ~/win-build.iso" > "${OUTPUT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
key_name=sign_key_name, | ||
) | ||
|
||
dvm.kill() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If starting dvm fails, this will fail too (UnboundLocalError: cannot access local variable 'dvm' where it is not associated with a value
). Either move starting dvm before the try
part, or initialize the variable early (with None
?) and check for it here.
But also, it looks like the dvm start can be moved much later? Currently it's at the start of the build, but it's used only after the build - so, if you move it later, you can save starting it in case of build failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
qubes.WinSign.CreateKey +Qubes__Windows__Tools work-qubesos vault-sign allow | ||
qubes.WinSign.DeleteKey +Qubes__Windows__Tools work-qubesos vault-sign allow | ||
qubes.WinSign.GetCert +Qubes__Windows__Tools work-qubesos vault-sign allow | ||
qubes.WinSign.Sign +Qubes__Windows__Tools work-qubesos vault-sign allow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing policy for the timestamp service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
admin.vm.property.Get * work-qubesos win-build allow target=dom0 | ||
admin.vm.device.block.Attach * work-qubesos win-build allow target=dom0 | ||
|
||
qubes.WinSign.QueryKey +Qubes__Windows__Tools work-qubesos vault-sign allow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally for builder-specific services we use qubesbuilder.
prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
def run( | ||
self, | ||
cmd: List[str], | ||
copy_in: List[Tuple[Path, PurePath]] = None, | ||
copy_out: List[Tuple[PurePath, Path]] = None, | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support building in DispVM, this should be able to create and start new DispVM first and kill it at the end.
It does mean fresh DispVM for each component - is that a problem? In other words - are there some hidden assumption about reusing the same VM (like, depending on some files being present from previous build)?
For development builds it probably make sense to retain option to reuse the same VM over and over, so the DispVM case can be under some config option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be a DispVM all the time, for development I usually just do local builds without the builder.
qubesbuilder/executors/windows.py
Outdated
from qubesadmin import Qubes | ||
from qubesadmin.devices import DeviceAssignment, UnknownDevice | ||
from qubesadmin.exc import DeviceAlreadyAttached, QubesException | ||
from qubesadmin.utils import encode_for_vmexec | ||
from qubesadmin.vm import DispVM, QubesVM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to use qubes-builderv2 outside of Qubes VM too. It doesn't need to support building Windows code there, but it shouldn't crash on ImportError
. I think there need to be try / except ImportError
somewhere, that will catch it nicely. I have an idea where - see separate comment.
qubesbuilder/config.py
Outdated
@@ -31,6 +31,7 @@ | |||
from qubesbuilder.executors.container import ContainerExecutor | |||
from qubesbuilder.executors.local import LocalExecutor | |||
from qubesbuilder.executors.qubes import LinuxQubesExecutor | |||
from qubesbuilder.executors.windows import WindowsExecutor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can catch ImportError
here, and set some variable like windows_executor_available = False
qubesbuilder/config.py
Outdated
@@ -575,6 +576,8 @@ def get_executor(options): | |||
executor = LocalExecutor(**executor_options) # type: ignore | |||
elif executor_type == "qubes": | |||
executor = LinuxQubesExecutor(**executor_options) # type: ignore | |||
elif executor_type == "windows": | |||
executor = WindowsExecutor(**executor_options) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here throw an exception if windows_executor_available
is false.
from qubesbuilder.config import Config | ||
from qubesbuilder.distribution import QubesDistribution | ||
from qubesbuilder.executors import ExecutorError | ||
from qubesbuilder.executors.windows import WindowsExecutor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And similarly this (and the qubesadmin
imports above) can be problematic. It wants either some wrapping here (and raise an exception early in run
if qubesadmin is not available), or changing PluginManager
so that plugin import error is not fatal. IMO the first option is better if wouldn't clutter the code too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW several CI tests that are unrelated to QWT fail due to importing qubesadmin
. That could be a good check if it works as expected - tests not related to QWT should pass even if qubesadmin
cannot be imported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the qubesadmin
dependency.
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Add option to not ask user to enable network discovery Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
…age options Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #181 +/- ##
==========================================
- Coverage 78.74% 74.79% -3.95%
==========================================
Files 47 51 +4
Lines 5388 5865 +477
==========================================
+ Hits 4243 4387 +144
- Misses 1145 1478 +333 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Can you squash the fixup commits (just do |
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
…utor Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Amazing work @omeg ! Can't wait to test testing packages. Also really interesting piece of work in terms of complex qubes-builderv2 for a learner. Thanks! |
I reviewed this as of 5f3210a, and generally looks good, I'll re-test it again and if all good should be good for merging. There are a couple of TODO comments - are planning to handle them now, or leave for later (I'm fine with either)? |
I think we can merge, the remaining TODOs are minor improvements that don't impact functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this version, using window-ssh
executor I needed to attach EWDK myself. I think it was done automatically before. Since the lifetime of this VM is outside of the builder control (right?) this step needs to be documented. In theory it's one time thing (persistent attach), but the loop device needs to be re-created after each work-qubesos VM restart (or added to rc.local...). But if it can be automated, even better.
tools/windows/edit-iso.sh
Outdated
SELF=$(qubesdb-read /name) | ||
read -r -a result <<< "$(qrexec_call "${SELF}" admin.vm.property.Get+default_dispvm)" | ||
dispvm_template="${result[2]}" # default=False type=vm vm-name | ||
DISPVM=$(qrexec_call "$dispvm_template" admin.vm.CreateDisposable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DISPVM=$(qrexec_call "$dispvm_template" admin.vm.CreateDisposable) | |
DISPVM=$(qrexec_call "dom0" admin.vm.CreateDisposable) |
Doing the call to dom0 makes it use default_dispvm, so you can save one call. And admin.vm.property.Get
in the policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
rpc/qubesbuilder.WinSign.GetCert
Outdated
set -efo pipefail | ||
|
||
# shellcheck source=SCRIPTDIR/qubesbuilder.WinSign.common | ||
. "$(dirname "$0")/qubes.WinSign.common" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. "$(dirname "$0")/qubes.WinSign.common" | |
. "$(dirname "$0")/qubesbuilder.WinSign.common" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
admin.vm.device.block.Available * work-qubesos work-qubesos allow target=dom0 | ||
|
||
admin.vm.Start * work-qubesos win-build allow target=dom0 | ||
admin.vm.CurrentState * work-qubesos win-build allow target=dom0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing policy for qubesbuilder.WinFileCopyIn
and qubesbuilder.WinFileCopyOut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
qubesbuilder/executors/qubes.py
Outdated
what="copy-in", | ||
vm=self.dispvm, | ||
service=f"{self.copy_in_service}+{encoded_dst_path}", | ||
args=["/usr/lib/qubes/qfile-agent", str(src)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest for windows adding --ignore-symlinks
, or ignore them at the receiver side. At least for me it choked on them (I did have some in one of the repos).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you added the parameter, but it isn't actually used in the command...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed.
qubesbuilder/executors/qrexec.py
Outdated
qrexec_call( | ||
log=log, | ||
what="remove vm", | ||
vm=vm, | ||
service="admin.vm.Remove", | ||
ignore_errors=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kill on a DispVM implicitly remove it already. In practice this one is harmless, but results in a warning, as the target VM doesn't exist at this point anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dispvm is created in a stopped state (to attach EWDK) so Kill
doesn't do anything if there's some error during this phase. I guess I can only call Remove
if Kill
fails...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Yes, doing Remove if Kill fails with QubesVMNotStartedError (or maybe simply any error) is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved dispvm removal.
I followed @fepitre suggestion that in the SSH case the Windows worker could be any (even non-Qubes) Windows machine. Maybe I should add a config option to auto attach EWDK in the common (Qubes VM) case? |
Or even better, try to attach EWDK if the current |
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
I've added |
tools/windows/generate-iso.sh
Outdated
" | ||
} | ||
|
||
if ! OPTS=$(getopt -o hi:o: --long help,iso,output: -n "$0" -- "$@"); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ! OPTS=$(getopt -o hi:o: --long help,iso,output: -n "$0" -- "$@"); then | |
if ! OPTS=$(getopt -o hi:o: --long help,iso:,output: -n "$0" -- "$@"); then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tools/windows/edit-iso.sh
Outdated
SCRIPT_DIR=$(readlink -f "${SCRIPT_DIR}") | ||
|
||
echo "[*] Setting up a loop device for the ISO..." | ||
LODEV=$(losetup -f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also this sometimes needs sudo (if there are no free devices and one needs to be created)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Also support auto-starting a SSH qube and attaching EWDK to it. Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
QubesOS/qubes-issues#1861