/*1* Client definitions for the CUPS scheduler.2*3* Copyright © 2021-2022 by OpenPrinting.4* Copyright © 2007-2018 by Apple Inc.5* Copyright © 1997-2007 by Easy Software Products, all rights reserved.6*7* Licensed under Apache License v2.0. See the file "LICENSE" for more8* information.9*/1011#ifdef HAVE_AUTHORIZATION_H12# include <Security/Authorization.h>13#endif /* HAVE_AUTHORIZATION_H */141516/*17* HTTP client structure...18*/1920struct cupsd_client_s21{22int number; /* Connection number */23http_t *http; /* HTTP client connection */24ipp_t *request, /* IPP request information */25*response; /* IPP response information */26cupsd_location_t *best; /* Best match for AAA */27struct timeval start; /* Request start time */28http_state_t operation; /* Request operation */29off_t bytes; /* Bytes transferred for this request */30int is_browser; /* Is the client a web browser? */31int type; /* AuthType for username */32char username[HTTP_MAX_VALUE],33/* Username from Authorization: line */34password[HTTP_MAX_VALUE],35/* Password from Authorization: line */36uri[HTTP_MAX_URI],37/* Localized URL/URI for GET/PUT */38*filename, /* Filename of output file */39*command, /* Command to run */40*options, /* Options for command */41*query_string; /* QUERY_STRING environment variable */42int file; /* Input/output file */43int file_ready; /* Input ready on file/pipe? */44int pipe_pid; /* Pipe process ID (or 0 if not a pipe) */45http_status_t pipe_status; /* HTTP status from pipe process */46int sent_header, /* Non-zero if sent HTTP header */47got_fields, /* Non-zero if all fields seen */48header_used; /* Number of header bytes used */49char header[2048]; /* Header from CGI program */50cups_lang_t *language; /* Language to use */51#ifdef HAVE_TLS52int auto_ssl; /* Automatic test for SSL/TLS */53#endif /* HAVE_TLS */54http_addr_t clientaddr; /* Client's server address */55char clientname[256];/* Client's server name for connection */56int clientport; /* Client's server port for connection */57char servername[256];/* Server name for connection */58int serverport; /* Server port for connection */59#ifdef HAVE_GSSAPI60int have_gss; /* Have GSS credentials? */61uid_t gss_uid; /* User ID for local prints */62#endif /* HAVE_GSSAPI */63#ifdef HAVE_AUTHORIZATION_H64AuthorizationRef authref; /* Authorization ref */65#endif /* HAVE_AUTHORIZATION_H */66};6768#define HTTP(con) ((con)->http)697071/*72* HTTP listener structure...73*/7475typedef struct76{77int fd; /* File descriptor for this server */78http_addr_t address; /* Bind address of socket */79http_encryption_t encryption; /* To encrypt or not to encrypt... */80#ifdef HAVE_ONDEMAND81int on_demand; /* Is this a socket from launchd/systemd/upstart? */82#endif /* HAVE_ONDEMAND */83} cupsd_listener_t;848586/*87* Globals...88*/8990VAR int LastClientNumber VALUE(0),91/* Last client connection number */92LocalPort VALUE(631),93/* Local port to use */94RemotePort VALUE(0);95/* Remote port to use */96VAR http_encryption_t LocalEncryption VALUE(HTTP_ENCRYPT_IF_REQUESTED);97/* Local port encryption to use */98VAR cups_array_t *Listeners VALUE(NULL);99/* Listening sockets */100VAR time_t ListeningPaused VALUE(0);101/* Time when listening was paused */102VAR cups_array_t *Clients VALUE(NULL),103/* HTTP clients */104*ActiveClients VALUE(NULL);105/* Active HTTP clients */106VAR char *ServerHeader VALUE(NULL);107/* Server header in requests */108VAR int CGIPipes[2] VALUE2(-1,-1);109/* Pipes for CGI error/debug output */110VAR cupsd_statbuf_t *CGIStatusBuffer VALUE(NULL);111/* Status buffer for pipes */112113114/*115* Prototypes...116*/117118extern void cupsdAcceptClient(cupsd_listener_t *lis);119extern void cupsdCloseAllClients(void);120extern int cupsdCloseClient(cupsd_client_t *con);121extern void cupsdDeleteAllListeners(void);122extern void cupsdPauseListening(void);123extern int cupsdProcessIPPRequest(cupsd_client_t *con);124extern void cupsdReadClient(cupsd_client_t *con);125extern void cupsdResumeListening(void);126extern int cupsdSendCommand(cupsd_client_t *con, char *command,127char *options, int root);128extern int cupsdSendError(cupsd_client_t *con, http_status_t code,129int auth_type);130extern int cupsdSendHeader(cupsd_client_t *con, http_status_t code,131char *type, int auth_type);132extern void cupsdShutdownClient(cupsd_client_t *con);133extern void cupsdStartListening(void);134extern void cupsdStopListening(void);135extern void cupsdUpdateCGI(void);136extern void cupsdWriteClient(cupsd_client_t *con);137138#ifdef HAVE_TLS139extern int cupsdEndTLS(cupsd_client_t *con);140extern int cupsdStartTLS(cupsd_client_t *con);141#endif /* HAVE_TLS */142143144