From: Didier Raboud <odyx@debian.org>
Date: Tue, 9 Aug 2016 18:11:24 +0200
Subject: Debian: Move cupsd.conf.default from SERVERROOT to DATADIR

Origin: vendor
Bug: https://github.com/apple/cups/issues/4342
Bug: https://github.com/OpenPrinting/cups/pull/26
Bug-Debian: https://bugs.debian.org/640124
---
 cgi-bin/admin.c | 6 +++++-
 conf/Makefile   | 5 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

Index: cups/cgi-bin/admin.c
===================================================================
--- cups.orig/cgi-bin/admin.c	2022-02-20 07:05:20.762157072 +0000
+++ cups/cgi-bin/admin.c	2022-02-20 07:05:20.754156523 +0000
@@ -1635,6 +1635,7 @@
     int		ch;			/* Character from file */
     char	filename[1024];		/* Filename */
     const char	*server_root;		/* Location of config files */
+    const char	*data_dir;		/* Location of data files */
 
 
    /*
@@ -1718,7 +1719,10 @@
     * well...
     */
 
-    strlcat(filename, ".default", sizeof(filename));
+    if ((data_dir = getenv("CUPS_DATADIR")) == NULL)
+      data_dir = CUPS_DATADIR;
+
+    snprintf(filename, sizeof(filename), "%s/cupsd.conf.default",data_dir);
 
     if (!stat(filename, &info) && info.st_size < (1024 * 1024) &&
         (cupsd = cupsFileOpen(filename, "r")) != NULL)
Index: cups/conf/Makefile
===================================================================
--- cups.orig/conf/Makefile	2022-02-20 07:05:20.762157072 +0000
+++ cups/conf/Makefile	2022-02-20 07:05:20.754156523 +0000
@@ -70,7 +70,7 @@
 		else \
 			$(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT) ; \
 		fi ; \
-		$(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT)/$$file.default; \
+		$(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(DATADIR)/$$file.default; \
 	done
 	$(INSTALL_DIR) -m 755 $(DATADIR)/mime
 	for file in $(REPLACE); do \
@@ -118,9 +118,10 @@
 #
 
 uninstall:
-	for file in $(KEEP) $(REPLACE) cupsd.conf.default; do \
+	for file in $(KEEP) $(REPLACE); do \
 		$(RM) $(SERVERROOT)/$$file; \
 	done
+	$(RM) $(DATADIR)/cupsd.conf.default
 	-$(RMDIR) $(SERVERROOT)
 	for file in $(REPLACE); do \
 		$(RM) $(DATADIR)/mime/$$file; \
