summaryrefslogtreecommitdiff
path: root/scheduler/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'scheduler/conf.c')
-rw-r--r--scheduler/conf.c856
1 files changed, 250 insertions, 606 deletions
diff --git a/scheduler/conf.c b/scheduler/conf.c
index 3ddcdcd8..aaf42734 100644
--- a/scheduler/conf.c
+++ b/scheduler/conf.c
@@ -1,9 +1,9 @@
/*
- * "$Id: conf.c 10121 2011-11-16 15:28:11Z mike $"
+ * "$Id: conf.c 10482 2012-05-18 19:51:02Z mike $"
*
* Configuration routines for the CUPS scheduler.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -17,6 +17,7 @@
* cupsdAddAlias() - Add a host alias.
* cupsdCheckPermissions() - Fix the mode and ownership of a file or
* directory.
+ * cupsdDefaultAuthType() - Get the default AuthType.
* cupsdFreeAliases() - Free all of the alias entries.
* cupsdReadConfiguration() - Read the cupsd.conf file.
* get_address() - Get an address + port number from a line.
@@ -64,6 +65,7 @@
typedef enum
{
CUPSD_VARTYPE_INTEGER, /* Integer option */
+ CUPSD_VARTYPE_TIME, /* Time interval option */
CUPSD_VARTYPE_STRING, /* String option */
CUPSD_VARTYPE_BOOLEAN, /* Boolean option */
CUPSD_VARTYPE_PATHNAME /* File/directory name option */
@@ -71,7 +73,7 @@ typedef enum
typedef struct
{
- char *name; /* Name of variable */
+ const char *name; /* Name of variable */
void *ptr; /* Pointer to variable */
cupsd_vartype_t type; /* Type (int, string, address) */
} cupsd_var_t;
@@ -81,28 +83,15 @@ typedef struct
* Local globals...
*/
+static int default_auth_type = CUPSD_AUTH_AUTO;
+ /* Default AuthType, if not specified */
static const cupsd_var_t variables[] =
{
{ "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING },
{ "AutoPurgeJobs", &JobAutoPurge, CUPSD_VARTYPE_BOOLEAN },
#ifdef HAVE_DNSSD
- { "BrowseDNSSDRegType", &DNSSDRegType, CUPSD_VARTYPE_STRING },
+ { "BrowseDNSSDSubTypes", &DNSSDSubTypes, CUPSD_VARTYPE_STRING },
#endif /* HAVE_DNSSD */
- { "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER },
-#ifdef HAVE_LDAP
- { "BrowseLDAPBindDN", &BrowseLDAPBindDN, CUPSD_VARTYPE_STRING },
-# ifdef HAVE_LDAP_SSL
- { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile, CUPSD_VARTYPE_PATHNAME },
-# endif /* HAVE_LDAP_SSL */
- { "BrowseLDAPDN", &BrowseLDAPDN, CUPSD_VARTYPE_STRING },
- { "BrowseLDAPPassword", &BrowseLDAPPassword, CUPSD_VARTYPE_STRING },
- { "BrowseLDAPServer", &BrowseLDAPServer, CUPSD_VARTYPE_STRING },
-#endif /* HAVE_LDAP */
- { "BrowseLocalOptions", &BrowseLocalOptions, CUPSD_VARTYPE_STRING },
- { "BrowsePort", &BrowsePort, CUPSD_VARTYPE_INTEGER },
- { "BrowseRemoteOptions", &BrowseRemoteOptions, CUPSD_VARTYPE_STRING },
- { "BrowseShortNames", &BrowseShortNames, CUPSD_VARTYPE_BOOLEAN },
- { "BrowseTimeout", &BrowseTimeout, CUPSD_VARTYPE_INTEGER },
{ "BrowseWebIF", &BrowseWebIF, CUPSD_VARTYPE_BOOLEAN },
{ "Browsing", &Browsing, CUPSD_VARTYPE_BOOLEAN },
{ "CacheDir", &CacheDir, CUPSD_VARTYPE_STRING },
@@ -111,11 +100,11 @@ static const cupsd_var_t variables[] =
{ "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_INTEGER },
{ "DataDir", &DataDir, CUPSD_VARTYPE_STRING },
{ "DefaultLanguage", &DefaultLanguage, CUPSD_VARTYPE_STRING },
- { "DefaultLeaseDuration", &DefaultLeaseDuration, CUPSD_VARTYPE_INTEGER },
+ { "DefaultLeaseDuration", &DefaultLeaseDuration, CUPSD_VARTYPE_TIME },
{ "DefaultPaperSize", &DefaultPaperSize, CUPSD_VARTYPE_STRING },
{ "DefaultPolicy", &DefaultPolicy, CUPSD_VARTYPE_STRING },
{ "DefaultShared", &DefaultShared, CUPSD_VARTYPE_BOOLEAN },
- { "DirtyCleanInterval", &DirtyCleanInterval, CUPSD_VARTYPE_INTEGER },
+ { "DirtyCleanInterval", &DirtyCleanInterval, CUPSD_VARTYPE_TIME },
{ "DocumentRoot", &DocumentRoot, CUPSD_VARTYPE_STRING },
{ "ErrorLog", &ErrorLog, CUPSD_VARTYPE_STRING },
{ "ErrorPolicy", &ErrorPolicy, CUPSD_VARTYPE_STRING },
@@ -123,16 +112,16 @@ static const cupsd_var_t variables[] =
{ "FilterLimit", &FilterLimit, CUPSD_VARTYPE_INTEGER },
{ "FilterNice", &FilterNice, CUPSD_VARTYPE_INTEGER },
{ "FontPath", &FontPath, CUPSD_VARTYPE_STRING },
- { "HideImplicitMembers", &HideImplicitMembers, CUPSD_VARTYPE_BOOLEAN },
- { "ImplicitClasses", &ImplicitClasses, CUPSD_VARTYPE_BOOLEAN },
- { "ImplicitAnyClasses", &ImplicitAnyClasses, CUPSD_VARTYPE_BOOLEAN },
- { "JobKillDelay", &JobKillDelay, CUPSD_VARTYPE_INTEGER },
+#ifdef HAVE_GSSAPI
+ { "GSSServiceName", &GSSServiceName, CUPSD_VARTYPE_STRING },
+#endif /* HAVE_GSSAPI */
+ { "JobKillDelay", &JobKillDelay, CUPSD_VARTYPE_TIME },
{ "JobRetryLimit", &JobRetryLimit, CUPSD_VARTYPE_INTEGER },
- { "JobRetryInterval", &JobRetryInterval, CUPSD_VARTYPE_INTEGER },
- { "KeepAliveTimeout", &KeepAliveTimeout, CUPSD_VARTYPE_INTEGER },
+ { "JobRetryInterval", &JobRetryInterval, CUPSD_VARTYPE_TIME },
+ { "KeepAliveTimeout", &KeepAliveTimeout, CUPSD_VARTYPE_TIME },
{ "KeepAlive", &KeepAlive, CUPSD_VARTYPE_BOOLEAN },
#ifdef HAVE_LAUNCHD
- { "LaunchdTimeout", &LaunchdTimeout, CUPSD_VARTYPE_INTEGER },
+ { "LaunchdTimeout", &LaunchdTimeout, CUPSD_VARTYPE_TIME },
#endif /* HAVE_LAUNCHD */
{ "LimitRequestBody", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
{ "ListenBackLog", &ListenBackLog, CUPSD_VARTYPE_INTEGER },
@@ -144,28 +133,30 @@ static const cupsd_var_t variables[] =
{ "MaxClientsPerHost", &MaxClientsPerHost, CUPSD_VARTYPE_INTEGER },
{ "MaxCopies", &MaxCopies, CUPSD_VARTYPE_INTEGER },
{ "MaxEvents", &MaxEvents, CUPSD_VARTYPE_INTEGER },
+ { "MaxHoldTime", &MaxHoldTime, CUPSD_VARTYPE_TIME },
{ "MaxJobs", &MaxJobs, CUPSD_VARTYPE_INTEGER },
{ "MaxJobsPerPrinter", &MaxJobsPerPrinter, CUPSD_VARTYPE_INTEGER },
{ "MaxJobsPerUser", &MaxJobsPerUser, CUPSD_VARTYPE_INTEGER },
- { "MaxLeaseDuration", &MaxLeaseDuration, CUPSD_VARTYPE_INTEGER },
+ { "MaxJobTime", &MaxJobTime, CUPSD_VARTYPE_INTEGER },
+ { "MaxLeaseDuration", &MaxLeaseDuration, CUPSD_VARTYPE_TIME },
{ "MaxLogSize", &MaxLogSize, CUPSD_VARTYPE_INTEGER },
{ "MaxRequestSize", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
{ "MaxSubscriptions", &MaxSubscriptions, CUPSD_VARTYPE_INTEGER },
{ "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob, CUPSD_VARTYPE_INTEGER },
{ "MaxSubscriptionsPerPrinter",&MaxSubscriptionsPerPrinter, CUPSD_VARTYPE_INTEGER },
{ "MaxSubscriptionsPerUser", &MaxSubscriptionsPerUser, CUPSD_VARTYPE_INTEGER },
- { "MultipleOperationTimeout", &MultipleOperationTimeout, CUPSD_VARTYPE_INTEGER },
+ { "MultipleOperationTimeout", &MultipleOperationTimeout, CUPSD_VARTYPE_TIME },
{ "PageLog", &PageLog, CUPSD_VARTYPE_STRING },
{ "PageLogFormat", &PageLogFormat, CUPSD_VARTYPE_STRING },
- { "PreserveJobFiles", &JobFiles, CUPSD_VARTYPE_BOOLEAN },
- { "PreserveJobHistory", &JobHistory, CUPSD_VARTYPE_BOOLEAN },
+ { "PreserveJobFiles", &JobFiles, CUPSD_VARTYPE_TIME },
+ { "PreserveJobHistory", &JobHistory, CUPSD_VARTYPE_TIME },
{ "Printcap", &Printcap, CUPSD_VARTYPE_STRING },
{ "PrintcapGUI", &PrintcapGUI, CUPSD_VARTYPE_STRING },
- { "ReloadTimeout", &ReloadTimeout, CUPSD_VARTYPE_INTEGER },
+ { "ReloadTimeout", &ReloadTimeout, CUPSD_VARTYPE_TIME },
{ "RemoteRoot", &RemoteRoot, CUPSD_VARTYPE_STRING },
{ "RequestRoot", &RequestRoot, CUPSD_VARTYPE_STRING },
{ "RIPCache", &RIPCache, CUPSD_VARTYPE_STRING },
- { "RootCertDuration", &RootCertDuration, CUPSD_VARTYPE_INTEGER },
+ { "RootCertDuration", &RootCertDuration, CUPSD_VARTYPE_TIME },
{ "ServerAdmin", &ServerAdmin, CUPSD_VARTYPE_STRING },
{ "ServerBin", &ServerBin, CUPSD_VARTYPE_PATHNAME },
#ifdef HAVE_SSL
@@ -178,12 +169,12 @@ static const cupsd_var_t variables[] =
{ "ServerRoot", &ServerRoot, CUPSD_VARTYPE_PATHNAME },
{ "SMBConfigFile", &SMBConfigFile, CUPSD_VARTYPE_STRING },
{ "StateDir", &StateDir, CUPSD_VARTYPE_STRING },
+ { "StrictConformance", &StrictConformance, CUPSD_VARTYPE_BOOLEAN },
#ifdef HAVE_AUTHORIZATION_H
{ "SystemGroupAuthKey", &SystemGroupAuthKey, CUPSD_VARTYPE_STRING },
#endif /* HAVE_AUTHORIZATION_H */
{ "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME },
- { "Timeout", &Timeout, CUPSD_VARTYPE_INTEGER },
- { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN },
+ { "Timeout", &Timeout, CUPSD_VARTYPE_TIME },
{ "WebInterface", &WebInterface, CUPSD_VARTYPE_BOOLEAN }
};
#define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
@@ -394,6 +385,118 @@ cupsdCheckPermissions(
/*
+ * 'cupsdDefaultAuthType()' - Get the default AuthType.
+ *
+ * When the default_auth_type is "auto", this function tries to get the GSS
+ * credentials for the server. If that succeeds we use Kerberos authentication,
+ * otherwise we do a fallback to Basic authentication against the local user
+ * accounts.
+ */
+
+int /* O - Default AuthType value */
+cupsdDefaultAuthType(void)
+{
+#ifdef HAVE_GSSAPI
+ OM_uint32 major_status, /* Major status code */
+ minor_status; /* Minor status code */
+ gss_name_t server_name; /* Server name */
+ gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
+ /* Service name token */
+ char buf[1024]; /* Service name buffer */
+#endif /* HAVE_GSSAPI */
+
+
+ /*
+ * If we have already determined the correct default AuthType, use it...
+ */
+
+ if (default_auth_type != CUPSD_AUTH_AUTO)
+ return (default_auth_type);
+
+#ifdef HAVE_GSSAPI
+# ifdef __APPLE__
+ /*
+ * If the weak-linked GSSAPI/Kerberos library is not present, don't try
+ * to use it...
+ */
+
+ if (gss_init_sec_context == NULL)
+ return (default_auth_type = CUPSD_AUTH_BASIC);
+# endif /* __APPLE__ */
+
+ /*
+ * Try to obtain the server's GSS credentials (GSSServiceName@servername). If
+ * that fails we must use Basic...
+ */
+
+ snprintf(buf, sizeof(buf), "%s@%s", GSSServiceName, ServerName);
+
+ token.value = buf;
+ token.length = strlen(buf);
+ server_name = GSS_C_NO_NAME;
+ major_status = gss_import_name(&minor_status, &token,
+ GSS_C_NT_HOSTBASED_SERVICE,
+ &server_name);
+
+ memset(&token, 0, sizeof(token));
+
+ if (GSS_ERROR(major_status))
+ {
+ cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
+ "cupsdDefaultAuthType: gss_import_name(%s) failed", buf);
+ return (default_auth_type = CUPSD_AUTH_BASIC);
+ }
+
+ major_status = gss_display_name(&minor_status, server_name, &token, NULL);
+
+ if (GSS_ERROR(major_status))
+ {
+ cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
+ "cupsdDefaultAuthType: gss_display_name(%s) failed",
+ buf);
+ return (default_auth_type = CUPSD_AUTH_BASIC);
+ }
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdDefaultAuthType: Attempting to acquire Kerberos "
+ "credentials for %s...", (char *)token.value);
+
+ ServerCreds = GSS_C_NO_CREDENTIAL;
+ major_status = gss_acquire_cred(&minor_status, server_name, GSS_C_INDEFINITE,
+ GSS_C_NO_OID_SET, GSS_C_ACCEPT,
+ &ServerCreds, NULL, NULL);
+ if (GSS_ERROR(major_status))
+ {
+ cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
+ "cupsdDefaultAuthType: gss_acquire_cred(%s) failed",
+ (char *)token.value);
+ gss_release_name(&minor_status, &server_name);
+ gss_release_buffer(&minor_status, &token);
+ return (default_auth_type = CUPSD_AUTH_BASIC);
+ }
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdDefaultAuthType: Kerberos credentials acquired "
+ "successfully for %s.", (char *)token.value);
+
+ gss_release_name(&minor_status, &server_name);
+ gss_release_buffer(&minor_status, &token);
+
+ HaveServerCreds = 1;
+
+ return (default_auth_type = CUPSD_AUTH_NEGOTIATE);
+
+#else
+ /*
+ * No Kerberos support compiled in so just use Basic all the time...
+ */
+
+ return (default_auth_type = CUPSD_AUTH_BASIC);
+#endif /* HAVE_GSSAPI */
+}
+
+
+/*
* 'cupsdFreeAliases()' - Free all of the alias entries.
*/
@@ -451,31 +554,6 @@ cupsdReadConfiguration(void)
cupsdDeleteAllLocations();
- if (NumBrowsers > 0)
- {
- free(Browsers);
- Browsers = NULL;
-
- NumBrowsers = 0;
- }
-
- if (NumPolled > 0)
- {
- free(Polled);
-
- NumPolled = 0;
- }
-
- if (NumRelays > 0)
- {
- for (i = 0; i < NumRelays; i ++)
- cupsArrayDelete(Relays[i].from);
-
- free(Relays);
-
- NumRelays = 0;
- }
-
cupsdDeleteAllListeners();
old_remote_port = RemotePort;
@@ -548,6 +626,21 @@ cupsdReadConfiguration(void)
cupsdSetString(&TempDir, NULL);
+#ifdef HAVE_GSSAPI
+ cupsdSetString(&GSSServiceName, CUPS_DEFAULT_GSSSERVICENAME);
+
+ if (HaveServerCreds)
+ {
+ OM_uint32 minor_status; /* Minor status code */
+
+ gss_release_cred(&minor_status, &ServerCreds);
+
+ HaveServerCreds = 0;
+ }
+
+ ServerCreds = GSS_C_NO_CREDENTIAL;
+#endif /* HAVE_GSSAPI */
+
/*
* Find the default user...
*/
@@ -604,7 +697,7 @@ cupsdReadConfiguration(void)
AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM;
FatalErrors = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS);
- DefaultAuthType = CUPSD_AUTH_BASIC;
+ default_auth_type = CUPSD_AUTH_BASIC;
#ifdef HAVE_SSL
DefaultEncryption = HTTP_ENCRYPT_REQUIRED;
SSLOptions = CUPSD_SSL_NONE;
@@ -618,9 +711,6 @@ cupsdReadConfiguration(void)
FilterLimit = 0;
FilterNice = 0;
HostNameLookups = FALSE;
- ImplicitClasses = CUPS_DEFAULT_IMPLICIT_CLASSES;
- ImplicitAnyClasses = FALSE;
- HideImplicitMembers = TRUE;
KeepAlive = TRUE;
KeepAliveTimeout = DEFAULT_KEEPALIVE;
ListenBackLog = SOMAXCONN;
@@ -633,51 +723,36 @@ cupsdReadConfiguration(void)
MaxLogSize = 1024 * 1024;
MaxRequestSize = 0;
MultipleOperationTimeout = DEFAULT_TIMEOUT;
+ NumSystemGroups = 0;
ReloadTimeout = DEFAULT_KEEPALIVE;
RootCertDuration = 300;
+ StrictConformance = FALSE;
Timeout = DEFAULT_TIMEOUT;
- NumSystemGroups = 0;
WebInterface = CUPS_DEFAULT_WEBIF;
- BrowseInterval = DEFAULT_INTERVAL;
- BrowsePort = ippPort();
BrowseLocalProtocols = parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS);
- BrowseRemoteProtocols = parse_protocols(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS);
- BrowseShortNames = CUPS_DEFAULT_BROWSE_SHORT_NAMES;
- BrowseTimeout = DEFAULT_TIMEOUT;
BrowseWebIF = FALSE;
Browsing = CUPS_DEFAULT_BROWSING;
DefaultShared = CUPS_DEFAULT_DEFAULT_SHARED;
#ifdef HAVE_DNSSD
- cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups");
+ cupsdSetString(&DNSSDSubTypes, "_cups,_print");
#endif /* HAVE_DNSSD */
cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
- cupsdClearString(&BrowseLocalOptions);
- cupsdClearString(&BrowseRemoteOptions);
-
cupsdSetString(&ErrorPolicy, "stop-printer");
-#ifdef HAVE_LDAP
- cupsdClearString(&BrowseLDAPBindDN);
- cupsdClearString(&BrowseLDAPDN);
- cupsdClearString(&BrowseLDAPPassword);
- cupsdClearString(&BrowseLDAPServer);
-# ifdef HAVE_LDAP_SSL
- cupsdClearString(&BrowseLDAPCACertFile);
-# endif /* HAVE_LDAP_SSL */
-#endif /* HAVE_LDAP */
-
JobHistory = DEFAULT_HISTORY;
JobFiles = DEFAULT_FILES;
JobAutoPurge = 0;
+ MaxHoldTime = 0;
MaxJobs = 500;
MaxActiveJobs = 0;
MaxJobsPerUser = 0;
MaxJobsPerPrinter = 0;
+ MaxJobTime = 3 * 60 * 60; /* 3 hours */
MaxCopies = CUPS_DEFAULT_MAX_COPIES;
cupsdDeleteAllPolicies();
@@ -695,7 +770,7 @@ cupsdReadConfiguration(void)
MaxLeaseDuration = 0;
#ifdef HAVE_LAUNCHD
- LaunchdTimeout = DEFAULT_TIMEOUT + 10;
+ LaunchdTimeout = 10;
#endif /* HAVE_LAUNCHD */
/*
@@ -833,12 +908,6 @@ cupsdReadConfiguration(void)
}
/*
- * Get the access control list for browsing...
- */
-
- BrowseACL = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL");
-
- /*
* Open the system log for cupsd if necessary...
*/
@@ -1156,24 +1225,6 @@ cupsdReadConfiguration(void)
MaxClientsPerHost);
/*
- * Make sure that BrowseTimeout is at least twice the interval...
- */
-
- if (BrowseTimeout < (2 * BrowseInterval) || BrowseTimeout <= 0)
- {
- cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid BrowseTimeout value %d.",
- BrowseTimeout);
-
- if (BrowseInterval)
- BrowseTimeout = BrowseInterval * 2;
- else
- BrowseTimeout = DEFAULT_TIMEOUT;
-
- cupsdLogMessage(CUPSD_LOG_ALERT, "Reset BrowseTimeout to %d.",
- BrowseTimeout);
- }
-
- /*
* Update the default policy, as needed...
*/
@@ -1477,7 +1528,6 @@ cupsdReadConfiguration(void)
cupsdLoadAllPrinters();
cupsdLoadAllClasses();
- cupsdLoadRemoteCache();
cupsdCreateCommonData();
@@ -1511,6 +1561,12 @@ cupsdReadConfiguration(void)
cupsdCreateCommonData();
/*
+ * Update all jobs as needed...
+ */
+
+ cupsdUpdateJobs();
+
+ /*
* Update all printers as needed...
*/
@@ -2474,20 +2530,10 @@ parse_protocols(const char *s) /* I - Space-delimited protocols */
* Add the protocol to the bitmask...
*/
- if (!_cups_strcasecmp(valstart, "cups"))
- protocols |= BROWSE_CUPS;
- else if (!_cups_strcasecmp(valstart, "slp"))
- protocols |= BROWSE_SLP;
- else if (!_cups_strcasecmp(valstart, "ldap"))
- protocols |= BROWSE_LDAP;
- else if (!_cups_strcasecmp(valstart, "dnssd") ||
- !_cups_strcasecmp(valstart, "dns-sd") ||
- !_cups_strcasecmp(valstart, "bonjour"))
+ if (!_cups_strcasecmp(valstart, "dnssd") ||
+ !_cups_strcasecmp(valstart, "dns-sd") ||
+ !_cups_strcasecmp(valstart, "bonjour"))
protocols |= BROWSE_DNSSD;
- else if (!_cups_strcasecmp(valstart, "lpd"))
- protocols |= BROWSE_LPD;
- else if (!_cups_strcasecmp(valstart, "smb"))
- protocols |= BROWSE_SMB;
else if (!_cups_strcasecmp(valstart, "all"))
protocols |= BROWSE_ALL;
else if (_cups_strcasecmp(valstart, "none"))
@@ -2516,18 +2562,12 @@ read_configuration(cups_file_t *fp) /* I - File to read from */
/* Line from file */
temp[HTTP_MAX_BUFFER],
/* Temporary buffer for value */
- *ptr, /* Pointer into line/temp */
*value, /* Pointer to value */
*valueptr; /* Pointer into value */
int valuelen; /* Length of value */
cupsd_var_t const *var; /* Current variable */
http_addrlist_t *addrlist, /* Address list */
*addr; /* Current address */
- unsigned ip[4], /* Address value */
- mask[4]; /* Netmask value */
- cupsd_dirsvc_relay_t *relay; /* Relay data */
- cupsd_dirsvc_poll_t *pollp; /* Polling data */
- cupsd_location_t *location; /* Browse location */
cups_file_t *incfile; /* Include file */
char incname[1024]; /* Include filename */
struct group *group; /* Group */
@@ -2711,117 +2751,12 @@ read_configuration(cups_file_t *fp) /* I - File to read from */
httpAddrFreeList(addrlist);
}
- else if (!_cups_strcasecmp(line, "BrowseAddress") && value)
- {
- /*
- * Add a browse address to the list...
- */
-
- cupsd_dirsvc_addr_t *dira; /* New browse address array */
-
-
- if (NumBrowsers == 0)
- dira = malloc(sizeof(cupsd_dirsvc_addr_t));
- else
- dira = realloc(Browsers, (NumBrowsers + 1) * sizeof(cupsd_dirsvc_addr_t));
-
- if (!dira)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate BrowseAddress at line %d - %s.",
- linenum, strerror(errno));
- continue;
- }
-
- Browsers = dira;
- dira += NumBrowsers;
-
- memset(dira, 0, sizeof(cupsd_dirsvc_addr_t));
-
- if (!_cups_strcasecmp(value, "@LOCAL"))
- {
- /*
- * Send browse data to all local interfaces...
- */
-
- strcpy(dira->iface, "*");
- NumBrowsers ++;
- }
- else if (!_cups_strncasecmp(value, "@IF(", 4))
- {
- /*
- * Send browse data to the named interface...
- */
-
- strlcpy(dira->iface, value + 4, sizeof(Browsers[0].iface));
-
- ptr = dira->iface + strlen(dira->iface) - 1;
- if (*ptr == ')')
- *ptr = '\0';
-
- NumBrowsers ++;
- }
- else if ((addrlist = get_address(value, BrowsePort)) != NULL)
- {
- /*
- * Only IPv4 addresses are supported...
- */
-
- for (addr = addrlist; addr; addr = addr->next)
- if (_httpAddrFamily(&(addr->addr)) == AF_INET)
- break;
-
- if (addr)
- {
- memcpy(&(dira->to), &(addrlist->addr), sizeof(dira->to));
- httpAddrString(&(dira->to), temp, sizeof(temp));
-
- cupsdLogMessage(CUPSD_LOG_INFO,
- "Sending browsing info to %s:%d (IPv4)",
- temp, _httpAddrPort(&(dira->to)));
-
- NumBrowsers ++;
- }
- else
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
- value, linenum);
-
- httpAddrFreeList(addrlist);
- }
- else
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
- value, linenum);
- }
- else if (!_cups_strcasecmp(line, "BrowseOrder") && value)
- {
- /*
- * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
- */
-
- if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL)
- if ((location = cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL)
- cupsdAddLocation(location);
-
- if (location == NULL)
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to initialize browse access control list.");
- else if (!_cups_strncasecmp(value, "deny", 4))
- location->order_type = CUPSD_AUTH_ALLOW;
- else if (!_cups_strncasecmp(value, "allow", 5))
- location->order_type = CUPSD_AUTH_DENY;
- else
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown BrowseOrder value %s on line %d.",
- value, linenum);
- }
else if (!_cups_strcasecmp(line, "BrowseProtocols") ||
- !_cups_strcasecmp(line, "BrowseLocalProtocols") ||
- !_cups_strcasecmp(line, "BrowseRemoteProtocols"))
+ !_cups_strcasecmp(line, "BrowseLocalProtocols"))
{
/*
* "BrowseProtocols name [... name]"
* "BrowseLocalProtocols name [... name]"
- * "BrowseRemoteProtocols name [... name]"
*/
int protocols = parse_protocols(value);
@@ -2834,386 +2769,28 @@ read_configuration(cups_file_t *fp) /* I - File to read from */
break;
}
- if (_cups_strcasecmp(line, "BrowseLocalProtocols"))
- BrowseRemoteProtocols = protocols;
- if (_cups_strcasecmp(line, "BrowseRemoteProtocols"))
- BrowseLocalProtocols = protocols;
+ BrowseLocalProtocols = protocols;
}
- else if ((!_cups_strcasecmp(line, "BrowseAllow") ||
- !_cups_strcasecmp(line, "BrowseDeny")) && value)
+ else if (!_cups_strcasecmp(line, "default_auth_type") && value)
{
/*
- * BrowseAllow [From] host/ip...
- * BrowseDeny [From] host/ip...
- */
-
- if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL)
- if ((location = cupsdNewLocation("CUPS_INTERNAL_BROWSE_ACL")) != NULL)
- cupsdAddLocation(location);
-
-
- if (location == NULL)
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to initialize browse access control list.");
- else
- {
- if (!_cups_strncasecmp(value, "from", 4))
- {
- /*
- * Skip leading "from"...
- */
-
- value += 4;
- }
-
- while (*value)
- {
- /*
- * Skip leading whitespace...
- */
-
- while (_cups_isspace(*value))
- value ++;
-
- if (!*value)
- break;
-
- /*
- * Find the end of the value...
- */
-
- for (valueptr = value;
- *valueptr && !_cups_isspace(*valueptr);
- valueptr ++);
-
- while (_cups_isspace(*valueptr))
- *valueptr++ = '\0';
-
- /*
- * Figure out what form the allow/deny address takes:
- *
- * All
- * None
- * *.domain.com
- * .domain.com
- * host.domain.com
- * nnn.*
- * nnn.nnn.*
- * nnn.nnn.nnn.*
- * nnn.nnn.nnn.nnn
- * nnn.nnn.nnn.nnn/mm
- * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
- */
-
- if (!_cups_strcasecmp(value, "all"))
- {
- /*
- * All hosts...
- */
-
- if (!_cups_strcasecmp(line, "BrowseAllow"))
- cupsdAddIPMask(&(location->allow), zeros, zeros);
- else
- cupsdAddIPMask(&(location->deny), zeros, zeros);
- }
- else if (!_cups_strcasecmp(value, "none"))
- {
- /*
- * No hosts...
- */
-
- if (!_cups_strcasecmp(line, "BrowseAllow"))
- cupsdAddIPMask(&(location->allow), ones, zeros);
- else
- cupsdAddIPMask(&(location->deny), ones, zeros);
- }
-#ifdef AF_INET6
- else if (value[0] == '*' || value[0] == '.' ||
- (!isdigit(value[0] & 255) && value[0] != '['))
-#else
- else if (value[0] == '*' || value[0] == '.' ||
- !isdigit(value[0] & 255))
-#endif /* AF_INET6 */
- {
- /*
- * Host or domain name...
- */
-
- if (!_cups_strcasecmp(line, "BrowseAllow"))
- cupsdAddNameMask(&(location->allow), value);
- else
- cupsdAddNameMask(&(location->deny), value);
- }
- else
- {
- /*
- * One of many IP address forms...
- */
-
- if (!get_addr_and_mask(value, ip, mask))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
- value, linenum);
- break;
- }
-
- if (!_cups_strcasecmp(line, "BrowseAllow"))
- cupsdAddIPMask(&(location->allow), ip, mask);
- else
- cupsdAddIPMask(&(location->deny), ip, mask);
- }
-
- /*
- * Advance to next value...
- */
-
- value = valueptr;
- }
- }
- }
- else if (!_cups_strcasecmp(line, "BrowseRelay") && value)
- {
- /*
- * BrowseRelay [from] source [to] destination
- */
-
- if (NumRelays == 0)
- relay = malloc(sizeof(cupsd_dirsvc_relay_t));
- else
- relay = realloc(Relays, (NumRelays + 1) * sizeof(cupsd_dirsvc_relay_t));
-
- if (!relay)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate BrowseRelay at line %d - %s.",
- linenum, strerror(errno));
- continue;
- }
-
- Relays = relay;
- relay += NumRelays;
-
- memset(relay, 0, sizeof(cupsd_dirsvc_relay_t));
-
- if (!_cups_strncasecmp(value, "from ", 5))
- {
- /*
- * Skip leading "from"...
- */
-
- value += 5;
-
- /*
- * Skip leading whitespace...
- */
-
- while (_cups_isspace(*value))
- value ++;
- }
-
- /*
- * Find the end of the from value...
- */
-
- for (valueptr = value;
- *valueptr && !_cups_isspace(*valueptr);
- valueptr ++);
-
- while (_cups_isspace(*valueptr))
- *valueptr++ = '\0';
-
- /*
- * Figure out what form the from address takes:
- *
- * *.domain.com
- * .domain.com
- * host.domain.com
- * nnn.*
- * nnn.nnn.*
- * nnn.nnn.nnn.*
- * nnn.nnn.nnn.nnn
- * nnn.nnn.nnn.nnn/mm
- * nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
- */
-
-#ifdef AF_INET6
- if (value[0] == '*' || value[0] == '.' ||
- (!isdigit(value[0] & 255) && value[0] != '['))
-#else
- if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255))
-#endif /* AF_INET6 */
- {
- /*
- * Host or domain name...
- */
-
- if (!cupsdAddNameMask(&(relay->from), value))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate BrowseRelay name at line %d - %s.",
- linenum, strerror(errno));
- continue;
- }
- }
- else
- {
- /*
- * One of many IP address forms...
- */
-
- if (!get_addr_and_mask(value, ip, mask))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
- value, linenum);
- break;
- }
-
- if (!cupsdAddIPMask(&(relay->from), ip, mask))
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate BrowseRelay IP at line %d - %s.",
- linenum, strerror(errno));
- continue;
- }
- }
-
- /*
- * Get "to" address and port...
- */
-
- if (!_cups_strncasecmp(valueptr, "to ", 3))
- {
- /*
- * Strip leading "to"...
- */
-
- valueptr += 3;
-
- while (_cups_isspace(*valueptr))
- valueptr ++;
- }
-
- if ((addrlist = get_address(valueptr, BrowsePort)) != NULL)
- {
- /*
- * Only IPv4 addresses are supported...
- */
-
- for (addr = addrlist; addr; addr = addr->next)
- if (addr->addr.addr.sa_family == AF_INET)
- break;
-
- if (addr)
- {
- memcpy(&(relay->to), &(addrlist->addr), sizeof(relay->to));
-
- httpAddrString(&(relay->to), temp, sizeof(temp));
-
- cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
- value, temp, _httpAddrPort(&(relay->to)));
-
- NumRelays ++;
- }
- else
- {
- cupsArrayDelete(relay->from);
- relay->from = NULL;
-
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
- valueptr, linenum);
- }
-
- httpAddrFreeList(addrlist);
- }
- else
- {
- cupsArrayDelete(relay->from);
- relay->from = NULL;
-
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
- valueptr, linenum);
- }
- }
- else if (!_cups_strcasecmp(line, "BrowsePoll") && value)
- {
- /*
- * BrowsePoll address[:port]
- */
-
- char *portname; /* Port name */
- int portnum; /* Port number */
- struct servent *service; /* Service */
-
-
- /*
- * Extract the port name from the address...
- */
-
- if ((portname = strrchr(value, ':')) != NULL && !strchr(portname, ']'))
- {
- *portname++ = '\0';
-
- if (isdigit(*portname & 255))
- portnum = atoi(portname);
- else if ((service = getservbyname(portname, NULL)) != NULL)
- portnum = ntohs(service->s_port);
- else
- {
- cupsdLogMessage(CUPSD_LOG_ERROR, "Lookup of service \"%s\" failed.",
- portname);
- continue;
- }
- }
- else
- portnum = ippPort();
-
- /*
- * Add the poll entry...
- */
-
- if (NumPolled == 0)
- pollp = malloc(sizeof(cupsd_dirsvc_poll_t));
- else
- pollp = realloc(Polled, (NumPolled + 1) * sizeof(cupsd_dirsvc_poll_t));
-
- if (!pollp)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate BrowsePoll at line %d - %s.",
- linenum, strerror(errno));
- continue;
- }
-
- Polled = pollp;
- pollp += NumPolled;
-
- NumPolled ++;
- memset(pollp, 0, sizeof(cupsd_dirsvc_poll_t));
-
- strlcpy(pollp->hostname, value, sizeof(pollp->hostname));
- pollp->port = portnum;
-
- cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
- pollp->port);
- }
- else if (!_cups_strcasecmp(line, "DefaultAuthType") && value)
- {
- /*
- * DefaultAuthType {basic,digest,basicdigest,negotiate}
+ * default_auth_type {basic,digest,basicdigest,negotiate}
*/
if (!_cups_strcasecmp(value, "none"))
- DefaultAuthType = CUPSD_AUTH_NONE;
+ default_auth_type = CUPSD_AUTH_NONE;
else if (!_cups_strcasecmp(value, "basic"))
- DefaultAuthType = CUPSD_AUTH_BASIC;
+ default_auth_type = CUPSD_AUTH_BASIC;
else if (!_cups_strcasecmp(value, "digest"))
- DefaultAuthType = CUPSD_AUTH_DIGEST;
+ default_auth_type = CUPSD_AUTH_DIGEST;
else if (!_cups_strcasecmp(value, "basicdigest"))
- DefaultAuthType = CUPSD_AUTH_BASICDIGEST;
+ default_auth_type = CUPSD_AUTH_BASICDIGEST;
#ifdef HAVE_GSSAPI
else if (!_cups_strcasecmp(value, "negotiate"))
- DefaultAuthType = CUPSD_AUTH_NEGOTIATE;
+ default_auth_type = CUPSD_AUTH_NEGOTIATE;
#endif /* HAVE_GSSAPI */
+ else if (!_cups_strcasecmp(value, "auto"))
+ default_auth_type = CUPSD_AUTH_AUTO;
else
{
cupsdLogMessage(CUPSD_LOG_WARN,
@@ -3572,12 +3149,15 @@ read_configuration(cups_file_t *fp) /* I - File to read from */
cupsdLogMessage(CUPSD_LOG_ERROR,
"Missing integer value for %s on line %d.",
line, linenum);
+ else if (!isdigit(*value & 255))
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad integer value for %s on line %d.",
+ line, linenum);
else
{
int n; /* Number */
char *units; /* Units */
-
n = strtol(value, &units, 0);
if (units && *units)
@@ -3590,6 +3170,13 @@ read_configuration(cups_file_t *fp) /* I - File to read from */
n *= 1024;
else if (tolower(units[0] & 255) == 't')
n *= 262144;
+ else
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown integer value for %s on line %d.",
+ line, linenum);
+ break;
+ }
}
if (n < 0)
@@ -3601,6 +3188,61 @@ read_configuration(cups_file_t *fp) /* I - File to read from */
}
break;
+ case CUPSD_VARTYPE_TIME :
+ if (!value)
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Missing time interval value for %s on line %d.",
+ line, linenum);
+ else if (!_cups_strncasecmp(line, "PreserveJob", 11) &&
+ (!_cups_strcasecmp(value, "true") ||
+ !_cups_strcasecmp(value, "on") ||
+ !_cups_strcasecmp(value, "enabled") ||
+ !_cups_strcasecmp(value, "yes")))
+ *((int *)var->ptr) = INT_MAX;
+ else if (!_cups_strcasecmp(value, "false") ||
+ !_cups_strcasecmp(value, "off") ||
+ !_cups_strcasecmp(value, "disabled") ||
+ !_cups_strcasecmp(value, "no"))
+ *((int *)var->ptr) = 0;
+ else if (!isdigit(*value & 255))
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown time interval value for %s on line %d.",
+ line, linenum);
+ else
+ {
+ double n; /* Number */
+ char *units; /* Units */
+
+ n = strtod(value, &units);
+
+ if (units && *units)
+ {
+ if (tolower(units[0] & 255) == 'w')
+ n *= 7 * 24 * 60 * 60;
+ else if (tolower(units[0] & 255) == 'd')
+ n *= 24 * 60 * 60;
+ else if (tolower(units[0] & 255) == 'h')
+ n *= 60 * 60;
+ else if (tolower(units[0] & 255) == 'm')
+ n *= 60;
+ else
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown time interval value for %s on line "
+ "%d.", line, linenum);
+ break;
+ }
+ }
+
+ if (n < 0.0 || n > INT_MAX)
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad time value for %s on line %d.",
+ line, linenum);
+ else
+ *((int *)var->ptr) = (int)n;
+ }
+ break;
+
case CUPSD_VARTYPE_BOOLEAN :
if (!value)
cupsdLogMessage(CUPSD_LOG_ERROR,
@@ -3970,6 +3612,7 @@ read_policy(cups_file_t *fp, /* I - Configuration file */
cupsdAddString(&(pol->job_attrs), "job-name");
cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
cupsdAddString(&(pol->job_attrs), "job-originating-user-name");
+ cupsdAddString(&(pol->job_attrs), "phone");
}
else
cupsdAddString(&(pol->job_attrs), value);
@@ -4194,6 +3837,7 @@ set_policy_defaults(cupsd_policy_t *pol)/* I - Policy */
cupsdAddString(&(pol->job_attrs), "job-name");
cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
cupsdAddString(&(pol->job_attrs), "job-originating-user-name");
+ cupsdAddString(&(pol->job_attrs), "phone");
}
if (!pol->sub_access)
@@ -4220,5 +3864,5 @@ set_policy_defaults(cupsd_policy_t *pol)/* I - Policy */
/*
- * End of "$Id: conf.c 10121 2011-11-16 15:28:11Z mike $".
+ * End of "$Id: conf.c 10482 2012-05-18 19:51:02Z mike $".
*/