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

Add FreeBSD support, round 1 #7765

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/confdb/confdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "config.h"

Check warning on line 22 in src/confdb/confdb.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "config.h" not found.

#ifdef __FreeBSD__
#include <sys/param.h>

Check warning on line 25 in src/confdb/confdb.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/param.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif // __FreeBSD__
#include <ctype.h>

Check warning on line 27 in src/confdb/confdb.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include "sbus/sbus_opath.h"

Check warning on line 28 in src/confdb/confdb.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "sbus/sbus_opath.h" not found.
#include "util/util.h"

Check warning on line 29 in src/confdb/confdb.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "util/util.h" not found.
#include "confdb/confdb.h"
#include "confdb/confdb_private.h"
#include "util/strtonum.h"
Expand Down
18 changes: 15 additions & 3 deletions src/external/platform.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_ARG_WITH([os],
[AC_HELP_STRING([--with-os=OS_TYPE], [Type of your operation system (unknown|fedora|redhat|suse|debian|gentoo)])]
[AC_HELP_STRING([--with-os=OS_TYPE], [Type of your operation system (unknown|fedora|freebsd|redhat|suse|gentoo)])]
)
osname=""
if test x"$with_os" != x ; then
Expand All @@ -21,6 +21,8 @@ if test x"$osname" = x ; then
. /etc/os-release
if ([[ "${ID}" = "suse" ]]) || ([[ "${ID_LIKE#*suse*}" != "${ID_LIKE}" ]]); then
osname="suse"
elif ([[ "${ID}" = "freebsd" ]]) || ([[ "${ID_LIKE#*freebsd*}" != "${ID_LIKE}" ]]); then
osname="freebsd"
fi
else
osname="unknown"
Expand All @@ -30,6 +32,7 @@ if test x"$osname" = x ; then
fi

AM_CONDITIONAL([HAVE_FEDORA], [test x"$osname" = xfedora])
AM_CONDITIONAL([HAVE_FREEBSD], [test x"$osname" = xfreebsd])
AM_CONDITIONAL([HAVE_REDHAT], [test x"$osname" = xredhat])
AM_CONDITIONAL([HAVE_SUSE], [test x"$osname" = xsuse])
AM_CONDITIONAL([HAVE_DEBIAN], [test x"$osname" = xdebian])
Expand All @@ -38,13 +41,22 @@ AM_CONDITIONAL([HAVE_GENTOO], [test x"$osname" = xgentoo])
AS_CASE([$osname],
[redhat], [AC_DEFINE_UNQUOTED([HAVE_REDHAT], 1, [Build with redhat config])],
[fedora], [AC_DEFINE_UNQUOTED([HAVE_FEDORA], 1, [Build with fedora config])],
[freebsd], [AC_DEFINE_UNQUOTED([HAVE_FREEBSD], 1, [Build with freebsd config])],
[suse], [AC_DEFINE_UNQUOTED([HAVE_SUSE], 1, [Build with suse config])],
[gentoo], [AC_DEFINE_UNQUOTED([HAVE_GENTOO], 1, [Build with gentoo config])],
[debian], [AC_DEFINE_UNQUOTED([HAVE_DEBIAN], 1, [Build with debian config])],
[AC_MSG_NOTICE([Build with $osname config])])

AC_CHECK_MEMBERS([struct ucred.pid, struct ucred.uid, struct ucred.gid], , ,
[[#include <sys/socket.h>]])
if test x"$osname" = x"freebsd"; then
AC_CHECK_MEMBERS([struct xucred.cr_pid, struct xucred.cr_uid, struct xucred.cr_gid], , , [[
#include <sys/param.h>
#include <sys/ucred.h>
]])
else
AC_CHECK_MEMBERS([struct ucred.pid, struct ucred.uid, struct ucred.gid], , ,
[[#include <sys/socket.h>]])
fi


if test x"$ac_cv_member_struct_ucred_pid" = xyes -a \
x"$ac_cv_member_struct_ucred_uid" = xyes -a \
Expand Down
3 changes: 3 additions & 0 deletions src/krb5_plugin/common/radius_kdcpreauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef __FreeBSD__
#include <sys/param.h>

Check warning on line 22 in src/krb5_plugin/common/radius_kdcpreauth.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/param.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif // __FreeBSD__
#include <errno.h>

Check warning on line 24 in src/krb5_plugin/common/radius_kdcpreauth.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <stdbool.h>

Check warning on line 25 in src/krb5_plugin/common/radius_kdcpreauth.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <stdbool.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <stdlib.h>

Check warning on line 26 in src/krb5_plugin/common/radius_kdcpreauth.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <string.h>
#include <limits.h>
#include <krad.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/certmap/sss_certmap.exports
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ SSS_CERTMAP_0.0 {
global:
sss_certmap_init;
sss_certmap_free_ctx;
sss_certmap_err_msg;
sss_certmap_add_rule;
sss_certmap_match_cert;
sss_certmap_get_search_filter;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/winbind_idmap_sss/winbind_idmap_sss.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sys/types.h>

Check warning on line 25 in src/lib/winbind_idmap_sss/winbind_idmap_sss.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <sys/time.h>
#include <string.h>
#include <errno.h>

Expand Down
2 changes: 2 additions & 0 deletions src/lib/winbind_idmap_sss/winbind_idmap_sss.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <stdbool.h>

#include <core/ntstatus.h>
#include <unistd.h>
#include <time.h>
#include <ndr.h>
#include <gen_ndr/security.h>

Expand Down
2 changes: 2 additions & 0 deletions src/p11_child/p11_child_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include <stdlib.h>
#include <string.h>
#include <popt.h>
#ifndef __FreeBSD__
#include <sys/prctl.h>
#endif // __FreeBSD__

#include "util/util.h"
#include "util/child_common.h"
Expand Down
4 changes: 4 additions & 0 deletions src/passkey_child/passkey_child_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
*/

#include <popt.h>
#ifndef __FreeBSD__
#include <sys/prctl.h>
#endif // __FreeBSD__
#include <fido/param.h>
#include <openssl/err.h>
#include <openssl/pem.h>
Expand Down Expand Up @@ -276,7 +278,9 @@ parse_arguments(TALLOC_CTX *mem_ctx, int argc, const char *argv[],

poptFreeContext(pc);

#ifndef __FreeBSD__
prctl(PR_SET_DUMPABLE, (dumpable == 0) ? 0 : 1);
#endif // __FreeBSD__

if (user_verification != NULL) {
if (strcmp(user_verification, "true") == 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ad/ad_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <ctype.h>

#include "providers/ad/ad_common.h"
Expand Down
4 changes: 4 additions & 0 deletions src/providers/ad/ad_gpo_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <ctype.h>
#include <unistd.h>
#include <popt.h>
#ifndef __FreeBSD__
#include <sys/prctl.h>
#endif // __FreeBSD__
#include <libsmbclient.h>
#include <security/pam_modules.h>

Expand Down Expand Up @@ -705,7 +707,9 @@ main(int argc, const char *argv[])

poptFreeContext(pc);

#ifndef __FreeBSD__
prctl(PR_SET_DUMPABLE, (dumpable == 0) ? 0 : 1);
#endif // __FreeBSD__

debug_prg_name = talloc_asprintf(NULL, "gpo_child[%d]", getpid());
if (debug_prg_name == NULL) {
Expand Down
2 changes: 2 additions & 0 deletions src/providers/ad/ad_pac.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#ifdef ldb_val
#error Please make sure to include ad_pac.h before ldb.h
#endif
#include <unistd.h>
#include <time.h>
#include <ndr.h>
#include <gen_ndr/krb5pac.h>
#include <gen_ndr/ndr_krb5pac.h>
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ad/ad_pac_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/


#include <sys/types.h>
#include <sys/time.h>

#include "providers/ad/ad_pac.h"
#include "util/util.h"

Expand Down
3 changes: 3 additions & 0 deletions src/providers/data_provider/dp_modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "providers/data_provider/dp.h"
#include "providers/data_provider/dp_private.h"
#include "providers/backend.h"
#ifdef __FreeBSD__
#include "util/sss_bsd_errno.h"
#endif // __FreeBSD__
#include "util/util.h"

/* There can be at most the same number of different modules loaded at
Expand Down
3 changes: 3 additions & 0 deletions src/providers/data_provider/dp_targets.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "providers/data_provider/dp_private.h"
#include "providers/data_provider/dp_builtin.h"
#include "providers/backend.h"
#ifdef __FreeBSD__
#include "util/sss_bsd_errno.h"
#endif // __FreeBSD__
#include "util/util.h"

#define DP_TARGET_INIT_FN "sssm_%s_%s_init"
Expand Down
2 changes: 2 additions & 0 deletions src/providers/data_provider_be.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/un.h>
#include <string.h>
#include <sys/time.h>
Expand Down
3 changes: 3 additions & 0 deletions src/providers/data_provider_fo.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <netdb.h>
#include <arpa/inet.h>
#include "providers/backend.h"
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ipa/ipa_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <netdb.h>
#include <ctype.h>
#include <arpa/inet.h>
Expand Down
2 changes: 2 additions & 0 deletions src/providers/ipa/ipa_deskprofile_rules_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "providers/ipa/ipa_deskprofile_rules_util.h"
#include "providers/ipa/ipa_deskprofile_private.h"
#include "providers/ipa/ipa_rules_common.h"
#include <sys/types.h>
#include <signal.h>
#include <ctype.h>
#include <fcntl.h>

Expand Down
2 changes: 2 additions & 0 deletions src/providers/krb5/krb5_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
#include <fcntl.h>
#include <ctype.h>
#include <popt.h>
#ifndef __FreeBSD__
#include <sys/prctl.h>
#endif // __FreeBSD__

#include <security/pam_modules.h>

Expand Down
26 changes: 26 additions & 0 deletions src/providers/ldap/ldap_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
#include <sys/time.h>
#include <strings.h>

#ifndef __FreeBSD__
#include <shadow.h>
#endif // __FreeBSD__
#include <security/pam_modules.h>

#include "util/util.h"
Expand All @@ -51,6 +53,24 @@

#define LDAP_PWEXPIRE_WARNING_TIME 0

#ifdef __FreeBSD__
struct spwd
{
char *sp_namp; /* Login name. */
char *sp_pwdp; /* Encrypted password. */
long int sp_lstchg; /* Date of last change. */
long int sp_min; /* Minimum number of days between changes. */
long int sp_max; /* Maximum number of days between changes. */
long int sp_warn; /* Number of days to warn user to change
the password. */
long int sp_inact; /* Number of days the account may be
inactive. */
long int sp_expire; /* Number of days since 1970-01-01 until
account expires. */
unsigned long int sp_flag; /* Reserved. */
};
#endif // __FreeBSD__

static errno_t add_expired_warning(struct pam_data *pd, long exp_time)
{
int ret;
Expand Down Expand Up @@ -96,9 +116,15 @@ static errno_t check_pwexpire_kerberos(const char *expire_date, time_t now,
}

DEBUG(SSSDBG_TRACE_ALL,
#ifdef __FreeBSD__
"Time info: tzname[0] [%s] tzname[1] [%s] "
"now [%"SPRItime"] expire_time [%"SPRItime"].\n",
tzname[0], tzname[1], now, expire_time);
#else // __FreeBSD__
"Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] "
"daylight [%d] now [%"SPRItime"] expire_time [%"SPRItime"].\n",
tzname[0], tzname[1], timezone, daylight, now, expire_time);
#endif // __FreeBSD__

if (expire_time == 0) {
/* Used by the MIT LDAP KDB plugin to indicate "never" */
Expand Down
5 changes: 5 additions & 0 deletions src/providers/ldap/ldap_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
*/

#include <sys/types.h>
#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <unistd.h>
#include <ctype.h>
#include <sys/stat.h>
#include <signal.h>
#include <popt.h>
#ifndef __FreeBSD__
#include <sys/prctl.h>
#endif // __FreeBSD__

#include "util/util.h"
#include "util/sss_krb5.h"
Expand Down
9 changes: 9 additions & 0 deletions src/providers/ldap/sdap_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "config.h"

#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <time.h>
#include <security/pam_modules.h>
#include <talloc.h>
Expand Down Expand Up @@ -568,9 +571,15 @@ bool nds_check_expired(const char *exp_time_str)

now = time(NULL);
DEBUG(SSSDBG_TRACE_ALL,
#ifdef __FreeBSD__
"Time info: tzname[0] [%s] tzname[1] [%s] "
"now [%"SPRItime"] expire_time [%"SPRItime"].\n",
tzname[0], tzname[1], now, expire_time);
#else // __FreeBSD__
"Time info: tzname[0] [%s] tzname[1] [%s] timezone [%ld] "
"daylight [%d] now [%"SPRItime"] expire_time [%"SPRItime"].\n",
tzname[0], tzname[1], timezone, daylight, now, expire_time);
#endif // __FreeBSD__

if (difftime(now, expire_time) > 0.0) {
DEBUG(SSSDBG_CONF_SETTINGS, "NDS account expired.\n");
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ldap/sdap_async_sudo_hostinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <errno.h>
#include <tevent.h>
#include <talloc.h>
Expand Down
14 changes: 14 additions & 0 deletions src/providers/proxy/proxy_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#ifdef __FreeBSD__
#include <stdlib.h>
#endif // __FreeBSD__
#include <string.h>
#include <sys/time.h>
#include <errno.h>
Expand Down Expand Up @@ -456,6 +459,17 @@ int proxy_child_process_init(TALLOC_CTX *mem_ctx, const char *domain,
return EOK;
}

#if (defined(__FreeBSD__) && (__FreeBSD__ < 14))
extern char **environ;

static int
clearenv(void)
{
*environ = NULL;
return 0;
}
#endif

int main(int argc, const char *argv[])
{
int opt;
Expand Down
3 changes: 3 additions & 0 deletions src/resolv/async_resolv_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef __FreeBSD__
#include <sys/param.h>
#endif // __FreeBSD__
#include <string.h>
#include <talloc.h>
#include <tevent.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <talloc.h>
#include <ldb.h>
#include <arpa/inet.h>
#ifdef __FreeBSD__
#include <sys/socket.h>
#endif // __FreeBSD__

#include "db/sysdb.h"
#include "db/sysdb_iphosts.h"
Expand Down
Loading
Loading