Skip to content

Commit b4072df

Browse files
august-altSemyon Knyazev
authored andcommitted
Add conditional build for LAPS v2
1 parent ed6130b commit b4072df

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

.gear/admc.spec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
%define _unpackaged_files_terminate_build 1
22

3+
%ifdef _priority_distbranch
4+
%define altbranch %_priority_distbranch
5+
%else
6+
%define altbranch %(rpm --eval %%_priority_distbranch)
7+
%endif
8+
%if "%altbranch" == "%nil"
9+
%define altbranch sisyphus
10+
%endif
11+
312
Name: admc
413
Version: 0.19.0
514
Release: alt1
@@ -25,8 +34,11 @@ BuildRequires: qt5-base-common
2534
BuildRequires: doxygen
2635
BuildRequires: libuuid-devel
2736
BuildRequires: libkrb5-devel
37+
38+
%if "%altbranch" == "sisyphus" || "%altbranch" == "p11"
2839
BuildRequires: libcng-dpapi-devel
2940
BuildRequires: libgkdi-devel
41+
%endif
3042

3143
Requires: libsasl2
3244
Requires: libsasl2-plugin-gssapi

src/admc/CMakeLists.txt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@ set(CMAKE_AUTOMOC ON)
99
set(CMAKE_AUTORCC ON)
1010
set(CMAKE_AUTOUIC ON)
1111

12+
find_library(LIBCNG_DPAPI_LIBRARY libcng-dpapi.so)
13+
1214
set(ADMC_APPLICATION_NAME "ADMC")
1315
set(ADMC_APPLICATION_DISPLAY_NAME "ADMC")
1416
set(ADMC_ORGANIZATION "BaseALT")
1517
set(ADMC_ORGANIZATION_DOMAIN "basealt.ru")
18+
19+
if (LIBCNG_DPAPI_LIBRARY)
20+
set(ADMC_ENABLE_NATIVE_LAPS 1)
21+
else()
22+
set(ADMC_ENABLE_NATIVE_LAPS 0)
23+
endif()
24+
1625
configure_file("config.h.in" "config.h")
1726

1827
include_directories(
@@ -35,9 +44,18 @@ if (RESOLV_LIBRARY)
3544
link_libraries(${RESOLV_LIBRARY})
3645
endif()
3746

38-
find_library(LIBCNG_DPAPI_LIBRARY libcng-dpapi.so REQUIRED)
3947

40-
link_libraries(${LIBCNG_DPAPI_LIBRARY})
48+
if (LIBCNG_DPAPI_LIBRARY)
49+
message("Found libcng-dpapi library in ${LIBCNG_DPAPI_LIBRARY} .")
50+
link_libraries(${LIBCNG_DPAPI_LIBRARY})
51+
set(LAPS_SOURCES
52+
tabs/laps_v2_tab.cpp
53+
attribute_edits/laps_encrypted_attribute_edit.cpp
54+
)
55+
else()
56+
message("Skipping libcng-dpapi library.")
57+
set(LAPS_SOURCES "")
58+
endif()
4159

4260
set(ADMC_SOURCES
4361
status.cpp
@@ -140,7 +158,6 @@ set(ADMC_SOURCES
140158
tabs/delegation_tab.cpp
141159
tabs/select_well_known_trustee_dialog.cpp
142160
tabs/laps_tab.cpp
143-
tabs/laps_v2_tab.cpp
144161
tabs/error_tab.cpp
145162
tabs/group_policy_tab.cpp
146163

@@ -179,7 +196,6 @@ set(ADMC_SOURCES
179196
attribute_edits/logon_computers_edit.cpp
180197
attribute_edits/logon_computers_dialog.cpp
181198
attribute_edits/protect_deletion_edit.cpp
182-
attribute_edits/laps_encrypted_attribute_edit.cpp
183199
attribute_edits/laps_expiry_edit.cpp
184200
attribute_edits/general_name_edit.cpp
185201
attribute_edits/dn_edit.cpp
@@ -231,6 +247,8 @@ set(ADMC_SOURCES
231247
admc.qrc
232248
)
233249

250+
set(ADMC_SOURCES ${ADMC_SOURCES} ${LAPS_SOURCES})
251+
234252
add_executable(admc
235253
main.cpp
236254
${ADMC_SOURCES}

src/admc/config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@
3636
# define ADMC_ORGANIZATION "${ADMC_ORGANIZATION}"
3737
# define ADMC_ORGANIZATION_DOMAIN "${ADMC_ORGANIZATION_DOMAIN}"
3838

39+
# define ADMC_ENABLE_NATIVE_LAPS @ADMC_ENABLE_NATIVE_LAPS@
40+
3941
#endif /* __ADMC_CONFIG_H */
4042

src/admc/properties_widgets/properties_dialog.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "adldap.h"
2525
#include "console_impls/object_impl.h"
2626
#include "globals.h"
27+
#include "config.h"
2728
#include "properties_warning_dialog.h"
2829
#include "security_sort_warning_dialog.h"
2930
#include "settings.h"
@@ -43,7 +44,9 @@
4344
#include "tabs/general_user_tab.h"
4445
#include "tabs/group_policy_tab.h"
4546
#include "tabs/laps_tab.h"
47+
#if ADMC_ENABLE_NATIVE_LAPS > 0
4648
#include "tabs/laps_v2_tab.h"
49+
#endif
4750
#include "tabs/managed_by_tab.h"
4851
#include "tabs/membership_tab.h"
4952
#include "tabs/object_tab.h"
@@ -240,6 +243,7 @@ PropertiesDialog::PropertiesDialog(AdInterface &ad, const QString &target_arg, C
240243
return out;
241244
}();
242245

246+
#if ADMC_ENABLE_NATIVE_LAPS > 0
243247
const bool laps_v2_enabled = [&]() {
244248
const QList<QString> attribute_list = object.attributes();
245249
const bool out = ((attribute_list.contains(ATTRIBUTE_LAPS_V2_ENCRYPTED_PASSWORD)
@@ -248,17 +252,21 @@ PropertiesDialog::PropertiesDialog(AdInterface &ad, const QString &target_arg, C
248252
&& attribute_list.contains(ATTRIBUTE_LAPS_V2_EXPIRATION_TIME));
249253
return out;
250254
}();
251-
255+
#else
256+
const bool laps_v2_enabled = false;
257+
#endif
252258
if (laps_enabled && !laps_v2_enabled) {
253259
auto laps_tab = new LAPSTab(&edit_list, this);
254260
ui->tab_widget->add_tab(laps_tab, tr("LAPS"));
255261
}
256262

263+
#if ADMC_ENABLE_NATIVE_LAPS > 0
257264
if (laps_v2_enabled)
258265
{
259266
auto laps_v2_tab = new LAPSV2Tab(&edit_list, this);
260267
ui->tab_widget->add_tab(laps_v2_tab, tr("LAPS"));
261268
}
269+
#endif
262270
}
263271

264272
const bool need_security_tab = object.attributes().contains(ATTRIBUTE_SECURITY_DESCRIPTOR);

0 commit comments

Comments
 (0)