4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2013 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 * Include necessary headers...
23 #include <sys/utsname.h>
28 #endif /* HAVE_LIBPAPER */
32 * Possibly missing network definitions...
36 # define INADDR_NONE 0xffffffff
37 #endif /* !INADDR_NONE */
41 * Configuration variable structure...
46 CUPSD_VARTYPE_INTEGER
, /* Integer option */
47 CUPSD_VARTYPE_TIME
, /* Time interval option */
48 CUPSD_VARTYPE_STRING
, /* String option */
49 CUPSD_VARTYPE_BOOLEAN
, /* Boolean option */
50 CUPSD_VARTYPE_PATHNAME
/* File/directory name option */
55 const char *name
; /* Name of variable */
56 void *ptr
; /* Pointer to variable */
57 cupsd_vartype_t type
; /* Type (int, string, address) */
65 static const cupsd_var_t cupsd_vars
[] =
67 { "AutoPurgeJobs", &JobAutoPurge
, CUPSD_VARTYPE_BOOLEAN
},
68 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
69 { "BrowseDNSSDSubTypes", &DNSSDSubTypes
, CUPSD_VARTYPE_STRING
},
70 #endif /* HAVE_DNSSD || HAVE_AVAHI */
71 { "BrowseWebIF", &BrowseWebIF
, CUPSD_VARTYPE_BOOLEAN
},
72 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
73 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
74 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
75 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
76 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_TIME
},
77 { "DefaultPaperSize", &DefaultPaperSize
, CUPSD_VARTYPE_STRING
},
78 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
79 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
80 { "DirtyCleanInterval", &DirtyCleanInterval
, CUPSD_VARTYPE_TIME
},
81 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
82 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
83 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
85 { "GSSServiceName", &GSSServiceName
, CUPSD_VARTYPE_STRING
},
86 #endif /* HAVE_GSSAPI */
87 { "JobKillDelay", &JobKillDelay
, CUPSD_VARTYPE_TIME
},
88 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
89 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_TIME
},
90 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_TIME
},
91 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
93 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_TIME
},
94 #endif /* HAVE_LAUNCHD */
95 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
96 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
97 { "LogDebugHistory", &LogDebugHistory
, CUPSD_VARTYPE_INTEGER
},
98 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
99 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
100 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
101 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
102 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
103 { "MaxHoldTime", &MaxHoldTime
, CUPSD_VARTYPE_TIME
},
104 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
105 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
106 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
107 { "MaxJobTime", &MaxJobTime
, CUPSD_VARTYPE_INTEGER
},
108 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_TIME
},
109 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
110 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
111 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
112 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
113 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
114 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
115 { "MultipleOperationTimeout", &MultipleOperationTimeout
, CUPSD_VARTYPE_TIME
},
116 { "PageLogFormat", &PageLogFormat
, CUPSD_VARTYPE_STRING
},
117 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_TIME
},
118 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_TIME
},
119 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_TIME
},
120 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
121 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_TIME
},
122 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
123 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
124 { "StrictConformance", &StrictConformance
, CUPSD_VARTYPE_BOOLEAN
},
125 { "Timeout", &Timeout
, CUPSD_VARTYPE_TIME
},
126 { "WebInterface", &WebInterface
, CUPSD_VARTYPE_BOOLEAN
}
128 static const cupsd_var_t cupsfiles_vars
[] =
130 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
131 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
132 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
133 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
134 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
135 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
136 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
137 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
138 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
139 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
140 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
141 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
142 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
143 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
144 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
146 { "ServerKeychain", &ServerKeychain
, CUPSD_VARTYPE_PATHNAME
},
147 #endif /* HAVE_SSL */
148 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
149 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
150 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
151 { "SyncOnClose", &SyncOnClose
, CUPSD_VARTYPE_BOOLEAN
},
152 #ifdef HAVE_AUTHORIZATION_H
153 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
154 #endif /* HAVE_AUTHORIZATION_H */
155 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
}
158 static int default_auth_type
= CUPSD_AUTH_AUTO
;
159 /* Default AuthType, if not specified */
161 static const unsigned ones
[4] =
163 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
165 static const unsigned zeros
[4] =
167 0x00000000, 0x00000000, 0x00000000, 0x00000000
175 static http_addrlist_t
*get_address(const char *value
, int defport
);
176 static int get_addr_and_mask(const char *value
, unsigned *ip
,
178 static void mime_error_cb(void *ctx
, const char *message
);
179 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
180 char *value
, int linenum
);
181 static int parse_fatal_errors(const char *s
);
182 static int parse_groups(const char *s
);
183 static int parse_protocols(const char *s
);
184 static int parse_variable(const char *filename
, int linenum
,
185 const char *line
, const char *value
,
187 const cupsd_var_t
*vars
);
188 static int read_cupsd_conf(cups_file_t
*fp
);
189 static int read_cups_files_conf(cups_file_t
*fp
);
190 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
191 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
192 static void set_policy_defaults(cupsd_policy_t
*pol
);
196 * 'cupsdAddAlias()' - Add a host alias.
200 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
201 const char *name
) /* I - Name to add */
203 cupsd_alias_t
*a
; /* New alias */
204 size_t namelen
; /* Length of name */
207 namelen
= strlen(name
);
209 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
212 a
->namelen
= namelen
;
213 memcpy(a
->name
, name
, namelen
+ 1); /* OK since a->name is allocated */
215 cupsArrayAdd(aliases
, a
);
220 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
223 int /* O - 0 on success, -1 on error, 1 on warning */
224 cupsdCheckPermissions(
225 const char *filename
, /* I - File/directory name */
226 const char *suffix
, /* I - Additional file/directory name */
227 int mode
, /* I - Permissions */
228 int user
, /* I - Owner */
229 int group
, /* I - Group */
230 int is_dir
, /* I - 1 = directory, 0 = file */
231 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
233 int dir_created
= 0; /* Did we create a directory? */
234 char pathname
[1024]; /* File name with prefix */
235 struct stat fileinfo
; /* Stat buffer */
236 int is_symlink
; /* Is "filename" a symlink? */
240 * Prepend the given root to the filename before testing it...
245 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
250 * See if we can stat the file/directory...
253 if (lstat(filename
, &fileinfo
))
255 if (errno
== ENOENT
&& create_dir
)
258 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
261 if (mkdir(filename
, mode
))
264 cupsdLogMessage(CUPSD_LOG_ERROR
,
265 "Unable to create directory \"%s\" - %s", filename
,
268 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
275 fileinfo
.st_mode
= mode
| S_IFDIR
;
278 return (create_dir
? -1 : 1);
281 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
283 if (stat(filename
, &fileinfo
))
285 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
286 filename
, strerror(errno
));
292 * Make sure it's a regular file or a directory as needed...
295 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
297 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file.", filename
);
301 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
304 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory.", filename
);
306 syslog(LOG_ERR
, "\"%s\" is not a directory.", filename
);
312 * If the filename is a symlink, do not change permissions (STR #2937)...
319 * Fix owner, group, and mode as needed...
322 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
325 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
328 if (chown(filename
, user
, group
) && !getuid())
331 cupsdLogMessage(CUPSD_LOG_ERROR
,
332 "Unable to change ownership of \"%s\" - %s", filename
,
335 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
342 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
345 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
348 if (chmod(filename
, mode
))
351 cupsdLogMessage(CUPSD_LOG_ERROR
,
352 "Unable to change permissions of \"%s\" - %s", filename
,
355 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
363 * Everything is OK...
371 * 'cupsdDefaultAuthType()' - Get the default AuthType.
373 * When the default_auth_type is "auto", this function tries to get the GSS
374 * credentials for the server. If that succeeds we use Kerberos authentication,
375 * otherwise we do a fallback to Basic authentication against the local user
379 int /* O - Default AuthType value */
380 cupsdDefaultAuthType(void)
383 OM_uint32 major_status
, /* Major status code */
384 minor_status
; /* Minor status code */
385 gss_name_t server_name
; /* Server name */
386 gss_buffer_desc token
= GSS_C_EMPTY_BUFFER
;
387 /* Service name token */
388 char buf
[1024]; /* Service name buffer */
389 #endif /* HAVE_GSSAPI */
393 * If we have already determined the correct default AuthType, use it...
396 if (default_auth_type
!= CUPSD_AUTH_AUTO
)
397 return (default_auth_type
);
402 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
406 if (gss_init_sec_context
== NULL
)
407 return (default_auth_type
= CUPSD_AUTH_BASIC
);
408 # endif /* __APPLE__ */
411 * Try to obtain the server's GSS credentials (GSSServiceName@servername). If
412 * that fails we must use Basic...
415 snprintf(buf
, sizeof(buf
), "%s@%s", GSSServiceName
, ServerName
);
418 token
.length
= strlen(buf
);
419 server_name
= GSS_C_NO_NAME
;
420 major_status
= gss_import_name(&minor_status
, &token
,
421 GSS_C_NT_HOSTBASED_SERVICE
,
424 memset(&token
, 0, sizeof(token
));
426 if (GSS_ERROR(major_status
))
428 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
429 "cupsdDefaultAuthType: gss_import_name(%s) failed", buf
);
430 return (default_auth_type
= CUPSD_AUTH_BASIC
);
433 major_status
= gss_display_name(&minor_status
, server_name
, &token
, NULL
);
435 if (GSS_ERROR(major_status
))
437 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
438 "cupsdDefaultAuthType: gss_display_name(%s) failed",
440 return (default_auth_type
= CUPSD_AUTH_BASIC
);
443 cupsdLogMessage(CUPSD_LOG_DEBUG
,
444 "cupsdDefaultAuthType: Attempting to acquire Kerberos "
445 "credentials for %s...", (char *)token
.value
);
447 ServerCreds
= GSS_C_NO_CREDENTIAL
;
448 major_status
= gss_acquire_cred(&minor_status
, server_name
, GSS_C_INDEFINITE
,
449 GSS_C_NO_OID_SET
, GSS_C_ACCEPT
,
450 &ServerCreds
, NULL
, NULL
);
451 if (GSS_ERROR(major_status
))
453 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
454 "cupsdDefaultAuthType: gss_acquire_cred(%s) failed",
455 (char *)token
.value
);
456 gss_release_name(&minor_status
, &server_name
);
457 gss_release_buffer(&minor_status
, &token
);
458 return (default_auth_type
= CUPSD_AUTH_BASIC
);
461 cupsdLogMessage(CUPSD_LOG_DEBUG
,
462 "cupsdDefaultAuthType: Kerberos credentials acquired "
463 "successfully for %s.", (char *)token
.value
);
465 gss_release_name(&minor_status
, &server_name
);
466 gss_release_buffer(&minor_status
, &token
);
470 return (default_auth_type
= CUPSD_AUTH_NEGOTIATE
);
474 * No Kerberos support compiled in so just use Basic all the time...
477 return (default_auth_type
= CUPSD_AUTH_BASIC
);
478 #endif /* HAVE_GSSAPI */
483 * 'cupsdFreeAliases()' - Free all of the alias entries.
487 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
489 cupsd_alias_t
*a
; /* Current alias */
492 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
494 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
497 cupsArrayDelete(aliases
);
502 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
505 int /* O - 1 on success, 0 otherwise */
506 cupsdReadConfiguration(void)
508 int i
; /* Looping var */
509 cups_file_t
*fp
; /* Configuration file */
510 int status
; /* Return status */
511 char temp
[1024], /* Temporary buffer */
512 mimedir
[1024], /* MIME directory */
513 *slash
; /* Directory separator */
514 cups_lang_t
*language
; /* Language */
515 struct passwd
*user
; /* Default user */
516 struct group
*group
; /* Default group */
517 char *old_serverroot
, /* Old ServerRoot */
518 *old_requestroot
; /* Old RequestRoot */
519 int old_remote_port
; /* Old RemotePort */
520 const char *tmpdir
; /* TMPDIR environment variable */
521 struct stat tmpinfo
; /* Temporary directory info */
522 cupsd_policy_t
*p
; /* Policy */
526 * Save the old root paths...
529 old_serverroot
= NULL
;
530 cupsdSetString(&old_serverroot
, ServerRoot
);
531 old_requestroot
= NULL
;
532 cupsdSetString(&old_requestroot
, RequestRoot
);
535 * Reset the server configuration data...
538 cupsdDeleteAllLocations();
540 cupsdDeleteAllListeners();
542 old_remote_port
= RemotePort
;
549 cupsdFreeAliases(ServerAlias
);
552 cupsdClearString(&ServerName
);
553 cupsdClearString(&ServerAdmin
);
554 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
555 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
556 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
557 cupsdSetString(&DataDir
, CUPS_DATADIR
);
558 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
559 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
560 cupsdClearString(&ErrorLog
);
561 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
562 cupsdSetString(&PageLogFormat
,
563 "%p %u %j %T %P %C %{job-billing} "
564 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
565 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
566 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
567 cupsdSetString(&RemoteRoot
, "remroot");
568 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
570 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
572 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
573 PrintcapFormat
= PRINTCAP_SOLARIS
;
574 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
575 "/Library/Preferences/org.cups.printers.plist"))
576 PrintcapFormat
= PRINTCAP_PLIST
;
578 PrintcapFormat
= PRINTCAP_BSD
;
580 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
581 if ((slash
= strrchr(temp
, '/')) != NULL
)
584 cupsdSetString(&ServerRoot
, temp
);
586 cupsdClearString(&Classification
);
587 ClassifyOverride
= 0;
591 cupsdSetString(&ServerKeychain
, "ssl");
593 cupsdSetString(&ServerKeychain
, "/Library/Keychains/System.keychain");
594 # endif /* HAVE_GNUTLS */
595 #endif /* HAVE_SSL */
597 language
= cupsLangDefault();
599 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
600 cupsdSetString(&DefaultLanguage
, "en");
602 cupsdSetString(&DefaultLanguage
, language
->language
);
604 cupsdClearString(&DefaultPaperSize
);
606 cupsdSetString(&RIPCache
, "128m");
608 cupsdSetString(&TempDir
, NULL
);
611 cupsdSetString(&GSSServiceName
, CUPS_DEFAULT_GSSSERVICENAME
);
615 OM_uint32 minor_status
; /* Minor status code */
617 gss_release_cred(&minor_status
, &ServerCreds
);
622 ServerCreds
= GSS_C_NO_CREDENTIAL
;
623 #endif /* HAVE_GSSAPI */
626 * Find the default user...
629 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
634 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
635 * complement number...)
644 * Find the default group...
647 group
= getgrnam(CUPS_DEFAULT_GROUP
);
651 Group
= group
->gr_gid
;
655 * Fallback to group "nobody"...
658 group
= getgrnam("nobody");
662 Group
= group
->gr_gid
;
666 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
667 * complement number...)
678 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
679 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
680 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
681 default_auth_type
= CUPSD_AUTH_BASIC
;
683 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
684 #endif /* HAVE_SSL */
685 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
686 JobKillDelay
= DEFAULT_TIMEOUT
;
688 JobRetryInterval
= 300;
693 HostNameLookups
= FALSE
;
695 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
696 ListenBackLog
= SOMAXCONN
;
697 LogDebugHistory
= 200;
698 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
699 LogLevel
= CUPSD_LOG_WARN
;
700 LogTimeFormat
= CUPSD_TIME_STANDARD
;
702 MaxClientsPerHost
= 0;
703 MaxLogSize
= 1024 * 1024;
705 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
707 ReloadTimeout
= DEFAULT_KEEPALIVE
;
708 RootCertDuration
= 300;
709 StrictConformance
= FALSE
;
711 Timeout
= DEFAULT_TIMEOUT
;
712 WebInterface
= CUPS_DEFAULT_WEBIF
;
714 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
716 Browsing
= CUPS_DEFAULT_BROWSING
;
717 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
719 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
720 cupsdSetString(&DNSSDSubTypes
, "_cups,_print");
721 #endif /* HAVE_DNSSD || HAVE_AVAHI */
723 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
724 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
726 cupsdSetString(&ErrorPolicy
, "stop-printer");
728 JobHistory
= DEFAULT_HISTORY
;
729 JobFiles
= DEFAULT_FILES
;
735 MaxJobsPerPrinter
= 0;
736 MaxJobTime
= 3 * 60 * 60; /* 3 hours */
737 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
739 cupsdDeleteAllPolicies();
740 cupsdClearString(&DefaultPolicy
);
742 #ifdef HAVE_AUTHORIZATION_H
743 cupsdSetString(&SystemGroupAuthKey
, CUPS_DEFAULT_SYSTEM_AUTHKEY
);
744 #endif /* HAVE_AUTHORIZATION_H */
746 MaxSubscriptions
= 100;
747 MaxSubscriptionsPerJob
= 0;
748 MaxSubscriptionsPerPrinter
= 0;
749 MaxSubscriptionsPerUser
= 0;
750 DefaultLeaseDuration
= 86400;
751 MaxLeaseDuration
= 0;
755 #endif /* HAVE_LAUNCHD */
758 * Setup environment variables...
764 * Read the cups-files.conf file...
767 if ((fp
= cupsFileOpen(CupsFilesFile
, "r")) != NULL
)
769 status
= read_cups_files_conf(fp
);
776 printf("\"%s\" contains errors.\n", CupsFilesFile
);
778 syslog(LOG_LPR
, "Unable to read \"%s\" due to errors.",
784 else if (errno
== ENOENT
)
785 cupsdLogMessage(CUPSD_LOG_INFO
, "No %s, using defaults.", CupsFilesFile
);
788 syslog(LOG_LPR
, "Unable to open \"%s\": %s", CupsFilesFile
,
794 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
797 * Read the cupsd.conf file...
800 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
802 syslog(LOG_LPR
, "Unable to open \"%s\": %s", ConfigurationFile
,
807 status
= read_cupsd_conf(fp
);
814 printf("\"%s\" contains errors.\n", ConfigurationFile
);
816 syslog(LOG_LPR
, "Unable to read \"%s\" due to errors.",
824 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
825 RemotePort
? "enabled" : "disabled");
828 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
831 * See if the ServerName is an IP address...
837 ServerAlias
= cupsArrayNew(NULL
, NULL
);
839 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
843 if (gethostname(temp
, sizeof(temp
)))
845 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
847 strlcpy(temp
, "localhost", sizeof(temp
));
850 cupsdSetString(&ServerName
, temp
);
853 ServerAlias
= cupsArrayNew(NULL
, NULL
);
855 cupsdAddAlias(ServerAlias
, temp
);
856 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
858 if (HostNameLookups
|| RemotePort
)
860 struct hostent
*host
; /* Host entry to get FQDN */
862 if ((host
= gethostbyname(temp
)) != NULL
)
864 if (_cups_strcasecmp(temp
, host
->h_name
))
866 cupsdSetString(&ServerName
, host
->h_name
);
867 cupsdAddAlias(ServerAlias
, host
->h_name
);
868 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
874 for (i
= 0; host
->h_aliases
[i
]; i
++)
875 if (_cups_strcasecmp(temp
, host
->h_aliases
[i
]))
877 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
878 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
886 * Make sure we have the base hostname added as an alias, too!
889 if ((slash
= strchr(temp
, '.')) != NULL
)
892 cupsdAddAlias(ServerAlias
, temp
);
893 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
897 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
899 ServerNameIsIP
= !*slash
;
902 * Make sure ServerAdmin is initialized...
906 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
909 * Use the default system group if none was supplied in cupsd.conf...
912 if (NumSystemGroups
== 0)
914 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
917 * Find the group associated with GID 0...
924 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
926 cupsdSetString(&SystemGroups
[0], "unknown");
928 SystemGroupIDs
[0] = 0;
934 * Make sure ConfigFilePerm and LogFilePerm have sane values...
937 ConfigFilePerm
&= 0664;
941 * Open the system log for cupsd if necessary...
945 if (!strcmp(AccessLog
, "syslog") ||
946 !strcmp(ErrorLog
, "syslog") ||
947 !strcmp(PageLog
, "syslog"))
948 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
949 #endif /* HAVE_VSYSLOG */
952 * Make sure each of the log files exists and gets rotated as necessary...
955 if (strcmp(AccessLog
, "syslog"))
956 cupsdCheckLogFile(&AccessFile
, AccessLog
);
958 if (strcmp(ErrorLog
, "syslog"))
959 cupsdCheckLogFile(&ErrorFile
, ErrorLog
);
961 if (strcmp(PageLog
, "syslog"))
962 cupsdCheckLogFile(&PageFile
, PageLog
);
965 * Log the configuration file that was used...
968 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
972 * Validate the Group and SystemGroup settings - they cannot be the same,
973 * otherwise the CGI programs will be able to authenticate as root without
979 for (i
= 0; i
< NumSystemGroups
; i
++)
980 if (Group
== SystemGroupIDs
[i
])
983 if (i
< NumSystemGroups
)
986 * Log the error and reset the group to a safe value...
989 cupsdLogMessage(CUPSD_LOG_NOTICE
,
990 "Group and SystemGroup cannot use the same groups.");
991 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
993 group
= getgrnam("nobody");
997 Group
= group
->gr_gid
;
1001 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
1002 * complement number...)
1011 * Check that we have at least one listen/port line; if not, report this
1012 * as an error and exit!
1015 if (cupsArrayCount(Listeners
) == 0)
1021 cupsdLogMessage(CUPSD_LOG_EMERG
,
1022 "No valid Listen or Port lines were found in the "
1023 "configuration file.");
1029 cupsdEndProcess(getpid(), 0);
1033 * Set the default locale using the language and charset...
1036 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
1039 * Update all relative filenames to include the full path from ServerRoot...
1042 if (DocumentRoot
[0] != '/')
1043 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
1045 if (RequestRoot
[0] != '/')
1046 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
1048 if (ServerBin
[0] != '/')
1049 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
1051 if (StateDir
[0] != '/')
1052 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
1054 if (CacheDir
[0] != '/')
1055 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
1058 if (ServerKeychain
[0] != '/')
1059 cupsdSetStringf(&ServerKeychain
, "%s/%s", ServerRoot
, ServerKeychain
);
1061 cupsSetServerCredentials(ServerKeychain
, ServerName
, 1);
1062 #endif /* HAVE_SSL */
1065 * Make sure that directories and config files are owned and
1066 * writable by the user and group in the cupsd.conf file...
1069 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
1071 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
1073 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
1075 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
1077 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
1079 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
1080 SystemGroupIDs
[0], 1, 1) < 0 ||
1081 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
1083 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
1085 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
1087 cupsdCheckPermissions(ConfigurationFile
, NULL
, ConfigFilePerm
, RunUser
,
1089 cupsdCheckPermissions(CupsFilesFile
, NULL
, ConfigFilePerm
, RunUser
,
1091 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
1093 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
1095 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
1096 Group
, 0, 0) < 0) &&
1097 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1101 * Update TempDir to the default if it hasn't been set already...
1105 if (TempDir
&& !RunUser
&&
1106 (!strncmp(TempDir
, "/private/tmp", 12) || !strncmp(TempDir
, "/tmp", 4)))
1108 cupsdLogMessage(CUPSD_LOG_ERROR
, "Cannot use %s for TempDir.", TempDir
);
1109 cupsdClearString(&TempDir
);
1111 #endif /* __APPLE__ */
1116 if ((tmpdir
= getenv("TMPDIR")) != NULL
&&
1117 strncmp(tmpdir
, "/private/tmp", 12) && strncmp(tmpdir
, "/tmp", 4))
1119 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1120 #endif /* __APPLE__ */
1123 * TMPDIR is defined, see if it is OK for us to use...
1126 if (stat(tmpdir
, &tmpinfo
))
1127 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1128 tmpdir
, strerror(errno
));
1129 else if (!S_ISDIR(tmpinfo
.st_mode
))
1130 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1132 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1133 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1134 !(tmpinfo
.st_mode
& S_IWOTH
))
1135 cupsdLogMessage(CUPSD_LOG_ERROR
,
1136 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1138 cupsdSetString(&TempDir
, tmpdir
);
1144 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1146 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1149 setenv("TMPDIR", TempDir
, 1);
1152 * Make sure the temporary directory has the right permissions...
1155 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1159 * Update ownership and permissions if the CUPS temp directory
1160 * is under the spool directory or does not exist...
1163 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1164 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1169 * Update environment variables...
1175 * Update default paper size setting as needed...
1178 if (!DefaultPaperSize
)
1180 #ifdef HAVE_LIBPAPER
1181 char *paper_result
; /* Paper size name from libpaper */
1183 if ((paper_result
= systempapername()) != NULL
)
1184 cupsdSetString(&DefaultPaperSize
, paper_result
);
1186 #endif /* HAVE_LIBPAPER */
1187 if (!DefaultLanguage
||
1188 !_cups_strcasecmp(DefaultLanguage
, "C") ||
1189 !_cups_strcasecmp(DefaultLanguage
, "POSIX") ||
1190 !_cups_strcasecmp(DefaultLanguage
, "en") ||
1191 !_cups_strncasecmp(DefaultLanguage
, "en.", 3) ||
1192 !_cups_strncasecmp(DefaultLanguage
, "en_US", 5) ||
1193 !_cups_strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1194 !_cups_strncasecmp(DefaultLanguage
, "fr_CA", 5))
1197 * These are the only locales that will default to "letter" size...
1200 cupsdSetString(&DefaultPaperSize
, "Letter");
1203 cupsdSetString(&DefaultPaperSize
, "A4");
1207 * Update classification setting as needed...
1210 if (Classification
&& !_cups_strcasecmp(Classification
, "none"))
1211 cupsdClearString(&Classification
);
1214 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1217 * Check the MaxClients setting, and then allocate memory for it...
1220 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1223 cupsdLogMessage(CUPSD_LOG_INFO
,
1224 "MaxClients limited to 1/3 (%d) of the file descriptor "
1226 MaxFDs
/ 3, MaxFDs
);
1228 MaxClients
= MaxFDs
/ 3;
1231 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1235 * Check the MaxActiveJobs setting; limit to 1/3 the available
1236 * file descriptors, since we need a pipe for each job...
1239 if (MaxActiveJobs
> (MaxFDs
/ 3))
1240 MaxActiveJobs
= MaxFDs
/ 3;
1243 * Update the MaxClientsPerHost value, as needed...
1246 if (MaxClientsPerHost
<= 0)
1247 MaxClientsPerHost
= MaxClients
;
1249 if (MaxClientsPerHost
> MaxClients
)
1250 MaxClientsPerHost
= MaxClients
;
1252 cupsdLogMessage(CUPSD_LOG_INFO
,
1253 "Allowing up to %d client connections per host.",
1257 * Update the default policy, as needed...
1261 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1263 DefaultPolicyPtr
= NULL
;
1265 if (!DefaultPolicyPtr
)
1267 cupsd_location_t
*po
; /* New policy operation */
1271 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1274 cupsdSetString(&DefaultPolicy
, "default");
1276 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1277 cupsdLogMessage(CUPSD_LOG_INFO
,
1278 "Using policy \"default\" as the default.");
1281 cupsdLogMessage(CUPSD_LOG_INFO
,
1282 "Creating CUPS default administrative policy:");
1284 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1286 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1288 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1289 cupsdAddString(&(p
->job_access
), "@OWNER");
1290 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1292 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1293 cupsdAddString(&(p
->job_attrs
), "job-name");
1294 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1295 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1297 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1298 cupsdAddString(&(p
->sub_access
), "@OWNER");
1299 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1301 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1302 cupsdAddString(&(p
->job_attrs
), "notify-events");
1303 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1304 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1305 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1306 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1308 cupsdLogMessage(CUPSD_LOG_INFO
,
1309 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1310 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1312 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1313 po
->order_type
= CUPSD_AUTH_ALLOW
;
1315 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1316 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1317 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1319 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1321 cupsdLogMessage(CUPSD_LOG_INFO
,
1322 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1323 "Release-Job Restart-Job Purge-Jobs "
1324 "Set-Job-Attributes Create-Job-Subscription "
1325 "Renew-Subscription Cancel-Subscription "
1326 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1327 "Suspend-Current-Job Resume-Job "
1328 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1329 "CUPS-Authenticate-Job CUPS-Get-Document>");
1330 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1332 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1333 po
->order_type
= CUPSD_AUTH_ALLOW
;
1334 po
->level
= CUPSD_AUTH_USER
;
1336 cupsdAddName(po
, "@OWNER");
1337 cupsdAddName(po
, "@SYSTEM");
1338 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1340 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1341 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1342 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1343 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1344 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1345 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1346 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1347 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1348 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1349 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1350 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1351 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1352 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1353 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1354 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1355 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1356 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1357 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1358 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1359 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1361 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1363 cupsdLogMessage(CUPSD_LOG_INFO
,
1364 "<Limit Pause-Printer Resume-Printer "
1365 "Set-Printer-Attributes Enable-Printer "
1366 "Disable-Printer Pause-Printer-After-Current-Job "
1367 "Hold-New-Jobs Release-Held-New-Jobs "
1368 "Deactivate-Printer Activate-Printer Restart-Printer "
1369 "Shutdown-Printer Startup-Printer Promote-Job "
1370 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1371 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1372 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1373 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1374 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1376 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1377 po
->order_type
= CUPSD_AUTH_ALLOW
;
1378 po
->type
= CUPSD_AUTH_DEFAULT
;
1379 po
->level
= CUPSD_AUTH_USER
;
1381 cupsdAddName(po
, "@SYSTEM");
1382 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1384 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1385 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1386 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1387 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1388 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1389 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1390 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1391 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1392 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1393 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1394 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1395 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1396 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1397 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1398 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1399 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1400 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1401 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1402 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1403 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1404 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1405 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1407 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1409 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1410 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1412 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1413 po
->order_type
= CUPSD_AUTH_ALLOW
;
1415 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1416 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1420 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1421 cupsArrayCount(Policies
));
1422 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1424 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1425 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1426 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1429 * If we are doing a full reload or the server root has changed, flush
1430 * the jobs, printers, etc. and start from scratch...
1433 if (NeedReload
== RELOAD_ALL
||
1434 old_remote_port
!= RemotePort
||
1435 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1436 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1438 mime_type_t
*type
; /* Current type */
1439 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1440 /* MIME type name */
1443 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1446 * Free all memory...
1449 cupsdDeleteAllSubscriptions();
1451 cupsdDeleteAllPrinters();
1453 DefaultPrinter
= NULL
;
1455 if (MimeDatabase
!= NULL
)
1456 mimeDelete(MimeDatabase
);
1460 for (i
= 0; i
< NumMimeTypes
; i
++)
1461 _cupsStrFree(MimeTypes
[i
]);
1467 * Read the MIME type and conversion database...
1470 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1471 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1473 MimeDatabase
= mimeNew();
1474 mimeSetErrorCallback(MimeDatabase
, mime_error_cb
, NULL
);
1476 MimeDatabase
= mimeLoadTypes(MimeDatabase
, mimedir
);
1477 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1478 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1479 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1483 cupsdLogMessage(CUPSD_LOG_EMERG
,
1484 "Unable to load MIME database from \"%s\" or \"%s\".",
1485 mimedir
, ServerRoot
);
1486 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1490 cupsdLogMessage(CUPSD_LOG_INFO
,
1491 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1492 "%d filters...", mimedir
, ServerRoot
,
1493 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1496 * Create a list of MIME types for the document-format-supported
1500 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1501 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1504 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1506 cupsdLogMessage(CUPSD_LOG_ERROR
,
1507 "Unable to allocate memory for %d MIME types.",
1513 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1515 i
++, type
= mimeNextType(MimeDatabase
))
1517 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1519 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1522 if (i
< NumMimeTypes
)
1523 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1526 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1528 mime_filter_t
*filter
; /* Current filter */
1531 for (type
= mimeFirstType(MimeDatabase
);
1533 type
= mimeNextType(MimeDatabase
))
1534 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1535 type
->super
, type
->type
);
1537 for (filter
= mimeFirstFilter(MimeDatabase
);
1539 filter
= mimeNextFilter(MimeDatabase
))
1540 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1541 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1542 filter
->src
->super
, filter
->src
->type
,
1543 filter
->dst
->super
, filter
->dst
->type
,
1544 filter
->cost
, filter
->filter
);
1551 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1552 cupsdLoadBanners(temp
);
1555 * Load printers and classes...
1558 cupsdLoadAllPrinters();
1559 cupsdLoadAllClasses();
1561 cupsdCreateCommonData();
1564 * Update the printcap file as needed...
1567 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1568 cupsdWritePrintcap();
1571 * Load queued jobs...
1577 * Load subscriptions...
1580 cupsdLoadAllSubscriptions();
1582 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1587 * Not a full reload, so recreate the common printer attributes...
1590 cupsdCreateCommonData();
1593 * Update all jobs as needed...
1599 * Update all printers as needed...
1602 cupsdUpdatePrinters();
1603 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1605 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1609 * Reset the reload state...
1612 NeedReload
= RELOAD_NONE
;
1614 cupsdClearString(&old_serverroot
);
1615 cupsdClearString(&old_requestroot
);
1622 * 'get_address()' - Get an address + port number from a line.
1625 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1626 get_address(const char *value
, /* I - Value string */
1627 int defport
) /* I - Default port */
1629 char buffer
[1024], /* Hostname + port number buffer */
1630 defpname
[255], /* Default port name */
1631 *hostname
, /* Hostname or IP */
1632 *portname
; /* Port number or name */
1633 http_addrlist_t
*addrlist
; /* Address list */
1637 * Check for an empty value...
1642 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1647 * Grab a hostname and port number; if there is no colon and the port name
1648 * is only digits, then we have a port number by itself...
1651 strlcpy(buffer
, value
, sizeof(buffer
));
1653 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1660 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1665 * Use the default port...
1668 sprintf(defpname
, "%d", defport
);
1669 portname
= defpname
;
1675 * The buffer contains just a port number...
1683 if (hostname
&& !strcmp(hostname
, "*"))
1687 * Now lookup the address using httpAddrGetList()...
1690 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1691 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1692 hostname
? hostname
: "(nil)");
1699 * 'get_addr_and_mask()' - Get an IP address and netmask.
1702 static int /* O - 1 on success, 0 on failure */
1703 get_addr_and_mask(const char *value
, /* I - String from config file */
1704 unsigned *ip
, /* O - Address value */
1705 unsigned *mask
) /* O - Mask value */
1707 int i
, j
, /* Looping vars */
1708 family
, /* Address family */
1709 ipcount
; /* Count of fields in address */
1710 unsigned ipval
; /* Value */
1711 const char *maskval
, /* Pointer to start of mask value */
1712 *ptr
, /* Pointer into value */
1717 * Get the address...
1720 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1721 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1723 if ((maskval
= strchr(value
, '/')) != NULL
)
1726 maskval
= value
+ strlen(value
);
1730 * Check for an IPv6 address...
1736 * Parse hexadecimal IPv6/IPv4 address...
1741 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1745 else if (!strncmp(ptr
, "::", 2))
1747 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1749 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1754 else if (isdigit(*ptr
& 255) && strchr(ptr
+ 1, '.') && i
>= 6)
1757 * Read IPv4 dotted quad...
1760 unsigned val
[4] = { 0, 0, 0, 0 };
1761 /* IPv4 address values */
1763 ipcount
= sscanf(ptr
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2,
1767 * Range check the IP numbers...
1770 for (i
= 0; i
< ipcount
; i
++)
1775 * Merge everything into a 32-bit IPv4 address in ip[3]...
1778 ip
[3] = ((((((unsigned)val
[0] << 8) | (unsigned)val
[1]) << 8) |
1779 (unsigned)val
[2]) << 8) | (unsigned)val
[3];
1782 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1785 * If the leading words are all 0's then this is an IPv4 address...
1788 if (!val
[0] && !val
[1] && !val
[2])
1791 while (isdigit(*ptr
& 255) || *ptr
== '.')
1795 else if (isxdigit(*ptr
& 255))
1797 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1799 if (*ptr
== ':' && ptr
[1] != ':')
1808 ip
[i
/ 2] |= ipval
<< 16;
1819 if (*ptr
&& *ptr
!= '/')
1823 #endif /* AF_INET6 */
1826 * Parse dotted-decimal IPv4 address...
1829 unsigned val
[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
1833 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1836 * Range check the IP numbers...
1839 for (i
= 0; i
< ipcount
; i
++)
1844 * Merge everything into a 32-bit IPv4 address in ip[3]...
1847 ip
[3] = ((((((unsigned)val
[0] << 8) | (unsigned)val
[1]) << 8) |
1848 (unsigned)val
[2]) << 8) | (unsigned)val
[3];
1851 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1857 * Get the netmask value(s)...
1860 memset(mask
, 0, sizeof(unsigned) * 4);
1862 if (strchr(maskval
, '.'))
1865 * Get dotted-decimal mask...
1868 if (family
!= AF_INET
)
1871 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2,
1875 mask
[3] |= (((((unsigned)mask
[0] << 8) | (unsigned)mask
[1]) << 8) |
1876 (unsigned)mask
[2]) << 8;
1877 mask
[0] = mask
[1] = mask
[2] = 0;
1882 * Get address/bits format...
1888 if (family
== AF_INET6
)
1896 mask
[0] = 0xffffffff;
1898 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1901 mask
[1] = 0xffffffff;
1905 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1908 mask
[2] = 0xffffffff;
1912 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1915 mask
[3] = 0xffffffff;
1919 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1922 #endif /* AF_INET6 */
1927 mask
[0] = 0xffffffff;
1928 mask
[1] = 0xffffffff;
1929 mask
[2] = 0xffffffff;
1932 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1934 mask
[3] = 0xffffffff;
1939 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1940 "get_addr_and_mask(value=\"%s\", "
1941 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1942 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1946 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1949 if ((ip
[0] & ~mask
[0]) != 0 ||
1950 (ip
[1] & ~mask
[1]) != 0 ||
1951 (ip
[2] & ~mask
[2]) != 0 ||
1952 (ip
[3] & ~mask
[3]) != 0)
1960 * 'mime_error_cb()' - Log a MIME error.
1964 mime_error_cb(void *ctx
, /* I - Context pointer (unused) */
1965 const char *message
) /* I - Message */
1969 cupsdLogMessage(CUPSD_LOG_ERROR
, "%s", message
);
1974 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1977 static int /* O - 1 on success, 0 on failure */
1978 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1979 char *line
, /* I - Line from file */
1980 char *value
, /* I - Start of value data */
1981 int linenum
) /* I - Current line number */
1983 char *valptr
; /* Pointer into value */
1984 unsigned ip
[4], /* IP address components */
1985 mask
[4]; /* IP netmask components */
1988 if (!_cups_strcasecmp(line
, "Encryption"))
1991 * "Encryption xxx" - set required encryption level...
1994 if (!_cups_strcasecmp(value
, "never"))
1995 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1996 else if (!_cups_strcasecmp(value
, "always"))
1998 cupsdLogMessage(CUPSD_LOG_ERROR
,
1999 "Encryption value \"%s\" on line %d is invalid in this "
2000 "context. Using \"required\" instead.", value
, linenum
);
2002 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2004 else if (!_cups_strcasecmp(value
, "required"))
2005 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2006 else if (!_cups_strcasecmp(value
, "ifrequested"))
2007 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
2010 cupsdLogMessage(CUPSD_LOG_ERROR
,
2011 "Unknown Encryption value %s on line %d.", value
, linenum
);
2015 else if (!_cups_strcasecmp(line
, "Order"))
2018 * "Order Deny,Allow" or "Order Allow,Deny"...
2021 if (!_cups_strncasecmp(value
, "deny", 4))
2022 loc
->order_type
= CUPSD_AUTH_ALLOW
;
2023 else if (!_cups_strncasecmp(value
, "allow", 5))
2024 loc
->order_type
= CUPSD_AUTH_DENY
;
2027 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
2032 else if (!_cups_strcasecmp(line
, "Allow") || !_cups_strcasecmp(line
, "Deny"))
2035 * Allow [From] host/ip...
2036 * Deny [From] host/ip...
2041 if (!_cups_strncasecmp(value
, "from", 4))
2044 * Strip leading "from"...
2049 while (_cups_isspace(*value
))
2057 * Find the end of the value...
2060 for (valptr
= value
; *valptr
&& !_cups_isspace(*valptr
); valptr
++);
2062 while (_cups_isspace(*valptr
))
2066 * Figure out what form the allow/deny address takes:
2077 * nnn.nnn.nnn.nnn/mm
2078 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2081 if (!_cups_strcasecmp(value
, "all"))
2087 if (!_cups_strcasecmp(line
, "Allow"))
2088 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
2090 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
2092 else if (!_cups_strcasecmp(value
, "none"))
2098 if (!_cups_strcasecmp(line
, "Allow"))
2099 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
2101 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
2104 else if (value
[0] == '*' || value
[0] == '.' ||
2105 (!isdigit(value
[0] & 255) && value
[0] != '['))
2107 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2108 #endif /* AF_INET6 */
2111 * Host or domain name...
2114 if (value
[0] == '*')
2117 if (!_cups_strcasecmp(line
, "Allow"))
2118 cupsdAddNameMask(&(loc
->allow
), value
);
2120 cupsdAddNameMask(&(loc
->deny
), value
);
2125 * One of many IP address forms...
2128 if (!get_addr_and_mask(value
, ip
, mask
))
2130 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2135 if (!_cups_strcasecmp(line
, "Allow"))
2136 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
2138 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
2142 * Advance to next value...
2148 else if (!_cups_strcasecmp(line
, "AuthType"))
2151 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2154 if (!_cups_strcasecmp(value
, "none"))
2156 loc
->type
= CUPSD_AUTH_NONE
;
2157 loc
->level
= CUPSD_AUTH_ANON
;
2159 else if (!_cups_strcasecmp(value
, "basic"))
2161 loc
->type
= CUPSD_AUTH_BASIC
;
2163 if (loc
->level
== CUPSD_AUTH_ANON
)
2164 loc
->level
= CUPSD_AUTH_USER
;
2166 else if (!_cups_strcasecmp(value
, "digest"))
2168 loc
->type
= CUPSD_AUTH_DIGEST
;
2170 if (loc
->level
== CUPSD_AUTH_ANON
)
2171 loc
->level
= CUPSD_AUTH_USER
;
2173 else if (!_cups_strcasecmp(value
, "basicdigest"))
2175 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2177 if (loc
->level
== CUPSD_AUTH_ANON
)
2178 loc
->level
= CUPSD_AUTH_USER
;
2180 else if (!_cups_strcasecmp(value
, "default"))
2182 loc
->type
= CUPSD_AUTH_DEFAULT
;
2184 if (loc
->level
== CUPSD_AUTH_ANON
)
2185 loc
->level
= CUPSD_AUTH_USER
;
2188 else if (!_cups_strcasecmp(value
, "negotiate"))
2190 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2192 if (loc
->level
== CUPSD_AUTH_ANON
)
2193 loc
->level
= CUPSD_AUTH_USER
;
2195 #endif /* HAVE_GSSAPI */
2198 cupsdLogMessage(CUPSD_LOG_WARN
,
2199 "Unknown authorization type %s on line %d.",
2204 else if (!_cups_strcasecmp(line
, "AuthClass"))
2207 * AuthClass anonymous, user, system, group
2210 if (!_cups_strcasecmp(value
, "anonymous"))
2212 loc
->type
= CUPSD_AUTH_NONE
;
2213 loc
->level
= CUPSD_AUTH_ANON
;
2215 cupsdLogMessage(CUPSD_LOG_WARN
,
2216 "\"AuthClass %s\" is deprecated; consider removing "
2220 else if (!_cups_strcasecmp(value
, "user"))
2222 loc
->level
= CUPSD_AUTH_USER
;
2224 cupsdLogMessage(CUPSD_LOG_WARN
,
2225 "\"AuthClass %s\" is deprecated; consider using "
2226 "\"Require valid-user\" on line %d.",
2229 else if (!_cups_strcasecmp(value
, "group"))
2231 loc
->level
= CUPSD_AUTH_GROUP
;
2233 cupsdLogMessage(CUPSD_LOG_WARN
,
2234 "\"AuthClass %s\" is deprecated; consider using "
2235 "\"Require user @groupname\" on line %d.",
2238 else if (!_cups_strcasecmp(value
, "system"))
2240 loc
->level
= CUPSD_AUTH_GROUP
;
2242 cupsdAddName(loc
, "@SYSTEM");
2244 cupsdLogMessage(CUPSD_LOG_WARN
,
2245 "\"AuthClass %s\" is deprecated; consider using "
2246 "\"Require user @SYSTEM\" on line %d.",
2251 cupsdLogMessage(CUPSD_LOG_WARN
,
2252 "Unknown authorization class %s on line %d.",
2257 else if (!_cups_strcasecmp(line
, "AuthGroupName"))
2259 cupsdAddName(loc
, value
);
2261 cupsdLogMessage(CUPSD_LOG_WARN
,
2262 "\"AuthGroupName %s\" directive is deprecated; consider "
2263 "using \"Require user @%s\" on line %d.",
2264 value
, value
, linenum
);
2266 else if (!_cups_strcasecmp(line
, "Require"))
2269 * Apache synonym for AuthClass and AuthGroupName...
2273 * Require valid-user
2274 * Require group names
2275 * Require user names
2278 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2283 if (!_cups_strcasecmp(value
, "valid-user") ||
2284 !_cups_strcasecmp(value
, "user"))
2285 loc
->level
= CUPSD_AUTH_USER
;
2286 else if (!_cups_strcasecmp(value
, "group"))
2287 loc
->level
= CUPSD_AUTH_GROUP
;
2290 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2296 * Get the list of names from the line...
2299 for (value
= valptr
; *value
;)
2301 while (_cups_isspace(*value
))
2304 #ifdef HAVE_AUTHORIZATION_H
2305 if (!strncmp(value
, "@AUTHKEY(", 9))
2308 * Grab "@AUTHKEY(name)" value...
2311 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2317 #endif /* HAVE_AUTHORIZATION_H */
2318 if (*value
== '\"' || *value
== '\'')
2321 * Grab quoted name...
2324 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2331 * Grab literal name.
2334 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2340 cupsdAddName(loc
, value
);
2342 for (value
= valptr
; _cups_isspace(*value
); value
++);
2345 else if (!_cups_strcasecmp(line
, "Satisfy"))
2347 if (!_cups_strcasecmp(value
, "all"))
2348 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2349 else if (!_cups_strcasecmp(value
, "any"))
2350 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2353 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2366 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2369 static int /* O - FatalErrors bits */
2370 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2372 int fatal
; /* FatalErrors bits */
2373 char value
[1024], /* Value string */
2374 *valstart
, /* Pointer into value */
2375 *valend
; /* End of value */
2379 * Empty FatalErrors line yields NULL pointer...
2383 return (CUPSD_FATAL_NONE
);
2386 * Loop through the value string,...
2389 strlcpy(value
, s
, sizeof(value
));
2391 fatal
= CUPSD_FATAL_NONE
;
2393 for (valstart
= value
; *valstart
;)
2396 * Get the current space/comma-delimited kind name...
2399 for (valend
= valstart
; *valend
; valend
++)
2400 if (_cups_isspace(*valend
) || *valend
== ',')
2407 * Add the error to the bitmask...
2410 if (!_cups_strcasecmp(valstart
, "all"))
2411 fatal
= CUPSD_FATAL_ALL
;
2412 else if (!_cups_strcasecmp(valstart
, "browse"))
2413 fatal
|= CUPSD_FATAL_BROWSE
;
2414 else if (!_cups_strcasecmp(valstart
, "-browse"))
2415 fatal
&= ~CUPSD_FATAL_BROWSE
;
2416 else if (!_cups_strcasecmp(valstart
, "config"))
2417 fatal
|= CUPSD_FATAL_CONFIG
;
2418 else if (!_cups_strcasecmp(valstart
, "-config"))
2419 fatal
&= ~CUPSD_FATAL_CONFIG
;
2420 else if (!_cups_strcasecmp(valstart
, "listen"))
2421 fatal
|= CUPSD_FATAL_LISTEN
;
2422 else if (!_cups_strcasecmp(valstart
, "-listen"))
2423 fatal
&= ~CUPSD_FATAL_LISTEN
;
2424 else if (!_cups_strcasecmp(valstart
, "log"))
2425 fatal
|= CUPSD_FATAL_LOG
;
2426 else if (!_cups_strcasecmp(valstart
, "-log"))
2427 fatal
&= ~CUPSD_FATAL_LOG
;
2428 else if (!_cups_strcasecmp(valstart
, "permissions"))
2429 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2430 else if (!_cups_strcasecmp(valstart
, "-permissions"))
2431 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2432 else if (_cups_strcasecmp(valstart
, "none"))
2433 cupsdLogMessage(CUPSD_LOG_ERROR
,
2434 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2436 for (valstart
= valend
; *valstart
; valstart
++)
2437 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2446 * 'parse_groups()' - Parse system group names in a string.
2449 static int /* O - 1 on success, 0 on failure */
2450 parse_groups(const char *s
) /* I - Space-delimited groups */
2452 int status
; /* Return status */
2453 char value
[1024], /* Value string */
2454 *valstart
, /* Pointer into value */
2455 *valend
, /* End of value */
2456 quote
; /* Quote character */
2457 struct group
*group
; /* Group */
2461 * Make a copy of the string and parse out the groups...
2464 strlcpy(value
, s
, sizeof(value
));
2469 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2471 if (*valstart
== '\'' || *valstart
== '\"')
2474 * Scan quoted name...
2477 quote
= *valstart
++;
2479 for (valend
= valstart
; *valend
; valend
++)
2480 if (*valend
== quote
)
2486 * Scan space or comma-delimited name...
2489 for (valend
= valstart
; *valend
; valend
++)
2490 if (_cups_isspace(*valend
) || *valend
== ',')
2497 group
= getgrnam(valstart
);
2500 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2501 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2512 while (*valstart
== ',' || _cups_isspace(*valstart
))
2521 * 'parse_protocols()' - Parse browse protocols in a string.
2524 static int /* O - Browse protocol bits */
2525 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2527 int protocols
; /* Browse protocol bits */
2528 char value
[1024], /* Value string */
2529 *valstart
, /* Pointer into value */
2530 *valend
; /* End of value */
2534 * Empty protocol line yields NULL pointer...
2541 * Loop through the value string,...
2544 strlcpy(value
, s
, sizeof(value
));
2548 for (valstart
= value
; *valstart
;)
2551 * Get the current space/comma-delimited protocol name...
2554 for (valend
= valstart
; *valend
; valend
++)
2555 if (_cups_isspace(*valend
) || *valend
== ',')
2562 * Add the protocol to the bitmask...
2565 if (!_cups_strcasecmp(valstart
, "dnssd") ||
2566 !_cups_strcasecmp(valstart
, "dns-sd") ||
2567 !_cups_strcasecmp(valstart
, "bonjour"))
2568 protocols
|= BROWSE_DNSSD
;
2569 else if (!_cups_strcasecmp(valstart
, "all"))
2570 protocols
|= BROWSE_ALL
;
2571 else if (_cups_strcasecmp(valstart
, "none"))
2572 cupsdLogMessage(CUPSD_LOG_ERROR
,
2573 "Unknown browse protocol \"%s\" ignored.", valstart
);
2575 for (valstart
= valend
; *valstart
; valstart
++)
2576 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2585 * 'parse_variable()' - Parse a variable line.
2588 static int /* O - 1 on success, 0 on failure */
2590 const char *filename
, /* I - Name of configuration file */
2591 int linenum
, /* I - Line in configuration file */
2592 const char *line
, /* I - Line from configuration file */
2593 const char *value
, /* I - Value from configuration file */
2594 size_t num_vars
, /* I - Number of variables */
2595 const cupsd_var_t
*vars
) /* I - Variables */
2597 size_t i
; /* Looping var */
2598 const cupsd_var_t
*var
; /* Variables */
2599 char temp
[1024]; /* Temporary string */
2602 for (i
= num_vars
, var
= vars
; i
> 0; i
--, var
++)
2603 if (!_cups_strcasecmp(line
, var
->name
))
2609 * Unknown directive! Output an error message and continue...
2613 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d of %s.",
2614 line
, linenum
, filename
);
2616 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d of %s.",
2617 line
, linenum
, filename
);
2624 case CUPSD_VARTYPE_INTEGER
:
2627 cupsdLogMessage(CUPSD_LOG_ERROR
,
2628 "Missing integer value for %s on line %d of %s.",
2629 line
, linenum
, filename
);
2632 else if (!isdigit(*value
& 255))
2634 cupsdLogMessage(CUPSD_LOG_ERROR
,
2635 "Bad integer value for %s on line %d of %s.",
2636 line
, linenum
, filename
);
2642 char *units
; /* Units */
2644 n
= strtol(value
, &units
, 0);
2646 if (units
&& *units
)
2648 if (tolower(units
[0] & 255) == 'g')
2649 n
*= 1024 * 1024 * 1024;
2650 else if (tolower(units
[0] & 255) == 'm')
2652 else if (tolower(units
[0] & 255) == 'k')
2654 else if (tolower(units
[0] & 255) == 't')
2658 cupsdLogMessage(CUPSD_LOG_ERROR
,
2659 "Unknown integer value for %s on line %d of %s.",
2660 line
, linenum
, filename
);
2667 cupsdLogMessage(CUPSD_LOG_ERROR
,
2668 "Bad negative integer value for %s on line %d of "
2669 "%s.", line
, linenum
, filename
);
2674 *((int *)var
->ptr
) = n
;
2679 case CUPSD_VARTYPE_TIME
:
2682 cupsdLogMessage(CUPSD_LOG_ERROR
,
2683 "Missing time interval value for %s on line %d of "
2684 "%s.", line
, linenum
, filename
);
2687 else if (!_cups_strncasecmp(line
, "PreserveJob", 11) &&
2688 (!_cups_strcasecmp(value
, "true") ||
2689 !_cups_strcasecmp(value
, "on") ||
2690 !_cups_strcasecmp(value
, "enabled") ||
2691 !_cups_strcasecmp(value
, "yes")))
2693 *((int *)var
->ptr
) = INT_MAX
;
2695 else if (!_cups_strcasecmp(value
, "false") ||
2696 !_cups_strcasecmp(value
, "off") ||
2697 !_cups_strcasecmp(value
, "disabled") ||
2698 !_cups_strcasecmp(value
, "no"))
2700 *((int *)var
->ptr
) = 0;
2702 else if (!isdigit(*value
& 255))
2704 cupsdLogMessage(CUPSD_LOG_ERROR
,
2705 "Unknown time interval value for %s on line %d of "
2706 "%s.", line
, linenum
, filename
);
2711 double n
; /* Number */
2712 char *units
; /* Units */
2714 n
= strtod(value
, &units
);
2716 if (units
&& *units
)
2718 if (tolower(units
[0] & 255) == 'w')
2719 n
*= 7 * 24 * 60 * 60;
2720 else if (tolower(units
[0] & 255) == 'd')
2722 else if (tolower(units
[0] & 255) == 'h')
2724 else if (tolower(units
[0] & 255) == 'm')
2728 cupsdLogMessage(CUPSD_LOG_ERROR
,
2729 "Unknown time interval value for %s on line "
2730 "%d of %s.", line
, linenum
, filename
);
2735 if (n
< 0.0 || n
> INT_MAX
)
2737 cupsdLogMessage(CUPSD_LOG_ERROR
,
2738 "Bad time value for %s on line %d of %s.",
2739 line
, linenum
, filename
);
2744 *((int *)var
->ptr
) = (int)n
;
2749 case CUPSD_VARTYPE_BOOLEAN
:
2752 cupsdLogMessage(CUPSD_LOG_ERROR
,
2753 "Missing boolean value for %s on line %d of %s.",
2754 line
, linenum
, filename
);
2757 else if (!_cups_strcasecmp(value
, "true") ||
2758 !_cups_strcasecmp(value
, "on") ||
2759 !_cups_strcasecmp(value
, "enabled") ||
2760 !_cups_strcasecmp(value
, "yes") ||
2763 *((int *)var
->ptr
) = TRUE
;
2765 else if (!_cups_strcasecmp(value
, "false") ||
2766 !_cups_strcasecmp(value
, "off") ||
2767 !_cups_strcasecmp(value
, "disabled") ||
2768 !_cups_strcasecmp(value
, "no") ||
2769 !_cups_strcasecmp(value
, "0"))
2771 *((int *)var
->ptr
) = FALSE
;
2775 cupsdLogMessage(CUPSD_LOG_ERROR
,
2776 "Unknown boolean value %s on line %d of %s.",
2777 value
, linenum
, filename
);
2782 case CUPSD_VARTYPE_PATHNAME
:
2785 cupsdLogMessage(CUPSD_LOG_ERROR
,
2786 "Missing pathname value for %s on line %d of %s.",
2787 line
, linenum
, filename
);
2791 if (value
[0] == '/')
2792 strlcpy(temp
, value
, sizeof(temp
));
2794 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
2796 if (access(temp
, 0))
2798 cupsdLogMessage(CUPSD_LOG_ERROR
,
2799 "File or directory for \"%s %s\" on line %d of %s "
2800 "does not exist.", line
, value
, linenum
, filename
);
2804 cupsdSetString((char **)var
->ptr
, temp
);
2807 case CUPSD_VARTYPE_STRING
:
2808 cupsdSetString((char **)var
->ptr
, value
);
2817 * 'read_cupsd_conf()' - Read the cupsd.conf configuration file.
2820 static int /* O - 1 on success, 0 on failure */
2821 read_cupsd_conf(cups_file_t
*fp
) /* I - File to read from */
2823 int linenum
; /* Current line number */
2824 char line
[HTTP_MAX_BUFFER
],
2825 /* Line from file */
2826 temp
[HTTP_MAX_BUFFER
],
2827 /* Temporary buffer for value */
2828 *value
, /* Pointer to value */
2829 *valueptr
; /* Pointer into value */
2830 int valuelen
; /* Length of value */
2831 http_addrlist_t
*addrlist
, /* Address list */
2832 *addr
; /* Current address */
2833 cups_file_t
*incfile
; /* Include file */
2834 char incname
[1024]; /* Include filename */
2838 * Loop through each line in the file...
2843 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2846 * Decode the directive...
2849 if (!_cups_strcasecmp(line
, "Include") && value
)
2855 if (value
[0] == '/')
2856 strlcpy(incname
, value
, sizeof(incname
));
2858 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2860 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2861 cupsdLogMessage(CUPSD_LOG_ERROR
,
2862 "Unable to include config file \"%s\" - %s",
2863 incname
, strerror(errno
));
2866 read_cupsd_conf(incfile
);
2867 cupsFileClose(incfile
);
2870 else if (!_cups_strcasecmp(line
, "<Location") && value
)
2876 linenum
= read_location(fp
, value
, linenum
);
2880 else if (!_cups_strcasecmp(line
, "<Policy") && value
)
2886 linenum
= read_policy(fp
, value
, linenum
);
2890 else if (!_cups_strcasecmp(line
, "FaxRetryInterval") && value
)
2892 JobRetryInterval
= atoi(value
);
2893 cupsdLogMessage(CUPSD_LOG_WARN
,
2894 "FaxRetryInterval is deprecated; use "
2895 "JobRetryInterval on line %d.", linenum
);
2897 else if (!_cups_strcasecmp(line
, "FaxRetryLimit") && value
)
2899 JobRetryLimit
= atoi(value
);
2900 cupsdLogMessage(CUPSD_LOG_WARN
,
2901 "FaxRetryLimit is deprecated; use "
2902 "JobRetryLimit on line %d.", linenum
);
2904 else if ((!_cups_strcasecmp(line
, "Port") || !_cups_strcasecmp(line
, "Listen")
2906 || !_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen")
2907 #endif /* HAVE_SSL */
2911 * Add listening address(es) to the list...
2914 cupsd_listener_t
*lis
; /* New listeners array */
2918 * Get the address list...
2921 addrlist
= get_address(value
, IPP_PORT
);
2925 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2931 * Add each address...
2934 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2937 * See if this address is already present...
2940 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2942 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2943 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2944 httpAddrPort(&(addr
->addr
)) == httpAddrPort(&(lis
->address
)))
2949 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2950 cupsdLogMessage(CUPSD_LOG_WARN
,
2951 "Duplicate listen address \"%s\" ignored.", temp
);
2956 * Allocate another listener...
2960 Listeners
= cupsArrayNew(NULL
, NULL
);
2964 cupsdLogMessage(CUPSD_LOG_ERROR
,
2965 "Unable to allocate %s at line %d - %s.",
2966 line
, linenum
, strerror(errno
));
2970 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2972 cupsdLogMessage(CUPSD_LOG_ERROR
,
2973 "Unable to allocate %s at line %d - %s.",
2974 line
, linenum
, strerror(errno
));
2978 cupsArrayAdd(Listeners
, lis
);
2981 * Copy the current address and log it...
2984 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2988 if (!_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen"))
2989 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2990 #endif /* HAVE_SSL */
2992 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2995 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2996 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2998 #endif /* AF_LOCAL */
2999 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
3000 httpAddrPort(&(lis
->address
)),
3001 httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
3003 if (!httpAddrLocalhost(&(lis
->address
)))
3004 RemotePort
= httpAddrPort(&(lis
->address
));
3011 httpAddrFreeList(addrlist
);
3013 else if (!_cups_strcasecmp(line
, "BrowseProtocols") ||
3014 !_cups_strcasecmp(line
, "BrowseLocalProtocols"))
3017 * "BrowseProtocols name [... name]"
3018 * "BrowseLocalProtocols name [... name]"
3021 int protocols
= parse_protocols(value
);
3025 cupsdLogMessage(CUPSD_LOG_ERROR
,
3026 "Unknown browse protocol \"%s\" on line %d.",
3031 BrowseLocalProtocols
= protocols
;
3033 else if (!_cups_strcasecmp(line
, "DefaultAuthType") && value
)
3036 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3039 if (!_cups_strcasecmp(value
, "none"))
3040 default_auth_type
= CUPSD_AUTH_NONE
;
3041 else if (!_cups_strcasecmp(value
, "basic"))
3042 default_auth_type
= CUPSD_AUTH_BASIC
;
3043 else if (!_cups_strcasecmp(value
, "digest"))
3044 default_auth_type
= CUPSD_AUTH_DIGEST
;
3045 else if (!_cups_strcasecmp(value
, "basicdigest"))
3046 default_auth_type
= CUPSD_AUTH_BASICDIGEST
;
3048 else if (!_cups_strcasecmp(value
, "negotiate"))
3049 default_auth_type
= CUPSD_AUTH_NEGOTIATE
;
3050 #endif /* HAVE_GSSAPI */
3051 else if (!_cups_strcasecmp(value
, "auto"))
3052 default_auth_type
= CUPSD_AUTH_AUTO
;
3055 cupsdLogMessage(CUPSD_LOG_WARN
,
3056 "Unknown default authorization type %s on line %d.",
3058 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3063 else if (!_cups_strcasecmp(line
, "DefaultEncryption"))
3066 * DefaultEncryption {Never,IfRequested,Required}
3069 if (!value
|| !_cups_strcasecmp(value
, "never"))
3070 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3071 else if (!_cups_strcasecmp(value
, "required"))
3072 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3073 else if (!_cups_strcasecmp(value
, "ifrequested"))
3074 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3077 cupsdLogMessage(CUPSD_LOG_WARN
,
3078 "Unknown default encryption %s on line %d.",
3080 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3084 #endif /* HAVE_SSL */
3085 else if (!_cups_strcasecmp(line
, "HostNameLookups") && value
)
3088 * Do hostname lookups?
3091 if (!_cups_strcasecmp(value
, "off") || !_cups_strcasecmp(value
, "no") ||
3092 !_cups_strcasecmp(value
, "false"))
3093 HostNameLookups
= 0;
3094 else if (!_cups_strcasecmp(value
, "on") || !_cups_strcasecmp(value
, "yes") ||
3095 !_cups_strcasecmp(value
, "true"))
3096 HostNameLookups
= 1;
3097 else if (!_cups_strcasecmp(value
, "double"))
3098 HostNameLookups
= 2;
3100 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3103 else if (!_cups_strcasecmp(line
, "AccessLogLevel") && value
)
3106 * Amount of logging to do to access log...
3109 if (!_cups_strcasecmp(value
, "all"))
3110 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3111 else if (!_cups_strcasecmp(value
, "actions"))
3112 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3113 else if (!_cups_strcasecmp(value
, "config"))
3114 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3116 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3119 else if (!_cups_strcasecmp(line
, "LogLevel") && value
)
3122 * Amount of logging to do to error log...
3125 if (!_cups_strcasecmp(value
, "debug2"))
3126 LogLevel
= CUPSD_LOG_DEBUG2
;
3127 else if (!_cups_strcasecmp(value
, "debug"))
3128 LogLevel
= CUPSD_LOG_DEBUG
;
3129 else if (!_cups_strcasecmp(value
, "info"))
3130 LogLevel
= CUPSD_LOG_INFO
;
3131 else if (!_cups_strcasecmp(value
, "notice"))
3132 LogLevel
= CUPSD_LOG_NOTICE
;
3133 else if (!_cups_strcasecmp(value
, "warn"))
3134 LogLevel
= CUPSD_LOG_WARN
;
3135 else if (!_cups_strcasecmp(value
, "error"))
3136 LogLevel
= CUPSD_LOG_ERROR
;
3137 else if (!_cups_strcasecmp(value
, "crit"))
3138 LogLevel
= CUPSD_LOG_CRIT
;
3139 else if (!_cups_strcasecmp(value
, "alert"))
3140 LogLevel
= CUPSD_LOG_ALERT
;
3141 else if (!_cups_strcasecmp(value
, "emerg"))
3142 LogLevel
= CUPSD_LOG_EMERG
;
3143 else if (!_cups_strcasecmp(value
, "none"))
3144 LogLevel
= CUPSD_LOG_NONE
;
3146 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3149 else if (!_cups_strcasecmp(line
, "LogTimeFormat") && value
)
3152 * Amount of logging to do to error log...
3155 if (!_cups_strcasecmp(value
, "standard"))
3156 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3157 else if (!_cups_strcasecmp(value
, "usecs"))
3158 LogTimeFormat
= CUPSD_TIME_USECS
;
3160 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3163 else if (!_cups_strcasecmp(line
, "ServerTokens") && value
)
3166 * Set the string used for the Server header...
3169 struct utsname plat
; /* Platform info */
3174 if (!_cups_strcasecmp(value
, "ProductOnly"))
3175 cupsdSetString(&ServerHeader
, "CUPS IPP");
3176 else if (!_cups_strcasecmp(value
, "Major"))
3177 cupsdSetStringf(&ServerHeader
, "CUPS/%d IPP/2", CUPS_VERSION_MAJOR
);
3178 else if (!_cups_strcasecmp(value
, "Minor"))
3179 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
3180 CUPS_VERSION_MINOR
);
3181 else if (!_cups_strcasecmp(value
, "Minimal"))
3182 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
" IPP/2.1");
3183 else if (!_cups_strcasecmp(value
, "OS"))
3184 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s) IPP/2.1",
3185 plat
.sysname
, plat
.release
);
3186 else if (!_cups_strcasecmp(value
, "Full"))
3187 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s; %s) IPP/2.1",
3188 plat
.sysname
, plat
.release
, plat
.machine
);
3189 else if (!_cups_strcasecmp(value
, "None"))
3190 cupsdClearString(&ServerHeader
);
3192 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3195 else if (!_cups_strcasecmp(line
, "PassEnv") && value
)
3198 * PassEnv variable [... variable]
3203 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3204 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3207 if (value
[valuelen
])
3209 value
[valuelen
] = '\0';
3213 cupsdSetEnv(value
, NULL
);
3215 for (value
+= valuelen
; *value
; value
++)
3216 if (!_cups_isspace(*value
) || *value
!= ',')
3220 else if (!_cups_strcasecmp(line
, "ServerAlias") && value
)
3223 * ServerAlias name [... name]
3227 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3231 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3232 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3235 if (value
[valuelen
])
3237 value
[valuelen
] = '\0';
3241 cupsdAddAlias(ServerAlias
, value
);
3243 for (value
+= valuelen
; *value
; value
++)
3244 if (!_cups_isspace(*value
) || *value
!= ',')
3248 else if (!_cups_strcasecmp(line
, "SetEnv") && value
)
3251 * SetEnv variable value
3254 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3262 while (isspace(*valueptr
& 255))
3265 cupsdSetEnv(value
, valueptr
);
3268 cupsdLogMessage(CUPSD_LOG_ERROR
,
3269 "Missing value for SetEnv directive on line %d.",
3272 else if (!_cups_strcasecmp(line
, "AccessLog") ||
3273 !_cups_strcasecmp(line
, "CacheDir") ||
3274 !_cups_strcasecmp(line
, "ConfigFilePerm") ||
3275 !_cups_strcasecmp(line
, "DataDir") ||
3276 !_cups_strcasecmp(line
, "DocumentRoot") ||
3277 !_cups_strcasecmp(line
, "ErrorLog") ||
3278 !_cups_strcasecmp(line
, "FatalErrors") ||
3279 !_cups_strcasecmp(line
, "FileDevice") ||
3280 !_cups_strcasecmp(line
, "FontPath") ||
3281 !_cups_strcasecmp(line
, "Group") ||
3282 !_cups_strcasecmp(line
, "LogFilePerm") ||
3283 !_cups_strcasecmp(line
, "LPDConfigFile") ||
3284 !_cups_strcasecmp(line
, "PageLog") ||
3285 !_cups_strcasecmp(line
, "Printcap") ||
3286 !_cups_strcasecmp(line
, "PrintcapFormat") ||
3287 !_cups_strcasecmp(line
, "RemoteRoot") ||
3288 !_cups_strcasecmp(line
, "RequestRoot") ||
3289 !_cups_strcasecmp(line
, "ServerBin") ||
3290 !_cups_strcasecmp(line
, "ServerCertificate") ||
3291 !_cups_strcasecmp(line
, "ServerKey") ||
3292 !_cups_strcasecmp(line
, "ServerKeychain") ||
3293 !_cups_strcasecmp(line
, "ServerRoot") ||
3294 !_cups_strcasecmp(line
, "SMBConfigFile") ||
3295 !_cups_strcasecmp(line
, "StateDir") ||
3296 !_cups_strcasecmp(line
, "SystemGroup") ||
3297 !_cups_strcasecmp(line
, "SystemGroupAuthKey") ||
3298 !_cups_strcasecmp(line
, "TempDir") ||
3299 !_cups_strcasecmp(line
, "User"))
3301 cupsdLogMessage(CUPSD_LOG_INFO
,
3302 "Please move \"%s%s%s\" on line %d of %s to the %s file; "
3303 "this will become an error in a future release.",
3304 line
, value
? " " : "", value
? value
: "", linenum
,
3305 ConfigurationFile
, CupsFilesFile
);
3308 parse_variable(ConfigurationFile
, linenum
, line
, value
,
3309 sizeof(cupsd_vars
) / sizeof(cupsd_vars
[0]), cupsd_vars
);
3317 * 'read_cups_files_conf()' - Read the cups-files.conf configuration file.
3320 static int /* O - 1 on success, 0 on failure */
3321 read_cups_files_conf(cups_file_t
*fp
) /* I - File to read from */
3323 int linenum
; /* Current line number */
3324 char line
[HTTP_MAX_BUFFER
], /* Line from file */
3325 *value
; /* Value from line */
3326 struct group
*group
; /* Group */
3330 * Loop through each line in the file...
3335 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3337 if (!_cups_strcasecmp(line
, "FatalErrors"))
3338 FatalErrors
= parse_fatal_errors(value
);
3339 else if (!_cups_strcasecmp(line
, "Group") && value
)
3342 * Group ID to run as...
3345 if (isdigit(value
[0]))
3346 Group
= atoi(value
);
3350 group
= getgrnam(value
);
3353 Group
= group
->gr_gid
;
3356 cupsdLogMessage(CUPSD_LOG_ERROR
,
3357 "Unknown Group \"%s\" on line %d of %s.", value
,
3358 linenum
, CupsFilesFile
);
3359 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3364 else if (!_cups_strcasecmp(line
, "PrintcapFormat") && value
)
3367 * Format of printcap file?
3370 if (!_cups_strcasecmp(value
, "bsd"))
3371 PrintcapFormat
= PRINTCAP_BSD
;
3372 else if (!_cups_strcasecmp(value
, "plist"))
3373 PrintcapFormat
= PRINTCAP_PLIST
;
3374 else if (!_cups_strcasecmp(value
, "solaris"))
3375 PrintcapFormat
= PRINTCAP_SOLARIS
;
3378 cupsdLogMessage(CUPSD_LOG_ERROR
,
3379 "Unknown PrintcapFormat \"%s\" on line %d of %s.",
3380 value
, linenum
, CupsFilesFile
);
3381 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3385 else if (!_cups_strcasecmp(line
, "SystemGroup") && value
)
3388 * SystemGroup (admin) group(s)...
3391 if (!parse_groups(value
))
3393 cupsdLogMessage(CUPSD_LOG_ERROR
,
3394 "Unknown SystemGroup \"%s\" on line %d of %s.", value
,
3395 linenum
, CupsFilesFile
);
3396 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3400 else if (!_cups_strcasecmp(line
, "User") && value
)
3403 * User ID to run as...
3406 if (isdigit(value
[0] & 255))
3408 int uid
= atoi(value
);
3412 cupsdLogMessage(CUPSD_LOG_ERROR
,
3413 "Will not use User 0 as specified on line %d of %s "
3414 "for security reasons. You must use a non-"
3415 "privileged account instead.",
3416 linenum
, CupsFilesFile
);
3417 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3425 struct passwd
*p
; /* Password information */
3428 p
= getpwnam(value
);
3434 cupsdLogMessage(CUPSD_LOG_ERROR
,
3435 "Will not use User %s (UID=0) as specified on line "
3436 "%d of %s for security reasons. You must use a "
3437 "non-privileged account instead.",
3438 value
, linenum
, CupsFilesFile
);
3439 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3447 cupsdLogMessage(CUPSD_LOG_ERROR
,
3448 "Unknown User \"%s\" on line %d of %s.",
3449 value
, linenum
, CupsFilesFile
);
3450 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3455 else if (!_cups_strcasecmp(line
, "ServerCertificate") ||
3456 !_cups_strcasecmp(line
, "ServerKey"))
3458 cupsdLogMessage(CUPSD_LOG_INFO
,
3459 "The \"%s\" directive on line %d of %s is no longer "
3460 "supported; this will become an error in a future "
3462 line
, linenum
, CupsFilesFile
);
3464 else if (!parse_variable(CupsFilesFile
, linenum
, line
, value
,
3465 sizeof(cupsfiles_vars
) / sizeof(cupsfiles_vars
[0]),
3467 (FatalErrors
& CUPSD_FATAL_CONFIG
))
3476 * 'read_location()' - Read a <Location path> definition.
3479 static int /* O - New line number or 0 on error */
3480 read_location(cups_file_t
*fp
, /* I - Configuration file */
3481 char *location
, /* I - Location name/path */
3482 int linenum
) /* I - Current line number */
3484 cupsd_location_t
*loc
, /* New location */
3485 *parent
; /* Parent location */
3486 char line
[HTTP_MAX_BUFFER
],
3488 *value
, /* Value for directive */
3489 *valptr
; /* Pointer into value */
3492 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3493 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3495 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3499 cupsdAddLocation(parent
);
3501 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3506 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3509 * Decode the directive...
3512 if (!_cups_strcasecmp(line
, "</Location>"))
3514 else if (!_cups_strcasecmp(line
, "<Limit") ||
3515 !_cups_strcasecmp(line
, "<LimitExcept"))
3519 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3520 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3526 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3529 cupsdAddLocation(loc
);
3534 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3539 if (!strcmp(value
, "ALL"))
3540 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3541 else if (!strcmp(value
, "GET"))
3542 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3543 else if (!strcmp(value
, "HEAD"))
3544 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3545 else if (!strcmp(value
, "OPTIONS"))
3546 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3547 else if (!strcmp(value
, "POST"))
3548 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3549 else if (!strcmp(value
, "PUT"))
3550 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3551 else if (!strcmp(value
, "TRACE"))
3552 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3554 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3557 for (value
= valptr
; isspace(*value
& 255); value
++);
3560 if (!_cups_strcasecmp(line
, "<LimitExcept"))
3561 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3563 parent
->limit
&= ~loc
->limit
;
3565 else if (!_cups_strcasecmp(line
, "</Limit>") ||
3566 !_cups_strcasecmp(line
, "</LimitExcept>"))
3570 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3571 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3574 else if (!parse_aaa(loc
, line
, value
, linenum
))
3576 cupsdLogMessage(CUPSD_LOG_ERROR
,
3577 "Unknown Location directive %s on line %d.",
3579 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3584 cupsdLogMessage(CUPSD_LOG_ERROR
,
3585 "Unexpected end-of-file at line %d while reading location.",
3588 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3593 * 'read_policy()' - Read a <Policy name> definition.
3596 static int /* O - New line number or 0 on error */
3597 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3598 char *policy
, /* I - Location name/path */
3599 int linenum
) /* I - Current line number */
3601 int i
; /* Looping var */
3602 cupsd_policy_t
*pol
; /* Policy */
3603 cupsd_location_t
*op
; /* Policy operation */
3604 int num_ops
; /* Number of IPP operations */
3605 ipp_op_t ops
[100]; /* Operations */
3606 char line
[HTTP_MAX_BUFFER
],
3608 *value
, /* Value for directive */
3609 *valptr
; /* Pointer into value */
3613 * Create the policy...
3616 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3617 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3619 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3623 * Read from the file...
3629 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3632 * Decode the directive...
3635 if (!_cups_strcasecmp(line
, "</Policy>"))
3638 cupsdLogMessage(CUPSD_LOG_WARN
,
3639 "Missing </Limit> before </Policy> on line %d.",
3642 set_policy_defaults(pol
);
3646 else if (!_cups_strcasecmp(line
, "<Limit") && !op
)
3650 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3651 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3658 * Scan for IPP operation names...
3665 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3670 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3672 if (!_cups_strcasecmp(value
, "All"))
3673 ops
[num_ops
] = IPP_ANY_OPERATION
;
3674 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3675 cupsdLogMessage(CUPSD_LOG_ERROR
,
3676 "Bad IPP operation name \"%s\" on line %d.",
3682 cupsdLogMessage(CUPSD_LOG_ERROR
,
3683 "Too many operations listed on line %d.",
3686 for (value
= valptr
; isspace(*value
& 255); value
++);
3690 * If none are specified, apply the policy to all operations...
3695 ops
[0] = IPP_ANY_OPERATION
;
3700 * Add a new policy for the first operation...
3703 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3705 else if (!_cups_strcasecmp(line
, "</Limit>") && op
)
3708 * Finish the current operation limit...
3714 * Copy the policy to the other operations...
3717 for (i
= 1; i
< num_ops
; i
++)
3718 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3725 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3726 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3729 else if (!_cups_strcasecmp(line
, "JobPrivateAccess") ||
3730 !_cups_strcasecmp(line
, "JobPrivateValues") ||
3731 !_cups_strcasecmp(line
, "SubscriptionPrivateAccess") ||
3732 !_cups_strcasecmp(line
, "SubscriptionPrivateValues"))
3736 cupsdLogMessage(CUPSD_LOG_ERROR
,
3737 "%s directive must appear outside <Limit>...</Limit> "
3738 "on line %d.", line
, linenum
);
3739 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3745 * Pull out whitespace-delimited values...
3751 * Find the end of the current value...
3754 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3760 * Save it appropriately...
3763 if (!_cups_strcasecmp(line
, "JobPrivateAccess"))
3766 * JobPrivateAccess {all|default|user/group list|@@ACL}
3769 if (!_cups_strcasecmp(value
, "default"))
3771 cupsdAddString(&(pol
->job_access
), "@OWNER");
3772 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3775 cupsdAddString(&(pol
->job_access
), value
);
3777 else if (!_cups_strcasecmp(line
, "JobPrivateValues"))
3780 * JobPrivateValues {all|none|default|attribute list}
3783 if (!_cups_strcasecmp(value
, "default"))
3785 cupsdAddString(&(pol
->job_attrs
), "job-name");
3786 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3787 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3788 cupsdAddString(&(pol
->job_attrs
), "phone");
3791 cupsdAddString(&(pol
->job_attrs
), value
);
3793 else if (!_cups_strcasecmp(line
, "SubscriptionPrivateAccess"))
3796 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3799 if (!_cups_strcasecmp(value
, "default"))
3801 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3802 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3805 cupsdAddString(&(pol
->sub_access
), value
);
3807 else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
3810 * SubscriptionPrivateValues {all|none|default|attribute list}
3813 if (!_cups_strcasecmp(value
, "default"))
3815 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3816 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3817 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3818 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3819 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3822 cupsdAddString(&(pol
->sub_attrs
), value
);
3826 * Find the next string on the line...
3829 for (value
= valptr
; isspace(*value
& 255); value
++);
3835 cupsdLogMessage(CUPSD_LOG_ERROR
,
3836 "Missing <Limit ops> directive before %s on line %d.",
3838 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3841 else if (!parse_aaa(op
, line
, value
, linenum
))
3843 cupsdLogMessage(CUPSD_LOG_ERROR
,
3844 "Unknown Policy Limit directive %s on line %d.",
3847 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3852 cupsdLogMessage(CUPSD_LOG_ERROR
,
3853 "Unexpected end-of-file at line %d while reading policy "
3854 "\"%s\".", linenum
, policy
);
3856 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3861 * 'set_policy_defaults()' - Set default policy values as needed.
3865 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3867 cupsd_location_t
*op
; /* Policy operation */
3871 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3872 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3873 * upgrades do not introduce new security issues...
3876 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3877 op
->op
== IPP_ANY_OPERATION
)
3879 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3880 op
->op
!= IPP_ANY_OPERATION
)
3883 * Add a new limit for Validate-Job using the Print-Job limit as a
3887 cupsdLogMessage(CUPSD_LOG_WARN
,
3888 "No limit for Validate-Job defined in policy %s "
3889 "- using Print-Job's policy.", pol
->name
);
3891 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3894 cupsdLogMessage(CUPSD_LOG_WARN
,
3895 "No limit for Validate-Job defined in policy %s "
3896 "and no suitable template found.", pol
->name
);
3899 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3900 op
->op
== IPP_ANY_OPERATION
)
3902 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3903 op
->op
!= IPP_ANY_OPERATION
)
3906 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3910 cupsdLogMessage(CUPSD_LOG_WARN
,
3911 "No limit for Cancel-Jobs defined in policy %s "
3912 "- using Pause-Printer's policy.", pol
->name
);
3914 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3917 cupsdLogMessage(CUPSD_LOG_WARN
,
3918 "No limit for Cancel-Jobs defined in policy %s "
3919 "and no suitable template found.", pol
->name
);
3922 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3923 op
->op
== IPP_ANY_OPERATION
)
3925 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3926 op
->op
!= IPP_ANY_OPERATION
)
3929 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
3933 cupsdLogMessage(CUPSD_LOG_WARN
,
3934 "No limit for Cancel-My-Jobs defined in policy %s "
3935 "- using Send-Document's policy.", pol
->name
);
3937 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
3940 cupsdLogMessage(CUPSD_LOG_WARN
,
3941 "No limit for Cancel-My-Jobs defined in policy %s "
3942 "and no suitable template found.", pol
->name
);
3945 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
3946 op
->op
== IPP_ANY_OPERATION
)
3948 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3949 op
->op
!= IPP_ANY_OPERATION
)
3952 * Add a new limit for Close-Job using the Send-Document limit as a
3956 cupsdLogMessage(CUPSD_LOG_WARN
,
3957 "No limit for Close-Job defined in policy %s "
3958 "- using Send-Document's policy.", pol
->name
);
3960 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
3963 cupsdLogMessage(CUPSD_LOG_WARN
,
3964 "No limit for Close-Job defined in policy %s "
3965 "and no suitable template found.", pol
->name
);
3968 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
3969 op
->op
== IPP_ANY_OPERATION
)
3971 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3972 op
->op
!= IPP_ANY_OPERATION
)
3975 * Add a new limit for CUPS-Get-Document using the Send-Document
3976 * limit as a template...
3979 cupsdLogMessage(CUPSD_LOG_WARN
,
3980 "No limit for CUPS-Get-Document defined in policy %s "
3981 "- using Send-Document's policy.", pol
->name
);
3983 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
3986 cupsdLogMessage(CUPSD_LOG_WARN
,
3987 "No limit for CUPS-Get-Document defined in policy %s "
3988 "and no suitable template found.", pol
->name
);
3992 * Verify we have JobPrivateAccess, JobPrivateValues,
3993 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
3996 if (!pol
->job_access
)
3998 cupsdLogMessage(CUPSD_LOG_WARN
,
3999 "No JobPrivateAccess defined in policy %s "
4000 "- using defaults.", pol
->name
);
4001 cupsdAddString(&(pol
->job_access
), "@OWNER");
4002 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4005 if (!pol
->job_attrs
)
4007 cupsdLogMessage(CUPSD_LOG_WARN
,
4008 "No JobPrivateValues defined in policy %s "
4009 "- using defaults.", pol
->name
);
4010 cupsdAddString(&(pol
->job_attrs
), "job-name");
4011 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4012 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4013 cupsdAddString(&(pol
->job_attrs
), "phone");
4016 if (!pol
->sub_access
)
4018 cupsdLogMessage(CUPSD_LOG_WARN
,
4019 "No SubscriptionPrivateAccess defined in policy %s "
4020 "- using defaults.", pol
->name
);
4021 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4022 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4025 if (!pol
->sub_attrs
)
4027 cupsdLogMessage(CUPSD_LOG_WARN
,
4028 "No SubscriptionPrivateValues defined in policy %s "
4029 "- using defaults.", pol
->name
);
4030 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4031 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4032 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4033 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4034 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");