Commit Graph

43 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
cc83b8d344
qrexec: fix exit code from qrexec-client-vm
It should be remote process exit code, not the local one.
Also do not 'return' from the middle of the look, just use 'break' to
execute common cleanup code (which will be introduced in next commit).
2015-08-07 21:36:49 +02:00
Marek Marczykowski-Górecki
52a1fee533 qrexec: do not show message about missing fork-sever - it isn't an error 2015-05-24 20:47:34 +02:00
Marek Marczykowski-Górecki
23a9512402 qrexec: prefer VM-local service file (if present) over default one
This will allow a service to be overridden per-VM.
2015-05-13 23:21:01 +02:00
Marek Marczykowski-Górecki
731ee3e09a qrexec: do not reset umask to 077 for every started process
This umask will be inherited by any process started directly by qrexec
(i.e. without help of fork-server).
2015-04-10 18:07:32 +02:00
Marek Marczykowski-Górecki
5c3ab559c6 Merge branch 'master' of git://github.com/woju/qubes-core-agent-linux 2015-03-31 22:25:23 +02:00
Marek Marczykowski-Górecki
74490b0b94 qrexec: try to recover from fork-server communication error
Simply forget about that connection, instead of waiting for further
messages. If that connection is no longer available, select would return
EBADF, which would cause qrexec-agent termination.
2015-03-29 15:43:21 +02:00
Wojtek Porczyk
6c0e567929 qubes-rpc-multiplexer: deprecate /etc/qubes_rpc, allow /usr/local
/usr/local resides in private.img, so it is possible to define per-appvm RPC

Also, with the upcoming 3.0 release support for old (R1) paths is
removed.
2015-03-21 01:48:06 +01:00
Marek Marczykowski-Górecki
c33565b001 qrexec: enable compiler optimization
Besides obvious profits, it also enables some additional compiler
warnings.
2015-03-20 12:06:33 +01:00
Marek Marczykowski-Górecki
b718747c09 qrexec: do not wait for local process if no one exists 2015-03-20 12:05:48 +01:00
Marek Marczykowski-Górecki
9fe45aeae5 qrexec: fix compile warning 2015-03-20 03:05:05 +01:00
Marek Marczykowski-Górecki
9a7b161c37 qrexec: move qrexec-client-vm to /usr/bin 2015-03-17 23:11:47 +01:00
Marek Marczykowski-Górecki
4b451ef680 qrexec: execute RPC service directly (without a shell) if it has executable bit set
This will allow to use some different shell/language for a service (for
example python).
2015-03-17 14:47:29 +01:00
Marek Marczykowski-Górecki
0f75603d6d qrexec: do not leak FDs to logger process
This would prevent qrexec from detecting EOF.
2015-03-17 14:46:53 +01:00
Marek Marczykowski-Górecki
a86d980ff4 qrexec: add option to use real stdin/out of qrexec-client-vm 2015-03-17 14:17:01 +01:00
Marek Marczykowski-Górecki
8f00bdb4a6 qrexec: process vchan data queue (esp MSG_EXIT_CODE) before sending anything
In case of remote process exit even when some messages are still
waiting, vchan connection can be already closed. If we try to send some
data in this case (for example stdout of local process), there will be
an error, which will terminate qrexec-client-vm/qrexec-agent child. So
first check vchan data (where could be MSG_EXIT_CODE queued) , then
local process.

There is still some race condition in this code - remote process could
exit just after we check vchan, but before we send some data. But this
is much less probable and in the worst case we only loose remote process
exit code.
2015-03-17 12:39:30 +01:00
Marek Marczykowski-Górecki
16c27fc409 qrexec: minor readability fix 2015-03-16 21:41:36 +01:00
Marek Marczykowski-Górecki
55e040cbef qrexec: do not break connection on duplicated SIGUSR1
Child process can request to use single socket for both stdin and
stdout by sending SIGUSR1 signal. If it does so twice or more, previous
code broke the connection by closing the socket.
2015-03-16 21:39:34 +01:00
Marek Marczykowski-Górecki
23fc3599e8 qrexec: better handle remote process termination
If remote end terminates without proper protocol finish
(MSG_DATA_EXIT_CODE), terminate also local part instead of waiting
indefinitely.
2015-03-16 21:37:59 +01:00
Marek Marczykowski-Górecki
4eb1d72aee qrexec: return remote process status as qrexec-client-vm exit code
This doesn't cover all the cases, because local process could want to
receive that value (currently it cant), but I can't think of any simple,
*compatible* way to pass it there.
2015-03-16 21:32:34 +01:00
Marek Marczykowski-Górecki
1aa05ebc36 qrexec: handle data vchan directly from qrexec-client-vm
This way qrexec-client-vm will have much more information, at least:
 - will know whether the service call was accepted or refused
 - potentially will know remote process exit code
This commit implements the first point - the local process will not be
started if service call was refused.
2015-03-16 21:10:25 +01:00
Marek Marczykowski-Górecki
203691fae0 qrexec: simplify makefile 2015-03-16 20:51:28 +01:00
Marek Marczykowski-Górecki
29f5709c53 qrexec: fork into background after setting up qrexec-fork-server socket
This allows qubes-session signalling dom0 when session is really ready.
2015-02-22 03:12:54 +01:00
Marek Marczykowski-Górecki
e43c43f7b5 qrexec: fix compile warning 2015-02-17 14:09:36 +01:00
Marek Marczykowski-Górecki
700c240d37 qrexec: add simple "fork server" to spawn new processes inside user session
This process should be started from user session (most likely
qubes-session). New processes (of that user) will be created as
children of that session making logind and such crap happy. This should
also solve problems with EOF transmission (no additional "su" process)
and prevent loading all the environment multiple times.
2015-02-17 04:18:34 +01:00
Marek Marczykowski-Górecki
4b5960daa3 qrexec: reorganise code for upcoming change
Move (qrexec-agent version of) do_exec to qrexec-agent.c, move
handle_handshake to qrexec-agent-data.c (common to all agent binaries).
Fix indentation (tabs -> spaces).
2015-02-17 04:06:19 +01:00
Marek Marczykowski-Górecki
c1cb78e0e8 qrexec: use sockets instead of pipes to communicate with child process
The main advantage is possible use of single socket for both stdin and
stdout. This is strictly required for using USBIP over qrexec.

For compatibility qrexec still creates three socket pairs (instead of
pipes) for stdin/out/err respectively. When qrexec-agent receives
SIGUSR1, it will close stdout socket and use stdin socket for both
directions.

Some additional work is needed here to actually allow child process to
send that signal - qrexec is running as root, but child as "user" in
most cases.
2015-02-17 01:36:09 +01:00
Marek Marczykowski-Górecki
48685938ff qrexec: register exec function
Update for shared libqrexec.so API (instead of statically linked one).
2014-11-19 15:34:34 +01:00
Marek Marczykowski-Górecki
b13844afe1 qrexec: new protocol - direct data vchan connections 2014-11-19 15:34:34 +01:00
Marek Marczykowski-Górecki
d84381b87f code style: replace tabs with spaces 2014-11-19 15:34:34 +01:00
Marek Marczykowski-Górecki
b8588c4856 qrexec: remove dom0 targets from makefile 2014-11-19 15:34:33 +01:00
Marek Marczykowski
95839ddab5 Update for new vchan API 2014-11-19 15:34:32 +01:00
Marek Marczykowski-Górecki
f0f82fc7e5 qrexec: fix loop bounds 2014-07-26 02:14:56 +02:00
Marek Marczykowski-Górecki
acb74e89e2 qubes-rpc: log service stderr to syslog instead of sending to dom0 (#842) 2014-05-05 05:22:06 +02:00
Marek Marczykowski-Górecki
8018b9d3ee Fix compiler warnings.
Mostly harmless cases of warn_unused_result.
2014-04-22 00:56:52 +02:00
Marek Marczykowski-Górecki
f8b1a6c562 qrexec: use proper unsigned type instead of muting compiler warning 2014-02-19 20:53:54 +01:00
Marek Marczykowski-Górecki
c632f0d067 Add -Wextra -Werror to all C code 2014-02-16 11:34:22 +01:00
Marek Marczykowski-Górecki
75b1e24bab qubes-rpc, qrexec: register callbacks for qrexec-lib
Now qrexec-lib do not use exported symbols of particular names, but
explicitly registered callbacks.
2014-02-07 05:36:15 +01:00
Vincent Penquerc'h
511b614f56 qrexec-agent: catch failure to deliver signal 2014-01-06 17:57:40 +01:00
Vincent Penquerc'h
1dfd1d0e70 qrexec-agent: fix array read underflow 2014-01-06 17:57:40 +01:00
Vincent Penquerc'h
b2e84900a3 qrexec-agent: fix file leak on read error 2014-01-06 17:57:40 +01:00
Vincent Penquerc'h
c14f810067 qrexec-agent: pass an int pointer to sscanf to match %d
and check for 16 bit unsigned range after that.
2014-01-06 17:57:40 +01:00
Vincent Penquerc'h
475421b2e2 core-agent-linux: misc const fixups 2014-01-06 17:57:40 +01:00
Marek Marczykowski
44fab139f4 Add qrexec back, use qubes-utils libraries for common code 2013-03-20 06:23:44 +01:00