2 * "$Id: conf.c 9352 2010-11-06 04:55:26Z 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
}
189 #define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
192 static const unsigned ones
[4] =
194 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
196 static const unsigned zeros
[4] =
198 0x00000000, 0x00000000, 0x00000000, 0x00000000
206 static http_addrlist_t
*get_address(const char *value
, int defport
);
207 static int get_addr_and_mask(const char *value
, unsigned *ip
,
209 static void mime_error_cb(void *ctx
, const char *message
);
210 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
211 char *value
, int linenum
);
212 static int parse_fatal_errors(const char *s
);
213 static int parse_groups(const char *s
);
214 static int parse_protocols(const char *s
);
215 static int read_configuration(cups_file_t
*fp
);
216 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
217 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
218 static void set_policy_defaults(cupsd_policy_t
*pol
);
222 * 'cupsdAddAlias()' - Add a host alias.
226 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
227 const char *name
) /* I - Name to add */
229 cupsd_alias_t
*a
; /* New alias */
230 size_t namelen
; /* Length of name */
233 namelen
= strlen(name
);
235 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
238 a
->namelen
= namelen
;
239 strcpy(a
->name
, name
); /* OK since a->name is allocated */
241 cupsArrayAdd(aliases
, a
);
246 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
249 int /* O - 0 on success, -1 on error, 1 on warning */
250 cupsdCheckPermissions(
251 const char *filename
, /* I - File/directory name */
252 const char *suffix
, /* I - Additional file/directory name */
253 int mode
, /* I - Permissions */
254 int user
, /* I - Owner */
255 int group
, /* I - Group */
256 int is_dir
, /* I - 1 = directory, 0 = file */
257 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
259 int dir_created
= 0; /* Did we create a directory? */
260 char pathname
[1024]; /* File name with prefix */
261 struct stat fileinfo
; /* Stat buffer */
262 int is_symlink
; /* Is "filename" a symlink? */
266 * Prepend the given root to the filename before testing it...
271 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
276 * See if we can stat the file/directory...
279 if (lstat(filename
, &fileinfo
))
281 if (errno
== ENOENT
&& create_dir
)
284 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
287 if (mkdir(filename
, mode
))
290 cupsdLogMessage(CUPSD_LOG_ERROR
,
291 "Unable to create directory \"%s\" - %s", filename
,
294 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
301 fileinfo
.st_mode
= mode
| S_IFDIR
;
304 return (create_dir
? -1 : 1);
307 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
309 if (stat(filename
, &fileinfo
))
311 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
312 filename
, strerror(errno
));
318 * Make sure it's a regular file or a directory as needed...
321 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
323 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file.", filename
);
327 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
330 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory.", filename
);
332 syslog(LOG_ERR
, "\"%s\" is not a directory.", filename
);
338 * If the filename is a symlink, do not change permissions (STR #2937)...
345 * Fix owner, group, and mode as needed...
348 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
351 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
354 if (chown(filename
, user
, group
) && !getuid())
357 cupsdLogMessage(CUPSD_LOG_ERROR
,
358 "Unable to change ownership of \"%s\" - %s", filename
,
361 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
368 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
371 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
374 if (chmod(filename
, mode
))
377 cupsdLogMessage(CUPSD_LOG_ERROR
,
378 "Unable to change permissions of \"%s\" - %s", filename
,
381 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
389 * Everything is OK...
397 * 'cupsdFreeAliases()' - Free all of the alias entries.
401 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
403 cupsd_alias_t
*a
; /* Current alias */
406 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
408 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
411 cupsArrayDelete(aliases
);
416 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
419 int /* O - 1 on success, 0 otherwise */
420 cupsdReadConfiguration(void)
422 int i
; /* Looping var */
423 cups_file_t
*fp
; /* Configuration file */
424 int status
; /* Return status */
425 char temp
[1024], /* Temporary buffer */
426 mimedir
[1024], /* MIME directory */
427 *slash
; /* Directory separator */
428 cups_lang_t
*language
; /* Language */
429 struct passwd
*user
; /* Default user */
430 struct group
*group
; /* Default group */
431 char *old_serverroot
, /* Old ServerRoot */
432 *old_requestroot
; /* Old RequestRoot */
433 int old_remote_port
; /* Old RemotePort */
434 const char *tmpdir
; /* TMPDIR environment variable */
435 struct stat tmpinfo
; /* Temporary directory info */
436 cupsd_policy_t
*p
; /* Policy */
440 * Save the old root paths...
443 old_serverroot
= NULL
;
444 cupsdSetString(&old_serverroot
, ServerRoot
);
445 old_requestroot
= NULL
;
446 cupsdSetString(&old_requestroot
, RequestRoot
);
449 * Reset the server configuration data...
452 cupsdDeleteAllLocations();
471 for (i
= 0; i
< NumRelays
; i
++)
472 cupsArrayDelete(Relays
[i
].from
);
479 cupsdDeleteAllListeners();
481 old_remote_port
= RemotePort
;
488 cupsdFreeAliases(ServerAlias
);
491 cupsdClearString(&ServerName
);
492 cupsdClearString(&ServerAdmin
);
493 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
494 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
495 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
496 cupsdSetString(&DataDir
, CUPS_DATADIR
);
497 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
498 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
499 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
500 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
501 cupsdSetString(&PageLogFormat
,
502 "%p %u %j %T %P %C %{job-billing} "
503 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
504 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
505 cupsdSetString(&PrintcapGUI
, "/usr/bin/glpoptions");
506 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
507 cupsdSetString(&RemoteRoot
, "remroot");
508 cupsdSetString(&ServerHeader
, "CUPS/1.4");
509 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
511 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
512 PrintcapFormat
= PRINTCAP_SOLARIS
;
513 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
514 "/Library/Preferences/org.cups.printers.plist"))
515 PrintcapFormat
= PRINTCAP_PLIST
;
517 PrintcapFormat
= PRINTCAP_BSD
;
519 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
520 if ((slash
= strrchr(temp
, '/')) != NULL
)
523 cupsdSetString(&ServerRoot
, temp
);
525 cupsdClearString(&Classification
);
526 ClassifyOverride
= 0;
530 cupsdSetString(&ServerCertificate
, "/Library/Keychains/System.keychain");
532 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
533 cupsdSetString(&ServerKey
, "ssl/server.key");
534 # endif /* HAVE_CDSASSL */
535 #endif /* HAVE_SSL */
537 language
= cupsLangDefault();
539 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
540 cupsdSetString(&DefaultLanguage
, "en");
542 cupsdSetString(&DefaultLanguage
, language
->language
);
544 cupsdClearString(&DefaultPaperSize
);
546 cupsdSetString(&RIPCache
, "128m");
548 cupsdSetString(&TempDir
, NULL
);
551 * Find the default user...
554 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
559 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
560 * complement number...)
569 * Find the default group...
572 group
= getgrnam(CUPS_DEFAULT_GROUP
);
576 Group
= group
->gr_gid
;
580 * Fallback to group "nobody"...
583 group
= getgrnam("nobody");
587 Group
= group
->gr_gid
;
591 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
592 * complement number...)
603 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
604 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
605 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
606 DefaultAuthType
= CUPSD_AUTH_BASIC
;
608 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
609 SSLOptions
= CUPSD_SSL_NONE
;
610 #endif /* HAVE_SSL */
611 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
612 JobKillDelay
= DEFAULT_TIMEOUT
;
614 JobRetryInterval
= 300;
619 HostNameLookups
= FALSE
;
620 ImplicitClasses
= CUPS_DEFAULT_IMPLICIT_CLASSES
;
621 ImplicitAnyClasses
= FALSE
;
622 HideImplicitMembers
= TRUE
;
624 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
625 ListenBackLog
= SOMAXCONN
;
626 LogDebugHistory
= 200;
627 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
628 LogLevel
= CUPSD_LOG_WARN
;
629 LogTimeFormat
= CUPSD_TIME_STANDARD
;
631 MaxClientsPerHost
= 0;
632 MaxLogSize
= 1024 * 1024;
634 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
635 ReloadTimeout
= DEFAULT_KEEPALIVE
;
636 RootCertDuration
= 300;
637 Timeout
= DEFAULT_TIMEOUT
;
639 WebInterface
= CUPS_DEFAULT_WEBIF
;
641 BrowseInterval
= DEFAULT_INTERVAL
;
642 BrowsePort
= ippPort();
643 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
644 BrowseRemoteProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS
);
645 BrowseShortNames
= CUPS_DEFAULT_BROWSE_SHORT_NAMES
;
646 BrowseTimeout
= DEFAULT_TIMEOUT
;
648 Browsing
= CUPS_DEFAULT_BROWSING
;
649 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
652 cupsdSetString(&DNSSDRegType
, "_ipp._tcp,_cups");
653 #endif /* HAVE_DNSSD */
655 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
656 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
658 cupsdClearString(&BrowseLocalOptions
);
659 cupsdClearString(&BrowseRemoteOptions
);
661 cupsdSetString(&ErrorPolicy
, "stop-printer");
664 cupsdClearString(&BrowseLDAPBindDN
);
665 cupsdClearString(&BrowseLDAPDN
);
666 cupsdClearString(&BrowseLDAPPassword
);
667 cupsdClearString(&BrowseLDAPServer
);
668 # ifdef HAVE_LDAP_SSL
669 cupsdClearString(&BrowseLDAPCACertFile
);
670 # endif /* HAVE_LDAP_SSL */
671 #endif /* HAVE_LDAP */
673 JobHistory
= DEFAULT_HISTORY
;
674 JobFiles
= DEFAULT_FILES
;
679 MaxJobsPerPrinter
= 0;
680 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
682 cupsdDeleteAllPolicies();
683 cupsdClearString(&DefaultPolicy
);
685 #ifdef HAVE_AUTHORIZATION_H
686 cupsdClearString(&SystemGroupAuthKey
);
687 #endif /* HAVE_AUTHORIZATION_H */
689 MaxSubscriptions
= 100;
690 MaxSubscriptionsPerJob
= 0;
691 MaxSubscriptionsPerPrinter
= 0;
692 MaxSubscriptionsPerUser
= 0;
693 DefaultLeaseDuration
= 86400;
694 MaxLeaseDuration
= 0;
697 LaunchdTimeout
= DEFAULT_TIMEOUT
+ 10;
698 #endif /* HAVE_LAUNCHD */
701 * Setup environment variables...
707 * Read the configuration file...
710 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
713 status
= read_configuration(fp
);
722 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
723 RemotePort
? "enabled" : "disabled");
726 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
729 * See if the ServerName is an IP address...
735 ServerAlias
= cupsArrayNew(NULL
, NULL
);
737 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
741 if (gethostname(temp
, sizeof(temp
)))
743 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
745 strlcpy(temp
, "localhost", sizeof(temp
));
748 cupsdSetString(&ServerName
, temp
);
751 ServerAlias
= cupsArrayNew(NULL
, NULL
);
753 cupsdAddAlias(ServerAlias
, temp
);
754 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
756 if (HostNameLookups
|| RemotePort
)
758 struct hostent
*host
; /* Host entry to get FQDN */
760 if ((host
= gethostbyname(temp
)) != NULL
)
762 if (strcasecmp(temp
, host
->h_name
))
764 cupsdSetString(&ServerName
, host
->h_name
);
765 cupsdAddAlias(ServerAlias
, host
->h_name
);
766 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
772 for (i
= 0; host
->h_aliases
[i
]; i
++)
773 if (strcasecmp(temp
, host
->h_aliases
[i
]))
775 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
776 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
784 * Make sure we have the base hostname added as an alias, too!
787 if ((slash
= strchr(temp
, '.')) != NULL
)
790 cupsdAddAlias(ServerAlias
, temp
);
791 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
795 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
797 ServerNameIsIP
= !*slash
;
800 * Make sure ServerAdmin is initialized...
804 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
807 * Use the default system group if none was supplied in cupsd.conf...
810 if (NumSystemGroups
== 0)
812 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
815 * Find the group associated with GID 0...
822 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
824 cupsdSetString(&SystemGroups
[0], "unknown");
826 SystemGroupIDs
[0] = 0;
832 * Get the access control list for browsing...
835 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
838 * Open the system log for cupsd if necessary...
842 if (!strcmp(AccessLog
, "syslog") ||
843 !strcmp(ErrorLog
, "syslog") ||
844 !strcmp(PageLog
, "syslog"))
845 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
846 #endif /* HAVE_VSYSLOG */
849 * Make sure each of the log files exists and gets rotated as necessary...
852 if (strcmp(AccessLog
, "syslog"))
853 cupsdCheckLogFile(&AccessFile
, AccessLog
);
855 if (strcmp(ErrorLog
, "syslog"))
856 cupsdCheckLogFile(&ErrorFile
, ErrorLog
);
858 if (strcmp(PageLog
, "syslog"))
859 cupsdCheckLogFile(&PageFile
, PageLog
);
862 * Log the configuration file that was used...
865 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
869 * Validate the Group and SystemGroup settings - they cannot be the same,
870 * otherwise the CGI programs will be able to authenticate as root without
876 for (i
= 0; i
< NumSystemGroups
; i
++)
877 if (Group
== SystemGroupIDs
[i
])
880 if (i
< NumSystemGroups
)
883 * Log the error and reset the group to a safe value...
886 cupsdLogMessage(CUPSD_LOG_NOTICE
,
887 "Group and SystemGroup cannot use the same groups.");
888 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
890 group
= getgrnam("nobody");
894 Group
= group
->gr_gid
;
898 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
899 * complement number...)
908 * Check that we have at least one listen/port line; if not, report this
909 * as an error and exit!
912 if (cupsArrayCount(Listeners
) == 0)
918 cupsdLogMessage(CUPSD_LOG_EMERG
,
919 "No valid Listen or Port lines were found in the "
920 "configuration file.");
926 cupsdEndProcess(getpid(), 0);
930 * Set the default locale using the language and charset...
933 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
936 * Update all relative filenames to include the full path from ServerRoot...
939 if (DocumentRoot
[0] != '/')
940 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
942 if (RequestRoot
[0] != '/')
943 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
945 if (ServerBin
[0] != '/')
946 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
948 if (StateDir
[0] != '/')
949 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
951 if (CacheDir
[0] != '/')
952 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
955 if (ServerCertificate
[0] != '/')
956 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
958 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
959 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
961 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
964 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
965 if (ServerKey
[0] != '/')
966 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
968 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
969 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
970 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
972 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
973 #endif /* HAVE_SSL */
976 * Make sure that directories and config files are owned and
977 * writable by the user and group in the cupsd.conf file...
980 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
982 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
984 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
986 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
988 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
990 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
991 SystemGroupIDs
[0], 1, 1) < 0 ||
992 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
994 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
996 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
998 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
1000 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
1002 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
1004 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
1005 Group
, 0, 0) < 0) &&
1006 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1010 * Update TempDir to the default if it hasn't been set already...
1015 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1018 * TMPDIR is defined, see if it is OK for us to use...
1021 if (stat(tmpdir
, &tmpinfo
))
1022 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1023 tmpdir
, strerror(errno
));
1024 else if (!S_ISDIR(tmpinfo
.st_mode
))
1025 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1027 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1028 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1029 !(tmpinfo
.st_mode
& S_IWOTH
))
1030 cupsdLogMessage(CUPSD_LOG_ERROR
,
1031 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1033 cupsdSetString(&TempDir
, tmpdir
);
1038 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1040 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1045 * Make sure the temporary directory has the right permissions...
1048 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1052 * Update ownership and permissions if the CUPS temp directory
1053 * is under the spool directory or does not exist...
1056 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1057 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1062 * Update environment variables...
1068 * Update default paper size setting as needed...
1071 if (!DefaultPaperSize
)
1073 #ifdef HAVE_LIBPAPER
1074 char *paper_result
; /* Paper size name from libpaper */
1076 if ((paper_result
= systempapername()) != NULL
)
1077 cupsdSetString(&DefaultPaperSize
, paper_result
);
1079 #endif /* HAVE_LIBPAPER */
1080 if (!DefaultLanguage
||
1081 !strcasecmp(DefaultLanguage
, "C") ||
1082 !strcasecmp(DefaultLanguage
, "POSIX") ||
1083 !strcasecmp(DefaultLanguage
, "en") ||
1084 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1085 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1086 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1087 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1090 * These are the only locales that will default to "letter" size...
1093 cupsdSetString(&DefaultPaperSize
, "Letter");
1096 cupsdSetString(&DefaultPaperSize
, "A4");
1100 * Update classification setting as needed...
1103 if (Classification
&& !strcasecmp(Classification
, "none"))
1104 cupsdClearString(&Classification
);
1107 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1110 * Check the MaxClients setting, and then allocate memory for it...
1113 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1116 cupsdLogMessage(CUPSD_LOG_INFO
,
1117 "MaxClients limited to 1/3 (%d) of the file descriptor "
1119 MaxFDs
/ 3, MaxFDs
);
1121 MaxClients
= MaxFDs
/ 3;
1124 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1128 * Check the MaxActiveJobs setting; limit to 1/3 the available
1129 * file descriptors, since we need a pipe for each job...
1132 if (MaxActiveJobs
> (MaxFDs
/ 3))
1133 MaxActiveJobs
= MaxFDs
/ 3;
1136 * Update the MaxClientsPerHost value, as needed...
1139 if (MaxClientsPerHost
<= 0)
1140 MaxClientsPerHost
= MaxClients
;
1142 if (MaxClientsPerHost
> MaxClients
)
1143 MaxClientsPerHost
= MaxClients
;
1145 cupsdLogMessage(CUPSD_LOG_INFO
,
1146 "Allowing up to %d client connections per host.",
1150 * Make sure that BrowseTimeout is at least twice the interval...
1153 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1155 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d.",
1159 BrowseTimeout
= BrowseInterval
* 2;
1161 BrowseTimeout
= DEFAULT_TIMEOUT
;
1163 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d.",
1168 * Update the default policy, as needed...
1172 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1174 DefaultPolicyPtr
= NULL
;
1176 if (!DefaultPolicyPtr
)
1178 cupsd_location_t
*po
; /* New policy operation */
1182 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1185 cupsdSetString(&DefaultPolicy
, "default");
1187 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1188 cupsdLogMessage(CUPSD_LOG_INFO
,
1189 "Using policy \"default\" as the default.");
1192 cupsdLogMessage(CUPSD_LOG_INFO
,
1193 "Creating CUPS default administrative policy:");
1195 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1197 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1199 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1200 cupsdAddString(&(p
->job_access
), "@OWNER");
1201 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1203 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1204 cupsdAddString(&(p
->job_attrs
), "job-name");
1205 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1206 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1208 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1209 cupsdAddString(&(p
->sub_access
), "@OWNER");
1210 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1212 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1213 cupsdAddString(&(p
->job_attrs
), "notify-events");
1214 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1215 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1216 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1217 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1219 cupsdLogMessage(CUPSD_LOG_INFO
,
1220 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1221 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1223 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1224 po
->order_type
= CUPSD_AUTH_ALLOW
;
1226 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1227 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1228 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1230 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1232 cupsdLogMessage(CUPSD_LOG_INFO
,
1233 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1234 "Release-Job Restart-Job Purge-Jobs "
1235 "Set-Job-Attributes Create-Job-Subscription "
1236 "Renew-Subscription Cancel-Subscription "
1237 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1238 "Suspend-Current-Job Resume-Job "
1239 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1240 "CUPS-Authenticate-Job CUPS-Get-Document>");
1241 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1243 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1244 po
->order_type
= CUPSD_AUTH_ALLOW
;
1245 po
->level
= CUPSD_AUTH_USER
;
1247 cupsdAddName(po
, "@OWNER");
1248 cupsdAddName(po
, "@SYSTEM");
1249 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1251 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1252 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1253 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1254 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1255 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1256 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1257 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1258 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1259 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1260 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1261 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1262 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1263 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1264 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1265 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1266 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1267 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1268 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1269 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1270 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1272 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1274 cupsdLogMessage(CUPSD_LOG_INFO
,
1275 "<Limit Pause-Printer Resume-Printer "
1276 "Set-Printer-Attributes Enable-Printer "
1277 "Disable-Printer Pause-Printer-After-Current-Job "
1278 "Hold-New-Jobs Release-Held-New-Jobs "
1279 "Deactivate-Printer Activate-Printer Restart-Printer "
1280 "Shutdown-Printer Startup-Printer Promote-Job "
1281 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1282 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1283 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1284 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1285 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1287 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1288 po
->order_type
= CUPSD_AUTH_ALLOW
;
1289 po
->type
= CUPSD_AUTH_DEFAULT
;
1290 po
->level
= CUPSD_AUTH_USER
;
1292 cupsdAddName(po
, "@SYSTEM");
1293 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1295 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1296 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1297 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1298 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1299 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1300 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1301 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1302 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1303 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1304 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1305 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1306 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1307 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1308 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1309 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1310 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1311 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1312 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1313 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1314 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1315 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1316 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1318 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1320 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1321 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1323 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1324 po
->order_type
= CUPSD_AUTH_ALLOW
;
1326 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1327 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1331 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1332 cupsArrayCount(Policies
));
1333 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1335 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1336 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1337 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1340 * If we are doing a full reload or the server root has changed, flush
1341 * the jobs, printers, etc. and start from scratch...
1344 if (NeedReload
== RELOAD_ALL
||
1345 old_remote_port
!= RemotePort
||
1346 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1347 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1349 mime_type_t
*type
; /* Current type */
1350 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1351 /* MIME type name */
1354 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1357 * Free all memory...
1360 cupsdDeleteAllSubscriptions();
1362 cupsdDeleteAllPrinters();
1364 DefaultPrinter
= NULL
;
1366 if (MimeDatabase
!= NULL
)
1367 mimeDelete(MimeDatabase
);
1371 for (i
= 0; i
< NumMimeTypes
; i
++)
1372 _cupsStrFree(MimeTypes
[i
]);
1378 * Read the MIME type and conversion database...
1381 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1382 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1384 MimeDatabase
= mimeNew();
1385 mimeSetErrorCallback(MimeDatabase
, mime_error_cb
, NULL
);
1387 MimeDatabase
= mimeLoadTypes(MimeDatabase
, mimedir
);
1388 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1389 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1390 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1394 cupsdLogMessage(CUPSD_LOG_EMERG
,
1395 "Unable to load MIME database from \"%s\" or \"%s\".",
1396 mimedir
, ServerRoot
);
1397 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1401 cupsdLogMessage(CUPSD_LOG_INFO
,
1402 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1403 "%d filters...", mimedir
, ServerRoot
,
1404 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1407 * Create a list of MIME types for the document-format-supported
1411 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1412 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1415 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1417 cupsdLogMessage(CUPSD_LOG_ERROR
,
1418 "Unable to allocate memory for %d MIME types.",
1424 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1426 i
++, type
= mimeNextType(MimeDatabase
))
1428 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1430 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1433 if (i
< NumMimeTypes
)
1434 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1437 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1439 mime_filter_t
*filter
; /* Current filter */
1442 for (type
= mimeFirstType(MimeDatabase
);
1444 type
= mimeNextType(MimeDatabase
))
1445 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1446 type
->super
, type
->type
);
1448 for (filter
= mimeFirstFilter(MimeDatabase
);
1450 filter
= mimeNextFilter(MimeDatabase
))
1451 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1452 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1453 filter
->src
->super
, filter
->src
->type
,
1454 filter
->dst
->super
, filter
->dst
->type
,
1455 filter
->cost
, filter
->filter
);
1462 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1463 cupsdLoadBanners(temp
);
1466 * Load printers and classes...
1469 cupsdLoadAllPrinters();
1470 cupsdLoadAllClasses();
1471 cupsdLoadRemoteCache();
1473 cupsdCreateCommonData();
1476 * Update the printcap file as needed...
1479 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1480 cupsdWritePrintcap();
1483 * Load queued jobs...
1489 * Load subscriptions...
1492 cupsdLoadAllSubscriptions();
1494 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1499 * Not a full reload, so recreate the common printer attributes...
1502 cupsdCreateCommonData();
1505 * Update all printers as needed...
1508 cupsdUpdatePrinters();
1509 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1511 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1515 * Reset the reload state...
1518 NeedReload
= RELOAD_NONE
;
1520 cupsdClearString(&old_serverroot
);
1521 cupsdClearString(&old_requestroot
);
1528 * 'get_address()' - Get an address + port number from a line.
1531 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1532 get_address(const char *value
, /* I - Value string */
1533 int defport
) /* I - Default port */
1535 char buffer
[1024], /* Hostname + port number buffer */
1536 defpname
[255], /* Default port name */
1537 *hostname
, /* Hostname or IP */
1538 *portname
; /* Port number or name */
1539 http_addrlist_t
*addrlist
; /* Address list */
1543 * Check for an empty value...
1548 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1553 * Grab a hostname and port number; if there is no colon and the port name
1554 * is only digits, then we have a port number by itself...
1557 strlcpy(buffer
, value
, sizeof(buffer
));
1559 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1566 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1571 * Use the default port...
1574 sprintf(defpname
, "%d", defport
);
1575 portname
= defpname
;
1581 * The buffer contains just a port number...
1589 if (hostname
&& !strcmp(hostname
, "*"))
1593 * Now lookup the address using httpAddrGetList()...
1596 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1597 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1598 hostname
? hostname
: "(nil)");
1605 * 'get_addr_and_mask()' - Get an IP address and netmask.
1608 static int /* O - 1 on success, 0 on failure */
1609 get_addr_and_mask(const char *value
, /* I - String from config file */
1610 unsigned *ip
, /* O - Address value */
1611 unsigned *mask
) /* O - Mask value */
1613 int i
, j
, /* Looping vars */
1614 family
, /* Address family */
1615 ipcount
; /* Count of fields in address */
1616 unsigned ipval
; /* Value */
1617 const char *maskval
, /* Pointer to start of mask value */
1618 *ptr
, /* Pointer into value */
1623 * Get the address...
1626 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1627 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1629 if ((maskval
= strchr(value
, '/')) != NULL
)
1632 maskval
= value
+ strlen(value
);
1636 * Check for an IPv6 address...
1642 * Parse hexadecimal IPv6 address...
1647 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1651 else if (!strncmp(ptr
, "::", 2))
1653 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1655 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1660 else if (isxdigit(*ptr
& 255))
1662 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1670 ip
[i
/ 2] |= ipval
<< 16;
1684 if (*ptr
&& *ptr
!= '/')
1688 #endif /* AF_INET6 */
1691 * Parse dotted-decimal IPv4 address...
1694 unsigned val
[4]; /* IPv4 address values */
1698 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1701 * Range check the IP numbers...
1704 for (i
= 0; i
< ipcount
; i
++)
1709 * Make sure the trailing values are zeroed, as some C libraries like
1710 * glibc apparently like to fill the unused arguments with garbage...
1713 for (i
= ipcount
; i
< 4; i
++)
1717 * Merge everything into a 32-bit IPv4 address in ip[3]...
1720 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1723 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1729 * Get the netmask value(s)...
1732 memset(mask
, 0, sizeof(unsigned) * 4);
1734 if (strchr(maskval
, '.'))
1737 * Get dotted-decimal mask...
1740 if (family
!= AF_INET
)
1743 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1746 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1747 mask
[0] = mask
[1] = mask
[2] = 0;
1752 * Get address/bits format...
1758 if (family
== AF_INET6
)
1766 mask
[0] = 0xffffffff;
1768 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1771 mask
[1] = 0xffffffff;
1775 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1778 mask
[2] = 0xffffffff;
1782 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1785 mask
[3] = 0xffffffff;
1789 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1792 #endif /* AF_INET6 */
1797 mask
[0] = 0xffffffff;
1798 mask
[1] = 0xffffffff;
1799 mask
[2] = 0xffffffff;
1802 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1804 mask
[3] = 0xffffffff;
1809 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1810 "get_addr_and_mask(value=\"%s\", "
1811 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1812 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1816 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1819 if ((ip
[0] & ~mask
[0]) != 0 ||
1820 (ip
[1] & ~mask
[1]) != 0 ||
1821 (ip
[2] & ~mask
[2]) != 0 ||
1822 (ip
[3] & ~mask
[3]) != 0)
1830 * 'mime_error_cb()' - Log a MIME error.
1834 mime_error_cb(void *ctx
, /* I - Context pointer (unused) */
1835 const char *message
) /* I - Message */
1837 cupsdLogMessage(CUPSD_LOG_ERROR
, "%s", message
);
1842 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1845 static int /* O - 1 on success, 0 on failure */
1846 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1847 char *line
, /* I - Line from file */
1848 char *value
, /* I - Start of value data */
1849 int linenum
) /* I - Current line number */
1851 char *valptr
; /* Pointer into value */
1852 unsigned ip
[4], /* IP address components */
1853 mask
[4]; /* IP netmask components */
1856 if (!strcasecmp(line
, "Encryption"))
1859 * "Encryption xxx" - set required encryption level...
1862 if (!strcasecmp(value
, "never"))
1863 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1864 else if (!strcasecmp(value
, "always"))
1866 cupsdLogMessage(CUPSD_LOG_ERROR
,
1867 "Encryption value \"%s\" on line %d is invalid in this "
1868 "context. Using \"required\" instead.", value
, linenum
);
1870 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1872 else if (!strcasecmp(value
, "required"))
1873 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1874 else if (!strcasecmp(value
, "ifrequested"))
1875 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1878 cupsdLogMessage(CUPSD_LOG_ERROR
,
1879 "Unknown Encryption value %s on line %d.", value
, linenum
);
1883 else if (!strcasecmp(line
, "Order"))
1886 * "Order Deny,Allow" or "Order Allow,Deny"...
1889 if (!strncasecmp(value
, "deny", 4))
1890 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1891 else if (!strncasecmp(value
, "allow", 5))
1892 loc
->order_type
= CUPSD_AUTH_DENY
;
1895 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1900 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1903 * Allow [From] host/ip...
1904 * Deny [From] host/ip...
1909 if (!strncasecmp(value
, "from", 4))
1912 * Strip leading "from"...
1917 while (isspace(*value
& 255))
1925 * Find the end of the value...
1928 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1930 while (isspace(*valptr
& 255))
1934 * Figure out what form the allow/deny address takes:
1945 * nnn.nnn.nnn.nnn/mm
1946 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1949 if (!strcasecmp(value
, "all"))
1955 if (!strcasecmp(line
, "Allow"))
1956 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1958 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1960 else if (!strcasecmp(value
, "none"))
1966 if (!strcasecmp(line
, "Allow"))
1967 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1969 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1972 else if (value
[0] == '*' || value
[0] == '.' ||
1973 (!isdigit(value
[0] & 255) && value
[0] != '['))
1975 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1976 #endif /* AF_INET6 */
1979 * Host or domain name...
1982 if (value
[0] == '*')
1985 if (!strcasecmp(line
, "Allow"))
1986 cupsdAddNameMask(&(loc
->allow
), value
);
1988 cupsdAddNameMask(&(loc
->deny
), value
);
1993 * One of many IP address forms...
1996 if (!get_addr_and_mask(value
, ip
, mask
))
1998 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2003 if (!strcasecmp(line
, "Allow"))
2004 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
2006 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
2010 * Advance to next value...
2016 else if (!strcasecmp(line
, "AuthType"))
2019 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2022 if (!strcasecmp(value
, "none"))
2024 loc
->type
= CUPSD_AUTH_NONE
;
2025 loc
->level
= CUPSD_AUTH_ANON
;
2027 else if (!strcasecmp(value
, "basic"))
2029 loc
->type
= CUPSD_AUTH_BASIC
;
2031 if (loc
->level
== CUPSD_AUTH_ANON
)
2032 loc
->level
= CUPSD_AUTH_USER
;
2034 else if (!strcasecmp(value
, "digest"))
2036 loc
->type
= CUPSD_AUTH_DIGEST
;
2038 if (loc
->level
== CUPSD_AUTH_ANON
)
2039 loc
->level
= CUPSD_AUTH_USER
;
2041 else if (!strcasecmp(value
, "basicdigest"))
2043 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2045 if (loc
->level
== CUPSD_AUTH_ANON
)
2046 loc
->level
= CUPSD_AUTH_USER
;
2048 else if (!strcasecmp(value
, "default"))
2050 loc
->type
= CUPSD_AUTH_DEFAULT
;
2052 if (loc
->level
== CUPSD_AUTH_ANON
)
2053 loc
->level
= CUPSD_AUTH_USER
;
2056 else if (!strcasecmp(value
, "negotiate"))
2058 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2060 if (loc
->level
== CUPSD_AUTH_ANON
)
2061 loc
->level
= CUPSD_AUTH_USER
;
2063 #endif /* HAVE_GSSAPI */
2066 cupsdLogMessage(CUPSD_LOG_WARN
,
2067 "Unknown authorization type %s on line %d.",
2072 else if (!strcasecmp(line
, "AuthClass"))
2075 * AuthClass anonymous, user, system, group
2078 if (!strcasecmp(value
, "anonymous"))
2080 loc
->type
= CUPSD_AUTH_NONE
;
2081 loc
->level
= CUPSD_AUTH_ANON
;
2083 cupsdLogMessage(CUPSD_LOG_WARN
,
2084 "\"AuthClass %s\" is deprecated; consider removing "
2088 else if (!strcasecmp(value
, "user"))
2090 loc
->level
= CUPSD_AUTH_USER
;
2092 cupsdLogMessage(CUPSD_LOG_WARN
,
2093 "\"AuthClass %s\" is deprecated; consider using "
2094 "\"Require valid-user\" on line %d.",
2097 else if (!strcasecmp(value
, "group"))
2099 loc
->level
= CUPSD_AUTH_GROUP
;
2101 cupsdLogMessage(CUPSD_LOG_WARN
,
2102 "\"AuthClass %s\" is deprecated; consider using "
2103 "\"Require user @groupname\" on line %d.",
2106 else if (!strcasecmp(value
, "system"))
2108 loc
->level
= CUPSD_AUTH_GROUP
;
2110 cupsdAddName(loc
, "@SYSTEM");
2112 cupsdLogMessage(CUPSD_LOG_WARN
,
2113 "\"AuthClass %s\" is deprecated; consider using "
2114 "\"Require user @SYSTEM\" on line %d.",
2119 cupsdLogMessage(CUPSD_LOG_WARN
,
2120 "Unknown authorization class %s on line %d.",
2125 else if (!strcasecmp(line
, "AuthGroupName"))
2127 cupsdAddName(loc
, value
);
2129 cupsdLogMessage(CUPSD_LOG_WARN
,
2130 "\"AuthGroupName %s\" directive is deprecated; consider "
2131 "using \"Require user @%s\" on line %d.",
2132 value
, value
, linenum
);
2134 else if (!strcasecmp(line
, "Require"))
2137 * Apache synonym for AuthClass and AuthGroupName...
2141 * Require valid-user
2142 * Require group names
2143 * Require user names
2146 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2151 if (!strcasecmp(value
, "valid-user") ||
2152 !strcasecmp(value
, "user"))
2153 loc
->level
= CUPSD_AUTH_USER
;
2154 else if (!strcasecmp(value
, "group"))
2155 loc
->level
= CUPSD_AUTH_GROUP
;
2158 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2164 * Get the list of names from the line...
2167 for (value
= valptr
; *value
;)
2169 while (isspace(*value
& 255))
2172 #ifdef HAVE_AUTHORIZATION_H
2173 if (!strncmp(value
, "@AUTHKEY(", 9))
2176 * Grab "@AUTHKEY(name)" value...
2179 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2185 #endif /* HAVE_AUTHORIZATION_H */
2186 if (*value
== '\"' || *value
== '\'')
2189 * Grab quoted name...
2192 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2199 * Grab literal name.
2202 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2208 cupsdAddName(loc
, value
);
2210 for (value
= valptr
; isspace(*value
& 255); value
++);
2213 else if (!strcasecmp(line
, "Satisfy"))
2215 if (!strcasecmp(value
, "all"))
2216 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2217 else if (!strcasecmp(value
, "any"))
2218 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2221 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2234 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2237 static int /* O - FatalErrors bits */
2238 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2240 int fatal
; /* FatalErrors bits */
2241 char value
[1024], /* Value string */
2242 *valstart
, /* Pointer into value */
2243 *valend
; /* End of value */
2247 * Empty FatalErrors line yields NULL pointer...
2251 return (CUPSD_FATAL_NONE
);
2254 * Loop through the value string,...
2257 strlcpy(value
, s
, sizeof(value
));
2259 fatal
= CUPSD_FATAL_NONE
;
2261 for (valstart
= value
; *valstart
;)
2264 * Get the current space/comma-delimited kind name...
2267 for (valend
= valstart
; *valend
; valend
++)
2268 if (isspace(*valend
& 255) || *valend
== ',')
2275 * Add the error to the bitmask...
2278 if (!strcasecmp(valstart
, "all"))
2279 fatal
= CUPSD_FATAL_ALL
;
2280 else if (!strcasecmp(valstart
, "browse"))
2281 fatal
|= CUPSD_FATAL_BROWSE
;
2282 else if (!strcasecmp(valstart
, "-browse"))
2283 fatal
&= ~CUPSD_FATAL_BROWSE
;
2284 else if (!strcasecmp(valstart
, "config"))
2285 fatal
|= CUPSD_FATAL_CONFIG
;
2286 else if (!strcasecmp(valstart
, "-config"))
2287 fatal
&= ~CUPSD_FATAL_CONFIG
;
2288 else if (!strcasecmp(valstart
, "listen"))
2289 fatal
|= CUPSD_FATAL_LISTEN
;
2290 else if (!strcasecmp(valstart
, "-listen"))
2291 fatal
&= ~CUPSD_FATAL_LISTEN
;
2292 else if (!strcasecmp(valstart
, "log"))
2293 fatal
|= CUPSD_FATAL_LOG
;
2294 else if (!strcasecmp(valstart
, "-log"))
2295 fatal
&= ~CUPSD_FATAL_LOG
;
2296 else if (!strcasecmp(valstart
, "permissions"))
2297 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2298 else if (!strcasecmp(valstart
, "-permissions"))
2299 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2300 else if (strcasecmp(valstart
, "none"))
2301 cupsdLogMessage(CUPSD_LOG_ERROR
,
2302 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2304 for (valstart
= valend
; *valstart
; valstart
++)
2305 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2314 * 'parse_groups()' - Parse system group names in a string.
2317 static int /* O - 1 on success, 0 on failure */
2318 parse_groups(const char *s
) /* I - Space-delimited groups */
2320 int status
; /* Return status */
2321 char value
[1024], /* Value string */
2322 *valstart
, /* Pointer into value */
2323 *valend
, /* End of value */
2324 quote
; /* Quote character */
2325 struct group
*group
; /* Group */
2329 * Make a copy of the string and parse out the groups...
2332 strlcpy(value
, s
, sizeof(value
));
2337 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2339 if (*valstart
== '\'' || *valstart
== '\"')
2342 * Scan quoted name...
2345 quote
= *valstart
++;
2347 for (valend
= valstart
; *valend
; valend
++)
2348 if (*valend
== quote
)
2354 * Scan space or comma-delimited name...
2357 for (valend
= valstart
; *valend
; valend
++)
2358 if (isspace(*valend
) || *valend
== ',')
2365 group
= getgrnam(valstart
);
2368 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2369 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2380 while (*valstart
== ',' || isspace(*valstart
))
2389 * 'parse_protocols()' - Parse browse protocols in a string.
2392 static int /* O - Browse protocol bits */
2393 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2395 int protocols
; /* Browse protocol bits */
2396 char value
[1024], /* Value string */
2397 *valstart
, /* Pointer into value */
2398 *valend
; /* End of value */
2402 * Empty protocol line yields NULL pointer...
2409 * Loop through the value string,...
2412 strlcpy(value
, s
, sizeof(value
));
2416 for (valstart
= value
; *valstart
;)
2419 * Get the current space/comma-delimited protocol name...
2422 for (valend
= valstart
; *valend
; valend
++)
2423 if (isspace(*valend
& 255) || *valend
== ',')
2430 * Add the protocol to the bitmask...
2433 if (!strcasecmp(valstart
, "cups"))
2434 protocols
|= BROWSE_CUPS
;
2435 else if (!strcasecmp(valstart
, "slp"))
2436 protocols
|= BROWSE_SLP
;
2437 else if (!strcasecmp(valstart
, "ldap"))
2438 protocols
|= BROWSE_LDAP
;
2439 else if (!strcasecmp(valstart
, "dnssd") ||
2440 !strcasecmp(valstart
, "dns-sd") ||
2441 !strcasecmp(valstart
, "bonjour"))
2442 protocols
|= BROWSE_DNSSD
;
2443 else if (!strcasecmp(valstart
, "lpd"))
2444 protocols
|= BROWSE_LPD
;
2445 else if (!strcasecmp(valstart
, "smb"))
2446 protocols
|= BROWSE_SMB
;
2447 else if (!strcasecmp(valstart
, "all"))
2448 protocols
|= BROWSE_ALL
;
2449 else if (strcasecmp(valstart
, "none"))
2450 cupsdLogMessage(CUPSD_LOG_ERROR
,
2451 "Unknown browse protocol \"%s\" ignored.", valstart
);
2453 for (valstart
= valend
; *valstart
; valstart
++)
2454 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2463 * 'read_configuration()' - Read a configuration file.
2466 static int /* O - 1 on success, 0 on failure */
2467 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2469 int i
; /* Looping var */
2470 int linenum
; /* Current line number */
2471 char line
[HTTP_MAX_BUFFER
],
2472 /* Line from file */
2473 temp
[HTTP_MAX_BUFFER
],
2474 /* Temporary buffer for value */
2475 *ptr
, /* Pointer into line/temp */
2476 *value
, /* Pointer to value */
2477 *valueptr
; /* Pointer into value */
2478 int valuelen
; /* Length of value */
2479 cupsd_var_t
const *var
; /* Current variable */
2480 http_addrlist_t
*addrlist
, /* Address list */
2481 *addr
; /* Current address */
2482 unsigned ip
[4], /* Address value */
2483 mask
[4]; /* Netmask value */
2484 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2485 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2486 cupsd_location_t
*location
; /* Browse location */
2487 cups_file_t
*incfile
; /* Include file */
2488 char incname
[1024]; /* Include filename */
2489 struct group
*group
; /* Group */
2493 * Loop through each line in the file...
2498 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2501 * Decode the directive...
2504 if (!strcasecmp(line
, "Include") && value
)
2510 if (value
[0] == '/')
2511 strlcpy(incname
, value
, sizeof(incname
));
2513 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2515 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2516 cupsdLogMessage(CUPSD_LOG_ERROR
,
2517 "Unable to include config file \"%s\" - %s",
2518 incname
, strerror(errno
));
2521 read_configuration(incfile
);
2522 cupsFileClose(incfile
);
2525 else if (!strcasecmp(line
, "<Location") && value
)
2531 linenum
= read_location(fp
, value
, linenum
);
2535 else if (!strcasecmp(line
, "<Policy") && value
)
2541 linenum
= read_policy(fp
, value
, linenum
);
2545 else if (!strcasecmp(line
, "FatalErrors"))
2546 FatalErrors
= parse_fatal_errors(value
);
2547 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2549 JobRetryInterval
= atoi(value
);
2550 cupsdLogMessage(CUPSD_LOG_WARN
,
2551 "FaxRetryInterval is deprecated; use "
2552 "JobRetryInterval on line %d.", linenum
);
2554 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2556 JobRetryLimit
= atoi(value
);
2557 cupsdLogMessage(CUPSD_LOG_WARN
,
2558 "FaxRetryLimit is deprecated; use "
2559 "JobRetryLimit on line %d.", linenum
);
2561 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2563 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2564 #endif /* HAVE_SSL */
2568 * Add listening address(es) to the list...
2571 cupsd_listener_t
*lis
; /* New listeners array */
2575 * Get the address list...
2578 addrlist
= get_address(value
, IPP_PORT
);
2582 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2588 * Add each address...
2591 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2594 * See if this address is already present...
2597 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2599 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2600 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2601 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2606 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2607 cupsdLogMessage(CUPSD_LOG_WARN
,
2608 "Duplicate listen address \"%s\" ignored.", temp
);
2613 * Allocate another listener...
2617 Listeners
= cupsArrayNew(NULL
, NULL
);
2621 cupsdLogMessage(CUPSD_LOG_ERROR
,
2622 "Unable to allocate %s at line %d - %s.",
2623 line
, linenum
, strerror(errno
));
2627 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2629 cupsdLogMessage(CUPSD_LOG_ERROR
,
2630 "Unable to allocate %s at line %d - %s.",
2631 line
, linenum
, strerror(errno
));
2635 cupsArrayAdd(Listeners
, lis
);
2638 * Copy the current address and log it...
2641 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2645 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2646 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2647 #endif /* HAVE_SSL */
2649 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2652 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2653 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2655 #endif /* AF_LOCAL */
2656 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
2657 _httpAddrPort(&(lis
->address
)),
2658 _httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
2660 if (!httpAddrLocalhost(&(lis
->address
)))
2661 RemotePort
= _httpAddrPort(&(lis
->address
));
2668 httpAddrFreeList(addrlist
);
2670 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2673 * Add a browse address to the list...
2676 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2679 if (NumBrowsers
== 0)
2680 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2682 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2686 cupsdLogMessage(CUPSD_LOG_ERROR
,
2687 "Unable to allocate BrowseAddress at line %d - %s.",
2688 linenum
, strerror(errno
));
2693 dira
+= NumBrowsers
;
2695 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2697 if (!strcasecmp(value
, "@LOCAL"))
2700 * Send browse data to all local interfaces...
2703 strcpy(dira
->iface
, "*");
2706 else if (!strncasecmp(value
, "@IF(", 4))
2709 * Send browse data to the named interface...
2712 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2714 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2720 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2723 * Only IPv4 addresses are supported...
2726 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2727 if (_httpAddrFamily(&(addr
->addr
)) == AF_INET
)
2732 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2733 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2735 cupsdLogMessage(CUPSD_LOG_INFO
,
2736 "Sending browsing info to %s:%d (IPv4)",
2737 temp
, _httpAddrPort(&(dira
->to
)));
2742 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2745 httpAddrFreeList(addrlist
);
2748 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2751 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2754 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2757 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2758 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2759 cupsdAddLocation(location
);
2761 if (location
== NULL
)
2762 cupsdLogMessage(CUPSD_LOG_ERROR
,
2763 "Unable to initialize browse access control list.");
2764 else if (!strncasecmp(value
, "deny", 4))
2765 location
->order_type
= CUPSD_AUTH_ALLOW
;
2766 else if (!strncasecmp(value
, "allow", 5))
2767 location
->order_type
= CUPSD_AUTH_DENY
;
2769 cupsdLogMessage(CUPSD_LOG_ERROR
,
2770 "Unknown BrowseOrder value %s on line %d.",
2773 else if (!strcasecmp(line
, "BrowseProtocols") ||
2774 !strcasecmp(line
, "BrowseLocalProtocols") ||
2775 !strcasecmp(line
, "BrowseRemoteProtocols"))
2778 * "BrowseProtocols name [... name]"
2779 * "BrowseLocalProtocols name [... name]"
2780 * "BrowseRemoteProtocols name [... name]"
2783 int protocols
= parse_protocols(value
);
2787 cupsdLogMessage(CUPSD_LOG_ERROR
,
2788 "Unknown browse protocol \"%s\" on line %d.",
2793 if (strcasecmp(line
, "BrowseLocalProtocols"))
2794 BrowseRemoteProtocols
= protocols
;
2795 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2796 BrowseLocalProtocols
= protocols
;
2798 else if ((!strcasecmp(line
, "BrowseAllow") ||
2799 !strcasecmp(line
, "BrowseDeny")) && value
)
2802 * BrowseAllow [From] host/ip...
2803 * BrowseDeny [From] host/ip...
2806 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2807 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2808 cupsdAddLocation(location
);
2811 if (location
== NULL
)
2812 cupsdLogMessage(CUPSD_LOG_ERROR
,
2813 "Unable to initialize browse access control list.");
2816 if (!strncasecmp(value
, "from", 4))
2819 * Skip leading "from"...
2828 * Skip leading whitespace...
2831 while (isspace(*value
& 255))
2838 * Find the end of the value...
2841 for (valueptr
= value
;
2842 *valueptr
&& !isspace(*valueptr
& 255);
2845 while (isspace(*valueptr
& 255))
2849 * Figure out what form the allow/deny address takes:
2860 * nnn.nnn.nnn.nnn/mm
2861 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2864 if (!strcasecmp(value
, "all"))
2870 if (!strcasecmp(line
, "BrowseAllow"))
2871 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2873 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2875 else if (!strcasecmp(value
, "none"))
2881 if (!strcasecmp(line
, "BrowseAllow"))
2882 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2884 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2887 else if (value
[0] == '*' || value
[0] == '.' ||
2888 (!isdigit(value
[0] & 255) && value
[0] != '['))
2890 else if (value
[0] == '*' || value
[0] == '.' ||
2891 !isdigit(value
[0] & 255))
2892 #endif /* AF_INET6 */
2895 * Host or domain name...
2898 if (!strcasecmp(line
, "BrowseAllow"))
2899 cupsdAddNameMask(&(location
->allow
), value
);
2901 cupsdAddNameMask(&(location
->deny
), value
);
2906 * One of many IP address forms...
2909 if (!get_addr_and_mask(value
, ip
, mask
))
2911 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2916 if (!strcasecmp(line
, "BrowseAllow"))
2917 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2919 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2923 * Advance to next value...
2930 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2933 * BrowseRelay [from] source [to] destination
2937 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2939 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2943 cupsdLogMessage(CUPSD_LOG_ERROR
,
2944 "Unable to allocate BrowseRelay at line %d - %s.",
2945 linenum
, strerror(errno
));
2952 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2954 if (!strncasecmp(value
, "from ", 5))
2957 * Skip leading "from"...
2963 * Skip leading whitespace...
2966 while (isspace(*value
))
2971 * Find the end of the from value...
2974 for (valueptr
= value
;
2975 *valueptr
&& !isspace(*valueptr
& 255);
2978 while (isspace(*valueptr
& 255))
2982 * Figure out what form the from address takes:
2991 * nnn.nnn.nnn.nnn/mm
2992 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2996 if (value
[0] == '*' || value
[0] == '.' ||
2997 (!isdigit(value
[0] & 255) && value
[0] != '['))
2999 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
3000 #endif /* AF_INET6 */
3003 * Host or domain name...
3006 if (!cupsdAddNameMask(&(relay
->from
), value
))
3008 cupsdLogMessage(CUPSD_LOG_ERROR
,
3009 "Unable to allocate BrowseRelay name at line %d - %s.",
3010 linenum
, strerror(errno
));
3017 * One of many IP address forms...
3020 if (!get_addr_and_mask(value
, ip
, mask
))
3022 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
3027 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
3029 cupsdLogMessage(CUPSD_LOG_ERROR
,
3030 "Unable to allocate BrowseRelay IP at line %d - %s.",
3031 linenum
, strerror(errno
));
3037 * Get "to" address and port...
3040 if (!strncasecmp(valueptr
, "to ", 3))
3043 * Strip leading "to"...
3048 while (isspace(*valueptr
))
3052 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3055 * Only IPv4 addresses are supported...
3058 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3059 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3064 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3066 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3068 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3069 value
, temp
, _httpAddrPort(&(relay
->to
)));
3075 cupsArrayDelete(relay
->from
);
3078 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3082 httpAddrFreeList(addrlist
);
3086 cupsArrayDelete(relay
->from
);
3089 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3093 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3096 * BrowsePoll address[:port]
3099 char *portname
; /* Port name */
3100 int portnum
; /* Port number */
3101 struct servent
*service
; /* Service */
3105 * Extract the port name from the address...
3108 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3112 if (isdigit(*portname
& 255))
3113 portnum
= atoi(portname
);
3114 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3115 portnum
= ntohs(service
->s_port
);
3118 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed.",
3124 portnum
= ippPort();
3127 * Add the poll entry...
3131 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3133 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3137 cupsdLogMessage(CUPSD_LOG_ERROR
,
3138 "Unable to allocate BrowsePoll at line %d - %s.",
3139 linenum
, strerror(errno
));
3147 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3149 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3150 pollp
->port
= portnum
;
3152 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3155 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3158 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3161 if (!strcasecmp(value
, "none"))
3162 DefaultAuthType
= CUPSD_AUTH_NONE
;
3163 else if (!strcasecmp(value
, "basic"))
3164 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3165 else if (!strcasecmp(value
, "digest"))
3166 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3167 else if (!strcasecmp(value
, "basicdigest"))
3168 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3170 else if (!strcasecmp(value
, "negotiate"))
3171 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3172 #endif /* HAVE_GSSAPI */
3175 cupsdLogMessage(CUPSD_LOG_WARN
,
3176 "Unknown default authorization type %s on line %d.",
3178 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3183 else if (!strcasecmp(line
, "DefaultEncryption"))
3186 * DefaultEncryption {Never,IfRequested,Required}
3189 if (!value
|| !strcasecmp(value
, "never"))
3190 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3191 else if (!strcasecmp(value
, "required"))
3192 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3193 else if (!strcasecmp(value
, "ifrequested"))
3194 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3197 cupsdLogMessage(CUPSD_LOG_WARN
,
3198 "Unknown default encryption %s on line %d.",
3200 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3204 #endif /* HAVE_SSL */
3205 else if (!strcasecmp(line
, "User") && value
)
3208 * User ID to run as...
3211 if (isdigit(value
[0] & 255))
3213 int uid
= atoi(value
);
3216 cupsdLogMessage(CUPSD_LOG_ERROR
,
3217 "Will not use User 0 as specified on line %d "
3218 "for security reasons. You must use a non-"
3219 "privileged account instead.",
3226 struct passwd
*p
; /* Password information */
3229 p
= getpwnam(value
);
3234 cupsdLogMessage(CUPSD_LOG_ERROR
,
3235 "Will not use User %s (UID=0) as specified on line "
3236 "%d for security reasons. You must use a non-"
3237 "privileged account instead.",
3243 cupsdLogMessage(CUPSD_LOG_ERROR
,
3244 "Unknown User \"%s\" on line %d, ignoring.",
3248 else if (!strcasecmp(line
, "Group") && value
)
3251 * Group ID to run as...
3254 if (isdigit(value
[0]))
3255 Group
= atoi(value
);
3259 group
= getgrnam(value
);
3262 Group
= group
->gr_gid
;
3264 cupsdLogMessage(CUPSD_LOG_ERROR
,
3265 "Unknown Group \"%s\" on line %d, ignoring.",
3269 else if (!strcasecmp(line
, "SystemGroup") && value
)
3272 * SystemGroup (admin) group(s)...
3275 if (!parse_groups(value
))
3276 cupsdLogMessage(CUPSD_LOG_ERROR
,
3277 "Unknown SystemGroup \"%s\" on line %d, ignoring.",
3280 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3283 * Do hostname lookups?
3286 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3287 !strcasecmp(value
, "false"))
3288 HostNameLookups
= 0;
3289 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3290 !strcasecmp(value
, "true"))
3291 HostNameLookups
= 1;
3292 else if (!strcasecmp(value
, "double"))
3293 HostNameLookups
= 2;
3295 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3298 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3301 * Amount of logging to do to access log...
3304 if (!strcasecmp(value
, "all"))
3305 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3306 else if (!strcasecmp(value
, "actions"))
3307 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3308 else if (!strcasecmp(value
, "config"))
3309 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3311 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3314 else if (!strcasecmp(line
, "LogLevel") && value
)
3317 * Amount of logging to do to error log...
3320 if (!strcasecmp(value
, "debug2"))
3321 LogLevel
= CUPSD_LOG_DEBUG2
;
3322 else if (!strcasecmp(value
, "debug"))
3323 LogLevel
= CUPSD_LOG_DEBUG
;
3324 else if (!strcasecmp(value
, "info"))
3325 LogLevel
= CUPSD_LOG_INFO
;
3326 else if (!strcasecmp(value
, "notice"))
3327 LogLevel
= CUPSD_LOG_NOTICE
;
3328 else if (!strcasecmp(value
, "warn"))
3329 LogLevel
= CUPSD_LOG_WARN
;
3330 else if (!strcasecmp(value
, "error"))
3331 LogLevel
= CUPSD_LOG_ERROR
;
3332 else if (!strcasecmp(value
, "crit"))
3333 LogLevel
= CUPSD_LOG_CRIT
;
3334 else if (!strcasecmp(value
, "alert"))
3335 LogLevel
= CUPSD_LOG_ALERT
;
3336 else if (!strcasecmp(value
, "emerg"))
3337 LogLevel
= CUPSD_LOG_EMERG
;
3338 else if (!strcasecmp(value
, "none"))
3339 LogLevel
= CUPSD_LOG_NONE
;
3341 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3344 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3347 * Amount of logging to do to error log...
3350 if (!strcasecmp(value
, "standard"))
3351 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3352 else if (!strcasecmp(value
, "usecs"))
3353 LogTimeFormat
= CUPSD_TIME_USECS
;
3355 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3358 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3361 * Format of printcap file?
3364 if (!strcasecmp(value
, "bsd"))
3365 PrintcapFormat
= PRINTCAP_BSD
;
3366 else if (!strcasecmp(value
, "plist"))
3367 PrintcapFormat
= PRINTCAP_PLIST
;
3368 else if (!strcasecmp(value
, "solaris"))
3369 PrintcapFormat
= PRINTCAP_SOLARIS
;
3371 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3374 else if (!strcasecmp(line
, "ServerTokens") && value
)
3377 * Set the string used for the Server header...
3380 struct utsname plat
; /* Platform info */
3385 if (!strcasecmp(value
, "ProductOnly"))
3386 cupsdSetString(&ServerHeader
, "CUPS");
3387 else if (!strcasecmp(value
, "Major"))
3388 cupsdSetString(&ServerHeader
, "CUPS/1");
3389 else if (!strcasecmp(value
, "Minor"))
3390 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3391 else if (!strcasecmp(value
, "Minimal"))
3392 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3393 else if (!strcasecmp(value
, "OS"))
3394 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3395 else if (!strcasecmp(value
, "Full"))
3396 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3398 else if (!strcasecmp(value
, "None"))
3399 cupsdClearString(&ServerHeader
);
3401 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3404 else if (!strcasecmp(line
, "PassEnv") && value
)
3407 * PassEnv variable [... variable]
3412 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3413 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3416 if (value
[valuelen
])
3418 value
[valuelen
] = '\0';
3422 cupsdSetEnv(value
, NULL
);
3424 for (value
+= valuelen
; *value
; value
++)
3425 if (!isspace(*value
) || *value
!= ',')
3429 else if (!strcasecmp(line
, "ServerAlias") && value
)
3432 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3434 cupsdAddAlias(ServerAlias
, value
);
3436 else if (!strcasecmp(line
, "SetEnv") && value
)
3439 * SetEnv variable value
3442 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3450 while (isspace(*valueptr
& 255))
3453 cupsdSetEnv(value
, valueptr
);
3456 cupsdLogMessage(CUPSD_LOG_ERROR
,
3457 "Missing value for SetEnv directive on line %d.",
3461 else if (!strcasecmp(line
, "SSLOptions"))
3464 * SSLOptions options
3467 if (!value
|| !strcasecmp(value
, "none"))
3468 SSLOptions
= CUPSD_SSL_NONE
;
3469 else if (!strcasecmp(value
, "noemptyfragments"))
3470 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3472 cupsdLogMessage(CUPSD_LOG_ERROR
,
3473 "Unknown value \"%s\" for SSLOptions directive on "
3474 "line %d.", value
, linenum
);
3476 #endif /* HAVE_SSL */
3480 * Find a simple variable in the list...
3483 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3484 if (!strcasecmp(line
, var
->name
))
3490 * Unknown directive! Output an error message and continue...
3494 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3497 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3504 case CUPSD_VARTYPE_INTEGER
:
3506 cupsdLogMessage(CUPSD_LOG_ERROR
,
3507 "Missing integer value for %s on line %d.",
3512 char *units
; /* Units */
3515 n
= strtol(value
, &units
, 0);
3517 if (units
&& *units
)
3519 if (tolower(units
[0] & 255) == 'g')
3520 n
*= 1024 * 1024 * 1024;
3521 else if (tolower(units
[0] & 255) == 'm')
3523 else if (tolower(units
[0] & 255) == 'k')
3525 else if (tolower(units
[0] & 255) == 't')
3530 cupsdLogMessage(CUPSD_LOG_ERROR
,
3531 "Bad negative integer value for %s on line %d.",
3534 *((int *)var
->ptr
) = n
;
3538 case CUPSD_VARTYPE_BOOLEAN
:
3540 cupsdLogMessage(CUPSD_LOG_ERROR
,
3541 "Missing boolean value for %s on line %d.",
3543 else if (!strcasecmp(value
, "true") ||
3544 !strcasecmp(value
, "on") ||
3545 !strcasecmp(value
, "enabled") ||
3546 !strcasecmp(value
, "yes") ||
3548 *((int *)var
->ptr
) = TRUE
;
3549 else if (!strcasecmp(value
, "false") ||
3550 !strcasecmp(value
, "off") ||
3551 !strcasecmp(value
, "disabled") ||
3552 !strcasecmp(value
, "no") ||
3553 !strcasecmp(value
, "0"))
3554 *((int *)var
->ptr
) = FALSE
;
3556 cupsdLogMessage(CUPSD_LOG_ERROR
,
3557 "Unknown boolean value %s on line %d.",
3561 case CUPSD_VARTYPE_PATHNAME
:
3564 cupsdLogMessage(CUPSD_LOG_ERROR
,
3565 "Missing pathname value for %s on line %d.",
3570 if (value
[0] == '/')
3571 strlcpy(temp
, value
, sizeof(temp
));
3573 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3575 if (access(temp
, 0))
3577 cupsdLogMessage(CUPSD_LOG_ERROR
,
3578 "File or directory for \"%s %s\" on line %d "
3579 "does not exist.", line
, value
, linenum
);
3583 case CUPSD_VARTYPE_STRING
:
3584 cupsdSetString((char **)var
->ptr
, value
);
3595 * 'read_location()' - Read a <Location path> definition.
3598 static int /* O - New line number or 0 on error */
3599 read_location(cups_file_t
*fp
, /* I - Configuration file */
3600 char *location
, /* I - Location name/path */
3601 int linenum
) /* I - Current line number */
3603 cupsd_location_t
*loc
, /* New location */
3604 *parent
; /* Parent location */
3605 char line
[HTTP_MAX_BUFFER
],
3607 *value
, /* Value for directive */
3608 *valptr
; /* Pointer into value */
3611 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3612 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3614 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3618 cupsdAddLocation(parent
);
3620 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3625 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3628 * Decode the directive...
3631 if (!strcasecmp(line
, "</Location>"))
3633 else if (!strcasecmp(line
, "<Limit") ||
3634 !strcasecmp(line
, "<LimitExcept"))
3638 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3639 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3645 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3648 cupsdAddLocation(loc
);
3653 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3658 if (!strcmp(value
, "ALL"))
3659 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3660 else if (!strcmp(value
, "GET"))
3661 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3662 else if (!strcmp(value
, "HEAD"))
3663 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3664 else if (!strcmp(value
, "OPTIONS"))
3665 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3666 else if (!strcmp(value
, "POST"))
3667 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3668 else if (!strcmp(value
, "PUT"))
3669 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3670 else if (!strcmp(value
, "TRACE"))
3671 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3673 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3676 for (value
= valptr
; isspace(*value
& 255); value
++);
3679 if (!strcasecmp(line
, "<LimitExcept"))
3680 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3682 parent
->limit
&= ~loc
->limit
;
3684 else if (!strcasecmp(line
, "</Limit>") ||
3685 !strcasecmp(line
, "</LimitExcept>"))
3687 else if (!parse_aaa(loc
, line
, value
, linenum
))
3689 cupsdLogMessage(CUPSD_LOG_ERROR
,
3690 "Unknown Location directive %s on line %d.",
3692 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3697 cupsdLogMessage(CUPSD_LOG_ERROR
,
3698 "Unexpected end-of-file at line %d while reading location.",
3701 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3706 * 'read_policy()' - Read a <Policy name> definition.
3709 static int /* O - New line number or 0 on error */
3710 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3711 char *policy
, /* I - Location name/path */
3712 int linenum
) /* I - Current line number */
3714 int i
; /* Looping var */
3715 cupsd_policy_t
*pol
; /* Policy */
3716 cupsd_location_t
*op
; /* Policy operation */
3717 int num_ops
; /* Number of IPP operations */
3718 ipp_op_t ops
[100]; /* Operations */
3719 char line
[HTTP_MAX_BUFFER
],
3721 *value
, /* Value for directive */
3722 *valptr
; /* Pointer into value */
3726 * Create the policy...
3729 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3730 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3732 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3736 * Read from the file...
3742 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3745 * Decode the directive...
3748 if (!strcasecmp(line
, "</Policy>"))
3751 cupsdLogMessage(CUPSD_LOG_WARN
,
3752 "Missing </Limit> before </Policy> on line %d.",
3755 set_policy_defaults(pol
);
3759 else if (!strcasecmp(line
, "<Limit") && !op
)
3763 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3764 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3771 * Scan for IPP operation names...
3778 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3783 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3785 if (!strcasecmp(value
, "All"))
3786 ops
[num_ops
] = IPP_ANY_OPERATION
;
3787 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3788 cupsdLogMessage(CUPSD_LOG_ERROR
,
3789 "Bad IPP operation name \"%s\" on line %d.",
3795 cupsdLogMessage(CUPSD_LOG_ERROR
,
3796 "Too many operations listed on line %d.",
3799 for (value
= valptr
; isspace(*value
& 255); value
++);
3803 * If none are specified, apply the policy to all operations...
3808 ops
[0] = IPP_ANY_OPERATION
;
3813 * Add a new policy for the first operation...
3816 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3818 else if (!strcasecmp(line
, "</Limit>") && op
)
3821 * Finish the current operation limit...
3827 * Copy the policy to the other operations...
3830 for (i
= 1; i
< num_ops
; i
++)
3831 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3836 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3837 !strcasecmp(line
, "JobPrivateValues") ||
3838 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3839 !strcasecmp(line
, "SubscriptionPrivateValues"))
3843 cupsdLogMessage(CUPSD_LOG_ERROR
,
3844 "%s directive must appear outside <Limit>...</Limit> "
3845 "on line %d.", line
, linenum
);
3846 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3852 * Pull out whitespace-delimited values...
3858 * Find the end of the current value...
3861 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3867 * Save it appropriately...
3870 if (!strcasecmp(line
, "JobPrivateAccess"))
3873 * JobPrivateAccess {all|default|user/group list|@@ACL}
3876 if (!strcasecmp(value
, "default"))
3878 cupsdAddString(&(pol
->job_access
), "@OWNER");
3879 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3882 cupsdAddString(&(pol
->job_access
), value
);
3884 else if (!strcasecmp(line
, "JobPrivateValues"))
3887 * JobPrivateValues {all|none|default|attribute list}
3890 if (!strcasecmp(value
, "default"))
3892 cupsdAddString(&(pol
->job_attrs
), "job-name");
3893 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3894 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3897 cupsdAddString(&(pol
->job_attrs
), value
);
3899 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3902 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3905 if (!strcasecmp(value
, "default"))
3907 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3908 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3911 cupsdAddString(&(pol
->sub_access
), value
);
3913 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3916 * SubscriptionPrivateValues {all|none|default|attribute list}
3919 if (!strcasecmp(value
, "default"))
3921 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3922 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3923 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3924 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3925 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3928 cupsdAddString(&(pol
->sub_attrs
), value
);
3932 * Find the next string on the line...
3935 for (value
= valptr
; isspace(*value
& 255); value
++);
3941 cupsdLogMessage(CUPSD_LOG_ERROR
,
3942 "Missing <Limit ops> directive before %s on line %d.",
3944 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3947 else if (!parse_aaa(op
, line
, value
, linenum
))
3950 cupsdLogMessage(CUPSD_LOG_ERROR
,
3951 "Unknown Policy Limit directive %s on line %d.",
3954 cupsdLogMessage(CUPSD_LOG_ERROR
,
3955 "Unknown Policy directive %s on line %d.",
3958 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3963 cupsdLogMessage(CUPSD_LOG_ERROR
,
3964 "Unexpected end-of-file at line %d while reading policy "
3965 "\"%s\".", linenum
, policy
);
3967 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3972 * 'set_policy_defaults()' - Set default policy values as needed.
3976 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3978 cupsd_location_t
*op
; /* Policy operation */
3982 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3983 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3984 * upgrades do not introduce new security issues...
3987 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3988 op
->op
== IPP_ANY_OPERATION
)
3990 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3991 op
->op
!= IPP_ANY_OPERATION
)
3994 * Add a new limit for Validate-Job using the Print-Job limit as a
3998 cupsdLogMessage(CUPSD_LOG_WARN
,
3999 "No limit for Validate-Job defined in policy %s "
4000 "- using Print-Job's policy.", pol
->name
);
4002 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
4005 cupsdLogMessage(CUPSD_LOG_WARN
,
4006 "No limit for Validate-Job defined in policy %s "
4007 "and no suitable template found.", pol
->name
);
4010 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
4011 op
->op
== IPP_ANY_OPERATION
)
4013 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
4014 op
->op
!= IPP_ANY_OPERATION
)
4017 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
4021 cupsdLogMessage(CUPSD_LOG_WARN
,
4022 "No limit for Cancel-Jobs defined in policy %s "
4023 "- using Pause-Printer's policy.", pol
->name
);
4025 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
4028 cupsdLogMessage(CUPSD_LOG_WARN
,
4029 "No limit for Cancel-Jobs defined in policy %s "
4030 "and no suitable template found.", pol
->name
);
4033 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
4034 op
->op
== IPP_ANY_OPERATION
)
4036 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4037 op
->op
!= IPP_ANY_OPERATION
)
4040 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4044 cupsdLogMessage(CUPSD_LOG_WARN
,
4045 "No limit for Cancel-My-Jobs defined in policy %s "
4046 "- using Send-Document's policy.", pol
->name
);
4048 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4051 cupsdLogMessage(CUPSD_LOG_WARN
,
4052 "No limit for Cancel-My-Jobs defined in policy %s "
4053 "and no suitable template found.", pol
->name
);
4056 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
4057 op
->op
== IPP_ANY_OPERATION
)
4059 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4060 op
->op
!= IPP_ANY_OPERATION
)
4063 * Add a new limit for Close-Job using the Send-Document limit as a
4067 cupsdLogMessage(CUPSD_LOG_WARN
,
4068 "No limit for Close-Job defined in policy %s "
4069 "- using Send-Document's policy.", pol
->name
);
4071 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4074 cupsdLogMessage(CUPSD_LOG_WARN
,
4075 "No limit for Close-Job defined in policy %s "
4076 "and no suitable template found.", pol
->name
);
4079 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4080 op
->op
== IPP_ANY_OPERATION
)
4082 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4083 op
->op
!= IPP_ANY_OPERATION
)
4086 * Add a new limit for CUPS-Get-Document using the Send-Document
4087 * limit as a template...
4090 cupsdLogMessage(CUPSD_LOG_WARN
,
4091 "No limit for CUPS-Get-Document defined in policy %s "
4092 "- using Send-Document's policy.", pol
->name
);
4094 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4097 cupsdLogMessage(CUPSD_LOG_WARN
,
4098 "No limit for CUPS-Get-Document defined in policy %s "
4099 "and no suitable template found.", pol
->name
);
4103 * Verify we have JobPrivateAccess, JobPrivateValues,
4104 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4107 if (!pol
->job_access
)
4109 cupsdLogMessage(CUPSD_LOG_WARN
,
4110 "No JobPrivateAccess defined in policy %s "
4111 "- using defaults.", pol
->name
);
4112 cupsdAddString(&(pol
->job_access
), "@OWNER");
4113 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4116 if (!pol
->job_attrs
)
4118 cupsdLogMessage(CUPSD_LOG_WARN
,
4119 "No JobPrivateValues defined in policy %s "
4120 "- using defaults.", pol
->name
);
4121 cupsdAddString(&(pol
->job_attrs
), "job-name");
4122 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4123 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4126 if (!pol
->sub_access
)
4128 cupsdLogMessage(CUPSD_LOG_WARN
,
4129 "No SubscriptionPrivateAccess defined in policy %s "
4130 "- using defaults.", pol
->name
);
4131 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4132 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4135 if (!pol
->sub_attrs
)
4137 cupsdLogMessage(CUPSD_LOG_WARN
,
4138 "No SubscriptionPrivateValues defined in policy %s "
4139 "- using defaults.", pol
->name
);
4140 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4141 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4142 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4143 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4144 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4150 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".