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