qrexec - indentation

This commit is contained in:
Rafal Wojtczuk 2011-05-04 13:00:39 +02:00
parent b4fb7a4b5d
commit d84289f983
2 changed files with 45 additions and 31 deletions

View File

@ -195,8 +195,8 @@ void send_exit_code(int client_id, int status)
s_hdr.len = sizeof status;
write_all_vchan_ext(&s_hdr, sizeof s_hdr);
write_all_vchan_ext(&status, sizeof(status));
fprintf(stderr, "send exit code for client_id %d pid %d\n", client_id,
client_info[client_id].pid);
fprintf(stderr, "send exit code for client_id %d pid %d\n",
client_id, client_info[client_id].pid);
}
@ -206,7 +206,8 @@ void remove_process(int client_id, int status)
int i;
if (!client_info[client_id].pid)
return;
fork_and_flush_stdin(client_info[client_id].stdin_fd, &client_info[client_id].buffer);
fork_and_flush_stdin(client_info[client_id].stdin_fd,
&client_info[client_id].buffer);
#if 0
// let's let it die by itself, possibly after it has received buffered stdin
kill(client_info[client_id].pid, SIGKILL);
@ -242,7 +243,8 @@ void handle_input(int client_id, int len)
if (len == 0) {
if (client_info[client_id].is_blocked)
client_info[client_id].is_close_after_flush_needed = 1;
client_info[client_id].
is_close_after_flush_needed = 1;
else {
close(client_info[client_id].stdin_fd);
client_info[client_id].stdin_fd = -1;
@ -453,7 +455,8 @@ int fill_fds_for_select(fd_set * rdset, fd_set * wrset)
void flush_client_data_agent(int client_id)
{
struct _client_info *info = &client_info[client_id];
switch (flush_client_data(info->stdin_fd, client_id, &info->buffer)) {
switch (flush_client_data
(info->stdin_fd, client_id, &info->buffer)) {
case WRITE_STDIN_OK:
info->is_blocked = 0;
if (info->is_close_after_flush_needed) {
@ -486,7 +489,8 @@ void handle_trigger_io()
if (!strcmp(buf, "FCPR"))
s_hdr.client_id = QREXEC_EXECUTE_FILE_COPY;
else if (!strcmp(buf, "DVMR"))
s_hdr.client_id = QREXEC_EXECUTE_FILE_COPY_FOR_DISPVM;
s_hdr.client_id =
QREXEC_EXECUTE_FILE_COPY_FOR_DISPVM;
if (s_hdr.client_id) {
s_hdr.type = MSG_AGENT_TO_SERVER_TRIGGER_EXEC;
write_all_vchan_ext(&s_hdr, sizeof s_hdr);

View File

@ -96,7 +96,9 @@ void init(int xid)
snprintf(qrexec_error_log_name, sizeof(qrexec_error_log_name),
"/var/log/qubes/qrexec.%d.log", xid);
umask(0007); // make the log readable by the "qubes" group
logfd = open(qrexec_error_log_name, O_WRONLY | O_CREAT | O_TRUNC, 0640);
logfd =
open(qrexec_error_log_name, O_WRONLY | O_CREAT | O_TRUNC,
0640);
if (logfd < 0) {
perror("open");
@ -116,7 +118,8 @@ void init(int xid)
setuid(getuid());
/* When running as root, make the socket accessible; perms on /var/run/qubes still apply */
umask(0);
qrexec_daemon_unix_socket_fd = get_server_socket(xid, remote_domain_name);
qrexec_daemon_unix_socket_fd =
get_server_socket(xid, remote_domain_name);
umask(0077);
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, sigchld_handler);
@ -164,7 +167,9 @@ void terminate_client_and_flush_data(int fd)
write_all_vchan_ext(&s_hdr, sizeof(s_hdr));
}
void get_cmdline_body_from_client_and_pass_to_agent(int fd, struct server_header *s_hdr)
void get_cmdline_body_from_client_and_pass_to_agent(int fd,
struct server_header
*s_hdr)
{
int len = s_hdr->len;
char buf[len];
@ -246,7 +251,8 @@ buffered data.
*/
void write_buffered_data_to_client(int client_id)
{
switch (flush_client_data(client_id, client_id, &clients[client_id].buffer)) {
switch (flush_client_data
(client_id, client_id, &clients[client_id].buffer)) {
case WRITE_STDIN_OK: // no more buffered data
clients[client_id].state &= ~CLIENT_OUTQ_FULL;
break;
@ -265,7 +271,9 @@ void write_buffered_data_to_client(int client_id)
The header (hdr argument) is already built. Just read the raw data from
the packet, and pass it along with the header to the client.
*/
void get_packet_data_from_agent_and_pass_to_client(int client_id, struct client_header *hdr)
void get_packet_data_from_agent_and_pass_to_client(int client_id,
struct client_header
*hdr)
{
int len = hdr->len;
char buf[sizeof(*hdr) + len];
@ -380,7 +388,8 @@ void handle_execute_predefined_command(int req)
void check_client_id_in_range(unsigned int untrusted_client_id)
{
if (untrusted_client_id >= MAX_CLIENTS || untrusted_client_id < 0) {
fprintf(stderr, "from agent: client_id=%d\n", untrusted_client_id);
fprintf(stderr, "from agent: client_id=%d\n",
untrusted_client_id);
exit(1);
}
}
@ -474,7 +483,8 @@ void handle_message_from_agent()
read_all_vchan_ext(buf, s_hdr.len);
return;
}
get_packet_data_from_agent_and_pass_to_client(s_hdr.client_id, &hdr);
get_packet_data_from_agent_and_pass_to_client(s_hdr.client_id,
&hdr);
if (s_hdr.type == MSG_AGENT_TO_SERVER_EXIT_CODE)
terminate_client_and_flush_data(s_hdr.client_id);
}