MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsFileCheck

Function _cupsFileCheck

cups/file.c:77–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 */
76
77_cups_fc_result_t /* O - Check result */
78_cupsFileCheck(
79 const char *filename, /* I - Filename to check */
80 _cups_fc_filetype_t filetype, /* I - Type of file checks? */
81 int dorootchecks, /* I - Check for root permissions? */
82 _cups_fc_func_t cb, /* I - Callback function */
83 void *context) /* I - Context pointer for callback */
84
85{
86 struct stat fileinfo; /* File information */
87 char message[1024], /* Message string */
88 temp[1024], /* Parent directory filename */
89 *ptr; /* Pointer into parent directory */
90 _cups_fc_result_t result; /* Check result */
91
92
93 /*
94 * Does the filename contain a relative path ("../")?
95 */
96
97 if (strstr(filename, "../"))
98 {
99 /*
100 * Yes, fail it!
101 */
102
103 result = _CUPS_FILE_CHECK_RELATIVE_PATH;
104 goto finishup;
105 }
106
107 /*
108 * Does the program even exist and is it accessible?
109 */
110
111 if (stat(filename, &fileinfo))
112 {
113 /*
114 * Nope...
115 */
116
117 result = _CUPS_FILE_CHECK_MISSING;
118 goto finishup;
119 }
120
121 /*
122 * Check the execute bit...
123 */
124
125 result = _CUPS_FILE_CHECK_OK;
126
127 if (filetype == _CUPS_FILE_CHECK_DIRECTORY)
128 {
129 if (!S_ISDIR(fileinfo.st_mode))
130 result = _CUPS_FILE_CHECK_WRONG_TYPE;
131 }
132 else if (!S_ISREG(fileinfo.st_mode))
133 {
134 result = _CUPS_FILE_CHECK_WRONG_TYPE;

Callers 11

load_driversFunction · 0.85
load_ppdsFunction · 0.85
add_printer_filterFunction · 0.85
apple_register_profilesFunction · 0.85
colord_register_printerFunction · 0.85
start_jobFunction · 0.85
start_backendFunction · 0.85
add_printer_filterFunction · 0.85
load_ppdFunction · 0.85
cupsdStartProcessFunction · 0.85
load_classdriverFunction · 0.85

Calls 3

cupsLangDefaultFunction · 0.85
_cupsLangStringFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected