Use gui_fatal in qfile-agent-dvm.c
This commit is contained in:
parent
237ce31f27
commit
29ffbfd474
@ -3,8 +3,8 @@ CFLAGS=-Wall -I../common
|
|||||||
all: qubes_penctl qubes_add_pendrive_script qvm-open-in-dvm dvm_file_editor qfile-agent-dvm
|
all: qubes_penctl qubes_add_pendrive_script qvm-open-in-dvm dvm_file_editor qfile-agent-dvm
|
||||||
dvm_file_editor: dvm_file_editor.o ../common/ioall.o
|
dvm_file_editor: dvm_file_editor.o ../common/ioall.o
|
||||||
$(CC) -o dvm_file_editor dvm_file_editor.o ../common/ioall.o
|
$(CC) -o dvm_file_editor dvm_file_editor.o ../common/ioall.o
|
||||||
qfile-agent-dvm: qfile-agent-dvm.o ../common/ioall.o
|
qfile-agent-dvm: qfile-agent-dvm.o ../common/ioall.o ../common/gui-fatal.o
|
||||||
$(CC) -o qfile-agent-dvm qfile-agent-dvm.o ../common/ioall.o
|
$(CC) -o qfile-agent-dvm qfile-agent-dvm.o ../common/ioall.o ../common/gui-fatal.o
|
||||||
qubes_penctl: qubes_penctl.o
|
qubes_penctl: qubes_penctl.o
|
||||||
$(CC) -o qubes_penctl qubes_penctl.o -lxenstore
|
$(CC) -o qubes_penctl qubes_penctl.o -lxenstore
|
||||||
qubes_add_pendrive_script: qubes_add_pendrive_script.o
|
qubes_add_pendrive_script: qubes_add_pendrive_script.o
|
||||||
|
@ -9,32 +9,15 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ioall.h>
|
#include <ioall.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <gui-fatal.h>
|
||||||
#include "dvm2.h"
|
#include "dvm2.h"
|
||||||
|
|
||||||
//the below usage of "system" is smelly, but should be fine - input comes from the same vm
|
|
||||||
void fatal(char *msg)
|
|
||||||
{
|
|
||||||
char *errcmd;
|
|
||||||
asprintf(&errcmd, "DISPLAY=:0 kdialog --sorry 'qfile-agent-dvm: %s'", msg);
|
|
||||||
system(errcmd);
|
|
||||||
perror(msg);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nonfatal(char *msg)
|
|
||||||
{
|
|
||||||
char *errcmd;
|
|
||||||
asprintf(&errcmd, "DISPLAY=:0 kdialog --sorry 'qfile-agent-dvm: %s'", msg);
|
|
||||||
system(errcmd);
|
|
||||||
fprintf(stderr, "%s", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void send_file(char *fname)
|
void send_file(char *fname)
|
||||||
{
|
{
|
||||||
char *base;
|
char *base;
|
||||||
int fd = open(fname, O_RDONLY);
|
int fd = open(fname, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
fatal("open file_to_be_edited");
|
gui_fatal("open %s", fname);
|
||||||
base = rindex(fname, '/');
|
base = rindex(fname, '/');
|
||||||
if (!base)
|
if (!base)
|
||||||
base = fname;
|
base = fname;
|
||||||
@ -43,9 +26,9 @@ void send_file(char *fname)
|
|||||||
if (strlen(base) >= DVM_FILENAME_SIZE)
|
if (strlen(base) >= DVM_FILENAME_SIZE)
|
||||||
base += strlen(base) - DVM_FILENAME_SIZE + 1;
|
base += strlen(base) - DVM_FILENAME_SIZE + 1;
|
||||||
if (!write_all(1, base, DVM_FILENAME_SIZE))
|
if (!write_all(1, base, DVM_FILENAME_SIZE))
|
||||||
fatal("send filename");
|
gui_fatal("send filename to dispVM");
|
||||||
if (!copy_fd_all(1, fd))
|
if (!copy_fd_all(1, fd))
|
||||||
fatal("send file");
|
gui_fatal("send file to dispVM");
|
||||||
close(1);
|
close(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,9 +36,9 @@ int copy_and_return_nonemptiness(int tmpfd)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (!copy_fd_all(tmpfd, 0))
|
if (!copy_fd_all(tmpfd, 0))
|
||||||
fatal("receiving file");
|
gui_fatal("receiving file from dispVM");
|
||||||
if (fstat(tmpfd, &st))
|
if (fstat(tmpfd, &st))
|
||||||
fatal("fstat");
|
gui_fatal("fstat");
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
|
|
||||||
return st.st_size;
|
return st.st_size;
|
||||||
@ -70,7 +53,7 @@ void recv_file_nowrite(char *fname)
|
|||||||
asprintf(&tempfile, "/tmp/file_edited_in_dvm.XXXXXX");
|
asprintf(&tempfile, "/tmp/file_edited_in_dvm.XXXXXX");
|
||||||
tmpfd = mkstemp(tempfile);
|
tmpfd = mkstemp(tempfile);
|
||||||
if (tmpfd < 0)
|
if (tmpfd < 0)
|
||||||
fatal("unable to create any temporary file, aborting");
|
gui_fatal("unable to create any temporary file, aborting");
|
||||||
if (!copy_and_return_nonemptiness(tmpfd)) {
|
if (!copy_and_return_nonemptiness(tmpfd)) {
|
||||||
unlink(tempfile);
|
unlink(tempfile);
|
||||||
return;
|
return;
|
||||||
@ -79,7 +62,7 @@ void recv_file_nowrite(char *fname)
|
|||||||
"The file %s has been edited in Disposable VM and the modified content has been received, "
|
"The file %s has been edited in Disposable VM and the modified content has been received, "
|
||||||
"but this file is in nonwritable directory and thus cannot be modified safely. The edited file has been "
|
"but this file is in nonwritable directory and thus cannot be modified safely. The edited file has been "
|
||||||
"saved to %s", fname, tempfile);
|
"saved to %s", fname, tempfile);
|
||||||
nonfatal(errmsg);
|
gui_nonfatal(errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void actually_recv_file(char *fname, char *tempfile, int tmpfd)
|
void actually_recv_file(char *fname, char *tempfile, int tmpfd)
|
||||||
@ -89,7 +72,7 @@ void actually_recv_file(char *fname, char *tempfile, int tmpfd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rename(tempfile, fname))
|
if (rename(tempfile, fname))
|
||||||
fatal("rename");
|
gui_fatal("rename");
|
||||||
}
|
}
|
||||||
|
|
||||||
void recv_file(char *fname)
|
void recv_file(char *fname)
|
||||||
@ -121,13 +104,13 @@ void process_spoolentry(char *entry_name)
|
|||||||
entry_fd = open(abs_spool_entry_name, O_RDONLY);
|
entry_fd = open(abs_spool_entry_name, O_RDONLY);
|
||||||
unlink(abs_spool_entry_name);
|
unlink(abs_spool_entry_name);
|
||||||
if (entry_fd < 0 || fstat(entry_fd, &st))
|
if (entry_fd < 0 || fstat(entry_fd, &st))
|
||||||
fatal("bad dvm_entry");
|
gui_fatal("bad dvm_entry");
|
||||||
entry_size = st.st_size;
|
entry_size = st.st_size;
|
||||||
filename = calloc(1, entry_size + DVM_FILENAME_SIZE);
|
filename = calloc(1, entry_size + DVM_FILENAME_SIZE);
|
||||||
if (!filename)
|
if (!filename)
|
||||||
fatal("malloc");
|
gui_fatal("malloc");
|
||||||
if (!read_all(entry_fd, filename, entry_size))
|
if (!read_all(entry_fd, filename, entry_size))
|
||||||
fatal("read dvm entry");
|
gui_fatal("read dvm entry %s", abs_spool_entry_name);
|
||||||
close(entry_fd);
|
close(entry_fd);
|
||||||
talk_to_daemon(filename);
|
talk_to_daemon(filename);
|
||||||
}
|
}
|
||||||
@ -137,7 +120,7 @@ void scan_spool(char *name)
|
|||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
DIR *dir = opendir(name);
|
DIR *dir = opendir(name);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
fatal("opendir");
|
gui_fatal("opendir %s", name);
|
||||||
while ((ent = readdir(dir))) {
|
while ((ent = readdir(dir))) {
|
||||||
char *fname = ent->d_name;
|
char *fname = ent->d_name;
|
||||||
if (!strcmp(fname, ".") || !strcmp(fname, ".."))
|
if (!strcmp(fname, ".") || !strcmp(fname, ".."))
|
||||||
|
Loading…
Reference in New Issue
Block a user