1 From 236d6c8c0dd7e15d9a9795813b94bc87ce09eec5 Mon Sep 17 00:00:00 2001
2 From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
3 Date: Fri, 29 Apr 2022 19:32:29 +0200
4 Subject: [PATCH] Make it possible to build without debconf support
6 Not all systems have the debconfclient library available.
8 Upstream-Status: Submitted [https://salsa.debian.org/debian/base-passwd/-/merge_requests/11]
9 Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
12 configure.ac | 13 +++++++++++++
13 update-passwd.c | 15 +++++++++++++++
14 3 files changed, 28 insertions(+), 1 deletion(-)
16 diff --git a/Makefile.am b/Makefile.am
17 index 223916f..4bdd769 100644
20 @@ -3,7 +3,6 @@ SUBDIRS = doc man
21 sbin_PROGRAMS = update-passwd
23 update_passwd_SOURCES = update-passwd.c
24 -update_passwd_LDADD = -ldebconfclient
26 pkgdata_DATA = passwd.master group.master
28 diff --git a/configure.ac b/configure.ac
29 index 9d1ace5..1e35ad1 100644
32 @@ -14,6 +14,19 @@ AC_SYS_LARGEFILE
33 dnl Scan for things we need
34 AC_CHECK_FUNCS([putgrent])
36 +dnl Check for debconf
37 +AC_MSG_CHECKING([whether to enable debconf support])
38 +AC_ARG_ENABLE([debconf],
39 + [AS_HELP_STRING([--disable-debconf], [disable support for debconf])],
41 + [enable_debconf=yes])
42 +AC_MSG_RESULT($enable_debconf)
43 +AS_IF([test "x$enable_debconf" != xno],
44 + [AC_CHECK_LIB([debconfclient], [debconfclient_new], [],
46 + [debconf support not available (use --disable-debconf to disable)])])
47 + AC_DEFINE([HAVE_DEBCONF], [1], [Define if you have libdebconfclient])])
49 dnl Finally output everything
50 AC_CONFIG_FILES([Makefile doc/Makefile man/Makefile])
52 diff --git a/update-passwd.c b/update-passwd.c
53 index 3f3dffa..5b49740 100644
61 #include <cdebconf/debconfclient.h>
64 #define DEFAULT_PASSWD_MASTER "/usr/share/base-passwd/passwd.master"
65 #define DEFAULT_GROUP_MASTER "/usr/share/base-passwd/group.master"
66 @@ -143,6 +145,7 @@ int flag_debconf = 0;
67 const char* user_domain = DEFAULT_DEBCONF_DOMAIN;
68 const char* group_domain = DEFAULT_DEBCONF_DOMAIN;
71 struct debconfclient* debconf = NULL;
73 /* Abort the program if talking to debconf fails. Use ret exactly once. */
74 @@ -162,6 +165,10 @@ struct debconfclient* debconf = NULL;
75 DEBCONF_CHECK(debconf_register(debconf, (template), (question)))
76 #define DEBCONF_SUBST(question, var, value) \
77 DEBCONF_CHECK(debconf_subst(debconf, (question), (var), (value)))
79 +#define DEBCONF_REGISTER(template, question)
80 +#define DEBCONF_SUBST(question, var, value)
84 /* malloc() with out-of-memory checking.
85 @@ -621,6 +628,7 @@ void version() {
86 * flag. Aborts the problem on any failure.
88 int ask_debconf(const char* priority, const char* question) {
93 @@ -640,6 +648,9 @@ int ask_debconf(const char* priority, const char* question) {
103 @@ -1427,6 +1438,7 @@ int main(int argc, char** argv) {
104 /* If DEBIAN_HAS_FRONTEND is set in the environment, we're running under
105 * debconf. Enable debconf prompting unless --dry-run was also given.
108 if (getenv("DEBIAN_HAS_FRONTEND")!=NULL && !opt_dryrun) {
109 debconf=debconfclient_new();
111 @@ -1435,6 +1447,7 @@ int main(int argc, char** argv) {
117 if (read_passwd(&master_accounts, master_passwd)!=0)
119 @@ -1480,8 +1493,10 @@ int main(int argc, char** argv) {
125 debconfclient_delete(debconf);