qrexec: code style fix - use spaces for indentation
This commit is contained in:
parent
486f17ec2d
commit
1497b3b05b
@ -152,7 +152,7 @@ void send_exit_code(libvchan_t *data_vchan, int status)
|
||||
*/
|
||||
int handle_input(libvchan_t *vchan, int fd, int msg_type)
|
||||
{
|
||||
char buf[MAX_DATA_CHUNK];
|
||||
char buf[MAX_DATA_CHUNK];
|
||||
int len;
|
||||
struct msg_header hdr;
|
||||
|
||||
@ -201,7 +201,7 @@ int handle_input(libvchan_t *vchan, int fd, int msg_type)
|
||||
int handle_remote_data(libvchan_t *data_vchan, int stdin_fd, int *status,
|
||||
struct buffer *stdin_buf)
|
||||
{
|
||||
struct msg_header hdr;
|
||||
struct msg_header hdr;
|
||||
char buf[MAX_DATA_CHUNK];
|
||||
|
||||
/* do not receive any data if we have something already buffered */
|
||||
|
@ -160,6 +160,7 @@ void do_exec(const char *cmd)
|
||||
strcpy(buf + strlen(QUBES_RPC_MULTIPLEXER_PATH), realcmd + RPC_REQUEST_COMMAND_LEN);
|
||||
realcmd = buf;
|
||||
}
|
||||
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
|
||||
|
@ -35,19 +35,19 @@
|
||||
|
||||
void do_exec(const char *cmd)
|
||||
{
|
||||
char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - strlen(RPC_REQUEST_COMMAND) + 1];
|
||||
/* replace magic RPC cmd with RPC multiplexer path */
|
||||
if (strncmp(cmd, RPC_REQUEST_COMMAND " ", strlen(RPC_REQUEST_COMMAND)+1)==0) {
|
||||
strcpy(buf, QUBES_RPC_MULTIPLEXER_PATH);
|
||||
strcpy(buf + strlen(QUBES_RPC_MULTIPLEXER_PATH), cmd + strlen(RPC_REQUEST_COMMAND));
|
||||
cmd = buf;
|
||||
}
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - strlen(RPC_REQUEST_COMMAND) + 1];
|
||||
/* replace magic RPC cmd with RPC multiplexer path */
|
||||
if (strncmp(cmd, RPC_REQUEST_COMMAND " ", strlen(RPC_REQUEST_COMMAND)+1)==0) {
|
||||
strcpy(buf, QUBES_RPC_MULTIPLEXER_PATH);
|
||||
strcpy(buf + strlen(QUBES_RPC_MULTIPLEXER_PATH), cmd + strlen(RPC_REQUEST_COMMAND));
|
||||
cmd = buf;
|
||||
}
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
|
||||
execl("/bin/sh", "sh", "-c", cmd, NULL);
|
||||
perror("execl");
|
||||
exit(1);
|
||||
execl("/bin/sh", "sh", "-c", cmd, NULL);
|
||||
perror("execl");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void handle_vchan_error(const char *op)
|
||||
@ -57,43 +57,43 @@ void handle_vchan_error(const char *op)
|
||||
}
|
||||
|
||||
void handle_single_command(int fd, struct qrexec_cmd_info *info) {
|
||||
char cmdline[info->cmdline_len+1];
|
||||
char cmdline[info->cmdline_len+1];
|
||||
|
||||
if (!read_all(fd, cmdline, info->cmdline_len))
|
||||
return;
|
||||
cmdline[info->cmdline_len] = 0;
|
||||
if (!read_all(fd, cmdline, info->cmdline_len))
|
||||
return;
|
||||
cmdline[info->cmdline_len] = 0;
|
||||
|
||||
handle_new_process(info->type, info->connect_domain,
|
||||
info->connect_port,
|
||||
cmdline, info->cmdline_len);
|
||||
handle_new_process(info->type, info->connect_domain,
|
||||
info->connect_port,
|
||||
cmdline, info->cmdline_len);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int s, fd;
|
||||
char *socket_path;
|
||||
struct qrexec_cmd_info info;
|
||||
struct sockaddr_un peer;
|
||||
unsigned int addrlen;
|
||||
int s, fd;
|
||||
char *socket_path;
|
||||
struct qrexec_cmd_info info;
|
||||
struct sockaddr_un peer;
|
||||
unsigned int addrlen;
|
||||
|
||||
|
||||
if (argc == 2) {
|
||||
socket_path = argv[1];
|
||||
} else if (argc == 1) {
|
||||
/* this will be leaked, but we don't care as the process will then terminate */
|
||||
if (asprintf(&socket_path, QREXEC_FORK_SERVER_SOCKET, getenv("USER")) < 0) {
|
||||
fprintf(stderr, "Memory allocation failed\n");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Usage: %s [socket path]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 2) {
|
||||
socket_path = argv[1];
|
||||
} else if (argc == 1) {
|
||||
/* this will be leaked, but we don't care as the process will then terminate */
|
||||
if (asprintf(&socket_path, QREXEC_FORK_SERVER_SOCKET, getenv("USER")) < 0) {
|
||||
fprintf(stderr, "Memory allocation failed\n");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Usage: %s [socket path]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
s = get_server_socket(socket_path);
|
||||
if (fcntl(s, F_SETFD, O_CLOEXEC) < 0) {
|
||||
perror("fcntl");
|
||||
exit(1);
|
||||
}
|
||||
s = get_server_socket(socket_path);
|
||||
if (fcntl(s, F_SETFD, O_CLOEXEC) < 0) {
|
||||
perror("fcntl");
|
||||
exit(1);
|
||||
}
|
||||
/* fork into background */
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
@ -104,17 +104,17 @@ int main(int argc, char **argv) {
|
||||
default:
|
||||
exit(0);
|
||||
}
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
register_exec_func(do_exec);
|
||||
|
||||
while ((fd = accept(s, (struct sockaddr *) &peer, &addrlen)) >= 0) {
|
||||
if (read_all(fd, &info, sizeof(info))) {
|
||||
handle_single_command(fd, &info);
|
||||
}
|
||||
close(fd);
|
||||
addrlen = sizeof(peer);
|
||||
}
|
||||
close(s);
|
||||
unlink(socket_path);
|
||||
return 0;
|
||||
while ((fd = accept(s, (struct sockaddr *) &peer, &addrlen)) >= 0) {
|
||||
if (read_all(fd, &info, sizeof(info))) {
|
||||
handle_single_command(fd, &info);
|
||||
}
|
||||
close(fd);
|
||||
addrlen = sizeof(peer);
|
||||
}
|
||||
close(s);
|
||||
unlink(socket_path);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user