From f47f8e7c8f324ab96173d414627fbabe9fe47d3b Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 13 Nov 2012 04:02:49 +0100 Subject: [PATCH] dom0/dispvm: enable use of default_user setting for DispVM (#577) --- dom0/restore/qfile-daemon-dvm | 1 + dom0/restore/qubes_restore.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dom0/restore/qfile-daemon-dvm b/dom0/restore/qfile-daemon-dvm index 59b492f9..8b2a195b 100755 --- a/dom0/restore/qfile-daemon-dvm +++ b/dom0/restore/qfile-daemon-dvm @@ -68,6 +68,7 @@ class QfileDaemonDvm: retcode = subprocess.call(['/usr/lib/qubes/qubes_restore', current_savefile, current_dvm_conf, + '-u', str(vm.default_user), '-c', label.color, '-i', label.icon, '-l', str(label.index)]) diff --git a/dom0/restore/qubes_restore.c b/dom0/restore/qubes_restore.c index 25a09ba2..f3492851 100644 --- a/dom0/restore/qubes_restore.c +++ b/dom0/restore/qubes_restore.c @@ -139,7 +139,7 @@ void preload_cache(int fd) } } -void start_rexec(int domid) +void start_rexec(int domid, char *default_user) { int pid, status; char dstr[40]; @@ -150,7 +150,7 @@ void start_rexec(int domid) exit(1); case 0: execl("/usr/lib/qubes/qrexec_daemon", "qrexec_daemon", - dstr, NULL); + dstr, default_user, NULL); perror("execl"); exit(1); default:; @@ -171,9 +171,9 @@ void start_guid(int domid, int argc, char **argv) guid_args[0] = "qubes_guid"; guid_args[1] = "-d"; guid_args[2] = dstr; - for (i = 3; i < argc; i++) - guid_args[i] = argv[i]; - guid_args[argc] = NULL; + for (i = 0; i < argc; i++) + guid_args[i+3] = argv[i]; + guid_args[argc+3] = NULL; execv("/usr/bin/qubes_guid", guid_args); perror("execv"); } @@ -434,9 +434,11 @@ int main(int argc, char **argv) FILE *conf; char *name; char confname[256]; + char *default_user = NULL; + int guid_args_start = 3; if (argc < 3) { fprintf(stderr, - "usage: %s savefile conf_templ [guid args] \n", argv[0]); + "usage: %s savefile conf_templ [-u default_user] [guid args] \n", argv[0]); exit(1); } redirect_stderr(); @@ -448,6 +450,10 @@ int main(int argc, char **argv) perror("fopen vm conf"); exit(1); } + if (argc > 4 && strcmp(argv[3], "-u")==0) { + default_user = argv[4]; + guid_args_start += 2; + } dispid = get_next_disposable_id(); name = get_vmname_from_savefile(conf_templ); netvm_id = get_netvm_id_from_name(name); @@ -472,7 +478,7 @@ int main(int argc, char **argv) setup_xenstore(netvm_id, domid, dispid, name); fprintf(stderr, "time=%s, starting qubes_guid\n", gettime()); rm_fast_flag(); - start_rexec(domid); - start_guid(domid, argc, argv); + start_rexec(domid, default_user); + start_guid(domid, argc-guid_args_start, argv+guid_args_start); return 0; }