author | Olivier Brunel
<jjk@jjacky.com> 2023-11-26 13:56:07 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-12-14 18:55:00 UTC |
parent | 1a76bba22c733e0e47a46e9960cc030ca77d7294 |
meta/desc | +1 | -0 |
src/extra/miniexec.c | +2 | -1 |
src/extra/setuid.c | +3 | -1 |
src/include/slicd/err.h | +1 | -1 |
src/libslicd/errmsg.c | +1 | -1 |
src/libslicd/slicd_save.c | +1 | -1 |
src/slicd/slicd-exec.c | +20 | -19 |
src/slicd/slicd-sched.c | +1 | -1 |
diff --git a/meta/desc b/meta/desc new file mode 100644 index 0000000..d510a80 --- /dev/null +++ b/meta/desc @@ -0,0 +1 @@ +simple lightweight Linux cron daemon diff --git a/src/extra/miniexec.c b/src/extra/miniexec.c index 5b1a841..5dff3f7 100644 --- a/src/extra/miniexec.c +++ b/src/extra/miniexec.c @@ -25,6 +25,7 @@ #include <getopt.h> #include <skalibs/djbunix.h> #include <skalibs/bytestr.h> +#include <skalibs/exec.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/strerr2.h> @@ -197,6 +198,6 @@ main (int argc, char * const argv[]) stralloc_shrink (&sa); } - pathexec ((char const * const *) ga.s); + mexec ((char const * const *) ga.s); strerr_dieexec (RC_IO, genalloc_s (char *, &ga)[0]); } diff --git a/src/extra/setuid.c b/src/extra/setuid.c index a76dc71..8ca0011 100644 --- a/src/extra/setuid.c +++ b/src/extra/setuid.c @@ -33,6 +33,7 @@ #include <unistd.h> #include <skalibs/djbunix.h> #include <skalibs/bytestr.h> +#include <skalibs/exec.h> #include <skalibs/strerr2.h> #include <slicd/die.h> @@ -125,6 +126,7 @@ main (int argc, char * const argv[]) if (setuid (pw->pw_uid) < 0) strerr_diefu1sys (RC_OTHER, "setuid"); - pathexec ((char const * const *) ++argv); + ++argv; + mexec ((char const * const *) argv); strerr_dieexec (RC_IO, argv[0]); } diff --git a/src/include/slicd/err.h b/src/include/slicd/err.h index d7e246b..212f6cd 100644 --- a/src/include/slicd/err.h +++ b/src/include/slicd/err.h @@ -41,6 +41,6 @@ enum _SLICD_NB_ERR }; -extern const char const *slicd_errmsg[_SLICD_NB_ERR]; +extern const char * const slicd_errmsg[_SLICD_NB_ERR]; #endif /* SLICD_ERR_H */ diff --git a/src/libslicd/errmsg.c b/src/libslicd/errmsg.c index b087aa3..e492796 100644 --- a/src/libslicd/errmsg.c +++ b/src/libslicd/errmsg.c @@ -22,7 +22,7 @@ #include <slicd/err.h> -const char const *slicd_errmsg[_SLICD_NB_ERR] = { +const char * const slicd_errmsg[_SLICD_NB_ERR] = { "", "I/O error", "Memory error", diff --git a/src/libslicd/slicd_save.c b/src/libslicd/slicd_save.c index 0906011..e968491 100644 --- a/src/libslicd/slicd_save.c +++ b/src/libslicd/slicd_save.c @@ -39,7 +39,7 @@ slicd_save (slicd_t *slicd, const char *file) if (fd < 0) return -SLICD_ERR_IO; - uint32_pack (buf, (uint32) slicd->str.len); + uint32_pack (buf, (uint32_t) slicd->str.len); iov[0].iov_base = buf; iov[0].iov_len = 4; iov[1].iov_base = slicd->str.s; diff --git a/src/slicd/slicd-exec.c b/src/slicd/slicd-exec.c index b449443..53cc801 100644 --- a/src/slicd/slicd-exec.c +++ b/src/slicd/slicd-exec.c @@ -30,6 +30,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/buffer.h> +#include <skalibs/exec.h> #include <skalibs/iopause.h> #include <skalibs/selfpipe.h> #include <skalibs/tai.h> @@ -152,9 +153,9 @@ close_fd (int fd) if (i == (size_t) -1) { char buf[UINT32_FMT]; - uint32 u; + uint32_t u; - u = (uint32) fd; + u = (uint32_t) fd; buf[uint32_fmt (buf, u)] = '\0'; strerr_warnwu2x ("to find child for fd#", buf); return; @@ -180,7 +181,7 @@ static void new_child (char *line, size_t len) { char buf[UINT32_FMT]; - uint32 u; + uint32_t u; int p_int[2]; int p_out[2]; int p_err[2]; @@ -306,7 +307,7 @@ new_child (char *line, size_t len) fd_close (2); if (fd_move2 (1, p_out[1], 2, p_err[1]) < 0) { - u = (uint32) errno; + u = (uint32_t) errno; fd_write (p_int[1], "p", 1); uint32_pack (buf, u); fd_write (p_int[1], buf, 4); @@ -314,9 +315,9 @@ new_child (char *line, size_t len) strerr_diefu1sys (RC_IO, "set up pipes"); } - pathexec ((char const * const *) argv); + mexec ((char const * const *) argv); /* if it fails... */ - u = (uint32) errno; + u = (uint32_t) errno; fd_write (p_int[1], "e", 1); uint32_pack (buf, u); fd_write (p_int[1], buf, 4); @@ -343,7 +344,7 @@ new_child (char *line, size_t len) } buffer_putsnoflush (buffer_1small, "Forked PID#"); - u = (uint32) pid; + u = (uint32_t) pid; buf[uint32_fmt (buf, u)] = '\0'; buffer_putsnoflush (buffer_1small, buf); buffer_putsnoflush (buffer_1small, " for job '"); @@ -361,7 +362,7 @@ new_child (char *line, size_t len) case 1: /* child failed to exec */ { char b[4]; - uint32 e = 0; + uint32_t e = 0; if (fd_read (p_int[0], b, 4) == 4) uint32_unpack (b, &e); @@ -390,9 +391,9 @@ process_line (size_t i_c, int fd, char *line, size_t len) { struct child *child = &genalloc_s (struct child, &ga_child)[i_c]; char buf[UINT32_FMT]; - uint32 u; + uint32_t u; - u = (uint32) child->pid; + u = (uint32_t) child->pid; buf[uint32_fmt (buf, u)] = '\0'; buffer_putsnoflush (buffer_1small, "PID#"); @@ -420,9 +421,9 @@ handle_fd (int fd, int all) if (i_c == (size_t) -1) { char buf[UINT32_FMT]; - uint32 u; + uint32_t u; - u = (uint32) fd; + u = (uint32_t) fd; buf[uint32_fmt (buf, u)] = '\0'; strerr_warnwu3x ("to find child for fd#", buf, "; closing"); @@ -447,13 +448,13 @@ handle_fd (int fd, int all) if (errno != EPIPE) { char buf[UINT32_FMT]; - uint32 u; + uint32_t u; int e = errno; close_fd (fd); errno = e; - u = (uint32) fd; + u = (uint32_t) fd; buf[uint32_fmt (buf, u)] = '\0'; if (fd == 0) strerr_warnwu1sys ("read from stdin"); @@ -461,9 +462,9 @@ handle_fd (int fd, int all) { struct child *child = &genalloc_s (struct child, &ga_child)[i_c]; char buf[UINT32_FMT]; - uint32 u; + uint32_t u; - u = (uint32) child->pid; + u = (uint32_t) child->pid; buf[uint32_fmt (buf, u)] = '\0'; strerr_warnwu4sys ("read from ", (fd == child->fd_out) ? "stdout" : "stderr", @@ -510,7 +511,7 @@ handle_sigchld (void) { struct child *child; char buf[20 + UINT32_FMT]; - uint32 u; + uint32_t u; int wstat; pid_t pid; size_t i; @@ -525,7 +526,7 @@ handle_sigchld (void) else if (pid == 0) break; - u = (uint32) pid; + u = (uint32_t) pid; buf[20 + uint32_fmt (buf + 20, u)] = '\0'; for (i = 0; i < genalloc_len (struct child, &ga_child); ++i) @@ -549,7 +550,7 @@ handle_sigchld (void) if (WIFEXITED (wstat)) { byte_copy (buf, 9, "exitcode "); - buf[9 + uint32_fmt (buf + 9, (uint32) WEXITSTATUS (wstat))] = '\0'; + buf[9 + uint32_fmt (buf + 9, (uint32_t) WEXITSTATUS (wstat))] = '\0'; } else { diff --git a/src/slicd/slicd-sched.c b/src/slicd/slicd-sched.c index 7e0f67b..9c19835 100644 --- a/src/slicd/slicd-sched.c +++ b/src/slicd/slicd-sched.c @@ -89,7 +89,7 @@ handle_signals (const char *file) { slicd_free (&slicd); byte_copy (&slicd, sizeof (slicd), &new); - strerr_warn3x ("Compiled crontabs reloaded from '", file, "'"); + strerr_warn ("Compiled crontabs reloaded from '", file, "'"); return DO_RELOAD; } }