=== modified file 'TODO' --- TODO 2009-09-05 01:46:42 +0000 +++ TODO 2009-09-07 07:48:59 +0000 @@ -4,9 +4,12 @@ ** TODO [#A] Clean up /tmp directory and take down interface on signal :test: ** TODO [#B] use scandir(3) instead of readdir(3) ** TODO [#B] Prefix all debug output with argv[0] +** TODO [#B] Retry a server which has a non-definite reply. +*** A closed connection during the TLS handshake +*** A TCP timeout * splashy -** TODO [#A] Re-raise signal received when exiting due to handled signal. +** TODO [#A] Re-raise signal received when exiting due to handled signal :test: ** TODO [#B] use scandir(3) instead of readdir(3) ** TODO [#B] Prefix all debug output with argv[0] @@ -19,7 +22,6 @@ ** TODO [#B] Prefix all debug output with argv[0] * plugin-runner -** TODO [#A] Do not handle ignored signals ** TODO [#B] use scandir(3) instead of readdir(3) ** TODO [#C] use same file name rules as run-parts(8) === modified file 'plugin-runner.c' --- plugin-runner.c 2009-09-04 16:32:22 +0000 +++ plugin-runner.c 2009-09-07 07:48:59 +0000 @@ -1,4 +1,4 @@ -/* -*- coding: utf-8 -*- */ +/* -*- coding: utf-8; mode: c; mode: orgtbl -*- */ /* * Mandos plugin runner - Run Mandos plugins * @@ -110,13 +110,18 @@ } } /* Create a new plugin */ - plugin *new_plugin = malloc(sizeof(plugin)); + plugin *new_plugin = NULL; + do { + new_plugin = malloc(sizeof(plugin)); + } while(new_plugin == NULL and errno == EINTR); if(new_plugin == NULL){ return NULL; } char *copy_name = NULL; if(name != NULL){ - copy_name = strdup(name); + do { + copy_name = strdup(name); + } while(copy_name == NULL and errno == EINTR); if(copy_name == NULL){ free(new_plugin); return NULL; @@ -128,7 +133,9 @@ .disabled = false, .next = plugin_list }; - new_plugin->argv = malloc(sizeof(char *) * 2); + do { + new_plugin->argv = malloc(sizeof(char *) * 2); + } while(new_plugin->argv == NULL and errno == EINTR); if(new_plugin->argv == NULL){ free(copy_name); free(new_plugin); @@ -137,7 +144,9 @@ new_plugin->argv[0] = copy_name; new_plugin->argv[1] = NULL; - new_plugin->environ = malloc(sizeof(char *)); + do { + new_plugin->environ = malloc(sizeof(char *)); + } while(new_plugin->environ == NULL and errno == EINTR); if(new_plugin->environ == NULL){ free(copy_name); free(new_plugin->argv); @@ -155,14 +164,19 @@ static bool add_to_char_array(const char *new, char ***array, int *len){ /* Resize the pointed-to array to hold one more pointer */ - *array = realloc(*array, sizeof(char *) - * (size_t) ((*len) + 2)); + do { + *array = realloc(*array, sizeof(char *) + * (size_t) ((*len) + 2)); + } while(*array == NULL and errno == EINTR); /* Malloc check */ if(*array == NULL){ return false; } /* Make a copy of the new string */ - char *copy = strdup(new); + char *copy; + do { + copy = strdup(new); + } while(copy == NULL and errno == EINTR); if(copy == NULL){ return false; } @@ -194,7 +208,10 @@ if(strncmp(*e, def, namelen + 1) == 0){ /* It already exists */ if(replace){ - char *new = realloc(*e, strlen(def) + 1); + char *new; + do { + new = realloc(*e, strlen(def) + 1); + } while(new == NULL and errno == EINTR); if(new == NULL){ return false; } @@ -210,16 +227,16 @@ /* * Based on the example in the GNU LibC manual chapter 13.13 "File * Descriptor Flags". - * *Note File Descriptor Flags:(libc)Descriptor Flags. + | [[info:libc:Descriptor%20Flags][File Descriptor Flags]] | */ static int set_cloexec_flag(int fd){ - int ret = fcntl(fd, F_GETFD, 0); + int ret = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD, 0)); /* If reading the flags failed, return error indication now. */ if(ret < 0){ return ret; } /* Store modified flag word in the descriptor. */ - return fcntl(fd, F_SETFD, ret | FD_CLOEXEC); + return TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, ret | FD_CLOEXEC)); } @@ -317,7 +334,6 @@ fd_set rfds_all; int ret, maxfd = 0; ssize_t sret; - intmax_t tmpmax; uid_t uid = 65534; gid_t gid = 65534; bool debug = false; @@ -382,8 +398,9 @@ error_t parse_opt(int key, char *arg, __attribute__((unused)) struct argp_state *state){ - char *tmp; switch(key){ + char *tmp; + intmax_t tmpmax; case 'g': /* --global-options */ if(arg != NULL){ char *plugin_option; @@ -617,6 +634,14 @@ custom_argv[custom_argc] = NULL; } } + do { + ret = fclose(conffp); + } while(ret == EOF and errno == EINTR); + if(ret == EOF){ + perror("fclose"); + exitstatus = EXIT_FAILURE; + goto fallback; + } free(org_line); } else { /* Check for harmful errors and go to fallback. Other errors might @@ -701,7 +726,9 @@ /* Read and execute any executable in the plugin directory*/ while(true){ - dirst = readdir(dir); + do { + dirst = readdir(dir); + } while(dirst == NULL and errno == EINTR); /* All directory entries have been processed */ if(dirst == NULL){ @@ -761,16 +788,18 @@ char *filename; if(plugindir == NULL){ - ret = asprintf(&filename, PDIR "/%s", dirst->d_name); + ret = TEMP_FAILURE_RETRY(asprintf(&filename, PDIR "/%s", + dirst->d_name)); } else { - ret = asprintf(&filename, "%s/%s", plugindir, dirst->d_name); + ret = TEMP_FAILURE_RETRY(asprintf(&filename, "%s/%s", plugindir, + dirst->d_name)); } if(ret < 0){ perror("asprintf"); continue; } - ret = stat(filename, &st); + ret = TEMP_FAILURE_RETRY(stat(filename, &st)); if(ret == -1){ perror("stat"); free(filename); @@ -778,7 +807,8 @@ } /* Ignore non-executable files */ - if(not S_ISREG(st.st_mode) or (access(filename, X_OK) != 0)){ + if(not S_ISREG(st.st_mode) + or (TEMP_FAILURE_RETRY(access(filename, X_OK)) != 0)){ if(debug){ fprintf(stderr, "Ignoring plugin dir entry \"%s\"" " with bad type or mode\n", filename); @@ -830,7 +860,7 @@ } int pipefd[2]; - ret = pipe(pipefd); + ret = TEMP_FAILURE_RETRY(pipe(pipefd)); if(ret == -1){ perror("pipe"); exitstatus = EXIT_FAILURE; @@ -850,14 +880,19 @@ goto fallback; } /* Block SIGCHLD until process is safely in process list */ - ret = sigprocmask(SIG_BLOCK, &sigchld_action.sa_mask, NULL); + ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_BLOCK, + &sigchld_action.sa_mask, + NULL)); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; goto fallback; } /* Starting a new process to be watched */ - pid_t pid = fork(); + pid_t pid; + do { + pid = fork(); + } while(pid == -1 and errno == EINTR); if(pid == -1){ perror("fork"); exitstatus = EXIT_FAILURE; @@ -901,12 +936,15 @@ /* no return */ } /* Parent process */ - close(pipefd[1]); /* Close unused write end of pipe */ + TEMP_FAILURE_RETRY(close(pipefd[1])); /* Close unused write end of + pipe */ free(filename); plugin *new_plugin = getplugin(dirst->d_name); if(new_plugin == NULL){ perror("getplugin"); - ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, NULL); + ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK, + &sigchld_action.sa_mask, + NULL)); if(ret < 0){ perror("sigprocmask"); } @@ -919,7 +957,9 @@ /* Unblock SIGCHLD so signal handler can be run if this process has already completed */ - ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, NULL); + ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK, + &sigchld_action.sa_mask, + NULL)); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; @@ -933,7 +973,7 @@ } } - closedir(dir); + TEMP_FAILURE_RETRY(closedir(dir)); dir = NULL; free_plugin(getplugin(NULL)); @@ -952,7 +992,7 @@ while(plugin_list){ fd_set rfds = rfds_all; int select_ret = select(maxfd+1, &rfds, NULL, NULL, NULL); - if(select_ret == -1){ + if(select_ret == -1 and errno != EINTR){ perror("select"); exitstatus = EXIT_FAILURE; goto fallback; @@ -989,7 +1029,9 @@ FD_CLR(proc->fd, &rfds_all); /* Block signal while modifying process_list */ - ret = sigprocmask(SIG_BLOCK, &sigchld_action.sa_mask, NULL); + ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_BLOCK, + &sigchld_action.sa_mask, + NULL)); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; @@ -1001,8 +1043,9 @@ proc = next_plugin; /* We are done modifying process list, so unblock signal */ - ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, - NULL); + ret = TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK, + &sigchld_action.sa_mask, + NULL)); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; @@ -1045,8 +1088,10 @@ proc->buffer_size += BUFFER_SIZE; } /* Read from the process */ - sret = read(proc->fd, proc->buffer + proc->buffer_length, - BUFFER_SIZE); + sret = TEMP_FAILURE_RETRY(read(proc->fd, + proc->buffer + + proc->buffer_length, + BUFFER_SIZE)); if(sret < 0){ /* Read error from this process; ignore the error */ proc = proc->next; @@ -1114,7 +1159,7 @@ } /* Wait for any remaining child processes to terminate */ - do{ + do { ret = wait(NULL); } while(ret >= 0); if(errno != ECHILD){ === modified file 'plugins.d/askpass-fifo.c' --- plugins.d/askpass-fifo.c 2009-08-30 03:10:29 +0000 +++ plugins.d/askpass-fifo.c 2009-09-07 07:48:59 +0000 @@ -19,8 +19,7 @@ * along with this program. If not, see * . * - * Contact the authors at and - * . + * Contact the authors at . */ #define _GNU_SOURCE /* TEMP_FAILURE_RETRY() */ @@ -62,7 +61,7 @@ { size_t buf_allocated = 0; const size_t blocksize = 1024; - do{ + do { if(buf_len + blocksize > buf_allocated){ char *tmp = realloc(buf, buf_allocated + blocksize); if(tmp == NULL){ @@ -81,7 +80,7 @@ return EXIT_FAILURE; } buf_len += (size_t)sret; - }while(sret != 0); + } while(sret != 0); } /* Close FIFO */ === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-09-05 01:46:42 +0000 +++ plugins.d/mandos-client.c 2009-09-07 07:48:59 +0000 @@ -164,7 +164,6 @@ */ static bool init_gpgme(const char *seckey, const char *pubkey, const char *tempdir){ - int ret; gpgme_error_t rc; gpgme_engine_info_t engine_info; @@ -173,6 +172,7 @@ * Helper function to insert pub and seckey to the engine keyring. */ bool import_key(const char *filename){ + int ret; int fd; gpgme_data_t pgp_data; @@ -531,7 +531,6 @@ char *decrypted_buffer; size_t buffer_length = 0; size_t buffer_capacity = 0; - ssize_t decrypted_buffer_size; size_t written; int retval = 0; gnutls_session_t session; @@ -712,7 +711,7 @@ goto mandos_end; } - do{ + do { ret = gnutls_handshake(session); if(quit_now){ goto mandos_end; @@ -764,7 +763,7 @@ case GNUTLS_E_AGAIN: break; case GNUTLS_E_REHANDSHAKE: - do{ + do { ret = gnutls_handshake(session); if(quit_now){ @@ -805,10 +804,12 @@ } if(buffer_length > 0){ + ssize_t decrypted_buffer_size; decrypted_buffer_size = pgp_packet_decrypt(buffer, buffer_length, &decrypted_buffer); if(decrypted_buffer_size >= 0){ + written = 0; while(written < (size_t) decrypted_buffer_size){ if(quit_now){ === modified file 'plugins.d/password-prompt.c' --- plugins.d/password-prompt.c 2009-09-05 01:05:25 +0000 +++ plugins.d/password-prompt.c 2009-09-07 07:48:59 +0000 @@ -19,8 +19,7 @@ * along with this program. If not, see * . * - * Contact the authors at and - * . + * Contact the authors at . */ #define _GNU_SOURCE /* getline() */ === modified file 'plugins.d/splashy.c' --- plugins.d/splashy.c 2009-02-12 18:56:52 +0000 +++ plugins.d/splashy.c 2009-09-07 07:48:59 +0000 @@ -19,11 +19,10 @@ * along with this program. If not, see * . * - * Contact the authors at and - * . + * Contact the authors at . */ -#define _GNU_SOURCE /* asprintf() */ +#define _GNU_SOURCE /* TEMP_FAILURE_RETRY(), asprintf() */ #include /* sig_atomic_t, struct sigaction, sigemptyset(), sigaddset(), SIGINT, SIGHUP, SIGTERM, sigaction, @@ -41,24 +40,33 @@ #include /* not, or, and */ #include /* readlink(), fork(), execl(), sleep(), dup2() STDERR_FILENO, - STDOUT_FILENO, _exit() */ + STDOUT_FILENO, _exit(), + pause() */ #include /* memcmp() */ #include /* errno */ #include /* waitpid(), WIFEXITED(), WEXITSTATUS() */ sig_atomic_t interrupted_by_signal = 0; +int signal_received; -static void termination_handler(__attribute__((unused))int signum){ +static void termination_handler(int signum){ + if(interrupted_by_signal){ + return; + } interrupted_by_signal = 1; + signal_received = signum; } int main(__attribute__((unused))int argc, __attribute__((unused))char **argv){ int ret = 0; + char *prompt = NULL; + DIR *proc_dir = NULL; + pid_t splashy_pid = 0; + pid_t splashy_command_pid = 0; /* Create prompt string */ - char *prompt = NULL; { const char *const cryptsource = getenv("cryptsource"); const char *const crypttarget = getenv("crypttarget"); @@ -81,19 +89,18 @@ } } if(ret == -1){ - return EXIT_FAILURE; + prompt = NULL; + goto failure; } } /* Find splashy process */ - pid_t splashy_pid = 0; { const char splashy_name[] = "/sbin/splashy"; - DIR *proc_dir = opendir("/proc"); + proc_dir = opendir("/proc"); if(proc_dir == NULL){ - free(prompt); perror("opendir"); - return EXIT_FAILURE; + goto failure; } for(struct dirent *proc_ent = readdir(proc_dir); proc_ent != NULL; @@ -120,9 +127,7 @@ ret = asprintf(&exe_link, "/proc/%s/exe", proc_ent->d_name); if(ret == -1){ perror("asprintf"); - free(prompt); - closedir(proc_dir); - return EXIT_FAILURE; + goto failure; } /* Check that it refers to a symlink owned by root:root */ @@ -135,9 +140,7 @@ } perror("lstat"); free(exe_link); - free(prompt); - closedir(proc_dir); - return EXIT_FAILURE; + goto failure; } if(not S_ISLNK(exe_stat.st_mode) or exe_stat.st_uid != 0 @@ -157,10 +160,10 @@ } } closedir(proc_dir); + proc_dir = NULL; } if(splashy_pid == 0){ - free(prompt); - return EXIT_FAILURE; + goto failure; } /* Set up the signal handler */ @@ -170,134 +173,179 @@ .sa_flags = 0 }; sigemptyset(&new_action.sa_mask); sigaddset(&new_action.sa_mask, SIGINT); + if(ret == -1){ + perror("sigaddset"); + goto failure; + } sigaddset(&new_action.sa_mask, SIGHUP); + if(ret == -1){ + perror("sigaddset"); + goto failure; + } sigaddset(&new_action.sa_mask, SIGTERM); + if(ret == -1){ + perror("sigaddset"); + goto failure; + } ret = sigaction(SIGINT, NULL, &old_action); if(ret == -1){ perror("sigaction"); - free(prompt); - return EXIT_FAILURE; + goto failure; } if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGINT, &new_action, NULL); if(ret == -1){ perror("sigaction"); - free(prompt); - return EXIT_FAILURE; + goto failure; } } ret = sigaction(SIGHUP, NULL, &old_action); if(ret == -1){ perror("sigaction"); - free(prompt); - return EXIT_FAILURE; + goto failure; } if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGHUP, &new_action, NULL); if(ret == -1){ perror("sigaction"); - free(prompt); - return EXIT_FAILURE; + goto failure; } } ret = sigaction(SIGTERM, NULL, &old_action); if(ret == -1){ perror("sigaction"); - free(prompt); - return EXIT_FAILURE; + goto failure; } if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGTERM, &new_action, NULL); if(ret == -1){ perror("sigaction"); - free(prompt); - return EXIT_FAILURE; + goto failure; } } } + if(interrupted_by_signal){ + goto failure; + } + /* Fork off the splashy command to prompt for password */ - pid_t splashy_command_pid = 0; - if(not interrupted_by_signal){ - splashy_command_pid = fork(); - if(splashy_command_pid == -1){ - if(not interrupted_by_signal){ - perror("fork"); - } - return EXIT_FAILURE; - } - /* Child */ - if(splashy_command_pid == 0){ + splashy_command_pid = fork(); + if(splashy_command_pid != 0 and interrupted_by_signal){ + goto failure; + } + if(splashy_command_pid == -1){ + perror("fork"); + goto failure; + } + /* Child */ + if(splashy_command_pid == 0){ + if(not interrupted_by_signal){ const char splashy_command[] = "/sbin/splashy_update"; - ret = execl(splashy_command, splashy_command, prompt, - (char *)NULL); - if(not interrupted_by_signal){ - perror("execl"); - } - free(prompt); - _exit(EXIT_FAILURE); + execl(splashy_command, splashy_command, prompt, (char *)NULL); + perror("execl"); } + free(prompt); + _exit(EXIT_FAILURE); } /* Parent */ free(prompt); + prompt = NULL; + + if(interrupted_by_signal){ + goto failure; + } /* Wait for command to complete */ - if(not interrupted_by_signal and splashy_command_pid != 0){ + { int status; - ret = waitpid(splashy_command_pid, &status, 0); + do { + ret = waitpid(splashy_command_pid, &status, 0); + } while(ret == -1 and errno == EINTR + and not interrupted_by_signal); + if(interrupted_by_signal){ + goto failure; + } if(ret == -1){ - if(errno != EINTR){ - perror("waitpid"); - } + perror("waitpid"); if(errno == ECHILD){ splashy_command_pid = 0; } } else { /* The child process has exited */ splashy_command_pid = 0; - if(not interrupted_by_signal and WIFEXITED(status) - and WEXITSTATUS(status)==0){ + if(WIFEXITED(status) and WEXITSTATUS(status) == 0){ return EXIT_SUCCESS; } } } - kill(splashy_pid, SIGTERM); - if(interrupted_by_signal and splashy_command_pid != 0){ - kill(splashy_command_pid, SIGTERM); - } - sleep(2); - while(kill(splashy_pid, 0) == 0){ - kill(splashy_pid, SIGKILL); - sleep(1); - } - pid_t new_splashy_pid = fork(); - if(new_splashy_pid == 0){ - /* Child; will become new splashy process */ + + failure: + + free(prompt); + + if(proc_dir != NULL){ + TEMP_FAILURE_RETRY(closedir(proc_dir)); + } + + if(splashy_command_pid != 0){ + TEMP_FAILURE_RETRY(kill(splashy_command_pid, SIGTERM)); - /* Make the effective user ID (root) the only user ID instead of - the real user ID (_mandos) */ - ret = setuid(geteuid()); - if(ret == -1){ - perror("setuid"); + TEMP_FAILURE_RETRY(kill(splashy_pid, SIGTERM)); + sleep(2); + while(TEMP_FAILURE_RETRY(kill(splashy_pid, 0)) == 0){ + TEMP_FAILURE_RETRY(kill(splashy_pid, SIGKILL)); + sleep(1); } + pid_t new_splashy_pid = TEMP_FAILURE_RETRY(fork()); + if(new_splashy_pid == 0){ + /* Child; will become new splashy process */ + + /* Make the effective user ID (root) the only user ID instead of + the real user ID (_mandos) */ + ret = setuid(geteuid()); + if(ret == -1){ + perror("setuid"); + } + + setsid(); + ret = chdir("/"); + if(ret == -1){ + perror("chdir"); + } +/* if(fork() != 0){ */ +/* _exit(EXIT_SUCCESS); */ +/* } */ + ret = dup2(STDERR_FILENO, STDOUT_FILENO); /* replace stdout */ + if(ret == -1){ + perror("dup2"); + _exit(EXIT_FAILURE); + } - setsid(); - ret = chdir("/"); -/* if(fork() != 0){ */ -/* _exit(EXIT_SUCCESS); */ -/* } */ - ret = dup2(STDERR_FILENO, STDOUT_FILENO); /* replace our stdout */ - if(ret == -1){ - perror("dup2"); + execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL); + perror("execl"); _exit(EXIT_FAILURE); } - - execl("/sbin/splashy", "/sbin/splashy", "boot", (char *)NULL); - if(not interrupted_by_signal){ - perror("execl"); - } - _exit(EXIT_FAILURE); + } + + if(interrupted_by_signal){ + struct sigaction signal_action; + sigemptyset(&signal_action.sa_mask); + signal_action.sa_handler = SIG_DFL; + ret = TEMP_FAILURE_RETRY(sigaction(signal_received, + &signal_action, NULL)); + if(ret == -1){ + perror("sigaction"); + } + do { + ret = raise(signal_received); + } while(ret != 0 and errno == EINTR); + if(ret != 0){ + perror("raise"); + abort(); + } + TEMP_FAILURE_RETRY(pause()); } return EXIT_FAILURE; === modified file 'plugins.d/usplash.c' --- plugins.d/usplash.c 2009-09-07 22:21:35 +0000 +++ plugins.d/usplash.c 2009-09-07 23:50:12 +0000 @@ -19,8 +19,7 @@ * along with this program. If not, see * . * - * Contact the authors at and - * . + * Contact the authors at . */ #define _GNU_SOURCE /* asprintf() */ @@ -64,12 +63,12 @@ */ int ret; int fifo_fd; - do{ + do { fifo_fd = open("/dev/.initramfs/usplash_fifo", O_WRONLY); if((fifo_fd == -1) and (errno != EINTR or interrupted_by_signal)){ return false; } - }while(fifo_fd == -1); + } while(fifo_fd == -1); const char *cmd_line; size_t cmd_line_len; @@ -77,8 +76,8 @@ if(arg == NULL){ cmd_line = cmd; cmd_line_len = strlen(cmd); - }else{ - do{ + } else { + do { ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg); if(ret == -1 and (errno != EINTR or interrupted_by_signal)){ int e = errno; @@ -86,7 +85,7 @@ errno = e; return false; } - }while(ret == -1); + } while(ret == -1); cmd_line = cmd_line_alloc; cmd_line_len = (size_t)ret + 1; } @@ -110,12 +109,12 @@ written += (size_t)sret; } free(cmd_line_alloc); - do{ + do { ret = close(fifo_fd); if(ret == -1 and (errno != EINTR or interrupted_by_signal)){ return false; } - }while(ret == -1); + } while(ret == -1); if(interrupted_by_signal){ return false; } @@ -252,7 +251,7 @@ size_t cmdline_allocated = 0; char *tmp; const size_t blocksize = 1024; - do{ + do { if(cmdline_len + blocksize > cmdline_allocated){ tmp = realloc(cmdline, cmdline_allocated + blocksize); if(tmp == NULL){ @@ -366,7 +365,7 @@ /* Open FIFO */ int fifo_fd; - do{ + do { fifo_fd = open("/dev/.initramfs/usplash_outfifo", O_RDONLY); if(fifo_fd == -1){ if(errno != EINTR){ @@ -378,7 +377,7 @@ break; } } - }while(fifo_fd == -1); + } while(fifo_fd == -1); if(interrupted_by_signal or an_error_occured){ break; /* Big */ } @@ -386,7 +385,7 @@ /* Read from FIFO */ size_t buf_allocated = 0; const size_t blocksize = 1024; - do{ + do { if(buf_len + blocksize > buf_allocated){ char *tmp = realloc(buf, buf_allocated + blocksize); if(tmp == NULL){ @@ -397,7 +396,7 @@ buf = tmp; buf_allocated += blocksize; } - do{ + do { sret = read(fifo_fd, buf + buf_len, buf_allocated - buf_len); if(sret == -1){ if(errno != EINTR){ @@ -409,13 +408,13 @@ break; } } - }while(sret == -1); + } while(sret == -1); if(interrupted_by_signal or an_error_occured){ break; } buf_len += (size_t)sret; - }while(sret != 0); + } while(sret != 0); close(fifo_fd); if(interrupted_by_signal or an_error_occured){ break; /* Big */ @@ -433,7 +432,7 @@ /* Print password to stdout */ size_t written = 0; while(written < buf_len){ - do{ + do { sret = write(STDOUT_FILENO, buf + written, buf_len - written); if(sret == -1){ if(errno != EINTR){ @@ -445,7 +444,7 @@ break; } } - }while(sret == -1); + } while(sret == -1); if(interrupted_by_signal or an_error_occured){ break; }