Skip to content

Commit 05e391a

Browse files
committed
configure, meson: convert pam detection to meson
Reviewed-by: Daniel P. Berrangé <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ba7ed40 commit 05e391a

File tree

5 files changed

+34
-41
lines changed

5 files changed

+34
-41
lines changed

authz/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ authz_ss.add(files(
66
'simple.c',
77
))
88

9-
authz_ss.add(when: ['CONFIG_AUTH_PAM', pam], if_true: files('pamacct.c'))
9+
authz_ss.add(when: pam, if_true: files('pamacct.c'))

configure

+4-34
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ tls_priority="NORMAL"
407407
gnutls="auto"
408408
nettle="auto"
409409
gcrypt="auto"
410-
auth_pam="$default_feature"
410+
auth_pam="auto"
411411
vte="$default_feature"
412412
virglrenderer="$default_feature"
413413
tpm="$default_feature"
@@ -1383,9 +1383,9 @@ for opt do
13831383
;;
13841384
--enable-gcrypt) gcrypt="enabled"
13851385
;;
1386-
--disable-auth-pam) auth_pam="no"
1386+
--disable-auth-pam) auth_pam="disabled"
13871387
;;
1388-
--enable-auth-pam) auth_pam="yes"
1388+
--enable-auth-pam) auth_pam="enabled"
13891389
;;
13901390
--enable-rdma) rdma="yes"
13911391
;;
@@ -2799,33 +2799,6 @@ EOF
27992799
fi
28002800
fi
28012801

2802-
##########################################
2803-
# PAM probe
2804-
2805-
if test "$auth_pam" != "no"; then
2806-
cat > $TMPC <<EOF
2807-
#include <security/pam_appl.h>
2808-
#include <stdio.h>
2809-
int main(void) {
2810-
const char *service_name = "qemu";
2811-
const char *user = "frank";
2812-
const struct pam_conv pam_conv = { 0 };
2813-
pam_handle_t *pamh = NULL;
2814-
pam_start(service_name, user, &pam_conv, &pamh);
2815-
return 0;
2816-
}
2817-
EOF
2818-
if compile_prog "" "-lpam" ; then
2819-
auth_pam=yes
2820-
else
2821-
if test "$auth_pam" = "yes"; then
2822-
feature_not_found "PAM" "Install PAM development package"
2823-
else
2824-
auth_pam=no
2825-
fi
2826-
fi
2827-
fi
2828-
28292802
##########################################
28302803
# VTE probe
28312804

@@ -5540,9 +5513,6 @@ if test "$gdbus_codegen" != "" ; then
55405513
echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
55415514
fi
55425515
echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5543-
if test "$auth_pam" = "yes" ; then
5544-
echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
5545-
fi
55465516
if test "$have_broken_size_max" = "yes" ; then
55475517
echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
55485518
fi
@@ -6251,7 +6221,7 @@ if test "$skip_meson" = no; then
62516221
-Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
62526222
-Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
62536223
-Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
6254-
-Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt \
6224+
-Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
62556225
-Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
62566226
-Dattr=$attr -Ddefault_devices=$default_devices \
62576227
-Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \

meson.build

+26-5
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,6 @@ if have_system or have_tools
325325
pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
326326
method: 'pkg-config', kwargs: static_kwargs)
327327
endif
328-
pam = not_found
329-
if 'CONFIG_AUTH_PAM' in config_host
330-
pam = cc.find_library('pam')
331-
endif
332328
libaio = cc.find_library('aio', required: false)
333329
zlib = dependency('zlib', required: true, kwargs: static_kwargs)
334330
linux_io_uring = not_found
@@ -907,6 +903,31 @@ if get_option('vnc').enabled()
907903
endif
908904
endif
909905

906+
pam = not_found
907+
if not get_option('auth_pam').auto() or have_system
908+
pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
909+
required: get_option('auth_pam'),
910+
kwargs: static_kwargs)
911+
endif
912+
if pam.found() and not cc.links('''
913+
#include <stddef.h>
914+
#include <security/pam_appl.h>
915+
int main(void) {
916+
const char *service_name = "qemu";
917+
const char *user = "frank";
918+
const struct pam_conv pam_conv = { 0 };
919+
pam_handle_t *pamh = NULL;
920+
pam_start(service_name, user, &pam_conv, &pamh);
921+
return 0;
922+
}''', dependencies: pam)
923+
pam = not_found
924+
if get_option('auth_pam').enabled()
925+
error('could not link libpam')
926+
else
927+
warning('could not link libpam, disabling')
928+
endif
929+
endif
930+
910931
snappy = not_found
911932
if not get_option('snappy').auto() or have_system
912933
snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
@@ -2729,7 +2750,7 @@ summary_info += {'VTE support': config_host.has_key('CONFIG_VTE')}
27292750
# TODO: add back version
27302751
summary_info += {'slirp support': slirp_opt == 'disabled' ? false : slirp_opt}
27312752
summary_info += {'libtasn1': tasn1.found()}
2732-
summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
2753+
summary_info += {'PAM': pam.found()}
27332754
summary_info += {'iconv support': iconv.found()}
27342755
summary_info += {'curses support': curses.found()}
27352756
# TODO: add back version

meson_options.txt

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ option('multiprocess', type: 'feature', value: 'auto',
5252

5353
option('attr', type : 'feature', value : 'auto',
5454
description: 'attr/xattr support')
55+
option('auth_pam', type : 'feature', value : 'auto',
56+
description: 'PAM access control')
5557
option('brlapi', type : 'feature', value : 'auto',
5658
description: 'brlapi character device driver')
5759
option('bzip2', type : 'feature', value : 'auto',

tests/unit/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if have_block
9494
'test-io-channel-tls': ['io-channel-helpers.c', 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
9595
tasn1, io, crypto, gnutls]}
9696
endif
97-
if 'CONFIG_AUTH_PAM' in config_host
97+
if pam.found()
9898
tests += {'test-authz-pam': [authz]}
9999
endif
100100
if xts == 'private'

0 commit comments

Comments
 (0)