2 * "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $"
4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2012 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 * cupsdDefaultAuthType() - Get the default AuthType.
21 * cupsdFreeAliases() - Free all of the alias entries.
22 * cupsdReadConfiguration() - Read the cupsd.conf file.
23 * get_address() - Get an address + port number from a line.
24 * get_addr_and_mask() - Get an IP address and netmask.
25 * mime_error_cb() - Log a MIME error.
26 * parse_aaa() - Parse authentication, authorization, and access
28 * parse_fatal_errors() - Parse FatalErrors values in a string.
29 * parse_groups() - Parse system group names in a string.
30 * parse_protocols() - Parse browse protocols in a string.
31 * parse_variable() - Parse a variable line.
32 * read_cupsd_conf() - Read the cupsd.conf configuration file.
33 * read_cups_files_conf() - Read the cups-files.conf configuration file.
34 * read_location() - Read a <Location path> definition.
35 * read_policy() - Read a <Policy name> definition.
36 * set_policy_defaults() - Set default policy values as needed.
40 * Include necessary headers...
46 #include <sys/utsname.h>
51 #endif /* HAVE_LIBPAPER */
55 * Possibly missing network definitions...
59 # define INADDR_NONE 0xffffffff
60 #endif /* !INADDR_NONE */
64 * Configuration variable structure...
69 CUPSD_VARTYPE_INTEGER
, /* Integer option */
70 CUPSD_VARTYPE_TIME
, /* Time interval option */
71 CUPSD_VARTYPE_STRING
, /* String option */
72 CUPSD_VARTYPE_BOOLEAN
, /* Boolean option */
73 CUPSD_VARTYPE_PATHNAME
/* File/directory name option */
78 const char *name
; /* Name of variable */
79 void *ptr
; /* Pointer to variable */
80 cupsd_vartype_t type
; /* Type (int, string, address) */
88 static const cupsd_var_t cupsd_vars
[] =
90 { "AutoPurgeJobs", &JobAutoPurge
, CUPSD_VARTYPE_BOOLEAN
},
91 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
92 { "BrowseDNSSDSubTypes", &DNSSDSubTypes
, CUPSD_VARTYPE_STRING
},
93 #endif /* HAVE_DNSSD || HAVE_AVAHI */
94 { "BrowseWebIF", &BrowseWebIF
, CUPSD_VARTYPE_BOOLEAN
},
95 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
96 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
97 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
98 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
99 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_TIME
},
100 { "DefaultPaperSize", &DefaultPaperSize
, CUPSD_VARTYPE_STRING
},
101 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
102 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
103 { "DirtyCleanInterval", &DirtyCleanInterval
, CUPSD_VARTYPE_TIME
},
104 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
105 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
106 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
108 { "GSSServiceName", &GSSServiceName
, CUPSD_VARTYPE_STRING
},
109 #endif /* HAVE_GSSAPI */
110 { "JobKillDelay", &JobKillDelay
, CUPSD_VARTYPE_TIME
},
111 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
112 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_TIME
},
113 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_TIME
},
114 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
116 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_TIME
},
117 #endif /* HAVE_LAUNCHD */
118 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
119 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
120 { "LogDebugHistory", &LogDebugHistory
, CUPSD_VARTYPE_INTEGER
},
121 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
122 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
123 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
124 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
125 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
126 { "MaxHoldTime", &MaxHoldTime
, CUPSD_VARTYPE_TIME
},
127 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
128 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
129 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
130 { "MaxJobTime", &MaxJobTime
, CUPSD_VARTYPE_INTEGER
},
131 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_TIME
},
132 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
133 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
134 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
135 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
136 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
137 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
138 { "MultipleOperationTimeout", &MultipleOperationTimeout
, CUPSD_VARTYPE_TIME
},
139 { "PageLogFormat", &PageLogFormat
, CUPSD_VARTYPE_STRING
},
140 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_TIME
},
141 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_TIME
},
142 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_TIME
},
143 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
144 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
145 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_TIME
},
146 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
147 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
148 { "StrictConformance", &StrictConformance
, CUPSD_VARTYPE_BOOLEAN
},
149 { "Timeout", &Timeout
, CUPSD_VARTYPE_TIME
},
150 { "WebInterface", &WebInterface
, CUPSD_VARTYPE_BOOLEAN
}
152 static const cupsd_var_t cupsfiles_vars
[] =
154 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
155 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
156 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
157 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
158 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
159 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
160 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
161 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
162 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
163 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
164 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
165 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
166 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
167 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
169 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
170 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
171 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
172 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
173 #endif /* HAVE_SSL */
174 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
175 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
176 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
177 #ifdef HAVE_AUTHORIZATION_H
178 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
179 #endif /* HAVE_AUTHORIZATION_H */
180 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
}
183 static int default_auth_type
= CUPSD_AUTH_AUTO
;
184 /* Default AuthType, if not specified */
186 static const unsigned ones
[4] =
188 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
190 static const unsigned zeros
[4] =
192 0x00000000, 0x00000000, 0x00000000, 0x00000000
200 static http_addrlist_t
*get_address(const char *value
, int defport
);
201 static int get_addr_and_mask(const char *value
, unsigned *ip
,
203 static void mime_error_cb(void *ctx
, const char *message
);
204 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
205 char *value
, int linenum
);
206 static int parse_fatal_errors(const char *s
);
207 static int parse_groups(const char *s
);
208 static int parse_protocols(const char *s
);
209 static int parse_variable(const char *filename
, int linenum
,
210 const char *line
, const char *value
,
212 const cupsd_var_t
*vars
);
213 static int read_cupsd_conf(cups_file_t
*fp
);
214 static int read_cups_files_conf(cups_file_t
*fp
);
215 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
216 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
217 static void set_policy_defaults(cupsd_policy_t
*pol
);
221 * 'cupsdAddAlias()' - Add a host alias.
225 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
226 const char *name
) /* I - Name to add */
228 cupsd_alias_t
*a
; /* New alias */
229 size_t namelen
; /* Length of name */
232 namelen
= strlen(name
);
234 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
237 a
->namelen
= namelen
;
238 memcpy(a
->name
, name
, namelen
+ 1); /* OK since a->name is allocated */
240 cupsArrayAdd(aliases
, a
);
245 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
248 int /* O - 0 on success, -1 on error, 1 on warning */
249 cupsdCheckPermissions(
250 const char *filename
, /* I - File/directory name */
251 const char *suffix
, /* I - Additional file/directory name */
252 int mode
, /* I - Permissions */
253 int user
, /* I - Owner */
254 int group
, /* I - Group */
255 int is_dir
, /* I - 1 = directory, 0 = file */
256 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
258 int dir_created
= 0; /* Did we create a directory? */
259 char pathname
[1024]; /* File name with prefix */
260 struct stat fileinfo
; /* Stat buffer */
261 int is_symlink
; /* Is "filename" a symlink? */
265 * Prepend the given root to the filename before testing it...
270 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
275 * See if we can stat the file/directory...
278 if (lstat(filename
, &fileinfo
))
280 if (errno
== ENOENT
&& create_dir
)
283 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
286 if (mkdir(filename
, mode
))
289 cupsdLogMessage(CUPSD_LOG_ERROR
,
290 "Unable to create directory \"%s\" - %s", filename
,
293 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
300 fileinfo
.st_mode
= mode
| S_IFDIR
;
303 return (create_dir
? -1 : 1);
306 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
308 if (stat(filename
, &fileinfo
))
310 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
311 filename
, strerror(errno
));
317 * Make sure it's a regular file or a directory as needed...
320 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
322 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file.", filename
);
326 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
329 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory.", filename
);
331 syslog(LOG_ERR
, "\"%s\" is not a directory.", filename
);
337 * If the filename is a symlink, do not change permissions (STR #2937)...
344 * Fix owner, group, and mode as needed...
347 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
350 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
353 if (chown(filename
, user
, group
) && !getuid())
356 cupsdLogMessage(CUPSD_LOG_ERROR
,
357 "Unable to change ownership of \"%s\" - %s", filename
,
360 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
367 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
370 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
373 if (chmod(filename
, mode
))
376 cupsdLogMessage(CUPSD_LOG_ERROR
,
377 "Unable to change permissions of \"%s\" - %s", filename
,
380 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
388 * Everything is OK...
396 * 'cupsdDefaultAuthType()' - Get the default AuthType.
398 * When the default_auth_type is "auto", this function tries to get the GSS
399 * credentials for the server. If that succeeds we use Kerberos authentication,
400 * otherwise we do a fallback to Basic authentication against the local user
404 int /* O - Default AuthType value */
405 cupsdDefaultAuthType(void)
408 OM_uint32 major_status
, /* Major status code */
409 minor_status
; /* Minor status code */
410 gss_name_t server_name
; /* Server name */
411 gss_buffer_desc token
= GSS_C_EMPTY_BUFFER
;
412 /* Service name token */
413 char buf
[1024]; /* Service name buffer */
414 #endif /* HAVE_GSSAPI */
418 * If we have already determined the correct default AuthType, use it...
421 if (default_auth_type
!= CUPSD_AUTH_AUTO
)
422 return (default_auth_type
);
427 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
431 if (gss_init_sec_context
== NULL
)
432 return (default_auth_type
= CUPSD_AUTH_BASIC
);
433 # endif /* __APPLE__ */
436 * Try to obtain the server's GSS credentials (GSSServiceName@servername). If
437 * that fails we must use Basic...
440 snprintf(buf
, sizeof(buf
), "%s@%s", GSSServiceName
, ServerName
);
443 token
.length
= strlen(buf
);
444 server_name
= GSS_C_NO_NAME
;
445 major_status
= gss_import_name(&minor_status
, &token
,
446 GSS_C_NT_HOSTBASED_SERVICE
,
449 memset(&token
, 0, sizeof(token
));
451 if (GSS_ERROR(major_status
))
453 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
454 "cupsdDefaultAuthType: gss_import_name(%s) failed", buf
);
455 return (default_auth_type
= CUPSD_AUTH_BASIC
);
458 major_status
= gss_display_name(&minor_status
, server_name
, &token
, NULL
);
460 if (GSS_ERROR(major_status
))
462 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
463 "cupsdDefaultAuthType: gss_display_name(%s) failed",
465 return (default_auth_type
= CUPSD_AUTH_BASIC
);
468 cupsdLogMessage(CUPSD_LOG_DEBUG
,
469 "cupsdDefaultAuthType: Attempting to acquire Kerberos "
470 "credentials for %s...", (char *)token
.value
);
472 ServerCreds
= GSS_C_NO_CREDENTIAL
;
473 major_status
= gss_acquire_cred(&minor_status
, server_name
, GSS_C_INDEFINITE
,
474 GSS_C_NO_OID_SET
, GSS_C_ACCEPT
,
475 &ServerCreds
, NULL
, NULL
);
476 if (GSS_ERROR(major_status
))
478 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
479 "cupsdDefaultAuthType: gss_acquire_cred(%s) failed",
480 (char *)token
.value
);
481 gss_release_name(&minor_status
, &server_name
);
482 gss_release_buffer(&minor_status
, &token
);
483 return (default_auth_type
= CUPSD_AUTH_BASIC
);
486 cupsdLogMessage(CUPSD_LOG_DEBUG
,
487 "cupsdDefaultAuthType: Kerberos credentials acquired "
488 "successfully for %s.", (char *)token
.value
);
490 gss_release_name(&minor_status
, &server_name
);
491 gss_release_buffer(&minor_status
, &token
);
495 return (default_auth_type
= CUPSD_AUTH_NEGOTIATE
);
499 * No Kerberos support compiled in so just use Basic all the time...
502 return (default_auth_type
= CUPSD_AUTH_BASIC
);
503 #endif /* HAVE_GSSAPI */
508 * 'cupsdFreeAliases()' - Free all of the alias entries.
512 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
514 cupsd_alias_t
*a
; /* Current alias */
517 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
519 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
522 cupsArrayDelete(aliases
);
527 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
530 int /* O - 1 on success, 0 otherwise */
531 cupsdReadConfiguration(void)
533 int i
; /* Looping var */
534 cups_file_t
*fp
; /* Configuration file */
535 int status
; /* Return status */
536 char temp
[1024], /* Temporary buffer */
537 mimedir
[1024], /* MIME directory */
538 *slash
; /* Directory separator */
539 cups_lang_t
*language
; /* Language */
540 struct passwd
*user
; /* Default user */
541 struct group
*group
; /* Default group */
542 char *old_serverroot
, /* Old ServerRoot */
543 *old_requestroot
; /* Old RequestRoot */
544 int old_remote_port
; /* Old RemotePort */
545 const char *tmpdir
; /* TMPDIR environment variable */
546 struct stat tmpinfo
; /* Temporary directory info */
547 cupsd_policy_t
*p
; /* Policy */
551 * Save the old root paths...
554 old_serverroot
= NULL
;
555 cupsdSetString(&old_serverroot
, ServerRoot
);
556 old_requestroot
= NULL
;
557 cupsdSetString(&old_requestroot
, RequestRoot
);
560 * Reset the server configuration data...
563 cupsdDeleteAllLocations();
565 cupsdDeleteAllListeners();
567 old_remote_port
= RemotePort
;
574 cupsdFreeAliases(ServerAlias
);
577 cupsdClearString(&ServerName
);
578 cupsdClearString(&ServerAdmin
);
579 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
580 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
581 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
582 cupsdSetString(&DataDir
, CUPS_DATADIR
);
583 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
584 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
585 cupsdClearString(&ErrorLog
);
586 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
587 cupsdSetString(&PageLogFormat
,
588 "%p %u %j %T %P %C %{job-billing} "
589 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
590 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
591 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
592 cupsdSetString(&RemoteRoot
, "remroot");
593 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
595 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
597 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
598 PrintcapFormat
= PRINTCAP_SOLARIS
;
599 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
600 "/Library/Preferences/org.cups.printers.plist"))
601 PrintcapFormat
= PRINTCAP_PLIST
;
603 PrintcapFormat
= PRINTCAP_BSD
;
605 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
606 if ((slash
= strrchr(temp
, '/')) != NULL
)
609 cupsdSetString(&ServerRoot
, temp
);
611 cupsdClearString(&Classification
);
612 ClassifyOverride
= 0;
616 cupsdSetString(&ServerCertificate
, "/Library/Keychains/System.keychain");
618 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
619 cupsdSetString(&ServerKey
, "ssl/server.key");
620 # endif /* HAVE_CDSASSL */
621 #endif /* HAVE_SSL */
623 language
= cupsLangDefault();
625 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
626 cupsdSetString(&DefaultLanguage
, "en");
628 cupsdSetString(&DefaultLanguage
, language
->language
);
630 cupsdClearString(&DefaultPaperSize
);
632 cupsdSetString(&RIPCache
, "128m");
634 cupsdSetString(&TempDir
, NULL
);
637 cupsdSetString(&GSSServiceName
, CUPS_DEFAULT_GSSSERVICENAME
);
641 OM_uint32 minor_status
; /* Minor status code */
643 gss_release_cred(&minor_status
, &ServerCreds
);
648 ServerCreds
= GSS_C_NO_CREDENTIAL
;
649 #endif /* HAVE_GSSAPI */
652 * Find the default user...
655 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
660 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
661 * complement number...)
670 * Find the default group...
673 group
= getgrnam(CUPS_DEFAULT_GROUP
);
677 Group
= group
->gr_gid
;
681 * Fallback to group "nobody"...
684 group
= getgrnam("nobody");
688 Group
= group
->gr_gid
;
692 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
693 * complement number...)
704 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
705 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
706 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
707 default_auth_type
= CUPSD_AUTH_BASIC
;
709 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
710 SSLOptions
= CUPSD_SSL_NONE
;
711 #endif /* HAVE_SSL */
712 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
713 JobKillDelay
= DEFAULT_TIMEOUT
;
715 JobRetryInterval
= 300;
720 HostNameLookups
= FALSE
;
722 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
723 ListenBackLog
= SOMAXCONN
;
724 LogDebugHistory
= 200;
725 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
726 LogLevel
= CUPSD_LOG_WARN
;
727 LogTimeFormat
= CUPSD_TIME_STANDARD
;
729 MaxClientsPerHost
= 0;
730 MaxLogSize
= 1024 * 1024;
732 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
734 ReloadTimeout
= DEFAULT_KEEPALIVE
;
735 RootCertDuration
= 300;
736 StrictConformance
= FALSE
;
737 Timeout
= DEFAULT_TIMEOUT
;
738 WebInterface
= CUPS_DEFAULT_WEBIF
;
740 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
742 Browsing
= CUPS_DEFAULT_BROWSING
;
743 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
745 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
746 cupsdSetString(&DNSSDSubTypes
, "_cups,_print");
747 #endif /* HAVE_DNSSD || HAVE_AVAHI */
749 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
750 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
752 cupsdSetString(&ErrorPolicy
, "stop-printer");
754 JobHistory
= DEFAULT_HISTORY
;
755 JobFiles
= DEFAULT_FILES
;
761 MaxJobsPerPrinter
= 0;
762 MaxJobTime
= 3 * 60 * 60; /* 3 hours */
763 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
765 cupsdDeleteAllPolicies();
766 cupsdClearString(&DefaultPolicy
);
768 #ifdef HAVE_AUTHORIZATION_H
769 cupsdClearString(&SystemGroupAuthKey
);
770 #endif /* HAVE_AUTHORIZATION_H */
772 MaxSubscriptions
= 100;
773 MaxSubscriptionsPerJob
= 0;
774 MaxSubscriptionsPerPrinter
= 0;
775 MaxSubscriptionsPerUser
= 0;
776 DefaultLeaseDuration
= 86400;
777 MaxLeaseDuration
= 0;
781 #endif /* HAVE_LAUNCHD */
784 * Setup environment variables...
790 * Read the cups-files.conf file...
793 if ((fp
= cupsFileOpen(CupsFilesFile
, "r")) != NULL
)
795 status
= read_cups_files_conf(fp
);
802 else if (errno
== ENOENT
)
803 cupsdLogMessage(CUPSD_LOG_INFO
, "No %s, using defaults.", CupsFilesFile
);
806 cupsdLogMessage(CUPSD_LOG_CRIT
, "Unable to open %s: %s", CupsFilesFile
,
812 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
815 * Read the cupsd.conf file...
818 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
820 cupsdLogMessage(CUPSD_LOG_CRIT
, "Unable to open %s: %s", ConfigurationFile
,
825 status
= read_cupsd_conf(fp
);
834 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
835 RemotePort
? "enabled" : "disabled");
838 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
841 * See if the ServerName is an IP address...
847 ServerAlias
= cupsArrayNew(NULL
, NULL
);
849 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
853 if (gethostname(temp
, sizeof(temp
)))
855 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
857 strlcpy(temp
, "localhost", sizeof(temp
));
860 cupsdSetString(&ServerName
, temp
);
863 ServerAlias
= cupsArrayNew(NULL
, NULL
);
865 cupsdAddAlias(ServerAlias
, temp
);
866 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
868 if (HostNameLookups
|| RemotePort
)
870 struct hostent
*host
; /* Host entry to get FQDN */
872 if ((host
= gethostbyname(temp
)) != NULL
)
874 if (_cups_strcasecmp(temp
, host
->h_name
))
876 cupsdSetString(&ServerName
, host
->h_name
);
877 cupsdAddAlias(ServerAlias
, host
->h_name
);
878 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
884 for (i
= 0; host
->h_aliases
[i
]; i
++)
885 if (_cups_strcasecmp(temp
, host
->h_aliases
[i
]))
887 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
888 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
896 * Make sure we have the base hostname added as an alias, too!
899 if ((slash
= strchr(temp
, '.')) != NULL
)
902 cupsdAddAlias(ServerAlias
, temp
);
903 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
907 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
909 ServerNameIsIP
= !*slash
;
912 * Make sure ServerAdmin is initialized...
916 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
919 * Use the default system group if none was supplied in cupsd.conf...
922 if (NumSystemGroups
== 0)
924 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
927 * Find the group associated with GID 0...
934 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
936 cupsdSetString(&SystemGroups
[0], "unknown");
938 SystemGroupIDs
[0] = 0;
944 * Open the system log for cupsd if necessary...
948 if (!strcmp(AccessLog
, "syslog") ||
949 !strcmp(ErrorLog
, "syslog") ||
950 !strcmp(PageLog
, "syslog"))
951 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
952 #endif /* HAVE_VSYSLOG */
955 * Make sure each of the log files exists and gets rotated as necessary...
958 if (strcmp(AccessLog
, "syslog"))
959 cupsdCheckLogFile(&AccessFile
, AccessLog
);
961 if (strcmp(ErrorLog
, "syslog"))
962 cupsdCheckLogFile(&ErrorFile
, ErrorLog
);
964 if (strcmp(PageLog
, "syslog"))
965 cupsdCheckLogFile(&PageFile
, PageLog
);
968 * Log the configuration file that was used...
971 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
975 * Validate the Group and SystemGroup settings - they cannot be the same,
976 * otherwise the CGI programs will be able to authenticate as root without
982 for (i
= 0; i
< NumSystemGroups
; i
++)
983 if (Group
== SystemGroupIDs
[i
])
986 if (i
< NumSystemGroups
)
989 * Log the error and reset the group to a safe value...
992 cupsdLogMessage(CUPSD_LOG_NOTICE
,
993 "Group and SystemGroup cannot use the same groups.");
994 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
996 group
= getgrnam("nobody");
1000 Group
= group
->gr_gid
;
1004 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
1005 * complement number...)
1014 * Check that we have at least one listen/port line; if not, report this
1015 * as an error and exit!
1018 if (cupsArrayCount(Listeners
) == 0)
1024 cupsdLogMessage(CUPSD_LOG_EMERG
,
1025 "No valid Listen or Port lines were found in the "
1026 "configuration file.");
1032 cupsdEndProcess(getpid(), 0);
1036 * Set the default locale using the language and charset...
1039 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
1042 * Update all relative filenames to include the full path from ServerRoot...
1045 if (DocumentRoot
[0] != '/')
1046 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
1048 if (RequestRoot
[0] != '/')
1049 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
1051 if (ServerBin
[0] != '/')
1052 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
1054 if (StateDir
[0] != '/')
1055 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
1057 if (CacheDir
[0] != '/')
1058 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
1061 if (ServerCertificate
[0] != '/')
1062 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
1064 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
1065 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
1067 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1070 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
1071 if (ServerKey
[0] != '/')
1072 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
1074 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
1075 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
1076 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1078 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
1079 #endif /* HAVE_SSL */
1082 * Make sure that directories and config files are owned and
1083 * writable by the user and group in the cupsd.conf file...
1086 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
1088 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
1090 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
1092 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
1094 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
1096 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
1097 SystemGroupIDs
[0], 1, 1) < 0 ||
1098 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
1100 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
1102 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
1104 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
1106 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
1108 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
1110 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
1111 Group
, 0, 0) < 0) &&
1112 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1116 * Update TempDir to the default if it hasn't been set already...
1120 if (TempDir
&& !RunUser
&&
1121 (!strncmp(TempDir
, "/private/tmp", 12) || !strncmp(TempDir
, "/tmp", 4)))
1123 cupsdLogMessage(CUPSD_LOG_ERROR
, "Cannot use %s for TempDir.", TempDir
);
1124 cupsdClearString(&TempDir
);
1126 #endif /* __APPLE__ */
1131 if ((tmpdir
= getenv("TMPDIR")) != NULL
&&
1132 strncmp(tmpdir
, "/private/tmp", 12) && strncmp(tmpdir
, "/tmp", 4))
1134 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1135 #endif /* __APPLE__ */
1138 * TMPDIR is defined, see if it is OK for us to use...
1141 if (stat(tmpdir
, &tmpinfo
))
1142 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1143 tmpdir
, strerror(errno
));
1144 else if (!S_ISDIR(tmpinfo
.st_mode
))
1145 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1147 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1148 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1149 !(tmpinfo
.st_mode
& S_IWOTH
))
1150 cupsdLogMessage(CUPSD_LOG_ERROR
,
1151 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1153 cupsdSetString(&TempDir
, tmpdir
);
1159 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1161 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1165 * Make sure the temporary directory has the right permissions...
1168 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1172 * Update ownership and permissions if the CUPS temp directory
1173 * is under the spool directory or does not exist...
1176 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1177 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1182 * Update environment variables...
1188 * Update default paper size setting as needed...
1191 if (!DefaultPaperSize
)
1193 #ifdef HAVE_LIBPAPER
1194 char *paper_result
; /* Paper size name from libpaper */
1196 if ((paper_result
= systempapername()) != NULL
)
1197 cupsdSetString(&DefaultPaperSize
, paper_result
);
1199 #endif /* HAVE_LIBPAPER */
1200 if (!DefaultLanguage
||
1201 !_cups_strcasecmp(DefaultLanguage
, "C") ||
1202 !_cups_strcasecmp(DefaultLanguage
, "POSIX") ||
1203 !_cups_strcasecmp(DefaultLanguage
, "en") ||
1204 !_cups_strncasecmp(DefaultLanguage
, "en.", 3) ||
1205 !_cups_strncasecmp(DefaultLanguage
, "en_US", 5) ||
1206 !_cups_strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1207 !_cups_strncasecmp(DefaultLanguage
, "fr_CA", 5))
1210 * These are the only locales that will default to "letter" size...
1213 cupsdSetString(&DefaultPaperSize
, "Letter");
1216 cupsdSetString(&DefaultPaperSize
, "A4");
1220 * Update classification setting as needed...
1223 if (Classification
&& !_cups_strcasecmp(Classification
, "none"))
1224 cupsdClearString(&Classification
);
1227 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1230 * Check the MaxClients setting, and then allocate memory for it...
1233 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1236 cupsdLogMessage(CUPSD_LOG_INFO
,
1237 "MaxClients limited to 1/3 (%d) of the file descriptor "
1239 MaxFDs
/ 3, MaxFDs
);
1241 MaxClients
= MaxFDs
/ 3;
1244 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1248 * Check the MaxActiveJobs setting; limit to 1/3 the available
1249 * file descriptors, since we need a pipe for each job...
1252 if (MaxActiveJobs
> (MaxFDs
/ 3))
1253 MaxActiveJobs
= MaxFDs
/ 3;
1256 * Update the MaxClientsPerHost value, as needed...
1259 if (MaxClientsPerHost
<= 0)
1260 MaxClientsPerHost
= MaxClients
;
1262 if (MaxClientsPerHost
> MaxClients
)
1263 MaxClientsPerHost
= MaxClients
;
1265 cupsdLogMessage(CUPSD_LOG_INFO
,
1266 "Allowing up to %d client connections per host.",
1270 * Update the default policy, as needed...
1274 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1276 DefaultPolicyPtr
= NULL
;
1278 if (!DefaultPolicyPtr
)
1280 cupsd_location_t
*po
; /* New policy operation */
1284 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1287 cupsdSetString(&DefaultPolicy
, "default");
1289 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1290 cupsdLogMessage(CUPSD_LOG_INFO
,
1291 "Using policy \"default\" as the default.");
1294 cupsdLogMessage(CUPSD_LOG_INFO
,
1295 "Creating CUPS default administrative policy:");
1297 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1299 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1301 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1302 cupsdAddString(&(p
->job_access
), "@OWNER");
1303 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1305 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1306 cupsdAddString(&(p
->job_attrs
), "job-name");
1307 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1308 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1310 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1311 cupsdAddString(&(p
->sub_access
), "@OWNER");
1312 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1314 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1315 cupsdAddString(&(p
->job_attrs
), "notify-events");
1316 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1317 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1318 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1319 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1321 cupsdLogMessage(CUPSD_LOG_INFO
,
1322 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1323 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1325 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1326 po
->order_type
= CUPSD_AUTH_ALLOW
;
1328 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1329 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1330 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1332 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1334 cupsdLogMessage(CUPSD_LOG_INFO
,
1335 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1336 "Release-Job Restart-Job Purge-Jobs "
1337 "Set-Job-Attributes Create-Job-Subscription "
1338 "Renew-Subscription Cancel-Subscription "
1339 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1340 "Suspend-Current-Job Resume-Job "
1341 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1342 "CUPS-Authenticate-Job CUPS-Get-Document>");
1343 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1345 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1346 po
->order_type
= CUPSD_AUTH_ALLOW
;
1347 po
->level
= CUPSD_AUTH_USER
;
1349 cupsdAddName(po
, "@OWNER");
1350 cupsdAddName(po
, "@SYSTEM");
1351 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1353 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1354 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1355 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1356 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1357 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1358 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1359 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1360 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1361 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1362 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1363 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1364 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1365 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1366 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1367 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1368 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1369 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1370 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1371 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1372 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1374 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1376 cupsdLogMessage(CUPSD_LOG_INFO
,
1377 "<Limit Pause-Printer Resume-Printer "
1378 "Set-Printer-Attributes Enable-Printer "
1379 "Disable-Printer Pause-Printer-After-Current-Job "
1380 "Hold-New-Jobs Release-Held-New-Jobs "
1381 "Deactivate-Printer Activate-Printer Restart-Printer "
1382 "Shutdown-Printer Startup-Printer Promote-Job "
1383 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1384 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1385 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1386 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1387 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1389 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1390 po
->order_type
= CUPSD_AUTH_ALLOW
;
1391 po
->type
= CUPSD_AUTH_DEFAULT
;
1392 po
->level
= CUPSD_AUTH_USER
;
1394 cupsdAddName(po
, "@SYSTEM");
1395 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1397 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1398 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1399 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1400 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1401 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1402 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1403 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1404 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1405 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1406 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1407 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1408 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1409 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1410 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1411 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1412 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1413 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1414 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1415 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1416 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1417 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1418 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1420 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1422 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1423 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1425 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1426 po
->order_type
= CUPSD_AUTH_ALLOW
;
1428 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1429 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1433 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1434 cupsArrayCount(Policies
));
1435 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1437 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1438 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1439 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1442 * If we are doing a full reload or the server root has changed, flush
1443 * the jobs, printers, etc. and start from scratch...
1446 if (NeedReload
== RELOAD_ALL
||
1447 old_remote_port
!= RemotePort
||
1448 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1449 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1451 mime_type_t
*type
; /* Current type */
1452 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1453 /* MIME type name */
1456 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1459 * Free all memory...
1462 cupsdDeleteAllSubscriptions();
1464 cupsdDeleteAllPrinters();
1466 DefaultPrinter
= NULL
;
1468 if (MimeDatabase
!= NULL
)
1469 mimeDelete(MimeDatabase
);
1473 for (i
= 0; i
< NumMimeTypes
; i
++)
1474 _cupsStrFree(MimeTypes
[i
]);
1480 * Read the MIME type and conversion database...
1483 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1484 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1486 MimeDatabase
= mimeNew();
1487 mimeSetErrorCallback(MimeDatabase
, mime_error_cb
, NULL
);
1489 MimeDatabase
= mimeLoadTypes(MimeDatabase
, mimedir
);
1490 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1491 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1492 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1496 cupsdLogMessage(CUPSD_LOG_EMERG
,
1497 "Unable to load MIME database from \"%s\" or \"%s\".",
1498 mimedir
, ServerRoot
);
1499 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1503 cupsdLogMessage(CUPSD_LOG_INFO
,
1504 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1505 "%d filters...", mimedir
, ServerRoot
,
1506 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1509 * Create a list of MIME types for the document-format-supported
1513 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1514 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1517 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1519 cupsdLogMessage(CUPSD_LOG_ERROR
,
1520 "Unable to allocate memory for %d MIME types.",
1526 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1528 i
++, type
= mimeNextType(MimeDatabase
))
1530 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1532 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1535 if (i
< NumMimeTypes
)
1536 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1539 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1541 mime_filter_t
*filter
; /* Current filter */
1544 for (type
= mimeFirstType(MimeDatabase
);
1546 type
= mimeNextType(MimeDatabase
))
1547 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1548 type
->super
, type
->type
);
1550 for (filter
= mimeFirstFilter(MimeDatabase
);
1552 filter
= mimeNextFilter(MimeDatabase
))
1553 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1554 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1555 filter
->src
->super
, filter
->src
->type
,
1556 filter
->dst
->super
, filter
->dst
->type
,
1557 filter
->cost
, filter
->filter
);
1564 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1565 cupsdLoadBanners(temp
);
1568 * Load printers and classes...
1571 cupsdLoadAllPrinters();
1572 cupsdLoadAllClasses();
1574 cupsdCreateCommonData();
1577 * Update the printcap file as needed...
1580 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1581 cupsdWritePrintcap();
1584 * Load queued jobs...
1590 * Load subscriptions...
1593 cupsdLoadAllSubscriptions();
1595 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1600 * Not a full reload, so recreate the common printer attributes...
1603 cupsdCreateCommonData();
1606 * Update all jobs as needed...
1612 * Update all printers as needed...
1615 cupsdUpdatePrinters();
1616 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1618 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1622 * Reset the reload state...
1625 NeedReload
= RELOAD_NONE
;
1627 cupsdClearString(&old_serverroot
);
1628 cupsdClearString(&old_requestroot
);
1635 * 'get_address()' - Get an address + port number from a line.
1638 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1639 get_address(const char *value
, /* I - Value string */
1640 int defport
) /* I - Default port */
1642 char buffer
[1024], /* Hostname + port number buffer */
1643 defpname
[255], /* Default port name */
1644 *hostname
, /* Hostname or IP */
1645 *portname
; /* Port number or name */
1646 http_addrlist_t
*addrlist
; /* Address list */
1650 * Check for an empty value...
1655 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1660 * Grab a hostname and port number; if there is no colon and the port name
1661 * is only digits, then we have a port number by itself...
1664 strlcpy(buffer
, value
, sizeof(buffer
));
1666 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1673 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1678 * Use the default port...
1681 sprintf(defpname
, "%d", defport
);
1682 portname
= defpname
;
1688 * The buffer contains just a port number...
1696 if (hostname
&& !strcmp(hostname
, "*"))
1700 * Now lookup the address using httpAddrGetList()...
1703 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1704 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1705 hostname
? hostname
: "(nil)");
1712 * 'get_addr_and_mask()' - Get an IP address and netmask.
1715 static int /* O - 1 on success, 0 on failure */
1716 get_addr_and_mask(const char *value
, /* I - String from config file */
1717 unsigned *ip
, /* O - Address value */
1718 unsigned *mask
) /* O - Mask value */
1720 int i
, j
, /* Looping vars */
1721 family
, /* Address family */
1722 ipcount
; /* Count of fields in address */
1723 unsigned ipval
; /* Value */
1724 const char *maskval
, /* Pointer to start of mask value */
1725 *ptr
, /* Pointer into value */
1730 * Get the address...
1733 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1734 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1736 if ((maskval
= strchr(value
, '/')) != NULL
)
1739 maskval
= value
+ strlen(value
);
1743 * Check for an IPv6 address...
1749 * Parse hexadecimal IPv6/IPv4 address...
1754 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1758 else if (!strncmp(ptr
, "::", 2))
1760 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1762 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1767 else if (isdigit(*ptr
& 255) && strchr(ptr
+ 1, '.') && i
>= 6)
1770 * Read IPv4 dotted quad...
1773 unsigned val
[4] = { 0, 0, 0, 0 };
1774 /* IPv4 address values */
1776 ipcount
= sscanf(ptr
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2,
1780 * Range check the IP numbers...
1783 for (i
= 0; i
< ipcount
; i
++)
1788 * Merge everything into a 32-bit IPv4 address in ip[3]...
1791 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1794 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1797 * If the leading words are all 0's then this is an IPv4 address...
1800 if (!val
[0] && !val
[1] && !val
[2])
1803 while (isdigit(*ptr
& 255) || *ptr
== '.')
1807 else if (isxdigit(*ptr
& 255))
1809 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1811 if (*ptr
== ':' && ptr
[1] != ':')
1820 ip
[i
/ 2] |= ipval
<< 16;
1831 if (*ptr
&& *ptr
!= '/')
1835 #endif /* AF_INET6 */
1838 * Parse dotted-decimal IPv4 address...
1841 unsigned val
[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
1845 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1848 * Range check the IP numbers...
1851 for (i
= 0; i
< ipcount
; i
++)
1856 * Merge everything into a 32-bit IPv4 address in ip[3]...
1859 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1862 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1868 * Get the netmask value(s)...
1871 memset(mask
, 0, sizeof(unsigned) * 4);
1873 if (strchr(maskval
, '.'))
1876 * Get dotted-decimal mask...
1879 if (family
!= AF_INET
)
1882 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2,
1886 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1887 mask
[0] = mask
[1] = mask
[2] = 0;
1892 * Get address/bits format...
1898 if (family
== AF_INET6
)
1906 mask
[0] = 0xffffffff;
1908 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1911 mask
[1] = 0xffffffff;
1915 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1918 mask
[2] = 0xffffffff;
1922 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1925 mask
[3] = 0xffffffff;
1929 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1932 #endif /* AF_INET6 */
1937 mask
[0] = 0xffffffff;
1938 mask
[1] = 0xffffffff;
1939 mask
[2] = 0xffffffff;
1942 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1944 mask
[3] = 0xffffffff;
1949 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1950 "get_addr_and_mask(value=\"%s\", "
1951 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1952 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1956 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1959 if ((ip
[0] & ~mask
[0]) != 0 ||
1960 (ip
[1] & ~mask
[1]) != 0 ||
1961 (ip
[2] & ~mask
[2]) != 0 ||
1962 (ip
[3] & ~mask
[3]) != 0)
1970 * 'mime_error_cb()' - Log a MIME error.
1974 mime_error_cb(void *ctx
, /* I - Context pointer (unused) */
1975 const char *message
) /* I - Message */
1979 cupsdLogMessage(CUPSD_LOG_ERROR
, "%s", message
);
1984 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1987 static int /* O - 1 on success, 0 on failure */
1988 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1989 char *line
, /* I - Line from file */
1990 char *value
, /* I - Start of value data */
1991 int linenum
) /* I - Current line number */
1993 char *valptr
; /* Pointer into value */
1994 unsigned ip
[4], /* IP address components */
1995 mask
[4]; /* IP netmask components */
1998 if (!_cups_strcasecmp(line
, "Encryption"))
2001 * "Encryption xxx" - set required encryption level...
2004 if (!_cups_strcasecmp(value
, "never"))
2005 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
2006 else if (!_cups_strcasecmp(value
, "always"))
2008 cupsdLogMessage(CUPSD_LOG_ERROR
,
2009 "Encryption value \"%s\" on line %d is invalid in this "
2010 "context. Using \"required\" instead.", value
, linenum
);
2012 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2014 else if (!_cups_strcasecmp(value
, "required"))
2015 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2016 else if (!_cups_strcasecmp(value
, "ifrequested"))
2017 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
2020 cupsdLogMessage(CUPSD_LOG_ERROR
,
2021 "Unknown Encryption value %s on line %d.", value
, linenum
);
2025 else if (!_cups_strcasecmp(line
, "Order"))
2028 * "Order Deny,Allow" or "Order Allow,Deny"...
2031 if (!_cups_strncasecmp(value
, "deny", 4))
2032 loc
->order_type
= CUPSD_AUTH_ALLOW
;
2033 else if (!_cups_strncasecmp(value
, "allow", 5))
2034 loc
->order_type
= CUPSD_AUTH_DENY
;
2037 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
2042 else if (!_cups_strcasecmp(line
, "Allow") || !_cups_strcasecmp(line
, "Deny"))
2045 * Allow [From] host/ip...
2046 * Deny [From] host/ip...
2051 if (!_cups_strncasecmp(value
, "from", 4))
2054 * Strip leading "from"...
2059 while (_cups_isspace(*value
))
2067 * Find the end of the value...
2070 for (valptr
= value
; *valptr
&& !_cups_isspace(*valptr
); valptr
++);
2072 while (_cups_isspace(*valptr
))
2076 * Figure out what form the allow/deny address takes:
2087 * nnn.nnn.nnn.nnn/mm
2088 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2091 if (!_cups_strcasecmp(value
, "all"))
2097 if (!_cups_strcasecmp(line
, "Allow"))
2098 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
2100 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
2102 else if (!_cups_strcasecmp(value
, "none"))
2108 if (!_cups_strcasecmp(line
, "Allow"))
2109 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
2111 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
2114 else if (value
[0] == '*' || value
[0] == '.' ||
2115 (!isdigit(value
[0] & 255) && value
[0] != '['))
2117 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2118 #endif /* AF_INET6 */
2121 * Host or domain name...
2124 if (value
[0] == '*')
2127 if (!_cups_strcasecmp(line
, "Allow"))
2128 cupsdAddNameMask(&(loc
->allow
), value
);
2130 cupsdAddNameMask(&(loc
->deny
), value
);
2135 * One of many IP address forms...
2138 if (!get_addr_and_mask(value
, ip
, mask
))
2140 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2145 if (!_cups_strcasecmp(line
, "Allow"))
2146 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
2148 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
2152 * Advance to next value...
2158 else if (!_cups_strcasecmp(line
, "AuthType"))
2161 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2164 if (!_cups_strcasecmp(value
, "none"))
2166 loc
->type
= CUPSD_AUTH_NONE
;
2167 loc
->level
= CUPSD_AUTH_ANON
;
2169 else if (!_cups_strcasecmp(value
, "basic"))
2171 loc
->type
= CUPSD_AUTH_BASIC
;
2173 if (loc
->level
== CUPSD_AUTH_ANON
)
2174 loc
->level
= CUPSD_AUTH_USER
;
2176 else if (!_cups_strcasecmp(value
, "digest"))
2178 loc
->type
= CUPSD_AUTH_DIGEST
;
2180 if (loc
->level
== CUPSD_AUTH_ANON
)
2181 loc
->level
= CUPSD_AUTH_USER
;
2183 else if (!_cups_strcasecmp(value
, "basicdigest"))
2185 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2187 if (loc
->level
== CUPSD_AUTH_ANON
)
2188 loc
->level
= CUPSD_AUTH_USER
;
2190 else if (!_cups_strcasecmp(value
, "default"))
2192 loc
->type
= CUPSD_AUTH_DEFAULT
;
2194 if (loc
->level
== CUPSD_AUTH_ANON
)
2195 loc
->level
= CUPSD_AUTH_USER
;
2198 else if (!_cups_strcasecmp(value
, "negotiate"))
2200 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2202 if (loc
->level
== CUPSD_AUTH_ANON
)
2203 loc
->level
= CUPSD_AUTH_USER
;
2205 #endif /* HAVE_GSSAPI */
2208 cupsdLogMessage(CUPSD_LOG_WARN
,
2209 "Unknown authorization type %s on line %d.",
2214 else if (!_cups_strcasecmp(line
, "AuthClass"))
2217 * AuthClass anonymous, user, system, group
2220 if (!_cups_strcasecmp(value
, "anonymous"))
2222 loc
->type
= CUPSD_AUTH_NONE
;
2223 loc
->level
= CUPSD_AUTH_ANON
;
2225 cupsdLogMessage(CUPSD_LOG_WARN
,
2226 "\"AuthClass %s\" is deprecated; consider removing "
2230 else if (!_cups_strcasecmp(value
, "user"))
2232 loc
->level
= CUPSD_AUTH_USER
;
2234 cupsdLogMessage(CUPSD_LOG_WARN
,
2235 "\"AuthClass %s\" is deprecated; consider using "
2236 "\"Require valid-user\" on line %d.",
2239 else if (!_cups_strcasecmp(value
, "group"))
2241 loc
->level
= CUPSD_AUTH_GROUP
;
2243 cupsdLogMessage(CUPSD_LOG_WARN
,
2244 "\"AuthClass %s\" is deprecated; consider using "
2245 "\"Require user @groupname\" on line %d.",
2248 else if (!_cups_strcasecmp(value
, "system"))
2250 loc
->level
= CUPSD_AUTH_GROUP
;
2252 cupsdAddName(loc
, "@SYSTEM");
2254 cupsdLogMessage(CUPSD_LOG_WARN
,
2255 "\"AuthClass %s\" is deprecated; consider using "
2256 "\"Require user @SYSTEM\" on line %d.",
2261 cupsdLogMessage(CUPSD_LOG_WARN
,
2262 "Unknown authorization class %s on line %d.",
2267 else if (!_cups_strcasecmp(line
, "AuthGroupName"))
2269 cupsdAddName(loc
, value
);
2271 cupsdLogMessage(CUPSD_LOG_WARN
,
2272 "\"AuthGroupName %s\" directive is deprecated; consider "
2273 "using \"Require user @%s\" on line %d.",
2274 value
, value
, linenum
);
2276 else if (!_cups_strcasecmp(line
, "Require"))
2279 * Apache synonym for AuthClass and AuthGroupName...
2283 * Require valid-user
2284 * Require group names
2285 * Require user names
2288 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2293 if (!_cups_strcasecmp(value
, "valid-user") ||
2294 !_cups_strcasecmp(value
, "user"))
2295 loc
->level
= CUPSD_AUTH_USER
;
2296 else if (!_cups_strcasecmp(value
, "group"))
2297 loc
->level
= CUPSD_AUTH_GROUP
;
2300 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2306 * Get the list of names from the line...
2309 for (value
= valptr
; *value
;)
2311 while (_cups_isspace(*value
))
2314 #ifdef HAVE_AUTHORIZATION_H
2315 if (!strncmp(value
, "@AUTHKEY(", 9))
2318 * Grab "@AUTHKEY(name)" value...
2321 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2327 #endif /* HAVE_AUTHORIZATION_H */
2328 if (*value
== '\"' || *value
== '\'')
2331 * Grab quoted name...
2334 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2341 * Grab literal name.
2344 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2350 cupsdAddName(loc
, value
);
2352 for (value
= valptr
; _cups_isspace(*value
); value
++);
2355 else if (!_cups_strcasecmp(line
, "Satisfy"))
2357 if (!_cups_strcasecmp(value
, "all"))
2358 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2359 else if (!_cups_strcasecmp(value
, "any"))
2360 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2363 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2376 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2379 static int /* O - FatalErrors bits */
2380 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2382 int fatal
; /* FatalErrors bits */
2383 char value
[1024], /* Value string */
2384 *valstart
, /* Pointer into value */
2385 *valend
; /* End of value */
2389 * Empty FatalErrors line yields NULL pointer...
2393 return (CUPSD_FATAL_NONE
);
2396 * Loop through the value string,...
2399 strlcpy(value
, s
, sizeof(value
));
2401 fatal
= CUPSD_FATAL_NONE
;
2403 for (valstart
= value
; *valstart
;)
2406 * Get the current space/comma-delimited kind name...
2409 for (valend
= valstart
; *valend
; valend
++)
2410 if (_cups_isspace(*valend
) || *valend
== ',')
2417 * Add the error to the bitmask...
2420 if (!_cups_strcasecmp(valstart
, "all"))
2421 fatal
= CUPSD_FATAL_ALL
;
2422 else if (!_cups_strcasecmp(valstart
, "browse"))
2423 fatal
|= CUPSD_FATAL_BROWSE
;
2424 else if (!_cups_strcasecmp(valstart
, "-browse"))
2425 fatal
&= ~CUPSD_FATAL_BROWSE
;
2426 else if (!_cups_strcasecmp(valstart
, "config"))
2427 fatal
|= CUPSD_FATAL_CONFIG
;
2428 else if (!_cups_strcasecmp(valstart
, "-config"))
2429 fatal
&= ~CUPSD_FATAL_CONFIG
;
2430 else if (!_cups_strcasecmp(valstart
, "listen"))
2431 fatal
|= CUPSD_FATAL_LISTEN
;
2432 else if (!_cups_strcasecmp(valstart
, "-listen"))
2433 fatal
&= ~CUPSD_FATAL_LISTEN
;
2434 else if (!_cups_strcasecmp(valstart
, "log"))
2435 fatal
|= CUPSD_FATAL_LOG
;
2436 else if (!_cups_strcasecmp(valstart
, "-log"))
2437 fatal
&= ~CUPSD_FATAL_LOG
;
2438 else if (!_cups_strcasecmp(valstart
, "permissions"))
2439 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2440 else if (!_cups_strcasecmp(valstart
, "-permissions"))
2441 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2442 else if (_cups_strcasecmp(valstart
, "none"))
2443 cupsdLogMessage(CUPSD_LOG_ERROR
,
2444 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2446 for (valstart
= valend
; *valstart
; valstart
++)
2447 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2456 * 'parse_groups()' - Parse system group names in a string.
2459 static int /* O - 1 on success, 0 on failure */
2460 parse_groups(const char *s
) /* I - Space-delimited groups */
2462 int status
; /* Return status */
2463 char value
[1024], /* Value string */
2464 *valstart
, /* Pointer into value */
2465 *valend
, /* End of value */
2466 quote
; /* Quote character */
2467 struct group
*group
; /* Group */
2471 * Make a copy of the string and parse out the groups...
2474 strlcpy(value
, s
, sizeof(value
));
2479 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2481 if (*valstart
== '\'' || *valstart
== '\"')
2484 * Scan quoted name...
2487 quote
= *valstart
++;
2489 for (valend
= valstart
; *valend
; valend
++)
2490 if (*valend
== quote
)
2496 * Scan space or comma-delimited name...
2499 for (valend
= valstart
; *valend
; valend
++)
2500 if (_cups_isspace(*valend
) || *valend
== ',')
2507 group
= getgrnam(valstart
);
2510 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2511 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2522 while (*valstart
== ',' || _cups_isspace(*valstart
))
2531 * 'parse_protocols()' - Parse browse protocols in a string.
2534 static int /* O - Browse protocol bits */
2535 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2537 int protocols
; /* Browse protocol bits */
2538 char value
[1024], /* Value string */
2539 *valstart
, /* Pointer into value */
2540 *valend
; /* End of value */
2544 * Empty protocol line yields NULL pointer...
2551 * Loop through the value string,...
2554 strlcpy(value
, s
, sizeof(value
));
2558 for (valstart
= value
; *valstart
;)
2561 * Get the current space/comma-delimited protocol name...
2564 for (valend
= valstart
; *valend
; valend
++)
2565 if (_cups_isspace(*valend
) || *valend
== ',')
2572 * Add the protocol to the bitmask...
2575 if (!_cups_strcasecmp(valstart
, "dnssd") ||
2576 !_cups_strcasecmp(valstart
, "dns-sd") ||
2577 !_cups_strcasecmp(valstart
, "bonjour"))
2578 protocols
|= BROWSE_DNSSD
;
2579 else if (!_cups_strcasecmp(valstart
, "all"))
2580 protocols
|= BROWSE_ALL
;
2581 else if (_cups_strcasecmp(valstart
, "none"))
2582 cupsdLogMessage(CUPSD_LOG_ERROR
,
2583 "Unknown browse protocol \"%s\" ignored.", valstart
);
2585 for (valstart
= valend
; *valstart
; valstart
++)
2586 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2595 * 'parse_variable()' - Parse a variable line.
2598 static int /* O - 1 on success, 0 on failure */
2600 const char *filename
, /* I - Name of configuration file */
2601 int linenum
, /* I - Line in configuration file */
2602 const char *line
, /* I - Line from configuration file */
2603 const char *value
, /* I - Value from configuration file */
2604 size_t num_vars
, /* I - Number of variables */
2605 const cupsd_var_t
*vars
) /* I - Variables */
2607 size_t i
; /* Looping var */
2608 const cupsd_var_t
*var
; /* Variables */
2609 char temp
[1024]; /* Temporary string */
2612 for (i
= num_vars
, var
= vars
; i
> 0; i
--, var
++)
2613 if (!_cups_strcasecmp(line
, var
->name
))
2619 * Unknown directive! Output an error message and continue...
2623 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d of %s.",
2624 line
, linenum
, filename
);
2626 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d of %s.",
2627 line
, linenum
, filename
);
2634 case CUPSD_VARTYPE_INTEGER
:
2637 cupsdLogMessage(CUPSD_LOG_ERROR
,
2638 "Missing integer value for %s on line %d of %s.",
2639 line
, linenum
, filename
);
2642 else if (!isdigit(*value
& 255))
2644 cupsdLogMessage(CUPSD_LOG_ERROR
,
2645 "Bad integer value for %s on line %d of %s.",
2646 line
, linenum
, filename
);
2652 char *units
; /* Units */
2654 n
= strtol(value
, &units
, 0);
2656 if (units
&& *units
)
2658 if (tolower(units
[0] & 255) == 'g')
2659 n
*= 1024 * 1024 * 1024;
2660 else if (tolower(units
[0] & 255) == 'm')
2662 else if (tolower(units
[0] & 255) == 'k')
2664 else if (tolower(units
[0] & 255) == 't')
2668 cupsdLogMessage(CUPSD_LOG_ERROR
,
2669 "Unknown integer value for %s on line %d of %s.",
2670 line
, linenum
, filename
);
2677 cupsdLogMessage(CUPSD_LOG_ERROR
,
2678 "Bad negative integer value for %s on line %d of "
2679 "%s.", line
, linenum
, filename
);
2684 *((int *)var
->ptr
) = n
;
2689 case CUPSD_VARTYPE_TIME
:
2692 cupsdLogMessage(CUPSD_LOG_ERROR
,
2693 "Missing time interval value for %s on line %d of "
2694 "%s.", line
, linenum
, filename
);
2697 else if (!_cups_strncasecmp(line
, "PreserveJob", 11) &&
2698 (!_cups_strcasecmp(value
, "true") ||
2699 !_cups_strcasecmp(value
, "on") ||
2700 !_cups_strcasecmp(value
, "enabled") ||
2701 !_cups_strcasecmp(value
, "yes")))
2703 *((int *)var
->ptr
) = INT_MAX
;
2705 else if (!_cups_strcasecmp(value
, "false") ||
2706 !_cups_strcasecmp(value
, "off") ||
2707 !_cups_strcasecmp(value
, "disabled") ||
2708 !_cups_strcasecmp(value
, "no"))
2710 *((int *)var
->ptr
) = 0;
2712 else if (!isdigit(*value
& 255))
2714 cupsdLogMessage(CUPSD_LOG_ERROR
,
2715 "Unknown time interval value for %s on line %d of "
2716 "%s.", line
, linenum
, filename
);
2721 double n
; /* Number */
2722 char *units
; /* Units */
2724 n
= strtod(value
, &units
);
2726 if (units
&& *units
)
2728 if (tolower(units
[0] & 255) == 'w')
2729 n
*= 7 * 24 * 60 * 60;
2730 else if (tolower(units
[0] & 255) == 'd')
2732 else if (tolower(units
[0] & 255) == 'h')
2734 else if (tolower(units
[0] & 255) == 'm')
2738 cupsdLogMessage(CUPSD_LOG_ERROR
,
2739 "Unknown time interval value for %s on line "
2740 "%d of %s.", line
, linenum
, filename
);
2745 if (n
< 0.0 || n
> INT_MAX
)
2747 cupsdLogMessage(CUPSD_LOG_ERROR
,
2748 "Bad time value for %s on line %d of %s.",
2749 line
, linenum
, filename
);
2754 *((int *)var
->ptr
) = (int)n
;
2759 case CUPSD_VARTYPE_BOOLEAN
:
2762 cupsdLogMessage(CUPSD_LOG_ERROR
,
2763 "Missing boolean value for %s on line %d of %s.",
2764 line
, linenum
, filename
);
2767 else if (!_cups_strcasecmp(value
, "true") ||
2768 !_cups_strcasecmp(value
, "on") ||
2769 !_cups_strcasecmp(value
, "enabled") ||
2770 !_cups_strcasecmp(value
, "yes") ||
2773 *((int *)var
->ptr
) = TRUE
;
2775 else if (!_cups_strcasecmp(value
, "false") ||
2776 !_cups_strcasecmp(value
, "off") ||
2777 !_cups_strcasecmp(value
, "disabled") ||
2778 !_cups_strcasecmp(value
, "no") ||
2779 !_cups_strcasecmp(value
, "0"))
2781 *((int *)var
->ptr
) = FALSE
;
2785 cupsdLogMessage(CUPSD_LOG_ERROR
,
2786 "Unknown boolean value %s on line %d of %s.",
2787 value
, linenum
, filename
);
2792 case CUPSD_VARTYPE_PATHNAME
:
2795 cupsdLogMessage(CUPSD_LOG_ERROR
,
2796 "Missing pathname value for %s on line %d of %s.",
2797 line
, linenum
, filename
);
2801 if (value
[0] == '/')
2802 strlcpy(temp
, value
, sizeof(temp
));
2804 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
2806 if (access(temp
, 0))
2808 cupsdLogMessage(CUPSD_LOG_ERROR
,
2809 "File or directory for \"%s %s\" on line %d of %s "
2810 "does not exist.", line
, value
, linenum
, filename
);
2814 cupsdSetString((char **)var
->ptr
, temp
);
2817 case CUPSD_VARTYPE_STRING
:
2818 cupsdSetString((char **)var
->ptr
, value
);
2827 * 'read_cupsd_conf()' - Read the cupsd.conf configuration file.
2830 static int /* O - 1 on success, 0 on failure */
2831 read_cupsd_conf(cups_file_t
*fp
) /* I - File to read from */
2833 int linenum
; /* Current line number */
2834 char line
[HTTP_MAX_BUFFER
],
2835 /* Line from file */
2836 temp
[HTTP_MAX_BUFFER
],
2837 /* Temporary buffer for value */
2838 *value
, /* Pointer to value */
2839 *valueptr
; /* Pointer into value */
2840 int valuelen
; /* Length of value */
2841 http_addrlist_t
*addrlist
, /* Address list */
2842 *addr
; /* Current address */
2843 cups_file_t
*incfile
; /* Include file */
2844 char incname
[1024]; /* Include filename */
2848 * Loop through each line in the file...
2853 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2856 * Decode the directive...
2859 if (!_cups_strcasecmp(line
, "Include") && value
)
2865 if (value
[0] == '/')
2866 strlcpy(incname
, value
, sizeof(incname
));
2868 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2870 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2871 cupsdLogMessage(CUPSD_LOG_ERROR
,
2872 "Unable to include config file \"%s\" - %s",
2873 incname
, strerror(errno
));
2876 read_cupsd_conf(incfile
);
2877 cupsFileClose(incfile
);
2880 else if (!_cups_strcasecmp(line
, "<Location") && value
)
2886 linenum
= read_location(fp
, value
, linenum
);
2890 else if (!_cups_strcasecmp(line
, "<Policy") && value
)
2896 linenum
= read_policy(fp
, value
, linenum
);
2900 else if (!_cups_strcasecmp(line
, "FaxRetryInterval") && value
)
2902 JobRetryInterval
= atoi(value
);
2903 cupsdLogMessage(CUPSD_LOG_WARN
,
2904 "FaxRetryInterval is deprecated; use "
2905 "JobRetryInterval on line %d.", linenum
);
2907 else if (!_cups_strcasecmp(line
, "FaxRetryLimit") && value
)
2909 JobRetryLimit
= atoi(value
);
2910 cupsdLogMessage(CUPSD_LOG_WARN
,
2911 "FaxRetryLimit is deprecated; use "
2912 "JobRetryLimit on line %d.", linenum
);
2914 else if ((!_cups_strcasecmp(line
, "Port") || !_cups_strcasecmp(line
, "Listen")
2916 || !_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen")
2917 #endif /* HAVE_SSL */
2921 * Add listening address(es) to the list...
2924 cupsd_listener_t
*lis
; /* New listeners array */
2928 * Get the address list...
2931 addrlist
= get_address(value
, IPP_PORT
);
2935 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2941 * Add each address...
2944 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2947 * See if this address is already present...
2950 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2952 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2953 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2954 httpAddrPort(&(addr
->addr
)) == httpAddrPort(&(lis
->address
)))
2959 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2960 cupsdLogMessage(CUPSD_LOG_WARN
,
2961 "Duplicate listen address \"%s\" ignored.", temp
);
2966 * Allocate another listener...
2970 Listeners
= cupsArrayNew(NULL
, NULL
);
2974 cupsdLogMessage(CUPSD_LOG_ERROR
,
2975 "Unable to allocate %s at line %d - %s.",
2976 line
, linenum
, strerror(errno
));
2980 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2982 cupsdLogMessage(CUPSD_LOG_ERROR
,
2983 "Unable to allocate %s at line %d - %s.",
2984 line
, linenum
, strerror(errno
));
2988 cupsArrayAdd(Listeners
, lis
);
2991 * Copy the current address and log it...
2994 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2998 if (!_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen"))
2999 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
3000 #endif /* HAVE_SSL */
3002 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
3005 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
3006 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
3008 #endif /* AF_LOCAL */
3009 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
3010 httpAddrPort(&(lis
->address
)),
3011 _httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
3013 if (!httpAddrLocalhost(&(lis
->address
)))
3014 RemotePort
= httpAddrPort(&(lis
->address
));
3021 httpAddrFreeList(addrlist
);
3023 else if (!_cups_strcasecmp(line
, "BrowseProtocols") ||
3024 !_cups_strcasecmp(line
, "BrowseLocalProtocols"))
3027 * "BrowseProtocols name [... name]"
3028 * "BrowseLocalProtocols name [... name]"
3031 int protocols
= parse_protocols(value
);
3035 cupsdLogMessage(CUPSD_LOG_ERROR
,
3036 "Unknown browse protocol \"%s\" on line %d.",
3041 BrowseLocalProtocols
= protocols
;
3043 else if (!_cups_strcasecmp(line
, "DefaultAuthType") && value
)
3046 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3049 if (!_cups_strcasecmp(value
, "none"))
3050 default_auth_type
= CUPSD_AUTH_NONE
;
3051 else if (!_cups_strcasecmp(value
, "basic"))
3052 default_auth_type
= CUPSD_AUTH_BASIC
;
3053 else if (!_cups_strcasecmp(value
, "digest"))
3054 default_auth_type
= CUPSD_AUTH_DIGEST
;
3055 else if (!_cups_strcasecmp(value
, "basicdigest"))
3056 default_auth_type
= CUPSD_AUTH_BASICDIGEST
;
3058 else if (!_cups_strcasecmp(value
, "negotiate"))
3059 default_auth_type
= CUPSD_AUTH_NEGOTIATE
;
3060 #endif /* HAVE_GSSAPI */
3061 else if (!_cups_strcasecmp(value
, "auto"))
3062 default_auth_type
= CUPSD_AUTH_AUTO
;
3065 cupsdLogMessage(CUPSD_LOG_WARN
,
3066 "Unknown default authorization type %s on line %d.",
3068 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3073 else if (!_cups_strcasecmp(line
, "DefaultEncryption"))
3076 * DefaultEncryption {Never,IfRequested,Required}
3079 if (!value
|| !_cups_strcasecmp(value
, "never"))
3080 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3081 else if (!_cups_strcasecmp(value
, "required"))
3082 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3083 else if (!_cups_strcasecmp(value
, "ifrequested"))
3084 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3087 cupsdLogMessage(CUPSD_LOG_WARN
,
3088 "Unknown default encryption %s on line %d.",
3090 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3094 #endif /* HAVE_SSL */
3095 else if (!_cups_strcasecmp(line
, "HostNameLookups") && value
)
3098 * Do hostname lookups?
3101 if (!_cups_strcasecmp(value
, "off") || !_cups_strcasecmp(value
, "no") ||
3102 !_cups_strcasecmp(value
, "false"))
3103 HostNameLookups
= 0;
3104 else if (!_cups_strcasecmp(value
, "on") || !_cups_strcasecmp(value
, "yes") ||
3105 !_cups_strcasecmp(value
, "true"))
3106 HostNameLookups
= 1;
3107 else if (!_cups_strcasecmp(value
, "double"))
3108 HostNameLookups
= 2;
3110 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3113 else if (!_cups_strcasecmp(line
, "AccessLogLevel") && value
)
3116 * Amount of logging to do to access log...
3119 if (!_cups_strcasecmp(value
, "all"))
3120 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3121 else if (!_cups_strcasecmp(value
, "actions"))
3122 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3123 else if (!_cups_strcasecmp(value
, "config"))
3124 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3126 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3129 else if (!_cups_strcasecmp(line
, "LogLevel") && value
)
3132 * Amount of logging to do to error log...
3135 if (!_cups_strcasecmp(value
, "debug2"))
3136 LogLevel
= CUPSD_LOG_DEBUG2
;
3137 else if (!_cups_strcasecmp(value
, "debug"))
3138 LogLevel
= CUPSD_LOG_DEBUG
;
3139 else if (!_cups_strcasecmp(value
, "info"))
3140 LogLevel
= CUPSD_LOG_INFO
;
3141 else if (!_cups_strcasecmp(value
, "notice"))
3142 LogLevel
= CUPSD_LOG_NOTICE
;
3143 else if (!_cups_strcasecmp(value
, "warn"))
3144 LogLevel
= CUPSD_LOG_WARN
;
3145 else if (!_cups_strcasecmp(value
, "error"))
3146 LogLevel
= CUPSD_LOG_ERROR
;
3147 else if (!_cups_strcasecmp(value
, "crit"))
3148 LogLevel
= CUPSD_LOG_CRIT
;
3149 else if (!_cups_strcasecmp(value
, "alert"))
3150 LogLevel
= CUPSD_LOG_ALERT
;
3151 else if (!_cups_strcasecmp(value
, "emerg"))
3152 LogLevel
= CUPSD_LOG_EMERG
;
3153 else if (!_cups_strcasecmp(value
, "none"))
3154 LogLevel
= CUPSD_LOG_NONE
;
3156 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3159 else if (!_cups_strcasecmp(line
, "LogTimeFormat") && value
)
3162 * Amount of logging to do to error log...
3165 if (!_cups_strcasecmp(value
, "standard"))
3166 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3167 else if (!_cups_strcasecmp(value
, "usecs"))
3168 LogTimeFormat
= CUPSD_TIME_USECS
;
3170 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3173 else if (!_cups_strcasecmp(line
, "ServerTokens") && value
)
3176 * Set the string used for the Server header...
3179 struct utsname plat
; /* Platform info */
3184 if (!_cups_strcasecmp(value
, "ProductOnly"))
3185 cupsdSetString(&ServerHeader
, "CUPS IPP");
3186 else if (!_cups_strcasecmp(value
, "Major"))
3187 cupsdSetStringf(&ServerHeader
, "CUPS/%d IPP/2", CUPS_VERSION_MAJOR
);
3188 else if (!_cups_strcasecmp(value
, "Minor"))
3189 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
3190 CUPS_VERSION_MINOR
);
3191 else if (!_cups_strcasecmp(value
, "Minimal"))
3192 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
" IPP/2.1");
3193 else if (!_cups_strcasecmp(value
, "OS"))
3194 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s) IPP/2.1",
3195 plat
.sysname
, plat
.release
);
3196 else if (!_cups_strcasecmp(value
, "Full"))
3197 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s; %s) IPP/2.1",
3198 plat
.sysname
, plat
.release
, plat
.machine
);
3199 else if (!_cups_strcasecmp(value
, "None"))
3200 cupsdClearString(&ServerHeader
);
3202 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3205 else if (!_cups_strcasecmp(line
, "PassEnv") && value
)
3208 * PassEnv variable [... variable]
3213 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3214 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3217 if (value
[valuelen
])
3219 value
[valuelen
] = '\0';
3223 cupsdSetEnv(value
, NULL
);
3225 for (value
+= valuelen
; *value
; value
++)
3226 if (!_cups_isspace(*value
) || *value
!= ',')
3230 else if (!_cups_strcasecmp(line
, "ServerAlias") && value
)
3233 * ServerAlias name [... name]
3237 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3241 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3242 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3245 if (value
[valuelen
])
3247 value
[valuelen
] = '\0';
3251 cupsdAddAlias(ServerAlias
, value
);
3253 for (value
+= valuelen
; *value
; value
++)
3254 if (!_cups_isspace(*value
) || *value
!= ',')
3258 else if (!_cups_strcasecmp(line
, "SetEnv") && value
)
3261 * SetEnv variable value
3264 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3272 while (isspace(*valueptr
& 255))
3275 cupsdSetEnv(value
, valueptr
);
3278 cupsdLogMessage(CUPSD_LOG_ERROR
,
3279 "Missing value for SetEnv directive on line %d.",
3283 else if (!_cups_strcasecmp(line
, "SSLOptions"))
3286 * SSLOptions options
3289 if (!value
|| !_cups_strcasecmp(value
, "none"))
3290 SSLOptions
= CUPSD_SSL_NONE
;
3291 else if (!_cups_strcasecmp(value
, "noemptyfragments"))
3292 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3294 cupsdLogMessage(CUPSD_LOG_ERROR
,
3295 "Unknown value \"%s\" for SSLOptions directive on "
3296 "line %d.", value
, linenum
);
3298 #endif /* HAVE_SSL */
3300 parse_variable(ConfigurationFile
, linenum
, line
, value
,
3301 sizeof(cupsd_vars
) / sizeof(cupsd_vars
[0]), cupsd_vars
);
3309 * 'read_cups_files_conf()' - Read the cups-files.conf configuration file.
3312 static int /* O - 1 on success, 0 on failure */
3313 read_cups_files_conf(cups_file_t
*fp
) /* I - File to read from */
3315 int linenum
; /* Current line number */
3316 char line
[HTTP_MAX_BUFFER
], /* Line from file */
3317 *value
; /* Value from line */
3318 struct group
*group
; /* Group */
3322 * Loop through each line in the file...
3327 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3329 if (!_cups_strcasecmp(line
, "FatalErrors"))
3330 FatalErrors
= parse_fatal_errors(value
);
3331 else if (!_cups_strcasecmp(line
, "Group") && value
)
3334 * Group ID to run as...
3337 if (isdigit(value
[0]))
3338 Group
= atoi(value
);
3342 group
= getgrnam(value
);
3345 Group
= group
->gr_gid
;
3348 cupsdLogMessage(CUPSD_LOG_ERROR
,
3349 "Unknown Group \"%s\" on line %d of %s.", value
,
3350 linenum
, CupsFilesFile
);
3351 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3356 else if (!_cups_strcasecmp(line
, "PrintcapFormat") && value
)
3359 * Format of printcap file?
3362 if (!_cups_strcasecmp(value
, "bsd"))
3363 PrintcapFormat
= PRINTCAP_BSD
;
3364 else if (!_cups_strcasecmp(value
, "plist"))
3365 PrintcapFormat
= PRINTCAP_PLIST
;
3366 else if (!_cups_strcasecmp(value
, "solaris"))
3367 PrintcapFormat
= PRINTCAP_SOLARIS
;
3370 cupsdLogMessage(CUPSD_LOG_ERROR
,
3371 "Unknown PrintcapFormat \"%s\" on line %d of %s.",
3372 value
, linenum
, CupsFilesFile
);
3373 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3377 else if (!_cups_strcasecmp(line
, "SystemGroup") && value
)
3380 * SystemGroup (admin) group(s)...
3383 if (!parse_groups(value
))
3385 cupsdLogMessage(CUPSD_LOG_ERROR
,
3386 "Unknown SystemGroup \"%s\" on line %d of %s.", value
,
3387 linenum
, CupsFilesFile
);
3388 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3392 else if (!_cups_strcasecmp(line
, "User") && value
)
3395 * User ID to run as...
3398 if (isdigit(value
[0] & 255))
3400 int uid
= atoi(value
);
3404 cupsdLogMessage(CUPSD_LOG_ERROR
,
3405 "Will not use User 0 as specified on line %d of %s "
3406 "for security reasons. You must use a non-"
3407 "privileged account instead.",
3408 linenum
, CupsFilesFile
);
3409 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3417 struct passwd
*p
; /* Password information */
3420 p
= getpwnam(value
);
3426 cupsdLogMessage(CUPSD_LOG_ERROR
,
3427 "Will not use User %s (UID=0) as specified on line "
3428 "%d of %s for security reasons. You must use a "
3429 "non-privileged account instead.",
3430 value
, linenum
, CupsFilesFile
);
3431 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3439 cupsdLogMessage(CUPSD_LOG_ERROR
,
3440 "Unknown User \"%s\" on line %d of %s.",
3441 value
, linenum
, CupsFilesFile
);
3442 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3447 else if (!parse_variable(CupsFilesFile
, linenum
, line
, value
,
3448 sizeof(cupsfiles_vars
) / sizeof(cupsfiles_vars
[0]),
3450 (FatalErrors
& CUPSD_FATAL_CONFIG
))
3459 * 'read_location()' - Read a <Location path> definition.
3462 static int /* O - New line number or 0 on error */
3463 read_location(cups_file_t
*fp
, /* I - Configuration file */
3464 char *location
, /* I - Location name/path */
3465 int linenum
) /* I - Current line number */
3467 cupsd_location_t
*loc
, /* New location */
3468 *parent
; /* Parent location */
3469 char line
[HTTP_MAX_BUFFER
],
3471 *value
, /* Value for directive */
3472 *valptr
; /* Pointer into value */
3475 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3476 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3478 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3482 cupsdAddLocation(parent
);
3484 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3489 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3492 * Decode the directive...
3495 if (!_cups_strcasecmp(line
, "</Location>"))
3497 else if (!_cups_strcasecmp(line
, "<Limit") ||
3498 !_cups_strcasecmp(line
, "<LimitExcept"))
3502 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3503 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3509 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3512 cupsdAddLocation(loc
);
3517 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3522 if (!strcmp(value
, "ALL"))
3523 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3524 else if (!strcmp(value
, "GET"))
3525 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3526 else if (!strcmp(value
, "HEAD"))
3527 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3528 else if (!strcmp(value
, "OPTIONS"))
3529 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3530 else if (!strcmp(value
, "POST"))
3531 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3532 else if (!strcmp(value
, "PUT"))
3533 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3534 else if (!strcmp(value
, "TRACE"))
3535 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3537 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3540 for (value
= valptr
; isspace(*value
& 255); value
++);
3543 if (!_cups_strcasecmp(line
, "<LimitExcept"))
3544 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3546 parent
->limit
&= ~loc
->limit
;
3548 else if (!_cups_strcasecmp(line
, "</Limit>") ||
3549 !_cups_strcasecmp(line
, "</LimitExcept>"))
3553 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3554 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3557 else if (!parse_aaa(loc
, line
, value
, linenum
))
3559 cupsdLogMessage(CUPSD_LOG_ERROR
,
3560 "Unknown Location directive %s on line %d.",
3562 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3567 cupsdLogMessage(CUPSD_LOG_ERROR
,
3568 "Unexpected end-of-file at line %d while reading location.",
3571 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3576 * 'read_policy()' - Read a <Policy name> definition.
3579 static int /* O - New line number or 0 on error */
3580 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3581 char *policy
, /* I - Location name/path */
3582 int linenum
) /* I - Current line number */
3584 int i
; /* Looping var */
3585 cupsd_policy_t
*pol
; /* Policy */
3586 cupsd_location_t
*op
; /* Policy operation */
3587 int num_ops
; /* Number of IPP operations */
3588 ipp_op_t ops
[100]; /* Operations */
3589 char line
[HTTP_MAX_BUFFER
],
3591 *value
, /* Value for directive */
3592 *valptr
; /* Pointer into value */
3596 * Create the policy...
3599 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3600 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3602 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3606 * Read from the file...
3612 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3615 * Decode the directive...
3618 if (!_cups_strcasecmp(line
, "</Policy>"))
3621 cupsdLogMessage(CUPSD_LOG_WARN
,
3622 "Missing </Limit> before </Policy> on line %d.",
3625 set_policy_defaults(pol
);
3629 else if (!_cups_strcasecmp(line
, "<Limit") && !op
)
3633 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3634 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3641 * Scan for IPP operation names...
3648 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3653 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3655 if (!_cups_strcasecmp(value
, "All"))
3656 ops
[num_ops
] = IPP_ANY_OPERATION
;
3657 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3658 cupsdLogMessage(CUPSD_LOG_ERROR
,
3659 "Bad IPP operation name \"%s\" on line %d.",
3665 cupsdLogMessage(CUPSD_LOG_ERROR
,
3666 "Too many operations listed on line %d.",
3669 for (value
= valptr
; isspace(*value
& 255); value
++);
3673 * If none are specified, apply the policy to all operations...
3678 ops
[0] = IPP_ANY_OPERATION
;
3683 * Add a new policy for the first operation...
3686 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3688 else if (!_cups_strcasecmp(line
, "</Limit>") && op
)
3691 * Finish the current operation limit...
3697 * Copy the policy to the other operations...
3700 for (i
= 1; i
< num_ops
; i
++)
3701 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3708 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3709 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3712 else if (!_cups_strcasecmp(line
, "JobPrivateAccess") ||
3713 !_cups_strcasecmp(line
, "JobPrivateValues") ||
3714 !_cups_strcasecmp(line
, "SubscriptionPrivateAccess") ||
3715 !_cups_strcasecmp(line
, "SubscriptionPrivateValues"))
3719 cupsdLogMessage(CUPSD_LOG_ERROR
,
3720 "%s directive must appear outside <Limit>...</Limit> "
3721 "on line %d.", line
, linenum
);
3722 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3728 * Pull out whitespace-delimited values...
3734 * Find the end of the current value...
3737 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3743 * Save it appropriately...
3746 if (!_cups_strcasecmp(line
, "JobPrivateAccess"))
3749 * JobPrivateAccess {all|default|user/group list|@@ACL}
3752 if (!_cups_strcasecmp(value
, "default"))
3754 cupsdAddString(&(pol
->job_access
), "@OWNER");
3755 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3758 cupsdAddString(&(pol
->job_access
), value
);
3760 else if (!_cups_strcasecmp(line
, "JobPrivateValues"))
3763 * JobPrivateValues {all|none|default|attribute list}
3766 if (!_cups_strcasecmp(value
, "default"))
3768 cupsdAddString(&(pol
->job_attrs
), "job-name");
3769 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3770 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3771 cupsdAddString(&(pol
->job_attrs
), "phone");
3774 cupsdAddString(&(pol
->job_attrs
), value
);
3776 else if (!_cups_strcasecmp(line
, "SubscriptionPrivateAccess"))
3779 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3782 if (!_cups_strcasecmp(value
, "default"))
3784 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3785 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3788 cupsdAddString(&(pol
->sub_access
), value
);
3790 else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
3793 * SubscriptionPrivateValues {all|none|default|attribute list}
3796 if (!_cups_strcasecmp(value
, "default"))
3798 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3799 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3800 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3801 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3802 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3805 cupsdAddString(&(pol
->sub_attrs
), value
);
3809 * Find the next string on the line...
3812 for (value
= valptr
; isspace(*value
& 255); value
++);
3818 cupsdLogMessage(CUPSD_LOG_ERROR
,
3819 "Missing <Limit ops> directive before %s on line %d.",
3821 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3824 else if (!parse_aaa(op
, line
, value
, linenum
))
3826 cupsdLogMessage(CUPSD_LOG_ERROR
,
3827 "Unknown Policy Limit directive %s on line %d.",
3830 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3835 cupsdLogMessage(CUPSD_LOG_ERROR
,
3836 "Unexpected end-of-file at line %d while reading policy "
3837 "\"%s\".", linenum
, policy
);
3839 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3844 * 'set_policy_defaults()' - Set default policy values as needed.
3848 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3850 cupsd_location_t
*op
; /* Policy operation */
3854 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3855 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3856 * upgrades do not introduce new security issues...
3859 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3860 op
->op
== IPP_ANY_OPERATION
)
3862 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3863 op
->op
!= IPP_ANY_OPERATION
)
3866 * Add a new limit for Validate-Job using the Print-Job limit as a
3870 cupsdLogMessage(CUPSD_LOG_WARN
,
3871 "No limit for Validate-Job defined in policy %s "
3872 "- using Print-Job's policy.", pol
->name
);
3874 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3877 cupsdLogMessage(CUPSD_LOG_WARN
,
3878 "No limit for Validate-Job defined in policy %s "
3879 "and no suitable template found.", pol
->name
);
3882 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3883 op
->op
== IPP_ANY_OPERATION
)
3885 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3886 op
->op
!= IPP_ANY_OPERATION
)
3889 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3893 cupsdLogMessage(CUPSD_LOG_WARN
,
3894 "No limit for Cancel-Jobs defined in policy %s "
3895 "- using Pause-Printer's policy.", pol
->name
);
3897 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3900 cupsdLogMessage(CUPSD_LOG_WARN
,
3901 "No limit for Cancel-Jobs defined in policy %s "
3902 "and no suitable template found.", pol
->name
);
3905 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3906 op
->op
== IPP_ANY_OPERATION
)
3908 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3909 op
->op
!= IPP_ANY_OPERATION
)
3912 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
3916 cupsdLogMessage(CUPSD_LOG_WARN
,
3917 "No limit for Cancel-My-Jobs defined in policy %s "
3918 "- using Send-Document's policy.", pol
->name
);
3920 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
3923 cupsdLogMessage(CUPSD_LOG_WARN
,
3924 "No limit for Cancel-My-Jobs defined in policy %s "
3925 "and no suitable template found.", pol
->name
);
3928 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
3929 op
->op
== IPP_ANY_OPERATION
)
3931 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3932 op
->op
!= IPP_ANY_OPERATION
)
3935 * Add a new limit for Close-Job using the Send-Document limit as a
3939 cupsdLogMessage(CUPSD_LOG_WARN
,
3940 "No limit for Close-Job defined in policy %s "
3941 "- using Send-Document's policy.", pol
->name
);
3943 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
3946 cupsdLogMessage(CUPSD_LOG_WARN
,
3947 "No limit for Close-Job defined in policy %s "
3948 "and no suitable template found.", pol
->name
);
3951 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
3952 op
->op
== IPP_ANY_OPERATION
)
3954 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3955 op
->op
!= IPP_ANY_OPERATION
)
3958 * Add a new limit for CUPS-Get-Document using the Send-Document
3959 * limit as a template...
3962 cupsdLogMessage(CUPSD_LOG_WARN
,
3963 "No limit for CUPS-Get-Document defined in policy %s "
3964 "- using Send-Document's policy.", pol
->name
);
3966 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
3969 cupsdLogMessage(CUPSD_LOG_WARN
,
3970 "No limit for CUPS-Get-Document defined in policy %s "
3971 "and no suitable template found.", pol
->name
);
3975 * Verify we have JobPrivateAccess, JobPrivateValues,
3976 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
3979 if (!pol
->job_access
)
3981 cupsdLogMessage(CUPSD_LOG_WARN
,
3982 "No JobPrivateAccess defined in policy %s "
3983 "- using defaults.", pol
->name
);
3984 cupsdAddString(&(pol
->job_access
), "@OWNER");
3985 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3988 if (!pol
->job_attrs
)
3990 cupsdLogMessage(CUPSD_LOG_WARN
,
3991 "No JobPrivateValues defined in policy %s "
3992 "- using defaults.", pol
->name
);
3993 cupsdAddString(&(pol
->job_attrs
), "job-name");
3994 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3995 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3996 cupsdAddString(&(pol
->job_attrs
), "phone");
3999 if (!pol
->sub_access
)
4001 cupsdLogMessage(CUPSD_LOG_WARN
,
4002 "No SubscriptionPrivateAccess defined in policy %s "
4003 "- using defaults.", pol
->name
);
4004 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4005 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4008 if (!pol
->sub_attrs
)
4010 cupsdLogMessage(CUPSD_LOG_WARN
,
4011 "No SubscriptionPrivateValues defined in policy %s "
4012 "- using defaults.", pol
->name
);
4013 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4014 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4015 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4016 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4017 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4023 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".