• Home
  • Raw
  • Download

Lines Matching +full:server +full:- +full:password

2  * User, system, and password routines for CUPS.
4 * Copyright 2007-2019 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products.
15 #include "cups-private.h"
16 #include "debug-internal.h"
59 #define _CUPS_PASSCHAR '*' /* Character that is echoed for password */
76 any_root, /* Allow any (e.g., self-signed) root */
82 /* Server hostname */
117 * 'cupsEncryption()' - Get the current encryption settings.
125 * in a program. Multi-threaded programs that override the setting via the
130 http_encryption_t /* O - Encryption settings */
136 if (cg->encryption == (http_encryption_t)-1) in cupsEncryption()
139 return (cg->encryption); in cupsEncryption()
144 * 'cupsGetPassword()' - Get a password from the user.
146 * Uses the current password callback function. Returns @code NULL@ if the
147 * user does not provide a password.
149 * Note: The current password callback function is tracked separately for each
150 * thread in a program. Multi-threaded programs that override the setting via
157 const char * /* O - Password */
158 cupsGetPassword(const char *prompt) /* I - Prompt string */ in cupsGetPassword()
163 return ((cg->password_cb)(prompt, NULL, NULL, NULL, cg->password_data)); in cupsGetPassword()
168 * 'cupsGetPassword2()' - Get a password from the user using the current
169 * password callback.
171 * Uses the current password callback function. Returns @code NULL@ if the
172 * user does not provide a password.
174 * Note: The current password callback function is tracked separately for each
175 * thread in a program. Multi-threaded programs that override the setting via
182 const char * /* O - Password */
183 cupsGetPassword2(const char *prompt, /* I - Prompt string */ in cupsGetPassword2()
184 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ in cupsGetPassword2()
185 const char *method, /* I - Request method ("GET", "POST", "PUT") */ in cupsGetPassword2()
186 const char *resource) /* I - Resource path */ in cupsGetPassword2()
194 return ((cg->password_cb)(prompt, http, method, resource, cg->password_data)); in cupsGetPassword2()
199 * 'cupsServer()' - Return the hostname/address of the current server.
201 * The default server comes from the CUPS_SERVER environment variable, then the
203 * set, the default is the local system - either "localhost" or a domain socket
206 * The returned value can be a fully-qualified hostname, a numeric IPv4 or IPv6
209 * Note: The current server is tracked separately for each thread in a program.
210 * Multi-threaded programs that override the server via the
212 * server to be used.
215 const char * /* O - Server name */
221 if (!cg->server[0]) in cupsServer()
224 return (cg->server); in cupsServer()
229 * 'cupsSetClientCertCB()' - Set the client certificate callback.
234 * in a program. Multi-threaded programs that override the callback need to do
242 cups_client_cert_cb_t cb, /* I - Callback function */ in cupsSetClientCertCB()
243 void *user_data) /* I - User data pointer */ in cupsSetClientCertCB()
248 cg->client_cert_cb = cb; in cupsSetClientCertCB()
249 cg->client_cert_data = user_data; in cupsSetClientCertCB()
254 * 'cupsSetCredentials()' - Set the default credentials to be used for SSL/TLS
258 * program. Multi-threaded programs that override the setting need to do so in
264 int /* O - Status of call (0 = success) */
266 cups_array_t *credentials) /* I - Array of credentials */ in cupsSetCredentials()
272 return (-1); in cupsSetCredentials()
275 _httpFreeCredentials(cg->tls_credentials); in cupsSetCredentials()
276 cg->tls_credentials = _httpCreateCredentials(credentials); in cupsSetCredentials()
279 return (cg->tls_credentials ? 0 : -1); in cupsSetCredentials()
284 * 'cupsSetEncryption()' - Set the encryption preference.
292 * in a program. Multi-threaded programs that override the setting need to do
297 cupsSetEncryption(http_encryption_t e) /* I - New encryption preference */ in cupsSetEncryption()
302 cg->encryption = e; in cupsSetEncryption()
304 if (cg->http) in cupsSetEncryption()
305 httpEncryption(cg->http, e); in cupsSetEncryption()
310 * 'cupsSetPasswordCB()' - Set the password callback for CUPS.
312 * Pass @code NULL@ to restore the default (console) password callback, which
313 * reads the password from the console. Programs should call either this
317 * Note: The current password callback is tracked separately for each thread
318 * in a program. Multi-threaded programs that override the callback need to do
325 cupsSetPasswordCB(cups_password_cb_t cb)/* I - Callback function */ in cupsSetPasswordCB()
331 cg->password_cb = (cups_password_cb2_t)_cupsGetPassword; in cupsSetPasswordCB()
333 cg->password_cb = (cups_password_cb2_t)cb; in cupsSetPasswordCB()
335 cg->password_data = NULL; in cupsSetPasswordCB()
340 * 'cupsSetPasswordCB2()' - Set the advanced password callback for CUPS.
342 * Pass @code NULL@ to restore the default (console) password callback, which
343 * reads the password from the console. Programs should call either this
347 * Note: The current password callback is tracked separately for each thread
348 * in a program. Multi-threaded programs that override the callback need to do
356 cups_password_cb2_t cb, /* I - Callback function */ in cupsSetPasswordCB2()
357 void *user_data) /* I - User data pointer */ in cupsSetPasswordCB2()
363 cg->password_cb = (cups_password_cb2_t)_cupsGetPassword; in cupsSetPasswordCB2()
365 cg->password_cb = cb; in cupsSetPasswordCB2()
367 cg->password_data = user_data; in cupsSetPasswordCB2()
372 * 'cupsSetServer()' - Set the default server name and port.
374 * The "server" string can be a fully-qualified hostname, a numeric
378 * default server name and port.
380 * Note: The current server is tracked separately for each thread in a program.
381 * Multi-threaded programs that override the server need to do so in each
382 * thread for the same server to be used.
386 cupsSetServer(const char *server) /* I - Server name */ in cupsSetServer() argument
393 if (server) in cupsSetServer()
395 strlcpy(cg->server, server, sizeof(cg->server)); in cupsSetServer()
397 if (cg->server[0] != '/' && (options = strrchr(cg->server, '/')) != NULL) in cupsSetServer()
402 cg->server_version = 10; in cupsSetServer()
404 cg->server_version = 11; in cupsSetServer()
406 cg->server_version = 20; in cupsSetServer()
408 cg->server_version = 21; in cupsSetServer()
410 cg->server_version = 22; in cupsSetServer()
413 cg->server_version = 20; in cupsSetServer()
415 if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL && in cupsSetServer()
420 cg->ipp_port = atoi(port); in cupsSetServer()
423 if (!cg->ipp_port) in cupsSetServer()
426 if (cg->server[0] == '/') in cupsSetServer()
427 strlcpy(cg->servername, "localhost", sizeof(cg->servername)); in cupsSetServer()
429 strlcpy(cg->servername, cg->server, sizeof(cg->servername)); in cupsSetServer()
433 cg->server[0] = '\0'; in cupsSetServer()
434 cg->servername[0] = '\0'; in cupsSetServer()
435 cg->server_version = 20; in cupsSetServer()
436 cg->ipp_port = 0; in cupsSetServer()
439 if (cg->http) in cupsSetServer()
441 httpClose(cg->http); in cupsSetServer()
442 cg->http = NULL; in cupsSetServer()
448 * 'cupsSetServerCertCB()' - Set the server certificate callback.
453 * in a program. Multi-threaded programs that override the callback need to do
461 cups_server_cert_cb_t cb, /* I - Callback function */ in cupsSetServerCertCB()
462 void *user_data) /* I - User data pointer */ in cupsSetServerCertCB()
467 cg->server_cert_cb = cb; in cupsSetServerCertCB()
468 cg->server_cert_data = user_data; in cupsSetServerCertCB()
473 * 'cupsSetUser()' - Set the default user name.
478 * program. Multi-threaded programs that override the user name need to do so
483 cupsSetUser(const char *user) /* I - User name */ in cupsSetUser()
489 strlcpy(cg->user, user, sizeof(cg->user)); in cupsSetUser()
491 cg->user[0] = '\0'; in cupsSetUser()
496 * 'cupsSetUserAgent()' - Set the default HTTP User-Agent string.
505 cupsSetUserAgent(const char *user_agent)/* I - User-Agent string or @code NULL@ */ in cupsSetUserAgent()
524 strlcpy(cg->user_agent, user_agent, sizeof(cg->user_agent)); in cupsSetUserAgent()
528 if (cg->uatokens < _CUPS_UATOKENS_OS) in cupsSetUserAgent()
530 switch (cg->uatokens) in cupsSetUserAgent()
534 cg->user_agent[0] = '\0'; in cupsSetUserAgent()
537 strlcpy(cg->user_agent, "CUPS IPP", sizeof(cg->user_agent)); in cupsSetUserAgent()
540 snprintf(cg->user_agent, sizeof(cg->user_agent), "CUPS/%d IPP/2", CUPS_VERSION_MAJOR); in cupsSetUserAgent()
543 …snprintf(cg->user_agent, sizeof(cg->user_agent), "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR, CUPS_VE… in cupsSetUserAgent()
546 strlcpy(cg->user_agent, CUPS_MINIMAL " IPP/2.1", sizeof(cg->user_agent)); in cupsSetUserAgent()
553 * Gather Windows version information for the User-Agent string... in cupsSetUserAgent()
583 if (cg->uatokens == _CUPS_UATOKENS_OS) in cupsSetUserAgent()
584 …snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (Windows %d.%d) IPP/2.0", version.… in cupsSetUserAgent()
586 …snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (Windows %d.%d; %s) IPP/2.0", vers… in cupsSetUserAgent()
590 * Gather macOS/iOS version information for the User-Agent string... in cupsSetUserAgent()
595 len = sizeof(version) - 1; in cupsSetUserAgent()
602 if (cg->uatokens == _CUPS_UATOKENS_OS) in cupsSetUserAgent()
603 snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (macOS %s) IPP/2.0", version); in cupsSetUserAgent()
605 …snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (macOS %s; %s) IPP/2.0", version, … in cupsSetUserAgent()
608 if (cg->uatokens == _CUPS_UATOKENS_OS) in cupsSetUserAgent()
609 snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (iOS %s) IPP/2.0", version); in cupsSetUserAgent()
611 …snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (iOS %s; %s) IPP/2.0", version, na… in cupsSetUserAgent()
616 * Gather generic UNIX version information for the User-Agent string... in cupsSetUserAgent()
621 if (cg->uatokens == _CUPS_UATOKENS_OS) in cupsSetUserAgent()
622 …snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (%s %s) IPP/2.0", name.sysname, na… in cupsSetUserAgent()
624 …snprintf(cg->user_agent, sizeof(cg->user_agent), CUPS_MINIMAL " (%s %s; %s) IPP/2.0", name.sysname… in cupsSetUserAgent()
630 * 'cupsUser()' - Return the current user's name.
633 * program. Multi-threaded programs that override the user name with the
638 const char * /* O - User name */
644 if (!cg->user[0]) in cupsUser()
647 return (cg->user); in cupsUser()
652 * 'cupsUserAgent()' - Return the default HTTP User-Agent string.
657 const char * /* O - User-Agent string */
663 if (!cg->user_agent[0]) in cupsUserAgent()
666 return (cg->user_agent); in cupsUserAgent()
671 * '_cupsGetPassword()' - Get a password from the user.
674 const char * /* O - Password or @code NULL@ if none */
675 _cupsGetPassword(const char *prompt) /* I - Prompt string */ in _cupsGetPassword()
681 *passptr, /* Pointer into password string */ in _cupsGetPassword()
682 *passend; /* End of password string */ in _cupsGetPassword()
709 * Read the password string from /dev/tty until we get interrupted or get a in _cupsGetPassword()
713 passptr = cg->password; in _cupsGetPassword()
714 passend = cg->password + sizeof(cg->password) - 1; in _cupsGetPassword()
732 if (passptr > cg->password) in _cupsGetPassword()
734 passptr --; in _cupsGetPassword()
746 if (passptr > cg->password) in _cupsGetPassword()
748 while (passptr > cg->password) in _cupsGetPassword()
750 passptr --; in _cupsGetPassword()
763 passptr = cg->password; in _cupsGetPassword()
790 if (passbytes == 1 && passptr > cg->password) in _cupsGetPassword()
793 return (cg->password); in _cupsGetPassword()
797 memset(cg->password, 0, sizeof(cg->password)); in _cupsGetPassword()
802 int tty; /* /dev/tty - never read from stdin */ in _cupsGetPassword()
806 *passptr, /* Pointer into password string */ in _cupsGetPassword()
807 *passend; /* End of password string */ in _cupsGetPassword()
845 * Read the password string from /dev/tty until we get interrupted or get a in _cupsGetPassword()
849 passptr = cg->password; in _cupsGetPassword()
850 passend = cg->password + sizeof(cg->password) - 1; in _cupsGetPassword()
873 if (passptr > cg->password) in _cupsGetPassword()
875 passptr --; in _cupsGetPassword()
887 if (passptr > cg->password) in _cupsGetPassword()
889 while (passptr > cg->password) in _cupsGetPassword()
891 passptr --; in _cupsGetPassword()
905 passptr = cg->password; in _cupsGetPassword()
933 if (passbytes == 1 && passptr > cg->password) in _cupsGetPassword()
936 return (cg->password); in _cupsGetPassword()
940 memset(cg->password, 0, sizeof(cg->password)); in _cupsGetPassword()
949 * '_cupsGSSServiceName()' - Get the GSS (Kerberos) service name.
958 if (!cg->gss_service_name[0]) in _cupsGSSServiceName()
961 return (cg->gss_service_name); in _cupsGSSServiceName()
967 * '_cupsSetDefaults()' - Set the default server, port, and encryption.
992 snprintf(filename, sizeof(filename), "%s/client.conf", cg->cups_serverroot); in _cupsSetDefaults()
999 if (cg->home) in _cupsSetDefaults()
1005 snprintf(filename, sizeof(filename), "%s/.cups/client.conf", cg->home); in _cupsSetDefaults()
1019 cg->uatokens = cc.uatokens; in _cupsSetDefaults()
1021 if (cg->encryption == (http_encryption_t)-1) in _cupsSetDefaults()
1022 cg->encryption = cc.encryption; in _cupsSetDefaults()
1024 if (!cg->server[0] || !cg->ipp_port) in _cupsSetDefaults()
1027 if (!cg->ipp_port) in _cupsSetDefaults()
1030 if (!cg->user[0]) in _cupsSetDefaults()
1031 strlcpy(cg->user, cc.user, sizeof(cg->user)); in _cupsSetDefaults()
1034 if (!cg->gss_service_name[0]) in _cupsSetDefaults()
1035 strlcpy(cg->gss_service_name, cc.gss_service_name, sizeof(cg->gss_service_name)); in _cupsSetDefaults()
1038 if (cg->trust_first < 0) in _cupsSetDefaults()
1039 cg->trust_first = cc.trust_first; in _cupsSetDefaults()
1041 if (cg->any_root < 0) in _cupsSetDefaults()
1042 cg->any_root = cc.any_root; in _cupsSetDefaults()
1044 if (cg->expired_certs < 0) in _cupsSetDefaults()
1045 cg->expired_certs = cc.expired_certs; in _cupsSetDefaults()
1047 if (cg->validate_certs < 0) in _cupsSetDefaults()
1048 cg->validate_certs = cc.validate_certs; in _cupsSetDefaults()
1058 * 'cups_apple_get_boolean()' - Get a boolean setting from the CUPS preferences.
1061 static int /* O - 1 if set, 0 otherwise */
1063 CFStringRef key, /* I - Key (name) */ in cups_apple_get_boolean()
1064 int *value) /* O - Boolean value */ in cups_apple_get_boolean()
1080 * 'cups_apple_get_string()' - Get a string setting from the CUPS preferences.
1083 static int /* O - 1 if set, 0 otherwise */
1085 CFStringRef key, /* I - Key (name) */ in cups_apple_get_string()
1086 char *value, /* O - String value */ in cups_apple_get_string()
1087 size_t valsize) /* I - Size of value buffer */ in cups_apple_get_string()
1108 * 'cups_boolean_value()' - Convert a string to a boolean value.
1111 static int /* O - Boolean value */
1112 cups_boolean_value(const char *value) /* I - String value */ in cups_boolean_value()
1119 * 'cups_finalize_client_conf()' - Finalize client.conf values.
1124 _cups_client_conf_t *cc) /* I - client.conf values */ in cups_finalize_client_conf()
1130 cc->trust_first = cups_boolean_value(value); in cups_finalize_client_conf()
1133 cc->any_root = cups_boolean_value(value); in cups_finalize_client_conf()
1139 cc->expired_certs = cups_boolean_value(value); in cups_finalize_client_conf()
1153 cc->validate_certs = cups_boolean_value(value); in cups_finalize_client_conf()
1159 if (cc->trust_first < 0) in cups_finalize_client_conf()
1160 cc->trust_first = 1; in cups_finalize_client_conf()
1162 if (cc->any_root < 0) in cups_finalize_client_conf()
1163 cc->any_root = 1; in cups_finalize_client_conf()
1165 if (cc->encryption == (http_encryption_t)-1) in cups_finalize_client_conf()
1166 cc->encryption = HTTP_ENCRYPTION_IF_REQUESTED; in cups_finalize_client_conf()
1168 if (cc->expired_certs < 0) in cups_finalize_client_conf()
1169 cc->expired_certs = 0; in cups_finalize_client_conf()
1172 if (!cc->gss_service_name[0]) in cups_finalize_client_conf()
1176 if (!cc->server_name[0]) in cups_finalize_client_conf()
1196 if (!cc->user[0]) in cups_finalize_client_conf()
1205 size = sizeof(cc->user); in cups_finalize_client_conf()
1206 if (!GetUserNameA(cc->user, &size)) in cups_finalize_client_conf()
1224 if ((pw = getpwnam(envuser)) != NULL && pw->pw_uid != getuid()) in cups_finalize_client_conf()
1232 strlcpy(cc->user, pw->pw_name, sizeof(cc->user)); in cups_finalize_client_conf()
1240 strlcpy(cc->user, "unknown", sizeof(cc->user)); in cups_finalize_client_conf()
1244 if (cc->validate_certs < 0) in cups_finalize_client_conf()
1245 cc->validate_certs = 0; in cups_finalize_client_conf()
1250 * 'cups_init_client_conf()' - Initialize client.conf values.
1255 _cups_client_conf_t *cc) /* I - client.conf values */ in cups_init_client_conf()
1263 cc->uatokens = _CUPS_UATOKENS_MINIMAL; in cups_init_client_conf()
1270 cc->ssl_min_version = _HTTP_TLS_1_0; in cups_init_client_conf()
1271 cc->ssl_max_version = _HTTP_TLS_MAX; in cups_init_client_conf()
1273 cc->encryption = (http_encryption_t)-1; in cups_init_client_conf()
1274 cc->trust_first = -1; in cups_init_client_conf()
1275 cc->any_root = -1; in cups_init_client_conf()
1276 cc->expired_certs = -1; in cups_init_client_conf()
1277 cc->validate_certs = -1; in cups_init_client_conf()
1290 cc->any_root = bval; in cups_init_client_conf()
1293 cc->expired_certs = bval; in cups_init_client_conf()
1318 cc->trust_first = bval; in cups_init_client_conf()
1321 cc->validate_certs = bval; in cups_init_client_conf()
1328 strlcpy(cc->user, sval, sizeof(cc->user)); in cups_init_client_conf()
1337 * 'cups_read_client_conf()' - Read a client.conf file.
1342 cups_file_t *fp, /* I - File to read */ in cups_read_client_conf()
1343 _cups_client_conf_t *cc) /* I - client.conf values */ in cups_read_client_conf()
1374 cc->trust_first = cups_boolean_value(value); in cups_read_client_conf()
1376 cc->any_root = cups_boolean_value(value); in cups_read_client_conf()
1379 cc->expired_certs = cups_boolean_value(value); in cups_read_client_conf()
1381 cc->validate_certs = cups_boolean_value(value); in cups_read_client_conf()
1395 * 'cups_set_default_ipp_port()' - Set the default IPP port value.
1400 _cups_globals_t *cg) /* I - Global data */ in cups_set_default_ipp_port()
1407 if ((cg->ipp_port = atoi(ipp_port)) <= 0) in cups_set_default_ipp_port()
1408 cg->ipp_port = CUPS_DEFAULT_IPP_PORT; in cups_set_default_ipp_port()
1411 cg->ipp_port = CUPS_DEFAULT_IPP_PORT; in cups_set_default_ipp_port()
1416 * 'cups_set_digestoptions()' - Set the DigestOptions value.
1421 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_digestoptions()
1422 const char *value) /* I - Value */ in cups_set_digestoptions()
1425 cc->digestoptions = _CUPS_DIGESTOPTIONS_DENYMD5; in cups_set_digestoptions()
1427 cc->digestoptions = _CUPS_DIGESTOPTIONS_NONE; in cups_set_digestoptions()
1432 * 'cups_set_encryption()' - Set the Encryption value.
1437 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_encryption()
1438 const char *value) /* I - Value */ in cups_set_encryption()
1441 cc->encryption = HTTP_ENCRYPTION_NEVER; in cups_set_encryption()
1443 cc->encryption = HTTP_ENCRYPTION_ALWAYS; in cups_set_encryption()
1445 cc->encryption = HTTP_ENCRYPTION_REQUIRED; in cups_set_encryption()
1447 cc->encryption = HTTP_ENCRYPTION_IF_REQUESTED; in cups_set_encryption()
1452 * 'cups_set_gss_service_name()' - Set the GSSServiceName value.
1458 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_gss_service_name()
1459 const char *value) /* I - Value */ in cups_set_gss_service_name()
1461 strlcpy(cc->gss_service_name, value, sizeof(cc->gss_service_name)); in cups_set_gss_service_name()
1467 * 'cups_set_server_name()' - Set the ServerName value.
1472 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_server_name()
1473 const char *value) /* I - Value */ in cups_set_server_name()
1475 strlcpy(cc->server_name, value, sizeof(cc->server_name)); in cups_set_server_name()
1480 * 'cups_set_ssl_options()' - Set the SSLOptions value.
1486 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_ssl_options()
1487 const char *value) /* I - Value */ in cups_set_ssl_options()
1550 cc->ssl_options = options; in cups_set_ssl_options()
1551 cc->ssl_max_version = max_version; in cups_set_ssl_options()
1552 cc->ssl_min_version = min_version; in cups_set_ssl_options()
1560 * 'cups_set_uatokens()' - Set the UserAgentTokens value.
1565 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_uatokens()
1566 const char *value) /* I - Value */ in cups_set_uatokens()
1584 cc->uatokens = (_cups_uatokens_t)i; in cups_set_uatokens()
1592 * 'cups_set_user()' - Set the User value.
1597 _cups_client_conf_t *cc, /* I - client.conf values */ in cups_set_user()
1598 const char *value) /* I - Value */ in cups_set_user()
1600 strlcpy(cc->user, value, sizeof(cc->user)); in cups_set_user()