2 * "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $"
4 * Configuration routines for the CUPS scheduler.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdAddAlias() - Add a host alias.
18 * cupsdCheckPermissions() - Fix the mode and ownership of a file or
20 * cupsdFreeAliases() - Free all of the alias entries.
21 * cupsdReadConfiguration() - Read the cupsd.conf file.
22 * get_address() - Get an address + port number from a line.
23 * get_addr_and_mask() - Get an IP address and netmask.
24 * parse_aaa() - Parse authentication, authorization, and access
26 * parse_fatal_errors() - Parse FatalErrors values in a string.
27 * parse_groups() - Parse system group names in a string.
28 * parse_protocols() - Parse browse protocols in a string.
29 * read_configuration() - Read a configuration file.
30 * read_location() - Read a <Location path> definition.
31 * read_policy() - Read a <Policy name> definition.
32 * set_policy_defaults() - Set default policy values as needed.
36 * Include necessary headers...
42 #include <sys/utsname.h>
47 #endif /* HAVE_LIBPAPER */
51 * Possibly missing network definitions...
55 # define INADDR_NONE 0xffffffff
56 #endif /* !INADDR_NONE */
60 * Configuration variable structure...
65 CUPSD_VARTYPE_INTEGER
, /* Integer option */
66 CUPSD_VARTYPE_STRING
, /* String option */
67 CUPSD_VARTYPE_BOOLEAN
, /* Boolean option */
68 CUPSD_VARTYPE_PATHNAME
/* File/directory name option */
73 char *name
; /* Name of variable */
74 void *ptr
; /* Pointer to variable */
75 cupsd_vartype_t type
; /* Type (int, string, address) */
83 static const cupsd_var_t variables
[] =
85 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
86 { "AutoPurgeJobs", &JobAutoPurge
, CUPSD_VARTYPE_BOOLEAN
},
87 { "BrowseInterval", &BrowseInterval
, CUPSD_VARTYPE_INTEGER
},
89 { "BrowseLDAPBindDN", &BrowseLDAPBindDN
, CUPSD_VARTYPE_STRING
},
91 { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile
, CUPSD_VARTYPE_PATHNAME
},
92 # endif /* HAVE_LDAP_SSL */
93 { "BrowseLDAPDN", &BrowseLDAPDN
, CUPSD_VARTYPE_STRING
},
94 { "BrowseLDAPPassword", &BrowseLDAPPassword
, CUPSD_VARTYPE_STRING
},
95 { "BrowseLDAPServer", &BrowseLDAPServer
, CUPSD_VARTYPE_STRING
},
96 #endif /* HAVE_LDAP */
97 { "BrowseLocalOptions", &BrowseLocalOptions
, CUPSD_VARTYPE_STRING
},
98 { "BrowsePort", &BrowsePort
, CUPSD_VARTYPE_INTEGER
},
99 { "BrowseRemoteOptions", &BrowseRemoteOptions
, CUPSD_VARTYPE_STRING
},
100 { "BrowseShortNames", &BrowseShortNames
, CUPSD_VARTYPE_BOOLEAN
},
101 { "BrowseTimeout", &BrowseTimeout
, CUPSD_VARTYPE_INTEGER
},
102 { "BrowseWebIF", &BrowseWebIF
, CUPSD_VARTYPE_BOOLEAN
},
103 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
104 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
105 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
106 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
107 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
108 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
109 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
110 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
111 { "DefaultPaperSize", &DefaultPaperSize
, CUPSD_VARTYPE_STRING
},
112 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
113 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
114 { "DirtyCleanInterval", &DirtyCleanInterval
, CUPSD_VARTYPE_INTEGER
},
115 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
116 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
117 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
118 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
119 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
120 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
121 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
122 { "HideImplicitMembers", &HideImplicitMembers
, CUPSD_VARTYPE_BOOLEAN
},
123 { "ImplicitClasses", &ImplicitClasses
, CUPSD_VARTYPE_BOOLEAN
},
124 { "ImplicitAnyClasses", &ImplicitAnyClasses
, CUPSD_VARTYPE_BOOLEAN
},
125 { "JobKillDelay", &JobKillDelay
, CUPSD_VARTYPE_INTEGER
},
126 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
127 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_INTEGER
},
128 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_INTEGER
},
129 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
131 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_INTEGER
},
132 #endif /* HAVE_LAUNCHD */
133 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
134 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
135 { "LogDebugHistory", &LogDebugHistory
, CUPSD_VARTYPE_INTEGER
},
136 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
137 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
138 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
139 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
140 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
141 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
142 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
143 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
144 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
145 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
146 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
147 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
148 { "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 %u %j %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 * Setup environment variables...
700 * Read the configuration file...
703 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
706 status
= read_configuration(fp
);
715 cupsdLogMessage(CUPSD_LOG_INFO
, "Remote access is %s.",
716 RemotePort
? "enabled" : "disabled");
719 BrowseLocalProtocols
= 0; /* Disable sharing - no remote access */
722 * See if the ServerName is an IP address...
728 ServerAlias
= cupsArrayNew(NULL
, NULL
);
730 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", ServerName
);
734 if (gethostname(temp
, sizeof(temp
)))
736 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to get hostname: %s",
738 strlcpy(temp
, "localhost", sizeof(temp
));
741 cupsdSetString(&ServerName
, temp
);
744 ServerAlias
= cupsArrayNew(NULL
, NULL
);
746 cupsdAddAlias(ServerAlias
, temp
);
747 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
749 if (HostNameLookups
|| RemotePort
)
751 struct hostent
*host
; /* Host entry to get FQDN */
753 if ((host
= gethostbyname(temp
)) != NULL
)
755 if (strcasecmp(temp
, host
->h_name
))
757 cupsdSetString(&ServerName
, host
->h_name
);
758 cupsdAddAlias(ServerAlias
, host
->h_name
);
759 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
765 for (i
= 0; host
->h_aliases
[i
]; i
++)
766 if (strcasecmp(temp
, host
->h_aliases
[i
]))
768 cupsdAddAlias(ServerAlias
, host
->h_aliases
[i
]);
769 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s",
777 * Make sure we have the base hostname added as an alias, too!
780 if ((slash
= strchr(temp
, '.')) != NULL
)
783 cupsdAddAlias(ServerAlias
, temp
);
784 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Added auto ServerAlias %s", temp
);
788 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
790 ServerNameIsIP
= !*slash
;
793 * Make sure ServerAdmin is initialized...
797 cupsdSetStringf(&ServerAdmin
, "root@%s", ServerName
);
800 * Use the default system group if none was supplied in cupsd.conf...
803 if (NumSystemGroups
== 0)
805 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
808 * Find the group associated with GID 0...
815 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
817 cupsdSetString(&SystemGroups
[0], "unknown");
819 SystemGroupIDs
[0] = 0;
825 * Get the access control list for browsing...
828 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
831 * Open the system log for cupsd if necessary...
835 if (!strcmp(AccessLog
, "syslog") ||
836 !strcmp(ErrorLog
, "syslog") ||
837 !strcmp(PageLog
, "syslog"))
838 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
839 #endif /* HAVE_VSYSLOG */
842 * Log the configuration file that was used...
845 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
849 * Validate the Group and SystemGroup settings - they cannot be the same,
850 * otherwise the CGI programs will be able to authenticate as root without
856 for (i
= 0; i
< NumSystemGroups
; i
++)
857 if (Group
== SystemGroupIDs
[i
])
860 if (i
< NumSystemGroups
)
863 * Log the error and reset the group to a safe value...
866 cupsdLogMessage(CUPSD_LOG_NOTICE
,
867 "Group and SystemGroup cannot use the same groups.");
868 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
870 group
= getgrnam("nobody");
874 Group
= group
->gr_gid
;
878 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
879 * complement number...)
888 * Check that we have at least one listen/port line; if not, report this
889 * as an error and exit!
892 if (cupsArrayCount(Listeners
) == 0)
898 cupsdLogMessage(CUPSD_LOG_EMERG
,
899 "No valid Listen or Port lines were found in the "
900 "configuration file.");
906 cupsdEndProcess(getpid(), 0);
910 * Set the default locale using the language and charset...
913 cupsdSetStringf(&DefaultLocale
, "%s.UTF-8", DefaultLanguage
);
916 * Update all relative filenames to include the full path from ServerRoot...
919 if (DocumentRoot
[0] != '/')
920 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
922 if (RequestRoot
[0] != '/')
923 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
925 if (ServerBin
[0] != '/')
926 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
928 if (StateDir
[0] != '/')
929 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
931 if (CacheDir
[0] != '/')
932 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
935 if (ServerCertificate
[0] != '/')
936 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
938 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)) &&
939 cupsdCheckPermissions(ServerCertificate
, NULL
, 0600, RunUser
, Group
,
941 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
944 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
945 if (ServerKey
[0] != '/')
946 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
948 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)) &&
949 cupsdCheckPermissions(ServerKey
, NULL
, 0600, RunUser
, Group
, 0, 0) < 0 &&
950 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
952 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
953 #endif /* HAVE_SSL */
956 * Make sure that directories and config files are owned and
957 * writable by the user and group in the cupsd.conf file...
960 snprintf(temp
, sizeof(temp
), "%s/rss", CacheDir
);
962 if ((cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
964 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
966 cupsdCheckPermissions(temp
, NULL
, 0775, RunUser
,
968 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
970 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
971 SystemGroupIDs
[0], 1, 1) < 0 ||
972 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
974 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
976 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
978 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
980 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
982 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
984 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
986 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
990 * Update TempDir to the default if it hasn't been set already...
995 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
998 * TMPDIR is defined, see if it is OK for us to use...
1001 if (stat(tmpdir
, &tmpinfo
))
1002 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
1003 tmpdir
, strerror(errno
));
1004 else if (!S_ISDIR(tmpinfo
.st_mode
))
1005 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory.",
1007 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
1008 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
1009 !(tmpinfo
.st_mode
& S_IWOTH
))
1010 cupsdLogMessage(CUPSD_LOG_ERROR
,
1011 "TMPDIR (%s) has the wrong permissions.", tmpdir
);
1013 cupsdSetString(&TempDir
, tmpdir
);
1018 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
1020 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
1025 * Make sure the temporary directory has the right permissions...
1028 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
1032 * Update ownership and permissions if the CUPS temp directory
1033 * is under the spool directory or does not exist...
1036 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0 &&
1037 (FatalErrors
& CUPSD_FATAL_PERMISSIONS
))
1042 * Update environment variables...
1048 * Update default paper size setting as needed...
1051 if (!DefaultPaperSize
)
1053 #ifdef HAVE_LIBPAPER
1054 char *paper_result
; /* Paper size name from libpaper */
1056 if ((paper_result
= systempapername()) != NULL
)
1057 cupsdSetString(&DefaultPaperSize
, paper_result
);
1059 #endif /* HAVE_LIBPAPER */
1060 if (!DefaultLanguage
||
1061 !strcasecmp(DefaultLanguage
, "C") ||
1062 !strcasecmp(DefaultLanguage
, "POSIX") ||
1063 !strcasecmp(DefaultLanguage
, "en") ||
1064 !strncasecmp(DefaultLanguage
, "en.", 3) ||
1065 !strncasecmp(DefaultLanguage
, "en_US", 5) ||
1066 !strncasecmp(DefaultLanguage
, "en_CA", 5) ||
1067 !strncasecmp(DefaultLanguage
, "fr_CA", 5))
1070 * These are the only locales that will default to "letter" size...
1073 cupsdSetString(&DefaultPaperSize
, "Letter");
1076 cupsdSetString(&DefaultPaperSize
, "A4");
1080 * Update classification setting as needed...
1083 if (Classification
&& !strcasecmp(Classification
, "none"))
1084 cupsdClearString(&Classification
);
1087 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
1090 * Check the MaxClients setting, and then allocate memory for it...
1093 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
1096 cupsdLogMessage(CUPSD_LOG_INFO
,
1097 "MaxClients limited to 1/3 (%d) of the file descriptor "
1099 MaxFDs
/ 3, MaxFDs
);
1101 MaxClients
= MaxFDs
/ 3;
1104 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
1108 * Check the MaxActiveJobs setting; limit to 1/3 the available
1109 * file descriptors, since we need a pipe for each job...
1112 if (MaxActiveJobs
> (MaxFDs
/ 3))
1113 MaxActiveJobs
= MaxFDs
/ 3;
1116 * Update the MaxClientsPerHost value, as needed...
1119 if (MaxClientsPerHost
<= 0)
1120 MaxClientsPerHost
= MaxClients
;
1122 if (MaxClientsPerHost
> MaxClients
)
1123 MaxClientsPerHost
= MaxClients
;
1125 cupsdLogMessage(CUPSD_LOG_INFO
,
1126 "Allowing up to %d client connections per host.",
1130 * Make sure that BrowseTimeout is at least twice the interval...
1133 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
1135 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d.",
1139 BrowseTimeout
= BrowseInterval
* 2;
1141 BrowseTimeout
= DEFAULT_TIMEOUT
;
1143 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d.",
1148 * Update the default policy, as needed...
1152 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
1154 DefaultPolicyPtr
= NULL
;
1156 if (!DefaultPolicyPtr
)
1158 cupsd_location_t
*po
; /* New policy operation */
1162 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found.",
1165 cupsdSetString(&DefaultPolicy
, "default");
1167 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
1168 cupsdLogMessage(CUPSD_LOG_INFO
,
1169 "Using policy \"default\" as the default.");
1172 cupsdLogMessage(CUPSD_LOG_INFO
,
1173 "Creating CUPS default administrative policy:");
1175 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
1177 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
1179 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateAccess default");
1180 cupsdAddString(&(p
->job_access
), "@OWNER");
1181 cupsdAddString(&(p
->job_access
), "@SYSTEM");
1183 cupsdLogMessage(CUPSD_LOG_INFO
, "JobPrivateValues default");
1184 cupsdAddString(&(p
->job_attrs
), "job-name");
1185 cupsdAddString(&(p
->job_attrs
), "job-originating-host-name");
1186 cupsdAddString(&(p
->job_attrs
), "job-originating-user-name");
1188 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateAccess default");
1189 cupsdAddString(&(p
->sub_access
), "@OWNER");
1190 cupsdAddString(&(p
->sub_access
), "@SYSTEM");
1192 cupsdLogMessage(CUPSD_LOG_INFO
, "SubscriptionPrivateValues default");
1193 cupsdAddString(&(p
->job_attrs
), "notify-events");
1194 cupsdAddString(&(p
->job_attrs
), "notify-pull-method");
1195 cupsdAddString(&(p
->job_attrs
), "notify-recipient-uri");
1196 cupsdAddString(&(p
->job_attrs
), "notify-subscriber-user-name");
1197 cupsdAddString(&(p
->job_attrs
), "notify-user-data");
1199 cupsdLogMessage(CUPSD_LOG_INFO
,
1200 "<Limit Create-Job Print-Job Print-URI Validate-Job>");
1201 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1203 po
= cupsdAddPolicyOp(p
, NULL
, IPP_CREATE_JOB
);
1204 po
->order_type
= CUPSD_AUTH_ALLOW
;
1206 cupsdAddPolicyOp(p
, po
, IPP_PRINT_JOB
);
1207 cupsdAddPolicyOp(p
, po
, IPP_PRINT_URI
);
1208 cupsdAddPolicyOp(p
, po
, IPP_VALIDATE_JOB
);
1210 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1212 cupsdLogMessage(CUPSD_LOG_INFO
,
1213 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
1214 "Release-Job Restart-Job Purge-Jobs "
1215 "Set-Job-Attributes Create-Job-Subscription "
1216 "Renew-Subscription Cancel-Subscription "
1217 "Get-Notifications Reprocess-Job Cancel-Current-Job "
1218 "Suspend-Current-Job Resume-Job "
1219 "Cancel-My-Jobs Close-Job CUPS-Move-Job "
1220 "CUPS-Authenticate-Job CUPS-Get-Document>");
1221 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1223 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
1224 po
->order_type
= CUPSD_AUTH_ALLOW
;
1225 po
->level
= CUPSD_AUTH_USER
;
1227 cupsdAddName(po
, "@OWNER");
1228 cupsdAddName(po
, "@SYSTEM");
1229 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
1231 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
1232 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
1233 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
1234 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
1235 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
1236 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
1237 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
1238 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
1239 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
1240 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
1241 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
1242 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
1243 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
1244 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
1245 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
1246 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_MY_JOBS
);
1247 cupsdAddPolicyOp(p
, po
, IPP_CLOSE_JOB
);
1248 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
1249 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
1250 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
1252 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1254 cupsdLogMessage(CUPSD_LOG_INFO
,
1255 "<Limit Pause-Printer Resume-Printer "
1256 "Set-Printer-Attributes Enable-Printer "
1257 "Disable-Printer Pause-Printer-After-Current-Job "
1258 "Hold-New-Jobs Release-Held-New-Jobs "
1259 "Deactivate-Printer Activate-Printer Restart-Printer "
1260 "Shutdown-Printer Startup-Printer Promote-Job "
1261 "Schedule-Job-After Cancel-Jobs CUPS-Add-Printer "
1262 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1263 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1264 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1265 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1267 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1268 po
->order_type
= CUPSD_AUTH_ALLOW
;
1269 po
->type
= CUPSD_AUTH_DEFAULT
;
1270 po
->level
= CUPSD_AUTH_USER
;
1272 cupsdAddName(po
, "@SYSTEM");
1273 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1275 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1276 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1277 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1278 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1279 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1280 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1281 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1282 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1283 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1284 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1285 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1286 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1287 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1288 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1289 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOBS
);
1290 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1291 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1292 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1293 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1294 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1295 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1296 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1298 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1300 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1301 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1303 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1304 po
->order_type
= CUPSD_AUTH_ALLOW
;
1306 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1307 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1311 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1312 cupsArrayCount(Policies
));
1313 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1315 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1316 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1317 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1320 * If we are doing a full reload or the server root has changed, flush
1321 * the jobs, printers, etc. and start from scratch...
1324 if (NeedReload
== RELOAD_ALL
||
1325 old_remote_port
!= RemotePort
||
1326 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1327 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1329 mime_type_t
*type
; /* Current type */
1330 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1331 /* MIME type name */
1334 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1337 * Free all memory...
1340 cupsdDeleteAllSubscriptions();
1342 cupsdDeleteAllPrinters();
1344 DefaultPrinter
= NULL
;
1346 if (MimeDatabase
!= NULL
)
1347 mimeDelete(MimeDatabase
);
1351 for (i
= 0; i
< NumMimeTypes
; i
++)
1352 _cupsStrFree(MimeTypes
[i
]);
1358 * Read the MIME type and conversion database...
1361 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1362 snprintf(mimedir
, sizeof(mimedir
), "%s/mime", DataDir
);
1364 MimeDatabase
= mimeLoadTypes(NULL
, mimedir
);
1365 MimeDatabase
= mimeLoadTypes(MimeDatabase
, ServerRoot
);
1366 MimeDatabase
= mimeLoadFilters(MimeDatabase
, mimedir
, temp
);
1367 MimeDatabase
= mimeLoadFilters(MimeDatabase
, ServerRoot
, temp
);
1371 cupsdLogMessage(CUPSD_LOG_EMERG
,
1372 "Unable to load MIME database from \"%s\" or \"%s\".",
1373 mimedir
, ServerRoot
);
1374 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
1378 cupsdLogMessage(CUPSD_LOG_INFO
,
1379 "Loaded MIME database from \"%s\" and \"%s\": %d types, "
1380 "%d filters...", mimedir
, ServerRoot
,
1381 mimeNumTypes(MimeDatabase
), mimeNumFilters(MimeDatabase
));
1384 * Create a list of MIME types for the document-format-supported
1388 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1389 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1392 if ((MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *))) == NULL
)
1394 cupsdLogMessage(CUPSD_LOG_ERROR
,
1395 "Unable to allocate memory for %d MIME types.",
1401 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1403 i
++, type
= mimeNextType(MimeDatabase
))
1405 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1407 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1410 if (i
< NumMimeTypes
)
1411 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1414 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1416 mime_filter_t
*filter
; /* Current filter */
1419 for (type
= mimeFirstType(MimeDatabase
);
1421 type
= mimeNextType(MimeDatabase
))
1422 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1423 type
->super
, type
->type
);
1425 for (filter
= mimeFirstFilter(MimeDatabase
);
1427 filter
= mimeNextFilter(MimeDatabase
))
1428 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1429 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1430 filter
->src
->super
, filter
->src
->type
,
1431 filter
->dst
->super
, filter
->dst
->type
,
1432 filter
->cost
, filter
->filter
);
1439 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1440 cupsdLoadBanners(temp
);
1443 * Load printers and classes...
1446 cupsdLoadAllPrinters();
1447 cupsdLoadAllClasses();
1448 cupsdLoadRemoteCache();
1450 cupsdCreateCommonData();
1453 * Update the printcap file as needed...
1456 if (Printcap
&& *Printcap
&& access(Printcap
, 0))
1457 cupsdWritePrintcap();
1460 * Load queued jobs...
1466 * Load subscriptions...
1469 cupsdLoadAllSubscriptions();
1471 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1476 * Not a full reload, so recreate the common printer attributes...
1479 cupsdCreateCommonData();
1482 * Update all printers as needed...
1485 cupsdUpdatePrinters();
1486 cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP
);
1488 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1492 * Reset the reload state...
1495 NeedReload
= RELOAD_NONE
;
1497 cupsdClearString(&old_serverroot
);
1498 cupsdClearString(&old_requestroot
);
1505 * 'get_address()' - Get an address + port number from a line.
1508 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1509 get_address(const char *value
, /* I - Value string */
1510 int defport
) /* I - Default port */
1512 char buffer
[1024], /* Hostname + port number buffer */
1513 defpname
[255], /* Default port name */
1514 *hostname
, /* Hostname or IP */
1515 *portname
; /* Port number or name */
1516 http_addrlist_t
*addrlist
; /* Address list */
1520 * Check for an empty value...
1525 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address.");
1530 * Grab a hostname and port number; if there is no colon and the port name
1531 * is only digits, then we have a port number by itself...
1534 strlcpy(buffer
, value
, sizeof(buffer
));
1536 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1543 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1548 * Use the default port...
1551 sprintf(defpname
, "%d", defport
);
1552 portname
= defpname
;
1558 * The buffer contains just a port number...
1566 if (hostname
&& !strcmp(hostname
, "*"))
1570 * Now lookup the address using httpAddrGetList()...
1573 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1574 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed.",
1575 hostname
? hostname
: "(nil)");
1582 * 'get_addr_and_mask()' - Get an IP address and netmask.
1585 static int /* O - 1 on success, 0 on failure */
1586 get_addr_and_mask(const char *value
, /* I - String from config file */
1587 unsigned *ip
, /* O - Address value */
1588 unsigned *mask
) /* O - Mask value */
1590 int i
, j
, /* Looping vars */
1591 family
, /* Address family */
1592 ipcount
; /* Count of fields in address */
1593 unsigned ipval
; /* Value */
1594 const char *maskval
, /* Pointer to start of mask value */
1595 *ptr
, /* Pointer into value */
1600 * Get the address...
1603 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1604 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1606 if ((maskval
= strchr(value
, '/')) != NULL
)
1609 maskval
= value
+ strlen(value
);
1613 * Check for an IPv6 address...
1619 * Parse hexadecimal IPv6 address...
1624 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1628 else if (!strncmp(ptr
, "::", 2))
1630 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1632 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1637 else if (isxdigit(*ptr
& 255))
1639 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1647 ip
[i
/ 2] |= ipval
<< 16;
1661 if (*ptr
&& *ptr
!= '/')
1665 #endif /* AF_INET6 */
1668 * Parse dotted-decimal IPv4 address...
1671 unsigned val
[4]; /* IPv4 address values */
1675 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1678 * Range check the IP numbers...
1681 for (i
= 0; i
< ipcount
; i
++)
1686 * Make sure the trailing values are zeroed, as some C libraries like
1687 * glibc apparently like to fill the unused arguments with garbage...
1690 for (i
= ipcount
; i
< 4; i
++)
1694 * Merge everything into a 32-bit IPv4 address in ip[3]...
1697 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1700 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1706 * Get the netmask value(s)...
1709 memset(mask
, 0, sizeof(unsigned) * 4);
1711 if (strchr(maskval
, '.'))
1714 * Get dotted-decimal mask...
1717 if (family
!= AF_INET
)
1720 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1723 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1724 mask
[0] = mask
[1] = mask
[2] = 0;
1729 * Get address/bits format...
1735 if (family
== AF_INET6
)
1743 mask
[0] = 0xffffffff;
1745 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1748 mask
[1] = 0xffffffff;
1752 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1755 mask
[2] = 0xffffffff;
1759 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1762 mask
[3] = 0xffffffff;
1766 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1769 #endif /* AF_INET6 */
1774 mask
[0] = 0xffffffff;
1775 mask
[1] = 0xffffffff;
1776 mask
[2] = 0xffffffff;
1779 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1781 mask
[3] = 0xffffffff;
1786 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1787 "get_addr_and_mask(value=\"%s\", "
1788 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1789 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1793 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1796 if ((ip
[0] & ~mask
[0]) != 0 ||
1797 (ip
[1] & ~mask
[1]) != 0 ||
1798 (ip
[2] & ~mask
[2]) != 0 ||
1799 (ip
[3] & ~mask
[3]) != 0)
1807 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1810 static int /* O - 1 on success, 0 on failure */
1811 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1812 char *line
, /* I - Line from file */
1813 char *value
, /* I - Start of value data */
1814 int linenum
) /* I - Current line number */
1816 char *valptr
; /* Pointer into value */
1817 unsigned ip
[4], /* IP address components */
1818 mask
[4]; /* IP netmask components */
1821 if (!strcasecmp(line
, "Encryption"))
1824 * "Encryption xxx" - set required encryption level...
1827 if (!strcasecmp(value
, "never"))
1828 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1829 else if (!strcasecmp(value
, "always"))
1831 cupsdLogMessage(CUPSD_LOG_ERROR
,
1832 "Encryption value \"%s\" on line %d is invalid in this "
1833 "context. Using \"required\" instead.", value
, linenum
);
1835 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1837 else if (!strcasecmp(value
, "required"))
1838 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1839 else if (!strcasecmp(value
, "ifrequested"))
1840 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1843 cupsdLogMessage(CUPSD_LOG_ERROR
,
1844 "Unknown Encryption value %s on line %d.", value
, linenum
);
1848 else if (!strcasecmp(line
, "Order"))
1851 * "Order Deny,Allow" or "Order Allow,Deny"...
1854 if (!strncasecmp(value
, "deny", 4))
1855 loc
->order_type
= CUPSD_AUTH_ALLOW
;
1856 else if (!strncasecmp(value
, "allow", 5))
1857 loc
->order_type
= CUPSD_AUTH_DENY
;
1860 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1865 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1868 * Allow [From] host/ip...
1869 * Deny [From] host/ip...
1874 if (!strncasecmp(value
, "from", 4))
1877 * Strip leading "from"...
1882 while (isspace(*value
& 255))
1890 * Find the end of the value...
1893 for (valptr
= value
; *valptr
&& !isspace(*valptr
& 255); valptr
++);
1895 while (isspace(*valptr
& 255))
1899 * Figure out what form the allow/deny address takes:
1910 * nnn.nnn.nnn.nnn/mm
1911 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1914 if (!strcasecmp(value
, "all"))
1920 if (!strcasecmp(line
, "Allow"))
1921 cupsdAddIPMask(&(loc
->allow
), zeros
, zeros
);
1923 cupsdAddIPMask(&(loc
->deny
), zeros
, zeros
);
1925 else if (!strcasecmp(value
, "none"))
1931 if (!strcasecmp(line
, "Allow"))
1932 cupsdAddIPMask(&(loc
->allow
), ones
, zeros
);
1934 cupsdAddIPMask(&(loc
->deny
), ones
, zeros
);
1937 else if (value
[0] == '*' || value
[0] == '.' ||
1938 (!isdigit(value
[0] & 255) && value
[0] != '['))
1940 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1941 #endif /* AF_INET6 */
1944 * Host or domain name...
1947 if (value
[0] == '*')
1950 if (!strcasecmp(line
, "Allow"))
1951 cupsdAddNameMask(&(loc
->allow
), value
);
1953 cupsdAddNameMask(&(loc
->deny
), value
);
1958 * One of many IP address forms...
1961 if (!get_addr_and_mask(value
, ip
, mask
))
1963 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1968 if (!strcasecmp(line
, "Allow"))
1969 cupsdAddIPMask(&(loc
->allow
), ip
, mask
);
1971 cupsdAddIPMask(&(loc
->deny
), ip
, mask
);
1975 * Advance to next value...
1981 else if (!strcasecmp(line
, "AuthType"))
1984 * AuthType {none,basic,digest,basicdigest,negotiate,default}
1987 if (!strcasecmp(value
, "none"))
1989 loc
->type
= CUPSD_AUTH_NONE
;
1990 loc
->level
= CUPSD_AUTH_ANON
;
1992 else if (!strcasecmp(value
, "basic"))
1994 loc
->type
= CUPSD_AUTH_BASIC
;
1996 if (loc
->level
== CUPSD_AUTH_ANON
)
1997 loc
->level
= CUPSD_AUTH_USER
;
1999 else if (!strcasecmp(value
, "digest"))
2001 loc
->type
= CUPSD_AUTH_DIGEST
;
2003 if (loc
->level
== CUPSD_AUTH_ANON
)
2004 loc
->level
= CUPSD_AUTH_USER
;
2006 else if (!strcasecmp(value
, "basicdigest"))
2008 loc
->type
= CUPSD_AUTH_BASICDIGEST
;
2010 if (loc
->level
== CUPSD_AUTH_ANON
)
2011 loc
->level
= CUPSD_AUTH_USER
;
2013 else if (!strcasecmp(value
, "default"))
2015 loc
->type
= CUPSD_AUTH_DEFAULT
;
2017 if (loc
->level
== CUPSD_AUTH_ANON
)
2018 loc
->level
= CUPSD_AUTH_USER
;
2021 else if (!strcasecmp(value
, "negotiate"))
2023 loc
->type
= CUPSD_AUTH_NEGOTIATE
;
2025 if (loc
->level
== CUPSD_AUTH_ANON
)
2026 loc
->level
= CUPSD_AUTH_USER
;
2028 #endif /* HAVE_GSSAPI */
2031 cupsdLogMessage(CUPSD_LOG_WARN
,
2032 "Unknown authorization type %s on line %d.",
2037 else if (!strcasecmp(line
, "AuthClass"))
2040 * AuthClass anonymous, user, system, group
2043 if (!strcasecmp(value
, "anonymous"))
2045 loc
->type
= CUPSD_AUTH_NONE
;
2046 loc
->level
= CUPSD_AUTH_ANON
;
2048 cupsdLogMessage(CUPSD_LOG_WARN
,
2049 "\"AuthClass %s\" is deprecated; consider removing "
2053 else if (!strcasecmp(value
, "user"))
2055 loc
->level
= CUPSD_AUTH_USER
;
2057 cupsdLogMessage(CUPSD_LOG_WARN
,
2058 "\"AuthClass %s\" is deprecated; consider using "
2059 "\"Require valid-user\" on line %d.",
2062 else if (!strcasecmp(value
, "group"))
2064 loc
->level
= CUPSD_AUTH_GROUP
;
2066 cupsdLogMessage(CUPSD_LOG_WARN
,
2067 "\"AuthClass %s\" is deprecated; consider using "
2068 "\"Require user @groupname\" on line %d.",
2071 else if (!strcasecmp(value
, "system"))
2073 loc
->level
= CUPSD_AUTH_GROUP
;
2075 cupsdAddName(loc
, "@SYSTEM");
2077 cupsdLogMessage(CUPSD_LOG_WARN
,
2078 "\"AuthClass %s\" is deprecated; consider using "
2079 "\"Require user @SYSTEM\" on line %d.",
2084 cupsdLogMessage(CUPSD_LOG_WARN
,
2085 "Unknown authorization class %s on line %d.",
2090 else if (!strcasecmp(line
, "AuthGroupName"))
2092 cupsdAddName(loc
, value
);
2094 cupsdLogMessage(CUPSD_LOG_WARN
,
2095 "\"AuthGroupName %s\" directive is deprecated; consider "
2096 "using \"Require user @%s\" on line %d.",
2097 value
, value
, linenum
);
2099 else if (!strcasecmp(line
, "Require"))
2102 * Apache synonym for AuthClass and AuthGroupName...
2106 * Require valid-user
2107 * Require group names
2108 * Require user names
2111 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2116 if (!strcasecmp(value
, "valid-user") ||
2117 !strcasecmp(value
, "user"))
2118 loc
->level
= CUPSD_AUTH_USER
;
2119 else if (!strcasecmp(value
, "group"))
2120 loc
->level
= CUPSD_AUTH_GROUP
;
2123 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
2129 * Get the list of names from the line...
2132 for (value
= valptr
; *value
;)
2134 while (isspace(*value
& 255))
2137 #ifdef HAVE_AUTHORIZATION_H
2138 if (!strncmp(value
, "@AUTHKEY(", 9))
2141 * Grab "@AUTHKEY(name)" value...
2144 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
2150 #endif /* HAVE_AUTHORIZATION_H */
2151 if (*value
== '\"' || *value
== '\'')
2154 * Grab quoted name...
2157 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
2164 * Grab literal name.
2167 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
2173 cupsdAddName(loc
, value
);
2175 for (value
= valptr
; isspace(*value
& 255); value
++);
2178 else if (!strcasecmp(line
, "Satisfy"))
2180 if (!strcasecmp(value
, "all"))
2181 loc
->satisfy
= CUPSD_AUTH_SATISFY_ALL
;
2182 else if (!strcasecmp(value
, "any"))
2183 loc
->satisfy
= CUPSD_AUTH_SATISFY_ANY
;
2186 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
2199 * 'parse_fatal_errors()' - Parse FatalErrors values in a string.
2202 static int /* O - FatalErrors bits */
2203 parse_fatal_errors(const char *s
) /* I - FatalErrors string */
2205 int fatal
; /* FatalErrors bits */
2206 char value
[1024], /* Value string */
2207 *valstart
, /* Pointer into value */
2208 *valend
; /* End of value */
2212 * Empty FatalErrors line yields NULL pointer...
2216 return (CUPSD_FATAL_NONE
);
2219 * Loop through the value string,...
2222 strlcpy(value
, s
, sizeof(value
));
2224 fatal
= CUPSD_FATAL_NONE
;
2226 for (valstart
= value
; *valstart
;)
2229 * Get the current space/comma-delimited kind name...
2232 for (valend
= valstart
; *valend
; valend
++)
2233 if (isspace(*valend
& 255) || *valend
== ',')
2240 * Add the error to the bitmask...
2243 if (!strcasecmp(valstart
, "all"))
2244 fatal
= CUPSD_FATAL_ALL
;
2245 else if (!strcasecmp(valstart
, "browse"))
2246 fatal
|= CUPSD_FATAL_BROWSE
;
2247 else if (!strcasecmp(valstart
, "-browse"))
2248 fatal
&= ~CUPSD_FATAL_BROWSE
;
2249 else if (!strcasecmp(valstart
, "config"))
2250 fatal
|= CUPSD_FATAL_CONFIG
;
2251 else if (!strcasecmp(valstart
, "-config"))
2252 fatal
&= ~CUPSD_FATAL_CONFIG
;
2253 else if (!strcasecmp(valstart
, "listen"))
2254 fatal
|= CUPSD_FATAL_LISTEN
;
2255 else if (!strcasecmp(valstart
, "-listen"))
2256 fatal
&= ~CUPSD_FATAL_LISTEN
;
2257 else if (!strcasecmp(valstart
, "log"))
2258 fatal
|= CUPSD_FATAL_LOG
;
2259 else if (!strcasecmp(valstart
, "-log"))
2260 fatal
&= ~CUPSD_FATAL_LOG
;
2261 else if (!strcasecmp(valstart
, "permissions"))
2262 fatal
|= CUPSD_FATAL_PERMISSIONS
;
2263 else if (!strcasecmp(valstart
, "-permissions"))
2264 fatal
&= ~CUPSD_FATAL_PERMISSIONS
;
2265 else if (strcasecmp(valstart
, "none"))
2266 cupsdLogMessage(CUPSD_LOG_ERROR
,
2267 "Unknown FatalErrors kind \"%s\" ignored.", valstart
);
2269 for (valstart
= valend
; *valstart
; valstart
++)
2270 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2279 * 'parse_groups()' - Parse system group names in a string.
2282 static int /* O - 1 on success, 0 on failure */
2283 parse_groups(const char *s
) /* I - Space-delimited groups */
2285 int status
; /* Return status */
2286 char value
[1024], /* Value string */
2287 *valstart
, /* Pointer into value */
2288 *valend
, /* End of value */
2289 quote
; /* Quote character */
2290 struct group
*group
; /* Group */
2294 * Make a copy of the string and parse out the groups...
2297 strlcpy(value
, s
, sizeof(value
));
2302 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
2304 if (*valstart
== '\'' || *valstart
== '\"')
2307 * Scan quoted name...
2310 quote
= *valstart
++;
2312 for (valend
= valstart
; *valend
; valend
++)
2313 if (*valend
== quote
)
2319 * Scan space or comma-delimited name...
2322 for (valend
= valstart
; *valend
; valend
++)
2323 if (isspace(*valend
) || *valend
== ',')
2330 group
= getgrnam(valstart
);
2333 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
2334 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
2345 while (*valstart
== ',' || isspace(*valstart
))
2354 * 'parse_protocols()' - Parse browse protocols in a string.
2357 static int /* O - Browse protocol bits */
2358 parse_protocols(const char *s
) /* I - Space-delimited protocols */
2360 int protocols
; /* Browse protocol bits */
2361 char value
[1024], /* Value string */
2362 *valstart
, /* Pointer into value */
2363 *valend
; /* End of value */
2367 * Empty protocol line yields NULL pointer...
2374 * Loop through the value string,...
2377 strlcpy(value
, s
, sizeof(value
));
2381 for (valstart
= value
; *valstart
;)
2384 * Get the current space/comma-delimited protocol name...
2387 for (valend
= valstart
; *valend
; valend
++)
2388 if (isspace(*valend
& 255) || *valend
== ',')
2395 * Add the protocol to the bitmask...
2398 if (!strcasecmp(valstart
, "cups"))
2399 protocols
|= BROWSE_CUPS
;
2400 else if (!strcasecmp(valstart
, "slp"))
2401 protocols
|= BROWSE_SLP
;
2402 else if (!strcasecmp(valstart
, "ldap"))
2403 protocols
|= BROWSE_LDAP
;
2404 else if (!strcasecmp(valstart
, "dnssd") ||
2405 !strcasecmp(valstart
, "dns-sd") ||
2406 !strcasecmp(valstart
, "bonjour"))
2407 protocols
|= BROWSE_DNSSD
;
2408 else if (!strcasecmp(valstart
, "lpd"))
2409 protocols
|= BROWSE_LPD
;
2410 else if (!strcasecmp(valstart
, "smb"))
2411 protocols
|= BROWSE_SMB
;
2412 else if (!strcasecmp(valstart
, "all"))
2413 protocols
|= BROWSE_ALL
;
2414 else if (strcasecmp(valstart
, "none"))
2415 cupsdLogMessage(CUPSD_LOG_ERROR
,
2416 "Unknown browse protocol \"%s\" ignored.", valstart
);
2418 for (valstart
= valend
; *valstart
; valstart
++)
2419 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2428 * 'read_configuration()' - Read a configuration file.
2431 static int /* O - 1 on success, 0 on failure */
2432 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2434 int i
; /* Looping var */
2435 int linenum
; /* Current line number */
2436 char line
[HTTP_MAX_BUFFER
],
2437 /* Line from file */
2438 temp
[HTTP_MAX_BUFFER
],
2439 /* Temporary buffer for value */
2440 *ptr
, /* Pointer into line/temp */
2441 *value
, /* Pointer to value */
2442 *valueptr
; /* Pointer into value */
2443 int valuelen
; /* Length of value */
2444 cupsd_var_t
const *var
; /* Current variable */
2445 http_addrlist_t
*addrlist
, /* Address list */
2446 *addr
; /* Current address */
2447 unsigned ip
[4], /* Address value */
2448 mask
[4]; /* Netmask value */
2449 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2450 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2451 cupsd_location_t
*location
; /* Browse location */
2452 cups_file_t
*incfile
; /* Include file */
2453 char incname
[1024]; /* Include filename */
2454 struct group
*group
; /* Group */
2458 * Loop through each line in the file...
2463 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2466 * Decode the directive...
2469 if (!strcasecmp(line
, "Include") && value
)
2475 if (value
[0] == '/')
2476 strlcpy(incname
, value
, sizeof(incname
));
2478 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2480 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2481 cupsdLogMessage(CUPSD_LOG_ERROR
,
2482 "Unable to include config file \"%s\" - %s",
2483 incname
, strerror(errno
));
2486 read_configuration(incfile
);
2487 cupsFileClose(incfile
);
2490 else if (!strcasecmp(line
, "<Location") && value
)
2496 linenum
= read_location(fp
, value
, linenum
);
2500 else if (!strcasecmp(line
, "<Policy") && value
)
2506 linenum
= read_policy(fp
, value
, linenum
);
2510 else if (!strcasecmp(line
, "FatalErrors"))
2511 FatalErrors
= parse_fatal_errors(value
);
2512 else if (!strcasecmp(line
, "FaxRetryInterval") && value
)
2514 JobRetryInterval
= atoi(value
);
2515 cupsdLogMessage(CUPSD_LOG_WARN
,
2516 "FaxRetryInterval is deprecated; use "
2517 "JobRetryInterval on line %d.", linenum
);
2519 else if (!strcasecmp(line
, "FaxRetryLimit") && value
)
2521 JobRetryLimit
= atoi(value
);
2522 cupsdLogMessage(CUPSD_LOG_WARN
,
2523 "FaxRetryLimit is deprecated; use "
2524 "JobRetryLimit on line %d.", linenum
);
2526 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2528 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2529 #endif /* HAVE_SSL */
2533 * Add listening address(es) to the list...
2536 cupsd_listener_t
*lis
; /* New listeners array */
2540 * Get the address list...
2543 addrlist
= get_address(value
, IPP_PORT
);
2547 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2553 * Add each address...
2556 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2559 * See if this address is already present...
2562 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
2564 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
2565 if (httpAddrEqual(&(addr
->addr
), &(lis
->address
)) &&
2566 _httpAddrPort(&(addr
->addr
)) == _httpAddrPort(&(lis
->address
)))
2571 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2572 cupsdLogMessage(CUPSD_LOG_WARN
,
2573 "Duplicate listen address \"%s\" ignored.", temp
);
2578 * Allocate another listener...
2582 Listeners
= cupsArrayNew(NULL
, NULL
);
2586 cupsdLogMessage(CUPSD_LOG_ERROR
,
2587 "Unable to allocate %s at line %d - %s.",
2588 line
, linenum
, strerror(errno
));
2592 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2594 cupsdLogMessage(CUPSD_LOG_ERROR
,
2595 "Unable to allocate %s at line %d - %s.",
2596 line
, linenum
, strerror(errno
));
2600 cupsArrayAdd(Listeners
, lis
);
2603 * Copy the current address and log it...
2606 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2610 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2611 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2612 #endif /* HAVE_SSL */
2614 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2617 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2618 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv6)", temp
,
2619 ntohs(lis
->address
.ipv6
.sin6_port
));
2621 #endif /* AF_INET6 */
2623 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2624 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2626 #endif /* AF_LOCAL */
2627 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv4)", temp
,
2628 ntohs(lis
->address
.ipv4
.sin_port
));
2630 if (!httpAddrLocalhost(&(lis
->address
)))
2633 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2634 RemotePort
= ntohs(lis
->address
.ipv6
.sin6_port
);
2636 #endif /* AF_INET6 */
2637 RemotePort
= ntohs(lis
->address
.ipv4
.sin_port
);
2645 httpAddrFreeList(addrlist
);
2647 else if (!strcasecmp(line
, "BrowseAddress") && value
)
2650 * Add a browse address to the list...
2653 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2656 if (NumBrowsers
== 0)
2657 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2659 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2663 cupsdLogMessage(CUPSD_LOG_ERROR
,
2664 "Unable to allocate BrowseAddress at line %d - %s.",
2665 linenum
, strerror(errno
));
2670 dira
+= NumBrowsers
;
2672 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2674 if (!strcasecmp(value
, "@LOCAL"))
2677 * Send browse data to all local interfaces...
2680 strcpy(dira
->iface
, "*");
2683 else if (!strncasecmp(value
, "@IF(", 4))
2686 * Send browse data to the named interface...
2689 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2691 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2697 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2700 * Only IPv4 addresses are supported...
2703 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2704 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2709 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2710 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2712 cupsdLogMessage(CUPSD_LOG_INFO
,
2713 "Sending browsing info to %s:%d (IPv4)",
2714 temp
, ntohs(dira
->to
.ipv4
.sin_port
));
2719 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2722 httpAddrFreeList(addrlist
);
2725 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2728 else if (!strcasecmp(line
, "BrowseOrder") && value
)
2731 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2734 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2735 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2736 cupsdAddLocation(location
);
2738 if (location
== NULL
)
2739 cupsdLogMessage(CUPSD_LOG_ERROR
,
2740 "Unable to initialize browse access control list.");
2741 else if (!strncasecmp(value
, "deny", 4))
2742 location
->order_type
= CUPSD_AUTH_ALLOW
;
2743 else if (!strncasecmp(value
, "allow", 5))
2744 location
->order_type
= CUPSD_AUTH_DENY
;
2746 cupsdLogMessage(CUPSD_LOG_ERROR
,
2747 "Unknown BrowseOrder value %s on line %d.",
2750 else if (!strcasecmp(line
, "BrowseProtocols") ||
2751 !strcasecmp(line
, "BrowseLocalProtocols") ||
2752 !strcasecmp(line
, "BrowseRemoteProtocols"))
2755 * "BrowseProtocols name [... name]"
2756 * "BrowseLocalProtocols name [... name]"
2757 * "BrowseRemoteProtocols name [... name]"
2760 int protocols
= parse_protocols(value
);
2764 cupsdLogMessage(CUPSD_LOG_ERROR
,
2765 "Unknown browse protocol \"%s\" on line %d.",
2770 if (strcasecmp(line
, "BrowseLocalProtocols"))
2771 BrowseRemoteProtocols
= protocols
;
2772 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2773 BrowseLocalProtocols
= protocols
;
2775 else if ((!strcasecmp(line
, "BrowseAllow") ||
2776 !strcasecmp(line
, "BrowseDeny")) && value
)
2779 * BrowseAllow [From] host/ip...
2780 * BrowseDeny [From] host/ip...
2783 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2784 if ((location
= cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL
)
2785 cupsdAddLocation(location
);
2788 if (location
== NULL
)
2789 cupsdLogMessage(CUPSD_LOG_ERROR
,
2790 "Unable to initialize browse access control list.");
2793 if (!strncasecmp(value
, "from", 4))
2796 * Skip leading "from"...
2805 * Skip leading whitespace...
2808 while (isspace(*value
& 255))
2815 * Find the end of the value...
2818 for (valueptr
= value
;
2819 *valueptr
&& !isspace(*valueptr
& 255);
2822 while (isspace(*valueptr
& 255))
2826 * Figure out what form the allow/deny address takes:
2837 * nnn.nnn.nnn.nnn/mm
2838 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2841 if (!strcasecmp(value
, "all"))
2847 if (!strcasecmp(line
, "BrowseAllow"))
2848 cupsdAddIPMask(&(location
->allow
), zeros
, zeros
);
2850 cupsdAddIPMask(&(location
->deny
), zeros
, zeros
);
2852 else if (!strcasecmp(value
, "none"))
2858 if (!strcasecmp(line
, "BrowseAllow"))
2859 cupsdAddIPMask(&(location
->allow
), ones
, zeros
);
2861 cupsdAddIPMask(&(location
->deny
), ones
, zeros
);
2864 else if (value
[0] == '*' || value
[0] == '.' ||
2865 (!isdigit(value
[0] & 255) && value
[0] != '['))
2867 else if (value
[0] == '*' || value
[0] == '.' ||
2868 !isdigit(value
[0] & 255))
2869 #endif /* AF_INET6 */
2872 * Host or domain name...
2875 if (!strcasecmp(line
, "BrowseAllow"))
2876 cupsdAddNameMask(&(location
->allow
), value
);
2878 cupsdAddNameMask(&(location
->deny
), value
);
2883 * One of many IP address forms...
2886 if (!get_addr_and_mask(value
, ip
, mask
))
2888 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2893 if (!strcasecmp(line
, "BrowseAllow"))
2894 cupsdAddIPMask(&(location
->allow
), ip
, mask
);
2896 cupsdAddIPMask(&(location
->deny
), ip
, mask
);
2900 * Advance to next value...
2907 else if (!strcasecmp(line
, "BrowseRelay") && value
)
2910 * BrowseRelay [from] source [to] destination
2914 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2916 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2920 cupsdLogMessage(CUPSD_LOG_ERROR
,
2921 "Unable to allocate BrowseRelay at line %d - %s.",
2922 linenum
, strerror(errno
));
2929 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2931 if (!strncasecmp(value
, "from ", 5))
2934 * Skip leading "from"...
2940 * Skip leading whitespace...
2943 while (isspace(*value
))
2948 * Find the end of the from value...
2951 for (valueptr
= value
;
2952 *valueptr
&& !isspace(*valueptr
& 255);
2955 while (isspace(*valueptr
& 255))
2959 * Figure out what form the from address takes:
2968 * nnn.nnn.nnn.nnn/mm
2969 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2973 if (value
[0] == '*' || value
[0] == '.' ||
2974 (!isdigit(value
[0] & 255) && value
[0] != '['))
2976 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2977 #endif /* AF_INET6 */
2980 * Host or domain name...
2983 if (!cupsdAddNameMask(&(relay
->from
), value
))
2985 cupsdLogMessage(CUPSD_LOG_ERROR
,
2986 "Unable to allocate BrowseRelay name at line %d - %s.",
2987 linenum
, strerror(errno
));
2994 * One of many IP address forms...
2997 if (!get_addr_and_mask(value
, ip
, mask
))
2999 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
3004 if (!cupsdAddIPMask(&(relay
->from
), ip
, mask
))
3006 cupsdLogMessage(CUPSD_LOG_ERROR
,
3007 "Unable to allocate BrowseRelay IP at line %d - %s.",
3008 linenum
, strerror(errno
));
3014 * Get "to" address and port...
3017 if (!strncasecmp(valueptr
, "to ", 3))
3020 * Strip leading "to"...
3025 while (isspace(*valueptr
))
3029 if ((addrlist
= get_address(valueptr
, BrowsePort
)) != NULL
)
3032 * Only IPv4 addresses are supported...
3035 for (addr
= addrlist
; addr
; addr
= addr
->next
)
3036 if (addr
->addr
.addr
.sa_family
== AF_INET
)
3041 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
3043 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
3045 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
3046 value
, temp
, ntohs(relay
->to
.ipv4
.sin_port
));
3052 cupsArrayDelete(relay
->from
);
3055 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3059 httpAddrFreeList(addrlist
);
3063 cupsArrayDelete(relay
->from
);
3066 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
3070 else if (!strcasecmp(line
, "BrowsePoll") && value
)
3073 * BrowsePoll address[:port]
3076 char *portname
; /* Port name */
3077 int portnum
; /* Port number */
3078 struct servent
*service
; /* Service */
3082 * Extract the port name from the address...
3085 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
3089 if (isdigit(*portname
& 255))
3090 portnum
= atoi(portname
);
3091 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
3092 portnum
= ntohs(service
->s_port
);
3095 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed.",
3101 portnum
= ippPort();
3104 * Add the poll entry...
3108 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
3110 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
3114 cupsdLogMessage(CUPSD_LOG_ERROR
,
3115 "Unable to allocate BrowsePoll at line %d - %s.",
3116 linenum
, strerror(errno
));
3124 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
3126 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
3127 pollp
->port
= portnum
;
3129 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
3132 else if (!strcasecmp(line
, "DefaultAuthType") && value
)
3135 * DefaultAuthType {basic,digest,basicdigest,negotiate}
3138 if (!strcasecmp(value
, "none"))
3139 DefaultAuthType
= CUPSD_AUTH_NONE
;
3140 else if (!strcasecmp(value
, "basic"))
3141 DefaultAuthType
= CUPSD_AUTH_BASIC
;
3142 else if (!strcasecmp(value
, "digest"))
3143 DefaultAuthType
= CUPSD_AUTH_DIGEST
;
3144 else if (!strcasecmp(value
, "basicdigest"))
3145 DefaultAuthType
= CUPSD_AUTH_BASICDIGEST
;
3147 else if (!strcasecmp(value
, "negotiate"))
3148 DefaultAuthType
= CUPSD_AUTH_NEGOTIATE
;
3149 #endif /* HAVE_GSSAPI */
3152 cupsdLogMessage(CUPSD_LOG_WARN
,
3153 "Unknown default authorization type %s on line %d.",
3155 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3160 else if (!strcasecmp(line
, "DefaultEncryption"))
3163 * DefaultEncryption {Never,IfRequested,Required}
3166 if (!value
|| !strcasecmp(value
, "never"))
3167 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
3168 else if (!strcasecmp(value
, "required"))
3169 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
3170 else if (!strcasecmp(value
, "ifrequested"))
3171 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
3174 cupsdLogMessage(CUPSD_LOG_WARN
,
3175 "Unknown default encryption %s on line %d.",
3177 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3181 #endif /* HAVE_SSL */
3182 else if (!strcasecmp(line
, "User") && value
)
3185 * User ID to run as...
3188 if (isdigit(value
[0] & 255))
3190 int uid
= atoi(value
);
3193 cupsdLogMessage(CUPSD_LOG_ERROR
,
3194 "Will not use User 0 as specified on line %d "
3195 "for security reasons. You must use a non-"
3196 "privileged account instead.",
3203 struct passwd
*p
; /* Password information */
3206 p
= getpwnam(value
);
3211 cupsdLogMessage(CUPSD_LOG_ERROR
,
3212 "Will not use User %s (UID=0) as specified on line "
3213 "%d for security reasons. You must use a non-"
3214 "privileged account instead.",
3220 cupsdLogMessage(CUPSD_LOG_ERROR
,
3221 "Unknown User \"%s\" on line %d, ignoring.",
3225 else if (!strcasecmp(line
, "Group") && value
)
3228 * Group ID to run as...
3231 if (isdigit(value
[0]))
3232 Group
= atoi(value
);
3236 group
= getgrnam(value
);
3239 Group
= group
->gr_gid
;
3241 cupsdLogMessage(CUPSD_LOG_ERROR
,
3242 "Unknown Group \"%s\" on line %d, ignoring.",
3246 else if (!strcasecmp(line
, "SystemGroup") && value
)
3249 * SystemGroup (admin) group(s)...
3252 if (!parse_groups(value
))
3253 cupsdLogMessage(CUPSD_LOG_ERROR
,
3254 "Unknown SystemGroup \"%s\" on line %d, ignoring.",
3257 else if (!strcasecmp(line
, "HostNameLookups") && value
)
3260 * Do hostname lookups?
3263 if (!strcasecmp(value
, "off") || !strcasecmp(value
, "no") ||
3264 !strcasecmp(value
, "false"))
3265 HostNameLookups
= 0;
3266 else if (!strcasecmp(value
, "on") || !strcasecmp(value
, "yes") ||
3267 !strcasecmp(value
, "true"))
3268 HostNameLookups
= 1;
3269 else if (!strcasecmp(value
, "double"))
3270 HostNameLookups
= 2;
3272 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
3275 else if (!strcasecmp(line
, "AccessLogLevel") && value
)
3278 * Amount of logging to do to access log...
3281 if (!strcasecmp(value
, "all"))
3282 AccessLogLevel
= CUPSD_ACCESSLOG_ALL
;
3283 else if (!strcasecmp(value
, "actions"))
3284 AccessLogLevel
= CUPSD_ACCESSLOG_ACTIONS
;
3285 else if (!strcasecmp(value
, "config"))
3286 AccessLogLevel
= CUPSD_ACCESSLOG_CONFIG
;
3288 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown AccessLogLevel %s on line %d.",
3291 else if (!strcasecmp(line
, "LogLevel") && value
)
3294 * Amount of logging to do to error log...
3297 if (!strcasecmp(value
, "debug2"))
3298 LogLevel
= CUPSD_LOG_DEBUG2
;
3299 else if (!strcasecmp(value
, "debug"))
3300 LogLevel
= CUPSD_LOG_DEBUG
;
3301 else if (!strcasecmp(value
, "info"))
3302 LogLevel
= CUPSD_LOG_INFO
;
3303 else if (!strcasecmp(value
, "notice"))
3304 LogLevel
= CUPSD_LOG_NOTICE
;
3305 else if (!strcasecmp(value
, "warn"))
3306 LogLevel
= CUPSD_LOG_WARN
;
3307 else if (!strcasecmp(value
, "error"))
3308 LogLevel
= CUPSD_LOG_ERROR
;
3309 else if (!strcasecmp(value
, "crit"))
3310 LogLevel
= CUPSD_LOG_CRIT
;
3311 else if (!strcasecmp(value
, "alert"))
3312 LogLevel
= CUPSD_LOG_ALERT
;
3313 else if (!strcasecmp(value
, "emerg"))
3314 LogLevel
= CUPSD_LOG_EMERG
;
3315 else if (!strcasecmp(value
, "none"))
3316 LogLevel
= CUPSD_LOG_NONE
;
3318 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
3321 else if (!strcasecmp(line
, "LogTimeFormat") && value
)
3324 * Amount of logging to do to error log...
3327 if (!strcasecmp(value
, "standard"))
3328 LogTimeFormat
= CUPSD_TIME_STANDARD
;
3329 else if (!strcasecmp(value
, "usecs"))
3330 LogTimeFormat
= CUPSD_TIME_USECS
;
3332 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogTimeFormat %s on line %d.",
3335 else if (!strcasecmp(line
, "PrintcapFormat") && value
)
3338 * Format of printcap file?
3341 if (!strcasecmp(value
, "bsd"))
3342 PrintcapFormat
= PRINTCAP_BSD
;
3343 else if (!strcasecmp(value
, "plist"))
3344 PrintcapFormat
= PRINTCAP_PLIST
;
3345 else if (!strcasecmp(value
, "solaris"))
3346 PrintcapFormat
= PRINTCAP_SOLARIS
;
3348 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
3351 else if (!strcasecmp(line
, "ServerTokens") && value
)
3354 * Set the string used for the Server header...
3357 struct utsname plat
; /* Platform info */
3362 if (!strcasecmp(value
, "ProductOnly"))
3363 cupsdSetString(&ServerHeader
, "CUPS");
3364 else if (!strcasecmp(value
, "Major"))
3365 cupsdSetString(&ServerHeader
, "CUPS/1");
3366 else if (!strcasecmp(value
, "Minor"))
3367 cupsdSetString(&ServerHeader
, "CUPS/1.4");
3368 else if (!strcasecmp(value
, "Minimal"))
3369 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
3370 else if (!strcasecmp(value
, "OS"))
3371 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
3372 else if (!strcasecmp(value
, "Full"))
3373 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
3375 else if (!strcasecmp(value
, "None"))
3376 cupsdClearString(&ServerHeader
);
3378 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
3381 else if (!strcasecmp(line
, "PassEnv") && value
)
3384 * PassEnv variable [... variable]
3389 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
3390 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
3393 if (value
[valuelen
])
3395 value
[valuelen
] = '\0';
3399 cupsdSetEnv(value
, NULL
);
3401 for (value
+= valuelen
; *value
; value
++)
3402 if (!isspace(*value
) || *value
!= ',')
3406 else if (!strcasecmp(line
, "ServerAlias") && value
)
3409 ServerAlias
= cupsArrayNew(NULL
, NULL
);
3411 cupsdAddAlias(ServerAlias
, value
);
3413 else if (!strcasecmp(line
, "SetEnv") && value
)
3416 * SetEnv variable value
3419 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3427 while (isspace(*valueptr
& 255))
3430 cupsdSetEnv(value
, valueptr
);
3433 cupsdLogMessage(CUPSD_LOG_ERROR
,
3434 "Missing value for SetEnv directive on line %d.",
3438 else if (!strcasecmp(line
, "SSLOptions"))
3441 * SSLOptions options
3444 if (!value
|| !strcasecmp(value
, "none"))
3445 SSLOptions
= CUPSD_SSL_NONE
;
3446 else if (!strcasecmp(value
, "noemptyfragments"))
3447 SSLOptions
= CUPSD_SSL_NOEMPTY
;
3449 cupsdLogMessage(CUPSD_LOG_ERROR
,
3450 "Unknown value \"%s\" for SSLOptions directive on "
3451 "line %d.", value
, linenum
);
3453 #endif /* HAVE_SSL */
3457 * Find a simple variable in the list...
3460 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3461 if (!strcasecmp(line
, var
->name
))
3467 * Unknown directive! Output an error message and continue...
3471 cupsdLogMessage(CUPSD_LOG_ERROR
, "Missing value for %s on line %d.",
3474 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3481 case CUPSD_VARTYPE_INTEGER
:
3483 cupsdLogMessage(CUPSD_LOG_ERROR
,
3484 "Missing integer value for %s on line %d.",
3489 char *units
; /* Units */
3492 n
= strtol(value
, &units
, 0);
3494 if (units
&& *units
)
3496 if (tolower(units
[0] & 255) == 'g')
3497 n
*= 1024 * 1024 * 1024;
3498 else if (tolower(units
[0] & 255) == 'm')
3500 else if (tolower(units
[0] & 255) == 'k')
3502 else if (tolower(units
[0] & 255) == 't')
3507 cupsdLogMessage(CUPSD_LOG_ERROR
,
3508 "Bad negative integer value for %s on line %d.",
3511 *((int *)var
->ptr
) = n
;
3515 case CUPSD_VARTYPE_BOOLEAN
:
3517 cupsdLogMessage(CUPSD_LOG_ERROR
,
3518 "Missing boolean value for %s on line %d.",
3520 else if (!strcasecmp(value
, "true") ||
3521 !strcasecmp(value
, "on") ||
3522 !strcasecmp(value
, "enabled") ||
3523 !strcasecmp(value
, "yes") ||
3525 *((int *)var
->ptr
) = TRUE
;
3526 else if (!strcasecmp(value
, "false") ||
3527 !strcasecmp(value
, "off") ||
3528 !strcasecmp(value
, "disabled") ||
3529 !strcasecmp(value
, "no") ||
3530 !strcasecmp(value
, "0"))
3531 *((int *)var
->ptr
) = FALSE
;
3533 cupsdLogMessage(CUPSD_LOG_ERROR
,
3534 "Unknown boolean value %s on line %d.",
3538 case CUPSD_VARTYPE_PATHNAME
:
3541 cupsdLogMessage(CUPSD_LOG_ERROR
,
3542 "Missing pathname value for %s on line %d.",
3547 if (value
[0] == '/')
3548 strlcpy(temp
, value
, sizeof(temp
));
3550 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3552 if (access(temp
, 0))
3554 cupsdLogMessage(CUPSD_LOG_ERROR
,
3555 "File or directory for \"%s %s\" on line %d "
3556 "does not exist.", line
, value
, linenum
);
3560 case CUPSD_VARTYPE_STRING
:
3561 cupsdSetString((char **)var
->ptr
, value
);
3572 * 'read_location()' - Read a <Location path> definition.
3575 static int /* O - New line number or 0 on error */
3576 read_location(cups_file_t
*fp
, /* I - Configuration file */
3577 char *location
, /* I - Location name/path */
3578 int linenum
) /* I - Current line number */
3580 cupsd_location_t
*loc
, /* New location */
3581 *parent
; /* Parent location */
3582 char line
[HTTP_MAX_BUFFER
],
3584 *value
, /* Value for directive */
3585 *valptr
; /* Pointer into value */
3588 if ((parent
= cupsdFindLocation(location
)) != NULL
)
3589 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Location %s> on line %d.",
3591 else if ((parent
= cupsdNewLocation(location
)) == NULL
)
3595 cupsdAddLocation(parent
);
3597 parent
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3602 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3605 * Decode the directive...
3608 if (!strcasecmp(line
, "</Location>"))
3610 else if (!strcasecmp(line
, "<Limit") ||
3611 !strcasecmp(line
, "<LimitExcept"))
3615 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3616 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3622 if ((loc
= cupsdCopyLocation(parent
)) == NULL
)
3625 cupsdAddLocation(loc
);
3630 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3635 if (!strcmp(value
, "ALL"))
3636 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
;
3637 else if (!strcmp(value
, "GET"))
3638 loc
->limit
|= CUPSD_AUTH_LIMIT_GET
;
3639 else if (!strcmp(value
, "HEAD"))
3640 loc
->limit
|= CUPSD_AUTH_LIMIT_HEAD
;
3641 else if (!strcmp(value
, "OPTIONS"))
3642 loc
->limit
|= CUPSD_AUTH_LIMIT_OPTIONS
;
3643 else if (!strcmp(value
, "POST"))
3644 loc
->limit
|= CUPSD_AUTH_LIMIT_POST
;
3645 else if (!strcmp(value
, "PUT"))
3646 loc
->limit
|= CUPSD_AUTH_LIMIT_PUT
;
3647 else if (!strcmp(value
, "TRACE"))
3648 loc
->limit
|= CUPSD_AUTH_LIMIT_TRACE
;
3650 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d.",
3653 for (value
= valptr
; isspace(*value
& 255); value
++);
3656 if (!strcasecmp(line
, "<LimitExcept"))
3657 loc
->limit
= CUPSD_AUTH_LIMIT_ALL
^ loc
->limit
;
3659 parent
->limit
&= ~loc
->limit
;
3661 else if (!strcasecmp(line
, "</Limit>") ||
3662 !strcasecmp(line
, "</LimitExcept>"))
3664 else if (!parse_aaa(loc
, line
, value
, linenum
))
3666 cupsdLogMessage(CUPSD_LOG_ERROR
,
3667 "Unknown Location directive %s on line %d.",
3669 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3674 cupsdLogMessage(CUPSD_LOG_ERROR
,
3675 "Unexpected end-of-file at line %d while reading location.",
3678 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3683 * 'read_policy()' - Read a <Policy name> definition.
3686 static int /* O - New line number or 0 on error */
3687 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3688 char *policy
, /* I - Location name/path */
3689 int linenum
) /* I - Current line number */
3691 int i
; /* Looping var */
3692 cupsd_policy_t
*pol
; /* Policy */
3693 cupsd_location_t
*op
; /* Policy operation */
3694 int num_ops
; /* Number of IPP operations */
3695 ipp_op_t ops
[100]; /* Operations */
3696 char line
[HTTP_MAX_BUFFER
],
3698 *value
, /* Value for directive */
3699 *valptr
; /* Pointer into value */
3703 * Create the policy...
3706 if ((pol
= cupsdFindPolicy(policy
)) != NULL
)
3707 cupsdLogMessage(CUPSD_LOG_WARN
, "Duplicate <Policy %s> on line %d.",
3709 else if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3713 * Read from the file...
3719 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3722 * Decode the directive...
3725 if (!strcasecmp(line
, "</Policy>"))
3728 cupsdLogMessage(CUPSD_LOG_WARN
,
3729 "Missing </Limit> before </Policy> on line %d.",
3732 set_policy_defaults(pol
);
3736 else if (!strcasecmp(line
, "<Limit") && !op
)
3740 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3741 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3748 * Scan for IPP operation names...
3755 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3760 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3762 if (!strcasecmp(value
, "All"))
3763 ops
[num_ops
] = IPP_ANY_OPERATION
;
3764 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3765 cupsdLogMessage(CUPSD_LOG_ERROR
,
3766 "Bad IPP operation name \"%s\" on line %d.",
3772 cupsdLogMessage(CUPSD_LOG_ERROR
,
3773 "Too many operations listed on line %d.",
3776 for (value
= valptr
; isspace(*value
& 255); value
++);
3780 * If none are specified, apply the policy to all operations...
3785 ops
[0] = IPP_ANY_OPERATION
;
3790 * Add a new policy for the first operation...
3793 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3795 else if (!strcasecmp(line
, "</Limit>") && op
)
3798 * Finish the current operation limit...
3804 * Copy the policy to the other operations...
3807 for (i
= 1; i
< num_ops
; i
++)
3808 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3813 else if (!strcasecmp(line
, "JobPrivateAccess") ||
3814 !strcasecmp(line
, "JobPrivateValues") ||
3815 !strcasecmp(line
, "SubscriptionPrivateAccess") ||
3816 !strcasecmp(line
, "SubscriptionPrivateValues"))
3820 cupsdLogMessage(CUPSD_LOG_ERROR
,
3821 "%s directive must appear outside <Limit>...</Limit> "
3822 "on line %d.", line
, linenum
);
3823 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3829 * Pull out whitespace-delimited values...
3835 * Find the end of the current value...
3838 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3844 * Save it appropriately...
3847 if (!strcasecmp(line
, "JobPrivateAccess"))
3850 * JobPrivateAccess {all|default|user/group list|@@ACL}
3853 if (!strcasecmp(value
, "default"))
3855 cupsdAddString(&(pol
->job_access
), "@OWNER");
3856 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
3859 cupsdAddString(&(pol
->job_access
), value
);
3861 else if (!strcasecmp(line
, "JobPrivateValues"))
3864 * JobPrivateValues {all|none|default|attribute list}
3867 if (!strcasecmp(value
, "default"))
3869 cupsdAddString(&(pol
->job_attrs
), "job-name");
3870 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
3871 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
3874 cupsdAddString(&(pol
->job_attrs
), value
);
3876 else if (!strcasecmp(line
, "SubscriptionPrivateAccess"))
3879 * SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
3882 if (!strcasecmp(value
, "default"))
3884 cupsdAddString(&(pol
->sub_access
), "@OWNER");
3885 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
3888 cupsdAddString(&(pol
->sub_access
), value
);
3890 else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
3893 * SubscriptionPrivateValues {all|none|default|attribute list}
3896 if (!strcasecmp(value
, "default"))
3898 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
3899 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
3900 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
3901 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
3902 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
3905 cupsdAddString(&(pol
->sub_attrs
), value
);
3909 * Find the next string on the line...
3912 for (value
= valptr
; isspace(*value
& 255); value
++);
3918 cupsdLogMessage(CUPSD_LOG_ERROR
,
3919 "Missing <Limit ops> directive before %s on line %d.",
3921 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3924 else if (!parse_aaa(op
, line
, value
, linenum
))
3927 cupsdLogMessage(CUPSD_LOG_ERROR
,
3928 "Unknown Policy Limit directive %s on line %d.",
3931 cupsdLogMessage(CUPSD_LOG_ERROR
,
3932 "Unknown Policy directive %s on line %d.",
3935 if (FatalErrors
& CUPSD_FATAL_CONFIG
)
3940 cupsdLogMessage(CUPSD_LOG_ERROR
,
3941 "Unexpected end-of-file at line %d while reading policy "
3942 "\"%s\".", linenum
, policy
);
3944 return ((FatalErrors
& CUPSD_FATAL_CONFIG
) ? 0 : linenum
);
3949 * 'set_policy_defaults()' - Set default policy values as needed.
3953 set_policy_defaults(cupsd_policy_t
*pol
)/* I - Policy */
3955 cupsd_location_t
*op
; /* Policy operation */
3959 * Verify that we have an explicit policy for Validate-Job, Cancel-Jobs,
3960 * Cancel-My-Jobs, Close-Job, and CUPS-Get-Document, which ensures that
3961 * upgrades do not introduce new security issues...
3964 if ((op
= cupsdFindPolicyOp(pol
, IPP_VALIDATE_JOB
)) == NULL
||
3965 op
->op
== IPP_ANY_OPERATION
)
3967 if ((op
= cupsdFindPolicyOp(pol
, IPP_PRINT_JOB
)) != NULL
&&
3968 op
->op
!= IPP_ANY_OPERATION
)
3971 * Add a new limit for Validate-Job using the Print-Job limit as a
3975 cupsdLogMessage(CUPSD_LOG_WARN
,
3976 "No limit for Validate-Job defined in policy %s "
3977 "- using Print-Job's policy.", pol
->name
);
3979 cupsdAddPolicyOp(pol
, op
, IPP_VALIDATE_JOB
);
3982 cupsdLogMessage(CUPSD_LOG_WARN
,
3983 "No limit for Validate-Job defined in policy %s "
3984 "and no suitable template found.", pol
->name
);
3987 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_JOBS
)) == NULL
||
3988 op
->op
== IPP_ANY_OPERATION
)
3990 if ((op
= cupsdFindPolicyOp(pol
, IPP_PAUSE_PRINTER
)) != NULL
&&
3991 op
->op
!= IPP_ANY_OPERATION
)
3994 * Add a new limit for Cancel-Jobs using the Pause-Printer limit as a
3998 cupsdLogMessage(CUPSD_LOG_WARN
,
3999 "No limit for Cancel-Jobs defined in policy %s "
4000 "- using Pause-Printer's policy.", pol
->name
);
4002 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_JOBS
);
4005 cupsdLogMessage(CUPSD_LOG_WARN
,
4006 "No limit for Cancel-Jobs defined in policy %s "
4007 "and no suitable template found.", pol
->name
);
4010 if ((op
= cupsdFindPolicyOp(pol
, IPP_CANCEL_MY_JOBS
)) == NULL
||
4011 op
->op
== IPP_ANY_OPERATION
)
4013 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4014 op
->op
!= IPP_ANY_OPERATION
)
4017 * Add a new limit for Cancel-My-Jobs using the Send-Document limit as
4021 cupsdLogMessage(CUPSD_LOG_WARN
,
4022 "No limit for Cancel-My-Jobs defined in policy %s "
4023 "- using Send-Document's policy.", pol
->name
);
4025 cupsdAddPolicyOp(pol
, op
, IPP_CANCEL_MY_JOBS
);
4028 cupsdLogMessage(CUPSD_LOG_WARN
,
4029 "No limit for Cancel-My-Jobs defined in policy %s "
4030 "and no suitable template found.", pol
->name
);
4033 if ((op
= cupsdFindPolicyOp(pol
, IPP_CLOSE_JOB
)) == NULL
||
4034 op
->op
== IPP_ANY_OPERATION
)
4036 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4037 op
->op
!= IPP_ANY_OPERATION
)
4040 * Add a new limit for Close-Job using the Send-Document limit as a
4044 cupsdLogMessage(CUPSD_LOG_WARN
,
4045 "No limit for Close-Job defined in policy %s "
4046 "- using Send-Document's policy.", pol
->name
);
4048 cupsdAddPolicyOp(pol
, op
, IPP_CLOSE_JOB
);
4051 cupsdLogMessage(CUPSD_LOG_WARN
,
4052 "No limit for Close-Job defined in policy %s "
4053 "and no suitable template found.", pol
->name
);
4056 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
4057 op
->op
== IPP_ANY_OPERATION
)
4059 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
4060 op
->op
!= IPP_ANY_OPERATION
)
4063 * Add a new limit for CUPS-Get-Document using the Send-Document
4064 * limit as a template...
4067 cupsdLogMessage(CUPSD_LOG_WARN
,
4068 "No limit for CUPS-Get-Document defined in policy %s "
4069 "- using Send-Document's policy.", pol
->name
);
4071 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
4074 cupsdLogMessage(CUPSD_LOG_WARN
,
4075 "No limit for CUPS-Get-Document defined in policy %s "
4076 "and no suitable template found.", pol
->name
);
4080 * Verify we have JobPrivateAccess, JobPrivateValues,
4081 * SubscriptionPrivateAccess, and SubscriptionPrivateValues in the policy.
4084 if (!pol
->job_access
)
4086 cupsdLogMessage(CUPSD_LOG_WARN
,
4087 "No JobPrivateAccess defined in policy %s "
4088 "- using defaults.", pol
->name
);
4089 cupsdAddString(&(pol
->job_access
), "@OWNER");
4090 cupsdAddString(&(pol
->job_access
), "@SYSTEM");
4093 if (!pol
->job_attrs
)
4095 cupsdLogMessage(CUPSD_LOG_WARN
,
4096 "No JobPrivateValues defined in policy %s "
4097 "- using defaults.", pol
->name
);
4098 cupsdAddString(&(pol
->job_attrs
), "job-name");
4099 cupsdAddString(&(pol
->job_attrs
), "job-originating-host-name");
4100 cupsdAddString(&(pol
->job_attrs
), "job-originating-user-name");
4103 if (!pol
->sub_access
)
4105 cupsdLogMessage(CUPSD_LOG_WARN
,
4106 "No SubscriptionPrivateAccess defined in policy %s "
4107 "- using defaults.", pol
->name
);
4108 cupsdAddString(&(pol
->sub_access
), "@OWNER");
4109 cupsdAddString(&(pol
->sub_access
), "@SYSTEM");
4112 if (!pol
->sub_attrs
)
4114 cupsdLogMessage(CUPSD_LOG_WARN
,
4115 "No SubscriptionPrivateValues defined in policy %s "
4116 "- using defaults.", pol
->name
);
4117 cupsdAddString(&(pol
->sub_attrs
), "notify-events");
4118 cupsdAddString(&(pol
->sub_attrs
), "notify-pull-method");
4119 cupsdAddString(&(pol
->sub_attrs
), "notify-recipient-uri");
4120 cupsdAddString(&(pol
->sub_attrs
), "notify-subscriber-user-name");
4121 cupsdAddString(&(pol
->sub_attrs
), "notify-user-data");
4127 * End of "$Id: conf.c 9352 2010-11-06 04:55:26Z mike $".