};
+/*
+ * File permissions...
+ */
+
+#define MODE_WRITE 0022 /* Group/other write */
+#define MODE_MASK 0555 /* Owner/group/other read+exec/search */
+#define MODE_DATAFILE 0444 /* Owner/group/other read */
+#define MODE_DIRECTORY 0555 /* Owner/group/other read+search */
+#define MODE_PROGRAM 0555 /* Owner/group/other read+exec */
+
+
/*
* Standard Adobe media keywords (must remain sorted)...
*/
int files; /* Number of files */
int verbose; /* Want verbose output? */
int warn; /* Which errors to just warn about */
+ int ignore; /* Which errors to ignore */
int status; /* Exit status */
int errors; /* Number of conformance errors */
int ppdversion; /* PPD spec version in PPD file */
status = ERROR_NONE;
root = "";
warn = WARN_NONE;
+ ignore = WARN_NONE;
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-' && argv[i][1])
for (opt = argv[i] + 1; *opt; opt ++)
switch (*opt)
{
+ case 'I' : /* Ignore errors */
+ i ++;
+
+ if (i >= argc)
+ usage();
+
+ if (!strcmp(argv[i], "none"))
+ ignore = WARN_NONE;
+ else if (!strcmp(argv[i], "filters"))
+ ignore |= WARN_FILTERS;
+ else if (!strcmp(argv[i], "profiles"))
+ ignore |= WARN_PROFILES;
+ else if (!strcmp(argv[i], "all"))
+ ignore = WARN_FILTERS | WARN_PROFILES;
+ else
+ usage();
+ break;
+
case 'R' : /* Alternate root directory */
i ++;
root = argv[i];
break;
- case 'W' : /* Turn errors into warnings */
+ case 'W' : /* Turn errors into warnings */
i ++;
if (i >= argc)
if (!(warn & WARN_CONSTRAINTS))
errors = check_constraints(ppd, errors, verbose, 0);
- if (!(warn & WARN_FILTERS))
+ if (!(warn & WARN_FILTERS) && !(ignore & WARN_FILTERS))
errors = check_filters(ppd, root, errors, verbose, 0);
- if (!(warn & WARN_PROFILES))
+ if (!(warn & WARN_PROFILES) && !(ignore & WARN_PROFILES))
errors = check_profiles(ppd, root, errors, verbose, 0);
if (!(warn & WARN_SIZES))
{
check_basics(argv[i]);
- if (warn & WARN_CONSTRAINTS)
- errors = check_constraints(ppd, errors, verbose, 1);
-
if (warn & WARN_DEFAULTS)
errors = check_defaults(ppd, errors, verbose, 1);
- if (warn & WARN_PROFILES)
- errors = check_profiles(ppd, root, errors, verbose, 1);
+ if (warn & WARN_CONSTRAINTS)
+ errors = check_constraints(ppd, errors, verbose, 1);
- if (warn & WARN_FILTERS)
+ if ((warn & WARN_FILTERS) && !(ignore & WARN_FILTERS))
errors = check_filters(ppd, root, errors, verbose, 1);
+ if ((warn & WARN_PROFILES) && !(ignore & WARN_PROFILES))
+ errors = check_profiles(ppd, root, errors, verbose, 1);
+
if (warn & WARN_SIZES)
errors = check_sizes(ppd, errors, verbose, 1);
else
pathprog[1024]; /* Complete path to program/filter */
int cost; /* Cost of filter */
const char *prefix; /* WARN/FAIL prefix */
+ struct stat fileinfo; /* File information */
prefix = warn ? " WARN " : "**FAIL**";
program);
}
- if (access(pathprog, X_OK))
+ if (stat(pathprog, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing cupsFilter "
- "file \"%s\"\n"), prefix, program);
+ "file \"%s\"\n"), prefix, pathprog);
+
+ if (!warn)
+ errors ++;
+ }
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_PROGRAM)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on cupsFilter "
+ "file \"%s\"\n"), prefix, pathprog);
if (!warn)
errors ++;
program);
}
- if (access(pathprog, X_OK))
+ if (stat(pathprog, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing cupsPreFilter "
- "file \"%s\"\n"), prefix, program);
+ "file \"%s\"\n"), prefix, pathprog);
if (!warn)
errors ++;
}
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_PROGRAM)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "cupsPreFilter file \"%s\"\n"), prefix,
+ pathprog);
+
+ if (!warn)
+ errors ++;
+ }
else
errors = valid_path("cupsPreFilter", pathprog, errors, verbose, warn);
}
if (!warn)
errors ++;
}
+
+ snprintf(pathprog, sizeof(pathprog), "%s%s", root,
+ attr->value ? attr->value : "(null)");
- if (!attr->value || access(attr->value, 0))
+ if (!attr->value || stat(pathprog, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing "
"APDialogExtension file \"%s\"\n"),
- prefix, attr->value ? attr->value : "<NULL>");
+ prefix, pathprog);
+
+ if (!warn)
+ errors ++;
+ }
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_DIRECTORY)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "APDialogExtension file \"%s\"\n"), prefix,
+ pathprog);
if (!warn)
errors ++;
}
else
- errors = valid_path("APDialogExtension", attr->value, errors, verbose,
+ errors = valid_path("APDialogExtension", pathprog, errors, verbose,
warn);
}
errors ++;
}
- if (!attr->value || access(attr->value, 0))
+ snprintf(pathprog, sizeof(pathprog), "%s%s", root,
+ attr->value ? attr->value : "(null)");
+
+ if (!attr->value || stat(pathprog, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing "
"APPrinterIconPath file \"%s\"\n"),
- prefix, attr->value ? attr->value : "<NULL>");
+ prefix, pathprog);
+
+ if (!warn)
+ errors ++;
+ }
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_DATAFILE)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "APPrinterIconPath file \"%s\"\n"), prefix,
+ pathprog);
if (!warn)
errors ++;
}
else
- errors = valid_path("APPrinterIconPath", attr->value, errors, verbose,
+ errors = valid_path("APPrinterIconPath", pathprog, errors, verbose,
warn);
}
errors ++;
}
- if (!attr->value || access(attr->value, 0))
+ snprintf(pathprog, sizeof(pathprog), "%s%s", root,
+ attr->value ? attr->value : "(null)");
+
+ if (!attr->value || stat(pathprog, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing "
"APPrinterLowInkTool file \"%s\"\n"),
- prefix, attr->value ? attr->value : "<NULL>");
+ prefix, pathprog);
+
+ if (!warn)
+ errors ++;
+ }
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_DIRECTORY)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "APPrinterLowInkTool file \"%s\"\n"), prefix,
+ pathprog);
if (!warn)
errors ++;
}
else
- errors = valid_path("APPrinterLowInkTool", attr->value, errors, verbose,
+ errors = valid_path("APPrinterLowInkTool", pathprog, errors, verbose,
warn);
}
errors ++;
}
- if (!attr->value || access(attr->value, 0))
+ snprintf(pathprog, sizeof(pathprog), "%s%s", root,
+ attr->value ? attr->value : "(null)");
+
+ if (!attr->value || stat(pathprog, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing "
"APPrinterUtilityPath file \"%s\"\n"),
- prefix, attr->value ? attr->value : "<NULL>");
+ prefix, pathprog);
+
+ if (!warn)
+ errors ++;
+ }
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_DIRECTORY)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "APPrinterUtilityPath file \"%s\"\n"), prefix,
+ pathprog);
if (!warn)
errors ++;
}
else
- errors = valid_path("APPrinterUtilityPath", attr->value, errors, verbose,
+ errors = valid_path("APPrinterUtilityPath", pathprog, errors, verbose,
warn);
}
errors ++;
}
- if (!attr->value || access(attr->value, 0))
+ if (!attr->value || stat(attr->value, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (!warn)
errors ++;
}
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_DIRECTORY)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "APScanAppPath file \"%s\"\n"), prefix,
+ attr->value);
+
+ if (!warn)
+ errors ++;
+ }
else
errors = valid_path("APScanAppPath", attr->value, errors, verbose,
warn);
const char *ptr; /* Pointer into string */
const char *prefix; /* WARN/FAIL prefix */
char filename[1024]; /* Profile filename */
+ struct stat fileinfo; /* File information */
int num_profiles = 0; /* Number of profiles */
unsigned hash, /* Current hash value */
hashes[1000]; /* Hash values of profile names */
attr->value);
}
- if (access(filename, 0))
+ if (stat(filename, &fileinfo))
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout, _(" %s Missing cupsICCProfile "
- "file \"%s\"!\n"), prefix, attr->value);
+ "file \"%s\"!\n"), prefix, filename);
+
+ if (!warn)
+ errors ++;
+ }
+ else if (fileinfo.st_uid != 0 ||
+ (fileinfo.st_mode & MODE_WRITE) ||
+ (fileinfo.st_mode & MODE_MASK) != MODE_DATAFILE)
+ {
+ if (!warn && !errors && !verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout, _(" %s Bad permissions on "
+ "cupsICCProfile file \"%s\"\n"), prefix,
+ filename);
if (!warn)
errors ++;
"\n"
"Options:\n"
"\n"
+ " -I {filters,profiles}\n"
+ " Ignore missing files\n"
" -R root-directory Set alternate root\n"
" -W {all,none,constraints,defaults,duplex,filters,"
"profiles,sizes,translations}\n"