2 * "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $"
4 * Configuration routines for the Common UNIX Printing System (CUPS).
6 * Copyright 2007 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 * cupsdCheckPermissions() - Fix the mode and ownership of a file or
19 * cupsdReadConfiguration() - Read the cupsd.conf file.
20 * get_address() - Get an address + port number from a line.
21 * get_addr_and_mask() - Get an IP address and netmask.
22 * parse_aaa() - Parse authentication, authorization, and
23 * access control lines.
24 * parse_groups() - Parse system group names in a string.
25 * parse_protocols() - Parse browse protocols in a string.
26 * read_configuration() - Read a configuration file.
27 * read_location() - Read a <Location path> definition.
28 * read_policy() - Read a <Policy name> definition.
32 * Include necessary headers...
38 #include <sys/utsname.h>
43 * Possibly missing network definitions...
47 # define INADDR_NONE 0xffffffff
48 #endif /* !INADDR_NONE */
52 * Configuration variable structure...
57 CUPSD_VARTYPE_INTEGER
, /* Integer option */
58 CUPSD_VARTYPE_STRING
, /* String option */
59 CUPSD_VARTYPE_BOOLEAN
, /* Boolean option */
60 CUPSD_VARTYPE_PATHNAME
/* File/directory name option */
65 char *name
; /* Name of variable */
66 void *ptr
; /* Pointer to variable */
67 cupsd_vartype_t type
; /* Type (int, string, address) */
75 static cupsd_var_t variables
[] =
77 { "AccessLog", &AccessLog
, CUPSD_VARTYPE_STRING
},
79 { "AppleQuotas", &AppleQuotas
, CUPSD_VARTYPE_BOOLEAN
},
80 #endif /* __APPLE__ */
81 { "AutoPurgeJobs", &JobAutoPurge
, CUPSD_VARTYPE_BOOLEAN
},
82 { "BrowseInterval", &BrowseInterval
, CUPSD_VARTYPE_INTEGER
},
84 { "BrowseLDAPBindDN", &BrowseLDAPBindDN
, CUPSD_VARTYPE_STRING
},
85 { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile
, CUPSD_VARTYPE_PATHNAME
},
86 { "BrowseLDAPDN", &BrowseLDAPDN
, CUPSD_VARTYPE_STRING
},
87 { "BrowseLDAPPassword", &BrowseLDAPPassword
, CUPSD_VARTYPE_STRING
},
88 { "BrowseLDAPServer", &BrowseLDAPServer
, CUPSD_VARTYPE_STRING
},
89 #endif /* HAVE_LDAP */
90 { "BrowseLocalOptions", &BrowseLocalOptions
, CUPSD_VARTYPE_STRING
},
91 { "BrowsePort", &BrowsePort
, CUPSD_VARTYPE_INTEGER
},
92 { "BrowseRemoteOptions", &BrowseRemoteOptions
, CUPSD_VARTYPE_STRING
},
93 { "BrowseShortNames", &BrowseShortNames
, CUPSD_VARTYPE_BOOLEAN
},
94 { "BrowseTimeout", &BrowseTimeout
, CUPSD_VARTYPE_INTEGER
},
95 { "Browsing", &Browsing
, CUPSD_VARTYPE_BOOLEAN
},
96 { "CacheDir", &CacheDir
, CUPSD_VARTYPE_STRING
},
97 { "Classification", &Classification
, CUPSD_VARTYPE_STRING
},
98 { "ClassifyOverride", &ClassifyOverride
, CUPSD_VARTYPE_BOOLEAN
},
99 { "ConfigFilePerm", &ConfigFilePerm
, CUPSD_VARTYPE_INTEGER
},
100 { "DataDir", &DataDir
, CUPSD_VARTYPE_STRING
},
101 { "DefaultCharset", &DefaultCharset
, CUPSD_VARTYPE_STRING
},
102 { "DefaultLanguage", &DefaultLanguage
, CUPSD_VARTYPE_STRING
},
103 { "DefaultLeaseDuration", &DefaultLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
104 { "DefaultPolicy", &DefaultPolicy
, CUPSD_VARTYPE_STRING
},
105 { "DefaultShared", &DefaultShared
, CUPSD_VARTYPE_BOOLEAN
},
106 { "DocumentRoot", &DocumentRoot
, CUPSD_VARTYPE_STRING
},
107 { "ErrorLog", &ErrorLog
, CUPSD_VARTYPE_STRING
},
108 { "ErrorPolicy", &ErrorPolicy
, CUPSD_VARTYPE_STRING
},
109 { "FileDevice", &FileDevice
, CUPSD_VARTYPE_BOOLEAN
},
110 { "FilterLimit", &FilterLimit
, CUPSD_VARTYPE_INTEGER
},
111 { "FilterNice", &FilterNice
, CUPSD_VARTYPE_INTEGER
},
112 { "FontPath", &FontPath
, CUPSD_VARTYPE_STRING
},
114 { "GSSServiceName", &GSSServiceName
, CUPSD_VARTYPE_STRING
},
115 #endif /* HAVE_GSSAPI */
116 { "ImplicitClasses", &ImplicitClasses
, CUPSD_VARTYPE_BOOLEAN
},
117 { "ImplicitAnyClasses", &ImplicitAnyClasses
, CUPSD_VARTYPE_BOOLEAN
},
118 { "JobRetryLimit", &JobRetryLimit
, CUPSD_VARTYPE_INTEGER
},
119 { "JobRetryInterval", &JobRetryInterval
, CUPSD_VARTYPE_INTEGER
},
120 { "KeepAliveTimeout", &KeepAliveTimeout
, CUPSD_VARTYPE_INTEGER
},
121 { "KeepAlive", &KeepAlive
, CUPSD_VARTYPE_BOOLEAN
},
123 { "LaunchdTimeout", &LaunchdTimeout
, CUPSD_VARTYPE_INTEGER
},
124 { "LaunchdConf", &LaunchdConf
, CUPSD_VARTYPE_STRING
},
125 #endif /* HAVE_LAUNCHD */
126 { "LimitRequestBody", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
127 { "ListenBackLog", &ListenBackLog
, CUPSD_VARTYPE_INTEGER
},
128 { "LogFilePerm", &LogFilePerm
, CUPSD_VARTYPE_INTEGER
},
129 { "LPDConfigFile", &LPDConfigFile
, CUPSD_VARTYPE_STRING
},
130 { "MaxActiveJobs", &MaxActiveJobs
, CUPSD_VARTYPE_INTEGER
},
131 { "MaxClients", &MaxClients
, CUPSD_VARTYPE_INTEGER
},
132 { "MaxClientsPerHost", &MaxClientsPerHost
, CUPSD_VARTYPE_INTEGER
},
133 { "MaxCopies", &MaxCopies
, CUPSD_VARTYPE_INTEGER
},
134 { "MaxEvents", &MaxEvents
, CUPSD_VARTYPE_INTEGER
},
135 { "MaxJobs", &MaxJobs
, CUPSD_VARTYPE_INTEGER
},
136 { "MaxJobsPerPrinter", &MaxJobsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
137 { "MaxJobsPerUser", &MaxJobsPerUser
, CUPSD_VARTYPE_INTEGER
},
138 { "MaxLeaseDuration", &MaxLeaseDuration
, CUPSD_VARTYPE_INTEGER
},
139 { "MaxLogSize", &MaxLogSize
, CUPSD_VARTYPE_INTEGER
},
140 { "MaxPrinterHistory", &MaxPrinterHistory
, CUPSD_VARTYPE_INTEGER
},
141 { "MaxRequestSize", &MaxRequestSize
, CUPSD_VARTYPE_INTEGER
},
142 { "MaxSubscriptions", &MaxSubscriptions
, CUPSD_VARTYPE_INTEGER
},
143 { "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob
, CUPSD_VARTYPE_INTEGER
},
144 { "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter
, CUPSD_VARTYPE_INTEGER
},
145 { "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser
, CUPSD_VARTYPE_INTEGER
},
146 { "PageLog", &PageLog
, CUPSD_VARTYPE_STRING
},
147 { "PreserveJobFiles", &JobFiles
, CUPSD_VARTYPE_BOOLEAN
},
148 { "PreserveJobHistory", &JobHistory
, CUPSD_VARTYPE_BOOLEAN
},
149 { "Printcap", &Printcap
, CUPSD_VARTYPE_STRING
},
150 { "PrintcapGUI", &PrintcapGUI
, CUPSD_VARTYPE_STRING
},
151 { "ReloadTimeout", &ReloadTimeout
, CUPSD_VARTYPE_INTEGER
},
152 { "RemoteRoot", &RemoteRoot
, CUPSD_VARTYPE_STRING
},
153 { "RequestRoot", &RequestRoot
, CUPSD_VARTYPE_STRING
},
154 { "RIPCache", &RIPCache
, CUPSD_VARTYPE_STRING
},
155 { "RootCertDuration", &RootCertDuration
, CUPSD_VARTYPE_INTEGER
},
156 { "ServerAdmin", &ServerAdmin
, CUPSD_VARTYPE_STRING
},
157 { "ServerBin", &ServerBin
, CUPSD_VARTYPE_PATHNAME
},
159 { "ServerCertificate", &ServerCertificate
, CUPSD_VARTYPE_PATHNAME
},
160 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
161 { "ServerKey", &ServerKey
, CUPSD_VARTYPE_PATHNAME
},
162 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
163 #endif /* HAVE_SSL */
164 { "ServerName", &ServerName
, CUPSD_VARTYPE_STRING
},
165 { "ServerRoot", &ServerRoot
, CUPSD_VARTYPE_PATHNAME
},
166 { "SMBConfigFile", &SMBConfigFile
, CUPSD_VARTYPE_STRING
},
167 { "StateDir", &StateDir
, CUPSD_VARTYPE_STRING
},
168 #ifdef HAVE_AUTHORIZATION_H
169 { "SystemGroupAuthKey", &SystemGroupAuthKey
, CUPSD_VARTYPE_STRING
},
170 #endif /* HAVE_AUTHORIZATION_H */
171 { "TempDir", &TempDir
, CUPSD_VARTYPE_PATHNAME
},
172 { "Timeout", &Timeout
, CUPSD_VARTYPE_INTEGER
},
173 { "UseNetworkDefault", &UseNetworkDefault
, CUPSD_VARTYPE_BOOLEAN
}
175 #define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
178 static unsigned ones
[4] =
180 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
182 static unsigned zeros
[4] =
184 0x00000000, 0x00000000, 0x00000000, 0x00000000
191 static http_addrlist_t
*get_address(const char *value
, int defport
);
192 static int get_addr_and_mask(const char *value
, unsigned *ip
,
194 static int parse_aaa(cupsd_location_t
*loc
, char *line
,
195 char *value
, int linenum
);
196 static int parse_groups(const char *s
);
197 static int parse_protocols(const char *s
);
198 static int read_configuration(cups_file_t
*fp
);
199 static int read_location(cups_file_t
*fp
, char *name
, int linenum
);
200 static int read_policy(cups_file_t
*fp
, char *name
, int linenum
);
204 * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
207 int /* O - 0 on success, -1 on error, 1 on warning */
208 cupsdCheckPermissions(
209 const char *filename
, /* I - File/directory name */
210 const char *suffix
, /* I - Additional file/directory name */
211 int mode
, /* I - Permissions */
212 int user
, /* I - Owner */
213 int group
, /* I - Group */
214 int is_dir
, /* I - 1 = directory, 0 = file */
215 int create_dir
) /* I - 1 = create directory, -1 = create w/o logging, 0 = not */
217 int dir_created
= 0; /* Did we create a directory? */
218 char pathname
[1024]; /* File name with prefix */
219 struct stat fileinfo
; /* Stat buffer */
223 * Prepend the given root to the filename before testing it...
228 snprintf(pathname
, sizeof(pathname
), "%s/%s", filename
, suffix
);
233 * See if we can stat the file/directory...
236 if (stat(filename
, &fileinfo
))
238 if (errno
== ENOENT
&& create_dir
)
241 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Creating missing directory \"%s\"",
244 if (mkdir(filename
, mode
))
247 cupsdLogMessage(CUPSD_LOG_ERROR
,
248 "Unable to create directory \"%s\" - %s", filename
,
251 syslog(LOG_ERR
, "Unable to create directory \"%s\" - %s", filename
,
260 return (create_dir
? -1 : 1);
264 * Make sure it's a regular file...
267 if (!dir_created
&& !is_dir
&& !S_ISREG(fileinfo
.st_mode
))
269 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a regular file!", filename
);
273 if (!dir_created
&& is_dir
&& !S_ISDIR(fileinfo
.st_mode
))
276 cupsdLogMessage(CUPSD_LOG_ERROR
, "\"%s\" is not a directory!", filename
);
278 syslog(LOG_ERR
, "\"%s\" is not a directory!", filename
);
284 * Fix owner, group, and mode as needed...
287 if (dir_created
|| fileinfo
.st_uid
!= user
|| fileinfo
.st_gid
!= group
)
290 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing ownership of \"%s\"",
293 if (chown(filename
, user
, group
) && !getuid())
296 cupsdLogMessage(CUPSD_LOG_ERROR
,
297 "Unable to change ownership of \"%s\" - %s", filename
,
300 syslog(LOG_ERR
, "Unable to change ownership of \"%s\" - %s", filename
,
307 if (dir_created
|| (fileinfo
.st_mode
& 07777) != mode
)
310 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Repairing access permissions of \"%s\"",
313 if (chmod(filename
, mode
))
316 cupsdLogMessage(CUPSD_LOG_ERROR
,
317 "Unable to change permissions of \"%s\" - %s", filename
,
320 syslog(LOG_ERR
, "Unable to change permissions of \"%s\" - %s", filename
,
328 * Everything is OK...
336 * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
339 int /* O - 1 on success, 0 otherwise */
340 cupsdReadConfiguration(void)
342 int i
; /* Looping var */
343 cups_file_t
*fp
; /* Configuration file */
344 int status
; /* Return status */
345 char temp
[1024], /* Temporary buffer */
346 *slash
; /* Directory separator */
347 cups_lang_t
*language
; /* Language */
348 struct passwd
*user
; /* Default user */
349 struct group
*group
; /* Default group */
350 char *old_serverroot
, /* Old ServerRoot */
351 *old_requestroot
; /* Old RequestRoot */
352 const char *tmpdir
; /* TMPDIR environment variable */
353 struct stat tmpinfo
; /* Temporary directory info */
354 cupsd_policy_t
*p
; /* Policy */
358 * Save the old root paths...
361 old_serverroot
= NULL
;
362 cupsdSetString(&old_serverroot
, ServerRoot
);
363 old_requestroot
= NULL
;
364 cupsdSetString(&old_requestroot
, RequestRoot
);
367 * Reset the server configuration data...
370 cupsdDeleteAllLocations();
389 for (i
= 0; i
< NumRelays
; i
++)
390 if (Relays
[i
].from
.type
== AUTH_NAME
)
391 free(Relays
[i
].from
.mask
.name
.name
);
398 cupsdDeleteAllListeners();
404 cupsdSetString(&ServerName
, httpGetHostname(NULL
, temp
, sizeof(temp
)));
405 cupsdSetStringf(&ServerAdmin
, "root@%s", temp
);
406 cupsdSetString(&ServerBin
, CUPS_SERVERBIN
);
407 cupsdSetString(&RequestRoot
, CUPS_REQUESTS
);
408 cupsdSetString(&CacheDir
, CUPS_CACHEDIR
);
409 cupsdSetString(&DataDir
, CUPS_DATADIR
);
410 cupsdSetString(&DocumentRoot
, CUPS_DOCROOT
);
411 cupsdSetString(&AccessLog
, CUPS_LOGDIR
"/access_log");
412 cupsdSetString(&ErrorLog
, CUPS_LOGDIR
"/error_log");
413 cupsdSetString(&PageLog
, CUPS_LOGDIR
"/page_log");
414 cupsdSetString(&Printcap
, CUPS_DEFAULT_PRINTCAP
);
415 cupsdSetString(&PrintcapGUI
, "/usr/bin/glpoptions");
416 cupsdSetString(&FontPath
, CUPS_FONTPATH
);
417 cupsdSetString(&RemoteRoot
, "remroot");
418 cupsdSetString(&ServerHeader
, "CUPS/1.2");
419 cupsdSetString(&StateDir
, CUPS_STATEDIR
);
421 cupsdSetString(&GSSServiceName
, CUPS_DEFAULT_GSSSERVICENAME
);
422 #endif /* HAVE_GSSAPI */
424 if (!strcmp(CUPS_DEFAULT_PRINTCAP
, "/etc/printers.conf"))
425 PrintcapFormat
= PRINTCAP_SOLARIS
;
427 PrintcapFormat
= PRINTCAP_BSD
;
429 strlcpy(temp
, ConfigurationFile
, sizeof(temp
));
430 if ((slash
= strrchr(temp
, '/')) != NULL
)
433 cupsdSetString(&ServerRoot
, temp
);
435 cupsdClearString(&Classification
);
436 ClassifyOverride
= 0;
440 cupsdSetString(&ServerCertificate
, "/Library/Keychains/System.keychain");
442 cupsdSetString(&ServerCertificate
, "ssl/server.crt");
443 cupsdSetString(&ServerKey
, "ssl/server.key");
444 # endif /* HAVE_CDSASSL */
445 #endif /* HAVE_SSL */
447 language
= cupsLangDefault();
449 if (!strcmp(language
->language
, "C") || !strcmp(language
->language
, "POSIX"))
450 cupsdSetString(&DefaultLanguage
, "en");
452 cupsdSetString(&DefaultLanguage
, language
->language
);
454 cupsdSetString(&DefaultCharset
, _cupsEncodingName(language
->encoding
));
456 cupsdSetString(&RIPCache
, "8m");
458 cupsdSetString(&TempDir
, NULL
);
461 * Find the default user...
464 if ((user
= getpwnam(CUPS_DEFAULT_USER
)) != NULL
)
469 * Use the (historical) NFS nobody user ID (-2 as a 16-bit twos-
470 * complement number...)
479 * Find the default group...
482 group
= getgrnam(CUPS_DEFAULT_GROUP
);
486 Group
= group
->gr_gid
;
490 * Fallback to group "nobody"...
493 group
= getgrnam("nobody");
497 Group
= group
->gr_gid
;
501 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
502 * complement number...)
513 ConfigFilePerm
= CUPS_DEFAULT_CONFIG_FILE_PERM
;
514 DefaultAuthType
= AUTH_BASIC
;
516 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
517 #endif /* HAVE_SSL */
519 JobRetryInterval
= 300;
524 HostNameLookups
= FALSE
;
525 ImplicitClasses
= CUPS_DEFAULT_IMPLICIT_CLASSES
;
526 ImplicitAnyClasses
= FALSE
;
527 HideImplicitMembers
= TRUE
;
529 KeepAliveTimeout
= DEFAULT_KEEPALIVE
;
530 ListenBackLog
= SOMAXCONN
;
531 LogFilePerm
= CUPS_DEFAULT_LOG_FILE_PERM
;
532 LogLevel
= CUPSD_LOG_ERROR
;
534 MaxClientsPerHost
= 0;
535 MaxLogSize
= 1024 * 1024;
536 MaxPrinterHistory
= 10;
539 RootCertDuration
= 300;
540 Timeout
= DEFAULT_TIMEOUT
;
543 BrowseInterval
= DEFAULT_INTERVAL
;
544 BrowsePort
= ippPort();
545 BrowseLocalProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS
);
546 BrowseRemoteProtocols
= parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS
);
547 BrowseShortNames
= CUPS_DEFAULT_BROWSE_SHORT_NAMES
;
548 BrowseTimeout
= DEFAULT_TIMEOUT
;
549 Browsing
= CUPS_DEFAULT_BROWSING
;
550 DefaultShared
= CUPS_DEFAULT_DEFAULT_SHARED
;
552 cupsdSetString(&LPDConfigFile
, CUPS_DEFAULT_LPD_CONFIG_FILE
);
553 cupsdSetString(&SMBConfigFile
, CUPS_DEFAULT_SMB_CONFIG_FILE
);
555 cupsdClearString(&BrowseLocalOptions
);
556 cupsdClearString(&BrowseRemoteOptions
);
558 cupsdSetString(&ErrorPolicy
, "stop-printer");
561 cupsdClearString(&BrowseLDAPBindDN
);
562 cupsdClearString(&BrowseLDAPDN
);
563 cupsdClearString(&BrowseLDAPPassword
);
564 cupsdClearString(&BrowseLDAPServer
);
565 cupsdClearString(&BrowseLDAPCACertFile
);
566 #endif /* HAVE_LDAP */
568 JobHistory
= DEFAULT_HISTORY
;
569 JobFiles
= DEFAULT_FILES
;
574 MaxJobsPerPrinter
= 0;
575 MaxCopies
= CUPS_DEFAULT_MAX_COPIES
;
577 cupsdDeleteAllPolicies();
578 cupsdClearString(&DefaultPolicy
);
580 #ifdef HAVE_AUTHORIZATION_H
581 cupsdClearString(&SystemGroupAuthKey
);
582 #endif /* HAVE_AUTHORIZATION_H */
584 MaxSubscriptions
= 100;
585 MaxSubscriptionsPerJob
= 0;
586 MaxSubscriptionsPerPrinter
= 0;
587 MaxSubscriptionsPerUser
= 0;
588 DefaultLeaseDuration
= 86400;
589 MaxLeaseDuration
= 0;
592 LaunchdTimeout
= DEFAULT_TIMEOUT
+ 10;
593 cupsdSetString(&LaunchdConf
, CUPS_DEFAULT_LAUNCHD_CONF
);
594 #endif /* HAVE_LAUNCHD */
598 #endif /* __APPLE__ */
601 * Read the configuration file...
604 if ((fp
= cupsFileOpen(ConfigurationFile
, "r")) == NULL
)
607 status
= read_configuration(fp
);
617 * See if the ServerName is an IP address...
620 for (slash
= ServerName
; isdigit(*slash
& 255) || *slash
== '.'; slash
++);
622 ServerNameIsIP
= !*slash
;
625 * Use the default system group if none was supplied in cupsd.conf...
628 if (NumSystemGroups
== 0)
630 if (!parse_groups(CUPS_DEFAULT_SYSTEM_GROUPS
))
633 * Find the group associated with GID 0...
640 cupsdSetString(&SystemGroups
[0], group
->gr_name
);
642 cupsdSetString(&SystemGroups
[0], "unknown");
644 SystemGroupIDs
[0] = 0;
650 * Get the access control list for browsing...
653 BrowseACL
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
656 * Open the system log for cupsd if necessary...
660 if (!strcmp(AccessLog
, "syslog") ||
661 !strcmp(ErrorLog
, "syslog") ||
662 !strcmp(PageLog
, "syslog"))
663 openlog("cupsd", LOG_PID
| LOG_NOWAIT
| LOG_NDELAY
, LOG_LPR
);
664 #endif /* HAVE_VSYSLOG */
667 * Log the configuration file that was used...
670 cupsdLogMessage(CUPSD_LOG_INFO
, "Loaded configuration file \"%s\"",
674 * Validate the Group and SystemGroup settings - they cannot be the same,
675 * otherwise the CGI programs will be able to authenticate as root without
681 for (i
= 0; i
< NumSystemGroups
; i
++)
682 if (Group
== SystemGroupIDs
[i
])
685 if (i
< NumSystemGroups
)
688 * Log the error and reset the group to a safe value...
691 cupsdLogMessage(CUPSD_LOG_NOTICE
,
692 "Group and SystemGroup cannot use the same groups!");
693 cupsdLogMessage(CUPSD_LOG_INFO
, "Resetting Group to \"nobody\"...");
695 group
= getgrnam("nobody");
699 Group
= group
->gr_gid
;
703 * Use the (historical) NFS nobody group ID (-2 as a 16-bit twos-
704 * complement number...)
713 * Check that we have at least one listen/port line; if not, report this
714 * as an error and exit!
717 if (cupsArrayCount(Listeners
) == 0)
723 cupsdLogMessage(CUPSD_LOG_EMERG
,
724 "No valid Listen or Port lines were found in the configuration file!");
730 cupsdEndProcess(getpid(), 0);
734 * Set the default locale using the language and charset...
737 cupsdSetStringf(&DefaultLocale
, "%s.%s", DefaultLanguage
, DefaultCharset
);
740 * Update all relative filenames to include the full path from ServerRoot...
743 if (DocumentRoot
[0] != '/')
744 cupsdSetStringf(&DocumentRoot
, "%s/%s", ServerRoot
, DocumentRoot
);
746 if (RequestRoot
[0] != '/')
747 cupsdSetStringf(&RequestRoot
, "%s/%s", ServerRoot
, RequestRoot
);
749 if (ServerBin
[0] != '/')
750 cupsdSetStringf(&ServerBin
, "%s/%s", ServerRoot
, ServerBin
);
752 if (StateDir
[0] != '/')
753 cupsdSetStringf(&StateDir
, "%s/%s", ServerRoot
, StateDir
);
755 if (CacheDir
[0] != '/')
756 cupsdSetStringf(&CacheDir
, "%s/%s", ServerRoot
, CacheDir
);
759 if (ServerCertificate
[0] != '/')
760 cupsdSetStringf(&ServerCertificate
, "%s/%s", ServerRoot
, ServerCertificate
);
762 if (!strncmp(ServerRoot
, ServerCertificate
, strlen(ServerRoot
)))
764 chown(ServerCertificate
, RunUser
, Group
);
765 chmod(ServerCertificate
, 0600);
768 # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
769 if (ServerKey
[0] != '/')
770 cupsdSetStringf(&ServerKey
, "%s/%s", ServerRoot
, ServerKey
);
772 if (!strncmp(ServerRoot
, ServerKey
, strlen(ServerRoot
)))
774 chown(ServerKey
, RunUser
, Group
);
775 chmod(ServerKey
, 0600);
777 # endif /* HAVE_LIBSSL || HAVE_GNUTLS */
778 #endif /* HAVE_SSL */
781 * Make sure that directories and config files are owned and
782 * writable by the user and group in the cupsd.conf file...
785 if (cupsdCheckPermissions(RequestRoot
, NULL
, 0710, RunUser
,
787 cupsdCheckPermissions(CacheDir
, NULL
, 0775, RunUser
,
789 cupsdCheckPermissions(StateDir
, NULL
, 0755, RunUser
,
791 cupsdCheckPermissions(StateDir
, "certs", RunUser
? 0711 : 0511, User
,
792 SystemGroupIDs
[0], 1, 1) < 0 ||
793 cupsdCheckPermissions(ServerRoot
, NULL
, 0755, RunUser
,
795 cupsdCheckPermissions(ServerRoot
, "ppd", 0755, RunUser
,
797 cupsdCheckPermissions(ServerRoot
, "ssl", 0700, RunUser
,
799 cupsdCheckPermissions(ServerRoot
, "cupsd.conf", ConfigFilePerm
, RunUser
,
801 cupsdCheckPermissions(ServerRoot
, "classes.conf", 0600, RunUser
,
803 cupsdCheckPermissions(ServerRoot
, "printers.conf", 0600, RunUser
,
805 cupsdCheckPermissions(ServerRoot
, "passwd.md5", 0600, User
,
810 * Update TempDir to the default if it hasn't been set already...
815 if ((tmpdir
= getenv("TMPDIR")) != NULL
)
818 * TMPDIR is defined, see if it is OK for us to use...
821 if (stat(tmpdir
, &tmpinfo
))
822 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to access TMPDIR (%s): %s",
823 tmpdir
, strerror(errno
));
824 else if (!S_ISDIR(tmpinfo
.st_mode
))
825 cupsdLogMessage(CUPSD_LOG_ERROR
, "TMPDIR (%s) is not a directory!",
827 else if ((tmpinfo
.st_uid
!= User
|| !(tmpinfo
.st_mode
& S_IWUSR
)) &&
828 (tmpinfo
.st_gid
!= Group
|| !(tmpinfo
.st_mode
& S_IWGRP
)) &&
829 !(tmpinfo
.st_mode
& S_IWOTH
))
830 cupsdLogMessage(CUPSD_LOG_ERROR
,
831 "TMPDIR (%s) has the wrong permissions!", tmpdir
);
833 cupsdSetString(&TempDir
, tmpdir
);
838 cupsdLogMessage(CUPSD_LOG_INFO
, "Using default TempDir of %s/tmp...",
840 cupsdSetStringf(&TempDir
, "%s/tmp", RequestRoot
);
845 * Make sure the temporary directory has the right permissions...
848 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)) ||
852 * Update ownership and permissions if the CUPS temp directory
853 * is under the spool directory or does not exist...
856 if (cupsdCheckPermissions(TempDir
, NULL
, 01770, RunUser
, Group
, 1, 1) < 0)
861 * Setup environment variables...
867 * Check the MaxClients setting, and then allocate memory for it...
870 if (MaxClients
> (MaxFDs
/ 3) || MaxClients
<= 0)
873 cupsdLogMessage(CUPSD_LOG_INFO
, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...",
876 MaxClients
= MaxFDs
/ 3;
879 cupsdLogMessage(CUPSD_LOG_INFO
, "Configured for up to %d clients.",
883 * Check the MaxActiveJobs setting; limit to 1/3 the available
884 * file descriptors, since we need a pipe for each job...
887 if (MaxActiveJobs
> (MaxFDs
/ 3))
888 MaxActiveJobs
= MaxFDs
/ 3;
890 if (Classification
&& !strcasecmp(Classification
, "none"))
891 cupsdClearString(&Classification
);
894 cupsdLogMessage(CUPSD_LOG_INFO
, "Security set to \"%s\"", Classification
);
897 * Update the MaxClientsPerHost value, as needed...
900 if (MaxClientsPerHost
<= 0)
901 MaxClientsPerHost
= MaxClients
;
903 if (MaxClientsPerHost
> MaxClients
)
904 MaxClientsPerHost
= MaxClients
;
906 cupsdLogMessage(CUPSD_LOG_INFO
,
907 "Allowing up to %d client connections per host.",
911 * Make sure that BrowseTimeout is at least twice the interval...
914 if (BrowseTimeout
< (2 * BrowseInterval
) || BrowseTimeout
<= 0)
916 cupsdLogMessage(CUPSD_LOG_ALERT
, "Invalid BrowseTimeout value %d!",
920 BrowseTimeout
= BrowseInterval
* 2;
922 BrowseTimeout
= DEFAULT_TIMEOUT
;
924 cupsdLogMessage(CUPSD_LOG_ALERT
, "Reset BrowseTimeout to %d!",
929 * Update the default policy, as needed...
933 DefaultPolicyPtr
= cupsdFindPolicy(DefaultPolicy
);
935 DefaultPolicyPtr
= NULL
;
937 if (!DefaultPolicyPtr
)
939 cupsd_location_t
*po
; /* New policy operation */
943 cupsdLogMessage(CUPSD_LOG_ERROR
, "Default policy \"%s\" not found!",
946 cupsdSetString(&DefaultPolicy
, "default");
948 if ((DefaultPolicyPtr
= cupsdFindPolicy("default")) != NULL
)
949 cupsdLogMessage(CUPSD_LOG_INFO
,
950 "Using policy \"default\" as the default!");
953 cupsdLogMessage(CUPSD_LOG_INFO
,
954 "Creating CUPS default administrative policy:");
956 DefaultPolicyPtr
= p
= cupsdAddPolicy("default");
958 cupsdLogMessage(CUPSD_LOG_INFO
, "<Policy default>");
959 cupsdLogMessage(CUPSD_LOG_INFO
,
960 "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
961 "Release-Job Restart-Job Purge-Jobs "
962 "Set-Job-Attributes Create-Job-Subscription "
963 "Renew-Subscription Cancel-Subscription "
964 "Get-Notifications Reprocess-Job Cancel-Current-Job "
965 "Suspend-Current-Job Resume-Job CUPS-Move-Job "
966 "CUPS-Authenticate-Job CUPS-Get-Document>");
967 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
969 po
= cupsdAddPolicyOp(p
, NULL
, IPP_SEND_DOCUMENT
);
970 po
->order_type
= AUTH_ALLOW
;
971 po
->level
= AUTH_USER
;
973 cupsdAddName(po
, "@OWNER");
974 cupsdAddName(po
, "@SYSTEM");
975 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @OWNER @SYSTEM");
977 cupsdAddPolicyOp(p
, po
, IPP_SEND_URI
);
978 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_JOB
);
979 cupsdAddPolicyOp(p
, po
, IPP_HOLD_JOB
);
980 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_JOB
);
981 cupsdAddPolicyOp(p
, po
, IPP_RESTART_JOB
);
982 cupsdAddPolicyOp(p
, po
, IPP_PURGE_JOBS
);
983 cupsdAddPolicyOp(p
, po
, IPP_SET_JOB_ATTRIBUTES
);
984 cupsdAddPolicyOp(p
, po
, IPP_CREATE_JOB_SUBSCRIPTION
);
985 cupsdAddPolicyOp(p
, po
, IPP_RENEW_SUBSCRIPTION
);
986 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_SUBSCRIPTION
);
987 cupsdAddPolicyOp(p
, po
, IPP_GET_NOTIFICATIONS
);
988 cupsdAddPolicyOp(p
, po
, IPP_REPROCESS_JOB
);
989 cupsdAddPolicyOp(p
, po
, IPP_CANCEL_CURRENT_JOB
);
990 cupsdAddPolicyOp(p
, po
, IPP_SUSPEND_CURRENT_JOB
);
991 cupsdAddPolicyOp(p
, po
, IPP_RESUME_JOB
);
992 cupsdAddPolicyOp(p
, po
, CUPS_MOVE_JOB
);
993 cupsdAddPolicyOp(p
, po
, CUPS_AUTHENTICATE_JOB
);
994 cupsdAddPolicyOp(p
, po
, CUPS_GET_DOCUMENT
);
996 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
998 cupsdLogMessage(CUPSD_LOG_INFO
,
999 "<Limit Pause-Printer Resume-Printer "
1000 "Set-Printer-Attributes Enable-Printer "
1001 "Disable-Printer Pause-Printer-After-Current-Job "
1002 "Hold-New-Jobs Release-Held-New-Jobs "
1003 "Deactivate-Printer Activate-Printer Restart-Printer "
1004 "Shutdown-Printer Startup-Printer Promote-Job "
1005 "Schedule-Job-After CUPS-Add-Printer "
1006 "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
1007 "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
1008 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1009 cupsdLogMessage(CUPSD_LOG_INFO
, "AuthType Default");
1011 po
= cupsdAddPolicyOp(p
, NULL
, IPP_PAUSE_PRINTER
);
1012 po
->order_type
= AUTH_ALLOW
;
1013 po
->type
= AUTH_DEFAULT
;
1014 po
->level
= AUTH_USER
;
1016 cupsdAddName(po
, "@SYSTEM");
1017 cupsdLogMessage(CUPSD_LOG_INFO
, "Require user @SYSTEM");
1019 cupsdAddPolicyOp(p
, po
, IPP_RESUME_PRINTER
);
1020 cupsdAddPolicyOp(p
, po
, IPP_SET_PRINTER_ATTRIBUTES
);
1021 cupsdAddPolicyOp(p
, po
, IPP_ENABLE_PRINTER
);
1022 cupsdAddPolicyOp(p
, po
, IPP_DISABLE_PRINTER
);
1023 cupsdAddPolicyOp(p
, po
, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB
);
1024 cupsdAddPolicyOp(p
, po
, IPP_HOLD_NEW_JOBS
);
1025 cupsdAddPolicyOp(p
, po
, IPP_RELEASE_HELD_NEW_JOBS
);
1026 cupsdAddPolicyOp(p
, po
, IPP_DEACTIVATE_PRINTER
);
1027 cupsdAddPolicyOp(p
, po
, IPP_ACTIVATE_PRINTER
);
1028 cupsdAddPolicyOp(p
, po
, IPP_RESTART_PRINTER
);
1029 cupsdAddPolicyOp(p
, po
, IPP_SHUTDOWN_PRINTER
);
1030 cupsdAddPolicyOp(p
, po
, IPP_STARTUP_PRINTER
);
1031 cupsdAddPolicyOp(p
, po
, IPP_PROMOTE_JOB
);
1032 cupsdAddPolicyOp(p
, po
, IPP_SCHEDULE_JOB_AFTER
);
1033 cupsdAddPolicyOp(p
, po
, CUPS_ADD_PRINTER
);
1034 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_PRINTER
);
1035 cupsdAddPolicyOp(p
, po
, CUPS_ADD_CLASS
);
1036 cupsdAddPolicyOp(p
, po
, CUPS_DELETE_CLASS
);
1037 cupsdAddPolicyOp(p
, po
, CUPS_ACCEPT_JOBS
);
1038 cupsdAddPolicyOp(p
, po
, CUPS_REJECT_JOBS
);
1039 cupsdAddPolicyOp(p
, po
, CUPS_SET_DEFAULT
);
1041 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1043 cupsdLogMessage(CUPSD_LOG_INFO
, "<Limit All>");
1044 cupsdLogMessage(CUPSD_LOG_INFO
, "Order Deny,Allow");
1046 po
= cupsdAddPolicyOp(p
, NULL
, IPP_ANY_OPERATION
);
1047 po
->order_type
= AUTH_ALLOW
;
1049 cupsdLogMessage(CUPSD_LOG_INFO
, "</Limit>");
1050 cupsdLogMessage(CUPSD_LOG_INFO
, "</Policy>");
1054 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: NumPolicies=%d",
1055 cupsArrayCount(Policies
));
1056 for (i
= 0, p
= (cupsd_policy_t
*)cupsArrayFirst(Policies
);
1058 i
++, p
= (cupsd_policy_t
*)cupsArrayNext(Policies
))
1059 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1060 "cupsdReadConfiguration: Policies[%d]=\"%s\"", i
, p
->name
);
1063 * If we are doing a full reload or the server root has changed, flush
1064 * the jobs, printers, etc. and start from scratch...
1067 if (NeedReload
== RELOAD_ALL
||
1068 !old_serverroot
|| !ServerRoot
|| strcmp(old_serverroot
, ServerRoot
) ||
1069 !old_requestroot
|| !RequestRoot
|| strcmp(old_requestroot
, RequestRoot
))
1071 mime_type_t
*type
; /* Current type */
1072 char mimetype
[MIME_MAX_SUPER
+ MIME_MAX_TYPE
];
1073 /* MIME type name */
1076 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload is required.");
1079 * Free all memory...
1082 cupsdDeleteAllSubscriptions();
1084 cupsdDeleteAllClasses();
1085 cupsdDeleteAllPrinters();
1087 DefaultPrinter
= NULL
;
1089 if (MimeDatabase
!= NULL
)
1090 mimeDelete(MimeDatabase
);
1094 for (i
= 0; i
< NumMimeTypes
; i
++)
1095 _cupsStrFree(MimeTypes
[i
]);
1101 * Read the MIME type and conversion database...
1104 snprintf(temp
, sizeof(temp
), "%s/filter", ServerBin
);
1106 MimeDatabase
= mimeLoad(ServerRoot
, temp
);
1110 cupsdLogMessage(CUPSD_LOG_EMERG
,
1111 "Unable to load MIME database from \'%s\'!", ServerRoot
);
1115 cupsdLogMessage(CUPSD_LOG_INFO
,
1116 "Loaded MIME database from \'%s\': %d types, %d filters...",
1117 ServerRoot
, mimeNumTypes(MimeDatabase
),
1118 mimeNumFilters(MimeDatabase
));
1121 * Create a list of MIME types for the document-format-supported
1125 NumMimeTypes
= mimeNumTypes(MimeDatabase
);
1126 if (!mimeType(MimeDatabase
, "application", "octet-stream"))
1129 MimeTypes
= calloc(NumMimeTypes
, sizeof(const char *));
1131 for (i
= 0, type
= mimeFirstType(MimeDatabase
);
1133 i
++, type
= mimeNextType(MimeDatabase
))
1135 snprintf(mimetype
, sizeof(mimetype
), "%s/%s", type
->super
, type
->type
);
1137 MimeTypes
[i
] = _cupsStrAlloc(mimetype
);
1140 if (i
< NumMimeTypes
)
1141 MimeTypes
[i
] = _cupsStrAlloc("application/octet-stream");
1143 if (LogLevel
== CUPSD_LOG_DEBUG2
)
1145 mime_filter_t
*filter
; /* Current filter */
1148 for (type
= mimeFirstType(MimeDatabase
);
1150 type
= mimeNextType(MimeDatabase
))
1151 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "cupsdReadConfiguration: type %s/%s",
1152 type
->super
, type
->type
);
1154 for (filter
= mimeFirstFilter(MimeDatabase
);
1156 filter
= mimeNextFilter(MimeDatabase
))
1157 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1158 "cupsdReadConfiguration: filter %s/%s to %s/%s %d %s",
1159 filter
->src
->super
, filter
->src
->type
,
1160 filter
->dst
->super
, filter
->dst
->type
,
1161 filter
->cost
, filter
->filter
);
1168 snprintf(temp
, sizeof(temp
), "%s/banners", DataDir
);
1169 cupsdLoadBanners(temp
);
1172 * Load printers and classes...
1175 cupsdLoadAllPrinters();
1176 cupsdLoadAllClasses();
1177 cupsdLoadRemoteCache();
1178 cupsdWritePrintcap();
1180 cupsdCreateCommonData();
1183 * Load queued jobs...
1189 * Load subscriptions...
1192 cupsdLoadAllSubscriptions();
1194 cupsdLogMessage(CUPSD_LOG_INFO
, "Full reload complete.");
1199 * Not a full reload, so recreate the common printer attributes...
1202 cupsdCreateCommonData();
1205 * Update all printers as needed...
1208 cupsdUpdatePrinters();
1209 cupsdWritePrintcap();
1211 cupsdLogMessage(CUPSD_LOG_INFO
, "Partial reload complete.");
1215 * Reset the reload state...
1218 NeedReload
= RELOAD_NONE
;
1220 cupsdClearString(&old_serverroot
);
1221 cupsdClearString(&old_requestroot
);
1228 * 'get_address()' - Get an address + port number from a line.
1231 static http_addrlist_t
* /* O - Pointer to list if address good, NULL if bad */
1232 get_address(const char *value
, /* I - Value string */
1233 int defport
) /* I - Default port */
1235 char buffer
[1024], /* Hostname + port number buffer */
1236 defpname
[255], /* Default port name */
1237 *hostname
, /* Hostname or IP */
1238 *portname
; /* Port number or name */
1239 http_addrlist_t
*addrlist
; /* Address list */
1243 * Check for an empty value...
1248 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad (empty) address!");
1253 * Grab a hostname and port number; if there is no colon and the port name
1254 * is only digits, then we have a port number by itself...
1257 strlcpy(buffer
, value
, sizeof(buffer
));
1259 if ((portname
= strrchr(buffer
, ':')) != NULL
&& !strchr(portname
, ']'))
1266 for (portname
= buffer
; isdigit(*portname
& 255); portname
++);
1271 * Use the default port...
1274 sprintf(defpname
, "%d", defport
);
1275 portname
= defpname
;
1281 * The buffer contains just a port number...
1289 if (hostname
&& !strcmp(hostname
, "*"))
1293 * Now lookup the address using httpAddrGetList()...
1296 if ((addrlist
= httpAddrGetList(hostname
, AF_UNSPEC
, portname
)) == NULL
)
1297 cupsdLogMessage(CUPSD_LOG_ERROR
, "Hostname lookup for \"%s\" failed!",
1298 hostname
? hostname
: "(nil)");
1305 * 'get_addr_and_mask()' - Get an IP address and netmask.
1308 static int /* O - 1 on success, 0 on failure */
1309 get_addr_and_mask(const char *value
, /* I - String from config file */
1310 unsigned *ip
, /* O - Address value */
1311 unsigned *mask
) /* O - Mask value */
1313 int i
, j
, /* Looping vars */
1314 family
, /* Address family */
1315 ipcount
; /* Count of fields in address */
1316 unsigned ipval
; /* Value */
1317 const char *maskval
, /* Pointer to start of mask value */
1318 *ptr
, /* Pointer into value */
1323 * Get the address...
1326 ip
[0] = ip
[1] = ip
[2] = ip
[3] = 0x00000000;
1327 mask
[0] = mask
[1] = mask
[2] = mask
[3] = 0xffffffff;
1329 if ((maskval
= strchr(value
, '/')) != NULL
)
1332 maskval
= value
+ strlen(value
);
1336 * Check for an IPv6 address...
1342 * Parse hexadecimal IPv6 address...
1347 for (i
= 0, ptr
= value
+ 1; *ptr
&& i
< 8; i
++)
1351 else if (!strncmp(ptr
, "::", 2))
1353 for (ptr2
= strchr(ptr
+ 2, ':'), j
= 0;
1355 ptr2
= strchr(ptr2
+ 1, ':'), j
++);
1360 else if (isxdigit(*ptr
& 255))
1362 ipval
= strtoul(ptr
, (char **)&ptr
, 16);
1370 ip
[i
/ 2] |= ipval
<< 16;
1384 if (*ptr
&& *ptr
!= '/')
1388 #endif /* AF_INET6 */
1391 * Parse dotted-decimal IPv4 address...
1394 unsigned val
[4]; /* IPv4 address values */
1398 ipcount
= sscanf(value
, "%u.%u.%u.%u", val
+ 0, val
+ 1, val
+ 2, val
+ 3);
1401 * Range check the IP numbers...
1404 for (i
= 0; i
< ipcount
; i
++)
1409 * Make sure the trailing values are zeroed, as some C libraries like
1410 * glibc apparently like to fill the unused arguments with garbage...
1413 for (i
= ipcount
; i
< 4; i
++)
1417 * Merge everything into a 32-bit IPv4 address in ip[3]...
1420 ip
[3] = (((((val
[0] << 8) | val
[1]) << 8) | val
[2]) << 8) | val
[3];
1423 mask
[3] = (0xffffffff << (32 - 8 * ipcount
)) & 0xffffffff;
1429 * Get the netmask value(s)...
1432 memset(mask
, 0, sizeof(unsigned) * 4);
1434 if (strchr(maskval
, '.'))
1437 * Get dotted-decimal mask...
1440 if (family
!= AF_INET
)
1443 if (sscanf(maskval
, "%u.%u.%u.%u", mask
+ 0, mask
+ 1, mask
+ 2, mask
+ 3) != 4)
1446 mask
[3] |= ((((mask
[0] << 8) | mask
[1]) << 8) | mask
[2]) << 8;
1447 mask
[0] = mask
[1] = mask
[2] = 0;
1452 * Get address/bits format...
1458 if (family
== AF_INET6
)
1466 mask
[0] = 0xffffffff;
1468 mask
[0] = (0xffffffff << (i
- 96)) & 0xffffffff;
1471 mask
[1] = 0xffffffff;
1475 mask
[1] = (0xffffffff << (i
- 64)) & 0xffffffff;
1478 mask
[2] = 0xffffffff;
1482 mask
[2] = (0xffffffff << (i
- 32)) & 0xffffffff;
1485 mask
[3] = 0xffffffff;
1489 mask
[3] = (0xffffffff << i
) & 0xffffffff;
1492 #endif /* AF_INET6 */
1497 mask
[0] = 0xffffffff;
1498 mask
[1] = 0xffffffff;
1499 mask
[2] = 0xffffffff;
1502 mask
[3] = (0xffffffff << (32 - i
)) & 0xffffffff;
1504 mask
[3] = 0xffffffff;
1509 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1510 "get_addr_and_mask(value=\"%s\", "
1511 "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x])",
1512 value
, ip
[0], ip
[1], ip
[2], ip
[3], mask
[0], mask
[1], mask
[2],
1516 * Check for a valid netmask; no fallback like in CUPS 1.1.x!
1519 if ((ip
[0] & ~mask
[0]) != 0 ||
1520 (ip
[1] & ~mask
[1]) != 0 ||
1521 (ip
[2] & ~mask
[2]) != 0 ||
1522 (ip
[3] & ~mask
[3]) != 0)
1530 * 'parse_aaa()' - Parse authentication, authorization, and access control lines.
1533 static int /* O - 1 on success, 0 on failure */
1534 parse_aaa(cupsd_location_t
*loc
, /* I - Location */
1535 char *line
, /* I - Line from file */
1536 char *value
, /* I - Start of value data */
1537 int linenum
) /* I - Current line number */
1539 char *valptr
; /* Pointer into value */
1540 unsigned ip
[4], /* IP address components */
1541 mask
[4]; /* IP netmask components */
1544 if (!strcasecmp(line
, "Encryption"))
1547 * "Encryption xxx" - set required encryption level...
1550 if (!strcasecmp(value
, "never"))
1551 loc
->encryption
= HTTP_ENCRYPT_NEVER
;
1552 else if (!strcasecmp(value
, "always"))
1554 cupsdLogMessage(CUPSD_LOG_ERROR
,
1555 "Encryption value \"%s\" on line %d is invalid in this "
1556 "context. Using \"required\" instead.", value
, linenum
);
1558 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1560 else if (!strcasecmp(value
, "required"))
1561 loc
->encryption
= HTTP_ENCRYPT_REQUIRED
;
1562 else if (!strcasecmp(value
, "ifrequested"))
1563 loc
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
1566 cupsdLogMessage(CUPSD_LOG_ERROR
,
1567 "Unknown Encryption value %s on line %d.", value
, linenum
);
1571 else if (!strcasecmp(line
, "Order"))
1574 * "Order Deny,Allow" or "Order Allow,Deny"...
1577 if (!strncasecmp(value
, "deny", 4))
1578 loc
->order_type
= AUTH_ALLOW
;
1579 else if (!strncasecmp(value
, "allow", 5))
1580 loc
->order_type
= AUTH_DENY
;
1583 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown Order value %s on line %d.",
1588 else if (!strcasecmp(line
, "Allow") || !strcasecmp(line
, "Deny"))
1591 * Allow [From] host/ip...
1592 * Deny [From] host/ip...
1595 if (!strncasecmp(value
, "from", 4))
1598 * Strip leading "from"...
1603 while (isspace(*value
& 255))
1608 * Figure out what form the allow/deny address takes:
1619 * nnn.nnn.nnn.nnn/mm
1620 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
1623 if (!strcasecmp(value
, "all"))
1629 if (!strcasecmp(line
, "Allow"))
1630 cupsdAllowIP(loc
, zeros
, zeros
);
1632 cupsdDenyIP(loc
, zeros
, zeros
);
1634 else if (!strcasecmp(value
, "none"))
1640 if (!strcasecmp(line
, "Allow"))
1641 cupsdAllowIP(loc
, ones
, zeros
);
1643 cupsdDenyIP(loc
, ones
, zeros
);
1646 else if (value
[0] == '*' || value
[0] == '.' ||
1647 (!isdigit(value
[0] & 255) && value
[0] != '['))
1649 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
1650 #endif /* AF_INET6 */
1653 * Host or domain name...
1656 if (value
[0] == '*')
1659 if (!strcasecmp(line
, "Allow"))
1660 cupsdAllowHost(loc
, value
);
1662 cupsdDenyHost(loc
, value
);
1667 * One of many IP address forms...
1670 if (!get_addr_and_mask(value
, ip
, mask
))
1672 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
1677 if (!strcasecmp(line
, "Allow"))
1678 cupsdAllowIP(loc
, ip
, mask
);
1680 cupsdDenyIP(loc
, ip
, mask
);
1683 else if (!strcasecmp(line
, "AuthType"))
1686 * AuthType {none,basic,digest,basicdigest,negotiate,default}
1689 if (!strcasecmp(value
, "none"))
1691 loc
->type
= AUTH_NONE
;
1692 loc
->level
= AUTH_ANON
;
1694 else if (!strcasecmp(value
, "basic"))
1696 loc
->type
= AUTH_BASIC
;
1698 if (loc
->level
== AUTH_ANON
)
1699 loc
->level
= AUTH_USER
;
1701 else if (!strcasecmp(value
, "digest"))
1703 loc
->type
= AUTH_DIGEST
;
1705 if (loc
->level
== AUTH_ANON
)
1706 loc
->level
= AUTH_USER
;
1708 else if (!strcasecmp(value
, "basicdigest"))
1710 loc
->type
= AUTH_BASICDIGEST
;
1712 if (loc
->level
== AUTH_ANON
)
1713 loc
->level
= AUTH_USER
;
1715 else if (!strcasecmp(value
, "default"))
1717 loc
->type
= AUTH_DEFAULT
;
1719 if (loc
->level
== AUTH_ANON
)
1720 loc
->level
= AUTH_USER
;
1723 else if (!strcasecmp(value
, "negotiate"))
1725 loc
->type
= AUTH_NEGOTIATE
;
1727 if (loc
->level
== AUTH_ANON
)
1728 loc
->level
= AUTH_USER
;
1730 #endif /* HAVE_GSSAPI */
1733 cupsdLogMessage(CUPSD_LOG_WARN
,
1734 "Unknown authorization type %s on line %d.",
1739 else if (!strcasecmp(line
, "AuthClass"))
1742 * AuthClass anonymous, user, system, group
1745 if (!strcasecmp(value
, "anonymous"))
1747 loc
->type
= AUTH_NONE
;
1748 loc
->level
= AUTH_ANON
;
1750 cupsdLogMessage(CUPSD_LOG_WARN
,
1751 "\"AuthClass %s\" is deprecated; consider removing "
1755 else if (!strcasecmp(value
, "user"))
1757 loc
->level
= AUTH_USER
;
1759 cupsdLogMessage(CUPSD_LOG_WARN
,
1760 "\"AuthClass %s\" is deprecated; consider using "
1761 "\"Require valid-user\" on line %d.",
1764 else if (!strcasecmp(value
, "group"))
1766 loc
->level
= AUTH_GROUP
;
1768 cupsdLogMessage(CUPSD_LOG_WARN
,
1769 "\"AuthClass %s\" is deprecated; consider using "
1770 "\"Require user @groupname\" on line %d.",
1773 else if (!strcasecmp(value
, "system"))
1775 loc
->level
= AUTH_GROUP
;
1777 cupsdAddName(loc
, "@SYSTEM");
1779 cupsdLogMessage(CUPSD_LOG_WARN
,
1780 "\"AuthClass %s\" is deprecated; consider using "
1781 "\"Require user @SYSTEM\" on line %d.",
1786 cupsdLogMessage(CUPSD_LOG_WARN
,
1787 "Unknown authorization class %s on line %d.",
1792 else if (!strcasecmp(line
, "AuthGroupName"))
1794 cupsdAddName(loc
, value
);
1796 cupsdLogMessage(CUPSD_LOG_WARN
,
1797 "\"AuthGroupName %s\" directive is deprecated; consider "
1798 "using \"Require user @%s\" on line %d.",
1799 value
, value
, linenum
);
1801 else if (!strcasecmp(line
, "Require"))
1804 * Apache synonym for AuthClass and AuthGroupName...
1808 * Require valid-user
1809 * Require group names
1810 * Require user names
1813 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
1818 if (!strcasecmp(value
, "valid-user") ||
1819 !strcasecmp(value
, "user"))
1820 loc
->level
= AUTH_USER
;
1821 else if (!strcasecmp(value
, "group"))
1822 loc
->level
= AUTH_GROUP
;
1825 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Require type %s on line %d.",
1831 * Get the list of names from the line...
1834 for (value
= valptr
; *value
;)
1836 while (isspace(*value
& 255))
1839 #ifdef HAVE_AUTHORIZATION_H
1840 if (!strncmp(value
, "@AUTHKEY(", 9))
1843 * Grab "@AUTHKEY(name)" value...
1846 for (valptr
= value
+ 9; *valptr
!= ')' && *valptr
; valptr
++);
1852 #endif /* HAVE_AUTHORIZATION_H */
1853 if (*value
== '\"' || *value
== '\'')
1856 * Grab quoted name...
1859 for (valptr
= value
+ 1; *valptr
!= *value
&& *valptr
; valptr
++);
1866 * Grab literal name.
1869 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
1875 cupsdAddName(loc
, value
);
1877 for (value
= valptr
; isspace(*value
& 255); value
++);
1880 else if (!strcasecmp(line
, "Satisfy"))
1882 if (!strcasecmp(value
, "all"))
1883 loc
->satisfy
= AUTH_SATISFY_ALL
;
1884 else if (!strcasecmp(value
, "any"))
1885 loc
->satisfy
= AUTH_SATISFY_ANY
;
1888 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown Satisfy value %s on line %d.",
1901 * 'parse_groups()' - Parse system group names in a string.
1904 static int /* O - 1 on success, 0 on failure */
1905 parse_groups(const char *s
) /* I - Space-delimited groups */
1907 int status
; /* Return status */
1908 char value
[1024], /* Value string */
1909 *valstart
, /* Pointer into value */
1910 *valend
, /* End of value */
1911 quote
; /* Quote character */
1912 struct group
*group
; /* Group */
1916 * Make a copy of the string and parse out the groups...
1919 strlcpy(value
, s
, sizeof(value
));
1924 while (*valstart
&& NumSystemGroups
< MAX_SYSTEM_GROUPS
)
1926 if (*valstart
== '\'' || *valstart
== '\"')
1929 * Scan quoted name...
1932 quote
= *valstart
++;
1934 for (valend
= valstart
; *valend
; valend
++)
1935 if (*valend
== quote
)
1941 * Scan space or comma-delimited name...
1944 for (valend
= valstart
; *valend
; valend
++)
1945 if (isspace(*valend
) || *valend
== ',')
1952 group
= getgrnam(valstart
);
1955 cupsdSetString(SystemGroups
+ NumSystemGroups
, valstart
);
1956 SystemGroupIDs
[NumSystemGroups
] = group
->gr_gid
;
1967 while (*valstart
== ',' || isspace(*valstart
))
1976 * 'parse_protocols()' - Parse browse protocols in a string.
1979 static int /* O - Browse protocol bits */
1980 parse_protocols(const char *s
) /* I - Space-delimited protocols */
1982 int protocols
; /* Browse protocol bits */
1983 char value
[1024], /* Value string */
1984 *valstart
, /* Pointer into value */
1985 *valend
; /* End of value */
1989 * Empty protocol line yields NULL pointer...
1996 * Loop through the value string,...
1999 strlcpy(value
, s
, sizeof(value
));
2003 for (valstart
= value
; *valstart
;)
2006 * Get the current space/comma-delimited protocol name...
2009 for (valend
= valstart
; *valend
; valend
++)
2010 if (isspace(*valend
& 255) || *valend
== ',')
2017 * Add the protocol to the bitmask...
2020 if (!strcasecmp(valstart
, "cups"))
2021 protocols
|= BROWSE_CUPS
;
2022 else if (!strcasecmp(valstart
, "slp"))
2023 protocols
|= BROWSE_SLP
;
2024 else if (!strcasecmp(valstart
, "ldap"))
2025 protocols
|= BROWSE_LDAP
;
2026 else if (!strcasecmp(valstart
, "dnssd") || !strcasecmp(valstart
, "bonjour"))
2027 protocols
|= BROWSE_DNSSD
;
2028 else if (!strcasecmp(valstart
, "lpd"))
2029 protocols
|= BROWSE_LPD
;
2030 else if (!strcasecmp(valstart
, "smb"))
2031 protocols
|= BROWSE_SMB
;
2032 else if (!strcasecmp(valstart
, "all"))
2033 protocols
|= BROWSE_ALL
;
2034 else if (strcasecmp(valstart
, "none"))
2037 for (valstart
= valend
; *valstart
; valstart
++)
2038 if (!isspace(*valstart
& 255) || *valstart
!= ',')
2047 * 'read_configuration()' - Read a configuration file.
2050 static int /* O - 1 on success, 0 on failure */
2051 read_configuration(cups_file_t
*fp
) /* I - File to read from */
2053 int i
; /* Looping var */
2054 int linenum
; /* Current line number */
2055 char line
[HTTP_MAX_BUFFER
],
2056 /* Line from file */
2057 temp
[HTTP_MAX_BUFFER
],
2058 /* Temporary buffer for value */
2059 temp2
[HTTP_MAX_BUFFER
],
2060 /* Temporary buffer 2 for value */
2061 *ptr
, /* Pointer into line/temp */
2062 *value
, /* Pointer to value */
2063 *valueptr
; /* Pointer into value */
2064 int valuelen
; /* Length of value */
2065 cupsd_var_t
*var
; /* Current variable */
2066 http_addrlist_t
*addrlist
, /* Address list */
2067 *addr
; /* Current address */
2068 unsigned ip
[4], /* Address value */
2069 mask
[4]; /* Netmask value */
2070 cupsd_dirsvc_relay_t
*relay
; /* Relay data */
2071 cupsd_dirsvc_poll_t
*pollp
; /* Polling data */
2072 cupsd_location_t
*location
; /* Browse location */
2073 cups_file_t
*incfile
; /* Include file */
2074 char incname
[1024]; /* Include filename */
2075 struct group
*group
; /* Group */
2079 * Loop through each line in the file...
2084 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
2087 * Decode the directive...
2090 if (!strcasecmp(line
, "Include"))
2096 if (value
[0] == '/')
2097 strlcpy(incname
, value
, sizeof(incname
));
2099 snprintf(incname
, sizeof(incname
), "%s/%s", ServerRoot
, value
);
2101 if ((incfile
= cupsFileOpen(incname
, "rb")) == NULL
)
2102 cupsdLogMessage(CUPSD_LOG_ERROR
,
2103 "Unable to include config file \"%s\" - %s",
2104 incname
, strerror(errno
));
2107 read_configuration(incfile
);
2108 cupsFileClose(incfile
);
2111 else if (!strcasecmp(line
, "<Location"))
2119 linenum
= read_location(fp
, value
, linenum
);
2125 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.",
2130 else if (!strcasecmp(line
, "<Policy"))
2138 linenum
= read_policy(fp
, value
, linenum
);
2144 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
2148 else if (!strcasecmp(line
, "FaxRetryInterval"))
2152 JobRetryInterval
= atoi(value
);
2153 cupsdLogMessage(CUPSD_LOG_WARN
,
2154 "FaxRetryInterval is deprecated; use "
2155 "JobRetryInterval on line %d.", linenum
);
2159 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
2163 else if (!strcasecmp(line
, "FaxRetryLimit"))
2167 JobRetryLimit
= atoi(value
);
2168 cupsdLogMessage(CUPSD_LOG_WARN
,
2169 "FaxRetryLimit is deprecated; use "
2170 "JobRetryLimit on line %d.", linenum
);
2174 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
2178 else if (!strcasecmp(line
, "Port") || !strcasecmp(line
, "Listen")
2180 || !strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen")
2181 #endif /* HAVE_SSL */
2185 * Add listening address(es) to the list...
2188 cupsd_listener_t
*lis
; /* New listeners array */
2192 * Get the address list...
2195 addrlist
= get_address(value
, IPP_PORT
);
2199 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad %s address %s at line %d.", line
,
2205 * Add each address...
2208 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2211 * Allocate another listener...
2215 Listeners
= cupsArrayNew(NULL
, NULL
);
2219 cupsdLogMessage(CUPSD_LOG_ERROR
,
2220 "Unable to allocate %s at line %d - %s.",
2221 line
, linenum
, strerror(errno
));
2225 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
2227 cupsdLogMessage(CUPSD_LOG_ERROR
,
2228 "Unable to allocate %s at line %d - %s.",
2229 line
, linenum
, strerror(errno
));
2233 cupsArrayAdd(Listeners
, lis
);
2236 * Copy the current address and log it...
2239 memcpy(&(lis
->address
), &(addr
->addr
), sizeof(lis
->address
));
2243 if (!strcasecmp(line
, "SSLPort") || !strcasecmp(line
, "SSLListen"))
2244 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
2245 #endif /* HAVE_SSL */
2247 httpAddrString(&lis
->address
, temp
, sizeof(temp
));
2250 if (lis
->address
.addr
.sa_family
== AF_INET6
)
2251 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv6)", temp
,
2252 ntohs(lis
->address
.ipv6
.sin6_port
));
2254 #endif /* AF_INET6 */
2256 if (lis
->address
.addr
.sa_family
== AF_LOCAL
)
2257 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s (Domain)", temp
);
2259 #endif /* AF_LOCAL */
2260 cupsdLogMessage(CUPSD_LOG_INFO
, "Listening to %s:%d (IPv4)", temp
,
2261 ntohs(lis
->address
.ipv4
.sin_port
));
2268 httpAddrFreeList(addrlist
);
2270 else if (!strcasecmp(line
, "BrowseAddress"))
2273 * Add a browse address to the list...
2276 cupsd_dirsvc_addr_t
*dira
; /* New browse address array */
2279 if (NumBrowsers
== 0)
2280 dira
= malloc(sizeof(cupsd_dirsvc_addr_t
));
2282 dira
= realloc(Browsers
, (NumBrowsers
+ 1) * sizeof(cupsd_dirsvc_addr_t
));
2286 cupsdLogMessage(CUPSD_LOG_ERROR
,
2287 "Unable to allocate BrowseAddress at line %d - %s.",
2288 linenum
, strerror(errno
));
2293 dira
+= NumBrowsers
;
2295 memset(dira
, 0, sizeof(cupsd_dirsvc_addr_t
));
2297 if (!strcasecmp(value
, "@LOCAL"))
2300 * Send browse data to all local interfaces...
2303 strcpy(dira
->iface
, "*");
2306 else if (!strncasecmp(value
, "@IF(", 4))
2309 * Send browse data to the named interface...
2312 strlcpy(dira
->iface
, value
+ 4, sizeof(Browsers
[0].iface
));
2314 ptr
= dira
->iface
+ strlen(dira
->iface
) - 1;
2320 else if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2323 * Only IPv4 addresses are supported...
2326 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2327 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2332 memcpy(&(dira
->to
), &(addrlist
->addr
), sizeof(dira
->to
));
2333 httpAddrString(&(dira
->to
), temp
, sizeof(temp
));
2335 cupsdLogMessage(CUPSD_LOG_INFO
,
2336 "Sending browsing info to %s:%d (IPv4)",
2337 temp
, ntohs(dira
->to
.ipv4
.sin_port
));
2342 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2345 httpAddrFreeList(addrlist
);
2348 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad BrowseAddress %s at line %d.",
2351 else if (!strcasecmp(line
, "BrowseOrder"))
2354 * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
2357 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2358 location
= cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL");
2360 if (location
== NULL
)
2361 cupsdLogMessage(CUPSD_LOG_ERROR
,
2362 "Unable to initialize browse access control list!");
2363 else if (!strncasecmp(value
, "deny", 4))
2364 location
->order_type
= AUTH_ALLOW
;
2365 else if (!strncasecmp(value
, "allow", 5))
2366 location
->order_type
= AUTH_DENY
;
2368 cupsdLogMessage(CUPSD_LOG_ERROR
,
2369 "Unknown BrowseOrder value %s on line %d.",
2372 else if (!strcasecmp(line
, "BrowseProtocols") ||
2373 !strcasecmp(line
, "BrowseLocalProtocols") ||
2374 !strcasecmp(line
, "BrowseRemoteProtocols"))
2377 * "BrowseProtocols name [... name]"
2378 * "BrowseLocalProtocols name [... name]"
2379 * "BrowseRemoteProtocols name [... name]"
2382 int protocols
= parse_protocols(value
);
2386 cupsdLogMessage(CUPSD_LOG_ERROR
,
2387 "Unknown browse protocol \"%s\" on line %d.",
2392 if (strcasecmp(line
, "BrowseLocalProtocols"))
2393 BrowseRemoteProtocols
= protocols
;
2394 if (strcasecmp(line
, "BrowseRemoteProtocols"))
2395 BrowseLocalProtocols
= protocols
;
2397 else if (!strcasecmp(line
, "BrowseAllow") ||
2398 !strcasecmp(line
, "BrowseDeny"))
2401 * BrowseAllow [From] host/ip...
2402 * BrowseDeny [From] host/ip...
2405 if ((location
= cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL
)
2406 location
= cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL");
2408 if (location
== NULL
)
2409 cupsdLogMessage(CUPSD_LOG_ERROR
,
2410 "Unable to initialize browse access control list!");
2413 if (!strncasecmp(value
, "from ", 5))
2416 * Strip leading "from"...
2421 while (isspace(*value
))
2426 * Figure out what form the allow/deny address takes:
2437 * nnn.nnn.nnn.nnn/mm
2438 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2441 if (!strcasecmp(value
, "all"))
2447 if (!strcasecmp(line
, "BrowseAllow"))
2448 cupsdAllowIP(location
, zeros
, zeros
);
2450 cupsdDenyIP(location
, zeros
, zeros
);
2452 else if (!strcasecmp(value
, "none"))
2458 if (!strcasecmp(line
, "BrowseAllow"))
2459 cupsdAllowIP(location
, ones
, zeros
);
2461 cupsdDenyIP(location
, ones
, zeros
);
2464 else if (value
[0] == '*' || value
[0] == '.' ||
2465 (!isdigit(value
[0] & 255) && value
[0] != '['))
2467 else if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2468 #endif /* AF_INET6 */
2471 * Host or domain name...
2474 if (value
[0] == '*')
2477 if (!strcasecmp(line
, "BrowseAllow"))
2478 cupsdAllowHost(location
, value
);
2480 cupsdDenyHost(location
, value
);
2485 * One of many IP address forms...
2488 if (!get_addr_and_mask(value
, ip
, mask
))
2490 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2495 if (!strcasecmp(line
, "BrowseAllow"))
2496 cupsdAllowIP(location
, ip
, mask
);
2498 cupsdDenyIP(location
, ip
, mask
);
2502 else if (!strcasecmp(line
, "BrowseRelay"))
2505 * BrowseRelay [from] source [to] destination
2509 relay
= malloc(sizeof(cupsd_dirsvc_relay_t
));
2511 relay
= realloc(Relays
, (NumRelays
+ 1) * sizeof(cupsd_dirsvc_relay_t
));
2515 cupsdLogMessage(CUPSD_LOG_ERROR
,
2516 "Unable to allocate BrowseRelay at line %d - %s.",
2517 linenum
, strerror(errno
));
2524 memset(relay
, 0, sizeof(cupsd_dirsvc_relay_t
));
2526 if (!strncasecmp(value
, "from ", 5))
2529 * Strip leading "from"...
2534 while (isspace(*value
))
2539 * Figure out what form the from address takes:
2548 * nnn.nnn.nnn.nnn/mm
2549 * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
2553 if (value
[0] == '*' || value
[0] == '.' ||
2554 (!isdigit(value
[0] & 255) && value
[0] != '['))
2556 if (value
[0] == '*' || value
[0] == '.' || !isdigit(value
[0] & 255))
2557 #endif /* AF_INET6 */
2560 * Host or domain name...
2563 if (value
[0] == '*')
2566 strlcpy(temp
, value
, sizeof(temp
));
2567 if ((ptr
= strchr(temp
, ' ')) != NULL
)
2570 relay
->from
.type
= AUTH_NAME
;
2571 relay
->from
.mask
.name
.name
= strdup(temp
);
2572 relay
->from
.mask
.name
.length
= strlen(temp
);
2577 * One of many IP address forms...
2580 if (!get_addr_and_mask(value
, ip
, mask
))
2582 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad netmask value %s on line %d.",
2587 relay
->from
.type
= AUTH_IP
;
2588 memcpy(relay
->from
.mask
.ip
.address
, ip
,
2589 sizeof(relay
->from
.mask
.ip
.address
));
2590 memcpy(relay
->from
.mask
.ip
.netmask
, mask
,
2591 sizeof(relay
->from
.mask
.ip
.netmask
));
2595 * Skip value and trailing whitespace...
2598 for (; *value
; value
++)
2599 if (isspace(*value
))
2602 while (isspace(*value
))
2605 if (!strncasecmp(value
, "to ", 3))
2608 * Strip leading "to"...
2613 while (isspace(*value
))
2618 * Get "to" address and port...
2621 if ((addrlist
= get_address(value
, BrowsePort
)) != NULL
)
2624 * Only IPv4 addresses are supported...
2627 for (addr
= addrlist
; addr
; addr
= addr
->next
)
2628 if (addr
->addr
.addr
.sa_family
== AF_INET
)
2633 memcpy(&(relay
->to
), &(addrlist
->addr
), sizeof(relay
->to
));
2635 httpAddrString(&(relay
->to
), temp
, sizeof(temp
));
2637 if (relay
->from
.type
== AUTH_IP
)
2638 snprintf(temp2
, sizeof(temp2
), "%u.%u.%u.%u/%u.%u.%u.%u",
2639 relay
->from
.mask
.ip
.address
[0] >> 24,
2640 (relay
->from
.mask
.ip
.address
[0] >> 16) & 255,
2641 (relay
->from
.mask
.ip
.address
[0] >> 8) & 255,
2642 relay
->from
.mask
.ip
.address
[0] & 255,
2643 relay
->from
.mask
.ip
.netmask
[0] >> 24,
2644 (relay
->from
.mask
.ip
.netmask
[0] >> 16) & 255,
2645 (relay
->from
.mask
.ip
.netmask
[0] >> 8) & 255,
2646 relay
->from
.mask
.ip
.netmask
[0] & 255);
2648 strlcpy(temp2
, relay
->from
.mask
.name
.name
, sizeof(temp2
));
2650 cupsdLogMessage(CUPSD_LOG_INFO
, "Relaying from %s to %s:%d (IPv4)",
2651 temp2
, temp
, ntohs(relay
->to
.ipv4
.sin_port
));
2656 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
2659 httpAddrFreeList(addrlist
);
2663 if (relay
->from
.type
== AUTH_NAME
)
2664 free(relay
->from
.mask
.name
.name
);
2666 cupsdLogMessage(CUPSD_LOG_ERROR
, "Bad relay address %s at line %d.",
2670 else if (!strcasecmp(line
, "BrowsePoll"))
2673 * BrowsePoll address[:port]
2676 char *portname
; /* Port name */
2677 int portnum
; /* Port number */
2678 struct servent
*service
; /* Service */
2682 * Extract the port name from the address...
2685 if ((portname
= strrchr(value
, ':')) != NULL
&& !strchr(portname
, ']'))
2689 if (isdigit(*portname
& 255))
2690 portnum
= atoi(portname
);
2691 else if ((service
= getservbyname(portname
, NULL
)) != NULL
)
2692 portnum
= ntohs(service
->s_port
);
2695 cupsdLogMessage(CUPSD_LOG_ERROR
, "Lookup of service \"%s\" failed!",
2701 portnum
= ippPort();
2704 * Add the poll entry...
2708 pollp
= malloc(sizeof(cupsd_dirsvc_poll_t
));
2710 pollp
= realloc(Polled
, (NumPolled
+ 1) * sizeof(cupsd_dirsvc_poll_t
));
2714 cupsdLogMessage(CUPSD_LOG_ERROR
,
2715 "Unable to allocate BrowsePoll at line %d - %s.",
2716 linenum
, strerror(errno
));
2724 memset(pollp
, 0, sizeof(cupsd_dirsvc_poll_t
));
2726 strlcpy(pollp
->hostname
, value
, sizeof(pollp
->hostname
));
2727 pollp
->port
= portnum
;
2729 cupsdLogMessage(CUPSD_LOG_INFO
, "Polling %s:%d", pollp
->hostname
,
2732 else if (!strcasecmp(line
, "DefaultAuthType"))
2735 * DefaultAuthType {basic,digest,basicdigest,negotiate}
2738 if (!strcasecmp(value
, "none"))
2739 DefaultAuthType
= AUTH_NONE
;
2740 else if (!strcasecmp(value
, "basic"))
2741 DefaultAuthType
= AUTH_BASIC
;
2742 else if (!strcasecmp(value
, "digest"))
2743 DefaultAuthType
= AUTH_DIGEST
;
2744 else if (!strcasecmp(value
, "basicdigest"))
2745 DefaultAuthType
= AUTH_BASICDIGEST
;
2747 else if (!strcasecmp(value
, "negotiate"))
2748 DefaultAuthType
= AUTH_NEGOTIATE
;
2749 #endif /* HAVE_GSSAPI */
2752 cupsdLogMessage(CUPSD_LOG_WARN
,
2753 "Unknown default authorization type %s on line %d.",
2759 else if (!strcasecmp(line
, "DefaultEncryption"))
2762 * DefaultEncryption {Never,IfRequested,Required}
2765 if (!value
|| !strcasecmp(value
, "never"))
2766 DefaultEncryption
= HTTP_ENCRYPT_NEVER
;
2767 else if (!strcasecmp(value
, "required"))
2768 DefaultEncryption
= HTTP_ENCRYPT_REQUIRED
;
2769 else if (!strcasecmp(value
, "ifrequested"))
2770 DefaultEncryption
= HTTP_ENCRYPT_IF_REQUESTED
;
2773 cupsdLogMessage(CUPSD_LOG_WARN
,
2774 "Unknown default encryption %s on line %d.",
2779 #endif /* HAVE_SSL */
2781 else if (!strcasecmp(line
, "Krb5Keytab"))
2783 cupsdSetStringf(&Krb5Keytab
, "KRB5_KTNAME=%s", value
);
2786 # ifdef HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY
2787 gsskrb5_register_acceptor_identity(value
);
2789 cupsdSetEnv("KRB5_KTNAME", value
);
2790 # endif /* HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY */
2792 #endif /* HAVE_GSSAPI */
2793 else if (!strcasecmp(line
, "User"))
2796 * User ID to run as...
2799 if (value
&& isdigit(value
[0] & 255))
2801 int uid
= atoi(value
);
2804 cupsdLogMessage(CUPSD_LOG_ERROR
,
2805 "Will not use User 0 as specified on line %d "
2806 "for security reasons. You must use a non-"
2807 "privileged account instead.",
2814 struct passwd
*p
; /* Password information */
2817 p
= getpwnam(value
);
2822 cupsdLogMessage(CUPSD_LOG_ERROR
,
2823 "Will not use User %s (UID=0) as specified on line "
2824 "%d for security reasons. You must use a non-"
2825 "privileged account instead.",
2831 cupsdLogMessage(CUPSD_LOG_ERROR
,
2832 "Unknown User \"%s\" on line %d, ignoring!",
2836 cupsdLogMessage(CUPSD_LOG_ERROR
,
2837 "User directive on line %d missing the username!",
2840 else if (!strcasecmp(line
, "Group"))
2843 * Group ID to run as...
2846 if (isdigit(value
[0]))
2847 Group
= atoi(value
);
2851 group
= getgrnam(value
);
2854 Group
= group
->gr_gid
;
2856 cupsdLogMessage(CUPSD_LOG_ERROR
,
2857 "Unknown Group \"%s\" on line %d, ignoring!",
2861 else if (!strcasecmp(line
, "SystemGroup"))
2864 * SystemGroup (admin) group(s)...
2867 if (!parse_groups(value
))
2868 cupsdLogMessage(CUPSD_LOG_ERROR
,
2869 "Unknown SystemGroup \"%s\" on line %d, ignoring!",
2872 else if (!strcasecmp(line
, "HostNameLookups"))
2875 * Do hostname lookups?
2878 if (!strcasecmp(value
, "off"))
2879 HostNameLookups
= 0;
2880 else if (!strcasecmp(value
, "on"))
2881 HostNameLookups
= 1;
2882 else if (!strcasecmp(value
, "double"))
2883 HostNameLookups
= 2;
2885 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown HostNameLookups %s on line %d.",
2888 else if (!strcasecmp(line
, "LogLevel"))
2891 * Amount of logging to do...
2894 if (!strcasecmp(value
, "debug2"))
2895 LogLevel
= CUPSD_LOG_DEBUG2
;
2896 else if (!strcasecmp(value
, "debug"))
2897 LogLevel
= CUPSD_LOG_DEBUG
;
2898 else if (!strcasecmp(value
, "info"))
2899 LogLevel
= CUPSD_LOG_INFO
;
2900 else if (!strcasecmp(value
, "notice"))
2901 LogLevel
= CUPSD_LOG_NOTICE
;
2902 else if (!strcasecmp(value
, "warn"))
2903 LogLevel
= CUPSD_LOG_WARN
;
2904 else if (!strcasecmp(value
, "error"))
2905 LogLevel
= CUPSD_LOG_ERROR
;
2906 else if (!strcasecmp(value
, "crit"))
2907 LogLevel
= CUPSD_LOG_CRIT
;
2908 else if (!strcasecmp(value
, "alert"))
2909 LogLevel
= CUPSD_LOG_ALERT
;
2910 else if (!strcasecmp(value
, "emerg"))
2911 LogLevel
= CUPSD_LOG_EMERG
;
2912 else if (!strcasecmp(value
, "none"))
2913 LogLevel
= CUPSD_LOG_NONE
;
2915 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown LogLevel %s on line %d.",
2918 else if (!strcasecmp(line
, "PrintcapFormat"))
2921 * Format of printcap file?
2924 if (!strcasecmp(value
, "bsd"))
2925 PrintcapFormat
= PRINTCAP_BSD
;
2926 else if (!strcasecmp(value
, "solaris"))
2927 PrintcapFormat
= PRINTCAP_SOLARIS
;
2929 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown PrintcapFormat %s on line %d.",
2932 else if (!strcasecmp(line
, "ServerTokens"))
2935 * Set the string used for the Server header...
2938 struct utsname plat
; /* Platform info */
2943 if (!strcasecmp(value
, "ProductOnly"))
2944 cupsdSetString(&ServerHeader
, "CUPS");
2945 else if (!strcasecmp(value
, "Major"))
2946 cupsdSetString(&ServerHeader
, "CUPS/1");
2947 else if (!strcasecmp(value
, "Minor"))
2948 cupsdSetString(&ServerHeader
, "CUPS/1.2");
2949 else if (!strcasecmp(value
, "Minimal"))
2950 cupsdSetString(&ServerHeader
, CUPS_MINIMAL
);
2951 else if (!strcasecmp(value
, "OS"))
2952 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s)", plat
.sysname
);
2953 else if (!strcasecmp(value
, "Full"))
2954 cupsdSetStringf(&ServerHeader
, CUPS_MINIMAL
" (%s) IPP/1.1",
2956 else if (!strcasecmp(value
, "None"))
2957 cupsdClearString(&ServerHeader
);
2959 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown ServerTokens %s on line %d.",
2962 else if (!strcasecmp(line
, "PassEnv"))
2965 * PassEnv variable [... variable]
2970 for (valuelen
= 0; value
[valuelen
]; valuelen
++)
2971 if (isspace(value
[valuelen
]) || value
[valuelen
] == ',')
2974 if (value
[valuelen
])
2976 value
[valuelen
] = '\0';
2980 cupsdSetEnv(value
, NULL
);
2982 for (value
+= valuelen
; *value
; value
++)
2983 if (!isspace(*value
) || *value
!= ',')
2987 else if (!strcasecmp(line
, "SetEnv"))
2990 * SetEnv variable value
2993 for (valueptr
= value
; *valueptr
&& !isspace(*valueptr
& 255); valueptr
++);
3001 while (isspace(*valueptr
& 255))
3004 cupsdSetEnv(value
, valueptr
);
3007 cupsdLogMessage(CUPSD_LOG_ERROR
,
3008 "Missing value for SetEnv directive on line %d.",
3014 * Find a simple variable in the list...
3017 for (i
= NUM_VARS
, var
= variables
; i
> 0; i
--, var
++)
3018 if (!strcasecmp(line
, var
->name
))
3024 * Unknown directive! Output an error message and continue...
3027 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unknown directive %s on line %d.",
3034 case CUPSD_VARTYPE_INTEGER
:
3036 cupsdLogMessage(CUPSD_LOG_ERROR
,
3037 "Missing integer value for %s on line %d!",
3042 char *units
; /* Units */
3045 n
= strtol(value
, &units
, 0);
3047 if (units
&& *units
)
3049 if (tolower(units
[0] & 255) == 'g')
3050 n
*= 1024 * 1024 * 1024;
3051 else if (tolower(units
[0] & 255) == 'm')
3053 else if (tolower(units
[0] & 255) == 'k')
3055 else if (tolower(units
[0] & 255) == 't')
3060 cupsdLogMessage(CUPSD_LOG_ERROR
,
3061 "Bad negative integer value for %s on line %d!",
3064 *((int *)var
->ptr
) = n
;
3068 case CUPSD_VARTYPE_BOOLEAN
:
3070 cupsdLogMessage(CUPSD_LOG_ERROR
,
3071 "Missing boolean value for %s on line %d!",
3073 else if (!strcasecmp(value
, "true") ||
3074 !strcasecmp(value
, "on") ||
3075 !strcasecmp(value
, "enabled") ||
3076 !strcasecmp(value
, "yes") ||
3078 *((int *)var
->ptr
) = TRUE
;
3079 else if (!strcasecmp(value
, "false") ||
3080 !strcasecmp(value
, "off") ||
3081 !strcasecmp(value
, "disabled") ||
3082 !strcasecmp(value
, "no") ||
3083 !strcasecmp(value
, "0"))
3084 *((int *)var
->ptr
) = FALSE
;
3086 cupsdLogMessage(CUPSD_LOG_ERROR
,
3087 "Unknown boolean value %s on line %d.",
3091 case CUPSD_VARTYPE_PATHNAME
:
3092 if (value
[0] == '/')
3093 strlcpy(temp
, value
, sizeof(temp
));
3095 snprintf(temp
, sizeof(temp
), "%s/%s", ServerRoot
, value
);
3097 if (access(temp
, 0))
3099 cupsdLogMessage(CUPSD_LOG_ERROR
,
3100 "File or directory for \"%s %s\" on line %d "
3101 "does not exist!", line
, value
, linenum
);
3105 case CUPSD_VARTYPE_STRING
:
3106 cupsdSetString((char **)var
->ptr
, value
);
3117 * 'read_location()' - Read a <Location path> definition.
3120 static int /* O - New line number or 0 on error */
3121 read_location(cups_file_t
*fp
, /* I - Configuration file */
3122 char *location
, /* I - Location name/path */
3123 int linenum
) /* I - Current line number */
3125 cupsd_location_t
*loc
, /* New location */
3126 *parent
; /* Parent location */
3127 char line
[HTTP_MAX_BUFFER
],
3129 *value
, /* Value for directive */
3130 *valptr
; /* Pointer into value */
3133 if ((parent
= cupsdAddLocation(location
)) == NULL
)
3136 parent
->limit
= AUTH_LIMIT_ALL
;
3139 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3142 * Decode the directive...
3145 if (!strcasecmp(line
, "</Location>"))
3147 else if (!strcasecmp(line
, "<Limit") ||
3148 !strcasecmp(line
, "<LimitExcept"))
3152 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3156 if ((loc
= cupsdCopyLocation(&parent
)) == NULL
)
3162 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3167 if (!strcmp(value
, "ALL"))
3168 loc
->limit
= AUTH_LIMIT_ALL
;
3169 else if (!strcmp(value
, "GET"))
3170 loc
->limit
|= AUTH_LIMIT_GET
;
3171 else if (!strcmp(value
, "HEAD"))
3172 loc
->limit
|= AUTH_LIMIT_HEAD
;
3173 else if (!strcmp(value
, "OPTIONS"))
3174 loc
->limit
|= AUTH_LIMIT_OPTIONS
;
3175 else if (!strcmp(value
, "POST"))
3176 loc
->limit
|= AUTH_LIMIT_POST
;
3177 else if (!strcmp(value
, "PUT"))
3178 loc
->limit
|= AUTH_LIMIT_PUT
;
3179 else if (!strcmp(value
, "TRACE"))
3180 loc
->limit
|= AUTH_LIMIT_TRACE
;
3182 cupsdLogMessage(CUPSD_LOG_WARN
, "Unknown request type %s on line %d!",
3185 for (value
= valptr
; isspace(*value
& 255); value
++);
3188 if (!strcasecmp(line
, "<LimitExcept"))
3189 loc
->limit
= AUTH_LIMIT_ALL
^ loc
->limit
;
3191 parent
->limit
&= ~loc
->limit
;
3193 else if (!strcasecmp(line
, "</Limit>"))
3195 else if (!parse_aaa(loc
, line
, value
, linenum
))
3197 cupsdLogMessage(CUPSD_LOG_ERROR
,
3198 "Unknown Location directive %s on line %d.",
3204 cupsdLogMessage(CUPSD_LOG_ERROR
,
3205 "Unexpected end-of-file at line %d while reading location!",
3213 * 'read_policy()' - Read a <Policy name> definition.
3216 static int /* O - New line number or 0 on error */
3217 read_policy(cups_file_t
*fp
, /* I - Configuration file */
3218 char *policy
, /* I - Location name/path */
3219 int linenum
) /* I - Current line number */
3221 int i
; /* Looping var */
3222 cupsd_policy_t
*pol
; /* Policy */
3223 cupsd_location_t
*op
; /* Policy operation */
3224 int num_ops
; /* Number of IPP operations */
3225 ipp_op_t ops
[100]; /* Operations */
3226 char line
[HTTP_MAX_BUFFER
],
3228 *value
, /* Value for directive */
3229 *valptr
; /* Pointer into value */
3233 * Create the policy...
3236 if ((pol
= cupsdAddPolicy(policy
)) == NULL
)
3240 * Read from the file...
3246 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
3249 * Decode the directive...
3252 if (!strcasecmp(line
, "</Policy>"))
3255 cupsdLogMessage(CUPSD_LOG_WARN
,
3256 "Missing </Limit> before </Policy> on line %d!",
3260 * Verify that we have an explicit policy for CUPS-Get-Document
3261 * (ensures that upgrades do not introduce new security issues...)
3264 if ((op
= cupsdFindPolicyOp(pol
, CUPS_GET_DOCUMENT
)) == NULL
||
3265 op
->op
== IPP_ANY_OPERATION
)
3267 if ((op
= cupsdFindPolicyOp(pol
, IPP_SEND_DOCUMENT
)) != NULL
&&
3268 op
->op
!= IPP_ANY_OPERATION
)
3271 * Add a new limit for CUPS-Get-Document using the Send-Document
3272 * limit as a template...
3275 cupsdLogMessage(CUPSD_LOG_WARN
,
3276 "No limit for CUPS-Get-Document defined in policy %s "
3277 "- using Send-Document's policy", pol
->name
);
3279 cupsdAddPolicyOp(pol
, op
, CUPS_GET_DOCUMENT
);
3285 else if (!strcasecmp(line
, "<Limit") && !op
)
3289 cupsdLogMessage(CUPSD_LOG_ERROR
, "Syntax error on line %d.", linenum
);
3294 * Scan for IPP operation names...
3301 for (valptr
= value
; !isspace(*valptr
& 255) && *valptr
; valptr
++);
3306 if (num_ops
< (int)(sizeof(ops
) / sizeof(ops
[0])))
3308 if (!strcasecmp(value
, "All"))
3309 ops
[num_ops
] = IPP_ANY_OPERATION
;
3310 else if ((ops
[num_ops
] = ippOpValue(value
)) == IPP_BAD_OPERATION
)
3311 cupsdLogMessage(CUPSD_LOG_ERROR
,
3312 "Bad IPP operation name \"%s\" on line %d!",
3318 cupsdLogMessage(CUPSD_LOG_ERROR
,
3319 "Too many operations listed on line %d!",
3322 for (value
= valptr
; isspace(*value
& 255); value
++);
3326 * If none are specified, apply the policy to all operations...
3331 ops
[0] = IPP_ANY_OPERATION
;
3336 * Add a new policy for the first operation...
3339 op
= cupsdAddPolicyOp(pol
, NULL
, ops
[0]);
3341 else if (!strcasecmp(line
, "</Limit>") && op
)
3344 * Finish the current operation limit...
3350 * Copy the policy to the other operations...
3353 for (i
= 1; i
< num_ops
; i
++)
3354 cupsdAddPolicyOp(pol
, op
, ops
[i
]);
3361 cupsdLogMessage(CUPSD_LOG_ERROR
,
3362 "Missing <Limit ops> directive before %s on line %d.",
3366 else if (!parse_aaa(op
, line
, value
, linenum
))
3369 cupsdLogMessage(CUPSD_LOG_ERROR
,
3370 "Unknown Policy Limit directive %s on line %d.",
3373 cupsdLogMessage(CUPSD_LOG_ERROR
,
3374 "Unknown Policy directive %s on line %d.",
3381 cupsdLogMessage(CUPSD_LOG_ERROR
,
3382 "Unexpected end-of-file at line %d while reading policy \"%s\"!",
3390 * End of "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $".