| 3198 | */ |
| 3199 | |
| 3200 | static int /* O - 1 = CGI, 0 = file */ |
| 3201 | is_cgi(cupsd_client_t *con, /* I - Client connection */ |
| 3202 | const char *filename, /* I - Real filename */ |
| 3203 | struct stat *filestats, /* I - File information */ |
| 3204 | mime_type_t *type) /* I - MIME type */ |
| 3205 | { |
| 3206 | const char *options; /* Options on URL */ |
| 3207 | |
| 3208 | |
| 3209 | /* |
| 3210 | * Get the options, if any... |
| 3211 | */ |
| 3212 | |
| 3213 | if ((options = strchr(con->uri, '?')) != NULL) |
| 3214 | { |
| 3215 | options ++; |
| 3216 | cupsdSetStringf(&(con->query_string), "QUERY_STRING=%s", options); |
| 3217 | } |
| 3218 | |
| 3219 | /* |
| 3220 | * Check for known types... |
| 3221 | */ |
| 3222 | |
| 3223 | if (!type || _cups_strcasecmp(type->super, "application")) |
| 3224 | { |
| 3225 | cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, filestats, type ? type->super : "unknown", type ? type->type : "unknown"); |
| 3226 | return (0); |
| 3227 | } |
| 3228 | |
| 3229 | if (!_cups_strcasecmp(type->type, "x-httpd-cgi") && (filestats->st_mode & 0111) && (getuid() || !(filestats->st_mode & 022))) |
| 3230 | { |
| 3231 | /* |
| 3232 | * "application/x-httpd-cgi" is a CGI script. |
| 3233 | */ |
| 3234 | |
| 3235 | cupsdSetString(&con->command, filename); |
| 3236 | |
| 3237 | if (options) |
| 3238 | cupsdSetStringf(&con->options, " %s", options); |
| 3239 | |
| 3240 | cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 1.", filename, filestats, type->super, type->type); |
| 3241 | return (1); |
| 3242 | } |
| 3243 | |
| 3244 | cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, filestats, type->super, type->type); |
| 3245 | return (0); |
| 3246 | } |
| 3247 | |
| 3248 | |
| 3249 | /* |
no test coverage detected