1
1
#define _GNU_SOURCE /* asprintf() */
2
2
#include <signal.h> /* sig_atomic_t, struct sigaction,
3
sigemptyset(), sigaddset(), SIGINT,
4
SIGHUP, SIGTERM, sigaction(),
5
SIG_IGN, kill(), SIGKILL */
6
#include <stdbool.h> /* bool, false, true */
7
#include <fcntl.h> /* open(), O_WRONLY, O_RDONLY */
8
#include <iso646.h> /* and, or, not*/
9
#include <errno.h> /* errno, EINTR */
10
#include <sys/types.h> /* size_t, ssize_t, pid_t, DIR, struct
3
sigemptyset(), sigaddset(),
4
sigaction, SIGINT, SIG_IGN, SIGHUP,
5
SIGTERM, kill(), SIGKILL */
12
6
#include <stddef.h> /* NULL */
13
#include <string.h> /* strlen(), memcmp() */
7
#include <stdlib.h> /* getenv() */
14
8
#include <stdio.h> /* asprintf(), perror() */
15
#include <unistd.h> /* close(), write(), readlink(),
16
read(), STDOUT_FILENO, sleep(),
17
fork(), setuid(), geteuid(),
18
setsid(), chdir(), dup2(),
19
STDERR_FILENO, execv() */
20
#include <stdlib.h> /* free(), EXIT_FAILURE, strtoul(),
21
realloc(), EXIT_SUCCESS, malloc(),
23
#include <stdlib.h> /* getenv() */
9
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS,
11
#include <sys/types.h> /* pid_t, DIR, struct dirent,
24
13
#include <dirent.h> /* opendir(), readdir(), closedir() */
25
#include <sys/stat.h> /* struct stat, lstat(), S_ISLNK */
14
#include <unistd.h> /* readlink(), fork(), execl(),
16
#include <string.h> /* memcmp() */
17
#include <iso646.h> /* and */
18
#include <stdbool.h> /* bool, false, true */
19
#include <errno.h> /* errno */
20
#include <sys/wait.h> /* waitpid(), WIFEXITED(),
22
#include <fcntl.h> /* open(), O_RDONLY */
27
24
sig_atomic_t interrupted_by_signal = 0;
414
388
if(interrupted_by_signal or an_error_occured){
417
392
written += (size_t)sret;
393
}while(written < buf_len);
420
394
if(not interrupted_by_signal and not an_error_occured){
422
395
return EXIT_SUCCESS;
425
} /* end of non-loop while() */
427
400
/* If we got here, an error or interrupt must have happened */
429
/* Create argc and argv for new usplash*/
430
402
int cmdline_argc = 0;
431
403
char **cmdline_argv = malloc(sizeof(char *));
404
/* Create argv and argc for new usplash*/
433
406
size_t position = 0;
434
407
while(position < cmdline_len){
435
408
char **tmp = realloc(cmdline_argv,
437
* (size_t)(cmdline_argc + 2)));
409
(sizeof(char *) * (size_t)(cmdline_argc + 2)));
439
411
perror("realloc");
440
412
free(cmdline_argv);