2 * "$Id: client.c,v 1.86 2001/02/21 20:16:46 mike Exp $"
4 * Client routines for the Common UNIX Printing System (CUPS) scheduler.
6 * Copyright 1997-2001 by Easy Software Products, all rights reserved.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * AcceptClient() - Accept a new client.
27 * CloseAllClients() - Close all remote clients immediately.
28 * CloseClient() - Close a remote client.
29 * EncryptClient() - Enable encryption for the client...
30 * ReadClient() - Read data from a client.
31 * SendCommand() - Send output from a command via HTTP.
32 * SendError() - Send an error message via HTTP.
33 * SendFile() - Send a file via HTTP.
34 * SendHeader() - Send an HTTP request.
35 * WriteClient() - Write data to a client as needed.
36 * check_if_modified() - Decode an "If-Modified-Since" line.
37 * decode_auth() - Decode an authorization string.
38 * get_file() - Get a filename and state info.
39 * pipe_command() - Pipe the output of a command to the remote client.
43 * Include necessary headers...
49 # include <openssl/err.h>
50 # include <openssl/ssl.h>
51 # include <openssl/rand.h>
52 #endif /* HAVE_LIBSSL */
59 static int check_if_modified(client_t
*con
, struct stat
*filestats
);
60 static void decode_auth(client_t
*con
);
61 static char *get_file(client_t
*con
, struct stat
*filestats
);
62 static int pipe_command(client_t
*con
, int infile
, int *outfile
, char *command
, char *options
);
66 * 'AcceptClient()' - Accept a new client.
70 AcceptClient(listener_t
*lis
) /* I - Listener socket */
72 int i
; /* Looping var */
73 int val
; /* Parameter value */
74 client_t
*con
; /* New client pointer */
75 unsigned address
;/* Address of client */
76 struct hostent
*host
; /* Host entry for address */
79 LogMessage(L_DEBUG2
, "AcceptClient(%08x) %d NumClients = %d",
80 lis
, lis
->fd
, NumClients
);
83 * Make sure we don't have a full set of clients already...
86 if (NumClients
== MaxClients
)
90 * Get a pointer to the next available client...
93 con
= Clients
+ NumClients
;
95 memset(con
, 0, sizeof(client_t
));
96 con
->http
.activity
= time(NULL
);
99 * Accept the client and get the remote address...
102 val
= sizeof(struct sockaddr_in
);
104 if ((con
->http
.fd
= accept(lis
->fd
, (struct sockaddr
*)&(con
->http
.hostaddr
),
107 LogMessage(L_ERROR
, "Unable to accept client connection - %s.",
112 con
->http
.hostaddr
.sin_port
= lis
->address
.sin_port
;
115 * Get the hostname or format the IP address as needed...
118 address
= ntohl(con
->http
.hostaddr
.sin_addr
.s_addr
);
122 host
= gethostbyaddr((char *)&(con
->http
.hostaddr
.sin_addr
),
123 sizeof(struct in_addr
), AF_INET
);
125 host
= gethostbyaddr(&(con
->http
.hostaddr
.sin_addr
),
126 sizeof(struct in_addr
), AF_INET
);
131 if (con
->http
.hostaddr
.sin_addr
.s_addr
== ServerAddr
.sin_addr
.s_addr
)
134 * Map accesses from the same host to the server name.
137 strncpy(con
->http
.hostname
, ServerName
, sizeof(con
->http
.hostname
) - 1);
139 else if (host
== NULL
)
141 sprintf(con
->http
.hostname
, "%d.%d.%d.%d", (address
>> 24) & 255,
142 (address
>> 16) & 255, (address
>> 8) & 255, address
& 255);
144 if (HostNameLookups
== 2)
147 * Can't have an unresolved IP address with double-lookups enabled...
151 closesocket(con
->http
.fd
);
156 LogMessage(L_WARN
, "Name lookup failed - connection from %s closed!",
162 strncpy(con
->http
.hostname
, host
->h_name
, sizeof(con
->http
.hostname
) - 1);
164 if (HostNameLookups
== 2)
167 * Do double lookups as needed...
170 if ((host
= gethostbyname(con
->http
.hostname
)) != NULL
)
173 * See if the hostname maps to the IP address...
176 if (host
->h_length
!= 4 || host
->h_addrtype
!= AF_INET
)
179 * Not an IPv4 address...
187 * Compare all of the addresses against this one...
190 for (i
= 0; host
->h_addr_list
[i
]; i
++)
191 if (memcmp(&(con
->http
.hostaddr
.sin_addr
), host
->h_addr_list
[i
], 4) == 0)
194 if (!host
->h_addr_list
[i
])
202 * Can't have a hostname that doesn't resolve to the same IP address
203 * with double-lookups enabled...
207 closesocket(con
->http
.fd
);
212 LogMessage(L_WARN
, "IP lookup failed - connection from %s closed!",
218 LogMessage(L_DEBUG
, "AcceptClient() %d from %s:%d.", con
->http
.fd
,
219 con
->http
.hostname
, ntohs(con
->http
.hostaddr
.sin_port
));
222 * Add the socket to the select() input mask.
225 fcntl(con
->http
.fd
, F_SETFD
, fcntl(con
->http
.fd
, F_GETFD
) | FD_CLOEXEC
);
227 LogMessage(L_DEBUG2
, "AcceptClient() Adding fd %d to InputSet...",
229 FD_SET(con
->http
.fd
, &InputSet
);
234 * Temporarily suspend accept()'s until we lose a client...
237 if (NumClients
== MaxClients
)
242 * See if we are connecting on a secure port...
245 if (lis
->encryption
== HTTP_ENCRYPT_ALWAYS
)
248 * https connection; go secure...
253 #endif /* HAVE_LIBSSL */
258 * 'CloseAllClients()' - Close all remote clients immediately.
262 CloseAllClients(void)
264 while (NumClients
> 0)
265 CloseClient(Clients
);
270 * 'CloseClient()' - Close a remote client.
274 CloseClient(client_t
*con
) /* I - Client to close */
276 int status
; /* Exit status of pipe command */
278 SSL_CTX
*context
; /* Context for encryption */
279 SSL
*conn
; /* Connection for encryption */
280 #endif /* HAVE_LIBSSL */
283 LogMessage(L_DEBUG
, "CloseClient() %d", con
->http
.fd
);
287 * Shutdown encryption as needed...
292 conn
= (SSL
*)(con
->http
.tls
);
293 context
= SSL_get_SSL_CTX(conn
);
296 SSL_CTX_free(context
);
299 con
->http
.tls
= NULL
;
301 #endif /* HAVE_LIBSSL */
304 * Close the socket and clear the file from the input set for select()...
307 if (con
->http
.fd
> 0)
309 LogMessage(L_DEBUG2
, "CloseClient: Removing fd %d from InputSet...",
312 FD_CLR(con
->http
.fd
, &InputSet
);
313 FD_CLR(con
->http
.fd
, &OutputSet
);
317 if (con
->pipe_pid
!= 0)
319 LogMessage(L_DEBUG2
, "CloseClient: Removing fd %d from InputSet...",
321 FD_CLR(con
->file
, &InputSet
);
327 * Close the open data file...
332 kill(con
->pipe_pid
, SIGKILL
);
333 waitpid(con
->pipe_pid
, &status
, WNOHANG
);
336 FD_CLR(con
->file
, &InputSet
);
343 ippDelete(con
->request
);
349 ippDelete(con
->response
);
350 con
->response
= NULL
;
355 cupsLangFree(con
->language
);
356 con
->language
= NULL
;
360 * Re-enable new client connections if we are going back under the
364 if (NumClients
== MaxClients
)
368 * Compact the list of clients as necessary...
373 if (con
< (Clients
+ NumClients
))
374 memcpy(con
, con
+ 1, (Clients
+ NumClients
- con
) * sizeof(client_t
));
379 * 'EncryptClient()' - Enable encryption for the client...
382 int /* O - 1 on success, 0 on error */
383 EncryptClient(client_t
*con
) /* I - Client to encrypt */
386 SSL_CTX
*context
; /* Context for encryption */
387 SSL
*conn
; /* Connection for encryption */
388 int error
; /* Error code */
392 * Create the SSL context and accept the connection...
395 context
= SSL_CTX_new(SSLv23_method());
396 conn
= SSL_new(context
);
398 SSL_use_PrivateKey_file(conn
, ServerKey
, SSL_FILETYPE_PEM
);
399 SSL_use_certificate_file(conn
, ServerCertificate
, SSL_FILETYPE_PEM
);
401 SSL_set_fd(conn
, con
->http
.fd
);
402 if (SSL_accept(conn
) != 1)
404 while ((error
= ERR_get_error()) != 0)
405 LogMessage(L_ERROR
, "EncryptClient: %s", ERR_error_string(error
, NULL
));
407 SSL_CTX_free(context
);
412 con
->http
.tls
= conn
;
416 #endif /* HAVE_LIBSSL */
421 * 'ReadClient()' - Read data from a client.
424 int /* O - 1 on success, 0 on error */
425 ReadClient(client_t
*con
) /* I - Client to read from */
427 char line
[8192], /* Line from client... */
428 operation
[64], /* Operation code from socket */
429 version
[64]; /* HTTP version number string */
430 int major
, minor
; /* HTTP version numbers */
431 http_status_t status
; /* Transfer status */
432 ipp_state_t ipp_state
; /* State of IPP transfer */
433 int bytes
; /* Number of bytes to POST */
434 char *filename
; /* Name of file for GET/HEAD */
435 struct stat filestats
; /* File information */
436 mime_type_t
*type
; /* MIME type of file */
437 printer_t
*p
; /* Printer */
438 location_t
*best
; /* Best match for authentication */
439 static unsigned request_id
= 0;/* Request ID for temp files */
442 status
= HTTP_CONTINUE
;
444 switch (con
->http
.state
)
448 * See if we've received a request line...
451 if (httpGets(line
, sizeof(line
) - 1, HTTP(con
)) == NULL
)
458 * Ignore blank request lines...
465 * Clear other state variables...
468 httpClearFields(HTTP(con
));
470 con
->http
.activity
= time(NULL
);
471 con
->http
.version
= HTTP_1_0
;
472 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
473 con
->http
.data_encoding
= HTTP_ENCODE_LENGTH
;
474 con
->http
.data_remaining
= 0;
475 con
->operation
= HTTP_WAITING
;
479 con
->command
[0] = '\0';
480 con
->username
[0] = '\0';
481 con
->password
[0] = '\0';
484 if (con
->language
!= NULL
)
486 cupsLangFree(con
->language
);
487 con
->language
= NULL
;
491 * Grab the request line...
494 switch (sscanf(line
, "%63s%1023s%63s", operation
, con
->uri
, version
))
497 SendError(con
, HTTP_BAD_REQUEST
);
501 con
->http
.version
= HTTP_0_9
;
504 if (sscanf(version
, "HTTP/%d.%d", &major
, &minor
) != 2)
506 SendError(con
, HTTP_BAD_REQUEST
);
513 con
->http
.version
= (http_version_t
)(major
* 100 + minor
);
514 if (con
->http
.version
== HTTP_1_1
)
515 con
->http
.keep_alive
= HTTP_KEEPALIVE_ON
;
517 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
521 SendError(con
, HTTP_NOT_SUPPORTED
);
529 * Process the request...
532 if (strcmp(operation
, "GET") == 0)
533 con
->http
.state
= HTTP_GET
;
534 else if (strcmp(operation
, "PUT") == 0)
535 con
->http
.state
= HTTP_PUT
;
536 else if (strcmp(operation
, "POST") == 0)
537 con
->http
.state
= HTTP_POST
;
538 else if (strcmp(operation
, "DELETE") == 0)
539 con
->http
.state
= HTTP_DELETE
;
540 else if (strcmp(operation
, "TRACE") == 0)
541 con
->http
.state
= HTTP_TRACE
;
542 else if (strcmp(operation
, "OPTIONS") == 0)
543 con
->http
.state
= HTTP_OPTIONS
;
544 else if (strcmp(operation
, "HEAD") == 0)
545 con
->http
.state
= HTTP_HEAD
;
548 SendError(con
, HTTP_BAD_REQUEST
);
553 con
->start
= time(NULL
);
554 con
->operation
= con
->http
.state
;
556 LogMessage(L_DEBUG
, "ReadClient() %d %s %s HTTP/%d.%d", con
->http
.fd
,
558 con
->http
.version
/ 100, con
->http
.version
% 100);
560 con
->http
.status
= HTTP_OK
;
570 * Parse incoming parameters until the status changes...
573 status
= httpUpdate(HTTP(con
));
575 if (status
!= HTTP_OK
&& status
!= HTTP_CONTINUE
)
577 SendError(con
, HTTP_BAD_REQUEST
);
584 break; /* Anti-compiler-warning-code */
588 * Handle new transfers...
591 if (status
== HTTP_OK
)
593 con
->language
= cupsLangGet(con
->http
.fields
[HTTP_FIELD_ACCEPT_LANGUAGE
]);
597 if (strncmp(con
->http
.fields
[HTTP_FIELD_CONNECTION
], "Keep-Alive", 10) == 0)
598 con
->http
.keep_alive
= HTTP_KEEPALIVE_ON
;
600 if (con
->http
.fields
[HTTP_FIELD_HOST
][0] == '\0' &&
601 con
->http
.version
>= HTTP_1_1
)
604 * HTTP/1.1 and higher require the "Host:" field...
607 if (!SendError(con
, HTTP_BAD_REQUEST
))
613 else if (con
->operation
== HTTP_OPTIONS
)
616 * Do OPTIONS command...
619 if ((best
= FindBest(con
)) != NULL
&&
620 best
->type
!= AUTH_NONE
)
622 if (!SendHeader(con
, HTTP_UNAUTHORIZED
, NULL
))
629 if ((strcasecmp(con
->http
.fields
[HTTP_FIELD_CONNECTION
], "Upgrade") == 0 ||
630 (best
!= NULL
&& best
->encryption
== HTTP_ENCRYPT_ALWAYS
)) &&
631 con
->http
.tls
== NULL
)
635 * Do encryption stuff...
638 if (!SendHeader(con
, HTTP_SWITCHING_PROTOCOLS
, NULL
))
644 httpPrintf(HTTP(con
), "Connection: Upgrade\r\n");
645 httpPrintf(HTTP(con
), "Upgrade: TLS/1.0,SSL/2.0,SSL/3.0\r\n");
646 httpPrintf(HTTP(con
), "Content-Length: 0\r\n");
647 httpPrintf(HTTP(con
), "\r\n");
651 if (!SendError(con
, HTTP_NOT_IMPLEMENTED
))
656 #endif /* HAVE_LIBSSL */
659 if (!SendHeader(con
, HTTP_OK
, NULL
))
665 httpPrintf(HTTP(con
), "Allow: GET, HEAD, OPTIONS, POST\r\n");
666 httpPrintf(HTTP(con
), "Content-Length: 0\r\n");
667 httpPrintf(HTTP(con
), "\r\n");
669 else if (strstr(con
->uri
, "..") != NULL
)
672 * Protect against malicious users!
675 if (!SendError(con
, HTTP_FORBIDDEN
))
681 else if (con
->uri
[0] != '/')
684 * Don't allow proxying (yet)...
687 if (!SendError(con
, HTTP_METHOD_NOT_ALLOWED
))
695 if ((status
= IsAuthorized(con
)) == HTTP_UPGRADE_REQUIRED
)
699 * Do encryption stuff...
702 if (!SendHeader(con
, HTTP_SWITCHING_PROTOCOLS
, NULL
))
708 httpPrintf(HTTP(con
), "Connection: Upgrade\r\n");
709 httpPrintf(HTTP(con
), "Upgrade: TLS/1.0,SSL/2.0,SSL/3.0\r\n");
710 httpPrintf(HTTP(con
), "Content-Length: 0\r\n");
711 httpPrintf(HTTP(con
), "\r\n");
715 if (!SendError(con
, HTTP_NOT_IMPLEMENTED
))
720 #endif /* HAVE_LIBSSL */
722 else if (status
!= HTTP_OK
)
724 SendError(con
, status
);
729 switch (con
->http
.state
)
732 if (strncmp(con
->uri
, "/printers/", 10) == 0 &&
733 strcmp(con
->uri
+ strlen(con
->uri
) - 4, ".ppd") == 0)
736 * Send PPD file - get the real printer name since printer
737 * names are not case sensitive but filenames can be...
740 con
->uri
[strlen(con
->uri
) - 4] = '\0'; /* Drop ".ppd" */
742 if ((p
= FindPrinter(con
->uri
+ 10)) != NULL
)
743 snprintf(con
->uri
, sizeof(con
->uri
), "/ppd/%s.ppd", p
->name
);
746 if (!SendError(con
, HTTP_NOT_FOUND
))
756 if (strncmp(con
->uri
, "/admin", 6) == 0 ||
757 strncmp(con
->uri
, "/printers", 9) == 0 ||
758 strncmp(con
->uri
, "/classes", 8) == 0 ||
759 strncmp(con
->uri
, "/jobs", 5) == 0)
765 if (strncmp(con
->uri
, "/admin", 6) == 0)
767 snprintf(con
->command
, sizeof(con
->command
),
768 "%s/cgi-bin/admin.cgi", ServerBin
);
769 con
->options
= con
->uri
+ 6;
771 else if (strncmp(con
->uri
, "/printers", 9) == 0)
773 snprintf(con
->command
, sizeof(con
->command
),
774 "%s/cgi-bin/printers.cgi", ServerBin
);
775 con
->options
= con
->uri
+ 9;
777 else if (strncmp(con
->uri
, "/classes", 8) == 0)
779 snprintf(con
->command
, sizeof(con
->command
),
780 "%s/cgi-bin/classes.cgi", ServerBin
);
781 con
->options
= con
->uri
+ 8;
785 snprintf(con
->command
, sizeof(con
->command
),
786 "%s/cgi-bin/jobs.cgi", ServerBin
);
787 con
->options
= con
->uri
+ 5;
790 if (con
->options
[0] == '/')
793 if (!SendCommand(con
, con
->command
, con
->options
))
795 if (!SendError(con
, HTTP_NOT_FOUND
))
802 LogRequest(con
, HTTP_OK
);
804 if (con
->http
.version
<= HTTP_1_0
)
805 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
813 if ((filename
= get_file(con
, &filestats
)) == NULL
)
815 if (!SendError(con
, HTTP_NOT_FOUND
))
821 else if (!check_if_modified(con
, &filestats
))
823 if (!SendError(con
, HTTP_NOT_MODIFIED
))
831 type
= mimeFileType(MimeDatabase
, filename
);
833 strcpy(line
, "text/plain");
835 snprintf(line
, sizeof(line
), "%s/%s", type
->super
, type
->type
);
837 if (!SendFile(con
, HTTP_OK
, filename
, line
, &filestats
))
846 case HTTP_POST_RECV
:
848 * See if the POST request includes a Content-Length field, and if
849 * so check the length against any limits that are set...
852 LogMessage(L_DEBUG2
, "POST %s", con
->uri
);
853 LogMessage(L_DEBUG2
, "CONTENT_TYPE = %s", con
->http
.fields
[HTTP_FIELD_CONTENT_TYPE
]);
855 if (con
->http
.fields
[HTTP_FIELD_CONTENT_LENGTH
][0] &&
856 atoi(con
->http
.fields
[HTTP_FIELD_CONTENT_LENGTH
]) > MaxRequestSize
&&
860 * Request too large...
863 if (!SendError(con
, HTTP_REQUEST_TOO_LARGE
))
873 * See what kind of POST request this is; for IPP requests the
874 * content-type field will be "application/ipp"...
877 if (strcmp(con
->http
.fields
[HTTP_FIELD_CONTENT_TYPE
], "application/ipp") == 0)
878 con
->request
= ippNew();
879 else if (strncmp(con
->uri
, "/admin", 6) == 0 ||
880 strncmp(con
->uri
, "/printers", 9) == 0 ||
881 strncmp(con
->uri
, "/classes", 8) == 0 ||
882 strncmp(con
->uri
, "/jobs", 5) == 0)
888 if (strncmp(con
->uri
, "/admin", 6) == 0)
890 snprintf(con
->command
, sizeof(con
->command
),
891 "%s/cgi-bin/admin.cgi", ServerBin
);
892 con
->options
= con
->uri
+ 6;
894 else if (strncmp(con
->uri
, "/printers", 9) == 0)
896 snprintf(con
->command
, sizeof(con
->command
),
897 "%s/cgi-bin/printers.cgi", ServerBin
);
898 con
->options
= con
->uri
+ 9;
900 else if (strncmp(con
->uri
, "/classes", 8) == 0)
902 snprintf(con
->command
, sizeof(con
->command
),
903 "%s/cgi-bin/classes.cgi", ServerBin
);
904 con
->options
= con
->uri
+ 8;
908 snprintf(con
->command
, sizeof(con
->command
),
909 "%s/cgi-bin/jobs.cgi", ServerBin
);
910 con
->options
= con
->uri
+ 5;
913 if (con
->options
[0] == '/')
916 LogMessage(L_DEBUG2
, "ReadClient() %d command=\"%s\", options = \"%s\"",
917 con
->http
.fd
, con
->command
, con
->options
);
919 if (con
->http
.version
<= HTTP_1_0
)
920 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
922 else if (!SendError(con
, HTTP_UNAUTHORIZED
))
932 SendError(con
, HTTP_NOT_IMPLEMENTED
);
937 if (strncmp(con
->uri
, "/printers/", 10) == 0 &&
938 strcmp(con
->uri
+ strlen(con
->uri
) - 4, ".ppd") == 0)
941 * Send PPD file - get the real printer name since printer
942 * names are not case sensitive but filenames can be...
945 con
->uri
[strlen(con
->uri
) - 4] = '\0'; /* Drop ".ppd" */
947 if ((p
= FindPrinter(con
->uri
+ 10)) != NULL
)
948 snprintf(con
->uri
, sizeof(con
->uri
), "/ppd/%s.ppd", p
->name
);
951 if (!SendError(con
, HTTP_NOT_FOUND
))
961 if (strncmp(con
->uri
, "/admin/", 7) == 0 ||
962 strncmp(con
->uri
, "/printers/", 10) == 0 ||
963 strncmp(con
->uri
, "/classes/", 9) == 0 ||
964 strncmp(con
->uri
, "/jobs/", 6) == 0)
970 if (!SendHeader(con
, HTTP_OK
, "text/html"))
976 if (httpPrintf(HTTP(con
), "\r\n") < 0)
982 LogRequest(con
, HTTP_OK
);
984 else if ((filename
= get_file(con
, &filestats
)) == NULL
)
986 if (!SendHeader(con
, HTTP_NOT_FOUND
, "text/html"))
992 LogRequest(con
, HTTP_NOT_FOUND
);
994 else if (!check_if_modified(con
, &filestats
))
996 if (!SendError(con
, HTTP_NOT_MODIFIED
))
1002 LogRequest(con
, HTTP_NOT_MODIFIED
);
1010 type
= mimeFileType(MimeDatabase
, filename
);
1012 strcpy(line
, "text/plain");
1014 snprintf(line
, sizeof(line
), "%s/%s", type
->super
, type
->type
);
1016 if (!SendHeader(con
, HTTP_OK
, line
))
1022 if (httpPrintf(HTTP(con
), "Last-Modified: %s\r\n",
1023 httpGetDateString(filestats
.st_mtime
)) < 0)
1029 if (httpPrintf(HTTP(con
), "Content-Length: %d\r\n",
1030 filestats
.st_size
) < 0)
1036 LogRequest(con
, HTTP_OK
);
1039 if (httpPrintf(HTTP(con
), "\r\n") < 0)
1045 con
->http
.state
= HTTP_WAITING
;
1049 break; /* Anti-compiler-warning-code */
1055 * Handle any incoming data...
1058 switch (con
->http
.state
)
1060 case HTTP_PUT_RECV
:
1063 case HTTP_POST_RECV
:
1064 LogMessage(L_DEBUG2
, "ReadClient() %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d",
1066 con
->http
.data_encoding
== HTTP_ENCODE_CHUNKED
? "chunked" : "length",
1067 con
->http
.data_remaining
, con
->file
);
1069 if (con
->request
!= NULL
)
1072 * Grab any request data from the connection...
1075 if ((ipp_state
= ippRead(&(con
->http
), con
->request
)) == IPP_ERROR
)
1077 LogMessage(L_ERROR
, "ReadClient() %d IPP Read Error!",
1082 else if (ipp_state
!= IPP_DATA
)
1085 con
->bytes
+= ippLength(con
->request
);
1088 if (con
->file
== 0 && con
->http
.state
!= HTTP_POST_SEND
)
1091 * Create a file as needed for the request data...
1094 snprintf(con
->filename
, sizeof(con
->filename
), "%s/%08x",
1095 RequestRoot
, request_id
++);
1096 con
->file
= open(con
->filename
, O_WRONLY
| O_CREAT
| O_TRUNC
, 0640);
1097 fchmod(con
->file
, 0640);
1098 fchown(con
->file
, User
, Group
);
1100 LogMessage(L_DEBUG2
, "ReadClient() %d REQUEST %s", con
->http
.fd
,
1105 if (!SendError(con
, HTTP_REQUEST_TOO_LARGE
))
1113 if (con
->http
.state
!= HTTP_POST_SEND
)
1115 if ((bytes
= httpRead(HTTP(con
), line
, sizeof(line
))) < 0)
1122 con
->bytes
+= bytes
;
1124 LogMessage(L_DEBUG2
, "ReadClient() %d writing %d bytes",
1125 con
->http
.fd
, bytes
);
1127 if (write(con
->file
, line
, bytes
) < bytes
)
1131 unlink(con
->filename
);
1133 if (!SendError(con
, HTTP_REQUEST_TOO_LARGE
))
1140 else if (con
->http
.state
!= HTTP_POST_SEND
)
1147 if (con
->http
.state
== HTTP_POST_SEND
)
1151 fstat(con
->file
, &filestats
);
1155 if (filestats
.st_size
> MaxRequestSize
&&
1159 * Request is too big; remove it and send an error...
1162 unlink(con
->filename
);
1167 * Delete any IPP request data...
1170 ippDelete(con
->request
);
1171 con
->request
= NULL
;
1174 if (!SendError(con
, HTTP_REQUEST_TOO_LARGE
))
1181 if (con
->command
[0])
1183 if (!SendCommand(con
, con
->command
, con
->options
))
1185 if (!SendError(con
, HTTP_NOT_FOUND
))
1192 LogRequest(con
, HTTP_OK
);
1197 ProcessIPPRequest(con
);
1202 break; /* Anti-compiler-warning-code */
1205 if (!con
->http
.keep_alive
&& con
->http
.state
== HTTP_WAITING
)
1216 * 'SendCommand()' - Send output from a command via HTTP.
1220 SendCommand(client_t
*con
,
1227 if (con
->filename
[0])
1228 fd
= open(con
->filename
, O_RDONLY
);
1230 fd
= open("/dev/null", O_RDONLY
);
1232 con
->pipe_pid
= pipe_command(con
, fd
, &(con
->file
), command
, options
);
1236 LogMessage(L_DEBUG
, "SendCommand() %d command=\"%s\" file=%d pipe_pid=%d",
1237 con
->http
.fd
, command
, con
->file
, con
->pipe_pid
);
1239 if (con
->pipe_pid
== 0)
1242 fcntl(con
->file
, F_SETFD
, fcntl(con
->file
, F_GETFD
) | FD_CLOEXEC
);
1244 LogMessage(L_DEBUG2
, "SendCommand: Adding fd %d to InputSet...", con
->file
);
1245 FD_SET(con
->file
, &InputSet
);
1246 FD_SET(con
->http
.fd
, &OutputSet
);
1248 if (!SendHeader(con
, HTTP_OK
, NULL
))
1251 if (con
->http
.version
== HTTP_1_1
)
1253 con
->http
.data_encoding
= HTTP_ENCODE_CHUNKED
;
1255 if (httpPrintf(HTTP(con
), "Transfer-Encoding: chunked\r\n") < 0)
1259 con
->got_fields
= 0;
1267 * 'SendError()' - Send an error message via HTTP.
1270 int /* O - 1 if successful, 0 otherwise */
1271 SendError(client_t
*con
, /* I - Connection */
1272 http_status_t code
) /* I - Error code */
1274 char message
[1024]; /* Message for user */
1278 * Put the request in the access_log file...
1281 if (con
->operation
> HTTP_WAITING
)
1282 LogRequest(con
, code
);
1285 * To work around bugs in some proxies, don't use Keep-Alive for some
1289 if (code
>= HTTP_BAD_REQUEST
)
1290 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
1293 * Send an error message back to the client. If the error code is a
1294 * 400 or 500 series, make sure the message contains some text, too!
1297 if (!SendHeader(con
, code
, NULL
))
1301 if (code
== HTTP_UPGRADE_REQUIRED
)
1303 if (httpPrintf(HTTP(con
), "Connection: Upgrade\r\n") < 0)
1306 if (httpPrintf(HTTP(con
), "Upgrade: TLS/1.0,SSL/2.0,SSL/3.0\r\n") < 0)
1309 #endif /* HAVE_LIBSSL */
1311 if (con
->http
.version
>= HTTP_1_1
&& !con
->http
.keep_alive
)
1313 if (httpPrintf(HTTP(con
), "Connection: close\r\n") < 0)
1317 if (code
>= HTTP_BAD_REQUEST
)
1320 * Send a human-readable error message.
1323 snprintf(message
, sizeof(message
),
1324 "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>"
1325 "<BODY><H1>%s</H1>%s</BODY></HTML>\n",
1326 code
, httpStatus(code
), httpStatus(code
),
1327 con
->language
? con
->language
->messages
[code
] :
1330 if (httpPrintf(HTTP(con
), "Content-Type: text/html\r\n") < 0)
1332 if (httpPrintf(HTTP(con
), "Content-Length: %d\r\n", strlen(message
)) < 0)
1334 if (httpPrintf(HTTP(con
), "\r\n") < 0)
1336 if (httpPrintf(HTTP(con
), "%s", message
) < 0)
1339 else if (httpPrintf(HTTP(con
), "\r\n") < 0)
1342 con
->http
.state
= HTTP_WAITING
;
1349 * 'SendFile()' - Send a file via HTTP.
1353 SendFile(client_t
*con
,
1357 struct stat
*filestats
)
1359 con
->file
= open(filename
, O_RDONLY
);
1361 LogMessage(L_DEBUG
, "SendFile() %d file=%d", con
->http
.fd
, con
->file
);
1366 fcntl(con
->file
, F_SETFD
, fcntl(con
->file
, F_GETFD
) | FD_CLOEXEC
);
1370 if (!SendHeader(con
, code
, type
))
1373 if (httpPrintf(HTTP(con
), "Last-Modified: %s\r\n", httpGetDateString(filestats
->st_mtime
)) < 0)
1375 if (httpPrintf(HTTP(con
), "Content-Length: %d\r\n", filestats
->st_size
) < 0)
1377 if (httpPrintf(HTTP(con
), "\r\n") < 0)
1380 FD_SET(con
->http
.fd
, &OutputSet
);
1387 * 'SendHeader()' - Send an HTTP request.
1390 int /* O - 1 on success, 0 on failure */
1391 SendHeader(client_t
*con
, /* I - Client to send to */
1392 http_status_t code
, /* I - HTTP status code */
1393 char *type
) /* I - MIME type of document */
1395 location_t
*loc
; /* Authentication location */
1398 if (httpPrintf(HTTP(con
), "HTTP/%d.%d %d %s\r\n", con
->http
.version
/ 100,
1399 con
->http
.version
% 100, code
, httpStatus(code
)) < 0)
1401 if (httpPrintf(HTTP(con
), "Date: %s\r\n", httpGetDateString(time(NULL
))) < 0)
1403 if (httpPrintf(HTTP(con
), "Server: CUPS/1.1\r\n") < 0)
1405 if (con
->http
.keep_alive
&& con
->http
.version
>= HTTP_1_0
)
1407 if (httpPrintf(HTTP(con
), "Connection: Keep-Alive\r\n") < 0)
1409 if (httpPrintf(HTTP(con
), "Keep-Alive: timeout=%d\r\n", KeepAliveTimeout
) < 0)
1412 if (code
== HTTP_METHOD_NOT_ALLOWED
)
1413 if (httpPrintf(HTTP(con
), "Allow: GET, HEAD, OPTIONS, POST\r\n") < 0)
1416 if (code
== HTTP_UNAUTHORIZED
)
1418 loc
= FindBest(con
); /* This already succeeded in IsAuthorized */
1420 if (loc
->type
== AUTH_BASIC
)
1422 if (httpPrintf(HTTP(con
), "WWW-Authenticate: Basic realm=\"CUPS\"\r\n") < 0)
1427 if (httpPrintf(HTTP(con
), "WWW-Authenticate: Digest realm=\"CUPS\" "
1428 "nonce=\"%s\"\r\n", con
->http
.hostname
) < 0)
1432 if (con
->language
!= NULL
)
1434 if (httpPrintf(HTTP(con
), "Content-Language: %s\r\n",
1435 con
->language
->language
) < 0)
1439 if (httpPrintf(HTTP(con
), "Content-Type: %s; charset=%s\r\n", type
,
1440 cupsLangEncoding(con
->language
)) < 0)
1443 else if (type
!= NULL
)
1444 if (httpPrintf(HTTP(con
), "Content-Type: %s\r\n", type
) < 0)
1452 * 'WriteClient()' - Write data to a client as needed.
1455 int /* O - 1 if success, 0 if fail */
1456 WriteClient(client_t
*con
) /* I - Client connection */
1458 int bytes
; /* Number of bytes written */
1459 char buf
[HTTP_MAX_BUFFER
+ 1];/* Data buffer */
1460 char *bufptr
; /* Pointer into buffer */
1461 ipp_state_t ipp_state
; /* IPP state value */
1464 if (con
->http
.state
!= HTTP_GET_SEND
&&
1465 con
->http
.state
!= HTTP_POST_SEND
)
1468 if (con
->response
!= NULL
)
1470 ipp_state
= ippWrite(&(con
->http
), con
->response
);
1471 bytes
= ipp_state
!= IPP_ERROR
&& ipp_state
!= IPP_DATA
;
1473 else if ((bytes
= read(con
->file
, buf
, HTTP_MAX_BUFFER
)) > 0)
1475 if (con
->pipe_pid
&& !con
->got_fields
)
1478 * Inspect the data for Content-Type and other fields.
1483 for (bufptr
= buf
; !con
->got_fields
&& *bufptr
; bufptr
++)
1484 if (*bufptr
== '\n')
1487 * Send line to client...
1490 if (bufptr
> buf
&& bufptr
[-1] == '\r')
1494 httpPrintf(HTTP(con
), "%s\r\n", buf
);
1495 LogMessage(L_DEBUG2
, "WriteClient() %d %s", con
->http
.fd
, buf
);
1501 bytes
-= (bufptr
- buf
);
1502 memcpy(buf
, bufptr
, bytes
+ 1);
1506 * See if the line was empty...
1509 if (con
->field_col
== 0)
1510 con
->got_fields
= 1;
1514 else if (*bufptr
!= '\r')
1517 if (bytes
> 0 && !con
->got_fields
)
1520 * Remaining text needs to go out...
1523 httpPrintf(HTTP(con
), "%s", buf
);
1525 con
->http
.activity
= time(NULL
);
1528 else if (bytes
== 0)
1530 con
->http
.activity
= time(NULL
);
1535 if (httpWrite(HTTP(con
), buf
, bytes
) < 0)
1541 con
->bytes
+= bytes
;
1546 LogRequest(con
, HTTP_OK
);
1548 if (con
->http
.data_encoding
== HTTP_ENCODE_CHUNKED
)
1550 if (httpPrintf(HTTP(con
), "0\r\n\r\n") < 0)
1557 con
->http
.state
= HTTP_WAITING
;
1559 FD_CLR(con
->http
.fd
, &OutputSet
);
1563 LogMessage(L_DEBUG2
, "WriteClient() Removing fd %d from InputSet...",
1565 FD_CLR(con
->file
, &InputSet
);
1568 kill(con
->pipe_pid
, SIGTERM
);
1575 if (con
->filename
[0])
1576 unlink(con
->filename
);
1578 if (con
->request
!= NULL
)
1580 ippDelete(con
->request
);
1581 con
->request
= NULL
;
1584 if (con
->response
!= NULL
)
1586 ippDelete(con
->response
);
1587 con
->response
= NULL
;
1590 if (!con
->http
.keep_alive
)
1598 LogMessage(L_DEBUG2
, "WriteClient() %d %d bytes", con
->http
.fd
, bytes
);
1600 con
->http
.activity
= time(NULL
);
1607 * 'check_if_modified()' - Decode an "If-Modified-Since" line.
1610 static int /* O - 1 if modified since */
1611 check_if_modified(client_t
*con
, /* I - Client connection */
1612 struct stat
*filestats
) /* I - File information */
1614 char *ptr
; /* Pointer into field */
1615 time_t date
; /* Time/date value */
1616 int size
; /* Size/length value */
1621 ptr
= con
->http
.fields
[HTTP_FIELD_IF_MODIFIED_SINCE
];
1626 LogMessage(L_DEBUG2
, "check_if_modified() %d If-Modified-Since=\"%s\"",
1629 while (*ptr
!= '\0')
1631 while (isspace(*ptr
) || *ptr
== ';')
1634 if (strncasecmp(ptr
, "length=", 7) == 0)
1639 while (isdigit(*ptr
))
1642 else if (isalpha(*ptr
))
1644 date
= httpGetDateTime(ptr
);
1645 while (*ptr
!= '\0' && *ptr
!= ';')
1650 LogMessage(L_DEBUG2
, "check_if_modified() %d sizes=%d,%d dates=%d,%d",
1651 con
->http
.fd
, size
, filestats
->st_size
, date
, filestats
->st_mtime
);
1653 return ((size
!= filestats
->st_size
&& size
!= 0) ||
1654 (date
< filestats
->st_mtime
&& date
!= 0) ||
1655 (size
== 0 && date
== 0));
1660 * 'decode_auth()' - Decode an authorization string.
1664 decode_auth(client_t
*con
) /* I - Client to decode to */
1666 char *s
, /* Authorization string */
1667 value
[1024]; /* Value string */
1668 const char *username
; /* Certificate username */
1672 * Decode the string...
1675 s
= con
->http
.fields
[HTTP_FIELD_AUTHORIZATION
];
1677 LogMessage(L_DEBUG2
, "decode_auth(%08x): Authorization string = \"%s\"",
1680 if (strncmp(s
, "Basic", 5) == 0)
1686 httpDecode64(value
, s
);
1689 * Pull the username and password out...
1692 if ((s
= strchr(value
, ':')) == NULL
)
1694 LogMessage(L_DEBUG
, "decode_auth() %d no colon in auth string \"%s\"",
1695 con
->http
.fd
, value
);
1701 strncpy(con
->username
, value
, sizeof(con
->username
) - 1);
1702 con
->username
[sizeof(con
->username
) - 1] = '\0';
1704 strncpy(con
->password
, s
, sizeof(con
->password
) - 1);
1705 con
->password
[sizeof(con
->password
) - 1] = '\0';
1707 else if (strncmp(s
, "Local", 5) == 0)
1713 if ((username
= FindCert(s
)) != NULL
)
1715 strncpy(con
->username
, username
, sizeof(con
->username
) - 1);
1716 con
->username
[sizeof(con
->username
) - 1] = '\0';
1719 else if (strncmp(s
, "Digest", 5) == 0)
1722 * Get the username and password from the Digest attributes...
1725 if (httpGetSubField(&(con
->http
), HTTP_FIELD_WWW_AUTHENTICATE
, "username",
1728 strncpy(con
->username
, value
, sizeof(con
->username
) - 1);
1729 con
->username
[sizeof(con
->username
) - 1] = '\0';
1732 if (httpGetSubField(&(con
->http
), HTTP_FIELD_WWW_AUTHENTICATE
, "response",
1735 strncpy(con
->password
, value
, sizeof(con
->password
) - 1);
1736 con
->password
[sizeof(con
->password
) - 1] = '\0';
1740 LogMessage(L_DEBUG2
, "decode_auth() %d username=\"%s\"",
1741 con
->http
.fd
, con
->username
);
1746 * 'get_file()' - Get a filename and state info.
1749 static char * /* O - Real filename */
1750 get_file(client_t
*con
, /* I - Client connection */
1751 struct stat
*filestats
)/* O - File information */
1753 int status
; /* Status of filesystem calls */
1754 char *params
; /* Pointer to parameters in URI */
1755 static char filename
[1024]; /* Filename buffer */
1759 * Need to add DocumentRoot global...
1762 if (strncmp(con
->uri
, "/ppd/", 5) == 0)
1763 snprintf(filename
, sizeof(filename
), "%s%s", ServerRoot
, con
->uri
);
1764 else if (con
->language
!= NULL
)
1765 snprintf(filename
, sizeof(filename
), "%s/%s%s", DocumentRoot
, con
->language
->language
,
1768 snprintf(filename
, sizeof(filename
), "%s%s", DocumentRoot
, con
->uri
);
1770 if ((params
= strchr(filename
, '?')) != NULL
)
1774 * Grab the status for this language; if there isn't a language-specific file
1775 * then fallback to the default one...
1778 if ((status
= stat(filename
, filestats
)) != 0 && con
->language
!= NULL
)
1781 * Drop the language prefix and try the current directory...
1784 if (strncmp(con
->uri
, "/ppd/", 5) != 0)
1786 snprintf(filename
, sizeof(filename
), "%s%s", DocumentRoot
, con
->uri
);
1788 status
= stat(filename
, filestats
);
1793 * If we're found a directory, get the index.html file instead...
1796 if (!status
&& S_ISDIR(filestats
->st_mode
))
1798 if (filename
[strlen(filename
) - 1] == '/')
1799 strncat(filename
, "index.html", sizeof(filename
));
1801 strncat(filename
, "/index.html", sizeof(filename
));
1803 filename
[sizeof(filename
) - 1] = '\0';
1805 status
= stat(filename
, filestats
);
1808 LogMessage(L_DEBUG2
, "get_file() %d filename=%s size=%d",
1809 con
->http
.fd
, filename
, status
? -1 : filestats
->st_size
);
1819 * 'pipe_command()' - Pipe the output of a command to the remote client.
1822 static int /* O - Process ID */
1823 pipe_command(client_t
*con
, /* I - Client connection */
1824 int infile
, /* I - Standard input for command */
1825 int *outfile
, /* O - Standard output for command */
1826 char *command
, /* I - Command to run */
1827 char *options
) /* I - Options for command */
1829 int pid
; /* Process ID */
1830 char *commptr
; /* Command string pointer */
1831 int fd
; /* Looping var */
1832 int fds
[2]; /* Pipe FDs */
1833 int argc
; /* Number of arguments */
1834 int envc
; /* Number of environment variables */
1835 char argbuf
[10240], /* Argument buffer */
1836 *argv
[100], /* Argument strings */
1837 *envp
[100]; /* Environment variables */
1838 char lang
[1024], /* LANG env variable */
1839 content_length
[1024], /* CONTENT_LENGTH env variable */
1840 content_type
[1024], /* CONTENT_TYPE env variable */
1841 ipp_port
[1024], /* Default listen port */
1842 server_port
[1024], /* Default server port */
1843 server_name
[1024], /* Default listen hostname */
1844 remote_host
[1024], /* REMOTE_HOST env variable */
1845 remote_user
[1024], /* REMOTE_USER env variable */
1846 tmpdir
[1024], /* TMPDIR environment variable */
1847 ldpath
[1024], /* LD_LIBRARY_PATH environment variable */
1848 datadir
[1024], /* CUPS_DATADIR environment variable */
1849 root
[1024], /* CUPS_SERVERROOT environment variable */
1850 query_string
[10240]; /* QUERY_STRING env variable */
1854 * Copy the command string...
1857 strncpy(argbuf
, options
, sizeof(argbuf
) - 1);
1858 argbuf
[sizeof(argbuf
) - 1] = '\0';
1861 * Parse the string; arguments can be separated by + and are terminated
1867 for (commptr
= argbuf
, argc
= 1; *commptr
!= '\0' && argc
< 99; commptr
++)
1868 if (*commptr
== ' ' || *commptr
== '+')
1872 while (*commptr
== ' ')
1875 if (*commptr
!= '\0')
1877 argv
[argc
] = commptr
;
1883 else if (*commptr
== '%')
1885 if (commptr
[1] >= '0' && commptr
[1] <= '9')
1886 *commptr
= (commptr
[1] - '0') << 4;
1888 *commptr
= (tolower(commptr
[1]) - 'a' + 10) << 4;
1890 if (commptr
[2] >= '0' && commptr
[2] <= '9')
1891 *commptr
|= commptr
[2] - '0';
1893 *commptr
|= tolower(commptr
[2]) - 'a' + 10;
1895 strcpy(commptr
+ 1, commptr
+ 3);
1897 else if (*commptr
== '?')
1902 if (argv
[0][0] == '\0')
1903 argv
[0] = strrchr(command
, '/') + 1;
1906 * Setup the environment variables as needed...
1909 snprintf(lang
, sizeof(lang
), "LANG=%s",
1910 con
->language
? con
->language
->language
: "C");
1911 sprintf(ipp_port
, "IPP_PORT=%d", ntohs(con
->http
.hostaddr
.sin_port
));
1912 sprintf(server_port
, "SERVER_PORT=%d", ntohs(con
->http
.hostaddr
.sin_port
));
1913 snprintf(server_name
, sizeof(server_name
), "SERVER_NAME=%s", ServerName
);
1914 snprintf(remote_host
, sizeof(remote_host
), "REMOTE_HOST=%s", con
->http
.hostname
);
1915 snprintf(remote_user
, sizeof(remote_user
), "REMOTE_USER=%s", con
->username
);
1916 snprintf(tmpdir
, sizeof(tmpdir
), "TMPDIR=%s", TempDir
);
1917 snprintf(datadir
, sizeof(datadir
), "CUPS_DATADIR=%s", DataDir
);
1918 snprintf(root
, sizeof(root
), "CUPS_SERVERROOT=%s", ServerRoot
);
1920 if (getenv("LD_LIBRARY_PATH") != NULL
)
1921 snprintf(ldpath
, sizeof(ldpath
), "LD_LIBRARY_PATH=%s", getenv("LD_LIBRARY_PATH"));
1925 envp
[0] = "PATH=/bin:/usr/bin";
1926 envp
[1] = "SERVER_SOFTWARE=CUPS/1.1";
1927 envp
[2] = "GATEWAY_INTERFACE=CGI/1.1";
1928 envp
[3] = "SERVER_PROTOCOL=HTTP/1.1";
1930 envp
[5] = server_name
;
1931 envp
[6] = server_port
;
1932 envp
[7] = remote_host
;
1933 envp
[8] = remote_user
;
1943 envp
[envc
++] = ldpath
;
1945 if (con
->operation
== HTTP_GET
)
1947 envp
[envc
++] = "REQUEST_METHOD=GET";
1952 * Add GET form variables after ?...
1957 snprintf(query_string
, sizeof(query_string
), "QUERY_STRING=%s", commptr
);
1958 envp
[envc
++] = query_string
;
1963 sprintf(content_length
, "CONTENT_LENGTH=%d", con
->bytes
);
1964 snprintf(content_type
, sizeof(content_type
), "CONTENT_TYPE=%s",
1965 con
->http
.fields
[HTTP_FIELD_CONTENT_TYPE
]);
1967 envp
[envc
++] = "REQUEST_METHOD=POST";
1968 envp
[envc
++] = content_length
;
1969 envp
[envc
++] = content_type
;
1975 * Create a pipe for the output...
1980 LogMessage(L_ERROR
, "Unable to create pipes for CGI %s - %s",
1981 argv
[0], strerror(errno
));
1986 * Then execute the command...
1989 if ((pid
= fork()) == 0)
1992 * Child comes here... Close stdin if necessary and dup the pipe to stdout.
1998 * Running as root, so change to non-priviledged user...
2009 * Reset group membership to just the main one we belong to.
2015 * Update stdin/stdout...
2028 * Close extra file descriptors...
2031 for (fd
= 3; fd
< MaxFDs
; fd
++)
2035 * Change umask to restrict permissions on created files...
2041 * Execute the pipe program; if an error occurs, exit with status 1...
2044 execve(command
, argv
, envp
);
2045 perror("execve failed");
2052 * Error - can't fork!
2055 LogMessage(L_ERROR
, "Unable to fork for CGI %s - %s", argv
[0],
2065 * Fork successful - return the PID...
2068 AddCert(pid
, con
->username
);
2070 LogMessage(L_DEBUG
, "CGI %s started - PID = %d", argv
[0], pid
);
2081 * End of "$Id: client.c,v 1.86 2001/02/21 20:16:46 mike Exp $".