summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2013-09-17 16:47:07 -0500
committerNathan Straz <nstraz@redhat.com>2013-09-17 18:04:51 -0400
commite67d6e11c13131a9922be45a264d3cb111452aeb (patch)
tree1a13281489654076e4276208938b12df95c9876d
parent0871b7a61e68c532f3b4386c9ae584b24304f649 (diff)
downloadqarsh-e67d6e11c13131a9922be45a264d3cb111452aeb.zip
qarsh-e67d6e11c13131a9922be45a264d3cb111452aeb.tar.gz
qarsh-e67d6e11c13131a9922be45a264d3cb111452aeb.tar.xz
Check all returns from send_packet in qarsh
-rw-r--r--qarsh.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/qarsh.c b/qarsh.c
index 61c73e2..49210db 100644
--- a/qarsh.c
+++ b/qarsh.c
@@ -182,6 +182,7 @@ int
run_remote_cmd(char *cmdline)
{
struct qa_packet *qp;
+ int ret;
int rc;
int allowed_in = 0; /* bytes we can send to qarshd */
char b_out[QARSH_BUFSIZE], b_err[QARSH_BUFSIZE]; /* Buffers */
@@ -196,19 +197,31 @@ run_remote_cmd(char *cmdline)
short stdin_isatty = isatty(fileno(stdin));
qp = make_qp_runcmd(cmdline);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
qpfree(qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send runcmd packet: %s\n", strerror(errno));
+ exit(125);
+ }
/* Setup signal handling stuff so we can propogate signals */
setup_signals();
/* Tell qarshd how much data it can send on stdout and stderr */
qp = make_qp_data_allow(1, QARSH_BUFSIZE);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
qpfree(qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno));
+ exit(125);
+ }
qp = make_qp_data_allow(2, QARSH_BUFSIZE);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
qpfree(qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno));
+ exit(125);
+ }
hbeat(qarsh_hb);
cmd_finished = 0;
@@ -228,7 +241,11 @@ run_remote_cmd(char *cmdline)
/* close stdin if it is a tty */
if (stdin_isatty) {
qp = make_qp_data(0, 0, 0, NULL);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send data packet: %s\n", strerror(errno));
+ exit(125);
+ }
qpfree(qp);
close(fileno(stdin));
allowed_in = -1;
@@ -258,7 +275,11 @@ run_remote_cmd(char *cmdline)
/* Only test signals */
if (signal_to_send) {
qp = make_qp_kill(signal_to_send);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send kill packet: %s\n", strerror(errno));
+ exit(125);
+ }
qpfree(qp);
signal_to_send = 0;
}
@@ -273,7 +294,11 @@ run_remote_cmd(char *cmdline)
nbytes = read(fileno(stdin), buf, allowed_in);
if (nbytes >= 0) {
qp = make_qp_data(0, 0, nbytes, buf);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send data packet: %s\n", strerror(errno));
+ exit(125);
+ }
qpfree(qp);
allowed_in -= nbytes;
if (nbytes == 0) {
@@ -296,7 +321,11 @@ run_remote_cmd(char *cmdline)
}
if (!eof_out) {
qp = make_qp_data_allow(1, nbytes);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno));
+ exit(125);
+ }
qpfree(qp);
}
nset--;
@@ -312,7 +341,11 @@ run_remote_cmd(char *cmdline)
}
if (!eof_err) {
qp = make_qp_data_allow(2, nbytes);
- send_packet(qarsh_fd, qp);
+ ret = send_packet(qarsh_fd, qp);
+ if (ret == -1) {
+ fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno));
+ exit(125);
+ }
qpfree(qp);
}
nset--;