]> git.ipfire.org Git - thirdparty/cups.git/blame_incremental - scheduler/client.h
Merge pull request #1454 from zdohnal/osh-fixes-post-cve
[thirdparty/cups.git] / scheduler / client.h
... / ...
CommitLineData
1/*
2 * Client definitions for the CUPS scheduler.
3 *
4 * Copyright © 2020-2025 by OpenPrinting.
5 * Copyright © 2007-2018 by Apple Inc.
6 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
7 *
8 * Licensed under Apache License v2.0. See the file "LICENSE" for more
9 * information.
10 */
11
12#ifdef HAVE_AUTHORIZATION_H
13# include <Security/Authorization.h>
14#endif /* HAVE_AUTHORIZATION_H */
15
16
17/*
18 * HTTP client structure...
19 */
20
21struct cupsd_client_s
22{
23 int number; /* Connection number */
24 http_t *http; /* HTTP client connection */
25 ipp_t *request, /* IPP request information */
26 *response; /* IPP response information */
27 cupsd_location_t *best; /* Best match for AAA */
28 struct timeval start; /* Request start time */
29 http_state_t operation; /* Request operation */
30 off_t bytes; /* Bytes transferred for this request */
31 int is_browser; /* Is the client a web browser? */
32 int type; /* AuthType for username */
33 char username[HTTP_MAX_VALUE],
34 /* Username from Authorization: line */
35 password[HTTP_MAX_VALUE],
36 /* Password from Authorization: line */
37 email[HTTP_MAX_VALUE],
38 /* EMail from OAuth Bearer token */
39 realname[HTTP_MAX_VALUE],
40 /* Real name from OAuth Bearer token */
41 autherror[HTTP_MAX_VALUE],
42 /* Authorization error, if any */
43 uri[2048], /* Localized URL/URI for GET/PUT */
44 *filename, /* Filename of output file */
45 *command, /* Command to run */
46 *options, /* Options for command */
47 *query_string; /* QUERY_STRING environment variable */
48 int file; /* Input/output file */
49 int file_ready; /* Input ready on file/pipe? */
50 int bg_pending; /* Background response pending? */
51 cupsd_printer_t *bg_printer; /* Background printer */
52 int pipe_pid; /* Pipe process ID (or 0 if not a pipe) */
53 http_status_t pipe_status; /* HTTP status from pipe process */
54 int sent_header, /* Non-zero if sent HTTP header */
55 got_fields, /* Non-zero if all fields seen */
56 header_used; /* Number of header bytes used */
57 char header[4096]; /* Header from CGI program */
58 cups_lang_t *language; /* Language to use */
59 int auto_ssl; /* Automatic test for SSL/TLS */
60 time_t tls_start; /* Start time for TLS negotiation */
61 int tls_upgrade; /* Doing TLS upgrade via OPTIONS? */
62 http_encryption_t encryption; /* Type of TLS negotiation */
63 http_addr_t clientaddr; /* Client's server address */
64 char clientname[256];/* Client's server name for connection */
65 int clientport; /* Client's server port for connection */
66 char servername[256];/* Server name for connection */
67 int serverport; /* Server port for connection */
68#ifdef HAVE_GSSAPI
69 int have_gss; /* Have GSS credentials? */
70 uid_t gss_uid; /* User ID for local prints */
71#endif /* HAVE_GSSAPI */
72#ifdef HAVE_AUTHORIZATION_H
73 AuthorizationRef authref; /* Authorization ref */
74#endif /* HAVE_AUTHORIZATION_H */
75};
76
77#define HTTP(con) ((con)->http)
78
79
80/*
81 * HTTP listener structure...
82 */
83
84typedef struct
85{
86 int fd; /* File descriptor for this server */
87 http_addr_t address; /* Bind address of socket */
88 http_encryption_t encryption; /* To encrypt or not to encrypt... */
89#ifdef HAVE_ONDEMAND
90 int on_demand; /* Is this a socket from launchd/systemd/upstart? */
91#endif /* HAVE_ONDEMAND */
92} cupsd_listener_t;
93
94
95/*
96 * Globals...
97 */
98
99VAR int LastClientNumber VALUE(0),
100 /* Last client connection number */
101 LocalPort VALUE(631),
102 /* Local port to use */
103 RemotePort VALUE(0);
104 /* Remote port to use */
105VAR http_encryption_t LocalEncryption VALUE(HTTP_ENCRYPTION_IF_REQUESTED);
106 /* Local port encryption to use */
107VAR cups_array_t *Listeners VALUE(NULL);
108 /* Listening sockets */
109VAR time_t ListeningPaused VALUE(0);
110 /* Time when listening was paused */
111VAR cups_array_t *Clients VALUE(NULL),
112 /* HTTP clients */
113 *ActiveClients VALUE(NULL);
114 /* Active HTTP clients */
115VAR char *ServerHeader VALUE(NULL);
116 /* Server header in requests */
117VAR int CGIPipes[2] VALUE2(-1,-1);
118 /* Pipes for CGI error/debug output */
119VAR cupsd_statbuf_t *CGIStatusBuffer VALUE(NULL);
120 /* Status buffer for pipes */
121
122
123/*
124 * Prototypes...
125 */
126
127extern void cupsdAcceptClient(cupsd_listener_t *lis);
128extern void cupsdCloseAllClients(void);
129extern int cupsdCloseClient(cupsd_client_t *con);
130extern void cupsdDeleteAllListeners(void);
131extern void cupsdPauseListening(void);
132extern int cupsdProcessIPPRequest(cupsd_client_t *con);
133extern void cupsdReadClient(cupsd_client_t *con);
134extern void cupsdResumeListening(void);
135extern int cupsdSendCommand(cupsd_client_t *con, char *command,
136 char *options, int root);
137extern int cupsdSendError(cupsd_client_t *con, http_status_t code,
138 int auth_type);
139extern int cupsdSendHeader(cupsd_client_t *con, http_status_t code,
140 char *type, int auth_type);
141extern void cupsdShutdownClient(cupsd_client_t *con);
142extern void cupsdStartListening(void);
143extern void cupsdStopListening(void);
144extern void cupsdUpdateCGI(void);
145extern void cupsdWriteClient(cupsd_client_t *con);
146
147extern int cupsdEndTLS(cupsd_client_t *con);
148extern int cupsdStartTLS(cupsd_client_t *con);