1
1
#define _GNU_SOURCE /* asprintf() */
2
2
#include <signal.h> /* sig_atomic_t, struct sigaction,
3
sigemptyset(), sigaddset(),
4
sigaction, SIGINT, SIG_IGN, SIGHUP,
5
SIGTERM, kill(), SIGKILL */
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
6
12
#include <stddef.h> /* NULL */
13
#include <string.h> /* strlen(), memcmp() */
14
#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(),
7
23
#include <stdlib.h> /* getenv() */
8
#include <stdio.h> /* asprintf(), perror() */
9
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS,
11
#include <sys/types.h> /* pid_t, DIR, struct dirent,
13
24
#include <dirent.h> /* opendir(), readdir(), closedir() */
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 */
25
#include <sys/stat.h> /* struct stat, lstat(), S_ISLNK */
24
27
sig_atomic_t interrupted_by_signal = 0;
388
414
if(interrupted_by_signal or an_error_occured){
392
417
written += (size_t)sret;
393
}while(written < buf_len);
394
420
if(not interrupted_by_signal and not an_error_occured){
395
422
return EXIT_SUCCESS;
425
} /* end of non-loop while() */
400
427
/* If we got here, an error or interrupt must have happened */
429
/* Create argc and argv for new usplash*/
402
430
int cmdline_argc = 0;
403
431
char **cmdline_argv = malloc(sizeof(char *));
404
/* Create argv and argc for new usplash*/
406
433
size_t position = 0;
407
434
while(position < cmdline_len){
408
435
char **tmp = realloc(cmdline_argv,
409
(sizeof(char *) * (size_t)(cmdline_argc + 2)));
437
* (size_t)(cmdline_argc + 2)));
411
439
perror("realloc");
412
440
free(cmdline_argv);