Merge branch 'upstream'
Timo Aaltonen
4 years ago
0 | VERSION != grep AC_INIT configure.ac|cut -d, -f2|tr -d ")" | |
1 | outdir=. | |
2 | SUDO= | |
3 | ||
4 | srpm: | |
5 | $(SUDO) dnf -y install rpm-build autoconf automake libtool \ | |
6 | /usr/bin/rpcgen 389-ds-base-devel libnsl2-devel \ | |
7 | libsss_nss_idmap-devel nspr-devel nss-devel \ | |
8 | openldap-devel pam-devel ; \ | |
9 | ./autogen.sh; \ | |
10 | ./configure; \ | |
11 | tmpdir=`mktemp -d /tmp/make_archive_XXXXXX`;\ | |
12 | make dist;\ | |
13 | mv slapi-nis-$(VERSION).tar.gz $$tmpdir; \ | |
14 | touch $$tmpdir/slapi-nis-$(VERSION).tar.gz.sig;\ | |
15 | rpmbuild \ | |
16 | --define "_topdir $$tmpdir" \ | |
17 | --define "_sourcedir $$tmpdir" \ | |
18 | --define "_specdir $$tmpdir" \ | |
19 | --define "_builddir $$tmpdir" \ | |
20 | --define "_srcrpmdir $$tmpdir" \ | |
21 | --define "_rpmdir $$tmpdir" \ | |
22 | --build-in-place \ | |
23 | -ts $$tmpdir/slapi-nis-$(VERSION).tar.gz;\ | |
24 | cp -v $$tmpdir/slapi-nis-$(VERSION)-*.src.rpm $(outdir)/; \ | |
25 | rm -rf $$tmpdir |
0 | 0.56.3 * Bug 1694263: On some 'cn=config' updates bepost_op are not called | |
1 | that leads to lock leak | |
2 | * Bug 1435663: deadlock between write and search operation in | |
3 | schema-compat plugin | |
0 | 4 | 0.52 * Properly note in the nsslapd-pluginVersion attribute whether or |
1 | 5 | not transaction support is available. |
2 | 6 | * Fix a pair of incorrect memcpy()-instead-of-memmove() cases which |
0 | AC_INIT(slapi-nis,0.56.2) | |
0 | AC_INIT(slapi-nis,0.56.4) | |
1 | 1 | AC_CONFIG_MACRO_DIR([m4]) |
2 | 2 | AM_INIT_AUTOMAKE(foreign) |
3 | 3 | LT_INIT([disable-static]) |
272 | 272 | ]) |
273 | 273 | if test $use_tirpc = yes ; then |
274 | 274 | PKG_CHECK_MODULES(TIRPC,libtirpc) |
275 | fi | |
276 | ||
277 | PKG_CHECK_MODULES(NSL,libnsl,[use_libnsl=yes],[use_libnsl=no]) | |
278 | if test "$use_libnsl" = yes ; then | |
279 | RPC_CFLAGS="$NSL_CFLAGS" | |
280 | RPC_LIBS="$NSL_LIBS" | |
275 | 281 | else |
276 | 282 | RPC_CFLAGS= |
277 | 283 | RPC_LIBS=-lnsl |
9 | 9 | %endif |
10 | 10 | |
11 | 11 | Name: slapi-nis |
12 | Version: 0.56.2 | |
12 | Version: 0.56.4 | |
13 | 13 | Release: 1%{?dist} |
14 | 14 | Summary: NIS Server and Schema Compatibility plugins for Directory Server |
15 | Group: System Environment/Daemons | |
16 | 15 | License: GPLv2 |
17 | URL: http://slapi-nis.fedorahosted.org/ | |
18 | Source0: https://fedorahosted.org/releases/s/l/slapi-nis/slapi-nis-%{version}.tar.gz | |
19 | #Source1: https://fedorahosted.org/releases/s/l/slapi-nis/slapi-nis-%{version}.tar.gz.sig | |
20 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | |
16 | URL: http://pagure.io/slapi-nis/ | |
17 | Source0: https://releases.pagure.org/slapi-nis/slapi-nis-%{version}.tar.gz | |
18 | Source1: https://releases.pagure.org/slapi-nis/slapi-nis-%{version}.tar.gz.sig | |
19 | BuildRequires: autoconf | |
20 | BuildRequires: automake | |
21 | BuildRequires: libtool | |
21 | 22 | BuildRequires: 389-ds-base-devel >= 1.3.5.6, %{ldap_impl}-devel |
22 | 23 | BuildRequires: nspr-devel, nss-devel, /usr/bin/rpcgen |
23 | 24 | %if 0%{?fedora} > 18 || 0%{?rhel} > 6 |
27 | 28 | %define sss_nss_opts %{nil} |
28 | 29 | %endif |
29 | 30 | BuildRequires: pam-devel |
30 | %if 0%{?fedora} > 6 || 0%{?rhel} > 5 | |
31 | BuildRequires: tcp_wrappers-devel | |
32 | %else | |
33 | BuildRequires: tcp_wrappers | |
34 | %endif | |
35 | %if 0%{?fedora} > 14 || 0%{?rhel} > 6 | |
31 | %if (0%{?fedora} > 14 && 0%{?fedora} < 28) || (0%{?rhel} > 6 && 0%{?rhel} < 8) | |
36 | 32 | BuildRequires: libtirpc-devel |
37 | %endif | |
38 | %if 0%{?rhel} > 0 && 0%{?rhel} < 7 | |
39 | ExclusiveArch: x86_64 %{ix86} | |
33 | %else: | |
34 | BuildRequires: libnsl2-devel | |
35 | %endif | |
36 | %if 0%{?fedora} > 27 | |
37 | ExcludeArch: %{ix86} | |
40 | 38 | %endif |
41 | 39 | Requires: 389-ds-base >= 1.3.5.6 |
42 | 40 | |
57 | 55 | %setup -q |
58 | 56 | |
59 | 57 | %build |
60 | %configure --disable-static --with-tcp-wrappers --with-ldap=%{ldap_impl} \ | |
58 | autoconf --force | |
59 | %configure --disable-static --with-ldap=%{ldap_impl} \ | |
61 | 60 | --with-nsswitch --with-pam --with-pam-service=system-auth \ |
62 | 61 | %{sss_nss_opts} %{betxn_opts} |
63 | 62 | sed -i -e 's,%{_libdir}/dirsrv/plugins/,,g' -e 's,.so$,,g' doc/examples/*.ldif |
74 | 73 | make check |
75 | 74 | %endif |
76 | 75 | |
77 | %clean | |
78 | rm -rf $RPM_BUILD_ROOT | |
79 | ||
80 | 76 | %files |
81 | %defattr(-,root,root,-) | |
82 | 77 | %doc COPYING NEWS README STATUS doc/*.txt doc/examples/*.ldif doc/ipa |
83 | 78 | %{_mandir}/man1/* |
84 | 79 | %{_libdir}/dirsrv/plugins/*.so |
85 | 80 | %{_sbindir}/nisserver-plugin-defs |
86 | 81 | |
87 | 82 | %changelog |
83 | * Fri Feb 07 2020 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.4-1 | |
84 | - New upstream release | |
85 | - Fix build with newer gcc versions | |
86 | - Resolves rhbz#1800097 | |
87 | ||
88 | * Wed Jun 05 2019 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.3-1 | |
89 | - New upstream release | |
90 | ||
91 | * Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.56.2-8 | |
92 | - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild | |
93 | ||
94 | * Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.56.2-7 | |
95 | - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild | |
96 | ||
97 | * Wed May 02 2018 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.2-6 | |
98 | - Force rebuild of configure | |
99 | ||
100 | * Wed May 02 2018 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.2-5 | |
101 | - Link with libnsl explicitly in Fedora 28 or later | |
102 | - Require libnsl2-devel for build | |
103 | - Resolves rhbz#1573636 | |
104 | ||
105 | * Thu Mar 15 2018 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.2-4 | |
106 | - Remove tcpwrappers support as they aren't available in Fedora anymore | |
107 | ||
108 | * Thu Mar 15 2018 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.2-3 | |
109 | - Do not build on i686 in Fedora 28 or later as 389-ds-base is not available there anymore | |
110 | - Resolves rhbz#1556448 | |
111 | - Remove outdated ExclusiveArch for RHEL6 | |
112 | ||
113 | * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.56.2-2 | |
114 | - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild | |
115 | ||
88 | 116 | * Fri Jan 19 2018 Alexander Bokovoy <abokovoy@redhat.com> - 0.56.2-1 |
89 | 117 | - New upstream release |
118 | - Update links to the upstream project page and releases | |
90 | 119 | - Use extended SSSD API to signal that an entry should not be cached anymore |
91 | 120 | - Add support for timeout-based NSS queries with libsss_nss_idmap |
121 | ||
122 | * Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.56.1-4 | |
123 | - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild | |
124 | ||
125 | * Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.56.1-3 | |
126 | - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild | |
92 | 127 | |
93 | 128 | * Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.56.1-2 |
94 | 129 | - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild |
848 | 848 | request_set(state->request_info, RQ_DAEMON, |
849 | 849 | DEFAULT_TCPWRAP_NAME); |
850 | 850 | } |
851 | #else | |
852 | (void)tmp; | |
851 | 853 | #endif |
852 | 854 | use_be_txns = backend_shr_get_vattr_boolean(state, our_entry, |
853 | 855 | "nsslapd-pluginbetxn", |
55 | 55 | idview_get_overrides(struct backend_search_cbdata *cbdata) |
56 | 56 | { |
57 | 57 | char *dn = NULL; |
58 | int ret = 0, result = 0; | |
58 | int result = 0; | |
59 | 59 | const Slapi_DN *suffix = NULL; |
60 | 60 | Slapi_PBlock *pb; |
61 | 61 | |
75 | 75 | slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_SUBTREE, |
76 | 76 | "(objectclass=ipaOverrideAnchor)", NULL, 0, |
77 | 77 | NULL, NULL, cbdata->state->plugin_identity, 0); |
78 | ret = slapi_search_internal_pb(pb); | |
78 | slapi_search_internal_pb(pb); | |
79 | 79 | slapi_ch_free_string(&dn); |
80 | 80 | slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result); |
81 | 81 | |
179 | 179 | } |
180 | 180 | result = slapi_attr_get_valueset(override_attr, &override_valueset); |
181 | 181 | result = slapi_entry_add_valueset(entry, override_type, override_valueset); |
182 | slapi_valueset_free(override_valueset); | |
182 | 183 | } |
183 | 184 | result = slapi_entry_next_attr(override_entry, override_attr, &override_attr); |
184 | 185 | } |
286 | 287 | new_target = slapi_ch_smprintf("%s", cnviews+10); |
287 | 288 | } |
288 | 289 | cnviews[0] = ','; |
290 | slapi_ch_free_string(target); | |
289 | 291 | *target = new_target; |
290 | 292 | } |
291 | 293 | } |
410 | 412 | { |
411 | 413 | struct backend_search_filter_config config = |
412 | 414 | {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL, NULL, NULL}; |
413 | int res = 0; | |
414 | ||
415 | 415 | if (cbdata->idview == NULL) { |
416 | 416 | return; |
417 | 417 | } |
420 | 420 | config.callback_data = cbdata; |
421 | 421 | |
422 | 422 | /* Ignore the return code as it will always be SLAPI_FILTER_SCAN_NO_MORE */ |
423 | res = backend_analyze_search_filter(cbdata->filter, &config); | |
423 | (void)backend_analyze_search_filter(cbdata->filter, &config); | |
424 | 424 | |
425 | 425 | if (config.name != NULL) { |
426 | 426 | slapi_ch_free_string(&config.name); |
167 | 167 | } |
168 | 168 | } else { |
169 | 169 | if (rc == PAM_SUCCESS) { |
170 | *errmsg = PR_smprintf("PAM %s succeeds for user \"%s\" " | |
171 | "(bind DN \"%s\")", | |
172 | fn, user, binddn); | |
170 | *errmsg = PR_smprintf("PAM %s succeeds for bind DN \"%s\"", | |
171 | fn, binddn); | |
173 | 172 | } else { |
174 | 173 | if (pamh != NULL) { |
175 | 174 | *errmsg = PR_smprintf("PAM %s error for invalid user " |
53 | 53 | #include "plugin.h" |
54 | 54 | #include "map.h" |
55 | 55 | #include "back-sch.h" |
56 | ||
57 | /* | |
58 | * This is not a public function in 389-ds but we need to use it in backend_search_cb(), | |
59 | * see a comment there on the difference between slapi_send_ldap_result() and send_ldap_result(). | |
60 | */ | |
61 | extern void send_ldap_result(Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls); | |
56 | 62 | |
57 | 63 | static int backend_passwdmod_extop(Slapi_PBlock *pb); |
58 | 64 | backend_extop_handlers_t extop_handlers[] = {{EXTOP_PASSWD_OID, (IFP) backend_passwdmod_extop}, |
431 | 437 | * plugin want to override the values using the configuration, they |
432 | 438 | * can. */ |
433 | 439 | if (gmtime_r(×tamp, ×tamp_tm) == ×tamp_tm) { |
434 | sprintf(timestamp_str, "%04d%02d%02d%02d%02d%02dZ", | |
435 | timestamp_tm.tm_year + 1900, | |
436 | timestamp_tm.tm_mon + 1, | |
437 | timestamp_tm.tm_mday, | |
438 | timestamp_tm.tm_hour, | |
439 | timestamp_tm.tm_min, | |
440 | timestamp_tm.tm_sec); | |
440 | strftime(timestamp_str, sizeof(timestamp_str), | |
441 | "%Y%m%d%H%M%SZ", ×tamp_tm); | |
441 | 442 | slapi_entry_add_string(e, "createTimestamp", timestamp_str); |
442 | 443 | slapi_entry_add_string(e, "modifyTimestamp", timestamp_str); |
443 | 444 | } |
1523 | 1524 | struct entries_to_send *e_to_send = NULL; |
1524 | 1525 | struct cached_entry *entry = NULL; |
1525 | 1526 | bool_t dont_cache = FALSE; |
1527 | void *ndn_key = (void *) slapi_entry_get_ndn(e); | |
1526 | 1528 | PLHashTable* ht = (PLHashTable*) cbdata->state->cached_entries; |
1527 | 1529 | |
1528 | if ((cbdata == NULL) || (e == NULL)) return; | |
1530 | if ((cbdata == NULL) || (e == NULL) || (ndn_key == NULL)) return; | |
1529 | 1531 | |
1530 | 1532 | e_to_send = (struct entries_to_send *) slapi_ch_calloc(1, sizeof(struct entries_to_send)); |
1531 | 1533 | |
1532 | 1534 | dont_cache = cbdata->state->use_entry_cache ? FALSE : TRUE; |
1533 | 1535 | |
1534 | 1536 | if (!wrap_rwlock_wrlock(cbdata->state->cached_entries_lock)) { |
1535 | entry = PL_HashTableLookup(ht, slapi_entry_get_ndn(e)); | |
1537 | entry = PL_HashTableLookup(ht, ndn_key); | |
1536 | 1538 | if (entry != NULL) { |
1537 | 1539 | /* There is an entry in the hash table but is it the same? */ |
1538 | 1540 | char *e_modifyTimestamp = slapi_entry_attr_get_charptr(e, "modifyTimestamp"); |
1646 | 1648 | cbdata->entries_tail = NULL; |
1647 | 1649 | } |
1648 | 1650 | |
1651 | static void | |
1652 | backend_search_free_staged(struct backend_search_cbdata *cbdata) | |
1653 | { | |
1654 | struct backend_staged_search *staged, *next; | |
1655 | int i; | |
1656 | int nb_entries = 0; | |
1657 | int nb_stages = 0; | |
1658 | ||
1659 | if (cbdata == NULL) { | |
1660 | return; | |
1661 | } | |
1662 | ||
1663 | staged = cbdata->staged; | |
1664 | while (staged != NULL) { | |
1665 | nb_stages++; | |
1666 | for (i = 0; | |
1667 | (i < staged->count) && | |
1668 | (staged->entries != NULL) && | |
1669 | (staged->entries[i] != NULL); | |
1670 | i++) { | |
1671 | slapi_entry_free(staged->entries[i]); | |
1672 | staged->entries[i] = NULL; | |
1673 | } | |
1674 | nb_entries += i; | |
1675 | slapi_ch_free_string(&staged->map_group); | |
1676 | slapi_ch_free_string(&staged->map_set); | |
1677 | slapi_ch_free_string(&staged->name); | |
1678 | slapi_ch_free_string(&staged->container_sdn); | |
1679 | next = staged->next; | |
1680 | free(staged); | |
1681 | staged = next; | |
1682 | } | |
1683 | slapi_log_error(SLAPI_LOG_PLUGIN, | |
1684 | cbdata->state->plugin_desc->spd_id, | |
1685 | "backend_search_free_staged freed %d stages with %d entries\n", | |
1686 | nb_stages, | |
1687 | nb_entries); | |
1688 | cbdata->staged = NULL; | |
1689 | } | |
1649 | 1690 | static int |
1650 | 1691 | backend_search_cb(Slapi_PBlock *pb) |
1651 | 1692 | { |
1850 | 1891 | map_unlock(); |
1851 | 1892 | /* Return newly acquired entries */ |
1852 | 1893 | backend_send_mapped_entries(&cbdata); |
1894 | backend_search_free_staged(&cbdata); | |
1853 | 1895 | } else { |
1854 | 1896 | slapi_log_error(SLAPI_LOG_PLUGIN, |
1855 | 1897 | cbdata.state->plugin_desc->spd_id, |
2302 | 2344 | slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state); |
2303 | 2345 | return state->use_be_txns ? backend_write_cb(pb, state) : 0; |
2304 | 2346 | } |
2347 | static PRBool | |
2348 | backend_be_write_ignore(Slapi_PBlock *pb) | |
2349 | { | |
2350 | char *dn = NULL; | |
2351 | Slapi_DN *target_sdn = NULL; | |
2352 | int check; | |
2353 | int i = 0; | |
2354 | PRBool ignore = PR_FALSE; | |
2355 | ||
2356 | /* Check if the target DN is a subordinates of | |
2357 | * on of the ignored containers | |
2358 | */ | |
2359 | slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET, &dn); | |
2360 | target_sdn = slapi_sdn_new_dn_byval(dn); | |
2361 | ||
2362 | for (i = 0; ignored_containers_sdn[i]; i++) { | |
2363 | check = slapi_sdn_issuffix(target_sdn, ignored_containers_sdn[i]); | |
2364 | if (check != 0) { | |
2365 | /* This entry is an ignored container */ | |
2366 | ignore = PR_TRUE; | |
2367 | break; | |
2368 | } | |
2369 | } | |
2370 | slapi_sdn_free(&target_sdn); | |
2371 | return ignore; | |
2372 | } | |
2373 | ||
2374 | ||
2375 | static int | |
2376 | backend_be_pre_write_cb(Slapi_PBlock *pb) { | |
2377 | int ret = 0; | |
2378 | int lock_status; | |
2379 | int lock_count; | |
2380 | struct plugin_state *state; | |
2381 | ||
2382 | slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state); | |
2383 | ||
2384 | if (wrap_get_call_level() > 0) { | |
2385 | return 0; | |
2386 | } | |
2387 | if (state->ready_to_serve == 0) { | |
2388 | /* No data to serve yet */ | |
2389 | return 0; | |
2390 | } | |
2391 | if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) { | |
2392 | return 0; | |
2393 | } | |
2394 | if (backend_be_write_ignore(pb)) { | |
2395 | #if DEBUG_MAP_LOCK | |
2396 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
2397 | "backend_be_pre_write_cb: (%p) operation is not impacting schema compat\n", PR_MyThreadId(), 1); | |
2398 | #endif | |
2399 | return 0; | |
2400 | } | |
2401 | ||
2402 | ||
2403 | ||
2404 | wrap_inc_call_level(); | |
2405 | ||
2406 | lock_status = get_plugin_monitor_status(); | |
2407 | lock_count = get_plugin_monitor_count(); | |
2408 | if (lock_status == MAP_RWLOCK_UNINIT) { | |
2409 | return 0; | |
2410 | } | |
2411 | ||
2412 | if (lock_status == MAP_RWLOCK_FREE) { | |
2413 | /* This thread does not hold the map lock */ | |
2414 | set_plugin_monitor_count(1); | |
2415 | ||
2416 | if (plugin_wrlock() == 0) { | |
2417 | ret = 0; | |
2418 | } else { | |
2419 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
2420 | "backend_be_pre_write_cb: unable to acquire write lock\n"); | |
2421 | ret = -1; | |
2422 | } | |
2423 | #if DEBUG_MAP_LOCK | |
2424 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
2425 | "backend_be_pre_write_cb: (%p) MAP_RWLOCK_FREE -> MAP_WLOCK_HELD : count=%d\n", (void *) PR_MyThreadId(), 1); | |
2426 | #endif | |
2427 | } else { | |
2428 | set_plugin_monitor_count(lock_count + 1); | |
2429 | #if DEBUG_MAP_LOCK | |
2430 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2431 | "backend_be_pre_write_cb: (%p) %s --> MAP_WLOCK_HELD : count=%d\n", | |
2432 | (void *) PR_MyThreadId(), | |
2433 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD": "MAP_RLOCK_HELD", | |
2434 | lock_count + 1); | |
2435 | #endif | |
2436 | ret = 0; | |
2437 | if (lock_status == MAP_RLOCK_HELD) { | |
2438 | /* lock is already acquired in read */ | |
2439 | ||
2440 | #if DEBUG_MAP_LOCK | |
2441 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2442 | "map backend_be_pre_write_cb: weird situation map lock is held in read and now required in write mode\n"); | |
2443 | #endif | |
2444 | /* First free the lock held in read */ | |
2445 | ret = plugin_unlock(); | |
2446 | if (ret) { | |
2447 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2448 | "backend_be_pre_write_cb: fail to unlock plugin lock (%d)\n", ret); | |
2449 | } | |
2450 | ||
2451 | /* Second acquire it in write */ | |
2452 | ret = plugin_wrlock(); | |
2453 | if (ret) { | |
2454 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2455 | "backend_be_pre_write_cb: fail to write lock plugin lock (%d)\n", ret); | |
2456 | } | |
2457 | } | |
2458 | } | |
2459 | ||
2460 | set_plugin_monitor_status(MAP_WLOCK_HELD); | |
2461 | wrap_dec_call_level(); | |
2462 | ||
2463 | return ret; | |
2464 | } | |
2465 | ||
2466 | static int | |
2467 | backend_be_post_write_cb(Slapi_PBlock *pb) | |
2468 | { | |
2469 | int ret = 0; | |
2470 | int lock_status; | |
2471 | int lock_count; | |
2472 | struct plugin_state *state; | |
2473 | ||
2474 | slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state); | |
2475 | ||
2476 | if (wrap_get_call_level() > 0) { | |
2477 | return 0; | |
2478 | } | |
2479 | if (state->ready_to_serve == 0) { | |
2480 | /* No data to serve yet */ | |
2481 | return 0; | |
2482 | } | |
2483 | if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) { | |
2484 | return 0; | |
2485 | } | |
2486 | if (backend_be_write_ignore(pb)) { | |
2487 | #if DEBUG_MAP_LOCK | |
2488 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
2489 | "backend_be_post_write_cb: (%p) operation was not impacting schema compat\n", PR_MyThreadId(), 1); | |
2490 | #endif | |
2491 | return 0; | |
2492 | } | |
2493 | ||
2494 | wrap_inc_call_level(); | |
2495 | ||
2496 | lock_status = get_plugin_monitor_status(); | |
2497 | lock_count = get_plugin_monitor_count(); | |
2498 | if (lock_status == MAP_RWLOCK_UNINIT) { | |
2499 | return 0; | |
2500 | } | |
2501 | ||
2502 | if (lock_count == 1) { | |
2503 | set_plugin_monitor_status(MAP_RWLOCK_FREE); | |
2504 | if (plugin_unlock() == 0) { | |
2505 | ret = 0; | |
2506 | } else { | |
2507 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
2508 | "backend_be_post_write_cb: unable to release write lock\n"); | |
2509 | ret = -1; | |
2510 | } | |
2511 | #if DEBUG_MAP_LOCK | |
2512 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2513 | "backend_be_post_write_cb: (%p) %s --> MAP_RWLOCK_FREE : count=%d\n", | |
2514 | (void *) PR_MyThreadId(), | |
2515 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE", | |
2516 | 0); | |
2517 | #endif | |
2518 | } | |
2519 | if (lock_count >= 1) { | |
2520 | set_plugin_monitor_count(lock_count - 1); | |
2521 | #if DEBUG_MAP_LOCK | |
2522 | if (lock_count > 1) { | |
2523 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2524 | "backend_be_post_write_cb: (%p) keep %s : count=%d\n", | |
2525 | (void *) PR_MyThreadId(), | |
2526 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE", | |
2527 | lock_count - 1); | |
2528 | } else { | |
2529 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
2530 | "backend_be_post_write_cb: (%p) is now %s : count=%d\n", | |
2531 | (void *) PR_MyThreadId(), | |
2532 | "MAP_RWLOCK_FREE", | |
2533 | lock_count - 1); | |
2534 | } | |
2535 | #endif | |
2536 | } | |
2537 | wrap_dec_call_level(); | |
2538 | ||
2539 | return ret; | |
2540 | } | |
2305 | 2541 | |
2306 | 2542 | #ifdef USE_PAM |
2307 | 2543 | static int |
2814 | 3050 | } |
2815 | 3051 | |
2816 | 3052 | int |
3053 | backend_init_be_preop(Slapi_PBlock *pb, struct plugin_state *state) | |
3054 | { | |
3055 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3056 | "hooking up bet preoperation callbacks\n"); | |
3057 | /* Intercept write requests and return an insufficient-access error for | |
3058 | * attempts to write to anything we're managing. */ | |
3059 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN, | |
3060 | backend_be_pre_write_cb) != 0) { | |
3061 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3062 | "error hooking up betxn pre add callback\n"); | |
3063 | return -1; | |
3064 | } | |
3065 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_MODIFY_FN, | |
3066 | backend_be_pre_write_cb) != 0) { | |
3067 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3068 | "error hooking up betxn pre modify callback\n"); | |
3069 | return -1; | |
3070 | } | |
3071 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_MODRDN_FN, | |
3072 | backend_be_pre_write_cb) != 0) { | |
3073 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3074 | "error hooking up betxn pre modrdn callback\n"); | |
3075 | return -1; | |
3076 | } | |
3077 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_DELETE_FN, | |
3078 | backend_be_pre_write_cb) != 0) { | |
3079 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3080 | "error hooking up betxn pre delete callback\n"); | |
3081 | return -1; | |
3082 | } | |
3083 | /* We don't hook abandonment requests. */ | |
3084 | /* We don't hook unbind requests. */ | |
3085 | return 0; | |
3086 | } | |
3087 | ||
3088 | int | |
2817 | 3089 | backend_init_betxn_postop(Slapi_PBlock *pb, struct plugin_state *state) |
2818 | 3090 | { |
2819 | 3091 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, |
2820 | 3092 | "hooking up betxn postoperation callbacks\n"); |
2821 | 3093 | return backend_shr_betxn_postop_init(pb, state); |
2822 | 3094 | } |
3095 | ||
3096 | ||
3097 | int | |
3098 | backend_init_be_postop(Slapi_PBlock *pb, struct plugin_state *state) | |
3099 | { | |
3100 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_ADD_FN, | |
3101 | backend_be_post_write_cb) != 0) { | |
3102 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3103 | "error hooking up betxn post add callback\n"); | |
3104 | return -1; | |
3105 | } | |
3106 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_MODIFY_FN, | |
3107 | backend_be_post_write_cb) != 0) { | |
3108 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3109 | "error hooking up betxn post modify " | |
3110 | "callback\n"); | |
3111 | return -1; | |
3112 | } | |
3113 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_MODRDN_FN, | |
3114 | backend_be_post_write_cb) != 0) { | |
3115 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3116 | "error hooking up betxn post modrdn " | |
3117 | "callback\n"); | |
3118 | return -1; | |
3119 | } | |
3120 | if (slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_DELETE_FN, | |
3121 | backend_be_post_write_cb) != 0) { | |
3122 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
3123 | "error hooking up betxn post delete " | |
3124 | "callback\n"); | |
3125 | return -1; | |
3126 | } | |
3127 | return 0; | |
3128 | } | |
2823 | 3129 | #endif |
2824 | 3130 | |
2825 | 3131 | int |
36 | 36 | #endif |
37 | 37 | |
38 | 38 | #include <rpc/xdr.h> |
39 | #include <prtypes.h> | |
40 | /* NSPR private API for thread-local variables */ | |
41 | #include <private/prpriv.h> | |
39 | 42 | #include "../yp/yp.h" |
40 | 43 | |
41 | 44 | #ifdef HAVE_TCPD_H |
776 | 779 | backend_shr_data_initialize_thread(time_t when, void *arg) |
777 | 780 | { |
778 | 781 | struct backend_shr_data_init_cbdata *cbdata = (struct backend_shr_data_init_cbdata *)arg; |
779 | PRThread *thread = NULL; | |
780 | ||
781 | 782 | if (slapi_is_shutting_down()) { |
782 | 783 | return; |
783 | 784 | } |
2865 | 2866 | } |
2866 | 2867 | return 0; |
2867 | 2868 | } |
2869 | ||
2870 | int | |
2871 | PR_MyThreadId(void) | |
2872 | { | |
2873 | PRThread *thr = PR_GetCurrentThread(); | |
2874 | PRUint32 myself = PR_GetThreadID(thr); | |
2875 | return myself; | |
2876 | } | |
2877 | PRBool use_lock_status = PR_FALSE; | |
2878 | static unsigned int thread_plugin_lock_status; | |
2879 | PRBool use_lock_count = PR_FALSE; | |
2880 | static unsigned int thread_plugin_lock_count; | |
2881 | /* | |
2882 | * https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_NewThreadPrivateIndex | |
2883 | * It is called each time: | |
2884 | * - PR_SetThreadPrivate is call with a not NULL private value | |
2885 | * - on thread exit | |
2886 | */ | |
2887 | static void | |
2888 | lock_status_free(void *ptr) | |
2889 | { | |
2890 | int *lock_status = ptr; | |
2891 | if (lock_status) { | |
2892 | slapi_ch_free((void **)&lock_status); | |
2893 | } | |
2894 | } | |
2895 | static void | |
2896 | lock_count_free(void *ptr) | |
2897 | { | |
2898 | int *lock_count = ptr; | |
2899 | if (lock_count) { | |
2900 | slapi_ch_free((void **)&lock_count); | |
2901 | } | |
2902 | } | |
2903 | ||
2904 | /* This is used to ignore some write operations | |
2905 | * if they target subordinates entry of ignored containers | |
2906 | */ | |
2907 | Slapi_DN **ignored_containers_sdn = NULL; | |
2908 | void | |
2909 | init_map_lock(void) | |
2910 | { | |
2911 | #if DEBUG_MAP_LOCK | |
2912 | /* The plugin lock is initialized as free */ | |
2913 | slapi_log_error(SLAPI_LOG_FATAL, "init_plugin_lock", | |
2914 | "thread_id = %p\n", PR_MyThreadId()); | |
2915 | #endif | |
2916 | if (ignored_containers_sdn == NULL) { | |
2917 | /* allocates ignored_containers_sdn of Slapi_DN* only once | |
2918 | * It will be used later in be_pre/post_write_cb | |
2919 | */ | |
2920 | int cnt; | |
2921 | char *ignored_containers[4] = { "cn=config", "cn=schema", "cn=changelog", NULL}; | |
2922 | ||
2923 | for (cnt = 0; ignored_containers[cnt]; cnt++); | |
2924 | ignored_containers_sdn = (Slapi_DN **) slapi_ch_calloc(cnt + 1, sizeof(Slapi_DN *)); | |
2925 | ||
2926 | for (cnt = 0; ignored_containers[cnt]; cnt++) { | |
2927 | ignored_containers_sdn[cnt] = slapi_sdn_new_dn_byval(ignored_containers[cnt]); | |
2928 | } | |
2929 | } | |
2930 | ||
2931 | if (PR_NewThreadPrivateIndex(&thread_plugin_lock_status, lock_status_free) == PR_SUCCESS) { | |
2932 | use_lock_status = PR_TRUE; | |
2933 | } | |
2934 | if (PR_NewThreadPrivateIndex(&thread_plugin_lock_count, lock_count_free) == PR_SUCCESS) { | |
2935 | use_lock_count = PR_TRUE; | |
2936 | } | |
2937 | ||
2938 | #if DEBUG_MAP_LOCK | |
2939 | slapi_log_error(SLAPI_LOG_FATAL, "init_plugin_lock", | |
2940 | "thread_plugin_lock_status = %d\n", thread_plugin_lock_status); | |
2941 | slapi_log_error(SLAPI_LOG_FATAL, "init_map_lock", | |
2942 | "thread_plugin_lock_count = %d\n", thread_plugin_lock_count); | |
2943 | #endif | |
2944 | } | |
2945 | ||
2946 | int | |
2947 | rw_monitor_enabled(void) | |
2948 | { | |
2949 | if (use_lock_status) | |
2950 | return (int) MAP_MONITOR_ENABLED; | |
2951 | else | |
2952 | return (int) MAP_MONITOR_DISABLED; | |
2953 | } | |
2954 | ||
2955 | int | |
2956 | get_plugin_monitor_status(void) | |
2957 | { | |
2958 | int ret; | |
2959 | ||
2960 | if (use_lock_status) { | |
2961 | int *lock_status_p; | |
2962 | lock_status_p = (int *) PR_GetThreadPrivate(thread_plugin_lock_status); | |
2963 | if (lock_status_p == NULL) { | |
2964 | /* if it was not initialized then allocates a structure | |
2965 | * that will be private to that thread. | |
2966 | * Later when the structure is retrieved (PR_GetThreadPrivate), the | |
2967 | * content of the structure can be read/write without allocating | |
2968 | * this private structure PR_SetThreadPrivate. | |
2969 | * So this branch is processed one time per each thread | |
2970 | */ | |
2971 | lock_status_p = (int *) slapi_ch_calloc(1, sizeof (int)); | |
2972 | PR_SetThreadPrivate(thread_plugin_lock_status, (void *) lock_status_p); | |
2973 | *lock_status_p = MAP_RWLOCK_FREE; | |
2974 | } | |
2975 | ret = *lock_status_p; | |
2976 | } else | |
2977 | ret = (int) MAP_RWLOCK_UNINIT; | |
2978 | #if DEBUG_MAP_LOCK | |
2979 | slapi_log_error(SLAPI_LOG_FATAL, "get_plugin_monitor_status", | |
2980 | "(%s) lock_status = %d (%p)\n", use_lock_status ? "TRUE" : "FALSE", ret, (void *) PR_MyThreadId()); | |
2981 | #endif | |
2982 | return ret; | |
2983 | } | |
2984 | ||
2985 | void | |
2986 | set_plugin_monitor_status(int lock_status) | |
2987 | { | |
2988 | #if DEBUG_MAP_LOCK | |
2989 | slapi_log_error(SLAPI_LOG_FATAL, "set_plugin_monitor_status", | |
2990 | "(%s) lock_status = %d --> %d (%p)\n", use_lock_status ? "TRUE" : "FALSE", get_plugin_monitor_status(), (int) lock_status, (void *) PR_MyThreadId()); | |
2991 | #endif | |
2992 | ||
2993 | if (use_lock_status) { | |
2994 | int *lock_status_p; | |
2995 | ||
2996 | lock_status_p = (int *) PR_GetThreadPrivate(thread_plugin_lock_status); | |
2997 | if (lock_status_p == NULL) { | |
2998 | /* if it was not initialized then allocates a structure | |
2999 | * that will be private to that thread. | |
3000 | * Later when the structure is retrieved (PR_GetThreadPrivate), the | |
3001 | * content of the structure can be read/write without allocating | |
3002 | * this private structure PR_SetThreadPrivate. | |
3003 | * So this branch is processed one time per each thread | |
3004 | */ | |
3005 | lock_status_p = (int *) slapi_ch_calloc(1, sizeof (int)); | |
3006 | PR_SetThreadPrivate(thread_plugin_lock_status, (void *) lock_status_p); | |
3007 | } | |
3008 | *lock_status_p = lock_status; | |
3009 | } | |
3010 | } | |
3011 | ||
3012 | int | |
3013 | get_plugin_monitor_count(void) | |
3014 | { | |
3015 | int ret; | |
3016 | ||
3017 | if (use_lock_count) { | |
3018 | int *lock_count; | |
3019 | lock_count = (int *) PR_GetThreadPrivate(thread_plugin_lock_count); | |
3020 | if (lock_count == NULL) { | |
3021 | /* if it was not initialized then allocates a structure | |
3022 | * that will be private to that thread. | |
3023 | * Later when the structure is retrieved (PR_GetThreadPrivate), the | |
3024 | * content of the structure can be read/write without allocating | |
3025 | * this private structure PR_SetThreadPrivate. | |
3026 | * So this branch is processed one time per each thread | |
3027 | */ | |
3028 | lock_count = (int *) slapi_ch_calloc(1, sizeof (int)); | |
3029 | PR_SetThreadPrivate(thread_plugin_lock_count, (void *) lock_count); | |
3030 | *lock_count = 0; | |
3031 | } | |
3032 | ret = *lock_count; | |
3033 | } else | |
3034 | ret = (int) MAP_RWLOCK_UNINIT; | |
3035 | #if DEBUG_MAP_LOCK | |
3036 | slapi_log_error(SLAPI_LOG_FATAL, "get_plugin_monitor_count", | |
3037 | "(%s) lock_count = %d (%p)\n", use_lock_count ? "TRUE" : "FALSE", ret, (void *) PR_MyThreadId()); | |
3038 | #endif | |
3039 | return ret; | |
3040 | } | |
3041 | ||
3042 | void | |
3043 | set_plugin_monitor_count(int lock_count) | |
3044 | { | |
3045 | #if DEBUG_MAP_LOCK | |
3046 | slapi_log_error(SLAPI_LOG_FATAL, "set_plugin_monitor_count", | |
3047 | "(%s) lock_count = %d --> %d (%p)\n", use_lock_count ? "TRUE" : "FALSE", get_plugin_monitor_count(), (int) lock_count, (void *) PR_MyThreadId()); | |
3048 | #endif | |
3049 | if (use_lock_count) { | |
3050 | int *lock_count_p; | |
3051 | ||
3052 | lock_count_p = (int *) PR_GetThreadPrivate(thread_plugin_lock_count); | |
3053 | if (lock_count_p == NULL) { | |
3054 | /* if it was not initialized then allocates a structure | |
3055 | * that will be private to that thread. | |
3056 | * Later when the structure is retrieved (PR_GetThreadPrivate), the | |
3057 | * content of the structure can be read/write without allocating | |
3058 | * this private structure PR_SetThreadPrivate. | |
3059 | * So this branch is processed one time per each thread | |
3060 | */ | |
3061 | lock_count_p = (int *) slapi_ch_calloc(1, sizeof (int)); | |
3062 | PR_SetThreadPrivate(thread_plugin_lock_count, (void *) lock_count_p); | |
3063 | } | |
3064 | *lock_count_p = lock_count; | |
3065 | } | |
3066 | } |
20 | 20 | |
21 | 21 | #ifndef back_shr_h |
22 | 22 | #define back_shr_h |
23 | ||
24 | #define DEBUG_MAP_LOCK 0 | |
25 | #define MAP_MONITOR_DISABLED 0 | |
26 | #define MAP_MONITOR_ENABLED 1 | |
27 | ||
28 | #define MAP_RWLOCK_UNINIT 3 | |
29 | #define MAP_WLOCK_HELD 2 | |
30 | #define MAP_RLOCK_HELD 1 | |
31 | #define MAP_RWLOCK_FREE 0 | |
32 | int PR_MyThreadId(void); | |
33 | int rw_monitor_enabled(void); | |
34 | int get_plugin_monitor_status(void); | |
35 | void set_plugin_monitor_status(int lock_status); | |
36 | int get_plugin_monitor_count(void); | |
37 | void set_plugin_monitor_count(int lock_count); | |
38 | void init_map_lock(void); | |
39 | extern Slapi_DN **ignored_containers_sdn; | |
40 | ||
23 | 41 | |
24 | 42 | struct plugin_state; |
25 | 43 |
67 | 67 | int backend_init_internal_postop(struct slapi_pblock *pb, |
68 | 68 | struct plugin_state *state); |
69 | 69 | |
70 | /* Only used for schema compatibility plugin*/ | |
71 | int backend_init_be_preop(Slapi_PBlock *pb, struct plugin_state *state); | |
72 | int backend_init_be_postop(Slapi_PBlock *pb, struct plugin_state *state); | |
73 | ||
74 | ||
70 | 75 | /* Read the server's name. */ |
71 | 76 | int backend_read_master_name(struct plugin_state *state, |
72 | 77 | struct slapi_pblock *pb, |
22 | 22 | #include "config.h" |
23 | 23 | #endif |
24 | 24 | |
25 | #include <inttypes.h> | |
25 | 26 | #include <sys/types.h> |
26 | 27 | #include <search.h> |
27 | 28 | #include <stdlib.h> |
39 | 40 | |
40 | 41 | #include <rpc/rpc.h> |
41 | 42 | |
43 | /* NSPR private API for thread-local variables */ | |
44 | #include <private/prpriv.h> | |
45 | ||
42 | 46 | #include "backend.h" |
43 | 47 | #include "disp-nis.h" |
44 | 48 | #include "map.h" |
45 | 49 | #include "portmap.h" |
46 | 50 | #include "wrap.h" |
51 | #include "back-shr.h" | |
47 | 52 | |
48 | 53 | /* The singleton for the cache. */ |
49 | 54 | static struct { |
90 | 95 | } *domains; |
91 | 96 | int n_domains; |
92 | 97 | struct wrapped_rwlock *lock; |
98 | struct wrapped_rwlock *plugin_lock; | |
93 | 99 | } map_data; |
94 | 100 | |
95 | 101 | static void * |
1154 | 1160 | if (map_data.lock == NULL) { |
1155 | 1161 | return -1; |
1156 | 1162 | } |
1163 | map_data.plugin_lock = wrap_new_rwlock(); | |
1164 | if (map_data.plugin_lock == NULL) { | |
1165 | return -1; | |
1166 | } | |
1157 | 1167 | return 0; |
1158 | 1168 | } |
1159 | 1169 | |
1192 | 1202 | } |
1193 | 1203 | wrap_free_rwlock(map_data.lock); |
1194 | 1204 | map_data.lock = NULL; |
1205 | wrap_free_rwlock(map_data.plugin_lock); | |
1206 | map_data.plugin_lock = NULL; | |
1195 | 1207 | } |
1196 | 1208 | |
1197 | 1209 | int |
1218 | 1230 | } |
1219 | 1231 | |
1220 | 1232 | int |
1233 | plugin_rdlock(void) | |
1234 | { | |
1235 | return wrap_rwlock_rdlock(map_data.plugin_lock); | |
1236 | } | |
1237 | ||
1238 | int | |
1239 | plugin_wrlock(void) | |
1240 | { | |
1241 | return wrap_rwlock_wrlock(map_data.plugin_lock); | |
1242 | } | |
1243 | ||
1244 | int | |
1245 | plugin_unlock(void) | |
1246 | { | |
1247 | return wrap_rwlock_unlock(map_data.plugin_lock); | |
1248 | } | |
1249 | ||
1250 | int | |
1221 | 1251 | map_rdlock(void) |
1222 | 1252 | { |
1223 | return wrap_rwlock_rdlock(map_data.lock); | |
1224 | } | |
1253 | int lock_status; | |
1254 | int lock_count; | |
1255 | int rc = 0; | |
1256 | ||
1257 | if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) { | |
1258 | /* This is not initialized used the old way */ | |
1259 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1260 | "map rdlock: old way MAP_MONITOR_DISABLED\n"); | |
1261 | return wrap_rwlock_rdlock(map_data.lock); | |
1262 | } | |
1263 | ||
1264 | ||
1265 | lock_status = get_plugin_monitor_status(); | |
1266 | lock_count = get_plugin_monitor_count(); | |
1267 | ||
1268 | #if DEBUG_MAP_LOCK | |
1269 | slapi_log_error(SLAPI_LOG_FATAL, "map_rdlock", | |
1270 | "thread_id = %"PRIx32" (call level = %d)\n", PR_MyThreadId(), wrap_get_call_level()); | |
1271 | #endif | |
1272 | if (lock_status == MAP_RWLOCK_UNINIT) { | |
1273 | /* This is not initialized used the old way */ | |
1274 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1275 | "map rdlock: old way lock_status == MAP_RWLOCK_UNINIT\n"); | |
1276 | return wrap_rwlock_rdlock(map_data.lock); | |
1277 | } | |
1278 | ||
1279 | if (lock_status == MAP_RWLOCK_FREE) { | |
1280 | /* The plugin lock is free, acquire it */ | |
1281 | #if DEBUG_MAP_LOCK | |
1282 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1283 | "map rdlock: current lock_status == MAP_RWLOCK_FREE\n"); | |
1284 | #endif | |
1285 | set_plugin_monitor_status(MAP_RLOCK_HELD); | |
1286 | set_plugin_monitor_count(1); | |
1287 | #if DEBUG_MAP_LOCK | |
1288 | if (lock_count != 0) { | |
1289 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1290 | "map rdlock: (%"PRIx32") ALERT !!! count was %d -> 1\n", PR_MyThreadId(), lock_count); | |
1291 | } | |
1292 | #endif | |
1293 | ||
1294 | /* Acquire the slapi plugin in read */ | |
1295 | rc = plugin_rdlock(); | |
1296 | if (rc) { | |
1297 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1298 | "map rdlock: (%"PRIx32") MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", PR_MyThreadId(), rc); | |
1299 | return rc; | |
1300 | } | |
1301 | #if DEBUG_MAP_LOCK | |
1302 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1303 | "map rdlock: (%"PRIx32") MAP_RWLOCK_FREE -> MAP_RLOCK_HELD : count=%d\n", PR_MyThreadId(), 1); | |
1304 | #endif | |
1305 | rc = wrap_rwlock_rdlock(map_data.lock); | |
1306 | if (rc) { | |
1307 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1308 | "Fail to acquire map lock in read (%d)\n", rc); | |
1309 | plugin_unlock(); | |
1310 | return rc; | |
1311 | } | |
1312 | return 0; | |
1313 | } | |
1314 | ||
1315 | #if DEBUG_MAP_LOCK | |
1316 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1317 | "map rdlock: (%x"PRIx32") was already hold %s : count=%d > %d!!!\n", | |
1318 | PR_MyThreadId(), | |
1319 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : "MAP_RLOCK_HELD", | |
1320 | lock_count, lock_count + 1); | |
1321 | #endif | |
1322 | set_plugin_monitor_count(lock_count + 1); | |
1323 | return 0; | |
1324 | } | |
1225 | 1325 | |
1226 | 1326 | int |
1227 | 1327 | map_wrlock(void) |
1228 | 1328 | { |
1229 | return wrap_rwlock_wrlock(map_data.lock); | |
1230 | } | |
1329 | int lock_status; | |
1330 | int lock_count; | |
1331 | int rc = 0; | |
1332 | ||
1333 | if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) { | |
1334 | /* This is not initialized used the old way */ | |
1335 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1336 | "map wrlock: old way MAP_MONITOR_DISABLED\n"); | |
1337 | return wrap_rwlock_wrlock(map_data.lock); | |
1338 | } | |
1339 | ||
1340 | lock_status = get_plugin_monitor_status(); | |
1341 | lock_count = get_plugin_monitor_count(); | |
1342 | ||
1343 | #if DEBUG_MAP_LOCK | |
1344 | slapi_log_error(SLAPI_LOG_FATAL, "map wrlock", | |
1345 | "thread_id = %p (call level = %d)\n", (void *) PR_MyThreadId(), wrap_get_call_level()); | |
1346 | #endif | |
1347 | if (lock_status == MAP_RWLOCK_UNINIT) { | |
1348 | /* This is not initialized used the old way */ | |
1349 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1350 | "map wrlock: old way lock_status == MAP_LOCK_UNINIT\n"); | |
1351 | ||
1352 | return wrap_rwlock_wrlock(map_data.lock); | |
1353 | } | |
1354 | ||
1355 | if (lock_status == MAP_RWLOCK_FREE) { | |
1356 | /* The lock is free, acquire it */ | |
1357 | #if DEBUG_MAP_LOCK | |
1358 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1359 | "map wrlock: current lock_status == MAP_LOCK_FREE\n"); | |
1360 | #endif | |
1361 | ||
1362 | set_plugin_monitor_count(1); | |
1363 | #if DEBUG_MAP_LOCK | |
1364 | if (lock_count != 0) { | |
1365 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1366 | "map wrlock: (%"PRIx32") ALERT !!! count was %d --> 1\n", PR_MyThreadId(), lock_count); | |
1367 | } | |
1368 | #endif | |
1369 | /* Acquire the slapi plugin in write */ | |
1370 | rc = plugin_wrlock(); | |
1371 | if (rc) { | |
1372 | slapi_log_error(SLAPI_LOG_FATAL, "schemacompat", | |
1373 | "map wrlock: (%"PRIx32") MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", PR_MyThreadId(), rc); | |
1374 | return rc; | |
1375 | } | |
1376 | #if DEBUG_MAP_LOCK | |
1377 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1378 | "map wrlock: (%"PRIx32") MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : count=%d\n", PR_MyThreadId(), 1); | |
1379 | #endif | |
1380 | ||
1381 | rc = wrap_rwlock_wrlock(map_data.lock); | |
1382 | if (rc) { | |
1383 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1384 | "map wrlock: (%"PRIx32") MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : fail to write lock map lock (%d)\n", PR_MyThreadId(), rc); | |
1385 | plugin_unlock(); | |
1386 | goto common; | |
1387 | } | |
1388 | } else { | |
1389 | set_plugin_monitor_count(lock_count + 1); | |
1390 | #if DEBUG_MAP_LOCK | |
1391 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1392 | "map wrlock: (%"PRIx32") %s --> MAP_WLOCK_HELD : count=%d\n", | |
1393 | PR_MyThreadId(), | |
1394 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : "MAP_RLOCK_HELD", | |
1395 | lock_count + 1); | |
1396 | #endif | |
1397 | ||
1398 | if (lock_status == MAP_RLOCK_HELD) { | |
1399 | /* lock is already acquired in read */ | |
1400 | #if DEBUG_MAP_LOCK | |
1401 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1402 | "map wrlock: weird situation map lock is held in read and now required in write mode\n"); | |
1403 | #endif | |
1404 | /* First free the lock held in read */ | |
1405 | rc = plugin_unlock(); | |
1406 | if (rc) { | |
1407 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1408 | "map wrlock: fail to unlock plugin lock (%d)\n", rc); | |
1409 | goto common; | |
1410 | } | |
1411 | ||
1412 | /* Second acquire it in write */ | |
1413 | rc = plugin_wrlock(); | |
1414 | if (rc) { | |
1415 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1416 | "map wrlock: fail to write lock plugin lock (%d)\n", rc); | |
1417 | goto common; | |
1418 | } | |
1419 | } | |
1420 | } | |
1421 | ||
1422 | common: | |
1423 | set_plugin_monitor_status(MAP_WLOCK_HELD); | |
1424 | return rc; | |
1425 | } | |
1231 | 1426 | |
1232 | 1427 | int |
1233 | 1428 | map_unlock(void) |
1234 | { | |
1235 | return wrap_rwlock_unlock(map_data.lock); | |
1236 | } | |
1429 | { | |
1430 | int lock_status; | |
1431 | int lock_count; | |
1432 | int rc = 0; | |
1433 | ||
1434 | if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) { | |
1435 | /* This is not initialized used the old way */ | |
1436 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1437 | "map_unlock: old way MAP_MONITOR_DISABLED\n"); | |
1438 | return wrap_rwlock_unlock(map_data.lock); | |
1439 | } | |
1440 | ||
1441 | lock_status = get_plugin_monitor_status(); | |
1442 | lock_count = get_plugin_monitor_count(); | |
1443 | ||
1444 | #if DEBUG_MAP_LOCK | |
1445 | slapi_log_error(SLAPI_LOG_FATAL, "map_unlock", | |
1446 | "thread_id = %p (call level = %d)\n", (void *) PR_MyThreadId(), wrap_get_call_level()); | |
1447 | #endif | |
1448 | if (lock_status == MAP_RWLOCK_UNINIT) { | |
1449 | /* This is not initialized used the old way */ | |
1450 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1451 | "map_unlock: old way lock_status == MAP_RWLOCK_UNINIT\n"); | |
1452 | ||
1453 | return wrap_rwlock_unlock(map_data.lock); | |
1454 | } | |
1455 | ||
1456 | if (lock_count == 1) { | |
1457 | set_plugin_monitor_status(MAP_RWLOCK_FREE); | |
1458 | rc = plugin_unlock(); | |
1459 | if (rc) { | |
1460 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1461 | "map unlock: fail to unlock plugin lock (%d)\n", rc); | |
1462 | goto common; | |
1463 | } | |
1464 | #if DEBUG_MAP_LOCK | |
1465 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1466 | "map_unlock: (%p) %s --> MAP_RWLOCK_FREE : count=%d\n", | |
1467 | (void *) PR_MyThreadId(), | |
1468 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE", | |
1469 | 0); | |
1470 | #endif | |
1471 | rc = wrap_rwlock_unlock(map_data.lock); | |
1472 | if (rc) { | |
1473 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1474 | "map_unlock: fail to unlock map lock (%d)\n", rc); | |
1475 | goto common; | |
1476 | } | |
1477 | } | |
1478 | if (lock_count >= 1) { | |
1479 | set_plugin_monitor_count(lock_count - 1); | |
1480 | #if DEBUG_MAP_LOCK | |
1481 | if (lock_count > 1) { | |
1482 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1483 | "map_unlock: (%p) keep %s : count=%d\n", | |
1484 | (void *) PR_MyThreadId(), | |
1485 | (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE", | |
1486 | lock_count - 1); | |
1487 | } else { | |
1488 | slapi_log_error(SLAPI_LOG_FATAL, "schema-compat", | |
1489 | "map_unlock: (%p) is now %s : count=%d\n", | |
1490 | (void *) PR_MyThreadId(), | |
1491 | "MAP_RWLOCK_FREE", | |
1492 | lock_count - 1); | |
1493 | } | |
1494 | #endif | |
1495 | } | |
1496 | ||
1497 | common: | |
1498 | return rc; | |
1499 | } |
114 | 114 | const char *domain_name); |
115 | 115 | int map_data_get_map_size(struct plugin_state *state, |
116 | 116 | const char *domain_name, const char *map_name); |
117 | int plugin_rdlock(void); | |
118 | int plugin_wrlock(void); | |
119 | int plugin_unlock(void); | |
117 | 120 | int map_rdlock(void); |
118 | 121 | int map_wrlock(void); |
119 | 122 | int map_unlock(void); |
966 | 966 | AUTH *request_auth, *reply_auth; |
967 | 967 | char auth_buf[MAX_AUTH_BYTES]; |
968 | 968 | struct rpc_msg request, reply; |
969 | int auth_flavor, auth_len; | |
969 | int auth_flavor; | |
970 | 970 | struct ypresp_val reply_val; |
971 | 971 | struct ypresp_key_val reply_key_val; |
972 | 972 | struct ypresp_all reply_all; |
1056 | 1056 | } |
1057 | 1057 | auth_marshall(reply_auth, &auth_xdrs); |
1058 | 1058 | auth_destroy(reply_auth); |
1059 | auth_len = xdr_getpos(&auth_xdrs); | |
1059 | (void)xdr_getpos(&auth_xdrs); | |
1060 | 1060 | xdr_destroy(&auth_xdrs); |
1061 | 1061 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, |
1062 | 1062 | "built reply authenticator\n"); |
61 | 61 | #define PLUGIN_ID "schema-compat-plugin" |
62 | 62 | #define PLUGIN_PREOP_ID PLUGIN_ID "-preop" |
63 | 63 | #define PLUGIN_BETXN_PREOP_ID PLUGIN_ID "-betxn_preop" |
64 | #define PLUGIN_BE_POSTOP_ID PLUGIN_ID "-be_postop" | |
65 | #define PLUGIN_BE_PREOP_ID PLUGIN_ID "-be_preop" | |
64 | 66 | #define PLUGIN_BETXN_POSTOP_ID PLUGIN_ID "-betxn_postop" |
65 | 67 | #define PLUGIN_POSTOP_ID PLUGIN_ID "-postop" |
66 | 68 | #define PLUGIN_INTERNAL_POSTOP_ID PLUGIN_ID "-internal-postop" |
194 | 196 | if (state->plugin_base != NULL) { |
195 | 197 | slapi_ch_free((void **)&state->plugin_base); |
196 | 198 | } |
199 | if (ignored_containers_sdn) { | |
200 | int i; | |
201 | for (i = 0; ignored_containers_sdn[i]; i++) { | |
202 | slapi_sdn_free(&ignored_containers_sdn[i]); | |
203 | } | |
204 | slapi_ch_free((void **)&ignored_containers_sdn); | |
205 | } | |
197 | 206 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, |
198 | 207 | "plugin shutdown completed\n"); |
199 | 208 | return 0; |
252 | 261 | slapi_log_error(SLAPI_LOG_PLUGIN, |
253 | 262 | global_plugin_state->plugin_desc->spd_id, |
254 | 263 | "error registering betxn postoperation " |
264 | "hooks\n"); | |
265 | return -1; | |
266 | } | |
267 | return 0; | |
268 | } | |
269 | static int | |
270 | schema_compat_plugin_init_bepreop(Slapi_PBlock *pb) | |
271 | { | |
272 | slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03); | |
273 | slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description); | |
274 | slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, global_plugin_state); | |
275 | if (backend_init_be_preop(pb, global_plugin_state) == -1) { | |
276 | slapi_log_error(SLAPI_LOG_PLUGIN, | |
277 | global_plugin_state->plugin_desc->spd_id, | |
278 | "error registering be preoperation hooks\n"); | |
279 | return -1; | |
280 | } | |
281 | return 0; | |
282 | } | |
283 | static int | |
284 | schema_compat_plugin_init_bepostop(Slapi_PBlock *pb) | |
285 | { | |
286 | slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03); | |
287 | slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, &plugin_description); | |
288 | slapi_pblock_set(pb, SLAPI_PLUGIN_PRIVATE, global_plugin_state); | |
289 | if (backend_init_be_postop(pb, global_plugin_state) == -1) { | |
290 | slapi_log_error(SLAPI_LOG_PLUGIN, | |
291 | global_plugin_state->plugin_desc->spd_id, | |
292 | "error registering be postoperation " | |
255 | 293 | "hooks\n"); |
256 | 294 | return -1; |
257 | 295 | } |
299 | 337 | "error setting up plugin\n"); |
300 | 338 | return -1; |
301 | 339 | } |
340 | ||
341 | init_map_lock(); | |
342 | ||
302 | 343 | /* Read global configuration. */ |
303 | 344 | if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, |
304 | 345 | &plugin_entry) == 0) && |
340 | 381 | "error registering betxn preoperation plugin\n"); |
341 | 382 | return -1; |
342 | 383 | } |
384 | if (slapi_register_plugin("bepreoperation", TRUE, | |
385 | "schema_compat_plugin_init_bepreop", | |
386 | schema_compat_plugin_init_bepreop, | |
387 | PLUGIN_BE_PREOP_ID, NULL, | |
388 | state->plugin_identity) != 0) { | |
389 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
390 | "error registering betxn preoperation plugin\n"); | |
391 | return -1; | |
392 | } | |
343 | 393 | #endif |
344 | 394 | if (slapi_register_plugin("postoperation", TRUE, |
345 | 395 | "schema_compat_plugin_init_postop", |
364 | 414 | "schema_compat_plugin_init_betxn_postop", |
365 | 415 | schema_compat_plugin_init_betxn_postop, |
366 | 416 | PLUGIN_BETXN_POSTOP_ID, NULL, |
417 | state->plugin_identity) != 0) { | |
418 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, | |
419 | "error registering betxn postoperation plugin\n"); | |
420 | return -1; | |
421 | } | |
422 | if (slapi_register_plugin("bepostoperation", TRUE, | |
423 | "schema_compat_plugin_init_bepostop", | |
424 | schema_compat_plugin_init_bepostop, | |
425 | PLUGIN_BE_POSTOP_ID, NULL, | |
367 | 426 | state->plugin_identity) != 0) { |
368 | 427 | slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, |
369 | 428 | "error registering betxn postoperation plugin\n"); |
76 | 76 | int |
77 | 77 | main(int argc, char **argv) |
78 | 78 | { |
79 | int s, ret, port; | |
79 | int s, port; | |
80 | int ret __attribute__ ((unused)); | |
80 | 81 | s = socket(PF_INET, SOCK_DGRAM, 0); |
81 | 82 | if (s == -1) { |
82 | 83 | printf("error allocating socket\n"); |
93 | 94 | printf("error creating portmap/rpcbind client socket\n"); |
94 | 95 | return 1; |
95 | 96 | } |
96 | setregid(2516, 2516); | |
97 | setreuid(2510, 2510); | |
97 | if (setregid(2516, 2516) == -1) { | |
98 | printf("error setting real and effective group id %s\n", | |
99 | strerror(errno)); | |
100 | return 1; | |
101 | } | |
102 | if (setreuid(2510, 2510) == -1) { | |
103 | printf("error setting real and effective user id %s\n", | |
104 | strerror(errno)); | |
105 | return 1; | |
106 | } | |
98 | 107 | sleep(60); |
99 | 108 | portmap_unregister("portmap", &s, port, YPPROG, YPVERS, |
100 | 109 | AF_INET, IPPROTO_TCP, 0); |
152 | 152 | wrap_stop_thread(struct wrapped_thread *t) |
153 | 153 | { |
154 | 154 | void *returned = NULL; |
155 | int ret __attribute__ ((unused)); | |
155 | 156 | #ifdef USE_PTHREADS |
156 | write(t->stopfd[1], "", 1); | |
157 | ret = write(t->stopfd[1], "", 1); | |
157 | 158 | close(t->stopfd[1]); |
158 | 159 | pthread_join(t->tid, &returned); |
159 | 160 | #endif |
160 | 161 | #ifdef USE_NSPR_THREADS |
161 | write(t->stopfd[1], "", 1); | |
162 | ret = write(t->stopfd[1], "", 1); | |
162 | 163 | close(t->stopfd[1]); |
163 | 164 | PR_JoinThread(t->tid); |
164 | 165 | returned = t->args.result; |
0 | Test with azure pipelines | |
1 | ||
2 | Add pipeline definition that can be used to run build and test jobs in | |
3 | dev.azure.com environment. | |
4 | ||
5 | Following needs to be done to use the Azure Pipelines definition for | |
6 | slapi-nis: | |
7 | ||
8 | - Configure Azure DevOps organization | |
9 | - Create public project there | |
10 | - Clone your Git repository for slapi-nis from pagure.io | |
11 | - On Azure side, navigate to Repos -> Files, choose your repo top | |
12 | directory and click 'Clone' | |
13 | - The 'Clone Repository' dialog will show how to clone the repository | |
14 | with HTTPS or SSH. Choose SSH tab and note the URL. | |
15 | - Set mirroring hook on Pagure's project site (Settings -> Hooks -> | |
16 | Mirroring) by providing this URL | |
17 | - Return back to the hook settings in Pagure and copy public SSH key | |
18 | from there | |
19 | - Choose 'Manage SSH keys' in the 'Clone Repository' dialog and add a | |
20 | public SSH key there | |
21 | ||
22 | After these actions a push to pagure project will automatically be | |
23 | mirrored to Azure Repos repository. | |
24 | ||
25 | Now a pipeline can be set up in Azure by picking up azure-pipelines.yml | |
26 | file from the repo. |
0 | jobs: | |
1 | - job: Build | |
2 | pool: | |
3 | vmImage: 'Ubuntu-16.04' | |
4 | variables: | |
5 | builddir: /__w/1/s | |
6 | container: | |
7 | image: f30/fedora-toolbox | |
8 | endpoint: fedora-project-registry | |
9 | steps: | |
10 | - script: | | |
11 | sudo rm -rf /var/cache/dnf/* | |
12 | cd $(builddir) | |
13 | sudo dnf makecache || : | |
14 | sudo dnf -y install dnf-plugins-core rpm-build autoconf automake libtool \ | |
15 | /usr/bin/rpcgen 389-ds-base-devel libnsl2-devel \ | |
16 | libsss_nss_idmap-devel nspr-devel nss-devel \ | |
17 | openldap-devel pam-devel gdb gcc annobin make | |
18 | sudo dnf builddep -y --spec slapi-nis.spec --best --allowerasing --setopt=install_weak_deps=False | |
19 | displayName: Prepare build environment | |
20 | - script: | | |
21 | mkdir -p $(builddir)/dist | |
22 | make -f .copr/Makefile outdir=$(builddir)/dist SUDO=sudo srpm | |
23 | rpmbuild --rebuild \ | |
24 | --define "_topdir $(builddir)/build" \ | |
25 | --define "_sourcedir $(builddir)/build" \ | |
26 | --define "_specdir $(builddir)/build" \ | |
27 | --define "_builddir $(builddir)/build" \ | |
28 | --define "_srcrpmdir $(builddir)/dist" \ | |
29 | --define "_rpmdir $(builddir)/dist" \ | |
30 | $(builddir)/dist/*.src.rpm | |
31 | displayName: Build packages | |
32 | - script: | | |
33 | mv $(builddir)/dist/*/*.rpm $(builddir)/dist/ | |
34 | ls -la $(builddir)/dist | |
35 | displayName: List packages | |
36 | - task: PublishPipelineArtifact@0 | |
37 | displayName: Publish packages | |
38 | inputs: | |
39 | artifactName: 'packages-$(Build.BuildId)-$(Agent.OS)-$(Agent.OSArchitecture)' | |
40 | targetPath: $(Build.Repository.LocalPath)/dist | |
41 | condition: always() | |
42 | ||
43 | - job: Install_with_FreeIPA_packages | |
44 | dependsOn: Build | |
45 | condition: succeeded() | |
46 | pool: | |
47 | vmImage: 'Ubuntu-16.04' | |
48 | variables: | |
49 | builddir: /__w/1/s | |
50 | container: | |
51 | image: f30/fedora-toolbox | |
52 | endpoint: fedora-project-registry | |
53 | steps: | |
54 | - checkout: none | |
55 | - task: DownloadPipelineArtifact@0 | |
56 | displayName: Download pre-built packages | |
57 | inputs: | |
58 | artifactName: 'packages-$(Build.BuildId)-$(Agent.OS)-$(Agent.OSArchitecture)' | |
59 | targetPath: $(Build.Repository.LocalPath)/dist | |
60 | - script: | | |
61 | rm -f $(builddir)/dist/*.src.rpm | |
62 | displayName: Remove source package | |
63 | - script: | | |
64 | sudo rm -rf /var/cache/dnf/* | |
65 | cd $(builddir) | |
66 | sudo dnf makecache || : | |
67 | sudo dnf -y install freeipa-server-dns freeipa-server $(builddir)/dist/*.rpm | |
68 | displayName: Attempt package installation | |
69 |
11 | 11 | $(RPCGEN) -h -o $@ $^ |
12 | 12 | yp_xdr.c: ../../yp/yp.x |
13 | 13 | $(RM) -f $@ |
14 | $(RPCGEN) -c -o $@ $^ | |
14 | $(RPCGEN) -c -i 0 -o $@ $^ | |
15 | 15 | yp_clnt.c: ../../yp/yp.x |
16 | 16 | $(RM) -f $@ |
17 | 17 | $(RPCGEN) -l -o $@ $^ |
33 | 33 | #include <rpc/rpc.h> |
34 | 34 | #include "../../yp/yp.h" |
35 | 35 | |
36 | typedef int (*xdrrec_proc_t)(void *, void *, int); | |
37 | ||
36 | 38 | static struct sockaddr_in server; |
37 | 39 | static int connected; |
38 | 40 | |
161 | 163 | static int |
162 | 164 | all(CLIENT *client, FILE *output, int argc, char **argv) |
163 | 165 | { |
164 | ypresp_all *ret; | |
165 | int i, sock; | |
166 | int sock; | |
166 | 167 | ypreq_nokey nokey; |
167 | 168 | struct rpc_msg req, rep; |
168 | 169 | struct ypresp_all resp; |
188 | 189 | } |
189 | 190 | |
190 | 191 | memset(&s, 0, sizeof(s)); |
191 | xdrrec_create(&s, 0, 0, (char *) &sock, &readjunk, &writejunk); | |
192 | xdrrec_create(&s, 0, 0, (char *) &sock, (xdrrec_proc_t) &readjunk, (xdrrec_proc_t) &writejunk); | |
192 | 193 | s.x_op = XDR_ENCODE; |
193 | 194 | |
194 | 195 | memset(&req, 0, sizeof(req)); |
217 | 218 | xdr_destroy(&s); |
218 | 219 | |
219 | 220 | memset(&s, 0, sizeof(s)); |
220 | xdrrec_create(&s, 0, 0, (char *) &sock, &readjunk, &writejunk); | |
221 | xdrrec_create(&s, 0, 0, (char *) &sock, (xdrrec_proc_t) &readjunk, (xdrrec_proc_t) &writejunk); | |
221 | 222 | s.x_op = XDR_DECODE; |
222 | 223 | xdrrec_skiprecord(&s); |
223 | 224 |