]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Update cups-files.conf man page. 942/head
authorMichael R Sweet <msweet@msweet.org>
Tue, 16 Apr 2024 12:51:38 +0000 (08:51 -0400)
committerMichael R Sweet <msweet@msweet.org>
Tue, 16 Apr 2024 12:51:38 +0000 (08:51 -0400)
Move writing of strings files to cupsdCleanDirty, and add new
CUPSD_DIRTY_STRINGS bit.

Update PPD cache version and check modification time of cups-files.conf to
trigger re-load of strings.

Make sure "strings" subdirectory is created as necessary.

cups/ppd-private.h
cups/string-private.h
doc/help/man-cups-files.conf.html
man/cups-files.conf.5
scheduler/conf.c
scheduler/cupsd.h
scheduler/printers.c
scheduler/printers.h
scheduler/sysman.c
scheduler/sysman.h

index fbeac2d5599bee3b3a9a4267d45bbf5541526e6d..3f88fb46fdface94a112c1c6c1cde0a0d60e31fb 100644 (file)
@@ -25,7 +25,7 @@ extern "C" {
  * Constants...
  */
 
-#  define _PPD_CACHE_VERSION   12      /* Version number in cache file */
+#  define _PPD_CACHE_VERSION   13      /* Version number in cache file */
 
 
 /*
index 6f9d35dbe358d06a796fd61ad325750b171a4ac1..966382238cd4119f79581785429fe79830384a9c 100644 (file)
@@ -129,10 +129,10 @@ extern void       _cups_strcpy(char *dst, const char *src) _CUPS_PRIVATE;
 extern int     _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE;
 extern int     _cups_strncasecmp(const char *, const char *, size_t n) _CUPS_PRIVATE;
 
-extern int _cupsArrayStrcasecmp(const char *s, const char *t, void *data) _CUPS_PRIVATE;
-extern int _cupsArrayStrcmp(const char *s1, const char *s2, void *data) _CUPS_PRIVATE;
-extern char *_cupsArrayStrdup(const char *element, void *data) _CUPS_PRIVATE;
-extern void _cupsArrayFree(void *element, void *data) _CUPS_PRIVATE;
+extern int     _cupsArrayStrcasecmp(const char *s, const char *t, void *data) _CUPS_PRIVATE;
+extern int     _cupsArrayStrcmp(const char *s1, const char *s2, void *data) _CUPS_PRIVATE;
+extern char    *_cupsArrayStrdup(const char *element, void *data) _CUPS_PRIVATE;
+extern void    _cupsArrayFree(void *element, void *data) _CUPS_PRIVATE;
 
 extern char    *_cupsStrAlloc(const char *s) _CUPS_PRIVATE;
 extern char    *_cupsStrDate(char *buf, size_t bufsize, time_t timeval) _CUPS_PRIVATE;
index 9168af6a4082c45c2972a66db925331ebce9b26e..a4af17b927e30a728dc46eea967e310211777945 100644 (file)
@@ -124,6 +124,10 @@ Bad startup file permissions are fatal, for example shared TLS certificate and k
     <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>Group </strong><em>group-name-or-number</em><br>
 Specifies the group name or ID that will be used when executing external programs.
 The default group is operating system specific but is usually &quot;lp&quot; or &quot;nobody&quot;.
+</p>
+    <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>Languages </strong><em>LOCALE ... LOCALE</em><br>
+Lists the language locales that should be supported by the server.
+The default is English (&quot;en&quot;) and the current system locale (if not English).
 </p>
     <p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>LogFileGroup </strong><em>group-name-or-number</em><br>
 Specifies the group name or ID that will be used for log files.
index cbc7b1841a243333110d2fbfcc27ad820ddccfeb..1c43626e17214d9b07d4f10d084d848656382bdf 100644 (file)
@@ -8,7 +8,7 @@
 .\" Licensed under Apache License v2.0.  See the file "LICENSE" for more
 .\" information.
 .\"
-.TH cups-files.conf 5 "CUPS" "2021-03-06" "OpenPrinting"
+.TH cups-files.conf 5 "CUPS" "2024-04-16" "OpenPrinting"
 .SH NAME
 cups\-files.conf \- file and directory configuration file for cups
 .SH DESCRIPTION
@@ -132,6 +132,11 @@ Bad startup file permissions are fatal, for example shared TLS certificate and k
 \fBGroup \fIgroup-name-or-number\fR
 Specifies the group name or ID that will be used when executing external programs.
 The default group is operating system specific but is usually "lp" or "nobody".
+.\"#Languages
+.TP 5
+\fBLanguages \fILOCALE ... LOCALE\fR
+Lists the language locales that should be supported by the server.
+The default is English ("en") and the current system locale (if not English).
 .\"#LogFileGroup
 .TP 5
 \fBLogFileGroup \fIgroup-name-or-number\fR
index 6846f47bc7d3384c92121ac3468785e415c0a572..95abf82925547837ac242366d44869dcba87d9df 100644 (file)
@@ -1737,11 +1737,17 @@ cupsdWriteStrings(void)
   char         strings_file[1024];     // Strings file
 
 
+  // Make sure the strings directory is there...
+  if (cupsdCheckPermissions(ServerRoot, "strings", 0755, RunUser, Group, /*is_dir*/1, /*create_dir*/1) < 0)
+    return;
+
   // Save each language...
   for (lang = Languages; lang; lang = lang->next)
   {
     snprintf(strings_file, sizeof(strings_file), "%s/strings/%s.strings", ServerRoot, lang->language);
-    _cupsMessageSave(strings_file, _CUPS_MESSAGE_STRINGS, lang->strings);
+
+    if (_cupsMessageSave(strings_file, _CUPS_MESSAGE_STRINGS, lang->strings))
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to save '%s': %s", strings_file, strerror(errno));
   }
 }
 
index cf2023fc6f4fdc668293dc340f3325ec0c6d716b..689b88b49b2528f618d8a7f7847a9ac6ee5c6c9d 100644 (file)
@@ -9,11 +9,6 @@
  * information.
  */
 
-
-/*
- * Include necessary headers.
- */
-
 #include <cups/cups-private.h>
 #include <cups/file-private.h>
 #include <cups/ppd-private.h>
@@ -230,7 +225,3 @@ extern void         cupsdStopSelect(void);
 /* server.c */
 extern void            cupsdStartServer(void);
 extern void            cupsdStopServer(void);
-
-extern int             _cupsArrayStrcmp(const char *s1, const char *s2, void *data);
-extern char            *_cupsArrayStrdup(const char *element, void *data);
-extern void            _cupsArrayFree(void *element, void *data);
index 24353f20b57a305807d77064e7659335b107cb96..e67d32b41dd27443bcfe3284f6dd5d2b3a22d44e 100644 (file)
@@ -735,7 +735,6 @@ cupsdDeletePrinter(
   cupsdClearString(&p->port_monitor);
   cupsdClearString(&p->op_policy);
   cupsdClearString(&p->error_policy);
-  cupsdClearString(&p->strings);
 
   cupsdClearString(&p->alert);
   cupsdClearString(&p->alert_description);
@@ -3756,6 +3755,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
   char         cache_name[1024];       /* Cache filename */
   struct stat  cache_info;             /* Cache file info */
   struct stat  conf_info;              /* cupsd.conf file info */
+  struct stat  files_info;             /* cups-files.conf file info */
   ppd_file_t   *ppd;                   /* PPD file */
   char         ppd_name[1024];         /* PPD filename */
   struct stat  ppd_info;               /* PPD file info */
@@ -3888,6 +3888,9 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
   if (stat(ConfigurationFile, &conf_info))
     conf_info.st_mtime = 0;
 
+  if (stat(CupsFilesFile, &files_info))
+    files_info.st_mtime = 0;
+
   snprintf(cache_name, sizeof(cache_name), "%s/%s.data", CacheDir, p->name);
   if (stat(cache_name, &cache_info))
     cache_info.st_mtime = 0;
@@ -3904,7 +3907,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
   _ppdCacheDestroy(p->pc);
   p->pc = NULL;
 
-  if (cache_info.st_mtime >= ppd_info.st_mtime && cache_info.st_mtime >= conf_info.st_mtime)
+  if (cache_info.st_mtime >= ppd_info.st_mtime && cache_info.st_mtime >= conf_info.st_mtime && cache_info.st_mtime >= files_info.st_mtime)
   {
     cupsdLogMessage(CUPSD_LOG_DEBUG, "load_ppd: Loading %s...", cache_name);
 
@@ -3915,16 +3918,6 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
       * Loaded successfully!
       */
 
-     /*
-      * Set `strings` (source for printer-strings-uri IPP attribute)
-      * if printer's .strings file with localization exists.
-      */
-
-      if (!access(strings_name, R_OK))
-       cupsdSetString(&p->strings, strings_name);
-      else
-       cupsdClearString(&p->strings);
-
       return;
     }
   }
@@ -4029,7 +4022,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
     if (!p->pc)
       cupsdLogMessage(CUPSD_LOG_WARN, "Unable to create cache of \"%s\": %s", ppd_name, cupsGetErrorString());
 
-    cupsdWriteStrings();
+    cupsdMarkDirty(CUPSD_DIRTY_STRINGS);
 
     ppdMarkDefaults(ppd);
 
index 48d8aacf57893f6a6b93a1db7f92a2367c933369..3c1b12de41a88c9661d4bb1b2f9afb59af6c28d2 100644 (file)
@@ -64,7 +64,6 @@ struct cupsd_printer_s
                *info,                  /* Description */
                *organization,          /* Organization name */
                *organizational_unit,   /* Organizational unit (department, etc.) */
-               *strings,               /* Strings file, if any */
                *op_policy,             /* Operation policy name */
                *error_policy;          /* Error policy */
   cupsd_policy_t *op_policy_ptr;       /* Pointer to operation policy */
index 13ca84c20c43d3619852ac7204f282bbd0a738fd..cce3fa986cbe723c3dc5f334dcd7cea09b62e251 100644 (file)
@@ -69,6 +69,9 @@ cupsdCleanDirty(void)
   if (DirtyFiles & CUPSD_DIRTY_SUBSCRIPTIONS)
     cupsdSaveAllSubscriptions();
 
+  if (DirtyFiles & CUPSD_DIRTY_STRINGS)
+    cupsdWriteStrings();
+
   DirtyFiles     = CUPSD_DIRTY_NONE;
   DirtyCleanTime = 0;
 
index e9091bac4c8820a753f21cdcef6508ae7ba23869..e155705cb9c3543ae7f6844d355f91d21d67b37b 100644 (file)
@@ -18,6 +18,7 @@
 #define CUPSD_DIRTY_PRINTCAP   4       /* printcap is dirty */
 #define CUPSD_DIRTY_JOBS       8       /* jobs.cache or "c" file(s) are dirty */
 #define CUPSD_DIRTY_SUBSCRIPTIONS 16   /* subscriptions.conf is dirty */
+#define CUPSD_DIRTY_STRINGS    32      /* The .strings files are dirty */
 
 
 /*