2 * "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $"
4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdAddAlias() - Add a host alias.
18 * cupsdCheckPermissions() - Fix the mode and ownership of a file or
20 * cupsdFreeAliases() - Free all of the alias entries.
21 * cupsdReadConfiguration() - Read the cupsd.conf file.
22 * get_address() - Get an address + port number from a line.
23 * get_addr_and_mask() - Get an IP address and netmask.
24 * parse_aaa() - Parse authentication, authorization, and access
26 * parse_fatal_errors() - Parse FatalErrors values in a string.
27 * parse_groups() - Parse system group names in a string.
28 * parse_protocols() - Parse browse protocols in a string.
29 * read_configuration() - Read a configuration file.
30 * read_location() - Read a <Location path> definition.
31 * read_policy() - Read a <Policy name> definition.
32 * set_policy_defaults() - Set default policy values as needed.
36 * Include necessary headers...
42 #include <sys/utsname.h>
47 #endif /* HAVE_LIBPAPER */
51 * Possibly missing network definitions...
55 # define INADDR_NONE 0xffffffff
56 #endif /* !INADDR_NONE */
60 * Configuration variable structure...
65 CUPSD_VARTYPE_INTEGER
, /* Integer option */
66 CUPSD_VARTYPE_STRING
, /* String option */
67 CUPSD_VARTYPE_BOOLEAN
, /* Boolean option */
68 CUPSD_VARTYPE_PATHNAME
/* File/directory name option */
73 char *name
; /* Name of variable */
74 void *ptr
; /* Pointer to variable */
75 cupsd_vartype_t type
; /* Type (int, string, address) */
83 static const cupsd_var_t variables
[] =
85 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
86 { "AutoPurgeJobs", &JobAutoPurge
, CUPSD_VARTYPE_BOOLEAN
},
87 { "BrowseInterval", &BrowseInterval
, CUPSD_VARTYPE_INTEGER
},
89 { "BrowseLDAPBindDN", &BrowseLDAPBindDN
, CUPSD_VARTYPE_STRING
},
91 { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile
, CUPSD_VARTYPE_PATHNAME
},
92 # endif /* HAVE_LDAP_SSL */
93 { "BrowseLDAPDN", &BrowseLDAPDN
, CUPSD_VARTYPE_STRING
},
94 { "BrowseLDAPPassword", &BrowseLDAPPassword
, CUPSD_VARTYPE_STRING
},
95 { "BrowseLDAPServer", &BrowseLDAPServer
, CUPSD_VARTYPE_STRING
},
96 #endif /* HAVE_LDAP */
97 { "BrowseLocalOptions", &BrowseLocalOptions
, CUPSD_VARTYPE_STRING
},
98 { "BrowsePort", &BrowsePort
, CUPSD_VARTYPE_INTEGER
},
99 { "BrowseRemoteOptions", &BrowseRemoteOptions
, CUPSD_VARTYPE_STRING
},
100 { "BrowseShortNames", &BrowseShortNames
, CUPSD_VARTYPE_BOOLEAN
},
101 { "BrowseTimeout", &BrowseTimeout
, CUPSD_VARTYPE_INTEGER
},
102 { "BrowseWebIF", &BrowseWebIF
, CUPSD_VARTYPE_BOOLEAN
},
103 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
104 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
105 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
106 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
107 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
108 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
109 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
110 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
111 { "DefaultPaperSize", &DefaultPaperSize
, CUPSD_VARTYPE_STRING
},
112 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
113 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
114 { "DirtyCleanInterval", &DirtyCleanInterval
, CUPSD_VARTYPE_INTEGER
},
115 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
116 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
117 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
118 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
119 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
120 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
121 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
122 { "HideImplicitMembers", &HideImplicitMembers
, CUPSD_VARTYPE_BOOLEAN
},
123 { "ImplicitClasses", &ImplicitClasses
, CUPSD_VARTYPE_BOOLEAN
},
124 { "ImplicitAnyClasses", &ImplicitAnyClasses
, CUPSD_VARTYPE_BOOLEAN
},
125 { "JobKillDelay", &JobKillDelay
, CUPSD_VARTYPE_INTEGER
},
126 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
127 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_INTEGER
},
128 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_INTEGER
},
129 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
131 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_INTEGER
},
132 #endif /* HAVE_LAUNCHD */
133 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
134 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
135 { "LogDebugHistory", &LogDebugHistory
, CUPSD_VARTYPE_INTEGER
},
136 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
137 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
138 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
139 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
140 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
141 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
142 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
143 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
144 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
145 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
146 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
147 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
148 { "MaxPrinterHistory", &MaxPrinterHistory
, CUPSD_VARTYPE_INTEGER
},
149 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
150 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
151 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
152 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
153 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
154 { "MultipleOperationTimeout", &MultipleOperationTimeout
, CUPSD_VARTYPE_INTEGER
},
155 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
156 { "PageLogFormat", &PageLogFormat
, CUPSD_VARTYPE_STRING
},
157 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_BOOLEAN
},
158 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_BOOLEAN
},
159 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
160 { "PrintcapGUI", &PrintcapGUI
, CUPSD_VARTYPE_STRING
},
161 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_INTEGER
},
162 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
163 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
164 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
165 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_INTEGER
},
166 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
167 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
169 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
170 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
171 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
172 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
173 #endif /* HAVE_SSL */
174 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
175 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
176 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
177 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
178 #ifdef HAVE_AUTHORIZATION_H
179 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
180 #endif /* HAVE_AUTHORIZATION_H */
181 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
},
182 { "Timeout", &Timeout
, CUPSD_VARTYPE_INTEGER
},
183 { "UseNetworkDefault", &UseNetworkDefault
, CUPSD_VARTYPE_BOOLEAN
},
184 { "WebInterface", &WebInterface
, CUPSD_VARTYPE_BOOLEAN
}
186 #define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
189 static const unsigned ones
[4] =
191 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
193 static const unsigned zeros
[4] =
195 0x00000000, 0x00000000, 0x00000000, 0x00000000
203 static http_addrlist_t
*get_address(const char *value
, int defport
);
204 static int get_addr_and_mask(const char *value
, unsigned *ip
,
206 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
207 char *value
, int linenum
);
208 static int parse_fatal_errors(const char *s
);
209 static int parse_groups(const char *s
);
210 static int parse_protocols(const char *s
);
211 static int read_configuration(cups_file_t
*fp
);
212 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
213 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
214 static void set_policy_defaults(cupsd_policy_t
*pol
);
218 * 'cupsdAddAlias()' - Add a host alias.
222 cupsdAddAlias(cups_array_t
*aliases
, /* I - Array of aliases */
223 const char *name
) /* I - Name to add */
225 cupsd_alias_t
*a
; /* New alias */
226 size_t namelen
; /* Length of name */
229 namelen
= strlen(name
);
231 if ((a
= (cupsd_alias_t
*)malloc(sizeof(cupsd_alias_t
) + namelen
)) == NULL
)
234 a
->namelen
= namelen
;
235 strcpy(a
->name
, name
); /* OK since a->name is allocated */
237 cupsArrayAdd(aliases
, a
);
242 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
245 int /* O - 0 on success, -1 on error, 1 on warning */
246 cupsdCheckPermissions(
247 const char *filename
, /* I - File/directory name */
248 const char *suffix
, /* I - Additional file/directory name */
249 int mode
, /* I - Permissions */
250 int user
, /* I - Owner */
251 int group
, /* I - Group */
252 int is_dir
, /* I - 1 = directory, 0 = file */
253 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
255 int dir_created
= 0; /* Did we create a directory? */
256 char pathname
[1024]; /* File name with prefix */
257 struct stat fileinfo
; /* Stat buffer */
258 int is_symlink
; /* Is "filename" a symlink? */
262 * Prepend the given root to the filename before testing it...
267 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
272 * See if we can stat the file/directory...
275 if (lstat(filename
, &fileinfo
))
277 if (errno
== ENOENT
&& create_dir
)
280 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
283 if (mkdir(filename
, mode
))
286 cupsdLogMessage(CUPSD_LOG_ERROR
,
287 "Unable to create directory \"%s\" - %s", filename
,
290 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
297 fileinfo
.st_mode
= mode
| S_IFDIR
;
300 return (create_dir
? -1 : 1);
303 if ((is_symlink
= S_ISLNK(fileinfo
.st_mode
)) != 0)
305 if (stat(filename
, &fileinfo
))
307 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is a bad symlink - %s",
308 filename
, strerror(errno
));
314 * Make sure it's a regular file or a directory as needed...
317 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
319 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file!", filename
);
323 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
326 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory!", filename
);
328 syslog(LOG_ERR
, "\"%s\" is not a directory!", filename
);
334 * If the filename is a symlink, do not change permissions (STR #2937)...
341 * Fix owner, group, and mode as needed...
344 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
347 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
350 if (chown(filename
, user
, group
) && !getuid())
353 cupsdLogMessage(CUPSD_LOG_ERROR
,
354 "Unable to change ownership of \"%s\" - %s", filename
,
357 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
364 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
367 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
370 if (chmod(filename
, mode
))
373 cupsdLogMessage(CUPSD_LOG_ERROR
,
374 "Unable to change permissions of \"%s\" - %s", filename
,
377 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
385 * Everything is OK...
393 * 'cupsdFreeAliases()' - Free all of the alias entries.
397 cupsdFreeAliases(cups_array_t
*aliases
) /* I - Array of aliases */
399 cupsd_alias_t
*a
; /* Current alias */
402 for (a
= (cupsd_alias_t
*)cupsArrayFirst(aliases
);
404 a
= (cupsd_alias_t
*)cupsArrayNext(aliases
))
407 cupsArrayDelete(aliases
);
412 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
415 int /* O - 1 on success, 0 otherwise */
416 cupsdReadConfiguration(void)
418 int i
; /* Looping var */
419 cups_file_t
*fp
; /* Configuration file */
420 int status
; /* Return status */
421 char temp
[1024], /* Temporary buffer */
422 mimedir
[1024], /* MIME directory */
423 *slash
; /* Directory separator */
424 cups_lang_t
*language
; /* Language */
425 struct passwd
*user
; /* Default user */
426 struct group
*group
; /* Default group */
427 char *old_serverroot
, /* Old ServerRoot */
428 *old_requestroot
; /* Old RequestRoot */
429 int old_remote_port
; /* Old RemotePort */
430 const char *tmpdir
; /* TMPDIR environment variable */
431 struct stat tmpinfo
; /* Temporary directory info */
432 cupsd_policy_t
*p
; /* Policy */
436 * Save the old root paths...
439 old_serverroot
= NULL
;
440 cupsdSetString(&old_serverroot
, ServerRoot
);
441 old_requestroot
= NULL
;
442 cupsdSetString(&old_requestroot
, RequestRoot
);
445 * Reset the server configuration data...
448 cupsdDeleteAllLocations();
467 for (i
= 0; i
< NumRelays
; i
++)
468 cupsArrayDelete(Relays
[i
].from
);
475 cupsdDeleteAllListeners();
477 old_remote_port
= RemotePort
;
484 cupsdFreeAliases(ServerAlias
);
487 cupsdClearString(&ServerName
);
488 cupsdClearString(&ServerAdmin
);
489 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
490 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
491 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
492 cupsdSetString(&DataDir
, CUPS_DATADIR
);
493 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
494 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
495 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
496 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
497 cupsdSetString(&PageLogFormat
,
498 "%p %j %u %T %P %C %{job-billing} "
499 "%{job-originating-host-name} %{job-name} %{media} %{sides}");
500 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
501 cupsdSetString(&PrintcapGUI
, "/usr/bin/glpoptions");
502 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
503 cupsdSetString(&RemoteRoot
, "remroot");
504 cupsdSetString(&ServerHeader
, "CUPS/1.4");
505 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
507 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
508 PrintcapFormat
= PRINTCAP_SOLARIS
;
509 else if (!strcmp(CUPS_DEFAULT_PRINTCAP
,
510 "/Library/Preferences/org.cups.printers.plist"))
511 PrintcapFormat
= PRINTCAP_PLIST
;
513 PrintcapFormat
= PRINTCAP_BSD
;
515 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
516 if ((slash
= strrchr(temp
, '/')) != NULL
)
519 cupsdSetString(&ServerRoot
, temp
);
521 cupsdClearString(&Classification
);
522 ClassifyOverride
= 0;
526 cupsdSetString(&ServerCertificate
, "/Library/Keychains/System.keychain");
528 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
529 cupsdSetString(&ServerKey
, "ssl/server.key");
530 # endif /* HAVE_CDSASSL */
531 #endif /* HAVE_SSL */
533 language
= cupsLangDefault();
535 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
536 cupsdSetString(&DefaultLanguage
, "en");
538 cupsdSetString(&DefaultLanguage
, language
->language
);
540 cupsdClearString(&DefaultPaperSize
);
542 cupsdSetString(&RIPCache
, "8m");
544 cupsdSetString(&TempDir
, NULL
);
547 * Find the default user...
550 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
555 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
556 * complement number...)
565 * Find the default group...
568 group
= getgrnam(CUPS_DEFAULT_GROUP
);
572 Group
= group
->gr_gid
;
576 * Fallback to group "nobody"...
579 group
= getgrnam("nobody");
583 Group
= group
->gr_gid
;
587 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
588 * complement number...)
599 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
600 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
601 FatalErrors
= parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS
);
602 DefaultAuthType
= CUPSD_AUTH_BASIC
;
604 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
605 SSLOptions
= CUPSD_SSL_NONE
;
606 #endif /* HAVE_SSL */
607 DirtyCleanInterval
= DEFAULT_KEEPALIVE
;
608 JobKillDelay
= DEFAULT_TIMEOUT
;
610 JobRetryInterval
= 300;
615 HostNameLookups
= FALSE
;
616 ImplicitClasses
= CUPS_DEFAULT_IMPLICIT_CLASSES
;
617 ImplicitAnyClasses
= FALSE
;
618 HideImplicitMembers
= TRUE
;
620 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
621 ListenBackLog
= SOMAXCONN
;
622 LogDebugHistory
= 200;
623 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
624 LogLevel
= CUPSD_LOG_WARN
;
625 LogTimeFormat
= CUPSD_TIME_STANDARD
;
627 MaxClientsPerHost
= 0;
628 MaxLogSize
= 1024 * 1024;
629 MaxPrinterHistory
= 0;
631 MultipleOperationTimeout
= DEFAULT_TIMEOUT
;
632 ReloadTimeout
= DEFAULT_KEEPALIVE
;
633 RootCertDuration
= 300;
634 Timeout
= DEFAULT_TIMEOUT
;
636 WebInterface
= CUPS_DEFAULT_WEBIF
;
638 BrowseInterval
= DEFAULT_INTERVAL
;
639 BrowsePort
= ippPort();
640 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
641 BrowseRemoteProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS
);
642 BrowseShortNames
= CUPS_DEFAULT_BROWSE_SHORT_NAMES
;
643 BrowseTimeout
= DEFAULT_TIMEOUT
;
645 Browsing
= CUPS_DEFAULT_BROWSING
;
646 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
648 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
649 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
651 cupsdClearString(&BrowseLocalOptions
);
652 cupsdClearString(&BrowseRemoteOptions
);
654 cupsdSetString(&ErrorPolicy
, "stop-printer");
657 cupsdClearString(&BrowseLDAPBindDN
);
658 cupsdClearString(&BrowseLDAPDN
);
659 cupsdClearString(&BrowseLDAPPassword
);
660 cupsdClearString(&BrowseLDAPServer
);
661 # ifdef HAVE_LDAP_SSL
662 cupsdClearString(&BrowseLDAPCACertFile
);
663 # endif /* HAVE_LDAP_SSL */
664 #endif /* HAVE_LDAP */
666 JobHistory
= DEFAULT_HISTORY
;
667 JobFiles
= DEFAULT_FILES
;
672 MaxJobsPerPrinter
= 0;
673 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
675 cupsdDeleteAllPolicies();
676 cupsdClearString(&DefaultPolicy
);
678 #ifdef HAVE_AUTHORIZATION_H
679 cupsdClearString(&SystemGroupAuthKey
);
680 #endif /* HAVE_AUTHORIZATION_H */
682 MaxSubscriptions
= 100;
683 MaxSubscriptionsPerJob
= 0;
684 MaxSubscriptionsPerPrinter
= 0;
685 MaxSubscriptionsPerUser
= 0;
686 DefaultLeaseDuration
= 86400;
687 MaxLeaseDuration
= 0;
690 LaunchdTimeout
= DEFAULT_TIMEOUT
+ 10;
691 #endif /* HAVE_LAUNCHD */
694 * Read the configuration file...
697 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
700 status
= read_configuration(fp
);
709 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
710 RemotePort
? "enabled" : "disabled");
713 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
716 * See if the ServerName is an IP address...
722 ServerAlias
= cupsArrayNew(NULL
, NULL
);
724 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
728 if (gethostname(temp
, sizeof(temp
)))
730 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
732 strlcpy(temp
, "localhost", sizeof(temp
));
735 cupsdSetString(&ServerName
, temp
);
738 ServerAlias
= cupsArrayNew(NULL
, NULL
);
740 cupsdAddAlias(ServerAlias
, temp
);
741 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
743 if (HostNameLookups
|| RemotePort
)
745 struct hostent
*host
; /* Host entry to get FQDN */
747 if ((host
= gethostbyname(temp
)) != NULL
)
749 if (strcasecmp(temp
, host
->h_name
))
751 cupsdSetString(&ServerName
, host
->h_name
);
752 cupsdAddAlias(ServerAlias
, host
->h_name
);
753 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
759 for (i
= 0; host
->h_aliases
[i
]; i
++)
760 if (strcasecmp(temp
, host
->h_aliases
[i
]))
762 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
763 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
771 * Make sure we have the base hostname added as an alias, too!
774 if ((slash
= strchr(temp
, '.')) != NULL
)
777 cupsdAddAlias(ServerAlias
, temp
);
778 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
782 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
784 ServerNameIsIP
= !*slash
;
787 * Make sure ServerAdmin is initialized...
791 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
794 * Use the default system group if none was supplied in cupsd.conf...
797 if (NumSystemGroups
== 0)
799 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
802 * Find the group associated with GID 0...
809 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
811 cupsdSetString(&SystemGroups
[0], "unknown");
813 SystemGroupIDs
[0] = 0;
819 * Get the access control list for browsing...
822 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
825 * Open the system log for cupsd if necessary...
829 if (!strcmp(AccessLog
, "syslog") ||
830 !strcmp(ErrorLog
, "syslog") ||
831 !strcmp(PageLog
, "syslog"))
832 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
833 #endif /* HAVE_VSYSLOG */
836 * Log the configuration file that was used...
839 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
843 * Validate the Group and SystemGroup settings - they cannot be the same,
844 * otherwise the CGI programs will be able to authenticate as root without
850 for (i
= 0; i
< NumSystemGroups
; i
++)
851 if (Group
== SystemGroupIDs
[i
])
854 if (i
< NumSystemGroups
)
857 * Log the error and reset the group to a safe value...
860 cupsdLogMessage(CUPSD_LOG_NOTICE
,
861 "Group and SystemGroup cannot use the same groups!");
862 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
864 group
= getgrnam("nobody");
868 Group
= group
->gr_gid
;
872 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
873 * complement number...)
882 * Check that we have at least one listen/port line; if not, report this
883 * as an error and exit!
886 if (cupsArrayCount(Listeners
) == 0)
892 cupsdLogMessage(CUPSD_LOG_EMERG
,
893 "No valid Listen or Port lines were found in the "
894 "configuration file!");
900 cupsdEndProcess(getpid(), 0);
904 * Set the default locale using the language and charset...
907 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
910 * Update all relative filenames to include the full path from ServerRoot...
913 if (DocumentRoot
[0] != '/')
914 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
916 if (RequestRoot
[0] != '/')
917 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
919 if (ServerBin
[0] != '/')
920 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
922 if (StateDir
[0] != '/')
923 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
925 if (CacheDir
[0] != '/')
926 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
929 if (ServerCertificate
[0] != '/')
930 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
932 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
933 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
935 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
938 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
939 if (ServerKey
[0] != '/')
940 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
942 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
943 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
944 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
946 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
947 #endif /* HAVE_SSL */
950 * Make sure that directories and config files are owned and
951 * writable by the user and group in the cupsd.conf file...
954 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
956 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
958 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
960 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
962 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
964 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
965 SystemGroupIDs
[0], 1, 1) < 0 ||
966 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
968 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
970 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
972 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
974 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
976 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
978 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
980 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
984 * Update TempDir to the default if it hasn't been set already...
989 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
992 * TMPDIR is defined, see if it is OK for us to use...
995 if (stat(tmpdir
, &tmpinfo
))
996 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
997 tmpdir
, strerror(errno
));
998 else if (!S_ISDIR(tmpinfo
.st_mode
))
999 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory!",
1001 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1002 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1003 !(tmpinfo
.st_mode
& S_IWOTH
))
1004 cupsdLogMessage(CUPSD_LOG_ERROR
,
1005 "TMPDIR (%s) has the wrong permissions!", tmpdir
);
1007 cupsdSetString(&TempDir
, tmpdir
);
1012 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1014 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1019 * Make sure the temporary directory has the right permissions...
1022 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1026 * Update ownership and permissions if the CUPS temp directory
1027 * is under the spool directory or does not exist...
1030 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1031 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1036 * Setup environment variables...
1042 * Update default paper size setting as needed...
1045 if (!DefaultPaperSize
)
1047 #ifdef HAVE_LIBPAPER
1048 char *paper_result
; /* Paper size name from libpaper */
1050 if ((paper_result
= systempapername()) != NULL
)
1051 cupsdSetString(&DefaultPaperSize
, paper_result
);
1053 #endif /* HAVE_LIBPAPER */
1054 if (!DefaultLanguage
||
1055 !strcasecmp(DefaultLanguage
, "C") ||
1056 !strcasecmp(DefaultLanguage
, "POSIX") ||
1057 !strcasecmp(DefaultLanguage
, "en") ||
1058 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1059 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1060 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1061 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1064 * These are the only locales that will default to "letter" size...
1067 cupsdSetString(&DefaultPaperSize
, "Letter");
1070 cupsdSetString(&DefaultPaperSize
, "A4");
1074 * Update classification setting as needed...
1077 if (Classification
&& !strcasecmp(Classification
, "none"))
1078 cupsdClearString(&Classification
);
1081 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1084 * Check the MaxClients setting, and then allocate memory for it...
1087 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1090 cupsdLogMessage(CUPSD_LOG_INFO
,
1091 "MaxClients limited to 1/3 (%d) of the file descriptor "
1093 MaxFDs
/ 3, MaxFDs
);
1095 MaxClients
= MaxFDs
/ 3;
1098 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1102 * Check the MaxActiveJobs setting; limit to 1/3 the available
1103 * file descriptors, since we need a pipe for each job...
1106 if (MaxActiveJobs
> (MaxFDs
/ 3))
1107 MaxActiveJobs
= MaxFDs
/ 3;
1110 * Update the MaxClientsPerHost value, as needed...
1113 if (MaxClientsPerHost
<= 0)
1114 MaxClientsPerHost
= MaxClients
;
1116 if (MaxClientsPerHost
> MaxClients
)
1117 MaxClientsPerHost
= MaxClients
;
1119 cupsdLogMessage(CUPSD_LOG_INFO
,
1120 "Allowing up to %d client connections per host.",
1124 * Make sure that BrowseTimeout is at least twice the interval...
1127 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1129 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d!",
1133 BrowseTimeout
= BrowseInterval
* 2;
1135 BrowseTimeout
= DEFAULT_TIMEOUT
;
1137 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d!",
1142 * Update the default policy, as needed...
1146 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1148 DefaultPolicyPtr
= NULL
;
1150 if (!DefaultPolicyPtr
)
1152 cupsd_location_t
*po
; /* New policy operation */
1156 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found!",
1159 cupsdSetString(&DefaultPolicy
, "default");
1161 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1162 cupsdLogMessage(CUPSD_LOG_INFO
,
1163 "Using policy \"default\" as the default!");
1166 cupsdLogMessage(CUPSD_LOG_INFO
,
1167 "Creating CUPS default administrative policy:");
1169 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1171 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1173 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1174 cupsdAddString(&(p
->job_access
), "@OWNER");
1175 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1177 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1178 cupsdAddString(&(p
->job_attrs
), "job-name");
1179 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1180 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1182 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1183 cupsdAddString(&(p
->sub_access
), "@OWNER");
1184 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1186 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1187 cupsdAddString(&(p
->job_attrs
), "notify-events");
1188 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1189 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1190 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1191 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1193 cupsdLogMessage(CUPSD_LOG_INFO
,
1194 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1195 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1197 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1198 po
->order_type
= CUPSD_AUTH_ALLOW
;
1200 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1201 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1202 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1204 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1206 cupsdLogMessage(CUPSD_LOG_INFO
,
1207 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1208 "Release-Job Restart-Job Purge-Jobs "
1209 "Set-Job-Attributes Create-Job-Subscription "
1210 "Renew-Subscription Cancel-Subscription "
1211 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1212 "Suspend-Current-Job Resume-Job "
1213 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1214 "CUPS-Authenticate-Job CUPS-Get-Document>");
1215 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1217 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1218 po
->order_type
= CUPSD_AUTH_ALLOW
;
1219 po
->level
= CUPSD_AUTH_USER
;
1221 cupsdAddName(po
, "@OWNER");
1222 cupsdAddName(po
, "@SYSTEM");
1223 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1225 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1226 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1227 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1228 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1229 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1230 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1231 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1232 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1233 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1234 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1235 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1236 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1237 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1238 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1239 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1240 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1241 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1242 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1243 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1244 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1246 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1248 cupsdLogMessage(CUPSD_LOG_INFO
,
1249 "<Limit Pause-Printer Resume-Printer "
1250 "Set-Printer-Attributes Enable-Printer "
1251 "Disable-Printer Pause-Printer-After-Current-Job "
1252 "Hold-New-Jobs Release-Held-New-Jobs "
1253 "Deactivate-Printer Activate-Printer Restart-Printer "
1254 "Shutdown-Printer Startup-Printer Promote-Job "
1255 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1256 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1257 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1258 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1259 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1261 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1262 po
->order_type
= CUPSD_AUTH_ALLOW
;
1263 po
->type
= CUPSD_AUTH_DEFAULT
;
1264 po
->level
= CUPSD_AUTH_USER
;
1266 cupsdAddName(po
, "@SYSTEM");
1267 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1269 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1270 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1271 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1272 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1273 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1274 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1275 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1276 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1277 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1278 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1279 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1280 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1281 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1282 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1283 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1284 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1285 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1286 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1287 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1288 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1289 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1290 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1292 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1294 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1295 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1297 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1298 po
->order_type
= CUPSD_AUTH_ALLOW
;
1300 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1301 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1305 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1306 cupsArrayCount(Policies
));
1307 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1309 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1310 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1311 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1314 * If we are doing a full reload or the server root has changed, flush
1315 * the jobs, printers, etc. and start from scratch...
1318 if (NeedReload
== RELOAD_ALL
||
1319 old_remote_port
!= RemotePort
||
1320 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1321 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1323 mime_type_t
*type
; /* Current type */
1324 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1325 /* MIME type name */
1328 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1331 * Free all memory...
1334 cupsdDeleteAllSubscriptions();
1336 cupsdDeleteAllPrinters();
1338 DefaultPrinter
= NULL
;
1340 if (MimeDatabase
!= NULL
)
1341 mimeDelete(MimeDatabase
);
1345 for (i
= 0; i
< NumMimeTypes
; i
++)
1346 _cupsStrFree(MimeTypes
[i
]);
1352 * Read the MIME type and conversion database...
1355 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1356 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1358 MimeDatabase
= mimeLoadTypes(NULL
, mimedir
);
1359 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1360 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1361 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1365 cupsdLogMessage(CUPSD_LOG_EMERG
,
1366 "Unable to load MIME database from \"%s\" or \"%s\"!",
1367 mimedir
, ServerRoot
);
1368 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1372 cupsdLogMessage(CUPSD_LOG_INFO
,
1373 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1374 "%d filters...", mimedir
, ServerRoot
,
1375 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1378 * Create a list of MIME types for the document-format-supported
1382 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1383 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1386 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1388 cupsdLogMessage(CUPSD_LOG_ERROR
,
1389 "Unable to allocate memory for %d MIME types!",
1395 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1397 i
++, type
= mimeNextType(MimeDatabase
))
1399 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1401 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1404 if (i
< NumMimeTypes
)
1405 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1408 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1410 mime_filter_t
*filter
; /* Current filter */
1413 for (type
= mimeFirstType(MimeDatabase
);
1415 type
= mimeNextType(MimeDatabase
))
1416 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1417 type
->super
, type
->type
);
1419 for (filter
= mimeFirstFilter(MimeDatabase
);
1421 filter
= mimeNextFilter(MimeDatabase
))
1422 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1423 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1424 filter
->src
->super
, filter
->src
->type
,
1425 filter
->dst
->super
, filter
->dst
->type
,
1426 filter
->cost
, filter
->filter
);
1433 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1434 cupsdLoadBanners(temp
);
1437 * Load printers and classes...
1440 cupsdLoadAllPrinters();
1441 cupsdLoadAllClasses();
1442 cupsdLoadRemoteCache();
1444 cupsdCreateCommonData();
1447 * Update the printcap file as needed...
1450 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1451 cupsdWritePrintcap();
1454 * Load queued jobs...
1460 * Load subscriptions...
1463 cupsdLoadAllSubscriptions();
1465 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1470 * Not a full reload, so recreate the common printer attributes...
1473 cupsdCreateCommonData();
1476 * Update all printers as needed...
1479 cupsdUpdatePrinters();
1480 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1482 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1486 * Reset the reload state...
1489 NeedReload
= RELOAD_NONE
;
1491 cupsdClearString(&old_serverroot
);
1492 cupsdClearString(&old_requestroot
);
1499 * 'get_address()' - Get an address + port number from a line.
1502 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1503 get_address(const char *value
, /* I - Value string */
1504 int defport
) /* I - Default port */
1506 char buffer
[1024], /* Hostname + port number buffer */
1507 defpname
[255], /* Default port name */
1508 *hostname
, /* Hostname or IP */
1509 *portname
; /* Port number or name */
1510 http_addrlist_t
*addrlist
; /* Address list */
1514 * Check for an empty value...
1519 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address!");
1524 * Grab a hostname and port number; if there is no colon and the port name
1525 * is only digits, then we have a port number by itself...
1528 strlcpy(buffer
, value
, sizeof(buffer
));
1530 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1537 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1542 * Use the default port...
1545 sprintf(defpname
, "%d", defport
);
1546 portname
= defpname
;
1552 * The buffer contains just a port number...
1560 if (hostname
&& !strcmp(hostname
, "*"))
1564 * Now lookup the address using httpAddrGetList()...
1567 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1568 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed!",
1569 hostname
? hostname
: "(nil)");
1576 * 'get_addr_and_mask()' - Get an IP address and netmask.
1579 static int /* O - 1 on success, 0 on failure */
1580 get_addr_and_mask(const char *value
, /* I - String from config file */
1581 unsigned *ip
, /* O - Address value */
1582 unsigned *mask
) /* O - Mask value */
1584 int i
, j
, /* Looping vars */
1585 family
, /* Address family */
1586 ipcount
; /* Count of fields in address */
1587 unsigned ipval
; /* Value */
1588 const char *maskval
, /* Pointer to start of mask value */
1589 *ptr
, /* Pointer into value */
1594 * Get the address...
1597 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1598 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1600 if ((maskval
= strchr(value
, '/')) != NULL
)
1603 maskval
= value
+ strlen(value
);
1607 * Check for an IPv6 address...
1613 * Parse hexadecimal IPv6 address...
1618 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1622 else if (!strncmp(ptr
, "::", 2))
1624 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1626 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1631 else if (isxdigit(*ptr
& 255))
1633 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1641 ip
[i
/ 2] |= ipval
<< 16;
1655 if (*ptr
&& *ptr
!= '/')
1659 #endif /* AF_INET6 */
1662 * Parse dotted-decimal IPv4 address...
1665 unsigned val
[4]; /* IPv4 address values */
1669 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1672 * Range check the IP numbers...
1675 for (i
= 0; i
< ipcount
; i
++)
1680 * Make sure the trailing values are zeroed, as some C libraries like
1681 * glibc apparently like to fill the unused arguments with garbage...
1684 for (i
= ipcount
; i
< 4; i
++)
1688 * Merge everything into a 32-bit IPv4 address in ip[3]...
1691 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1694 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1700 * Get the netmask value(s)...
1703 memset(mask
, 0, sizeof(unsigned) * 4);
1705 if (strchr(maskval
, '.'))
1708 * Get dotted-decimal mask...
1711 if (family
!= AF_INET
)
1714 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1717 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1718 mask
[0] = mask
[1] = mask
[2] = 0;
1723 * Get address/bits format...
1729 if (family
== AF_INET6
)
1737 mask
[0] = 0xffffffff;
1739 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1742 mask
[1] = 0xffffffff;
1746 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1749 mask
[2] = 0xffffffff;
1753 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1756 mask
[3] = 0xffffffff;
1760 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1763 #endif /* AF_INET6 */
1768 mask
[0] = 0xffffffff;
1769 mask
[1] = 0xffffffff;
1770 mask
[2] = 0xffffffff;
1773 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1775 mask
[3] = 0xffffffff;
1780 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1781 "get_addr_and_mask(value=\"%s\", "
1782 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1783 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1787 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1790 if ((ip
[0] & ~mask
[0]) != 0 ||
1791 (ip
[1] & ~mask
[1]) != 0 ||
1792 (ip
[2] & ~mask
[2]) != 0 ||
1793 (ip
[3] & ~mask
[3]) != 0)
1801 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1804 static int /* O - 1 on success, 0 on failure */
1805 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1806 char *line
, /* I - Line from file */
1807 char *value
, /* I - Start of value data */
1808 int linenum
) /* I - Current line number */
1810 char *valptr
; /* Pointer into value */
1811 unsigned ip
[4], /* IP address components */
1812 mask
[4]; /* IP netmask components */
1815 if (!strcasecmp(line
, "Encryption"))
1818 * "Encryption xxx" - set required encryption level...
1821 if (!strcasecmp(value
, "never"))
1822 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1823 else if (!strcasecmp(value
, "always"))
1825 cupsdLogMessage(CUPSD_LOG_ERROR
,
1826 "Encryption value \"%s\" on line %d is invalid in this "
1827 "context. Using \"required\" instead.", value
, linenum
);
1829 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1831 else if (!strcasecmp(value
, "required"))
1832 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1833 else if (!strcasecmp(value
, "ifrequested"))
1834 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1837 cupsdLogMessage(CUPSD_LOG_ERROR
,
1838 "Unknown Encryption value %s on line %d.", value
, linenum
);
1842 else if (!strcasecmp(line
, "Order"))
1845 * "Order Deny,Allow" or "Order Allow,Deny"...
1848 if (!strncasecmp(value
, "deny", 4))
1849 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1850 else if (!strncasecmp(value
, "allow", 5))
1851 loc
->order_type
= CUPSD_AUTH_DENY
;
1854 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1859 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1862 * Allow [From] host/ip...
1863 * Deny [From] host/ip...
1868 if (!strncasecmp(value
, "from", 4))
1871 * Strip leading "from"...
1876 while (isspace(*value
& 255))
1884 * Find the end of the value...
1887 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1889 while (isspace(*valptr
& 255))
1893 * Figure out what form the allow/deny address takes:
1904 * nnn.nnn.nnn.nnn/mm
1905 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1908 if (!strcasecmp(value
, "all"))
1914 if (!strcasecmp(line
, "Allow"))
1915 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1917 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1919 else if (!strcasecmp(value
, "none"))
1925 if (!strcasecmp(line
, "Allow"))
1926 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1928 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1931 else if (value
[0] == '*' || value
[0] == '.' ||
1932 (!isdigit(value
[0] & 255) && value
[0] != '['))
1934 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1935 #endif /* AF_INET6 */
1938 * Host or domain name...
1941 if (value
[0] == '*')
1944 if (!strcasecmp(line
, "Allow"))
1945 cupsdAddNameMask(&(loc
->allow
), value
);
1947 cupsdAddNameMask(&(loc
->deny
), value
);
1952 * One of many IP address forms...
1955 if (!get_addr_and_mask(value
, ip
, mask
))
1957 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1962 if (!strcasecmp(line
, "Allow"))
1963 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
1965 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
1969 * Advance to next value...
1975 else if (!strcasecmp(line
, "AuthType"))
1978 * AuthType {none,basic,digest,basicdigest,negotiate,default}
1981 if (!strcasecmp(value
, "none"))
1983 loc
->type
= CUPSD_AUTH_NONE
;
1984 loc
->level
= CUPSD_AUTH_ANON
;
1986 else if (!strcasecmp(value
, "basic"))
1988 loc
->type
= CUPSD_AUTH_BASIC
;
1990 if (loc
->level
== CUPSD_AUTH_ANON
)
1991 loc
->level
= CUPSD_AUTH_USER
;
1993 else if (!strcasecmp(value
, "digest"))
1995 loc
->type
= CUPSD_AUTH_DIGEST
;
1997 if (loc
->level
== CUPSD_AUTH_ANON
)
1998 loc
->level
= CUPSD_AUTH_USER
;
2000 else if (!strcasecmp(value
, "basicdigest"))
2002 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2004 if (loc
->level
== CUPSD_AUTH_ANON
)
2005 loc
->level
= CUPSD_AUTH_USER
;
2007 else if (!strcasecmp(value
, "default"))
2009 loc
->type
= CUPSD_AUTH_DEFAULT
;
2011 if (loc
->level
== CUPSD_AUTH_ANON
)
2012 loc
->level
= CUPSD_AUTH_USER
;
2015 else if (!strcasecmp(value
, "negotiate"))
2017 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2019 if (loc
->level
== CUPSD_AUTH_ANON
)
2020 loc
->level
= CUPSD_AUTH_USER
;
2022 #endif /* HAVE_GSSAPI */
2025 cupsdLogMessage(CUPSD_LOG_WARN
,
2026 "Unknown authorization type %s on line %d.",
2031 else if (!strcasecmp(line
, "AuthClass"))
2034 * AuthClass anonymous, user, system, group
2037 if (!strcasecmp(value
, "anonymous"))
2039 loc
->type
= CUPSD_AUTH_NONE
;
2040 loc
->level
= CUPSD_AUTH_ANON
;
2042 cupsdLogMessage(CUPSD_LOG_WARN
,
2043 "\"AuthClass %s\" is deprecated; consider removing "
2047 else if (!strcasecmp(value
, "user"))
2049 loc
->level
= CUPSD_AUTH_USER
;
2051 cupsdLogMessage(CUPSD_LOG_WARN
,
2052 "\"AuthClass %s\" is deprecated; consider using "
2053 "\"Require valid-user\" on line %d.",
2056 else if (!strcasecmp(value
, "group"))
2058 loc
->level
= CUPSD_AUTH_GROUP
;
2060 cupsdLogMessage(CUPSD_LOG_WARN
,
2061 "\"AuthClass %s\" is deprecated; consider using "
2062 "\"Require user @groupname\" on line %d.",
2065 else if (!strcasecmp(value
, "system"))
2067 loc
->level
= CUPSD_AUTH_GROUP
;
2069 cupsdAddName(loc
, "@SYSTEM");
2071 cupsdLogMessage(CUPSD_LOG_WARN
,
2072 "\"AuthClass %s\" is deprecated; consider using "
2073 "\"Require user @SYSTEM\" on line %d.",
2078 cupsdLogMessage(CUPSD_LOG_WARN
,
2079 "Unknown authorization class %s on line %d.",
2084 else if (!strcasecmp(line
, "AuthGroupName"))
2086 cupsdAddName(loc
, value
);
2088 cupsdLogMessage(CUPSD_LOG_WARN
,
2089 "\"AuthGroupName %s\" directive is deprecated; consider "
2090 "using \"Require user @%s\" on line %d.",
2091 value
, value
, linenum
);
2093 else if (!strcasecmp(line
, "Require"))
2096 * Apache synonym for AuthClass and AuthGroupName...
2100 * Require valid-user
2101 * Require group names
2102 * Require user names
2105 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2110 if (!strcasecmp(value
, "valid-user") ||
2111 !strcasecmp(value
, "user"))
2112 loc
->level
= CUPSD_AUTH_USER
;
2113 else if (!strcasecmp(value
, "group"))
2114 loc
->level
= CUPSD_AUTH_GROUP
;
2117 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2123 * Get the list of names from the line...
2126 for (value
= valptr
; *value
;)
2128 while (isspace(*value
& 255))
2131 #ifdef HAVE_AUTHORIZATION_H
2132 if (!strncmp(value
, "@AUTHKEY(", 9))
2135 * Grab "@AUTHKEY(name)" value...
2138 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2144 #endif /* HAVE_AUTHORIZATION_H */
2145 if (*value
== '\"' || *value
== '\'')
2148 * Grab quoted name...
2151 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2158 * Grab literal name.
2161 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2167 cupsdAddName(loc
, value
);
2169 for (value
= valptr
; isspace(*value
& 255); value
++);
2172 else if (!strcasecmp(line
, "Satisfy"))
2174 if (!strcasecmp(value
, "all"))
2175 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2176 else if (!strcasecmp(value
, "any"))
2177 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2180 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2193 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2196 static int /* O - FatalErrors bits */
2197 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2199 int fatal
; /* FatalErrors bits */
2200 char value
[1024], /* Value string */
2201 *valstart
, /* Pointer into value */
2202 *valend
; /* End of value */
2206 * Empty FatalErrors line yields NULL pointer...
2210 return (CUPSD_FATAL_NONE
);
2213 * Loop through the value string,...
2216 strlcpy(value
, s
, sizeof(value
));
2218 fatal
= CUPSD_FATAL_NONE
;
2220 for (valstart
= value
; *valstart
;)
2223 * Get the current space/comma-delimited kind name...
2226 for (valend
= valstart
; *valend
; valend
++)
2227 if (isspace(*valend
& 255) || *valend
== ',')
2234 * Add the error to the bitmask...
2237 if (!strcasecmp(valstart
, "all"))
2238 fatal
= CUPSD_FATAL_ALL
;
2239 else if (!strcasecmp(valstart
, "browse"))
2240 fatal
|= CUPSD_FATAL_BROWSE
;
2241 else if (!strcasecmp(valstart
, "-browse"))
2242 fatal
&= ~CUPSD_FATAL_BROWSE
;
2243 else if (!strcasecmp(valstart
, "config"))
2244 fatal
|= CUPSD_FATAL_CONFIG
;
2245 else if (!strcasecmp(valstart
, "-config"))
2246 fatal
&= ~CUPSD_FATAL_CONFIG
;
2247 else if (!strcasecmp(valstart
, "listen"))
2248 fatal
|= CUPSD_FATAL_LISTEN
;
2249 else if (!strcasecmp(valstart
, "-listen"))
2250 fatal
&= ~CUPSD_FATAL_LISTEN
;
2251 else if (!strcasecmp(valstart
, "log"))
2252 fatal
|= CUPSD_FATAL_LOG
;
2253 else if (!strcasecmp(valstart
, "-log"))
2254 fatal
&= ~CUPSD_FATAL_LOG
;
2255 else if (!strcasecmp(valstart
, "permissions"))
2256 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2257 else if (!strcasecmp(valstart
, "-permissions"))
2258 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2259 else if (strcasecmp(valstart
, "none"))
2260 cupsdLogMessage(CUPSD_LOG_ERROR
,
2261 "Unknown FatalErrors kind \"%s\" ignored!", valstart
);
2263 for (valstart
= valend
; *valstart
; valstart
++)
2264 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2273 * 'parse_groups()' - Parse system group names in a string.
2276 static int /* O - 1 on success, 0 on failure */
2277 parse_groups(const char *s
) /* I - Space-delimited groups */
2279 int status
; /* Return status */
2280 char value
[1024], /* Value string */
2281 *valstart
, /* Pointer into value */
2282 *valend
, /* End of value */
2283 quote
; /* Quote character */
2284 struct group
*group
; /* Group */
2288 * Make a copy of the string and parse out the groups...
2291 strlcpy(value
, s
, sizeof(value
));
2296 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2298 if (*valstart
== '\'' || *valstart
== '\"')
2301 * Scan quoted name...
2304 quote
= *valstart
++;
2306 for (valend
= valstart
; *valend
; valend
++)
2307 if (*valend
== quote
)
2313 * Scan space or comma-delimited name...
2316 for (valend
= valstart
; *valend
; valend
++)
2317 if (isspace(*valend
) || *valend
== ',')
2324 group
= getgrnam(valstart
);
2327 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2328 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2339 while (*valstart
== ',' || isspace(*valstart
))
2348 * 'parse_protocols()' - Parse browse protocols in a string.
2351 static int /* O - Browse protocol bits */
2352 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2354 int protocols
; /* Browse protocol bits */
2355 char value
[1024], /* Value string */
2356 *valstart
, /* Pointer into value */
2357 *valend
; /* End of value */
2361 * Empty protocol line yields NULL pointer...
2368 * Loop through the value string,...
2371 strlcpy(value
, s
, sizeof(value
));
2375 for (valstart
= value
; *valstart
;)
2378 * Get the current space/comma-delimited protocol name...
2381 for (valend
= valstart
; *valend
; valend
++)
2382 if (isspace(*valend
& 255) || *valend
== ',')
2389 * Add the protocol to the bitmask...
2392 if (!strcasecmp(valstart
, "cups"))
2393 protocols
|= BROWSE_CUPS
;
2394 else if (!strcasecmp(valstart
, "slp"))
2395 protocols
|= BROWSE_SLP
;
2396 else if (!strcasecmp(valstart
, "ldap"))
2397 protocols
|= BROWSE_LDAP
;
2398 else if (!strcasecmp(valstart
, "dnssd") ||
2399 !strcasecmp(valstart
, "dns-sd") ||
2400 !strcasecmp(valstart
, "bonjour"))
2401 protocols
|= BROWSE_DNSSD
;
2402 else if (!strcasecmp(valstart
, "lpd"))
2403 protocols
|= BROWSE_LPD
;
2404 else if (!strcasecmp(valstart
, "smb"))
2405 protocols
|= BROWSE_SMB
;
2406 else if (!strcasecmp(valstart
, "all"))
2407 protocols
|= BROWSE_ALL
;
2408 else if (strcasecmp(valstart
, "none"))
2409 cupsdLogMessage(CUPSD_LOG_ERROR
,
2410 "Unknown browse protocol \"%s\" ignored!", valstart
);
2412 for (valstart
= valend
; *valstart
; valstart
++)
2413 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2422 * 'read_configuration()' - Read a configuration file.
2425 static int /* O - 1 on success, 0 on failure */
2426 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2428 int i
; /* Looping var */
2429 int linenum
; /* Current line number */
2430 char line
[HTTP_MAX_BUFFER
],
2431 /* Line from file */
2432 temp
[HTTP_MAX_BUFFER
],
2433 /* Temporary buffer for value */
2434 *ptr
, /* Pointer into line/temp */
2435 *value
, /* Pointer to value */
2436 *valueptr
; /* Pointer into value */
2437 int valuelen
; /* Length of value */
2438 cupsd_var_t
const *var
; /* Current variable */
2439 http_addrlist_t
*addrlist
, /* Address list */
2440 *addr
; /* Current address */
2441 unsigned ip
[4], /* Address value */
2442 mask
[4]; /* Netmask value */
2443 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2444 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2445 cupsd_location_t
*location
; /* Browse location */
2446 cups_file_t
*incfile
; /* Include file */
2447 char incname
[1024]; /* Include filename */
2448 struct group
*group
; /* Group */
2452 * Loop through each line in the file...
2457 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2460 * Decode the directive...
2463 if (!strcasecmp(line
, "Include") && value
)
2469 if (value
[0] == '/')
2470 strlcpy(incname
, value
, sizeof(incname
));
2472 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2474 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2475 cupsdLogMessage(CUPSD_LOG_ERROR
,
2476 "Unable to include config file \"%s\" - %s",
2477 incname
, strerror(errno
));
2480 read_configuration(incfile
);
2481 cupsFileClose(incfile
);
2484 else if (!strcasecmp(line
, "<Location") && value
)
2490 linenum
= read_location(fp
, value
, linenum
);
2494 else if (!strcasecmp(line
, "<Policy") && value
)
2500 linenum
= read_policy(fp
, value
, linenum
);
2504 else if (!strcasecmp(line
, "FatalErrors"))
2505 FatalErrors
= parse_fatal_errors(value
);
2506 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2508 JobRetryInterval
= atoi(value
);
2509 cupsdLogMessage(CUPSD_LOG_WARN
,
2510 "FaxRetryInterval is deprecated; use "
2511 "JobRetryInterval on line %d.", linenum
);
2513 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2515 JobRetryLimit
= atoi(value
);
2516 cupsdLogMessage(CUPSD_LOG_WARN
,
2517 "FaxRetryLimit is deprecated; use "
2518 "JobRetryLimit on line %d.", linenum
);
2520 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2522 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2523 #endif /* HAVE_SSL */
2527 * Add listening address(es) to the list...
2530 cupsd_listener_t
*lis
; /* New listeners array */
2534 * Get the address list...
2537 addrlist
= get_address(value
, IPP_PORT
);
2541 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2547 * Add each address...
2550 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2553 * See if this address is already present...
2556 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2558 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2559 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2560 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2565 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2566 cupsdLogMessage(CUPSD_LOG_WARN
,
2567 "Duplicate listen address \"%s\" ignored!", temp
);
2572 * Allocate another listener...
2576 Listeners
= cupsArrayNew(NULL
, NULL
);
2580 cupsdLogMessage(CUPSD_LOG_ERROR
,
2581 "Unable to allocate %s at line %d - %s.",
2582 line
, linenum
, strerror(errno
));
2586 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2588 cupsdLogMessage(CUPSD_LOG_ERROR
,
2589 "Unable to allocate %s at line %d - %s.",
2590 line
, linenum
, strerror(errno
));
2594 cupsArrayAdd(Listeners
, lis
);
2597 * Copy the current address and log it...
2600 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2604 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2605 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2606 #endif /* HAVE_SSL */
2608 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2611 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2612 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv6)", temp
,
2613 ntohs(lis
->address
.ipv6
.sin6_port
));
2615 #endif /* AF_INET6 */
2617 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2618 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2620 #endif /* AF_LOCAL */
2621 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv4)", temp
,
2622 ntohs(lis
->address
.ipv4
.sin_port
));
2624 if (!httpAddrLocalhost(&(lis
->address
)))
2627 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2628 RemotePort
= ntohs(lis
->address
.ipv6
.sin6_port
);
2630 #endif /* AF_INET6 */
2631 RemotePort
= ntohs(lis
->address
.ipv4
.sin_port
);
2639 httpAddrFreeList(addrlist
);
2641 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2644 * Add a browse address to the list...
2647 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2650 if (NumBrowsers
== 0)
2651 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2653 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2657 cupsdLogMessage(CUPSD_LOG_ERROR
,
2658 "Unable to allocate BrowseAddress at line %d - %s.",
2659 linenum
, strerror(errno
));
2664 dira
+= NumBrowsers
;
2666 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2668 if (!strcasecmp(value
, "@LOCAL"))
2671 * Send browse data to all local interfaces...
2674 strcpy(dira
->iface
, "*");
2677 else if (!strncasecmp(value
, "@IF(", 4))
2680 * Send browse data to the named interface...
2683 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2685 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2691 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2694 * Only IPv4 addresses are supported...
2697 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2698 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2703 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2704 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2706 cupsdLogMessage(CUPSD_LOG_INFO
,
2707 "Sending browsing info to %s:%d (IPv4)",
2708 temp
, ntohs(dira
->to
.ipv4
.sin_port
));
2713 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2716 httpAddrFreeList(addrlist
);
2719 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2722 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2725 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2728 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2729 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2730 cupsdAddLocation(location
);
2732 if (location
== NULL
)
2733 cupsdLogMessage(CUPSD_LOG_ERROR
,
2734 "Unable to initialize browse access control list!");
2735 else if (!strncasecmp(value
, "deny", 4))
2736 location
->order_type
= CUPSD_AUTH_ALLOW
;
2737 else if (!strncasecmp(value
, "allow", 5))
2738 location
->order_type
= CUPSD_AUTH_DENY
;
2740 cupsdLogMessage(CUPSD_LOG_ERROR
,
2741 "Unknown BrowseOrder value %s on line %d.",
2744 else if (!strcasecmp(line
, "BrowseProtocols") ||
2745 !strcasecmp(line
, "BrowseLocalProtocols") ||
2746 !strcasecmp(line
, "BrowseRemoteProtocols"))
2749 * "BrowseProtocols name [... name]"
2750 * "BrowseLocalProtocols name [... name]"
2751 * "BrowseRemoteProtocols name [... name]"
2754 int protocols
= parse_protocols(value
);
2758 cupsdLogMessage(CUPSD_LOG_ERROR
,
2759 "Unknown browse protocol \"%s\" on line %d.",
2764 if (strcasecmp(line
, "BrowseLocalProtocols"))
2765 BrowseRemoteProtocols
= protocols
;
2766 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2767 BrowseLocalProtocols
= protocols
;
2769 else if ((!strcasecmp(line
, "BrowseAllow") ||
2770 !strcasecmp(line
, "BrowseDeny")) && value
)
2773 * BrowseAllow [From] host/ip...
2774 * BrowseDeny [From] host/ip...
2777 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2778 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2779 cupsdAddLocation(location
);
2782 if (location
== NULL
)
2783 cupsdLogMessage(CUPSD_LOG_ERROR
,
2784 "Unable to initialize browse access control list!");
2787 if (!strncasecmp(value
, "from", 4))
2790 * Skip leading "from"...
2799 * Skip leading whitespace...
2802 while (isspace(*value
& 255))
2809 * Find the end of the value...
2812 for (valueptr
= value
;
2813 *valueptr
&& !isspace(*valueptr
& 255);
2816 while (isspace(*valueptr
& 255))
2820 * Figure out what form the allow/deny address takes:
2831 * nnn.nnn.nnn.nnn/mm
2832 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2835 if (!strcasecmp(value
, "all"))
2841 if (!strcasecmp(line
, "BrowseAllow"))
2842 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2844 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2846 else if (!strcasecmp(value
, "none"))
2852 if (!strcasecmp(line
, "BrowseAllow"))
2853 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2855 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2858 else if (value
[0] == '*' || value
[0] == '.' ||
2859 (!isdigit(value
[0] & 255) && value
[0] != '['))
2861 else if (value
[0] == '*' || value
[0] == '.' ||
2862 !isdigit(value
[0] & 255))
2863 #endif /* AF_INET6 */
2866 * Host or domain name...
2869 if (!strcasecmp(line
, "BrowseAllow"))
2870 cupsdAddNameMask(&(location
->allow
), value
);
2872 cupsdAddNameMask(&(location
->deny
), value
);
2877 * One of many IP address forms...
2880 if (!get_addr_and_mask(value
, ip
, mask
))
2882 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2887 if (!strcasecmp(line
, "BrowseAllow"))
2888 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2890 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2894 * Advance to next value...
2901 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2904 * BrowseRelay [from] source [to] destination
2908 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2910 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2914 cupsdLogMessage(CUPSD_LOG_ERROR
,
2915 "Unable to allocate BrowseRelay at line %d - %s.",
2916 linenum
, strerror(errno
));
2923 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2925 if (!strncasecmp(value
, "from ", 5))
2928 * Skip leading "from"...
2934 * Skip leading whitespace...
2937 while (isspace(*value
))
2942 * Find the end of the from value...
2945 for (valueptr
= value
;
2946 *valueptr
&& !isspace(*valueptr
& 255);
2949 while (isspace(*valueptr
& 255))
2953 * Figure out what form the from address takes:
2962 * nnn.nnn.nnn.nnn/mm
2963 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2967 if (value
[0] == '*' || value
[0] == '.' ||
2968 (!isdigit(value
[0] & 255) && value
[0] != '['))
2970 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2971 #endif /* AF_INET6 */
2974 * Host or domain name...
2977 if (!cupsdAddNameMask(&(relay
->from
), value
))
2979 cupsdLogMessage(CUPSD_LOG_ERROR
,
2980 "Unable to allocate BrowseRelay name at line %d - %s.",
2981 linenum
, strerror(errno
));
2988 * One of many IP address forms...
2991 if (!get_addr_and_mask(value
, ip
, mask
))
2993 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2998 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
3000 cupsdLogMessage(CUPSD_LOG_ERROR
,
3001 "Unable to allocate BrowseRelay IP at line %d - %s.",
3002 linenum
, strerror(errno
));
3008 * Get "to" address and port...
3011 if (!strncasecmp(valueptr
, "to ", 3))
3014 * Strip leading "to"...
3019 while (isspace(*valueptr
))
3023 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3026 * Only IPv4 addresses are supported...
3029 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3030 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3035 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3037 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3039 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3040 value
, temp
, ntohs(relay
->to
.ipv4
.sin_port
));
3046 cupsArrayDelete(relay
->from
);
3049 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3053 httpAddrFreeList(addrlist
);
3057 cupsArrayDelete(relay
->from
);
3060 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3064 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3067 * BrowsePoll address[:port]
3070 char *portname
; /* Port name */
3071 int portnum
; /* Port number */
3072 struct servent
*service
; /* Service */
3076 * Extract the port name from the address...
3079 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3083 if (isdigit(*portname
& 255))
3084 portnum
= atoi(portname
);
3085 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3086 portnum
= ntohs(service
->s_port
);
3089 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed!",
3095 portnum
= ippPort();
3098 * Add the poll entry...
3102 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3104 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3108 cupsdLogMessage(CUPSD_LOG_ERROR
,
3109 "Unable to allocate BrowsePoll at line %d - %s.",
3110 linenum
, strerror(errno
));
3118 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3120 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3121 pollp
->port
= portnum
;
3123 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3126 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3129 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3132 if (!strcasecmp(value
, "none"))
3133 DefaultAuthType
= CUPSD_AUTH_NONE
;
3134 else if (!strcasecmp(value
, "basic"))
3135 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3136 else if (!strcasecmp(value
, "digest"))
3137 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3138 else if (!strcasecmp(value
, "basicdigest"))
3139 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3141 else if (!strcasecmp(value
, "negotiate"))
3142 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3143 #endif /* HAVE_GSSAPI */
3146 cupsdLogMessage(CUPSD_LOG_WARN
,
3147 "Unknown default authorization type %s on line %d.",
3149 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3154 else if (!strcasecmp(line
, "DefaultEncryption"))
3157 * DefaultEncryption {Never,IfRequested,Required}
3160 if (!value
|| !strcasecmp(value
, "never"))
3161 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3162 else if (!strcasecmp(value
, "required"))
3163 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3164 else if (!strcasecmp(value
, "ifrequested"))
3165 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3168 cupsdLogMessage(CUPSD_LOG_WARN
,
3169 "Unknown default encryption %s on line %d.",
3171 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3175 #endif /* HAVE_SSL */
3176 else if (!strcasecmp(line
, "User") && value
)
3179 * User ID to run as...
3182 if (isdigit(value
[0] & 255))
3184 int uid
= atoi(value
);
3187 cupsdLogMessage(CUPSD_LOG_ERROR
,
3188 "Will not use User 0 as specified on line %d "
3189 "for security reasons. You must use a non-"
3190 "privileged account instead.",
3197 struct passwd
*p
; /* Password information */
3200 p
= getpwnam(value
);
3205 cupsdLogMessage(CUPSD_LOG_ERROR
,
3206 "Will not use User %s (UID=0) as specified on line "
3207 "%d for security reasons. You must use a non-"
3208 "privileged account instead.",
3214 cupsdLogMessage(CUPSD_LOG_ERROR
,
3215 "Unknown User \"%s\" on line %d, ignoring!",
3219 else if (!strcasecmp(line
, "Group") && value
)
3222 * Group ID to run as...
3225 if (isdigit(value
[0]))
3226 Group
= atoi(value
);
3230 group
= getgrnam(value
);
3233 Group
= group
->gr_gid
;
3235 cupsdLogMessage(CUPSD_LOG_ERROR
,
3236 "Unknown Group \"%s\" on line %d, ignoring!",
3240 else if (!strcasecmp(line
, "SystemGroup") && value
)
3243 * SystemGroup (admin) group(s)...
3246 if (!parse_groups(value
))
3247 cupsdLogMessage(CUPSD_LOG_ERROR
,
3248 "Unknown SystemGroup \"%s\" on line %d, ignoring!",
3251 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3254 * Do hostname lookups?
3257 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3258 !strcasecmp(value
, "false"))
3259 HostNameLookups
= 0;
3260 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3261 !strcasecmp(value
, "true"))
3262 HostNameLookups
= 1;
3263 else if (!strcasecmp(value
, "double"))
3264 HostNameLookups
= 2;
3266 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3269 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3272 * Amount of logging to do to access log...
3275 if (!strcasecmp(value
, "all"))
3276 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3277 else if (!strcasecmp(value
, "actions"))
3278 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3279 else if (!strcasecmp(value
, "config"))
3280 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3282 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3285 else if (!strcasecmp(line
, "LogLevel") && value
)
3288 * Amount of logging to do to error log...
3291 if (!strcasecmp(value
, "debug2"))
3292 LogLevel
= CUPSD_LOG_DEBUG2
;
3293 else if (!strcasecmp(value
, "debug"))
3294 LogLevel
= CUPSD_LOG_DEBUG
;
3295 else if (!strcasecmp(value
, "info"))
3296 LogLevel
= CUPSD_LOG_INFO
;
3297 else if (!strcasecmp(value
, "notice"))
3298 LogLevel
= CUPSD_LOG_NOTICE
;
3299 else if (!strcasecmp(value
, "warn"))
3300 LogLevel
= CUPSD_LOG_WARN
;
3301 else if (!strcasecmp(value
, "error"))
3302 LogLevel
= CUPSD_LOG_ERROR
;
3303 else if (!strcasecmp(value
, "crit"))
3304 LogLevel
= CUPSD_LOG_CRIT
;
3305 else if (!strcasecmp(value
, "alert"))
3306 LogLevel
= CUPSD_LOG_ALERT
;
3307 else if (!strcasecmp(value
, "emerg"))
3308 LogLevel
= CUPSD_LOG_EMERG
;
3309 else if (!strcasecmp(value
, "none"))
3310 LogLevel
= CUPSD_LOG_NONE
;
3312 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3315 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3318 * Amount of logging to do to error log...
3321 if (!strcasecmp(value
, "standard"))
3322 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3323 else if (!strcasecmp(value
, "usecs"))
3324 LogTimeFormat
= CUPSD_TIME_USECS
;
3326 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3329 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3332 * Format of printcap file?
3335 if (!strcasecmp(value
, "bsd"))
3336 PrintcapFormat
= PRINTCAP_BSD
;
3337 else if (!strcasecmp(value
, "plist"))
3338 PrintcapFormat
= PRINTCAP_PLIST
;
3339 else if (!strcasecmp(value
, "solaris"))
3340 PrintcapFormat
= PRINTCAP_SOLARIS
;
3342 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3345 else if (!strcasecmp(line
, "ServerTokens") && value
)
3348 * Set the string used for the Server header...
3351 struct utsname plat
; /* Platform info */
3356 if (!strcasecmp(value
, "ProductOnly"))
3357 cupsdSetString(&ServerHeader
, "CUPS");
3358 else if (!strcasecmp(value
, "Major"))
3359 cupsdSetString(&ServerHeader
, "CUPS/1");
3360 else if (!strcasecmp(value
, "Minor"))
3361 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3362 else if (!strcasecmp(value
, "Minimal"))
3363 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3364 else if (!strcasecmp(value
, "OS"))
3365 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3366 else if (!strcasecmp(value
, "Full"))
3367 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3369 else if (!strcasecmp(value
, "None"))
3370 cupsdClearString(&ServerHeader
);
3372 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3375 else if (!strcasecmp(line
, "PassEnv") && value
)
3378 * PassEnv variable [... variable]
3383 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3384 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3387 if (value
[valuelen
])
3389 value
[valuelen
] = '\0';
3393 cupsdSetEnv(value
, NULL
);
3395 for (value
+= valuelen
; *value
; value
++)
3396 if (!isspace(*value
) || *value
!= ',')
3400 else if (!strcasecmp(line
, "ServerAlias") && value
)
3403 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3405 cupsdAddAlias(ServerAlias
, value
);
3407 else if (!strcasecmp(line
, "SetEnv") && value
)
3410 * SetEnv variable value
3413 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3421 while (isspace(*valueptr
& 255))
3424 cupsdSetEnv(value
, valueptr
);
3427 cupsdLogMessage(CUPSD_LOG_ERROR
,
3428 "Missing value for SetEnv directive on line %d.",
3432 else if (!strcasecmp(line
, "SSLOptions"))
3435 * SSLOptions options
3438 if (!value
|| !strcasecmp(value
, "none"))
3439 SSLOptions
= CUPSD_SSL_NONE
;
3440 else if (!strcasecmp(value
, "noemptyfragments"))
3441 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3443 cupsdLogMessage(CUPSD_LOG_ERROR
,
3444 "Unknown value \"%s\" for SSLOptions directive on "
3445 "line %d.", value
, linenum
);
3447 #endif /* HAVE_SSL */
3451 * Find a simple variable in the list...
3454 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3455 if (!strcasecmp(line
, var
->name
))
3461 * Unknown directive! Output an error message and continue...
3465 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3468 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3475 case CUPSD_VARTYPE_INTEGER
:
3477 cupsdLogMessage(CUPSD_LOG_ERROR
,
3478 "Missing integer value for %s on line %d!",
3483 char *units
; /* Units */
3486 n
= strtol(value
, &units
, 0);
3488 if (units
&& *units
)
3490 if (tolower(units
[0] & 255) == 'g')
3491 n
*= 1024 * 1024 * 1024;
3492 else if (tolower(units
[0] & 255) == 'm')
3494 else if (tolower(units
[0] & 255) == 'k')
3496 else if (tolower(units
[0] & 255) == 't')
3501 cupsdLogMessage(CUPSD_LOG_ERROR
,
3502 "Bad negative integer value for %s on line %d!",
3505 *((int *)var
->ptr
) = n
;
3509 case CUPSD_VARTYPE_BOOLEAN
:
3511 cupsdLogMessage(CUPSD_LOG_ERROR
,
3512 "Missing boolean value for %s on line %d!",
3514 else if (!strcasecmp(value
, "true") ||
3515 !strcasecmp(value
, "on") ||
3516 !strcasecmp(value
, "enabled") ||
3517 !strcasecmp(value
, "yes") ||
3519 *((int *)var
->ptr
) = TRUE
;
3520 else if (!strcasecmp(value
, "false") ||
3521 !strcasecmp(value
, "off") ||
3522 !strcasecmp(value
, "disabled") ||
3523 !strcasecmp(value
, "no") ||
3524 !strcasecmp(value
, "0"))
3525 *((int *)var
->ptr
) = FALSE
;
3527 cupsdLogMessage(CUPSD_LOG_ERROR
,
3528 "Unknown boolean value %s on line %d.",
3532 case CUPSD_VARTYPE_PATHNAME
:
3535 cupsdLogMessage(CUPSD_LOG_ERROR
,
3536 "Missing pathname value for %s on line %d!",
3541 if (value
[0] == '/')
3542 strlcpy(temp
, value
, sizeof(temp
));
3544 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3546 if (access(temp
, 0))
3548 cupsdLogMessage(CUPSD_LOG_ERROR
,
3549 "File or directory for \"%s %s\" on line %d "
3550 "does not exist!", line
, value
, linenum
);
3554 case CUPSD_VARTYPE_STRING
:
3555 cupsdSetString((char **)var
->ptr
, value
);
3566 * 'read_location()' - Read a <Location path> definition.
3569 static int /* O - New line number or 0 on error */
3570 read_location(cups_file_t
*fp
, /* I - Configuration file */
3571 char *location
, /* I - Location name/path */
3572 int linenum
) /* I - Current line number */
3574 cupsd_location_t
*loc
, /* New location */
3575 *parent
; /* Parent location */
3576 char line
[HTTP_MAX_BUFFER
],
3578 *value
, /* Value for directive */
3579 *valptr
; /* Pointer into value */
3582 if ((parent
= cupsdNewLocation(location
)) == NULL
)
3585 cupsdAddLocation(parent
);
3587 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3590 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3593 * Decode the directive...
3596 if (!strcasecmp(line
, "</Location>"))
3598 else if (!strcasecmp(line
, "<Limit") ||
3599 !strcasecmp(line
, "<LimitExcept"))
3603 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3604 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3610 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3613 cupsdAddLocation(loc
);
3618 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3623 if (!strcmp(value
, "ALL"))
3624 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3625 else if (!strcmp(value
, "GET"))
3626 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3627 else if (!strcmp(value
, "HEAD"))
3628 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3629 else if (!strcmp(value
, "OPTIONS"))
3630 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3631 else if (!strcmp(value
, "POST"))
3632 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3633 else if (!strcmp(value
, "PUT"))
3634 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3635 else if (!strcmp(value
, "TRACE"))
3636 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3638 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d!",
3641 for (value
= valptr
; isspace(*value
& 255); value
++);
3644 if (!strcasecmp(line
, "<LimitExcept"))
3645 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3647 parent
->limit
&= ~loc
->limit
;
3649 else if (!strcasecmp(line
, "</Limit>") ||
3650 !strcasecmp(line
, "</LimitExcept>"))
3652 else if (!parse_aaa(loc
, line
, value
, linenum
))
3654 cupsdLogMessage(CUPSD_LOG_ERROR
,
3655 "Unknown Location directive %s on line %d.",
3657 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3662 cupsdLogMessage(CUPSD_LOG_ERROR
,
3663 "Unexpected end-of-file at line %d while reading location!",
3666 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3671 * 'read_policy()' - Read a <Policy name> definition.
3674 static int /* O - New line number or 0 on error */
3675 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3676 char *policy
, /* I - Location name/path */
3677 int linenum
) /* I - Current line number */
3679 int i
; /* Looping var */
3680 cupsd_policy_t
*pol
; /* Policy */
3681 cupsd_location_t
*op
; /* Policy operation */
3682 int num_ops
; /* Number of IPP operations */
3683 ipp_op_t ops
[100]; /* Operations */
3684 char line
[HTTP_MAX_BUFFER
],
3686 *value
, /* Value for directive */
3687 *valptr
; /* Pointer into value */
3691 * Create the policy...
3694 if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3698 * Read from the file...
3704 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3707 * Decode the directive...
3710 if (!strcasecmp(line
, "</Policy>"))
3713 cupsdLogMessage(CUPSD_LOG_WARN
,
3714 "Missing </Limit> before </Policy> on line %d!",
3717 set_policy_defaults(pol
);
3721 else if (!strcasecmp(line
, "<Limit") && !op
)
3725 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3726 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3733 * Scan for IPP operation names...
3740 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3745 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3747 if (!strcasecmp(value
, "All"))
3748 ops
[num_ops
] = IPP_ANY_OPERATION
;
3749 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3750 cupsdLogMessage(CUPSD_LOG_ERROR
,
3751 "Bad IPP operation name \"%s\" on line %d!",
3757 cupsdLogMessage(CUPSD_LOG_ERROR
,
3758 "Too many operations listed on line %d!",
3761 for (value
= valptr
; isspace(*value
& 255); value
++);
3765 * If none are specified, apply the policy to all operations...
3770 ops
[0] = IPP_ANY_OPERATION
;
3775 * Add a new policy for the first operation...
3778 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3780 else if (!strcasecmp(line
, "</Limit>") && op
)
3783 * Finish the current operation limit...
3789 * Copy the policy to the other operations...
3792 for (i
= 1; i
< num_ops
; i
++)
3793 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3798 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3799 !strcasecmp(line
, "JobPrivateValues") ||
3800 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3801 !strcasecmp(line
, "SubscriptionPrivateValues"))
3805 cupsdLogMessage(CUPSD_LOG_ERROR
,
3806 "%s directive must appear outside <Limit>...</Limit> "
3807 "on line %d.", line
, linenum
);
3808 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3814 * Pull out whitespace-delimited values...
3820 * Find the end of the current value...
3823 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3829 * Save it appropriately...
3832 if (!strcasecmp(line
, "JobPrivateAccess"))
3835 * JobPrivateAccess {all|default|user/group list|@@ACL}
3838 if (!strcasecmp(value
, "default"))
3840 cupsdAddString(&(pol
->job_access
), "@OWNER");
3841 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3844 cupsdAddString(&(pol
->job_access
), value
);
3846 else if (!strcasecmp(line
, "JobPrivateValues"))
3849 * JobPrivateValues {all|none|default|attribute list}
3852 if (!strcasecmp(value
, "default"))
3854 cupsdAddString(&(pol
->job_attrs
), "job-name");
3855 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3856 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3859 cupsdAddString(&(pol
->job_attrs
), value
);
3861 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3864 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3867 if (!strcasecmp(value
, "default"))
3869 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3870 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3873 cupsdAddString(&(pol
->sub_access
), value
);
3875 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3878 * SubscriptionPrivateValues {all|none|default|attribute list}
3881 if (!strcasecmp(value
, "default"))
3883 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3884 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3885 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3886 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3887 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3890 cupsdAddString(&(pol
->sub_attrs
), value
);
3894 * Find the next string on the line...
3897 for (value
= valptr
; isspace(*value
& 255); value
++);
3903 cupsdLogMessage(CUPSD_LOG_ERROR
,
3904 "Missing <Limit ops> directive before %s on line %d.",
3906 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3909 else if (!parse_aaa(op
, line
, value
, linenum
))
3912 cupsdLogMessage(CUPSD_LOG_ERROR
,
3913 "Unknown Policy Limit directive %s on line %d.",
3916 cupsdLogMessage(CUPSD_LOG_ERROR
,
3917 "Unknown Policy directive %s on line %d.",
3920 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3925 cupsdLogMessage(CUPSD_LOG_ERROR
,
3926 "Unexpected end-of-file at line %d while reading policy \"%s\"!",
3929 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3934 * 'set_policy_defaults()' - Set default policy values as needed.
3938 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3940 cupsd_location_t
*op
; /* Policy operation */
3944 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3945 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3946 * upgrades do not introduce new security issues...
3949 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3950 op
->op
== IPP_ANY_OPERATION
)
3952 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3953 op
->op
!= IPP_ANY_OPERATION
)
3956 * Add a new limit for Validate-Job using the Print-Job limit as a
3960 cupsdLogMessage(CUPSD_LOG_WARN
,
3961 "No limit for Validate-Job defined in policy %s "
3962 "- using Print-Job's policy.", pol
->name
);
3964 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3967 cupsdLogMessage(CUPSD_LOG_WARN
,
3968 "No limit for Validate-Job defined in policy %s "
3969 "and no suitable template found.", pol
->name
);
3972 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3973 op
->op
== IPP_ANY_OPERATION
)
3975 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3976 op
->op
!= IPP_ANY_OPERATION
)
3979 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3983 cupsdLogMessage(CUPSD_LOG_WARN
,
3984 "No limit for Cancel-Jobs defined in policy %s "
3985 "- using Pause-Printer's policy.", pol
->name
);
3987 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
3990 cupsdLogMessage(CUPSD_LOG_WARN
,
3991 "No limit for Cancel-Jobs defined in policy %s "
3992 "and no suitable template found.", pol
->name
);
3995 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
3996 op
->op
== IPP_ANY_OPERATION
)
3998 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3999 op
->op
!= IPP_ANY_OPERATION
)
4002 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4006 cupsdLogMessage(CUPSD_LOG_WARN
,
4007 "No limit for Cancel-My-Jobs defined in policy %s "
4008 "- using Send-Document's policy.", pol
->name
);
4010 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4013 cupsdLogMessage(CUPSD_LOG_WARN
,
4014 "No limit for Cancel-My-Jobs defined in policy %s "
4015 "and no suitable template found.", pol
->name
);
4018 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
4019 op
->op
== IPP_ANY_OPERATION
)
4021 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4022 op
->op
!= IPP_ANY_OPERATION
)
4025 * Add a new limit for Close-Job using the Send-Document limit as a
4029 cupsdLogMessage(CUPSD_LOG_WARN
,
4030 "No limit for Close-Job defined in policy %s "
4031 "- using Send-Document's policy.", pol
->name
);
4033 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4036 cupsdLogMessage(CUPSD_LOG_WARN
,
4037 "No limit for Close-Job defined in policy %s "
4038 "and no suitable template found.", pol
->name
);
4041 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4042 op
->op
== IPP_ANY_OPERATION
)
4044 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4045 op
->op
!= IPP_ANY_OPERATION
)
4048 * Add a new limit for CUPS-Get-Document using the Send-Document
4049 * limit as a template...
4052 cupsdLogMessage(CUPSD_LOG_WARN
,
4053 "No limit for CUPS-Get-Document defined in policy %s "
4054 "- using Send-Document's policy.", pol
->name
);
4056 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4059 cupsdLogMessage(CUPSD_LOG_WARN
,
4060 "No limit for CUPS-Get-Document defined in policy %s "
4061 "and no suitable template found.", pol
->name
);
4065 * Verify we have JobPrivateAccess, JobPrivateValues,
4066 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4069 if (!pol
->job_access
)
4071 cupsdLogMessage(CUPSD_LOG_WARN
,
4072 "No JobPrivateAccess defined in policy %s "
4073 "- using defaults.", pol
->name
);
4074 cupsdAddString(&(pol
->job_access
), "@OWNER");
4075 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4078 if (!pol
->job_attrs
)
4080 cupsdLogMessage(CUPSD_LOG_WARN
,
4081 "No JobPrivateValues defined in policy %s "
4082 "- using defaults.", pol
->name
);
4083 cupsdAddString(&(pol
->job_attrs
), "job-name");
4084 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4085 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4088 if (!pol
->sub_access
)
4090 cupsdLogMessage(CUPSD_LOG_WARN
,
4091 "No SubscriptionPrivateAccess defined in policy %s "
4092 "- using defaults.", pol
->name
);
4093 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4094 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4097 if (!pol
->sub_attrs
)
4099 cupsdLogMessage(CUPSD_LOG_WARN
,
4100 "No SubscriptionPrivateValues defined in policy %s "
4101 "- using defaults.", pol
->name
);
4102 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4103 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4104 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4105 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4106 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4112 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".