2 * "$Id: usersys.c 8498 2009-04-13 17:03:15Z mike $"
4 * User, system, and password routines for CUPS.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
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/".
15 * This file is subject to the Apple OS-Developed Software exception.
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
23 * cupsServer() - Return the hostname/address of the current
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.
40 * Include necessary headers...
43 #include "cups-private.h"
58 #define _CUPS_PASSCHAR '*' /* Character that is echoed for password */
65 static void cups_read_client_conf(cups_file_t
*fp
,
67 const char *cups_encryption
,
68 const char *cups_server
,
70 const char *cups_gssservicename
,
71 #endif /* HAVE_GSSAPI */
72 const char *cups_anyroot
,
73 const char *cups_expiredroot
,
74 const char *cups_expiredcerts
);
78 * 'cupsEncryption()' - Get the current encryption settings.
80 * The default encryption setting comes from the CUPS_ENCRYPTION
81 * environment variable, then the ~/.cups/client.conf file, and finally the
82 * /etc/cups/client.conf file. If not set, the default is
83 * @code HTTP_ENCRYPT_IF_REQUESTED@.
85 * Note: The current encryption setting is tracked separately for each thread
86 * in a program. Multi-threaded programs that override the setting via the
87 * @link cupsSetEncryption@ function need to do so in each thread for the same
91 http_encryption_t
/* O - Encryption settings */
94 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
97 if (cg
->encryption
== (http_encryption_t
)-1)
100 return (cg
->encryption
);
105 * 'cupsGetPassword()' - Get a password from the user.
107 * Uses the current password callback function. Returns @code NULL@ if the
108 * user does not provide a password.
110 * Note: The current password callback function is tracked separately for each
111 * thread in a program. Multi-threaded programs that override the setting via
112 * the @link cupsSetPasswordCB@ or @link cupsSetPasswordCB2@ functions need to
113 * do so in each thread for the same function to be used.
116 const char * /* O - Password */
117 cupsGetPassword(const char *prompt
) /* I - Prompt string */
119 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
122 return ((cg
->password_cb
)(prompt
, NULL
, NULL
, NULL
, cg
->password_data
));
127 * 'cupsGetPassword2()' - Get a password from the user using the advanced
130 * Uses the current password callback function. Returns @code NULL@ if the
131 * user does not provide a password.
133 * Note: The current password callback function is tracked separately for each
134 * thread in a program. Multi-threaded programs that override the setting via
135 * the @link cupsSetPasswordCB@ or @link cupsSetPasswordCB2@ functions need to
136 * do so in each thread for the same function to be used.
138 * @since CUPS 1.4/Mac OS X 10.6@
141 const char * /* O - Password */
142 cupsGetPassword2(const char *prompt
, /* I - Prompt string */
143 http_t
*http
, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
144 const char *method
, /* I - Request method ("GET", "POST", "PUT") */
145 const char *resource
) /* I - Resource path */
147 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
151 http
= _cupsConnect();
153 return ((cg
->password_cb
)(prompt
, http
, method
, resource
, cg
->password_data
));
158 * 'cupsServer()' - Return the hostname/address of the current server.
160 * The default server comes from the CUPS_SERVER environment variable, then the
161 * ~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not
162 * set, the default is the local system - either "localhost" or a domain socket
165 * The returned value can be a fully-qualified hostname, a numeric IPv4 or IPv6
166 * address, or a domain socket pathname.
168 * Note: The current server is tracked separately for each thread in a program.
169 * Multi-threaded programs that override the server via the
170 * @link cupsSetServer@ function need to do so in each thread for the same
174 const char * /* O - Server name */
177 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
188 * 'cupsSetClientCertCB()' - Set the client certificate callback.
190 * Pass @code NULL@ to restore the default callback.
192 * Note: The current certificate callback is tracked separately for each thread
193 * in a program. Multi-threaded programs that override the callback need to do
194 * so in each thread for the same callback to be used.
196 * @since CUPS 1.5/Mac OS X 10.7@
201 cups_client_cert_cb_t cb
, /* I - Callback function */
202 void *user_data
) /* I - User data pointer */
204 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
207 cg
->client_cert_cb
= cb
;
208 cg
->client_cert_data
= user_data
;
213 * 'cupsSetCredentials()' - Set the default credentials to be used for SSL/TLS
216 * Note: The default credentials are tracked separately for each thread in a
217 * program. Multi-threaded programs that override the setting need to do so in
218 * each thread for the same setting to be used.
220 * @since CUPS 1.5/Mac OS X 10.7@
223 int /* O - Status of call (0 = success) */
225 cups_array_t
*credentials
) /* I - Array of credentials */
227 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
230 if (cupsArrayCount(credentials
) < 1)
233 _httpFreeCredentials(cg
->tls_credentials
);
234 cg
->tls_credentials
= _httpCreateCredentials(credentials
);
236 return (cg
->tls_credentials
? 0 : -1);
241 * 'cupsSetEncryption()' - Set the encryption preference.
243 * The default encryption setting comes from the CUPS_ENCRYPTION
244 * environment variable, then the ~/.cups/client.conf file, and finally the
245 * /etc/cups/client.conf file. If not set, the default is
246 * @code HTTP_ENCRYPT_IF_REQUESTED@.
248 * Note: The current encryption setting is tracked separately for each thread
249 * in a program. Multi-threaded programs that override the setting need to do
250 * so in each thread for the same setting to be used.
254 cupsSetEncryption(http_encryption_t e
) /* I - New encryption preference */
256 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
262 httpEncryption(cg
->http
, e
);
267 * 'cupsSetPasswordCB()' - Set the password callback for CUPS.
269 * Pass @code NULL@ to restore the default (console) password callback, which
270 * reads the password from the console. Programs should call either this
271 * function or @link cupsSetPasswordCB2@, as only one callback can be registered
272 * by a program per thread.
274 * Note: The current password callback is tracked separately for each thread
275 * in a program. Multi-threaded programs that override the callback need to do
276 * so in each thread for the same callback to be used.
280 cupsSetPasswordCB(cups_password_cb_t cb
)/* I - Callback function */
282 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
285 if (cb
== (cups_password_cb_t
)0)
286 cg
->password_cb
= (cups_password_cb2_t
)_cupsGetPassword
;
288 cg
->password_cb
= (cups_password_cb2_t
)cb
;
290 cg
->password_data
= NULL
;
295 * 'cupsSetPasswordCB2()' - Set the advanced password callback for CUPS.
297 * Pass @code NULL@ to restore the default (console) password callback, which
298 * reads the password from the console. Programs should call either this
299 * function or @link cupsSetPasswordCB2@, as only one callback can be registered
300 * by a program per thread.
302 * Note: The current password callback is tracked separately for each thread
303 * in a program. Multi-threaded programs that override the callback need to do
304 * so in each thread for the same callback to be used.
306 * @since CUPS 1.4/Mac OS X 10.6@
311 cups_password_cb2_t cb
, /* I - Callback function */
312 void *user_data
) /* I - User data pointer */
314 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
317 if (cb
== (cups_password_cb2_t
)0)
318 cg
->password_cb
= (cups_password_cb2_t
)_cupsGetPassword
;
320 cg
->password_cb
= cb
;
322 cg
->password_data
= user_data
;
327 * 'cupsSetServer()' - Set the default server name and port.
329 * The "server" string can be a fully-qualified hostname, a numeric
330 * IPv4 or IPv6 address, or a domain socket pathname. Hostnames and numeric IP
331 * addresses can be optionally followed by a colon and port number to override
332 * the default port 631, e.g. "hostname:8631". Pass @code NULL@ to restore the
333 * default server name and port.
335 * Note: The current server is tracked separately for each thread in a program.
336 * Multi-threaded programs that override the server need to do so in each
337 * thread for the same server to be used.
341 cupsSetServer(const char *server
) /* I - Server name */
343 char *port
; /* Pointer to port */
344 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
349 strlcpy(cg
->server
, server
, sizeof(cg
->server
));
351 if (cg
->server
[0] != '/' && (port
= strrchr(cg
->server
, ':')) != NULL
&&
352 !strchr(port
, ']') && isdigit(port
[1] & 255))
356 cg
->ipp_port
= atoi(port
);
359 if (cg
->server
[0] == '/')
360 strcpy(cg
->servername
, "localhost");
362 strlcpy(cg
->servername
, cg
->server
, sizeof(cg
->servername
));
366 cg
->server
[0] = '\0';
367 cg
->servername
[0] = '\0';
379 * 'cupsSetServerCertCB()' - Set the server certificate callback.
381 * Pass @code NULL@ to restore the default callback.
383 * Note: The current credentials callback is tracked separately for each thread
384 * in a program. Multi-threaded programs that override the callback need to do
385 * so in each thread for the same callback to be used.
387 * @since CUPS 1.5/Mac OS X 10.7@
392 cups_server_cert_cb_t cb
, /* I - Callback function */
393 void *user_data
) /* I - User data pointer */
395 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
398 cg
->server_cert_cb
= cb
;
399 cg
->server_cert_data
= user_data
;
404 * 'cupsSetUser()' - Set the default user name.
406 * Pass @code NULL@ to restore the default user name.
408 * Note: The current user name is tracked separately for each thread in a
409 * program. Multi-threaded programs that override the user name need to do so
410 * in each thread for the same user name to be used.
414 cupsSetUser(const char *user
) /* I - User name */
416 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
420 strlcpy(cg
->user
, user
, sizeof(cg
->user
));
427 * 'cupsUser()' - Return the current user's name.
429 * Note: The current user name is tracked separately for each thread in a
430 * program. Multi-threaded programs that override the user name with the
431 * @link cupsSetUser@ function need to do so in each thread for the same user
435 const char * /* O - User name */
438 const char *user
; /* USER environment variable */
439 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
446 * Get the current user name from the OS...
449 DWORD size
; /* Size of string */
451 size
= sizeof(cg
->user
);
452 if (!GetUserName(cg
->user
, &size
))
455 * Get the user name corresponding to the current UID...
458 struct passwd
*pwd
; /* User/password entry */
461 if ((pwd
= getpwuid(getuid())) != NULL
)
467 strlcpy(cg
->user
, pwd
->pw_name
, sizeof(cg
->user
));
471 if ((user
= getenv("USER")) != NULL
)
474 * Use the username from the "USER" environment variable...
476 strlcpy(cg
->user
, user
, sizeof(cg
->user
));
481 * Use the default "unknown" user name...
484 strcpy(cg
->user
, "unknown");
493 * '_cupsGetPassword()' - Get a password from the user.
496 const char * /* O - Password or @code NULL@ if none */
497 _cupsGetPassword(const char *prompt
) /* I - Prompt string */
500 HANDLE tty
; /* Console handle */
501 DWORD mode
; /* Console mode */
502 char passch
, /* Current key press */
503 *passptr
, /* Pointer into password string */
504 *passend
; /* End of password string */
505 ssize_t passbytes
; /* Bytes read */
506 _cups_globals_t
*cg
= _cupsGlobals();
511 * Disable input echo and set raw input...
514 if ((tty
= GetStdHandle(STD_INPUT_HANDLE
)) == INVALID_HANDLE_VALUE
)
517 if (!GetConsoleMode(tty
, &mode
))
520 if (!SetConsoleMode(tty
, 0))
524 * Display the prompt...
527 printf("%s ", prompt
);
531 * Read the password string from /dev/tty until we get interrupted or get a
532 * carriage return or newline...
535 passptr
= cg
->password
;
536 passend
= cg
->password
+ sizeof(cg
->password
) - 1;
538 while ((passbytes
= read(tty
, &passch
, 1)) == 1)
540 if (passch
== 0x0A || passch
== 0x0D)
548 else if (passch
== 0x08 || passch
== 0x7F)
551 * Backspace/delete (erase character)...
554 if (passptr
> cg
->password
)
557 fputs("\010 \010", stdout
);
562 else if (passch
== 0x15)
565 * CTRL+U (erase line)
568 if (passptr
> cg
->password
)
570 while (passptr
> cg
->password
)
573 fputs("\010 \010", stdout
);
579 else if (passch
== 0x03)
585 passptr
= cg
->password
;
588 else if ((passch
& 255) < 0x20 || passptr
>= passend
)
593 putchar(_CUPS_PASSCHAR
);
606 SetConsoleMode(tty
, mode
);
609 * Return the proper value...
612 if (passbytes
== 1 && passptr
> cg
->password
)
615 return (cg
->password
);
619 memset(cg
->password
, 0, sizeof(cg
->password
));
624 int tty
; /* /dev/tty - never read from stdin */
625 struct termios original
, /* Original input mode */
626 noecho
; /* No echo input mode */
627 char passch
, /* Current key press */
628 *passptr
, /* Pointer into password string */
629 *passend
; /* End of password string */
630 ssize_t passbytes
; /* Bytes read */
631 _cups_globals_t
*cg
= _cupsGlobals();
636 * Disable input echo and set raw input...
639 if ((tty
= open("/dev/tty", O_RDONLY
)) < 0)
642 if (tcgetattr(tty
, &original
))
649 noecho
.c_lflag
&= ~(ICANON
| ECHO
| ECHOE
| ISIG
);
651 if (tcsetattr(tty
, TCSAFLUSH
, &noecho
))
658 * Display the prompt...
661 printf("%s ", prompt
);
665 * Read the password string from /dev/tty until we get interrupted or get a
666 * carriage return or newline...
669 passptr
= cg
->password
;
670 passend
= cg
->password
+ sizeof(cg
->password
) - 1;
672 while ((passbytes
= read(tty
, &passch
, 1)) == 1)
674 if (passch
== noecho
.c_cc
[VEOL
] || passch
== noecho
.c_cc
[VEOL2
] ||
675 passch
== 0x0A || passch
== 0x0D)
683 else if (passch
== noecho
.c_cc
[VERASE
] ||
684 passch
== 0x08 || passch
== 0x7F)
687 * Backspace/delete (erase character)...
690 if (passptr
> cg
->password
)
693 fputs("\010 \010", stdout
);
698 else if (passch
== noecho
.c_cc
[VKILL
])
701 * CTRL+U (erase line)
704 if (passptr
> cg
->password
)
706 while (passptr
> cg
->password
)
709 fputs("\010 \010", stdout
);
715 else if (passch
== noecho
.c_cc
[VINTR
] || passch
== noecho
.c_cc
[VQUIT
] ||
716 passch
== noecho
.c_cc
[VEOF
])
719 * CTRL+C, CTRL+D, or CTRL+Z...
722 passptr
= cg
->password
;
725 else if ((passch
& 255) < 0x20 || passptr
>= passend
)
730 putchar(_CUPS_PASSCHAR
);
743 tcsetattr(tty
, TCSAFLUSH
, &original
);
747 * Return the proper value...
750 if (passbytes
== 1 && passptr
> cg
->password
)
753 return (cg
->password
);
757 memset(cg
->password
, 0, sizeof(cg
->password
));
766 * '_cupsGSSServiceName()' - Get the GSS (Kerberos) service name.
770 _cupsGSSServiceName(void)
772 _cups_globals_t
*cg
= _cupsGlobals(); /* Thread globals */
775 if (!cg
->gss_service_name
[0])
778 return (cg
->gss_service_name
);
780 #endif /* HAVE_GSSAPI */
784 * '_cupsSetDefaults()' - Set the default server, port, and encryption.
788 _cupsSetDefaults(void)
790 cups_file_t
*fp
; /* File */
791 const char *home
, /* Home directory of user */
792 *cups_encryption
, /* CUPS_ENCRYPTION env var */
793 *cups_server
, /* CUPS_SERVER env var */
795 *cups_gssservicename
, /* CUPS_GSSSERVICENAME env var */
796 #endif /* HAVE_GSSAPI */
797 *cups_anyroot
, /* CUPS_ANYROOT env var */
798 *cups_expiredroot
, /* CUPS_EXPIREDROOT env var */
799 *cups_expiredcerts
; /* CUPS_EXPIREDCERTS env var */
800 char filename
[1024]; /* Filename */
801 _cups_globals_t
*cg
= _cupsGlobals(); /* Pointer to library globals */
804 DEBUG_puts("_cupsSetDefaults()");
807 * First collect environment variables...
810 cups_encryption
= getenv("CUPS_ENCRYPTION");
811 cups_server
= getenv("CUPS_SERVER");
813 cups_gssservicename
= getenv("CUPS_GSSSERVICENAME");
814 #endif /* HAVE_GSSAPI */
815 cups_anyroot
= getenv("CUPS_ANYROOT");
816 cups_expiredroot
= getenv("CUPS_EXPIREDROOT");
817 cups_expiredcerts
= getenv("CUPS_EXPIREDCERTS");
820 * Then, if needed, read the ~/.cups/client.conf or /etc/cups/client.conf
821 * files to get the default values...
824 if (cg
->encryption
== (http_encryption_t
)-1 || !cg
->server
[0] ||
827 if ((home
= getenv("HOME")) != NULL
)
830 * Look for ~/.cups/client.conf...
833 snprintf(filename
, sizeof(filename
), "%s/.cups/client.conf", home
);
834 fp
= cupsFileOpen(filename
, "r");
842 * Look for CUPS_SERVERROOT/client.conf...
845 snprintf(filename
, sizeof(filename
), "%s/client.conf",
846 cg
->cups_serverroot
);
847 fp
= cupsFileOpen(filename
, "r");
851 * Read the configuration file and apply any environment variables; both
852 * functions handle NULL cups_file_t pointers...
855 cups_read_client_conf(fp
, cg
, cups_encryption
, cups_server
,
858 #endif /* HAVE_GSSAPI */
859 cups_anyroot
, cups_expiredroot
,
867 * 'cups_read_client_conf()' - Read a client.conf file.
871 cups_read_client_conf(
872 cups_file_t
*fp
, /* I - File to read */
873 _cups_globals_t
*cg
, /* I - Global data */
874 const char *cups_encryption
, /* I - CUPS_ENCRYPTION env var */
875 const char *cups_server
, /* I - CUPS_SERVER env var */
877 const char *cups_gssservicename
,
878 /* I - CUPS_GSSSERVICENAME env var */
879 #endif /* HAVE_GSSAPI */
880 const char *cups_anyroot
, /* I - CUPS_ANYROOT env var */
881 const char *cups_expiredroot
, /* I - CUPS_EXPIREDROOT env var */
882 const char *cups_expiredcerts
) /* I - CUPS_EXPIREDCERTS env var */
884 int linenum
; /* Current line number */
885 char line
[1024], /* Line from file */
886 *value
, /* Pointer into line */
887 encryption
[1024], /* Encryption value */
889 server_name
[1024], /* ServerName value */
890 #endif /* !__APPLE__ */
891 any_root
[1024], /* AllowAnyRoot value */
892 expired_root
[1024], /* AllowExpiredRoot value */
893 expired_certs
[1024]; /* AllowExpiredCerts value */
895 char gss_service_name
[32]; /* GSSServiceName value */
896 #endif /* HAVE_GSSAPI */
900 * Read from the file...
904 while (cupsFileGetConf(fp
, line
, sizeof(line
), &value
, &linenum
))
906 if (!cups_encryption
&& cg
->encryption
== (http_encryption_t
)-1 &&
907 !_cups_strcasecmp(line
, "Encryption") && value
)
909 strlcpy(encryption
, value
, sizeof(encryption
));
910 cups_encryption
= encryption
;
914 * The Server directive is not supported on Mac OS X due to app sandboxing
915 * restrictions, i.e. not all apps request network access.
917 else if (!cups_server
&& (!cg
->server
[0] || !cg
->ipp_port
) &&
918 !_cups_strcasecmp(line
, "ServerName") && value
)
920 strlcpy(server_name
, value
, sizeof(server_name
));
921 cups_server
= server_name
;
923 #endif /* !__APPLE__ */
924 else if (!cups_anyroot
&& !_cups_strcasecmp(line
, "AllowAnyRoot") && value
)
926 strlcpy(any_root
, value
, sizeof(any_root
));
927 cups_anyroot
= any_root
;
929 else if (!cups_expiredroot
&& !_cups_strcasecmp(line
, "AllowExpiredRoot") &&
932 strlcpy(expired_root
, value
, sizeof(expired_root
));
933 cups_expiredroot
= expired_root
;
935 else if (!cups_expiredcerts
&& !_cups_strcasecmp(line
, "AllowExpiredCerts") &&
938 strlcpy(expired_certs
, value
, sizeof(expired_certs
));
939 cups_expiredcerts
= expired_certs
;
942 else if (!cups_gssservicename
&& !_cups_strcasecmp(line
, "GSSServiceName") &&
945 strlcpy(gss_service_name
, value
, sizeof(gss_service_name
));
946 cups_gssservicename
= gss_service_name
;
948 #endif /* HAVE_GSSAPI */
955 if (cg
->encryption
== (http_encryption_t
)-1 && cups_encryption
)
957 if (!_cups_strcasecmp(cups_encryption
, "never"))
958 cg
->encryption
= HTTP_ENCRYPT_NEVER
;
959 else if (!_cups_strcasecmp(cups_encryption
, "always"))
960 cg
->encryption
= HTTP_ENCRYPT_ALWAYS
;
961 else if (!_cups_strcasecmp(cups_encryption
, "required"))
962 cg
->encryption
= HTTP_ENCRYPT_REQUIRED
;
964 cg
->encryption
= HTTP_ENCRYPT_IF_REQUESTED
;
967 if ((!cg
->server
[0] || !cg
->ipp_port
) && cups_server
)
972 * Copy server name...
975 strlcpy(cg
->server
, cups_server
, sizeof(cg
->server
));
977 if (cg
->server
[0] != '/' && (value
= strrchr(cg
->server
, ':')) != NULL
&&
978 !strchr(value
, ']') && isdigit(value
[1] & 255))
983 if (cg
->server
[0] == '/')
984 strcpy(cg
->servername
, "localhost");
986 strlcpy(cg
->servername
, cg
->server
, sizeof(cg
->servername
));
988 else if (cups_server
[0] != '/' &&
989 (value
= strrchr(cups_server
, ':')) != NULL
&&
990 !strchr(value
, ']') && isdigit(value
[1] & 255))
995 if (!cg
->ipp_port
&& value
)
996 cg
->ipp_port
= atoi(value
);
1001 #ifdef CUPS_DEFAULT_DOMAINSOCKET
1003 * If we are compiled with domain socket support, only use the
1004 * domain socket if it exists and has the right permissions...
1007 struct stat sockinfo
; /* Domain socket information */
1009 if (!stat(CUPS_DEFAULT_DOMAINSOCKET
, &sockinfo
) &&
1010 (sockinfo
.st_mode
& S_IRWXO
) == S_IRWXO
)
1011 cups_server
= CUPS_DEFAULT_DOMAINSOCKET
;
1013 #endif /* CUPS_DEFAULT_DOMAINSOCKET */
1014 cups_server
= "localhost";
1016 cupsSetServer(cups_server
);
1021 const char *ipp_port
; /* IPP_PORT environment variable */
1023 if ((ipp_port
= getenv("IPP_PORT")) != NULL
)
1025 if ((cg
->ipp_port
= atoi(ipp_port
)) <= 0)
1026 cg
->ipp_port
= CUPS_DEFAULT_IPP_PORT
;
1029 cg
->ipp_port
= CUPS_DEFAULT_IPP_PORT
;
1033 if (!cups_gssservicename
)
1034 cups_gssservicename
= CUPS_DEFAULT_GSSSERVICENAME
;
1036 strlcpy(cg
->gss_service_name
, cups_gssservicename
,
1037 sizeof(cg
->gss_service_name
));
1038 #endif /* HAVE_GSSAPI */
1041 cg
->any_root
= !_cups_strcasecmp(cups_anyroot
, "yes") ||
1042 !_cups_strcasecmp(cups_anyroot
, "on") ||
1043 !_cups_strcasecmp(cups_anyroot
, "true");
1045 if (cups_expiredroot
)
1046 cg
->expired_root
= !_cups_strcasecmp(cups_expiredroot
, "yes") ||
1047 !_cups_strcasecmp(cups_expiredroot
, "on") ||
1048 !_cups_strcasecmp(cups_expiredroot
, "true");
1050 if (cups_expiredcerts
)
1051 cg
->expired_certs
= !_cups_strcasecmp(cups_expiredcerts
, "yes") ||
1052 !_cups_strcasecmp(cups_expiredcerts
, "on") ||
1053 !_cups_strcasecmp(cups_expiredcerts
, "true");
1058 * End of "$Id: usersys.c 8498 2009-04-13 17:03:15Z mike $".