summaryrefslogtreecommitdiffstats
path: root/src/external/samba.m4
blob: f54e8c1a8179ec0970e12bf8ae493d3651e86cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
AC_SUBST(NDR_NBT_CFLAGS)
AC_SUBST(NDR_NBT_LIBS)
AC_SUBST(SMBCLIENT_CFLAGS)
AC_SUBST(SMBCLIENT_LIBS)
AC_SUBST(NDR_KRB5PAC_CFLAGS)
AC_SUBST(NDR_KRB5PAC_LIBS)
AC_SUBST(IDMAP_SAMBA_LIBS)

if test x"$with_samba" = xyes; then
    PKG_CHECK_MODULES(NDR_NBT, ndr_nbt, ,
        AC_MSG_ERROR([[Please install Samba 4 NDR NBT development libraries.
Samba 4 libraries are necessary for building ad and ipa provider.
If you do not want to build these providers it is possible to build SSSD
without them. In this case, you will need to execute configure script
with argument --without-samba
    ]]))

    PKG_CHECK_MODULES(NDR_KRB5PAC, ndr_krb5pac, ,
        AC_MSG_ERROR([[Please install Samba 4 NDR KRB5PAC development libraries.
Samba 4 libraries are necessary for building ad and ipa provider.
If you do not want to build these providers it is possible to build SSSD
without them. In this case, you will need to execute configure script
with argument --without-samba
    ]]))

    PKG_CHECK_MODULES(SMBCLIENT, smbclient, ,
        AC_MSG_ERROR([[Please install libsmbclient development libraries.
libsmbclient libraries are necessary for building ad and ipa provider.
If you do not want to build these providers it is possible to build SSSD
without them. In this case, you will need to execute configure script
with argument --without-samba
    ]]))

    PKG_CHECK_MODULES(SAMBA_UTIL, samba-util, ,
        AC_MSG_ERROR([[Please install libsamba-util development libraries.
libsamba-util libraries are necessary for building ad and ipa provider.
If you do not want to build these providers it is possible to build SSSD
without them. In this case, you will need to execute configure script
with argument --without-samba
    ]]))

    if test x"$HAVE_LIBINI_CONFIG_V1_1" != x1; then
        AC_MSG_ERROR([[Please install libini_config development libraries
v1.1.0, or newer. libini_config libraries are necessary for building ipa
provider, as well as for building gpo-based access control in ad provider. If
you do not want to build these providers it is possible to build SSSD without
them. In this case, you will need to execute configure script with argument
--without-samba
        ]])
    fi

    AC_ARG_WITH([smb-idmap-interface-version],
                [AC_HELP_STRING([--with-smb-idmap-interface-version=[5|6]],
                                [Idmap interface version of installed Samba]
                               )
                ]
               )

    if test x"$with_smb_idmap_interface_version" != x; then
        if test x"$with_smb_idmap_interface_version" = x5 -o x"$with_smb_idmap_interface_version" = x6; then
            idmap_test_result=$with_smb_idmap_interface_version
        else
            AC_MSG_ERROR([Illegal value -$with_smb_idmap_interface_version- for option --with-smb-idmap-interface-version])
        fi
    else
        sambalibdir="`$PKG_CONFIG --variable=libdir smbclient`"/samba
        AC_MSG_CHECKING([Samba's idmap library])
        if test -f "${sambalibdir}/libidmap-private-samba.so"; then
                IDMAP_SAMBA_LIBS=idmap-private-samba
        elif test -f "${sambalibdir}/libidmap-samba4.so"; then
                IDMAP_SAMBA_LIBS=idmap-samba4
        else
                AC_MSG_ERROR([Cannot find private idmap-samba library])
        fi
        AC_MSG_RESULT([found: $IDMAP_SAMBA_LIBS])
        AC_MSG_CHECKING([Samba's idmap plugin interface version])
        SAVE_CFLAGS=$CFLAGS
        SAVE_LIBS=$LIBS
        CFLAGS="$CFLAGS $SMBCLIENT_CFLAGS $NDR_NBT_CFLAGS $NDR_KRB5PAC_CFLAGS"
        LIBS="$LIBS -L${sambalibdir} -l${IDMAP_SAMBA_LIBS} -Wl,-rpath ${sambalibdir}"
        AC_RUN_IFELSE(
            [AC_LANG_SOURCE([
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <tevent.h>
#include <core/ntstatus.h>

struct winbindd_domain;

/* overwrite some winbind internal functions */
struct winbindd_domain *find_domain_from_name(const char *domain_name)
{
    return NULL;
}

bool get_global_winbindd_state_offline(void) {
    return false;
}

struct tevent_context *winbind_event_context(void)
{
    return NULL;
}

struct idmap_methods;

NTSTATUS smb_register_idmap(int version, const char *name, struct idmap_methods *methods);

int main(void)
{
    int v;
    NTSTATUS ret;

    /* Check the versions we know about */
    for (v = 5; v <= 6; v++) {
        ret = smb_register_idmap(v, NULL, NULL);
        if (!NT_STATUS_EQUAL(ret, NT_STATUS_OBJECT_TYPE_MISMATCH)) {
            return v;
        }
    }

    return -1;
}])],
            [AC_MSG_ERROR([idmap version test program is not expected to return 0])],
            [idmap_test_result=$?; AC_MSG_RESULT([idmap test result is: $idmap_test_result])]
        )
    fi

    CFLAGS=$SAVE_CFLAGS
    LIBS=$SAVE_LIBS

    if test $idmap_test_result -eq 5 -o $idmap_test_result -eq 6 ; then
        idmap_version=$idmap_test_result
    else
        AC_MSG_ERROR([Cannot determine Samba's idmap interface version, please use --with-smb-idmap-interface-version])
    fi
    AC_MSG_NOTICE([Samba's idmap interface version: $idmap_version])
    AC_DEFINE_UNQUOTED(SMB_IDMAP_INTERFACE_VERSION, $idmap_version,
                       [Detected version of Samba's idmap plugin interface])

    samba_major_version=`printf '#include <samba/version.h>\nSAMBA_VERSION_MAJOR' | $CPP $SMBCLIENT_CFLAGS -P -`
    samba_minor_version=`printf '#include <samba/version.h>\nSAMBA_VERSION_MINOR' | $CPP $SMBCLIENT_CFLAGS -P -`
    samba_release_version=`printf '#include <samba/version.h>\nSAMBA_VERSION_RELEASE' | $CPP $SMBCLIENT_CFLAGS -P -`
    AC_MSG_NOTICE([Samba version: $samba_major_version $samba_minor_version $samba_release_version])
    if ([[ $samba_major_version -gt 4 ]]) ||
       ([[ $samba_major_version -eq 4 ]] && [[ $samba_minor_version -ge 8 ]]) ||
       ([[ $samba_major_version -eq 4 ]] && [[ $samba_minor_version -eq 7 ]] && [[ $samba_release_version -ge 4 ]]); then
        AC_DEFINE_UNQUOTED(SMB_IDMAP_DOMAIN_HAS_DOM_SID, 1,
                           [Samba's struct idmap_domain has dom_sid member])
        AC_MSG_NOTICE([Samba's struct idmap_domain has dom_sid member])
    else
        AC_MSG_NOTICE([Samba's struct idmap_domain does not have dom_sid member])
    fi

    if ([[ $samba_major_version -gt 4 ]]) ||
       ([[ $samba_major_version -eq 4 ]] && [[ $samba_minor_version -ge 12 ]]); then
        AC_DEFINE_UNQUOTED(SMB_HAS_NEW_NDR_PULL_STEAL_SWITCH, 1,
                           [Samba's new push/pull switch functions])
        AC_MSG_NOTICE([Samba has support for new ndr_push_steal_switch_value and ndr_pull_steal_switch_value functions])
    else
        AC_MSG_NOTICE([Samba supports old ndr_pull_steal_switch_value and ndr_pull_steal_switch_value functions])
    fi
fi

SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $SMBCLIENT_CFLAGS $NDR_NBT_CFLAGS $NDR_KRB5PAC_CFLAGS"
AC_CHECK_MEMBERS([struct PAC_LOGON_INFO.resource_groups], , ,
                 [[ #include <ndr.h>
                    #include <gen_ndr/krb5pac.h>
                    #include <gen_ndr/krb5pac.h>]])
AC_CHECK_MEMBERS([struct PAC_UPN_DNS_INFO.ex], ,
                 [AC_MSG_NOTICE([union PAC_UPN_DNS_INFO_EX is not available, PAC checks will be limited])],
                 [[ #include <ndr.h>
                    #include <gen_ndr/krb5pac.h>
                    #include <gen_ndr/krb5pac.h>]])
CFLAGS=$SAVE_CFLAGS