aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2024-10-15 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2024-10-15 08:00:00 +0000
commit29c390c7e5c7ee12a1beebd7458aed2fcba53f91 (patch)
tree8c9490a470d75a0e96d92a82d3f4d77922bfc450
parent83aa08a30f39c10e4cecae43686eb86a1e045496 (diff)
downloadpam-29c390c7e5c7ee12a1beebd7458aed2fcba53f91.tar.gz
pam-29c390c7e5c7ee12a1beebd7458aed2fcba53f91.tar.bz2
pam-29c390c7e5c7ee12a1beebd7458aed2fcba53f91.zip
build: check gdbm_close return type
gdbm_close() used to return void, later it was changed to return int. We cannot assume either way and have to check whether gdbm_close() returns int. Fixes: 45c2c496dcf8 ("pam_userdb: enable GDBM support")
-rw-r--r--meson.build6
-rw-r--r--modules/pam_userdb/pam_userdb.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 840ff74f..7fc68b96 100644
--- a/meson.build
+++ b/meson.build
@@ -372,6 +372,12 @@ else
if have
use_db = 'gdbm'
cdata.set('HAVE_GDBM_H', 1)
+ if cc.compiles('''#include <gdbm.h>
+ int db_close(void *dbm) {return gdbm_close(dbm);}''',
+ args: '-D_GNU_SOURCE',
+ name: 'gdbm_close returns int')
+ cdata.set('GDBM_CLOSE_RETURNS_INT', 1)
+ endif
endif
endif
endif
diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c
index e5942c8a..71012e57 100644
--- a/modules/pam_userdb/pam_userdb.c
+++ b/modules/pam_userdb/pam_userdb.c
@@ -185,7 +185,12 @@ static int
db_close(void *dbm)
{
#ifdef HAVE_GDBM_H
+# ifdef GDBM_CLOSE_RETURNS_INT
return gdbm_close(dbm);
+# else
+ gdbm_close(dbm);
+ return 0;
+# endif
#else
dbm_close(dbm);
return 0;