Skip to content

Commit

Permalink
Allow periods in qube names
Browse files Browse the repository at this point in the history
This allows periods in qube names by using the function from
libqubes-pure to validate them instead of the built-in version.

Part of QubesOS/qubes-issues#8199.
  • Loading branch information
DemiMarie committed Jun 3, 2023
1 parent adadf48 commit a8f4f49
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Build-Depends:
libpng-dev,
libnotify-dev,
qubesdb-dev,
help2man
help2man,
qubes-utils-dev (>= 4.2.10)
Standards-Version: 4.1.3
Homepage: https://qubes-os.org/
Vcs-Browser: https://github.com/QubesOS/qubes-gui-daemon
Expand Down
37 changes: 10 additions & 27 deletions gui-daemon/xside.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "trayicon.h"
#include "shm-args.h"
#include "util.h"
#include <qubes/pure.h>

/* Supported protocol version */

Expand Down Expand Up @@ -3897,28 +3898,6 @@ static void parse_trayicon_mode(Ghandles *g, const char *mode_str) {
}
}

static _Bool parse_vm_name(const char *arg, Ghandles *g) {
if (('a' > *arg || *arg > 'z') &&
('A' > *arg || *arg > 'Z'))
return false;
for (size_t i = 1; i < sizeof(g->vmname); ++i) {
switch (arg[i]) {
case 'A'...'Z':
case 'a'...'z':
case '0'...'9':
case '-':
case '_':
continue;
case '\0':
memcpy(g->vmname, arg, i + 1);
return true;
default:
return false;
}
}
return false;
}

/* FIXME: should be in a utility library */
static uint16_t parse_domid(const char *num)
{
Expand Down Expand Up @@ -3973,11 +3952,15 @@ static void parse_cmdline(Ghandles * g, int argc, char **argv)
errx(1, "Cannot specify target domid more than once (previous value %u)", g->target_domid);
g->target_domid = parse_domid(optarg);
break;
case 'N':
if (parse_vm_name(optarg, g))
break;
fprintf(stderr, "domain name not valid");
exit(1);
case 'N': {
struct QubesSlice s = qubes_pure_buffer_init_from_nul_terminated_string(optarg);
if (!qubes_pure_is_valid_qube_name(s))
errx(1, "domain name '%s' not valid", optarg);
if (s.length >= sizeof(g->vmname))
errx(1, "domain name '%s' is too long (this is a bug)", optarg);
memcpy(g->vmname, s.pointer, s.length + 1);
break;
}
case 'c':
g->cmdline_color = optarg;
break;
Expand Down
1 change: 1 addition & 0 deletions rpm_spec/gui-daemon.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ BuildRequires: qubes-core-libs-devel >= 1.6.1
BuildRequires: qubes-core-libs
BuildRequires: qubes-gui-common-devel >= 3.2.0
BuildRequires: qubes-libvchan-@BACKEND_VMM@-devel
BuildRequires: qubes-utils-devel >= 4.2.10

Source0: %{name}-%{version}.tar.gz

Expand Down

0 comments on commit a8f4f49

Please sign in to comment.