diff --git a/qrexec-lib/copy-file.c b/qrexec-lib/copy-file.c index df935ff..237a252 100644 --- a/qrexec-lib/copy-file.c +++ b/qrexec-lib/copy-file.c @@ -3,7 +3,11 @@ #include "libqubes-rpc-filecopy.h" #include "crc32.h" -extern void notify_progress(int, int); +notify_progress_t *notify_progress_func = NULL; +void register_notify_progress(notify_progress_t *func) +{ + notify_progress_func = func; +} int copy_file(int outfd, int infd, long long size, unsigned long *crc32) { @@ -26,7 +30,8 @@ int copy_file(int outfd, int infd, long long size, unsigned long *crc32) *crc32 = Crc32_ComputeBuf(*crc32, buf, ret); if (!write_all(outfd, buf, ret)) return COPY_FILE_WRITE_ERROR; - notify_progress(ret, 0); + if (notify_progress_func != NULL) + notify_progress_func(ret, 0); written += ret; } return COPY_FILE_OK; diff --git a/qrexec-lib/exec.c b/qrexec-lib/exec.c index b593af8..f0949bc 100644 --- a/qrexec-lib/exec.c +++ b/qrexec-lib/exec.c @@ -22,8 +22,12 @@ #include #include #include +#include "libqrexec-utils.h" -extern void do_exec(const char *); +static do_exec_t *exec_func = NULL; +void register_exec_func(do_exec_t *func) { + exec_func = func; +} void fix_fds(int fdin, int fdout, int fderr) { @@ -59,7 +63,8 @@ void do_fork_exec(const char *cmdline, int *pid, int *stdin_fd, int *stdout_fd, } else fix_fds(inpipe[0], outpipe[1], 2); - do_exec(cmdline); + if (exec_func != NULL) + exec_func(cmdline); exit(-1); default:; } diff --git a/qrexec-lib/libqrexec-utils.h b/qrexec-lib/libqrexec-utils.h index b090569..b8a354c 100644 --- a/qrexec-lib/libqrexec-utils.h +++ b/qrexec-lib/libqrexec-utils.h @@ -27,6 +27,9 @@ struct buffer { int buflen; }; +typedef void (do_exec_t)(const char *); +void register_exec_func(do_exec_t *func); + void buffer_init(struct buffer *b); void buffer_free(struct buffer *b); void buffer_append(struct buffer *b, const char *data, int len); diff --git a/qrexec-lib/libqubes-rpc-filecopy.h b/qrexec-lib/libqubes-rpc-filecopy.h index 8f57728..05f3849 100644 --- a/qrexec-lib/libqubes-rpc-filecopy.h +++ b/qrexec-lib/libqubes-rpc-filecopy.h @@ -60,6 +60,8 @@ enum { COPY_FILE_WRITE_ERROR }; +typedef void (notify_progress_t)(int, int); +void register_notify_progress(notify_progress_t *func); int copy_file(int outfd, int infd, long long size, unsigned long *crc32); char *copy_file_status_to_str(int status); void set_size_limit(long long new_bytes_limit, long long new_files_limit);