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
},
88 { "BrowseDNSSDRegType", &DNSSDRegType
, CUPSD_VARTYPE_STRING
},
89 #endif /* HAVE_DNSSD */
90 { "BrowseInterval", &BrowseInterval
, CUPSD_VARTYPE_INTEGER
},
92 { "BrowseLDAPBindDN", &BrowseLDAPBindDN
, CUPSD_VARTYPE_STRING
},
94 { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile
, CUPSD_VARTYPE_PATHNAME
},
95 # endif /* HAVE_LDAP_SSL */
96 { "BrowseLDAPDN", &BrowseLDAPDN
, CUPSD_VARTYPE_STRING
},
97 { "BrowseLDAPPassword", &BrowseLDAPPassword
, CUPSD_VARTYPE_STRING
},
98 { "BrowseLDAPServer", &BrowseLDAPServer
, CUPSD_VARTYPE_STRING
},
99 #endif /* HAVE_LDAP */
100 { "BrowseLocalOptions", &BrowseLocalOptions
, CUPSD_VARTYPE_STRING
},
101 { "BrowsePort", &BrowsePort
, CUPSD_VARTYPE_INTEGER
},
102 { "BrowseRemoteOptions", &BrowseRemoteOptions
, CUPSD_VARTYPE_STRING
},
103 { "BrowseShortNames", &BrowseShortNames
, CUPSD_VARTYPE_BOOLEAN
},
104 { "BrowseTimeout", &BrowseTimeout
, CUPSD_VARTYPE_INTEGER
},
105 { "BrowseWebIF", &BrowseWebIF
, CUPSD_VARTYPE_BOOLEAN
},
106 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
107 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
108 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
109 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
110 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
111 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
112 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
113 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
114 { "DefaultPaperSize", &DefaultPaperSize
, CUPSD_VARTYPE_STRING
},
115 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
116 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
117 { "DirtyCleanInterval", &DirtyCleanInterval
, CUPSD_VARTYPE_INTEGER
},
118 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
119 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
120 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
121 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
122 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
123 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
124 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
125 { "HideImplicitMembers", &HideImplicitMembers
, CUPSD_VARTYPE_BOOLEAN
},
126 { "ImplicitClasses", &ImplicitClasses
, CUPSD_VARTYPE_BOOLEAN
},
127 { "ImplicitAnyClasses", &ImplicitAnyClasses
, CUPSD_VARTYPE_BOOLEAN
},
128 { "JobKillDelay", &JobKillDelay
, CUPSD_VARTYPE_INTEGER
},
129 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
130 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_INTEGER
},
131 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_INTEGER
},
132 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
134 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_INTEGER
},
135 #endif /* HAVE_LAUNCHD */
136 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
137 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
138 { "LogDebugHistory", &LogDebugHistory
, CUPSD_VARTYPE_INTEGER
},
139 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
140 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
141 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
142 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
143 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
144 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
145 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
146 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
147 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
148 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
149 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
150 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
151 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
152 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
153 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
154 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
155 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
156 { "MultipleOperationTimeout", &MultipleOperationTimeout
, CUPSD_VARTYPE_INTEGER
},
157 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
158 { "PageLogFormat", &PageLogFormat
, CUPSD_VARTYPE_STRING
},
159 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_BOOLEAN
},
160 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_BOOLEAN
},
161 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
162 { "PrintcapGUI", &PrintcapGUI
, CUPSD_VARTYPE_STRING
},
163 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_INTEGER
},
164 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
165 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
166 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
167 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_INTEGER
},
168 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
169 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
171 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
172 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
173 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
174 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
175 #endif /* HAVE_SSL */
176 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
177 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
178 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
179 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
180 #ifdef HAVE_AUTHORIZATION_H
181 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
182 #endif /* HAVE_AUTHORIZATION_H */
183 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
},
184 { "Timeout", &Timeout
, CUPSD_VARTYPE_INTEGER
},
185 { "UseNetworkDefault", &UseNetworkDefault
, CUPSD_VARTYPE_BOOLEAN
},
186 { "WebInterface", &WebInterface
, CUPSD_VARTYPE_BOOLEAN
}
188 #define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
191 static const unsigned ones
[4] =
193 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
195 static const unsigned zeros
[4] =
197 0x00000000, 0x00000000, 0x00000000, 0x00000000
205 static http_addrlist_t
*get_address(const char *value
, int defport
);
206 static int get_addr_and_mask(const char *value
, unsigned *ip
,
208 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
209 char *value
, int linenum
);
210 static int parse_fatal_errors(const char *s
);
211 static int parse_groups(const char *s
);
212 static int parse_protocols(const char *s
);
213 static int read_configuration(cups_file_t
*fp
);
214 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
215 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
216 static void set_policy_defaults(cupsd_policy_t
*pol
);
220 * 'cupsdAddAlias()' - Add a host alias.
224 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
225 const char *name
) /* I - Name to add */
227 cupsd_alias_t
*a
; /* New alias */
228 size_t namelen
; /* Length of name */
231 namelen
= strlen(name
);
233 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
236 a
->namelen
= namelen
;
237 strcpy(a
->name
, name
); /* OK since a->name is allocated */
239 cupsArrayAdd(aliases
, a
);
244 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
247 int /* O - 0 on success, -1 on error, 1 on warning */
248 cupsdCheckPermissions(
249 const char *filename
, /* I - File/directory name */
250 const char *suffix
, /* I - Additional file/directory name */
251 int mode
, /* I - Permissions */
252 int user
, /* I - Owner */
253 int group
, /* I - Group */
254 int is_dir
, /* I - 1 = directory, 0 = file */
255 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
257 int dir_created
= 0; /* Did we create a directory? */
258 char pathname
[1024]; /* File name with prefix */
259 struct stat fileinfo
; /* Stat buffer */
260 int is_symlink
; /* Is "filename" a symlink? */
264 * Prepend the given root to the filename before testing it...
269 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
274 * See if we can stat the file/directory...
277 if (lstat(filename
, &fileinfo
))
279 if (errno
== ENOENT
&& create_dir
)
282 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
285 if (mkdir(filename
, mode
))
288 cupsdLogMessage(CUPSD_LOG_ERROR
,
289 "Unable to create directory \"%s\" - %s", filename
,
292 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
299 fileinfo
.st_mode
= mode
| S_IFDIR
;
302 return (create_dir
? -1 : 1);
305 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
307 if (stat(filename
, &fileinfo
))
309 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
310 filename
, strerror(errno
));
316 * Make sure it's a regular file or a directory as needed...
319 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
321 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file.", filename
);
325 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
328 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory.", filename
);
330 syslog(LOG_ERR
, "\"%s\" is not a directory.", filename
);
336 * If the filename is a symlink, do not change permissions (STR #2937)...
343 * Fix owner, group, and mode as needed...
346 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
349 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
352 if (chown(filename
, user
, group
) && !getuid())
355 cupsdLogMessage(CUPSD_LOG_ERROR
,
356 "Unable to change ownership of \"%s\" - %s", filename
,
359 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
366 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
369 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
372 if (chmod(filename
, mode
))
375 cupsdLogMessage(CUPSD_LOG_ERROR
,
376 "Unable to change permissions of \"%s\" - %s", filename
,
379 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
387 * Everything is OK...
395 * 'cupsdFreeAliases()' - Free all of the alias entries.
399 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
401 cupsd_alias_t
*a
; /* Current alias */
404 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
406 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
409 cupsArrayDelete(aliases
);
414 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
417 int /* O - 1 on success, 0 otherwise */
418 cupsdReadConfiguration(void)
420 int i
; /* Looping var */
421 cups_file_t
*fp
; /* Configuration file */
422 int status
; /* Return status */
423 char temp
[1024], /* Temporary buffer */
424 mimedir
[1024], /* MIME directory */
425 *slash
; /* Directory separator */
426 cups_lang_t
*language
; /* Language */
427 struct passwd
*user
; /* Default user */
428 struct group
*group
; /* Default group */
429 char *old_serverroot
, /* Old ServerRoot */
430 *old_requestroot
; /* Old RequestRoot */
431 int old_remote_port
; /* Old RemotePort */
432 const char *tmpdir
; /* TMPDIR environment variable */
433 struct stat tmpinfo
; /* Temporary directory info */
434 cupsd_policy_t
*p
; /* Policy */
438 * Save the old root paths...
441 old_serverroot
= NULL
;
442 cupsdSetString(&old_serverroot
, ServerRoot
);
443 old_requestroot
= NULL
;
444 cupsdSetString(&old_requestroot
, RequestRoot
);
447 * Reset the server configuration data...
450 cupsdDeleteAllLocations();
469 for (i
= 0; i
< NumRelays
; i
++)
470 cupsArrayDelete(Relays
[i
].from
);
477 cupsdDeleteAllListeners();
479 old_remote_port
= RemotePort
;
486 cupsdFreeAliases(ServerAlias
);
489 cupsdClearString(&ServerName
);
490 cupsdClearString(&ServerAdmin
);
491 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
492 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
493 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
494 cupsdSetString(&DataDir
, CUPS_DATADIR
);
495 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
496 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
497 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
498 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
499 cupsdSetString(&PageLogFormat
,
500 "%p %u %j %T %P %C %{job-billing} "
501 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
502 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
503 cupsdSetString(&PrintcapGUI
, "/usr/bin/glpoptions");
504 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
505 cupsdSetString(&RemoteRoot
, "remroot");
506 cupsdSetString(&ServerHeader
, "CUPS/1.4");
507 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
509 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
510 PrintcapFormat
= PRINTCAP_SOLARIS
;
511 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
512 "/Library/Preferences/org.cups.printers.plist"))
513 PrintcapFormat
= PRINTCAP_PLIST
;
515 PrintcapFormat
= PRINTCAP_BSD
;
517 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
518 if ((slash
= strrchr(temp
, '/')) != NULL
)
521 cupsdSetString(&ServerRoot
, temp
);
523 cupsdClearString(&Classification
);
524 ClassifyOverride
= 0;
528 cupsdSetString(&ServerCertificate
, "/Library/Keychains/System.keychain");
530 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
531 cupsdSetString(&ServerKey
, "ssl/server.key");
532 # endif /* HAVE_CDSASSL */
533 #endif /* HAVE_SSL */
535 language
= cupsLangDefault();
537 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
538 cupsdSetString(&DefaultLanguage
, "en");
540 cupsdSetString(&DefaultLanguage
, language
->language
);
542 cupsdClearString(&DefaultPaperSize
);
544 cupsdSetString(&RIPCache
, "8m");
546 cupsdSetString(&TempDir
, NULL
);
549 * Find the default user...
552 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
557 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
558 * complement number...)
567 * Find the default group...
570 group
= getgrnam(CUPS_DEFAULT_GROUP
);
574 Group
= group
->gr_gid
;
578 * Fallback to group "nobody"...
581 group
= getgrnam("nobody");
585 Group
= group
->gr_gid
;
589 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
590 * complement number...)
601 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
602 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
603 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
604 DefaultAuthType
= CUPSD_AUTH_BASIC
;
606 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
607 SSLOptions
= CUPSD_SSL_NONE
;
608 #endif /* HAVE_SSL */
609 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
610 JobKillDelay
= DEFAULT_TIMEOUT
;
612 JobRetryInterval
= 300;
617 HostNameLookups
= FALSE
;
618 ImplicitClasses
= CUPS_DEFAULT_IMPLICIT_CLASSES
;
619 ImplicitAnyClasses
= FALSE
;
620 HideImplicitMembers
= TRUE
;
622 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
623 ListenBackLog
= SOMAXCONN
;
624 LogDebugHistory
= 200;
625 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
626 LogLevel
= CUPSD_LOG_WARN
;
627 LogTimeFormat
= CUPSD_TIME_STANDARD
;
629 MaxClientsPerHost
= 0;
630 MaxLogSize
= 1024 * 1024;
632 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
633 ReloadTimeout
= DEFAULT_KEEPALIVE
;
634 RootCertDuration
= 300;
635 Timeout
= DEFAULT_TIMEOUT
;
637 WebInterface
= CUPS_DEFAULT_WEBIF
;
639 BrowseInterval
= DEFAULT_INTERVAL
;
640 BrowsePort
= ippPort();
641 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
642 BrowseRemoteProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS
);
643 BrowseShortNames
= CUPS_DEFAULT_BROWSE_SHORT_NAMES
;
644 BrowseTimeout
= DEFAULT_TIMEOUT
;
646 Browsing
= CUPS_DEFAULT_BROWSING
;
647 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
650 cupsdSetString(&DNSSDRegType
, "_ipp._tcp,_cups");
651 #endif /* HAVE_DNSSD */
653 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
654 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
656 cupsdClearString(&BrowseLocalOptions
);
657 cupsdClearString(&BrowseRemoteOptions
);
659 cupsdSetString(&ErrorPolicy
, "stop-printer");
662 cupsdClearString(&BrowseLDAPBindDN
);
663 cupsdClearString(&BrowseLDAPDN
);
664 cupsdClearString(&BrowseLDAPPassword
);
665 cupsdClearString(&BrowseLDAPServer
);
666 # ifdef HAVE_LDAP_SSL
667 cupsdClearString(&BrowseLDAPCACertFile
);
668 # endif /* HAVE_LDAP_SSL */
669 #endif /* HAVE_LDAP */
671 JobHistory
= DEFAULT_HISTORY
;
672 JobFiles
= DEFAULT_FILES
;
677 MaxJobsPerPrinter
= 0;
678 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
680 cupsdDeleteAllPolicies();
681 cupsdClearString(&DefaultPolicy
);
683 #ifdef HAVE_AUTHORIZATION_H
684 cupsdClearString(&SystemGroupAuthKey
);
685 #endif /* HAVE_AUTHORIZATION_H */
687 MaxSubscriptions
= 100;
688 MaxSubscriptionsPerJob
= 0;
689 MaxSubscriptionsPerPrinter
= 0;
690 MaxSubscriptionsPerUser
= 0;
691 DefaultLeaseDuration
= 86400;
692 MaxLeaseDuration
= 0;
695 LaunchdTimeout
= DEFAULT_TIMEOUT
+ 10;
696 #endif /* HAVE_LAUNCHD */
699 * Setup environment variables...
705 * Read the configuration file...
708 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
711 status
= read_configuration(fp
);
720 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
721 RemotePort
? "enabled" : "disabled");
724 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
727 * See if the ServerName is an IP address...
733 ServerAlias
= cupsArrayNew(NULL
, NULL
);
735 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
739 if (gethostname(temp
, sizeof(temp
)))
741 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
743 strlcpy(temp
, "localhost", sizeof(temp
));
746 cupsdSetString(&ServerName
, temp
);
749 ServerAlias
= cupsArrayNew(NULL
, NULL
);
751 cupsdAddAlias(ServerAlias
, temp
);
752 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
754 if (HostNameLookups
|| RemotePort
)
756 struct hostent
*host
; /* Host entry to get FQDN */
758 if ((host
= gethostbyname(temp
)) != NULL
)
760 if (strcasecmp(temp
, host
->h_name
))
762 cupsdSetString(&ServerName
, host
->h_name
);
763 cupsdAddAlias(ServerAlias
, host
->h_name
);
764 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
770 for (i
= 0; host
->h_aliases
[i
]; i
++)
771 if (strcasecmp(temp
, host
->h_aliases
[i
]))
773 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
774 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
782 * Make sure we have the base hostname added as an alias, too!
785 if ((slash
= strchr(temp
, '.')) != NULL
)
788 cupsdAddAlias(ServerAlias
, temp
);
789 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
793 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
795 ServerNameIsIP
= !*slash
;
798 * Make sure ServerAdmin is initialized...
802 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
805 * Use the default system group if none was supplied in cupsd.conf...
808 if (NumSystemGroups
== 0)
810 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
813 * Find the group associated with GID 0...
820 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
822 cupsdSetString(&SystemGroups
[0], "unknown");
824 SystemGroupIDs
[0] = 0;
830 * Get the access control list for browsing...
833 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
836 * Open the system log for cupsd if necessary...
840 if (!strcmp(AccessLog
, "syslog") ||
841 !strcmp(ErrorLog
, "syslog") ||
842 !strcmp(PageLog
, "syslog"))
843 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
844 #endif /* HAVE_VSYSLOG */
847 * Log the configuration file that was used...
850 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
854 * Validate the Group and SystemGroup settings - they cannot be the same,
855 * otherwise the CGI programs will be able to authenticate as root without
861 for (i
= 0; i
< NumSystemGroups
; i
++)
862 if (Group
== SystemGroupIDs
[i
])
865 if (i
< NumSystemGroups
)
868 * Log the error and reset the group to a safe value...
871 cupsdLogMessage(CUPSD_LOG_NOTICE
,
872 "Group and SystemGroup cannot use the same groups.");
873 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
875 group
= getgrnam("nobody");
879 Group
= group
->gr_gid
;
883 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
884 * complement number...)
893 * Check that we have at least one listen/port line; if not, report this
894 * as an error and exit!
897 if (cupsArrayCount(Listeners
) == 0)
903 cupsdLogMessage(CUPSD_LOG_EMERG
,
904 "No valid Listen or Port lines were found in the "
905 "configuration file.");
911 cupsdEndProcess(getpid(), 0);
915 * Set the default locale using the language and charset...
918 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
921 * Update all relative filenames to include the full path from ServerRoot...
924 if (DocumentRoot
[0] != '/')
925 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
927 if (RequestRoot
[0] != '/')
928 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
930 if (ServerBin
[0] != '/')
931 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
933 if (StateDir
[0] != '/')
934 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
936 if (CacheDir
[0] != '/')
937 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
940 if (ServerCertificate
[0] != '/')
941 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
943 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
944 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
946 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
949 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
950 if (ServerKey
[0] != '/')
951 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
953 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
954 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
955 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
957 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
958 #endif /* HAVE_SSL */
961 * Make sure that directories and config files are owned and
962 * writable by the user and group in the cupsd.conf file...
965 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
967 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
969 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
971 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
973 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
975 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
976 SystemGroupIDs
[0], 1, 1) < 0 ||
977 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
979 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
981 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
983 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
985 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
987 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
989 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
991 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
995 * Update TempDir to the default if it hasn't been set already...
1000 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1003 * TMPDIR is defined, see if it is OK for us to use...
1006 if (stat(tmpdir
, &tmpinfo
))
1007 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1008 tmpdir
, strerror(errno
));
1009 else if (!S_ISDIR(tmpinfo
.st_mode
))
1010 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1012 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1013 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1014 !(tmpinfo
.st_mode
& S_IWOTH
))
1015 cupsdLogMessage(CUPSD_LOG_ERROR
,
1016 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1018 cupsdSetString(&TempDir
, tmpdir
);
1023 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1025 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1030 * Make sure the temporary directory has the right permissions...
1033 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1037 * Update ownership and permissions if the CUPS temp directory
1038 * is under the spool directory or does not exist...
1041 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1042 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1047 * Update environment variables...
1053 * Update default paper size setting as needed...
1056 if (!DefaultPaperSize
)
1058 #ifdef HAVE_LIBPAPER
1059 char *paper_result
; /* Paper size name from libpaper */
1061 if ((paper_result
= systempapername()) != NULL
)
1062 cupsdSetString(&DefaultPaperSize
, paper_result
);
1064 #endif /* HAVE_LIBPAPER */
1065 if (!DefaultLanguage
||
1066 !strcasecmp(DefaultLanguage
, "C") ||
1067 !strcasecmp(DefaultLanguage
, "POSIX") ||
1068 !strcasecmp(DefaultLanguage
, "en") ||
1069 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1070 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1071 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1072 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1075 * These are the only locales that will default to "letter" size...
1078 cupsdSetString(&DefaultPaperSize
, "Letter");
1081 cupsdSetString(&DefaultPaperSize
, "A4");
1085 * Update classification setting as needed...
1088 if (Classification
&& !strcasecmp(Classification
, "none"))
1089 cupsdClearString(&Classification
);
1092 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1095 * Check the MaxClients setting, and then allocate memory for it...
1098 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1101 cupsdLogMessage(CUPSD_LOG_INFO
,
1102 "MaxClients limited to 1/3 (%d) of the file descriptor "
1104 MaxFDs
/ 3, MaxFDs
);
1106 MaxClients
= MaxFDs
/ 3;
1109 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1113 * Check the MaxActiveJobs setting; limit to 1/3 the available
1114 * file descriptors, since we need a pipe for each job...
1117 if (MaxActiveJobs
> (MaxFDs
/ 3))
1118 MaxActiveJobs
= MaxFDs
/ 3;
1121 * Update the MaxClientsPerHost value, as needed...
1124 if (MaxClientsPerHost
<= 0)
1125 MaxClientsPerHost
= MaxClients
;
1127 if (MaxClientsPerHost
> MaxClients
)
1128 MaxClientsPerHost
= MaxClients
;
1130 cupsdLogMessage(CUPSD_LOG_INFO
,
1131 "Allowing up to %d client connections per host.",
1135 * Make sure that BrowseTimeout is at least twice the interval...
1138 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1140 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d.",
1144 BrowseTimeout
= BrowseInterval
* 2;
1146 BrowseTimeout
= DEFAULT_TIMEOUT
;
1148 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d.",
1153 * Update the default policy, as needed...
1157 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1159 DefaultPolicyPtr
= NULL
;
1161 if (!DefaultPolicyPtr
)
1163 cupsd_location_t
*po
; /* New policy operation */
1167 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1170 cupsdSetString(&DefaultPolicy
, "default");
1172 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1173 cupsdLogMessage(CUPSD_LOG_INFO
,
1174 "Using policy \"default\" as the default.");
1177 cupsdLogMessage(CUPSD_LOG_INFO
,
1178 "Creating CUPS default administrative policy:");
1180 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1182 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1184 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1185 cupsdAddString(&(p
->job_access
), "@OWNER");
1186 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1188 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1189 cupsdAddString(&(p
->job_attrs
), "job-name");
1190 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1191 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1193 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1194 cupsdAddString(&(p
->sub_access
), "@OWNER");
1195 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1197 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1198 cupsdAddString(&(p
->job_attrs
), "notify-events");
1199 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1200 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1201 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1202 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1204 cupsdLogMessage(CUPSD_LOG_INFO
,
1205 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1206 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1208 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1209 po
->order_type
= CUPSD_AUTH_ALLOW
;
1211 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1212 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1213 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1215 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1217 cupsdLogMessage(CUPSD_LOG_INFO
,
1218 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1219 "Release-Job Restart-Job Purge-Jobs "
1220 "Set-Job-Attributes Create-Job-Subscription "
1221 "Renew-Subscription Cancel-Subscription "
1222 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1223 "Suspend-Current-Job Resume-Job "
1224 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1225 "CUPS-Authenticate-Job CUPS-Get-Document>");
1226 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1228 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1229 po
->order_type
= CUPSD_AUTH_ALLOW
;
1230 po
->level
= CUPSD_AUTH_USER
;
1232 cupsdAddName(po
, "@OWNER");
1233 cupsdAddName(po
, "@SYSTEM");
1234 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1236 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1237 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1238 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1239 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1240 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1241 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1242 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1243 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1244 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1245 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1246 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1247 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1248 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1249 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1250 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1251 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1252 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1253 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1254 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1255 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1257 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1259 cupsdLogMessage(CUPSD_LOG_INFO
,
1260 "<Limit Pause-Printer Resume-Printer "
1261 "Set-Printer-Attributes Enable-Printer "
1262 "Disable-Printer Pause-Printer-After-Current-Job "
1263 "Hold-New-Jobs Release-Held-New-Jobs "
1264 "Deactivate-Printer Activate-Printer Restart-Printer "
1265 "Shutdown-Printer Startup-Printer Promote-Job "
1266 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1267 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1268 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1269 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1270 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1272 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1273 po
->order_type
= CUPSD_AUTH_ALLOW
;
1274 po
->type
= CUPSD_AUTH_DEFAULT
;
1275 po
->level
= CUPSD_AUTH_USER
;
1277 cupsdAddName(po
, "@SYSTEM");
1278 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1280 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1281 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1282 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1283 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1284 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1285 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1286 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1287 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1288 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1289 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1290 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1291 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1292 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1293 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1294 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1295 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1296 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1297 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1298 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1299 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1300 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1301 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1303 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1305 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1306 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1308 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1309 po
->order_type
= CUPSD_AUTH_ALLOW
;
1311 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1312 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1316 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1317 cupsArrayCount(Policies
));
1318 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1320 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1321 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1322 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1325 * If we are doing a full reload or the server root has changed, flush
1326 * the jobs, printers, etc. and start from scratch...
1329 if (NeedReload
== RELOAD_ALL
||
1330 old_remote_port
!= RemotePort
||
1331 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1332 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1334 mime_type_t
*type
; /* Current type */
1335 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1336 /* MIME type name */
1339 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1342 * Free all memory...
1345 cupsdDeleteAllSubscriptions();
1347 cupsdDeleteAllPrinters();
1349 DefaultPrinter
= NULL
;
1351 if (MimeDatabase
!= NULL
)
1352 mimeDelete(MimeDatabase
);
1356 for (i
= 0; i
< NumMimeTypes
; i
++)
1357 _cupsStrFree(MimeTypes
[i
]);
1363 * Read the MIME type and conversion database...
1366 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1367 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1369 MimeDatabase
= mimeLoadTypes(NULL
, mimedir
);
1370 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1371 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1372 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1376 cupsdLogMessage(CUPSD_LOG_EMERG
,
1377 "Unable to load MIME database from \"%s\" or \"%s\".",
1378 mimedir
, ServerRoot
);
1379 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1383 cupsdLogMessage(CUPSD_LOG_INFO
,
1384 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1385 "%d filters...", mimedir
, ServerRoot
,
1386 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1389 * Create a list of MIME types for the document-format-supported
1393 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1394 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1397 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1399 cupsdLogMessage(CUPSD_LOG_ERROR
,
1400 "Unable to allocate memory for %d MIME types.",
1406 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1408 i
++, type
= mimeNextType(MimeDatabase
))
1410 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1412 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1415 if (i
< NumMimeTypes
)
1416 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1419 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1421 mime_filter_t
*filter
; /* Current filter */
1424 for (type
= mimeFirstType(MimeDatabase
);
1426 type
= mimeNextType(MimeDatabase
))
1427 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1428 type
->super
, type
->type
);
1430 for (filter
= mimeFirstFilter(MimeDatabase
);
1432 filter
= mimeNextFilter(MimeDatabase
))
1433 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1434 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1435 filter
->src
->super
, filter
->src
->type
,
1436 filter
->dst
->super
, filter
->dst
->type
,
1437 filter
->cost
, filter
->filter
);
1444 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1445 cupsdLoadBanners(temp
);
1448 * Load printers and classes...
1451 cupsdLoadAllPrinters();
1452 cupsdLoadAllClasses();
1453 cupsdLoadRemoteCache();
1455 cupsdCreateCommonData();
1458 * Update the printcap file as needed...
1461 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1462 cupsdWritePrintcap();
1465 * Load queued jobs...
1471 * Load subscriptions...
1474 cupsdLoadAllSubscriptions();
1476 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1481 * Not a full reload, so recreate the common printer attributes...
1484 cupsdCreateCommonData();
1487 * Update all printers as needed...
1490 cupsdUpdatePrinters();
1491 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1493 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1497 * Reset the reload state...
1500 NeedReload
= RELOAD_NONE
;
1502 cupsdClearString(&old_serverroot
);
1503 cupsdClearString(&old_requestroot
);
1510 * 'get_address()' - Get an address + port number from a line.
1513 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1514 get_address(const char *value
, /* I - Value string */
1515 int defport
) /* I - Default port */
1517 char buffer
[1024], /* Hostname + port number buffer */
1518 defpname
[255], /* Default port name */
1519 *hostname
, /* Hostname or IP */
1520 *portname
; /* Port number or name */
1521 http_addrlist_t
*addrlist
; /* Address list */
1525 * Check for an empty value...
1530 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1535 * Grab a hostname and port number; if there is no colon and the port name
1536 * is only digits, then we have a port number by itself...
1539 strlcpy(buffer
, value
, sizeof(buffer
));
1541 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1548 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1553 * Use the default port...
1556 sprintf(defpname
, "%d", defport
);
1557 portname
= defpname
;
1563 * The buffer contains just a port number...
1571 if (hostname
&& !strcmp(hostname
, "*"))
1575 * Now lookup the address using httpAddrGetList()...
1578 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1579 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1580 hostname
? hostname
: "(nil)");
1587 * 'get_addr_and_mask()' - Get an IP address and netmask.
1590 static int /* O - 1 on success, 0 on failure */
1591 get_addr_and_mask(const char *value
, /* I - String from config file */
1592 unsigned *ip
, /* O - Address value */
1593 unsigned *mask
) /* O - Mask value */
1595 int i
, j
, /* Looping vars */
1596 family
, /* Address family */
1597 ipcount
; /* Count of fields in address */
1598 unsigned ipval
; /* Value */
1599 const char *maskval
, /* Pointer to start of mask value */
1600 *ptr
, /* Pointer into value */
1605 * Get the address...
1608 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1609 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1611 if ((maskval
= strchr(value
, '/')) != NULL
)
1614 maskval
= value
+ strlen(value
);
1618 * Check for an IPv6 address...
1624 * Parse hexadecimal IPv6 address...
1629 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1633 else if (!strncmp(ptr
, "::", 2))
1635 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1637 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1642 else if (isxdigit(*ptr
& 255))
1644 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1652 ip
[i
/ 2] |= ipval
<< 16;
1666 if (*ptr
&& *ptr
!= '/')
1670 #endif /* AF_INET6 */
1673 * Parse dotted-decimal IPv4 address...
1676 unsigned val
[4]; /* IPv4 address values */
1680 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1683 * Range check the IP numbers...
1686 for (i
= 0; i
< ipcount
; i
++)
1691 * Make sure the trailing values are zeroed, as some C libraries like
1692 * glibc apparently like to fill the unused arguments with garbage...
1695 for (i
= ipcount
; i
< 4; i
++)
1699 * Merge everything into a 32-bit IPv4 address in ip[3]...
1702 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1705 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1711 * Get the netmask value(s)...
1714 memset(mask
, 0, sizeof(unsigned) * 4);
1716 if (strchr(maskval
, '.'))
1719 * Get dotted-decimal mask...
1722 if (family
!= AF_INET
)
1725 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1728 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1729 mask
[0] = mask
[1] = mask
[2] = 0;
1734 * Get address/bits format...
1740 if (family
== AF_INET6
)
1748 mask
[0] = 0xffffffff;
1750 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1753 mask
[1] = 0xffffffff;
1757 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1760 mask
[2] = 0xffffffff;
1764 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1767 mask
[3] = 0xffffffff;
1771 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1774 #endif /* AF_INET6 */
1779 mask
[0] = 0xffffffff;
1780 mask
[1] = 0xffffffff;
1781 mask
[2] = 0xffffffff;
1784 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1786 mask
[3] = 0xffffffff;
1791 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1792 "get_addr_and_mask(value=\"%s\", "
1793 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1794 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1798 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1801 if ((ip
[0] & ~mask
[0]) != 0 ||
1802 (ip
[1] & ~mask
[1]) != 0 ||
1803 (ip
[2] & ~mask
[2]) != 0 ||
1804 (ip
[3] & ~mask
[3]) != 0)
1812 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1815 static int /* O - 1 on success, 0 on failure */
1816 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1817 char *line
, /* I - Line from file */
1818 char *value
, /* I - Start of value data */
1819 int linenum
) /* I - Current line number */
1821 char *valptr
; /* Pointer into value */
1822 unsigned ip
[4], /* IP address components */
1823 mask
[4]; /* IP netmask components */
1826 if (!strcasecmp(line
, "Encryption"))
1829 * "Encryption xxx" - set required encryption level...
1832 if (!strcasecmp(value
, "never"))
1833 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1834 else if (!strcasecmp(value
, "always"))
1836 cupsdLogMessage(CUPSD_LOG_ERROR
,
1837 "Encryption value \"%s\" on line %d is invalid in this "
1838 "context. Using \"required\" instead.", value
, linenum
);
1840 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1842 else if (!strcasecmp(value
, "required"))
1843 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1844 else if (!strcasecmp(value
, "ifrequested"))
1845 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1848 cupsdLogMessage(CUPSD_LOG_ERROR
,
1849 "Unknown Encryption value %s on line %d.", value
, linenum
);
1853 else if (!strcasecmp(line
, "Order"))
1856 * "Order Deny,Allow" or "Order Allow,Deny"...
1859 if (!strncasecmp(value
, "deny", 4))
1860 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1861 else if (!strncasecmp(value
, "allow", 5))
1862 loc
->order_type
= CUPSD_AUTH_DENY
;
1865 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1870 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1873 * Allow [From] host/ip...
1874 * Deny [From] host/ip...
1879 if (!strncasecmp(value
, "from", 4))
1882 * Strip leading "from"...
1887 while (isspace(*value
& 255))
1895 * Find the end of the value...
1898 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1900 while (isspace(*valptr
& 255))
1904 * Figure out what form the allow/deny address takes:
1915 * nnn.nnn.nnn.nnn/mm
1916 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1919 if (!strcasecmp(value
, "all"))
1925 if (!strcasecmp(line
, "Allow"))
1926 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1928 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1930 else if (!strcasecmp(value
, "none"))
1936 if (!strcasecmp(line
, "Allow"))
1937 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1939 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1942 else if (value
[0] == '*' || value
[0] == '.' ||
1943 (!isdigit(value
[0] & 255) && value
[0] != '['))
1945 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1946 #endif /* AF_INET6 */
1949 * Host or domain name...
1952 if (value
[0] == '*')
1955 if (!strcasecmp(line
, "Allow"))
1956 cupsdAddNameMask(&(loc
->allow
), value
);
1958 cupsdAddNameMask(&(loc
->deny
), value
);
1963 * One of many IP address forms...
1966 if (!get_addr_and_mask(value
, ip
, mask
))
1968 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1973 if (!strcasecmp(line
, "Allow"))
1974 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
1976 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
1980 * Advance to next value...
1986 else if (!strcasecmp(line
, "AuthType"))
1989 * AuthType {none,basic,digest,basicdigest,negotiate,default}
1992 if (!strcasecmp(value
, "none"))
1994 loc
->type
= CUPSD_AUTH_NONE
;
1995 loc
->level
= CUPSD_AUTH_ANON
;
1997 else if (!strcasecmp(value
, "basic"))
1999 loc
->type
= CUPSD_AUTH_BASIC
;
2001 if (loc
->level
== CUPSD_AUTH_ANON
)
2002 loc
->level
= CUPSD_AUTH_USER
;
2004 else if (!strcasecmp(value
, "digest"))
2006 loc
->type
= CUPSD_AUTH_DIGEST
;
2008 if (loc
->level
== CUPSD_AUTH_ANON
)
2009 loc
->level
= CUPSD_AUTH_USER
;
2011 else if (!strcasecmp(value
, "basicdigest"))
2013 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2015 if (loc
->level
== CUPSD_AUTH_ANON
)
2016 loc
->level
= CUPSD_AUTH_USER
;
2018 else if (!strcasecmp(value
, "default"))
2020 loc
->type
= CUPSD_AUTH_DEFAULT
;
2022 if (loc
->level
== CUPSD_AUTH_ANON
)
2023 loc
->level
= CUPSD_AUTH_USER
;
2026 else if (!strcasecmp(value
, "negotiate"))
2028 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2030 if (loc
->level
== CUPSD_AUTH_ANON
)
2031 loc
->level
= CUPSD_AUTH_USER
;
2033 #endif /* HAVE_GSSAPI */
2036 cupsdLogMessage(CUPSD_LOG_WARN
,
2037 "Unknown authorization type %s on line %d.",
2042 else if (!strcasecmp(line
, "AuthClass"))
2045 * AuthClass anonymous, user, system, group
2048 if (!strcasecmp(value
, "anonymous"))
2050 loc
->type
= CUPSD_AUTH_NONE
;
2051 loc
->level
= CUPSD_AUTH_ANON
;
2053 cupsdLogMessage(CUPSD_LOG_WARN
,
2054 "\"AuthClass %s\" is deprecated; consider removing "
2058 else if (!strcasecmp(value
, "user"))
2060 loc
->level
= CUPSD_AUTH_USER
;
2062 cupsdLogMessage(CUPSD_LOG_WARN
,
2063 "\"AuthClass %s\" is deprecated; consider using "
2064 "\"Require valid-user\" on line %d.",
2067 else if (!strcasecmp(value
, "group"))
2069 loc
->level
= CUPSD_AUTH_GROUP
;
2071 cupsdLogMessage(CUPSD_LOG_WARN
,
2072 "\"AuthClass %s\" is deprecated; consider using "
2073 "\"Require user @groupname\" on line %d.",
2076 else if (!strcasecmp(value
, "system"))
2078 loc
->level
= CUPSD_AUTH_GROUP
;
2080 cupsdAddName(loc
, "@SYSTEM");
2082 cupsdLogMessage(CUPSD_LOG_WARN
,
2083 "\"AuthClass %s\" is deprecated; consider using "
2084 "\"Require user @SYSTEM\" on line %d.",
2089 cupsdLogMessage(CUPSD_LOG_WARN
,
2090 "Unknown authorization class %s on line %d.",
2095 else if (!strcasecmp(line
, "AuthGroupName"))
2097 cupsdAddName(loc
, value
);
2099 cupsdLogMessage(CUPSD_LOG_WARN
,
2100 "\"AuthGroupName %s\" directive is deprecated; consider "
2101 "using \"Require user @%s\" on line %d.",
2102 value
, value
, linenum
);
2104 else if (!strcasecmp(line
, "Require"))
2107 * Apache synonym for AuthClass and AuthGroupName...
2111 * Require valid-user
2112 * Require group names
2113 * Require user names
2116 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2121 if (!strcasecmp(value
, "valid-user") ||
2122 !strcasecmp(value
, "user"))
2123 loc
->level
= CUPSD_AUTH_USER
;
2124 else if (!strcasecmp(value
, "group"))
2125 loc
->level
= CUPSD_AUTH_GROUP
;
2128 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2134 * Get the list of names from the line...
2137 for (value
= valptr
; *value
;)
2139 while (isspace(*value
& 255))
2142 #ifdef HAVE_AUTHORIZATION_H
2143 if (!strncmp(value
, "@AUTHKEY(", 9))
2146 * Grab "@AUTHKEY(name)" value...
2149 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2155 #endif /* HAVE_AUTHORIZATION_H */
2156 if (*value
== '\"' || *value
== '\'')
2159 * Grab quoted name...
2162 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2169 * Grab literal name.
2172 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2178 cupsdAddName(loc
, value
);
2180 for (value
= valptr
; isspace(*value
& 255); value
++);
2183 else if (!strcasecmp(line
, "Satisfy"))
2185 if (!strcasecmp(value
, "all"))
2186 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2187 else if (!strcasecmp(value
, "any"))
2188 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2191 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2204 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2207 static int /* O - FatalErrors bits */
2208 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2210 int fatal
; /* FatalErrors bits */
2211 char value
[1024], /* Value string */
2212 *valstart
, /* Pointer into value */
2213 *valend
; /* End of value */
2217 * Empty FatalErrors line yields NULL pointer...
2221 return (CUPSD_FATAL_NONE
);
2224 * Loop through the value string,...
2227 strlcpy(value
, s
, sizeof(value
));
2229 fatal
= CUPSD_FATAL_NONE
;
2231 for (valstart
= value
; *valstart
;)
2234 * Get the current space/comma-delimited kind name...
2237 for (valend
= valstart
; *valend
; valend
++)
2238 if (isspace(*valend
& 255) || *valend
== ',')
2245 * Add the error to the bitmask...
2248 if (!strcasecmp(valstart
, "all"))
2249 fatal
= CUPSD_FATAL_ALL
;
2250 else if (!strcasecmp(valstart
, "browse"))
2251 fatal
|= CUPSD_FATAL_BROWSE
;
2252 else if (!strcasecmp(valstart
, "-browse"))
2253 fatal
&= ~CUPSD_FATAL_BROWSE
;
2254 else if (!strcasecmp(valstart
, "config"))
2255 fatal
|= CUPSD_FATAL_CONFIG
;
2256 else if (!strcasecmp(valstart
, "-config"))
2257 fatal
&= ~CUPSD_FATAL_CONFIG
;
2258 else if (!strcasecmp(valstart
, "listen"))
2259 fatal
|= CUPSD_FATAL_LISTEN
;
2260 else if (!strcasecmp(valstart
, "-listen"))
2261 fatal
&= ~CUPSD_FATAL_LISTEN
;
2262 else if (!strcasecmp(valstart
, "log"))
2263 fatal
|= CUPSD_FATAL_LOG
;
2264 else if (!strcasecmp(valstart
, "-log"))
2265 fatal
&= ~CUPSD_FATAL_LOG
;
2266 else if (!strcasecmp(valstart
, "permissions"))
2267 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2268 else if (!strcasecmp(valstart
, "-permissions"))
2269 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2270 else if (strcasecmp(valstart
, "none"))
2271 cupsdLogMessage(CUPSD_LOG_ERROR
,
2272 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2274 for (valstart
= valend
; *valstart
; valstart
++)
2275 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2284 * 'parse_groups()' - Parse system group names in a string.
2287 static int /* O - 1 on success, 0 on failure */
2288 parse_groups(const char *s
) /* I - Space-delimited groups */
2290 int status
; /* Return status */
2291 char value
[1024], /* Value string */
2292 *valstart
, /* Pointer into value */
2293 *valend
, /* End of value */
2294 quote
; /* Quote character */
2295 struct group
*group
; /* Group */
2299 * Make a copy of the string and parse out the groups...
2302 strlcpy(value
, s
, sizeof(value
));
2307 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2309 if (*valstart
== '\'' || *valstart
== '\"')
2312 * Scan quoted name...
2315 quote
= *valstart
++;
2317 for (valend
= valstart
; *valend
; valend
++)
2318 if (*valend
== quote
)
2324 * Scan space or comma-delimited name...
2327 for (valend
= valstart
; *valend
; valend
++)
2328 if (isspace(*valend
) || *valend
== ',')
2335 group
= getgrnam(valstart
);
2338 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2339 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2350 while (*valstart
== ',' || isspace(*valstart
))
2359 * 'parse_protocols()' - Parse browse protocols in a string.
2362 static int /* O - Browse protocol bits */
2363 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2365 int protocols
; /* Browse protocol bits */
2366 char value
[1024], /* Value string */
2367 *valstart
, /* Pointer into value */
2368 *valend
; /* End of value */
2372 * Empty protocol line yields NULL pointer...
2379 * Loop through the value string,...
2382 strlcpy(value
, s
, sizeof(value
));
2386 for (valstart
= value
; *valstart
;)
2389 * Get the current space/comma-delimited protocol name...
2392 for (valend
= valstart
; *valend
; valend
++)
2393 if (isspace(*valend
& 255) || *valend
== ',')
2400 * Add the protocol to the bitmask...
2403 if (!strcasecmp(valstart
, "cups"))
2404 protocols
|= BROWSE_CUPS
;
2405 else if (!strcasecmp(valstart
, "slp"))
2406 protocols
|= BROWSE_SLP
;
2407 else if (!strcasecmp(valstart
, "ldap"))
2408 protocols
|= BROWSE_LDAP
;
2409 else if (!strcasecmp(valstart
, "dnssd") ||
2410 !strcasecmp(valstart
, "dns-sd") ||
2411 !strcasecmp(valstart
, "bonjour"))
2412 protocols
|= BROWSE_DNSSD
;
2413 else if (!strcasecmp(valstart
, "lpd"))
2414 protocols
|= BROWSE_LPD
;
2415 else if (!strcasecmp(valstart
, "smb"))
2416 protocols
|= BROWSE_SMB
;
2417 else if (!strcasecmp(valstart
, "all"))
2418 protocols
|= BROWSE_ALL
;
2419 else if (strcasecmp(valstart
, "none"))
2420 cupsdLogMessage(CUPSD_LOG_ERROR
,
2421 "Unknown browse protocol \"%s\" ignored.", valstart
);
2423 for (valstart
= valend
; *valstart
; valstart
++)
2424 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2433 * 'read_configuration()' - Read a configuration file.
2436 static int /* O - 1 on success, 0 on failure */
2437 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2439 int i
; /* Looping var */
2440 int linenum
; /* Current line number */
2441 char line
[HTTP_MAX_BUFFER
],
2442 /* Line from file */
2443 temp
[HTTP_MAX_BUFFER
],
2444 /* Temporary buffer for value */
2445 *ptr
, /* Pointer into line/temp */
2446 *value
, /* Pointer to value */
2447 *valueptr
; /* Pointer into value */
2448 int valuelen
; /* Length of value */
2449 cupsd_var_t
const *var
; /* Current variable */
2450 http_addrlist_t
*addrlist
, /* Address list */
2451 *addr
; /* Current address */
2452 unsigned ip
[4], /* Address value */
2453 mask
[4]; /* Netmask value */
2454 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2455 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2456 cupsd_location_t
*location
; /* Browse location */
2457 cups_file_t
*incfile
; /* Include file */
2458 char incname
[1024]; /* Include filename */
2459 struct group
*group
; /* Group */
2463 * Loop through each line in the file...
2468 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2471 * Decode the directive...
2474 if (!strcasecmp(line
, "Include") && value
)
2480 if (value
[0] == '/')
2481 strlcpy(incname
, value
, sizeof(incname
));
2483 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2485 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2486 cupsdLogMessage(CUPSD_LOG_ERROR
,
2487 "Unable to include config file \"%s\" - %s",
2488 incname
, strerror(errno
));
2491 read_configuration(incfile
);
2492 cupsFileClose(incfile
);
2495 else if (!strcasecmp(line
, "<Location") && value
)
2501 linenum
= read_location(fp
, value
, linenum
);
2505 else if (!strcasecmp(line
, "<Policy") && value
)
2511 linenum
= read_policy(fp
, value
, linenum
);
2515 else if (!strcasecmp(line
, "FatalErrors"))
2516 FatalErrors
= parse_fatal_errors(value
);
2517 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2519 JobRetryInterval
= atoi(value
);
2520 cupsdLogMessage(CUPSD_LOG_WARN
,
2521 "FaxRetryInterval is deprecated; use "
2522 "JobRetryInterval on line %d.", linenum
);
2524 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2526 JobRetryLimit
= atoi(value
);
2527 cupsdLogMessage(CUPSD_LOG_WARN
,
2528 "FaxRetryLimit is deprecated; use "
2529 "JobRetryLimit on line %d.", linenum
);
2531 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2533 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2534 #endif /* HAVE_SSL */
2538 * Add listening address(es) to the list...
2541 cupsd_listener_t
*lis
; /* New listeners array */
2545 * Get the address list...
2548 addrlist
= get_address(value
, IPP_PORT
);
2552 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2558 * Add each address...
2561 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2564 * See if this address is already present...
2567 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2569 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2570 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2571 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2576 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2577 cupsdLogMessage(CUPSD_LOG_WARN
,
2578 "Duplicate listen address \"%s\" ignored.", temp
);
2583 * Allocate another listener...
2587 Listeners
= cupsArrayNew(NULL
, NULL
);
2591 cupsdLogMessage(CUPSD_LOG_ERROR
,
2592 "Unable to allocate %s at line %d - %s.",
2593 line
, linenum
, strerror(errno
));
2597 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2599 cupsdLogMessage(CUPSD_LOG_ERROR
,
2600 "Unable to allocate %s at line %d - %s.",
2601 line
, linenum
, strerror(errno
));
2605 cupsArrayAdd(Listeners
, lis
);
2608 * Copy the current address and log it...
2611 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2615 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2616 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2617 #endif /* HAVE_SSL */
2619 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2622 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2623 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv6)", temp
,
2624 ntohs(lis
->address
.ipv6
.sin6_port
));
2626 #endif /* AF_INET6 */
2628 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2629 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2631 #endif /* AF_LOCAL */
2632 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv4)", temp
,
2633 ntohs(lis
->address
.ipv4
.sin_port
));
2635 if (!httpAddrLocalhost(&(lis
->address
)))
2638 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2639 RemotePort
= ntohs(lis
->address
.ipv6
.sin6_port
);
2641 #endif /* AF_INET6 */
2642 RemotePort
= ntohs(lis
->address
.ipv4
.sin_port
);
2650 httpAddrFreeList(addrlist
);
2652 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2655 * Add a browse address to the list...
2658 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2661 if (NumBrowsers
== 0)
2662 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2664 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2668 cupsdLogMessage(CUPSD_LOG_ERROR
,
2669 "Unable to allocate BrowseAddress at line %d - %s.",
2670 linenum
, strerror(errno
));
2675 dira
+= NumBrowsers
;
2677 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2679 if (!strcasecmp(value
, "@LOCAL"))
2682 * Send browse data to all local interfaces...
2685 strcpy(dira
->iface
, "*");
2688 else if (!strncasecmp(value
, "@IF(", 4))
2691 * Send browse data to the named interface...
2694 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2696 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2702 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2705 * Only IPv4 addresses are supported...
2708 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2709 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2714 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2715 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2717 cupsdLogMessage(CUPSD_LOG_INFO
,
2718 "Sending browsing info to %s:%d (IPv4)",
2719 temp
, ntohs(dira
->to
.ipv4
.sin_port
));
2724 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2727 httpAddrFreeList(addrlist
);
2730 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2733 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2736 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2739 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2740 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2741 cupsdAddLocation(location
);
2743 if (location
== NULL
)
2744 cupsdLogMessage(CUPSD_LOG_ERROR
,
2745 "Unable to initialize browse access control list.");
2746 else if (!strncasecmp(value
, "deny", 4))
2747 location
->order_type
= CUPSD_AUTH_ALLOW
;
2748 else if (!strncasecmp(value
, "allow", 5))
2749 location
->order_type
= CUPSD_AUTH_DENY
;
2751 cupsdLogMessage(CUPSD_LOG_ERROR
,
2752 "Unknown BrowseOrder value %s on line %d.",
2755 else if (!strcasecmp(line
, "BrowseProtocols") ||
2756 !strcasecmp(line
, "BrowseLocalProtocols") ||
2757 !strcasecmp(line
, "BrowseRemoteProtocols"))
2760 * "BrowseProtocols name [... name]"
2761 * "BrowseLocalProtocols name [... name]"
2762 * "BrowseRemoteProtocols name [... name]"
2765 int protocols
= parse_protocols(value
);
2769 cupsdLogMessage(CUPSD_LOG_ERROR
,
2770 "Unknown browse protocol \"%s\" on line %d.",
2775 if (strcasecmp(line
, "BrowseLocalProtocols"))
2776 BrowseRemoteProtocols
= protocols
;
2777 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2778 BrowseLocalProtocols
= protocols
;
2780 else if ((!strcasecmp(line
, "BrowseAllow") ||
2781 !strcasecmp(line
, "BrowseDeny")) && value
)
2784 * BrowseAllow [From] host/ip...
2785 * BrowseDeny [From] host/ip...
2788 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2789 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2790 cupsdAddLocation(location
);
2793 if (location
== NULL
)
2794 cupsdLogMessage(CUPSD_LOG_ERROR
,
2795 "Unable to initialize browse access control list.");
2798 if (!strncasecmp(value
, "from", 4))
2801 * Skip leading "from"...
2810 * Skip leading whitespace...
2813 while (isspace(*value
& 255))
2820 * Find the end of the value...
2823 for (valueptr
= value
;
2824 *valueptr
&& !isspace(*valueptr
& 255);
2827 while (isspace(*valueptr
& 255))
2831 * Figure out what form the allow/deny address takes:
2842 * nnn.nnn.nnn.nnn/mm
2843 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2846 if (!strcasecmp(value
, "all"))
2852 if (!strcasecmp(line
, "BrowseAllow"))
2853 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2855 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2857 else if (!strcasecmp(value
, "none"))
2863 if (!strcasecmp(line
, "BrowseAllow"))
2864 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2866 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2869 else if (value
[0] == '*' || value
[0] == '.' ||
2870 (!isdigit(value
[0] & 255) && value
[0] != '['))
2872 else if (value
[0] == '*' || value
[0] == '.' ||
2873 !isdigit(value
[0] & 255))
2874 #endif /* AF_INET6 */
2877 * Host or domain name...
2880 if (!strcasecmp(line
, "BrowseAllow"))
2881 cupsdAddNameMask(&(location
->allow
), value
);
2883 cupsdAddNameMask(&(location
->deny
), value
);
2888 * One of many IP address forms...
2891 if (!get_addr_and_mask(value
, ip
, mask
))
2893 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2898 if (!strcasecmp(line
, "BrowseAllow"))
2899 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2901 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2905 * Advance to next value...
2912 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2915 * BrowseRelay [from] source [to] destination
2919 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2921 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2925 cupsdLogMessage(CUPSD_LOG_ERROR
,
2926 "Unable to allocate BrowseRelay at line %d - %s.",
2927 linenum
, strerror(errno
));
2934 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2936 if (!strncasecmp(value
, "from ", 5))
2939 * Skip leading "from"...
2945 * Skip leading whitespace...
2948 while (isspace(*value
))
2953 * Find the end of the from value...
2956 for (valueptr
= value
;
2957 *valueptr
&& !isspace(*valueptr
& 255);
2960 while (isspace(*valueptr
& 255))
2964 * Figure out what form the from address takes:
2973 * nnn.nnn.nnn.nnn/mm
2974 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2978 if (value
[0] == '*' || value
[0] == '.' ||
2979 (!isdigit(value
[0] & 255) && value
[0] != '['))
2981 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2982 #endif /* AF_INET6 */
2985 * Host or domain name...
2988 if (!cupsdAddNameMask(&(relay
->from
), value
))
2990 cupsdLogMessage(CUPSD_LOG_ERROR
,
2991 "Unable to allocate BrowseRelay name at line %d - %s.",
2992 linenum
, strerror(errno
));
2999 * One of many IP address forms...
3002 if (!get_addr_and_mask(value
, ip
, mask
))
3004 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
3009 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
3011 cupsdLogMessage(CUPSD_LOG_ERROR
,
3012 "Unable to allocate BrowseRelay IP at line %d - %s.",
3013 linenum
, strerror(errno
));
3019 * Get "to" address and port...
3022 if (!strncasecmp(valueptr
, "to ", 3))
3025 * Strip leading "to"...
3030 while (isspace(*valueptr
))
3034 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3037 * Only IPv4 addresses are supported...
3040 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3041 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3046 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3048 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3050 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3051 value
, temp
, ntohs(relay
->to
.ipv4
.sin_port
));
3057 cupsArrayDelete(relay
->from
);
3060 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3064 httpAddrFreeList(addrlist
);
3068 cupsArrayDelete(relay
->from
);
3071 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3075 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3078 * BrowsePoll address[:port]
3081 char *portname
; /* Port name */
3082 int portnum
; /* Port number */
3083 struct servent
*service
; /* Service */
3087 * Extract the port name from the address...
3090 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3094 if (isdigit(*portname
& 255))
3095 portnum
= atoi(portname
);
3096 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3097 portnum
= ntohs(service
->s_port
);
3100 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed.",
3106 portnum
= ippPort();
3109 * Add the poll entry...
3113 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3115 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3119 cupsdLogMessage(CUPSD_LOG_ERROR
,
3120 "Unable to allocate BrowsePoll at line %d - %s.",
3121 linenum
, strerror(errno
));
3129 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3131 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3132 pollp
->port
= portnum
;
3134 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3137 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3140 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3143 if (!strcasecmp(value
, "none"))
3144 DefaultAuthType
= CUPSD_AUTH_NONE
;
3145 else if (!strcasecmp(value
, "basic"))
3146 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3147 else if (!strcasecmp(value
, "digest"))
3148 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3149 else if (!strcasecmp(value
, "basicdigest"))
3150 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3152 else if (!strcasecmp(value
, "negotiate"))
3153 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3154 #endif /* HAVE_GSSAPI */
3157 cupsdLogMessage(CUPSD_LOG_WARN
,
3158 "Unknown default authorization type %s on line %d.",
3160 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3165 else if (!strcasecmp(line
, "DefaultEncryption"))
3168 * DefaultEncryption {Never,IfRequested,Required}
3171 if (!value
|| !strcasecmp(value
, "never"))
3172 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3173 else if (!strcasecmp(value
, "required"))
3174 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3175 else if (!strcasecmp(value
, "ifrequested"))
3176 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3179 cupsdLogMessage(CUPSD_LOG_WARN
,
3180 "Unknown default encryption %s on line %d.",
3182 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3186 #endif /* HAVE_SSL */
3187 else if (!strcasecmp(line
, "User") && value
)
3190 * User ID to run as...
3193 if (isdigit(value
[0] & 255))
3195 int uid
= atoi(value
);
3198 cupsdLogMessage(CUPSD_LOG_ERROR
,
3199 "Will not use User 0 as specified on line %d "
3200 "for security reasons. You must use a non-"
3201 "privileged account instead.",
3208 struct passwd
*p
; /* Password information */
3211 p
= getpwnam(value
);
3216 cupsdLogMessage(CUPSD_LOG_ERROR
,
3217 "Will not use User %s (UID=0) as specified on line "
3218 "%d for security reasons. You must use a non-"
3219 "privileged account instead.",
3225 cupsdLogMessage(CUPSD_LOG_ERROR
,
3226 "Unknown User \"%s\" on line %d, ignoring.",
3230 else if (!strcasecmp(line
, "Group") && value
)
3233 * Group ID to run as...
3236 if (isdigit(value
[0]))
3237 Group
= atoi(value
);
3241 group
= getgrnam(value
);
3244 Group
= group
->gr_gid
;
3246 cupsdLogMessage(CUPSD_LOG_ERROR
,
3247 "Unknown Group \"%s\" on line %d, ignoring.",
3251 else if (!strcasecmp(line
, "SystemGroup") && value
)
3254 * SystemGroup (admin) group(s)...
3257 if (!parse_groups(value
))
3258 cupsdLogMessage(CUPSD_LOG_ERROR
,
3259 "Unknown SystemGroup \"%s\" on line %d, ignoring.",
3262 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3265 * Do hostname lookups?
3268 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3269 !strcasecmp(value
, "false"))
3270 HostNameLookups
= 0;
3271 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3272 !strcasecmp(value
, "true"))
3273 HostNameLookups
= 1;
3274 else if (!strcasecmp(value
, "double"))
3275 HostNameLookups
= 2;
3277 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3280 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3283 * Amount of logging to do to access log...
3286 if (!strcasecmp(value
, "all"))
3287 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3288 else if (!strcasecmp(value
, "actions"))
3289 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3290 else if (!strcasecmp(value
, "config"))
3291 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3293 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3296 else if (!strcasecmp(line
, "LogLevel") && value
)
3299 * Amount of logging to do to error log...
3302 if (!strcasecmp(value
, "debug2"))
3303 LogLevel
= CUPSD_LOG_DEBUG2
;
3304 else if (!strcasecmp(value
, "debug"))
3305 LogLevel
= CUPSD_LOG_DEBUG
;
3306 else if (!strcasecmp(value
, "info"))
3307 LogLevel
= CUPSD_LOG_INFO
;
3308 else if (!strcasecmp(value
, "notice"))
3309 LogLevel
= CUPSD_LOG_NOTICE
;
3310 else if (!strcasecmp(value
, "warn"))
3311 LogLevel
= CUPSD_LOG_WARN
;
3312 else if (!strcasecmp(value
, "error"))
3313 LogLevel
= CUPSD_LOG_ERROR
;
3314 else if (!strcasecmp(value
, "crit"))
3315 LogLevel
= CUPSD_LOG_CRIT
;
3316 else if (!strcasecmp(value
, "alert"))
3317 LogLevel
= CUPSD_LOG_ALERT
;
3318 else if (!strcasecmp(value
, "emerg"))
3319 LogLevel
= CUPSD_LOG_EMERG
;
3320 else if (!strcasecmp(value
, "none"))
3321 LogLevel
= CUPSD_LOG_NONE
;
3323 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3326 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3329 * Amount of logging to do to error log...
3332 if (!strcasecmp(value
, "standard"))
3333 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3334 else if (!strcasecmp(value
, "usecs"))
3335 LogTimeFormat
= CUPSD_TIME_USECS
;
3337 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3340 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3343 * Format of printcap file?
3346 if (!strcasecmp(value
, "bsd"))
3347 PrintcapFormat
= PRINTCAP_BSD
;
3348 else if (!strcasecmp(value
, "plist"))
3349 PrintcapFormat
= PRINTCAP_PLIST
;
3350 else if (!strcasecmp(value
, "solaris"))
3351 PrintcapFormat
= PRINTCAP_SOLARIS
;
3353 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3356 else if (!strcasecmp(line
, "ServerTokens") && value
)
3359 * Set the string used for the Server header...
3362 struct utsname plat
; /* Platform info */
3367 if (!strcasecmp(value
, "ProductOnly"))
3368 cupsdSetString(&ServerHeader
, "CUPS");
3369 else if (!strcasecmp(value
, "Major"))
3370 cupsdSetString(&ServerHeader
, "CUPS/1");
3371 else if (!strcasecmp(value
, "Minor"))
3372 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3373 else if (!strcasecmp(value
, "Minimal"))
3374 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3375 else if (!strcasecmp(value
, "OS"))
3376 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3377 else if (!strcasecmp(value
, "Full"))
3378 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3380 else if (!strcasecmp(value
, "None"))
3381 cupsdClearString(&ServerHeader
);
3383 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3386 else if (!strcasecmp(line
, "PassEnv") && value
)
3389 * PassEnv variable [... variable]
3394 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3395 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3398 if (value
[valuelen
])
3400 value
[valuelen
] = '\0';
3404 cupsdSetEnv(value
, NULL
);
3406 for (value
+= valuelen
; *value
; value
++)
3407 if (!isspace(*value
) || *value
!= ',')
3411 else if (!strcasecmp(line
, "ServerAlias") && value
)
3414 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3416 cupsdAddAlias(ServerAlias
, value
);
3418 else if (!strcasecmp(line
, "SetEnv") && value
)
3421 * SetEnv variable value
3424 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3432 while (isspace(*valueptr
& 255))
3435 cupsdSetEnv(value
, valueptr
);
3438 cupsdLogMessage(CUPSD_LOG_ERROR
,
3439 "Missing value for SetEnv directive on line %d.",
3443 else if (!strcasecmp(line
, "SSLOptions"))
3446 * SSLOptions options
3449 if (!value
|| !strcasecmp(value
, "none"))
3450 SSLOptions
= CUPSD_SSL_NONE
;
3451 else if (!strcasecmp(value
, "noemptyfragments"))
3452 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3454 cupsdLogMessage(CUPSD_LOG_ERROR
,
3455 "Unknown value \"%s\" for SSLOptions directive on "
3456 "line %d.", value
, linenum
);
3458 #endif /* HAVE_SSL */
3462 * Find a simple variable in the list...
3465 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3466 if (!strcasecmp(line
, var
->name
))
3472 * Unknown directive! Output an error message and continue...
3476 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3479 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3486 case CUPSD_VARTYPE_INTEGER
:
3488 cupsdLogMessage(CUPSD_LOG_ERROR
,
3489 "Missing integer value for %s on line %d.",
3494 char *units
; /* Units */
3497 n
= strtol(value
, &units
, 0);
3499 if (units
&& *units
)
3501 if (tolower(units
[0] & 255) == 'g')
3502 n
*= 1024 * 1024 * 1024;
3503 else if (tolower(units
[0] & 255) == 'm')
3505 else if (tolower(units
[0] & 255) == 'k')
3507 else if (tolower(units
[0] & 255) == 't')
3512 cupsdLogMessage(CUPSD_LOG_ERROR
,
3513 "Bad negative integer value for %s on line %d.",
3516 *((int *)var
->ptr
) = n
;
3520 case CUPSD_VARTYPE_BOOLEAN
:
3522 cupsdLogMessage(CUPSD_LOG_ERROR
,
3523 "Missing boolean value for %s on line %d.",
3525 else if (!strcasecmp(value
, "true") ||
3526 !strcasecmp(value
, "on") ||
3527 !strcasecmp(value
, "enabled") ||
3528 !strcasecmp(value
, "yes") ||
3530 *((int *)var
->ptr
) = TRUE
;
3531 else if (!strcasecmp(value
, "false") ||
3532 !strcasecmp(value
, "off") ||
3533 !strcasecmp(value
, "disabled") ||
3534 !strcasecmp(value
, "no") ||
3535 !strcasecmp(value
, "0"))
3536 *((int *)var
->ptr
) = FALSE
;
3538 cupsdLogMessage(CUPSD_LOG_ERROR
,
3539 "Unknown boolean value %s on line %d.",
3543 case CUPSD_VARTYPE_PATHNAME
:
3546 cupsdLogMessage(CUPSD_LOG_ERROR
,
3547 "Missing pathname value for %s on line %d.",
3552 if (value
[0] == '/')
3553 strlcpy(temp
, value
, sizeof(temp
));
3555 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3557 if (access(temp
, 0))
3559 cupsdLogMessage(CUPSD_LOG_ERROR
,
3560 "File or directory for \"%s %s\" on line %d "
3561 "does not exist.", line
, value
, linenum
);
3565 case CUPSD_VARTYPE_STRING
:
3566 cupsdSetString((char **)var
->ptr
, value
);
3577 * 'read_location()' - Read a <Location path> definition.
3580 static int /* O - New line number or 0 on error */
3581 read_location(cups_file_t
*fp
, /* I - Configuration file */
3582 char *location
, /* I - Location name/path */
3583 int linenum
) /* I - Current line number */
3585 cupsd_location_t
*loc
, /* New location */
3586 *parent
; /* Parent location */
3587 char line
[HTTP_MAX_BUFFER
],
3589 *value
, /* Value for directive */
3590 *valptr
; /* Pointer into value */
3593 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3594 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3596 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3600 cupsdAddLocation(parent
);
3602 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3607 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3610 * Decode the directive...
3613 if (!strcasecmp(line
, "</Location>"))
3615 else if (!strcasecmp(line
, "<Limit") ||
3616 !strcasecmp(line
, "<LimitExcept"))
3620 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3621 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3627 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3630 cupsdAddLocation(loc
);
3635 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3640 if (!strcmp(value
, "ALL"))
3641 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3642 else if (!strcmp(value
, "GET"))
3643 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3644 else if (!strcmp(value
, "HEAD"))
3645 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3646 else if (!strcmp(value
, "OPTIONS"))
3647 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3648 else if (!strcmp(value
, "POST"))
3649 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3650 else if (!strcmp(value
, "PUT"))
3651 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3652 else if (!strcmp(value
, "TRACE"))
3653 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3655 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3658 for (value
= valptr
; isspace(*value
& 255); value
++);
3661 if (!strcasecmp(line
, "<LimitExcept"))
3662 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3664 parent
->limit
&= ~loc
->limit
;
3666 else if (!strcasecmp(line
, "</Limit>") ||
3667 !strcasecmp(line
, "</LimitExcept>"))
3669 else if (!parse_aaa(loc
, line
, value
, linenum
))
3671 cupsdLogMessage(CUPSD_LOG_ERROR
,
3672 "Unknown Location directive %s on line %d.",
3674 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3679 cupsdLogMessage(CUPSD_LOG_ERROR
,
3680 "Unexpected end-of-file at line %d while reading location.",
3683 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3688 * 'read_policy()' - Read a <Policy name> definition.
3691 static int /* O - New line number or 0 on error */
3692 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3693 char *policy
, /* I - Location name/path */
3694 int linenum
) /* I - Current line number */
3696 int i
; /* Looping var */
3697 cupsd_policy_t
*pol
; /* Policy */
3698 cupsd_location_t
*op
; /* Policy operation */
3699 int num_ops
; /* Number of IPP operations */
3700 ipp_op_t ops
[100]; /* Operations */
3701 char line
[HTTP_MAX_BUFFER
],
3703 *value
, /* Value for directive */
3704 *valptr
; /* Pointer into value */
3708 * Create the policy...
3711 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3712 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3714 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3718 * Read from the file...
3724 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3727 * Decode the directive...
3730 if (!strcasecmp(line
, "</Policy>"))
3733 cupsdLogMessage(CUPSD_LOG_WARN
,
3734 "Missing </Limit> before </Policy> on line %d.",
3737 set_policy_defaults(pol
);
3741 else if (!strcasecmp(line
, "<Limit") && !op
)
3745 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3746 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3753 * Scan for IPP operation names...
3760 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3765 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3767 if (!strcasecmp(value
, "All"))
3768 ops
[num_ops
] = IPP_ANY_OPERATION
;
3769 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3770 cupsdLogMessage(CUPSD_LOG_ERROR
,
3771 "Bad IPP operation name \"%s\" on line %d.",
3777 cupsdLogMessage(CUPSD_LOG_ERROR
,
3778 "Too many operations listed on line %d.",
3781 for (value
= valptr
; isspace(*value
& 255); value
++);
3785 * If none are specified, apply the policy to all operations...
3790 ops
[0] = IPP_ANY_OPERATION
;
3795 * Add a new policy for the first operation...
3798 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3800 else if (!strcasecmp(line
, "</Limit>") && op
)
3803 * Finish the current operation limit...
3809 * Copy the policy to the other operations...
3812 for (i
= 1; i
< num_ops
; i
++)
3813 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3818 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3819 !strcasecmp(line
, "JobPrivateValues") ||
3820 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3821 !strcasecmp(line
, "SubscriptionPrivateValues"))
3825 cupsdLogMessage(CUPSD_LOG_ERROR
,
3826 "%s directive must appear outside <Limit>...</Limit> "
3827 "on line %d.", line
, linenum
);
3828 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3834 * Pull out whitespace-delimited values...
3840 * Find the end of the current value...
3843 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3849 * Save it appropriately...
3852 if (!strcasecmp(line
, "JobPrivateAccess"))
3855 * JobPrivateAccess {all|default|user/group list|@@ACL}
3858 if (!strcasecmp(value
, "default"))
3860 cupsdAddString(&(pol
->job_access
), "@OWNER");
3861 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3864 cupsdAddString(&(pol
->job_access
), value
);
3866 else if (!strcasecmp(line
, "JobPrivateValues"))
3869 * JobPrivateValues {all|none|default|attribute list}
3872 if (!strcasecmp(value
, "default"))
3874 cupsdAddString(&(pol
->job_attrs
), "job-name");
3875 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3876 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3879 cupsdAddString(&(pol
->job_attrs
), value
);
3881 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3884 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3887 if (!strcasecmp(value
, "default"))
3889 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3890 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3893 cupsdAddString(&(pol
->sub_access
), value
);
3895 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3898 * SubscriptionPrivateValues {all|none|default|attribute list}
3901 if (!strcasecmp(value
, "default"))
3903 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3904 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3905 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3906 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3907 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3910 cupsdAddString(&(pol
->sub_attrs
), value
);
3914 * Find the next string on the line...
3917 for (value
= valptr
; isspace(*value
& 255); value
++);
3923 cupsdLogMessage(CUPSD_LOG_ERROR
,
3924 "Missing <Limit ops> directive before %s on line %d.",
3926 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3929 else if (!parse_aaa(op
, line
, value
, linenum
))
3932 cupsdLogMessage(CUPSD_LOG_ERROR
,
3933 "Unknown Policy Limit directive %s on line %d.",
3936 cupsdLogMessage(CUPSD_LOG_ERROR
,
3937 "Unknown Policy directive %s on line %d.",
3940 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3945 cupsdLogMessage(CUPSD_LOG_ERROR
,
3946 "Unexpected end-of-file at line %d while reading policy "
3947 "\"%s\".", linenum
, policy
);
3949 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3954 * 'set_policy_defaults()' - Set default policy values as needed.
3958 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3960 cupsd_location_t
*op
; /* Policy operation */
3964 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3965 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3966 * upgrades do not introduce new security issues...
3969 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3970 op
->op
== IPP_ANY_OPERATION
)
3972 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3973 op
->op
!= IPP_ANY_OPERATION
)
3976 * Add a new limit for Validate-Job using the Print-Job limit as a
3980 cupsdLogMessage(CUPSD_LOG_WARN
,
3981 "No limit for Validate-Job defined in policy %s "
3982 "- using Print-Job's policy.", pol
->name
);
3984 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3987 cupsdLogMessage(CUPSD_LOG_WARN
,
3988 "No limit for Validate-Job defined in policy %s "
3989 "and no suitable template found.", pol
->name
);
3992 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3993 op
->op
== IPP_ANY_OPERATION
)
3995 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3996 op
->op
!= IPP_ANY_OPERATION
)
3999 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
4003 cupsdLogMessage(CUPSD_LOG_WARN
,
4004 "No limit for Cancel-Jobs defined in policy %s "
4005 "- using Pause-Printer's policy.", pol
->name
);
4007 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
4010 cupsdLogMessage(CUPSD_LOG_WARN
,
4011 "No limit for Cancel-Jobs defined in policy %s "
4012 "and no suitable template found.", pol
->name
);
4015 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
4016 op
->op
== IPP_ANY_OPERATION
)
4018 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4019 op
->op
!= IPP_ANY_OPERATION
)
4022 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4026 cupsdLogMessage(CUPSD_LOG_WARN
,
4027 "No limit for Cancel-My-Jobs defined in policy %s "
4028 "- using Send-Document's policy.", pol
->name
);
4030 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4033 cupsdLogMessage(CUPSD_LOG_WARN
,
4034 "No limit for Cancel-My-Jobs defined in policy %s "
4035 "and no suitable template found.", pol
->name
);
4038 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
4039 op
->op
== IPP_ANY_OPERATION
)
4041 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4042 op
->op
!= IPP_ANY_OPERATION
)
4045 * Add a new limit for Close-Job using the Send-Document limit as a
4049 cupsdLogMessage(CUPSD_LOG_WARN
,
4050 "No limit for Close-Job defined in policy %s "
4051 "- using Send-Document's policy.", pol
->name
);
4053 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4056 cupsdLogMessage(CUPSD_LOG_WARN
,
4057 "No limit for Close-Job defined in policy %s "
4058 "and no suitable template found.", pol
->name
);
4061 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4062 op
->op
== IPP_ANY_OPERATION
)
4064 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4065 op
->op
!= IPP_ANY_OPERATION
)
4068 * Add a new limit for CUPS-Get-Document using the Send-Document
4069 * limit as a template...
4072 cupsdLogMessage(CUPSD_LOG_WARN
,
4073 "No limit for CUPS-Get-Document defined in policy %s "
4074 "- using Send-Document's policy.", pol
->name
);
4076 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4079 cupsdLogMessage(CUPSD_LOG_WARN
,
4080 "No limit for CUPS-Get-Document defined in policy %s "
4081 "and no suitable template found.", pol
->name
);
4085 * Verify we have JobPrivateAccess, JobPrivateValues,
4086 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4089 if (!pol
->job_access
)
4091 cupsdLogMessage(CUPSD_LOG_WARN
,
4092 "No JobPrivateAccess defined in policy %s "
4093 "- using defaults.", pol
->name
);
4094 cupsdAddString(&(pol
->job_access
), "@OWNER");
4095 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4098 if (!pol
->job_attrs
)
4100 cupsdLogMessage(CUPSD_LOG_WARN
,
4101 "No JobPrivateValues defined in policy %s "
4102 "- using defaults.", pol
->name
);
4103 cupsdAddString(&(pol
->job_attrs
), "job-name");
4104 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4105 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4108 if (!pol
->sub_access
)
4110 cupsdLogMessage(CUPSD_LOG_WARN
,
4111 "No SubscriptionPrivateAccess defined in policy %s "
4112 "- using defaults.", pol
->name
);
4113 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4114 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4117 if (!pol
->sub_attrs
)
4119 cupsdLogMessage(CUPSD_LOG_WARN
,
4120 "No SubscriptionPrivateValues defined in policy %s "
4121 "- using defaults.", pol
->name
);
4122 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4123 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4124 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4125 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4126 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4132 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".