2 * "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $"
4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdAddAlias() - Add a host alias.
18 * cupsdCheckPermissions() - Fix the mode and ownership of a file or
20 * cupsdFreeAliases() - Free all of the alias entries.
21 * cupsdReadConfiguration() - Read the cupsd.conf file.
22 * get_address() - Get an address + port number from a line.
23 * get_addr_and_mask() - Get an IP address and netmask.
24 * parse_aaa() - Parse authentication, authorization, and access
26 * parse_fatal_errors() - Parse FatalErrors values in a string.
27 * parse_groups() - Parse system group names in a string.
28 * parse_protocols() - Parse browse protocols in a string.
29 * read_configuration() - Read a configuration file.
30 * read_location() - Read a <Location path> definition.
31 * read_policy() - Read a <Policy name> definition.
32 * set_policy_defaults() - Set default policy values as needed.
36 * Include necessary headers...
42 #include <sys/utsname.h>
47 #endif /* HAVE_LIBPAPER */
51 * Possibly missing network definitions...
55 # define INADDR_NONE 0xffffffff
56 #endif /* !INADDR_NONE */
60 * Configuration variable structure...
65 CUPSD_VARTYPE_INTEGER
, /* Integer option */
66 CUPSD_VARTYPE_STRING
, /* String option */
67 CUPSD_VARTYPE_BOOLEAN
, /* Boolean option */
68 CUPSD_VARTYPE_PATHNAME
/* File/directory name option */
73 char *name
; /* Name of variable */
74 void *ptr
; /* Pointer to variable */
75 cupsd_vartype_t type
; /* Type (int, string, address) */
83 static const cupsd_var_t variables
[] =
85 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
86 { "AutoPurgeJobs", &JobAutoPurge
, CUPSD_VARTYPE_BOOLEAN
},
87 { "BrowseInterval", &BrowseInterval
, CUPSD_VARTYPE_INTEGER
},
89 { "BrowseLDAPBindDN", &BrowseLDAPBindDN
, CUPSD_VARTYPE_STRING
},
91 { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile
, CUPSD_VARTYPE_PATHNAME
},
92 # endif /* HAVE_LDAP_SSL */
93 { "BrowseLDAPDN", &BrowseLDAPDN
, CUPSD_VARTYPE_STRING
},
94 { "BrowseLDAPPassword", &BrowseLDAPPassword
, CUPSD_VARTYPE_STRING
},
95 { "BrowseLDAPServer", &BrowseLDAPServer
, CUPSD_VARTYPE_STRING
},
96 #endif /* HAVE_LDAP */
97 { "BrowseLocalOptions", &BrowseLocalOptions
, CUPSD_VARTYPE_STRING
},
98 { "BrowsePort", &BrowsePort
, CUPSD_VARTYPE_INTEGER
},
99 { "BrowseRemoteOptions", &BrowseRemoteOptions
, CUPSD_VARTYPE_STRING
},
100 { "BrowseShortNames", &BrowseShortNames
, CUPSD_VARTYPE_BOOLEAN
},
101 { "BrowseTimeout", &BrowseTimeout
, CUPSD_VARTYPE_INTEGER
},
102 { "BrowseWebIF", &BrowseWebIF
, CUPSD_VARTYPE_BOOLEAN
},
103 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
104 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
105 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
106 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
107 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
108 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
109 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
110 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
111 { "DefaultPaperSize", &DefaultPaperSize
, CUPSD_VARTYPE_STRING
},
112 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
113 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
114 { "DirtyCleanInterval", &DirtyCleanInterval
, CUPSD_VARTYPE_INTEGER
},
115 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
116 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
117 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
118 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
119 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
120 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
121 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
122 { "HideImplicitMembers", &HideImplicitMembers
, CUPSD_VARTYPE_BOOLEAN
},
123 { "ImplicitClasses", &ImplicitClasses
, CUPSD_VARTYPE_BOOLEAN
},
124 { "ImplicitAnyClasses", &ImplicitAnyClasses
, CUPSD_VARTYPE_BOOLEAN
},
125 { "JobKillDelay", &JobKillDelay
, CUPSD_VARTYPE_INTEGER
},
126 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
127 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_INTEGER
},
128 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_INTEGER
},
129 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
131 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_INTEGER
},
132 #endif /* HAVE_LAUNCHD */
133 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
134 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
135 { "LogDebugHistory", &LogDebugHistory
, CUPSD_VARTYPE_INTEGER
},
136 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
137 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
138 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
139 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
140 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
141 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
142 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
143 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
144 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
145 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
146 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
147 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
148 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
149 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
150 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
151 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
152 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
153 { "MultipleOperationTimeout", &MultipleOperationTimeout
, CUPSD_VARTYPE_INTEGER
},
154 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
155 { "PageLogFormat", &PageLogFormat
, CUPSD_VARTYPE_STRING
},
156 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_BOOLEAN
},
157 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_BOOLEAN
},
158 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
159 { "PrintcapGUI", &PrintcapGUI
, CUPSD_VARTYPE_STRING
},
160 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_INTEGER
},
161 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
162 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
163 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
164 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_INTEGER
},
165 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
166 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
168 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
169 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
170 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
171 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
172 #endif /* HAVE_SSL */
173 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
174 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
175 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
176 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
177 #ifdef HAVE_AUTHORIZATION_H
178 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
179 #endif /* HAVE_AUTHORIZATION_H */
180 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
},
181 { "Timeout", &Timeout
, CUPSD_VARTYPE_INTEGER
},
182 { "UseNetworkDefault", &UseNetworkDefault
, CUPSD_VARTYPE_BOOLEAN
},
183 { "WebInterface", &WebInterface
, CUPSD_VARTYPE_BOOLEAN
}
185 #define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
188 static const unsigned ones
[4] =
190 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
192 static const unsigned zeros
[4] =
194 0x00000000, 0x00000000, 0x00000000, 0x00000000
202 static http_addrlist_t
*get_address(const char *value
, int defport
);
203 static int get_addr_and_mask(const char *value
, unsigned *ip
,
205 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
206 char *value
, int linenum
);
207 static int parse_fatal_errors(const char *s
);
208 static int parse_groups(const char *s
);
209 static int parse_protocols(const char *s
);
210 static int read_configuration(cups_file_t
*fp
);
211 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
212 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
213 static void set_policy_defaults(cupsd_policy_t
*pol
);
217 * 'cupsdAddAlias()' - Add a host alias.
221 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
222 const char *name
) /* I - Name to add */
224 cupsd_alias_t
*a
; /* New alias */
225 size_t namelen
; /* Length of name */
228 namelen
= strlen(name
);
230 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
233 a
->namelen
= namelen
;
234 strcpy(a
->name
, name
); /* OK since a->name is allocated */
236 cupsArrayAdd(aliases
, a
);
241 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
244 int /* O - 0 on success, -1 on error, 1 on warning */
245 cupsdCheckPermissions(
246 const char *filename
, /* I - File/directory name */
247 const char *suffix
, /* I - Additional file/directory name */
248 int mode
, /* I - Permissions */
249 int user
, /* I - Owner */
250 int group
, /* I - Group */
251 int is_dir
, /* I - 1 = directory, 0 = file */
252 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
254 int dir_created
= 0; /* Did we create a directory? */
255 char pathname
[1024]; /* File name with prefix */
256 struct stat fileinfo
; /* Stat buffer */
257 int is_symlink
; /* Is "filename" a symlink? */
261 * Prepend the given root to the filename before testing it...
266 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
271 * See if we can stat the file/directory...
274 if (lstat(filename
, &fileinfo
))
276 if (errno
== ENOENT
&& create_dir
)
279 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
282 if (mkdir(filename
, mode
))
285 cupsdLogMessage(CUPSD_LOG_ERROR
,
286 "Unable to create directory \"%s\" - %s", filename
,
289 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
296 fileinfo
.st_mode
= mode
| S_IFDIR
;
299 return (create_dir
? -1 : 1);
302 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
304 if (stat(filename
, &fileinfo
))
306 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
307 filename
, strerror(errno
));
313 * Make sure it's a regular file or a directory as needed...
316 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
318 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file.", filename
);
322 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
325 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory.", filename
);
327 syslog(LOG_ERR
, "\"%s\" is not a directory.", filename
);
333 * If the filename is a symlink, do not change permissions (STR #2937)...
340 * Fix owner, group, and mode as needed...
343 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
346 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
349 if (chown(filename
, user
, group
) && !getuid())
352 cupsdLogMessage(CUPSD_LOG_ERROR
,
353 "Unable to change ownership of \"%s\" - %s", filename
,
356 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
363 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
366 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
369 if (chmod(filename
, mode
))
372 cupsdLogMessage(CUPSD_LOG_ERROR
,
373 "Unable to change permissions of \"%s\" - %s", filename
,
376 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
384 * Everything is OK...
392 * 'cupsdFreeAliases()' - Free all of the alias entries.
396 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
398 cupsd_alias_t
*a
; /* Current alias */
401 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
403 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
406 cupsArrayDelete(aliases
);
411 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
414 int /* O - 1 on success, 0 otherwise */
415 cupsdReadConfiguration(void)
417 int i
; /* Looping var */
418 cups_file_t
*fp
; /* Configuration file */
419 int status
; /* Return status */
420 char temp
[1024], /* Temporary buffer */
421 mimedir
[1024], /* MIME directory */
422 *slash
; /* Directory separator */
423 cups_lang_t
*language
; /* Language */
424 struct passwd
*user
; /* Default user */
425 struct group
*group
; /* Default group */
426 char *old_serverroot
, /* Old ServerRoot */
427 *old_requestroot
; /* Old RequestRoot */
428 int old_remote_port
; /* Old RemotePort */
429 const char *tmpdir
; /* TMPDIR environment variable */
430 struct stat tmpinfo
; /* Temporary directory info */
431 cupsd_policy_t
*p
; /* Policy */
435 * Save the old root paths...
438 old_serverroot
= NULL
;
439 cupsdSetString(&old_serverroot
, ServerRoot
);
440 old_requestroot
= NULL
;
441 cupsdSetString(&old_requestroot
, RequestRoot
);
444 * Reset the server configuration data...
447 cupsdDeleteAllLocations();
466 for (i
= 0; i
< NumRelays
; i
++)
467 cupsArrayDelete(Relays
[i
].from
);
474 cupsdDeleteAllListeners();
476 old_remote_port
= RemotePort
;
483 cupsdFreeAliases(ServerAlias
);
486 cupsdClearString(&ServerName
);
487 cupsdClearString(&ServerAdmin
);
488 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
489 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
490 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
491 cupsdSetString(&DataDir
, CUPS_DATADIR
);
492 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
493 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
494 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
495 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
496 cupsdSetString(&PageLogFormat
,
497 "%p %u %j %T %P %C %{job-billing} "
498 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
499 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
500 cupsdSetString(&PrintcapGUI
, "/usr/bin/glpoptions");
501 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
502 cupsdSetString(&RemoteRoot
, "remroot");
503 cupsdSetString(&ServerHeader
, "CUPS/1.4");
504 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
506 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
507 PrintcapFormat
= PRINTCAP_SOLARIS
;
508 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
509 "/Library/Preferences/org.cups.printers.plist"))
510 PrintcapFormat
= PRINTCAP_PLIST
;
512 PrintcapFormat
= PRINTCAP_BSD
;
514 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
515 if ((slash
= strrchr(temp
, '/')) != NULL
)
518 cupsdSetString(&ServerRoot
, temp
);
520 cupsdClearString(&Classification
);
521 ClassifyOverride
= 0;
525 cupsdSetString(&ServerCertificate
, "/Library/Keychains/System.keychain");
527 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
528 cupsdSetString(&ServerKey
, "ssl/server.key");
529 # endif /* HAVE_CDSASSL */
530 #endif /* HAVE_SSL */
532 language
= cupsLangDefault();
534 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
535 cupsdSetString(&DefaultLanguage
, "en");
537 cupsdSetString(&DefaultLanguage
, language
->language
);
539 cupsdClearString(&DefaultPaperSize
);
541 cupsdSetString(&RIPCache
, "8m");
543 cupsdSetString(&TempDir
, NULL
);
546 * Find the default user...
549 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
554 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
555 * complement number...)
564 * Find the default group...
567 group
= getgrnam(CUPS_DEFAULT_GROUP
);
571 Group
= group
->gr_gid
;
575 * Fallback to group "nobody"...
578 group
= getgrnam("nobody");
582 Group
= group
->gr_gid
;
586 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
587 * complement number...)
598 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
599 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
600 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
601 DefaultAuthType
= CUPSD_AUTH_BASIC
;
603 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
604 SSLOptions
= CUPSD_SSL_NONE
;
605 #endif /* HAVE_SSL */
606 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
607 JobKillDelay
= DEFAULT_TIMEOUT
;
609 JobRetryInterval
= 300;
614 HostNameLookups
= FALSE
;
615 ImplicitClasses
= CUPS_DEFAULT_IMPLICIT_CLASSES
;
616 ImplicitAnyClasses
= FALSE
;
617 HideImplicitMembers
= TRUE
;
619 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
620 ListenBackLog
= SOMAXCONN
;
621 LogDebugHistory
= 200;
622 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
623 LogLevel
= CUPSD_LOG_WARN
;
624 LogTimeFormat
= CUPSD_TIME_STANDARD
;
626 MaxClientsPerHost
= 0;
627 MaxLogSize
= 1024 * 1024;
629 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
630 ReloadTimeout
= DEFAULT_KEEPALIVE
;
631 RootCertDuration
= 300;
632 Timeout
= DEFAULT_TIMEOUT
;
634 WebInterface
= CUPS_DEFAULT_WEBIF
;
636 BrowseInterval
= DEFAULT_INTERVAL
;
637 BrowsePort
= ippPort();
638 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
639 BrowseRemoteProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS
);
640 BrowseShortNames
= CUPS_DEFAULT_BROWSE_SHORT_NAMES
;
641 BrowseTimeout
= DEFAULT_TIMEOUT
;
643 Browsing
= CUPS_DEFAULT_BROWSING
;
644 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
646 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
647 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
649 cupsdClearString(&BrowseLocalOptions
);
650 cupsdClearString(&BrowseRemoteOptions
);
652 cupsdSetString(&ErrorPolicy
, "stop-printer");
655 cupsdClearString(&BrowseLDAPBindDN
);
656 cupsdClearString(&BrowseLDAPDN
);
657 cupsdClearString(&BrowseLDAPPassword
);
658 cupsdClearString(&BrowseLDAPServer
);
659 # ifdef HAVE_LDAP_SSL
660 cupsdClearString(&BrowseLDAPCACertFile
);
661 # endif /* HAVE_LDAP_SSL */
662 #endif /* HAVE_LDAP */
664 JobHistory
= DEFAULT_HISTORY
;
665 JobFiles
= DEFAULT_FILES
;
670 MaxJobsPerPrinter
= 0;
671 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
673 cupsdDeleteAllPolicies();
674 cupsdClearString(&DefaultPolicy
);
676 #ifdef HAVE_AUTHORIZATION_H
677 cupsdClearString(&SystemGroupAuthKey
);
678 #endif /* HAVE_AUTHORIZATION_H */
680 MaxSubscriptions
= 100;
681 MaxSubscriptionsPerJob
= 0;
682 MaxSubscriptionsPerPrinter
= 0;
683 MaxSubscriptionsPerUser
= 0;
684 DefaultLeaseDuration
= 86400;
685 MaxLeaseDuration
= 0;
688 LaunchdTimeout
= DEFAULT_TIMEOUT
+ 10;
689 #endif /* HAVE_LAUNCHD */
692 * Setup environment variables...
698 * Read the configuration file...
701 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
704 status
= read_configuration(fp
);
713 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
714 RemotePort
? "enabled" : "disabled");
717 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
720 * See if the ServerName is an IP address...
726 ServerAlias
= cupsArrayNew(NULL
, NULL
);
728 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
732 if (gethostname(temp
, sizeof(temp
)))
734 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
736 strlcpy(temp
, "localhost", sizeof(temp
));
739 cupsdSetString(&ServerName
, temp
);
742 ServerAlias
= cupsArrayNew(NULL
, NULL
);
744 cupsdAddAlias(ServerAlias
, temp
);
745 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
747 if (HostNameLookups
|| RemotePort
)
749 struct hostent
*host
; /* Host entry to get FQDN */
751 if ((host
= gethostbyname(temp
)) != NULL
)
753 if (strcasecmp(temp
, host
->h_name
))
755 cupsdSetString(&ServerName
, host
->h_name
);
756 cupsdAddAlias(ServerAlias
, host
->h_name
);
757 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
763 for (i
= 0; host
->h_aliases
[i
]; i
++)
764 if (strcasecmp(temp
, host
->h_aliases
[i
]))
766 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
767 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
775 * Make sure we have the base hostname added as an alias, too!
778 if ((slash
= strchr(temp
, '.')) != NULL
)
781 cupsdAddAlias(ServerAlias
, temp
);
782 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
786 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
788 ServerNameIsIP
= !*slash
;
791 * Make sure ServerAdmin is initialized...
795 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
798 * Use the default system group if none was supplied in cupsd.conf...
801 if (NumSystemGroups
== 0)
803 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
806 * Find the group associated with GID 0...
813 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
815 cupsdSetString(&SystemGroups
[0], "unknown");
817 SystemGroupIDs
[0] = 0;
823 * Get the access control list for browsing...
826 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
829 * Open the system log for cupsd if necessary...
833 if (!strcmp(AccessLog
, "syslog") ||
834 !strcmp(ErrorLog
, "syslog") ||
835 !strcmp(PageLog
, "syslog"))
836 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
837 #endif /* HAVE_VSYSLOG */
840 * Log the configuration file that was used...
843 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
847 * Validate the Group and SystemGroup settings - they cannot be the same,
848 * otherwise the CGI programs will be able to authenticate as root without
854 for (i
= 0; i
< NumSystemGroups
; i
++)
855 if (Group
== SystemGroupIDs
[i
])
858 if (i
< NumSystemGroups
)
861 * Log the error and reset the group to a safe value...
864 cupsdLogMessage(CUPSD_LOG_NOTICE
,
865 "Group and SystemGroup cannot use the same groups.");
866 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
868 group
= getgrnam("nobody");
872 Group
= group
->gr_gid
;
876 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
877 * complement number...)
886 * Check that we have at least one listen/port line; if not, report this
887 * as an error and exit!
890 if (cupsArrayCount(Listeners
) == 0)
896 cupsdLogMessage(CUPSD_LOG_EMERG
,
897 "No valid Listen or Port lines were found in the "
898 "configuration file.");
904 cupsdEndProcess(getpid(), 0);
908 * Set the default locale using the language and charset...
911 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
914 * Update all relative filenames to include the full path from ServerRoot...
917 if (DocumentRoot
[0] != '/')
918 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
920 if (RequestRoot
[0] != '/')
921 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
923 if (ServerBin
[0] != '/')
924 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
926 if (StateDir
[0] != '/')
927 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
929 if (CacheDir
[0] != '/')
930 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
933 if (ServerCertificate
[0] != '/')
934 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
936 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
937 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
939 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
942 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
943 if (ServerKey
[0] != '/')
944 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
946 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
947 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
948 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
950 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
951 #endif /* HAVE_SSL */
954 * Make sure that directories and config files are owned and
955 * writable by the user and group in the cupsd.conf file...
958 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
960 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
962 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
964 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
966 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
968 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
969 SystemGroupIDs
[0], 1, 1) < 0 ||
970 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
972 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
974 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
976 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
978 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
980 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
982 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
984 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
988 * Update TempDir to the default if it hasn't been set already...
993 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
996 * TMPDIR is defined, see if it is OK for us to use...
999 if (stat(tmpdir
, &tmpinfo
))
1000 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1001 tmpdir
, strerror(errno
));
1002 else if (!S_ISDIR(tmpinfo
.st_mode
))
1003 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1005 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1006 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1007 !(tmpinfo
.st_mode
& S_IWOTH
))
1008 cupsdLogMessage(CUPSD_LOG_ERROR
,
1009 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1011 cupsdSetString(&TempDir
, tmpdir
);
1016 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1018 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1023 * Make sure the temporary directory has the right permissions...
1026 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1030 * Update ownership and permissions if the CUPS temp directory
1031 * is under the spool directory or does not exist...
1034 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1035 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1040 * Update environment variables...
1046 * Update default paper size setting as needed...
1049 if (!DefaultPaperSize
)
1051 #ifdef HAVE_LIBPAPER
1052 char *paper_result
; /* Paper size name from libpaper */
1054 if ((paper_result
= systempapername()) != NULL
)
1055 cupsdSetString(&DefaultPaperSize
, paper_result
);
1057 #endif /* HAVE_LIBPAPER */
1058 if (!DefaultLanguage
||
1059 !strcasecmp(DefaultLanguage
, "C") ||
1060 !strcasecmp(DefaultLanguage
, "POSIX") ||
1061 !strcasecmp(DefaultLanguage
, "en") ||
1062 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1063 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1064 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1065 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1068 * These are the only locales that will default to "letter" size...
1071 cupsdSetString(&DefaultPaperSize
, "Letter");
1074 cupsdSetString(&DefaultPaperSize
, "A4");
1078 * Update classification setting as needed...
1081 if (Classification
&& !strcasecmp(Classification
, "none"))
1082 cupsdClearString(&Classification
);
1085 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1088 * Check the MaxClients setting, and then allocate memory for it...
1091 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1094 cupsdLogMessage(CUPSD_LOG_INFO
,
1095 "MaxClients limited to 1/3 (%d) of the file descriptor "
1097 MaxFDs
/ 3, MaxFDs
);
1099 MaxClients
= MaxFDs
/ 3;
1102 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1106 * Check the MaxActiveJobs setting; limit to 1/3 the available
1107 * file descriptors, since we need a pipe for each job...
1110 if (MaxActiveJobs
> (MaxFDs
/ 3))
1111 MaxActiveJobs
= MaxFDs
/ 3;
1114 * Update the MaxClientsPerHost value, as needed...
1117 if (MaxClientsPerHost
<= 0)
1118 MaxClientsPerHost
= MaxClients
;
1120 if (MaxClientsPerHost
> MaxClients
)
1121 MaxClientsPerHost
= MaxClients
;
1123 cupsdLogMessage(CUPSD_LOG_INFO
,
1124 "Allowing up to %d client connections per host.",
1128 * Make sure that BrowseTimeout is at least twice the interval...
1131 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1133 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d.",
1137 BrowseTimeout
= BrowseInterval
* 2;
1139 BrowseTimeout
= DEFAULT_TIMEOUT
;
1141 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d.",
1146 * Update the default policy, as needed...
1150 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1152 DefaultPolicyPtr
= NULL
;
1154 if (!DefaultPolicyPtr
)
1156 cupsd_location_t
*po
; /* New policy operation */
1160 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1163 cupsdSetString(&DefaultPolicy
, "default");
1165 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1166 cupsdLogMessage(CUPSD_LOG_INFO
,
1167 "Using policy \"default\" as the default.");
1170 cupsdLogMessage(CUPSD_LOG_INFO
,
1171 "Creating CUPS default administrative policy:");
1173 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1175 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1177 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1178 cupsdAddString(&(p
->job_access
), "@OWNER");
1179 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1181 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1182 cupsdAddString(&(p
->job_attrs
), "job-name");
1183 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1184 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1186 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1187 cupsdAddString(&(p
->sub_access
), "@OWNER");
1188 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1190 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1191 cupsdAddString(&(p
->job_attrs
), "notify-events");
1192 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1193 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1194 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1195 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1197 cupsdLogMessage(CUPSD_LOG_INFO
,
1198 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1199 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1201 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1202 po
->order_type
= CUPSD_AUTH_ALLOW
;
1204 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1205 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1206 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1208 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1210 cupsdLogMessage(CUPSD_LOG_INFO
,
1211 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1212 "Release-Job Restart-Job Purge-Jobs "
1213 "Set-Job-Attributes Create-Job-Subscription "
1214 "Renew-Subscription Cancel-Subscription "
1215 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1216 "Suspend-Current-Job Resume-Job "
1217 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1218 "CUPS-Authenticate-Job CUPS-Get-Document>");
1219 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1221 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1222 po
->order_type
= CUPSD_AUTH_ALLOW
;
1223 po
->level
= CUPSD_AUTH_USER
;
1225 cupsdAddName(po
, "@OWNER");
1226 cupsdAddName(po
, "@SYSTEM");
1227 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1229 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1230 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1231 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1232 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1233 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1234 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1235 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1236 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1237 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1238 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1239 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1240 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1241 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1242 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1243 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1244 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1245 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1246 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1247 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1248 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1250 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1252 cupsdLogMessage(CUPSD_LOG_INFO
,
1253 "<Limit Pause-Printer Resume-Printer "
1254 "Set-Printer-Attributes Enable-Printer "
1255 "Disable-Printer Pause-Printer-After-Current-Job "
1256 "Hold-New-Jobs Release-Held-New-Jobs "
1257 "Deactivate-Printer Activate-Printer Restart-Printer "
1258 "Shutdown-Printer Startup-Printer Promote-Job "
1259 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1260 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1261 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1262 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1263 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1265 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1266 po
->order_type
= CUPSD_AUTH_ALLOW
;
1267 po
->type
= CUPSD_AUTH_DEFAULT
;
1268 po
->level
= CUPSD_AUTH_USER
;
1270 cupsdAddName(po
, "@SYSTEM");
1271 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1273 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1274 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1275 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1276 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1277 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1278 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1279 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1280 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1281 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1282 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1283 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1284 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1285 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1286 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1287 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1288 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1289 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1290 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1291 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1292 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1293 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1294 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1296 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1298 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1299 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1301 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1302 po
->order_type
= CUPSD_AUTH_ALLOW
;
1304 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1305 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1309 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1310 cupsArrayCount(Policies
));
1311 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1313 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1314 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1315 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1318 * If we are doing a full reload or the server root has changed, flush
1319 * the jobs, printers, etc. and start from scratch...
1322 if (NeedReload
== RELOAD_ALL
||
1323 old_remote_port
!= RemotePort
||
1324 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1325 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1327 mime_type_t
*type
; /* Current type */
1328 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1329 /* MIME type name */
1332 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1335 * Free all memory...
1338 cupsdDeleteAllSubscriptions();
1340 cupsdDeleteAllPrinters();
1342 DefaultPrinter
= NULL
;
1344 if (MimeDatabase
!= NULL
)
1345 mimeDelete(MimeDatabase
);
1349 for (i
= 0; i
< NumMimeTypes
; i
++)
1350 _cupsStrFree(MimeTypes
[i
]);
1356 * Read the MIME type and conversion database...
1359 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1360 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1362 MimeDatabase
= mimeLoadTypes(NULL
, mimedir
);
1363 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1364 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1365 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1369 cupsdLogMessage(CUPSD_LOG_EMERG
,
1370 "Unable to load MIME database from \"%s\" or \"%s\".",
1371 mimedir
, ServerRoot
);
1372 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1376 cupsdLogMessage(CUPSD_LOG_INFO
,
1377 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1378 "%d filters...", mimedir
, ServerRoot
,
1379 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1382 * Create a list of MIME types for the document-format-supported
1386 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1387 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1390 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1392 cupsdLogMessage(CUPSD_LOG_ERROR
,
1393 "Unable to allocate memory for %d MIME types.",
1399 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1401 i
++, type
= mimeNextType(MimeDatabase
))
1403 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1405 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1408 if (i
< NumMimeTypes
)
1409 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1412 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1414 mime_filter_t
*filter
; /* Current filter */
1417 for (type
= mimeFirstType(MimeDatabase
);
1419 type
= mimeNextType(MimeDatabase
))
1420 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1421 type
->super
, type
->type
);
1423 for (filter
= mimeFirstFilter(MimeDatabase
);
1425 filter
= mimeNextFilter(MimeDatabase
))
1426 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1427 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1428 filter
->src
->super
, filter
->src
->type
,
1429 filter
->dst
->super
, filter
->dst
->type
,
1430 filter
->cost
, filter
->filter
);
1437 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1438 cupsdLoadBanners(temp
);
1441 * Load printers and classes...
1444 cupsdLoadAllPrinters();
1445 cupsdLoadAllClasses();
1446 cupsdLoadRemoteCache();
1448 cupsdCreateCommonData();
1451 * Update the printcap file as needed...
1454 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1455 cupsdWritePrintcap();
1458 * Load queued jobs...
1464 * Load subscriptions...
1467 cupsdLoadAllSubscriptions();
1469 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1474 * Not a full reload, so recreate the common printer attributes...
1477 cupsdCreateCommonData();
1480 * Update all printers as needed...
1483 cupsdUpdatePrinters();
1484 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1486 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1490 * Reset the reload state...
1493 NeedReload
= RELOAD_NONE
;
1495 cupsdClearString(&old_serverroot
);
1496 cupsdClearString(&old_requestroot
);
1503 * 'get_address()' - Get an address + port number from a line.
1506 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1507 get_address(const char *value
, /* I - Value string */
1508 int defport
) /* I - Default port */
1510 char buffer
[1024], /* Hostname + port number buffer */
1511 defpname
[255], /* Default port name */
1512 *hostname
, /* Hostname or IP */
1513 *portname
; /* Port number or name */
1514 http_addrlist_t
*addrlist
; /* Address list */
1518 * Check for an empty value...
1523 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1528 * Grab a hostname and port number; if there is no colon and the port name
1529 * is only digits, then we have a port number by itself...
1532 strlcpy(buffer
, value
, sizeof(buffer
));
1534 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1541 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1546 * Use the default port...
1549 sprintf(defpname
, "%d", defport
);
1550 portname
= defpname
;
1556 * The buffer contains just a port number...
1564 if (hostname
&& !strcmp(hostname
, "*"))
1568 * Now lookup the address using httpAddrGetList()...
1571 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1572 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1573 hostname
? hostname
: "(nil)");
1580 * 'get_addr_and_mask()' - Get an IP address and netmask.
1583 static int /* O - 1 on success, 0 on failure */
1584 get_addr_and_mask(const char *value
, /* I - String from config file */
1585 unsigned *ip
, /* O - Address value */
1586 unsigned *mask
) /* O - Mask value */
1588 int i
, j
, /* Looping vars */
1589 family
, /* Address family */
1590 ipcount
; /* Count of fields in address */
1591 unsigned ipval
; /* Value */
1592 const char *maskval
, /* Pointer to start of mask value */
1593 *ptr
, /* Pointer into value */
1598 * Get the address...
1601 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1602 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1604 if ((maskval
= strchr(value
, '/')) != NULL
)
1607 maskval
= value
+ strlen(value
);
1611 * Check for an IPv6 address...
1617 * Parse hexadecimal IPv6 address...
1622 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1626 else if (!strncmp(ptr
, "::", 2))
1628 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1630 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1635 else if (isxdigit(*ptr
& 255))
1637 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1645 ip
[i
/ 2] |= ipval
<< 16;
1659 if (*ptr
&& *ptr
!= '/')
1663 #endif /* AF_INET6 */
1666 * Parse dotted-decimal IPv4 address...
1669 unsigned val
[4]; /* IPv4 address values */
1673 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1676 * Range check the IP numbers...
1679 for (i
= 0; i
< ipcount
; i
++)
1684 * Make sure the trailing values are zeroed, as some C libraries like
1685 * glibc apparently like to fill the unused arguments with garbage...
1688 for (i
= ipcount
; i
< 4; i
++)
1692 * Merge everything into a 32-bit IPv4 address in ip[3]...
1695 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1698 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1704 * Get the netmask value(s)...
1707 memset(mask
, 0, sizeof(unsigned) * 4);
1709 if (strchr(maskval
, '.'))
1712 * Get dotted-decimal mask...
1715 if (family
!= AF_INET
)
1718 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1721 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1722 mask
[0] = mask
[1] = mask
[2] = 0;
1727 * Get address/bits format...
1733 if (family
== AF_INET6
)
1741 mask
[0] = 0xffffffff;
1743 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1746 mask
[1] = 0xffffffff;
1750 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1753 mask
[2] = 0xffffffff;
1757 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1760 mask
[3] = 0xffffffff;
1764 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1767 #endif /* AF_INET6 */
1772 mask
[0] = 0xffffffff;
1773 mask
[1] = 0xffffffff;
1774 mask
[2] = 0xffffffff;
1777 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1779 mask
[3] = 0xffffffff;
1784 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1785 "get_addr_and_mask(value=\"%s\", "
1786 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1787 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1791 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1794 if ((ip
[0] & ~mask
[0]) != 0 ||
1795 (ip
[1] & ~mask
[1]) != 0 ||
1796 (ip
[2] & ~mask
[2]) != 0 ||
1797 (ip
[3] & ~mask
[3]) != 0)
1805 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1808 static int /* O - 1 on success, 0 on failure */
1809 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1810 char *line
, /* I - Line from file */
1811 char *value
, /* I - Start of value data */
1812 int linenum
) /* I - Current line number */
1814 char *valptr
; /* Pointer into value */
1815 unsigned ip
[4], /* IP address components */
1816 mask
[4]; /* IP netmask components */
1819 if (!strcasecmp(line
, "Encryption"))
1822 * "Encryption xxx" - set required encryption level...
1825 if (!strcasecmp(value
, "never"))
1826 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1827 else if (!strcasecmp(value
, "always"))
1829 cupsdLogMessage(CUPSD_LOG_ERROR
,
1830 "Encryption value \"%s\" on line %d is invalid in this "
1831 "context. Using \"required\" instead.", value
, linenum
);
1833 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1835 else if (!strcasecmp(value
, "required"))
1836 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1837 else if (!strcasecmp(value
, "ifrequested"))
1838 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1841 cupsdLogMessage(CUPSD_LOG_ERROR
,
1842 "Unknown Encryption value %s on line %d.", value
, linenum
);
1846 else if (!strcasecmp(line
, "Order"))
1849 * "Order Deny,Allow" or "Order Allow,Deny"...
1852 if (!strncasecmp(value
, "deny", 4))
1853 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1854 else if (!strncasecmp(value
, "allow", 5))
1855 loc
->order_type
= CUPSD_AUTH_DENY
;
1858 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1863 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1866 * Allow [From] host/ip...
1867 * Deny [From] host/ip...
1872 if (!strncasecmp(value
, "from", 4))
1875 * Strip leading "from"...
1880 while (isspace(*value
& 255))
1888 * Find the end of the value...
1891 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1893 while (isspace(*valptr
& 255))
1897 * Figure out what form the allow/deny address takes:
1908 * nnn.nnn.nnn.nnn/mm
1909 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1912 if (!strcasecmp(value
, "all"))
1918 if (!strcasecmp(line
, "Allow"))
1919 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1921 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1923 else if (!strcasecmp(value
, "none"))
1929 if (!strcasecmp(line
, "Allow"))
1930 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1932 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1935 else if (value
[0] == '*' || value
[0] == '.' ||
1936 (!isdigit(value
[0] & 255) && value
[0] != '['))
1938 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1939 #endif /* AF_INET6 */
1942 * Host or domain name...
1945 if (value
[0] == '*')
1948 if (!strcasecmp(line
, "Allow"))
1949 cupsdAddNameMask(&(loc
->allow
), value
);
1951 cupsdAddNameMask(&(loc
->deny
), value
);
1956 * One of many IP address forms...
1959 if (!get_addr_and_mask(value
, ip
, mask
))
1961 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1966 if (!strcasecmp(line
, "Allow"))
1967 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
1969 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
1973 * Advance to next value...
1979 else if (!strcasecmp(line
, "AuthType"))
1982 * AuthType {none,basic,digest,basicdigest,negotiate,default}
1985 if (!strcasecmp(value
, "none"))
1987 loc
->type
= CUPSD_AUTH_NONE
;
1988 loc
->level
= CUPSD_AUTH_ANON
;
1990 else if (!strcasecmp(value
, "basic"))
1992 loc
->type
= CUPSD_AUTH_BASIC
;
1994 if (loc
->level
== CUPSD_AUTH_ANON
)
1995 loc
->level
= CUPSD_AUTH_USER
;
1997 else if (!strcasecmp(value
, "digest"))
1999 loc
->type
= CUPSD_AUTH_DIGEST
;
2001 if (loc
->level
== CUPSD_AUTH_ANON
)
2002 loc
->level
= CUPSD_AUTH_USER
;
2004 else if (!strcasecmp(value
, "basicdigest"))
2006 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2008 if (loc
->level
== CUPSD_AUTH_ANON
)
2009 loc
->level
= CUPSD_AUTH_USER
;
2011 else if (!strcasecmp(value
, "default"))
2013 loc
->type
= CUPSD_AUTH_DEFAULT
;
2015 if (loc
->level
== CUPSD_AUTH_ANON
)
2016 loc
->level
= CUPSD_AUTH_USER
;
2019 else if (!strcasecmp(value
, "negotiate"))
2021 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2023 if (loc
->level
== CUPSD_AUTH_ANON
)
2024 loc
->level
= CUPSD_AUTH_USER
;
2026 #endif /* HAVE_GSSAPI */
2029 cupsdLogMessage(CUPSD_LOG_WARN
,
2030 "Unknown authorization type %s on line %d.",
2035 else if (!strcasecmp(line
, "AuthClass"))
2038 * AuthClass anonymous, user, system, group
2041 if (!strcasecmp(value
, "anonymous"))
2043 loc
->type
= CUPSD_AUTH_NONE
;
2044 loc
->level
= CUPSD_AUTH_ANON
;
2046 cupsdLogMessage(CUPSD_LOG_WARN
,
2047 "\"AuthClass %s\" is deprecated; consider removing "
2051 else if (!strcasecmp(value
, "user"))
2053 loc
->level
= CUPSD_AUTH_USER
;
2055 cupsdLogMessage(CUPSD_LOG_WARN
,
2056 "\"AuthClass %s\" is deprecated; consider using "
2057 "\"Require valid-user\" on line %d.",
2060 else if (!strcasecmp(value
, "group"))
2062 loc
->level
= CUPSD_AUTH_GROUP
;
2064 cupsdLogMessage(CUPSD_LOG_WARN
,
2065 "\"AuthClass %s\" is deprecated; consider using "
2066 "\"Require user @groupname\" on line %d.",
2069 else if (!strcasecmp(value
, "system"))
2071 loc
->level
= CUPSD_AUTH_GROUP
;
2073 cupsdAddName(loc
, "@SYSTEM");
2075 cupsdLogMessage(CUPSD_LOG_WARN
,
2076 "\"AuthClass %s\" is deprecated; consider using "
2077 "\"Require user @SYSTEM\" on line %d.",
2082 cupsdLogMessage(CUPSD_LOG_WARN
,
2083 "Unknown authorization class %s on line %d.",
2088 else if (!strcasecmp(line
, "AuthGroupName"))
2090 cupsdAddName(loc
, value
);
2092 cupsdLogMessage(CUPSD_LOG_WARN
,
2093 "\"AuthGroupName %s\" directive is deprecated; consider "
2094 "using \"Require user @%s\" on line %d.",
2095 value
, value
, linenum
);
2097 else if (!strcasecmp(line
, "Require"))
2100 * Apache synonym for AuthClass and AuthGroupName...
2104 * Require valid-user
2105 * Require group names
2106 * Require user names
2109 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2114 if (!strcasecmp(value
, "valid-user") ||
2115 !strcasecmp(value
, "user"))
2116 loc
->level
= CUPSD_AUTH_USER
;
2117 else if (!strcasecmp(value
, "group"))
2118 loc
->level
= CUPSD_AUTH_GROUP
;
2121 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2127 * Get the list of names from the line...
2130 for (value
= valptr
; *value
;)
2132 while (isspace(*value
& 255))
2135 #ifdef HAVE_AUTHORIZATION_H
2136 if (!strncmp(value
, "@AUTHKEY(", 9))
2139 * Grab "@AUTHKEY(name)" value...
2142 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2148 #endif /* HAVE_AUTHORIZATION_H */
2149 if (*value
== '\"' || *value
== '\'')
2152 * Grab quoted name...
2155 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2162 * Grab literal name.
2165 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2171 cupsdAddName(loc
, value
);
2173 for (value
= valptr
; isspace(*value
& 255); value
++);
2176 else if (!strcasecmp(line
, "Satisfy"))
2178 if (!strcasecmp(value
, "all"))
2179 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2180 else if (!strcasecmp(value
, "any"))
2181 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2184 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2197 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2200 static int /* O - FatalErrors bits */
2201 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2203 int fatal
; /* FatalErrors bits */
2204 char value
[1024], /* Value string */
2205 *valstart
, /* Pointer into value */
2206 *valend
; /* End of value */
2210 * Empty FatalErrors line yields NULL pointer...
2214 return (CUPSD_FATAL_NONE
);
2217 * Loop through the value string,...
2220 strlcpy(value
, s
, sizeof(value
));
2222 fatal
= CUPSD_FATAL_NONE
;
2224 for (valstart
= value
; *valstart
;)
2227 * Get the current space/comma-delimited kind name...
2230 for (valend
= valstart
; *valend
; valend
++)
2231 if (isspace(*valend
& 255) || *valend
== ',')
2238 * Add the error to the bitmask...
2241 if (!strcasecmp(valstart
, "all"))
2242 fatal
= CUPSD_FATAL_ALL
;
2243 else if (!strcasecmp(valstart
, "browse"))
2244 fatal
|= CUPSD_FATAL_BROWSE
;
2245 else if (!strcasecmp(valstart
, "-browse"))
2246 fatal
&= ~CUPSD_FATAL_BROWSE
;
2247 else if (!strcasecmp(valstart
, "config"))
2248 fatal
|= CUPSD_FATAL_CONFIG
;
2249 else if (!strcasecmp(valstart
, "-config"))
2250 fatal
&= ~CUPSD_FATAL_CONFIG
;
2251 else if (!strcasecmp(valstart
, "listen"))
2252 fatal
|= CUPSD_FATAL_LISTEN
;
2253 else if (!strcasecmp(valstart
, "-listen"))
2254 fatal
&= ~CUPSD_FATAL_LISTEN
;
2255 else if (!strcasecmp(valstart
, "log"))
2256 fatal
|= CUPSD_FATAL_LOG
;
2257 else if (!strcasecmp(valstart
, "-log"))
2258 fatal
&= ~CUPSD_FATAL_LOG
;
2259 else if (!strcasecmp(valstart
, "permissions"))
2260 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2261 else if (!strcasecmp(valstart
, "-permissions"))
2262 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2263 else if (strcasecmp(valstart
, "none"))
2264 cupsdLogMessage(CUPSD_LOG_ERROR
,
2265 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2267 for (valstart
= valend
; *valstart
; valstart
++)
2268 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2277 * 'parse_groups()' - Parse system group names in a string.
2280 static int /* O - 1 on success, 0 on failure */
2281 parse_groups(const char *s
) /* I - Space-delimited groups */
2283 int status
; /* Return status */
2284 char value
[1024], /* Value string */
2285 *valstart
, /* Pointer into value */
2286 *valend
, /* End of value */
2287 quote
; /* Quote character */
2288 struct group
*group
; /* Group */
2292 * Make a copy of the string and parse out the groups...
2295 strlcpy(value
, s
, sizeof(value
));
2300 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2302 if (*valstart
== '\'' || *valstart
== '\"')
2305 * Scan quoted name...
2308 quote
= *valstart
++;
2310 for (valend
= valstart
; *valend
; valend
++)
2311 if (*valend
== quote
)
2317 * Scan space or comma-delimited name...
2320 for (valend
= valstart
; *valend
; valend
++)
2321 if (isspace(*valend
) || *valend
== ',')
2328 group
= getgrnam(valstart
);
2331 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2332 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2343 while (*valstart
== ',' || isspace(*valstart
))
2352 * 'parse_protocols()' - Parse browse protocols in a string.
2355 static int /* O - Browse protocol bits */
2356 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2358 int protocols
; /* Browse protocol bits */
2359 char value
[1024], /* Value string */
2360 *valstart
, /* Pointer into value */
2361 *valend
; /* End of value */
2365 * Empty protocol line yields NULL pointer...
2372 * Loop through the value string,...
2375 strlcpy(value
, s
, sizeof(value
));
2379 for (valstart
= value
; *valstart
;)
2382 * Get the current space/comma-delimited protocol name...
2385 for (valend
= valstart
; *valend
; valend
++)
2386 if (isspace(*valend
& 255) || *valend
== ',')
2393 * Add the protocol to the bitmask...
2396 if (!strcasecmp(valstart
, "cups"))
2397 protocols
|= BROWSE_CUPS
;
2398 else if (!strcasecmp(valstart
, "slp"))
2399 protocols
|= BROWSE_SLP
;
2400 else if (!strcasecmp(valstart
, "ldap"))
2401 protocols
|= BROWSE_LDAP
;
2402 else if (!strcasecmp(valstart
, "dnssd") ||
2403 !strcasecmp(valstart
, "dns-sd") ||
2404 !strcasecmp(valstart
, "bonjour"))
2405 protocols
|= BROWSE_DNSSD
;
2406 else if (!strcasecmp(valstart
, "lpd"))
2407 protocols
|= BROWSE_LPD
;
2408 else if (!strcasecmp(valstart
, "smb"))
2409 protocols
|= BROWSE_SMB
;
2410 else if (!strcasecmp(valstart
, "all"))
2411 protocols
|= BROWSE_ALL
;
2412 else if (strcasecmp(valstart
, "none"))
2413 cupsdLogMessage(CUPSD_LOG_ERROR
,
2414 "Unknown browse protocol \"%s\" ignored.", valstart
);
2416 for (valstart
= valend
; *valstart
; valstart
++)
2417 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2426 * 'read_configuration()' - Read a configuration file.
2429 static int /* O - 1 on success, 0 on failure */
2430 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2432 int i
; /* Looping var */
2433 int linenum
; /* Current line number */
2434 char line
[HTTP_MAX_BUFFER
],
2435 /* Line from file */
2436 temp
[HTTP_MAX_BUFFER
],
2437 /* Temporary buffer for value */
2438 *ptr
, /* Pointer into line/temp */
2439 *value
, /* Pointer to value */
2440 *valueptr
; /* Pointer into value */
2441 int valuelen
; /* Length of value */
2442 cupsd_var_t
const *var
; /* Current variable */
2443 http_addrlist_t
*addrlist
, /* Address list */
2444 *addr
; /* Current address */
2445 unsigned ip
[4], /* Address value */
2446 mask
[4]; /* Netmask value */
2447 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2448 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2449 cupsd_location_t
*location
; /* Browse location */
2450 cups_file_t
*incfile
; /* Include file */
2451 char incname
[1024]; /* Include filename */
2452 struct group
*group
; /* Group */
2456 * Loop through each line in the file...
2461 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2464 * Decode the directive...
2467 if (!strcasecmp(line
, "Include") && value
)
2473 if (value
[0] == '/')
2474 strlcpy(incname
, value
, sizeof(incname
));
2476 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2478 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2479 cupsdLogMessage(CUPSD_LOG_ERROR
,
2480 "Unable to include config file \"%s\" - %s",
2481 incname
, strerror(errno
));
2484 read_configuration(incfile
);
2485 cupsFileClose(incfile
);
2488 else if (!strcasecmp(line
, "<Location") && value
)
2494 linenum
= read_location(fp
, value
, linenum
);
2498 else if (!strcasecmp(line
, "<Policy") && value
)
2504 linenum
= read_policy(fp
, value
, linenum
);
2508 else if (!strcasecmp(line
, "FatalErrors"))
2509 FatalErrors
= parse_fatal_errors(value
);
2510 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2512 JobRetryInterval
= atoi(value
);
2513 cupsdLogMessage(CUPSD_LOG_WARN
,
2514 "FaxRetryInterval is deprecated; use "
2515 "JobRetryInterval on line %d.", linenum
);
2517 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2519 JobRetryLimit
= atoi(value
);
2520 cupsdLogMessage(CUPSD_LOG_WARN
,
2521 "FaxRetryLimit is deprecated; use "
2522 "JobRetryLimit on line %d.", linenum
);
2524 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2526 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2527 #endif /* HAVE_SSL */
2531 * Add listening address(es) to the list...
2534 cupsd_listener_t
*lis
; /* New listeners array */
2538 * Get the address list...
2541 addrlist
= get_address(value
, IPP_PORT
);
2545 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2551 * Add each address...
2554 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2557 * See if this address is already present...
2560 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2562 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2563 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2564 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2569 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2570 cupsdLogMessage(CUPSD_LOG_WARN
,
2571 "Duplicate listen address \"%s\" ignored.", temp
);
2576 * Allocate another listener...
2580 Listeners
= cupsArrayNew(NULL
, NULL
);
2584 cupsdLogMessage(CUPSD_LOG_ERROR
,
2585 "Unable to allocate %s at line %d - %s.",
2586 line
, linenum
, strerror(errno
));
2590 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2592 cupsdLogMessage(CUPSD_LOG_ERROR
,
2593 "Unable to allocate %s at line %d - %s.",
2594 line
, linenum
, strerror(errno
));
2598 cupsArrayAdd(Listeners
, lis
);
2601 * Copy the current address and log it...
2604 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2608 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2609 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2610 #endif /* HAVE_SSL */
2612 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2615 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2616 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv6)", temp
,
2617 ntohs(lis
->address
.ipv6
.sin6_port
));
2619 #endif /* AF_INET6 */
2621 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2622 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2624 #endif /* AF_LOCAL */
2625 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv4)", temp
,
2626 ntohs(lis
->address
.ipv4
.sin_port
));
2628 if (!httpAddrLocalhost(&(lis
->address
)))
2631 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2632 RemotePort
= ntohs(lis
->address
.ipv6
.sin6_port
);
2634 #endif /* AF_INET6 */
2635 RemotePort
= ntohs(lis
->address
.ipv4
.sin_port
);
2643 httpAddrFreeList(addrlist
);
2645 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2648 * Add a browse address to the list...
2651 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2654 if (NumBrowsers
== 0)
2655 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2657 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2661 cupsdLogMessage(CUPSD_LOG_ERROR
,
2662 "Unable to allocate BrowseAddress at line %d - %s.",
2663 linenum
, strerror(errno
));
2668 dira
+= NumBrowsers
;
2670 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2672 if (!strcasecmp(value
, "@LOCAL"))
2675 * Send browse data to all local interfaces...
2678 strcpy(dira
->iface
, "*");
2681 else if (!strncasecmp(value
, "@IF(", 4))
2684 * Send browse data to the named interface...
2687 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2689 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2695 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2698 * Only IPv4 addresses are supported...
2701 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2702 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2707 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2708 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2710 cupsdLogMessage(CUPSD_LOG_INFO
,
2711 "Sending browsing info to %s:%d (IPv4)",
2712 temp
, ntohs(dira
->to
.ipv4
.sin_port
));
2717 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2720 httpAddrFreeList(addrlist
);
2723 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2726 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2729 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2732 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2733 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2734 cupsdAddLocation(location
);
2736 if (location
== NULL
)
2737 cupsdLogMessage(CUPSD_LOG_ERROR
,
2738 "Unable to initialize browse access control list.");
2739 else if (!strncasecmp(value
, "deny", 4))
2740 location
->order_type
= CUPSD_AUTH_ALLOW
;
2741 else if (!strncasecmp(value
, "allow", 5))
2742 location
->order_type
= CUPSD_AUTH_DENY
;
2744 cupsdLogMessage(CUPSD_LOG_ERROR
,
2745 "Unknown BrowseOrder value %s on line %d.",
2748 else if (!strcasecmp(line
, "BrowseProtocols") ||
2749 !strcasecmp(line
, "BrowseLocalProtocols") ||
2750 !strcasecmp(line
, "BrowseRemoteProtocols"))
2753 * "BrowseProtocols name [... name]"
2754 * "BrowseLocalProtocols name [... name]"
2755 * "BrowseRemoteProtocols name [... name]"
2758 int protocols
= parse_protocols(value
);
2762 cupsdLogMessage(CUPSD_LOG_ERROR
,
2763 "Unknown browse protocol \"%s\" on line %d.",
2768 if (strcasecmp(line
, "BrowseLocalProtocols"))
2769 BrowseRemoteProtocols
= protocols
;
2770 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2771 BrowseLocalProtocols
= protocols
;
2773 else if ((!strcasecmp(line
, "BrowseAllow") ||
2774 !strcasecmp(line
, "BrowseDeny")) && value
)
2777 * BrowseAllow [From] host/ip...
2778 * BrowseDeny [From] host/ip...
2781 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2782 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2783 cupsdAddLocation(location
);
2786 if (location
== NULL
)
2787 cupsdLogMessage(CUPSD_LOG_ERROR
,
2788 "Unable to initialize browse access control list.");
2791 if (!strncasecmp(value
, "from", 4))
2794 * Skip leading "from"...
2803 * Skip leading whitespace...
2806 while (isspace(*value
& 255))
2813 * Find the end of the value...
2816 for (valueptr
= value
;
2817 *valueptr
&& !isspace(*valueptr
& 255);
2820 while (isspace(*valueptr
& 255))
2824 * Figure out what form the allow/deny address takes:
2835 * nnn.nnn.nnn.nnn/mm
2836 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2839 if (!strcasecmp(value
, "all"))
2845 if (!strcasecmp(line
, "BrowseAllow"))
2846 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2848 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2850 else if (!strcasecmp(value
, "none"))
2856 if (!strcasecmp(line
, "BrowseAllow"))
2857 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2859 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2862 else if (value
[0] == '*' || value
[0] == '.' ||
2863 (!isdigit(value
[0] & 255) && value
[0] != '['))
2865 else if (value
[0] == '*' || value
[0] == '.' ||
2866 !isdigit(value
[0] & 255))
2867 #endif /* AF_INET6 */
2870 * Host or domain name...
2873 if (!strcasecmp(line
, "BrowseAllow"))
2874 cupsdAddNameMask(&(location
->allow
), value
);
2876 cupsdAddNameMask(&(location
->deny
), value
);
2881 * One of many IP address forms...
2884 if (!get_addr_and_mask(value
, ip
, mask
))
2886 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2891 if (!strcasecmp(line
, "BrowseAllow"))
2892 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2894 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2898 * Advance to next value...
2905 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2908 * BrowseRelay [from] source [to] destination
2912 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2914 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2918 cupsdLogMessage(CUPSD_LOG_ERROR
,
2919 "Unable to allocate BrowseRelay at line %d - %s.",
2920 linenum
, strerror(errno
));
2927 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2929 if (!strncasecmp(value
, "from ", 5))
2932 * Skip leading "from"...
2938 * Skip leading whitespace...
2941 while (isspace(*value
))
2946 * Find the end of the from value...
2949 for (valueptr
= value
;
2950 *valueptr
&& !isspace(*valueptr
& 255);
2953 while (isspace(*valueptr
& 255))
2957 * Figure out what form the from address takes:
2966 * nnn.nnn.nnn.nnn/mm
2967 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2971 if (value
[0] == '*' || value
[0] == '.' ||
2972 (!isdigit(value
[0] & 255) && value
[0] != '['))
2974 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2975 #endif /* AF_INET6 */
2978 * Host or domain name...
2981 if (!cupsdAddNameMask(&(relay
->from
), value
))
2983 cupsdLogMessage(CUPSD_LOG_ERROR
,
2984 "Unable to allocate BrowseRelay name at line %d - %s.",
2985 linenum
, strerror(errno
));
2992 * One of many IP address forms...
2995 if (!get_addr_and_mask(value
, ip
, mask
))
2997 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
3002 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
3004 cupsdLogMessage(CUPSD_LOG_ERROR
,
3005 "Unable to allocate BrowseRelay IP at line %d - %s.",
3006 linenum
, strerror(errno
));
3012 * Get "to" address and port...
3015 if (!strncasecmp(valueptr
, "to ", 3))
3018 * Strip leading "to"...
3023 while (isspace(*valueptr
))
3027 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3030 * Only IPv4 addresses are supported...
3033 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3034 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3039 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3041 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3043 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3044 value
, temp
, ntohs(relay
->to
.ipv4
.sin_port
));
3050 cupsArrayDelete(relay
->from
);
3053 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3057 httpAddrFreeList(addrlist
);
3061 cupsArrayDelete(relay
->from
);
3064 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3068 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3071 * BrowsePoll address[:port]
3074 char *portname
; /* Port name */
3075 int portnum
; /* Port number */
3076 struct servent
*service
; /* Service */
3080 * Extract the port name from the address...
3083 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3087 if (isdigit(*portname
& 255))
3088 portnum
= atoi(portname
);
3089 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3090 portnum
= ntohs(service
->s_port
);
3093 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed.",
3099 portnum
= ippPort();
3102 * Add the poll entry...
3106 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3108 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3112 cupsdLogMessage(CUPSD_LOG_ERROR
,
3113 "Unable to allocate BrowsePoll at line %d - %s.",
3114 linenum
, strerror(errno
));
3122 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3124 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3125 pollp
->port
= portnum
;
3127 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3130 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3133 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3136 if (!strcasecmp(value
, "none"))
3137 DefaultAuthType
= CUPSD_AUTH_NONE
;
3138 else if (!strcasecmp(value
, "basic"))
3139 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3140 else if (!strcasecmp(value
, "digest"))
3141 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3142 else if (!strcasecmp(value
, "basicdigest"))
3143 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3145 else if (!strcasecmp(value
, "negotiate"))
3146 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3147 #endif /* HAVE_GSSAPI */
3150 cupsdLogMessage(CUPSD_LOG_WARN
,
3151 "Unknown default authorization type %s on line %d.",
3153 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3158 else if (!strcasecmp(line
, "DefaultEncryption"))
3161 * DefaultEncryption {Never,IfRequested,Required}
3164 if (!value
|| !strcasecmp(value
, "never"))
3165 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3166 else if (!strcasecmp(value
, "required"))
3167 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3168 else if (!strcasecmp(value
, "ifrequested"))
3169 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3172 cupsdLogMessage(CUPSD_LOG_WARN
,
3173 "Unknown default encryption %s on line %d.",
3175 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3179 #endif /* HAVE_SSL */
3180 else if (!strcasecmp(line
, "User") && value
)
3183 * User ID to run as...
3186 if (isdigit(value
[0] & 255))
3188 int uid
= atoi(value
);
3191 cupsdLogMessage(CUPSD_LOG_ERROR
,
3192 "Will not use User 0 as specified on line %d "
3193 "for security reasons. You must use a non-"
3194 "privileged account instead.",
3201 struct passwd
*p
; /* Password information */
3204 p
= getpwnam(value
);
3209 cupsdLogMessage(CUPSD_LOG_ERROR
,
3210 "Will not use User %s (UID=0) as specified on line "
3211 "%d for security reasons. You must use a non-"
3212 "privileged account instead.",
3218 cupsdLogMessage(CUPSD_LOG_ERROR
,
3219 "Unknown User \"%s\" on line %d, ignoring.",
3223 else if (!strcasecmp(line
, "Group") && value
)
3226 * Group ID to run as...
3229 if (isdigit(value
[0]))
3230 Group
= atoi(value
);
3234 group
= getgrnam(value
);
3237 Group
= group
->gr_gid
;
3239 cupsdLogMessage(CUPSD_LOG_ERROR
,
3240 "Unknown Group \"%s\" on line %d, ignoring.",
3244 else if (!strcasecmp(line
, "SystemGroup") && value
)
3247 * SystemGroup (admin) group(s)...
3250 if (!parse_groups(value
))
3251 cupsdLogMessage(CUPSD_LOG_ERROR
,
3252 "Unknown SystemGroup \"%s\" on line %d, ignoring.",
3255 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3258 * Do hostname lookups?
3261 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3262 !strcasecmp(value
, "false"))
3263 HostNameLookups
= 0;
3264 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3265 !strcasecmp(value
, "true"))
3266 HostNameLookups
= 1;
3267 else if (!strcasecmp(value
, "double"))
3268 HostNameLookups
= 2;
3270 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3273 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3276 * Amount of logging to do to access log...
3279 if (!strcasecmp(value
, "all"))
3280 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3281 else if (!strcasecmp(value
, "actions"))
3282 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3283 else if (!strcasecmp(value
, "config"))
3284 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3286 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3289 else if (!strcasecmp(line
, "LogLevel") && value
)
3292 * Amount of logging to do to error log...
3295 if (!strcasecmp(value
, "debug2"))
3296 LogLevel
= CUPSD_LOG_DEBUG2
;
3297 else if (!strcasecmp(value
, "debug"))
3298 LogLevel
= CUPSD_LOG_DEBUG
;
3299 else if (!strcasecmp(value
, "info"))
3300 LogLevel
= CUPSD_LOG_INFO
;
3301 else if (!strcasecmp(value
, "notice"))
3302 LogLevel
= CUPSD_LOG_NOTICE
;
3303 else if (!strcasecmp(value
, "warn"))
3304 LogLevel
= CUPSD_LOG_WARN
;
3305 else if (!strcasecmp(value
, "error"))
3306 LogLevel
= CUPSD_LOG_ERROR
;
3307 else if (!strcasecmp(value
, "crit"))
3308 LogLevel
= CUPSD_LOG_CRIT
;
3309 else if (!strcasecmp(value
, "alert"))
3310 LogLevel
= CUPSD_LOG_ALERT
;
3311 else if (!strcasecmp(value
, "emerg"))
3312 LogLevel
= CUPSD_LOG_EMERG
;
3313 else if (!strcasecmp(value
, "none"))
3314 LogLevel
= CUPSD_LOG_NONE
;
3316 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3319 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3322 * Amount of logging to do to error log...
3325 if (!strcasecmp(value
, "standard"))
3326 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3327 else if (!strcasecmp(value
, "usecs"))
3328 LogTimeFormat
= CUPSD_TIME_USECS
;
3330 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3333 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3336 * Format of printcap file?
3339 if (!strcasecmp(value
, "bsd"))
3340 PrintcapFormat
= PRINTCAP_BSD
;
3341 else if (!strcasecmp(value
, "plist"))
3342 PrintcapFormat
= PRINTCAP_PLIST
;
3343 else if (!strcasecmp(value
, "solaris"))
3344 PrintcapFormat
= PRINTCAP_SOLARIS
;
3346 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3349 else if (!strcasecmp(line
, "ServerTokens") && value
)
3352 * Set the string used for the Server header...
3355 struct utsname plat
; /* Platform info */
3360 if (!strcasecmp(value
, "ProductOnly"))
3361 cupsdSetString(&ServerHeader
, "CUPS");
3362 else if (!strcasecmp(value
, "Major"))
3363 cupsdSetString(&ServerHeader
, "CUPS/1");
3364 else if (!strcasecmp(value
, "Minor"))
3365 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3366 else if (!strcasecmp(value
, "Minimal"))
3367 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3368 else if (!strcasecmp(value
, "OS"))
3369 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3370 else if (!strcasecmp(value
, "Full"))
3371 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3373 else if (!strcasecmp(value
, "None"))
3374 cupsdClearString(&ServerHeader
);
3376 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3379 else if (!strcasecmp(line
, "PassEnv") && value
)
3382 * PassEnv variable [... variable]
3387 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3388 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3391 if (value
[valuelen
])
3393 value
[valuelen
] = '\0';
3397 cupsdSetEnv(value
, NULL
);
3399 for (value
+= valuelen
; *value
; value
++)
3400 if (!isspace(*value
) || *value
!= ',')
3404 else if (!strcasecmp(line
, "ServerAlias") && value
)
3407 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3409 cupsdAddAlias(ServerAlias
, value
);
3411 else if (!strcasecmp(line
, "SetEnv") && value
)
3414 * SetEnv variable value
3417 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3425 while (isspace(*valueptr
& 255))
3428 cupsdSetEnv(value
, valueptr
);
3431 cupsdLogMessage(CUPSD_LOG_ERROR
,
3432 "Missing value for SetEnv directive on line %d.",
3436 else if (!strcasecmp(line
, "SSLOptions"))
3439 * SSLOptions options
3442 if (!value
|| !strcasecmp(value
, "none"))
3443 SSLOptions
= CUPSD_SSL_NONE
;
3444 else if (!strcasecmp(value
, "noemptyfragments"))
3445 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3447 cupsdLogMessage(CUPSD_LOG_ERROR
,
3448 "Unknown value \"%s\" for SSLOptions directive on "
3449 "line %d.", value
, linenum
);
3451 #endif /* HAVE_SSL */
3455 * Find a simple variable in the list...
3458 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3459 if (!strcasecmp(line
, var
->name
))
3465 * Unknown directive! Output an error message and continue...
3469 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3472 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3479 case CUPSD_VARTYPE_INTEGER
:
3481 cupsdLogMessage(CUPSD_LOG_ERROR
,
3482 "Missing integer value for %s on line %d.",
3487 char *units
; /* Units */
3490 n
= strtol(value
, &units
, 0);
3492 if (units
&& *units
)
3494 if (tolower(units
[0] & 255) == 'g')
3495 n
*= 1024 * 1024 * 1024;
3496 else if (tolower(units
[0] & 255) == 'm')
3498 else if (tolower(units
[0] & 255) == 'k')
3500 else if (tolower(units
[0] & 255) == 't')
3505 cupsdLogMessage(CUPSD_LOG_ERROR
,
3506 "Bad negative integer value for %s on line %d.",
3509 *((int *)var
->ptr
) = n
;
3513 case CUPSD_VARTYPE_BOOLEAN
:
3515 cupsdLogMessage(CUPSD_LOG_ERROR
,
3516 "Missing boolean value for %s on line %d.",
3518 else if (!strcasecmp(value
, "true") ||
3519 !strcasecmp(value
, "on") ||
3520 !strcasecmp(value
, "enabled") ||
3521 !strcasecmp(value
, "yes") ||
3523 *((int *)var
->ptr
) = TRUE
;
3524 else if (!strcasecmp(value
, "false") ||
3525 !strcasecmp(value
, "off") ||
3526 !strcasecmp(value
, "disabled") ||
3527 !strcasecmp(value
, "no") ||
3528 !strcasecmp(value
, "0"))
3529 *((int *)var
->ptr
) = FALSE
;
3531 cupsdLogMessage(CUPSD_LOG_ERROR
,
3532 "Unknown boolean value %s on line %d.",
3536 case CUPSD_VARTYPE_PATHNAME
:
3539 cupsdLogMessage(CUPSD_LOG_ERROR
,
3540 "Missing pathname value for %s on line %d.",
3545 if (value
[0] == '/')
3546 strlcpy(temp
, value
, sizeof(temp
));
3548 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3550 if (access(temp
, 0))
3552 cupsdLogMessage(CUPSD_LOG_ERROR
,
3553 "File or directory for \"%s %s\" on line %d "
3554 "does not exist.", line
, value
, linenum
);
3558 case CUPSD_VARTYPE_STRING
:
3559 cupsdSetString((char **)var
->ptr
, value
);
3570 * 'read_location()' - Read a <Location path> definition.
3573 static int /* O - New line number or 0 on error */
3574 read_location(cups_file_t
*fp
, /* I - Configuration file */
3575 char *location
, /* I - Location name/path */
3576 int linenum
) /* I - Current line number */
3578 cupsd_location_t
*loc
, /* New location */
3579 *parent
; /* Parent location */
3580 char line
[HTTP_MAX_BUFFER
],
3582 *value
, /* Value for directive */
3583 *valptr
; /* Pointer into value */
3586 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3587 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3589 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3593 cupsdAddLocation(parent
);
3595 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3600 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3603 * Decode the directive...
3606 if (!strcasecmp(line
, "</Location>"))
3608 else if (!strcasecmp(line
, "<Limit") ||
3609 !strcasecmp(line
, "<LimitExcept"))
3613 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3614 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3620 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3623 cupsdAddLocation(loc
);
3628 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3633 if (!strcmp(value
, "ALL"))
3634 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3635 else if (!strcmp(value
, "GET"))
3636 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3637 else if (!strcmp(value
, "HEAD"))
3638 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3639 else if (!strcmp(value
, "OPTIONS"))
3640 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3641 else if (!strcmp(value
, "POST"))
3642 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3643 else if (!strcmp(value
, "PUT"))
3644 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3645 else if (!strcmp(value
, "TRACE"))
3646 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3648 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3651 for (value
= valptr
; isspace(*value
& 255); value
++);
3654 if (!strcasecmp(line
, "<LimitExcept"))
3655 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3657 parent
->limit
&= ~loc
->limit
;
3659 else if (!strcasecmp(line
, "</Limit>") ||
3660 !strcasecmp(line
, "</LimitExcept>"))
3662 else if (!parse_aaa(loc
, line
, value
, linenum
))
3664 cupsdLogMessage(CUPSD_LOG_ERROR
,
3665 "Unknown Location directive %s on line %d.",
3667 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3672 cupsdLogMessage(CUPSD_LOG_ERROR
,
3673 "Unexpected end-of-file at line %d while reading location.",
3676 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3681 * 'read_policy()' - Read a <Policy name> definition.
3684 static int /* O - New line number or 0 on error */
3685 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3686 char *policy
, /* I - Location name/path */
3687 int linenum
) /* I - Current line number */
3689 int i
; /* Looping var */
3690 cupsd_policy_t
*pol
; /* Policy */
3691 cupsd_location_t
*op
; /* Policy operation */
3692 int num_ops
; /* Number of IPP operations */
3693 ipp_op_t ops
[100]; /* Operations */
3694 char line
[HTTP_MAX_BUFFER
],
3696 *value
, /* Value for directive */
3697 *valptr
; /* Pointer into value */
3701 * Create the policy...
3704 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3705 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3707 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3711 * Read from the file...
3717 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3720 * Decode the directive...
3723 if (!strcasecmp(line
, "</Policy>"))
3726 cupsdLogMessage(CUPSD_LOG_WARN
,
3727 "Missing </Limit> before </Policy> on line %d.",
3730 set_policy_defaults(pol
);
3734 else if (!strcasecmp(line
, "<Limit") && !op
)
3738 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3739 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3746 * Scan for IPP operation names...
3753 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3758 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3760 if (!strcasecmp(value
, "All"))
3761 ops
[num_ops
] = IPP_ANY_OPERATION
;
3762 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3763 cupsdLogMessage(CUPSD_LOG_ERROR
,
3764 "Bad IPP operation name \"%s\" on line %d.",
3770 cupsdLogMessage(CUPSD_LOG_ERROR
,
3771 "Too many operations listed on line %d.",
3774 for (value
= valptr
; isspace(*value
& 255); value
++);
3778 * If none are specified, apply the policy to all operations...
3783 ops
[0] = IPP_ANY_OPERATION
;
3788 * Add a new policy for the first operation...
3791 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3793 else if (!strcasecmp(line
, "</Limit>") && op
)
3796 * Finish the current operation limit...
3802 * Copy the policy to the other operations...
3805 for (i
= 1; i
< num_ops
; i
++)
3806 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3811 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3812 !strcasecmp(line
, "JobPrivateValues") ||
3813 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3814 !strcasecmp(line
, "SubscriptionPrivateValues"))
3818 cupsdLogMessage(CUPSD_LOG_ERROR
,
3819 "%s directive must appear outside <Limit>...</Limit> "
3820 "on line %d.", line
, linenum
);
3821 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3827 * Pull out whitespace-delimited values...
3833 * Find the end of the current value...
3836 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3842 * Save it appropriately...
3845 if (!strcasecmp(line
, "JobPrivateAccess"))
3848 * JobPrivateAccess {all|default|user/group list|@@ACL}
3851 if (!strcasecmp(value
, "default"))
3853 cupsdAddString(&(pol
->job_access
), "@OWNER");
3854 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3857 cupsdAddString(&(pol
->job_access
), value
);
3859 else if (!strcasecmp(line
, "JobPrivateValues"))
3862 * JobPrivateValues {all|none|default|attribute list}
3865 if (!strcasecmp(value
, "default"))
3867 cupsdAddString(&(pol
->job_attrs
), "job-name");
3868 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3869 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3872 cupsdAddString(&(pol
->job_attrs
), value
);
3874 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3877 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3880 if (!strcasecmp(value
, "default"))
3882 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3883 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3886 cupsdAddString(&(pol
->sub_access
), value
);
3888 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3891 * SubscriptionPrivateValues {all|none|default|attribute list}
3894 if (!strcasecmp(value
, "default"))
3896 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3897 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3898 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3899 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3900 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3903 cupsdAddString(&(pol
->sub_attrs
), value
);
3907 * Find the next string on the line...
3910 for (value
= valptr
; isspace(*value
& 255); value
++);
3916 cupsdLogMessage(CUPSD_LOG_ERROR
,
3917 "Missing <Limit ops> directive before %s on line %d.",
3919 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3922 else if (!parse_aaa(op
, line
, value
, linenum
))
3925 cupsdLogMessage(CUPSD_LOG_ERROR
,
3926 "Unknown Policy Limit directive %s on line %d.",
3929 cupsdLogMessage(CUPSD_LOG_ERROR
,
3930 "Unknown Policy directive %s on line %d.",
3933 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3938 cupsdLogMessage(CUPSD_LOG_ERROR
,
3939 "Unexpected end-of-file at line %d while reading policy "
3940 "\"%s\".", linenum
, policy
);
3942 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3947 * 'set_policy_defaults()' - Set default policy values as needed.
3951 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3953 cupsd_location_t
*op
; /* Policy operation */
3957 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3958 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3959 * upgrades do not introduce new security issues...
3962 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3963 op
->op
== IPP_ANY_OPERATION
)
3965 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3966 op
->op
!= IPP_ANY_OPERATION
)
3969 * Add a new limit for Validate-Job using the Print-Job limit as a
3973 cupsdLogMessage(CUPSD_LOG_WARN
,
3974 "No limit for Validate-Job defined in policy %s "
3975 "- using Print-Job's policy.", pol
->name
);
3977 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3980 cupsdLogMessage(CUPSD_LOG_WARN
,
3981 "No limit for Validate-Job defined in policy %s "
3982 "and no suitable template found.", pol
->name
);
3985 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3986 op
->op
== IPP_ANY_OPERATION
)
3988 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3989 op
->op
!= IPP_ANY_OPERATION
)
3992 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3996 cupsdLogMessage(CUPSD_LOG_WARN
,
3997 "No limit for Cancel-Jobs defined in policy %s "
3998 "- using Pause-Printer's policy.", pol
->name
);
4000 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
4003 cupsdLogMessage(CUPSD_LOG_WARN
,
4004 "No limit for Cancel-Jobs defined in policy %s "
4005 "and no suitable template found.", pol
->name
);
4008 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
4009 op
->op
== IPP_ANY_OPERATION
)
4011 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4012 op
->op
!= IPP_ANY_OPERATION
)
4015 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4019 cupsdLogMessage(CUPSD_LOG_WARN
,
4020 "No limit for Cancel-My-Jobs defined in policy %s "
4021 "- using Send-Document's policy.", pol
->name
);
4023 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4026 cupsdLogMessage(CUPSD_LOG_WARN
,
4027 "No limit for Cancel-My-Jobs defined in policy %s "
4028 "and no suitable template found.", pol
->name
);
4031 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
4032 op
->op
== IPP_ANY_OPERATION
)
4034 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4035 op
->op
!= IPP_ANY_OPERATION
)
4038 * Add a new limit for Close-Job using the Send-Document limit as a
4042 cupsdLogMessage(CUPSD_LOG_WARN
,
4043 "No limit for Close-Job defined in policy %s "
4044 "- using Send-Document's policy.", pol
->name
);
4046 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4049 cupsdLogMessage(CUPSD_LOG_WARN
,
4050 "No limit for Close-Job defined in policy %s "
4051 "and no suitable template found.", pol
->name
);
4054 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4055 op
->op
== IPP_ANY_OPERATION
)
4057 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4058 op
->op
!= IPP_ANY_OPERATION
)
4061 * Add a new limit for CUPS-Get-Document using the Send-Document
4062 * limit as a template...
4065 cupsdLogMessage(CUPSD_LOG_WARN
,
4066 "No limit for CUPS-Get-Document defined in policy %s "
4067 "- using Send-Document's policy.", pol
->name
);
4069 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4072 cupsdLogMessage(CUPSD_LOG_WARN
,
4073 "No limit for CUPS-Get-Document defined in policy %s "
4074 "and no suitable template found.", pol
->name
);
4078 * Verify we have JobPrivateAccess, JobPrivateValues,
4079 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4082 if (!pol
->job_access
)
4084 cupsdLogMessage(CUPSD_LOG_WARN
,
4085 "No JobPrivateAccess defined in policy %s "
4086 "- using defaults.", pol
->name
);
4087 cupsdAddString(&(pol
->job_access
), "@OWNER");
4088 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4091 if (!pol
->job_attrs
)
4093 cupsdLogMessage(CUPSD_LOG_WARN
,
4094 "No JobPrivateValues defined in policy %s "
4095 "- using defaults.", pol
->name
);
4096 cupsdAddString(&(pol
->job_attrs
), "job-name");
4097 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4098 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4101 if (!pol
->sub_access
)
4103 cupsdLogMessage(CUPSD_LOG_WARN
,
4104 "No SubscriptionPrivateAccess defined in policy %s "
4105 "- using defaults.", pol
->name
);
4106 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4107 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4110 if (!pol
->sub_attrs
)
4112 cupsdLogMessage(CUPSD_LOG_WARN
,
4113 "No SubscriptionPrivateValues defined in policy %s "
4114 "- using defaults.", pol
->name
);
4115 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4116 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4117 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4118 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4119 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4125 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".