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 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
144 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_TIME
},
145 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
146 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
147 { "StrictConformance", &StrictConformance
, CUPSD_VARTYPE_BOOLEAN
},
148 { "Timeout", &Timeout
, CUPSD_VARTYPE_TIME
},
149 { "WebInterface", &WebInterface
, CUPSD_VARTYPE_BOOLEAN
}
151 static const cupsd_var_t cupsfiles_vars
[] =
153 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
154 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
155 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
156 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
157 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
158 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
159 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
160 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
161 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
162 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
163 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
164 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
165 { "RemoteRoot", &RemoteRoot
, 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 cupsdSetString(&SystemGroupAuthKey
, CUPS_DEFAULT_SYSTEM_AUTHKEY
);
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 printf("\"%s\" contains errors.\n", CupsFilesFile
);
804 syslog(LOG_LPR
, "Unable to read \"%s\" due to errors.",
810 else if (errno
== ENOENT
)
811 cupsdLogMessage(CUPSD_LOG_INFO
, "No %s, using defaults.", CupsFilesFile
);
814 syslog(LOG_LPR
, "Unable to open \"%s\": %s", CupsFilesFile
,
820 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
823 * Read the cupsd.conf file...
826 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
828 syslog(LOG_LPR
, "Unable to open \"%s\": %s", ConfigurationFile
,
833 status
= read_cupsd_conf(fp
);
840 printf("\"%s\" contains errors.\n", ConfigurationFile
);
842 syslog(LOG_LPR
, "Unable to read \"%s\" due to errors.",
850 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
851 RemotePort
? "enabled" : "disabled");
854 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
857 * See if the ServerName is an IP address...
863 ServerAlias
= cupsArrayNew(NULL
, NULL
);
865 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
869 if (gethostname(temp
, sizeof(temp
)))
871 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
873 strlcpy(temp
, "localhost", sizeof(temp
));
876 cupsdSetString(&ServerName
, temp
);
879 ServerAlias
= cupsArrayNew(NULL
, NULL
);
881 cupsdAddAlias(ServerAlias
, temp
);
882 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
884 if (HostNameLookups
|| RemotePort
)
886 struct hostent
*host
; /* Host entry to get FQDN */
888 if ((host
= gethostbyname(temp
)) != NULL
)
890 if (_cups_strcasecmp(temp
, host
->h_name
))
892 cupsdSetString(&ServerName
, host
->h_name
);
893 cupsdAddAlias(ServerAlias
, host
->h_name
);
894 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
900 for (i
= 0; host
->h_aliases
[i
]; i
++)
901 if (_cups_strcasecmp(temp
, host
->h_aliases
[i
]))
903 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
904 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
912 * Make sure we have the base hostname added as an alias, too!
915 if ((slash
= strchr(temp
, '.')) != NULL
)
918 cupsdAddAlias(ServerAlias
, temp
);
919 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
923 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
925 ServerNameIsIP
= !*slash
;
928 * Make sure ServerAdmin is initialized...
932 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
935 * Use the default system group if none was supplied in cupsd.conf...
938 if (NumSystemGroups
== 0)
940 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
943 * Find the group associated with GID 0...
950 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
952 cupsdSetString(&SystemGroups
[0], "unknown");
954 SystemGroupIDs
[0] = 0;
960 * Make sure ConfigFilePerm and LogFilePerm have sane values...
963 ConfigFilePerm
&= 0664;
967 * Open the system log for cupsd if necessary...
971 if (!strcmp(AccessLog
, "syslog") ||
972 !strcmp(ErrorLog
, "syslog") ||
973 !strcmp(PageLog
, "syslog"))
974 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
975 #endif /* HAVE_VSYSLOG */
978 * Make sure each of the log files exists and gets rotated as necessary...
981 if (strcmp(AccessLog
, "syslog"))
982 cupsdCheckLogFile(&AccessFile
, AccessLog
);
984 if (strcmp(ErrorLog
, "syslog"))
985 cupsdCheckLogFile(&ErrorFile
, ErrorLog
);
987 if (strcmp(PageLog
, "syslog"))
988 cupsdCheckLogFile(&PageFile
, PageLog
);
991 * Log the configuration file that was used...
994 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
998 * Validate the Group and SystemGroup settings - they cannot be the same,
999 * otherwise the CGI programs will be able to authenticate as root without
1005 for (i
= 0; i
< NumSystemGroups
; i
++)
1006 if (Group
== SystemGroupIDs
[i
])
1009 if (i
< NumSystemGroups
)
1012 * Log the error and reset the group to a safe value...
1015 cupsdLogMessage(CUPSD_LOG_NOTICE
,
1016 "Group and SystemGroup cannot use the same groups.");
1017 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
1019 group
= getgrnam("nobody");
1023 Group
= group
->gr_gid
;
1027 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
1028 * complement number...)
1037 * Check that we have at least one listen/port line; if not, report this
1038 * as an error and exit!
1041 if (cupsArrayCount(Listeners
) == 0)
1047 cupsdLogMessage(CUPSD_LOG_EMERG
,
1048 "No valid Listen or Port lines were found in the "
1049 "configuration file.");
1055 cupsdEndProcess(getpid(), 0);
1059 * Set the default locale using the language and charset...
1062 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
1065 * Update all relative filenames to include the full path from ServerRoot...
1068 if (DocumentRoot
[0] != '/')
1069 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
1071 if (RequestRoot
[0] != '/')
1072 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
1074 if (ServerBin
[0] != '/')
1075 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
1077 if (StateDir
[0] != '/')
1078 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
1080 if (CacheDir
[0] != '/')
1081 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
1084 if (ServerCertificate
[0] != '/')
1085 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
1087 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
1088 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
1090 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1093 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
1094 if (ServerKey
[0] != '/')
1095 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
1097 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
1098 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
1099 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1101 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
1102 #endif /* HAVE_SSL */
1105 * Make sure that directories and config files are owned and
1106 * writable by the user and group in the cupsd.conf file...
1109 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
1111 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
1113 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
1115 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
1117 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
1119 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
1120 SystemGroupIDs
[0], 1, 1) < 0 ||
1121 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
1123 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
1125 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
1127 cupsdCheckPermissions(ConfigurationFile
, NULL
, ConfigFilePerm
, RunUser
,
1129 cupsdCheckPermissions(CupsFilesFile
, NULL
, ConfigFilePerm
, RunUser
,
1131 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
1133 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
1135 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
1136 Group
, 0, 0) < 0) &&
1137 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1141 * Update TempDir to the default if it hasn't been set already...
1145 if (TempDir
&& !RunUser
&&
1146 (!strncmp(TempDir
, "/private/tmp", 12) || !strncmp(TempDir
, "/tmp", 4)))
1148 cupsdLogMessage(CUPSD_LOG_ERROR
, "Cannot use %s for TempDir.", TempDir
);
1149 cupsdClearString(&TempDir
);
1151 #endif /* __APPLE__ */
1156 if ((tmpdir
= getenv("TMPDIR")) != NULL
&&
1157 strncmp(tmpdir
, "/private/tmp", 12) && strncmp(tmpdir
, "/tmp", 4))
1159 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1160 #endif /* __APPLE__ */
1163 * TMPDIR is defined, see if it is OK for us to use...
1166 if (stat(tmpdir
, &tmpinfo
))
1167 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1168 tmpdir
, strerror(errno
));
1169 else if (!S_ISDIR(tmpinfo
.st_mode
))
1170 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1172 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1173 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1174 !(tmpinfo
.st_mode
& S_IWOTH
))
1175 cupsdLogMessage(CUPSD_LOG_ERROR
,
1176 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1178 cupsdSetString(&TempDir
, tmpdir
);
1184 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1186 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1190 * Make sure the temporary directory has the right permissions...
1193 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1197 * Update ownership and permissions if the CUPS temp directory
1198 * is under the spool directory or does not exist...
1201 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1202 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1207 * Update environment variables...
1213 * Update default paper size setting as needed...
1216 if (!DefaultPaperSize
)
1218 #ifdef HAVE_LIBPAPER
1219 char *paper_result
; /* Paper size name from libpaper */
1221 if ((paper_result
= systempapername()) != NULL
)
1222 cupsdSetString(&DefaultPaperSize
, paper_result
);
1224 #endif /* HAVE_LIBPAPER */
1225 if (!DefaultLanguage
||
1226 !_cups_strcasecmp(DefaultLanguage
, "C") ||
1227 !_cups_strcasecmp(DefaultLanguage
, "POSIX") ||
1228 !_cups_strcasecmp(DefaultLanguage
, "en") ||
1229 !_cups_strncasecmp(DefaultLanguage
, "en.", 3) ||
1230 !_cups_strncasecmp(DefaultLanguage
, "en_US", 5) ||
1231 !_cups_strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1232 !_cups_strncasecmp(DefaultLanguage
, "fr_CA", 5))
1235 * These are the only locales that will default to "letter" size...
1238 cupsdSetString(&DefaultPaperSize
, "Letter");
1241 cupsdSetString(&DefaultPaperSize
, "A4");
1245 * Update classification setting as needed...
1248 if (Classification
&& !_cups_strcasecmp(Classification
, "none"))
1249 cupsdClearString(&Classification
);
1252 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1255 * Check the MaxClients setting, and then allocate memory for it...
1258 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1261 cupsdLogMessage(CUPSD_LOG_INFO
,
1262 "MaxClients limited to 1/3 (%d) of the file descriptor "
1264 MaxFDs
/ 3, MaxFDs
);
1266 MaxClients
= MaxFDs
/ 3;
1269 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1273 * Check the MaxActiveJobs setting; limit to 1/3 the available
1274 * file descriptors, since we need a pipe for each job...
1277 if (MaxActiveJobs
> (MaxFDs
/ 3))
1278 MaxActiveJobs
= MaxFDs
/ 3;
1281 * Update the MaxClientsPerHost value, as needed...
1284 if (MaxClientsPerHost
<= 0)
1285 MaxClientsPerHost
= MaxClients
;
1287 if (MaxClientsPerHost
> MaxClients
)
1288 MaxClientsPerHost
= MaxClients
;
1290 cupsdLogMessage(CUPSD_LOG_INFO
,
1291 "Allowing up to %d client connections per host.",
1295 * Update the default policy, as needed...
1299 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1301 DefaultPolicyPtr
= NULL
;
1303 if (!DefaultPolicyPtr
)
1305 cupsd_location_t
*po
; /* New policy operation */
1309 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1312 cupsdSetString(&DefaultPolicy
, "default");
1314 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1315 cupsdLogMessage(CUPSD_LOG_INFO
,
1316 "Using policy \"default\" as the default.");
1319 cupsdLogMessage(CUPSD_LOG_INFO
,
1320 "Creating CUPS default administrative policy:");
1322 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1324 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1326 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1327 cupsdAddString(&(p
->job_access
), "@OWNER");
1328 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1330 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1331 cupsdAddString(&(p
->job_attrs
), "job-name");
1332 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1333 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1335 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1336 cupsdAddString(&(p
->sub_access
), "@OWNER");
1337 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1339 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1340 cupsdAddString(&(p
->job_attrs
), "notify-events");
1341 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1342 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1343 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1344 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1346 cupsdLogMessage(CUPSD_LOG_INFO
,
1347 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1348 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1350 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1351 po
->order_type
= CUPSD_AUTH_ALLOW
;
1353 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1354 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1355 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1357 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1359 cupsdLogMessage(CUPSD_LOG_INFO
,
1360 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1361 "Release-Job Restart-Job Purge-Jobs "
1362 "Set-Job-Attributes Create-Job-Subscription "
1363 "Renew-Subscription Cancel-Subscription "
1364 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1365 "Suspend-Current-Job Resume-Job "
1366 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1367 "CUPS-Authenticate-Job CUPS-Get-Document>");
1368 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1370 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1371 po
->order_type
= CUPSD_AUTH_ALLOW
;
1372 po
->level
= CUPSD_AUTH_USER
;
1374 cupsdAddName(po
, "@OWNER");
1375 cupsdAddName(po
, "@SYSTEM");
1376 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1378 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1379 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1380 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1381 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1382 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1383 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1384 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1385 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1386 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1387 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1388 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1389 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1390 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1391 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1392 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1393 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1394 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1395 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1396 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1397 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1399 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1401 cupsdLogMessage(CUPSD_LOG_INFO
,
1402 "<Limit Pause-Printer Resume-Printer "
1403 "Set-Printer-Attributes Enable-Printer "
1404 "Disable-Printer Pause-Printer-After-Current-Job "
1405 "Hold-New-Jobs Release-Held-New-Jobs "
1406 "Deactivate-Printer Activate-Printer Restart-Printer "
1407 "Shutdown-Printer Startup-Printer Promote-Job "
1408 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1409 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1410 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1411 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1412 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1414 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1415 po
->order_type
= CUPSD_AUTH_ALLOW
;
1416 po
->type
= CUPSD_AUTH_DEFAULT
;
1417 po
->level
= CUPSD_AUTH_USER
;
1419 cupsdAddName(po
, "@SYSTEM");
1420 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1422 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1423 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1424 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1425 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1426 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1427 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1428 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1429 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1430 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1431 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1432 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1433 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1434 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1435 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1436 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1437 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1438 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1439 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1440 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1441 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1442 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1443 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1445 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1447 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1448 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1450 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1451 po
->order_type
= CUPSD_AUTH_ALLOW
;
1453 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1454 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1458 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1459 cupsArrayCount(Policies
));
1460 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1462 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1463 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1464 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1467 * If we are doing a full reload or the server root has changed, flush
1468 * the jobs, printers, etc. and start from scratch...
1471 if (NeedReload
== RELOAD_ALL
||
1472 old_remote_port
!= RemotePort
||
1473 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1474 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1476 mime_type_t
*type
; /* Current type */
1477 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1478 /* MIME type name */
1481 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1484 * Free all memory...
1487 cupsdDeleteAllSubscriptions();
1489 cupsdDeleteAllPrinters();
1491 DefaultPrinter
= NULL
;
1493 if (MimeDatabase
!= NULL
)
1494 mimeDelete(MimeDatabase
);
1498 for (i
= 0; i
< NumMimeTypes
; i
++)
1499 _cupsStrFree(MimeTypes
[i
]);
1505 * Read the MIME type and conversion database...
1508 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1509 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1511 MimeDatabase
= mimeNew();
1512 mimeSetErrorCallback(MimeDatabase
, mime_error_cb
, NULL
);
1514 MimeDatabase
= mimeLoadTypes(MimeDatabase
, mimedir
);
1515 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1516 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1517 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1521 cupsdLogMessage(CUPSD_LOG_EMERG
,
1522 "Unable to load MIME database from \"%s\" or \"%s\".",
1523 mimedir
, ServerRoot
);
1524 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1528 cupsdLogMessage(CUPSD_LOG_INFO
,
1529 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1530 "%d filters...", mimedir
, ServerRoot
,
1531 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1534 * Create a list of MIME types for the document-format-supported
1538 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1539 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1542 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1544 cupsdLogMessage(CUPSD_LOG_ERROR
,
1545 "Unable to allocate memory for %d MIME types.",
1551 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1553 i
++, type
= mimeNextType(MimeDatabase
))
1555 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1557 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1560 if (i
< NumMimeTypes
)
1561 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1564 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1566 mime_filter_t
*filter
; /* Current filter */
1569 for (type
= mimeFirstType(MimeDatabase
);
1571 type
= mimeNextType(MimeDatabase
))
1572 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1573 type
->super
, type
->type
);
1575 for (filter
= mimeFirstFilter(MimeDatabase
);
1577 filter
= mimeNextFilter(MimeDatabase
))
1578 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1579 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1580 filter
->src
->super
, filter
->src
->type
,
1581 filter
->dst
->super
, filter
->dst
->type
,
1582 filter
->cost
, filter
->filter
);
1589 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1590 cupsdLoadBanners(temp
);
1593 * Load printers and classes...
1596 cupsdLoadAllPrinters();
1597 cupsdLoadAllClasses();
1599 cupsdCreateCommonData();
1602 * Update the printcap file as needed...
1605 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1606 cupsdWritePrintcap();
1609 * Load queued jobs...
1615 * Load subscriptions...
1618 cupsdLoadAllSubscriptions();
1620 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1625 * Not a full reload, so recreate the common printer attributes...
1628 cupsdCreateCommonData();
1631 * Update all jobs as needed...
1637 * Update all printers as needed...
1640 cupsdUpdatePrinters();
1641 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1643 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1647 * Reset the reload state...
1650 NeedReload
= RELOAD_NONE
;
1652 cupsdClearString(&old_serverroot
);
1653 cupsdClearString(&old_requestroot
);
1660 * 'get_address()' - Get an address + port number from a line.
1663 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1664 get_address(const char *value
, /* I - Value string */
1665 int defport
) /* I - Default port */
1667 char buffer
[1024], /* Hostname + port number buffer */
1668 defpname
[255], /* Default port name */
1669 *hostname
, /* Hostname or IP */
1670 *portname
; /* Port number or name */
1671 http_addrlist_t
*addrlist
; /* Address list */
1675 * Check for an empty value...
1680 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1685 * Grab a hostname and port number; if there is no colon and the port name
1686 * is only digits, then we have a port number by itself...
1689 strlcpy(buffer
, value
, sizeof(buffer
));
1691 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1698 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1703 * Use the default port...
1706 sprintf(defpname
, "%d", defport
);
1707 portname
= defpname
;
1713 * The buffer contains just a port number...
1721 if (hostname
&& !strcmp(hostname
, "*"))
1725 * Now lookup the address using httpAddrGetList()...
1728 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1729 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1730 hostname
? hostname
: "(nil)");
1737 * 'get_addr_and_mask()' - Get an IP address and netmask.
1740 static int /* O - 1 on success, 0 on failure */
1741 get_addr_and_mask(const char *value
, /* I - String from config file */
1742 unsigned *ip
, /* O - Address value */
1743 unsigned *mask
) /* O - Mask value */
1745 int i
, j
, /* Looping vars */
1746 family
, /* Address family */
1747 ipcount
; /* Count of fields in address */
1748 unsigned ipval
; /* Value */
1749 const char *maskval
, /* Pointer to start of mask value */
1750 *ptr
, /* Pointer into value */
1755 * Get the address...
1758 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1759 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1761 if ((maskval
= strchr(value
, '/')) != NULL
)
1764 maskval
= value
+ strlen(value
);
1768 * Check for an IPv6 address...
1774 * Parse hexadecimal IPv6/IPv4 address...
1779 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1783 else if (!strncmp(ptr
, "::", 2))
1785 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1787 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1792 else if (isdigit(*ptr
& 255) && strchr(ptr
+ 1, '.') && i
>= 6)
1795 * Read IPv4 dotted quad...
1798 unsigned val
[4] = { 0, 0, 0, 0 };
1799 /* IPv4 address values */
1801 ipcount
= sscanf(ptr
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2,
1805 * Range check the IP numbers...
1808 for (i
= 0; i
< ipcount
; i
++)
1813 * Merge everything into a 32-bit IPv4 address in ip[3]...
1816 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1819 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1822 * If the leading words are all 0's then this is an IPv4 address...
1825 if (!val
[0] && !val
[1] && !val
[2])
1828 while (isdigit(*ptr
& 255) || *ptr
== '.')
1832 else if (isxdigit(*ptr
& 255))
1834 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1836 if (*ptr
== ':' && ptr
[1] != ':')
1845 ip
[i
/ 2] |= ipval
<< 16;
1856 if (*ptr
&& *ptr
!= '/')
1860 #endif /* AF_INET6 */
1863 * Parse dotted-decimal IPv4 address...
1866 unsigned val
[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
1870 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1873 * Range check the IP numbers...
1876 for (i
= 0; i
< ipcount
; i
++)
1881 * Merge everything into a 32-bit IPv4 address in ip[3]...
1884 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1887 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1893 * Get the netmask value(s)...
1896 memset(mask
, 0, sizeof(unsigned) * 4);
1898 if (strchr(maskval
, '.'))
1901 * Get dotted-decimal mask...
1904 if (family
!= AF_INET
)
1907 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2,
1911 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1912 mask
[0] = mask
[1] = mask
[2] = 0;
1917 * Get address/bits format...
1923 if (family
== AF_INET6
)
1931 mask
[0] = 0xffffffff;
1933 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1936 mask
[1] = 0xffffffff;
1940 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1943 mask
[2] = 0xffffffff;
1947 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1950 mask
[3] = 0xffffffff;
1954 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1957 #endif /* AF_INET6 */
1962 mask
[0] = 0xffffffff;
1963 mask
[1] = 0xffffffff;
1964 mask
[2] = 0xffffffff;
1967 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1969 mask
[3] = 0xffffffff;
1974 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1975 "get_addr_and_mask(value=\"%s\", "
1976 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1977 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1981 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1984 if ((ip
[0] & ~mask
[0]) != 0 ||
1985 (ip
[1] & ~mask
[1]) != 0 ||
1986 (ip
[2] & ~mask
[2]) != 0 ||
1987 (ip
[3] & ~mask
[3]) != 0)
1995 * 'mime_error_cb()' - Log a MIME error.
1999 mime_error_cb(void *ctx
, /* I - Context pointer (unused) */
2000 const char *message
) /* I - Message */
2004 cupsdLogMessage(CUPSD_LOG_ERROR
, "%s", message
);
2009 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
2012 static int /* O - 1 on success, 0 on failure */
2013 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
2014 char *line
, /* I - Line from file */
2015 char *value
, /* I - Start of value data */
2016 int linenum
) /* I - Current line number */
2018 char *valptr
; /* Pointer into value */
2019 unsigned ip
[4], /* IP address components */
2020 mask
[4]; /* IP netmask components */
2023 if (!_cups_strcasecmp(line
, "Encryption"))
2026 * "Encryption xxx" - set required encryption level...
2029 if (!_cups_strcasecmp(value
, "never"))
2030 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
2031 else if (!_cups_strcasecmp(value
, "always"))
2033 cupsdLogMessage(CUPSD_LOG_ERROR
,
2034 "Encryption value \"%s\" on line %d is invalid in this "
2035 "context. Using \"required\" instead.", value
, linenum
);
2037 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2039 else if (!_cups_strcasecmp(value
, "required"))
2040 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2041 else if (!_cups_strcasecmp(value
, "ifrequested"))
2042 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
2045 cupsdLogMessage(CUPSD_LOG_ERROR
,
2046 "Unknown Encryption value %s on line %d.", value
, linenum
);
2050 else if (!_cups_strcasecmp(line
, "Order"))
2053 * "Order Deny,Allow" or "Order Allow,Deny"...
2056 if (!_cups_strncasecmp(value
, "deny", 4))
2057 loc
->order_type
= CUPSD_AUTH_ALLOW
;
2058 else if (!_cups_strncasecmp(value
, "allow", 5))
2059 loc
->order_type
= CUPSD_AUTH_DENY
;
2062 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
2067 else if (!_cups_strcasecmp(line
, "Allow") || !_cups_strcasecmp(line
, "Deny"))
2070 * Allow [From] host/ip...
2071 * Deny [From] host/ip...
2076 if (!_cups_strncasecmp(value
, "from", 4))
2079 * Strip leading "from"...
2084 while (_cups_isspace(*value
))
2092 * Find the end of the value...
2095 for (valptr
= value
; *valptr
&& !_cups_isspace(*valptr
); valptr
++);
2097 while (_cups_isspace(*valptr
))
2101 * Figure out what form the allow/deny address takes:
2112 * nnn.nnn.nnn.nnn/mm
2113 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2116 if (!_cups_strcasecmp(value
, "all"))
2122 if (!_cups_strcasecmp(line
, "Allow"))
2123 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
2125 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
2127 else if (!_cups_strcasecmp(value
, "none"))
2133 if (!_cups_strcasecmp(line
, "Allow"))
2134 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
2136 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
2139 else if (value
[0] == '*' || value
[0] == '.' ||
2140 (!isdigit(value
[0] & 255) && value
[0] != '['))
2142 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2143 #endif /* AF_INET6 */
2146 * Host or domain name...
2149 if (value
[0] == '*')
2152 if (!_cups_strcasecmp(line
, "Allow"))
2153 cupsdAddNameMask(&(loc
->allow
), value
);
2155 cupsdAddNameMask(&(loc
->deny
), value
);
2160 * One of many IP address forms...
2163 if (!get_addr_and_mask(value
, ip
, mask
))
2165 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2170 if (!_cups_strcasecmp(line
, "Allow"))
2171 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
2173 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
2177 * Advance to next value...
2183 else if (!_cups_strcasecmp(line
, "AuthType"))
2186 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2189 if (!_cups_strcasecmp(value
, "none"))
2191 loc
->type
= CUPSD_AUTH_NONE
;
2192 loc
->level
= CUPSD_AUTH_ANON
;
2194 else if (!_cups_strcasecmp(value
, "basic"))
2196 loc
->type
= CUPSD_AUTH_BASIC
;
2198 if (loc
->level
== CUPSD_AUTH_ANON
)
2199 loc
->level
= CUPSD_AUTH_USER
;
2201 else if (!_cups_strcasecmp(value
, "digest"))
2203 loc
->type
= CUPSD_AUTH_DIGEST
;
2205 if (loc
->level
== CUPSD_AUTH_ANON
)
2206 loc
->level
= CUPSD_AUTH_USER
;
2208 else if (!_cups_strcasecmp(value
, "basicdigest"))
2210 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2212 if (loc
->level
== CUPSD_AUTH_ANON
)
2213 loc
->level
= CUPSD_AUTH_USER
;
2215 else if (!_cups_strcasecmp(value
, "default"))
2217 loc
->type
= CUPSD_AUTH_DEFAULT
;
2219 if (loc
->level
== CUPSD_AUTH_ANON
)
2220 loc
->level
= CUPSD_AUTH_USER
;
2223 else if (!_cups_strcasecmp(value
, "negotiate"))
2225 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2227 if (loc
->level
== CUPSD_AUTH_ANON
)
2228 loc
->level
= CUPSD_AUTH_USER
;
2230 #endif /* HAVE_GSSAPI */
2233 cupsdLogMessage(CUPSD_LOG_WARN
,
2234 "Unknown authorization type %s on line %d.",
2239 else if (!_cups_strcasecmp(line
, "AuthClass"))
2242 * AuthClass anonymous, user, system, group
2245 if (!_cups_strcasecmp(value
, "anonymous"))
2247 loc
->type
= CUPSD_AUTH_NONE
;
2248 loc
->level
= CUPSD_AUTH_ANON
;
2250 cupsdLogMessage(CUPSD_LOG_WARN
,
2251 "\"AuthClass %s\" is deprecated; consider removing "
2255 else if (!_cups_strcasecmp(value
, "user"))
2257 loc
->level
= CUPSD_AUTH_USER
;
2259 cupsdLogMessage(CUPSD_LOG_WARN
,
2260 "\"AuthClass %s\" is deprecated; consider using "
2261 "\"Require valid-user\" on line %d.",
2264 else if (!_cups_strcasecmp(value
, "group"))
2266 loc
->level
= CUPSD_AUTH_GROUP
;
2268 cupsdLogMessage(CUPSD_LOG_WARN
,
2269 "\"AuthClass %s\" is deprecated; consider using "
2270 "\"Require user @groupname\" on line %d.",
2273 else if (!_cups_strcasecmp(value
, "system"))
2275 loc
->level
= CUPSD_AUTH_GROUP
;
2277 cupsdAddName(loc
, "@SYSTEM");
2279 cupsdLogMessage(CUPSD_LOG_WARN
,
2280 "\"AuthClass %s\" is deprecated; consider using "
2281 "\"Require user @SYSTEM\" on line %d.",
2286 cupsdLogMessage(CUPSD_LOG_WARN
,
2287 "Unknown authorization class %s on line %d.",
2292 else if (!_cups_strcasecmp(line
, "AuthGroupName"))
2294 cupsdAddName(loc
, value
);
2296 cupsdLogMessage(CUPSD_LOG_WARN
,
2297 "\"AuthGroupName %s\" directive is deprecated; consider "
2298 "using \"Require user @%s\" on line %d.",
2299 value
, value
, linenum
);
2301 else if (!_cups_strcasecmp(line
, "Require"))
2304 * Apache synonym for AuthClass and AuthGroupName...
2308 * Require valid-user
2309 * Require group names
2310 * Require user names
2313 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2318 if (!_cups_strcasecmp(value
, "valid-user") ||
2319 !_cups_strcasecmp(value
, "user"))
2320 loc
->level
= CUPSD_AUTH_USER
;
2321 else if (!_cups_strcasecmp(value
, "group"))
2322 loc
->level
= CUPSD_AUTH_GROUP
;
2325 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2331 * Get the list of names from the line...
2334 for (value
= valptr
; *value
;)
2336 while (_cups_isspace(*value
))
2339 #ifdef HAVE_AUTHORIZATION_H
2340 if (!strncmp(value
, "@AUTHKEY(", 9))
2343 * Grab "@AUTHKEY(name)" value...
2346 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2352 #endif /* HAVE_AUTHORIZATION_H */
2353 if (*value
== '\"' || *value
== '\'')
2356 * Grab quoted name...
2359 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2366 * Grab literal name.
2369 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2375 cupsdAddName(loc
, value
);
2377 for (value
= valptr
; _cups_isspace(*value
); value
++);
2380 else if (!_cups_strcasecmp(line
, "Satisfy"))
2382 if (!_cups_strcasecmp(value
, "all"))
2383 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2384 else if (!_cups_strcasecmp(value
, "any"))
2385 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2388 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2401 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2404 static int /* O - FatalErrors bits */
2405 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2407 int fatal
; /* FatalErrors bits */
2408 char value
[1024], /* Value string */
2409 *valstart
, /* Pointer into value */
2410 *valend
; /* End of value */
2414 * Empty FatalErrors line yields NULL pointer...
2418 return (CUPSD_FATAL_NONE
);
2421 * Loop through the value string,...
2424 strlcpy(value
, s
, sizeof(value
));
2426 fatal
= CUPSD_FATAL_NONE
;
2428 for (valstart
= value
; *valstart
;)
2431 * Get the current space/comma-delimited kind name...
2434 for (valend
= valstart
; *valend
; valend
++)
2435 if (_cups_isspace(*valend
) || *valend
== ',')
2442 * Add the error to the bitmask...
2445 if (!_cups_strcasecmp(valstart
, "all"))
2446 fatal
= CUPSD_FATAL_ALL
;
2447 else if (!_cups_strcasecmp(valstart
, "browse"))
2448 fatal
|= CUPSD_FATAL_BROWSE
;
2449 else if (!_cups_strcasecmp(valstart
, "-browse"))
2450 fatal
&= ~CUPSD_FATAL_BROWSE
;
2451 else if (!_cups_strcasecmp(valstart
, "config"))
2452 fatal
|= CUPSD_FATAL_CONFIG
;
2453 else if (!_cups_strcasecmp(valstart
, "-config"))
2454 fatal
&= ~CUPSD_FATAL_CONFIG
;
2455 else if (!_cups_strcasecmp(valstart
, "listen"))
2456 fatal
|= CUPSD_FATAL_LISTEN
;
2457 else if (!_cups_strcasecmp(valstart
, "-listen"))
2458 fatal
&= ~CUPSD_FATAL_LISTEN
;
2459 else if (!_cups_strcasecmp(valstart
, "log"))
2460 fatal
|= CUPSD_FATAL_LOG
;
2461 else if (!_cups_strcasecmp(valstart
, "-log"))
2462 fatal
&= ~CUPSD_FATAL_LOG
;
2463 else if (!_cups_strcasecmp(valstart
, "permissions"))
2464 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2465 else if (!_cups_strcasecmp(valstart
, "-permissions"))
2466 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2467 else if (_cups_strcasecmp(valstart
, "none"))
2468 cupsdLogMessage(CUPSD_LOG_ERROR
,
2469 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2471 for (valstart
= valend
; *valstart
; valstart
++)
2472 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2481 * 'parse_groups()' - Parse system group names in a string.
2484 static int /* O - 1 on success, 0 on failure */
2485 parse_groups(const char *s
) /* I - Space-delimited groups */
2487 int status
; /* Return status */
2488 char value
[1024], /* Value string */
2489 *valstart
, /* Pointer into value */
2490 *valend
, /* End of value */
2491 quote
; /* Quote character */
2492 struct group
*group
; /* Group */
2496 * Make a copy of the string and parse out the groups...
2499 strlcpy(value
, s
, sizeof(value
));
2504 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2506 if (*valstart
== '\'' || *valstart
== '\"')
2509 * Scan quoted name...
2512 quote
= *valstart
++;
2514 for (valend
= valstart
; *valend
; valend
++)
2515 if (*valend
== quote
)
2521 * Scan space or comma-delimited name...
2524 for (valend
= valstart
; *valend
; valend
++)
2525 if (_cups_isspace(*valend
) || *valend
== ',')
2532 group
= getgrnam(valstart
);
2535 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2536 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2547 while (*valstart
== ',' || _cups_isspace(*valstart
))
2556 * 'parse_protocols()' - Parse browse protocols in a string.
2559 static int /* O - Browse protocol bits */
2560 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2562 int protocols
; /* Browse protocol bits */
2563 char value
[1024], /* Value string */
2564 *valstart
, /* Pointer into value */
2565 *valend
; /* End of value */
2569 * Empty protocol line yields NULL pointer...
2576 * Loop through the value string,...
2579 strlcpy(value
, s
, sizeof(value
));
2583 for (valstart
= value
; *valstart
;)
2586 * Get the current space/comma-delimited protocol name...
2589 for (valend
= valstart
; *valend
; valend
++)
2590 if (_cups_isspace(*valend
) || *valend
== ',')
2597 * Add the protocol to the bitmask...
2600 if (!_cups_strcasecmp(valstart
, "dnssd") ||
2601 !_cups_strcasecmp(valstart
, "dns-sd") ||
2602 !_cups_strcasecmp(valstart
, "bonjour"))
2603 protocols
|= BROWSE_DNSSD
;
2604 else if (!_cups_strcasecmp(valstart
, "all"))
2605 protocols
|= BROWSE_ALL
;
2606 else if (_cups_strcasecmp(valstart
, "none"))
2607 cupsdLogMessage(CUPSD_LOG_ERROR
,
2608 "Unknown browse protocol \"%s\" ignored.", valstart
);
2610 for (valstart
= valend
; *valstart
; valstart
++)
2611 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2620 * 'parse_variable()' - Parse a variable line.
2623 static int /* O - 1 on success, 0 on failure */
2625 const char *filename
, /* I - Name of configuration file */
2626 int linenum
, /* I - Line in configuration file */
2627 const char *line
, /* I - Line from configuration file */
2628 const char *value
, /* I - Value from configuration file */
2629 size_t num_vars
, /* I - Number of variables */
2630 const cupsd_var_t
*vars
) /* I - Variables */
2632 size_t i
; /* Looping var */
2633 const cupsd_var_t
*var
; /* Variables */
2634 char temp
[1024]; /* Temporary string */
2637 for (i
= num_vars
, var
= vars
; i
> 0; i
--, var
++)
2638 if (!_cups_strcasecmp(line
, var
->name
))
2644 * Unknown directive! Output an error message and continue...
2648 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d of %s.",
2649 line
, linenum
, filename
);
2651 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d of %s.",
2652 line
, linenum
, filename
);
2659 case CUPSD_VARTYPE_INTEGER
:
2662 cupsdLogMessage(CUPSD_LOG_ERROR
,
2663 "Missing integer value for %s on line %d of %s.",
2664 line
, linenum
, filename
);
2667 else if (!isdigit(*value
& 255))
2669 cupsdLogMessage(CUPSD_LOG_ERROR
,
2670 "Bad integer value for %s on line %d of %s.",
2671 line
, linenum
, filename
);
2677 char *units
; /* Units */
2679 n
= strtol(value
, &units
, 0);
2681 if (units
&& *units
)
2683 if (tolower(units
[0] & 255) == 'g')
2684 n
*= 1024 * 1024 * 1024;
2685 else if (tolower(units
[0] & 255) == 'm')
2687 else if (tolower(units
[0] & 255) == 'k')
2689 else if (tolower(units
[0] & 255) == 't')
2693 cupsdLogMessage(CUPSD_LOG_ERROR
,
2694 "Unknown integer value for %s on line %d of %s.",
2695 line
, linenum
, filename
);
2702 cupsdLogMessage(CUPSD_LOG_ERROR
,
2703 "Bad negative integer value for %s on line %d of "
2704 "%s.", line
, linenum
, filename
);
2709 *((int *)var
->ptr
) = n
;
2714 case CUPSD_VARTYPE_TIME
:
2717 cupsdLogMessage(CUPSD_LOG_ERROR
,
2718 "Missing time interval value for %s on line %d of "
2719 "%s.", line
, linenum
, filename
);
2722 else if (!_cups_strncasecmp(line
, "PreserveJob", 11) &&
2723 (!_cups_strcasecmp(value
, "true") ||
2724 !_cups_strcasecmp(value
, "on") ||
2725 !_cups_strcasecmp(value
, "enabled") ||
2726 !_cups_strcasecmp(value
, "yes")))
2728 *((int *)var
->ptr
) = INT_MAX
;
2730 else if (!_cups_strcasecmp(value
, "false") ||
2731 !_cups_strcasecmp(value
, "off") ||
2732 !_cups_strcasecmp(value
, "disabled") ||
2733 !_cups_strcasecmp(value
, "no"))
2735 *((int *)var
->ptr
) = 0;
2737 else if (!isdigit(*value
& 255))
2739 cupsdLogMessage(CUPSD_LOG_ERROR
,
2740 "Unknown time interval value for %s on line %d of "
2741 "%s.", line
, linenum
, filename
);
2746 double n
; /* Number */
2747 char *units
; /* Units */
2749 n
= strtod(value
, &units
);
2751 if (units
&& *units
)
2753 if (tolower(units
[0] & 255) == 'w')
2754 n
*= 7 * 24 * 60 * 60;
2755 else if (tolower(units
[0] & 255) == 'd')
2757 else if (tolower(units
[0] & 255) == 'h')
2759 else if (tolower(units
[0] & 255) == 'm')
2763 cupsdLogMessage(CUPSD_LOG_ERROR
,
2764 "Unknown time interval value for %s on line "
2765 "%d of %s.", line
, linenum
, filename
);
2770 if (n
< 0.0 || n
> INT_MAX
)
2772 cupsdLogMessage(CUPSD_LOG_ERROR
,
2773 "Bad time value for %s on line %d of %s.",
2774 line
, linenum
, filename
);
2779 *((int *)var
->ptr
) = (int)n
;
2784 case CUPSD_VARTYPE_BOOLEAN
:
2787 cupsdLogMessage(CUPSD_LOG_ERROR
,
2788 "Missing boolean value for %s on line %d of %s.",
2789 line
, linenum
, filename
);
2792 else if (!_cups_strcasecmp(value
, "true") ||
2793 !_cups_strcasecmp(value
, "on") ||
2794 !_cups_strcasecmp(value
, "enabled") ||
2795 !_cups_strcasecmp(value
, "yes") ||
2798 *((int *)var
->ptr
) = TRUE
;
2800 else if (!_cups_strcasecmp(value
, "false") ||
2801 !_cups_strcasecmp(value
, "off") ||
2802 !_cups_strcasecmp(value
, "disabled") ||
2803 !_cups_strcasecmp(value
, "no") ||
2804 !_cups_strcasecmp(value
, "0"))
2806 *((int *)var
->ptr
) = FALSE
;
2810 cupsdLogMessage(CUPSD_LOG_ERROR
,
2811 "Unknown boolean value %s on line %d of %s.",
2812 value
, linenum
, filename
);
2817 case CUPSD_VARTYPE_PATHNAME
:
2820 cupsdLogMessage(CUPSD_LOG_ERROR
,
2821 "Missing pathname value for %s on line %d of %s.",
2822 line
, linenum
, filename
);
2826 if (value
[0] == '/')
2827 strlcpy(temp
, value
, sizeof(temp
));
2829 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
2831 if (access(temp
, 0))
2833 cupsdLogMessage(CUPSD_LOG_ERROR
,
2834 "File or directory for \"%s %s\" on line %d of %s "
2835 "does not exist.", line
, value
, linenum
, filename
);
2839 cupsdSetString((char **)var
->ptr
, temp
);
2842 case CUPSD_VARTYPE_STRING
:
2843 cupsdSetString((char **)var
->ptr
, value
);
2852 * 'read_cupsd_conf()' - Read the cupsd.conf configuration file.
2855 static int /* O - 1 on success, 0 on failure */
2856 read_cupsd_conf(cups_file_t
*fp
) /* I - File to read from */
2858 int linenum
; /* Current line number */
2859 char line
[HTTP_MAX_BUFFER
],
2860 /* Line from file */
2861 temp
[HTTP_MAX_BUFFER
],
2862 /* Temporary buffer for value */
2863 *value
, /* Pointer to value */
2864 *valueptr
; /* Pointer into value */
2865 int valuelen
; /* Length of value */
2866 http_addrlist_t
*addrlist
, /* Address list */
2867 *addr
; /* Current address */
2868 cups_file_t
*incfile
; /* Include file */
2869 char incname
[1024]; /* Include filename */
2873 * Loop through each line in the file...
2878 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2881 * Decode the directive...
2884 if (!_cups_strcasecmp(line
, "Include") && value
)
2890 if (value
[0] == '/')
2891 strlcpy(incname
, value
, sizeof(incname
));
2893 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2895 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2896 cupsdLogMessage(CUPSD_LOG_ERROR
,
2897 "Unable to include config file \"%s\" - %s",
2898 incname
, strerror(errno
));
2901 read_cupsd_conf(incfile
);
2902 cupsFileClose(incfile
);
2905 else if (!_cups_strcasecmp(line
, "<Location") && value
)
2911 linenum
= read_location(fp
, value
, linenum
);
2915 else if (!_cups_strcasecmp(line
, "<Policy") && value
)
2921 linenum
= read_policy(fp
, value
, linenum
);
2925 else if (!_cups_strcasecmp(line
, "FaxRetryInterval") && value
)
2927 JobRetryInterval
= atoi(value
);
2928 cupsdLogMessage(CUPSD_LOG_WARN
,
2929 "FaxRetryInterval is deprecated; use "
2930 "JobRetryInterval on line %d.", linenum
);
2932 else if (!_cups_strcasecmp(line
, "FaxRetryLimit") && value
)
2934 JobRetryLimit
= atoi(value
);
2935 cupsdLogMessage(CUPSD_LOG_WARN
,
2936 "FaxRetryLimit is deprecated; use "
2937 "JobRetryLimit on line %d.", linenum
);
2939 else if ((!_cups_strcasecmp(line
, "Port") || !_cups_strcasecmp(line
, "Listen")
2941 || !_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen")
2942 #endif /* HAVE_SSL */
2946 * Add listening address(es) to the list...
2949 cupsd_listener_t
*lis
; /* New listeners array */
2953 * Get the address list...
2956 addrlist
= get_address(value
, IPP_PORT
);
2960 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2966 * Add each address...
2969 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2972 * See if this address is already present...
2975 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2977 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2978 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2979 httpAddrPort(&(addr
->addr
)) == httpAddrPort(&(lis
->address
)))
2984 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2985 cupsdLogMessage(CUPSD_LOG_WARN
,
2986 "Duplicate listen address \"%s\" ignored.", temp
);
2991 * Allocate another listener...
2995 Listeners
= cupsArrayNew(NULL
, NULL
);
2999 cupsdLogMessage(CUPSD_LOG_ERROR
,
3000 "Unable to allocate %s at line %d - %s.",
3001 line
, linenum
, strerror(errno
));
3005 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
3007 cupsdLogMessage(CUPSD_LOG_ERROR
,
3008 "Unable to allocate %s at line %d - %s.",
3009 line
, linenum
, strerror(errno
));
3013 cupsArrayAdd(Listeners
, lis
);
3016 * Copy the current address and log it...
3019 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
3023 if (!_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen"))
3024 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
3025 #endif /* HAVE_SSL */
3027 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
3030 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
3031 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
3033 #endif /* AF_LOCAL */
3034 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
3035 httpAddrPort(&(lis
->address
)),
3036 _httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
3038 if (!httpAddrLocalhost(&(lis
->address
)))
3039 RemotePort
= httpAddrPort(&(lis
->address
));
3046 httpAddrFreeList(addrlist
);
3048 else if (!_cups_strcasecmp(line
, "BrowseProtocols") ||
3049 !_cups_strcasecmp(line
, "BrowseLocalProtocols"))
3052 * "BrowseProtocols name [... name]"
3053 * "BrowseLocalProtocols name [... name]"
3056 int protocols
= parse_protocols(value
);
3060 cupsdLogMessage(CUPSD_LOG_ERROR
,
3061 "Unknown browse protocol \"%s\" on line %d.",
3066 BrowseLocalProtocols
= protocols
;
3068 else if (!_cups_strcasecmp(line
, "DefaultAuthType") && value
)
3071 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3074 if (!_cups_strcasecmp(value
, "none"))
3075 default_auth_type
= CUPSD_AUTH_NONE
;
3076 else if (!_cups_strcasecmp(value
, "basic"))
3077 default_auth_type
= CUPSD_AUTH_BASIC
;
3078 else if (!_cups_strcasecmp(value
, "digest"))
3079 default_auth_type
= CUPSD_AUTH_DIGEST
;
3080 else if (!_cups_strcasecmp(value
, "basicdigest"))
3081 default_auth_type
= CUPSD_AUTH_BASICDIGEST
;
3083 else if (!_cups_strcasecmp(value
, "negotiate"))
3084 default_auth_type
= CUPSD_AUTH_NEGOTIATE
;
3085 #endif /* HAVE_GSSAPI */
3086 else if (!_cups_strcasecmp(value
, "auto"))
3087 default_auth_type
= CUPSD_AUTH_AUTO
;
3090 cupsdLogMessage(CUPSD_LOG_WARN
,
3091 "Unknown default authorization type %s on line %d.",
3093 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3098 else if (!_cups_strcasecmp(line
, "DefaultEncryption"))
3101 * DefaultEncryption {Never,IfRequested,Required}
3104 if (!value
|| !_cups_strcasecmp(value
, "never"))
3105 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3106 else if (!_cups_strcasecmp(value
, "required"))
3107 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3108 else if (!_cups_strcasecmp(value
, "ifrequested"))
3109 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3112 cupsdLogMessage(CUPSD_LOG_WARN
,
3113 "Unknown default encryption %s on line %d.",
3115 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3119 #endif /* HAVE_SSL */
3120 else if (!_cups_strcasecmp(line
, "HostNameLookups") && value
)
3123 * Do hostname lookups?
3126 if (!_cups_strcasecmp(value
, "off") || !_cups_strcasecmp(value
, "no") ||
3127 !_cups_strcasecmp(value
, "false"))
3128 HostNameLookups
= 0;
3129 else if (!_cups_strcasecmp(value
, "on") || !_cups_strcasecmp(value
, "yes") ||
3130 !_cups_strcasecmp(value
, "true"))
3131 HostNameLookups
= 1;
3132 else if (!_cups_strcasecmp(value
, "double"))
3133 HostNameLookups
= 2;
3135 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3138 else if (!_cups_strcasecmp(line
, "AccessLogLevel") && value
)
3141 * Amount of logging to do to access log...
3144 if (!_cups_strcasecmp(value
, "all"))
3145 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3146 else if (!_cups_strcasecmp(value
, "actions"))
3147 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3148 else if (!_cups_strcasecmp(value
, "config"))
3149 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3151 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3154 else if (!_cups_strcasecmp(line
, "LogLevel") && value
)
3157 * Amount of logging to do to error log...
3160 if (!_cups_strcasecmp(value
, "debug2"))
3161 LogLevel
= CUPSD_LOG_DEBUG2
;
3162 else if (!_cups_strcasecmp(value
, "debug"))
3163 LogLevel
= CUPSD_LOG_DEBUG
;
3164 else if (!_cups_strcasecmp(value
, "info"))
3165 LogLevel
= CUPSD_LOG_INFO
;
3166 else if (!_cups_strcasecmp(value
, "notice"))
3167 LogLevel
= CUPSD_LOG_NOTICE
;
3168 else if (!_cups_strcasecmp(value
, "warn"))
3169 LogLevel
= CUPSD_LOG_WARN
;
3170 else if (!_cups_strcasecmp(value
, "error"))
3171 LogLevel
= CUPSD_LOG_ERROR
;
3172 else if (!_cups_strcasecmp(value
, "crit"))
3173 LogLevel
= CUPSD_LOG_CRIT
;
3174 else if (!_cups_strcasecmp(value
, "alert"))
3175 LogLevel
= CUPSD_LOG_ALERT
;
3176 else if (!_cups_strcasecmp(value
, "emerg"))
3177 LogLevel
= CUPSD_LOG_EMERG
;
3178 else if (!_cups_strcasecmp(value
, "none"))
3179 LogLevel
= CUPSD_LOG_NONE
;
3181 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3184 else if (!_cups_strcasecmp(line
, "LogTimeFormat") && value
)
3187 * Amount of logging to do to error log...
3190 if (!_cups_strcasecmp(value
, "standard"))
3191 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3192 else if (!_cups_strcasecmp(value
, "usecs"))
3193 LogTimeFormat
= CUPSD_TIME_USECS
;
3195 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3198 else if (!_cups_strcasecmp(line
, "ServerTokens") && value
)
3201 * Set the string used for the Server header...
3204 struct utsname plat
; /* Platform info */
3209 if (!_cups_strcasecmp(value
, "ProductOnly"))
3210 cupsdSetString(&ServerHeader
, "CUPS IPP");
3211 else if (!_cups_strcasecmp(value
, "Major"))
3212 cupsdSetStringf(&ServerHeader
, "CUPS/%d IPP/2", CUPS_VERSION_MAJOR
);
3213 else if (!_cups_strcasecmp(value
, "Minor"))
3214 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
3215 CUPS_VERSION_MINOR
);
3216 else if (!_cups_strcasecmp(value
, "Minimal"))
3217 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
" IPP/2.1");
3218 else if (!_cups_strcasecmp(value
, "OS"))
3219 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s) IPP/2.1",
3220 plat
.sysname
, plat
.release
);
3221 else if (!_cups_strcasecmp(value
, "Full"))
3222 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s; %s) IPP/2.1",
3223 plat
.sysname
, plat
.release
, plat
.machine
);
3224 else if (!_cups_strcasecmp(value
, "None"))
3225 cupsdClearString(&ServerHeader
);
3227 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3230 else if (!_cups_strcasecmp(line
, "PassEnv") && value
)
3233 * PassEnv variable [... variable]
3238 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3239 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3242 if (value
[valuelen
])
3244 value
[valuelen
] = '\0';
3248 cupsdSetEnv(value
, NULL
);
3250 for (value
+= valuelen
; *value
; value
++)
3251 if (!_cups_isspace(*value
) || *value
!= ',')
3255 else if (!_cups_strcasecmp(line
, "ServerAlias") && value
)
3258 * ServerAlias name [... name]
3262 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3266 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3267 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3270 if (value
[valuelen
])
3272 value
[valuelen
] = '\0';
3276 cupsdAddAlias(ServerAlias
, value
);
3278 for (value
+= valuelen
; *value
; value
++)
3279 if (!_cups_isspace(*value
) || *value
!= ',')
3283 else if (!_cups_strcasecmp(line
, "SetEnv") && value
)
3286 * SetEnv variable value
3289 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3297 while (isspace(*valueptr
& 255))
3300 cupsdSetEnv(value
, valueptr
);
3303 cupsdLogMessage(CUPSD_LOG_ERROR
,
3304 "Missing value for SetEnv directive on line %d.",
3308 else if (!_cups_strcasecmp(line
, "SSLOptions"))
3311 * SSLOptions options
3314 if (!value
|| !_cups_strcasecmp(value
, "none"))
3315 SSLOptions
= CUPSD_SSL_NONE
;
3316 else if (!_cups_strcasecmp(value
, "noemptyfragments"))
3317 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3319 cupsdLogMessage(CUPSD_LOG_ERROR
,
3320 "Unknown value \"%s\" for SSLOptions directive on "
3321 "line %d.", value
, linenum
);
3323 #endif /* HAVE_SSL */
3324 else if (!_cups_strcasecmp(line
, "AccessLog") ||
3325 !_cups_strcasecmp(line
, "CacheDir") ||
3326 !_cups_strcasecmp(line
, "ConfigFilePerm") ||
3327 !_cups_strcasecmp(line
, "DataDir") ||
3328 !_cups_strcasecmp(line
, "DocumentRoot") ||
3329 !_cups_strcasecmp(line
, "ErrorLog") ||
3330 !_cups_strcasecmp(line
, "FatalErrors") ||
3331 !_cups_strcasecmp(line
, "FileDevice") ||
3332 !_cups_strcasecmp(line
, "FontPath") ||
3333 !_cups_strcasecmp(line
, "Group") ||
3334 !_cups_strcasecmp(line
, "LogFilePerm") ||
3335 !_cups_strcasecmp(line
, "LPDConfigFile") ||
3336 !_cups_strcasecmp(line
, "PageLog") ||
3337 !_cups_strcasecmp(line
, "Printcap") ||
3338 !_cups_strcasecmp(line
, "PrintcapFormat") ||
3339 !_cups_strcasecmp(line
, "RemoteRoot") ||
3340 !_cups_strcasecmp(line
, "RequestRoot") ||
3341 !_cups_strcasecmp(line
, "ServerBin") ||
3342 !_cups_strcasecmp(line
, "ServerCertificate") ||
3343 !_cups_strcasecmp(line
, "ServerKey") ||
3344 !_cups_strcasecmp(line
, "ServerRoot") ||
3345 !_cups_strcasecmp(line
, "SMBConfigFile") ||
3346 !_cups_strcasecmp(line
, "StateDir") ||
3347 !_cups_strcasecmp(line
, "SystemGroup") ||
3348 !_cups_strcasecmp(line
, "SystemGroupAuthKey") ||
3349 !_cups_strcasecmp(line
, "TempDir") ||
3350 !_cups_strcasecmp(line
, "User"))
3352 cupsdLogMessage(CUPSD_LOG_INFO
,
3353 "Please move \"%s%s%s\" on line %d of %s to the %s file; "
3354 "this will become an error in a future release.",
3355 line
, value
? " " : "", value
? value
: "", linenum
,
3356 ConfigurationFile
, CupsFilesFile
);
3359 parse_variable(ConfigurationFile
, linenum
, line
, value
,
3360 sizeof(cupsd_vars
) / sizeof(cupsd_vars
[0]), cupsd_vars
);
3368 * 'read_cups_files_conf()' - Read the cups-files.conf configuration file.
3371 static int /* O - 1 on success, 0 on failure */
3372 read_cups_files_conf(cups_file_t
*fp
) /* I - File to read from */
3374 int linenum
; /* Current line number */
3375 char line
[HTTP_MAX_BUFFER
], /* Line from file */
3376 *value
; /* Value from line */
3377 struct group
*group
; /* Group */
3381 * Loop through each line in the file...
3386 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3388 if (!_cups_strcasecmp(line
, "FatalErrors"))
3389 FatalErrors
= parse_fatal_errors(value
);
3390 else if (!_cups_strcasecmp(line
, "Group") && value
)
3393 * Group ID to run as...
3396 if (isdigit(value
[0]))
3397 Group
= atoi(value
);
3401 group
= getgrnam(value
);
3404 Group
= group
->gr_gid
;
3407 cupsdLogMessage(CUPSD_LOG_ERROR
,
3408 "Unknown Group \"%s\" on line %d of %s.", value
,
3409 linenum
, CupsFilesFile
);
3410 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3415 else if (!_cups_strcasecmp(line
, "PrintcapFormat") && value
)
3418 * Format of printcap file?
3421 if (!_cups_strcasecmp(value
, "bsd"))
3422 PrintcapFormat
= PRINTCAP_BSD
;
3423 else if (!_cups_strcasecmp(value
, "plist"))
3424 PrintcapFormat
= PRINTCAP_PLIST
;
3425 else if (!_cups_strcasecmp(value
, "solaris"))
3426 PrintcapFormat
= PRINTCAP_SOLARIS
;
3429 cupsdLogMessage(CUPSD_LOG_ERROR
,
3430 "Unknown PrintcapFormat \"%s\" on line %d of %s.",
3431 value
, linenum
, CupsFilesFile
);
3432 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3436 else if (!_cups_strcasecmp(line
, "SystemGroup") && value
)
3439 * SystemGroup (admin) group(s)...
3442 if (!parse_groups(value
))
3444 cupsdLogMessage(CUPSD_LOG_ERROR
,
3445 "Unknown SystemGroup \"%s\" on line %d of %s.", value
,
3446 linenum
, CupsFilesFile
);
3447 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3451 else if (!_cups_strcasecmp(line
, "User") && value
)
3454 * User ID to run as...
3457 if (isdigit(value
[0] & 255))
3459 int uid
= atoi(value
);
3463 cupsdLogMessage(CUPSD_LOG_ERROR
,
3464 "Will not use User 0 as specified on line %d of %s "
3465 "for security reasons. You must use a non-"
3466 "privileged account instead.",
3467 linenum
, CupsFilesFile
);
3468 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3476 struct passwd
*p
; /* Password information */
3479 p
= getpwnam(value
);
3485 cupsdLogMessage(CUPSD_LOG_ERROR
,
3486 "Will not use User %s (UID=0) as specified on line "
3487 "%d of %s for security reasons. You must use a "
3488 "non-privileged account instead.",
3489 value
, linenum
, CupsFilesFile
);
3490 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3498 cupsdLogMessage(CUPSD_LOG_ERROR
,
3499 "Unknown User \"%s\" on line %d of %s.",
3500 value
, linenum
, CupsFilesFile
);
3501 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3506 else if (!parse_variable(CupsFilesFile
, linenum
, line
, value
,
3507 sizeof(cupsfiles_vars
) / sizeof(cupsfiles_vars
[0]),
3509 (FatalErrors
& CUPSD_FATAL_CONFIG
))
3518 * 'read_location()' - Read a <Location path> definition.
3521 static int /* O - New line number or 0 on error */
3522 read_location(cups_file_t
*fp
, /* I - Configuration file */
3523 char *location
, /* I - Location name/path */
3524 int linenum
) /* I - Current line number */
3526 cupsd_location_t
*loc
, /* New location */
3527 *parent
; /* Parent location */
3528 char line
[HTTP_MAX_BUFFER
],
3530 *value
, /* Value for directive */
3531 *valptr
; /* Pointer into value */
3534 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3535 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3537 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3541 cupsdAddLocation(parent
);
3543 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3548 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3551 * Decode the directive...
3554 if (!_cups_strcasecmp(line
, "</Location>"))
3556 else if (!_cups_strcasecmp(line
, "<Limit") ||
3557 !_cups_strcasecmp(line
, "<LimitExcept"))
3561 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3562 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3568 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3571 cupsdAddLocation(loc
);
3576 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3581 if (!strcmp(value
, "ALL"))
3582 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3583 else if (!strcmp(value
, "GET"))
3584 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3585 else if (!strcmp(value
, "HEAD"))
3586 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3587 else if (!strcmp(value
, "OPTIONS"))
3588 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3589 else if (!strcmp(value
, "POST"))
3590 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3591 else if (!strcmp(value
, "PUT"))
3592 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3593 else if (!strcmp(value
, "TRACE"))
3594 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3596 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3599 for (value
= valptr
; isspace(*value
& 255); value
++);
3602 if (!_cups_strcasecmp(line
, "<LimitExcept"))
3603 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3605 parent
->limit
&= ~loc
->limit
;
3607 else if (!_cups_strcasecmp(line
, "</Limit>") ||
3608 !_cups_strcasecmp(line
, "</LimitExcept>"))
3612 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3613 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3616 else if (!parse_aaa(loc
, line
, value
, linenum
))
3618 cupsdLogMessage(CUPSD_LOG_ERROR
,
3619 "Unknown Location directive %s on line %d.",
3621 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3626 cupsdLogMessage(CUPSD_LOG_ERROR
,
3627 "Unexpected end-of-file at line %d while reading location.",
3630 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3635 * 'read_policy()' - Read a <Policy name> definition.
3638 static int /* O - New line number or 0 on error */
3639 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3640 char *policy
, /* I - Location name/path */
3641 int linenum
) /* I - Current line number */
3643 int i
; /* Looping var */
3644 cupsd_policy_t
*pol
; /* Policy */
3645 cupsd_location_t
*op
; /* Policy operation */
3646 int num_ops
; /* Number of IPP operations */
3647 ipp_op_t ops
[100]; /* Operations */
3648 char line
[HTTP_MAX_BUFFER
],
3650 *value
, /* Value for directive */
3651 *valptr
; /* Pointer into value */
3655 * Create the policy...
3658 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3659 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3661 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3665 * Read from the file...
3671 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3674 * Decode the directive...
3677 if (!_cups_strcasecmp(line
, "</Policy>"))
3680 cupsdLogMessage(CUPSD_LOG_WARN
,
3681 "Missing </Limit> before </Policy> on line %d.",
3684 set_policy_defaults(pol
);
3688 else if (!_cups_strcasecmp(line
, "<Limit") && !op
)
3692 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3693 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3700 * Scan for IPP operation names...
3707 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3712 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3714 if (!_cups_strcasecmp(value
, "All"))
3715 ops
[num_ops
] = IPP_ANY_OPERATION
;
3716 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3717 cupsdLogMessage(CUPSD_LOG_ERROR
,
3718 "Bad IPP operation name \"%s\" on line %d.",
3724 cupsdLogMessage(CUPSD_LOG_ERROR
,
3725 "Too many operations listed on line %d.",
3728 for (value
= valptr
; isspace(*value
& 255); value
++);
3732 * If none are specified, apply the policy to all operations...
3737 ops
[0] = IPP_ANY_OPERATION
;
3742 * Add a new policy for the first operation...
3745 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3747 else if (!_cups_strcasecmp(line
, "</Limit>") && op
)
3750 * Finish the current operation limit...
3756 * Copy the policy to the other operations...
3759 for (i
= 1; i
< num_ops
; i
++)
3760 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3767 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3768 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3771 else if (!_cups_strcasecmp(line
, "JobPrivateAccess") ||
3772 !_cups_strcasecmp(line
, "JobPrivateValues") ||
3773 !_cups_strcasecmp(line
, "SubscriptionPrivateAccess") ||
3774 !_cups_strcasecmp(line
, "SubscriptionPrivateValues"))
3778 cupsdLogMessage(CUPSD_LOG_ERROR
,
3779 "%s directive must appear outside <Limit>...</Limit> "
3780 "on line %d.", line
, linenum
);
3781 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3787 * Pull out whitespace-delimited values...
3793 * Find the end of the current value...
3796 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3802 * Save it appropriately...
3805 if (!_cups_strcasecmp(line
, "JobPrivateAccess"))
3808 * JobPrivateAccess {all|default|user/group list|@@ACL}
3811 if (!_cups_strcasecmp(value
, "default"))
3813 cupsdAddString(&(pol
->job_access
), "@OWNER");
3814 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3817 cupsdAddString(&(pol
->job_access
), value
);
3819 else if (!_cups_strcasecmp(line
, "JobPrivateValues"))
3822 * JobPrivateValues {all|none|default|attribute list}
3825 if (!_cups_strcasecmp(value
, "default"))
3827 cupsdAddString(&(pol
->job_attrs
), "job-name");
3828 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3829 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3830 cupsdAddString(&(pol
->job_attrs
), "phone");
3833 cupsdAddString(&(pol
->job_attrs
), value
);
3835 else if (!_cups_strcasecmp(line
, "SubscriptionPrivateAccess"))
3838 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3841 if (!_cups_strcasecmp(value
, "default"))
3843 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3844 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3847 cupsdAddString(&(pol
->sub_access
), value
);
3849 else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
3852 * SubscriptionPrivateValues {all|none|default|attribute list}
3855 if (!_cups_strcasecmp(value
, "default"))
3857 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3858 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3859 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3860 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3861 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3864 cupsdAddString(&(pol
->sub_attrs
), value
);
3868 * Find the next string on the line...
3871 for (value
= valptr
; isspace(*value
& 255); value
++);
3877 cupsdLogMessage(CUPSD_LOG_ERROR
,
3878 "Missing <Limit ops> directive before %s on line %d.",
3880 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3883 else if (!parse_aaa(op
, line
, value
, linenum
))
3885 cupsdLogMessage(CUPSD_LOG_ERROR
,
3886 "Unknown Policy Limit directive %s on line %d.",
3889 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3894 cupsdLogMessage(CUPSD_LOG_ERROR
,
3895 "Unexpected end-of-file at line %d while reading policy "
3896 "\"%s\".", linenum
, policy
);
3898 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3903 * 'set_policy_defaults()' - Set default policy values as needed.
3907 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3909 cupsd_location_t
*op
; /* Policy operation */
3913 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3914 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3915 * upgrades do not introduce new security issues...
3918 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3919 op
->op
== IPP_ANY_OPERATION
)
3921 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3922 op
->op
!= IPP_ANY_OPERATION
)
3925 * Add a new limit for Validate-Job using the Print-Job limit as a
3929 cupsdLogMessage(CUPSD_LOG_WARN
,
3930 "No limit for Validate-Job defined in policy %s "
3931 "- using Print-Job's policy.", pol
->name
);
3933 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3936 cupsdLogMessage(CUPSD_LOG_WARN
,
3937 "No limit for Validate-Job defined in policy %s "
3938 "and no suitable template found.", pol
->name
);
3941 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3942 op
->op
== IPP_ANY_OPERATION
)
3944 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3945 op
->op
!= IPP_ANY_OPERATION
)
3948 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3952 cupsdLogMessage(CUPSD_LOG_WARN
,
3953 "No limit for Cancel-Jobs defined in policy %s "
3954 "- using Pause-Printer's policy.", pol
->name
);
3956 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3959 cupsdLogMessage(CUPSD_LOG_WARN
,
3960 "No limit for Cancel-Jobs defined in policy %s "
3961 "and no suitable template found.", pol
->name
);
3964 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3965 op
->op
== IPP_ANY_OPERATION
)
3967 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3968 op
->op
!= IPP_ANY_OPERATION
)
3971 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
3975 cupsdLogMessage(CUPSD_LOG_WARN
,
3976 "No limit for Cancel-My-Jobs defined in policy %s "
3977 "- using Send-Document's policy.", pol
->name
);
3979 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
3982 cupsdLogMessage(CUPSD_LOG_WARN
,
3983 "No limit for Cancel-My-Jobs defined in policy %s "
3984 "and no suitable template found.", pol
->name
);
3987 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
3988 op
->op
== IPP_ANY_OPERATION
)
3990 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3991 op
->op
!= IPP_ANY_OPERATION
)
3994 * Add a new limit for Close-Job using the Send-Document limit as a
3998 cupsdLogMessage(CUPSD_LOG_WARN
,
3999 "No limit for Close-Job defined in policy %s "
4000 "- using Send-Document's policy.", pol
->name
);
4002 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4005 cupsdLogMessage(CUPSD_LOG_WARN
,
4006 "No limit for Close-Job defined in policy %s "
4007 "and no suitable template found.", pol
->name
);
4010 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4011 op
->op
== IPP_ANY_OPERATION
)
4013 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4014 op
->op
!= IPP_ANY_OPERATION
)
4017 * Add a new limit for CUPS-Get-Document using the Send-Document
4018 * limit as a template...
4021 cupsdLogMessage(CUPSD_LOG_WARN
,
4022 "No limit for CUPS-Get-Document defined in policy %s "
4023 "- using Send-Document's policy.", pol
->name
);
4025 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4028 cupsdLogMessage(CUPSD_LOG_WARN
,
4029 "No limit for CUPS-Get-Document defined in policy %s "
4030 "and no suitable template found.", pol
->name
);
4034 * Verify we have JobPrivateAccess, JobPrivateValues,
4035 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4038 if (!pol
->job_access
)
4040 cupsdLogMessage(CUPSD_LOG_WARN
,
4041 "No JobPrivateAccess defined in policy %s "
4042 "- using defaults.", pol
->name
);
4043 cupsdAddString(&(pol
->job_access
), "@OWNER");
4044 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4047 if (!pol
->job_attrs
)
4049 cupsdLogMessage(CUPSD_LOG_WARN
,
4050 "No JobPrivateValues defined in policy %s "
4051 "- using defaults.", pol
->name
);
4052 cupsdAddString(&(pol
->job_attrs
), "job-name");
4053 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4054 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4055 cupsdAddString(&(pol
->job_attrs
), "phone");
4058 if (!pol
->sub_access
)
4060 cupsdLogMessage(CUPSD_LOG_WARN
,
4061 "No SubscriptionPrivateAccess defined in policy %s "
4062 "- using defaults.", pol
->name
);
4063 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4064 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4067 if (!pol
->sub_attrs
)
4069 cupsdLogMessage(CUPSD_LOG_WARN
,
4070 "No SubscriptionPrivateValues defined in policy %s "
4071 "- using defaults.", pol
->name
);
4072 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4073 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4074 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4075 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4076 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");