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", 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...
1122 if ((tmpdir
= getenv("TMPDIR")) != NULL
&&
1123 strncmp(tmpdir
, "/private/tmp", 12))
1125 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1126 #endif /* __APPLE__ */
1129 * TMPDIR is defined, see if it is OK for us to use...
1132 if (stat(tmpdir
, &tmpinfo
))
1133 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1134 tmpdir
, strerror(errno
));
1135 else if (!S_ISDIR(tmpinfo
.st_mode
))
1136 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1138 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1139 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1140 !(tmpinfo
.st_mode
& S_IWOTH
))
1141 cupsdLogMessage(CUPSD_LOG_ERROR
,
1142 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1144 cupsdSetString(&TempDir
, tmpdir
);
1149 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1151 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1156 * Make sure the temporary directory has the right permissions...
1159 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1163 * Update ownership and permissions if the CUPS temp directory
1164 * is under the spool directory or does not exist...
1167 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1168 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1173 * Update environment variables...
1179 * Update default paper size setting as needed...
1182 if (!DefaultPaperSize
)
1184 #ifdef HAVE_LIBPAPER
1185 char *paper_result
; /* Paper size name from libpaper */
1187 if ((paper_result
= systempapername()) != NULL
)
1188 cupsdSetString(&DefaultPaperSize
, paper_result
);
1190 #endif /* HAVE_LIBPAPER */
1191 if (!DefaultLanguage
||
1192 !_cups_strcasecmp(DefaultLanguage
, "C") ||
1193 !_cups_strcasecmp(DefaultLanguage
, "POSIX") ||
1194 !_cups_strcasecmp(DefaultLanguage
, "en") ||
1195 !_cups_strncasecmp(DefaultLanguage
, "en.", 3) ||
1196 !_cups_strncasecmp(DefaultLanguage
, "en_US", 5) ||
1197 !_cups_strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1198 !_cups_strncasecmp(DefaultLanguage
, "fr_CA", 5))
1201 * These are the only locales that will default to "letter" size...
1204 cupsdSetString(&DefaultPaperSize
, "Letter");
1207 cupsdSetString(&DefaultPaperSize
, "A4");
1211 * Update classification setting as needed...
1214 if (Classification
&& !_cups_strcasecmp(Classification
, "none"))
1215 cupsdClearString(&Classification
);
1218 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1221 * Check the MaxClients setting, and then allocate memory for it...
1224 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1227 cupsdLogMessage(CUPSD_LOG_INFO
,
1228 "MaxClients limited to 1/3 (%d) of the file descriptor "
1230 MaxFDs
/ 3, MaxFDs
);
1232 MaxClients
= MaxFDs
/ 3;
1235 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1239 * Check the MaxActiveJobs setting; limit to 1/3 the available
1240 * file descriptors, since we need a pipe for each job...
1243 if (MaxActiveJobs
> (MaxFDs
/ 3))
1244 MaxActiveJobs
= MaxFDs
/ 3;
1247 * Update the MaxClientsPerHost value, as needed...
1250 if (MaxClientsPerHost
<= 0)
1251 MaxClientsPerHost
= MaxClients
;
1253 if (MaxClientsPerHost
> MaxClients
)
1254 MaxClientsPerHost
= MaxClients
;
1256 cupsdLogMessage(CUPSD_LOG_INFO
,
1257 "Allowing up to %d client connections per host.",
1261 * Update the default policy, as needed...
1265 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1267 DefaultPolicyPtr
= NULL
;
1269 if (!DefaultPolicyPtr
)
1271 cupsd_location_t
*po
; /* New policy operation */
1275 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1278 cupsdSetString(&DefaultPolicy
, "default");
1280 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1281 cupsdLogMessage(CUPSD_LOG_INFO
,
1282 "Using policy \"default\" as the default.");
1285 cupsdLogMessage(CUPSD_LOG_INFO
,
1286 "Creating CUPS default administrative policy:");
1288 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1290 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1292 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1293 cupsdAddString(&(p
->job_access
), "@OWNER");
1294 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1296 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1297 cupsdAddString(&(p
->job_attrs
), "job-name");
1298 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1299 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1301 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1302 cupsdAddString(&(p
->sub_access
), "@OWNER");
1303 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1305 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1306 cupsdAddString(&(p
->job_attrs
), "notify-events");
1307 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1308 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1309 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1310 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1312 cupsdLogMessage(CUPSD_LOG_INFO
,
1313 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1314 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1316 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1317 po
->order_type
= CUPSD_AUTH_ALLOW
;
1319 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1320 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1321 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1323 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1325 cupsdLogMessage(CUPSD_LOG_INFO
,
1326 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1327 "Release-Job Restart-Job Purge-Jobs "
1328 "Set-Job-Attributes Create-Job-Subscription "
1329 "Renew-Subscription Cancel-Subscription "
1330 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1331 "Suspend-Current-Job Resume-Job "
1332 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1333 "CUPS-Authenticate-Job CUPS-Get-Document>");
1334 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1336 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1337 po
->order_type
= CUPSD_AUTH_ALLOW
;
1338 po
->level
= CUPSD_AUTH_USER
;
1340 cupsdAddName(po
, "@OWNER");
1341 cupsdAddName(po
, "@SYSTEM");
1342 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1344 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1345 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1346 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1347 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1348 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1349 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1350 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1351 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1352 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1353 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1354 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1355 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1356 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1357 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1358 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1359 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1360 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1361 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1362 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1363 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1365 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1367 cupsdLogMessage(CUPSD_LOG_INFO
,
1368 "<Limit Pause-Printer Resume-Printer "
1369 "Set-Printer-Attributes Enable-Printer "
1370 "Disable-Printer Pause-Printer-After-Current-Job "
1371 "Hold-New-Jobs Release-Held-New-Jobs "
1372 "Deactivate-Printer Activate-Printer Restart-Printer "
1373 "Shutdown-Printer Startup-Printer Promote-Job "
1374 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1375 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1376 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1377 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1378 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1380 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1381 po
->order_type
= CUPSD_AUTH_ALLOW
;
1382 po
->type
= CUPSD_AUTH_DEFAULT
;
1383 po
->level
= CUPSD_AUTH_USER
;
1385 cupsdAddName(po
, "@SYSTEM");
1386 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1388 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1389 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1390 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1391 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1392 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1393 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1394 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1395 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1396 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1397 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1398 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1399 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1400 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1401 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1402 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1403 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1404 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1405 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1406 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1407 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1408 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1409 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1411 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1413 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1414 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1416 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1417 po
->order_type
= CUPSD_AUTH_ALLOW
;
1419 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1420 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1424 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1425 cupsArrayCount(Policies
));
1426 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1428 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1429 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1430 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1433 * If we are doing a full reload or the server root has changed, flush
1434 * the jobs, printers, etc. and start from scratch...
1437 if (NeedReload
== RELOAD_ALL
||
1438 old_remote_port
!= RemotePort
||
1439 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1440 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1442 mime_type_t
*type
; /* Current type */
1443 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1444 /* MIME type name */
1447 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1450 * Free all memory...
1453 cupsdDeleteAllSubscriptions();
1455 cupsdDeleteAllPrinters();
1457 DefaultPrinter
= NULL
;
1459 if (MimeDatabase
!= NULL
)
1460 mimeDelete(MimeDatabase
);
1464 for (i
= 0; i
< NumMimeTypes
; i
++)
1465 _cupsStrFree(MimeTypes
[i
]);
1471 * Read the MIME type and conversion database...
1474 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1475 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1477 MimeDatabase
= mimeNew();
1478 mimeSetErrorCallback(MimeDatabase
, mime_error_cb
, NULL
);
1480 MimeDatabase
= mimeLoadTypes(MimeDatabase
, mimedir
);
1481 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1482 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1483 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1487 cupsdLogMessage(CUPSD_LOG_EMERG
,
1488 "Unable to load MIME database from \"%s\" or \"%s\".",
1489 mimedir
, ServerRoot
);
1490 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1494 cupsdLogMessage(CUPSD_LOG_INFO
,
1495 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1496 "%d filters...", mimedir
, ServerRoot
,
1497 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1500 * Create a list of MIME types for the document-format-supported
1504 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1505 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1508 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1510 cupsdLogMessage(CUPSD_LOG_ERROR
,
1511 "Unable to allocate memory for %d MIME types.",
1517 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1519 i
++, type
= mimeNextType(MimeDatabase
))
1521 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1523 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1526 if (i
< NumMimeTypes
)
1527 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1530 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1532 mime_filter_t
*filter
; /* Current filter */
1535 for (type
= mimeFirstType(MimeDatabase
);
1537 type
= mimeNextType(MimeDatabase
))
1538 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1539 type
->super
, type
->type
);
1541 for (filter
= mimeFirstFilter(MimeDatabase
);
1543 filter
= mimeNextFilter(MimeDatabase
))
1544 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1545 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1546 filter
->src
->super
, filter
->src
->type
,
1547 filter
->dst
->super
, filter
->dst
->type
,
1548 filter
->cost
, filter
->filter
);
1555 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1556 cupsdLoadBanners(temp
);
1559 * Load printers and classes...
1562 cupsdLoadAllPrinters();
1563 cupsdLoadAllClasses();
1565 cupsdCreateCommonData();
1568 * Update the printcap file as needed...
1571 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1572 cupsdWritePrintcap();
1575 * Load queued jobs...
1581 * Load subscriptions...
1584 cupsdLoadAllSubscriptions();
1586 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1591 * Not a full reload, so recreate the common printer attributes...
1594 cupsdCreateCommonData();
1597 * Update all jobs as needed...
1603 * Update all printers as needed...
1606 cupsdUpdatePrinters();
1607 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1609 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1613 * Reset the reload state...
1616 NeedReload
= RELOAD_NONE
;
1618 cupsdClearString(&old_serverroot
);
1619 cupsdClearString(&old_requestroot
);
1626 * 'get_address()' - Get an address + port number from a line.
1629 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1630 get_address(const char *value
, /* I - Value string */
1631 int defport
) /* I - Default port */
1633 char buffer
[1024], /* Hostname + port number buffer */
1634 defpname
[255], /* Default port name */
1635 *hostname
, /* Hostname or IP */
1636 *portname
; /* Port number or name */
1637 http_addrlist_t
*addrlist
; /* Address list */
1641 * Check for an empty value...
1646 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1651 * Grab a hostname and port number; if there is no colon and the port name
1652 * is only digits, then we have a port number by itself...
1655 strlcpy(buffer
, value
, sizeof(buffer
));
1657 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1664 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1669 * Use the default port...
1672 sprintf(defpname
, "%d", defport
);
1673 portname
= defpname
;
1679 * The buffer contains just a port number...
1687 if (hostname
&& !strcmp(hostname
, "*"))
1691 * Now lookup the address using httpAddrGetList()...
1694 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1695 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1696 hostname
? hostname
: "(nil)");
1703 * 'get_addr_and_mask()' - Get an IP address and netmask.
1706 static int /* O - 1 on success, 0 on failure */
1707 get_addr_and_mask(const char *value
, /* I - String from config file */
1708 unsigned *ip
, /* O - Address value */
1709 unsigned *mask
) /* O - Mask value */
1711 int i
, j
, /* Looping vars */
1712 family
, /* Address family */
1713 ipcount
; /* Count of fields in address */
1714 unsigned ipval
; /* Value */
1715 const char *maskval
, /* Pointer to start of mask value */
1716 *ptr
, /* Pointer into value */
1721 * Get the address...
1724 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1725 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1727 if ((maskval
= strchr(value
, '/')) != NULL
)
1730 maskval
= value
+ strlen(value
);
1734 * Check for an IPv6 address...
1740 * Parse hexadecimal IPv6/IPv4 address...
1745 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1749 else if (!strncmp(ptr
, "::", 2))
1751 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1753 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1758 else if (isdigit(*ptr
& 255) && strchr(ptr
+ 1, '.') && i
>= 6)
1761 * Read IPv4 dotted quad...
1764 unsigned val
[4] = { 0, 0, 0, 0 };
1765 /* IPv4 address values */
1767 ipcount
= sscanf(ptr
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2,
1771 * Range check the IP numbers...
1774 for (i
= 0; i
< ipcount
; i
++)
1779 * Merge everything into a 32-bit IPv4 address in ip[3]...
1782 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1785 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1788 * If the leading words are all 0's then this is an IPv4 address...
1791 if (!val
[0] && !val
[1] && !val
[2])
1794 while (isdigit(*ptr
& 255) || *ptr
== '.')
1798 else if (isxdigit(*ptr
& 255))
1800 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1802 if (*ptr
== ':' && ptr
[1] != ':')
1811 ip
[i
/ 2] |= ipval
<< 16;
1822 if (*ptr
&& *ptr
!= '/')
1826 #endif /* AF_INET6 */
1829 * Parse dotted-decimal IPv4 address...
1832 unsigned val
[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
1836 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1839 * Range check the IP numbers...
1842 for (i
= 0; i
< ipcount
; i
++)
1847 * Merge everything into a 32-bit IPv4 address in ip[3]...
1850 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1853 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1859 * Get the netmask value(s)...
1862 memset(mask
, 0, sizeof(unsigned) * 4);
1864 if (strchr(maskval
, '.'))
1867 * Get dotted-decimal mask...
1870 if (family
!= AF_INET
)
1873 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2,
1877 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1878 mask
[0] = mask
[1] = mask
[2] = 0;
1883 * Get address/bits format...
1889 if (family
== AF_INET6
)
1897 mask
[0] = 0xffffffff;
1899 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1902 mask
[1] = 0xffffffff;
1906 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1909 mask
[2] = 0xffffffff;
1913 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1916 mask
[3] = 0xffffffff;
1920 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1923 #endif /* AF_INET6 */
1928 mask
[0] = 0xffffffff;
1929 mask
[1] = 0xffffffff;
1930 mask
[2] = 0xffffffff;
1933 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1935 mask
[3] = 0xffffffff;
1940 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1941 "get_addr_and_mask(value=\"%s\", "
1942 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1943 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1947 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1950 if ((ip
[0] & ~mask
[0]) != 0 ||
1951 (ip
[1] & ~mask
[1]) != 0 ||
1952 (ip
[2] & ~mask
[2]) != 0 ||
1953 (ip
[3] & ~mask
[3]) != 0)
1961 * 'mime_error_cb()' - Log a MIME error.
1965 mime_error_cb(void *ctx
, /* I - Context pointer (unused) */
1966 const char *message
) /* I - Message */
1970 cupsdLogMessage(CUPSD_LOG_ERROR
, "%s", message
);
1975 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1978 static int /* O - 1 on success, 0 on failure */
1979 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1980 char *line
, /* I - Line from file */
1981 char *value
, /* I - Start of value data */
1982 int linenum
) /* I - Current line number */
1984 char *valptr
; /* Pointer into value */
1985 unsigned ip
[4], /* IP address components */
1986 mask
[4]; /* IP netmask components */
1989 if (!_cups_strcasecmp(line
, "Encryption"))
1992 * "Encryption xxx" - set required encryption level...
1995 if (!_cups_strcasecmp(value
, "never"))
1996 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1997 else if (!_cups_strcasecmp(value
, "always"))
1999 cupsdLogMessage(CUPSD_LOG_ERROR
,
2000 "Encryption value \"%s\" on line %d is invalid in this "
2001 "context. Using \"required\" instead.", value
, linenum
);
2003 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2005 else if (!_cups_strcasecmp(value
, "required"))
2006 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2007 else if (!_cups_strcasecmp(value
, "ifrequested"))
2008 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
2011 cupsdLogMessage(CUPSD_LOG_ERROR
,
2012 "Unknown Encryption value %s on line %d.", value
, linenum
);
2016 else if (!_cups_strcasecmp(line
, "Order"))
2019 * "Order Deny,Allow" or "Order Allow,Deny"...
2022 if (!_cups_strncasecmp(value
, "deny", 4))
2023 loc
->order_type
= CUPSD_AUTH_ALLOW
;
2024 else if (!_cups_strncasecmp(value
, "allow", 5))
2025 loc
->order_type
= CUPSD_AUTH_DENY
;
2028 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
2033 else if (!_cups_strcasecmp(line
, "Allow") || !_cups_strcasecmp(line
, "Deny"))
2036 * Allow [From] host/ip...
2037 * Deny [From] host/ip...
2042 if (!_cups_strncasecmp(value
, "from", 4))
2045 * Strip leading "from"...
2050 while (_cups_isspace(*value
))
2058 * Find the end of the value...
2061 for (valptr
= value
; *valptr
&& !_cups_isspace(*valptr
); valptr
++);
2063 while (_cups_isspace(*valptr
))
2067 * Figure out what form the allow/deny address takes:
2078 * nnn.nnn.nnn.nnn/mm
2079 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2082 if (!_cups_strcasecmp(value
, "all"))
2088 if (!_cups_strcasecmp(line
, "Allow"))
2089 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
2091 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
2093 else if (!_cups_strcasecmp(value
, "none"))
2099 if (!_cups_strcasecmp(line
, "Allow"))
2100 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
2102 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
2105 else if (value
[0] == '*' || value
[0] == '.' ||
2106 (!isdigit(value
[0] & 255) && value
[0] != '['))
2108 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2109 #endif /* AF_INET6 */
2112 * Host or domain name...
2115 if (value
[0] == '*')
2118 if (!_cups_strcasecmp(line
, "Allow"))
2119 cupsdAddNameMask(&(loc
->allow
), value
);
2121 cupsdAddNameMask(&(loc
->deny
), value
);
2126 * One of many IP address forms...
2129 if (!get_addr_and_mask(value
, ip
, mask
))
2131 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2136 if (!_cups_strcasecmp(line
, "Allow"))
2137 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
2139 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
2143 * Advance to next value...
2149 else if (!_cups_strcasecmp(line
, "AuthType"))
2152 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2155 if (!_cups_strcasecmp(value
, "none"))
2157 loc
->type
= CUPSD_AUTH_NONE
;
2158 loc
->level
= CUPSD_AUTH_ANON
;
2160 else if (!_cups_strcasecmp(value
, "basic"))
2162 loc
->type
= CUPSD_AUTH_BASIC
;
2164 if (loc
->level
== CUPSD_AUTH_ANON
)
2165 loc
->level
= CUPSD_AUTH_USER
;
2167 else if (!_cups_strcasecmp(value
, "digest"))
2169 loc
->type
= CUPSD_AUTH_DIGEST
;
2171 if (loc
->level
== CUPSD_AUTH_ANON
)
2172 loc
->level
= CUPSD_AUTH_USER
;
2174 else if (!_cups_strcasecmp(value
, "basicdigest"))
2176 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2178 if (loc
->level
== CUPSD_AUTH_ANON
)
2179 loc
->level
= CUPSD_AUTH_USER
;
2181 else if (!_cups_strcasecmp(value
, "default"))
2183 loc
->type
= CUPSD_AUTH_DEFAULT
;
2185 if (loc
->level
== CUPSD_AUTH_ANON
)
2186 loc
->level
= CUPSD_AUTH_USER
;
2189 else if (!_cups_strcasecmp(value
, "negotiate"))
2191 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2193 if (loc
->level
== CUPSD_AUTH_ANON
)
2194 loc
->level
= CUPSD_AUTH_USER
;
2196 #endif /* HAVE_GSSAPI */
2199 cupsdLogMessage(CUPSD_LOG_WARN
,
2200 "Unknown authorization type %s on line %d.",
2205 else if (!_cups_strcasecmp(line
, "AuthClass"))
2208 * AuthClass anonymous, user, system, group
2211 if (!_cups_strcasecmp(value
, "anonymous"))
2213 loc
->type
= CUPSD_AUTH_NONE
;
2214 loc
->level
= CUPSD_AUTH_ANON
;
2216 cupsdLogMessage(CUPSD_LOG_WARN
,
2217 "\"AuthClass %s\" is deprecated; consider removing "
2221 else if (!_cups_strcasecmp(value
, "user"))
2223 loc
->level
= CUPSD_AUTH_USER
;
2225 cupsdLogMessage(CUPSD_LOG_WARN
,
2226 "\"AuthClass %s\" is deprecated; consider using "
2227 "\"Require valid-user\" on line %d.",
2230 else if (!_cups_strcasecmp(value
, "group"))
2232 loc
->level
= CUPSD_AUTH_GROUP
;
2234 cupsdLogMessage(CUPSD_LOG_WARN
,
2235 "\"AuthClass %s\" is deprecated; consider using "
2236 "\"Require user @groupname\" on line %d.",
2239 else if (!_cups_strcasecmp(value
, "system"))
2241 loc
->level
= CUPSD_AUTH_GROUP
;
2243 cupsdAddName(loc
, "@SYSTEM");
2245 cupsdLogMessage(CUPSD_LOG_WARN
,
2246 "\"AuthClass %s\" is deprecated; consider using "
2247 "\"Require user @SYSTEM\" on line %d.",
2252 cupsdLogMessage(CUPSD_LOG_WARN
,
2253 "Unknown authorization class %s on line %d.",
2258 else if (!_cups_strcasecmp(line
, "AuthGroupName"))
2260 cupsdAddName(loc
, value
);
2262 cupsdLogMessage(CUPSD_LOG_WARN
,
2263 "\"AuthGroupName %s\" directive is deprecated; consider "
2264 "using \"Require user @%s\" on line %d.",
2265 value
, value
, linenum
);
2267 else if (!_cups_strcasecmp(line
, "Require"))
2270 * Apache synonym for AuthClass and AuthGroupName...
2274 * Require valid-user
2275 * Require group names
2276 * Require user names
2279 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2284 if (!_cups_strcasecmp(value
, "valid-user") ||
2285 !_cups_strcasecmp(value
, "user"))
2286 loc
->level
= CUPSD_AUTH_USER
;
2287 else if (!_cups_strcasecmp(value
, "group"))
2288 loc
->level
= CUPSD_AUTH_GROUP
;
2291 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2297 * Get the list of names from the line...
2300 for (value
= valptr
; *value
;)
2302 while (_cups_isspace(*value
))
2305 #ifdef HAVE_AUTHORIZATION_H
2306 if (!strncmp(value
, "@AUTHKEY(", 9))
2309 * Grab "@AUTHKEY(name)" value...
2312 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2318 #endif /* HAVE_AUTHORIZATION_H */
2319 if (*value
== '\"' || *value
== '\'')
2322 * Grab quoted name...
2325 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2332 * Grab literal name.
2335 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2341 cupsdAddName(loc
, value
);
2343 for (value
= valptr
; _cups_isspace(*value
); value
++);
2346 else if (!_cups_strcasecmp(line
, "Satisfy"))
2348 if (!_cups_strcasecmp(value
, "all"))
2349 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2350 else if (!_cups_strcasecmp(value
, "any"))
2351 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2354 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2367 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2370 static int /* O - FatalErrors bits */
2371 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2373 int fatal
; /* FatalErrors bits */
2374 char value
[1024], /* Value string */
2375 *valstart
, /* Pointer into value */
2376 *valend
; /* End of value */
2380 * Empty FatalErrors line yields NULL pointer...
2384 return (CUPSD_FATAL_NONE
);
2387 * Loop through the value string,...
2390 strlcpy(value
, s
, sizeof(value
));
2392 fatal
= CUPSD_FATAL_NONE
;
2394 for (valstart
= value
; *valstart
;)
2397 * Get the current space/comma-delimited kind name...
2400 for (valend
= valstart
; *valend
; valend
++)
2401 if (_cups_isspace(*valend
) || *valend
== ',')
2408 * Add the error to the bitmask...
2411 if (!_cups_strcasecmp(valstart
, "all"))
2412 fatal
= CUPSD_FATAL_ALL
;
2413 else if (!_cups_strcasecmp(valstart
, "browse"))
2414 fatal
|= CUPSD_FATAL_BROWSE
;
2415 else if (!_cups_strcasecmp(valstart
, "-browse"))
2416 fatal
&= ~CUPSD_FATAL_BROWSE
;
2417 else if (!_cups_strcasecmp(valstart
, "config"))
2418 fatal
|= CUPSD_FATAL_CONFIG
;
2419 else if (!_cups_strcasecmp(valstart
, "-config"))
2420 fatal
&= ~CUPSD_FATAL_CONFIG
;
2421 else if (!_cups_strcasecmp(valstart
, "listen"))
2422 fatal
|= CUPSD_FATAL_LISTEN
;
2423 else if (!_cups_strcasecmp(valstart
, "-listen"))
2424 fatal
&= ~CUPSD_FATAL_LISTEN
;
2425 else if (!_cups_strcasecmp(valstart
, "log"))
2426 fatal
|= CUPSD_FATAL_LOG
;
2427 else if (!_cups_strcasecmp(valstart
, "-log"))
2428 fatal
&= ~CUPSD_FATAL_LOG
;
2429 else if (!_cups_strcasecmp(valstart
, "permissions"))
2430 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2431 else if (!_cups_strcasecmp(valstart
, "-permissions"))
2432 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2433 else if (_cups_strcasecmp(valstart
, "none"))
2434 cupsdLogMessage(CUPSD_LOG_ERROR
,
2435 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2437 for (valstart
= valend
; *valstart
; valstart
++)
2438 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2447 * 'parse_groups()' - Parse system group names in a string.
2450 static int /* O - 1 on success, 0 on failure */
2451 parse_groups(const char *s
) /* I - Space-delimited groups */
2453 int status
; /* Return status */
2454 char value
[1024], /* Value string */
2455 *valstart
, /* Pointer into value */
2456 *valend
, /* End of value */
2457 quote
; /* Quote character */
2458 struct group
*group
; /* Group */
2462 * Make a copy of the string and parse out the groups...
2465 strlcpy(value
, s
, sizeof(value
));
2470 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2472 if (*valstart
== '\'' || *valstart
== '\"')
2475 * Scan quoted name...
2478 quote
= *valstart
++;
2480 for (valend
= valstart
; *valend
; valend
++)
2481 if (*valend
== quote
)
2487 * Scan space or comma-delimited name...
2490 for (valend
= valstart
; *valend
; valend
++)
2491 if (_cups_isspace(*valend
) || *valend
== ',')
2498 group
= getgrnam(valstart
);
2501 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2502 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2513 while (*valstart
== ',' || _cups_isspace(*valstart
))
2522 * 'parse_protocols()' - Parse browse protocols in a string.
2525 static int /* O - Browse protocol bits */
2526 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2528 int protocols
; /* Browse protocol bits */
2529 char value
[1024], /* Value string */
2530 *valstart
, /* Pointer into value */
2531 *valend
; /* End of value */
2535 * Empty protocol line yields NULL pointer...
2542 * Loop through the value string,...
2545 strlcpy(value
, s
, sizeof(value
));
2549 for (valstart
= value
; *valstart
;)
2552 * Get the current space/comma-delimited protocol name...
2555 for (valend
= valstart
; *valend
; valend
++)
2556 if (_cups_isspace(*valend
) || *valend
== ',')
2563 * Add the protocol to the bitmask...
2566 if (!_cups_strcasecmp(valstart
, "dnssd") ||
2567 !_cups_strcasecmp(valstart
, "dns-sd") ||
2568 !_cups_strcasecmp(valstart
, "bonjour"))
2569 protocols
|= BROWSE_DNSSD
;
2570 else if (!_cups_strcasecmp(valstart
, "all"))
2571 protocols
|= BROWSE_ALL
;
2572 else if (_cups_strcasecmp(valstart
, "none"))
2573 cupsdLogMessage(CUPSD_LOG_ERROR
,
2574 "Unknown browse protocol \"%s\" ignored.", valstart
);
2576 for (valstart
= valend
; *valstart
; valstart
++)
2577 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2586 * 'parse_variable()' - Parse a variable line.
2589 static int /* O - 1 on success, 0 on failure */
2591 const char *filename
, /* I - Name of configuration file */
2592 int linenum
, /* I - Line in configuration file */
2593 const char *line
, /* I - Line from configuration file */
2594 const char *value
, /* I - Value from configuration file */
2595 size_t num_vars
, /* I - Number of variables */
2596 const cupsd_var_t
*vars
) /* I - Variables */
2598 size_t i
; /* Looping var */
2599 const cupsd_var_t
*var
; /* Variables */
2600 char temp
[1024]; /* Temporary string */
2603 for (i
= num_vars
, var
= vars
; i
> 0; i
--, var
++)
2604 if (!_cups_strcasecmp(line
, var
->name
))
2610 * Unknown directive! Output an error message and continue...
2614 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d of %s.",
2615 line
, linenum
, filename
);
2617 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d of %s.",
2618 line
, linenum
, filename
);
2625 case CUPSD_VARTYPE_INTEGER
:
2628 cupsdLogMessage(CUPSD_LOG_ERROR
,
2629 "Missing integer value for %s on line %d of %s.",
2630 line
, linenum
, filename
);
2633 else if (!isdigit(*value
& 255))
2635 cupsdLogMessage(CUPSD_LOG_ERROR
,
2636 "Bad integer value for %s on line %d of %s.",
2637 line
, linenum
, filename
);
2643 char *units
; /* Units */
2645 n
= strtol(value
, &units
, 0);
2647 if (units
&& *units
)
2649 if (tolower(units
[0] & 255) == 'g')
2650 n
*= 1024 * 1024 * 1024;
2651 else if (tolower(units
[0] & 255) == 'm')
2653 else if (tolower(units
[0] & 255) == 'k')
2655 else if (tolower(units
[0] & 255) == 't')
2659 cupsdLogMessage(CUPSD_LOG_ERROR
,
2660 "Unknown integer value for %s on line %d of %s.",
2661 line
, linenum
, filename
);
2668 cupsdLogMessage(CUPSD_LOG_ERROR
,
2669 "Bad negative integer value for %s on line %d of "
2670 "%s.", line
, linenum
, filename
);
2675 *((int *)var
->ptr
) = n
;
2680 case CUPSD_VARTYPE_TIME
:
2683 cupsdLogMessage(CUPSD_LOG_ERROR
,
2684 "Missing time interval value for %s on line %d of "
2685 "%s.", line
, linenum
, filename
);
2688 else if (!_cups_strncasecmp(line
, "PreserveJob", 11) &&
2689 (!_cups_strcasecmp(value
, "true") ||
2690 !_cups_strcasecmp(value
, "on") ||
2691 !_cups_strcasecmp(value
, "enabled") ||
2692 !_cups_strcasecmp(value
, "yes")))
2694 *((int *)var
->ptr
) = INT_MAX
;
2696 else if (!_cups_strcasecmp(value
, "false") ||
2697 !_cups_strcasecmp(value
, "off") ||
2698 !_cups_strcasecmp(value
, "disabled") ||
2699 !_cups_strcasecmp(value
, "no"))
2701 *((int *)var
->ptr
) = 0;
2703 else if (!isdigit(*value
& 255))
2705 cupsdLogMessage(CUPSD_LOG_ERROR
,
2706 "Unknown time interval value for %s on line %d of "
2707 "%s.", line
, linenum
, filename
);
2712 double n
; /* Number */
2713 char *units
; /* Units */
2715 n
= strtod(value
, &units
);
2717 if (units
&& *units
)
2719 if (tolower(units
[0] & 255) == 'w')
2720 n
*= 7 * 24 * 60 * 60;
2721 else if (tolower(units
[0] & 255) == 'd')
2723 else if (tolower(units
[0] & 255) == 'h')
2725 else if (tolower(units
[0] & 255) == 'm')
2729 cupsdLogMessage(CUPSD_LOG_ERROR
,
2730 "Unknown time interval value for %s on line "
2731 "%d of %s.", line
, linenum
, filename
);
2736 if (n
< 0.0 || n
> INT_MAX
)
2738 cupsdLogMessage(CUPSD_LOG_ERROR
,
2739 "Bad time value for %s on line %d of %s.",
2740 line
, linenum
, filename
);
2745 *((int *)var
->ptr
) = (int)n
;
2750 case CUPSD_VARTYPE_BOOLEAN
:
2753 cupsdLogMessage(CUPSD_LOG_ERROR
,
2754 "Missing boolean value for %s on line %d of %s.",
2755 line
, linenum
, filename
);
2758 else if (!_cups_strcasecmp(value
, "true") ||
2759 !_cups_strcasecmp(value
, "on") ||
2760 !_cups_strcasecmp(value
, "enabled") ||
2761 !_cups_strcasecmp(value
, "yes") ||
2764 *((int *)var
->ptr
) = TRUE
;
2766 else if (!_cups_strcasecmp(value
, "false") ||
2767 !_cups_strcasecmp(value
, "off") ||
2768 !_cups_strcasecmp(value
, "disabled") ||
2769 !_cups_strcasecmp(value
, "no") ||
2770 !_cups_strcasecmp(value
, "0"))
2772 *((int *)var
->ptr
) = FALSE
;
2776 cupsdLogMessage(CUPSD_LOG_ERROR
,
2777 "Unknown boolean value %s on line %d of %s.",
2778 value
, linenum
, filename
);
2783 case CUPSD_VARTYPE_PATHNAME
:
2786 cupsdLogMessage(CUPSD_LOG_ERROR
,
2787 "Missing pathname value for %s on line %d of %s.",
2788 line
, linenum
, filename
);
2792 if (value
[0] == '/')
2793 strlcpy(temp
, value
, sizeof(temp
));
2795 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
2797 if (access(temp
, 0))
2799 cupsdLogMessage(CUPSD_LOG_ERROR
,
2800 "File or directory for \"%s %s\" on line %d of %s "
2801 "does not exist.", line
, value
, linenum
, filename
);
2805 cupsdSetString((char **)var
->ptr
, temp
);
2808 case CUPSD_VARTYPE_STRING
:
2809 cupsdSetString((char **)var
->ptr
, value
);
2818 * 'read_cupsd_conf()' - Read the cupsd.conf configuration file.
2821 static int /* O - 1 on success, 0 on failure */
2822 read_cupsd_conf(cups_file_t
*fp
) /* I - File to read from */
2824 int linenum
; /* Current line number */
2825 char line
[HTTP_MAX_BUFFER
],
2826 /* Line from file */
2827 temp
[HTTP_MAX_BUFFER
],
2828 /* Temporary buffer for value */
2829 *value
, /* Pointer to value */
2830 *valueptr
; /* Pointer into value */
2831 int valuelen
; /* Length of value */
2832 http_addrlist_t
*addrlist
, /* Address list */
2833 *addr
; /* Current address */
2834 cups_file_t
*incfile
; /* Include file */
2835 char incname
[1024]; /* Include filename */
2839 * Loop through each line in the file...
2844 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2847 * Decode the directive...
2850 if (!_cups_strcasecmp(line
, "Include") && value
)
2856 if (value
[0] == '/')
2857 strlcpy(incname
, value
, sizeof(incname
));
2859 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2861 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2862 cupsdLogMessage(CUPSD_LOG_ERROR
,
2863 "Unable to include config file \"%s\" - %s",
2864 incname
, strerror(errno
));
2867 read_cupsd_conf(incfile
);
2868 cupsFileClose(incfile
);
2871 else if (!_cups_strcasecmp(line
, "<Location") && value
)
2877 linenum
= read_location(fp
, value
, linenum
);
2881 else if (!_cups_strcasecmp(line
, "<Policy") && value
)
2887 linenum
= read_policy(fp
, value
, linenum
);
2891 else if (!_cups_strcasecmp(line
, "FaxRetryInterval") && value
)
2893 JobRetryInterval
= atoi(value
);
2894 cupsdLogMessage(CUPSD_LOG_WARN
,
2895 "FaxRetryInterval is deprecated; use "
2896 "JobRetryInterval on line %d.", linenum
);
2898 else if (!_cups_strcasecmp(line
, "FaxRetryLimit") && value
)
2900 JobRetryLimit
= atoi(value
);
2901 cupsdLogMessage(CUPSD_LOG_WARN
,
2902 "FaxRetryLimit is deprecated; use "
2903 "JobRetryLimit on line %d.", linenum
);
2905 else if ((!_cups_strcasecmp(line
, "Port") || !_cups_strcasecmp(line
, "Listen")
2907 || !_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen")
2908 #endif /* HAVE_SSL */
2912 * Add listening address(es) to the list...
2915 cupsd_listener_t
*lis
; /* New listeners array */
2919 * Get the address list...
2922 addrlist
= get_address(value
, IPP_PORT
);
2926 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2932 * Add each address...
2935 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2938 * See if this address is already present...
2941 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2943 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2944 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2945 httpAddrPort(&(addr
->addr
)) == httpAddrPort(&(lis
->address
)))
2950 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2951 cupsdLogMessage(CUPSD_LOG_WARN
,
2952 "Duplicate listen address \"%s\" ignored.", temp
);
2957 * Allocate another listener...
2961 Listeners
= cupsArrayNew(NULL
, NULL
);
2965 cupsdLogMessage(CUPSD_LOG_ERROR
,
2966 "Unable to allocate %s at line %d - %s.",
2967 line
, linenum
, strerror(errno
));
2971 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2973 cupsdLogMessage(CUPSD_LOG_ERROR
,
2974 "Unable to allocate %s at line %d - %s.",
2975 line
, linenum
, strerror(errno
));
2979 cupsArrayAdd(Listeners
, lis
);
2982 * Copy the current address and log it...
2985 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2989 if (!_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen"))
2990 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2991 #endif /* HAVE_SSL */
2993 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2996 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2997 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2999 #endif /* AF_LOCAL */
3000 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
3001 httpAddrPort(&(lis
->address
)),
3002 _httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
3004 if (!httpAddrLocalhost(&(lis
->address
)))
3005 RemotePort
= httpAddrPort(&(lis
->address
));
3012 httpAddrFreeList(addrlist
);
3014 else if (!_cups_strcasecmp(line
, "BrowseProtocols") ||
3015 !_cups_strcasecmp(line
, "BrowseLocalProtocols"))
3018 * "BrowseProtocols name [... name]"
3019 * "BrowseLocalProtocols name [... name]"
3022 int protocols
= parse_protocols(value
);
3026 cupsdLogMessage(CUPSD_LOG_ERROR
,
3027 "Unknown browse protocol \"%s\" on line %d.",
3032 BrowseLocalProtocols
= protocols
;
3034 else if (!_cups_strcasecmp(line
, "DefaultAuthType") && value
)
3037 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3040 if (!_cups_strcasecmp(value
, "none"))
3041 default_auth_type
= CUPSD_AUTH_NONE
;
3042 else if (!_cups_strcasecmp(value
, "basic"))
3043 default_auth_type
= CUPSD_AUTH_BASIC
;
3044 else if (!_cups_strcasecmp(value
, "digest"))
3045 default_auth_type
= CUPSD_AUTH_DIGEST
;
3046 else if (!_cups_strcasecmp(value
, "basicdigest"))
3047 default_auth_type
= CUPSD_AUTH_BASICDIGEST
;
3049 else if (!_cups_strcasecmp(value
, "negotiate"))
3050 default_auth_type
= CUPSD_AUTH_NEGOTIATE
;
3051 #endif /* HAVE_GSSAPI */
3052 else if (!_cups_strcasecmp(value
, "auto"))
3053 default_auth_type
= CUPSD_AUTH_AUTO
;
3056 cupsdLogMessage(CUPSD_LOG_WARN
,
3057 "Unknown default authorization type %s on line %d.",
3059 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3064 else if (!_cups_strcasecmp(line
, "DefaultEncryption"))
3067 * DefaultEncryption {Never,IfRequested,Required}
3070 if (!value
|| !_cups_strcasecmp(value
, "never"))
3071 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3072 else if (!_cups_strcasecmp(value
, "required"))
3073 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3074 else if (!_cups_strcasecmp(value
, "ifrequested"))
3075 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3078 cupsdLogMessage(CUPSD_LOG_WARN
,
3079 "Unknown default encryption %s on line %d.",
3081 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3085 #endif /* HAVE_SSL */
3086 else if (!_cups_strcasecmp(line
, "HostNameLookups") && value
)
3089 * Do hostname lookups?
3092 if (!_cups_strcasecmp(value
, "off") || !_cups_strcasecmp(value
, "no") ||
3093 !_cups_strcasecmp(value
, "false"))
3094 HostNameLookups
= 0;
3095 else if (!_cups_strcasecmp(value
, "on") || !_cups_strcasecmp(value
, "yes") ||
3096 !_cups_strcasecmp(value
, "true"))
3097 HostNameLookups
= 1;
3098 else if (!_cups_strcasecmp(value
, "double"))
3099 HostNameLookups
= 2;
3101 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3104 else if (!_cups_strcasecmp(line
, "AccessLogLevel") && value
)
3107 * Amount of logging to do to access log...
3110 if (!_cups_strcasecmp(value
, "all"))
3111 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3112 else if (!_cups_strcasecmp(value
, "actions"))
3113 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3114 else if (!_cups_strcasecmp(value
, "config"))
3115 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3117 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3120 else if (!_cups_strcasecmp(line
, "LogLevel") && value
)
3123 * Amount of logging to do to error log...
3126 if (!_cups_strcasecmp(value
, "debug2"))
3127 LogLevel
= CUPSD_LOG_DEBUG2
;
3128 else if (!_cups_strcasecmp(value
, "debug"))
3129 LogLevel
= CUPSD_LOG_DEBUG
;
3130 else if (!_cups_strcasecmp(value
, "info"))
3131 LogLevel
= CUPSD_LOG_INFO
;
3132 else if (!_cups_strcasecmp(value
, "notice"))
3133 LogLevel
= CUPSD_LOG_NOTICE
;
3134 else if (!_cups_strcasecmp(value
, "warn"))
3135 LogLevel
= CUPSD_LOG_WARN
;
3136 else if (!_cups_strcasecmp(value
, "error"))
3137 LogLevel
= CUPSD_LOG_ERROR
;
3138 else if (!_cups_strcasecmp(value
, "crit"))
3139 LogLevel
= CUPSD_LOG_CRIT
;
3140 else if (!_cups_strcasecmp(value
, "alert"))
3141 LogLevel
= CUPSD_LOG_ALERT
;
3142 else if (!_cups_strcasecmp(value
, "emerg"))
3143 LogLevel
= CUPSD_LOG_EMERG
;
3144 else if (!_cups_strcasecmp(value
, "none"))
3145 LogLevel
= CUPSD_LOG_NONE
;
3147 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3150 else if (!_cups_strcasecmp(line
, "LogTimeFormat") && value
)
3153 * Amount of logging to do to error log...
3156 if (!_cups_strcasecmp(value
, "standard"))
3157 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3158 else if (!_cups_strcasecmp(value
, "usecs"))
3159 LogTimeFormat
= CUPSD_TIME_USECS
;
3161 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3164 else if (!_cups_strcasecmp(line
, "ServerTokens") && value
)
3167 * Set the string used for the Server header...
3170 struct utsname plat
; /* Platform info */
3175 if (!_cups_strcasecmp(value
, "ProductOnly"))
3176 cupsdSetString(&ServerHeader
, "CUPS");
3177 else if (!_cups_strcasecmp(value
, "Major"))
3178 cupsdSetStringf(&ServerHeader
, "CUPS/%d", CUPS_VERSION_MAJOR
);
3179 else if (!_cups_strcasecmp(value
, "Minor"))
3180 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d", CUPS_VERSION_MAJOR
,
3181 CUPS_VERSION_MINOR
);
3182 else if (!_cups_strcasecmp(value
, "Minimal"))
3183 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3184 else if (!_cups_strcasecmp(value
, "OS"))
3185 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3186 else if (!_cups_strcasecmp(value
, "Full"))
3187 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/2.1",
3189 else if (!_cups_strcasecmp(value
, "None"))
3190 cupsdClearString(&ServerHeader
);
3192 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3195 else if (!_cups_strcasecmp(line
, "PassEnv") && value
)
3198 * PassEnv variable [... variable]
3203 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3204 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3207 if (value
[valuelen
])
3209 value
[valuelen
] = '\0';
3213 cupsdSetEnv(value
, NULL
);
3215 for (value
+= valuelen
; *value
; value
++)
3216 if (!_cups_isspace(*value
) || *value
!= ',')
3220 else if (!_cups_strcasecmp(line
, "ServerAlias") && value
)
3223 * ServerAlias name [... name]
3227 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3231 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3232 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3235 if (value
[valuelen
])
3237 value
[valuelen
] = '\0';
3241 cupsdAddAlias(ServerAlias
, value
);
3243 for (value
+= valuelen
; *value
; value
++)
3244 if (!_cups_isspace(*value
) || *value
!= ',')
3248 else if (!_cups_strcasecmp(line
, "SetEnv") && value
)
3251 * SetEnv variable value
3254 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3262 while (isspace(*valueptr
& 255))
3265 cupsdSetEnv(value
, valueptr
);
3268 cupsdLogMessage(CUPSD_LOG_ERROR
,
3269 "Missing value for SetEnv directive on line %d.",
3273 else if (!_cups_strcasecmp(line
, "SSLOptions"))
3276 * SSLOptions options
3279 if (!value
|| !_cups_strcasecmp(value
, "none"))
3280 SSLOptions
= CUPSD_SSL_NONE
;
3281 else if (!_cups_strcasecmp(value
, "noemptyfragments"))
3282 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3284 cupsdLogMessage(CUPSD_LOG_ERROR
,
3285 "Unknown value \"%s\" for SSLOptions directive on "
3286 "line %d.", value
, linenum
);
3288 #endif /* HAVE_SSL */
3290 parse_variable(ConfigurationFile
, linenum
, line
, value
,
3291 sizeof(cupsd_vars
) / sizeof(cupsd_vars
[0]), cupsd_vars
);
3299 * 'read_cups_files_conf()' - Read the cups-files.conf configuration file.
3302 static int /* O - 1 on success, 0 on failure */
3303 read_cups_files_conf(cups_file_t
*fp
) /* I - File to read from */
3305 int linenum
; /* Current line number */
3306 char line
[HTTP_MAX_BUFFER
], /* Line from file */
3307 *value
; /* Value from line */
3308 struct group
*group
; /* Group */
3312 * Loop through each line in the file...
3317 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3319 if (!_cups_strcasecmp(line
, "FatalErrors"))
3320 FatalErrors
= parse_fatal_errors(value
);
3321 else if (!_cups_strcasecmp(line
, "Group") && value
)
3324 * Group ID to run as...
3327 if (isdigit(value
[0]))
3328 Group
= atoi(value
);
3332 group
= getgrnam(value
);
3335 Group
= group
->gr_gid
;
3338 cupsdLogMessage(CUPSD_LOG_ERROR
,
3339 "Unknown Group \"%s\" on line %d of %s.", value
,
3340 linenum
, CupsFilesFile
);
3341 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3346 else if (!_cups_strcasecmp(line
, "PrintcapFormat") && value
)
3349 * Format of printcap file?
3352 if (!_cups_strcasecmp(value
, "bsd"))
3353 PrintcapFormat
= PRINTCAP_BSD
;
3354 else if (!_cups_strcasecmp(value
, "plist"))
3355 PrintcapFormat
= PRINTCAP_PLIST
;
3356 else if (!_cups_strcasecmp(value
, "solaris"))
3357 PrintcapFormat
= PRINTCAP_SOLARIS
;
3360 cupsdLogMessage(CUPSD_LOG_ERROR
,
3361 "Unknown PrintcapFormat \"%s\" on line %d of %s.",
3362 value
, linenum
, CupsFilesFile
);
3363 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3367 else if (!_cups_strcasecmp(line
, "SystemGroup") && value
)
3370 * SystemGroup (admin) group(s)...
3373 if (!parse_groups(value
))
3375 cupsdLogMessage(CUPSD_LOG_ERROR
,
3376 "Unknown SystemGroup \"%s\" on line %d of %s.", value
,
3377 linenum
, CupsFilesFile
);
3378 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3382 else if (!_cups_strcasecmp(line
, "User") && value
)
3385 * User ID to run as...
3388 if (isdigit(value
[0] & 255))
3390 int uid
= atoi(value
);
3394 cupsdLogMessage(CUPSD_LOG_ERROR
,
3395 "Will not use User 0 as specified on line %d of %s "
3396 "for security reasons. You must use a non-"
3397 "privileged account instead.",
3398 linenum
, CupsFilesFile
);
3399 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3407 struct passwd
*p
; /* Password information */
3410 p
= getpwnam(value
);
3416 cupsdLogMessage(CUPSD_LOG_ERROR
,
3417 "Will not use User %s (UID=0) as specified on line "
3418 "%d of %s for security reasons. You must use a "
3419 "non-privileged account instead.",
3420 value
, linenum
, CupsFilesFile
);
3421 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3429 cupsdLogMessage(CUPSD_LOG_ERROR
,
3430 "Unknown User \"%s\" on line %d of %s.",
3431 value
, linenum
, CupsFilesFile
);
3432 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3437 else if (!parse_variable(CupsFilesFile
, linenum
, line
, value
,
3438 sizeof(cupsfiles_vars
) / sizeof(cupsfiles_vars
[0]),
3440 (FatalErrors
& CUPSD_FATAL_CONFIG
))
3449 * 'read_location()' - Read a <Location path> definition.
3452 static int /* O - New line number or 0 on error */
3453 read_location(cups_file_t
*fp
, /* I - Configuration file */
3454 char *location
, /* I - Location name/path */
3455 int linenum
) /* I - Current line number */
3457 cupsd_location_t
*loc
, /* New location */
3458 *parent
; /* Parent location */
3459 char line
[HTTP_MAX_BUFFER
],
3461 *value
, /* Value for directive */
3462 *valptr
; /* Pointer into value */
3465 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3466 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3468 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3472 cupsdAddLocation(parent
);
3474 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3479 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3482 * Decode the directive...
3485 if (!_cups_strcasecmp(line
, "</Location>"))
3487 else if (!_cups_strcasecmp(line
, "<Limit") ||
3488 !_cups_strcasecmp(line
, "<LimitExcept"))
3492 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3493 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3499 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3502 cupsdAddLocation(loc
);
3507 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3512 if (!strcmp(value
, "ALL"))
3513 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3514 else if (!strcmp(value
, "GET"))
3515 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3516 else if (!strcmp(value
, "HEAD"))
3517 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3518 else if (!strcmp(value
, "OPTIONS"))
3519 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3520 else if (!strcmp(value
, "POST"))
3521 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3522 else if (!strcmp(value
, "PUT"))
3523 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3524 else if (!strcmp(value
, "TRACE"))
3525 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3527 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3530 for (value
= valptr
; isspace(*value
& 255); value
++);
3533 if (!_cups_strcasecmp(line
, "<LimitExcept"))
3534 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3536 parent
->limit
&= ~loc
->limit
;
3538 else if (!_cups_strcasecmp(line
, "</Limit>") ||
3539 !_cups_strcasecmp(line
, "</LimitExcept>"))
3543 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3544 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3547 else if (!parse_aaa(loc
, line
, value
, linenum
))
3549 cupsdLogMessage(CUPSD_LOG_ERROR
,
3550 "Unknown Location directive %s on line %d.",
3552 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3557 cupsdLogMessage(CUPSD_LOG_ERROR
,
3558 "Unexpected end-of-file at line %d while reading location.",
3561 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3566 * 'read_policy()' - Read a <Policy name> definition.
3569 static int /* O - New line number or 0 on error */
3570 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3571 char *policy
, /* I - Location name/path */
3572 int linenum
) /* I - Current line number */
3574 int i
; /* Looping var */
3575 cupsd_policy_t
*pol
; /* Policy */
3576 cupsd_location_t
*op
; /* Policy operation */
3577 int num_ops
; /* Number of IPP operations */
3578 ipp_op_t ops
[100]; /* Operations */
3579 char line
[HTTP_MAX_BUFFER
],
3581 *value
, /* Value for directive */
3582 *valptr
; /* Pointer into value */
3586 * Create the policy...
3589 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3590 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3592 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3596 * Read from the file...
3602 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3605 * Decode the directive...
3608 if (!_cups_strcasecmp(line
, "</Policy>"))
3611 cupsdLogMessage(CUPSD_LOG_WARN
,
3612 "Missing </Limit> before </Policy> on line %d.",
3615 set_policy_defaults(pol
);
3619 else if (!_cups_strcasecmp(line
, "<Limit") && !op
)
3623 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3624 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3631 * Scan for IPP operation names...
3638 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3643 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3645 if (!_cups_strcasecmp(value
, "All"))
3646 ops
[num_ops
] = IPP_ANY_OPERATION
;
3647 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3648 cupsdLogMessage(CUPSD_LOG_ERROR
,
3649 "Bad IPP operation name \"%s\" on line %d.",
3655 cupsdLogMessage(CUPSD_LOG_ERROR
,
3656 "Too many operations listed on line %d.",
3659 for (value
= valptr
; isspace(*value
& 255); value
++);
3663 * If none are specified, apply the policy to all operations...
3668 ops
[0] = IPP_ANY_OPERATION
;
3673 * Add a new policy for the first operation...
3676 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3678 else if (!_cups_strcasecmp(line
, "</Limit>") && op
)
3681 * Finish the current operation limit...
3687 * Copy the policy to the other operations...
3690 for (i
= 1; i
< num_ops
; i
++)
3691 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3698 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3699 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3702 else if (!_cups_strcasecmp(line
, "JobPrivateAccess") ||
3703 !_cups_strcasecmp(line
, "JobPrivateValues") ||
3704 !_cups_strcasecmp(line
, "SubscriptionPrivateAccess") ||
3705 !_cups_strcasecmp(line
, "SubscriptionPrivateValues"))
3709 cupsdLogMessage(CUPSD_LOG_ERROR
,
3710 "%s directive must appear outside <Limit>...</Limit> "
3711 "on line %d.", line
, linenum
);
3712 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3718 * Pull out whitespace-delimited values...
3724 * Find the end of the current value...
3727 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3733 * Save it appropriately...
3736 if (!_cups_strcasecmp(line
, "JobPrivateAccess"))
3739 * JobPrivateAccess {all|default|user/group list|@@ACL}
3742 if (!_cups_strcasecmp(value
, "default"))
3744 cupsdAddString(&(pol
->job_access
), "@OWNER");
3745 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3748 cupsdAddString(&(pol
->job_access
), value
);
3750 else if (!_cups_strcasecmp(line
, "JobPrivateValues"))
3753 * JobPrivateValues {all|none|default|attribute list}
3756 if (!_cups_strcasecmp(value
, "default"))
3758 cupsdAddString(&(pol
->job_attrs
), "job-name");
3759 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3760 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3761 cupsdAddString(&(pol
->job_attrs
), "phone");
3764 cupsdAddString(&(pol
->job_attrs
), value
);
3766 else if (!_cups_strcasecmp(line
, "SubscriptionPrivateAccess"))
3769 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3772 if (!_cups_strcasecmp(value
, "default"))
3774 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3775 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3778 cupsdAddString(&(pol
->sub_access
), value
);
3780 else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
3783 * SubscriptionPrivateValues {all|none|default|attribute list}
3786 if (!_cups_strcasecmp(value
, "default"))
3788 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3789 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3790 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3791 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3792 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3795 cupsdAddString(&(pol
->sub_attrs
), value
);
3799 * Find the next string on the line...
3802 for (value
= valptr
; isspace(*value
& 255); value
++);
3808 cupsdLogMessage(CUPSD_LOG_ERROR
,
3809 "Missing <Limit ops> directive before %s on line %d.",
3811 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3814 else if (!parse_aaa(op
, line
, value
, linenum
))
3816 cupsdLogMessage(CUPSD_LOG_ERROR
,
3817 "Unknown Policy Limit directive %s on line %d.",
3820 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3825 cupsdLogMessage(CUPSD_LOG_ERROR
,
3826 "Unexpected end-of-file at line %d while reading policy "
3827 "\"%s\".", linenum
, policy
);
3829 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3834 * 'set_policy_defaults()' - Set default policy values as needed.
3838 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3840 cupsd_location_t
*op
; /* Policy operation */
3844 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3845 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3846 * upgrades do not introduce new security issues...
3849 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3850 op
->op
== IPP_ANY_OPERATION
)
3852 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3853 op
->op
!= IPP_ANY_OPERATION
)
3856 * Add a new limit for Validate-Job using the Print-Job limit as a
3860 cupsdLogMessage(CUPSD_LOG_WARN
,
3861 "No limit for Validate-Job defined in policy %s "
3862 "- using Print-Job's policy.", pol
->name
);
3864 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3867 cupsdLogMessage(CUPSD_LOG_WARN
,
3868 "No limit for Validate-Job defined in policy %s "
3869 "and no suitable template found.", pol
->name
);
3872 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3873 op
->op
== IPP_ANY_OPERATION
)
3875 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3876 op
->op
!= IPP_ANY_OPERATION
)
3879 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3883 cupsdLogMessage(CUPSD_LOG_WARN
,
3884 "No limit for Cancel-Jobs defined in policy %s "
3885 "- using Pause-Printer's policy.", pol
->name
);
3887 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3890 cupsdLogMessage(CUPSD_LOG_WARN
,
3891 "No limit for Cancel-Jobs defined in policy %s "
3892 "and no suitable template found.", pol
->name
);
3895 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3896 op
->op
== IPP_ANY_OPERATION
)
3898 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3899 op
->op
!= IPP_ANY_OPERATION
)
3902 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
3906 cupsdLogMessage(CUPSD_LOG_WARN
,
3907 "No limit for Cancel-My-Jobs defined in policy %s "
3908 "- using Send-Document's policy.", pol
->name
);
3910 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
3913 cupsdLogMessage(CUPSD_LOG_WARN
,
3914 "No limit for Cancel-My-Jobs defined in policy %s "
3915 "and no suitable template found.", pol
->name
);
3918 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
3919 op
->op
== IPP_ANY_OPERATION
)
3921 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3922 op
->op
!= IPP_ANY_OPERATION
)
3925 * Add a new limit for Close-Job using the Send-Document limit as a
3929 cupsdLogMessage(CUPSD_LOG_WARN
,
3930 "No limit for Close-Job defined in policy %s "
3931 "- using Send-Document's policy.", pol
->name
);
3933 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
3936 cupsdLogMessage(CUPSD_LOG_WARN
,
3937 "No limit for Close-Job defined in policy %s "
3938 "and no suitable template found.", pol
->name
);
3941 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
3942 op
->op
== IPP_ANY_OPERATION
)
3944 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3945 op
->op
!= IPP_ANY_OPERATION
)
3948 * Add a new limit for CUPS-Get-Document using the Send-Document
3949 * limit as a template...
3952 cupsdLogMessage(CUPSD_LOG_WARN
,
3953 "No limit for CUPS-Get-Document defined in policy %s "
3954 "- using Send-Document's policy.", pol
->name
);
3956 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
3959 cupsdLogMessage(CUPSD_LOG_WARN
,
3960 "No limit for CUPS-Get-Document defined in policy %s "
3961 "and no suitable template found.", pol
->name
);
3965 * Verify we have JobPrivateAccess, JobPrivateValues,
3966 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
3969 if (!pol
->job_access
)
3971 cupsdLogMessage(CUPSD_LOG_WARN
,
3972 "No JobPrivateAccess defined in policy %s "
3973 "- using defaults.", pol
->name
);
3974 cupsdAddString(&(pol
->job_access
), "@OWNER");
3975 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3978 if (!pol
->job_attrs
)
3980 cupsdLogMessage(CUPSD_LOG_WARN
,
3981 "No JobPrivateValues defined in policy %s "
3982 "- using defaults.", pol
->name
);
3983 cupsdAddString(&(pol
->job_attrs
), "job-name");
3984 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3985 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3986 cupsdAddString(&(pol
->job_attrs
), "phone");
3989 if (!pol
->sub_access
)
3991 cupsdLogMessage(CUPSD_LOG_WARN
,
3992 "No SubscriptionPrivateAccess defined in policy %s "
3993 "- using defaults.", pol
->name
);
3994 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3995 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3998 if (!pol
->sub_attrs
)
4000 cupsdLogMessage(CUPSD_LOG_WARN
,
4001 "No SubscriptionPrivateValues defined in policy %s "
4002 "- using defaults.", pol
->name
);
4003 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4004 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4005 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4006 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4007 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4013 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".