2 * "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $"
4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2010 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 { "MaxPrinterHistory", &MaxPrinterHistory
, CUPSD_VARTYPE_INTEGER
},
149 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
150 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
151 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
152 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
153 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
154 { "MultipleOperationTimeout", &MultipleOperationTimeout
, CUPSD_VARTYPE_INTEGER
},
155 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
156 { "PageLogFormat", &PageLogFormat
, CUPSD_VARTYPE_STRING
},
157 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_BOOLEAN
},
158 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_BOOLEAN
},
159 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
160 { "PrintcapGUI", &PrintcapGUI
, CUPSD_VARTYPE_STRING
},
161 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_INTEGER
},
162 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
163 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
164 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
165 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_INTEGER
},
166 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
167 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
169 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
170 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
171 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
172 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
173 #endif /* HAVE_SSL */
174 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
175 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
176 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
177 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
178 #ifdef HAVE_AUTHORIZATION_H
179 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
180 #endif /* HAVE_AUTHORIZATION_H */
181 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
},
182 { "Timeout", &Timeout
, CUPSD_VARTYPE_INTEGER
},
183 { "UseNetworkDefault", &UseNetworkDefault
, 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 %j %u %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;
628 MaxPrinterHistory
= 0;
630 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
631 ReloadTimeout
= DEFAULT_KEEPALIVE
;
632 RootCertDuration
= 300;
633 Timeout
= DEFAULT_TIMEOUT
;
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 * Read the configuration file...
695 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
698 status
= read_configuration(fp
);
707 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
708 RemotePort
? "enabled" : "disabled");
711 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
714 * See if the ServerName is an IP address...
720 ServerAlias
= cupsArrayNew(NULL
, NULL
);
722 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
726 if (gethostname(temp
, sizeof(temp
)))
728 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
730 strlcpy(temp
, "localhost", sizeof(temp
));
733 cupsdSetString(&ServerName
, temp
);
736 ServerAlias
= cupsArrayNew(NULL
, NULL
);
738 cupsdAddAlias(ServerAlias
, temp
);
739 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
741 if (HostNameLookups
|| RemotePort
)
743 struct hostent
*host
; /* Host entry to get FQDN */
745 if ((host
= gethostbyname(temp
)) != NULL
)
747 if (strcasecmp(temp
, host
->h_name
))
749 cupsdSetString(&ServerName
, host
->h_name
);
750 cupsdAddAlias(ServerAlias
, host
->h_name
);
751 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
757 for (i
= 0; host
->h_aliases
[i
]; i
++)
758 if (strcasecmp(temp
, host
->h_aliases
[i
]))
760 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
761 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
769 * Make sure we have the base hostname added as an alias, too!
772 if ((slash
= strchr(temp
, '.')) != NULL
)
775 cupsdAddAlias(ServerAlias
, temp
);
776 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
780 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
782 ServerNameIsIP
= !*slash
;
785 * Make sure ServerAdmin is initialized...
789 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
792 * Use the default system group if none was supplied in cupsd.conf...
795 if (NumSystemGroups
== 0)
797 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
800 * Find the group associated with GID 0...
807 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
809 cupsdSetString(&SystemGroups
[0], "unknown");
811 SystemGroupIDs
[0] = 0;
817 * Get the access control list for browsing...
820 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
823 * Open the system log for cupsd if necessary...
827 if (!strcmp(AccessLog
, "syslog") ||
828 !strcmp(ErrorLog
, "syslog") ||
829 !strcmp(PageLog
, "syslog"))
830 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
831 #endif /* HAVE_VSYSLOG */
834 * Log the configuration file that was used...
837 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
841 * Validate the Group and SystemGroup settings - they cannot be the same,
842 * otherwise the CGI programs will be able to authenticate as root without
848 for (i
= 0; i
< NumSystemGroups
; i
++)
849 if (Group
== SystemGroupIDs
[i
])
852 if (i
< NumSystemGroups
)
855 * Log the error and reset the group to a safe value...
858 cupsdLogMessage(CUPSD_LOG_NOTICE
,
859 "Group and SystemGroup cannot use the same groups!");
860 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
862 group
= getgrnam("nobody");
866 Group
= group
->gr_gid
;
870 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
871 * complement number...)
880 * Check that we have at least one listen/port line; if not, report this
881 * as an error and exit!
884 if (cupsArrayCount(Listeners
) == 0)
890 cupsdLogMessage(CUPSD_LOG_EMERG
,
891 "No valid Listen or Port lines were found in the "
892 "configuration file!");
898 cupsdEndProcess(getpid(), 0);
902 * Set the default locale using the language and charset...
905 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
908 * Update all relative filenames to include the full path from ServerRoot...
911 if (DocumentRoot
[0] != '/')
912 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
914 if (RequestRoot
[0] != '/')
915 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
917 if (ServerBin
[0] != '/')
918 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
920 if (StateDir
[0] != '/')
921 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
923 if (CacheDir
[0] != '/')
924 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
927 if (ServerCertificate
[0] != '/')
928 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
930 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
931 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
933 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
936 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
937 if (ServerKey
[0] != '/')
938 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
940 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
941 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
942 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
944 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
945 #endif /* HAVE_SSL */
948 * Make sure that directories and config files are owned and
949 * writable by the user and group in the cupsd.conf file...
952 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
954 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
956 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
958 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
960 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
962 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
963 SystemGroupIDs
[0], 1, 1) < 0 ||
964 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
966 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
968 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
970 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
972 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
974 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
976 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
978 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
982 * Update TempDir to the default if it hasn't been set already...
987 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
990 * TMPDIR is defined, see if it is OK for us to use...
993 if (stat(tmpdir
, &tmpinfo
))
994 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
995 tmpdir
, strerror(errno
));
996 else if (!S_ISDIR(tmpinfo
.st_mode
))
997 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory!",
999 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1000 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1001 !(tmpinfo
.st_mode
& S_IWOTH
))
1002 cupsdLogMessage(CUPSD_LOG_ERROR
,
1003 "TMPDIR (%s) has the wrong permissions!", tmpdir
);
1005 cupsdSetString(&TempDir
, tmpdir
);
1010 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1012 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1017 * Make sure the temporary directory has the right permissions...
1020 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1024 * Update ownership and permissions if the CUPS temp directory
1025 * is under the spool directory or does not exist...
1028 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1029 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1034 * Setup environment variables...
1040 * Update default paper size setting as needed...
1043 if (!DefaultPaperSize
)
1045 #ifdef HAVE_LIBPAPER
1046 char *paper_result
; /* Paper size name from libpaper */
1048 if ((paper_result
= systempapername()) != NULL
)
1049 cupsdSetString(&DefaultPaperSize
, paper_result
);
1051 #endif /* HAVE_LIBPAPER */
1052 if (!DefaultLanguage
||
1053 !strcasecmp(DefaultLanguage
, "C") ||
1054 !strcasecmp(DefaultLanguage
, "POSIX") ||
1055 !strcasecmp(DefaultLanguage
, "en") ||
1056 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1057 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1058 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1059 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1062 * These are the only locales that will default to "letter" size...
1065 cupsdSetString(&DefaultPaperSize
, "Letter");
1068 cupsdSetString(&DefaultPaperSize
, "A4");
1072 * Update classification setting as needed...
1075 if (Classification
&& !strcasecmp(Classification
, "none"))
1076 cupsdClearString(&Classification
);
1079 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1082 * Check the MaxClients setting, and then allocate memory for it...
1085 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1088 cupsdLogMessage(CUPSD_LOG_INFO
,
1089 "MaxClients limited to 1/3 (%d) of the file descriptor "
1091 MaxFDs
/ 3, MaxFDs
);
1093 MaxClients
= MaxFDs
/ 3;
1096 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1100 * Check the MaxActiveJobs setting; limit to 1/3 the available
1101 * file descriptors, since we need a pipe for each job...
1104 if (MaxActiveJobs
> (MaxFDs
/ 3))
1105 MaxActiveJobs
= MaxFDs
/ 3;
1108 * Update the MaxClientsPerHost value, as needed...
1111 if (MaxClientsPerHost
<= 0)
1112 MaxClientsPerHost
= MaxClients
;
1114 if (MaxClientsPerHost
> MaxClients
)
1115 MaxClientsPerHost
= MaxClients
;
1117 cupsdLogMessage(CUPSD_LOG_INFO
,
1118 "Allowing up to %d client connections per host.",
1122 * Make sure that BrowseTimeout is at least twice the interval...
1125 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1127 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d!",
1131 BrowseTimeout
= BrowseInterval
* 2;
1133 BrowseTimeout
= DEFAULT_TIMEOUT
;
1135 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d!",
1140 * Update the default policy, as needed...
1144 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1146 DefaultPolicyPtr
= NULL
;
1148 if (!DefaultPolicyPtr
)
1150 cupsd_location_t
*po
; /* New policy operation */
1154 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found!",
1157 cupsdSetString(&DefaultPolicy
, "default");
1159 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1160 cupsdLogMessage(CUPSD_LOG_INFO
,
1161 "Using policy \"default\" as the default!");
1164 cupsdLogMessage(CUPSD_LOG_INFO
,
1165 "Creating CUPS default administrative policy:");
1167 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1169 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1171 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1172 cupsdAddString(&(p
->job_access
), "@OWNER");
1173 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1175 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1176 cupsdAddString(&(p
->job_attrs
), "job-name");
1177 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1178 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1180 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1181 cupsdAddString(&(p
->sub_access
), "@OWNER");
1182 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1184 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1185 cupsdAddString(&(p
->job_attrs
), "notify-events");
1186 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1187 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1188 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1189 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1191 cupsdLogMessage(CUPSD_LOG_INFO
,
1192 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1193 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1195 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1196 po
->order_type
= CUPSD_AUTH_ALLOW
;
1198 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1199 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1200 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1202 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1204 cupsdLogMessage(CUPSD_LOG_INFO
,
1205 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1206 "Release-Job Restart-Job Purge-Jobs "
1207 "Set-Job-Attributes Create-Job-Subscription "
1208 "Renew-Subscription Cancel-Subscription "
1209 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1210 "Suspend-Current-Job Resume-Job "
1211 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1212 "CUPS-Authenticate-Job CUPS-Get-Document>");
1213 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1215 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1216 po
->order_type
= CUPSD_AUTH_ALLOW
;
1217 po
->level
= CUPSD_AUTH_USER
;
1219 cupsdAddName(po
, "@OWNER");
1220 cupsdAddName(po
, "@SYSTEM");
1221 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1223 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1224 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1225 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1226 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1227 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1228 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1229 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1230 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1231 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1232 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1233 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1234 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1235 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1236 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1237 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1238 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1239 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1240 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1241 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1242 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1244 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1246 cupsdLogMessage(CUPSD_LOG_INFO
,
1247 "<Limit Pause-Printer Resume-Printer "
1248 "Set-Printer-Attributes Enable-Printer "
1249 "Disable-Printer Pause-Printer-After-Current-Job "
1250 "Hold-New-Jobs Release-Held-New-Jobs "
1251 "Deactivate-Printer Activate-Printer Restart-Printer "
1252 "Shutdown-Printer Startup-Printer Promote-Job "
1253 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1254 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1255 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1256 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1257 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1259 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1260 po
->order_type
= CUPSD_AUTH_ALLOW
;
1261 po
->type
= CUPSD_AUTH_DEFAULT
;
1262 po
->level
= CUPSD_AUTH_USER
;
1264 cupsdAddName(po
, "@SYSTEM");
1265 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1267 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1268 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1269 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1270 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1271 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1272 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1273 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1274 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1275 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1276 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1277 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1278 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1279 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1280 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1281 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1282 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1283 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1284 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1285 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1286 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1287 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1288 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1290 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1292 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1293 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1295 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1296 po
->order_type
= CUPSD_AUTH_ALLOW
;
1298 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1299 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1303 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1304 cupsArrayCount(Policies
));
1305 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1307 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1308 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1309 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1312 * If we are doing a full reload or the server root has changed, flush
1313 * the jobs, printers, etc. and start from scratch...
1316 if (NeedReload
== RELOAD_ALL
||
1317 old_remote_port
!= RemotePort
||
1318 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1319 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1321 mime_type_t
*type
; /* Current type */
1322 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1323 /* MIME type name */
1326 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1329 * Free all memory...
1332 cupsdDeleteAllSubscriptions();
1334 cupsdDeleteAllPrinters();
1336 DefaultPrinter
= NULL
;
1338 if (MimeDatabase
!= NULL
)
1339 mimeDelete(MimeDatabase
);
1343 for (i
= 0; i
< NumMimeTypes
; i
++)
1344 _cupsStrFree(MimeTypes
[i
]);
1350 * Read the MIME type and conversion database...
1353 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1354 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1356 MimeDatabase
= mimeLoadTypes(NULL
, mimedir
);
1357 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1358 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1359 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1363 cupsdLogMessage(CUPSD_LOG_EMERG
,
1364 "Unable to load MIME database from \"%s\" or \"%s\"!",
1365 mimedir
, ServerRoot
);
1366 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1370 cupsdLogMessage(CUPSD_LOG_INFO
,
1371 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1372 "%d filters...", mimedir
, ServerRoot
,
1373 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1376 * Create a list of MIME types for the document-format-supported
1380 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1381 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1384 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1386 cupsdLogMessage(CUPSD_LOG_ERROR
,
1387 "Unable to allocate memory for %d MIME types!",
1393 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1395 i
++, type
= mimeNextType(MimeDatabase
))
1397 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1399 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1402 if (i
< NumMimeTypes
)
1403 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1406 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1408 mime_filter_t
*filter
; /* Current filter */
1411 for (type
= mimeFirstType(MimeDatabase
);
1413 type
= mimeNextType(MimeDatabase
))
1414 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1415 type
->super
, type
->type
);
1417 for (filter
= mimeFirstFilter(MimeDatabase
);
1419 filter
= mimeNextFilter(MimeDatabase
))
1420 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1421 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1422 filter
->src
->super
, filter
->src
->type
,
1423 filter
->dst
->super
, filter
->dst
->type
,
1424 filter
->cost
, filter
->filter
);
1431 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1432 cupsdLoadBanners(temp
);
1435 * Load printers and classes...
1438 cupsdLoadAllPrinters();
1439 cupsdLoadAllClasses();
1440 cupsdLoadRemoteCache();
1442 cupsdCreateCommonData();
1445 * Update the printcap file as needed...
1448 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1449 cupsdWritePrintcap();
1452 * Load queued jobs...
1458 * Load subscriptions...
1461 cupsdLoadAllSubscriptions();
1463 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1468 * Not a full reload, so recreate the common printer attributes...
1471 cupsdCreateCommonData();
1474 * Update all printers as needed...
1477 cupsdUpdatePrinters();
1478 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1480 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1484 * Reset the reload state...
1487 NeedReload
= RELOAD_NONE
;
1489 cupsdClearString(&old_serverroot
);
1490 cupsdClearString(&old_requestroot
);
1497 * 'get_address()' - Get an address + port number from a line.
1500 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1501 get_address(const char *value
, /* I - Value string */
1502 int defport
) /* I - Default port */
1504 char buffer
[1024], /* Hostname + port number buffer */
1505 defpname
[255], /* Default port name */
1506 *hostname
, /* Hostname or IP */
1507 *portname
; /* Port number or name */
1508 http_addrlist_t
*addrlist
; /* Address list */
1512 * Check for an empty value...
1517 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address!");
1522 * Grab a hostname and port number; if there is no colon and the port name
1523 * is only digits, then we have a port number by itself...
1526 strlcpy(buffer
, value
, sizeof(buffer
));
1528 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1535 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1540 * Use the default port...
1543 sprintf(defpname
, "%d", defport
);
1544 portname
= defpname
;
1550 * The buffer contains just a port number...
1558 if (hostname
&& !strcmp(hostname
, "*"))
1562 * Now lookup the address using httpAddrGetList()...
1565 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1566 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed!",
1567 hostname
? hostname
: "(nil)");
1574 * 'get_addr_and_mask()' - Get an IP address and netmask.
1577 static int /* O - 1 on success, 0 on failure */
1578 get_addr_and_mask(const char *value
, /* I - String from config file */
1579 unsigned *ip
, /* O - Address value */
1580 unsigned *mask
) /* O - Mask value */
1582 int i
, j
, /* Looping vars */
1583 family
, /* Address family */
1584 ipcount
; /* Count of fields in address */
1585 unsigned ipval
; /* Value */
1586 const char *maskval
, /* Pointer to start of mask value */
1587 *ptr
, /* Pointer into value */
1592 * Get the address...
1595 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1596 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1598 if ((maskval
= strchr(value
, '/')) != NULL
)
1601 maskval
= value
+ strlen(value
);
1605 * Check for an IPv6 address...
1611 * Parse hexadecimal IPv6 address...
1616 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1620 else if (!strncmp(ptr
, "::", 2))
1622 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1624 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1629 else if (isxdigit(*ptr
& 255))
1631 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1639 ip
[i
/ 2] |= ipval
<< 16;
1653 if (*ptr
&& *ptr
!= '/')
1657 #endif /* AF_INET6 */
1660 * Parse dotted-decimal IPv4 address...
1663 unsigned val
[4]; /* IPv4 address values */
1667 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1670 * Range check the IP numbers...
1673 for (i
= 0; i
< ipcount
; i
++)
1678 * Make sure the trailing values are zeroed, as some C libraries like
1679 * glibc apparently like to fill the unused arguments with garbage...
1682 for (i
= ipcount
; i
< 4; i
++)
1686 * Merge everything into a 32-bit IPv4 address in ip[3]...
1689 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1692 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1698 * Get the netmask value(s)...
1701 memset(mask
, 0, sizeof(unsigned) * 4);
1703 if (strchr(maskval
, '.'))
1706 * Get dotted-decimal mask...
1709 if (family
!= AF_INET
)
1712 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1715 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1716 mask
[0] = mask
[1] = mask
[2] = 0;
1721 * Get address/bits format...
1727 if (family
== AF_INET6
)
1735 mask
[0] = 0xffffffff;
1737 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1740 mask
[1] = 0xffffffff;
1744 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1747 mask
[2] = 0xffffffff;
1751 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1754 mask
[3] = 0xffffffff;
1758 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1761 #endif /* AF_INET6 */
1766 mask
[0] = 0xffffffff;
1767 mask
[1] = 0xffffffff;
1768 mask
[2] = 0xffffffff;
1771 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1773 mask
[3] = 0xffffffff;
1778 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1779 "get_addr_and_mask(value=\"%s\", "
1780 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1781 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1785 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1788 if ((ip
[0] & ~mask
[0]) != 0 ||
1789 (ip
[1] & ~mask
[1]) != 0 ||
1790 (ip
[2] & ~mask
[2]) != 0 ||
1791 (ip
[3] & ~mask
[3]) != 0)
1799 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1802 static int /* O - 1 on success, 0 on failure */
1803 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1804 char *line
, /* I - Line from file */
1805 char *value
, /* I - Start of value data */
1806 int linenum
) /* I - Current line number */
1808 char *valptr
; /* Pointer into value */
1809 unsigned ip
[4], /* IP address components */
1810 mask
[4]; /* IP netmask components */
1813 if (!strcasecmp(line
, "Encryption"))
1816 * "Encryption xxx" - set required encryption level...
1819 if (!strcasecmp(value
, "never"))
1820 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1821 else if (!strcasecmp(value
, "always"))
1823 cupsdLogMessage(CUPSD_LOG_ERROR
,
1824 "Encryption value \"%s\" on line %d is invalid in this "
1825 "context. Using \"required\" instead.", value
, linenum
);
1827 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1829 else if (!strcasecmp(value
, "required"))
1830 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1831 else if (!strcasecmp(value
, "ifrequested"))
1832 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1835 cupsdLogMessage(CUPSD_LOG_ERROR
,
1836 "Unknown Encryption value %s on line %d.", value
, linenum
);
1840 else if (!strcasecmp(line
, "Order"))
1843 * "Order Deny,Allow" or "Order Allow,Deny"...
1846 if (!strncasecmp(value
, "deny", 4))
1847 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1848 else if (!strncasecmp(value
, "allow", 5))
1849 loc
->order_type
= CUPSD_AUTH_DENY
;
1852 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1857 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1860 * Allow [From] host/ip...
1861 * Deny [From] host/ip...
1866 if (!strncasecmp(value
, "from", 4))
1869 * Strip leading "from"...
1874 while (isspace(*value
& 255))
1882 * Find the end of the value...
1885 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1887 while (isspace(*valptr
& 255))
1891 * Figure out what form the allow/deny address takes:
1902 * nnn.nnn.nnn.nnn/mm
1903 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1906 if (!strcasecmp(value
, "all"))
1912 if (!strcasecmp(line
, "Allow"))
1913 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1915 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1917 else if (!strcasecmp(value
, "none"))
1923 if (!strcasecmp(line
, "Allow"))
1924 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1926 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1929 else if (value
[0] == '*' || value
[0] == '.' ||
1930 (!isdigit(value
[0] & 255) && value
[0] != '['))
1932 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1933 #endif /* AF_INET6 */
1936 * Host or domain name...
1939 if (value
[0] == '*')
1942 if (!strcasecmp(line
, "Allow"))
1943 cupsdAddNameMask(&(loc
->allow
), value
);
1945 cupsdAddNameMask(&(loc
->deny
), value
);
1950 * One of many IP address forms...
1953 if (!get_addr_and_mask(value
, ip
, mask
))
1955 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1960 if (!strcasecmp(line
, "Allow"))
1961 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
1963 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
1967 * Advance to next value...
1973 else if (!strcasecmp(line
, "AuthType"))
1976 * AuthType {none,basic,digest,basicdigest,negotiate,default}
1979 if (!strcasecmp(value
, "none"))
1981 loc
->type
= CUPSD_AUTH_NONE
;
1982 loc
->level
= CUPSD_AUTH_ANON
;
1984 else if (!strcasecmp(value
, "basic"))
1986 loc
->type
= CUPSD_AUTH_BASIC
;
1988 if (loc
->level
== CUPSD_AUTH_ANON
)
1989 loc
->level
= CUPSD_AUTH_USER
;
1991 else if (!strcasecmp(value
, "digest"))
1993 loc
->type
= CUPSD_AUTH_DIGEST
;
1995 if (loc
->level
== CUPSD_AUTH_ANON
)
1996 loc
->level
= CUPSD_AUTH_USER
;
1998 else if (!strcasecmp(value
, "basicdigest"))
2000 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2002 if (loc
->level
== CUPSD_AUTH_ANON
)
2003 loc
->level
= CUPSD_AUTH_USER
;
2005 else if (!strcasecmp(value
, "default"))
2007 loc
->type
= CUPSD_AUTH_DEFAULT
;
2009 if (loc
->level
== CUPSD_AUTH_ANON
)
2010 loc
->level
= CUPSD_AUTH_USER
;
2013 else if (!strcasecmp(value
, "negotiate"))
2015 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2017 if (loc
->level
== CUPSD_AUTH_ANON
)
2018 loc
->level
= CUPSD_AUTH_USER
;
2020 #endif /* HAVE_GSSAPI */
2023 cupsdLogMessage(CUPSD_LOG_WARN
,
2024 "Unknown authorization type %s on line %d.",
2029 else if (!strcasecmp(line
, "AuthClass"))
2032 * AuthClass anonymous, user, system, group
2035 if (!strcasecmp(value
, "anonymous"))
2037 loc
->type
= CUPSD_AUTH_NONE
;
2038 loc
->level
= CUPSD_AUTH_ANON
;
2040 cupsdLogMessage(CUPSD_LOG_WARN
,
2041 "\"AuthClass %s\" is deprecated; consider removing "
2045 else if (!strcasecmp(value
, "user"))
2047 loc
->level
= CUPSD_AUTH_USER
;
2049 cupsdLogMessage(CUPSD_LOG_WARN
,
2050 "\"AuthClass %s\" is deprecated; consider using "
2051 "\"Require valid-user\" on line %d.",
2054 else if (!strcasecmp(value
, "group"))
2056 loc
->level
= CUPSD_AUTH_GROUP
;
2058 cupsdLogMessage(CUPSD_LOG_WARN
,
2059 "\"AuthClass %s\" is deprecated; consider using "
2060 "\"Require user @groupname\" on line %d.",
2063 else if (!strcasecmp(value
, "system"))
2065 loc
->level
= CUPSD_AUTH_GROUP
;
2067 cupsdAddName(loc
, "@SYSTEM");
2069 cupsdLogMessage(CUPSD_LOG_WARN
,
2070 "\"AuthClass %s\" is deprecated; consider using "
2071 "\"Require user @SYSTEM\" on line %d.",
2076 cupsdLogMessage(CUPSD_LOG_WARN
,
2077 "Unknown authorization class %s on line %d.",
2082 else if (!strcasecmp(line
, "AuthGroupName"))
2084 cupsdAddName(loc
, value
);
2086 cupsdLogMessage(CUPSD_LOG_WARN
,
2087 "\"AuthGroupName %s\" directive is deprecated; consider "
2088 "using \"Require user @%s\" on line %d.",
2089 value
, value
, linenum
);
2091 else if (!strcasecmp(line
, "Require"))
2094 * Apache synonym for AuthClass and AuthGroupName...
2098 * Require valid-user
2099 * Require group names
2100 * Require user names
2103 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2108 if (!strcasecmp(value
, "valid-user") ||
2109 !strcasecmp(value
, "user"))
2110 loc
->level
= CUPSD_AUTH_USER
;
2111 else if (!strcasecmp(value
, "group"))
2112 loc
->level
= CUPSD_AUTH_GROUP
;
2115 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2121 * Get the list of names from the line...
2124 for (value
= valptr
; *value
;)
2126 while (isspace(*value
& 255))
2129 #ifdef HAVE_AUTHORIZATION_H
2130 if (!strncmp(value
, "@AUTHKEY(", 9))
2133 * Grab "@AUTHKEY(name)" value...
2136 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2142 #endif /* HAVE_AUTHORIZATION_H */
2143 if (*value
== '\"' || *value
== '\'')
2146 * Grab quoted name...
2149 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2156 * Grab literal name.
2159 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2165 cupsdAddName(loc
, value
);
2167 for (value
= valptr
; isspace(*value
& 255); value
++);
2170 else if (!strcasecmp(line
, "Satisfy"))
2172 if (!strcasecmp(value
, "all"))
2173 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2174 else if (!strcasecmp(value
, "any"))
2175 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2178 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2191 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2194 static int /* O - FatalErrors bits */
2195 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2197 int fatal
; /* FatalErrors bits */
2198 char value
[1024], /* Value string */
2199 *valstart
, /* Pointer into value */
2200 *valend
; /* End of value */
2204 * Empty FatalErrors line yields NULL pointer...
2208 return (CUPSD_FATAL_NONE
);
2211 * Loop through the value string,...
2214 strlcpy(value
, s
, sizeof(value
));
2216 fatal
= CUPSD_FATAL_NONE
;
2218 for (valstart
= value
; *valstart
;)
2221 * Get the current space/comma-delimited kind name...
2224 for (valend
= valstart
; *valend
; valend
++)
2225 if (isspace(*valend
& 255) || *valend
== ',')
2232 * Add the error to the bitmask...
2235 if (!strcasecmp(valstart
, "all"))
2236 fatal
= CUPSD_FATAL_ALL
;
2237 else if (!strcasecmp(valstart
, "browse"))
2238 fatal
|= CUPSD_FATAL_BROWSE
;
2239 else if (!strcasecmp(valstart
, "-browse"))
2240 fatal
&= ~CUPSD_FATAL_BROWSE
;
2241 else if (!strcasecmp(valstart
, "config"))
2242 fatal
|= CUPSD_FATAL_CONFIG
;
2243 else if (!strcasecmp(valstart
, "-config"))
2244 fatal
&= ~CUPSD_FATAL_CONFIG
;
2245 else if (!strcasecmp(valstart
, "listen"))
2246 fatal
|= CUPSD_FATAL_LISTEN
;
2247 else if (!strcasecmp(valstart
, "-listen"))
2248 fatal
&= ~CUPSD_FATAL_LISTEN
;
2249 else if (!strcasecmp(valstart
, "log"))
2250 fatal
|= CUPSD_FATAL_LOG
;
2251 else if (!strcasecmp(valstart
, "-log"))
2252 fatal
&= ~CUPSD_FATAL_LOG
;
2253 else if (!strcasecmp(valstart
, "permissions"))
2254 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2255 else if (!strcasecmp(valstart
, "-permissions"))
2256 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2257 else if (strcasecmp(valstart
, "none"))
2258 cupsdLogMessage(CUPSD_LOG_ERROR
,
2259 "Unknown FatalErrors kind \"%s\" ignored!", valstart
);
2261 for (valstart
= valend
; *valstart
; valstart
++)
2262 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2271 * 'parse_groups()' - Parse system group names in a string.
2274 static int /* O - 1 on success, 0 on failure */
2275 parse_groups(const char *s
) /* I - Space-delimited groups */
2277 int status
; /* Return status */
2278 char value
[1024], /* Value string */
2279 *valstart
, /* Pointer into value */
2280 *valend
, /* End of value */
2281 quote
; /* Quote character */
2282 struct group
*group
; /* Group */
2286 * Make a copy of the string and parse out the groups...
2289 strlcpy(value
, s
, sizeof(value
));
2294 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2296 if (*valstart
== '\'' || *valstart
== '\"')
2299 * Scan quoted name...
2302 quote
= *valstart
++;
2304 for (valend
= valstart
; *valend
; valend
++)
2305 if (*valend
== quote
)
2311 * Scan space or comma-delimited name...
2314 for (valend
= valstart
; *valend
; valend
++)
2315 if (isspace(*valend
) || *valend
== ',')
2322 group
= getgrnam(valstart
);
2325 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2326 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2337 while (*valstart
== ',' || isspace(*valstart
))
2346 * 'parse_protocols()' - Parse browse protocols in a string.
2349 static int /* O - Browse protocol bits */
2350 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2352 int protocols
; /* Browse protocol bits */
2353 char value
[1024], /* Value string */
2354 *valstart
, /* Pointer into value */
2355 *valend
; /* End of value */
2359 * Empty protocol line yields NULL pointer...
2366 * Loop through the value string,...
2369 strlcpy(value
, s
, sizeof(value
));
2373 for (valstart
= value
; *valstart
;)
2376 * Get the current space/comma-delimited protocol name...
2379 for (valend
= valstart
; *valend
; valend
++)
2380 if (isspace(*valend
& 255) || *valend
== ',')
2387 * Add the protocol to the bitmask...
2390 if (!strcasecmp(valstart
, "cups"))
2391 protocols
|= BROWSE_CUPS
;
2392 else if (!strcasecmp(valstart
, "slp"))
2393 protocols
|= BROWSE_SLP
;
2394 else if (!strcasecmp(valstart
, "ldap"))
2395 protocols
|= BROWSE_LDAP
;
2396 else if (!strcasecmp(valstart
, "dnssd") ||
2397 !strcasecmp(valstart
, "dns-sd") ||
2398 !strcasecmp(valstart
, "bonjour"))
2399 protocols
|= BROWSE_DNSSD
;
2400 else if (!strcasecmp(valstart
, "lpd"))
2401 protocols
|= BROWSE_LPD
;
2402 else if (!strcasecmp(valstart
, "smb"))
2403 protocols
|= BROWSE_SMB
;
2404 else if (!strcasecmp(valstart
, "all"))
2405 protocols
|= BROWSE_ALL
;
2406 else if (strcasecmp(valstart
, "none"))
2407 cupsdLogMessage(CUPSD_LOG_ERROR
,
2408 "Unknown browse protocol \"%s\" ignored!", valstart
);
2410 for (valstart
= valend
; *valstart
; valstart
++)
2411 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2420 * 'read_configuration()' - Read a configuration file.
2423 static int /* O - 1 on success, 0 on failure */
2424 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2426 int i
; /* Looping var */
2427 int linenum
; /* Current line number */
2428 char line
[HTTP_MAX_BUFFER
],
2429 /* Line from file */
2430 temp
[HTTP_MAX_BUFFER
],
2431 /* Temporary buffer for value */
2432 *ptr
, /* Pointer into line/temp */
2433 *value
, /* Pointer to value */
2434 *valueptr
; /* Pointer into value */
2435 int valuelen
; /* Length of value */
2436 cupsd_var_t
const *var
; /* Current variable */
2437 http_addrlist_t
*addrlist
, /* Address list */
2438 *addr
; /* Current address */
2439 unsigned ip
[4], /* Address value */
2440 mask
[4]; /* Netmask value */
2441 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2442 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2443 cupsd_location_t
*location
; /* Browse location */
2444 cups_file_t
*incfile
; /* Include file */
2445 char incname
[1024]; /* Include filename */
2446 struct group
*group
; /* Group */
2450 * Loop through each line in the file...
2455 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2458 * Decode the directive...
2461 if (!strcasecmp(line
, "Include") && value
)
2467 if (value
[0] == '/')
2468 strlcpy(incname
, value
, sizeof(incname
));
2470 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2472 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2473 cupsdLogMessage(CUPSD_LOG_ERROR
,
2474 "Unable to include config file \"%s\" - %s",
2475 incname
, strerror(errno
));
2478 read_configuration(incfile
);
2479 cupsFileClose(incfile
);
2482 else if (!strcasecmp(line
, "<Location") && value
)
2488 linenum
= read_location(fp
, value
, linenum
);
2492 else if (!strcasecmp(line
, "<Policy") && value
)
2498 linenum
= read_policy(fp
, value
, linenum
);
2502 else if (!strcasecmp(line
, "FatalErrors"))
2503 FatalErrors
= parse_fatal_errors(value
);
2504 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2506 JobRetryInterval
= atoi(value
);
2507 cupsdLogMessage(CUPSD_LOG_WARN
,
2508 "FaxRetryInterval is deprecated; use "
2509 "JobRetryInterval on line %d.", linenum
);
2511 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2513 JobRetryLimit
= atoi(value
);
2514 cupsdLogMessage(CUPSD_LOG_WARN
,
2515 "FaxRetryLimit is deprecated; use "
2516 "JobRetryLimit on line %d.", linenum
);
2518 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2520 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2521 #endif /* HAVE_SSL */
2525 * Add listening address(es) to the list...
2528 cupsd_listener_t
*lis
; /* New listeners array */
2532 * Get the address list...
2535 addrlist
= get_address(value
, IPP_PORT
);
2539 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2545 * Add each address...
2548 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2551 * See if this address is already present...
2554 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2556 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2557 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2558 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2563 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2564 cupsdLogMessage(CUPSD_LOG_WARN
,
2565 "Duplicate listen address \"%s\" ignored!", temp
);
2570 * Allocate another listener...
2574 Listeners
= cupsArrayNew(NULL
, NULL
);
2578 cupsdLogMessage(CUPSD_LOG_ERROR
,
2579 "Unable to allocate %s at line %d - %s.",
2580 line
, linenum
, strerror(errno
));
2584 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2586 cupsdLogMessage(CUPSD_LOG_ERROR
,
2587 "Unable to allocate %s at line %d - %s.",
2588 line
, linenum
, strerror(errno
));
2592 cupsArrayAdd(Listeners
, lis
);
2595 * Copy the current address and log it...
2598 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2602 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2603 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2604 #endif /* HAVE_SSL */
2606 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2609 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2610 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv6)", temp
,
2611 ntohs(lis
->address
.ipv6
.sin6_port
));
2613 #endif /* AF_INET6 */
2615 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2616 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2618 #endif /* AF_LOCAL */
2619 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv4)", temp
,
2620 ntohs(lis
->address
.ipv4
.sin_port
));
2622 if (!httpAddrLocalhost(&(lis
->address
)))
2625 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2626 RemotePort
= ntohs(lis
->address
.ipv6
.sin6_port
);
2628 #endif /* AF_INET6 */
2629 RemotePort
= ntohs(lis
->address
.ipv4
.sin_port
);
2637 httpAddrFreeList(addrlist
);
2639 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2642 * Add a browse address to the list...
2645 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2648 if (NumBrowsers
== 0)
2649 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2651 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2655 cupsdLogMessage(CUPSD_LOG_ERROR
,
2656 "Unable to allocate BrowseAddress at line %d - %s.",
2657 linenum
, strerror(errno
));
2662 dira
+= NumBrowsers
;
2664 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2666 if (!strcasecmp(value
, "@LOCAL"))
2669 * Send browse data to all local interfaces...
2672 strcpy(dira
->iface
, "*");
2675 else if (!strncasecmp(value
, "@IF(", 4))
2678 * Send browse data to the named interface...
2681 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2683 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2689 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2692 * Only IPv4 addresses are supported...
2695 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2696 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2701 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2702 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2704 cupsdLogMessage(CUPSD_LOG_INFO
,
2705 "Sending browsing info to %s:%d (IPv4)",
2706 temp
, ntohs(dira
->to
.ipv4
.sin_port
));
2711 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2714 httpAddrFreeList(addrlist
);
2717 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2720 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2723 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2726 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2727 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2728 cupsdAddLocation(location
);
2730 if (location
== NULL
)
2731 cupsdLogMessage(CUPSD_LOG_ERROR
,
2732 "Unable to initialize browse access control list!");
2733 else if (!strncasecmp(value
, "deny", 4))
2734 location
->order_type
= CUPSD_AUTH_ALLOW
;
2735 else if (!strncasecmp(value
, "allow", 5))
2736 location
->order_type
= CUPSD_AUTH_DENY
;
2738 cupsdLogMessage(CUPSD_LOG_ERROR
,
2739 "Unknown BrowseOrder value %s on line %d.",
2742 else if (!strcasecmp(line
, "BrowseProtocols") ||
2743 !strcasecmp(line
, "BrowseLocalProtocols") ||
2744 !strcasecmp(line
, "BrowseRemoteProtocols"))
2747 * "BrowseProtocols name [... name]"
2748 * "BrowseLocalProtocols name [... name]"
2749 * "BrowseRemoteProtocols name [... name]"
2752 int protocols
= parse_protocols(value
);
2756 cupsdLogMessage(CUPSD_LOG_ERROR
,
2757 "Unknown browse protocol \"%s\" on line %d.",
2762 if (strcasecmp(line
, "BrowseLocalProtocols"))
2763 BrowseRemoteProtocols
= protocols
;
2764 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2765 BrowseLocalProtocols
= protocols
;
2767 else if ((!strcasecmp(line
, "BrowseAllow") ||
2768 !strcasecmp(line
, "BrowseDeny")) && value
)
2771 * BrowseAllow [From] host/ip...
2772 * BrowseDeny [From] host/ip...
2775 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2776 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2777 cupsdAddLocation(location
);
2780 if (location
== NULL
)
2781 cupsdLogMessage(CUPSD_LOG_ERROR
,
2782 "Unable to initialize browse access control list!");
2785 if (!strncasecmp(value
, "from", 4))
2788 * Skip leading "from"...
2797 * Skip leading whitespace...
2800 while (isspace(*value
& 255))
2807 * Find the end of the value...
2810 for (valueptr
= value
;
2811 *valueptr
&& !isspace(*valueptr
& 255);
2814 while (isspace(*valueptr
& 255))
2818 * Figure out what form the allow/deny address takes:
2829 * nnn.nnn.nnn.nnn/mm
2830 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2833 if (!strcasecmp(value
, "all"))
2839 if (!strcasecmp(line
, "BrowseAllow"))
2840 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2842 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2844 else if (!strcasecmp(value
, "none"))
2850 if (!strcasecmp(line
, "BrowseAllow"))
2851 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2853 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2856 else if (value
[0] == '*' || value
[0] == '.' ||
2857 (!isdigit(value
[0] & 255) && value
[0] != '['))
2859 else if (value
[0] == '*' || value
[0] == '.' ||
2860 !isdigit(value
[0] & 255))
2861 #endif /* AF_INET6 */
2864 * Host or domain name...
2867 if (!strcasecmp(line
, "BrowseAllow"))
2868 cupsdAddNameMask(&(location
->allow
), value
);
2870 cupsdAddNameMask(&(location
->deny
), value
);
2875 * One of many IP address forms...
2878 if (!get_addr_and_mask(value
, ip
, mask
))
2880 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2885 if (!strcasecmp(line
, "BrowseAllow"))
2886 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2888 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2892 * Advance to next value...
2899 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2902 * BrowseRelay [from] source [to] destination
2906 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2908 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2912 cupsdLogMessage(CUPSD_LOG_ERROR
,
2913 "Unable to allocate BrowseRelay at line %d - %s.",
2914 linenum
, strerror(errno
));
2921 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2923 if (!strncasecmp(value
, "from ", 5))
2926 * Skip leading "from"...
2932 * Skip leading whitespace...
2935 while (isspace(*value
))
2940 * Find the end of the from value...
2943 for (valueptr
= value
;
2944 *valueptr
&& !isspace(*valueptr
& 255);
2947 while (isspace(*valueptr
& 255))
2951 * Figure out what form the from address takes:
2960 * nnn.nnn.nnn.nnn/mm
2961 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2965 if (value
[0] == '*' || value
[0] == '.' ||
2966 (!isdigit(value
[0] & 255) && value
[0] != '['))
2968 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2969 #endif /* AF_INET6 */
2972 * Host or domain name...
2975 if (!cupsdAddNameMask(&(relay
->from
), value
))
2977 cupsdLogMessage(CUPSD_LOG_ERROR
,
2978 "Unable to allocate BrowseRelay name at line %d - %s.",
2979 linenum
, strerror(errno
));
2986 * One of many IP address forms...
2989 if (!get_addr_and_mask(value
, ip
, mask
))
2991 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2996 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
2998 cupsdLogMessage(CUPSD_LOG_ERROR
,
2999 "Unable to allocate BrowseRelay IP at line %d - %s.",
3000 linenum
, strerror(errno
));
3006 * Get "to" address and port...
3009 if (!strncasecmp(valueptr
, "to ", 3))
3012 * Strip leading "to"...
3017 while (isspace(*valueptr
))
3021 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3024 * Only IPv4 addresses are supported...
3027 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3028 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3033 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3035 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3037 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3038 value
, temp
, ntohs(relay
->to
.ipv4
.sin_port
));
3044 cupsArrayDelete(relay
->from
);
3047 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3051 httpAddrFreeList(addrlist
);
3055 cupsArrayDelete(relay
->from
);
3058 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3062 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3065 * BrowsePoll address[:port]
3068 char *portname
; /* Port name */
3069 int portnum
; /* Port number */
3070 struct servent
*service
; /* Service */
3074 * Extract the port name from the address...
3077 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3081 if (isdigit(*portname
& 255))
3082 portnum
= atoi(portname
);
3083 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3084 portnum
= ntohs(service
->s_port
);
3087 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed!",
3093 portnum
= ippPort();
3096 * Add the poll entry...
3100 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3102 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3106 cupsdLogMessage(CUPSD_LOG_ERROR
,
3107 "Unable to allocate BrowsePoll at line %d - %s.",
3108 linenum
, strerror(errno
));
3116 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3118 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3119 pollp
->port
= portnum
;
3121 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3124 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3127 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3130 if (!strcasecmp(value
, "none"))
3131 DefaultAuthType
= CUPSD_AUTH_NONE
;
3132 else if (!strcasecmp(value
, "basic"))
3133 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3134 else if (!strcasecmp(value
, "digest"))
3135 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3136 else if (!strcasecmp(value
, "basicdigest"))
3137 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3139 else if (!strcasecmp(value
, "negotiate"))
3140 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3141 #endif /* HAVE_GSSAPI */
3144 cupsdLogMessage(CUPSD_LOG_WARN
,
3145 "Unknown default authorization type %s on line %d.",
3147 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3152 else if (!strcasecmp(line
, "DefaultEncryption"))
3155 * DefaultEncryption {Never,IfRequested,Required}
3158 if (!value
|| !strcasecmp(value
, "never"))
3159 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3160 else if (!strcasecmp(value
, "required"))
3161 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3162 else if (!strcasecmp(value
, "ifrequested"))
3163 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3166 cupsdLogMessage(CUPSD_LOG_WARN
,
3167 "Unknown default encryption %s on line %d.",
3169 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3173 #endif /* HAVE_SSL */
3174 else if (!strcasecmp(line
, "User") && value
)
3177 * User ID to run as...
3180 if (isdigit(value
[0] & 255))
3182 int uid
= atoi(value
);
3185 cupsdLogMessage(CUPSD_LOG_ERROR
,
3186 "Will not use User 0 as specified on line %d "
3187 "for security reasons. You must use a non-"
3188 "privileged account instead.",
3195 struct passwd
*p
; /* Password information */
3198 p
= getpwnam(value
);
3203 cupsdLogMessage(CUPSD_LOG_ERROR
,
3204 "Will not use User %s (UID=0) as specified on line "
3205 "%d for security reasons. You must use a non-"
3206 "privileged account instead.",
3212 cupsdLogMessage(CUPSD_LOG_ERROR
,
3213 "Unknown User \"%s\" on line %d, ignoring!",
3217 else if (!strcasecmp(line
, "Group") && value
)
3220 * Group ID to run as...
3223 if (isdigit(value
[0]))
3224 Group
= atoi(value
);
3228 group
= getgrnam(value
);
3231 Group
= group
->gr_gid
;
3233 cupsdLogMessage(CUPSD_LOG_ERROR
,
3234 "Unknown Group \"%s\" on line %d, ignoring!",
3238 else if (!strcasecmp(line
, "SystemGroup") && value
)
3241 * SystemGroup (admin) group(s)...
3244 if (!parse_groups(value
))
3245 cupsdLogMessage(CUPSD_LOG_ERROR
,
3246 "Unknown SystemGroup \"%s\" on line %d, ignoring!",
3249 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3252 * Do hostname lookups?
3255 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3256 !strcasecmp(value
, "false"))
3257 HostNameLookups
= 0;
3258 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3259 !strcasecmp(value
, "true"))
3260 HostNameLookups
= 1;
3261 else if (!strcasecmp(value
, "double"))
3262 HostNameLookups
= 2;
3264 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3267 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3270 * Amount of logging to do to access log...
3273 if (!strcasecmp(value
, "all"))
3274 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3275 else if (!strcasecmp(value
, "actions"))
3276 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3277 else if (!strcasecmp(value
, "config"))
3278 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3280 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3283 else if (!strcasecmp(line
, "LogLevel") && value
)
3286 * Amount of logging to do to error log...
3289 if (!strcasecmp(value
, "debug2"))
3290 LogLevel
= CUPSD_LOG_DEBUG2
;
3291 else if (!strcasecmp(value
, "debug"))
3292 LogLevel
= CUPSD_LOG_DEBUG
;
3293 else if (!strcasecmp(value
, "info"))
3294 LogLevel
= CUPSD_LOG_INFO
;
3295 else if (!strcasecmp(value
, "notice"))
3296 LogLevel
= CUPSD_LOG_NOTICE
;
3297 else if (!strcasecmp(value
, "warn"))
3298 LogLevel
= CUPSD_LOG_WARN
;
3299 else if (!strcasecmp(value
, "error"))
3300 LogLevel
= CUPSD_LOG_ERROR
;
3301 else if (!strcasecmp(value
, "crit"))
3302 LogLevel
= CUPSD_LOG_CRIT
;
3303 else if (!strcasecmp(value
, "alert"))
3304 LogLevel
= CUPSD_LOG_ALERT
;
3305 else if (!strcasecmp(value
, "emerg"))
3306 LogLevel
= CUPSD_LOG_EMERG
;
3307 else if (!strcasecmp(value
, "none"))
3308 LogLevel
= CUPSD_LOG_NONE
;
3310 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3313 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3316 * Amount of logging to do to error log...
3319 if (!strcasecmp(value
, "standard"))
3320 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3321 else if (!strcasecmp(value
, "usecs"))
3322 LogTimeFormat
= CUPSD_TIME_USECS
;
3324 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3327 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3330 * Format of printcap file?
3333 if (!strcasecmp(value
, "bsd"))
3334 PrintcapFormat
= PRINTCAP_BSD
;
3335 else if (!strcasecmp(value
, "plist"))
3336 PrintcapFormat
= PRINTCAP_PLIST
;
3337 else if (!strcasecmp(value
, "solaris"))
3338 PrintcapFormat
= PRINTCAP_SOLARIS
;
3340 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3343 else if (!strcasecmp(line
, "ServerTokens") && value
)
3346 * Set the string used for the Server header...
3349 struct utsname plat
; /* Platform info */
3354 if (!strcasecmp(value
, "ProductOnly"))
3355 cupsdSetString(&ServerHeader
, "CUPS");
3356 else if (!strcasecmp(value
, "Major"))
3357 cupsdSetString(&ServerHeader
, "CUPS/1");
3358 else if (!strcasecmp(value
, "Minor"))
3359 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3360 else if (!strcasecmp(value
, "Minimal"))
3361 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3362 else if (!strcasecmp(value
, "OS"))
3363 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3364 else if (!strcasecmp(value
, "Full"))
3365 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3367 else if (!strcasecmp(value
, "None"))
3368 cupsdClearString(&ServerHeader
);
3370 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3373 else if (!strcasecmp(line
, "PassEnv") && value
)
3376 * PassEnv variable [... variable]
3381 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3382 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3385 if (value
[valuelen
])
3387 value
[valuelen
] = '\0';
3391 cupsdSetEnv(value
, NULL
);
3393 for (value
+= valuelen
; *value
; value
++)
3394 if (!isspace(*value
) || *value
!= ',')
3398 else if (!strcasecmp(line
, "ServerAlias") && value
)
3401 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3403 cupsdAddAlias(ServerAlias
, value
);
3405 else if (!strcasecmp(line
, "SetEnv") && value
)
3408 * SetEnv variable value
3411 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3419 while (isspace(*valueptr
& 255))
3422 cupsdSetEnv(value
, valueptr
);
3425 cupsdLogMessage(CUPSD_LOG_ERROR
,
3426 "Missing value for SetEnv directive on line %d.",
3430 else if (!strcasecmp(line
, "SSLOptions"))
3433 * SSLOptions options
3436 if (!value
|| !strcasecmp(value
, "none"))
3437 SSLOptions
= CUPSD_SSL_NONE
;
3438 else if (!strcasecmp(value
, "noemptyfragments"))
3439 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3441 cupsdLogMessage(CUPSD_LOG_ERROR
,
3442 "Unknown value \"%s\" for SSLOptions directive on "
3443 "line %d.", value
, linenum
);
3445 #endif /* HAVE_SSL */
3449 * Find a simple variable in the list...
3452 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3453 if (!strcasecmp(line
, var
->name
))
3459 * Unknown directive! Output an error message and continue...
3463 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3466 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3473 case CUPSD_VARTYPE_INTEGER
:
3475 cupsdLogMessage(CUPSD_LOG_ERROR
,
3476 "Missing integer value for %s on line %d!",
3481 char *units
; /* Units */
3484 n
= strtol(value
, &units
, 0);
3486 if (units
&& *units
)
3488 if (tolower(units
[0] & 255) == 'g')
3489 n
*= 1024 * 1024 * 1024;
3490 else if (tolower(units
[0] & 255) == 'm')
3492 else if (tolower(units
[0] & 255) == 'k')
3494 else if (tolower(units
[0] & 255) == 't')
3499 cupsdLogMessage(CUPSD_LOG_ERROR
,
3500 "Bad negative integer value for %s on line %d!",
3503 *((int *)var
->ptr
) = n
;
3507 case CUPSD_VARTYPE_BOOLEAN
:
3509 cupsdLogMessage(CUPSD_LOG_ERROR
,
3510 "Missing boolean value for %s on line %d!",
3512 else if (!strcasecmp(value
, "true") ||
3513 !strcasecmp(value
, "on") ||
3514 !strcasecmp(value
, "enabled") ||
3515 !strcasecmp(value
, "yes") ||
3517 *((int *)var
->ptr
) = TRUE
;
3518 else if (!strcasecmp(value
, "false") ||
3519 !strcasecmp(value
, "off") ||
3520 !strcasecmp(value
, "disabled") ||
3521 !strcasecmp(value
, "no") ||
3522 !strcasecmp(value
, "0"))
3523 *((int *)var
->ptr
) = FALSE
;
3525 cupsdLogMessage(CUPSD_LOG_ERROR
,
3526 "Unknown boolean value %s on line %d.",
3530 case CUPSD_VARTYPE_PATHNAME
:
3533 cupsdLogMessage(CUPSD_LOG_ERROR
,
3534 "Missing pathname value for %s on line %d!",
3539 if (value
[0] == '/')
3540 strlcpy(temp
, value
, sizeof(temp
));
3542 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3544 if (access(temp
, 0))
3546 cupsdLogMessage(CUPSD_LOG_ERROR
,
3547 "File or directory for \"%s %s\" on line %d "
3548 "does not exist!", line
, value
, linenum
);
3552 case CUPSD_VARTYPE_STRING
:
3553 cupsdSetString((char **)var
->ptr
, value
);
3564 * 'read_location()' - Read a <Location path> definition.
3567 static int /* O - New line number or 0 on error */
3568 read_location(cups_file_t
*fp
, /* I - Configuration file */
3569 char *location
, /* I - Location name/path */
3570 int linenum
) /* I - Current line number */
3572 cupsd_location_t
*loc
, /* New location */
3573 *parent
; /* Parent location */
3574 char line
[HTTP_MAX_BUFFER
],
3576 *value
, /* Value for directive */
3577 *valptr
; /* Pointer into value */
3580 if ((parent
= cupsdNewLocation(location
)) == NULL
)
3583 cupsdAddLocation(parent
);
3585 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3588 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3591 * Decode the directive...
3594 if (!strcasecmp(line
, "</Location>"))
3596 else if (!strcasecmp(line
, "<Limit") ||
3597 !strcasecmp(line
, "<LimitExcept"))
3601 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3602 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3608 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3611 cupsdAddLocation(loc
);
3616 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3621 if (!strcmp(value
, "ALL"))
3622 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3623 else if (!strcmp(value
, "GET"))
3624 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3625 else if (!strcmp(value
, "HEAD"))
3626 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3627 else if (!strcmp(value
, "OPTIONS"))
3628 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3629 else if (!strcmp(value
, "POST"))
3630 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3631 else if (!strcmp(value
, "PUT"))
3632 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3633 else if (!strcmp(value
, "TRACE"))
3634 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3636 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d!",
3639 for (value
= valptr
; isspace(*value
& 255); value
++);
3642 if (!strcasecmp(line
, "<LimitExcept"))
3643 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3645 parent
->limit
&= ~loc
->limit
;
3647 else if (!strcasecmp(line
, "</Limit>") ||
3648 !strcasecmp(line
, "</LimitExcept>"))
3650 else if (!parse_aaa(loc
, line
, value
, linenum
))
3652 cupsdLogMessage(CUPSD_LOG_ERROR
,
3653 "Unknown Location directive %s on line %d.",
3655 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3660 cupsdLogMessage(CUPSD_LOG_ERROR
,
3661 "Unexpected end-of-file at line %d while reading location!",
3664 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3669 * 'read_policy()' - Read a <Policy name> definition.
3672 static int /* O - New line number or 0 on error */
3673 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3674 char *policy
, /* I - Location name/path */
3675 int linenum
) /* I - Current line number */
3677 int i
; /* Looping var */
3678 cupsd_policy_t
*pol
; /* Policy */
3679 cupsd_location_t
*op
; /* Policy operation */
3680 int num_ops
; /* Number of IPP operations */
3681 ipp_op_t ops
[100]; /* Operations */
3682 char line
[HTTP_MAX_BUFFER
],
3684 *value
, /* Value for directive */
3685 *valptr
; /* Pointer into value */
3689 * Create the policy...
3692 if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3696 * Read from the file...
3702 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3705 * Decode the directive...
3708 if (!strcasecmp(line
, "</Policy>"))
3711 cupsdLogMessage(CUPSD_LOG_WARN
,
3712 "Missing </Limit> before </Policy> on line %d!",
3715 set_policy_defaults(pol
);
3719 else if (!strcasecmp(line
, "<Limit") && !op
)
3723 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3724 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3731 * Scan for IPP operation names...
3738 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3743 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3745 if (!strcasecmp(value
, "All"))
3746 ops
[num_ops
] = IPP_ANY_OPERATION
;
3747 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3748 cupsdLogMessage(CUPSD_LOG_ERROR
,
3749 "Bad IPP operation name \"%s\" on line %d!",
3755 cupsdLogMessage(CUPSD_LOG_ERROR
,
3756 "Too many operations listed on line %d!",
3759 for (value
= valptr
; isspace(*value
& 255); value
++);
3763 * If none are specified, apply the policy to all operations...
3768 ops
[0] = IPP_ANY_OPERATION
;
3773 * Add a new policy for the first operation...
3776 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3778 else if (!strcasecmp(line
, "</Limit>") && op
)
3781 * Finish the current operation limit...
3787 * Copy the policy to the other operations...
3790 for (i
= 1; i
< num_ops
; i
++)
3791 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3796 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3797 !strcasecmp(line
, "JobPrivateValues") ||
3798 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3799 !strcasecmp(line
, "SubscriptionPrivateValues"))
3803 cupsdLogMessage(CUPSD_LOG_ERROR
,
3804 "%s directive must appear outside <Limit>...</Limit> "
3805 "on line %d.", line
, linenum
);
3806 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3812 * Pull out whitespace-delimited values...
3818 * Find the end of the current value...
3821 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3827 * Save it appropriately...
3830 if (!strcasecmp(line
, "JobPrivateAccess"))
3833 * JobPrivateAccess {all|default|user/group list|@@ACL}
3836 if (!strcasecmp(value
, "default"))
3838 cupsdAddString(&(pol
->job_access
), "@OWNER");
3839 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3842 cupsdAddString(&(pol
->job_access
), value
);
3844 else if (!strcasecmp(line
, "JobPrivateValues"))
3847 * JobPrivateValues {all|none|default|attribute list}
3850 if (!strcasecmp(value
, "default"))
3852 cupsdAddString(&(pol
->job_attrs
), "job-name");
3853 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3854 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3857 cupsdAddString(&(pol
->job_attrs
), value
);
3859 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3862 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3865 if (!strcasecmp(value
, "default"))
3867 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3868 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3871 cupsdAddString(&(pol
->sub_access
), value
);
3873 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3876 * SubscriptionPrivateValues {all|none|default|attribute list}
3879 if (!strcasecmp(value
, "default"))
3881 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3882 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3883 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3884 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3885 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3888 cupsdAddString(&(pol
->sub_attrs
), value
);
3892 * Find the next string on the line...
3895 for (value
= valptr
; isspace(*value
& 255); value
++);
3901 cupsdLogMessage(CUPSD_LOG_ERROR
,
3902 "Missing <Limit ops> directive before %s on line %d.",
3904 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3907 else if (!parse_aaa(op
, line
, value
, linenum
))
3910 cupsdLogMessage(CUPSD_LOG_ERROR
,
3911 "Unknown Policy Limit directive %s on line %d.",
3914 cupsdLogMessage(CUPSD_LOG_ERROR
,
3915 "Unknown Policy directive %s on line %d.",
3918 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3923 cupsdLogMessage(CUPSD_LOG_ERROR
,
3924 "Unexpected end-of-file at line %d while reading policy \"%s\"!",
3927 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3932 * 'set_policy_defaults()' - Set default policy values as needed.
3936 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3938 cupsd_location_t
*op
; /* Policy operation */
3942 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3943 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3944 * upgrades do not introduce new security issues...
3947 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3948 op
->op
== IPP_ANY_OPERATION
)
3950 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3951 op
->op
!= IPP_ANY_OPERATION
)
3954 * Add a new limit for Validate-Job using the Print-Job limit as a
3958 cupsdLogMessage(CUPSD_LOG_WARN
,
3959 "No limit for Validate-Job defined in policy %s "
3960 "- using Print-Job's policy.", pol
->name
);
3962 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3965 cupsdLogMessage(CUPSD_LOG_WARN
,
3966 "No limit for Validate-Job defined in policy %s "
3967 "and no suitable template found.", pol
->name
);
3970 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3971 op
->op
== IPP_ANY_OPERATION
)
3973 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3974 op
->op
!= IPP_ANY_OPERATION
)
3977 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3981 cupsdLogMessage(CUPSD_LOG_WARN
,
3982 "No limit for Cancel-Jobs defined in policy %s "
3983 "- using Pause-Printer's policy.", pol
->name
);
3985 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3988 cupsdLogMessage(CUPSD_LOG_WARN
,
3989 "No limit for Cancel-Jobs defined in policy %s "
3990 "and no suitable template found.", pol
->name
);
3993 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3994 op
->op
== IPP_ANY_OPERATION
)
3996 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3997 op
->op
!= IPP_ANY_OPERATION
)
4000 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4004 cupsdLogMessage(CUPSD_LOG_WARN
,
4005 "No limit for Cancel-My-Jobs defined in policy %s "
4006 "- using Send-Document's policy.", pol
->name
);
4008 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4011 cupsdLogMessage(CUPSD_LOG_WARN
,
4012 "No limit for Cancel-My-Jobs defined in policy %s "
4013 "and no suitable template found.", pol
->name
);
4016 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
4017 op
->op
== IPP_ANY_OPERATION
)
4019 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4020 op
->op
!= IPP_ANY_OPERATION
)
4023 * Add a new limit for Close-Job using the Send-Document limit as a
4027 cupsdLogMessage(CUPSD_LOG_WARN
,
4028 "No limit for Close-Job defined in policy %s "
4029 "- using Send-Document's policy.", pol
->name
);
4031 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4034 cupsdLogMessage(CUPSD_LOG_WARN
,
4035 "No limit for Close-Job defined in policy %s "
4036 "and no suitable template found.", pol
->name
);
4039 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4040 op
->op
== IPP_ANY_OPERATION
)
4042 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4043 op
->op
!= IPP_ANY_OPERATION
)
4046 * Add a new limit for CUPS-Get-Document using the Send-Document
4047 * limit as a template...
4050 cupsdLogMessage(CUPSD_LOG_WARN
,
4051 "No limit for CUPS-Get-Document defined in policy %s "
4052 "- using Send-Document's policy.", pol
->name
);
4054 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4057 cupsdLogMessage(CUPSD_LOG_WARN
,
4058 "No limit for CUPS-Get-Document defined in policy %s "
4059 "and no suitable template found.", pol
->name
);
4063 * Verify we have JobPrivateAccess, JobPrivateValues,
4064 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4067 if (!pol
->job_access
)
4069 cupsdLogMessage(CUPSD_LOG_WARN
,
4070 "No JobPrivateAccess defined in policy %s "
4071 "- using defaults.", pol
->name
);
4072 cupsdAddString(&(pol
->job_access
), "@OWNER");
4073 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4076 if (!pol
->job_attrs
)
4078 cupsdLogMessage(CUPSD_LOG_WARN
,
4079 "No JobPrivateValues defined in policy %s "
4080 "- using defaults.", pol
->name
);
4081 cupsdAddString(&(pol
->job_attrs
), "job-name");
4082 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4083 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4086 if (!pol
->sub_access
)
4088 cupsdLogMessage(CUPSD_LOG_WARN
,
4089 "No SubscriptionPrivateAccess defined in policy %s "
4090 "- using defaults.", pol
->name
);
4091 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4092 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4095 if (!pol
->sub_attrs
)
4097 cupsdLogMessage(CUPSD_LOG_WARN
,
4098 "No SubscriptionPrivateValues defined in policy %s "
4099 "- using defaults.", pol
->name
);
4100 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4101 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4102 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4103 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4104 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4110 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".