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
},
147 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
148 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
149 # endif /* HAVE_GNUTLS */
150 { "ServerKeychain", &ServerKeychain
, CUPSD_VARTYPE_PATHNAME
},
151 #endif /* HAVE_SSL */
152 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
153 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
154 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
155 { "SyncOnClose", &SyncOnClose
, CUPSD_VARTYPE_BOOLEAN
},
156 #ifdef HAVE_AUTHORIZATION_H
157 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
158 #endif /* HAVE_AUTHORIZATION_H */
159 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
}
162 static int default_auth_type
= CUPSD_AUTH_AUTO
;
163 /* Default AuthType, if not specified */
165 static const unsigned ones
[4] =
167 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
169 static const unsigned zeros
[4] =
171 0x00000000, 0x00000000, 0x00000000, 0x00000000
179 static http_addrlist_t
*get_address(const char *value
, int defport
);
180 static int get_addr_and_mask(const char *value
, unsigned *ip
,
182 static void mime_error_cb(void *ctx
, const char *message
);
183 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
184 char *value
, int linenum
);
185 static int parse_fatal_errors(const char *s
);
186 static int parse_groups(const char *s
);
187 static int parse_protocols(const char *s
);
188 static int parse_variable(const char *filename
, int linenum
,
189 const char *line
, const char *value
,
191 const cupsd_var_t
*vars
);
192 static int read_cupsd_conf(cups_file_t
*fp
);
193 static int read_cups_files_conf(cups_file_t
*fp
);
194 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
195 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
196 static void set_policy_defaults(cupsd_policy_t
*pol
);
200 * 'cupsdAddAlias()' - Add a host alias.
204 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
205 const char *name
) /* I - Name to add */
207 cupsd_alias_t
*a
; /* New alias */
208 size_t namelen
; /* Length of name */
211 namelen
= strlen(name
);
213 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
216 a
->namelen
= namelen
;
217 memcpy(a
->name
, name
, namelen
+ 1); /* OK since a->name is allocated */
219 cupsArrayAdd(aliases
, a
);
224 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
227 int /* O - 0 on success, -1 on error, 1 on warning */
228 cupsdCheckPermissions(
229 const char *filename
, /* I - File/directory name */
230 const char *suffix
, /* I - Additional file/directory name */
231 int mode
, /* I - Permissions */
232 int user
, /* I - Owner */
233 int group
, /* I - Group */
234 int is_dir
, /* I - 1 = directory, 0 = file */
235 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
237 int dir_created
= 0; /* Did we create a directory? */
238 char pathname
[1024]; /* File name with prefix */
239 struct stat fileinfo
; /* Stat buffer */
240 int is_symlink
; /* Is "filename" a symlink? */
244 * Prepend the given root to the filename before testing it...
249 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
254 * See if we can stat the file/directory...
257 if (lstat(filename
, &fileinfo
))
259 if (errno
== ENOENT
&& create_dir
)
262 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
265 if (mkdir(filename
, mode
))
268 cupsdLogMessage(CUPSD_LOG_ERROR
,
269 "Unable to create directory \"%s\" - %s", filename
,
272 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
279 fileinfo
.st_mode
= mode
| S_IFDIR
;
282 return (create_dir
? -1 : 1);
285 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
287 if (stat(filename
, &fileinfo
))
289 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
290 filename
, strerror(errno
));
296 * Make sure it's a regular file or a directory as needed...
299 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
301 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file.", filename
);
305 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
308 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory.", filename
);
310 syslog(LOG_ERR
, "\"%s\" is not a directory.", filename
);
316 * If the filename is a symlink, do not change permissions (STR #2937)...
323 * Fix owner, group, and mode as needed...
326 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
329 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
332 if (chown(filename
, user
, group
) && !getuid())
335 cupsdLogMessage(CUPSD_LOG_ERROR
,
336 "Unable to change ownership of \"%s\" - %s", filename
,
339 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
346 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
349 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
352 if (chmod(filename
, mode
))
355 cupsdLogMessage(CUPSD_LOG_ERROR
,
356 "Unable to change permissions of \"%s\" - %s", filename
,
359 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
367 * Everything is OK...
375 * 'cupsdDefaultAuthType()' - Get the default AuthType.
377 * When the default_auth_type is "auto", this function tries to get the GSS
378 * credentials for the server. If that succeeds we use Kerberos authentication,
379 * otherwise we do a fallback to Basic authentication against the local user
383 int /* O - Default AuthType value */
384 cupsdDefaultAuthType(void)
387 OM_uint32 major_status
, /* Major status code */
388 minor_status
; /* Minor status code */
389 gss_name_t server_name
; /* Server name */
390 gss_buffer_desc token
= GSS_C_EMPTY_BUFFER
;
391 /* Service name token */
392 char buf
[1024]; /* Service name buffer */
393 #endif /* HAVE_GSSAPI */
397 * If we have already determined the correct default AuthType, use it...
400 if (default_auth_type
!= CUPSD_AUTH_AUTO
)
401 return (default_auth_type
);
406 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
410 if (gss_init_sec_context
== NULL
)
411 return (default_auth_type
= CUPSD_AUTH_BASIC
);
412 # endif /* __APPLE__ */
415 * Try to obtain the server's GSS credentials (GSSServiceName@servername). If
416 * that fails we must use Basic...
419 snprintf(buf
, sizeof(buf
), "%s@%s", GSSServiceName
, ServerName
);
422 token
.length
= strlen(buf
);
423 server_name
= GSS_C_NO_NAME
;
424 major_status
= gss_import_name(&minor_status
, &token
,
425 GSS_C_NT_HOSTBASED_SERVICE
,
428 memset(&token
, 0, sizeof(token
));
430 if (GSS_ERROR(major_status
))
432 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
433 "cupsdDefaultAuthType: gss_import_name(%s) failed", buf
);
434 return (default_auth_type
= CUPSD_AUTH_BASIC
);
437 major_status
= gss_display_name(&minor_status
, server_name
, &token
, NULL
);
439 if (GSS_ERROR(major_status
))
441 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
442 "cupsdDefaultAuthType: gss_display_name(%s) failed",
444 return (default_auth_type
= CUPSD_AUTH_BASIC
);
447 cupsdLogMessage(CUPSD_LOG_DEBUG
,
448 "cupsdDefaultAuthType: Attempting to acquire Kerberos "
449 "credentials for %s...", (char *)token
.value
);
451 ServerCreds
= GSS_C_NO_CREDENTIAL
;
452 major_status
= gss_acquire_cred(&minor_status
, server_name
, GSS_C_INDEFINITE
,
453 GSS_C_NO_OID_SET
, GSS_C_ACCEPT
,
454 &ServerCreds
, NULL
, NULL
);
455 if (GSS_ERROR(major_status
))
457 cupsdLogGSSMessage(CUPSD_LOG_DEBUG
, major_status
, minor_status
,
458 "cupsdDefaultAuthType: gss_acquire_cred(%s) failed",
459 (char *)token
.value
);
460 gss_release_name(&minor_status
, &server_name
);
461 gss_release_buffer(&minor_status
, &token
);
462 return (default_auth_type
= CUPSD_AUTH_BASIC
);
465 cupsdLogMessage(CUPSD_LOG_DEBUG
,
466 "cupsdDefaultAuthType: Kerberos credentials acquired "
467 "successfully for %s.", (char *)token
.value
);
469 gss_release_name(&minor_status
, &server_name
);
470 gss_release_buffer(&minor_status
, &token
);
474 return (default_auth_type
= CUPSD_AUTH_NEGOTIATE
);
478 * No Kerberos support compiled in so just use Basic all the time...
481 return (default_auth_type
= CUPSD_AUTH_BASIC
);
482 #endif /* HAVE_GSSAPI */
487 * 'cupsdFreeAliases()' - Free all of the alias entries.
491 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
493 cupsd_alias_t
*a
; /* Current alias */
496 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
498 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
501 cupsArrayDelete(aliases
);
506 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
509 int /* O - 1 on success, 0 otherwise */
510 cupsdReadConfiguration(void)
512 int i
; /* Looping var */
513 cups_file_t
*fp
; /* Configuration file */
514 int status
; /* Return status */
515 char temp
[1024], /* Temporary buffer */
516 mimedir
[1024], /* MIME directory */
517 *slash
; /* Directory separator */
518 cups_lang_t
*language
; /* Language */
519 struct passwd
*user
; /* Default user */
520 struct group
*group
; /* Default group */
521 char *old_serverroot
, /* Old ServerRoot */
522 *old_requestroot
; /* Old RequestRoot */
523 int old_remote_port
; /* Old RemotePort */
524 const char *tmpdir
; /* TMPDIR environment variable */
525 struct stat tmpinfo
; /* Temporary directory info */
526 cupsd_policy_t
*p
; /* Policy */
530 * Save the old root paths...
533 old_serverroot
= NULL
;
534 cupsdSetString(&old_serverroot
, ServerRoot
);
535 old_requestroot
= NULL
;
536 cupsdSetString(&old_requestroot
, RequestRoot
);
539 * Reset the server configuration data...
542 cupsdDeleteAllLocations();
544 cupsdDeleteAllListeners();
546 old_remote_port
= RemotePort
;
553 cupsdFreeAliases(ServerAlias
);
556 cupsdClearString(&ServerName
);
557 cupsdClearString(&ServerAdmin
);
558 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
559 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
560 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
561 cupsdSetString(&DataDir
, CUPS_DATADIR
);
562 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
563 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
564 cupsdClearString(&ErrorLog
);
565 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
566 cupsdSetString(&PageLogFormat
,
567 "%p %u %j %T %P %C %{job-billing} "
568 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
569 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
570 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
571 cupsdSetString(&RemoteRoot
, "remroot");
572 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
574 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
576 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
577 PrintcapFormat
= PRINTCAP_SOLARIS
;
578 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
579 "/Library/Preferences/org.cups.printers.plist"))
580 PrintcapFormat
= PRINTCAP_PLIST
;
582 PrintcapFormat
= PRINTCAP_BSD
;
584 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
585 if ((slash
= strrchr(temp
, '/')) != NULL
)
588 cupsdSetString(&ServerRoot
, temp
);
590 cupsdClearString(&Classification
);
591 ClassifyOverride
= 0;
595 cupsdClearString(&ServerKeychain
);
596 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
597 cupsdSetString(&ServerKey
, "ssl/server.key");
599 cupsdSetString(&ServerKeychain
, "/Library/Keychains/System.keychain");
600 # endif /* HAVE_GNUTLS */
601 #endif /* HAVE_SSL */
603 language
= cupsLangDefault();
605 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
606 cupsdSetString(&DefaultLanguage
, "en");
608 cupsdSetString(&DefaultLanguage
, language
->language
);
610 cupsdClearString(&DefaultPaperSize
);
612 cupsdSetString(&RIPCache
, "128m");
614 cupsdSetString(&TempDir
, NULL
);
617 cupsdSetString(&GSSServiceName
, CUPS_DEFAULT_GSSSERVICENAME
);
621 OM_uint32 minor_status
; /* Minor status code */
623 gss_release_cred(&minor_status
, &ServerCreds
);
628 ServerCreds
= GSS_C_NO_CREDENTIAL
;
629 #endif /* HAVE_GSSAPI */
632 * Find the default user...
635 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
640 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
641 * complement number...)
650 * Find the default group...
653 group
= getgrnam(CUPS_DEFAULT_GROUP
);
657 Group
= group
->gr_gid
;
661 * Fallback to group "nobody"...
664 group
= getgrnam("nobody");
668 Group
= group
->gr_gid
;
672 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
673 * complement number...)
684 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
685 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
686 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
687 default_auth_type
= CUPSD_AUTH_BASIC
;
689 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
690 #endif /* HAVE_SSL */
691 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
692 JobKillDelay
= DEFAULT_TIMEOUT
;
694 JobRetryInterval
= 300;
699 HostNameLookups
= FALSE
;
701 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
702 ListenBackLog
= SOMAXCONN
;
703 LogDebugHistory
= 200;
704 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
705 LogLevel
= CUPSD_LOG_WARN
;
706 LogTimeFormat
= CUPSD_TIME_STANDARD
;
708 MaxClientsPerHost
= 0;
709 MaxLogSize
= 1024 * 1024;
711 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
713 ReloadTimeout
= DEFAULT_KEEPALIVE
;
714 RootCertDuration
= 300;
715 StrictConformance
= FALSE
;
717 Timeout
= DEFAULT_TIMEOUT
;
718 WebInterface
= CUPS_DEFAULT_WEBIF
;
720 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
722 Browsing
= CUPS_DEFAULT_BROWSING
;
723 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
725 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
726 cupsdSetString(&DNSSDSubTypes
, "_cups,_print");
727 #endif /* HAVE_DNSSD || HAVE_AVAHI */
729 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
730 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
732 cupsdSetString(&ErrorPolicy
, "stop-printer");
734 JobHistory
= DEFAULT_HISTORY
;
735 JobFiles
= DEFAULT_FILES
;
741 MaxJobsPerPrinter
= 0;
742 MaxJobTime
= 3 * 60 * 60; /* 3 hours */
743 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
745 cupsdDeleteAllPolicies();
746 cupsdClearString(&DefaultPolicy
);
748 #ifdef HAVE_AUTHORIZATION_H
749 cupsdSetString(&SystemGroupAuthKey
, CUPS_DEFAULT_SYSTEM_AUTHKEY
);
750 #endif /* HAVE_AUTHORIZATION_H */
752 MaxSubscriptions
= 100;
753 MaxSubscriptionsPerJob
= 0;
754 MaxSubscriptionsPerPrinter
= 0;
755 MaxSubscriptionsPerUser
= 0;
756 DefaultLeaseDuration
= 86400;
757 MaxLeaseDuration
= 0;
761 #endif /* HAVE_LAUNCHD */
764 * Setup environment variables...
770 * Read the cups-files.conf file...
773 if ((fp
= cupsFileOpen(CupsFilesFile
, "r")) != NULL
)
775 status
= read_cups_files_conf(fp
);
782 printf("\"%s\" contains errors.\n", CupsFilesFile
);
784 syslog(LOG_LPR
, "Unable to read \"%s\" due to errors.",
790 else if (errno
== ENOENT
)
791 cupsdLogMessage(CUPSD_LOG_INFO
, "No %s, using defaults.", CupsFilesFile
);
794 syslog(LOG_LPR
, "Unable to open \"%s\": %s", CupsFilesFile
,
800 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
803 * Read the cupsd.conf file...
806 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
808 syslog(LOG_LPR
, "Unable to open \"%s\": %s", ConfigurationFile
,
813 status
= read_cupsd_conf(fp
);
820 printf("\"%s\" contains errors.\n", ConfigurationFile
);
822 syslog(LOG_LPR
, "Unable to read \"%s\" due to errors.",
830 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
831 RemotePort
? "enabled" : "disabled");
834 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
837 * See if the ServerName is an IP address...
843 ServerAlias
= cupsArrayNew(NULL
, NULL
);
845 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
849 if (gethostname(temp
, sizeof(temp
)))
851 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
853 strlcpy(temp
, "localhost", sizeof(temp
));
856 cupsdSetString(&ServerName
, temp
);
859 ServerAlias
= cupsArrayNew(NULL
, NULL
);
861 cupsdAddAlias(ServerAlias
, temp
);
862 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
864 if (HostNameLookups
|| RemotePort
)
866 struct hostent
*host
; /* Host entry to get FQDN */
868 if ((host
= gethostbyname(temp
)) != NULL
)
870 if (_cups_strcasecmp(temp
, host
->h_name
))
872 cupsdSetString(&ServerName
, host
->h_name
);
873 cupsdAddAlias(ServerAlias
, host
->h_name
);
874 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
880 for (i
= 0; host
->h_aliases
[i
]; i
++)
881 if (_cups_strcasecmp(temp
, host
->h_aliases
[i
]))
883 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
884 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
892 * Make sure we have the base hostname added as an alias, too!
895 if ((slash
= strchr(temp
, '.')) != NULL
)
898 cupsdAddAlias(ServerAlias
, temp
);
899 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
903 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
905 ServerNameIsIP
= !*slash
;
908 * Make sure ServerAdmin is initialized...
912 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
915 * Use the default system group if none was supplied in cupsd.conf...
918 if (NumSystemGroups
== 0)
920 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
923 * Find the group associated with GID 0...
930 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
932 cupsdSetString(&SystemGroups
[0], "unknown");
934 SystemGroupIDs
[0] = 0;
940 * Make sure ConfigFilePerm and LogFilePerm have sane values...
943 ConfigFilePerm
&= 0664;
947 * Open the system log for cupsd if necessary...
951 if (!strcmp(AccessLog
, "syslog") ||
952 !strcmp(ErrorLog
, "syslog") ||
953 !strcmp(PageLog
, "syslog"))
954 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
955 #endif /* HAVE_VSYSLOG */
958 * Make sure each of the log files exists and gets rotated as necessary...
961 if (strcmp(AccessLog
, "syslog"))
962 cupsdCheckLogFile(&AccessFile
, AccessLog
);
964 if (strcmp(ErrorLog
, "syslog"))
965 cupsdCheckLogFile(&ErrorFile
, ErrorLog
);
967 if (strcmp(PageLog
, "syslog"))
968 cupsdCheckLogFile(&PageFile
, PageLog
);
971 * Log the configuration file that was used...
974 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
978 * Validate the Group and SystemGroup settings - they cannot be the same,
979 * otherwise the CGI programs will be able to authenticate as root without
985 for (i
= 0; i
< NumSystemGroups
; i
++)
986 if (Group
== SystemGroupIDs
[i
])
989 if (i
< NumSystemGroups
)
992 * Log the error and reset the group to a safe value...
995 cupsdLogMessage(CUPSD_LOG_NOTICE
,
996 "Group and SystemGroup cannot use the same groups.");
997 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
999 group
= getgrnam("nobody");
1003 Group
= group
->gr_gid
;
1007 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
1008 * complement number...)
1017 * Check that we have at least one listen/port line; if not, report this
1018 * as an error and exit!
1021 if (cupsArrayCount(Listeners
) == 0)
1027 cupsdLogMessage(CUPSD_LOG_EMERG
,
1028 "No valid Listen or Port lines were found in the "
1029 "configuration file.");
1035 cupsdEndProcess(getpid(), 0);
1039 * Set the default locale using the language and charset...
1042 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
1045 * Update all relative filenames to include the full path from ServerRoot...
1048 if (DocumentRoot
[0] != '/')
1049 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
1051 if (RequestRoot
[0] != '/')
1052 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
1054 if (ServerBin
[0] != '/')
1055 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
1057 if (StateDir
[0] != '/')
1058 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
1060 if (CacheDir
[0] != '/')
1061 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
1065 if (ServerCertificate
[0] != '/')
1066 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
1068 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
1069 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
1071 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1074 if (ServerKey
[0] != '/')
1075 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
1077 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
1078 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
1079 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1081 # endif /* HAVE_GNUTLS */
1083 if (ServerKeychain
[0] != '/')
1084 cupsdSetStringf(&ServerKeychain
, "%s/%s", ServerRoot
, ServerKeychain
);
1085 #endif /* HAVE_SSL */
1088 * Make sure that directories and config files are owned and
1089 * writable by the user and group in the cupsd.conf file...
1092 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
1094 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
1096 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
1098 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
1100 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
1102 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
1103 SystemGroupIDs
[0], 1, 1) < 0 ||
1104 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
1106 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
1108 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
1110 cupsdCheckPermissions(ConfigurationFile
, NULL
, ConfigFilePerm
, RunUser
,
1112 cupsdCheckPermissions(CupsFilesFile
, NULL
, ConfigFilePerm
, RunUser
,
1114 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
1116 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
1118 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
1119 Group
, 0, 0) < 0) &&
1120 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1124 * Update TempDir to the default if it hasn't been set already...
1128 if (TempDir
&& !RunUser
&&
1129 (!strncmp(TempDir
, "/private/tmp", 12) || !strncmp(TempDir
, "/tmp", 4)))
1131 cupsdLogMessage(CUPSD_LOG_ERROR
, "Cannot use %s for TempDir.", TempDir
);
1132 cupsdClearString(&TempDir
);
1134 #endif /* __APPLE__ */
1139 if ((tmpdir
= getenv("TMPDIR")) != NULL
&&
1140 strncmp(tmpdir
, "/private/tmp", 12) && strncmp(tmpdir
, "/tmp", 4))
1142 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1143 #endif /* __APPLE__ */
1146 * TMPDIR is defined, see if it is OK for us to use...
1149 if (stat(tmpdir
, &tmpinfo
))
1150 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1151 tmpdir
, strerror(errno
));
1152 else if (!S_ISDIR(tmpinfo
.st_mode
))
1153 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1155 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1156 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1157 !(tmpinfo
.st_mode
& S_IWOTH
))
1158 cupsdLogMessage(CUPSD_LOG_ERROR
,
1159 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1161 cupsdSetString(&TempDir
, tmpdir
);
1167 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1169 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1173 * Make sure the temporary directory has the right permissions...
1176 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1180 * Update ownership and permissions if the CUPS temp directory
1181 * is under the spool directory or does not exist...
1184 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1185 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1190 * Update environment variables...
1196 * Update default paper size setting as needed...
1199 if (!DefaultPaperSize
)
1201 #ifdef HAVE_LIBPAPER
1202 char *paper_result
; /* Paper size name from libpaper */
1204 if ((paper_result
= systempapername()) != NULL
)
1205 cupsdSetString(&DefaultPaperSize
, paper_result
);
1207 #endif /* HAVE_LIBPAPER */
1208 if (!DefaultLanguage
||
1209 !_cups_strcasecmp(DefaultLanguage
, "C") ||
1210 !_cups_strcasecmp(DefaultLanguage
, "POSIX") ||
1211 !_cups_strcasecmp(DefaultLanguage
, "en") ||
1212 !_cups_strncasecmp(DefaultLanguage
, "en.", 3) ||
1213 !_cups_strncasecmp(DefaultLanguage
, "en_US", 5) ||
1214 !_cups_strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1215 !_cups_strncasecmp(DefaultLanguage
, "fr_CA", 5))
1218 * These are the only locales that will default to "letter" size...
1221 cupsdSetString(&DefaultPaperSize
, "Letter");
1224 cupsdSetString(&DefaultPaperSize
, "A4");
1228 * Update classification setting as needed...
1231 if (Classification
&& !_cups_strcasecmp(Classification
, "none"))
1232 cupsdClearString(&Classification
);
1235 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1238 * Check the MaxClients setting, and then allocate memory for it...
1241 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1244 cupsdLogMessage(CUPSD_LOG_INFO
,
1245 "MaxClients limited to 1/3 (%d) of the file descriptor "
1247 MaxFDs
/ 3, MaxFDs
);
1249 MaxClients
= MaxFDs
/ 3;
1252 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1256 * Check the MaxActiveJobs setting; limit to 1/3 the available
1257 * file descriptors, since we need a pipe for each job...
1260 if (MaxActiveJobs
> (MaxFDs
/ 3))
1261 MaxActiveJobs
= MaxFDs
/ 3;
1264 * Update the MaxClientsPerHost value, as needed...
1267 if (MaxClientsPerHost
<= 0)
1268 MaxClientsPerHost
= MaxClients
;
1270 if (MaxClientsPerHost
> MaxClients
)
1271 MaxClientsPerHost
= MaxClients
;
1273 cupsdLogMessage(CUPSD_LOG_INFO
,
1274 "Allowing up to %d client connections per host.",
1278 * Update the default policy, as needed...
1282 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1284 DefaultPolicyPtr
= NULL
;
1286 if (!DefaultPolicyPtr
)
1288 cupsd_location_t
*po
; /* New policy operation */
1292 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1295 cupsdSetString(&DefaultPolicy
, "default");
1297 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1298 cupsdLogMessage(CUPSD_LOG_INFO
,
1299 "Using policy \"default\" as the default.");
1302 cupsdLogMessage(CUPSD_LOG_INFO
,
1303 "Creating CUPS default administrative policy:");
1305 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1307 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1309 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1310 cupsdAddString(&(p
->job_access
), "@OWNER");
1311 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1313 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1314 cupsdAddString(&(p
->job_attrs
), "job-name");
1315 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1316 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1318 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1319 cupsdAddString(&(p
->sub_access
), "@OWNER");
1320 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1322 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1323 cupsdAddString(&(p
->job_attrs
), "notify-events");
1324 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1325 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1326 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1327 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1329 cupsdLogMessage(CUPSD_LOG_INFO
,
1330 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1331 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1333 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1334 po
->order_type
= CUPSD_AUTH_ALLOW
;
1336 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1337 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1338 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1340 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1342 cupsdLogMessage(CUPSD_LOG_INFO
,
1343 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1344 "Release-Job Restart-Job Purge-Jobs "
1345 "Set-Job-Attributes Create-Job-Subscription "
1346 "Renew-Subscription Cancel-Subscription "
1347 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1348 "Suspend-Current-Job Resume-Job "
1349 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1350 "CUPS-Authenticate-Job CUPS-Get-Document>");
1351 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1353 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1354 po
->order_type
= CUPSD_AUTH_ALLOW
;
1355 po
->level
= CUPSD_AUTH_USER
;
1357 cupsdAddName(po
, "@OWNER");
1358 cupsdAddName(po
, "@SYSTEM");
1359 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1361 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1362 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1363 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1364 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1365 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1366 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1367 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1368 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1369 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1370 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1371 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1372 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1373 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1374 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1375 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1376 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1377 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1378 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1379 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1380 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1382 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1384 cupsdLogMessage(CUPSD_LOG_INFO
,
1385 "<Limit Pause-Printer Resume-Printer "
1386 "Set-Printer-Attributes Enable-Printer "
1387 "Disable-Printer Pause-Printer-After-Current-Job "
1388 "Hold-New-Jobs Release-Held-New-Jobs "
1389 "Deactivate-Printer Activate-Printer Restart-Printer "
1390 "Shutdown-Printer Startup-Printer Promote-Job "
1391 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1392 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1393 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1394 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1395 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1397 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1398 po
->order_type
= CUPSD_AUTH_ALLOW
;
1399 po
->type
= CUPSD_AUTH_DEFAULT
;
1400 po
->level
= CUPSD_AUTH_USER
;
1402 cupsdAddName(po
, "@SYSTEM");
1403 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1405 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1406 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1407 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1408 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1409 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1410 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1411 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1412 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1413 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1414 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1415 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1416 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1417 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1418 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1419 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1420 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1421 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1422 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1423 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1424 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1425 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1426 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1428 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1430 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1431 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1433 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1434 po
->order_type
= CUPSD_AUTH_ALLOW
;
1436 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1437 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1441 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1442 cupsArrayCount(Policies
));
1443 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1445 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1446 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1447 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1450 * If we are doing a full reload or the server root has changed, flush
1451 * the jobs, printers, etc. and start from scratch...
1454 if (NeedReload
== RELOAD_ALL
||
1455 old_remote_port
!= RemotePort
||
1456 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1457 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1459 mime_type_t
*type
; /* Current type */
1460 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1461 /* MIME type name */
1464 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1467 * Free all memory...
1470 cupsdDeleteAllSubscriptions();
1472 cupsdDeleteAllPrinters();
1474 DefaultPrinter
= NULL
;
1476 if (MimeDatabase
!= NULL
)
1477 mimeDelete(MimeDatabase
);
1481 for (i
= 0; i
< NumMimeTypes
; i
++)
1482 _cupsStrFree(MimeTypes
[i
]);
1488 * Read the MIME type and conversion database...
1491 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1492 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1494 MimeDatabase
= mimeNew();
1495 mimeSetErrorCallback(MimeDatabase
, mime_error_cb
, NULL
);
1497 MimeDatabase
= mimeLoadTypes(MimeDatabase
, mimedir
);
1498 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1499 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1500 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1504 cupsdLogMessage(CUPSD_LOG_EMERG
,
1505 "Unable to load MIME database from \"%s\" or \"%s\".",
1506 mimedir
, ServerRoot
);
1507 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1511 cupsdLogMessage(CUPSD_LOG_INFO
,
1512 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1513 "%d filters...", mimedir
, ServerRoot
,
1514 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1517 * Create a list of MIME types for the document-format-supported
1521 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1522 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1525 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1527 cupsdLogMessage(CUPSD_LOG_ERROR
,
1528 "Unable to allocate memory for %d MIME types.",
1534 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1536 i
++, type
= mimeNextType(MimeDatabase
))
1538 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1540 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1543 if (i
< NumMimeTypes
)
1544 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1547 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1549 mime_filter_t
*filter
; /* Current filter */
1552 for (type
= mimeFirstType(MimeDatabase
);
1554 type
= mimeNextType(MimeDatabase
))
1555 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1556 type
->super
, type
->type
);
1558 for (filter
= mimeFirstFilter(MimeDatabase
);
1560 filter
= mimeNextFilter(MimeDatabase
))
1561 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1562 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1563 filter
->src
->super
, filter
->src
->type
,
1564 filter
->dst
->super
, filter
->dst
->type
,
1565 filter
->cost
, filter
->filter
);
1572 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1573 cupsdLoadBanners(temp
);
1576 * Load printers and classes...
1579 cupsdLoadAllPrinters();
1580 cupsdLoadAllClasses();
1582 cupsdCreateCommonData();
1585 * Update the printcap file as needed...
1588 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1589 cupsdWritePrintcap();
1592 * Load queued jobs...
1598 * Load subscriptions...
1601 cupsdLoadAllSubscriptions();
1603 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1608 * Not a full reload, so recreate the common printer attributes...
1611 cupsdCreateCommonData();
1614 * Update all jobs as needed...
1620 * Update all printers as needed...
1623 cupsdUpdatePrinters();
1624 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1626 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1630 * Reset the reload state...
1633 NeedReload
= RELOAD_NONE
;
1635 cupsdClearString(&old_serverroot
);
1636 cupsdClearString(&old_requestroot
);
1643 * 'get_address()' - Get an address + port number from a line.
1646 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1647 get_address(const char *value
, /* I - Value string */
1648 int defport
) /* I - Default port */
1650 char buffer
[1024], /* Hostname + port number buffer */
1651 defpname
[255], /* Default port name */
1652 *hostname
, /* Hostname or IP */
1653 *portname
; /* Port number or name */
1654 http_addrlist_t
*addrlist
; /* Address list */
1658 * Check for an empty value...
1663 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1668 * Grab a hostname and port number; if there is no colon and the port name
1669 * is only digits, then we have a port number by itself...
1672 strlcpy(buffer
, value
, sizeof(buffer
));
1674 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1681 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1686 * Use the default port...
1689 sprintf(defpname
, "%d", defport
);
1690 portname
= defpname
;
1696 * The buffer contains just a port number...
1704 if (hostname
&& !strcmp(hostname
, "*"))
1708 * Now lookup the address using httpAddrGetList()...
1711 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1712 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1713 hostname
? hostname
: "(nil)");
1720 * 'get_addr_and_mask()' - Get an IP address and netmask.
1723 static int /* O - 1 on success, 0 on failure */
1724 get_addr_and_mask(const char *value
, /* I - String from config file */
1725 unsigned *ip
, /* O - Address value */
1726 unsigned *mask
) /* O - Mask value */
1728 int i
, j
, /* Looping vars */
1729 family
, /* Address family */
1730 ipcount
; /* Count of fields in address */
1731 unsigned ipval
; /* Value */
1732 const char *maskval
, /* Pointer to start of mask value */
1733 *ptr
, /* Pointer into value */
1738 * Get the address...
1741 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1742 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1744 if ((maskval
= strchr(value
, '/')) != NULL
)
1747 maskval
= value
+ strlen(value
);
1751 * Check for an IPv6 address...
1757 * Parse hexadecimal IPv6/IPv4 address...
1762 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1766 else if (!strncmp(ptr
, "::", 2))
1768 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1770 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1775 else if (isdigit(*ptr
& 255) && strchr(ptr
+ 1, '.') && i
>= 6)
1778 * Read IPv4 dotted quad...
1781 unsigned val
[4] = { 0, 0, 0, 0 };
1782 /* IPv4 address values */
1784 ipcount
= sscanf(ptr
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2,
1788 * Range check the IP numbers...
1791 for (i
= 0; i
< ipcount
; i
++)
1796 * Merge everything into a 32-bit IPv4 address in ip[3]...
1799 ip
[3] = ((((((unsigned)val
[0] << 8) | (unsigned)val
[1]) << 8) |
1800 (unsigned)val
[2]) << 8) | (unsigned)val
[3];
1803 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1806 * If the leading words are all 0's then this is an IPv4 address...
1809 if (!val
[0] && !val
[1] && !val
[2])
1812 while (isdigit(*ptr
& 255) || *ptr
== '.')
1816 else if (isxdigit(*ptr
& 255))
1818 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1820 if (*ptr
== ':' && ptr
[1] != ':')
1829 ip
[i
/ 2] |= ipval
<< 16;
1840 if (*ptr
&& *ptr
!= '/')
1844 #endif /* AF_INET6 */
1847 * Parse dotted-decimal IPv4 address...
1850 unsigned val
[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
1854 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1857 * Range check the IP numbers...
1860 for (i
= 0; i
< ipcount
; i
++)
1865 * Merge everything into a 32-bit IPv4 address in ip[3]...
1868 ip
[3] = ((((((unsigned)val
[0] << 8) | (unsigned)val
[1]) << 8) |
1869 (unsigned)val
[2]) << 8) | (unsigned)val
[3];
1872 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1878 * Get the netmask value(s)...
1881 memset(mask
, 0, sizeof(unsigned) * 4);
1883 if (strchr(maskval
, '.'))
1886 * Get dotted-decimal mask...
1889 if (family
!= AF_INET
)
1892 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2,
1896 mask
[3] |= (((((unsigned)mask
[0] << 8) | (unsigned)mask
[1]) << 8) |
1897 (unsigned)mask
[2]) << 8;
1898 mask
[0] = mask
[1] = mask
[2] = 0;
1903 * Get address/bits format...
1909 if (family
== AF_INET6
)
1917 mask
[0] = 0xffffffff;
1919 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1922 mask
[1] = 0xffffffff;
1926 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1929 mask
[2] = 0xffffffff;
1933 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1936 mask
[3] = 0xffffffff;
1940 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1943 #endif /* AF_INET6 */
1948 mask
[0] = 0xffffffff;
1949 mask
[1] = 0xffffffff;
1950 mask
[2] = 0xffffffff;
1953 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1955 mask
[3] = 0xffffffff;
1960 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1961 "get_addr_and_mask(value=\"%s\", "
1962 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1963 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1967 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1970 if ((ip
[0] & ~mask
[0]) != 0 ||
1971 (ip
[1] & ~mask
[1]) != 0 ||
1972 (ip
[2] & ~mask
[2]) != 0 ||
1973 (ip
[3] & ~mask
[3]) != 0)
1981 * 'mime_error_cb()' - Log a MIME error.
1985 mime_error_cb(void *ctx
, /* I - Context pointer (unused) */
1986 const char *message
) /* I - Message */
1990 cupsdLogMessage(CUPSD_LOG_ERROR
, "%s", message
);
1995 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1998 static int /* O - 1 on success, 0 on failure */
1999 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
2000 char *line
, /* I - Line from file */
2001 char *value
, /* I - Start of value data */
2002 int linenum
) /* I - Current line number */
2004 char *valptr
; /* Pointer into value */
2005 unsigned ip
[4], /* IP address components */
2006 mask
[4]; /* IP netmask components */
2009 if (!_cups_strcasecmp(line
, "Encryption"))
2012 * "Encryption xxx" - set required encryption level...
2015 if (!_cups_strcasecmp(value
, "never"))
2016 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
2017 else if (!_cups_strcasecmp(value
, "always"))
2019 cupsdLogMessage(CUPSD_LOG_ERROR
,
2020 "Encryption value \"%s\" on line %d is invalid in this "
2021 "context. Using \"required\" instead.", value
, linenum
);
2023 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2025 else if (!_cups_strcasecmp(value
, "required"))
2026 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
2027 else if (!_cups_strcasecmp(value
, "ifrequested"))
2028 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
2031 cupsdLogMessage(CUPSD_LOG_ERROR
,
2032 "Unknown Encryption value %s on line %d.", value
, linenum
);
2036 else if (!_cups_strcasecmp(line
, "Order"))
2039 * "Order Deny,Allow" or "Order Allow,Deny"...
2042 if (!_cups_strncasecmp(value
, "deny", 4))
2043 loc
->order_type
= CUPSD_AUTH_ALLOW
;
2044 else if (!_cups_strncasecmp(value
, "allow", 5))
2045 loc
->order_type
= CUPSD_AUTH_DENY
;
2048 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
2053 else if (!_cups_strcasecmp(line
, "Allow") || !_cups_strcasecmp(line
, "Deny"))
2056 * Allow [From] host/ip...
2057 * Deny [From] host/ip...
2062 if (!_cups_strncasecmp(value
, "from", 4))
2065 * Strip leading "from"...
2070 while (_cups_isspace(*value
))
2078 * Find the end of the value...
2081 for (valptr
= value
; *valptr
&& !_cups_isspace(*valptr
); valptr
++);
2083 while (_cups_isspace(*valptr
))
2087 * Figure out what form the allow/deny address takes:
2098 * nnn.nnn.nnn.nnn/mm
2099 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2102 if (!_cups_strcasecmp(value
, "all"))
2108 if (!_cups_strcasecmp(line
, "Allow"))
2109 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
2111 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
2113 else if (!_cups_strcasecmp(value
, "none"))
2119 if (!_cups_strcasecmp(line
, "Allow"))
2120 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
2122 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
2125 else if (value
[0] == '*' || value
[0] == '.' ||
2126 (!isdigit(value
[0] & 255) && value
[0] != '['))
2128 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2129 #endif /* AF_INET6 */
2132 * Host or domain name...
2135 if (value
[0] == '*')
2138 if (!_cups_strcasecmp(line
, "Allow"))
2139 cupsdAddNameMask(&(loc
->allow
), value
);
2141 cupsdAddNameMask(&(loc
->deny
), value
);
2146 * One of many IP address forms...
2149 if (!get_addr_and_mask(value
, ip
, mask
))
2151 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2156 if (!_cups_strcasecmp(line
, "Allow"))
2157 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
2159 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
2163 * Advance to next value...
2169 else if (!_cups_strcasecmp(line
, "AuthType"))
2172 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2175 if (!_cups_strcasecmp(value
, "none"))
2177 loc
->type
= CUPSD_AUTH_NONE
;
2178 loc
->level
= CUPSD_AUTH_ANON
;
2180 else if (!_cups_strcasecmp(value
, "basic"))
2182 loc
->type
= CUPSD_AUTH_BASIC
;
2184 if (loc
->level
== CUPSD_AUTH_ANON
)
2185 loc
->level
= CUPSD_AUTH_USER
;
2187 else if (!_cups_strcasecmp(value
, "digest"))
2189 loc
->type
= CUPSD_AUTH_DIGEST
;
2191 if (loc
->level
== CUPSD_AUTH_ANON
)
2192 loc
->level
= CUPSD_AUTH_USER
;
2194 else if (!_cups_strcasecmp(value
, "basicdigest"))
2196 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2198 if (loc
->level
== CUPSD_AUTH_ANON
)
2199 loc
->level
= CUPSD_AUTH_USER
;
2201 else if (!_cups_strcasecmp(value
, "default"))
2203 loc
->type
= CUPSD_AUTH_DEFAULT
;
2205 if (loc
->level
== CUPSD_AUTH_ANON
)
2206 loc
->level
= CUPSD_AUTH_USER
;
2209 else if (!_cups_strcasecmp(value
, "negotiate"))
2211 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2213 if (loc
->level
== CUPSD_AUTH_ANON
)
2214 loc
->level
= CUPSD_AUTH_USER
;
2216 #endif /* HAVE_GSSAPI */
2219 cupsdLogMessage(CUPSD_LOG_WARN
,
2220 "Unknown authorization type %s on line %d.",
2225 else if (!_cups_strcasecmp(line
, "AuthClass"))
2228 * AuthClass anonymous, user, system, group
2231 if (!_cups_strcasecmp(value
, "anonymous"))
2233 loc
->type
= CUPSD_AUTH_NONE
;
2234 loc
->level
= CUPSD_AUTH_ANON
;
2236 cupsdLogMessage(CUPSD_LOG_WARN
,
2237 "\"AuthClass %s\" is deprecated; consider removing "
2241 else if (!_cups_strcasecmp(value
, "user"))
2243 loc
->level
= CUPSD_AUTH_USER
;
2245 cupsdLogMessage(CUPSD_LOG_WARN
,
2246 "\"AuthClass %s\" is deprecated; consider using "
2247 "\"Require valid-user\" on line %d.",
2250 else if (!_cups_strcasecmp(value
, "group"))
2252 loc
->level
= CUPSD_AUTH_GROUP
;
2254 cupsdLogMessage(CUPSD_LOG_WARN
,
2255 "\"AuthClass %s\" is deprecated; consider using "
2256 "\"Require user @groupname\" on line %d.",
2259 else if (!_cups_strcasecmp(value
, "system"))
2261 loc
->level
= CUPSD_AUTH_GROUP
;
2263 cupsdAddName(loc
, "@SYSTEM");
2265 cupsdLogMessage(CUPSD_LOG_WARN
,
2266 "\"AuthClass %s\" is deprecated; consider using "
2267 "\"Require user @SYSTEM\" on line %d.",
2272 cupsdLogMessage(CUPSD_LOG_WARN
,
2273 "Unknown authorization class %s on line %d.",
2278 else if (!_cups_strcasecmp(line
, "AuthGroupName"))
2280 cupsdAddName(loc
, value
);
2282 cupsdLogMessage(CUPSD_LOG_WARN
,
2283 "\"AuthGroupName %s\" directive is deprecated; consider "
2284 "using \"Require user @%s\" on line %d.",
2285 value
, value
, linenum
);
2287 else if (!_cups_strcasecmp(line
, "Require"))
2290 * Apache synonym for AuthClass and AuthGroupName...
2294 * Require valid-user
2295 * Require group names
2296 * Require user names
2299 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2304 if (!_cups_strcasecmp(value
, "valid-user") ||
2305 !_cups_strcasecmp(value
, "user"))
2306 loc
->level
= CUPSD_AUTH_USER
;
2307 else if (!_cups_strcasecmp(value
, "group"))
2308 loc
->level
= CUPSD_AUTH_GROUP
;
2311 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2317 * Get the list of names from the line...
2320 for (value
= valptr
; *value
;)
2322 while (_cups_isspace(*value
))
2325 #ifdef HAVE_AUTHORIZATION_H
2326 if (!strncmp(value
, "@AUTHKEY(", 9))
2329 * Grab "@AUTHKEY(name)" value...
2332 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2338 #endif /* HAVE_AUTHORIZATION_H */
2339 if (*value
== '\"' || *value
== '\'')
2342 * Grab quoted name...
2345 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2352 * Grab literal name.
2355 for (valptr
= value
; !_cups_isspace(*valptr
) && *valptr
; valptr
++);
2361 cupsdAddName(loc
, value
);
2363 for (value
= valptr
; _cups_isspace(*value
); value
++);
2366 else if (!_cups_strcasecmp(line
, "Satisfy"))
2368 if (!_cups_strcasecmp(value
, "all"))
2369 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2370 else if (!_cups_strcasecmp(value
, "any"))
2371 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2374 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2387 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2390 static int /* O - FatalErrors bits */
2391 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2393 int fatal
; /* FatalErrors bits */
2394 char value
[1024], /* Value string */
2395 *valstart
, /* Pointer into value */
2396 *valend
; /* End of value */
2400 * Empty FatalErrors line yields NULL pointer...
2404 return (CUPSD_FATAL_NONE
);
2407 * Loop through the value string,...
2410 strlcpy(value
, s
, sizeof(value
));
2412 fatal
= CUPSD_FATAL_NONE
;
2414 for (valstart
= value
; *valstart
;)
2417 * Get the current space/comma-delimited kind name...
2420 for (valend
= valstart
; *valend
; valend
++)
2421 if (_cups_isspace(*valend
) || *valend
== ',')
2428 * Add the error to the bitmask...
2431 if (!_cups_strcasecmp(valstart
, "all"))
2432 fatal
= CUPSD_FATAL_ALL
;
2433 else if (!_cups_strcasecmp(valstart
, "browse"))
2434 fatal
|= CUPSD_FATAL_BROWSE
;
2435 else if (!_cups_strcasecmp(valstart
, "-browse"))
2436 fatal
&= ~CUPSD_FATAL_BROWSE
;
2437 else if (!_cups_strcasecmp(valstart
, "config"))
2438 fatal
|= CUPSD_FATAL_CONFIG
;
2439 else if (!_cups_strcasecmp(valstart
, "-config"))
2440 fatal
&= ~CUPSD_FATAL_CONFIG
;
2441 else if (!_cups_strcasecmp(valstart
, "listen"))
2442 fatal
|= CUPSD_FATAL_LISTEN
;
2443 else if (!_cups_strcasecmp(valstart
, "-listen"))
2444 fatal
&= ~CUPSD_FATAL_LISTEN
;
2445 else if (!_cups_strcasecmp(valstart
, "log"))
2446 fatal
|= CUPSD_FATAL_LOG
;
2447 else if (!_cups_strcasecmp(valstart
, "-log"))
2448 fatal
&= ~CUPSD_FATAL_LOG
;
2449 else if (!_cups_strcasecmp(valstart
, "permissions"))
2450 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2451 else if (!_cups_strcasecmp(valstart
, "-permissions"))
2452 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2453 else if (_cups_strcasecmp(valstart
, "none"))
2454 cupsdLogMessage(CUPSD_LOG_ERROR
,
2455 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2457 for (valstart
= valend
; *valstart
; valstart
++)
2458 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2467 * 'parse_groups()' - Parse system group names in a string.
2470 static int /* O - 1 on success, 0 on failure */
2471 parse_groups(const char *s
) /* I - Space-delimited groups */
2473 int status
; /* Return status */
2474 char value
[1024], /* Value string */
2475 *valstart
, /* Pointer into value */
2476 *valend
, /* End of value */
2477 quote
; /* Quote character */
2478 struct group
*group
; /* Group */
2482 * Make a copy of the string and parse out the groups...
2485 strlcpy(value
, s
, sizeof(value
));
2490 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2492 if (*valstart
== '\'' || *valstart
== '\"')
2495 * Scan quoted name...
2498 quote
= *valstart
++;
2500 for (valend
= valstart
; *valend
; valend
++)
2501 if (*valend
== quote
)
2507 * Scan space or comma-delimited name...
2510 for (valend
= valstart
; *valend
; valend
++)
2511 if (_cups_isspace(*valend
) || *valend
== ',')
2518 group
= getgrnam(valstart
);
2521 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2522 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2533 while (*valstart
== ',' || _cups_isspace(*valstart
))
2542 * 'parse_protocols()' - Parse browse protocols in a string.
2545 static int /* O - Browse protocol bits */
2546 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2548 int protocols
; /* Browse protocol bits */
2549 char value
[1024], /* Value string */
2550 *valstart
, /* Pointer into value */
2551 *valend
; /* End of value */
2555 * Empty protocol line yields NULL pointer...
2562 * Loop through the value string,...
2565 strlcpy(value
, s
, sizeof(value
));
2569 for (valstart
= value
; *valstart
;)
2572 * Get the current space/comma-delimited protocol name...
2575 for (valend
= valstart
; *valend
; valend
++)
2576 if (_cups_isspace(*valend
) || *valend
== ',')
2583 * Add the protocol to the bitmask...
2586 if (!_cups_strcasecmp(valstart
, "dnssd") ||
2587 !_cups_strcasecmp(valstart
, "dns-sd") ||
2588 !_cups_strcasecmp(valstart
, "bonjour"))
2589 protocols
|= BROWSE_DNSSD
;
2590 else if (!_cups_strcasecmp(valstart
, "all"))
2591 protocols
|= BROWSE_ALL
;
2592 else if (_cups_strcasecmp(valstart
, "none"))
2593 cupsdLogMessage(CUPSD_LOG_ERROR
,
2594 "Unknown browse protocol \"%s\" ignored.", valstart
);
2596 for (valstart
= valend
; *valstart
; valstart
++)
2597 if (!_cups_isspace(*valstart
) || *valstart
!= ',')
2606 * 'parse_variable()' - Parse a variable line.
2609 static int /* O - 1 on success, 0 on failure */
2611 const char *filename
, /* I - Name of configuration file */
2612 int linenum
, /* I - Line in configuration file */
2613 const char *line
, /* I - Line from configuration file */
2614 const char *value
, /* I - Value from configuration file */
2615 size_t num_vars
, /* I - Number of variables */
2616 const cupsd_var_t
*vars
) /* I - Variables */
2618 size_t i
; /* Looping var */
2619 const cupsd_var_t
*var
; /* Variables */
2620 char temp
[1024]; /* Temporary string */
2623 for (i
= num_vars
, var
= vars
; i
> 0; i
--, var
++)
2624 if (!_cups_strcasecmp(line
, var
->name
))
2630 * Unknown directive! Output an error message and continue...
2634 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d of %s.",
2635 line
, linenum
, filename
);
2637 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d of %s.",
2638 line
, linenum
, filename
);
2645 case CUPSD_VARTYPE_INTEGER
:
2648 cupsdLogMessage(CUPSD_LOG_ERROR
,
2649 "Missing integer value for %s on line %d of %s.",
2650 line
, linenum
, filename
);
2653 else if (!isdigit(*value
& 255))
2655 cupsdLogMessage(CUPSD_LOG_ERROR
,
2656 "Bad integer value for %s on line %d of %s.",
2657 line
, linenum
, filename
);
2663 char *units
; /* Units */
2665 n
= strtol(value
, &units
, 0);
2667 if (units
&& *units
)
2669 if (tolower(units
[0] & 255) == 'g')
2670 n
*= 1024 * 1024 * 1024;
2671 else if (tolower(units
[0] & 255) == 'm')
2673 else if (tolower(units
[0] & 255) == 'k')
2675 else if (tolower(units
[0] & 255) == 't')
2679 cupsdLogMessage(CUPSD_LOG_ERROR
,
2680 "Unknown integer value for %s on line %d of %s.",
2681 line
, linenum
, filename
);
2688 cupsdLogMessage(CUPSD_LOG_ERROR
,
2689 "Bad negative integer value for %s on line %d of "
2690 "%s.", line
, linenum
, filename
);
2695 *((int *)var
->ptr
) = n
;
2700 case CUPSD_VARTYPE_TIME
:
2703 cupsdLogMessage(CUPSD_LOG_ERROR
,
2704 "Missing time interval value for %s on line %d of "
2705 "%s.", line
, linenum
, filename
);
2708 else if (!_cups_strncasecmp(line
, "PreserveJob", 11) &&
2709 (!_cups_strcasecmp(value
, "true") ||
2710 !_cups_strcasecmp(value
, "on") ||
2711 !_cups_strcasecmp(value
, "enabled") ||
2712 !_cups_strcasecmp(value
, "yes")))
2714 *((int *)var
->ptr
) = INT_MAX
;
2716 else if (!_cups_strcasecmp(value
, "false") ||
2717 !_cups_strcasecmp(value
, "off") ||
2718 !_cups_strcasecmp(value
, "disabled") ||
2719 !_cups_strcasecmp(value
, "no"))
2721 *((int *)var
->ptr
) = 0;
2723 else if (!isdigit(*value
& 255))
2725 cupsdLogMessage(CUPSD_LOG_ERROR
,
2726 "Unknown time interval value for %s on line %d of "
2727 "%s.", line
, linenum
, filename
);
2732 double n
; /* Number */
2733 char *units
; /* Units */
2735 n
= strtod(value
, &units
);
2737 if (units
&& *units
)
2739 if (tolower(units
[0] & 255) == 'w')
2740 n
*= 7 * 24 * 60 * 60;
2741 else if (tolower(units
[0] & 255) == 'd')
2743 else if (tolower(units
[0] & 255) == 'h')
2745 else if (tolower(units
[0] & 255) == 'm')
2749 cupsdLogMessage(CUPSD_LOG_ERROR
,
2750 "Unknown time interval value for %s on line "
2751 "%d of %s.", line
, linenum
, filename
);
2756 if (n
< 0.0 || n
> INT_MAX
)
2758 cupsdLogMessage(CUPSD_LOG_ERROR
,
2759 "Bad time value for %s on line %d of %s.",
2760 line
, linenum
, filename
);
2765 *((int *)var
->ptr
) = (int)n
;
2770 case CUPSD_VARTYPE_BOOLEAN
:
2773 cupsdLogMessage(CUPSD_LOG_ERROR
,
2774 "Missing boolean value for %s on line %d of %s.",
2775 line
, linenum
, filename
);
2778 else if (!_cups_strcasecmp(value
, "true") ||
2779 !_cups_strcasecmp(value
, "on") ||
2780 !_cups_strcasecmp(value
, "enabled") ||
2781 !_cups_strcasecmp(value
, "yes") ||
2784 *((int *)var
->ptr
) = TRUE
;
2786 else if (!_cups_strcasecmp(value
, "false") ||
2787 !_cups_strcasecmp(value
, "off") ||
2788 !_cups_strcasecmp(value
, "disabled") ||
2789 !_cups_strcasecmp(value
, "no") ||
2790 !_cups_strcasecmp(value
, "0"))
2792 *((int *)var
->ptr
) = FALSE
;
2796 cupsdLogMessage(CUPSD_LOG_ERROR
,
2797 "Unknown boolean value %s on line %d of %s.",
2798 value
, linenum
, filename
);
2803 case CUPSD_VARTYPE_PATHNAME
:
2806 cupsdLogMessage(CUPSD_LOG_ERROR
,
2807 "Missing pathname value for %s on line %d of %s.",
2808 line
, linenum
, filename
);
2812 if (value
[0] == '/')
2813 strlcpy(temp
, value
, sizeof(temp
));
2815 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
2817 if (access(temp
, 0))
2819 cupsdLogMessage(CUPSD_LOG_ERROR
,
2820 "File or directory for \"%s %s\" on line %d of %s "
2821 "does not exist.", line
, value
, linenum
, filename
);
2825 cupsdSetString((char **)var
->ptr
, temp
);
2828 case CUPSD_VARTYPE_STRING
:
2829 cupsdSetString((char **)var
->ptr
, value
);
2838 * 'read_cupsd_conf()' - Read the cupsd.conf configuration file.
2841 static int /* O - 1 on success, 0 on failure */
2842 read_cupsd_conf(cups_file_t
*fp
) /* I - File to read from */
2844 int linenum
; /* Current line number */
2845 char line
[HTTP_MAX_BUFFER
],
2846 /* Line from file */
2847 temp
[HTTP_MAX_BUFFER
],
2848 /* Temporary buffer for value */
2849 *value
, /* Pointer to value */
2850 *valueptr
; /* Pointer into value */
2851 int valuelen
; /* Length of value */
2852 http_addrlist_t
*addrlist
, /* Address list */
2853 *addr
; /* Current address */
2854 cups_file_t
*incfile
; /* Include file */
2855 char incname
[1024]; /* Include filename */
2859 * Loop through each line in the file...
2864 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2867 * Decode the directive...
2870 if (!_cups_strcasecmp(line
, "Include") && value
)
2876 if (value
[0] == '/')
2877 strlcpy(incname
, value
, sizeof(incname
));
2879 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2881 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2882 cupsdLogMessage(CUPSD_LOG_ERROR
,
2883 "Unable to include config file \"%s\" - %s",
2884 incname
, strerror(errno
));
2887 read_cupsd_conf(incfile
);
2888 cupsFileClose(incfile
);
2891 else if (!_cups_strcasecmp(line
, "<Location") && value
)
2897 linenum
= read_location(fp
, value
, linenum
);
2901 else if (!_cups_strcasecmp(line
, "<Policy") && value
)
2907 linenum
= read_policy(fp
, value
, linenum
);
2911 else if (!_cups_strcasecmp(line
, "FaxRetryInterval") && value
)
2913 JobRetryInterval
= atoi(value
);
2914 cupsdLogMessage(CUPSD_LOG_WARN
,
2915 "FaxRetryInterval is deprecated; use "
2916 "JobRetryInterval on line %d.", linenum
);
2918 else if (!_cups_strcasecmp(line
, "FaxRetryLimit") && value
)
2920 JobRetryLimit
= atoi(value
);
2921 cupsdLogMessage(CUPSD_LOG_WARN
,
2922 "FaxRetryLimit is deprecated; use "
2923 "JobRetryLimit on line %d.", linenum
);
2925 else if ((!_cups_strcasecmp(line
, "Port") || !_cups_strcasecmp(line
, "Listen")
2927 || !_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen")
2928 #endif /* HAVE_SSL */
2932 * Add listening address(es) to the list...
2935 cupsd_listener_t
*lis
; /* New listeners array */
2939 * Get the address list...
2942 addrlist
= get_address(value
, IPP_PORT
);
2946 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2952 * Add each address...
2955 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2958 * See if this address is already present...
2961 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2963 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2964 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2965 httpAddrPort(&(addr
->addr
)) == httpAddrPort(&(lis
->address
)))
2970 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2971 cupsdLogMessage(CUPSD_LOG_WARN
,
2972 "Duplicate listen address \"%s\" ignored.", temp
);
2977 * Allocate another listener...
2981 Listeners
= cupsArrayNew(NULL
, NULL
);
2985 cupsdLogMessage(CUPSD_LOG_ERROR
,
2986 "Unable to allocate %s at line %d - %s.",
2987 line
, linenum
, strerror(errno
));
2991 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2993 cupsdLogMessage(CUPSD_LOG_ERROR
,
2994 "Unable to allocate %s at line %d - %s.",
2995 line
, linenum
, strerror(errno
));
2999 cupsArrayAdd(Listeners
, lis
);
3002 * Copy the current address and log it...
3005 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
3009 if (!_cups_strcasecmp(line
, "SSLPort") || !_cups_strcasecmp(line
, "SSLListen"))
3010 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
3011 #endif /* HAVE_SSL */
3013 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
3016 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
3017 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
3019 #endif /* AF_LOCAL */
3020 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
3021 httpAddrPort(&(lis
->address
)),
3022 httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
3024 if (!httpAddrLocalhost(&(lis
->address
)))
3025 RemotePort
= httpAddrPort(&(lis
->address
));
3032 httpAddrFreeList(addrlist
);
3034 else if (!_cups_strcasecmp(line
, "BrowseProtocols") ||
3035 !_cups_strcasecmp(line
, "BrowseLocalProtocols"))
3038 * "BrowseProtocols name [... name]"
3039 * "BrowseLocalProtocols name [... name]"
3042 int protocols
= parse_protocols(value
);
3046 cupsdLogMessage(CUPSD_LOG_ERROR
,
3047 "Unknown browse protocol \"%s\" on line %d.",
3052 BrowseLocalProtocols
= protocols
;
3054 else if (!_cups_strcasecmp(line
, "DefaultAuthType") && value
)
3057 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3060 if (!_cups_strcasecmp(value
, "none"))
3061 default_auth_type
= CUPSD_AUTH_NONE
;
3062 else if (!_cups_strcasecmp(value
, "basic"))
3063 default_auth_type
= CUPSD_AUTH_BASIC
;
3064 else if (!_cups_strcasecmp(value
, "digest"))
3065 default_auth_type
= CUPSD_AUTH_DIGEST
;
3066 else if (!_cups_strcasecmp(value
, "basicdigest"))
3067 default_auth_type
= CUPSD_AUTH_BASICDIGEST
;
3069 else if (!_cups_strcasecmp(value
, "negotiate"))
3070 default_auth_type
= CUPSD_AUTH_NEGOTIATE
;
3071 #endif /* HAVE_GSSAPI */
3072 else if (!_cups_strcasecmp(value
, "auto"))
3073 default_auth_type
= CUPSD_AUTH_AUTO
;
3076 cupsdLogMessage(CUPSD_LOG_WARN
,
3077 "Unknown default authorization type %s on line %d.",
3079 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3084 else if (!_cups_strcasecmp(line
, "DefaultEncryption"))
3087 * DefaultEncryption {Never,IfRequested,Required}
3090 if (!value
|| !_cups_strcasecmp(value
, "never"))
3091 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3092 else if (!_cups_strcasecmp(value
, "required"))
3093 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3094 else if (!_cups_strcasecmp(value
, "ifrequested"))
3095 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3098 cupsdLogMessage(CUPSD_LOG_WARN
,
3099 "Unknown default encryption %s on line %d.",
3101 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3105 #endif /* HAVE_SSL */
3106 else if (!_cups_strcasecmp(line
, "HostNameLookups") && value
)
3109 * Do hostname lookups?
3112 if (!_cups_strcasecmp(value
, "off") || !_cups_strcasecmp(value
, "no") ||
3113 !_cups_strcasecmp(value
, "false"))
3114 HostNameLookups
= 0;
3115 else if (!_cups_strcasecmp(value
, "on") || !_cups_strcasecmp(value
, "yes") ||
3116 !_cups_strcasecmp(value
, "true"))
3117 HostNameLookups
= 1;
3118 else if (!_cups_strcasecmp(value
, "double"))
3119 HostNameLookups
= 2;
3121 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3124 else if (!_cups_strcasecmp(line
, "AccessLogLevel") && value
)
3127 * Amount of logging to do to access log...
3130 if (!_cups_strcasecmp(value
, "all"))
3131 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3132 else if (!_cups_strcasecmp(value
, "actions"))
3133 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3134 else if (!_cups_strcasecmp(value
, "config"))
3135 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3137 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3140 else if (!_cups_strcasecmp(line
, "LogLevel") && value
)
3143 * Amount of logging to do to error log...
3146 if (!_cups_strcasecmp(value
, "debug2"))
3147 LogLevel
= CUPSD_LOG_DEBUG2
;
3148 else if (!_cups_strcasecmp(value
, "debug"))
3149 LogLevel
= CUPSD_LOG_DEBUG
;
3150 else if (!_cups_strcasecmp(value
, "info"))
3151 LogLevel
= CUPSD_LOG_INFO
;
3152 else if (!_cups_strcasecmp(value
, "notice"))
3153 LogLevel
= CUPSD_LOG_NOTICE
;
3154 else if (!_cups_strcasecmp(value
, "warn"))
3155 LogLevel
= CUPSD_LOG_WARN
;
3156 else if (!_cups_strcasecmp(value
, "error"))
3157 LogLevel
= CUPSD_LOG_ERROR
;
3158 else if (!_cups_strcasecmp(value
, "crit"))
3159 LogLevel
= CUPSD_LOG_CRIT
;
3160 else if (!_cups_strcasecmp(value
, "alert"))
3161 LogLevel
= CUPSD_LOG_ALERT
;
3162 else if (!_cups_strcasecmp(value
, "emerg"))
3163 LogLevel
= CUPSD_LOG_EMERG
;
3164 else if (!_cups_strcasecmp(value
, "none"))
3165 LogLevel
= CUPSD_LOG_NONE
;
3167 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3170 else if (!_cups_strcasecmp(line
, "LogTimeFormat") && value
)
3173 * Amount of logging to do to error log...
3176 if (!_cups_strcasecmp(value
, "standard"))
3177 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3178 else if (!_cups_strcasecmp(value
, "usecs"))
3179 LogTimeFormat
= CUPSD_TIME_USECS
;
3181 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3184 else if (!_cups_strcasecmp(line
, "ServerTokens") && value
)
3187 * Set the string used for the Server header...
3190 struct utsname plat
; /* Platform info */
3195 if (!_cups_strcasecmp(value
, "ProductOnly"))
3196 cupsdSetString(&ServerHeader
, "CUPS IPP");
3197 else if (!_cups_strcasecmp(value
, "Major"))
3198 cupsdSetStringf(&ServerHeader
, "CUPS/%d IPP/2", CUPS_VERSION_MAJOR
);
3199 else if (!_cups_strcasecmp(value
, "Minor"))
3200 cupsdSetStringf(&ServerHeader
, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR
,
3201 CUPS_VERSION_MINOR
);
3202 else if (!_cups_strcasecmp(value
, "Minimal"))
3203 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
" IPP/2.1");
3204 else if (!_cups_strcasecmp(value
, "OS"))
3205 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s) IPP/2.1",
3206 plat
.sysname
, plat
.release
);
3207 else if (!_cups_strcasecmp(value
, "Full"))
3208 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s %s; %s) IPP/2.1",
3209 plat
.sysname
, plat
.release
, plat
.machine
);
3210 else if (!_cups_strcasecmp(value
, "None"))
3211 cupsdClearString(&ServerHeader
);
3213 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3216 else if (!_cups_strcasecmp(line
, "PassEnv") && value
)
3219 * PassEnv variable [... variable]
3224 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3225 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3228 if (value
[valuelen
])
3230 value
[valuelen
] = '\0';
3234 cupsdSetEnv(value
, NULL
);
3236 for (value
+= valuelen
; *value
; value
++)
3237 if (!_cups_isspace(*value
) || *value
!= ',')
3241 else if (!_cups_strcasecmp(line
, "ServerAlias") && value
)
3244 * ServerAlias name [... name]
3248 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3252 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3253 if (_cups_isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3256 if (value
[valuelen
])
3258 value
[valuelen
] = '\0';
3262 cupsdAddAlias(ServerAlias
, value
);
3264 for (value
+= valuelen
; *value
; value
++)
3265 if (!_cups_isspace(*value
) || *value
!= ',')
3269 else if (!_cups_strcasecmp(line
, "SetEnv") && value
)
3272 * SetEnv variable value
3275 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3283 while (isspace(*valueptr
& 255))
3286 cupsdSetEnv(value
, valueptr
);
3289 cupsdLogMessage(CUPSD_LOG_ERROR
,
3290 "Missing value for SetEnv directive on line %d.",
3293 else if (!_cups_strcasecmp(line
, "AccessLog") ||
3294 !_cups_strcasecmp(line
, "CacheDir") ||
3295 !_cups_strcasecmp(line
, "ConfigFilePerm") ||
3296 !_cups_strcasecmp(line
, "DataDir") ||
3297 !_cups_strcasecmp(line
, "DocumentRoot") ||
3298 !_cups_strcasecmp(line
, "ErrorLog") ||
3299 !_cups_strcasecmp(line
, "FatalErrors") ||
3300 !_cups_strcasecmp(line
, "FileDevice") ||
3301 !_cups_strcasecmp(line
, "FontPath") ||
3302 !_cups_strcasecmp(line
, "Group") ||
3303 !_cups_strcasecmp(line
, "LogFilePerm") ||
3304 !_cups_strcasecmp(line
, "LPDConfigFile") ||
3305 !_cups_strcasecmp(line
, "PageLog") ||
3306 !_cups_strcasecmp(line
, "Printcap") ||
3307 !_cups_strcasecmp(line
, "PrintcapFormat") ||
3308 !_cups_strcasecmp(line
, "RemoteRoot") ||
3309 !_cups_strcasecmp(line
, "RequestRoot") ||
3310 !_cups_strcasecmp(line
, "ServerBin") ||
3311 !_cups_strcasecmp(line
, "ServerCertificate") ||
3312 !_cups_strcasecmp(line
, "ServerKey") ||
3313 !_cups_strcasecmp(line
, "ServerRoot") ||
3314 !_cups_strcasecmp(line
, "SMBConfigFile") ||
3315 !_cups_strcasecmp(line
, "StateDir") ||
3316 !_cups_strcasecmp(line
, "SystemGroup") ||
3317 !_cups_strcasecmp(line
, "SystemGroupAuthKey") ||
3318 !_cups_strcasecmp(line
, "TempDir") ||
3319 !_cups_strcasecmp(line
, "User"))
3321 cupsdLogMessage(CUPSD_LOG_INFO
,
3322 "Please move \"%s%s%s\" on line %d of %s to the %s file; "
3323 "this will become an error in a future release.",
3324 line
, value
? " " : "", value
? value
: "", linenum
,
3325 ConfigurationFile
, CupsFilesFile
);
3328 parse_variable(ConfigurationFile
, linenum
, line
, value
,
3329 sizeof(cupsd_vars
) / sizeof(cupsd_vars
[0]), cupsd_vars
);
3337 * 'read_cups_files_conf()' - Read the cups-files.conf configuration file.
3340 static int /* O - 1 on success, 0 on failure */
3341 read_cups_files_conf(cups_file_t
*fp
) /* I - File to read from */
3343 int linenum
; /* Current line number */
3344 char line
[HTTP_MAX_BUFFER
], /* Line from file */
3345 *value
; /* Value from line */
3346 struct group
*group
; /* Group */
3350 * Loop through each line in the file...
3355 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3357 if (!_cups_strcasecmp(line
, "FatalErrors"))
3358 FatalErrors
= parse_fatal_errors(value
);
3359 else if (!_cups_strcasecmp(line
, "Group") && value
)
3362 * Group ID to run as...
3365 if (isdigit(value
[0]))
3366 Group
= atoi(value
);
3370 group
= getgrnam(value
);
3373 Group
= group
->gr_gid
;
3376 cupsdLogMessage(CUPSD_LOG_ERROR
,
3377 "Unknown Group \"%s\" on line %d of %s.", value
,
3378 linenum
, CupsFilesFile
);
3379 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3384 else if (!_cups_strcasecmp(line
, "PrintcapFormat") && value
)
3387 * Format of printcap file?
3390 if (!_cups_strcasecmp(value
, "bsd"))
3391 PrintcapFormat
= PRINTCAP_BSD
;
3392 else if (!_cups_strcasecmp(value
, "plist"))
3393 PrintcapFormat
= PRINTCAP_PLIST
;
3394 else if (!_cups_strcasecmp(value
, "solaris"))
3395 PrintcapFormat
= PRINTCAP_SOLARIS
;
3398 cupsdLogMessage(CUPSD_LOG_ERROR
,
3399 "Unknown PrintcapFormat \"%s\" on line %d of %s.",
3400 value
, linenum
, CupsFilesFile
);
3401 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3405 else if (!_cups_strcasecmp(line
, "SystemGroup") && value
)
3408 * SystemGroup (admin) group(s)...
3411 if (!parse_groups(value
))
3413 cupsdLogMessage(CUPSD_LOG_ERROR
,
3414 "Unknown SystemGroup \"%s\" on line %d of %s.", value
,
3415 linenum
, CupsFilesFile
);
3416 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3420 else if (!_cups_strcasecmp(line
, "User") && value
)
3423 * User ID to run as...
3426 if (isdigit(value
[0] & 255))
3428 int uid
= atoi(value
);
3432 cupsdLogMessage(CUPSD_LOG_ERROR
,
3433 "Will not use User 0 as specified on line %d of %s "
3434 "for security reasons. You must use a non-"
3435 "privileged account instead.",
3436 linenum
, CupsFilesFile
);
3437 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3445 struct passwd
*p
; /* Password information */
3448 p
= getpwnam(value
);
3454 cupsdLogMessage(CUPSD_LOG_ERROR
,
3455 "Will not use User %s (UID=0) as specified on line "
3456 "%d of %s for security reasons. You must use a "
3457 "non-privileged account instead.",
3458 value
, linenum
, CupsFilesFile
);
3459 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3467 cupsdLogMessage(CUPSD_LOG_ERROR
,
3468 "Unknown User \"%s\" on line %d of %s.",
3469 value
, linenum
, CupsFilesFile
);
3470 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3475 else if (!parse_variable(CupsFilesFile
, linenum
, line
, value
,
3476 sizeof(cupsfiles_vars
) / sizeof(cupsfiles_vars
[0]),
3478 (FatalErrors
& CUPSD_FATAL_CONFIG
))
3487 * 'read_location()' - Read a <Location path> definition.
3490 static int /* O - New line number or 0 on error */
3491 read_location(cups_file_t
*fp
, /* I - Configuration file */
3492 char *location
, /* I - Location name/path */
3493 int linenum
) /* I - Current line number */
3495 cupsd_location_t
*loc
, /* New location */
3496 *parent
; /* Parent location */
3497 char line
[HTTP_MAX_BUFFER
],
3499 *value
, /* Value for directive */
3500 *valptr
; /* Pointer into value */
3503 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3504 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3506 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3510 cupsdAddLocation(parent
);
3512 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3517 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3520 * Decode the directive...
3523 if (!_cups_strcasecmp(line
, "</Location>"))
3525 else if (!_cups_strcasecmp(line
, "<Limit") ||
3526 !_cups_strcasecmp(line
, "<LimitExcept"))
3530 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3531 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3537 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3540 cupsdAddLocation(loc
);
3545 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3550 if (!strcmp(value
, "ALL"))
3551 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3552 else if (!strcmp(value
, "GET"))
3553 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3554 else if (!strcmp(value
, "HEAD"))
3555 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3556 else if (!strcmp(value
, "OPTIONS"))
3557 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3558 else if (!strcmp(value
, "POST"))
3559 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3560 else if (!strcmp(value
, "PUT"))
3561 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3562 else if (!strcmp(value
, "TRACE"))
3563 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3565 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3568 for (value
= valptr
; isspace(*value
& 255); value
++);
3571 if (!_cups_strcasecmp(line
, "<LimitExcept"))
3572 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3574 parent
->limit
&= ~loc
->limit
;
3576 else if (!_cups_strcasecmp(line
, "</Limit>") ||
3577 !_cups_strcasecmp(line
, "</LimitExcept>"))
3581 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3582 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3585 else if (!parse_aaa(loc
, line
, value
, linenum
))
3587 cupsdLogMessage(CUPSD_LOG_ERROR
,
3588 "Unknown Location directive %s on line %d.",
3590 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3595 cupsdLogMessage(CUPSD_LOG_ERROR
,
3596 "Unexpected end-of-file at line %d while reading location.",
3599 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3604 * 'read_policy()' - Read a <Policy name> definition.
3607 static int /* O - New line number or 0 on error */
3608 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3609 char *policy
, /* I - Location name/path */
3610 int linenum
) /* I - Current line number */
3612 int i
; /* Looping var */
3613 cupsd_policy_t
*pol
; /* Policy */
3614 cupsd_location_t
*op
; /* Policy operation */
3615 int num_ops
; /* Number of IPP operations */
3616 ipp_op_t ops
[100]; /* Operations */
3617 char line
[HTTP_MAX_BUFFER
],
3619 *value
, /* Value for directive */
3620 *valptr
; /* Pointer into value */
3624 * Create the policy...
3627 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3628 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3630 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3634 * Read from the file...
3640 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3643 * Decode the directive...
3646 if (!_cups_strcasecmp(line
, "</Policy>"))
3649 cupsdLogMessage(CUPSD_LOG_WARN
,
3650 "Missing </Limit> before </Policy> on line %d.",
3653 set_policy_defaults(pol
);
3657 else if (!_cups_strcasecmp(line
, "<Limit") && !op
)
3661 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3662 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3669 * Scan for IPP operation names...
3676 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3681 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3683 if (!_cups_strcasecmp(value
, "All"))
3684 ops
[num_ops
] = IPP_ANY_OPERATION
;
3685 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3686 cupsdLogMessage(CUPSD_LOG_ERROR
,
3687 "Bad IPP operation name \"%s\" on line %d.",
3693 cupsdLogMessage(CUPSD_LOG_ERROR
,
3694 "Too many operations listed on line %d.",
3697 for (value
= valptr
; isspace(*value
& 255); value
++);
3701 * If none are specified, apply the policy to all operations...
3706 ops
[0] = IPP_ANY_OPERATION
;
3711 * Add a new policy for the first operation...
3714 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3716 else if (!_cups_strcasecmp(line
, "</Limit>") && op
)
3719 * Finish the current operation limit...
3725 * Copy the policy to the other operations...
3728 for (i
= 1; i
< num_ops
; i
++)
3729 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3736 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value on line %d.", linenum
);
3737 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3740 else if (!_cups_strcasecmp(line
, "JobPrivateAccess") ||
3741 !_cups_strcasecmp(line
, "JobPrivateValues") ||
3742 !_cups_strcasecmp(line
, "SubscriptionPrivateAccess") ||
3743 !_cups_strcasecmp(line
, "SubscriptionPrivateValues"))
3747 cupsdLogMessage(CUPSD_LOG_ERROR
,
3748 "%s directive must appear outside <Limit>...</Limit> "
3749 "on line %d.", line
, linenum
);
3750 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3756 * Pull out whitespace-delimited values...
3762 * Find the end of the current value...
3765 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3771 * Save it appropriately...
3774 if (!_cups_strcasecmp(line
, "JobPrivateAccess"))
3777 * JobPrivateAccess {all|default|user/group list|@@ACL}
3780 if (!_cups_strcasecmp(value
, "default"))
3782 cupsdAddString(&(pol
->job_access
), "@OWNER");
3783 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3786 cupsdAddString(&(pol
->job_access
), value
);
3788 else if (!_cups_strcasecmp(line
, "JobPrivateValues"))
3791 * JobPrivateValues {all|none|default|attribute list}
3794 if (!_cups_strcasecmp(value
, "default"))
3796 cupsdAddString(&(pol
->job_attrs
), "job-name");
3797 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3798 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3799 cupsdAddString(&(pol
->job_attrs
), "phone");
3802 cupsdAddString(&(pol
->job_attrs
), value
);
3804 else if (!_cups_strcasecmp(line
, "SubscriptionPrivateAccess"))
3807 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3810 if (!_cups_strcasecmp(value
, "default"))
3812 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3813 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3816 cupsdAddString(&(pol
->sub_access
), value
);
3818 else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
3821 * SubscriptionPrivateValues {all|none|default|attribute list}
3824 if (!_cups_strcasecmp(value
, "default"))
3826 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3827 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3828 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3829 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3830 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3833 cupsdAddString(&(pol
->sub_attrs
), value
);
3837 * Find the next string on the line...
3840 for (value
= valptr
; isspace(*value
& 255); value
++);
3846 cupsdLogMessage(CUPSD_LOG_ERROR
,
3847 "Missing <Limit ops> directive before %s on line %d.",
3849 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3852 else if (!parse_aaa(op
, line
, value
, linenum
))
3854 cupsdLogMessage(CUPSD_LOG_ERROR
,
3855 "Unknown Policy Limit directive %s on line %d.",
3858 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3863 cupsdLogMessage(CUPSD_LOG_ERROR
,
3864 "Unexpected end-of-file at line %d while reading policy "
3865 "\"%s\".", linenum
, policy
);
3867 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3872 * 'set_policy_defaults()' - Set default policy values as needed.
3876 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3878 cupsd_location_t
*op
; /* Policy operation */
3882 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3883 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3884 * upgrades do not introduce new security issues...
3887 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3888 op
->op
== IPP_ANY_OPERATION
)
3890 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3891 op
->op
!= IPP_ANY_OPERATION
)
3894 * Add a new limit for Validate-Job using the Print-Job limit as a
3898 cupsdLogMessage(CUPSD_LOG_WARN
,
3899 "No limit for Validate-Job defined in policy %s "
3900 "- using Print-Job's policy.", pol
->name
);
3902 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3905 cupsdLogMessage(CUPSD_LOG_WARN
,
3906 "No limit for Validate-Job defined in policy %s "
3907 "and no suitable template found.", pol
->name
);
3910 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3911 op
->op
== IPP_ANY_OPERATION
)
3913 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3914 op
->op
!= IPP_ANY_OPERATION
)
3917 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3921 cupsdLogMessage(CUPSD_LOG_WARN
,
3922 "No limit for Cancel-Jobs defined in policy %s "
3923 "- using Pause-Printer's policy.", pol
->name
);
3925 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3928 cupsdLogMessage(CUPSD_LOG_WARN
,
3929 "No limit for Cancel-Jobs defined in policy %s "
3930 "and no suitable template found.", pol
->name
);
3933 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3934 op
->op
== IPP_ANY_OPERATION
)
3936 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3937 op
->op
!= IPP_ANY_OPERATION
)
3940 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
3944 cupsdLogMessage(CUPSD_LOG_WARN
,
3945 "No limit for Cancel-My-Jobs defined in policy %s "
3946 "- using Send-Document's policy.", pol
->name
);
3948 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
3951 cupsdLogMessage(CUPSD_LOG_WARN
,
3952 "No limit for Cancel-My-Jobs defined in policy %s "
3953 "and no suitable template found.", pol
->name
);
3956 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
3957 op
->op
== IPP_ANY_OPERATION
)
3959 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3960 op
->op
!= IPP_ANY_OPERATION
)
3963 * Add a new limit for Close-Job using the Send-Document limit as a
3967 cupsdLogMessage(CUPSD_LOG_WARN
,
3968 "No limit for Close-Job defined in policy %s "
3969 "- using Send-Document's policy.", pol
->name
);
3971 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
3974 cupsdLogMessage(CUPSD_LOG_WARN
,
3975 "No limit for Close-Job defined in policy %s "
3976 "and no suitable template found.", pol
->name
);
3979 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
3980 op
->op
== IPP_ANY_OPERATION
)
3982 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3983 op
->op
!= IPP_ANY_OPERATION
)
3986 * Add a new limit for CUPS-Get-Document using the Send-Document
3987 * limit as a template...
3990 cupsdLogMessage(CUPSD_LOG_WARN
,
3991 "No limit for CUPS-Get-Document defined in policy %s "
3992 "- using Send-Document's policy.", pol
->name
);
3994 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
3997 cupsdLogMessage(CUPSD_LOG_WARN
,
3998 "No limit for CUPS-Get-Document defined in policy %s "
3999 "and no suitable template found.", pol
->name
);
4003 * Verify we have JobPrivateAccess, JobPrivateValues,
4004 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4007 if (!pol
->job_access
)
4009 cupsdLogMessage(CUPSD_LOG_WARN
,
4010 "No JobPrivateAccess defined in policy %s "
4011 "- using defaults.", pol
->name
);
4012 cupsdAddString(&(pol
->job_access
), "@OWNER");
4013 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4016 if (!pol
->job_attrs
)
4018 cupsdLogMessage(CUPSD_LOG_WARN
,
4019 "No JobPrivateValues defined in policy %s "
4020 "- using defaults.", pol
->name
);
4021 cupsdAddString(&(pol
->job_attrs
), "job-name");
4022 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4023 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4024 cupsdAddString(&(pol
->job_attrs
), "phone");
4027 if (!pol
->sub_access
)
4029 cupsdLogMessage(CUPSD_LOG_WARN
,
4030 "No SubscriptionPrivateAccess defined in policy %s "
4031 "- using defaults.", pol
->name
);
4032 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4033 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4036 if (!pol
->sub_attrs
)
4038 cupsdLogMessage(CUPSD_LOG_WARN
,
4039 "No SubscriptionPrivateValues defined in policy %s "
4040 "- using defaults.", pol
->name
);
4041 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4042 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4043 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4044 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4045 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");