Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Fix build on FreeBSD 12 (latest patch level) #93

Open
bsdtrhodes opened this issue Sep 8, 2020 · 0 comments
Open

[PATCH] Fix build on FreeBSD 12 (latest patch level) #93

bsdtrhodes opened this issue Sep 8, 2020 · 0 comments

Comments

@bsdtrhodes
Copy link

bsdtrhodes commented Sep 8, 2020

This patch should cleanly apply to the checkout directory. Next up, I'll look at launchd and/or libdispatch, but we'll see how much work they need. Also, I don't now why these "no new lines at end of file" appear, seems to be specific to git, at least on my system. Thoughts? Also, looks like the patch blows up in the paste - I'm new to github, if you want a diff emailed, let me know.

diff --git a/event_loop.c b/event_loop.c
index 95e6346..8e725c2 100644
--- a/event_loop.c
+++ b/event_loop.c
@@ -18,6 +18,12 @@
 #include <errno.h>
 #include <unistd.h>

+#ifdef __FreeBSD__
+#include <sys/signal.h>
+#include <signal.h>
+#include <fcntl.h>
+#endif
+
 #ifdef __linux__
 #include <sys/epoll.h>
 #include <sys/prctl.h>
@@ -147,7 +153,11 @@ register_signal_handlers(void)
 #else
     struct kevent kev;

-    for (sh = &signal_handlers[0]; sh->signum; sh++) {
+#ifdef __FreeBSD__
+    for (sh = &elopt.signal_handlers[0]; sh->signum; sh++) {
+#else
+    for (sh = &elopt.signal_handlers[0]; sh->signum; sh++) { */
+#endif
         if (signal(sh->signum, (sh->signum == SIGCHLD ? SIG_DFL : SIG_IGN)) == SIG_ERR)
             return printlog(LOG_ERR, "signal(2): %d: %s", sh->signum, strerror(errno));

@@ -229,4 +239,4 @@ dispatch_event(void)
             (*cb)(&ev);
         }
     }
-}
\ No newline at end of file
+}
diff --git a/job.c b/job.c
index b8a99d9..e014552 100644
--- a/job.c
+++ b/job.c
@@ -152,7 +152,11 @@ _job_child_pre_exec(struct child_context *ctx)
             return printlog(LOG_ERR, "setgid(2): %s", strerror(errno));
 #ifndef __GLIBC__
         /* KLUDGE: above is actually a test for BSD */
-        if (setlogin(user_name) < 0) {
+#ifdef __FreeBSD__
+        if (setlogin(ctx->user_name) < 0) {
+#else
+       if (setlogin(user_name) < 0) {
+#endif /* FreeBSD */
             printlog(LOG_ERR, "setlogin(2): %s", strerror(errno));
             exit(EXIT_FAILURE);
         }
@@ -799,4 +803,4 @@ int job_get_id(int64_t *jid, const char *label)
 const char *job_get_label(const struct job *job)
 {
     return job->id;
-}
\ No newline at end of file
+}
diff --git a/logger.h b/logger.h
index 8528e31..c0468cd 100644
--- a/logger.h
+++ b/logger.h
@@ -37,6 +37,10 @@ void logger_shutdown(void);
 int logger_open(const char *);
 int __attribute__((format(printf, 2, 3))) logger_append(int level, const char *format, ...);
 void logger_set_verbose(int);
+#ifdef __FreeBSD__
+int logger_redirect_file_descriptor(int oldfd, const char *path, int flags, __mode_t mode);
+#else
 int logger_redirect_file_descriptor(int oldfd, const char *path, int flags, mode_t mode);
+#endif

 #endif /* _LOGGER_H */
diff --git a/parser.c b/parser.c
index 52b9b12..0114c95 100644
--- a/parser.c
+++ b/parser.c
@@ -25,6 +25,10 @@
 #include <unistd.h>
 #include <sys/stat.h>

+#ifdef __FreeBSD__
+#include <sys/syslimits.h>
+#endif
+
 #include "config.h"
 #include "database.h"
 #include "logger.h"
@@ -719,4 +723,4 @@ parser_import(const char *path)
         (void) db_exec(dbh, "ROLLBACK");
         return -1;
     }
-}
\ No newline at end of file
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant