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 * Make sure each of the log files exists and gets rotated as necessary...
850 if (!strcmp(AccessLog
, "syslog"))
851 cupsdCheckLogFile(&AccessFile
, AccessLog
);
853 if (!strcmp(ErrorLog
, "syslog"))
854 cupsdCheckLogFile(&ErrorFile
, ErrorLog
);
856 if (!strcmp(PageLog
, "syslog"))
857 cupsdCheckLogFile(&PageFile
, PageLog
);
860 * Log the configuration file that was used...
863 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
867 * Validate the Group and SystemGroup settings - they cannot be the same,
868 * otherwise the CGI programs will be able to authenticate as root without
874 for (i
= 0; i
< NumSystemGroups
; i
++)
875 if (Group
== SystemGroupIDs
[i
])
878 if (i
< NumSystemGroups
)
881 * Log the error and reset the group to a safe value...
884 cupsdLogMessage(CUPSD_LOG_NOTICE
,
885 "Group and SystemGroup cannot use the same groups.");
886 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
888 group
= getgrnam("nobody");
892 Group
= group
->gr_gid
;
896 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
897 * complement number...)
906 * Check that we have at least one listen/port line; if not, report this
907 * as an error and exit!
910 if (cupsArrayCount(Listeners
) == 0)
916 cupsdLogMessage(CUPSD_LOG_EMERG
,
917 "No valid Listen or Port lines were found in the "
918 "configuration file.");
924 cupsdEndProcess(getpid(), 0);
928 * Set the default locale using the language and charset...
931 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
934 * Update all relative filenames to include the full path from ServerRoot...
937 if (DocumentRoot
[0] != '/')
938 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
940 if (RequestRoot
[0] != '/')
941 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
943 if (ServerBin
[0] != '/')
944 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
946 if (StateDir
[0] != '/')
947 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
949 if (CacheDir
[0] != '/')
950 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
953 if (ServerCertificate
[0] != '/')
954 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
956 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
957 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
959 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
962 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
963 if (ServerKey
[0] != '/')
964 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
966 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
967 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
968 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
970 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
971 #endif /* HAVE_SSL */
974 * Make sure that directories and config files are owned and
975 * writable by the user and group in the cupsd.conf file...
978 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
980 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
982 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
984 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
986 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
988 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
989 SystemGroupIDs
[0], 1, 1) < 0 ||
990 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
992 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
994 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
996 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
998 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
1000 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
1002 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
1003 Group
, 0, 0) < 0) &&
1004 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1008 * Update TempDir to the default if it hasn't been set already...
1013 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
1016 * TMPDIR is defined, see if it is OK for us to use...
1019 if (stat(tmpdir
, &tmpinfo
))
1020 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1021 tmpdir
, strerror(errno
));
1022 else if (!S_ISDIR(tmpinfo
.st_mode
))
1023 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1025 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1026 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1027 !(tmpinfo
.st_mode
& S_IWOTH
))
1028 cupsdLogMessage(CUPSD_LOG_ERROR
,
1029 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1031 cupsdSetString(&TempDir
, tmpdir
);
1036 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1038 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1043 * Make sure the temporary directory has the right permissions...
1046 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1050 * Update ownership and permissions if the CUPS temp directory
1051 * is under the spool directory or does not exist...
1054 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1055 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1060 * Update environment variables...
1066 * Update default paper size setting as needed...
1069 if (!DefaultPaperSize
)
1071 #ifdef HAVE_LIBPAPER
1072 char *paper_result
; /* Paper size name from libpaper */
1074 if ((paper_result
= systempapername()) != NULL
)
1075 cupsdSetString(&DefaultPaperSize
, paper_result
);
1077 #endif /* HAVE_LIBPAPER */
1078 if (!DefaultLanguage
||
1079 !strcasecmp(DefaultLanguage
, "C") ||
1080 !strcasecmp(DefaultLanguage
, "POSIX") ||
1081 !strcasecmp(DefaultLanguage
, "en") ||
1082 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1083 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1084 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1085 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1088 * These are the only locales that will default to "letter" size...
1091 cupsdSetString(&DefaultPaperSize
, "Letter");
1094 cupsdSetString(&DefaultPaperSize
, "A4");
1098 * Update classification setting as needed...
1101 if (Classification
&& !strcasecmp(Classification
, "none"))
1102 cupsdClearString(&Classification
);
1105 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1108 * Check the MaxClients setting, and then allocate memory for it...
1111 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1114 cupsdLogMessage(CUPSD_LOG_INFO
,
1115 "MaxClients limited to 1/3 (%d) of the file descriptor "
1117 MaxFDs
/ 3, MaxFDs
);
1119 MaxClients
= MaxFDs
/ 3;
1122 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1126 * Check the MaxActiveJobs setting; limit to 1/3 the available
1127 * file descriptors, since we need a pipe for each job...
1130 if (MaxActiveJobs
> (MaxFDs
/ 3))
1131 MaxActiveJobs
= MaxFDs
/ 3;
1134 * Update the MaxClientsPerHost value, as needed...
1137 if (MaxClientsPerHost
<= 0)
1138 MaxClientsPerHost
= MaxClients
;
1140 if (MaxClientsPerHost
> MaxClients
)
1141 MaxClientsPerHost
= MaxClients
;
1143 cupsdLogMessage(CUPSD_LOG_INFO
,
1144 "Allowing up to %d client connections per host.",
1148 * Make sure that BrowseTimeout is at least twice the interval...
1151 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1153 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d.",
1157 BrowseTimeout
= BrowseInterval
* 2;
1159 BrowseTimeout
= DEFAULT_TIMEOUT
;
1161 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d.",
1166 * Update the default policy, as needed...
1170 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1172 DefaultPolicyPtr
= NULL
;
1174 if (!DefaultPolicyPtr
)
1176 cupsd_location_t
*po
; /* New policy operation */
1180 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1183 cupsdSetString(&DefaultPolicy
, "default");
1185 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1186 cupsdLogMessage(CUPSD_LOG_INFO
,
1187 "Using policy \"default\" as the default.");
1190 cupsdLogMessage(CUPSD_LOG_INFO
,
1191 "Creating CUPS default administrative policy:");
1193 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1195 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1197 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1198 cupsdAddString(&(p
->job_access
), "@OWNER");
1199 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1201 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1202 cupsdAddString(&(p
->job_attrs
), "job-name");
1203 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1204 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1206 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1207 cupsdAddString(&(p
->sub_access
), "@OWNER");
1208 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1210 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1211 cupsdAddString(&(p
->job_attrs
), "notify-events");
1212 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1213 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1214 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1215 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1217 cupsdLogMessage(CUPSD_LOG_INFO
,
1218 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1219 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1221 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1222 po
->order_type
= CUPSD_AUTH_ALLOW
;
1224 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1225 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1226 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1228 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1230 cupsdLogMessage(CUPSD_LOG_INFO
,
1231 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1232 "Release-Job Restart-Job Purge-Jobs "
1233 "Set-Job-Attributes Create-Job-Subscription "
1234 "Renew-Subscription Cancel-Subscription "
1235 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1236 "Suspend-Current-Job Resume-Job "
1237 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1238 "CUPS-Authenticate-Job CUPS-Get-Document>");
1239 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1241 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1242 po
->order_type
= CUPSD_AUTH_ALLOW
;
1243 po
->level
= CUPSD_AUTH_USER
;
1245 cupsdAddName(po
, "@OWNER");
1246 cupsdAddName(po
, "@SYSTEM");
1247 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1249 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1250 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1251 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1252 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1253 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1254 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1255 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1256 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1257 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1258 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1259 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1260 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1261 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1262 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1263 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1264 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1265 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1266 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1267 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1268 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1270 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1272 cupsdLogMessage(CUPSD_LOG_INFO
,
1273 "<Limit Pause-Printer Resume-Printer "
1274 "Set-Printer-Attributes Enable-Printer "
1275 "Disable-Printer Pause-Printer-After-Current-Job "
1276 "Hold-New-Jobs Release-Held-New-Jobs "
1277 "Deactivate-Printer Activate-Printer Restart-Printer "
1278 "Shutdown-Printer Startup-Printer Promote-Job "
1279 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1280 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1281 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1282 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1283 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1285 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1286 po
->order_type
= CUPSD_AUTH_ALLOW
;
1287 po
->type
= CUPSD_AUTH_DEFAULT
;
1288 po
->level
= CUPSD_AUTH_USER
;
1290 cupsdAddName(po
, "@SYSTEM");
1291 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1293 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1294 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1295 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1296 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1297 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1298 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1299 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1300 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1301 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1302 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1303 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1304 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1305 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1306 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1307 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1308 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1309 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1310 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1311 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1312 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1313 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1314 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1316 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1318 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1319 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1321 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1322 po
->order_type
= CUPSD_AUTH_ALLOW
;
1324 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1325 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1329 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1330 cupsArrayCount(Policies
));
1331 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1333 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1334 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1335 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1338 * If we are doing a full reload or the server root has changed, flush
1339 * the jobs, printers, etc. and start from scratch...
1342 if (NeedReload
== RELOAD_ALL
||
1343 old_remote_port
!= RemotePort
||
1344 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1345 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1347 mime_type_t
*type
; /* Current type */
1348 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1349 /* MIME type name */
1352 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1355 * Free all memory...
1358 cupsdDeleteAllSubscriptions();
1360 cupsdDeleteAllPrinters();
1362 DefaultPrinter
= NULL
;
1364 if (MimeDatabase
!= NULL
)
1365 mimeDelete(MimeDatabase
);
1369 for (i
= 0; i
< NumMimeTypes
; i
++)
1370 _cupsStrFree(MimeTypes
[i
]);
1376 * Read the MIME type and conversion database...
1379 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1380 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1382 MimeDatabase
= mimeLoadTypes(NULL
, mimedir
);
1383 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1384 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1385 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1389 cupsdLogMessage(CUPSD_LOG_EMERG
,
1390 "Unable to load MIME database from \"%s\" or \"%s\".",
1391 mimedir
, ServerRoot
);
1392 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1396 cupsdLogMessage(CUPSD_LOG_INFO
,
1397 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1398 "%d filters...", mimedir
, ServerRoot
,
1399 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1402 * Create a list of MIME types for the document-format-supported
1406 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1407 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1410 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1412 cupsdLogMessage(CUPSD_LOG_ERROR
,
1413 "Unable to allocate memory for %d MIME types.",
1419 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1421 i
++, type
= mimeNextType(MimeDatabase
))
1423 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1425 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1428 if (i
< NumMimeTypes
)
1429 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1432 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1434 mime_filter_t
*filter
; /* Current filter */
1437 for (type
= mimeFirstType(MimeDatabase
);
1439 type
= mimeNextType(MimeDatabase
))
1440 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1441 type
->super
, type
->type
);
1443 for (filter
= mimeFirstFilter(MimeDatabase
);
1445 filter
= mimeNextFilter(MimeDatabase
))
1446 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1447 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1448 filter
->src
->super
, filter
->src
->type
,
1449 filter
->dst
->super
, filter
->dst
->type
,
1450 filter
->cost
, filter
->filter
);
1457 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1458 cupsdLoadBanners(temp
);
1461 * Load printers and classes...
1464 cupsdLoadAllPrinters();
1465 cupsdLoadAllClasses();
1466 cupsdLoadRemoteCache();
1468 cupsdCreateCommonData();
1471 * Update the printcap file as needed...
1474 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1475 cupsdWritePrintcap();
1478 * Load queued jobs...
1484 * Load subscriptions...
1487 cupsdLoadAllSubscriptions();
1489 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1494 * Not a full reload, so recreate the common printer attributes...
1497 cupsdCreateCommonData();
1500 * Update all printers as needed...
1503 cupsdUpdatePrinters();
1504 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1506 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1510 * Reset the reload state...
1513 NeedReload
= RELOAD_NONE
;
1515 cupsdClearString(&old_serverroot
);
1516 cupsdClearString(&old_requestroot
);
1523 * 'get_address()' - Get an address + port number from a line.
1526 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1527 get_address(const char *value
, /* I - Value string */
1528 int defport
) /* I - Default port */
1530 char buffer
[1024], /* Hostname + port number buffer */
1531 defpname
[255], /* Default port name */
1532 *hostname
, /* Hostname or IP */
1533 *portname
; /* Port number or name */
1534 http_addrlist_t
*addrlist
; /* Address list */
1538 * Check for an empty value...
1543 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1548 * Grab a hostname and port number; if there is no colon and the port name
1549 * is only digits, then we have a port number by itself...
1552 strlcpy(buffer
, value
, sizeof(buffer
));
1554 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1561 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1566 * Use the default port...
1569 sprintf(defpname
, "%d", defport
);
1570 portname
= defpname
;
1576 * The buffer contains just a port number...
1584 if (hostname
&& !strcmp(hostname
, "*"))
1588 * Now lookup the address using httpAddrGetList()...
1591 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1592 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1593 hostname
? hostname
: "(nil)");
1600 * 'get_addr_and_mask()' - Get an IP address and netmask.
1603 static int /* O - 1 on success, 0 on failure */
1604 get_addr_and_mask(const char *value
, /* I - String from config file */
1605 unsigned *ip
, /* O - Address value */
1606 unsigned *mask
) /* O - Mask value */
1608 int i
, j
, /* Looping vars */
1609 family
, /* Address family */
1610 ipcount
; /* Count of fields in address */
1611 unsigned ipval
; /* Value */
1612 const char *maskval
, /* Pointer to start of mask value */
1613 *ptr
, /* Pointer into value */
1618 * Get the address...
1621 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1622 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1624 if ((maskval
= strchr(value
, '/')) != NULL
)
1627 maskval
= value
+ strlen(value
);
1631 * Check for an IPv6 address...
1637 * Parse hexadecimal IPv6 address...
1642 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1646 else if (!strncmp(ptr
, "::", 2))
1648 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1650 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1655 else if (isxdigit(*ptr
& 255))
1657 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1665 ip
[i
/ 2] |= ipval
<< 16;
1679 if (*ptr
&& *ptr
!= '/')
1683 #endif /* AF_INET6 */
1686 * Parse dotted-decimal IPv4 address...
1689 unsigned val
[4]; /* IPv4 address values */
1693 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1696 * Range check the IP numbers...
1699 for (i
= 0; i
< ipcount
; i
++)
1704 * Make sure the trailing values are zeroed, as some C libraries like
1705 * glibc apparently like to fill the unused arguments with garbage...
1708 for (i
= ipcount
; i
< 4; i
++)
1712 * Merge everything into a 32-bit IPv4 address in ip[3]...
1715 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1718 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1724 * Get the netmask value(s)...
1727 memset(mask
, 0, sizeof(unsigned) * 4);
1729 if (strchr(maskval
, '.'))
1732 * Get dotted-decimal mask...
1735 if (family
!= AF_INET
)
1738 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1741 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1742 mask
[0] = mask
[1] = mask
[2] = 0;
1747 * Get address/bits format...
1753 if (family
== AF_INET6
)
1761 mask
[0] = 0xffffffff;
1763 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1766 mask
[1] = 0xffffffff;
1770 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1773 mask
[2] = 0xffffffff;
1777 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1780 mask
[3] = 0xffffffff;
1784 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1787 #endif /* AF_INET6 */
1792 mask
[0] = 0xffffffff;
1793 mask
[1] = 0xffffffff;
1794 mask
[2] = 0xffffffff;
1797 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1799 mask
[3] = 0xffffffff;
1804 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1805 "get_addr_and_mask(value=\"%s\", "
1806 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1807 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1811 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1814 if ((ip
[0] & ~mask
[0]) != 0 ||
1815 (ip
[1] & ~mask
[1]) != 0 ||
1816 (ip
[2] & ~mask
[2]) != 0 ||
1817 (ip
[3] & ~mask
[3]) != 0)
1825 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1828 static int /* O - 1 on success, 0 on failure */
1829 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1830 char *line
, /* I - Line from file */
1831 char *value
, /* I - Start of value data */
1832 int linenum
) /* I - Current line number */
1834 char *valptr
; /* Pointer into value */
1835 unsigned ip
[4], /* IP address components */
1836 mask
[4]; /* IP netmask components */
1839 if (!strcasecmp(line
, "Encryption"))
1842 * "Encryption xxx" - set required encryption level...
1845 if (!strcasecmp(value
, "never"))
1846 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1847 else if (!strcasecmp(value
, "always"))
1849 cupsdLogMessage(CUPSD_LOG_ERROR
,
1850 "Encryption value \"%s\" on line %d is invalid in this "
1851 "context. Using \"required\" instead.", value
, linenum
);
1853 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1855 else if (!strcasecmp(value
, "required"))
1856 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1857 else if (!strcasecmp(value
, "ifrequested"))
1858 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1861 cupsdLogMessage(CUPSD_LOG_ERROR
,
1862 "Unknown Encryption value %s on line %d.", value
, linenum
);
1866 else if (!strcasecmp(line
, "Order"))
1869 * "Order Deny,Allow" or "Order Allow,Deny"...
1872 if (!strncasecmp(value
, "deny", 4))
1873 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1874 else if (!strncasecmp(value
, "allow", 5))
1875 loc
->order_type
= CUPSD_AUTH_DENY
;
1878 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1883 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1886 * Allow [From] host/ip...
1887 * Deny [From] host/ip...
1892 if (!strncasecmp(value
, "from", 4))
1895 * Strip leading "from"...
1900 while (isspace(*value
& 255))
1908 * Find the end of the value...
1911 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1913 while (isspace(*valptr
& 255))
1917 * Figure out what form the allow/deny address takes:
1928 * nnn.nnn.nnn.nnn/mm
1929 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1932 if (!strcasecmp(value
, "all"))
1938 if (!strcasecmp(line
, "Allow"))
1939 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1941 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1943 else if (!strcasecmp(value
, "none"))
1949 if (!strcasecmp(line
, "Allow"))
1950 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1952 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1955 else if (value
[0] == '*' || value
[0] == '.' ||
1956 (!isdigit(value
[0] & 255) && value
[0] != '['))
1958 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1959 #endif /* AF_INET6 */
1962 * Host or domain name...
1965 if (value
[0] == '*')
1968 if (!strcasecmp(line
, "Allow"))
1969 cupsdAddNameMask(&(loc
->allow
), value
);
1971 cupsdAddNameMask(&(loc
->deny
), value
);
1976 * One of many IP address forms...
1979 if (!get_addr_and_mask(value
, ip
, mask
))
1981 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1986 if (!strcasecmp(line
, "Allow"))
1987 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
1989 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
1993 * Advance to next value...
1999 else if (!strcasecmp(line
, "AuthType"))
2002 * AuthType {none,basic,digest,basicdigest,negotiate,default}
2005 if (!strcasecmp(value
, "none"))
2007 loc
->type
= CUPSD_AUTH_NONE
;
2008 loc
->level
= CUPSD_AUTH_ANON
;
2010 else if (!strcasecmp(value
, "basic"))
2012 loc
->type
= CUPSD_AUTH_BASIC
;
2014 if (loc
->level
== CUPSD_AUTH_ANON
)
2015 loc
->level
= CUPSD_AUTH_USER
;
2017 else if (!strcasecmp(value
, "digest"))
2019 loc
->type
= CUPSD_AUTH_DIGEST
;
2021 if (loc
->level
== CUPSD_AUTH_ANON
)
2022 loc
->level
= CUPSD_AUTH_USER
;
2024 else if (!strcasecmp(value
, "basicdigest"))
2026 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2028 if (loc
->level
== CUPSD_AUTH_ANON
)
2029 loc
->level
= CUPSD_AUTH_USER
;
2031 else if (!strcasecmp(value
, "default"))
2033 loc
->type
= CUPSD_AUTH_DEFAULT
;
2035 if (loc
->level
== CUPSD_AUTH_ANON
)
2036 loc
->level
= CUPSD_AUTH_USER
;
2039 else if (!strcasecmp(value
, "negotiate"))
2041 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2043 if (loc
->level
== CUPSD_AUTH_ANON
)
2044 loc
->level
= CUPSD_AUTH_USER
;
2046 #endif /* HAVE_GSSAPI */
2049 cupsdLogMessage(CUPSD_LOG_WARN
,
2050 "Unknown authorization type %s on line %d.",
2055 else if (!strcasecmp(line
, "AuthClass"))
2058 * AuthClass anonymous, user, system, group
2061 if (!strcasecmp(value
, "anonymous"))
2063 loc
->type
= CUPSD_AUTH_NONE
;
2064 loc
->level
= CUPSD_AUTH_ANON
;
2066 cupsdLogMessage(CUPSD_LOG_WARN
,
2067 "\"AuthClass %s\" is deprecated; consider removing "
2071 else if (!strcasecmp(value
, "user"))
2073 loc
->level
= CUPSD_AUTH_USER
;
2075 cupsdLogMessage(CUPSD_LOG_WARN
,
2076 "\"AuthClass %s\" is deprecated; consider using "
2077 "\"Require valid-user\" on line %d.",
2080 else if (!strcasecmp(value
, "group"))
2082 loc
->level
= CUPSD_AUTH_GROUP
;
2084 cupsdLogMessage(CUPSD_LOG_WARN
,
2085 "\"AuthClass %s\" is deprecated; consider using "
2086 "\"Require user @groupname\" on line %d.",
2089 else if (!strcasecmp(value
, "system"))
2091 loc
->level
= CUPSD_AUTH_GROUP
;
2093 cupsdAddName(loc
, "@SYSTEM");
2095 cupsdLogMessage(CUPSD_LOG_WARN
,
2096 "\"AuthClass %s\" is deprecated; consider using "
2097 "\"Require user @SYSTEM\" on line %d.",
2102 cupsdLogMessage(CUPSD_LOG_WARN
,
2103 "Unknown authorization class %s on line %d.",
2108 else if (!strcasecmp(line
, "AuthGroupName"))
2110 cupsdAddName(loc
, value
);
2112 cupsdLogMessage(CUPSD_LOG_WARN
,
2113 "\"AuthGroupName %s\" directive is deprecated; consider "
2114 "using \"Require user @%s\" on line %d.",
2115 value
, value
, linenum
);
2117 else if (!strcasecmp(line
, "Require"))
2120 * Apache synonym for AuthClass and AuthGroupName...
2124 * Require valid-user
2125 * Require group names
2126 * Require user names
2129 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2134 if (!strcasecmp(value
, "valid-user") ||
2135 !strcasecmp(value
, "user"))
2136 loc
->level
= CUPSD_AUTH_USER
;
2137 else if (!strcasecmp(value
, "group"))
2138 loc
->level
= CUPSD_AUTH_GROUP
;
2141 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2147 * Get the list of names from the line...
2150 for (value
= valptr
; *value
;)
2152 while (isspace(*value
& 255))
2155 #ifdef HAVE_AUTHORIZATION_H
2156 if (!strncmp(value
, "@AUTHKEY(", 9))
2159 * Grab "@AUTHKEY(name)" value...
2162 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2168 #endif /* HAVE_AUTHORIZATION_H */
2169 if (*value
== '\"' || *value
== '\'')
2172 * Grab quoted name...
2175 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2182 * Grab literal name.
2185 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2191 cupsdAddName(loc
, value
);
2193 for (value
= valptr
; isspace(*value
& 255); value
++);
2196 else if (!strcasecmp(line
, "Satisfy"))
2198 if (!strcasecmp(value
, "all"))
2199 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2200 else if (!strcasecmp(value
, "any"))
2201 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2204 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2217 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2220 static int /* O - FatalErrors bits */
2221 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2223 int fatal
; /* FatalErrors bits */
2224 char value
[1024], /* Value string */
2225 *valstart
, /* Pointer into value */
2226 *valend
; /* End of value */
2230 * Empty FatalErrors line yields NULL pointer...
2234 return (CUPSD_FATAL_NONE
);
2237 * Loop through the value string,...
2240 strlcpy(value
, s
, sizeof(value
));
2242 fatal
= CUPSD_FATAL_NONE
;
2244 for (valstart
= value
; *valstart
;)
2247 * Get the current space/comma-delimited kind name...
2250 for (valend
= valstart
; *valend
; valend
++)
2251 if (isspace(*valend
& 255) || *valend
== ',')
2258 * Add the error to the bitmask...
2261 if (!strcasecmp(valstart
, "all"))
2262 fatal
= CUPSD_FATAL_ALL
;
2263 else if (!strcasecmp(valstart
, "browse"))
2264 fatal
|= CUPSD_FATAL_BROWSE
;
2265 else if (!strcasecmp(valstart
, "-browse"))
2266 fatal
&= ~CUPSD_FATAL_BROWSE
;
2267 else if (!strcasecmp(valstart
, "config"))
2268 fatal
|= CUPSD_FATAL_CONFIG
;
2269 else if (!strcasecmp(valstart
, "-config"))
2270 fatal
&= ~CUPSD_FATAL_CONFIG
;
2271 else if (!strcasecmp(valstart
, "listen"))
2272 fatal
|= CUPSD_FATAL_LISTEN
;
2273 else if (!strcasecmp(valstart
, "-listen"))
2274 fatal
&= ~CUPSD_FATAL_LISTEN
;
2275 else if (!strcasecmp(valstart
, "log"))
2276 fatal
|= CUPSD_FATAL_LOG
;
2277 else if (!strcasecmp(valstart
, "-log"))
2278 fatal
&= ~CUPSD_FATAL_LOG
;
2279 else if (!strcasecmp(valstart
, "permissions"))
2280 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2281 else if (!strcasecmp(valstart
, "-permissions"))
2282 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2283 else if (strcasecmp(valstart
, "none"))
2284 cupsdLogMessage(CUPSD_LOG_ERROR
,
2285 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2287 for (valstart
= valend
; *valstart
; valstart
++)
2288 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2297 * 'parse_groups()' - Parse system group names in a string.
2300 static int /* O - 1 on success, 0 on failure */
2301 parse_groups(const char *s
) /* I - Space-delimited groups */
2303 int status
; /* Return status */
2304 char value
[1024], /* Value string */
2305 *valstart
, /* Pointer into value */
2306 *valend
, /* End of value */
2307 quote
; /* Quote character */
2308 struct group
*group
; /* Group */
2312 * Make a copy of the string and parse out the groups...
2315 strlcpy(value
, s
, sizeof(value
));
2320 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2322 if (*valstart
== '\'' || *valstart
== '\"')
2325 * Scan quoted name...
2328 quote
= *valstart
++;
2330 for (valend
= valstart
; *valend
; valend
++)
2331 if (*valend
== quote
)
2337 * Scan space or comma-delimited name...
2340 for (valend
= valstart
; *valend
; valend
++)
2341 if (isspace(*valend
) || *valend
== ',')
2348 group
= getgrnam(valstart
);
2351 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2352 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2363 while (*valstart
== ',' || isspace(*valstart
))
2372 * 'parse_protocols()' - Parse browse protocols in a string.
2375 static int /* O - Browse protocol bits */
2376 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2378 int protocols
; /* Browse protocol bits */
2379 char value
[1024], /* Value string */
2380 *valstart
, /* Pointer into value */
2381 *valend
; /* End of value */
2385 * Empty protocol line yields NULL pointer...
2392 * Loop through the value string,...
2395 strlcpy(value
, s
, sizeof(value
));
2399 for (valstart
= value
; *valstart
;)
2402 * Get the current space/comma-delimited protocol name...
2405 for (valend
= valstart
; *valend
; valend
++)
2406 if (isspace(*valend
& 255) || *valend
== ',')
2413 * Add the protocol to the bitmask...
2416 if (!strcasecmp(valstart
, "cups"))
2417 protocols
|= BROWSE_CUPS
;
2418 else if (!strcasecmp(valstart
, "slp"))
2419 protocols
|= BROWSE_SLP
;
2420 else if (!strcasecmp(valstart
, "ldap"))
2421 protocols
|= BROWSE_LDAP
;
2422 else if (!strcasecmp(valstart
, "dnssd") ||
2423 !strcasecmp(valstart
, "dns-sd") ||
2424 !strcasecmp(valstart
, "bonjour"))
2425 protocols
|= BROWSE_DNSSD
;
2426 else if (!strcasecmp(valstart
, "lpd"))
2427 protocols
|= BROWSE_LPD
;
2428 else if (!strcasecmp(valstart
, "smb"))
2429 protocols
|= BROWSE_SMB
;
2430 else if (!strcasecmp(valstart
, "all"))
2431 protocols
|= BROWSE_ALL
;
2432 else if (strcasecmp(valstart
, "none"))
2433 cupsdLogMessage(CUPSD_LOG_ERROR
,
2434 "Unknown browse protocol \"%s\" ignored.", valstart
);
2436 for (valstart
= valend
; *valstart
; valstart
++)
2437 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2446 * 'read_configuration()' - Read a configuration file.
2449 static int /* O - 1 on success, 0 on failure */
2450 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2452 int i
; /* Looping var */
2453 int linenum
; /* Current line number */
2454 char line
[HTTP_MAX_BUFFER
],
2455 /* Line from file */
2456 temp
[HTTP_MAX_BUFFER
],
2457 /* Temporary buffer for value */
2458 *ptr
, /* Pointer into line/temp */
2459 *value
, /* Pointer to value */
2460 *valueptr
; /* Pointer into value */
2461 int valuelen
; /* Length of value */
2462 cupsd_var_t
const *var
; /* Current variable */
2463 http_addrlist_t
*addrlist
, /* Address list */
2464 *addr
; /* Current address */
2465 unsigned ip
[4], /* Address value */
2466 mask
[4]; /* Netmask value */
2467 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2468 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2469 cupsd_location_t
*location
; /* Browse location */
2470 cups_file_t
*incfile
; /* Include file */
2471 char incname
[1024]; /* Include filename */
2472 struct group
*group
; /* Group */
2476 * Loop through each line in the file...
2481 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2484 * Decode the directive...
2487 if (!strcasecmp(line
, "Include") && value
)
2493 if (value
[0] == '/')
2494 strlcpy(incname
, value
, sizeof(incname
));
2496 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2498 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2499 cupsdLogMessage(CUPSD_LOG_ERROR
,
2500 "Unable to include config file \"%s\" - %s",
2501 incname
, strerror(errno
));
2504 read_configuration(incfile
);
2505 cupsFileClose(incfile
);
2508 else if (!strcasecmp(line
, "<Location") && value
)
2514 linenum
= read_location(fp
, value
, linenum
);
2518 else if (!strcasecmp(line
, "<Policy") && value
)
2524 linenum
= read_policy(fp
, value
, linenum
);
2528 else if (!strcasecmp(line
, "FatalErrors"))
2529 FatalErrors
= parse_fatal_errors(value
);
2530 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2532 JobRetryInterval
= atoi(value
);
2533 cupsdLogMessage(CUPSD_LOG_WARN
,
2534 "FaxRetryInterval is deprecated; use "
2535 "JobRetryInterval on line %d.", linenum
);
2537 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2539 JobRetryLimit
= atoi(value
);
2540 cupsdLogMessage(CUPSD_LOG_WARN
,
2541 "FaxRetryLimit is deprecated; use "
2542 "JobRetryLimit on line %d.", linenum
);
2544 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2546 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2547 #endif /* HAVE_SSL */
2551 * Add listening address(es) to the list...
2554 cupsd_listener_t
*lis
; /* New listeners array */
2558 * Get the address list...
2561 addrlist
= get_address(value
, IPP_PORT
);
2565 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2571 * Add each address...
2574 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2577 * See if this address is already present...
2580 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2582 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2583 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2584 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2589 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2590 cupsdLogMessage(CUPSD_LOG_WARN
,
2591 "Duplicate listen address \"%s\" ignored.", temp
);
2596 * Allocate another listener...
2600 Listeners
= cupsArrayNew(NULL
, NULL
);
2604 cupsdLogMessage(CUPSD_LOG_ERROR
,
2605 "Unable to allocate %s at line %d - %s.",
2606 line
, linenum
, strerror(errno
));
2610 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2612 cupsdLogMessage(CUPSD_LOG_ERROR
,
2613 "Unable to allocate %s at line %d - %s.",
2614 line
, linenum
, strerror(errno
));
2618 cupsArrayAdd(Listeners
, lis
);
2621 * Copy the current address and log it...
2624 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2628 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2629 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2630 #endif /* HAVE_SSL */
2632 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2635 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2636 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2638 #endif /* AF_LOCAL */
2639 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv%d)", temp
,
2640 _httpAddrPort(&(lis
->address
)),
2641 _httpAddrFamily(&(lis
->address
)) == AF_INET
? 4 : 6);
2643 if (!httpAddrLocalhost(&(lis
->address
)))
2644 RemotePort
= _httpAddrPort(&(lis
->address
));
2651 httpAddrFreeList(addrlist
);
2653 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2656 * Add a browse address to the list...
2659 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2662 if (NumBrowsers
== 0)
2663 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2665 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2669 cupsdLogMessage(CUPSD_LOG_ERROR
,
2670 "Unable to allocate BrowseAddress at line %d - %s.",
2671 linenum
, strerror(errno
));
2676 dira
+= NumBrowsers
;
2678 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2680 if (!strcasecmp(value
, "@LOCAL"))
2683 * Send browse data to all local interfaces...
2686 strcpy(dira
->iface
, "*");
2689 else if (!strncasecmp(value
, "@IF(", 4))
2692 * Send browse data to the named interface...
2695 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2697 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2703 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2706 * Only IPv4 addresses are supported...
2709 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2710 if (_httpAddrFamily(&(addr
->addr
)) == AF_INET
)
2715 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2716 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2718 cupsdLogMessage(CUPSD_LOG_INFO
,
2719 "Sending browsing info to %s:%d (IPv4)",
2720 temp
, _httpAddrPort(&(dira
->to
)));
2725 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2728 httpAddrFreeList(addrlist
);
2731 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2734 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2737 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2740 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2741 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2742 cupsdAddLocation(location
);
2744 if (location
== NULL
)
2745 cupsdLogMessage(CUPSD_LOG_ERROR
,
2746 "Unable to initialize browse access control list.");
2747 else if (!strncasecmp(value
, "deny", 4))
2748 location
->order_type
= CUPSD_AUTH_ALLOW
;
2749 else if (!strncasecmp(value
, "allow", 5))
2750 location
->order_type
= CUPSD_AUTH_DENY
;
2752 cupsdLogMessage(CUPSD_LOG_ERROR
,
2753 "Unknown BrowseOrder value %s on line %d.",
2756 else if (!strcasecmp(line
, "BrowseProtocols") ||
2757 !strcasecmp(line
, "BrowseLocalProtocols") ||
2758 !strcasecmp(line
, "BrowseRemoteProtocols"))
2761 * "BrowseProtocols name [... name]"
2762 * "BrowseLocalProtocols name [... name]"
2763 * "BrowseRemoteProtocols name [... name]"
2766 int protocols
= parse_protocols(value
);
2770 cupsdLogMessage(CUPSD_LOG_ERROR
,
2771 "Unknown browse protocol \"%s\" on line %d.",
2776 if (strcasecmp(line
, "BrowseLocalProtocols"))
2777 BrowseRemoteProtocols
= protocols
;
2778 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2779 BrowseLocalProtocols
= protocols
;
2781 else if ((!strcasecmp(line
, "BrowseAllow") ||
2782 !strcasecmp(line
, "BrowseDeny")) && value
)
2785 * BrowseAllow [From] host/ip...
2786 * BrowseDeny [From] host/ip...
2789 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2790 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2791 cupsdAddLocation(location
);
2794 if (location
== NULL
)
2795 cupsdLogMessage(CUPSD_LOG_ERROR
,
2796 "Unable to initialize browse access control list.");
2799 if (!strncasecmp(value
, "from", 4))
2802 * Skip leading "from"...
2811 * Skip leading whitespace...
2814 while (isspace(*value
& 255))
2821 * Find the end of the value...
2824 for (valueptr
= value
;
2825 *valueptr
&& !isspace(*valueptr
& 255);
2828 while (isspace(*valueptr
& 255))
2832 * Figure out what form the allow/deny address takes:
2843 * nnn.nnn.nnn.nnn/mm
2844 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2847 if (!strcasecmp(value
, "all"))
2853 if (!strcasecmp(line
, "BrowseAllow"))
2854 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2856 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2858 else if (!strcasecmp(value
, "none"))
2864 if (!strcasecmp(line
, "BrowseAllow"))
2865 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2867 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2870 else if (value
[0] == '*' || value
[0] == '.' ||
2871 (!isdigit(value
[0] & 255) && value
[0] != '['))
2873 else if (value
[0] == '*' || value
[0] == '.' ||
2874 !isdigit(value
[0] & 255))
2875 #endif /* AF_INET6 */
2878 * Host or domain name...
2881 if (!strcasecmp(line
, "BrowseAllow"))
2882 cupsdAddNameMask(&(location
->allow
), value
);
2884 cupsdAddNameMask(&(location
->deny
), value
);
2889 * One of many IP address forms...
2892 if (!get_addr_and_mask(value
, ip
, mask
))
2894 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2899 if (!strcasecmp(line
, "BrowseAllow"))
2900 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2902 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2906 * Advance to next value...
2913 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2916 * BrowseRelay [from] source [to] destination
2920 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2922 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2926 cupsdLogMessage(CUPSD_LOG_ERROR
,
2927 "Unable to allocate BrowseRelay at line %d - %s.",
2928 linenum
, strerror(errno
));
2935 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2937 if (!strncasecmp(value
, "from ", 5))
2940 * Skip leading "from"...
2946 * Skip leading whitespace...
2949 while (isspace(*value
))
2954 * Find the end of the from value...
2957 for (valueptr
= value
;
2958 *valueptr
&& !isspace(*valueptr
& 255);
2961 while (isspace(*valueptr
& 255))
2965 * Figure out what form the from address takes:
2974 * nnn.nnn.nnn.nnn/mm
2975 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2979 if (value
[0] == '*' || value
[0] == '.' ||
2980 (!isdigit(value
[0] & 255) && value
[0] != '['))
2982 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2983 #endif /* AF_INET6 */
2986 * Host or domain name...
2989 if (!cupsdAddNameMask(&(relay
->from
), value
))
2991 cupsdLogMessage(CUPSD_LOG_ERROR
,
2992 "Unable to allocate BrowseRelay name at line %d - %s.",
2993 linenum
, strerror(errno
));
3000 * One of many IP address forms...
3003 if (!get_addr_and_mask(value
, ip
, mask
))
3005 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
3010 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
3012 cupsdLogMessage(CUPSD_LOG_ERROR
,
3013 "Unable to allocate BrowseRelay IP at line %d - %s.",
3014 linenum
, strerror(errno
));
3020 * Get "to" address and port...
3023 if (!strncasecmp(valueptr
, "to ", 3))
3026 * Strip leading "to"...
3031 while (isspace(*valueptr
))
3035 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3038 * Only IPv4 addresses are supported...
3041 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3042 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3047 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3049 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3051 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3052 value
, temp
, _httpAddrPort(&(relay
->to
)));
3058 cupsArrayDelete(relay
->from
);
3061 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3065 httpAddrFreeList(addrlist
);
3069 cupsArrayDelete(relay
->from
);
3072 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3076 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3079 * BrowsePoll address[:port]
3082 char *portname
; /* Port name */
3083 int portnum
; /* Port number */
3084 struct servent
*service
; /* Service */
3088 * Extract the port name from the address...
3091 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3095 if (isdigit(*portname
& 255))
3096 portnum
= atoi(portname
);
3097 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3098 portnum
= ntohs(service
->s_port
);
3101 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed.",
3107 portnum
= ippPort();
3110 * Add the poll entry...
3114 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3116 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3120 cupsdLogMessage(CUPSD_LOG_ERROR
,
3121 "Unable to allocate BrowsePoll at line %d - %s.",
3122 linenum
, strerror(errno
));
3130 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3132 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3133 pollp
->port
= portnum
;
3135 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3138 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3141 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3144 if (!strcasecmp(value
, "none"))
3145 DefaultAuthType
= CUPSD_AUTH_NONE
;
3146 else if (!strcasecmp(value
, "basic"))
3147 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3148 else if (!strcasecmp(value
, "digest"))
3149 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3150 else if (!strcasecmp(value
, "basicdigest"))
3151 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3153 else if (!strcasecmp(value
, "negotiate"))
3154 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3155 #endif /* HAVE_GSSAPI */
3158 cupsdLogMessage(CUPSD_LOG_WARN
,
3159 "Unknown default authorization type %s on line %d.",
3161 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3166 else if (!strcasecmp(line
, "DefaultEncryption"))
3169 * DefaultEncryption {Never,IfRequested,Required}
3172 if (!value
|| !strcasecmp(value
, "never"))
3173 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3174 else if (!strcasecmp(value
, "required"))
3175 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3176 else if (!strcasecmp(value
, "ifrequested"))
3177 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3180 cupsdLogMessage(CUPSD_LOG_WARN
,
3181 "Unknown default encryption %s on line %d.",
3183 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3187 #endif /* HAVE_SSL */
3188 else if (!strcasecmp(line
, "User") && value
)
3191 * User ID to run as...
3194 if (isdigit(value
[0] & 255))
3196 int uid
= atoi(value
);
3199 cupsdLogMessage(CUPSD_LOG_ERROR
,
3200 "Will not use User 0 as specified on line %d "
3201 "for security reasons. You must use a non-"
3202 "privileged account instead.",
3209 struct passwd
*p
; /* Password information */
3212 p
= getpwnam(value
);
3217 cupsdLogMessage(CUPSD_LOG_ERROR
,
3218 "Will not use User %s (UID=0) as specified on line "
3219 "%d for security reasons. You must use a non-"
3220 "privileged account instead.",
3226 cupsdLogMessage(CUPSD_LOG_ERROR
,
3227 "Unknown User \"%s\" on line %d, ignoring.",
3231 else if (!strcasecmp(line
, "Group") && value
)
3234 * Group ID to run as...
3237 if (isdigit(value
[0]))
3238 Group
= atoi(value
);
3242 group
= getgrnam(value
);
3245 Group
= group
->gr_gid
;
3247 cupsdLogMessage(CUPSD_LOG_ERROR
,
3248 "Unknown Group \"%s\" on line %d, ignoring.",
3252 else if (!strcasecmp(line
, "SystemGroup") && value
)
3255 * SystemGroup (admin) group(s)...
3258 if (!parse_groups(value
))
3259 cupsdLogMessage(CUPSD_LOG_ERROR
,
3260 "Unknown SystemGroup \"%s\" on line %d, ignoring.",
3263 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3266 * Do hostname lookups?
3269 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3270 !strcasecmp(value
, "false"))
3271 HostNameLookups
= 0;
3272 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3273 !strcasecmp(value
, "true"))
3274 HostNameLookups
= 1;
3275 else if (!strcasecmp(value
, "double"))
3276 HostNameLookups
= 2;
3278 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3281 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3284 * Amount of logging to do to access log...
3287 if (!strcasecmp(value
, "all"))
3288 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3289 else if (!strcasecmp(value
, "actions"))
3290 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3291 else if (!strcasecmp(value
, "config"))
3292 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3294 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3297 else if (!strcasecmp(line
, "LogLevel") && value
)
3300 * Amount of logging to do to error log...
3303 if (!strcasecmp(value
, "debug2"))
3304 LogLevel
= CUPSD_LOG_DEBUG2
;
3305 else if (!strcasecmp(value
, "debug"))
3306 LogLevel
= CUPSD_LOG_DEBUG
;
3307 else if (!strcasecmp(value
, "info"))
3308 LogLevel
= CUPSD_LOG_INFO
;
3309 else if (!strcasecmp(value
, "notice"))
3310 LogLevel
= CUPSD_LOG_NOTICE
;
3311 else if (!strcasecmp(value
, "warn"))
3312 LogLevel
= CUPSD_LOG_WARN
;
3313 else if (!strcasecmp(value
, "error"))
3314 LogLevel
= CUPSD_LOG_ERROR
;
3315 else if (!strcasecmp(value
, "crit"))
3316 LogLevel
= CUPSD_LOG_CRIT
;
3317 else if (!strcasecmp(value
, "alert"))
3318 LogLevel
= CUPSD_LOG_ALERT
;
3319 else if (!strcasecmp(value
, "emerg"))
3320 LogLevel
= CUPSD_LOG_EMERG
;
3321 else if (!strcasecmp(value
, "none"))
3322 LogLevel
= CUPSD_LOG_NONE
;
3324 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3327 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3330 * Amount of logging to do to error log...
3333 if (!strcasecmp(value
, "standard"))
3334 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3335 else if (!strcasecmp(value
, "usecs"))
3336 LogTimeFormat
= CUPSD_TIME_USECS
;
3338 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3341 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3344 * Format of printcap file?
3347 if (!strcasecmp(value
, "bsd"))
3348 PrintcapFormat
= PRINTCAP_BSD
;
3349 else if (!strcasecmp(value
, "plist"))
3350 PrintcapFormat
= PRINTCAP_PLIST
;
3351 else if (!strcasecmp(value
, "solaris"))
3352 PrintcapFormat
= PRINTCAP_SOLARIS
;
3354 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3357 else if (!strcasecmp(line
, "ServerTokens") && value
)
3360 * Set the string used for the Server header...
3363 struct utsname plat
; /* Platform info */
3368 if (!strcasecmp(value
, "ProductOnly"))
3369 cupsdSetString(&ServerHeader
, "CUPS");
3370 else if (!strcasecmp(value
, "Major"))
3371 cupsdSetString(&ServerHeader
, "CUPS/1");
3372 else if (!strcasecmp(value
, "Minor"))
3373 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3374 else if (!strcasecmp(value
, "Minimal"))
3375 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3376 else if (!strcasecmp(value
, "OS"))
3377 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3378 else if (!strcasecmp(value
, "Full"))
3379 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3381 else if (!strcasecmp(value
, "None"))
3382 cupsdClearString(&ServerHeader
);
3384 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3387 else if (!strcasecmp(line
, "PassEnv") && value
)
3390 * PassEnv variable [... variable]
3395 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3396 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3399 if (value
[valuelen
])
3401 value
[valuelen
] = '\0';
3405 cupsdSetEnv(value
, NULL
);
3407 for (value
+= valuelen
; *value
; value
++)
3408 if (!isspace(*value
) || *value
!= ',')
3412 else if (!strcasecmp(line
, "ServerAlias") && value
)
3415 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3417 cupsdAddAlias(ServerAlias
, value
);
3419 else if (!strcasecmp(line
, "SetEnv") && value
)
3422 * SetEnv variable value
3425 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3433 while (isspace(*valueptr
& 255))
3436 cupsdSetEnv(value
, valueptr
);
3439 cupsdLogMessage(CUPSD_LOG_ERROR
,
3440 "Missing value for SetEnv directive on line %d.",
3444 else if (!strcasecmp(line
, "SSLOptions"))
3447 * SSLOptions options
3450 if (!value
|| !strcasecmp(value
, "none"))
3451 SSLOptions
= CUPSD_SSL_NONE
;
3452 else if (!strcasecmp(value
, "noemptyfragments"))
3453 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3455 cupsdLogMessage(CUPSD_LOG_ERROR
,
3456 "Unknown value \"%s\" for SSLOptions directive on "
3457 "line %d.", value
, linenum
);
3459 #endif /* HAVE_SSL */
3463 * Find a simple variable in the list...
3466 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3467 if (!strcasecmp(line
, var
->name
))
3473 * Unknown directive! Output an error message and continue...
3477 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3480 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3487 case CUPSD_VARTYPE_INTEGER
:
3489 cupsdLogMessage(CUPSD_LOG_ERROR
,
3490 "Missing integer value for %s on line %d.",
3495 char *units
; /* Units */
3498 n
= strtol(value
, &units
, 0);
3500 if (units
&& *units
)
3502 if (tolower(units
[0] & 255) == 'g')
3503 n
*= 1024 * 1024 * 1024;
3504 else if (tolower(units
[0] & 255) == 'm')
3506 else if (tolower(units
[0] & 255) == 'k')
3508 else if (tolower(units
[0] & 255) == 't')
3513 cupsdLogMessage(CUPSD_LOG_ERROR
,
3514 "Bad negative integer value for %s on line %d.",
3517 *((int *)var
->ptr
) = n
;
3521 case CUPSD_VARTYPE_BOOLEAN
:
3523 cupsdLogMessage(CUPSD_LOG_ERROR
,
3524 "Missing boolean value for %s on line %d.",
3526 else if (!strcasecmp(value
, "true") ||
3527 !strcasecmp(value
, "on") ||
3528 !strcasecmp(value
, "enabled") ||
3529 !strcasecmp(value
, "yes") ||
3531 *((int *)var
->ptr
) = TRUE
;
3532 else if (!strcasecmp(value
, "false") ||
3533 !strcasecmp(value
, "off") ||
3534 !strcasecmp(value
, "disabled") ||
3535 !strcasecmp(value
, "no") ||
3536 !strcasecmp(value
, "0"))
3537 *((int *)var
->ptr
) = FALSE
;
3539 cupsdLogMessage(CUPSD_LOG_ERROR
,
3540 "Unknown boolean value %s on line %d.",
3544 case CUPSD_VARTYPE_PATHNAME
:
3547 cupsdLogMessage(CUPSD_LOG_ERROR
,
3548 "Missing pathname value for %s on line %d.",
3553 if (value
[0] == '/')
3554 strlcpy(temp
, value
, sizeof(temp
));
3556 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3558 if (access(temp
, 0))
3560 cupsdLogMessage(CUPSD_LOG_ERROR
,
3561 "File or directory for \"%s %s\" on line %d "
3562 "does not exist.", line
, value
, linenum
);
3566 case CUPSD_VARTYPE_STRING
:
3567 cupsdSetString((char **)var
->ptr
, value
);
3578 * 'read_location()' - Read a <Location path> definition.
3581 static int /* O - New line number or 0 on error */
3582 read_location(cups_file_t
*fp
, /* I - Configuration file */
3583 char *location
, /* I - Location name/path */
3584 int linenum
) /* I - Current line number */
3586 cupsd_location_t
*loc
, /* New location */
3587 *parent
; /* Parent location */
3588 char line
[HTTP_MAX_BUFFER
],
3590 *value
, /* Value for directive */
3591 *valptr
; /* Pointer into value */
3594 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3595 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3597 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3601 cupsdAddLocation(parent
);
3603 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3608 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3611 * Decode the directive...
3614 if (!strcasecmp(line
, "</Location>"))
3616 else if (!strcasecmp(line
, "<Limit") ||
3617 !strcasecmp(line
, "<LimitExcept"))
3621 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3622 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3628 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3631 cupsdAddLocation(loc
);
3636 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3641 if (!strcmp(value
, "ALL"))
3642 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3643 else if (!strcmp(value
, "GET"))
3644 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3645 else if (!strcmp(value
, "HEAD"))
3646 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3647 else if (!strcmp(value
, "OPTIONS"))
3648 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3649 else if (!strcmp(value
, "POST"))
3650 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3651 else if (!strcmp(value
, "PUT"))
3652 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3653 else if (!strcmp(value
, "TRACE"))
3654 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3656 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3659 for (value
= valptr
; isspace(*value
& 255); value
++);
3662 if (!strcasecmp(line
, "<LimitExcept"))
3663 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3665 parent
->limit
&= ~loc
->limit
;
3667 else if (!strcasecmp(line
, "</Limit>") ||
3668 !strcasecmp(line
, "</LimitExcept>"))
3670 else if (!parse_aaa(loc
, line
, value
, linenum
))
3672 cupsdLogMessage(CUPSD_LOG_ERROR
,
3673 "Unknown Location directive %s on line %d.",
3675 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3680 cupsdLogMessage(CUPSD_LOG_ERROR
,
3681 "Unexpected end-of-file at line %d while reading location.",
3684 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3689 * 'read_policy()' - Read a <Policy name> definition.
3692 static int /* O - New line number or 0 on error */
3693 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3694 char *policy
, /* I - Location name/path */
3695 int linenum
) /* I - Current line number */
3697 int i
; /* Looping var */
3698 cupsd_policy_t
*pol
; /* Policy */
3699 cupsd_location_t
*op
; /* Policy operation */
3700 int num_ops
; /* Number of IPP operations */
3701 ipp_op_t ops
[100]; /* Operations */
3702 char line
[HTTP_MAX_BUFFER
],
3704 *value
, /* Value for directive */
3705 *valptr
; /* Pointer into value */
3709 * Create the policy...
3712 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3713 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3715 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3719 * Read from the file...
3725 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3728 * Decode the directive...
3731 if (!strcasecmp(line
, "</Policy>"))
3734 cupsdLogMessage(CUPSD_LOG_WARN
,
3735 "Missing </Limit> before </Policy> on line %d.",
3738 set_policy_defaults(pol
);
3742 else if (!strcasecmp(line
, "<Limit") && !op
)
3746 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3747 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3754 * Scan for IPP operation names...
3761 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3766 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3768 if (!strcasecmp(value
, "All"))
3769 ops
[num_ops
] = IPP_ANY_OPERATION
;
3770 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3771 cupsdLogMessage(CUPSD_LOG_ERROR
,
3772 "Bad IPP operation name \"%s\" on line %d.",
3778 cupsdLogMessage(CUPSD_LOG_ERROR
,
3779 "Too many operations listed on line %d.",
3782 for (value
= valptr
; isspace(*value
& 255); value
++);
3786 * If none are specified, apply the policy to all operations...
3791 ops
[0] = IPP_ANY_OPERATION
;
3796 * Add a new policy for the first operation...
3799 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3801 else if (!strcasecmp(line
, "</Limit>") && op
)
3804 * Finish the current operation limit...
3810 * Copy the policy to the other operations...
3813 for (i
= 1; i
< num_ops
; i
++)
3814 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3819 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3820 !strcasecmp(line
, "JobPrivateValues") ||
3821 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3822 !strcasecmp(line
, "SubscriptionPrivateValues"))
3826 cupsdLogMessage(CUPSD_LOG_ERROR
,
3827 "%s directive must appear outside <Limit>...</Limit> "
3828 "on line %d.", line
, linenum
);
3829 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3835 * Pull out whitespace-delimited values...
3841 * Find the end of the current value...
3844 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3850 * Save it appropriately...
3853 if (!strcasecmp(line
, "JobPrivateAccess"))
3856 * JobPrivateAccess {all|default|user/group list|@@ACL}
3859 if (!strcasecmp(value
, "default"))
3861 cupsdAddString(&(pol
->job_access
), "@OWNER");
3862 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3865 cupsdAddString(&(pol
->job_access
), value
);
3867 else if (!strcasecmp(line
, "JobPrivateValues"))
3870 * JobPrivateValues {all|none|default|attribute list}
3873 if (!strcasecmp(value
, "default"))
3875 cupsdAddString(&(pol
->job_attrs
), "job-name");
3876 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3877 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3880 cupsdAddString(&(pol
->job_attrs
), value
);
3882 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3885 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3888 if (!strcasecmp(value
, "default"))
3890 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3891 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3894 cupsdAddString(&(pol
->sub_access
), value
);
3896 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3899 * SubscriptionPrivateValues {all|none|default|attribute list}
3902 if (!strcasecmp(value
, "default"))
3904 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3905 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3906 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3907 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3908 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3911 cupsdAddString(&(pol
->sub_attrs
), value
);
3915 * Find the next string on the line...
3918 for (value
= valptr
; isspace(*value
& 255); value
++);
3924 cupsdLogMessage(CUPSD_LOG_ERROR
,
3925 "Missing <Limit ops> directive before %s on line %d.",
3927 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3930 else if (!parse_aaa(op
, line
, value
, linenum
))
3933 cupsdLogMessage(CUPSD_LOG_ERROR
,
3934 "Unknown Policy Limit directive %s on line %d.",
3937 cupsdLogMessage(CUPSD_LOG_ERROR
,
3938 "Unknown Policy directive %s on line %d.",
3941 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3946 cupsdLogMessage(CUPSD_LOG_ERROR
,
3947 "Unexpected end-of-file at line %d while reading policy "
3948 "\"%s\".", linenum
, policy
);
3950 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3955 * 'set_policy_defaults()' - Set default policy values as needed.
3959 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3961 cupsd_location_t
*op
; /* Policy operation */
3965 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3966 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3967 * upgrades do not introduce new security issues...
3970 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3971 op
->op
== IPP_ANY_OPERATION
)
3973 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3974 op
->op
!= IPP_ANY_OPERATION
)
3977 * Add a new limit for Validate-Job using the Print-Job limit as a
3981 cupsdLogMessage(CUPSD_LOG_WARN
,
3982 "No limit for Validate-Job defined in policy %s "
3983 "- using Print-Job's policy.", pol
->name
);
3985 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3988 cupsdLogMessage(CUPSD_LOG_WARN
,
3989 "No limit for Validate-Job defined in policy %s "
3990 "and no suitable template found.", pol
->name
);
3993 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3994 op
->op
== IPP_ANY_OPERATION
)
3996 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3997 op
->op
!= IPP_ANY_OPERATION
)
4000 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
4004 cupsdLogMessage(CUPSD_LOG_WARN
,
4005 "No limit for Cancel-Jobs defined in policy %s "
4006 "- using Pause-Printer's policy.", pol
->name
);
4008 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
4011 cupsdLogMessage(CUPSD_LOG_WARN
,
4012 "No limit for Cancel-Jobs defined in policy %s "
4013 "and no suitable template found.", pol
->name
);
4016 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == 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 Cancel-My-Jobs using the Send-Document limit as
4027 cupsdLogMessage(CUPSD_LOG_WARN
,
4028 "No limit for Cancel-My-Jobs defined in policy %s "
4029 "- using Send-Document's policy.", pol
->name
);
4031 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4034 cupsdLogMessage(CUPSD_LOG_WARN
,
4035 "No limit for Cancel-My-Jobs defined in policy %s "
4036 "and no suitable template found.", pol
->name
);
4039 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == 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 Close-Job using the Send-Document limit as a
4050 cupsdLogMessage(CUPSD_LOG_WARN
,
4051 "No limit for Close-Job defined in policy %s "
4052 "- using Send-Document's policy.", pol
->name
);
4054 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4057 cupsdLogMessage(CUPSD_LOG_WARN
,
4058 "No limit for Close-Job defined in policy %s "
4059 "and no suitable template found.", pol
->name
);
4062 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4063 op
->op
== IPP_ANY_OPERATION
)
4065 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4066 op
->op
!= IPP_ANY_OPERATION
)
4069 * Add a new limit for CUPS-Get-Document using the Send-Document
4070 * limit as a template...
4073 cupsdLogMessage(CUPSD_LOG_WARN
,
4074 "No limit for CUPS-Get-Document defined in policy %s "
4075 "- using Send-Document's policy.", pol
->name
);
4077 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4080 cupsdLogMessage(CUPSD_LOG_WARN
,
4081 "No limit for CUPS-Get-Document defined in policy %s "
4082 "and no suitable template found.", pol
->name
);
4086 * Verify we have JobPrivateAccess, JobPrivateValues,
4087 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4090 if (!pol
->job_access
)
4092 cupsdLogMessage(CUPSD_LOG_WARN
,
4093 "No JobPrivateAccess defined in policy %s "
4094 "- using defaults.", pol
->name
);
4095 cupsdAddString(&(pol
->job_access
), "@OWNER");
4096 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4099 if (!pol
->job_attrs
)
4101 cupsdLogMessage(CUPSD_LOG_WARN
,
4102 "No JobPrivateValues defined in policy %s "
4103 "- using defaults.", pol
->name
);
4104 cupsdAddString(&(pol
->job_attrs
), "job-name");
4105 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4106 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4109 if (!pol
->sub_access
)
4111 cupsdLogMessage(CUPSD_LOG_WARN
,
4112 "No SubscriptionPrivateAccess defined in policy %s "
4113 "- using defaults.", pol
->name
);
4114 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4115 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4118 if (!pol
->sub_attrs
)
4120 cupsdLogMessage(CUPSD_LOG_WARN
,
4121 "No SubscriptionPrivateValues defined in policy %s "
4122 "- using defaults.", pol
->name
);
4123 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4124 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4125 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4126 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4127 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4133 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".