]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/usersys.c
Merge changes from CUPS 1.5svn-r9675.
[thirdparty/cups.git] / cups / usersys.c
1 /*
2 * "$Id: usersys.c 8498 2009-04-13 17:03:15Z mike $"
3 *
4 * User, system, and password routines for CUPS.
5 *
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 *
17 * Contents:
18 *
19 * cupsEncryption() - Get the current encryption settings.
20 * cupsGetPassword() - Get a password from the user.
21 * cupsGetPassword2() - Get a password from the user using the advanced
22 * password callback.
23 * cupsServer() - Return the hostname/address of the current
24 * server.
25 * cupsSetClientCertCB() - Set the client certificate callback.
26 * cupsSetEncryption() - Set the encryption preference.
27 * cupsSetPasswordCB() - Set the password callback for CUPS.
28 * cupsSetPasswordCB2() - Set the advanced password callback for CUPS.
29 * cupsSetServer() - Set the default server name and port.
30 * cupsSetServerCertCB() - Set the server certificate callback.
31 * cupsSetUser() - Set the default user name.
32 * cupsUser() - Return the current user's name.
33 * _cupsGetPassword() - Get a password from the user.
34 * _cupsSetDefaults() - Set the default server, port, and encryption.
35 * cups_read_client_conf() - Read a client.conf file.
36 */
37
38 /*
39 * Include necessary headers...
40 */
41
42 #include "cups-private.h"
43 #include <stdlib.h>
44 #include <sys/stat.h>
45 #ifdef WIN32
46 # include <windows.h>
47 #else
48 # include <pwd.h>
49 #endif /* WIN32 */
50
51
52 /*
53 * Local functions...
54 */
55
56 static void cups_read_client_conf(cups_file_t *fp,
57 _cups_globals_t *cg,
58 const char *cups_encryption,
59 const char *cups_server,
60 #ifdef HAVE_GSSAPI
61 const char *cups_gssservicename,
62 #endif /* HAVE_GSSAPI */
63 const char *cups_anyroot,
64 const char *cups_expiredroot,
65 const char *cups_expiredcerts);
66
67
68 /*
69 * 'cupsEncryption()' - Get the current encryption settings.
70 *
71 * The default encryption setting comes from the CUPS_ENCRYPTION
72 * environment variable, then the ~/.cups/client.conf file, and finally the
73 * /etc/cups/client.conf file. If not set, the default is
74 * @code HTTP_ENCRYPT_IF_REQUESTED@.
75 *
76 * Note: The current encryption setting is tracked separately for each thread
77 * in a program. Multi-threaded programs that override the setting via the
78 * @link cupsSetEncryption@ function need to do so in each thread for the same
79 * setting to be used.
80 */
81
82 http_encryption_t /* O - Encryption settings */
83 cupsEncryption(void)
84 {
85 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
86
87
88 if (cg->encryption == (http_encryption_t)-1)
89 _cupsSetDefaults();
90
91 return (cg->encryption);
92 }
93
94
95 /*
96 * 'cupsGetPassword()' - Get a password from the user.
97 *
98 * Uses the current password callback function. Returns @code NULL@ if the
99 * user does not provide a password.
100 *
101 * Note: The current password callback function is tracked separately for each
102 * thread in a program. Multi-threaded programs that override the setting via
103 * the @link cupsSetPasswordCB@ or @link cupsSetPasswordCB2@ functions need to
104 * do so in each thread for the same function to be used.
105 */
106
107 const char * /* O - Password */
108 cupsGetPassword(const char *prompt) /* I - Prompt string */
109 {
110 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
111
112
113 return ((cg->password_cb)(prompt, NULL, NULL, NULL, cg->password_data));
114 }
115
116
117 /*
118 * 'cupsGetPassword2()' - Get a password from the user using the advanced
119 * password callback.
120 *
121 * Uses the current password callback function. Returns @code NULL@ if the
122 * user does not provide a password.
123 *
124 * Note: The current password callback function is tracked separately for each
125 * thread in a program. Multi-threaded programs that override the setting via
126 * the @link cupsSetPasswordCB@ or @link cupsSetPasswordCB2@ functions need to
127 * do so in each thread for the same function to be used.
128 *
129 * @since CUPS 1.4/Mac OS X 10.6@
130 */
131
132 const char * /* O - Password */
133 cupsGetPassword2(const char *prompt, /* I - Prompt string */
134 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
135 const char *method, /* I - Request method ("GET", "POST", "PUT") */
136 const char *resource) /* I - Resource path */
137 {
138 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
139
140
141 if (!http)
142 http = _cupsConnect();
143
144 return ((cg->password_cb)(prompt, http, method, resource, cg->password_data));
145 }
146
147
148 /*
149 * 'cupsServer()' - Return the hostname/address of the current server.
150 *
151 * The default server comes from the CUPS_SERVER environment variable, then the
152 * ~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not
153 * set, the default is the local system - either "localhost" or a domain socket
154 * path.
155 *
156 * The returned value can be a fully-qualified hostname, a numeric IPv4 or IPv6
157 * address, or a domain socket pathname.
158 *
159 * Note: The current server is tracked separately for each thread in a program.
160 * Multi-threaded programs that override the server via the
161 * @link cupsSetServer@ function need to do so in each thread for the same
162 * server to be used.
163 */
164
165 const char * /* O - Server name */
166 cupsServer(void)
167 {
168 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
169
170
171 if (!cg->server[0])
172 _cupsSetDefaults();
173
174 return (cg->server);
175 }
176
177
178 /*
179 * 'cupsSetClientCertCB()' - Set the client certificate callback.
180 *
181 * Pass @code NULL@ to restore the default callback.
182 *
183 * Note: The current certificate callback is tracked separately for each thread
184 * in a program. Multi-threaded programs that override the callback need to do
185 * so in each thread for the same callback to be used.
186 *
187 * @since CUPS 1.5@
188 */
189
190 void
191 cupsSetClientCertCB(
192 cups_client_cert_cb_t cb, /* I - Callback function */
193 void *user_data) /* I - User data pointer */
194 {
195 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
196
197
198 cg->client_cert_cb = cb;
199 cg->client_cert_data = user_data;
200 }
201
202
203 /*
204 * 'cupsSetCredentials()' - Set the default credentials to be used for SSL/TLS
205 * connections.
206 *
207 * Note: The default credentials are tracked separately for each thread in a
208 * program. Multi-threaded programs that override the setting need to do so in
209 * each thread for the same setting to be used.
210 *
211 * @since CUPS 1.5@
212 */
213
214 int /* O - Status of call (0 = success) */
215 cupsSetCredentials(
216 cups_array_t *credentials) /* I - Array of credentials */
217 {
218 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
219
220
221 if (cupsArrayCount(credentials) < 1)
222 return (-1);
223
224 _httpFreeCredentials(cg->tls_credentials);
225 cg->tls_credentials = _httpConvertCredentials(credentials);
226
227 return (cg->tls_credentials ? 0 : -1);
228 }
229
230
231 /*
232 * 'cupsSetEncryption()' - Set the encryption preference.
233 *
234 * The default encryption setting comes from the CUPS_ENCRYPTION
235 * environment variable, then the ~/.cups/client.conf file, and finally the
236 * /etc/cups/client.conf file. If not set, the default is
237 * @code HTTP_ENCRYPT_IF_REQUESTED@.
238 *
239 * Note: The current encryption setting is tracked separately for each thread
240 * in a program. Multi-threaded programs that override the setting need to do
241 * so in each thread for the same setting to be used.
242 */
243
244 void
245 cupsSetEncryption(http_encryption_t e) /* I - New encryption preference */
246 {
247 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
248
249
250 cg->encryption = e;
251
252 if (cg->http)
253 httpEncryption(cg->http, e);
254 }
255
256
257 /*
258 * 'cupsSetPasswordCB()' - Set the password callback for CUPS.
259 *
260 * Pass @code NULL@ to restore the default (console) password callback, which
261 * reads the password from the console. Programs should call either this
262 * function or @link cupsSetPasswordCB2@, as only one callback can be registered
263 * by a program per thread.
264 *
265 * Note: The current password callback is tracked separately for each thread
266 * in a program. Multi-threaded programs that override the callback need to do
267 * so in each thread for the same callback to be used.
268 */
269
270 void
271 cupsSetPasswordCB(cups_password_cb_t cb)/* I - Callback function */
272 {
273 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
274
275
276 if (cb == (cups_password_cb_t)0)
277 cg->password_cb = (cups_password_cb2_t)_cupsGetPassword;
278 else
279 cg->password_cb = (cups_password_cb2_t)cb;
280
281 cg->password_data = NULL;
282 }
283
284
285 /*
286 * 'cupsSetPasswordCB2()' - Set the advanced password callback for CUPS.
287 *
288 * Pass @code NULL@ to restore the default (console) password callback, which
289 * reads the password from the console. Programs should call either this
290 * function or @link cupsSetPasswordCB2@, as only one callback can be registered
291 * by a program per thread.
292 *
293 * Note: The current password callback is tracked separately for each thread
294 * in a program. Multi-threaded programs that override the callback need to do
295 * so in each thread for the same callback to be used.
296 *
297 * @since CUPS 1.4/Mac OS X 10.6@
298 */
299
300 void
301 cupsSetPasswordCB2(
302 cups_password_cb2_t cb, /* I - Callback function */
303 void *user_data) /* I - User data pointer */
304 {
305 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
306
307
308 if (cb == (cups_password_cb2_t)0)
309 cg->password_cb = (cups_password_cb2_t)_cupsGetPassword;
310 else
311 cg->password_cb = cb;
312
313 cg->password_data = user_data;
314 }
315
316
317 /*
318 * 'cupsSetServer()' - Set the default server name and port.
319 *
320 * The "server" string can be a fully-qualified hostname, a numeric
321 * IPv4 or IPv6 address, or a domain socket pathname. Hostnames and numeric IP
322 * addresses can be optionally followed by a colon and port number to override
323 * the default port 631, e.g. "hostname:8631". Pass @code NULL@ to restore the
324 * default server name and port.
325 *
326 * Note: The current server is tracked separately for each thread in a program.
327 * Multi-threaded programs that override the server need to do so in each
328 * thread for the same server to be used.
329 */
330
331 void
332 cupsSetServer(const char *server) /* I - Server name */
333 {
334 char *port; /* Pointer to port */
335 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
336
337
338 if (server)
339 {
340 strlcpy(cg->server, server, sizeof(cg->server));
341
342 if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL &&
343 !strchr(port, ']') && isdigit(port[1] & 255))
344 {
345 *port++ = '\0';
346
347 cg->ipp_port = atoi(port);
348 }
349
350 if (cg->server[0] == '/')
351 strcpy(cg->servername, "localhost");
352 else
353 strlcpy(cg->servername, cg->server, sizeof(cg->servername));
354 }
355 else
356 {
357 cg->server[0] = '\0';
358 cg->servername[0] = '\0';
359 }
360
361 if (cg->http)
362 {
363 httpClose(cg->http);
364 cg->http = NULL;
365 }
366 }
367
368
369 /*
370 * 'cupsSetServerCertCB()' - Set the server certificate callback.
371 *
372 * Pass @code NULL@ to restore the default callback.
373 *
374 * Note: The current credentials callback is tracked separately for each thread
375 * in a program. Multi-threaded programs that override the callback need to do
376 * so in each thread for the same callback to be used.
377 *
378 * @since CUPS 1.5@
379 */
380
381 void
382 cupsSetServerCertCB(
383 cups_server_cert_cb_t cb, /* I - Callback function */
384 void *user_data) /* I - User data pointer */
385 {
386 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
387
388
389 cg->server_cert_cb = cb;
390 cg->server_cert_data = user_data;
391 }
392
393
394 /*
395 * 'cupsSetUser()' - Set the default user name.
396 *
397 * Pass @code NULL@ to restore the default user name.
398 *
399 * Note: The current user name is tracked separately for each thread in a
400 * program. Multi-threaded programs that override the user name need to do so
401 * in each thread for the same user name to be used.
402 */
403
404 void
405 cupsSetUser(const char *user) /* I - User name */
406 {
407 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
408
409
410 if (user)
411 strlcpy(cg->user, user, sizeof(cg->user));
412 else
413 cg->user[0] = '\0';
414 }
415
416
417 /*
418 * 'cupsUser()' - Return the current user's name.
419 *
420 * Note: The current user name is tracked separately for each thread in a
421 * program. Multi-threaded programs that override the user name with the
422 * @link cupsSetUser@ function need to do so in each thread for the same user
423 * name to be used.
424 */
425
426 const char * /* O - User name */
427 cupsUser(void)
428 {
429 const char *user; /* USER environment variable */
430 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
431
432
433 if (!cg->user[0])
434 {
435 #ifdef WIN32
436 /*
437 * Get the current user name from the OS...
438 */
439
440 DWORD size; /* Size of string */
441
442 size = sizeof(cg->user);
443 if (!GetUserName(cg->user, &size))
444 #else
445 /*
446 * Get the user name corresponding to the current UID...
447 */
448
449 struct passwd *pwd; /* User/password entry */
450
451 setpwent();
452 if ((pwd = getpwuid(getuid())) != NULL)
453 {
454 /*
455 * Found a match!
456 */
457
458 strlcpy(cg->user, pwd->pw_name, sizeof(cg->user));
459 }
460 else
461 #endif /* WIN32 */
462 if ((user = getenv("USER")) != NULL)
463 {
464 /*
465 * Use the username from the "USER" environment variable...
466 */
467 strlcpy(cg->user, user, sizeof(cg->user));
468 }
469 else
470 {
471 /*
472 * Use the default "unknown" user name...
473 */
474
475 strcpy(cg->user, "unknown");
476 }
477 }
478
479 return (cg->user);
480 }
481
482
483 /*
484 * '_cupsGetPassword()' - Get a password from the user.
485 */
486
487 const char * /* O - Password */
488 _cupsGetPassword(const char *prompt) /* I - Prompt string */
489 {
490 #ifdef WIN32
491 /*
492 * Currently no console password support is provided on Windows.
493 */
494
495 return (NULL);
496
497 #else
498 /*
499 * Use the standard getpass function to get a password from the console. An
500 * empty password is treated as canceling the authentication request.
501 */
502
503 const char *password = getpass(prompt);
504 /* Password string */
505
506 if (!password || !password[0])
507 return (NULL);
508 else
509 return (password);
510 #endif /* WIN32 */
511 }
512
513
514 /*
515 * '_cupsSetDefaults()' - Set the default server, port, and encryption.
516 */
517
518 void
519 _cupsSetDefaults(void)
520 {
521 cups_file_t *fp; /* File */
522 const char *home, /* Home directory of user */
523 *cups_encryption, /* CUPS_ENCRYPTION env var */
524 *cups_server, /* CUPS_SERVER env var */
525 #ifdef HAVE_GSSAPI
526 *cups_gssservicename, /* CUPS_GSSSERVICENAME env var */
527 #endif /* HAVE_GSSAPI */
528 *cups_anyroot, /* CUPS_ANYROOT env var */
529 *cups_expiredroot, /* CUPS_EXPIREDROOT env var */
530 *cups_expiredcerts; /* CUPS_EXPIREDCERTS env var */
531 char filename[1024]; /* Filename */
532 _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
533
534
535 DEBUG_puts("_cupsSetDefaults()");
536
537 /*
538 * First collect environment variables...
539 */
540
541 cups_encryption = getenv("CUPS_ENCRYPTION");
542 cups_server = getenv("CUPS_SERVER");
543 #ifdef HAVE_GSSAPI
544 cups_gssservicename = getenv("CUPS_GSSSERVICENAME");
545 #endif /* HAVE_GSSAPI */
546 cups_anyroot = getenv("CUPS_ANYROOT");
547 cups_expiredroot = getenv("CUPS_EXPIREDROOT");
548 cups_expiredcerts = getenv("CUPS_EXPIREDCERTS");
549
550 /*
551 * Then, if needed, read the ~/.cups/client.conf or /etc/cups/client.conf
552 * files to get the default values...
553 */
554
555 if (cg->encryption == (http_encryption_t)-1 || !cg->server[0] ||
556 !cg->ipp_port)
557 {
558 if ((home = getenv("HOME")) != NULL)
559 {
560 /*
561 * Look for ~/.cups/client.conf...
562 */
563
564 snprintf(filename, sizeof(filename), "%s/.cups/client.conf", home);
565 fp = cupsFileOpen(filename, "r");
566 }
567 else
568 fp = NULL;
569
570 if (!fp)
571 {
572 /*
573 * Look for CUPS_SERVERROOT/client.conf...
574 */
575
576 snprintf(filename, sizeof(filename), "%s/client.conf",
577 cg->cups_serverroot);
578 fp = cupsFileOpen(filename, "r");
579 }
580
581 /*
582 * Read the configuration file and apply any environment variables; both
583 * functions handle NULL cups_file_t pointers...
584 */
585
586 cups_read_client_conf(fp, cg, cups_encryption, cups_server,
587 #ifdef HAVE_GSSAPI
588 cups_gssservicename,
589 #endif /* HAVE_GSSAPI */
590 cups_anyroot, cups_expiredroot,
591 cups_expiredcerts);
592 cupsFileClose(fp);
593 }
594 }
595
596
597 /*
598 * 'cups_read_client_conf()' - Read a client.conf file.
599 */
600
601 static void
602 cups_read_client_conf(
603 cups_file_t *fp, /* I - File to read */
604 _cups_globals_t *cg, /* I - Global data */
605 const char *cups_encryption, /* I - CUPS_ENCRYPTION env var */
606 const char *cups_server, /* I - CUPS_SERVER env var */
607 #ifdef HAVE_GSSAPI
608 const char *cups_gssservicename,
609 /* I - CUPS_GSSSERVICENAME env var */
610 #endif /* HAVE_GSSAPI */
611 const char *cups_anyroot, /* I - CUPS_ANYROOT env var */
612 const char *cups_expiredroot, /* I - CUPS_EXPIREDROOT env var */
613 const char *cups_expiredcerts) /* I - CUPS_EXPIREDCERTS env var */
614 {
615 int linenum; /* Current line number */
616 char line[1024], /* Line from file */
617 *value, /* Pointer into line */
618 encryption[1024], /* Encryption value */
619 server_name[1024], /* ServerName value */
620 any_root[1024], /* AllowAnyRoot value */
621 expired_root[1024], /* AllowExpiredRoot value */
622 expired_certs[1024]; /* AllowExpiredCerts value */
623 #ifdef HAVE_GSSAPI
624 char gss_service_name[32]; /* GSSServiceName value */
625 #endif /* HAVE_GSSAPI */
626
627
628 /*
629 * Read from the file...
630 */
631
632 linenum = 0;
633 while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
634 {
635 if (!cups_encryption && cg->encryption == (http_encryption_t)-1 &&
636 !strcasecmp(line, "Encryption") && value)
637 {
638 strlcpy(encryption, value, sizeof(encryption));
639 cups_encryption = encryption;
640 }
641 else if (!cups_server && (!cg->server[0] || !cg->ipp_port) &&
642 !strcasecmp(line, "ServerName") && value)
643 {
644 strlcpy(server_name, value, sizeof(server_name));
645 cups_server = server_name;
646 }
647 else if (!cups_anyroot && !strcasecmp(line, "AllowAnyRoot") && value)
648 {
649 strlcpy(any_root, value, sizeof(any_root));
650 cups_anyroot = any_root;
651 }
652 else if (!cups_expiredroot && !strcasecmp(line, "AllowExpiredRoot") &&
653 value)
654 {
655 strlcpy(expired_root, value, sizeof(expired_root));
656 cups_expiredroot = expired_root;
657 }
658 else if (!cups_expiredcerts && !strcasecmp(line, "AllowExpiredCerts") &&
659 value)
660 {
661 strlcpy(expired_certs, value, sizeof(expired_certs));
662 cups_expiredcerts = expired_certs;
663 }
664 #ifdef HAVE_GSSAPI
665 else if (!cups_gssservicename && !strcasecmp(line, "GSSServiceName") &&
666 value)
667 {
668 strlcpy(gss_service_name, value, sizeof(gss_service_name));
669 cups_gssservicename = gss_service_name;
670 }
671 #endif /* HAVE_GSSAPI */
672 }
673
674 /*
675 * Set values...
676 */
677
678 if (cg->encryption == (http_encryption_t)-1 && cups_encryption)
679 {
680 if (!strcasecmp(cups_encryption, "never"))
681 cg->encryption = HTTP_ENCRYPT_NEVER;
682 else if (!strcasecmp(cups_encryption, "always"))
683 cg->encryption = HTTP_ENCRYPT_ALWAYS;
684 else if (!strcasecmp(cups_encryption, "required"))
685 cg->encryption = HTTP_ENCRYPT_REQUIRED;
686 else
687 cg->encryption = HTTP_ENCRYPT_IF_REQUESTED;
688 }
689
690 if ((!cg->server[0] || !cg->ipp_port) && cups_server)
691 {
692 if (!cg->server[0])
693 {
694 /*
695 * Copy server name...
696 */
697
698 strlcpy(cg->server, cups_server, sizeof(cg->server));
699
700 if (cg->server[0] != '/' && (value = strrchr(cg->server, ':')) != NULL &&
701 !strchr(value, ']') && isdigit(value[1] & 255))
702 *value++ = '\0';
703 else
704 value = NULL;
705
706 if (cg->server[0] == '/')
707 strcpy(cg->servername, "localhost");
708 else
709 strlcpy(cg->servername, cg->server, sizeof(cg->servername));
710 }
711 else if (cups_server[0] != '/' &&
712 (value = strrchr(cups_server, ':')) != NULL &&
713 !strchr(value, ']') && isdigit(value[1] & 255))
714 value ++;
715 else
716 value = NULL;
717
718 if (!cg->ipp_port && value)
719 cg->ipp_port = atoi(value);
720 }
721
722 if (!cg->server[0])
723 {
724 #ifdef CUPS_DEFAULT_DOMAINSOCKET
725 /*
726 * If we are compiled with domain socket support, only use the
727 * domain socket if it exists and has the right permissions...
728 */
729
730 struct stat sockinfo; /* Domain socket information */
731
732 if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
733 (sockinfo.st_mode & S_IRWXO) == S_IRWXO)
734 cups_server = CUPS_DEFAULT_DOMAINSOCKET;
735 else
736 #endif /* CUPS_DEFAULT_DOMAINSOCKET */
737 cups_server = "localhost";
738
739 cupsSetServer(cups_server);
740 }
741
742 if (!cg->ipp_port)
743 {
744 const char *ipp_port; /* IPP_PORT environment variable */
745 struct servent *service; /* Port number info */
746
747
748 if ((ipp_port = getenv("IPP_PORT")) != NULL)
749 {
750 if ((cg->ipp_port = atoi(ipp_port)) <= 0)
751 cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
752 }
753 else if ((service = getservbyname("ipp", NULL)) == NULL ||
754 service->s_port <= 0)
755 cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
756 else
757 cg->ipp_port = ntohs(service->s_port);
758 }
759
760 #ifdef HAVE_GSSAPI
761 if (!cups_gssservicename)
762 cups_gssservicename = CUPS_DEFAULT_GSSSERVICENAME;
763
764 strlcpy(cg->gss_service_name, cups_gssservicename,
765 sizeof(cg->gss_service_name));
766 #endif /* HAVE_GSSAPI */
767
768 if (cups_anyroot)
769 cg->any_root = !strcasecmp(cups_anyroot, "yes") ||
770 !strcasecmp(cups_anyroot, "on") ||
771 !strcasecmp(cups_anyroot, "true");
772
773 if (cups_expiredroot)
774 cg->expired_root = !strcasecmp(cups_expiredroot, "yes") ||
775 !strcasecmp(cups_expiredroot, "on") ||
776 !strcasecmp(cups_expiredroot, "true");
777
778 if (cups_expiredcerts)
779 cg->expired_certs = !strcasecmp(cups_expiredcerts, "yes") ||
780 !strcasecmp(cups_expiredcerts, "on") ||
781 !strcasecmp(cups_expiredcerts, "true");
782 }
783
784
785 /*
786 * End of "$Id: usersys.c 8498 2009-04-13 17:03:15Z mike $".
787 */