diff --git a/AntiEvilMaid.md b/AntiEvilMaid.md index 0ffd201c..2b6ec1b0 100644 --- a/AntiEvilMaid.md +++ b/AntiEvilMaid.md @@ -18,9 +18,9 @@ Installing In Dom0 install anti-evil-maid: -{% highlight trac-wiki %} +``` sudo qubes-dom0-update anti-evil-maid -{% endhighlight %} +``` More information regarding configuration in the [README](https://github.com/QubesOS/qubes-antievilmaid/blob/master/README) file. diff --git a/AssigningDevices.md b/AssigningDevices.md index a75fdb84..04cc8338 100644 --- a/AssigningDevices.md +++ b/AssigningDevices.md @@ -10,21 +10,21 @@ Assigning Devices to VMs In order to assign a whole PCI(e) device to a VM, one should use `qvm-pci` tool. E.g. -{% highlight trac-wiki %} +``` lspci -{% endhighlight %} +``` Find the BDF address of the device you want to assign, and then: -{% highlight trac-wiki %} +``` qvm-pci -a -{% endhighlight %} +``` E.g. assuming 00:1a.0 is a BDF of the device I want to assign to the "personal" domain: -{% highlight trac-wiki %} +``` qvm-pci -a personal 00:1a.0 -{% endhighlight %} +``` Note that one can only assign full PCI or PCI Express devices. This means one cannot assign single USB devices -- only the whole USB controller with whatever USB devices connected to it. This limit is imposed by PC and VT-d architecture. @@ -40,33 +40,33 @@ Finding the right USB controller If you want assign certain USB device to a VM (by attaching a whole USB controller), you need to figure out which PCI device is the right controller. First check to which USB bus the device is connected: -{% highlight trac-wiki %} +``` lsusb -{% endhighlight %} +``` For example I want assign a broadband modem to the netvm. In lsusb output it can be listed as something like this (in this case device isn't fully identified): -{% highlight trac-wiki %} +``` Bus 003 Device 003: ID 413c:818d Dell Computer Corp. -{% endhighlight %} +``` The device is connected to the USB bus \#3. Then check which other devices are connected to the same bus - all of them will be assigned to the same VM. Now is the time to find right USB controller: -{% highlight trac-wiki %} +``` readlink /sys/bus/usb/devices/usb3 -{% endhighlight %} +``` This should output something like: -{% highlight trac-wiki %} +``` ../../../devices/pci-0/pci0000:00/0000:00:1a.0/usb3 -{% endhighlight %} +``` Now you see BDF address in the path (right before final usb3). Strip leading "0000:" and pass the rest to qvm-pci tool: -{% highlight trac-wiki %} +``` qvm-pci -a netvm 00:1a.0 -{% endhighlight %} +``` Possible issues --------------- @@ -75,11 +75,11 @@ Possible issues VMs with assigned PCI devices in Qubes have allocated a small buffer for DMA operations (called swiotlb). By default it is 2MB, but some devices need a larger buffer. To change this allocation, edit VM's kernel parameters (this is expressed in 512B chunks): -{% highlight trac-wiki %} +``` # qvm-prefs netvm |grep kernelopts kernelopts : iommu=soft swiotlb=2048 (default) # qvm-prefs -s netvm kernelopts "iommu=soft swiotlb=4096" -{% endhighlight %} +``` This is [known to be needed](https://groups.google.com/group/qubes-devel/browse_thread/thread/631c4a3a9d1186e3) for Realtek RTL8111DL Gigabit Ethernet Controller. @@ -87,7 +87,7 @@ This is [known to be needed](https://groups.google.com/group/qubes-devel/browse_ Sometimes PCI arbitrator is too strict. There is a way to enable permissive mode for it. Create `/etc/systemd/system/qubes-pre-netvm.service`: -{% highlight trac-wiki %} +``` [Unit] Description=Netvm fixup Before=qubes-netvm.service @@ -99,7 +99,7 @@ RemainAfterExit=yes [Install] WantedBy=multi-user.target -{% endhighlight %} +``` Then enable it with `systemctl enable qubes-pre-netvm.service` @@ -118,11 +118,11 @@ or 1. Go to the sysfs (`/sys/bus/pci`), find the right device, detach it from the pciback driver and attach back to the original driver. Replace `` with your device, for example `00:1c.2`: - {% highlight trac-wiki %} + ``` echo 0000: > /sys/bus/pci/drivers/pciback/unbind MODALIAS=`cat /sys/bus/pci/devices/0000:/modalias` MOD=`modprobe -R $MODALIAS | head -n 1` echo > /sys/bus/pci/drivers/$MOD/bind - {% endhighlight %} + ``` diff --git a/BackupEmergencyRestoreV2.md b/BackupEmergencyRestoreV2.md index f8359783..f9750a24 100644 --- a/BackupEmergencyRestoreV2.md +++ b/BackupEmergencyRestoreV2.md @@ -15,7 +15,7 @@ The Qubes backup system has been designed with emergency disaster recovery in mi 1. Untar the main backup file. - {% highlight trac-wiki %} + ``` [user@restore ~]$ tar -i -xvf qubes-backup-2013-12-26-123456 backup-header backup-header.hmac @@ -31,17 +31,17 @@ The Qubes backup system has been designed with emergency disaster recovery in mi vm1/whitelisted-appmenus.list.000.hmac dom0-home/dom0user.000 dom0-home/dom0user.000.hmac - {% endhighlight %} + ``` 1. Verify the integrity of the `private.img` file which houses your data. - {% highlight trac-wiki %} + ``` [user@restore ~]$ cd vm1/ [user@restore vm1]$ openssl dgst -sha512 -hmac "your_passphrase" private.img.000 HMAC-SHA512(private.img.000)= cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e [user@restore vm1]$ cat private.img.000.hmac (stdin)= cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e - {% endhighlight %} + ``` **Note:** The hash values should match. If they do not match, then the backup file may have been tampered with, or there may have been a storage error. @@ -49,59 +49,59 @@ The Qubes backup system has been designed with emergency disaster recovery in mi 1. Decrypt the `private.img` file. - {% highlight trac-wiki %} + ``` [user@restore vm1]$ openssl enc -d -pass pass:your_passphrase -aes-256-cbc -in private.img.000 -out private.img.dec.000 - {% endhighlight %} + ``` **Note:** For multi-part files, a loop can be used: - {% highlight trac-wiki %} + ``` for f in private.img.*; do openssl enc -d -pass pass:your_passphrase -aes-256-cbc -in $f -out ${f/.img/.img.dec} done - {% endhighlight %} + ``` **Note:** If your backup was encrypted with a cipher algorithm other than `aes-256-cbc`, you must substitute the correct cipher command. A complete list of supported cipher algorithms can be found with `openssl list-cipher-algorithms`. 1. Decompress the decrypted `private.img` file. - {% highlight trac-wiki %} + ``` [user@restore vm1]$ zforce private.img.dec.* [user@restore vm1]$ gunzip private.img.dec.000.gz - {% endhighlight %} + ``` **Note:** If your backup was compressed with a program other than `gzip`, you must substitute the correct compression program. 1. Untar the decrypted and decompressed `private.img` file. - {% highlight trac-wiki %} + ``` [user@restore vm1]$ tar -M -xvf private.img.dec.000 vm1/private.img - {% endhighlight %} + ``` **Note:** For multi-part files, a script is required: 1. Create a `new-volume-script`: - {% highlight trac-wiki %} + ``` #!/bin/sh name=`expr $TAR_ARCHIVE : '\(.*\)\..*'` suffix=`printf %03d $[ $TAR_VOLUME - 1 ]` echo $name.$suffix >&$TAR_FD - {% endhighlight %} + ``` 2. `chmod +x new-volume-script`. 3. `tar --new-volume-script=./new-volume-script -xvf private.img.dec.000`. (The `--new-volume-script` option enables multi-volume untaring.) 1. Mount the private.img file and access your data. - {% highlight trac-wiki %} + ``` [user@restore vm1]$ sudo mkdir /mnt/img [user@restore vm1]$ sudo mount -o loop vm1/private.img /mnt/img/ [user@restore vm1]$ cat /mnt/img/home/user/your_data.txt This data has been successfully recovered! - {% endhighlight %} + ``` **Note:** You may wish to store a plain text copy of these instructions with your Qubes backups in the event that you fail to recall the above procedure while this web page is inaccessible. You may obtain a plaintext version of this file in Git repository housing all the documentation at: diff --git a/BuildingArchlinuxTemplate.md b/BuildingArchlinuxTemplate.md index 9cd6ab90..e70c2be9 100644 --- a/BuildingArchlinuxTemplate.md +++ b/BuildingArchlinuxTemplate.md @@ -23,17 +23,17 @@ Change the following variables GIT\_SUBDIR=marmarek DISTS\_VM=archlinux Get all required sources ------------------------ -{% highlight trac-wiki %} +``` make get-sources -{% endhighlight %} +``` Note that make get-sources sometimes fails because it didn't download packages that are not used by archlinux such as xfce or kde packages. You can ignore the repositories that are failing by adding the following line to your builder.conf: -{% highlight trac-wiki %} +``` COMPONENTS:=$(filter-out desktop-linux-kde desktop-linux-xfce,$(COMPONENTS)) -{% endhighlight %} +``` Just don't forget that you need to comment this line again if you want to build the whole Qubes-OS install CD. @@ -42,23 +42,23 @@ Make all required qubes components The first use of the builder can take several hours depending on your bandwidth as it will install an archlinux chroot: -{% highlight trac-wiki %} +``` make vmm-xen-vm make core-vchan-xen-vm make linux-utils-vm make core-agent-linux-vm make gui-common-vm make gui-agent-linux-vm -{% endhighlight %} +``` Now build the template itself ----------------------------- This can take again several hours, especially the first time you built and archlinux template: -{% highlight trac-wiki %} +``` make linux-template-builder -{% endhighlight %} +``` Retrieve your template ---------------------- @@ -75,30 +75,30 @@ Can't open file archlinux-2013.02.01-dual.iso Archlinux ISO files are sometimes removed from mirrors. Check the last version available on the archlinux mirror (eg: [http://mir.archlinux.fr/iso/](http://mir.archlinux.fr/iso/)), and update qubes-src/linux-template-builder/scripts\_archlinux/00\_prepare.sh accordingly: -{% highlight trac-wiki %} +``` ISO_VERSION=2013.06.01 -{% endhighlight %} +``` You will also need to download the signature matching this ISO version inside qubes-src/linux-template-builder/scripts\_archlinux/: -{% highlight trac-wiki %} +``` wget http://mir.archlinux.fr/iso/2013.06.01/archlinux-2013.06.01-dual.iso.sig -{% endhighlight %} +``` The nm-applet (network manager icon) fails to start when archlinux is defined as a template-vm: ----------------------------------------------------------------------------------------------- In fact /etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf does not allow a standard user to run network manager clients. To allow this, one need to change inside \: -{% highlight trac-wiki %} +``` -{% endhighlight %} +``` to -{% highlight trac-wiki %} +``` -{% endhighlight %} +``` DispVM, Yum proxy and most Qubes addons (thunderbird ...) have not been tested at all. -------------------------------------------------------------------------------------- @@ -111,26 +111,26 @@ This is apparently a bug in Archlinux between glibc and pulseaudio package 4.0-6 Error when building the gui-agent-linux with pulsecore error ------------------------------------------------------------ -{% highlight trac-wiki %} +``` module-vchan-sink.c:62:34: fatal error: pulsecore/core-error.h: No such file or directory #include -{% endhighlight %} +``` This error is because Archlinux update package too quickly. Probably, a new version of pulseaudio has been released, but the qubes team has not imported the new development headers yet. You can create fake new headers just by copying the old headers: -{% highlight trac-wiki %} +``` cd qubes-builder/qubes-src/gui-agent-linux/pulse ls cp -r pulsecore-#lastversion pulsecore-#archlinuxversion -{% endhighlight %} +``` You can check the current archlinux pulseaudio version like this: -{% highlight trac-wiki %} +``` sudo chroot chroot-archlinux/ pacman -Qi pulseaudio -{% endhighlight %} +``` chroot-archlinux/dev/pts has not been unmounted ----------------------------------------------- @@ -154,15 +154,15 @@ The boot process fails without visible errors in the logs, but spawn a recovery The problem is a new conflict between systemd and the old sysvinit style. To fix this, you can change the master xen template in dom0 to remove sysvinit remains: Edit **INSIDE DOM0** /usr/share/qubes/vm-template.conf, and change the variable 'extra' that contains the kernel variables: from: -{% highlight trac-wiki %} +``` extra="ro nomodeset 3 console=hvc0 rd_NO_PLYMOUTH {kernelopts}" -{% endhighlight %} +``` to: -{% highlight trac-wiki %} +``` extra="ro nomodeset console=hvc0 rd_NO_PLYMOUTH {kernelopts}" -{% endhighlight %} +``` Qubes-OS is now using different xenstore variable names, which makes to archlinux VM failing to boot ---------------------------------------------------------------------------------------------------- @@ -171,15 +171,15 @@ Apply the following fix in the template to revert the variable name to the old Q You can edit the template the following way: -{% highlight trac-wiki %} +``` sudo mkdir /mnt/vm sudo mount /var/lib/qubes/vm-templates/archlinux-x64/root.img /mnt/vm sudo chroot /mnt/vm -{% endhighlight %} +``` Then apply the fix: -{% highlight trac-wiki %} +``` sudo sed 's:qubes-keyboard:qubes_keyboard:g' -i /etc/X11/xinit/xinitrc.d/qubes-keymap.sh sudo sed 's:qubes-netvm-domid:qubes_netvm_domid:g' -i /etc/NetworkManager/dispatcher.d/30-qubes-external-ip @@ -212,19 +212,19 @@ sudo sed 's:qubes-vm-updateable:qubes_vm_updateable:g' -i /usr/lib/qubes/qubes_t sudo sed 's:qubes-vm-type:qubes_vm_type:g' -i /usr/bin/qubes-session sudo sed 's:qubes-vm-updateable:qubes_vm_updateable:g' -i /usr/bin/qubes-session -{% endhighlight %} +``` Do not forgot to: -{% highlight trac-wiki %} +``` umount /mnt/vm -{% endhighlight %} +``` Installing the template in dom0 fails because of a missing dependency (qubes-core-dom0-linux) --------------------------------------------------------------------------------------------- Again you built a template based on a recent Qubes API which has not been released yet. So skip the dependency for now: -{% highlight trac-wiki %} +``` sudo rpm -U --nodeps yourpackage.rpm -{% endhighlight %} +``` diff --git a/BuildingNonFedoraTemplate.md b/BuildingNonFedoraTemplate.md index 7f654b46..3fb15c8a 100644 --- a/BuildingNonFedoraTemplate.md +++ b/BuildingNonFedoraTemplate.md @@ -24,11 +24,11 @@ You need to install your OS inside a chroot that will be used to build all the r The scripts you will be interested in will be inside the qubes-src/linux-template-builder project: -{% highlight trac-wiki %} +``` scripts_fedora scripts_archlinux scripts_yourOSname -{% endhighlight %} +``` ### 00\_prepare.sh @@ -42,19 +42,19 @@ The goal of this script is to install a base environment of your target OS insid Edit the builder.conf file to change the variable DISTS\_VM to your OS name (DISTS\_VM=your\_os\_name). The try to make the template to check that at least these to first scripts are working correctly: -{% highlight trac-wiki %} +``` make linux-template-builder -{% endhighlight %} +``` Qubes builder Makefiles ----------------------- Now you need to create Makefiles specific to your OS. You will find the required scripts directly inside qubes-builder: -{% highlight trac-wiki %} +``` prepare-chroot-yourOSname Makefile.yourOSname -{% endhighlight %} +``` ### prepare-chroot-yourOSname @@ -103,11 +103,11 @@ Additional Installation scripts Again you need to work on scripts inside the qubes-src/linux-template-builder project: -{% highlight trac-wiki %} +``` scripts_fedora scripts_archlinux scripts_yourOSname -{% endhighlight %} +``` ### 02\_install\_groups.sh diff --git a/CodingStyle.md b/CodingStyle.md index a26c6561..5e1aa7f5 100644 --- a/CodingStyle.md +++ b/CodingStyle.md @@ -47,14 +47,14 @@ General typographic conventions - Comments should be indent together with the code, e.g. like this: - {% highlight trac-wiki %} + ``` for (...) { // The following code finds PGP private key matching the given public key in O(1) while (key_found) { (...) } } - {% endhighlight %} + ``` File naming conventions ----------------------- @@ -87,29 +87,29 @@ General programming style guidelines - Use comments to explain non-trivial code fragments, or expected behavior of more complex functions, if it is not clear from their name. - Do **not** use comments for code fragments where it is immediately clear what the code does. E.g. avoid constructs like this: - {% highlight trac-wiki %} + ``` // Return window id int get_window_id (...) { (...) return id; } - {% endhighlight %} + ``` - Do **not** use comments to disable code fragments. In a production code there should really be no commented or disabled code fragments. If you really, really have a good reason to retain some fragment of unused code, use \#if or \#ifdef to disable it, e.g.: - {% highlight trac-wiki %} + ``` #if 0 (...) // Some unused code here #endif - {% endhighlight %} + ``` ... and preferably use some descriptive macro instead of just `0`, e.g.: - {% highlight trac-wiki %} + ``` #if USE_OLD_WINDOW_TRAVERSING (...) // Some unused code here #endif - {% endhighlight %} + ``` Not sure how to do similar thing in Python... Anyone? @@ -137,7 +137,7 @@ Security coding guidelines - Any input that comes from untrusted, or less trusted, or just differently-trusted, entity should always be considered as malicious and should always be sanitized and verified. So, if your software runs in Dom0 and processes some input from any of the VMs, this input should be considered to be malicious. Even if your software runs in a VM, and processes input from some other VM, you should also assume that the input is malicious and verify it. - Use `untrusted_` prefix for all variables that hold values read from untrusted party and which have not yet been verified to be decent, e.g.: - {% highlight trac-wiki %} + ``` read_struct(untrusted_conf); /* sanitize start */ if (untrusted_conf.width > MAX_WINDOW_WIDTH) @@ -146,7 +146,7 @@ Security coding guidelines untrusted_conf.height = MAX_WINDOW_HEIGHT; width = untrusted_conf.width; height = untrusted_conf.height; - {% endhighlight %} + ``` - Use another variables, without the `untrusted_` prefix to hold the sanitized values, as shown above. diff --git a/CopyPaste.md b/CopyPaste.md index 7ac185ce..689c4c78 100644 --- a/CopyPaste.md +++ b/CopyPaste.md @@ -52,22 +52,22 @@ Clipboard automatic policy enforcement The Qubes clipboard policy is configurable in: -{% highlight trac-wiki %} +``` /etc/qubes-rpc/policy/qubes.ClipboardPaste -{% endhighlight %} +``` You may wish to configure this policy in order to prevent user error. For example, if you are certain that you never wish to paste *into* your "vault" AppVM (and it is highly recommended that you do not), then you should edit the policy as follows: -{% highlight trac-wiki %} +``` $anyvm vault deny $anyvm $anyvm ask -{% endhighlight %} +``` Shortcut Configuration ---------------------- The copy/paste shortcuts are configurable in: -{% highlight trac-wiki %} +``` /etc/qubes/guid.conf -{% endhighlight %} +``` diff --git a/CopyToDomZero.md b/CopyToDomZero.md index 93606a17..ed62636f 100644 --- a/CopyToDomZero.md +++ b/CopyToDomZero.md @@ -12,15 +12,15 @@ First, there should normally be few reasons for the user to want to copy files f For this reason we intentionally do not provide a convenient tool for copying files between VMs and Dom0 (while we provide a tool for copying files between VMs). However, if you're determined to copy some files to Dom0 anyway, you can use the following method (run this command from Dom0's console): -{% highlight trac-wiki %} +``` qvm-run --pass-io 'cat /path/to/file_in_src_domain' > /path/to/file_name_in_dom0 -{% endhighlight %} +``` BTW, you can use the same method to copy files from Dom0 to VMs: -{% highlight trac-wiki %} +``` cat /path/to/file_in_dom0 | qvm-run --pass-io 'cat > /path/to/file_name_in_appvm' -{% endhighlight %} +``` ### Copying logs from dom0 diff --git a/DevelopmentWorkflow.md b/DevelopmentWorkflow.md index c32016ef..9def5daa 100644 --- a/DevelopmentWorkflow.md +++ b/DevelopmentWorkflow.md @@ -22,10 +22,10 @@ The best way to write and contribute code is to create a git repo somewhere (e.g **Example:** -{% highlight trac-wiki %} +``` $ cd qubes-builder/qubes-src/qubes-manager $ git remote add abel git@github.com:abeluck/qubes-manager.git -{% endhighlight %} +``` You can then proceed to easily develop in your own branches, pull in new commits from the dev branches, merge them, and eventually push to your own repo on github. @@ -37,55 +37,55 @@ When you are ready to submit your changes to Qubes to be merged, push your chang In qubes-builder/qubes-src/kernel: -{% highlight trac-wiki %} +``` make prep -{% endhighlight %} +``` The resulting tree will be in kernel-\/linux-\: -{% highlight trac-wiki %} +``` ls -ltrd kernel*/linux* -{% endhighlight %} +``` -{% highlight trac-wiki %} +``` drwxr-xr-x 23 user user 4096 Nov 5 09:50 kernel-3.4.18/linux-3.4.18 drwxr-xr-x 6 user user 4096 Nov 21 20:48 kernel-3.4.18/linux-obj -{% endhighlight %} +``` #### Go to the kernel tree and update the version In qubes-builder/qubes-src/kernel: -{% highlight trac-wiki %} +``` cd kernel-3.4.18/linux-3.4.18 -{% endhighlight %} +``` #### Changing the config In kernel-3.4.18/linux-3.4.18: -{% highlight trac-wiki %} +``` cp ../../config-pvops .config make oldconfig -{% endhighlight %} +``` Now change the configuration. For example, in kernel-3.4.18/linux-3.4.18: -{% highlight trac-wiki %} +``` make menuconfig -{% endhighlight %} +``` Copy the modified config back into the kernel tree: -{% highlight trac-wiki %} +``` cp .config ../../../config-pvops -{% endhighlight %} +``` #### Patching the code TODO: describe the workflow for patching the code, below are some random notes, not working well -{% highlight trac-wiki %} +``` ln -s ../../patches.xen export QUILT_PATCHES=patches.xen export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" @@ -101,7 +101,7 @@ quilt add drivers/usb/host/Kconfig drivers/usb/host/Makefile \ quilt refresh cd ../.. vi series-pvops.conf -{% endhighlight %} +``` #### Building RPMS @@ -113,20 +113,20 @@ You might want to take a moment here to review (git diff, git status), commit yo To actually build RPMS, in qubes-src/kernel: -{% highlight trac-wiki %} +``` make rpms -{% endhighlight %} +``` RPMS will appear in qubes-src/kernel/rpm/x86\_64: -{% highlight trac-wiki %} +``` -rw-rw-r-- 1 user user 42996126 Nov 17 04:08 kernel-3.4.18-1debug20121116c.pvops.qubes.x86_64.rpm -rw-rw-r-- 1 user user 43001450 Nov 17 05:36 kernel-3.4.18-1debug20121117a.pvops.qubes.x86_64.rpm -rw-rw-r-- 1 user user 8940138 Nov 17 04:08 kernel-devel-3.4.18-1debug20121116c.pvops.qubes.x86_64.rpm -rw-rw-r-- 1 user user 8937818 Nov 17 05:36 kernel-devel-3.4.18-1debug20121117a.pvops.qubes.x86_64.rpm -rw-rw-r-- 1 user user 54490741 Nov 17 04:08 kernel-qubes-vm-3.4.18-1debug20121116c.pvops.qubes.x86_64.rpm -rw-rw-r-- 1 user user 54502117 Nov 17 05:37 kernel-qubes-vm-3.4.18-1debug20121117a.pvops.qubes.x86_64.rpm -{% endhighlight %} +``` ### Useful [QubesBuilder](/doc/QubesBuilder/) commands @@ -148,7 +148,7 @@ You may also like to run your [test environment on separate machine](/doc/TestBe TODO: edit this script to be more generic -{% highlight trac-wiki %} +``` #!/bin/sh set -x @@ -171,24 +171,24 @@ sudo cp misc/qubes-start.desktop /usr/share/qubes/ sudo cp misc/block-snapshot /etc/xen/scripts/ sudo cp aux-tools/qubes-dom0-updates.cron /etc/cron.daily/ # FIXME(Abel Luck): I hope to -{% endhighlight %} +``` ### Apply qvm-tools TODO: make it more generic -{% highlight trac-wiki %} +``` #!/bin/sh BAK=qvm-tools.bak$$ mkdir -p $BAK cp -a /usr/bin/qvm-* /usr/bin/qubes-* $BAK/ sudo cp qvm-tools/qvm-* qvm-tools/qubes-* /usr/bin/ -{% endhighlight %} +``` ### Copy from dom0 to an appvm -{% highlight trac-wiki %} +``` #/bin/sh # # usage ./cp-domain @@ -199,4 +199,4 @@ fname=`basename $file` qvm-run $domain 'mkdir /home/user/incoming/dom0 -p' cat $file| qvm-run --pass-io $domain "cat > /home/user/incoming/dom0/$fname" -{% endhighlight %} +``` diff --git a/DiskTRIM.md b/DiskTRIM.md index 3d91bddf..8567ac9b 100644 --- a/DiskTRIM.md +++ b/DiskTRIM.md @@ -11,23 +11,23 @@ To enable TRIM in dom0 you need: 1. Get your LUKS device UUID: - {% highlight trac-wiki %} + ``` ls /dev/mapper/luks-* - {% endhighlight %} + ``` 2. Add entry to `/etc/crypttab` (replace luks-\ with the device name and the \ with UUID alone): - {% highlight trac-wiki %} + ``` luks- UUID= none allow-discards - {% endhighlight %} + ``` 3. Add `rd.luks.allow-discards=1` to kernel cmdline (`/etc/default/grub`, GRUB\_CMDLINE\_LINUX line) 4. Rebuild grub config (`grub2-mkconfig -o /boot/grub2/grub.cfg`) 5. Rebuild initrd **in hostonly mode**: - {% highlight trac-wiki %} + ``` dracut -H -f - {% endhighlight %} + ``` 6. Add "discard" option to `/etc/fstab` for root device 7. Reboot the system, verify that allow-discards is really enabled (`dmsetup table`) diff --git a/DisposableVms.md b/DisposableVms.md index 0f1d4e61..461ac310 100644 --- a/DisposableVms.md +++ b/DisposableVms.md @@ -38,9 +38,9 @@ Opening a file in a Disposable VM via command line (from AppVM) Use the `qvm-open-in-dvm` command line (from your AppVM), e.g.: -{% highlight trac-wiki %} +``` [user@work-pub ~]$ qvm-open-in-dvm Downloads/apple-sandbox.pdf -{% endhighlight %} +``` The qvm-open-in-dvm will not exit until you close the application in the Disposable VM. @@ -49,9 +49,9 @@ Starting an arbitrary application in a disposable VM via command line (from Dom0 **Note:** Normally there should be no need for doing this -- this is just for Qubes hackers ;) -{% highlight trac-wiki %} +``` [joanna@dom0 ~]$ echo xterm | /usr/lib/qubes/qfile-daemon-dvm qubes.VMShell dom0 DEFAULT red -{% endhighlight %} +``` In fact the Disposable VM appmenu used for starting Firefox contains a very similar command to the above. Please note, however, that it generally makes little sense to start any other application other than a Web Browser this way... @@ -60,9 +60,9 @@ Starting an arbitrary program in a Disposable VM from an AppVM Sometimes it might be useful to start an arbitrary program, such as e.g. terminal in an Disposable VM from an AppVM. This could be simply done this way: -{% highlight trac-wiki %} +``` [user@vault ~]$ qvm-run '$dispvm' xterm -{% endhighlight %} +``` Note the above command is issued in an AppVM, not in Dom0. The created Disposable VM can be normally accessed via other tools, such as e.g. `qvm-copy-to-vm`, using its 'dispX' name, as shown by the Qubes Manager or `qvm-ls` tools. diff --git a/Donations.md b/Donations.md index 386eba81..1f5a01c5 100644 --- a/Donations.md +++ b/Donations.md @@ -10,9 +10,9 @@ Donating to the Qubes Project The Qubes project is now accepting donations in Bitcoins. You can use the following address to send Bitcoins to the project (but you might want to read the short FAQ below first): -{% highlight trac-wiki %} +``` 14zockMSKKp5MK6X2cHJ3mQwm9MwYsJ39j -{% endhighlight %} +``` This address can also be found in a message posted to Qubes mailing list, which can be viewed via Google Groups Web interface over SSL [here](https://groups.google.com/d/msg/qubes-devel/u3wAzm1dB5Y/s5CiUGDebL4J), for double verification. For additional verification, you can verify the digital signature on the message, which should come from Joanna Rutkowska. diff --git a/ExternalAudio.md b/ExternalAudio.md index deedc75e..4e1f6fa6 100644 --- a/ExternalAudio.md +++ b/ExternalAudio.md @@ -22,16 +22,16 @@ First you need to identify an user VM dedicated to audio and [assign a device](/ In a terminal of the template from which you user VM depends, install pavucontrol with: -{% highlight trac-wiki %} +``` sudo yum install pavucontrol -{% endhighlight %} +``` Close the template and start or restart your user VM, insert your external audio device, open a terminal and prepare pulseaudio to use it with: -{% highlight trac-wiki %} +``` sudo chmod a+rw /dev/snd/* pactl load-module module-udev-detect -{% endhighlight %} +``` Start the audio application that is going to use the external audio device. @@ -39,8 +39,8 @@ Launch pavucontrol, for example using "run command in VM" of Qubes Manager and s If you detach your external audio device, then want to insert it again, or change it with another one, you need to repeat the previous commands in terminal, adding an other line at the beginning: -{% highlight trac-wiki %} +``` pactl unload-module module-udev-detect sudo chmod a+rw /dev/snd/* pactl load-module module-udev-detect -{% endhighlight %} +``` diff --git a/ExternalDeviceMountPoint.md b/ExternalDeviceMountPoint.md index 65220cf2..c5301fe6 100644 --- a/ExternalDeviceMountPoint.md +++ b/ExternalDeviceMountPoint.md @@ -7,8 +7,8 @@ redirect_from: /wiki/ExternalDeviceMountPoint/ All external storage devices connected to an AppVM using the Fedora template can be found under -{% highlight trac-wiki %} +``` /run/media/user/ -{% endhighlight %} +``` ...of that AppVM's filesystem. diff --git a/FedoraTemplateUpgrade18.md b/FedoraTemplateUpgrade18.md index f15d521e..06b929ba 100644 --- a/FedoraTemplateUpgrade18.md +++ b/FedoraTemplateUpgrade18.md @@ -17,32 +17,32 @@ Upgrading Fedora 18 to Fedora 20 Commands to run in dom0 console (you can do the same from Qubes Manager): -{% highlight trac-wiki %} +``` qvm-clone fedora-18-x64 fedora-20-x64 qvm-run -a fedora-20-x64 gnome-terminal -{% endhighlight %} +``` Commands to run in new fedora-20-x64 template: -{% highlight trac-wiki %} +``` sudo yum --releasever=20 distro-sync poweroff -{% endhighlight %} +``` If you have installed a lot of software in your template, it may happen that you don't have enough disk space for upgrade. Yum will tell you this just after confirming the operation (before it change anything to your system). In that case you need to provide some "external" place for yum cache (uses about 2GB during upgrade). For example attach virtual disk stored in some file. Prepare the file in dom0: -{% highlight trac-wiki %} +``` truncate -s 5GB /var/tmp/template-upgrade-cache.img qvm-block -A fedora-20-x64 dom0:/var/tmp/template-upgrade-cache.img -{% endhighlight %} +``` Then use it in template: -{% highlight trac-wiki %} +``` sudo mkfs.ext4 /dev/xvdi sudo mount /dev/xvdi /mnt/removable sudo yum --releasever=20 --setopt=cachedir=/mnt/removable distro-sync -{% endhighlight %} +``` After upgrade is finished, you can remove /var/tmp/template-upgrade-cache.img file. @@ -55,17 +55,17 @@ fstrim, nor "discard" mount option do not work on template root fs, so when some You can compact root.img in the "old way", you'll need about 15GB (template's max size + really used space there) in dom0 for this operation: Start the template, fill all the free space with zeros, for example with: -{% highlight trac-wiki %} +``` dd if=/dev/zero of=/var/tmp/zero (wait for "No space left on device" error) rm -f /var/tmp/zero -{% endhighlight %} +``` Then shutdown template and all VMs based on it. Go into template directory in dom0 (/var/lib/qubes/vm-templates/fedora-20-x64 or so) and issue: -{% highlight trac-wiki %} +``` cp --sparse=always root.img root.img.new mv root.img.new root.img -{% endhighlight %} +``` Done. diff --git a/Fetchmail.md b/Fetchmail.md index 7c35a6b8..a4a06dbf 100644 --- a/Fetchmail.md +++ b/Fetchmail.md @@ -24,7 +24,7 @@ Assuming you have more than one account (safe assumption these days), you need t In TemplateVM create `/etc/systemd/system/fetchmail@.service`: -{% highlight trac-wiki %} +``` [Unit] Description=Mail Retrieval Agent After=network.target @@ -34,11 +34,11 @@ Requires=postfix.service User=user ExecStart=/bin/fetchmail -f /usr/local/etc/fetchmail/%I.rc -d 60 -i /usr/local/etc/fetchmail/.%I.fetchids --pidfile /usr/local/etc/fetchmail/.%I.pid RestartSec=1 -{% endhighlight %} +``` Then shutdown TemplateVM, start AppVM and create directory `/usr/local/etc/fetchmail`. In it, create one `.rc` file for each instance of fetchmail, ie. `personal1.rc` and `personal2.rc`. Sample configuration file: -{% highlight trac-wiki %} +``` set syslog set no bouncemail #set daemon 600 @@ -57,13 +57,13 @@ user woju pass supersecret idle # vim: ft=fetchmail -{% endhighlight %} +``` Then `chown -R user:user /usr/local/etc/fetchmail` and `chmod 600 /usr/local/etc/fetchmail/*.rc`. **This is important**, fetchmail will refuse to run with wrong permissions on its rc-file. Next, add this to `/rw/config/rc.local`: -{% highlight trac-wiki %} +``` #!/bin/sh for rc in /usr/local/etc/fetchmail/*.rc; do @@ -71,6 +71,6 @@ for rc in /usr/local/etc/fetchmail/*.rc; do instance=${instance##*/} echo systemctl --no-block start fetchmail@${instance} done -{% endhighlight %} +``` Now reboot your AppVM and you are done. diff --git a/FullScreenMode.md b/FullScreenMode.md index 11ff817d..7078f4b9 100644 --- a/FullScreenMode.md +++ b/FullScreenMode.md @@ -30,19 +30,19 @@ If you want to enable full screen mode for select VMs, you can do that by creati **Note:** There should be only one `VM: {}` block in the file (or you will [get into problems](https://groups.google.com/d/msg/qubes-users/-Yf9yNvTsVI/xXsEm8y2lrYJ)) -{% highlight trac-wiki %} +``` VM: { personal: { allow_fullscreen = true; }; }; -{% endhighlight %} +``` The string 'personal' above is exemplary and should be replaced by the actual name of the VM for which you want to enable this functionality. One can also enable this functionality for all the VMs globally in the same file, by modifying the 'global' section: -{% highlight trac-wiki %} +``` global: { # default values allow_fullscreen = true; @@ -51,6 +51,6 @@ global: { #secure_paste_sequence = "Ctrl-Shift-v"; #windows_count_limit = 500; }; -{% endhighlight %} +``` Be sure to restart the VM(s) after modifying this file, for the changes to take effect. diff --git a/GUIdocs.md b/GUIdocs.md index 4bc6f56c..32b091d9 100644 --- a/GUIdocs.md +++ b/GUIdocs.md @@ -100,7 +100,7 @@ Window manager hints and flags are described at [http://standards.freedesktop.or Each message starts with the following header -{% highlight trac-wiki %} +``` struct msghdr { uint32_t type; uint32_t window; @@ -111,7 +111,7 @@ struct msghdr { * whatever it wants! */ uint32_t untrusted_len; }; -{% endhighlight %} +``` The header is followed by message-specific data. @@ -183,12 +183,12 @@ Proper handling of the below messages is NOT security-critical. Each message starts with the following header -{% highlight trac-wiki %} +``` struct msghdr { uint32_t type; uint32_t window; }; -{% endhighlight %} +``` The header is followed by message-specific data. ` KEYPRESS, BUTTON, MOTION, FOCUS ` messages pass information extracted from dom0 XEvent; see appropriate event documentation. diff --git a/GettingStarted.md b/GettingStarted.md index bb771d17..aa9691cb 100644 --- a/GettingStarted.md +++ b/GettingStarted.md @@ -55,15 +55,15 @@ By default, each domain's menu contains only a few shortcuts. If you'd like to a To start apps from the console in dom0, type: -{% highlight trac-wiki %} +``` qvm-run -a " [arguments]" -{% endhighlight %} +``` e.g.: -{% highlight trac-wiki %} +``` qvm-run -a untrusted firefox -{% endhighlight %} +``` Adding, Removing, and Listing Domains ------------------------------------- @@ -96,7 +96,7 @@ To allow domains to enter full screen mode, one should edit the `/etc/qubes/guid E.g. to allow all domains to enter full screen mode, set `allow_fullscreen` flag to `true` in the `global` section: -{% highlight trac-wiki %} +``` global: { # default values allow_fullscreen = false; @@ -105,18 +105,18 @@ global: { #secure_paste_sequence = "Ctrl-Shift-v"; #windows_count_limit = 500; }; -{% endhighlight %} +``` To allow only select AppVMs to enter full screen mode, create a per-VM section, and set `allow_fullscreen` flag there to `true`: -{% highlight trac-wiki %} +``` VM: { work: { allow_fullscreen = true; }; }; -{% endhighlight %} +``` In order for the changes to take effect, restart the AppVM(s). diff --git a/HvmCreate.md b/HvmCreate.md index 9f9a9f46..b3cde776 100644 --- a/HvmCreate.md +++ b/HvmCreate.md @@ -20,23 +20,23 @@ Creating an HVM domain First, lets create a new HVM domain (use the --hvm switch to qvm-create, or choose HVM type in the Qubes Manager VM creation dialog box): -{% highlight trac-wiki %} +``` qvm-create win7 --hvm --label green -{% endhighlight %} +``` (Of course, the name of the domain ("win7"), as well as it's label ("green"), are just exemplary). Now, we need to install an OS inside this VM, this can done by attaching an installation ISO upon starting the VM (this currently can be done only from command line, but in the future we surely will added an option to do this also from the manager): -{% highlight trac-wiki %} +``` qvm-start win7 --cdrom=/usr/local/iso/win7_en.iso -{% endhighlight %} +``` The command above assumes the installation ISO was somehow transferred to Dom0, e.g. copied using `dd` command from an installation CDROM. If one wishes to use the actual physical media without copying it first to a file, then one can just pass `/dev/cdrom` as an argument to `--cdrom`: -{% highlight trac-wiki %} +``` qvm-start win7 --cdrom=/dev/cdrom -{% endhighlight %} +``` Now, the VM will start booting from the attached CDROM device, which in the example above just happens to be the Windows 7 installation disk. Depending on the OS that is being installed in the VM, one might be required to start the VM several times (as is the case e.g. with Windows 7 installation), because whenever the installer wants to "reboot the system", it actually shutdowns the VM (and Qubes won't automatically start it), so several invocations of qvm-start command (as shown above) might be needed. @@ -47,16 +47,16 @@ Using Installation ISOs located in other VMs Sometimes one wants to download the installation ISO from the Web and use it for HVM creation. However, for security reasons, networking is disabled for Qubes Dom0, which makes it not possible to download an ISO within Dom0. Also Qubes do not provide any (easy to use) mechanisms for copying files between AppVMs and Dom0, and generally tries to discourage such actions. So, it would be inconvenient to require that the installation ISO for an HVM domain be always located in Dom0. And the good news is that this is indeed not required -- one can use the following syntax when specifying the location of /usr/local/iso/win7\_en.iso the installation ISO: -{% highlight trac-wiki %} +``` --cdrom=[appvm]:[/path/to/iso/within/appvm] -{% endhighlight %} +``` Assuming e.g. the an installation ISO named `ubuntu-12.10-desktop-i386.iso` has been downloaded in `work-web` AppVM, and located within `/home/user/Downloads` directory within this AppVM, one can immediately create a new HVM and use this ISO as an installation media with the following command (issued in Dom0, of course): -{% highlight trac-wiki %} +``` qvm-create --hvm ubuntu --label red qvm-start ubuntu --cdrom=work-web:/home/user/Downloads/ubuntu-12.10-desktop-i386.iso -{% endhighlight %} +``` Of course the AppVM where the ISO is kept must also be running for this to work (this VM is now serving the ISO and acting as a disk backend). @@ -93,7 +93,7 @@ Just like normal AppVMs, the HVM domains can also be cloned, either using a comm The cloned VM will get identical root and private image, and essentially will be identical to the original VM, except that it will get a different MAC address for the networking interface: -{% highlight trac-wiki %} +``` [joanna@dom0 ~]$ qvm-prefs win7 name : win7 label : green @@ -145,21 +145,21 @@ qrexec_installed : False qrexec timeout : 60 drive : None timezone : localtime -{% endhighlight %} +``` Note how the MAC addresses differ between those two, otherwise identical VMs. Of course, the IP addresses, assigned by Qubes, will also be different, to allow networking to function properly: -{% highlight trac-wiki %} +``` [joanna@dom0 ~]$ qvm-ls -n /.../ win7-copy | | Halted | Yes | | *firewallvm | green | 10.137.2.3 | n/a | 10.137.2.1 | win7 | | Halted | Yes | | *firewallvm | green | 10.137.2.7 | n/a | 10.137.2.1 | /.../ -{% endhighlight %} +``` If, for any reason, one would like to make sure that the two VMs have the same MAC address, one can use qvm-prefs to set a fixed MAC address for the VM: -{% highlight trac-wiki %} +``` [joanna@dom0 ~]$ qvm-prefs win7-copy -s mac 00:16:3E:5E:6C:05 [joanna@dom0 ~]$ qvm-prefs win7-copy name : win7-copy @@ -184,7 +184,7 @@ qrexec_installed : False qrexec timeout : 60 drive : None timezone : localtime -{% endhighlight %} +``` Please note that as of now Qubes does not support shared templates for HVM domains. This means that HVM domains cloned this way will have two separate copies of the whole filesystems. This has consequences in taking much more disk space compared to standard AppVMs that share the root fs with the Template VM. Another consequence is that it's probably not legal to clone a proprietary OS, such as Windows this way, unless your license specifically allows for that (even though Windows Activation won't complain when one sets identical MAC address for the cloned VMs, it's doubtful practice at best). @@ -211,22 +211,22 @@ Qubes Windows Support Tools are not open source and are distributed under a comm Because the Windows Support Tools are not licensed under a GPL license they are not distributed with Qubes installation ISO. Instead, one can download them when needed using the standard Qubes command for installing software in Dom0: -{% highlight trac-wiki %} +``` sudo qubes-dom0-update qubes-windows-tools -{% endhighlight %} +``` This should install `qubes-windows-tools-*.rpm` in your system, a package that brings an ISO with Windows Support Tools: -{% highlight trac-wiki %} +``` [joanna@dom0 ~]$ rpm -ql qubes-windows-tools-1-201211301354.noarch /usr/lib/qubes/qubes-windows-tools-201211301354.iso -{% endhighlight %} +``` Now, in order to install the tools in a Windows VM one should start the VM with the ISO attached: -{% highlight trac-wiki %} +``` qvm-start lab-win7 --cdrom=/usr/lib/qubes/qubes-windows-tools-201211301354.iso -{% endhighlight %} +``` Once the Windows VM boots, a CDROM should appear in the 'My Computer' menu (typically as `D:`) with a setup program in its main directory: @@ -242,25 +242,25 @@ After successful installation, the Windows VM must be shut down. Additionally, once should inform Qubes that tools have been installed in this VM by setting the `qrexec_installed` flag in the VM's properties -- this can be done using the `qvm-prefs` command in Dom0, e.g.: -{% highlight trac-wiki %} +``` qvm-prefs lab-win7 -s qrexec_installed true -{% endhighlight %} +``` Also, by default Qubes assumes that the default user in the Windows VM is named `user` -- if one has chosen a different user during Windows installation, Qubes should be informed about this by setting the `default_user` property for the VM, e.g.: -{% highlight trac-wiki %} +``` qvm-prefs lab-win7 -s default_user joanna -{% endhighlight %} +``` If everything went fine (please remember about the need to reboot the Windows VM after installation of the tools), one can run some simple tests to see if qrexec service runs fine with this VM, e.g.: -{% highlight trac-wiki %} +``` qvm-run lab-win7 calc -{% endhighlight %} +``` ... or something more fancy (a "networkless" telnet to Windows ;): -{% highlight trac-wiki %} +``` [joanna@dom0 ~]$ qvm-run lab-win7 -p cmd.exe Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. @@ -283,7 +283,7 @@ dir c:\ C:\Windows\system32>exit exit -{% endhighlight %} +``` Another things to check are if clipboard copy/paste and file copy works fine with this VM. If it doesn't, then perhaps one more VM reboot is necessary (seriously, hey this is Windows!). diff --git a/InstallNvidiaDriver.md b/InstallNvidiaDriver.md index 38816b74..822dffb7 100644 --- a/InstallNvidiaDriver.md +++ b/InstallNvidiaDriver.md @@ -17,19 +17,19 @@ There are rpm packages with all necessary software on rpmfusion. The only packag You will need any Fedora 18 system to download and build packages. You can use Qubes AppVM for it, but it isn't necessary. To download packages from rpmfusion - add this repository to your yum configuration (instructions are on their website). Then download packages using yumdownloader: -{% highlight trac-wiki %} +``` yumdownloader --resolve xorg-x11-drv-nvidia yumdownloader --source nvidia-kmod -{% endhighlight %} +``` ###Build kernel package You will need at least kernel-devel (matching your Qubes dom0 kernel), rpmbuild tool and kmodtool, and then you can use it to build package: -{% highlight trac-wiki %} +``` yum install kernel-devel rpm-build kmodtool rpmbuild --nodeps -D "kernels `uname -r`" --rebuild nvidia-kmod-260.19.36-1.fc13.3.src.rpm -{% endhighlight %} +``` In above command replace `uname -r` with kernel version from your Qubes dom0. If everything went right, you have now complete packages with nvidia drivers for Qubes system. Transfer them to dom0 (eg using USB stick) and install (using standard "yum install /path/to/file"). @@ -37,15 +37,15 @@ Then you need to disable nouveau (normally it is done by install scripts from nv Edit /etc/default/grub: - {% highlight trac-wiki %} + ``` GRUB_CMDLINE_LINUX="quiet rhgb nouveau.modeset=0 rd.driver.blacklist=nouveau video=vesa:off" - {% endhighlight %} + ``` Regenerate grub configuration: - {% highlight trac-wiki %} + ``` grub2-mkconfig -o /boot/grub2/grub.cfg - {% endhighlight %} + ``` Reboot. @@ -65,9 +65,9 @@ See [this page](/doc/CopyToDomZero/) for instructions on how to transfer files t Install libraries, Xorg driver, configuration utilities. This can by done by nvidia-installer: -{% highlight trac-wiki %} +``` ./NVIDIA-Linux-x86_64-260.19.44.run --ui=none --no-x-check --keep --no-nouveau-check --no-kernel-module -{% endhighlight %} +``` ###Kernel module @@ -85,21 +85,21 @@ This installation must be done manually, because nvidia-installer refused to ins If all the files are not there correct the errors manually. To build kernel module, enter *NVIDIA-Linux-x86\_64-260.19.44/kernel* directory and execute: -{% highlight trac-wiki %} +``` make IGNORE_XEN_PRESENCE=1 CC="gcc -DNV_VMAP_4_PRESENT -DNV_SIGNAL_STRUCT_RLIM" make -f Makefile.kbuild mv /lib/modules/2.6.34.1-12.xenlinux.qubes.x86_64/kernel/drivers/video/nvidia.ko /lib/modules/2.6.34.1-12.xenlinux.qubes.x86_64/extra/ -{% endhighlight %} +``` Ignore any errors while inserting nvidia.ko (at the end of make phase). ###Disable nouveau: -{% highlight trac-wiki %} +``` cat /etc/modprobe.d/nouveau-disable.conf # blacklist isn't enough... install nouveau /bin/true -{% endhighlight %} +``` Add *rdblacklist=nouveau* option to /boot/grub/menu.lst (at the end of line containing *vmlinuz*). @@ -107,11 +107,11 @@ Add *rdblacklist=nouveau* option to /boot/grub/menu.lst (at the end of line cont After all, you should configure Xorg to use nvidia driver. You can use *nvidia-xconfig* or do it manually: -{% highlight trac-wiki %} +``` X -configure mv /root/xorg.conf.new /etc/X11/xorg.conf # replace Driver in Device section by "nvidia" -{% endhighlight %} +``` diff --git a/InstallationIsoBuilding.md b/InstallationIsoBuilding.md index f8f0fc9a..2c942a6e 100644 --- a/InstallationIsoBuilding.md +++ b/InstallationIsoBuilding.md @@ -17,10 +17,10 @@ Build installer packages Get [Qubes Installer repository](http://git.qubes-os.org/?p=smoku/installer) and build its packages: -{% highlight trac-wiki %} +``` cd installer make rpms -{% endhighlight %} +``` Packages will be in `rpm/noarch` and `rpm/x86_64`. @@ -29,10 +29,10 @@ Install Revisor Next install the freshly built revisor and anaconda: -{% highlight trac-wiki %} +``` yum install rpm/noarch/revisor*.rpm yum install rpm/x86_64/anaconda*.rpm -{% endhighlight %} +``` Review configuration files -------------------------- @@ -68,18 +68,18 @@ The ```build/yum/dom0-updates``` is to be used for select rpms that should also Update your local repos: -{% highlight trac-wiki %} +``` make update-repo -{% endhighlight %} +``` Build ISO --------- Now you're finally ready to build the ISO image: -{% highlight trac-wiki %} +``` make iso -{% endhighlight %} +``` and wait... diff --git a/KdeDom0.md b/KdeDom0.md index f21b6f48..2446e1fc 100644 --- a/KdeDom0.md +++ b/KdeDom0.md @@ -13,9 +13,9 @@ The Qubes kde-dom0 project (see [Source Code](/doc/SourceCode/)) contains the so Getting the sources ------------------- -{% highlight trac-wiki %} +``` git clone git://qubes-os.org/mainstream/kde-dom0.git kde-dom0 -{% endhighlight %} +``` Building the packages --------------------- @@ -24,27 +24,27 @@ It's best to use Fedora 12 or 13 as a development system. First, you should download and verify the original KDE sources (not part of the kde-dom0 repository): -{% highlight trac-wiki %} +``` make get-sources verify-sources -{% endhighlight %} +``` Now, check if you have all the required build dependencies: -{% highlight trac-wiki %} +``` make prep -{% endhighlight %} +``` Install any required packages that `make` might have complained about. Then you're ready to build the rpms (you might want to adjust the release of each rpm package by editing the `rel` variable at the beginning of each `.spec` file): -{% highlight trac-wiki %} +``` make rpms -{% endhighlight %} +``` **Note:** The `kdebase-*` packages build process requires corresponding `kdelibs-devel` package to be installed first. If your build system is based on Fedora 12/13, and if the `kdelibs-devel` package exist in Fedora repo that is based the same KDE software version (e.g. 4.4.3) as the KDE packages you're building (see the `version` file), than you should be able to use the Fedora package: -{% highlight trac-wiki %} +``` yum install kdelibs-devel-{version} -{% endhighlight %} +``` If not, then you should build your `kdelibs-devel` first (`cd kdelibs-devel && make rpms`), then install it on your build system, and then you can build all the rest (`make rpms`). diff --git a/LinuxHVMTips.md b/LinuxHVMTips.md index 5a3db991..0f2f47cf 100644 --- a/LinuxHVMTips.md +++ b/LinuxHVMTips.md @@ -20,24 +20,24 @@ To achieve it (all commands run as root): 1. Generate XOrg configuratio (if you don't have it): - {% highlight trac-wiki %} + ``` X -configure :1 && mv ~/xorg.conf.new /etc/X11/xorg.conf - {% endhighlight %} + ``` 2. Add HorizSync line to Monitor section, it should look something like: - {% highlight trac-wiki %} + ``` Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "Monitor Model" HorizSync 30.0 - 60.0 EndSection - {% endhighlight %} + ``` 3. Change driver to "vesa" in Device section: - {% highlight trac-wiki %} + ``` Section "Device" # (...) Identifier "Card0" @@ -46,7 +46,7 @@ To achieve it (all commands run as root): BoardName "Unknown Board" BusID "PCI:0:2:0" EndSection - {% endhighlight %} + ``` Now you should get at least 1280x1024 and be able to choose other modes. diff --git a/Mutt.md b/Mutt.md index a86aad17..7b797dc0 100644 --- a/Mutt.md +++ b/Mutt.md @@ -33,7 +33,7 @@ Mutt generally works out of the box. This configuration guide discusses only Qub First, paste this to `/etc/Muttrc.local` in TemplateVM: -{% highlight trac-wiki %} +``` # specify your key or override in ~/.mutt/muttrc in AppVM set pgp_sign_as="0xDEADBEEF" @@ -105,11 +105,11 @@ send-hook "~A" set pgp_autoinline=no crypt_autoencrypt=no send-hook "~t @invisiblethingslab\.com" set crypt_autoencrypt=yes # vim:ft=muttrc -{% endhighlight %} +``` Then shutdown your TemplateVM. Next open your AppVM, create file `/home/user/.mutt/muttrc` and adjust for your needs: -{% highlight trac-wiki %} +``` # # accounts # @@ -134,14 +134,14 @@ subscribe (qubes-(users|devel)|othergroup)@googlegroups\.com fcc-save-hook qubes-users@googlegroups\.com =list/qubes-users/ fcc-save-hook qubes-devel@googlegroups\.com =list/qubes-devel/ fcc-save-hook othergroup@googlegroups\.com =list/othergroup/ -{% endhighlight %} +``` You may also create `/home/user/.signature`: -{% highlight trac-wiki %} +``` regards, Wojciech Porczyk -{% endhighlight %} +``` Some additional useful settings ------------------------------- diff --git a/NetworkBridgeSupport.md b/NetworkBridgeSupport.md index 469c2a15..3035f076 100644 --- a/NetworkBridgeSupport.md +++ b/NetworkBridgeSupport.md @@ -22,20 +22,20 @@ Qubes manager patch (Qubes R2B2) The following patches can be applied to the Qubes Manager GUI in order to add an option to easily bridge a VM. Use it at your own risk. If the patch breaks the Qubes Manager, you can try to restore the qubes packages: -{% highlight trac-wiki %} +``` # qubes-dom-update qubes-core-dom0 qubes-manager # yum reinstall qubes-core-dom0 # yum reinstall qubes-manager -{% endhighlight %} +``` First, retrieve the attachment of this Wifi article in dom0. Then apply the three patches the following way after installing the patch tool : -{% highlight trac-wiki %} +``` # qubes-dom0-update patch # patch /usr/lib64/python2.7/site-package/qubes/qubes.py < qubes.py-bridge.diff # patch /usr/lib64/python2.7/site-package/qubesmanager/settings.py < settings.py-bridge.diff # patch /usr/lib64/python2.7/site-package/qubesmanager/ui_settingsdlg.py < ui_settingsdlg.py-bridge.diff -{% endhighlight %} +``` Finally restart the qubes manager GUI. @@ -50,7 +50,7 @@ Modify manually the Template you use for your NetVM (not the NetVM itself). This - Starting from the line -A POSTROUTING -j MASQUERADE that you need to comment : - {% highlight trac-wiki %} + ``` # Bridge support # Comment the following line #-A POSTROUTING -j MASQUERADE @@ -59,26 +59,26 @@ Modify manually the Template you use for your NetVM (not the NetVM itself). This # Allow redirection of bridge packets (optional as POSTROUTING default is ACCEPT) #-A POSTROUTING -o bridge+ -j ACCEPT # End Bridge support - {% endhighlight %} + ``` - Starting from the line -A FORWARD -i vif+ -j ACCEPT: - {% highlight trac-wiki %} + ``` -A FORWARD -i vif+ -o vif+ -j DROP -A FORWARD -i vif+ -j ACCEPT # Bridge Support -A FORWARD -i bridge+ -j ACCEPT # End Bridge Support -A FORWARD -j DROP - {% endhighlight %} + ``` Ensure that the IP addresses used by default in qubes are in the form 10.137.1.\* or 10.137.2.\* by running ifconfig. Of course, this setup won't work with IPv6. Now you need to restart the NetVM and FirewallVM or only iptables in both VMs if you prefer: -{% highlight trac-wiki %} +``` # systemctl restart iptables -{% endhighlight %} +``` Create a Bridge inside the NetVM -------------------------------- @@ -96,7 +96,7 @@ The bridge edition GUI is somehow buggy as it does not remember all the paramete - Bridge-DHCP - {% highlight trac-wiki %} + ``` [connection] id=Bridge-DHCP uuid=fd68198b-313a-47cb-9155-52e95cdc67f3 @@ -113,13 +113,13 @@ The bridge edition GUI is somehow buggy as it does not remember all the paramete [bridge] interface-name=bridge0 stp=false - {% endhighlight %} + ``` Note: Do not forget to put stp=false if you bridge only eth0 because sending BPDUs could make your admins angry :) - bridge0-eth0 - {% highlight trac-wiki %} + ``` [802-3-ethernet] duplex=full mac-address=88:AE:1D:AE:30:31 @@ -132,12 +132,12 @@ Note: Do not forget to put stp=false if you bridge only eth0 because sending BPD timestamp=1363601650 master=fd68198b-313a-47cb-9155-52e95cdc67f3 slave-type=bridge - {% endhighlight %} + ``` If you do not manager to start your bridge, you can start it manually from a NetVM terminal: -{% highlight trac-wiki %} +``` $ nmcli con up id bridge0-eth0 -{% endhighlight %} +``` Now that the bridge is ready, the bridged AppVM can be started... diff --git a/NvidiaTroubleshooting.md b/NvidiaTroubleshooting.md index 71a560fd..60ddbc1a 100644 --- a/NvidiaTroubleshooting.md +++ b/NvidiaTroubleshooting.md @@ -22,15 +22,15 @@ Assuming your X Window System works fine now when you booted from the "failsafe" 1. Switch to runlevel 3 (this should kill your X server): -{% highlight trac-wiki %} +``` init 3 -{% endhighlight %} +``` 1. Run X-autoconfiguration: -{% highlight trac-wiki %} +``` Xorg -configure -{% endhighlight %} +``` This should generate a file `xorg.conf.new` in the `/root` directory. @@ -40,29 +40,29 @@ In most cases you can ignore any warning or error messages displayed by the X se - Uncomment the ShadowFB option, so that you should now have something like this: - {% highlight trac-wiki %} + ``` Option "ShadowFB" # [] - {% endhighlight %} + ``` - Change the driver name to `nouveau` (you will probably have `nv` written there): - {% highlight trac-wiki %} + ``` Driver "nouveau" - {% endhighlight %} + ``` Save the modification, exit the editor. 1. Move the file to `/etc/X11` and rename it as `xorg.conf`: -{% highlight trac-wiki %} +``` mv /root/xorg.conf.new /etc/X11/xorg.conf -{% endhighlight %} +``` 1. Verify that X will work with those new settings: -{% highlight trac-wiki %} +``` xinit -{% endhighlight %} +``` If you see a terminal window in the top left corner, it means you most likely succeeded, even if your keyboard or mouse do not work now (don't worry about them). diff --git a/OutOfmemory.md b/OutOfmemory.md index b4bc7717..bee0c1b7 100644 --- a/OutOfmemory.md +++ b/OutOfmemory.md @@ -9,18 +9,18 @@ VMs specially templates use disk space. Also default private storage max size is So it is a good practice to regularly check disk space usage with command -{% highlight trac-wiki %} +``` df -{% endhighlight %} +``` in dom0 terminal. A system in out of space condition should be able to boot, but may be unable to load a desktop manager. In this case it is possible to login to dom0 terminal with Alt + Ctrl + F2. To recover disk space it may be possible to delete files in a userVM connecting to the userVM terminal: -{% highlight trac-wiki %} +``` qvm-start sudo xl console -{% endhighlight %} +``` If this does not work, check the size of /var/lib/qubes/qubes.xml. If it is zero, you'll need to use one of the file backup (stored in /var/lib/qubes/backup), hopefully you have the current data there. Find the most recent one and place in /var/lib/qubes/qubes.xml instead of the empty file. @@ -28,25 +28,25 @@ In any case you'll need some disk space to start the VM. Check "df" output if yo 1. Clean yum cache: -{% highlight trac-wiki %} +``` sudo yum clean all -{% endhighlight %} +``` 1. Delete .img files of a less important VM, that can be found in /var/lib/qubes/appvms/. Then, when the system is working again, cleanup the rest with: -{% highlight trac-wiki %} +``` qvm-remove -{% endhighlight %} +``` With this method you lose one VM data, but it'll more securely work. 1. Decrease filesystem safety margin (5% by default): -{% highlight trac-wiki %} +``` sudo tune2fs -m 4 /dev/mapper/vg_dom0-lv_root -{% endhighlight %} +``` 1. Remove some unneeded files in dom0 home (if you have one, most likely no). diff --git a/Postfix.md b/Postfix.md index 77c73c7d..000157f7 100644 --- a/Postfix.md +++ b/Postfix.md @@ -22,9 +22,9 @@ Configuration In TemplateVM open `/etc/aliases` and add line: -{% highlight trac-wiki %} +``` root: user -{% endhighlight %} +``` and run `newaliases`. @@ -36,7 +36,7 @@ Now shutdown TemplateVM, start AppVM. Create directory `/usr/local/etc/postfix` Postfix keeps its lookup tables in bdb hash databases. They need to be compiled from source files. Postfix admins like to keep track of them by means of `/usr/local/etc/postfix/Makefile`: -{% highlight trac-wiki %} +``` all: $(addsuffix .db,$(shell sed -n -e '/^[^#].*hash:\/etc\/postfix/s:.*/::p' main.cf)) newaliases clean: @@ -45,13 +45,13 @@ clean: %.db: % /usr/sbin/postmap hash:$< -{% endhighlight %} +``` ### Postfix main configuration `/usr/local/etc/postfix/main.cf` (`/etc/postfix` is intentional, don't correct it): -{% highlight trac-wiki %} +``` mydestination = $myhostname, $myhostname.$mydomain, $myhostname.localdomain, localhost, localhost.$mydomain, localhost.localdomain, $mydomain, localdomain mynetworks_style = host @@ -84,36 +84,36 @@ sendmail_path = /usr/sbin/sendmail newaliases_path = /usr/bin/newaliases mailq_path = /usr/bin/mailq alias_maps = hash:/etc/aliases -{% endhighlight %} +``` ### Lookup tables `/usr/local/etc/postfix/generic` (put there your primary address): -{% highlight trac-wiki %} +``` @localhost your.mail@example.com -{% endhighlight %} +``` `/usr/local/etc/postfix/sender_relay`. This is important file. Put there all your SMTP servers. Pay attention to port (smtp/submission). Square brackets have their special meaning, they are almost certainly needed. For more info consult Postfix manual. -{% highlight trac-wiki %} +``` your.mail@exmaple.com [mail.example.com]:submission your.other@mail.com [smtp.mail.com]:smtp -{% endhighlight %} +``` `/usr/local/etc/postfix/saslpass`. Here you put passwords to abovementioned servers. It depends on provider if you need to put whole email as username or just the part before `@`. -{% highlight trac-wiki %} +``` [mail.example.com]:submission your.mail:y0urP4ssw0rd [smtp.mail.com]:smtp your.other@mail.com:supers3cret -{% endhighlight %} +``` `/usr/local/etc/postfix/sender_access`. I use it to nullroute known spam domains. If you do not need it, comment respective line in `main.cf`. -{% highlight trac-wiki %} +``` spamdomain1.com DISCARD spamdomain2.com DISCARD -{% endhighlight %} +``` Now run `make` in `/usr/local/etc/postfix`. It will hopefully compile four abovementioned lookup tables (`generic.db`, `sender_relay.db`, `saslpass.db` and `sender_access`). @@ -121,7 +121,7 @@ Now run `make` in `/usr/local/etc/postfix`. It will hopefully compile four above Don't start postfix or fetchmail yet, first create `/home/user/.procmailrc`: -{% highlight trac-wiki %} +``` MAILDIR = "${HOME}/.maildir" ORGMAIL = "${MAILDIR}/" DEFAULT = "${MAILDIR}/" @@ -133,18 +133,18 @@ list/qubes-users/ :0 * ^List-Id:.*qubes-devel\.googlegroups\.com list/qubes-devel/ -{% endhighlight %} +``` Run --- Open `/rw/config/rc.local` and add those two lines (before fetchmail lines, if you have them): -{% highlight trac-wiki %} +``` #!/bin/sh mount --bind /usr/local/etc/postfix /etc/postfix systemctl --no-block start postfix -{% endhighlight %} +``` Reboot your AppVM and you are done. diff --git a/Profiling.md b/Profiling.md index df0df114..4cd9b144 100644 --- a/Profiling.md +++ b/Profiling.md @@ -15,17 +15,17 @@ For the purpose of this document, `qubes-dev` is name of the domain used for pos Requirements ------------ -{% highlight trac-wiki %} +``` yum install gprof2dot graphviz git clone http://git.woju.eu/qubes/profiling.git -{% endhighlight %} +``` If you profile something on dom0, move `Upload.sh` from repository to dom0: -{% highlight trac-wiki %} +``` mkdir -p ~/profiling qvm-run -p qubes-dev 'cat ~/profiling/Upload.sh' > ~/profiling/Upload.sh -{% endhighlight %} +``` - WARNING: this will obviously be running third party code which is not signed by ITL nor Fedora. You have been warned. @@ -62,28 +62,28 @@ Remember to revert your changes to application afterwards. If you are in dom0: -{% highlight trac-wiki %} +``` cd ~/profiling ./Upload.sh -{% endhighlight %} +``` ### Analyse -{% highlight trac-wiki %} +``` make -{% endhighlight %} +``` For every `${basename}.pstats` this will produce `${basename}.txt` and `${basename}.svg`. SVG contains call graph. Text file contains list of all functions sorted by cumulative execution time. You may also try `make all-png`. -{% highlight trac-wiki %} +``` make index.html -{% endhighlight %} +``` This creates `index.html` with all SVG graphics linked to TXT files. Ready for upload. -{% highlight trac-wiki %} +``` make REMOTE=example.com:public_html/qubes/profiling/ upload -{% endhighlight %} +``` Example ------- diff --git a/Qrexec.md b/Qrexec.md index 36da6c19..e7345214 100644 --- a/Qrexec.md +++ b/Qrexec.md @@ -19,9 +19,9 @@ Typically, the first thing that a `qrexec-client` instance does is to send a req E.g., to start a primitive shell in a VM type the following in Dom0 console: -{% highlight trac-wiki %} +``` [user@dom0 ~]$ /usr/lib/qubes/qrexec-client -d user:bash -{% endhighlight %} +``` The string before first semicolon specifies what user to run the command as. @@ -65,9 +65,9 @@ In dom0, there is a bunch of files in `/etc/qubes-rpc/policy/` directory, whose These files contain lines with the following format: -{% highlight trac-wiki %} +``` srcvm destvm (allow|deny|ask)[,user=user_to_run_as][,target=VM_to_redirect_to] -{% endhighlight %} +``` You can specify `srcvm` and `destvm` by name, or by one of `$anyvm`, `$dispvm`, `dom0` reserved keywords (note string `dom0` does not match the `$anyvm` pattern; all other names do). Only `$anyvm` keyword makes sense in the `srcvm` field (service calls from dom0 are currently always allowed, `$dispvm` means "new VM created for this particular request" - so it is never a source of request). Currently, there is no way to specify source VM by type, but this is planned for Qubes R3. @@ -80,9 +80,9 @@ Requesting VM-VM (and VM-Dom0) services execution In a src VM, one should invoke the qrexec client via the following command: -{% highlight trac-wiki %} +``` /usr/lib/qubes/qrexec-client-vm [local program arguments]` -{% endhighlight %} +``` Note that only stdin/stdout is passed between RPC server and client - notably, no cmdline argument are passed. @@ -103,9 +103,9 @@ Qubes RPC policy supports an "ask" action, that will prompt the user whether a g In order to remove such authorization, issue this command from a Dom0 terminal (example below for qubes.Filecopy service): -{% highlight trac-wiki %} +``` sudo nano /etc/qubes-rpc/policy/qubes.Filecopy -{% endhighlight %} +``` and then remove any line(s) ending in "allow" (before the first \#\# comment) which are the "Yes to All" results. @@ -117,37 +117,37 @@ We will show the necessary files to create a simple RPC call that adds two integ - Client code on source VM (`/usr/bin/our_test_add_client`) -{% highlight trac-wiki %} +``` #!/bin/sh echo $1 $2 # pass data to rpc server exec cat >&$SAVED_FD_1 # print result to the original stdout, not to the other rpc endpoint -{% endhighlight %} +``` - Server code on target VM (`/usr/bin/our_test_add_server`) -{% highlight trac-wiki %} +``` #!/bin/sh read arg1 arg2 # read from stdin, which is received from the rpc client echo $(($arg1+$arg2)) # print to stdout - so, pass to the rpc client -{% endhighlight %} +``` - Policy file in dom0 (`/etc/qubes-rpc/policy/test.Add`) -{% highlight trac-wiki %} +``` $anyvm $anyvm ask -{% endhighlight %} +``` - Server path definition on target VM (`/etc/qubes-rpc/test.Add`) -{% highlight trac-wiki %} +``` /usr/bin/our_test_add_server -{% endhighlight %} +``` - To test this service, run the following in the source VM: -{% highlight trac-wiki %} +``` /usr/lib/qubes/qrexec-client-vm test.Add /usr/bin/our_test_add_client 1 2 -{% endhighlight %} +``` and we should get "3" as answer, provided dom0 policy allows the call to pass through, which would happen after we click "Yes" in the popup that should appear after the invocation of this command. If we changed the policy from "ask" to "allow", then no popup should be presented, and the call will always be allowed. diff --git a/Qrexec3.md b/Qrexec3.md index 0600946e..0c8abc98 100644 --- a/Qrexec3.md +++ b/Qrexec3.md @@ -87,37 +87,37 @@ We will show the necessary files to create rpc call that adds two integers on th - rpc client code (*/usr/bin/our\_test\_add\_client*) - {% highlight trac-wiki %} + ``` #!/bin/sh echo $1 $2 # pass data to rpc server exec cat >&$SAVED_FD_1 # print result to the original stdout, not to the other rpc endpoint - {% endhighlight %} + ``` - rpc server code (*/usr/bin/our\_test\_add\_server*) - {% highlight trac-wiki %} + ``` #!/bin/sh read arg1 arg2 # read from stdin, which is received from the rpc client echo $(($arg1+$arg2)) # print to stdout - so, pass to the rpc client - {% endhighlight %} + ``` - policy file in dom0 (*/etc/qubes-rpc/policy/test.Add* ) - {% highlight trac-wiki %} + ``` $anyvm $anyvm ask - {% endhighlight %} + ``` - server path definition ( */etc/qubes-rpc/test.Add*) - {% highlight trac-wiki %} + ``` /usr/bin/our_test_add_server - {% endhighlight %} + ``` - invoke rpc via - {% highlight trac-wiki %} + ``` /usr/lib/qubes/qrexec-client-vm target_vm test.Add /usr/bin/our_test_add_client 1 2 - {% endhighlight %} + ``` and we should get "3" as answer, after dom0 allows it. diff --git a/Qrexec3Implementation.md b/Qrexec3Implementation.md index 218cedb0..2bb2fc7c 100644 --- a/Qrexec3Implementation.md +++ b/Qrexec3Implementation.md @@ -66,21 +66,21 @@ Qrexec protocol details Qrexec protocol is message-based. All messages share a common header followed by an optional data packet. -{% highlight trac-wiki %} +``` /* uniform for all peers, data type depends on message type */ struct msg_header { uint32_t type; /* message type */ uint32_t len; /* data length */ }; -{% endhighlight %} +``` When two peers establish connection, the server sends `MSG_HELLO` followed by `peer_info` struct: -{% highlight trac-wiki %} +``` struct peer_info { uint32_t version; /* qrexec protocol version */ }; -{% endhighlight %} +``` The client then should reply with its own `MSG_HELLO` and `peer_info`. If protocol versions don't match, the connection is closed. TODO: fallback for backwards compatibility, don't do handshake in the same domain?. @@ -101,14 +101,14 @@ Details of all possible use cases and the messages involved are described below. - **dom0**: `qrexec-client` replies with `MSG_HELLO` header followed by `peer_info` to `qrexec-daemon`. - **dom0**: `qrexec-client` sends `MSG_EXEC_CMDLINE` header followed by `exec_params` to `qrexec-daemon` - {% highlight trac-wiki %} + ``` /* variable size */ struct exec_params { uint32_t connect_domain; /* target domain id */ uint32_t connect_port; /* target vchan port for i/o exchange */ char cmdline[0]; /* command line to execute, size = msg_header.len - sizeof(struct exec_params) */ }; - {% endhighlight %} + ``` In this case, `connect_domain` and `connect_port` are set to 0. @@ -133,7 +133,7 @@ Details of all possible use cases and the messages involved are described below. - **domY**: `qrexec-client-vm` connects to `qrexec-agent` (via local socket/named pipe). - **domY**: `qrexec-client-vm` sends `trigger_service_params` data to `qrexec-agent` (without filling the `request_id` field): - {% highlight trac-wiki %} + ``` struct trigger_service_params { char service_name[64]; char target_domain[32]; @@ -143,7 +143,7 @@ Details of all possible use cases and the messages involved are described below. struct service_params { char ident[32]; }; - {% endhighlight %} + ``` - **domY**: `qrexec-agent` allocates a locally-unique (for this domain) `request_id` (let's say `13`) and fills it in the `trigger_service_params` struct received from `qrexec-client-vm`. - **domY**: `qrexec-agent` sends `MSG_TRIGGER_SERVICE` header followed by `trigger_service_params` to `qrexec-daemon` in **dom0** via vchan. @@ -159,14 +159,14 @@ Details of all possible use cases and the messages involved are described below. - **dom0**: `qrexec-client` replies with `MSG_HELLO` header followed by `peer_info` to **domX**'s`qrexec-daemon`. - **dom0**: `qrexec-client` sends `MSG_EXEC_CMDLINE` header followed by `exec_params` to **domX**'s`qrexec-daemon` - {% highlight trac-wiki %} + ``` /* variable size */ struct exec_params { uint32_t connect_domain; /* target domain id */ uint32_t connect_port; /* target vchan port for i/o exchange */ char cmdline[0]; /* command line to execute, size = msg_header.len - sizeof(struct exec_params) */ }; - {% endhighlight %} + ``` In this case, `connect_domain` is set to id of **domY** (from the `-c` parameter) and `connect_port` is set to 0. `cmdline` field contains the RPC to execute, in this case `user:QUBESRPC qubes.SomeRpc domY`. diff --git a/QubesBuilder.md b/QubesBuilder.md index 2a74dd9f..3dc36153 100644 --- a/QubesBuilder.md +++ b/QubesBuilder.md @@ -26,15 +26,15 @@ In order to use it one should use an rpm-based distro, like Fedora :) and should Unusually one can install those packages by just issuing: -{% highlight trac-wiki %} +``` sudo yum install git createrepo rpm-build make wget rpmdevtools python-sh dialog rpm-sign -{% endhighlight %} +``` The build system creates build environments in chroots and so no other packages are needed on the host. All files created by the build system are contained within the qubes-builder directory. The full build requires some 25GB of free space, so keep that in mind when deciding where to place this directory. The build system is configured via builder.conf file -- one should copy the attached builder.conf.default, and modify it as needed, e.g.: -{% highlight trac-wiki %} +``` cp builder.conf.default builder.conf # edit the builder.conf file and set the following variables: # (make sure to leave no spaces around '=' sign!) @@ -44,23 +44,23 @@ NO_SIGN=1 # and VMs is fc20 so if you want to build Qubes 2 DIST_DOM0=fc20 DISTS_VM=fc20 -{% endhighlight %} +``` One additional useful requirement is that 'sudo root' work without any prompt, which is default on most distros (e.g. 'sudo bash' brings you the root shell without asking for any password). This is important as the builder needs to switch to root and then back to user several times during the build process. Additionally, if building with signing enabled (so NO\_SIGN is not set), one must adjust \~/.rpmmacro file so that it point to the GPG key used for package signing, e.g.: -{% highlight trac-wiki %} +``` %_signature gpg %_gpg_path /home/user/.gnupg %_gpg_name AC1BF9B3 # <-- Key ID used for signing -{% endhighlight %} +``` It is also recommended to use an empty passphrase for the private key used for signing. Contrary to a popular belief, this doesn't affect your key or sources security -- if somebody compromised your system, then the game is over, whether you use additional passphrase for the key or not. So, to build Qubes one would do: -{% highlight trac-wiki %} +``` # Import the Qubes master key gpg --recv-keys 0x36879494 @@ -90,7 +90,7 @@ make qubes # ... and then to build the ISO make iso -{% endhighlight %} +``` And this should produce a shiny new ISO. @@ -128,9 +128,9 @@ If you want to somehow modify sources, you can also do it, here are some basic s > `get-sources` is already done, so continue with the next one. You can skip `sign-all` if you've disabled signing > -> {% highlight trac-wiki %} +> ``` > make xen core kernel gui addons docs template kde-dom0 installer qubes-manager dom0-updates -> {% endhighlight %} +> ``` 1. build iso installation image @@ -141,11 +141,11 @@ Code verification keys management [QubesBuilder](/doc/QubesBuilder/) by default verifies signed tags on every downloaded code. Public keys used for that are stored in `keyrings/git`. By default Qubes developers' keys are imported automatically, but if you need some additional keys (for example your own), you can add them using: -{% highlight trac-wiki %} +``` GNUPGHOME=$PWD/keyrings/git gpg --import /path/to/key.asc GNUPGHOME=$PWD/keyrings/git gpg --edit-key ID_OF_JUST_IMPORTED_KEY # here use "trust" command to set key fully or ultimately trusted - only those keys are accepted by QubesBuilder -{% endhighlight %} +``` All Qubes developers' keys are signed by the Qubes Master Signing Key (which is set as ultimately trusted key), so are trusted automatically. diff --git a/QubesFirewall.md b/QubesFirewall.md index d9431769..63f9ca09 100644 --- a/QubesFirewall.md +++ b/QubesFirewall.md @@ -34,15 +34,15 @@ Reconnecting AppVMs after a NetVM reboot Normally Qubes doesn't let the user to stop a NetVM if there are other AppVMs running which use it as their own NetVM. But in case the NetVM stops for whatever reason (e.g. it crashes, or the user forces its shutdown via qvm-kill via terminal in the netvm), then there is an easy way to restore the connection to the netvm by issuing: -{% highlight trac-wiki %} +``` qvm-prefs -s netvm -{% endhighlight %} +``` Normally AppVMs do not connect directly to the actual NetVM which has networking devices, but rather to the default FirewallVM first, and in most cases it would be the NetVM that would crash, e.g. in response to S3 sleep/restore or other issues with WiFi drivers. In that case it is necessary to just issue the above command once, for the FirewallVM (this assumes default VM-nameing used by the default Qubes installation): -{% highlight trac-wiki %} +``` qvm-prefs firewallvm -s netvm netvm -{% endhighlight %} +``` Enabling networking between two AppVMs -------------------------------------- @@ -56,18 +56,18 @@ In order to allow networking between AppVM A and B follow those steps: - Start both AppVMs, and also open a terminal in the firewall VM - In the firewall VM's terminal enter the following iptables rule: - {% highlight trac-wiki %} + ``` sudo iptables -I FORWARD 2 -s -d -j ACCEPT - {% endhighlight %} + ``` - Now you should be able to reach the AppVM B from A -- test it using e.g. ping issues from AppVM A. Note however, that this doesn't allow you to reach A from B -- for this you would need another rule, with A and B addresses swapped. - If everything works as expected, then the above iptables rule(s) should be written into firewall VM's `qubes_firewall_user_script` script which is run on every firewall update. This is necessary, because Qubes orders every firewall VM to update all the rules whenever new VM is started in the system. If we didn't enter our rules into this "hook" script, then shortly our custom rules would disappear and inter-VM networking would stop working. Here's an example how to update the script (note that, by default, there is no script file present, so we likely will be creating it, unless we had some other custom rules defines earlier in this firewallvm): - {% highlight trac-wiki %} + ``` [user@firewallvm ~]$ sudo bash [root@firewallvm user]# echo "iptables -I FORWARD 2 -s 10.137.2.25 -d 10.137.2.6 -j ACCEPT" >> /rw/config/qubes_firewall_user_script [root@firewallvm user]# chmod +x /rw/config/qubes_firewall_user_script - {% endhighlight %} + ``` Port forwarding to an AppVM from the outside world -------------------------------------------------- @@ -90,15 +90,15 @@ In NetVM terminal, take note of the interface name and IPAddress on which you wa Still in NetVM terminal, code the appropriate natting firewall rule to intercept traffic on the inbound interface for the service and nat the destination IP address to the one of the firewallVM for the traffic to be routed there: -{% highlight trac-wiki %} +``` iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -d 192.168.0.10 -j DNAT --to-destination 10.137.1.x -{% endhighlight %} +``` Code the appropriate new filtering firewall rule to allow new connections for the service: -{% highlight trac-wiki %} +``` iptables -I FORWARD 2 -i eth0 -d 10.137.1.x -p tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT -{% endhighlight %} +``` Note: If you want to expose the service on multiple interfaces, repeat the steps described in part 1 for each interface. @@ -114,23 +114,23 @@ In order to ensure your set-up survive a reboot we need in the NetVM to: Store these commands in ` /rw/config/rc.local `: -{% highlight trac-wiki %} +``` sudo nano /rw/config/rc.local -{% endhighlight %} +``` -{% highlight trac-wiki %} +``` #!/bin/sh /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -d 192.168.0.10 -j DNAT --to-destination 10.137.1.x /sbin/iptables -I FORWARD 2 -s 192.168.0.0/24 -d 10.137.1.x -p tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT -{% endhighlight %} +``` Make this file executable: -{% highlight trac-wiki %} +``` sudo chmod +x /rw/config/rc.local -{% endhighlight %} +``` **2. Allow packets to be routed from the firewallVM to the appVM** @@ -140,15 +140,15 @@ In FirewallVM Terminal, take note of the IPAddress for interface eth0 using the Still in FirewallVM terminal, code the appropriate natting firewall rule to intercept traffic on the inbound interface for the service and nat the destination IP address to the one of the AppVM for the traffic to be routed there: -{% highlight trac-wiki %} +``` iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -d 10.137.1.x -j DNAT --to-destination 10.137.2.y -{% endhighlight %} +``` Code the appropriate new filtering firewall rule to allow new connections for the service: -{% highlight trac-wiki %} +``` iptables -I FORWARD 2 -i eth0 -s 192.168.0.0/24 -d 10.137.2.y -p tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT -{% endhighlight %} +``` > Note: If you do not wish to limit the IP addresses connecting to the service, remove the ` -s 192.168.0.1/24 ` @@ -158,28 +158,28 @@ This time in order to ensure your set-up survive a reboot we need in the firewal Store these commands in ` /rw/config/qubes_firewall_user_script `: -{% highlight trac-wiki %} +``` #!/bin/sh /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -d 10.137.1.x -j DNAT --to-destination 10.137.2.y /sbin/iptables -I FORWARD 4 -i eth0 -s 192.168.0.0/24 -d 10.137.2.y -p tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT -{% endhighlight %} +``` And again make this file executable: -{% highlight trac-wiki %} +``` sudo chmod +x /rw/config/qubes_firewall_user_script -{% endhighlight %} +``` **3. Allow packets into the AppVM to reach the service** Here no routing is required, only filtering. Proceed in the same way as above but store the filtering rule in the `/rw/config/rc.local` script. -{% highlight trac-wiki %} +``` #!/bin/sh /sbin/iptables -I INPUT 5 -p tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT -{% endhighlight %} +``` This time testing should allow connectivity to the service. diff --git a/QubesR3Building.md b/QubesR3Building.md index 2e6d63ce..7d371c77 100644 --- a/QubesR3Building.md +++ b/QubesR3Building.md @@ -10,47 +10,47 @@ Building Qubes OS 3.0 ISO Ensure your system is rpm-based and that you have necessary dependencies installed (see [QubesBuilder](/doc/QubesBuilder/) for more info): -{% highlight trac-wiki %} +``` sudo yum install git createrepo rpm-build make wget rpmdevtools pandoc -{% endhighlight %} +``` Get the necessary keys to verify the sources: -{% highlight trac-wiki %} +``` $ wget https://keys.qubes-os.org/keys/qubes-master-signing-key.asc $ gpg --import qubes-master-signing-key.asc $ gpg --edit-key 36879494 # Verify fingerprint!, set trust to *ultimate* $ wget https://keys.qubes-os.org/keys/qubes-developers-keys.asc $ gpg --import qubes-developers-keys.asc -{% endhighlight %} +``` Note we do *not* relay above on the security of our server (keys.qubes-os.org) nor the connection (ssl, cert) -- we only rely on you getting the Qubes Master Signing Key fingerprint *somehow* and ensure they match! Now lets bootstrap the builder. Unfortunately the builder cannot verify itself (the classic Chicken and Egg problem), so we need to verify the signature manually: -{% highlight trac-wiki %} +``` $ git clone git://github.com/QubesOS/qubes-builder.git $ cd qubes-builder $ git describe --exact-match HEAD $ git tag -v -{% endhighlight %} +``` Assuming the verification went fine, we're good to go with all the rest without ever thinking more about verifying digital signatures on all the rest of the components, as the builder will do that for us, for each component, every time we, even for all aux files (e.g. Xen or Linux kernel sources). Let's configure the builder first (we can use one of the example configs, either for R2 or "master", which currently means pre-released R3): -{% highlight trac-wiki %} +``` cp example-configs/qubes-os-master.conf builder.conf -{% endhighlight %} +``` You can take a loot at the `builder.conf.default` for a description of all available options. Nevertheless, the default config should be enough for start: -{% highlight trac-wiki %} +``` $ make get-sources qubes $ make sign-all # this requires setting SIGN_KEY in the builder.conf, can be skipped for test builds. $ make iso -{% endhighlight %} +``` Enjoy your new ISO! diff --git a/QubesService.md b/QubesService.md index 6e9044e7..4e826ae5 100644 --- a/QubesService.md +++ b/QubesService.md @@ -12,11 +12,11 @@ Under the hood enabled service in VM is signaled by file in /var/run/qubes-servi 1. Disable old service: `systemctl disable ` 2. Create `/etc/systemd/system/.service` file containing: - {% highlight trac-wiki %} + ``` .include /lib/systemd/system/.service [Unit] ConditionPathExists=/var/run/qubes-service/ - {% endhighlight %} + ``` 3. Enable new service: `systemctl enable `. diff --git a/ResizeDiskImage.md b/ResizeDiskImage.md index 508ef188..82848563 100644 --- a/ResizeDiskImage.md +++ b/ResizeDiskImage.md @@ -17,17 +17,17 @@ There are several disk images which can be easily extended. To grow the private disk image of a AppVM beyond this limit [qubes-grow-private](/doc/Dom0Tools/QvmGrowPrivate/) can be used: -{% highlight trac-wiki %} +``` qvm-grow-private -{% endhighlight %} +``` Note: Size is the target size (i.e. 4096MB or 16GB, ...), not the size to add to the existing disk. Note2: If once the VM is started, the disk is has not been increased, you can issue in the VM's terminal: -{% highlight trac-wiki %} +``` sudo resize2fs /dev/xvdb -{% endhighlight %} +``` ### Shrinking private disk image (Linux VM) @@ -40,14 +40,14 @@ The basic idea is to: Ext4 does not support online shrinking, so can't be done as convenient as image grown. Note that we don't want to touch the VM filesystem directly in dom0 for security reasons. First you need to start VM without `/rw` mounted. One of the possibility is to interrupt its normal startup by adding `rd.break` kernel option: -{% highlight trac-wiki %} +``` qvm-prefs -s kernelopts rd.break qvm-start --no-guid -{% endhighlight %} +``` And wait for qrexec connect timeout (or simply press Ctrl-C). Then you can connect to VM console and shrink the filesystem: -{% highlight trac-wiki %} +``` sudo xl console # you should get dracut emergency shell here mount --bind /dev /sysroot/dev @@ -59,19 +59,19 @@ umount /proc exit umount /sysroot/dev poweroff -{% endhighlight %} +``` Now you can resize the image: -{% highlight trac-wiki %} +``` truncate -s /var/lib/qubes/appvms//private.img -{% endhighlight %} +``` **It is critical to use the same (or bigger for some safety margin) size in truncate call compared to resize2fs call. Otherwise you will loose your data!** Then reset kernel options back to default: -{% highlight trac-wiki %} +``` qvm-prefs -s kernelopts default -{% endhighlight %} +``` Done. @@ -97,12 +97,12 @@ First, stop/shutdown the HVM. Then, from a Dom0 terminal (in KDE: System Tools -\> Terminal Emulator) do the following: -{% highlight trac-wiki %} +``` cd /var/lib/qubes/appvms// ls -lh root.img (<--verify current size of disk image) truncate -s 30GB root.img ls -lh root.img (<--verify new size of disk image) -{% endhighlight %} +``` The partition table and file-system must be adjusted after this change: @@ -117,9 +117,9 @@ No reboot required. #### FreeBSD -{% highlight trac-wiki %} +``` gpart recover ada0 sysctl kern.geom.debugflags=0x10 gpart resize -i index ada0 zpool online -e poolname ada0 -{% endhighlight %} +``` diff --git a/Rxvt.md b/Rxvt.md index 237c2dd1..5b6a24f8 100644 --- a/Rxvt.md +++ b/Rxvt.md @@ -20,7 +20,7 @@ Xresources In TemplateVM create file `/etc/X11/Xresources.urxvt` and paste config below. `!`-lines are comments and may be left out. `#`-lines are directives to CPP (C preprocessor) and are neccessary. This shouldn't go to `/etc/X11/Xresources`, because that file is not preprocessed by default. -{% highlight trac-wiki %} +``` ! CGA colour palette !*color0: #000000 @@ -123,15 +123,15 @@ URxvt.insecure: False ! some termcap-aware software sometimes throw '$TERM too long' !URxvt.termName: rxvt-256color -{% endhighlight %} +``` Then create script to automatically merge those to xrdb. File `/etc/X11/xinit/xinitrc.d/urxvt.sh`: -{% highlight trac-wiki %} +``` #!/bin/sh [ -r /etc/X11/Xresources.urxvt ] && xrdb -merge /etc/X11/Xresources.urxvt -{% endhighlight %} +``` Shortcuts --------- diff --git a/SecurityGuidelines.md b/SecurityGuidelines.md index fe66c27d..aaabf8b9 100644 --- a/SecurityGuidelines.md +++ b/SecurityGuidelines.md @@ -29,17 +29,17 @@ Download Verification Standard program installation -{% highlight trac-wiki %} +``` sudo yum install -{% endhighlight %} +``` on template terminal already accomplishes verification, for fedora and qubes repositories. If you install new repositories, they might have gpgcheck disabled. [Check the config files](http://docs.fedoraproject.org/en-US/Fedora/12/html/Deployment_Guide/sec-Configuring_Yum_and_Yum_Repositories.html) and be sure to check that -{% highlight trac-wiki %} +``` gpgcheck=1 -{% endhighlight %} +``` Plus, also make sure you **safely import their signing keys**. This may require you check from multiple sources that the signing key is always the same. @@ -66,9 +66,9 @@ Enabling and Verifying VT-d/IOMMU In **Dom0** terminal, run: -{% highlight trac-wiki %} +``` qubes-hcl-report -{% endhighlight %} +``` where \ is the name of the VM within which the report will be written (but the report will also be displayed in the Dom0 terminal). If it displays that VT-d is active, you should be able to assign **PCIe devices to a HVM** and **enjoy DMA protection** for your driver domains, so you successfully passed this step. @@ -79,15 +79,15 @@ Updating Software To keep your system regularly updated against security related bugs and get new features, run in Dom0: -{% highlight trac-wiki %} +``` sudo qubes-dom0-update -{% endhighlight %} +``` and run in templates and standalone VM -{% highlight trac-wiki %} +``` sudo yum update -{% endhighlight %} +``` or use the equivalent items in Qubes Manager, which displays an icon when an update is available. @@ -145,9 +145,9 @@ An **USBVM** operates like a dedicated temporary parking area, used just to prev 5. Click OK. Restart the AppVM. (Restarting may not even be required.) 6. Set the VM to start automatically at Boot using the VM Manager, (under VM Settings), or **In dom0 terminal**, run - {% highlight trac-wiki %} + ``` qvm-prefs -s usbvm autostart true - {% endhighlight %} + ``` This will cause your new **USBVM** to automatically start when the system starts up. So that in case you forgot to start it and then accidentally plugged a USB stick (or your colleague at work did it while you were at lunch), **it won't compromise the Dom0**. diff --git a/SecurityPage.md b/SecurityPage.md index 8f3f4c96..362cbe42 100644 --- a/SecurityPage.md +++ b/SecurityPage.md @@ -21,9 +21,9 @@ Qubes Security Team The Qubes Security Team can be contacted via email using the following address: -{% highlight trac-wiki %} +``` security at qubes-os dot org -{% endhighlight %} +``` Qubes Security Team GPG Key --------------------------- diff --git a/SoftwareUpdateDom0.md b/SoftwareUpdateDom0.md index f6a2c60b..342a3fba 100644 --- a/SoftwareUpdateDom0.md +++ b/SoftwareUpdateDom0.md @@ -35,15 +35,15 @@ Of course, command line tools are still available for accomplishing various upda 1. To check and install updates for dom0 software: - {% highlight trac-wiki %} + ``` $ sudo qubes-dom0-update - {% endhighlight %} + ``` 1. To install additional packages in dom0 (usually not recommended): - {% highlight trac-wiki %} + ``` $ sudo qubes-dom0-update anti-evil-maid - {% endhighlight %} + ``` You may also pass the `--enablerepo=` option in order to enable optional repositories (see yum configuration in dom0). However, this is only for advanced users who really understand what they are doing. @@ -51,30 +51,30 @@ Of course, command line tools are still available for accomplishing various upda 1. Download an older version of the package: - {% highlight trac-wiki %} + ``` sudo qubes-dom0-update package-version - {% endhighlight %} + ``` Yum will say that there is no update, but the package will nonetheless be downloaded to dom0. 1. Downgrade the packge: - {% highlight trac-wiki %} + ``` sudo yum downgrade package-version - {% endhighlight %} + ``` ### Kernel Upgrade ### Install newer kernel. The following example installs kernel 3.19 and was tested on Qubes R3 RC1. - {% highlight trac-wiki %} + ``` sudo qubes-dom0-update kernel-3.19* - {% endhighlight %} + ``` Rebuild grub config. - {% highlight trac-wiki %} + ``` sudo grub2-mkconfig -o /boot/grub2/grub.cfg - {% endhighlight %} + ``` Reboot required. diff --git a/SoftwareUpdateVM.md b/SoftwareUpdateVM.md index 97b51251..3d0c1b91 100644 --- a/SoftwareUpdateVM.md +++ b/SoftwareUpdateVM.md @@ -72,9 +72,9 @@ Sometime it might be convenient to have a VM that has its own filesystem, where In order to create a standalone VM you can use a command line like this (from console in Dom0): -{% highlight trac-wiki %} +``` qvm-create --standalone --label