2 * "$Id: conf.c 10121 2011-11-16 15:28:11Z mike $"
4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdAddAlias() - Add a host alias.
18 * cupsdCheckPermissions() - Fix the mode and ownership of a file or
20 * cupsdFreeAliases() - Free all of the alias entries.
21 * cupsdReadConfiguration() - Read the cupsd.conf file.
22 * get_address() - Get an address + port number from a line.
23 * get_addr_and_mask() - Get an IP address and netmask.
24 * mime_error_cb() - Log a MIME error.
25 * parse_aaa() - Parse authentication, authorization, and access
27 * parse_fatal_errors() - Parse FatalErrors values in a string.
28 * parse_groups() - Parse system group names in a string.
29 * parse_protocols() - Parse browse protocols in a string.
30 * read_configuration() - Read a configuration file.
31 * read_location() - Read a <Location path> definition.
32 * read_policy() - Read a <Policy name> definition.
33 * set_policy_defaults() - Set default policy values as needed.
37 * Include necessary headers...
43 #include <sys/utsname.h>
48 #endif /* HAVE_LIBPAPER */
52 * Possibly missing network definitions...
56 # define INADDR_NONE 0xffffffff
57 #endif /* !INADDR_NONE */
61 * Configuration variable structure...
66 CUPSD_VARTYPE_INTEGER, /* Integer option */
67 CUPSD_VARTYPE_STRING, /* String option */
68 CUPSD_VARTYPE_BOOLEAN, /* Boolean option */
69 CUPSD_VARTYPE_PATHNAME /* File/directory name option */
74 char *name; /* Name of variable */
75 void *ptr; /* Pointer to variable */
76 cupsd_vartype_t type; /* Type (int, string, address) */
84 static const cupsd_var_t variables[] =
86 { "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING },
87 { "AutoPurgeJobs", &JobAutoPurge, CUPSD_VARTYPE_BOOLEAN },
89 { "BrowseDNSSDRegType", &DNSSDRegType, CUPSD_VARTYPE_STRING },
90 #endif /* HAVE_DNSSD */
91 { "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER },
93 { "BrowseLDAPBindDN", &BrowseLDAPBindDN, CUPSD_VARTYPE_STRING },
95 { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile, CUPSD_VARTYPE_PATHNAME },
96 # endif /* HAVE_LDAP_SSL */
97 { "BrowseLDAPDN", &BrowseLDAPDN, CUPSD_VARTYPE_STRING },
98 { "BrowseLDAPPassword", &BrowseLDAPPassword, CUPSD_VARTYPE_STRING },
99 { "BrowseLDAPServer", &BrowseLDAPServer, CUPSD_VARTYPE_STRING },
100 #endif /* HAVE_LDAP */
101 { "BrowseLocalOptions", &BrowseLocalOptions, CUPSD_VARTYPE_STRING },
102 { "BrowsePort", &BrowsePort, CUPSD_VARTYPE_INTEGER },
103 { "BrowseRemoteOptions", &BrowseRemoteOptions, CUPSD_VARTYPE_STRING },
104 { "BrowseShortNames", &BrowseShortNames, CUPSD_VARTYPE_BOOLEAN },
105 { "BrowseTimeout", &BrowseTimeout, CUPSD_VARTYPE_INTEGER },
106 { "BrowseWebIF", &BrowseWebIF, CUPSD_VARTYPE_BOOLEAN },
107 { "Browsing", &Browsing, CUPSD_VARTYPE_BOOLEAN },
108 { "CacheDir", &CacheDir, CUPSD_VARTYPE_STRING },
109 { "Classification", &Classification, CUPSD_VARTYPE_STRING },
110 { "ClassifyOverride", &ClassifyOverride, CUPSD_VARTYPE_BOOLEAN },
111 { "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_INTEGER },
112 { "DataDir", &DataDir, CUPSD_VARTYPE_STRING },
113 { "DefaultLanguage", &DefaultLanguage, CUPSD_VARTYPE_STRING },
114 { "DefaultLeaseDuration", &DefaultLeaseDuration, CUPSD_VARTYPE_INTEGER },
115 { "DefaultPaperSize", &DefaultPaperSize, CUPSD_VARTYPE_STRING },
116 { "DefaultPolicy", &DefaultPolicy, CUPSD_VARTYPE_STRING },
117 { "DefaultShared", &DefaultShared, CUPSD_VARTYPE_BOOLEAN },
118 { "DirtyCleanInterval", &DirtyCleanInterval, CUPSD_VARTYPE_INTEGER },
119 { "DocumentRoot", &DocumentRoot, CUPSD_VARTYPE_STRING },
120 { "ErrorLog", &ErrorLog, CUPSD_VARTYPE_STRING },
121 { "ErrorPolicy", &ErrorPolicy, CUPSD_VARTYPE_STRING },
122 { "FileDevice", &FileDevice, CUPSD_VARTYPE_BOOLEAN },
123 { "FilterLimit", &FilterLimit, CUPSD_VARTYPE_INTEGER },
124 { "FilterNice", &FilterNice, CUPSD_VARTYPE_INTEGER },
125 { "FontPath", &FontPath, CUPSD_VARTYPE_STRING },
126 { "HideImplicitMembers", &HideImplicitMembers, CUPSD_VARTYPE_BOOLEAN },
127 { "ImplicitClasses", &ImplicitClasses, CUPSD_VARTYPE_BOOLEAN },
128 { "ImplicitAnyClasses", &ImplicitAnyClasses, CUPSD_VARTYPE_BOOLEAN },
129 { "JobKillDelay", &JobKillDelay, CUPSD_VARTYPE_INTEGER },
130 { "JobRetryLimit", &JobRetryLimit, CUPSD_VARTYPE_INTEGER },
131 { "JobRetryInterval", &JobRetryInterval, CUPSD_VARTYPE_INTEGER },
132 { "KeepAliveTimeout", &KeepAliveTimeout, CUPSD_VARTYPE_INTEGER },
133 { "KeepAlive", &KeepAlive, CUPSD_VARTYPE_BOOLEAN },
135 { "LaunchdTimeout", &LaunchdTimeout, CUPSD_VARTYPE_INTEGER },
136 #endif /* HAVE_LAUNCHD */
137 { "LimitRequestBody", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
138 { "ListenBackLog", &ListenBackLog, CUPSD_VARTYPE_INTEGER },
139 { "LogDebugHistory", &LogDebugHistory, CUPSD_VARTYPE_INTEGER },
140 { "LogFilePerm", &LogFilePerm, CUPSD_VARTYPE_INTEGER },
141 { "LPDConfigFile", &LPDConfigFile, CUPSD_VARTYPE_STRING },
142 { "MaxActiveJobs", &MaxActiveJobs, CUPSD_VARTYPE_INTEGER },
143 { "MaxClients", &MaxClients, CUPSD_VARTYPE_INTEGER },
144 { "MaxClientsPerHost", &MaxClientsPerHost, CUPSD_VARTYPE_INTEGER },
145 { "MaxCopies", &MaxCopies, CUPSD_VARTYPE_INTEGER },
146 { "MaxEvents", &MaxEvents, CUPSD_VARTYPE_INTEGER },
147 { "MaxJobs", &MaxJobs, CUPSD_VARTYPE_INTEGER },
148 { "MaxJobsPerPrinter", &MaxJobsPerPrinter, CUPSD_VARTYPE_INTEGER },
149 { "MaxJobsPerUser", &MaxJobsPerUser, CUPSD_VARTYPE_INTEGER },
150 { "MaxLeaseDuration", &MaxLeaseDuration, CUPSD_VARTYPE_INTEGER },
151 { "MaxLogSize", &MaxLogSize, CUPSD_VARTYPE_INTEGER },
152 { "MaxRequestSize", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
153 { "MaxSubscriptions", &MaxSubscriptions, CUPSD_VARTYPE_INTEGER },
154 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob, CUPSD_VARTYPE_INTEGER },
155 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter, CUPSD_VARTYPE_INTEGER },
156 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser, CUPSD_VARTYPE_INTEGER },
157 { "MultipleOperationTimeout", &MultipleOperationTimeout, CUPSD_VARTYPE_INTEGER },
158 { "PageLog", &PageLog, CUPSD_VARTYPE_STRING },
159 { "PageLogFormat", &PageLogFormat, CUPSD_VARTYPE_STRING },
160 { "PreserveJobFiles", &JobFiles, CUPSD_VARTYPE_BOOLEAN },
161 { "PreserveJobHistory", &JobHistory, CUPSD_VARTYPE_BOOLEAN },
162 { "Printcap", &Printcap, CUPSD_VARTYPE_STRING },
163 { "PrintcapGUI", &PrintcapGUI, CUPSD_VARTYPE_STRING },
164 { "ReloadTimeout", &ReloadTimeout, CUPSD_VARTYPE_INTEGER },
165 { "RemoteRoot", &RemoteRoot, CUPSD_VARTYPE_STRING },
166 { "RequestRoot", &RequestRoot, CUPSD_VARTYPE_STRING },
167 { "RIPCache", &RIPCache, CUPSD_VARTYPE_STRING },
168 { "RootCertDuration", &RootCertDuration, CUPSD_VARTYPE_INTEGER },
169 { "ServerAdmin", &ServerAdmin, CUPSD_VARTYPE_STRING },
170 { "ServerBin", &ServerBin, CUPSD_VARTYPE_PATHNAME },
172 { "ServerCertificate", &ServerCertificate, CUPSD_VARTYPE_PATHNAME },
173 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
174 { "ServerKey", &ServerKey, CUPSD_VARTYPE_PATHNAME },
175 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
176 #endif /* HAVE_SSL */
177 { "ServerName", &ServerName, CUPSD_VARTYPE_STRING },
178 { "ServerRoot", &ServerRoot, CUPSD_VARTYPE_PATHNAME },
179 { "SMBConfigFile", &SMBConfigFile, CUPSD_VARTYPE_STRING },
180 { "StateDir", &StateDir, CUPSD_VARTYPE_STRING },
181 #ifdef HAVE_AUTHORIZATION_H
182 { "SystemGroupAuthKey", &SystemGroupAuthKey, CUPSD_VARTYPE_STRING },
183 #endif /* HAVE_AUTHORIZATION_H */
184 { "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME },
185 { "Timeout", &Timeout, CUPSD_VARTYPE_INTEGER },
186 { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN },
187 { "WebInterface", &WebInterface, CUPSD_VARTYPE_BOOLEAN },
188 { "PidFile", &PidFile, CUPSD_VARTYPE_STRING }
190 #define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
193 static const unsigned ones[4] =
195 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
197 static const unsigned zeros[4] =
199 0x00000000, 0x00000000, 0x00000000, 0x00000000
207 static http_addrlist_t *get_address(const char *value, int defport);
208 static int get_addr_and_mask(const char *value, unsigned *ip,
210 static void mime_error_cb(void *ctx, const char *message);
211 static int parse_aaa(cupsd_location_t *loc, char *line,
212 char *value, int linenum);
213 static int parse_fatal_errors(const char *s);
214 static int parse_groups(const char *s);
215 static int parse_protocols(const char *s);
216 static int read_configuration(cups_file_t *fp);
217 static int read_location(cups_file_t *fp, char *name, int linenum);
218 static int read_policy(cups_file_t *fp, char *name, int linenum);
219 static void set_policy_defaults(cupsd_policy_t *pol);
223 * 'cupsdAddAlias()' - Add a host alias.
227 cupsdAddAlias(cups_array_t *aliases, /* I - Array of aliases */
228 const char *name) /* I - Name to add */
230 cupsd_alias_t *a; /* New alias */
231 size_t namelen; /* Length of name */
234 namelen = strlen(name);
236 if ((a = (cupsd_alias_t *)malloc(sizeof(cupsd_alias_t) + namelen)) == NULL)
239 a->namelen = namelen;
240 strcpy(a->name, name); /* OK since a->name is allocated */
242 cupsArrayAdd(aliases, a);
247 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
250 int /* O - 0 on success, -1 on error, 1 on warning */
251 cupsdCheckPermissions(
252 const char *filename, /* I - File/directory name */
253 const char *suffix, /* I - Additional file/directory name */
254 int mode, /* I - Permissions */
255 int user, /* I - Owner */
256 int group, /* I - Group */
257 int is_dir, /* I - 1 = directory, 0 = file */
258 int create_dir) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
260 int dir_created = 0; /* Did we create a directory? */
261 char pathname[1024]; /* File name with prefix */
262 struct stat fileinfo; /* Stat buffer */
263 int is_symlink; /* Is "filename" a symlink? */
267 * Prepend the given root to the filename before testing it...
272 snprintf(pathname, sizeof(pathname), "%s/%s", filename, suffix);
277 * See if we can stat the file/directory...
280 if (lstat(filename, &fileinfo))
282 if (errno == ENOENT && create_dir)
285 cupsdLogMessage(CUPSD_LOG_DEBUG, "Creating missing directory \"%s\"",
288 if (mkdir(filename, mode))
291 cupsdLogMessage(CUPSD_LOG_ERROR,
292 "Unable to create directory \"%s\" - %s", filename,
295 syslog(LOG_ERR, "Unable to create directory \"%s\" - %s", filename,
302 fileinfo.st_mode = mode | S_IFDIR;
305 return (create_dir ? -1 : 1);
308 if ((is_symlink = S_ISLNK(fileinfo.st_mode)) != 0)
310 if (stat(filename, &fileinfo))
312 cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is a bad symlink - %s",
313 filename, strerror(errno));
319 * Make sure it's a regular file or a directory as needed...
322 if (!dir_created && !is_dir && !S_ISREG(fileinfo.st_mode))
324 cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a regular file.", filename);
328 if (!dir_created && is_dir && !S_ISDIR(fileinfo.st_mode))
331 cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a directory.", filename);
333 syslog(LOG_ERR, "\"%s\" is not a directory.", filename);
339 * If the filename is a symlink, do not change permissions (STR #2937)...
346 * Fix owner, group, and mode as needed...
349 if (dir_created || fileinfo.st_uid != user || fileinfo.st_gid != group)
352 cupsdLogMessage(CUPSD_LOG_DEBUG, "Repairing ownership of \"%s\"",
355 if (chown(filename, user, group) && !getuid())
358 cupsdLogMessage(CUPSD_LOG_ERROR,
359 "Unable to change ownership of \"%s\" - %s", filename,
362 syslog(LOG_ERR, "Unable to change ownership of \"%s\" - %s", filename,
369 if (dir_created || (fileinfo.st_mode & 07777) != mode)
372 cupsdLogMessage(CUPSD_LOG_DEBUG, "Repairing access permissions of \"%s\"",
375 if (chmod(filename, mode))
378 cupsdLogMessage(CUPSD_LOG_ERROR,
379 "Unable to change permissions of \"%s\" - %s", filename,
382 syslog(LOG_ERR, "Unable to change permissions of \"%s\" - %s", filename,
390 * Everything is OK...
398 * 'cupsdFreeAliases()' - Free all of the alias entries.
402 cupsdFreeAliases(cups_array_t *aliases) /* I - Array of aliases */
404 cupsd_alias_t *a; /* Current alias */
407 for (a = (cupsd_alias_t *)cupsArrayFirst(aliases);
409 a = (cupsd_alias_t *)cupsArrayNext(aliases))
412 cupsArrayDelete(aliases);
417 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
420 int /* O - 1 on success, 0 otherwise */
421 cupsdReadConfiguration(void)
423 int i; /* Looping var */
424 cups_file_t *fp; /* Configuration file */
425 int status; /* Return status */
426 char temp[1024], /* Temporary buffer */
427 mimedir[1024], /* MIME directory */
428 *slash; /* Directory separator */
429 cups_lang_t *language; /* Language */
430 struct passwd *user; /* Default user */
431 struct group *group; /* Default group */
432 char *old_serverroot, /* Old ServerRoot */
433 *old_requestroot; /* Old RequestRoot */
434 int old_remote_port; /* Old RemotePort */
435 const char *tmpdir; /* TMPDIR environment variable */
436 struct stat tmpinfo; /* Temporary directory info */
437 cupsd_policy_t *p; /* Policy */
441 * Save the old root paths...
444 old_serverroot = NULL;
445 cupsdSetString(&old_serverroot, ServerRoot);
446 old_requestroot = NULL;
447 cupsdSetString(&old_requestroot, RequestRoot);
450 * Reset the server configuration data...
453 cupsdDeleteAllLocations();
472 for (i = 0; i < NumRelays; i ++)
473 cupsArrayDelete(Relays[i].from);
480 cupsdDeleteAllListeners();
482 old_remote_port = RemotePort;
489 cupsdFreeAliases(ServerAlias);
492 cupsdClearString(&ServerName);
493 cupsdClearString(&ServerAdmin);
494 cupsdSetString(&ServerBin, CUPS_SERVERBIN);
495 cupsdSetString(&RequestRoot, CUPS_REQUESTS);
496 cupsdSetString(&CacheDir, CUPS_CACHEDIR);
497 cupsdSetString(&DataDir, CUPS_DATADIR);
498 cupsdSetString(&DocumentRoot, CUPS_DOCROOT);
499 cupsdSetString(&AccessLog, CUPS_LOGDIR "/access_log");
500 cupsdClearString(&ErrorLog);
501 cupsdSetString(&PageLog, CUPS_LOGDIR "/page_log");
502 cupsdSetString(&PageLogFormat,
503 "%p %u %j %T %P %C %{job-billing} "
504 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
505 cupsdSetString(&Printcap, CUPS_DEFAULT_PRINTCAP);
506 cupsdSetString(&PrintcapGUI, "/usr/bin/glpoptions");
507 cupsdSetString(&FontPath, CUPS_FONTPATH);
508 cupsdSetString(&RemoteRoot, "remroot");
509 cupsdSetStringf(&ServerHeader, "CUPS/%d.%d", CUPS_VERSION_MAJOR,
511 cupsdSetString(&StateDir, CUPS_STATEDIR);
512 cupsdSetString(&PidFile, "/opt/var/run/cups/cupsd.pid");
514 if (!strcmp(CUPS_DEFAULT_PRINTCAP, "/etc/printers.conf"))
515 PrintcapFormat = PRINTCAP_SOLARIS;
516 else if (!strcmp(CUPS_DEFAULT_PRINTCAP,
517 "/Library/Preferences/org.cups.printers.plist"))
518 PrintcapFormat = PRINTCAP_PLIST;
520 PrintcapFormat = PRINTCAP_BSD;
522 strlcpy(temp, ConfigurationFile, sizeof(temp));
523 if ((slash = strrchr(temp, '/')) != NULL)
526 cupsdSetString(&ServerRoot, temp);
528 cupsdClearString(&Classification);
529 ClassifyOverride = 0;
533 cupsdSetString(&ServerCertificate, "/Library/Keychains/System.keychain");
535 cupsdSetString(&ServerCertificate, "ssl/server.crt");
536 cupsdSetString(&ServerKey, "ssl/server.key");
537 # endif /* HAVE_CDSASSL */
538 #endif /* HAVE_SSL */
540 language = cupsLangDefault();
542 if (!strcmp(language->language, "C") || !strcmp(language->language, "POSIX"))
543 cupsdSetString(&DefaultLanguage, "en");
545 cupsdSetString(&DefaultLanguage, language->language);
547 cupsdClearString(&DefaultPaperSize);
549 cupsdSetString(&RIPCache, "128m");
551 cupsdSetString(&TempDir, NULL);
554 * Find the default user...
557 if ((user = getpwnam(CUPS_DEFAULT_USER)) != NULL)
562 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
563 * complement number...)
572 * Find the default group...
575 group = getgrnam(CUPS_DEFAULT_GROUP);
579 Group = group->gr_gid;
583 * Fallback to group "nobody"...
586 group = getgrnam("nobody");
590 Group = group->gr_gid;
594 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
595 * complement number...)
606 AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
607 ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM;
608 FatalErrors = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS);
609 DefaultAuthType = CUPSD_AUTH_BASIC;
611 DefaultEncryption = HTTP_ENCRYPT_REQUIRED;
612 SSLOptions = CUPSD_SSL_NONE;
613 #endif /* HAVE_SSL */
614 DirtyCleanInterval = DEFAULT_KEEPALIVE;
615 JobKillDelay = DEFAULT_TIMEOUT;
617 JobRetryInterval = 300;
622 HostNameLookups = FALSE;
623 ImplicitClasses = CUPS_DEFAULT_IMPLICIT_CLASSES;
624 ImplicitAnyClasses = FALSE;
625 HideImplicitMembers = TRUE;
627 KeepAliveTimeout = DEFAULT_KEEPALIVE;
628 ListenBackLog = SOMAXCONN;
629 LogDebugHistory = 99999;
630 LogFilePerm = CUPS_DEFAULT_LOG_FILE_PERM;
631 LogLevel = CUPSD_LOG_WARN;
632 LogTimeFormat = CUPSD_TIME_STANDARD;
634 MaxClientsPerHost = 0;
635 MaxLogSize = 1024 * 1024;
637 MultipleOperationTimeout = DEFAULT_TIMEOUT;
638 ReloadTimeout = DEFAULT_KEEPALIVE;
639 RootCertDuration = 300;
640 Timeout = DEFAULT_TIMEOUT;
642 WebInterface = CUPS_DEFAULT_WEBIF;
644 BrowseInterval = DEFAULT_INTERVAL;
645 BrowsePort = ippPort();
646 BrowseLocalProtocols = parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS);
647 BrowseRemoteProtocols = parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS);
648 BrowseShortNames = CUPS_DEFAULT_BROWSE_SHORT_NAMES;
649 BrowseTimeout = DEFAULT_TIMEOUT;
651 Browsing = CUPS_DEFAULT_BROWSING;
652 DefaultShared = CUPS_DEFAULT_DEFAULT_SHARED;
654 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
655 cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups,_universal");
656 #endif /* HAVE_DNSSD */
658 cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
659 cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
661 cupsdClearString(&BrowseLocalOptions);
662 cupsdClearString(&BrowseRemoteOptions);
664 cupsdSetString(&ErrorPolicy, "stop-printer");
667 cupsdClearString(&BrowseLDAPBindDN);
668 cupsdClearString(&BrowseLDAPDN);
669 cupsdClearString(&BrowseLDAPPassword);
670 cupsdClearString(&BrowseLDAPServer);
671 # ifdef HAVE_LDAP_SSL
672 cupsdClearString(&BrowseLDAPCACertFile);
673 # endif /* HAVE_LDAP_SSL */
674 #endif /* HAVE_LDAP */
676 JobHistory = DEFAULT_HISTORY;
677 JobFiles = DEFAULT_FILES;
682 MaxJobsPerPrinter = 0;
683 MaxCopies = CUPS_DEFAULT_MAX_COPIES;
685 cupsdDeleteAllPolicies();
686 cupsdClearString(&DefaultPolicy);
688 #ifdef HAVE_AUTHORIZATION_H
689 cupsdClearString(&SystemGroupAuthKey);
690 #endif /* HAVE_AUTHORIZATION_H */
692 MaxSubscriptions = 100;
693 MaxSubscriptionsPerJob = 0;
694 MaxSubscriptionsPerPrinter = 0;
695 MaxSubscriptionsPerUser = 0;
696 DefaultLeaseDuration = 86400;
697 MaxLeaseDuration = 0;
700 LaunchdTimeout = DEFAULT_TIMEOUT + 10;
701 #endif /* HAVE_LAUNCHD */
704 * Setup environment variables...
710 * Read the configuration file...
713 if ((fp = cupsFileOpen(ConfigurationFile, "r")) == NULL)
716 status = read_configuration(fp);
724 cupsdSetString(&ErrorLog, CUPS_LOGDIR "/error_log");
728 cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
729 RemotePort ? "enabled" : "disabled");
732 BrowseLocalProtocols = 0; /* Disable sharing - no remote access */
735 * See if the ServerName is an IP address...
741 ServerAlias = cupsArrayNew(NULL, NULL);
743 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", ServerName);
747 if (gethostname(temp, sizeof(temp)))
749 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",
751 strlcpy(temp, "localhost", sizeof(temp));
754 cupsdSetString(&ServerName, temp);
757 ServerAlias = cupsArrayNew(NULL, NULL);
759 cupsdAddAlias(ServerAlias, temp);
760 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", temp);
764 struct hostent *host; /* Host entry to get FQDN */
766 if ((host = gethostbyname(temp)) != NULL)
768 if (_cups_strcasecmp(temp, host->h_name))
770 cupsdSetString(&ServerName, host->h_name);
771 cupsdAddAlias(ServerAlias, host->h_name);
772 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
778 for (i = 0; host->h_aliases[i]; i ++)
779 if (_cups_strcasecmp(temp, host->h_aliases[i]))
781 cupsdAddAlias(ServerAlias, host->h_aliases[i]);
782 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
790 * Make sure we have the base hostname added as an alias, too!
793 if ((slash = strchr(temp, '.')) != NULL)
796 cupsdAddAlias(ServerAlias, temp);
797 cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", temp);
801 for (slash = ServerName; isdigit(*slash & 255) || *slash == '.'; slash ++);
803 ServerNameIsIP = !*slash;
806 * Make sure ServerAdmin is initialized...
810 cupsdSetStringf(&ServerAdmin, "root@%s", ServerName);
813 * Use the default system group if none was supplied in cupsd.conf...
816 if (NumSystemGroups == 0)
818 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS))
821 * Find the group associated with GID 0...
828 cupsdSetString(&SystemGroups[0], group->gr_name);
830 cupsdSetString(&SystemGroups[0], "unknown");
832 SystemGroupIDs[0] = 0;
838 * Get the access control list for browsing...
841 BrowseACL = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
844 * Open the system log for cupsd if necessary...
848 if (!strcmp(AccessLog, "syslog") ||
849 !strcmp(ErrorLog, "syslog") ||
850 !strcmp(PageLog, "syslog"))
851 openlog("cupsd", LOG_PID | LOG_NOWAIT | LOG_NDELAY, LOG_LPR);
852 #endif /* HAVE_VSYSLOG */
855 * Make sure each of the log files exists and gets rotated as necessary...
858 if (strcmp(AccessLog, "syslog"))
859 cupsdCheckLogFile(&AccessFile, AccessLog);
861 if (strcmp(ErrorLog, "syslog"))
862 cupsdCheckLogFile(&ErrorFile, ErrorLog);
864 if (strcmp(PageLog, "syslog"))
865 cupsdCheckLogFile(&PageFile, PageLog);
868 * Log the configuration file that was used...
871 cupsdLogMessage(CUPSD_LOG_INFO, "Loaded configuration file \"%s\"",
875 * Validate the Group and SystemGroup settings - they cannot be the same,
876 * otherwise the CGI programs will be able to authenticate as root without
882 for (i = 0; i < NumSystemGroups; i ++)
883 if (Group == SystemGroupIDs[i])
886 if (i < NumSystemGroups)
889 * Log the error and reset the group to a safe value...
892 cupsdLogMessage(CUPSD_LOG_NOTICE,
893 "Group and SystemGroup cannot use the same groups.");
894 cupsdLogMessage(CUPSD_LOG_INFO, "Resetting Group to \"nobody\"...");
896 group = getgrnam("nobody");
900 Group = group->gr_gid;
904 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
905 * complement number...)
914 * Check that we have at least one listen/port line; if not, report this
915 * as an error and exit!
918 if (cupsArrayCount(Listeners) == 0)
924 cupsdLogMessage(CUPSD_LOG_EMERG,
925 "No valid Listen or Port lines were found in the "
926 "configuration file.");
932 cupsdEndProcess(getpid(), 0);
936 * Set the default locale using the language and charset...
939 cupsdSetStringf(&DefaultLocale, "%s.UTF-8", DefaultLanguage);
942 * Update all relative filenames to include the full path from ServerRoot...
945 if (DocumentRoot[0] != '/')
946 cupsdSetStringf(&DocumentRoot, "%s/%s", ServerRoot, DocumentRoot);
948 if (RequestRoot[0] != '/')
949 cupsdSetStringf(&RequestRoot, "%s/%s", ServerRoot, RequestRoot);
951 if (ServerBin[0] != '/')
952 cupsdSetStringf(&ServerBin, "%s/%s", ServerRoot, ServerBin);
954 if (StateDir[0] != '/')
955 cupsdSetStringf(&StateDir, "%s/%s", ServerRoot, StateDir);
957 if (CacheDir[0] != '/')
958 cupsdSetStringf(&CacheDir, "%s/%s", ServerRoot, CacheDir);
961 if (ServerCertificate[0] != '/')
962 cupsdSetStringf(&ServerCertificate, "%s/%s", ServerRoot, ServerCertificate);
964 if (!strncmp(ServerRoot, ServerCertificate, strlen(ServerRoot)) &&
965 cupsdCheckPermissions(ServerCertificate, NULL, 0600, RunUser, Group,
967 (FatalErrors & CUPSD_FATAL_PERMISSIONS))
970 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
971 if (ServerKey[0] != '/')
972 cupsdSetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey);
974 if (!strncmp(ServerRoot, ServerKey, strlen(ServerRoot)) &&
975 cupsdCheckPermissions(ServerKey, NULL, 0600, RunUser, Group, 0, 0) < 0 &&
976 (FatalErrors & CUPSD_FATAL_PERMISSIONS))
978 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
979 #endif /* HAVE_SSL */
982 * Make sure that directories and config files are owned and
983 * writable by the user and group in the cupsd.conf file...
986 snprintf(temp, sizeof(temp), "%s/rss", CacheDir);
988 if ((cupsdCheckPermissions(RequestRoot, NULL, 0710, RunUser,
990 cupsdCheckPermissions(CacheDir, NULL, 0775, RunUser,
992 cupsdCheckPermissions(temp, NULL, 0775, RunUser,
994 cupsdCheckPermissions(StateDir, NULL, 0755, RunUser,
996 cupsdCheckPermissions(StateDir, "certs", RunUser ? 0711 : 0511, User,
997 SystemGroupIDs[0], 1, 1) < 0 ||
998 cupsdCheckPermissions(ServerRoot, NULL, 0755, RunUser,
1000 cupsdCheckPermissions(ServerRoot, "ppd", 0755, RunUser,
1002 cupsdCheckPermissions(ServerRoot, "ssl", 0700, RunUser,
1004 /* Never alter permissions of central conffile
1005 cupsdCheckPermissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser,
1008 cupsdCheckPermissions(ServerRoot, "classes.conf", 0600, RunUser,
1010 cupsdCheckPermissions(ServerRoot, "printers.conf", 0600, RunUser,
1012 cupsdCheckPermissions(ServerRoot, "passwd.md5", 0600, User,
1013 Group, 0, 0) < 0) &&
1014 (FatalErrors & CUPSD_FATAL_PERMISSIONS))
1018 * Update TempDir to the default if it hasn't been set already...
1024 if ((tmpdir = getenv("TMPDIR")) != NULL &&
1025 strncmp(tmpdir, "/private/tmp", 12))
1027 if ((tmpdir = getenv("TMPDIR")) != NULL)
1028 #endif /* __APPLE__ */
1031 * TMPDIR is defined, see if it is OK for us to use...
1034 if (stat(tmpdir, &tmpinfo))
1035 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to access TMPDIR (%s): %s",
1036 tmpdir, strerror(errno));
1037 else if (!S_ISDIR(tmpinfo.st_mode))
1038 cupsdLogMessage(CUPSD_LOG_ERROR, "TMPDIR (%s) is not a directory.",
1040 else if ((tmpinfo.st_uid != User || !(tmpinfo.st_mode & S_IWUSR)) &&
1041 (tmpinfo.st_gid != Group || !(tmpinfo.st_mode & S_IWGRP)) &&
1042 !(tmpinfo.st_mode & S_IWOTH))
1043 cupsdLogMessage(CUPSD_LOG_ERROR,
1044 "TMPDIR (%s) has the wrong permissions.", tmpdir);
1046 cupsdSetString(&TempDir, tmpdir);
1051 cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...",
1053 cupsdSetStringf(&TempDir, "%s/tmp", RequestRoot);
1058 * Make sure the temporary directory has the right permissions...
1061 if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)) ||
1065 * Update ownership and permissions if the CUPS temp directory
1066 * is under the spool directory or does not exist...
1069 if (cupsdCheckPermissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0 &&
1070 (FatalErrors & CUPSD_FATAL_PERMISSIONS))
1075 * Update environment variables...
1081 * Update default paper size setting as needed...
1084 if (!DefaultPaperSize)
1086 #ifdef HAVE_LIBPAPER
1087 char *paper_result; /* Paper size name from libpaper */
1089 if ((paper_result = systempapername()) != NULL)
1090 cupsdSetString(&DefaultPaperSize, paper_result);
1092 #endif /* HAVE_LIBPAPER */
1093 if (!DefaultLanguage ||
1094 !_cups_strcasecmp(DefaultLanguage, "C") ||
1095 !_cups_strcasecmp(DefaultLanguage, "POSIX") ||
1096 !_cups_strcasecmp(DefaultLanguage, "en") ||
1097 !_cups_strncasecmp(DefaultLanguage, "en.", 3) ||
1098 !_cups_strncasecmp(DefaultLanguage, "en_US", 5) ||
1099 !_cups_strncasecmp(DefaultLanguage, "en_CA", 5) ||
1100 !_cups_strncasecmp(DefaultLanguage, "fr_CA", 5))
1103 * These are the only locales that will default to "letter" size...
1106 cupsdSetString(&DefaultPaperSize, "Letter");
1109 cupsdSetString(&DefaultPaperSize, "A4");
1113 * Update classification setting as needed...
1116 if (Classification && !_cups_strcasecmp(Classification, "none"))
1117 cupsdClearString(&Classification);
1120 cupsdLogMessage(CUPSD_LOG_INFO, "Security set to \"%s\"", Classification);
1123 * Check the MaxClients setting, and then allocate memory for it...
1126 if (MaxClients > (MaxFDs / 3) || MaxClients <= 0)
1129 cupsdLogMessage(CUPSD_LOG_INFO,
1130 "MaxClients limited to 1/3 (%d) of the file descriptor "
1132 MaxFDs / 3, MaxFDs);
1134 MaxClients = MaxFDs / 3;
1137 cupsdLogMessage(CUPSD_LOG_INFO, "Configured for up to %d clients.",
1141 * Check the MaxActiveJobs setting; limit to 1/3 the available
1142 * file descriptors, since we need a pipe for each job...
1145 if (MaxActiveJobs > (MaxFDs / 3))
1146 MaxActiveJobs = MaxFDs / 3;
1149 * Update the MaxClientsPerHost value, as needed...
1152 if (MaxClientsPerHost <= 0)
1153 MaxClientsPerHost = MaxClients;
1155 if (MaxClientsPerHost > MaxClients)
1156 MaxClientsPerHost = MaxClients;
1158 cupsdLogMessage(CUPSD_LOG_INFO,
1159 "Allowing up to %d client connections per host.",
1163 * Make sure that BrowseTimeout is at least twice the interval...
1166 if (BrowseTimeout < (2 * BrowseInterval) || BrowseTimeout <= 0)
1168 cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid BrowseTimeout value %d.",
1172 BrowseTimeout = BrowseInterval * 2;
1174 BrowseTimeout = DEFAULT_TIMEOUT;
1176 cupsdLogMessage(CUPSD_LOG_ALERT, "Reset BrowseTimeout to %d.",
1181 * Update the default policy, as needed...
1185 DefaultPolicyPtr = cupsdFindPolicy(DefaultPolicy);
1187 DefaultPolicyPtr = NULL;
1189 if (!DefaultPolicyPtr)
1191 cupsd_location_t *po; /* New policy operation */
1195 cupsdLogMessage(CUPSD_LOG_ERROR, "Default policy \"%s\" not found.",
1198 cupsdSetString(&DefaultPolicy, "default");
1200 if ((DefaultPolicyPtr = cupsdFindPolicy("default")) != NULL)
1201 cupsdLogMessage(CUPSD_LOG_INFO,
1202 "Using policy \"default\" as the default.");
1205 cupsdLogMessage(CUPSD_LOG_INFO,
1206 "Creating CUPS default administrative policy:");
1208 DefaultPolicyPtr = p = cupsdAddPolicy("default");
1210 cupsdLogMessage(CUPSD_LOG_INFO, "<Policy default>");
1212 cupsdLogMessage(CUPSD_LOG_INFO, "JobPrivateAccess default");
1213 cupsdAddString(&(p->job_access), "@OWNER");
1214 cupsdAddString(&(p->job_access), "@SYSTEM");
1216 cupsdLogMessage(CUPSD_LOG_INFO, "JobPrivateValues default");
1217 cupsdAddString(&(p->job_attrs), "job-name");
1218 cupsdAddString(&(p->job_attrs), "job-originating-host-name");
1219 cupsdAddString(&(p->job_attrs), "job-originating-user-name");
1221 cupsdLogMessage(CUPSD_LOG_INFO, "SubscriptionPrivateAccess default");
1222 cupsdAddString(&(p->sub_access), "@OWNER");
1223 cupsdAddString(&(p->sub_access), "@SYSTEM");
1225 cupsdLogMessage(CUPSD_LOG_INFO, "SubscriptionPrivateValues default");
1226 cupsdAddString(&(p->job_attrs), "notify-events");
1227 cupsdAddString(&(p->job_attrs), "notify-pull-method");
1228 cupsdAddString(&(p->job_attrs), "notify-recipient-uri");
1229 cupsdAddString(&(p->job_attrs), "notify-subscriber-user-name");
1230 cupsdAddString(&(p->job_attrs), "notify-user-data");
1232 cupsdLogMessage(CUPSD_LOG_INFO,
1233 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1234 cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
1236 po = cupsdAddPolicyOp(p, NULL, IPP_CREATE_JOB);
1237 po->order_type = CUPSD_AUTH_ALLOW;
1239 cupsdAddPolicyOp(p, po, IPP_PRINT_JOB);
1240 cupsdAddPolicyOp(p, po, IPP_PRINT_URI);
1241 cupsdAddPolicyOp(p, po, IPP_VALIDATE_JOB);
1243 cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
1245 cupsdLogMessage(CUPSD_LOG_INFO,
1246 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1247 "Release-Job Restart-Job Purge-Jobs "
1248 "Set-Job-Attributes Create-Job-Subscription "
1249 "Renew-Subscription Cancel-Subscription "
1250 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1251 "Suspend-Current-Job Resume-Job "
1252 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1253 "CUPS-Authenticate-Job CUPS-Get-Document>");
1254 cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
1256 po = cupsdAddPolicyOp(p, NULL, IPP_SEND_DOCUMENT);
1257 po->order_type = CUPSD_AUTH_ALLOW;
1258 po->level = CUPSD_AUTH_USER;
1260 cupsdAddName(po, "@OWNER");
1261 cupsdAddName(po, "@SYSTEM");
1262 cupsdLogMessage(CUPSD_LOG_INFO, "Require user @OWNER @SYSTEM");
1264 cupsdAddPolicyOp(p, po, IPP_SEND_URI);
1265 cupsdAddPolicyOp(p, po, IPP_CANCEL_JOB);
1266 cupsdAddPolicyOp(p, po, IPP_HOLD_JOB);
1267 cupsdAddPolicyOp(p, po, IPP_RELEASE_JOB);
1268 cupsdAddPolicyOp(p, po, IPP_RESTART_JOB);
1269 cupsdAddPolicyOp(p, po, IPP_PURGE_JOBS);
1270 cupsdAddPolicyOp(p, po, IPP_SET_JOB_ATTRIBUTES);
1271 cupsdAddPolicyOp(p, po, IPP_CREATE_JOB_SUBSCRIPTION);
1272 cupsdAddPolicyOp(p, po, IPP_RENEW_SUBSCRIPTION);
1273 cupsdAddPolicyOp(p, po, IPP_CANCEL_SUBSCRIPTION);
1274 cupsdAddPolicyOp(p, po, IPP_GET_NOTIFICATIONS);
1275 cupsdAddPolicyOp(p, po, IPP_REPROCESS_JOB);
1276 cupsdAddPolicyOp(p, po, IPP_CANCEL_CURRENT_JOB);
1277 cupsdAddPolicyOp(p, po, IPP_SUSPEND_CURRENT_JOB);
1278 cupsdAddPolicyOp(p, po, IPP_RESUME_JOB);
1279 cupsdAddPolicyOp(p, po, IPP_CANCEL_MY_JOBS);
1280 cupsdAddPolicyOp(p, po, IPP_CLOSE_JOB);
1281 cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB);
1282 cupsdAddPolicyOp(p, po, CUPS_AUTHENTICATE_JOB);
1283 cupsdAddPolicyOp(p, po, CUPS_GET_DOCUMENT);
1285 cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
1287 cupsdLogMessage(CUPSD_LOG_INFO,
1288 "<Limit Pause-Printer Resume-Printer "
1289 "Set-Printer-Attributes Enable-Printer "
1290 "Disable-Printer Pause-Printer-After-Current-Job "
1291 "Hold-New-Jobs Release-Held-New-Jobs "
1292 "Deactivate-Printer Activate-Printer Restart-Printer "
1293 "Shutdown-Printer Startup-Printer Promote-Job "
1294 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1295 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1296 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1297 cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
1298 cupsdLogMessage(CUPSD_LOG_INFO, "AuthType Default");
1300 po = cupsdAddPolicyOp(p, NULL, IPP_PAUSE_PRINTER);
1301 po->order_type = CUPSD_AUTH_ALLOW;
1302 po->type = CUPSD_AUTH_DEFAULT;
1303 po->level = CUPSD_AUTH_USER;
1305 cupsdAddName(po, "@SYSTEM");
1306 cupsdLogMessage(CUPSD_LOG_INFO, "Require user @SYSTEM");
1308 cupsdAddPolicyOp(p, po, IPP_RESUME_PRINTER);
1309 cupsdAddPolicyOp(p, po, IPP_SET_PRINTER_ATTRIBUTES);
1310 cupsdAddPolicyOp(p, po, IPP_ENABLE_PRINTER);
1311 cupsdAddPolicyOp(p, po, IPP_DISABLE_PRINTER);
1312 cupsdAddPolicyOp(p, po, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB);
1313 cupsdAddPolicyOp(p, po, IPP_HOLD_NEW_JOBS);
1314 cupsdAddPolicyOp(p, po, IPP_RELEASE_HELD_NEW_JOBS);
1315 cupsdAddPolicyOp(p, po, IPP_DEACTIVATE_PRINTER);
1316 cupsdAddPolicyOp(p, po, IPP_ACTIVATE_PRINTER);
1317 cupsdAddPolicyOp(p, po, IPP_RESTART_PRINTER);
1318 cupsdAddPolicyOp(p, po, IPP_SHUTDOWN_PRINTER);
1319 cupsdAddPolicyOp(p, po, IPP_STARTUP_PRINTER);
1320 cupsdAddPolicyOp(p, po, IPP_PROMOTE_JOB);
1321 cupsdAddPolicyOp(p, po, IPP_SCHEDULE_JOB_AFTER);
1322 cupsdAddPolicyOp(p, po, IPP_CANCEL_JOBS);
1323 cupsdAddPolicyOp(p, po, CUPS_ADD_PRINTER);
1324 cupsdAddPolicyOp(p, po, CUPS_DELETE_PRINTER);
1325 cupsdAddPolicyOp(p, po, CUPS_ADD_CLASS);
1326 cupsdAddPolicyOp(p, po, CUPS_DELETE_CLASS);
1327 cupsdAddPolicyOp(p, po, CUPS_ACCEPT_JOBS);
1328 cupsdAddPolicyOp(p, po, CUPS_REJECT_JOBS);
1329 cupsdAddPolicyOp(p, po, CUPS_SET_DEFAULT);
1331 cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
1333 cupsdLogMessage(CUPSD_LOG_INFO, "<Limit All>");
1334 cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
1336 po = cupsdAddPolicyOp(p, NULL, IPP_ANY_OPERATION);
1337 po->order_type = CUPSD_AUTH_ALLOW;
1339 cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
1340 cupsdLogMessage(CUPSD_LOG_INFO, "</Policy>");
1344 cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: NumPolicies=%d",
1345 cupsArrayCount(Policies));
1346 for (i = 0, p = (cupsd_policy_t *)cupsArrayFirst(Policies);
1348 i ++, p = (cupsd_policy_t *)cupsArrayNext(Policies))
1349 cupsdLogMessage(CUPSD_LOG_DEBUG2,
1350 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i, p->name);
1353 * If we are doing a full reload or the server root has changed, flush
1354 * the jobs, printers, etc. and start from scratch...
1357 if (NeedReload == RELOAD_ALL ||
1358 old_remote_port != RemotePort ||
1359 !old_serverroot || !ServerRoot || strcmp(old_serverroot, ServerRoot) ||
1360 !old_requestroot || !RequestRoot || strcmp(old_requestroot, RequestRoot))
1362 mime_type_t *type; /* Current type */
1363 char mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE];
1364 /* MIME type name */
1367 cupsdLogMessage(CUPSD_LOG_INFO, "Full reload is required.");
1370 * Free all memory...
1373 cupsdDeleteAllSubscriptions();
1375 cupsdDeleteAllPrinters();
1377 DefaultPrinter = NULL;
1379 if (MimeDatabase != NULL)
1380 mimeDelete(MimeDatabase);
1384 for (i = 0; i < NumMimeTypes; i ++)
1385 _cupsStrFree(MimeTypes[i]);
1391 * Read the MIME type and conversion database...
1394 snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
1395 snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
1397 MimeDatabase = mimeNew();
1398 mimeSetErrorCallback(MimeDatabase, mime_error_cb, NULL);
1400 MimeDatabase = mimeLoadTypes(MimeDatabase, mimedir);
1401 MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
1402 MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
1403 MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
1407 cupsdLogMessage(CUPSD_LOG_EMERG,
1408 "Unable to load MIME database from \"%s\" or \"%s\".",
1409 mimedir, ServerRoot);
1410 if (FatalErrors & CUPSD_FATAL_CONFIG)
1414 cupsdLogMessage(CUPSD_LOG_INFO,
1415 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1416 "%d filters...", mimedir, ServerRoot,
1417 mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase));
1420 * Create a list of MIME types for the document-format-supported
1424 NumMimeTypes = mimeNumTypes(MimeDatabase);
1425 if (!mimeType(MimeDatabase, "application", "octet-stream"))
1428 if ((MimeTypes = calloc(NumMimeTypes, sizeof(const char *))) == NULL)
1430 cupsdLogMessage(CUPSD_LOG_ERROR,
1431 "Unable to allocate memory for %d MIME types.",
1437 for (i = 0, type = mimeFirstType(MimeDatabase);
1439 i ++, type = mimeNextType(MimeDatabase))
1441 snprintf(mimetype, sizeof(mimetype), "%s/%s", type->super, type->type);
1443 MimeTypes[i] = _cupsStrAlloc(mimetype);
1446 if (i < NumMimeTypes)
1447 MimeTypes[i] = _cupsStrAlloc("application/octet-stream");
1450 if (LogLevel == CUPSD_LOG_DEBUG2)
1452 mime_filter_t *filter; /* Current filter */
1455 for (type = mimeFirstType(MimeDatabase);
1457 type = mimeNextType(MimeDatabase))
1458 cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadConfiguration: type %s/%s",
1459 type->super, type->type);
1461 for (filter = mimeFirstFilter(MimeDatabase);
1463 filter = mimeNextFilter(MimeDatabase))
1464 cupsdLogMessage(CUPSD_LOG_DEBUG2,
1465 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1466 filter->src->super, filter->src->type,
1467 filter->dst->super, filter->dst->type,
1468 filter->cost, filter->filter);
1475 snprintf(temp, sizeof(temp), "%s/banners", DataDir);
1476 cupsdLoadBanners(temp);
1479 * Load printers and classes...
1482 cupsdLoadAllPrinters();
1483 cupsdLoadAllClasses();
1484 cupsdLoadRemoteCache();
1486 cupsdCreateCommonData();
1489 * Update the printcap file as needed...
1492 if (Printcap && *Printcap && access(Printcap, 0))
1493 cupsdWritePrintcap();
1496 * Load queued jobs...
1502 * Load subscriptions...
1505 cupsdLoadAllSubscriptions();
1507 cupsdLogMessage(CUPSD_LOG_INFO, "Full reload complete.");
1512 * Not a full reload, so recreate the common printer attributes...
1515 cupsdCreateCommonData();
1518 * Update all printers as needed...
1521 cupsdUpdatePrinters();
1522 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
1524 cupsdLogMessage(CUPSD_LOG_INFO, "Partial reload complete.");
1528 * Reset the reload state...
1531 NeedReload = RELOAD_NONE;
1533 cupsdClearString(&old_serverroot);
1534 cupsdClearString(&old_requestroot);
1541 * 'get_address()' - Get an address + port number from a line.
1544 static http_addrlist_t * /* O - Pointer to list if address good, NULL if bad */
1545 get_address(const char *value, /* I - Value string */
1546 int defport) /* I - Default port */
1548 char buffer[1024], /* Hostname + port number buffer */
1549 defpname[255], /* Default port name */
1550 *hostname, /* Hostname or IP */
1551 *portname; /* Port number or name */
1552 http_addrlist_t *addrlist; /* Address list */
1556 * Check for an empty value...
1561 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad (empty) address.");
1566 * Grab a hostname and port number; if there is no colon and the port name
1567 * is only digits, then we have a port number by itself...
1570 strlcpy(buffer, value, sizeof(buffer));
1572 if ((portname = strrchr(buffer, ':')) != NULL && !strchr(portname, ']'))
1579 for (portname = buffer; isdigit(*portname & 255); portname ++);
1584 * Use the default port...
1587 sprintf(defpname, "%d", defport);
1588 portname = defpname;
1594 * The buffer contains just a port number...
1602 if (hostname && !strcmp(hostname, "*"))
1606 * Now lookup the address using httpAddrGetList()...
1609 if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
1610 cupsdLogMessage(CUPSD_LOG_ERROR, "Hostname lookup for \"%s\" failed.",
1611 hostname ? hostname : "(nil)");
1618 * 'get_addr_and_mask()' - Get an IP address and netmask.
1621 static int /* O - 1 on success, 0 on failure */
1622 get_addr_and_mask(const char *value, /* I - String from config file */
1623 unsigned *ip, /* O - Address value */
1624 unsigned *mask) /* O - Mask value */
1626 int i, j, /* Looping vars */
1627 family, /* Address family */
1628 ipcount; /* Count of fields in address */
1629 unsigned ipval; /* Value */
1630 const char *maskval, /* Pointer to start of mask value */
1631 *ptr, /* Pointer into value */
1636 * Get the address...
1639 ip[0] = ip[1] = ip[2] = ip[3] = 0x00000000;
1640 mask[0] = mask[1] = mask[2] = mask[3] = 0xffffffff;
1642 if ((maskval = strchr(value, '/')) != NULL)
1645 maskval = value + strlen(value);
1649 * Check for an IPv6 address...
1655 * Parse hexadecimal IPv6/IPv4 address...
1660 for (i = 0, ptr = value + 1; *ptr && i < 8; i ++)
1664 else if (!strncmp(ptr, "::", 2))
1666 for (ptr2 = strchr(ptr + 2, ':'), j = 0;
1668 ptr2 = strchr(ptr2 + 1, ':'), j ++);
1673 else if (isdigit(*ptr & 255) && strchr(ptr + 1, '.') && i >= 6)
1676 * Read IPv4 dotted quad...
1679 unsigned val[4] = { 0, 0, 0, 0 };
1680 /* IPv4 address values */
1682 ipcount = sscanf(ptr, "%u.%u.%u.%u", val + 0, val + 1, val + 2,
1686 * Range check the IP numbers...
1689 for (i = 0; i < ipcount; i ++)
1694 * Merge everything into a 32-bit IPv4 address in ip[3]...
1697 ip[3] = (((((val[0] << 8) | val[1]) << 8) | val[2]) << 8) | val[3];
1700 mask[3] = (0xffffffff << (32 - 8 * ipcount)) & 0xffffffff;
1703 * If the leading words are all 0's then this is an IPv4 address...
1706 if (!val[0] && !val[1] && !val[2])
1709 while (isdigit(*ptr & 255) || *ptr == '.')
1713 else if (isxdigit(*ptr & 255))
1715 ipval = strtoul(ptr, (char **)&ptr, 16);
1717 if (*ptr == ':' && ptr[1] != ':')
1726 ip[i / 2] |= ipval << 16;
1737 if (*ptr && *ptr != '/')
1741 #endif /* AF_INET6 */
1744 * Parse dotted-decimal IPv4 address...
1747 unsigned val[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
1751 ipcount = sscanf(value, "%u.%u.%u.%u", val + 0, val + 1, val + 2, val + 3);
1754 * Range check the IP numbers...
1757 for (i = 0; i < ipcount; i ++)
1762 * Merge everything into a 32-bit IPv4 address in ip[3]...
1765 ip[3] = (((((val[0] << 8) | val[1]) << 8) | val[2]) << 8) | val[3];
1768 mask[3] = (0xffffffff << (32 - 8 * ipcount)) & 0xffffffff;
1774 * Get the netmask value(s)...
1777 memset(mask, 0, sizeof(unsigned) * 4);
1779 if (strchr(maskval, '.'))
1782 * Get dotted-decimal mask...
1785 if (family != AF_INET)
1788 if (sscanf(maskval, "%u.%u.%u.%u", mask + 0, mask + 1, mask + 2,
1792 mask[3] |= ((((mask[0] << 8) | mask[1]) << 8) | mask[2]) << 8;
1793 mask[0] = mask[1] = mask[2] = 0;
1798 * Get address/bits format...
1804 if (family == AF_INET6)
1812 mask[0] = 0xffffffff;
1814 mask[0] = (0xffffffff << (i - 96)) & 0xffffffff;
1817 mask[1] = 0xffffffff;
1821 mask[1] = (0xffffffff << (i - 64)) & 0xffffffff;
1824 mask[2] = 0xffffffff;
1828 mask[2] = (0xffffffff << (i - 32)) & 0xffffffff;
1831 mask[3] = 0xffffffff;
1835 mask[3] = (0xffffffff << i) & 0xffffffff;
1838 #endif /* AF_INET6 */
1843 mask[0] = 0xffffffff;
1844 mask[1] = 0xffffffff;
1845 mask[2] = 0xffffffff;
1848 mask[3] = (0xffffffff << (32 - i)) & 0xffffffff;
1850 mask[3] = 0xffffffff;
1855 cupsdLogMessage(CUPSD_LOG_DEBUG2,
1856 "get_addr_and_mask(value=\"%s\", "
1857 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1858 value, ip[0], ip[1], ip[2], ip[3], mask[0], mask[1], mask[2],
1862 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1865 if ((ip[0] & ~mask[0]) != 0 ||
1866 (ip[1] & ~mask[1]) != 0 ||
1867 (ip[2] & ~mask[2]) != 0 ||
1868 (ip[3] & ~mask[3]) != 0)
1876 * 'mime_error_cb()' - Log a MIME error.
1880 mime_error_cb(void *ctx, /* I - Context pointer (unused) */
1881 const char *message) /* I - Message */
1885 cupsdLogMessage(CUPSD_LOG_ERROR, "%s", message);
1890 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1893 static int /* O - 1 on success, 0 on failure */
1894 parse_aaa(cupsd_location_t *loc, /* I - Location */
1895 char *line, /* I - Line from file */
1896 char *value, /* I - Start of value data */
1897 int linenum) /* I - Current line number */
1899 char *valptr; /* Pointer into value */
1900 unsigned ip[4], /* IP address components */
1901 mask[4]; /* IP netmask components */
1904 if (!_cups_strcasecmp(line, "Encryption"))
1907 * "Encryption xxx" - set required encryption level...
1910 if (!_cups_strcasecmp(value, "never"))
1911 loc->encryption = HTTP_ENCRYPT_NEVER;
1912 else if (!_cups_strcasecmp(value, "always"))
1914 cupsdLogMessage(CUPSD_LOG_ERROR,
1915 "Encryption value \"%s\" on line %d is invalid in this "
1916 "context. Using \"required\" instead.", value, linenum);
1918 loc->encryption = HTTP_ENCRYPT_REQUIRED;
1920 else if (!_cups_strcasecmp(value, "required"))
1921 loc->encryption = HTTP_ENCRYPT_REQUIRED;
1922 else if (!_cups_strcasecmp(value, "ifrequested"))
1923 loc->encryption = HTTP_ENCRYPT_IF_REQUESTED;
1926 cupsdLogMessage(CUPSD_LOG_ERROR,
1927 "Unknown Encryption value %s on line %d.", value, linenum);
1931 else if (!_cups_strcasecmp(line, "Order"))
1934 * "Order Deny,Allow" or "Order Allow,Deny"...
1937 if (!_cups_strncasecmp(value, "deny", 4))
1938 loc->order_type = CUPSD_AUTH_ALLOW;
1939 else if (!_cups_strncasecmp(value, "allow", 5))
1940 loc->order_type = CUPSD_AUTH_DENY;
1943 cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown Order value %s on line %d.",
1948 else if (!_cups_strcasecmp(line, "Allow") || !_cups_strcasecmp(line, "Deny"))
1951 * Allow [From] host/ip...
1952 * Deny [From] host/ip...
1957 if (!_cups_strncasecmp(value, "from", 4))
1960 * Strip leading "from"...
1965 while (_cups_isspace(*value))
1973 * Find the end of the value...
1976 for (valptr = value; *valptr && !_cups_isspace(*valptr); valptr ++);
1978 while (_cups_isspace(*valptr))
1982 * Figure out what form the allow/deny address takes:
1993 * nnn.nnn.nnn.nnn/mm
1994 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1997 if (!_cups_strcasecmp(value, "all"))
2003 if (!_cups_strcasecmp(line, "Allow"))
2004 cupsdAddIPMask(&(loc->allow), zeros, zeros);
2006 cupsdAddIPMask(&(loc->deny), zeros, zeros);
2008 else if (!_cups_strcasecmp(value, "none"))
2014 if (!_cups_strcasecmp(line, "Allow"))
2015 cupsdAddIPMask(&(loc->allow), ones, zeros);
2017 cupsdAddIPMask(&(loc->deny), ones, zeros);
2020 else if (value[0] == '*' || value[0] == '.' ||
2021 (!isdigit(value[0] & 255) && value[0] != '['))
2023 else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
2024 #endif /* AF_INET6 */
2027 * Host or domain name...
2030 if (value[0] == '*')
2033 if (!_cups_strcasecmp(line, "Allow"))
2034 cupsdAddNameMask(&(loc->allow), value);
2036 cupsdAddNameMask(&(loc->deny), value);
2041 * One of many IP address forms...
2044 if (!get_addr_and_mask(value, ip, mask))
2046 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
2051 if (!_cups_strcasecmp(line, "Allow"))
2052 cupsdAddIPMask(&(loc->allow), ip, mask);
2054 cupsdAddIPMask(&(loc->deny), ip, mask);
2058 * Advance to next value...
2064 else if (!_cups_strcasecmp(line, "AuthType"))
2067 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2070 if (!_cups_strcasecmp(value, "none"))
2072 loc->type = CUPSD_AUTH_NONE;
2073 loc->level = CUPSD_AUTH_ANON;
2075 else if (!_cups_strcasecmp(value, "basic"))
2077 loc->type = CUPSD_AUTH_BASIC;
2079 if (loc->level == CUPSD_AUTH_ANON)
2080 loc->level = CUPSD_AUTH_USER;
2082 else if (!_cups_strcasecmp(value, "digest"))
2084 loc->type = CUPSD_AUTH_DIGEST;
2086 if (loc->level == CUPSD_AUTH_ANON)
2087 loc->level = CUPSD_AUTH_USER;
2089 else if (!_cups_strcasecmp(value, "basicdigest"))
2091 loc->type = CUPSD_AUTH_BASICDIGEST;
2093 if (loc->level == CUPSD_AUTH_ANON)
2094 loc->level = CUPSD_AUTH_USER;
2096 else if (!_cups_strcasecmp(value, "default"))
2098 loc->type = CUPSD_AUTH_DEFAULT;
2100 if (loc->level == CUPSD_AUTH_ANON)
2101 loc->level = CUPSD_AUTH_USER;
2104 else if (!_cups_strcasecmp(value, "negotiate"))
2106 loc->type = CUPSD_AUTH_NEGOTIATE;
2108 if (loc->level == CUPSD_AUTH_ANON)
2109 loc->level = CUPSD_AUTH_USER;
2111 #endif /* HAVE_GSSAPI */
2114 cupsdLogMessage(CUPSD_LOG_WARN,
2115 "Unknown authorization type %s on line %d.",
2120 else if (!_cups_strcasecmp(line, "AuthClass"))
2123 * AuthClass anonymous, user, system, group
2126 if (!_cups_strcasecmp(value, "anonymous"))
2128 loc->type = CUPSD_AUTH_NONE;
2129 loc->level = CUPSD_AUTH_ANON;
2131 cupsdLogMessage(CUPSD_LOG_WARN,
2132 "\"AuthClass %s\" is deprecated; consider removing "
2136 else if (!_cups_strcasecmp(value, "user"))
2138 loc->level = CUPSD_AUTH_USER;
2140 cupsdLogMessage(CUPSD_LOG_WARN,
2141 "\"AuthClass %s\" is deprecated; consider using "
2142 "\"Require valid-user\" on line %d.",
2145 else if (!_cups_strcasecmp(value, "group"))
2147 loc->level = CUPSD_AUTH_GROUP;
2149 cupsdLogMessage(CUPSD_LOG_WARN,
2150 "\"AuthClass %s\" is deprecated; consider using "
2151 "\"Require user @groupname\" on line %d.",
2154 else if (!_cups_strcasecmp(value, "system"))
2156 loc->level = CUPSD_AUTH_GROUP;
2158 cupsdAddName(loc, "@SYSTEM");
2160 cupsdLogMessage(CUPSD_LOG_WARN,
2161 "\"AuthClass %s\" is deprecated; consider using "
2162 "\"Require user @SYSTEM\" on line %d.",
2167 cupsdLogMessage(CUPSD_LOG_WARN,
2168 "Unknown authorization class %s on line %d.",
2173 else if (!_cups_strcasecmp(line, "AuthGroupName"))
2175 cupsdAddName(loc, value);
2177 cupsdLogMessage(CUPSD_LOG_WARN,
2178 "\"AuthGroupName %s\" directive is deprecated; consider "
2179 "using \"Require user @%s\" on line %d.",
2180 value, value, linenum);
2182 else if (!_cups_strcasecmp(line, "Require"))
2185 * Apache synonym for AuthClass and AuthGroupName...
2189 * Require valid-user
2190 * Require group names
2191 * Require user names
2194 for (valptr = value; !_cups_isspace(*valptr) && *valptr; valptr ++);
2199 if (!_cups_strcasecmp(value, "valid-user") ||
2200 !_cups_strcasecmp(value, "user"))
2201 loc->level = CUPSD_AUTH_USER;
2202 else if (!_cups_strcasecmp(value, "group"))
2203 loc->level = CUPSD_AUTH_GROUP;
2206 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown Require type %s on line %d.",
2212 * Get the list of names from the line...
2215 for (value = valptr; *value;)
2217 while (_cups_isspace(*value))
2220 #ifdef HAVE_AUTHORIZATION_H
2221 if (!strncmp(value, "@AUTHKEY(", 9))
2224 * Grab "@AUTHKEY(name)" value...
2227 for (valptr = value + 9; *valptr != ')' && *valptr; valptr ++);
2233 #endif /* HAVE_AUTHORIZATION_H */
2234 if (*value == '\"' || *value == '\'')
2237 * Grab quoted name...
2240 for (valptr = value + 1; *valptr != *value && *valptr; valptr ++);
2247 * Grab literal name.
2250 for (valptr = value; !_cups_isspace(*valptr) && *valptr; valptr ++);
2256 cupsdAddName(loc, value);
2258 for (value = valptr; _cups_isspace(*value); value ++);
2261 else if (!_cups_strcasecmp(line, "Satisfy"))
2263 if (!_cups_strcasecmp(value, "all"))
2264 loc->satisfy = CUPSD_AUTH_SATISFY_ALL;
2265 else if (!_cups_strcasecmp(value, "any"))
2266 loc->satisfy = CUPSD_AUTH_SATISFY_ANY;
2269 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown Satisfy value %s on line %d.",
2282 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2285 static int /* O - FatalErrors bits */
2286 parse_fatal_errors(const char *s) /* I - FatalErrors string */
2288 int fatal; /* FatalErrors bits */
2289 char value[1024], /* Value string */
2290 *valstart, /* Pointer into value */
2291 *valend; /* End of value */
2295 * Empty FatalErrors line yields NULL pointer...
2299 return (CUPSD_FATAL_NONE);
2302 * Loop through the value string,...
2305 strlcpy(value, s, sizeof(value));
2307 fatal = CUPSD_FATAL_NONE;
2309 for (valstart = value; *valstart;)
2312 * Get the current space/comma-delimited kind name...
2315 for (valend = valstart; *valend; valend ++)
2316 if (_cups_isspace(*valend) || *valend == ',')
2323 * Add the error to the bitmask...
2326 if (!_cups_strcasecmp(valstart, "all"))
2327 fatal = CUPSD_FATAL_ALL;
2328 else if (!_cups_strcasecmp(valstart, "browse"))
2329 fatal |= CUPSD_FATAL_BROWSE;
2330 else if (!_cups_strcasecmp(valstart, "-browse"))
2331 fatal &= ~CUPSD_FATAL_BROWSE;
2332 else if (!_cups_strcasecmp(valstart, "config"))
2333 fatal |= CUPSD_FATAL_CONFIG;
2334 else if (!_cups_strcasecmp(valstart, "-config"))
2335 fatal &= ~CUPSD_FATAL_CONFIG;
2336 else if (!_cups_strcasecmp(valstart, "listen"))
2337 fatal |= CUPSD_FATAL_LISTEN;
2338 else if (!_cups_strcasecmp(valstart, "-listen"))
2339 fatal &= ~CUPSD_FATAL_LISTEN;
2340 else if (!_cups_strcasecmp(valstart, "log"))
2341 fatal |= CUPSD_FATAL_LOG;
2342 else if (!_cups_strcasecmp(valstart, "-log"))
2343 fatal &= ~CUPSD_FATAL_LOG;
2344 else if (!_cups_strcasecmp(valstart, "permissions"))
2345 fatal |= CUPSD_FATAL_PERMISSIONS;
2346 else if (!_cups_strcasecmp(valstart, "-permissions"))
2347 fatal &= ~CUPSD_FATAL_PERMISSIONS;
2348 else if (_cups_strcasecmp(valstart, "none"))
2349 cupsdLogMessage(CUPSD_LOG_ERROR,
2350 "Unknown FatalErrors kind \"%s\" ignored.", valstart);
2352 for (valstart = valend; *valstart; valstart ++)
2353 if (!_cups_isspace(*valstart) || *valstart != ',')
2362 * 'parse_groups()' - Parse system group names in a string.
2365 static int /* O - 1 on success, 0 on failure */
2366 parse_groups(const char *s) /* I - Space-delimited groups */
2368 int status; /* Return status */
2369 char value[1024], /* Value string */
2370 *valstart, /* Pointer into value */
2371 *valend, /* End of value */
2372 quote; /* Quote character */
2373 struct group *group; /* Group */
2377 * Make a copy of the string and parse out the groups...
2380 strlcpy(value, s, sizeof(value));
2385 while (*valstart && NumSystemGroups < MAX_SYSTEM_GROUPS)
2387 if (*valstart == '\'' || *valstart == '\"')
2390 * Scan quoted name...
2393 quote = *valstart++;
2395 for (valend = valstart; *valend; valend ++)
2396 if (*valend == quote)
2402 * Scan space or comma-delimited name...
2405 for (valend = valstart; *valend; valend ++)
2406 if (_cups_isspace(*valend) || *valend == ',')
2413 group = getgrnam(valstart);
2416 cupsdSetString(SystemGroups + NumSystemGroups, valstart);
2417 SystemGroupIDs[NumSystemGroups] = group->gr_gid;
2428 while (*valstart == ',' || _cups_isspace(*valstart))
2437 * 'parse_protocols()' - Parse browse protocols in a string.
2440 static int /* O - Browse protocol bits */
2441 parse_protocols(const char *s) /* I - Space-delimited protocols */
2443 int protocols; /* Browse protocol bits */
2444 char value[1024], /* Value string */
2445 *valstart, /* Pointer into value */
2446 *valend; /* End of value */
2450 * Empty protocol line yields NULL pointer...
2457 * Loop through the value string,...
2460 strlcpy(value, s, sizeof(value));
2464 for (valstart = value; *valstart;)
2467 * Get the current space/comma-delimited protocol name...
2470 for (valend = valstart; *valend; valend ++)
2471 if (_cups_isspace(*valend) || *valend == ',')
2478 * Add the protocol to the bitmask...
2481 if (!_cups_strcasecmp(valstart, "cups"))
2482 protocols |= BROWSE_CUPS;
2483 else if (!_cups_strcasecmp(valstart, "slp"))
2484 protocols |= BROWSE_SLP;
2485 else if (!_cups_strcasecmp(valstart, "ldap"))
2486 protocols |= BROWSE_LDAP;
2487 else if (!_cups_strcasecmp(valstart, "dnssd") ||
2488 !_cups_strcasecmp(valstart, "dns-sd") ||
2489 !_cups_strcasecmp(valstart, "bonjour"))
2490 protocols |= BROWSE_DNSSD;
2491 else if (!_cups_strcasecmp(valstart, "lpd"))
2492 protocols |= BROWSE_LPD;
2493 else if (!_cups_strcasecmp(valstart, "smb"))
2494 protocols |= BROWSE_SMB;
2495 else if (!_cups_strcasecmp(valstart, "all"))
2496 protocols |= BROWSE_ALL;
2497 else if (_cups_strcasecmp(valstart, "none"))
2498 cupsdLogMessage(CUPSD_LOG_ERROR,
2499 "Unknown browse protocol \"%s\" ignored.", valstart);
2501 for (valstart = valend; *valstart; valstart ++)
2502 if (!_cups_isspace(*valstart) || *valstart != ',')
2511 * 'read_configuration()' - Read a configuration file.
2514 static int /* O - 1 on success, 0 on failure */
2515 read_configuration(cups_file_t *fp) /* I - File to read from */
2517 int i; /* Looping var */
2518 int linenum; /* Current line number */
2519 char line[HTTP_MAX_BUFFER],
2520 /* Line from file */
2521 temp[HTTP_MAX_BUFFER],
2522 /* Temporary buffer for value */
2523 *ptr, /* Pointer into line/temp */
2524 *value, /* Pointer to value */
2525 *valueptr; /* Pointer into value */
2526 int valuelen; /* Length of value */
2527 cupsd_var_t const *var; /* Current variable */
2528 http_addrlist_t *addrlist, /* Address list */
2529 *addr; /* Current address */
2530 unsigned ip[4], /* Address value */
2531 mask[4]; /* Netmask value */
2532 cupsd_dirsvc_relay_t *relay; /* Relay data */
2533 cupsd_dirsvc_poll_t *pollp; /* Polling data */
2534 cupsd_location_t *location; /* Browse location */
2535 cups_file_t *incfile; /* Include file */
2536 char incname[1024]; /* Include filename */
2537 struct group *group; /* Group */
2541 * Loop through each line in the file...
2546 while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
2549 * Decode the directive...
2552 if (!_cups_strcasecmp(line, "Include") && value)
2558 if (value[0] == '/')
2559 strlcpy(incname, value, sizeof(incname));
2561 snprintf(incname, sizeof(incname), "%s/%s", ServerRoot, value);
2563 if ((incfile = cupsFileOpen(incname, "rb")) == NULL)
2564 cupsdLogMessage(CUPSD_LOG_ERROR,
2565 "Unable to include config file \"%s\" - %s",
2566 incname, strerror(errno));
2569 read_configuration(incfile);
2570 cupsFileClose(incfile);
2573 else if (!_cups_strcasecmp(line, "<Location") && value)
2579 linenum = read_location(fp, value, linenum);
2583 else if (!_cups_strcasecmp(line, "<Policy") && value)
2589 linenum = read_policy(fp, value, linenum);
2593 else if (!_cups_strcasecmp(line, "FatalErrors"))
2594 FatalErrors = parse_fatal_errors(value);
2595 else if (!_cups_strcasecmp(line, "FaxRetryInterval") && value)
2597 JobRetryInterval = atoi(value);
2598 cupsdLogMessage(CUPSD_LOG_WARN,
2599 "FaxRetryInterval is deprecated; use "
2600 "JobRetryInterval on line %d.", linenum);
2602 else if (!_cups_strcasecmp(line, "FaxRetryLimit") && value)
2604 JobRetryLimit = atoi(value);
2605 cupsdLogMessage(CUPSD_LOG_WARN,
2606 "FaxRetryLimit is deprecated; use "
2607 "JobRetryLimit on line %d.", linenum);
2609 else if ((!_cups_strcasecmp(line, "Port") || !_cups_strcasecmp(line, "Listen")
2611 || !_cups_strcasecmp(line, "SSLPort") || !_cups_strcasecmp(line, "SSLListen")
2612 #endif /* HAVE_SSL */
2616 * Add listening address(es) to the list...
2619 cupsd_listener_t *lis; /* New listeners array */
2623 * Get the address list...
2626 addrlist = get_address(value, IPP_PORT);
2630 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad %s address %s at line %d.", line,
2636 * Add each address...
2639 for (addr = addrlist; addr; addr = addr->next)
2642 * See if this address is already present...
2645 for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
2647 lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
2648 if (httpAddrEqual(&(addr->addr), &(lis->address)) &&
2649 _httpAddrPort(&(addr->addr)) == _httpAddrPort(&(lis->address)))
2654 httpAddrString(&lis->address, temp, sizeof(temp));
2655 cupsdLogMessage(CUPSD_LOG_WARN,
2656 "Duplicate listen address \"%s\" ignored.", temp);
2661 * Allocate another listener...
2665 Listeners = cupsArrayNew(NULL, NULL);
2669 cupsdLogMessage(CUPSD_LOG_ERROR,
2670 "Unable to allocate %s at line %d - %s.",
2671 line, linenum, strerror(errno));
2675 if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
2677 cupsdLogMessage(CUPSD_LOG_ERROR,
2678 "Unable to allocate %s at line %d - %s.",
2679 line, linenum, strerror(errno));
2683 cupsArrayAdd(Listeners, lis);
2686 * Copy the current address and log it...
2689 memcpy(&(lis->address), &(addr->addr), sizeof(lis->address));
2693 if (!_cups_strcasecmp(line, "SSLPort") || !_cups_strcasecmp(line, "SSLListen"))
2694 lis->encryption = HTTP_ENCRYPT_ALWAYS;
2695 #endif /* HAVE_SSL */
2697 httpAddrString(&lis->address, temp, sizeof(temp));
2700 if (lis->address.addr.sa_family == AF_LOCAL)
2701 cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s (Domain)", temp);
2703 #endif /* AF_LOCAL */
2704 cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv%d)", temp,
2705 _httpAddrPort(&(lis->address)),
2706 _httpAddrFamily(&(lis->address)) == AF_INET ? 4 : 6);
2708 if (!httpAddrLocalhost(&(lis->address)))
2709 RemotePort = _httpAddrPort(&(lis->address));
2716 httpAddrFreeList(addrlist);
2718 else if (!_cups_strcasecmp(line, "BrowseAddress") && value)
2721 * Add a browse address to the list...
2724 cupsd_dirsvc_addr_t *dira; /* New browse address array */
2727 if (NumBrowsers == 0)
2728 dira = malloc(sizeof(cupsd_dirsvc_addr_t));
2730 dira = realloc(Browsers, (NumBrowsers + 1) * sizeof(cupsd_dirsvc_addr_t));
2734 cupsdLogMessage(CUPSD_LOG_ERROR,
2735 "Unable to allocate BrowseAddress at line %d - %s.",
2736 linenum, strerror(errno));
2741 dira += NumBrowsers;
2743 memset(dira, 0, sizeof(cupsd_dirsvc_addr_t));
2745 if (!_cups_strcasecmp(value, "@LOCAL"))
2748 * Send browse data to all local interfaces...
2751 strcpy(dira->iface, "*");
2754 else if (!_cups_strncasecmp(value, "@IF(", 4))
2757 * Send browse data to the named interface...
2760 strlcpy(dira->iface, value + 4, sizeof(Browsers[0].iface));
2762 ptr = dira->iface + strlen(dira->iface) - 1;
2768 else if ((addrlist = get_address(value, BrowsePort)) != NULL)
2771 * Only IPv4 addresses are supported...
2774 for (addr = addrlist; addr; addr = addr->next)
2775 if (_httpAddrFamily(&(addr->addr)) == AF_INET)
2780 memcpy(&(dira->to), &(addrlist->addr), sizeof(dira->to));
2781 httpAddrString(&(dira->to), temp, sizeof(temp));
2783 cupsdLogMessage(CUPSD_LOG_INFO,
2784 "Sending browsing info to %s:%d (IPv4)",
2785 temp, _httpAddrPort(&(dira->to)));
2790 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
2793 httpAddrFreeList(addrlist);
2796 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
2799 else if (!_cups_strcasecmp(line, "BrowseOrder") && value)
2802 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2805 if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL)
2806 if ((location = cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL)
2807 cupsdAddLocation(location);
2809 if (location == NULL)
2810 cupsdLogMessage(CUPSD_LOG_ERROR,
2811 "Unable to initialize browse access control list.");
2812 else if (!_cups_strncasecmp(value, "deny", 4))
2813 location->order_type = CUPSD_AUTH_ALLOW;
2814 else if (!_cups_strncasecmp(value, "allow", 5))
2815 location->order_type = CUPSD_AUTH_DENY;
2817 cupsdLogMessage(CUPSD_LOG_ERROR,
2818 "Unknown BrowseOrder value %s on line %d.",
2821 else if (!_cups_strcasecmp(line, "BrowseProtocols") ||
2822 !_cups_strcasecmp(line, "BrowseLocalProtocols") ||
2823 !_cups_strcasecmp(line, "BrowseRemoteProtocols"))
2826 * "BrowseProtocols name [... name]"
2827 * "BrowseLocalProtocols name [... name]"
2828 * "BrowseRemoteProtocols name [... name]"
2831 int protocols = parse_protocols(value);
2835 cupsdLogMessage(CUPSD_LOG_ERROR,
2836 "Unknown browse protocol \"%s\" on line %d.",
2841 if (_cups_strcasecmp(line, "BrowseLocalProtocols"))
2842 BrowseRemoteProtocols = protocols;
2843 if (_cups_strcasecmp(line, "BrowseRemoteProtocols"))
2844 BrowseLocalProtocols = protocols;
2846 else if ((!_cups_strcasecmp(line, "BrowseAllow") ||
2847 !_cups_strcasecmp(line, "BrowseDeny")) && value)
2850 * BrowseAllow [From] host/ip...
2851 * BrowseDeny [From] host/ip...
2854 if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL)
2855 if ((location = cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL)
2856 cupsdAddLocation(location);
2859 if (location == NULL)
2860 cupsdLogMessage(CUPSD_LOG_ERROR,
2861 "Unable to initialize browse access control list.");
2864 if (!_cups_strncasecmp(value, "from", 4))
2867 * Skip leading "from"...
2876 * Skip leading whitespace...
2879 while (_cups_isspace(*value))
2886 * Find the end of the value...
2889 for (valueptr = value;
2890 *valueptr && !_cups_isspace(*valueptr);
2893 while (_cups_isspace(*valueptr))
2897 * Figure out what form the allow/deny address takes:
2908 * nnn.nnn.nnn.nnn/mm
2909 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2912 if (!_cups_strcasecmp(value, "all"))
2918 if (!_cups_strcasecmp(line, "BrowseAllow"))
2919 cupsdAddIPMask(&(location->allow), zeros, zeros);
2921 cupsdAddIPMask(&(location->deny), zeros, zeros);
2923 else if (!_cups_strcasecmp(value, "none"))
2929 if (!_cups_strcasecmp(line, "BrowseAllow"))
2930 cupsdAddIPMask(&(location->allow), ones, zeros);
2932 cupsdAddIPMask(&(location->deny), ones, zeros);
2935 else if (value[0] == '*' || value[0] == '.' ||
2936 (!isdigit(value[0] & 255) && value[0] != '['))
2938 else if (value[0] == '*' || value[0] == '.' ||
2939 !isdigit(value[0] & 255))
2940 #endif /* AF_INET6 */
2943 * Host or domain name...
2946 if (!_cups_strcasecmp(line, "BrowseAllow"))
2947 cupsdAddNameMask(&(location->allow), value);
2949 cupsdAddNameMask(&(location->deny), value);
2954 * One of many IP address forms...
2957 if (!get_addr_and_mask(value, ip, mask))
2959 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
2964 if (!_cups_strcasecmp(line, "BrowseAllow"))
2965 cupsdAddIPMask(&(location->allow), ip, mask);
2967 cupsdAddIPMask(&(location->deny), ip, mask);
2971 * Advance to next value...
2978 else if (!_cups_strcasecmp(line, "BrowseRelay") && value)
2981 * BrowseRelay [from] source [to] destination
2985 relay = malloc(sizeof(cupsd_dirsvc_relay_t));
2987 relay = realloc(Relays, (NumRelays + 1) * sizeof(cupsd_dirsvc_relay_t));
2991 cupsdLogMessage(CUPSD_LOG_ERROR,
2992 "Unable to allocate BrowseRelay at line %d - %s.",
2993 linenum, strerror(errno));
3000 memset(relay, 0, sizeof(cupsd_dirsvc_relay_t));
3002 if (!_cups_strncasecmp(value, "from ", 5))
3005 * Skip leading "from"...
3011 * Skip leading whitespace...
3014 while (_cups_isspace(*value))
3019 * Find the end of the from value...
3022 for (valueptr = value;
3023 *valueptr && !_cups_isspace(*valueptr);
3026 while (_cups_isspace(*valueptr))
3030 * Figure out what form the from address takes:
3039 * nnn.nnn.nnn.nnn/mm
3040 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
3044 if (value[0] == '*' || value[0] == '.' ||
3045 (!isdigit(value[0] & 255) && value[0] != '['))
3047 if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
3048 #endif /* AF_INET6 */
3051 * Host or domain name...
3054 if (!cupsdAddNameMask(&(relay->from), value))
3056 cupsdLogMessage(CUPSD_LOG_ERROR,
3057 "Unable to allocate BrowseRelay name at line %d - %s.",
3058 linenum, strerror(errno));
3065 * One of many IP address forms...
3068 if (!get_addr_and_mask(value, ip, mask))
3070 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
3075 if (!cupsdAddIPMask(&(relay->from), ip, mask))
3077 cupsdLogMessage(CUPSD_LOG_ERROR,
3078 "Unable to allocate BrowseRelay IP at line %d - %s.",
3079 linenum, strerror(errno));
3085 * Get "to" address and port...
3088 if (!_cups_strncasecmp(valueptr, "to ", 3))
3091 * Strip leading "to"...
3096 while (_cups_isspace(*valueptr))
3100 if ((addrlist = get_address(valueptr, BrowsePort)) != NULL)
3103 * Only IPv4 addresses are supported...
3106 for (addr = addrlist; addr; addr = addr->next)
3107 if (addr->addr.addr.sa_family == AF_INET)
3112 memcpy(&(relay->to), &(addrlist->addr), sizeof(relay->to));
3114 httpAddrString(&(relay->to), temp, sizeof(temp));
3116 cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
3117 value, temp, _httpAddrPort(&(relay->to)));
3123 cupsArrayDelete(relay->from);
3126 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
3130 httpAddrFreeList(addrlist);
3134 cupsArrayDelete(relay->from);
3137 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
3141 else if (!_cups_strcasecmp(line, "BrowsePoll") && value)
3144 * BrowsePoll address[:port]
3147 char *portname; /* Port name */
3148 int portnum; /* Port number */
3149 struct servent *service; /* Service */
3153 * Extract the port name from the address...
3156 if ((portname = strrchr(value, ':')) != NULL && !strchr(portname, ']'))
3160 if (isdigit(*portname & 255))
3161 portnum = atoi(portname);
3162 else if ((service = getservbyname(portname, NULL)) != NULL)
3163 portnum = ntohs(service->s_port);
3166 cupsdLogMessage(CUPSD_LOG_ERROR, "Lookup of service \"%s\" failed.",
3172 portnum = ippPort();
3175 * Add the poll entry...
3179 pollp = malloc(sizeof(cupsd_dirsvc_poll_t));
3181 pollp = realloc(Polled, (NumPolled + 1) * sizeof(cupsd_dirsvc_poll_t));
3185 cupsdLogMessage(CUPSD_LOG_ERROR,
3186 "Unable to allocate BrowsePoll at line %d - %s.",
3187 linenum, strerror(errno));
3195 memset(pollp, 0, sizeof(cupsd_dirsvc_poll_t));
3197 strlcpy(pollp->hostname, value, sizeof(pollp->hostname));
3198 pollp->port = portnum;
3200 cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
3203 else if (!_cups_strcasecmp(line, "DefaultAuthType") && value)
3206 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3209 if (!_cups_strcasecmp(value, "none"))
3210 DefaultAuthType = CUPSD_AUTH_NONE;
3211 else if (!_cups_strcasecmp(value, "basic"))
3212 DefaultAuthType = CUPSD_AUTH_BASIC;
3213 else if (!_cups_strcasecmp(value, "digest"))
3214 DefaultAuthType = CUPSD_AUTH_DIGEST;
3215 else if (!_cups_strcasecmp(value, "basicdigest"))
3216 DefaultAuthType = CUPSD_AUTH_BASICDIGEST;
3218 else if (!_cups_strcasecmp(value, "negotiate"))
3219 DefaultAuthType = CUPSD_AUTH_NEGOTIATE;
3220 #endif /* HAVE_GSSAPI */
3223 cupsdLogMessage(CUPSD_LOG_WARN,
3224 "Unknown default authorization type %s on line %d.",
3226 if (FatalErrors & CUPSD_FATAL_CONFIG)
3231 else if (!_cups_strcasecmp(line, "DefaultEncryption"))
3234 * DefaultEncryption {Never,IfRequested,Required}
3237 if (!value || !_cups_strcasecmp(value, "never"))
3238 DefaultEncryption = HTTP_ENCRYPT_NEVER;
3239 else if (!_cups_strcasecmp(value, "required"))
3240 DefaultEncryption = HTTP_ENCRYPT_REQUIRED;
3241 else if (!_cups_strcasecmp(value, "ifrequested"))
3242 DefaultEncryption = HTTP_ENCRYPT_IF_REQUESTED;
3245 cupsdLogMessage(CUPSD_LOG_WARN,
3246 "Unknown default encryption %s on line %d.",
3248 if (FatalErrors & CUPSD_FATAL_CONFIG)
3252 #endif /* HAVE_SSL */
3253 else if (!_cups_strcasecmp(line, "User") && value)
3256 * User ID to run as...
3259 if (isdigit(value[0] & 255))
3261 int uid = atoi(value);
3264 cupsdLogMessage(CUPSD_LOG_ERROR,
3265 "Will not use User 0 as specified on line %d "
3266 "for security reasons. You must use a non-"
3267 "privileged account instead.",
3274 struct passwd *p; /* Password information */
3277 p = getpwnam(value);
3282 cupsdLogMessage(CUPSD_LOG_ERROR,
3283 "Will not use User %s (UID=0) as specified on line "
3284 "%d for security reasons. You must use a non-"
3285 "privileged account instead.",
3291 cupsdLogMessage(CUPSD_LOG_ERROR,
3292 "Unknown User \"%s\" on line %d, ignoring.",
3296 else if (!_cups_strcasecmp(line, "Group") && value)
3299 * Group ID to run as...
3302 if (isdigit(value[0]))
3303 Group = atoi(value);
3307 group = getgrnam(value);
3310 Group = group->gr_gid;
3312 cupsdLogMessage(CUPSD_LOG_ERROR,
3313 "Unknown Group \"%s\" on line %d, ignoring.",
3317 else if (!_cups_strcasecmp(line, "SystemGroup") && value)
3320 * SystemGroup (admin) group(s)...
3323 if (!parse_groups(value))
3324 cupsdLogMessage(CUPSD_LOG_ERROR,
3325 "Unknown SystemGroup \"%s\" on line %d, ignoring.",
3328 else if (!_cups_strcasecmp(line, "HostNameLookups") && value)
3331 * Do hostname lookups?
3334 if (!_cups_strcasecmp(value, "off") || !_cups_strcasecmp(value, "no") ||
3335 !_cups_strcasecmp(value, "false"))
3336 HostNameLookups = 0;
3337 else if (!_cups_strcasecmp(value, "on") || !_cups_strcasecmp(value, "yes") ||
3338 !_cups_strcasecmp(value, "true"))
3339 HostNameLookups = 1;
3340 else if (!_cups_strcasecmp(value, "double"))
3341 HostNameLookups = 2;
3343 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.",
3346 else if (!_cups_strcasecmp(line, "AccessLogLevel") && value)
3349 * Amount of logging to do to access log...
3352 if (!_cups_strcasecmp(value, "all"))
3353 AccessLogLevel = CUPSD_ACCESSLOG_ALL;
3354 else if (!_cups_strcasecmp(value, "actions"))
3355 AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
3356 else if (!_cups_strcasecmp(value, "config"))
3357 AccessLogLevel = CUPSD_ACCESSLOG_CONFIG;
3359 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown AccessLogLevel %s on line %d.",
3362 else if (!_cups_strcasecmp(line, "LogLevel") && value)
3365 * Amount of logging to do to error log...
3368 if (!_cups_strcasecmp(value, "debug2"))
3369 LogLevel = CUPSD_LOG_DEBUG2;
3370 else if (!_cups_strcasecmp(value, "debug"))
3371 LogLevel = CUPSD_LOG_DEBUG;
3372 else if (!_cups_strcasecmp(value, "info"))
3373 LogLevel = CUPSD_LOG_INFO;
3374 else if (!_cups_strcasecmp(value, "notice"))
3375 LogLevel = CUPSD_LOG_NOTICE;
3376 else if (!_cups_strcasecmp(value, "warn"))
3377 LogLevel = CUPSD_LOG_WARN;
3378 else if (!_cups_strcasecmp(value, "error"))
3379 LogLevel = CUPSD_LOG_ERROR;
3380 else if (!_cups_strcasecmp(value, "crit"))
3381 LogLevel = CUPSD_LOG_CRIT;
3382 else if (!_cups_strcasecmp(value, "alert"))
3383 LogLevel = CUPSD_LOG_ALERT;
3384 else if (!_cups_strcasecmp(value, "emerg"))
3385 LogLevel = CUPSD_LOG_EMERG;
3386 else if (!_cups_strcasecmp(value, "none"))
3387 LogLevel = CUPSD_LOG_NONE;
3389 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogLevel %s on line %d.",
3392 else if (!_cups_strcasecmp(line, "LogTimeFormat") && value)
3395 * Amount of logging to do to error log...
3398 if (!_cups_strcasecmp(value, "standard"))
3399 LogTimeFormat = CUPSD_TIME_STANDARD;
3400 else if (!_cups_strcasecmp(value, "usecs"))
3401 LogTimeFormat = CUPSD_TIME_USECS;
3403 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogTimeFormat %s on line %d.",
3406 else if (!_cups_strcasecmp(line, "PrintcapFormat") && value)
3409 * Format of printcap file?
3412 if (!_cups_strcasecmp(value, "bsd"))
3413 PrintcapFormat = PRINTCAP_BSD;
3414 else if (!_cups_strcasecmp(value, "plist"))
3415 PrintcapFormat = PRINTCAP_PLIST;
3416 else if (!_cups_strcasecmp(value, "solaris"))
3417 PrintcapFormat = PRINTCAP_SOLARIS;
3419 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown PrintcapFormat %s on line %d.",
3422 else if (!_cups_strcasecmp(line, "ServerTokens") && value)
3425 * Set the string used for the Server header...
3428 struct utsname plat; /* Platform info */
3433 if (!_cups_strcasecmp(value, "ProductOnly"))
3434 cupsdSetString(&ServerHeader, "CUPS");
3435 else if (!_cups_strcasecmp(value, "Major"))
3436 cupsdSetStringf(&ServerHeader, "CUPS/%d", CUPS_VERSION_MAJOR);
3437 else if (!_cups_strcasecmp(value, "Minor"))
3438 cupsdSetStringf(&ServerHeader, "CUPS/%d.%d", CUPS_VERSION_MAJOR,
3439 CUPS_VERSION_MINOR);
3440 else if (!_cups_strcasecmp(value, "Minimal"))
3441 cupsdSetString(&ServerHeader, CUPS_MINIMAL);
3442 else if (!_cups_strcasecmp(value, "OS"))
3443 cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s)", plat.sysname);
3444 else if (!_cups_strcasecmp(value, "Full"))
3445 cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/2.1",
3447 else if (!_cups_strcasecmp(value, "None"))
3448 cupsdClearString(&ServerHeader);
3450 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown ServerTokens %s on line %d.",
3453 else if (!_cups_strcasecmp(line, "PassEnv") && value)
3456 * PassEnv variable [... variable]
3461 for (valuelen = 0; value[valuelen]; valuelen ++)
3462 if (_cups_isspace(value[valuelen]) || value[valuelen] == ',')
3465 if (value[valuelen])
3467 value[valuelen] = '\0';
3471 cupsdSetEnv(value, NULL);
3473 for (value += valuelen; *value; value ++)
3474 if (!_cups_isspace(*value) || *value != ',')
3478 else if (!_cups_strcasecmp(line, "ServerAlias") && value)
3481 * ServerAlias name [... name]
3485 ServerAlias = cupsArrayNew(NULL, NULL);
3489 for (valuelen = 0; value[valuelen]; valuelen ++)
3490 if (_cups_isspace(value[valuelen]) || value[valuelen] == ',')
3493 if (value[valuelen])
3495 value[valuelen] = '\0';
3499 cupsdAddAlias(ServerAlias, value);
3501 for (value += valuelen; *value; value ++)
3502 if (!_cups_isspace(*value) || *value != ',')
3506 else if (!_cups_strcasecmp(line, "SetEnv") && value)
3509 * SetEnv variable value
3512 for (valueptr = value; *valueptr && !isspace(*valueptr & 255); valueptr ++);
3520 while (isspace(*valueptr & 255))
3523 cupsdSetEnv(value, valueptr);
3526 cupsdLogMessage(CUPSD_LOG_ERROR,
3527 "Missing value for SetEnv directive on line %d.",
3531 else if (!_cups_strcasecmp(line, "SSLOptions"))
3534 * SSLOptions options
3537 if (!value || !_cups_strcasecmp(value, "none"))
3538 SSLOptions = CUPSD_SSL_NONE;
3539 else if (!_cups_strcasecmp(value, "noemptyfragments"))
3540 SSLOptions = CUPSD_SSL_NOEMPTY;
3542 cupsdLogMessage(CUPSD_LOG_ERROR,
3543 "Unknown value \"%s\" for SSLOptions directive on "
3544 "line %d.", value, linenum);
3546 #endif /* HAVE_SSL */
3550 * Find a simple variable in the list...
3553 for (i = NUM_VARS, var = variables; i > 0; i --, var ++)
3554 if (!_cups_strcasecmp(line, var->name))
3560 * Unknown directive! Output an error message and continue...
3564 cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value for %s on line %d.",
3567 cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d.",
3574 case CUPSD_VARTYPE_INTEGER :
3576 cupsdLogMessage(CUPSD_LOG_ERROR,
3577 "Missing integer value for %s on line %d.",
3582 char *units; /* Units */
3585 n = strtol(value, &units, 0);
3587 if (units && *units)
3589 if (tolower(units[0] & 255) == 'g')
3590 n *= 1024 * 1024 * 1024;
3591 else if (tolower(units[0] & 255) == 'm')
3593 else if (tolower(units[0] & 255) == 'k')
3595 else if (tolower(units[0] & 255) == 't')
3600 cupsdLogMessage(CUPSD_LOG_ERROR,
3601 "Bad negative integer value for %s on line %d.",
3604 *((int *)var->ptr) = n;
3608 case CUPSD_VARTYPE_BOOLEAN :
3610 cupsdLogMessage(CUPSD_LOG_ERROR,
3611 "Missing boolean value for %s on line %d.",
3613 else if (!_cups_strcasecmp(value, "true") ||
3614 !_cups_strcasecmp(value, "on") ||
3615 !_cups_strcasecmp(value, "enabled") ||
3616 !_cups_strcasecmp(value, "yes") ||
3618 *((int *)var->ptr) = TRUE;
3619 else if (!_cups_strcasecmp(value, "false") ||
3620 !_cups_strcasecmp(value, "off") ||
3621 !_cups_strcasecmp(value, "disabled") ||
3622 !_cups_strcasecmp(value, "no") ||
3623 !_cups_strcasecmp(value, "0"))
3624 *((int *)var->ptr) = FALSE;
3626 cupsdLogMessage(CUPSD_LOG_ERROR,
3627 "Unknown boolean value %s on line %d.",
3631 case CUPSD_VARTYPE_PATHNAME :
3634 cupsdLogMessage(CUPSD_LOG_ERROR,
3635 "Missing pathname value for %s on line %d.",
3640 if (value[0] == '/')
3641 strlcpy(temp, value, sizeof(temp));
3643 snprintf(temp, sizeof(temp), "%s/%s", ServerRoot, value);
3645 if (access(temp, 0))
3647 cupsdLogMessage(CUPSD_LOG_ERROR,
3648 "File or directory for \"%s %s\" on line %d "
3649 "does not exist.", line, value, linenum);
3653 case CUPSD_VARTYPE_STRING :
3654 cupsdSetString((char **)var->ptr, value);
3665 * 'read_location()' - Read a <Location path> definition.
3668 static int /* O - New line number or 0 on error */
3669 read_location(cups_file_t *fp, /* I - Configuration file */
3670 char *location, /* I - Location name/path */
3671 int linenum) /* I - Current line number */
3673 cupsd_location_t *loc, /* New location */
3674 *parent; /* Parent location */
3675 char line[HTTP_MAX_BUFFER],
3677 *value, /* Value for directive */
3678 *valptr; /* Pointer into value */
3681 if ((parent = cupsdFindLocation(location)) != NULL)
3682 cupsdLogMessage(CUPSD_LOG_WARN, "Duplicate <Location %s> on line %d.",
3684 else if ((parent = cupsdNewLocation(location)) == NULL)
3688 cupsdAddLocation(parent);
3690 parent->limit = CUPSD_AUTH_LIMIT_ALL;
3695 while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
3698 * Decode the directive...
3701 if (!_cups_strcasecmp(line, "</Location>"))
3703 else if (!_cups_strcasecmp(line, "<Limit") ||
3704 !_cups_strcasecmp(line, "<LimitExcept"))
3708 cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
3709 if (FatalErrors & CUPSD_FATAL_CONFIG)
3715 if ((loc = cupsdCopyLocation(parent)) == NULL)
3718 cupsdAddLocation(loc);
3723 for (valptr = value; !isspace(*valptr & 255) && *valptr; valptr ++);
3728 if (!strcmp(value, "ALL"))
3729 loc->limit = CUPSD_AUTH_LIMIT_ALL;
3730 else if (!strcmp(value, "GET"))
3731 loc->limit |= CUPSD_AUTH_LIMIT_GET;
3732 else if (!strcmp(value, "HEAD"))
3733 loc->limit |= CUPSD_AUTH_LIMIT_HEAD;
3734 else if (!strcmp(value, "OPTIONS"))
3735 loc->limit |= CUPSD_AUTH_LIMIT_OPTIONS;
3736 else if (!strcmp(value, "POST"))
3737 loc->limit |= CUPSD_AUTH_LIMIT_POST;
3738 else if (!strcmp(value, "PUT"))
3739 loc->limit |= CUPSD_AUTH_LIMIT_PUT;
3740 else if (!strcmp(value, "TRACE"))
3741 loc->limit |= CUPSD_AUTH_LIMIT_TRACE;
3743 cupsdLogMessage(CUPSD_LOG_WARN, "Unknown request type %s on line %d.",
3746 for (value = valptr; isspace(*value & 255); value ++);
3749 if (!_cups_strcasecmp(line, "<LimitExcept"))
3750 loc->limit = CUPSD_AUTH_LIMIT_ALL ^ loc->limit;
3752 parent->limit &= ~loc->limit;
3754 else if (!_cups_strcasecmp(line, "</Limit>") ||
3755 !_cups_strcasecmp(line, "</LimitExcept>"))
3759 cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value on line %d.", linenum);
3760 if (FatalErrors & CUPSD_FATAL_CONFIG)
3763 else if (!parse_aaa(loc, line, value, linenum))
3765 cupsdLogMessage(CUPSD_LOG_ERROR,
3766 "Unknown Location directive %s on line %d.",
3768 if (FatalErrors & CUPSD_FATAL_CONFIG)
3773 cupsdLogMessage(CUPSD_LOG_ERROR,
3774 "Unexpected end-of-file at line %d while reading location.",
3777 return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
3782 * 'read_policy()' - Read a <Policy name> definition.
3785 static int /* O - New line number or 0 on error */
3786 read_policy(cups_file_t *fp, /* I - Configuration file */
3787 char *policy, /* I - Location name/path */
3788 int linenum) /* I - Current line number */
3790 int i; /* Looping var */
3791 cupsd_policy_t *pol; /* Policy */
3792 cupsd_location_t *op; /* Policy operation */
3793 int num_ops; /* Number of IPP operations */
3794 ipp_op_t ops[100]; /* Operations */
3795 char line[HTTP_MAX_BUFFER],
3797 *value, /* Value for directive */
3798 *valptr; /* Pointer into value */
3802 * Create the policy...
3805 if ((pol = cupsdFindPolicy(policy)) != NULL)
3806 cupsdLogMessage(CUPSD_LOG_WARN, "Duplicate <Policy %s> on line %d.",
3808 else if ((pol = cupsdAddPolicy(policy)) == NULL)
3812 * Read from the file...
3818 while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
3821 * Decode the directive...
3824 if (!_cups_strcasecmp(line, "</Policy>"))
3827 cupsdLogMessage(CUPSD_LOG_WARN,
3828 "Missing </Limit> before </Policy> on line %d.",
3831 set_policy_defaults(pol);
3835 else if (!_cups_strcasecmp(line, "<Limit") && !op)
3839 cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
3840 if (FatalErrors & CUPSD_FATAL_CONFIG)
3847 * Scan for IPP operation names...
3854 for (valptr = value; !isspace(*valptr & 255) && *valptr; valptr ++);
3859 if (num_ops < (int)(sizeof(ops) / sizeof(ops[0])))
3861 if (!_cups_strcasecmp(value, "All"))
3862 ops[num_ops] = IPP_ANY_OPERATION;
3863 else if ((ops[num_ops] = ippOpValue(value)) == IPP_BAD_OPERATION)
3864 cupsdLogMessage(CUPSD_LOG_ERROR,
3865 "Bad IPP operation name \"%s\" on line %d.",
3871 cupsdLogMessage(CUPSD_LOG_ERROR,
3872 "Too many operations listed on line %d.",
3875 for (value = valptr; isspace(*value & 255); value ++);
3879 * If none are specified, apply the policy to all operations...
3884 ops[0] = IPP_ANY_OPERATION;
3889 * Add a new policy for the first operation...
3892 op = cupsdAddPolicyOp(pol, NULL, ops[0]);
3894 else if (!_cups_strcasecmp(line, "</Limit>") && op)
3897 * Finish the current operation limit...
3903 * Copy the policy to the other operations...
3906 for (i = 1; i < num_ops; i ++)
3907 cupsdAddPolicyOp(pol, op, ops[i]);
3914 cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value on line %d.", linenum);
3915 if (FatalErrors & CUPSD_FATAL_CONFIG)
3918 else if (!_cups_strcasecmp(line, "JobPrivateAccess") ||
3919 !_cups_strcasecmp(line, "JobPrivateValues") ||
3920 !_cups_strcasecmp(line, "SubscriptionPrivateAccess") ||
3921 !_cups_strcasecmp(line, "SubscriptionPrivateValues"))
3925 cupsdLogMessage(CUPSD_LOG_ERROR,
3926 "%s directive must appear outside <Limit>...</Limit> "
3927 "on line %d.", line, linenum);
3928 if (FatalErrors & CUPSD_FATAL_CONFIG)
3934 * Pull out whitespace-delimited values...
3940 * Find the end of the current value...
3943 for (valptr = value; !isspace(*valptr & 255) && *valptr; valptr ++);
3949 * Save it appropriately...
3952 if (!_cups_strcasecmp(line, "JobPrivateAccess"))
3955 * JobPrivateAccess {all|default|user/group list|@@ACL}
3958 if (!_cups_strcasecmp(value, "default"))
3960 cupsdAddString(&(pol->job_access), "@OWNER");
3961 cupsdAddString(&(pol->job_access), "@SYSTEM");
3964 cupsdAddString(&(pol->job_access), value);
3966 else if (!_cups_strcasecmp(line, "JobPrivateValues"))
3969 * JobPrivateValues {all|none|default|attribute list}
3972 if (!_cups_strcasecmp(value, "default"))
3974 cupsdAddString(&(pol->job_attrs), "job-name");
3975 cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
3976 cupsdAddString(&(pol->job_attrs), "job-originating-user-name");
3979 cupsdAddString(&(pol->job_attrs), value);
3981 else if (!_cups_strcasecmp(line, "SubscriptionPrivateAccess"))
3984 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3987 if (!_cups_strcasecmp(value, "default"))
3989 cupsdAddString(&(pol->sub_access), "@OWNER");
3990 cupsdAddString(&(pol->sub_access), "@SYSTEM");
3993 cupsdAddString(&(pol->sub_access), value);
3995 else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
3998 * SubscriptionPrivateValues {all|none|default|attribute list}
4001 if (!_cups_strcasecmp(value, "default"))
4003 cupsdAddString(&(pol->sub_attrs), "notify-events");
4004 cupsdAddString(&(pol->sub_attrs), "notify-pull-method");
4005 cupsdAddString(&(pol->sub_attrs), "notify-recipient-uri");
4006 cupsdAddString(&(pol->sub_attrs), "notify-subscriber-user-name");
4007 cupsdAddString(&(pol->sub_attrs), "notify-user-data");
4010 cupsdAddString(&(pol->sub_attrs), value);
4014 * Find the next string on the line...
4017 for (value = valptr; isspace(*value & 255); value ++);
4023 cupsdLogMessage(CUPSD_LOG_ERROR,
4024 "Missing <Limit ops> directive before %s on line %d.",
4026 if (FatalErrors & CUPSD_FATAL_CONFIG)
4029 else if (!parse_aaa(op, line, value, linenum))
4031 cupsdLogMessage(CUPSD_LOG_ERROR,
4032 "Unknown Policy Limit directive %s on line %d.",
4035 if (FatalErrors & CUPSD_FATAL_CONFIG)
4040 cupsdLogMessage(CUPSD_LOG_ERROR,
4041 "Unexpected end-of-file at line %d while reading policy "
4042 "\"%s\".", linenum, policy);
4044 return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
4049 * 'set_policy_defaults()' - Set default policy values as needed.
4053 set_policy_defaults(cupsd_policy_t *pol)/* I - Policy */
4055 cupsd_location_t *op; /* Policy operation */
4059 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
4060 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
4061 * upgrades do not introduce new security issues...
4064 if ((op = cupsdFindPolicyOp(pol, IPP_VALIDATE_JOB)) == NULL ||
4065 op->op == IPP_ANY_OPERATION)
4067 if ((op = cupsdFindPolicyOp(pol, IPP_PRINT_JOB)) != NULL &&
4068 op->op != IPP_ANY_OPERATION)
4071 * Add a new limit for Validate-Job using the Print-Job limit as a
4075 cupsdLogMessage(CUPSD_LOG_WARN,
4076 "No limit for Validate-Job defined in policy %s "
4077 "- using Print-Job's policy.", pol->name);
4079 cupsdAddPolicyOp(pol, op, IPP_VALIDATE_JOB);
4082 cupsdLogMessage(CUPSD_LOG_WARN,
4083 "No limit for Validate-Job defined in policy %s "
4084 "and no suitable template found.", pol->name);
4087 if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_JOBS)) == NULL ||
4088 op->op == IPP_ANY_OPERATION)
4090 if ((op = cupsdFindPolicyOp(pol, IPP_PAUSE_PRINTER)) != NULL &&
4091 op->op != IPP_ANY_OPERATION)
4094 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
4098 cupsdLogMessage(CUPSD_LOG_WARN,
4099 "No limit for Cancel-Jobs defined in policy %s "
4100 "- using Pause-Printer's policy.", pol->name);
4102 cupsdAddPolicyOp(pol, op, IPP_CANCEL_JOBS);
4105 cupsdLogMessage(CUPSD_LOG_WARN,
4106 "No limit for Cancel-Jobs defined in policy %s "
4107 "and no suitable template found.", pol->name);
4110 if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_MY_JOBS)) == NULL ||
4111 op->op == IPP_ANY_OPERATION)
4113 if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
4114 op->op != IPP_ANY_OPERATION)
4117 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4121 cupsdLogMessage(CUPSD_LOG_WARN,
4122 "No limit for Cancel-My-Jobs defined in policy %s "
4123 "- using Send-Document's policy.", pol->name);
4125 cupsdAddPolicyOp(pol, op, IPP_CANCEL_MY_JOBS);
4128 cupsdLogMessage(CUPSD_LOG_WARN,
4129 "No limit for Cancel-My-Jobs defined in policy %s "
4130 "and no suitable template found.", pol->name);
4133 if ((op = cupsdFindPolicyOp(pol, IPP_CLOSE_JOB)) == NULL ||
4134 op->op == IPP_ANY_OPERATION)
4136 if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
4137 op->op != IPP_ANY_OPERATION)
4140 * Add a new limit for Close-Job using the Send-Document limit as a
4144 cupsdLogMessage(CUPSD_LOG_WARN,
4145 "No limit for Close-Job defined in policy %s "
4146 "- using Send-Document's policy.", pol->name);
4148 cupsdAddPolicyOp(pol, op, IPP_CLOSE_JOB);
4151 cupsdLogMessage(CUPSD_LOG_WARN,
4152 "No limit for Close-Job defined in policy %s "
4153 "and no suitable template found.", pol->name);
4156 if ((op = cupsdFindPolicyOp(pol, CUPS_GET_DOCUMENT)) == NULL ||
4157 op->op == IPP_ANY_OPERATION)
4159 if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
4160 op->op != IPP_ANY_OPERATION)
4163 * Add a new limit for CUPS-Get-Document using the Send-Document
4164 * limit as a template...
4167 cupsdLogMessage(CUPSD_LOG_WARN,
4168 "No limit for CUPS-Get-Document defined in policy %s "
4169 "- using Send-Document's policy.", pol->name);
4171 cupsdAddPolicyOp(pol, op, CUPS_GET_DOCUMENT);
4174 cupsdLogMessage(CUPSD_LOG_WARN,
4175 "No limit for CUPS-Get-Document defined in policy %s "
4176 "and no suitable template found.", pol->name);
4180 * Verify we have JobPrivateAccess, JobPrivateValues,
4181 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4184 if (!pol->job_access)
4186 cupsdLogMessage(CUPSD_LOG_WARN,
4187 "No JobPrivateAccess defined in policy %s "
4188 "- using defaults.", pol->name);
4189 cupsdAddString(&(pol->job_access), "@OWNER");
4190 cupsdAddString(&(pol->job_access), "@SYSTEM");
4193 if (!pol->job_attrs)
4195 cupsdLogMessage(CUPSD_LOG_WARN,
4196 "No JobPrivateValues defined in policy %s "
4197 "- using defaults.", pol->name);
4198 cupsdAddString(&(pol->job_attrs), "job-name");
4199 cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
4200 cupsdAddString(&(pol->job_attrs), "job-originating-user-name");
4203 if (!pol->sub_access)
4205 cupsdLogMessage(CUPSD_LOG_WARN,
4206 "No SubscriptionPrivateAccess defined in policy %s "
4207 "- using defaults.", pol->name);
4208 cupsdAddString(&(pol->sub_access), "@OWNER");
4209 cupsdAddString(&(pol->sub_access), "@SYSTEM");
4212 if (!pol->sub_attrs)
4214 cupsdLogMessage(CUPSD_LOG_WARN,
4215 "No SubscriptionPrivateValues defined in policy %s "
4216 "- using defaults.", pol->name);
4217 cupsdAddString(&(pol->sub_attrs), "notify-events");
4218 cupsdAddString(&(pol->sub_attrs), "notify-pull-method");
4219 cupsdAddString(&(pol->sub_attrs), "notify-recipient-uri");
4220 cupsdAddString(&(pol->sub_attrs), "notify-subscriber-user-name");
4221 cupsdAddString(&(pol->sub_attrs), "notify-user-data");
4227 * End of "$Id: conf.c 10121 2011-11-16 15:28:11Z mike $".