*
* Configuration routines for the CUPS scheduler.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* cupsdReadConfiguration() - Read the cupsd.conf file.
* get_address() - Get an address + port number from a line.
* get_addr_and_mask() - Get an IP address and netmask.
+ * mime_error_cb() - Log a MIME error.
* parse_aaa() - Parse authentication, authorization, and access
* control lines.
* parse_fatal_errors() - Parse FatalErrors values in a string.
{
{ "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING },
{ "AutoPurgeJobs", &JobAutoPurge, CUPSD_VARTYPE_BOOLEAN },
+#ifdef HAVE_DNSSD
+ { "BrowseDNSSDRegType", &DNSSDRegType, CUPSD_VARTYPE_STRING },
+#endif /* HAVE_DNSSD */
{ "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER },
#ifdef HAVE_LDAP
{ "BrowseLDAPBindDN", &BrowseLDAPBindDN, CUPSD_VARTYPE_STRING },
{ "MaxJobsPerUser", &MaxJobsPerUser, CUPSD_VARTYPE_INTEGER },
{ "MaxLeaseDuration", &MaxLeaseDuration, CUPSD_VARTYPE_INTEGER },
{ "MaxLogSize", &MaxLogSize, CUPSD_VARTYPE_INTEGER },
- { "MaxPrinterHistory", &MaxPrinterHistory, CUPSD_VARTYPE_INTEGER },
{ "MaxRequestSize", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
{ "MaxSubscriptions", &MaxSubscriptions, CUPSD_VARTYPE_INTEGER },
{ "MaxSubscriptionsPerJob", &MaxSubscriptionsPerJob, CUPSD_VARTYPE_INTEGER },
#endif /* HAVE_AUTHORIZATION_H */
{ "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME },
{ "Timeout", &Timeout, CUPSD_VARTYPE_INTEGER },
- { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN }
+ { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN },
+ { "WebInterface", &WebInterface, CUPSD_VARTYPE_BOOLEAN }
};
#define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
static http_addrlist_t *get_address(const char *value, int defport);
static int get_addr_and_mask(const char *value, unsigned *ip,
unsigned *mask);
+static void mime_error_cb(void *ctx, const char *message);
static int parse_aaa(cupsd_location_t *loc, char *line,
char *value, int linenum);
static int parse_fatal_errors(const char *s);
if (!dir_created && !is_dir && !S_ISREG(fileinfo.st_mode))
{
- cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a regular file!", filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a regular file.", filename);
return (-1);
}
if (!dir_created && is_dir && !S_ISDIR(fileinfo.st_mode))
{
if (create_dir >= 0)
- cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a directory!", filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "\"%s\" is not a directory.", filename);
else
- syslog(LOG_ERR, "\"%s\" is not a directory!", filename);
+ syslog(LOG_ERR, "\"%s\" is not a directory.", filename);
return (-1);
}
cupsdSetString(&DataDir, CUPS_DATADIR);
cupsdSetString(&DocumentRoot, CUPS_DOCROOT);
cupsdSetString(&AccessLog, CUPS_LOGDIR "/access_log");
- cupsdSetString(&ErrorLog, CUPS_LOGDIR "/error_log");
+ cupsdClearString(&ErrorLog);
cupsdSetString(&PageLog, CUPS_LOGDIR "/page_log");
cupsdSetString(&PageLogFormat,
- "%p %j %u %T %P %C %{job-billing} "
+ "%p %u %j %T %P %C %{job-billing} "
"%{job-originating-host-name} %{job-name} %{media} %{sides}");
cupsdSetString(&Printcap, CUPS_DEFAULT_PRINTCAP);
cupsdSetString(&PrintcapGUI, "/usr/bin/glpoptions");
cupsdSetString(&FontPath, CUPS_FONTPATH);
cupsdSetString(&RemoteRoot, "remroot");
- cupsdSetString(&ServerHeader, "CUPS/1.4");
+ cupsdSetStringf(&ServerHeader, "CUPS/%d.%d", CUPS_VERSION_MAJOR,
+ CUPS_VERSION_MINOR);
cupsdSetString(&StateDir, CUPS_STATEDIR);
if (!strcmp(CUPS_DEFAULT_PRINTCAP, "/etc/printers.conf"))
cupsdClearString(&DefaultPaperSize);
- cupsdSetString(&RIPCache, "8m");
+ cupsdSetString(&RIPCache, "128m");
cupsdSetString(&TempDir, NULL);
MaxClients = 100;
MaxClientsPerHost = 0;
MaxLogSize = 1024 * 1024;
- MaxPrinterHistory = 0;
MaxRequestSize = 0;
MultipleOperationTimeout = DEFAULT_TIMEOUT;
ReloadTimeout = DEFAULT_KEEPALIVE;
RootCertDuration = 300;
Timeout = DEFAULT_TIMEOUT;
NumSystemGroups = 0;
+ WebInterface = CUPS_DEFAULT_WEBIF;
BrowseInterval = DEFAULT_INTERVAL;
BrowsePort = ippPort();
Browsing = CUPS_DEFAULT_BROWSING;
DefaultShared = CUPS_DEFAULT_DEFAULT_SHARED;
+#ifdef HAVE_DNSSD
+ cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups");
+#endif /* HAVE_DNSSD */
+
cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
LaunchdTimeout = DEFAULT_TIMEOUT + 10;
#endif /* HAVE_LAUNCHD */
+ /*
+ * Setup environment variables...
+ */
+
+ cupsdInitEnv();
+
/*
* Read the configuration file...
*/
if (!status)
return (0);
+ if (!ErrorLog)
+ cupsdSetString(&ErrorLog, CUPS_LOGDIR "/error_log");
+
RunUser = getuid();
cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
if ((host = gethostbyname(temp)) != NULL)
{
- if (strcasecmp(temp, host->h_name))
+ if (_cups_strcasecmp(temp, host->h_name))
{
cupsdSetString(&ServerName, host->h_name);
cupsdAddAlias(ServerAlias, host->h_name);
if (host->h_aliases)
{
for (i = 0; host->h_aliases[i]; i ++)
- if (strcasecmp(temp, host->h_aliases[i]))
+ if (_cups_strcasecmp(temp, host->h_aliases[i]))
{
cupsdAddAlias(ServerAlias, host->h_aliases[i]);
cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
openlog("cupsd", LOG_PID | LOG_NOWAIT | LOG_NDELAY, LOG_LPR);
#endif /* HAVE_VSYSLOG */
+ /*
+ * Make sure each of the log files exists and gets rotated as necessary...
+ */
+
+ if (strcmp(AccessLog, "syslog"))
+ cupsdCheckLogFile(&AccessFile, AccessLog);
+
+ if (strcmp(ErrorLog, "syslog"))
+ cupsdCheckLogFile(&ErrorFile, ErrorLog);
+
+ if (strcmp(PageLog, "syslog"))
+ cupsdCheckLogFile(&PageFile, PageLog);
+
/*
* Log the configuration file that was used...
*/
*/
cupsdLogMessage(CUPSD_LOG_NOTICE,
- "Group and SystemGroup cannot use the same groups!");
+ "Group and SystemGroup cannot use the same groups.");
cupsdLogMessage(CUPSD_LOG_INFO, "Resetting Group to \"nobody\"...");
group = getgrnam("nobody");
cupsdLogMessage(CUPSD_LOG_EMERG,
"No valid Listen or Port lines were found in the "
- "configuration file!");
+ "configuration file.");
/*
* Commit suicide...
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to access TMPDIR (%s): %s",
tmpdir, strerror(errno));
else if (!S_ISDIR(tmpinfo.st_mode))
- cupsdLogMessage(CUPSD_LOG_ERROR, "TMPDIR (%s) is not a directory!",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "TMPDIR (%s) is not a directory.",
tmpdir);
else if ((tmpinfo.st_uid != User || !(tmpinfo.st_mode & S_IWUSR)) &&
(tmpinfo.st_gid != Group || !(tmpinfo.st_mode & S_IWGRP)) &&
!(tmpinfo.st_mode & S_IWOTH))
cupsdLogMessage(CUPSD_LOG_ERROR,
- "TMPDIR (%s) has the wrong permissions!", tmpdir);
+ "TMPDIR (%s) has the wrong permissions.", tmpdir);
else
cupsdSetString(&TempDir, tmpdir);
}
}
/*
- * Setup environment variables...
+ * Update environment variables...
*/
- cupsdInitEnv();
+ cupsdUpdateEnv();
/*
* Update default paper size setting as needed...
else
#endif /* HAVE_LIBPAPER */
if (!DefaultLanguage ||
- !strcasecmp(DefaultLanguage, "C") ||
- !strcasecmp(DefaultLanguage, "POSIX") ||
- !strcasecmp(DefaultLanguage, "en") ||
- !strncasecmp(DefaultLanguage, "en.", 3) ||
- !strncasecmp(DefaultLanguage, "en_US", 5) ||
- !strncasecmp(DefaultLanguage, "en_CA", 5) ||
- !strncasecmp(DefaultLanguage, "fr_CA", 5))
+ !_cups_strcasecmp(DefaultLanguage, "C") ||
+ !_cups_strcasecmp(DefaultLanguage, "POSIX") ||
+ !_cups_strcasecmp(DefaultLanguage, "en") ||
+ !_cups_strncasecmp(DefaultLanguage, "en.", 3) ||
+ !_cups_strncasecmp(DefaultLanguage, "en_US", 5) ||
+ !_cups_strncasecmp(DefaultLanguage, "en_CA", 5) ||
+ !_cups_strncasecmp(DefaultLanguage, "fr_CA", 5))
{
/*
* These are the only locales that will default to "letter" size...
* Update classification setting as needed...
*/
- if (Classification && !strcasecmp(Classification, "none"))
+ if (Classification && !_cups_strcasecmp(Classification, "none"))
cupsdClearString(&Classification);
if (Classification)
if (BrowseTimeout < (2 * BrowseInterval) || BrowseTimeout <= 0)
{
- cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid BrowseTimeout value %d!",
+ cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid BrowseTimeout value %d.",
BrowseTimeout);
if (BrowseInterval)
else
BrowseTimeout = DEFAULT_TIMEOUT;
- cupsdLogMessage(CUPSD_LOG_ALERT, "Reset BrowseTimeout to %d!",
+ cupsdLogMessage(CUPSD_LOG_ALERT, "Reset BrowseTimeout to %d.",
BrowseTimeout);
}
if (DefaultPolicy)
- cupsdLogMessage(CUPSD_LOG_ERROR, "Default policy \"%s\" not found!",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Default policy \"%s\" not found.",
DefaultPolicy);
cupsdSetString(&DefaultPolicy, "default");
if ((DefaultPolicyPtr = cupsdFindPolicy("default")) != NULL)
cupsdLogMessage(CUPSD_LOG_INFO,
- "Using policy \"default\" as the default!");
+ "Using policy \"default\" as the default.");
else
{
cupsdLogMessage(CUPSD_LOG_INFO,
snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
- MimeDatabase = mimeLoadTypes(NULL, mimedir);
+ MimeDatabase = mimeNew();
+ mimeSetErrorCallback(MimeDatabase, mime_error_cb, NULL);
+
+ MimeDatabase = mimeLoadTypes(MimeDatabase, mimedir);
MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
if (!MimeDatabase)
{
cupsdLogMessage(CUPSD_LOG_EMERG,
- "Unable to load MIME database from \"%s\" or \"%s\"!",
+ "Unable to load MIME database from \"%s\" or \"%s\".",
mimedir, ServerRoot);
if (FatalErrors & CUPSD_FATAL_CONFIG)
return (0);
if ((MimeTypes = calloc(NumMimeTypes, sizeof(const char *))) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate memory for %d MIME types!",
+ "Unable to allocate memory for %d MIME types.",
NumMimeTypes);
NumMimeTypes = 0;
}
if (!*value)
{
- cupsdLogMessage(CUPSD_LOG_ERROR, "Bad (empty) address!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad (empty) address.");
return (NULL);
}
*/
if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
- cupsdLogMessage(CUPSD_LOG_ERROR, "Hostname lookup for \"%s\" failed!",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Hostname lookup for \"%s\" failed.",
hostname ? hostname : "(nil)");
return (addrlist);
if (*value == '[')
{
/*
- * Parse hexadecimal IPv6 address...
+ * Parse hexadecimal IPv6/IPv4 address...
*/
family = AF_INET6;
ptr2;
ptr2 = strchr(ptr2 + 1, ':'), j ++);
- i = 7 - j;
- ptr ++;
+ i = 6 - j;
+ ptr += 2;
+ }
+ else if (isdigit(*ptr & 255) && strchr(ptr + 1, '.') && i >= 6)
+ {
+ /*
+ * Read IPv4 dotted quad...
+ */
+
+ unsigned val[4] = { 0, 0, 0, 0 };
+ /* IPv4 address values */
+
+ ipcount = sscanf(ptr, "%u.%u.%u.%u", val + 0, val + 1, val + 2,
+ val + 3);
+
+ /*
+ * Range check the IP numbers...
+ */
+
+ for (i = 0; i < ipcount; i ++)
+ if (val[i] > 255)
+ return (0);
+
+ /*
+ * Merge everything into a 32-bit IPv4 address in ip[3]...
+ */
+
+ ip[3] = (((((val[0] << 8) | val[1]) << 8) | val[2]) << 8) | val[3];
+
+ if (ipcount < 4)
+ mask[3] = (0xffffffff << (32 - 8 * ipcount)) & 0xffffffff;
+
+ /*
+ * If the leading words are all 0's then this is an IPv4 address...
+ */
+
+ if (!val[0] && !val[1] && !val[2])
+ family = AF_INET;
+
+ while (isdigit(*ptr & 255) || *ptr == '.')
+ ptr ++;
+ break;
}
else if (isxdigit(*ptr & 255))
{
ipval = strtoul(ptr, (char **)&ptr, 16);
+ if (*ptr == ':' && ptr[1] != ':')
+ ptr ++;
+
if (ipval > 0xffff)
return (0);
}
else
return (0);
-
- while (*ptr == ':')
- ptr ++;
}
if (*ptr != ']')
* Parse dotted-decimal IPv4 address...
*/
- unsigned val[4]; /* IPv4 address values */
+ unsigned val[4] = { 0, 0, 0, 0 }; /* IPv4 address values */
family = AF_INET;
if (val[i] > 255)
return (0);
- /*
- * Make sure the trailing values are zeroed, as some C libraries like
- * glibc apparently like to fill the unused arguments with garbage...
- */
-
- for (i = ipcount; i < 4; i ++)
- val[i] = 0;
-
/*
* Merge everything into a 32-bit IPv4 address in ip[3]...
*/
if (family != AF_INET)
return (0);
- if (sscanf(maskval, "%u.%u.%u.%u", mask + 0, mask + 1, mask + 2, mask + 3) != 4)
+ if (sscanf(maskval, "%u.%u.%u.%u", mask + 0, mask + 1, mask + 2,
+ mask + 3) != 4)
return (0);
mask[3] |= ((((mask[0] << 8) | mask[1]) << 8) | mask[2]) << 8;
}
+/*
+ * 'mime_error_cb()' - Log a MIME error.
+ */
+
+static void
+mime_error_cb(void *ctx, /* I - Context pointer (unused) */
+ const char *message) /* I - Message */
+{
+ (void)ctx;
+
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s", message);
+}
+
+
/*
* 'parse_aaa()' - Parse authentication, authorization, and access control lines.
*/
mask[4]; /* IP netmask components */
- if (!strcasecmp(line, "Encryption"))
+ if (!_cups_strcasecmp(line, "Encryption"))
{
/*
* "Encryption xxx" - set required encryption level...
*/
- if (!strcasecmp(value, "never"))
+ if (!_cups_strcasecmp(value, "never"))
loc->encryption = HTTP_ENCRYPT_NEVER;
- else if (!strcasecmp(value, "always"))
+ else if (!_cups_strcasecmp(value, "always"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Encryption value \"%s\" on line %d is invalid in this "
loc->encryption = HTTP_ENCRYPT_REQUIRED;
}
- else if (!strcasecmp(value, "required"))
+ else if (!_cups_strcasecmp(value, "required"))
loc->encryption = HTTP_ENCRYPT_REQUIRED;
- else if (!strcasecmp(value, "ifrequested"))
+ else if (!_cups_strcasecmp(value, "ifrequested"))
loc->encryption = HTTP_ENCRYPT_IF_REQUESTED;
else
{
return (0);
}
}
- else if (!strcasecmp(line, "Order"))
+ else if (!_cups_strcasecmp(line, "Order"))
{
/*
* "Order Deny,Allow" or "Order Allow,Deny"...
*/
- if (!strncasecmp(value, "deny", 4))
+ if (!_cups_strncasecmp(value, "deny", 4))
loc->order_type = CUPSD_AUTH_ALLOW;
- else if (!strncasecmp(value, "allow", 5))
+ else if (!_cups_strncasecmp(value, "allow", 5))
loc->order_type = CUPSD_AUTH_DENY;
else
{
return (0);
}
}
- else if (!strcasecmp(line, "Allow") || !strcasecmp(line, "Deny"))
+ else if (!_cups_strcasecmp(line, "Allow") || !_cups_strcasecmp(line, "Deny"))
{
/*
* Allow [From] host/ip...
while (*value)
{
- if (!strncasecmp(value, "from", 4))
+ if (!_cups_strncasecmp(value, "from", 4))
{
/*
* Strip leading "from"...
value += 4;
- while (isspace(*value & 255))
+ while (_cups_isspace(*value))
value ++;
if (!*value)
* Find the end of the value...
*/
- for (valptr = value; *valptr && !isspace(*valptr & 255); valptr ++);
+ for (valptr = value; *valptr && !_cups_isspace(*valptr); valptr ++);
- while (isspace(*valptr & 255))
+ while (_cups_isspace(*valptr))
*valptr++ = '\0';
/*
* nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
*/
- if (!strcasecmp(value, "all"))
+ if (!_cups_strcasecmp(value, "all"))
{
/*
* All hosts...
*/
- if (!strcasecmp(line, "Allow"))
+ if (!_cups_strcasecmp(line, "Allow"))
cupsdAddIPMask(&(loc->allow), zeros, zeros);
else
cupsdAddIPMask(&(loc->deny), zeros, zeros);
}
- else if (!strcasecmp(value, "none"))
+ else if (!_cups_strcasecmp(value, "none"))
{
/*
* No hosts...
*/
- if (!strcasecmp(line, "Allow"))
+ if (!_cups_strcasecmp(line, "Allow"))
cupsdAddIPMask(&(loc->allow), ones, zeros);
else
cupsdAddIPMask(&(loc->deny), ones, zeros);
if (value[0] == '*')
value ++;
- if (!strcasecmp(line, "Allow"))
+ if (!_cups_strcasecmp(line, "Allow"))
cupsdAddNameMask(&(loc->allow), value);
else
cupsdAddNameMask(&(loc->deny), value);
return (0);
}
- if (!strcasecmp(line, "Allow"))
+ if (!_cups_strcasecmp(line, "Allow"))
cupsdAddIPMask(&(loc->allow), ip, mask);
else
cupsdAddIPMask(&(loc->deny), ip, mask);
value = valptr;
}
}
- else if (!strcasecmp(line, "AuthType"))
+ else if (!_cups_strcasecmp(line, "AuthType"))
{
/*
* AuthType {none,basic,digest,basicdigest,negotiate,default}
*/
- if (!strcasecmp(value, "none"))
+ if (!_cups_strcasecmp(value, "none"))
{
loc->type = CUPSD_AUTH_NONE;
loc->level = CUPSD_AUTH_ANON;
}
- else if (!strcasecmp(value, "basic"))
+ else if (!_cups_strcasecmp(value, "basic"))
{
loc->type = CUPSD_AUTH_BASIC;
if (loc->level == CUPSD_AUTH_ANON)
loc->level = CUPSD_AUTH_USER;
}
- else if (!strcasecmp(value, "digest"))
+ else if (!_cups_strcasecmp(value, "digest"))
{
loc->type = CUPSD_AUTH_DIGEST;
if (loc->level == CUPSD_AUTH_ANON)
loc->level = CUPSD_AUTH_USER;
}
- else if (!strcasecmp(value, "basicdigest"))
+ else if (!_cups_strcasecmp(value, "basicdigest"))
{
loc->type = CUPSD_AUTH_BASICDIGEST;
if (loc->level == CUPSD_AUTH_ANON)
loc->level = CUPSD_AUTH_USER;
}
- else if (!strcasecmp(value, "default"))
+ else if (!_cups_strcasecmp(value, "default"))
{
loc->type = CUPSD_AUTH_DEFAULT;
loc->level = CUPSD_AUTH_USER;
}
#ifdef HAVE_GSSAPI
- else if (!strcasecmp(value, "negotiate"))
+ else if (!_cups_strcasecmp(value, "negotiate"))
{
loc->type = CUPSD_AUTH_NEGOTIATE;
return (0);
}
}
- else if (!strcasecmp(line, "AuthClass"))
+ else if (!_cups_strcasecmp(line, "AuthClass"))
{
/*
* AuthClass anonymous, user, system, group
*/
- if (!strcasecmp(value, "anonymous"))
+ if (!_cups_strcasecmp(value, "anonymous"))
{
loc->type = CUPSD_AUTH_NONE;
loc->level = CUPSD_AUTH_ANON;
"it from line %d.",
value, linenum);
}
- else if (!strcasecmp(value, "user"))
+ else if (!_cups_strcasecmp(value, "user"))
{
loc->level = CUPSD_AUTH_USER;
"\"Require valid-user\" on line %d.",
value, linenum);
}
- else if (!strcasecmp(value, "group"))
+ else if (!_cups_strcasecmp(value, "group"))
{
loc->level = CUPSD_AUTH_GROUP;
"\"Require user @groupname\" on line %d.",
value, linenum);
}
- else if (!strcasecmp(value, "system"))
+ else if (!_cups_strcasecmp(value, "system"))
{
loc->level = CUPSD_AUTH_GROUP;
return (0);
}
}
- else if (!strcasecmp(line, "AuthGroupName"))
+ else if (!_cups_strcasecmp(line, "AuthGroupName"))
{
cupsdAddName(loc, value);
"using \"Require user @%s\" on line %d.",
value, value, linenum);
}
- else if (!strcasecmp(line, "Require"))
+ else if (!_cups_strcasecmp(line, "Require"))
{
/*
* Apache synonym for AuthClass and AuthGroupName...
* Require user names
*/
- for (valptr = value; !isspace(*valptr & 255) && *valptr; valptr ++);
+ for (valptr = value; !_cups_isspace(*valptr) && *valptr; valptr ++);
if (*valptr)
*valptr++ = '\0';
- if (!strcasecmp(value, "valid-user") ||
- !strcasecmp(value, "user"))
+ if (!_cups_strcasecmp(value, "valid-user") ||
+ !_cups_strcasecmp(value, "user"))
loc->level = CUPSD_AUTH_USER;
- else if (!strcasecmp(value, "group"))
+ else if (!_cups_strcasecmp(value, "group"))
loc->level = CUPSD_AUTH_GROUP;
else
{
for (value = valptr; *value;)
{
- while (isspace(*value & 255))
+ while (_cups_isspace(*value))
value ++;
#ifdef HAVE_AUTHORIZATION_H
* Grab literal name.
*/
- for (valptr = value; !isspace(*valptr & 255) && *valptr; valptr ++);
+ for (valptr = value; !_cups_isspace(*valptr) && *valptr; valptr ++);
}
if (*valptr)
cupsdAddName(loc, value);
- for (value = valptr; isspace(*value & 255); value ++);
+ for (value = valptr; _cups_isspace(*value); value ++);
}
}
- else if (!strcasecmp(line, "Satisfy"))
+ else if (!_cups_strcasecmp(line, "Satisfy"))
{
- if (!strcasecmp(value, "all"))
+ if (!_cups_strcasecmp(value, "all"))
loc->satisfy = CUPSD_AUTH_SATISFY_ALL;
- else if (!strcasecmp(value, "any"))
+ else if (!_cups_strcasecmp(value, "any"))
loc->satisfy = CUPSD_AUTH_SATISFY_ANY;
else
{
*/
for (valend = valstart; *valend; valend ++)
- if (isspace(*valend & 255) || *valend == ',')
+ if (_cups_isspace(*valend) || *valend == ',')
break;
if (*valend)
* Add the error to the bitmask...
*/
- if (!strcasecmp(valstart, "all"))
+ if (!_cups_strcasecmp(valstart, "all"))
fatal = CUPSD_FATAL_ALL;
- else if (!strcasecmp(valstart, "browse"))
+ else if (!_cups_strcasecmp(valstart, "browse"))
fatal |= CUPSD_FATAL_BROWSE;
- else if (!strcasecmp(valstart, "-browse"))
+ else if (!_cups_strcasecmp(valstart, "-browse"))
fatal &= ~CUPSD_FATAL_BROWSE;
- else if (!strcasecmp(valstart, "config"))
+ else if (!_cups_strcasecmp(valstart, "config"))
fatal |= CUPSD_FATAL_CONFIG;
- else if (!strcasecmp(valstart, "-config"))
+ else if (!_cups_strcasecmp(valstart, "-config"))
fatal &= ~CUPSD_FATAL_CONFIG;
- else if (!strcasecmp(valstart, "listen"))
+ else if (!_cups_strcasecmp(valstart, "listen"))
fatal |= CUPSD_FATAL_LISTEN;
- else if (!strcasecmp(valstart, "-listen"))
+ else if (!_cups_strcasecmp(valstart, "-listen"))
fatal &= ~CUPSD_FATAL_LISTEN;
- else if (!strcasecmp(valstart, "log"))
+ else if (!_cups_strcasecmp(valstart, "log"))
fatal |= CUPSD_FATAL_LOG;
- else if (!strcasecmp(valstart, "-log"))
+ else if (!_cups_strcasecmp(valstart, "-log"))
fatal &= ~CUPSD_FATAL_LOG;
- else if (!strcasecmp(valstart, "permissions"))
+ else if (!_cups_strcasecmp(valstart, "permissions"))
fatal |= CUPSD_FATAL_PERMISSIONS;
- else if (!strcasecmp(valstart, "-permissions"))
+ else if (!_cups_strcasecmp(valstart, "-permissions"))
fatal &= ~CUPSD_FATAL_PERMISSIONS;
- else if (strcasecmp(valstart, "none"))
+ else if (_cups_strcasecmp(valstart, "none"))
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown FatalErrors kind \"%s\" ignored!", valstart);
+ "Unknown FatalErrors kind \"%s\" ignored.", valstart);
for (valstart = valend; *valstart; valstart ++)
- if (!isspace(*valstart & 255) || *valstart != ',')
+ if (!_cups_isspace(*valstart) || *valstart != ',')
break;
}
*/
for (valend = valstart; *valend; valend ++)
- if (isspace(*valend) || *valend == ',')
+ if (_cups_isspace(*valend) || *valend == ',')
break;
}
valstart = valend;
- while (*valstart == ',' || isspace(*valstart))
+ while (*valstart == ',' || _cups_isspace(*valstart))
valstart ++;
}
*/
for (valend = valstart; *valend; valend ++)
- if (isspace(*valend & 255) || *valend == ',')
+ if (_cups_isspace(*valend) || *valend == ',')
break;
if (*valend)
* Add the protocol to the bitmask...
*/
- if (!strcasecmp(valstart, "cups"))
+ if (!_cups_strcasecmp(valstart, "cups"))
protocols |= BROWSE_CUPS;
- else if (!strcasecmp(valstart, "slp"))
+ else if (!_cups_strcasecmp(valstart, "slp"))
protocols |= BROWSE_SLP;
- else if (!strcasecmp(valstart, "ldap"))
+ else if (!_cups_strcasecmp(valstart, "ldap"))
protocols |= BROWSE_LDAP;
- else if (!strcasecmp(valstart, "dnssd") ||
- !strcasecmp(valstart, "dns-sd") ||
- !strcasecmp(valstart, "bonjour"))
+ else if (!_cups_strcasecmp(valstart, "dnssd") ||
+ !_cups_strcasecmp(valstart, "dns-sd") ||
+ !_cups_strcasecmp(valstart, "bonjour"))
protocols |= BROWSE_DNSSD;
- else if (!strcasecmp(valstart, "lpd"))
+ else if (!_cups_strcasecmp(valstart, "lpd"))
protocols |= BROWSE_LPD;
- else if (!strcasecmp(valstart, "smb"))
+ else if (!_cups_strcasecmp(valstart, "smb"))
protocols |= BROWSE_SMB;
- else if (!strcasecmp(valstart, "all"))
+ else if (!_cups_strcasecmp(valstart, "all"))
protocols |= BROWSE_ALL;
- else if (strcasecmp(valstart, "none"))
+ else if (_cups_strcasecmp(valstart, "none"))
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown browse protocol \"%s\" ignored!", valstart);
+ "Unknown browse protocol \"%s\" ignored.", valstart);
for (valstart = valend; *valstart; valstart ++)
- if (!isspace(*valstart & 255) || *valstart != ',')
+ if (!_cups_isspace(*valstart) || *valstart != ',')
break;
}
* Decode the directive...
*/
- if (!strcasecmp(line, "Include") && value)
+ if (!_cups_strcasecmp(line, "Include") && value)
{
/*
* Include filename
cupsFileClose(incfile);
}
}
- else if (!strcasecmp(line, "<Location") && value)
+ else if (!_cups_strcasecmp(line, "<Location") && value)
{
/*
* <Location path>
if (linenum == 0)
return (0);
}
- else if (!strcasecmp(line, "<Policy") && value)
+ else if (!_cups_strcasecmp(line, "<Policy") && value)
{
/*
* <Policy name>
if (linenum == 0)
return (0);
}
- else if (!strcasecmp(line, "FatalErrors"))
+ else if (!_cups_strcasecmp(line, "FatalErrors"))
FatalErrors = parse_fatal_errors(value);
- else if (!strcasecmp(line, "FaxRetryInterval") && value)
+ else if (!_cups_strcasecmp(line, "FaxRetryInterval") && value)
{
JobRetryInterval = atoi(value);
cupsdLogMessage(CUPSD_LOG_WARN,
"FaxRetryInterval is deprecated; use "
"JobRetryInterval on line %d.", linenum);
}
- else if (!strcasecmp(line, "FaxRetryLimit") && value)
+ else if (!_cups_strcasecmp(line, "FaxRetryLimit") && value)
{
JobRetryLimit = atoi(value);
cupsdLogMessage(CUPSD_LOG_WARN,
"FaxRetryLimit is deprecated; use "
"JobRetryLimit on line %d.", linenum);
}
- else if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")
+ else if ((!_cups_strcasecmp(line, "Port") || !_cups_strcasecmp(line, "Listen")
#ifdef HAVE_SSL
- || !strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen")
+ || !_cups_strcasecmp(line, "SSLPort") || !_cups_strcasecmp(line, "SSLListen")
#endif /* HAVE_SSL */
- )
+ ) && value)
{
/*
* Add listening address(es) to the list...
{
httpAddrString(&lis->address, temp, sizeof(temp));
cupsdLogMessage(CUPSD_LOG_WARN,
- "Duplicate listen address \"%s\" ignored!", temp);
+ "Duplicate listen address \"%s\" ignored.", temp);
continue;
}
lis->fd = -1;
#ifdef HAVE_SSL
- if (!strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen"))
+ if (!_cups_strcasecmp(line, "SSLPort") || !_cups_strcasecmp(line, "SSLListen"))
lis->encryption = HTTP_ENCRYPT_ALWAYS;
#endif /* HAVE_SSL */
httpAddrString(&lis->address, temp, sizeof(temp));
-#ifdef AF_INET6
- if (lis->address.addr.sa_family == AF_INET6)
- cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv6)", temp,
- ntohs(lis->address.ipv6.sin6_port));
- else
-#endif /* AF_INET6 */
#ifdef AF_LOCAL
if (lis->address.addr.sa_family == AF_LOCAL)
cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s (Domain)", temp);
else
#endif /* AF_LOCAL */
- cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
- ntohs(lis->address.ipv4.sin_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv%d)", temp,
+ _httpAddrPort(&(lis->address)),
+ _httpAddrFamily(&(lis->address)) == AF_INET ? 4 : 6);
if (!httpAddrLocalhost(&(lis->address)))
- {
-#ifdef AF_INET6
- if (lis->address.addr.sa_family == AF_INET6)
- RemotePort = ntohs(lis->address.ipv6.sin6_port);
- else
-#endif /* AF_INET6 */
- RemotePort = ntohs(lis->address.ipv4.sin_port);
- }
+ RemotePort = _httpAddrPort(&(lis->address));
}
/*
httpAddrFreeList(addrlist);
}
- else if (!strcasecmp(line, "BrowseAddress") && value)
+ else if (!_cups_strcasecmp(line, "BrowseAddress") && value)
{
/*
* Add a browse address to the list...
memset(dira, 0, sizeof(cupsd_dirsvc_addr_t));
- if (!strcasecmp(value, "@LOCAL"))
+ if (!_cups_strcasecmp(value, "@LOCAL"))
{
/*
* Send browse data to all local interfaces...
strcpy(dira->iface, "*");
NumBrowsers ++;
}
- else if (!strncasecmp(value, "@IF(", 4))
+ else if (!_cups_strncasecmp(value, "@IF(", 4))
{
/*
* Send browse data to the named interface...
*/
for (addr = addrlist; addr; addr = addr->next)
- if (addr->addr.addr.sa_family == AF_INET)
+ if (_httpAddrFamily(&(addr->addr)) == AF_INET)
break;
if (addr)
cupsdLogMessage(CUPSD_LOG_INFO,
"Sending browsing info to %s:%d (IPv4)",
- temp, ntohs(dira->to.ipv4.sin_port));
+ temp, _httpAddrPort(&(dira->to)));
NumBrowsers ++;
}
cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "BrowseOrder") && value)
+ else if (!_cups_strcasecmp(line, "BrowseOrder") && value)
{
/*
* "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"...
if (location == NULL)
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to initialize browse access control list!");
- else if (!strncasecmp(value, "deny", 4))
+ "Unable to initialize browse access control list.");
+ else if (!_cups_strncasecmp(value, "deny", 4))
location->order_type = CUPSD_AUTH_ALLOW;
- else if (!strncasecmp(value, "allow", 5))
+ 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 (!strcasecmp(line, "BrowseProtocols") ||
- !strcasecmp(line, "BrowseLocalProtocols") ||
- !strcasecmp(line, "BrowseRemoteProtocols"))
+ else if (!_cups_strcasecmp(line, "BrowseProtocols") ||
+ !_cups_strcasecmp(line, "BrowseLocalProtocols") ||
+ !_cups_strcasecmp(line, "BrowseRemoteProtocols"))
{
/*
* "BrowseProtocols name [... name]"
break;
}
- if (strcasecmp(line, "BrowseLocalProtocols"))
+ if (_cups_strcasecmp(line, "BrowseLocalProtocols"))
BrowseRemoteProtocols = protocols;
- if (strcasecmp(line, "BrowseRemoteProtocols"))
+ if (_cups_strcasecmp(line, "BrowseRemoteProtocols"))
BrowseLocalProtocols = protocols;
}
- else if ((!strcasecmp(line, "BrowseAllow") ||
- !strcasecmp(line, "BrowseDeny")) && value)
+ else if ((!_cups_strcasecmp(line, "BrowseAllow") ||
+ !_cups_strcasecmp(line, "BrowseDeny")) && value)
{
/*
* BrowseAllow [From] host/ip...
if (location == NULL)
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to initialize browse access control list!");
+ "Unable to initialize browse access control list.");
else
{
- if (!strncasecmp(value, "from", 4))
+ if (!_cups_strncasecmp(value, "from", 4))
{
/*
* Skip leading "from"...
* Skip leading whitespace...
*/
- while (isspace(*value & 255))
+ while (_cups_isspace(*value))
value ++;
if (!*value)
*/
for (valueptr = value;
- *valueptr && !isspace(*valueptr & 255);
+ *valueptr && !_cups_isspace(*valueptr);
valueptr ++);
- while (isspace(*valueptr & 255))
+ while (_cups_isspace(*valueptr))
*valueptr++ = '\0';
/*
* nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm
*/
- if (!strcasecmp(value, "all"))
+ if (!_cups_strcasecmp(value, "all"))
{
/*
* All hosts...
*/
- if (!strcasecmp(line, "BrowseAllow"))
+ if (!_cups_strcasecmp(line, "BrowseAllow"))
cupsdAddIPMask(&(location->allow), zeros, zeros);
else
cupsdAddIPMask(&(location->deny), zeros, zeros);
}
- else if (!strcasecmp(value, "none"))
+ else if (!_cups_strcasecmp(value, "none"))
{
/*
* No hosts...
*/
- if (!strcasecmp(line, "BrowseAllow"))
+ if (!_cups_strcasecmp(line, "BrowseAllow"))
cupsdAddIPMask(&(location->allow), ones, zeros);
else
cupsdAddIPMask(&(location->deny), ones, zeros);
* Host or domain name...
*/
- if (!strcasecmp(line, "BrowseAllow"))
+ if (!_cups_strcasecmp(line, "BrowseAllow"))
cupsdAddNameMask(&(location->allow), value);
else
cupsdAddNameMask(&(location->deny), value);
break;
}
- if (!strcasecmp(line, "BrowseAllow"))
+ if (!_cups_strcasecmp(line, "BrowseAllow"))
cupsdAddIPMask(&(location->allow), ip, mask);
else
cupsdAddIPMask(&(location->deny), ip, mask);
}
}
}
- else if (!strcasecmp(line, "BrowseRelay") && value)
+ else if (!_cups_strcasecmp(line, "BrowseRelay") && value)
{
/*
* BrowseRelay [from] source [to] destination
memset(relay, 0, sizeof(cupsd_dirsvc_relay_t));
- if (!strncasecmp(value, "from ", 5))
+ if (!_cups_strncasecmp(value, "from ", 5))
{
/*
* Skip leading "from"...
* Skip leading whitespace...
*/
- while (isspace(*value))
+ while (_cups_isspace(*value))
value ++;
}
*/
for (valueptr = value;
- *valueptr && !isspace(*valueptr & 255);
+ *valueptr && !_cups_isspace(*valueptr);
valueptr ++);
- while (isspace(*valueptr & 255))
+ while (_cups_isspace(*valueptr))
*valueptr++ = '\0';
/*
* Get "to" address and port...
*/
- if (!strncasecmp(valueptr, "to ", 3))
+ if (!_cups_strncasecmp(valueptr, "to ", 3))
{
/*
* Strip leading "to"...
valueptr += 3;
- while (isspace(*valueptr))
+ while (_cups_isspace(*valueptr))
valueptr ++;
}
httpAddrString(&(relay->to), temp, sizeof(temp));
cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
- value, temp, ntohs(relay->to.ipv4.sin_port));
+ value, temp, _httpAddrPort(&(relay->to)));
NumRelays ++;
}
valueptr, linenum);
}
}
- else if (!strcasecmp(line, "BrowsePoll") && value)
+ else if (!_cups_strcasecmp(line, "BrowsePoll") && value)
{
/*
* BrowsePoll address[:port]
portnum = ntohs(service->s_port);
else
{
- cupsdLogMessage(CUPSD_LOG_ERROR, "Lookup of service \"%s\" failed!",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Lookup of service \"%s\" failed.",
portname);
continue;
}
cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", pollp->hostname,
pollp->port);
}
- else if (!strcasecmp(line, "DefaultAuthType") && value)
+ else if (!_cups_strcasecmp(line, "DefaultAuthType") && value)
{
/*
* DefaultAuthType {basic,digest,basicdigest,negotiate}
*/
- if (!strcasecmp(value, "none"))
+ if (!_cups_strcasecmp(value, "none"))
DefaultAuthType = CUPSD_AUTH_NONE;
- else if (!strcasecmp(value, "basic"))
+ else if (!_cups_strcasecmp(value, "basic"))
DefaultAuthType = CUPSD_AUTH_BASIC;
- else if (!strcasecmp(value, "digest"))
+ else if (!_cups_strcasecmp(value, "digest"))
DefaultAuthType = CUPSD_AUTH_DIGEST;
- else if (!strcasecmp(value, "basicdigest"))
+ else if (!_cups_strcasecmp(value, "basicdigest"))
DefaultAuthType = CUPSD_AUTH_BASICDIGEST;
#ifdef HAVE_GSSAPI
- else if (!strcasecmp(value, "negotiate"))
+ else if (!_cups_strcasecmp(value, "negotiate"))
DefaultAuthType = CUPSD_AUTH_NEGOTIATE;
#endif /* HAVE_GSSAPI */
else
}
}
#ifdef HAVE_SSL
- else if (!strcasecmp(line, "DefaultEncryption"))
+ else if (!_cups_strcasecmp(line, "DefaultEncryption"))
{
/*
* DefaultEncryption {Never,IfRequested,Required}
*/
- if (!value || !strcasecmp(value, "never"))
+ if (!value || !_cups_strcasecmp(value, "never"))
DefaultEncryption = HTTP_ENCRYPT_NEVER;
- else if (!strcasecmp(value, "required"))
+ else if (!_cups_strcasecmp(value, "required"))
DefaultEncryption = HTTP_ENCRYPT_REQUIRED;
- else if (!strcasecmp(value, "ifrequested"))
+ else if (!_cups_strcasecmp(value, "ifrequested"))
DefaultEncryption = HTTP_ENCRYPT_IF_REQUESTED;
else
{
}
}
#endif /* HAVE_SSL */
- else if (!strcasecmp(line, "User") && value)
+ else if (!_cups_strcasecmp(line, "User") && value)
{
/*
* User ID to run as...
}
else
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown User \"%s\" on line %d, ignoring!",
+ "Unknown User \"%s\" on line %d, ignoring.",
value, linenum);
}
}
- else if (!strcasecmp(line, "Group") && value)
+ else if (!_cups_strcasecmp(line, "Group") && value)
{
/*
* Group ID to run as...
Group = group->gr_gid;
else
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown Group \"%s\" on line %d, ignoring!",
+ "Unknown Group \"%s\" on line %d, ignoring.",
value, linenum);
}
}
- else if (!strcasecmp(line, "SystemGroup") && value)
+ else if (!_cups_strcasecmp(line, "SystemGroup") && value)
{
/*
* SystemGroup (admin) group(s)...
if (!parse_groups(value))
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown SystemGroup \"%s\" on line %d, ignoring!",
+ "Unknown SystemGroup \"%s\" on line %d, ignoring.",
value, linenum);
}
- else if (!strcasecmp(line, "HostNameLookups") && value)
+ else if (!_cups_strcasecmp(line, "HostNameLookups") && value)
{
/*
* Do hostname lookups?
*/
- if (!strcasecmp(value, "off") || !strcasecmp(value, "no") ||
- !strcasecmp(value, "false"))
+ if (!_cups_strcasecmp(value, "off") || !_cups_strcasecmp(value, "no") ||
+ !_cups_strcasecmp(value, "false"))
HostNameLookups = 0;
- else if (!strcasecmp(value, "on") || !strcasecmp(value, "yes") ||
- !strcasecmp(value, "true"))
+ else if (!_cups_strcasecmp(value, "on") || !_cups_strcasecmp(value, "yes") ||
+ !_cups_strcasecmp(value, "true"))
HostNameLookups = 1;
- else if (!strcasecmp(value, "double"))
+ else if (!_cups_strcasecmp(value, "double"))
HostNameLookups = 2;
else
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "AccessLogLevel") && value)
+ else if (!_cups_strcasecmp(line, "AccessLogLevel") && value)
{
/*
* Amount of logging to do to access log...
*/
- if (!strcasecmp(value, "all"))
+ if (!_cups_strcasecmp(value, "all"))
AccessLogLevel = CUPSD_ACCESSLOG_ALL;
- else if (!strcasecmp(value, "actions"))
+ else if (!_cups_strcasecmp(value, "actions"))
AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
- else if (!strcasecmp(value, "config"))
+ else if (!_cups_strcasecmp(value, "config"))
AccessLogLevel = CUPSD_ACCESSLOG_CONFIG;
else
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown AccessLogLevel %s on line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "LogLevel") && value)
+ else if (!_cups_strcasecmp(line, "LogLevel") && value)
{
/*
* Amount of logging to do to error log...
*/
- if (!strcasecmp(value, "debug2"))
+ if (!_cups_strcasecmp(value, "debug2"))
LogLevel = CUPSD_LOG_DEBUG2;
- else if (!strcasecmp(value, "debug"))
+ else if (!_cups_strcasecmp(value, "debug"))
LogLevel = CUPSD_LOG_DEBUG;
- else if (!strcasecmp(value, "info"))
+ else if (!_cups_strcasecmp(value, "info"))
LogLevel = CUPSD_LOG_INFO;
- else if (!strcasecmp(value, "notice"))
+ else if (!_cups_strcasecmp(value, "notice"))
LogLevel = CUPSD_LOG_NOTICE;
- else if (!strcasecmp(value, "warn"))
+ else if (!_cups_strcasecmp(value, "warn"))
LogLevel = CUPSD_LOG_WARN;
- else if (!strcasecmp(value, "error"))
+ else if (!_cups_strcasecmp(value, "error"))
LogLevel = CUPSD_LOG_ERROR;
- else if (!strcasecmp(value, "crit"))
+ else if (!_cups_strcasecmp(value, "crit"))
LogLevel = CUPSD_LOG_CRIT;
- else if (!strcasecmp(value, "alert"))
+ else if (!_cups_strcasecmp(value, "alert"))
LogLevel = CUPSD_LOG_ALERT;
- else if (!strcasecmp(value, "emerg"))
+ else if (!_cups_strcasecmp(value, "emerg"))
LogLevel = CUPSD_LOG_EMERG;
- else if (!strcasecmp(value, "none"))
+ else if (!_cups_strcasecmp(value, "none"))
LogLevel = CUPSD_LOG_NONE;
else
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogLevel %s on line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "LogTimeFormat") && value)
+ else if (!_cups_strcasecmp(line, "LogTimeFormat") && value)
{
/*
* Amount of logging to do to error log...
*/
- if (!strcasecmp(value, "standard"))
+ if (!_cups_strcasecmp(value, "standard"))
LogTimeFormat = CUPSD_TIME_STANDARD;
- else if (!strcasecmp(value, "usecs"))
+ else if (!_cups_strcasecmp(value, "usecs"))
LogTimeFormat = CUPSD_TIME_USECS;
else
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogTimeFormat %s on line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "PrintcapFormat") && value)
+ else if (!_cups_strcasecmp(line, "PrintcapFormat") && value)
{
/*
* Format of printcap file?
*/
- if (!strcasecmp(value, "bsd"))
+ if (!_cups_strcasecmp(value, "bsd"))
PrintcapFormat = PRINTCAP_BSD;
- else if (!strcasecmp(value, "plist"))
+ else if (!_cups_strcasecmp(value, "plist"))
PrintcapFormat = PRINTCAP_PLIST;
- else if (!strcasecmp(value, "solaris"))
+ else if (!_cups_strcasecmp(value, "solaris"))
PrintcapFormat = PRINTCAP_SOLARIS;
else
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown PrintcapFormat %s on line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "ServerTokens") && value)
+ else if (!_cups_strcasecmp(line, "ServerTokens") && value)
{
/*
* Set the string used for the Server header...
uname(&plat);
- if (!strcasecmp(value, "ProductOnly"))
+ if (!_cups_strcasecmp(value, "ProductOnly"))
cupsdSetString(&ServerHeader, "CUPS");
- else if (!strcasecmp(value, "Major"))
- cupsdSetString(&ServerHeader, "CUPS/1");
- else if (!strcasecmp(value, "Minor"))
- cupsdSetString(&ServerHeader, "CUPS/1.4");
- else if (!strcasecmp(value, "Minimal"))
+ else if (!_cups_strcasecmp(value, "Major"))
+ cupsdSetStringf(&ServerHeader, "CUPS/%d", CUPS_VERSION_MAJOR);
+ else if (!_cups_strcasecmp(value, "Minor"))
+ cupsdSetStringf(&ServerHeader, "CUPS/%d.%d", CUPS_VERSION_MAJOR,
+ CUPS_VERSION_MINOR);
+ else if (!_cups_strcasecmp(value, "Minimal"))
cupsdSetString(&ServerHeader, CUPS_MINIMAL);
- else if (!strcasecmp(value, "OS"))
+ else if (!_cups_strcasecmp(value, "OS"))
cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s)", plat.sysname);
- else if (!strcasecmp(value, "Full"))
- cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/1.1",
+ else if (!_cups_strcasecmp(value, "Full"))
+ cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/2.1",
plat.sysname);
- else if (!strcasecmp(value, "None"))
+ else if (!_cups_strcasecmp(value, "None"))
cupsdClearString(&ServerHeader);
else
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown ServerTokens %s on line %d.",
value, linenum);
}
- else if (!strcasecmp(line, "PassEnv") && value)
+ else if (!_cups_strcasecmp(line, "PassEnv") && value)
{
/*
* PassEnv variable [... variable]
for (; *value;)
{
for (valuelen = 0; value[valuelen]; valuelen ++)
- if (isspace(value[valuelen]) || value[valuelen] == ',')
+ if (_cups_isspace(value[valuelen]) || value[valuelen] == ',')
break;
if (value[valuelen])
cupsdSetEnv(value, NULL);
for (value += valuelen; *value; value ++)
- if (!isspace(*value) || *value != ',')
+ if (!_cups_isspace(*value) || *value != ',')
break;
}
}
- else if (!strcasecmp(line, "ServerAlias") && value)
+ else if (!_cups_strcasecmp(line, "ServerAlias") && value)
{
+ /*
+ * ServerAlias name [... name]
+ */
+
if (!ServerAlias)
ServerAlias = cupsArrayNew(NULL, NULL);
- cupsdAddAlias(ServerAlias, value);
+ for (; *value;)
+ {
+ for (valuelen = 0; value[valuelen]; valuelen ++)
+ if (_cups_isspace(value[valuelen]) || value[valuelen] == ',')
+ break;
+
+ if (value[valuelen])
+ {
+ value[valuelen] = '\0';
+ valuelen ++;
+ }
+
+ cupsdAddAlias(ServerAlias, value);
+
+ for (value += valuelen; *value; value ++)
+ if (!_cups_isspace(*value) || *value != ',')
+ break;
+ }
}
- else if (!strcasecmp(line, "SetEnv") && value)
+ else if (!_cups_strcasecmp(line, "SetEnv") && value)
{
/*
* SetEnv variable value
linenum);
}
#ifdef HAVE_SSL
- else if (!strcasecmp(line, "SSLOptions"))
+ else if (!_cups_strcasecmp(line, "SSLOptions"))
{
/*
* SSLOptions options
*/
- if (!value || !strcasecmp(value, "none"))
+ if (!value || !_cups_strcasecmp(value, "none"))
SSLOptions = CUPSD_SSL_NONE;
- else if (!strcasecmp(value, "noemptyfragments"))
+ else if (!_cups_strcasecmp(value, "noemptyfragments"))
SSLOptions = CUPSD_SSL_NOEMPTY;
else
cupsdLogMessage(CUPSD_LOG_ERROR,
*/
for (i = NUM_VARS, var = variables; i > 0; i --, var ++)
- if (!strcasecmp(line, var->name))
+ if (!_cups_strcasecmp(line, var->name))
break;
if (i == 0)
case CUPSD_VARTYPE_INTEGER :
if (!value)
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Missing integer value for %s on line %d!",
+ "Missing integer value for %s on line %d.",
line, linenum);
else
{
if (n < 0)
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Bad negative integer value for %s on line %d!",
+ "Bad negative integer value for %s on line %d.",
line, linenum);
else
*((int *)var->ptr) = n;
case CUPSD_VARTYPE_BOOLEAN :
if (!value)
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Missing boolean value for %s on line %d!",
+ "Missing boolean value for %s on line %d.",
line, linenum);
- else if (!strcasecmp(value, "true") ||
- !strcasecmp(value, "on") ||
- !strcasecmp(value, "enabled") ||
- !strcasecmp(value, "yes") ||
+ else if (!_cups_strcasecmp(value, "true") ||
+ !_cups_strcasecmp(value, "on") ||
+ !_cups_strcasecmp(value, "enabled") ||
+ !_cups_strcasecmp(value, "yes") ||
atoi(value) != 0)
*((int *)var->ptr) = TRUE;
- else if (!strcasecmp(value, "false") ||
- !strcasecmp(value, "off") ||
- !strcasecmp(value, "disabled") ||
- !strcasecmp(value, "no") ||
- !strcasecmp(value, "0"))
+ else if (!_cups_strcasecmp(value, "false") ||
+ !_cups_strcasecmp(value, "off") ||
+ !_cups_strcasecmp(value, "disabled") ||
+ !_cups_strcasecmp(value, "no") ||
+ !_cups_strcasecmp(value, "0"))
*((int *)var->ptr) = FALSE;
else
cupsdLogMessage(CUPSD_LOG_ERROR,
if (!value)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Missing pathname value for %s on line %d!",
+ "Missing pathname value for %s on line %d.",
line, linenum);
break;
}
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"File or directory for \"%s %s\" on line %d "
- "does not exist!", line, value, linenum);
+ "does not exist.", line, value, linenum);
break;
}
*valptr; /* Pointer into value */
- if ((parent = cupsdNewLocation(location)) == NULL)
+ if ((parent = cupsdFindLocation(location)) != NULL)
+ cupsdLogMessage(CUPSD_LOG_WARN, "Duplicate <Location %s> on line %d.",
+ location, linenum);
+ else if ((parent = cupsdNewLocation(location)) == NULL)
return (0);
+ else
+ {
+ cupsdAddLocation(parent);
- cupsdAddLocation(parent);
+ parent->limit = CUPSD_AUTH_LIMIT_ALL;
+ }
- parent->limit = CUPSD_AUTH_LIMIT_ALL;
- loc = parent;
+ loc = parent;
while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
{
* Decode the directive...
*/
- if (!strcasecmp(line, "</Location>"))
+ if (!_cups_strcasecmp(line, "</Location>"))
return (linenum);
- else if (!strcasecmp(line, "<Limit") ||
- !strcasecmp(line, "<LimitExcept"))
+ else if (!_cups_strcasecmp(line, "<Limit") ||
+ !_cups_strcasecmp(line, "<LimitExcept"))
{
if (!value)
{
else if (!strcmp(value, "TRACE"))
loc->limit |= CUPSD_AUTH_LIMIT_TRACE;
else
- cupsdLogMessage(CUPSD_LOG_WARN, "Unknown request type %s on line %d!",
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown request type %s on line %d.",
value, linenum);
for (value = valptr; isspace(*value & 255); value ++);
}
- if (!strcasecmp(line, "<LimitExcept"))
+ if (!_cups_strcasecmp(line, "<LimitExcept"))
loc->limit = CUPSD_AUTH_LIMIT_ALL ^ loc->limit;
parent->limit &= ~loc->limit;
}
- else if (!strcasecmp(line, "</Limit>") ||
- !strcasecmp(line, "</LimitExcept>"))
+ else if (!_cups_strcasecmp(line, "</Limit>") ||
+ !_cups_strcasecmp(line, "</LimitExcept>"))
loc = parent;
+ else if (!value)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value on line %d.", linenum);
+ if (FatalErrors & CUPSD_FATAL_CONFIG)
+ return (0);
+ }
else if (!parse_aaa(loc, line, value, linenum))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
}
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unexpected end-of-file at line %d while reading location!",
+ "Unexpected end-of-file at line %d while reading location.",
linenum);
return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
* Create the policy...
*/
- if ((pol = cupsdAddPolicy(policy)) == NULL)
+ if ((pol = cupsdFindPolicy(policy)) != NULL)
+ cupsdLogMessage(CUPSD_LOG_WARN, "Duplicate <Policy %s> on line %d.",
+ policy, linenum);
+ else if ((pol = cupsdAddPolicy(policy)) == NULL)
return (0);
/*
* Decode the directive...
*/
- if (!strcasecmp(line, "</Policy>"))
+ if (!_cups_strcasecmp(line, "</Policy>"))
{
if (op)
cupsdLogMessage(CUPSD_LOG_WARN,
- "Missing </Limit> before </Policy> on line %d!",
+ "Missing </Limit> before </Policy> on line %d.",
linenum);
set_policy_defaults(pol);
return (linenum);
}
- else if (!strcasecmp(line, "<Limit") && !op)
+ else if (!_cups_strcasecmp(line, "<Limit") && !op)
{
if (!value)
{
if (num_ops < (int)(sizeof(ops) / sizeof(ops[0])))
{
- if (!strcasecmp(value, "All"))
+ if (!_cups_strcasecmp(value, "All"))
ops[num_ops] = IPP_ANY_OPERATION;
else if ((ops[num_ops] = ippOpValue(value)) == IPP_BAD_OPERATION)
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Bad IPP operation name \"%s\" on line %d!",
+ "Bad IPP operation name \"%s\" on line %d.",
value, linenum);
else
num_ops ++;
}
else
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Too many operations listed on line %d!",
+ "Too many operations listed on line %d.",
linenum);
for (value = valptr; isspace(*value & 255); value ++);
op = cupsdAddPolicyOp(pol, NULL, ops[0]);
}
- else if (!strcasecmp(line, "</Limit>") && op)
+ else if (!_cups_strcasecmp(line, "</Limit>") && op)
{
/*
* Finish the current operation limit...
op = NULL;
}
- else if (!strcasecmp(line, "JobPrivateAccess") ||
- !strcasecmp(line, "JobPrivateValues") ||
- !strcasecmp(line, "SubscriptionPrivateAccess") ||
- !strcasecmp(line, "SubscriptionPrivateValues"))
+ else if (!value)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Missing value on line %d.", linenum);
+ if (FatalErrors & CUPSD_FATAL_CONFIG)
+ return (0);
+ }
+ else if (!_cups_strcasecmp(line, "JobPrivateAccess") ||
+ !_cups_strcasecmp(line, "JobPrivateValues") ||
+ !_cups_strcasecmp(line, "SubscriptionPrivateAccess") ||
+ !_cups_strcasecmp(line, "SubscriptionPrivateValues"))
{
if (op)
{
* Save it appropriately...
*/
- if (!strcasecmp(line, "JobPrivateAccess"))
+ if (!_cups_strcasecmp(line, "JobPrivateAccess"))
{
/*
* JobPrivateAccess {all|default|user/group list|@@ACL}
*/
- if (!strcasecmp(value, "default"))
+ if (!_cups_strcasecmp(value, "default"))
{
cupsdAddString(&(pol->job_access), "@OWNER");
cupsdAddString(&(pol->job_access), "@SYSTEM");
else
cupsdAddString(&(pol->job_access), value);
}
- else if (!strcasecmp(line, "JobPrivateValues"))
+ else if (!_cups_strcasecmp(line, "JobPrivateValues"))
{
/*
* JobPrivateValues {all|none|default|attribute list}
*/
- if (!strcasecmp(value, "default"))
+ if (!_cups_strcasecmp(value, "default"))
{
cupsdAddString(&(pol->job_attrs), "job-name");
cupsdAddString(&(pol->job_attrs), "job-originating-host-name");
else
cupsdAddString(&(pol->job_attrs), value);
}
- else if (!strcasecmp(line, "SubscriptionPrivateAccess"))
+ else if (!_cups_strcasecmp(line, "SubscriptionPrivateAccess"))
{
/*
* SubscriptionPrivateAccess {all|default|user/group list|@@ACL}
*/
- if (!strcasecmp(value, "default"))
+ if (!_cups_strcasecmp(value, "default"))
{
cupsdAddString(&(pol->sub_access), "@OWNER");
cupsdAddString(&(pol->sub_access), "@SYSTEM");
else
cupsdAddString(&(pol->sub_access), value);
}
- else /* if (!strcasecmp(line, "SubscriptionPrivateValues")) */
+ else /* if (!_cups_strcasecmp(line, "SubscriptionPrivateValues")) */
{
/*
* SubscriptionPrivateValues {all|none|default|attribute list}
*/
- if (!strcasecmp(value, "default"))
+ if (!_cups_strcasecmp(value, "default"))
{
cupsdAddString(&(pol->sub_attrs), "notify-events");
cupsdAddString(&(pol->sub_attrs), "notify-pull-method");
}
else if (!parse_aaa(op, line, value, linenum))
{
- if (op)
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown Policy Limit directive %s on line %d.",
- line, linenum);
- else
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unknown Policy directive %s on line %d.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown Policy Limit directive %s on line %d.",
+ line, linenum);
if (FatalErrors & CUPSD_FATAL_CONFIG)
return (0);
}
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unexpected end-of-file at line %d while reading policy \"%s\"!",
- linenum, policy);
+ "Unexpected end-of-file at line %d while reading policy "
+ "\"%s\".", linenum, policy);
return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
}