Move opening file viewer/editor into separate shell script

No functional change.

This will make it easier to switch the tool (without recompiling
vm-file-editor), or even use differrent tools depending on some
conditions.

QubesOS/qubes-issues#1621
This commit is contained in:
Marek Marczykowski-Górecki 2016-02-01 12:15:09 +01:00
parent 858ee225e5
commit 0211ea5d1d
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
4 changed files with 12 additions and 11 deletions

View File

@ -210,6 +210,7 @@ install-common:
install qubes-rpc/qvm-move-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/xdg-icon $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)$(LIBDIR)/qubes
install qubes-rpc/qubes-open $(DESTDIR)/usr/bin
install qubes-rpc/tar2qfile $(DESTDIR)$(LIBDIR)/qubes
# Install qfile-unpacker as SUID - because it will fail to receive files from other vm
install -m 4755 qubes-rpc/qfile-unpacker $(DESTDIR)$(LIBDIR)/qubes

9
qubes-rpc/qubes-open Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
if [ -r /etc/profile.d/qubes-session.sh ]; then
. /etc/profile.d/qubes-session.sh
fi
MIMEINFO_DATABASES="/usr/share/mime:/usr/local/share/mime:$HOME/.local/share/mime:/usr/share/qubes/mime-override"
exec mimeopen -n --database "$MIMEINFO_DATABASES" "$@"

View File

@ -11,7 +11,6 @@
#include "dvm2.h"
#define USER_HOME "/home/user"
#define MIMEINFO_DATABASES "/usr/share/mime:/usr/local/share/mime:" USER_HOME "/.local/share/mime:/usr/share/qubes/mime-override"
#define TMP_LOC "/tmp/qopen/"
static const char *cleanup_filename = NULL;
@ -148,8 +147,6 @@ main()
struct stat stat_pre, stat_post, session_stat;
char *filename = get_filename();
int child, status, log_fd, null_fd;
char var[1024], val[4096];
FILE *env_file;
FILE *waiter_pidfile;
copy_file_by_name(filename);
@ -196,12 +193,6 @@ main()
dup2(null_fd, 0);
close(null_fd);
env_file = fopen("/tmp/qubes-session-env", "r");
while(fscanf(env_file, "%1024[^=]=%4096[^\n]\n", var, val) == 2) {
setenv(var, val, 1);
}
fclose(env_file);
log_fd = open("/tmp/mimeopen.log", O_CREAT | O_APPEND, 0666);
if (log_fd == -1) {
perror("open /tmp/mimeopen.log");
@ -212,8 +203,7 @@ main()
setenv("HOME", USER_HOME, 1);
setenv("DISPLAY", ":0", 1);
execl("/usr/bin/mimeopen", "mimeopen", "-n",
"--database", MIMEINFO_DATABASES, filename, (char*)NULL);
execl("/usr/bin/qubes-open", "qubes-open", filename, (char*)NULL);
perror("execl");
exit(1);
default:

View File

@ -379,6 +379,7 @@ rm -f %{name}-%{version}
/usr/bin/qvm-mru-entry
/usr/bin/xenstore-watch-qubes
/usr/bin/qubes-desktop-run
/usr/bin/qubes-open
/usr/bin/qrexec-fork-server
/usr/bin/qrexec-client-vm
/usr/bin/qubes-session-autostart