Changeset View
Changeset View
Standalone View
Standalone View
crypto/openssh/ssh.c
Show All 35 Lines | |||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include "includes.h" | #include "includes.h" | ||||
__RCSID("$FreeBSD$"); | |||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifdef HAVE_SYS_STAT_H | #ifdef HAVE_SYS_STAT_H | ||||
# include <sys/stat.h> | # include <sys/stat.h> | ||||
#endif | #endif | ||||
#include <sys/resource.h> | #include <sys/resource.h> | ||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
▲ Show 20 Lines • Show All 759 Lines • ▼ Show 20 Lines | case 'v': | ||||
} else { | } else { | ||||
if (options.log_level < SYSLOG_LEVEL_DEBUG3) { | if (options.log_level < SYSLOG_LEVEL_DEBUG3) { | ||||
debug_flag++; | debug_flag++; | ||||
options.log_level++; | options.log_level++; | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case 'V': | case 'V': | ||||
fprintf(stderr, "%s, %s\n", | if (options.version_addendum && | ||||
SSH_RELEASE, | *options.version_addendum != '\0') | ||||
#ifdef WITH_OPENSSL | fprintf(stderr, "%s %s, %s\n", SSH_RELEASE, | ||||
OpenSSL_version(OPENSSL_VERSION) | options.version_addendum, | ||||
#else | OPENSSL_VERSION_STRING); | ||||
"without OpenSSL" | else | ||||
#endif | fprintf(stderr, "%s, %s\n", SSH_RELEASE, | ||||
); | OPENSSL_VERSION_STRING); | ||||
if (opt == 'V') | if (opt == 'V') | ||||
exit(0); | exit(0); | ||||
break; | break; | ||||
case 'w': | case 'w': | ||||
if (options.tun_open == -1) | if (options.tun_open == -1) | ||||
options.tun_open = SSH_TUNMODE_DEFAULT; | options.tun_open = SSH_TUNMODE_DEFAULT; | ||||
options.tun_local = a2tun(optarg, &options.tun_remote); | options.tun_local = a2tun(optarg, &options.tun_remote); | ||||
if (options.tun_local == SSH_TUNID_ERR) { | if (options.tun_local == SSH_TUNID_ERR) { | ||||
▲ Show 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | #endif | ||||
log_init(argv0, | log_init(argv0, | ||||
options.log_level == SYSLOG_LEVEL_NOT_SET ? | options.log_level == SYSLOG_LEVEL_NOT_SET ? | ||||
SYSLOG_LEVEL_INFO : options.log_level, | SYSLOG_LEVEL_INFO : options.log_level, | ||||
options.log_facility == SYSLOG_FACILITY_NOT_SET ? | options.log_facility == SYSLOG_FACILITY_NOT_SET ? | ||||
SYSLOG_FACILITY_USER : options.log_facility, | SYSLOG_FACILITY_USER : options.log_facility, | ||||
!use_syslog); | !use_syslog); | ||||
if (debug_flag) | if (debug_flag) | ||||
logit("%s, %s", SSH_RELEASE, | /* version_addendum is always NULL at this point */ | ||||
#ifdef WITH_OPENSSL | logit("%s, %s", SSH_RELEASE, OPENSSL_VERSION_STRING); | ||||
OpenSSL_version(OPENSSL_VERSION) | |||||
#else | |||||
"without OpenSSL" | |||||
#endif | |||||
); | |||||
/* Parse the configuration files */ | /* Parse the configuration files */ | ||||
process_config_files(host_arg, pw, 0, &want_final_pass); | process_config_files(host_arg, pw, 0, &want_final_pass); | ||||
if (want_final_pass) | if (want_final_pass) | ||||
debug("configuration requests final Match pass"); | debug("configuration requests final Match pass"); | ||||
/* Hostname canonicalisation needs a few options filled. */ | /* Hostname canonicalisation needs a few options filled. */ | ||||
fill_default_options_for_canonicalization(&options); | fill_default_options_for_canonicalization(&options); | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | #endif | ||||
/* Set up strings used to percent_expand() arguments */ | /* Set up strings used to percent_expand() arguments */ | ||||
if (gethostname(thishost, sizeof(thishost)) == -1) | if (gethostname(thishost, sizeof(thishost)) == -1) | ||||
fatal("gethostname: %s", strerror(errno)); | fatal("gethostname: %s", strerror(errno)); | ||||
strlcpy(shorthost, thishost, sizeof(shorthost)); | strlcpy(shorthost, thishost, sizeof(shorthost)); | ||||
shorthost[strcspn(thishost, ".")] = '\0'; | shorthost[strcspn(thishost, ".")] = '\0'; | ||||
snprintf(portstr, sizeof(portstr), "%d", options.port); | snprintf(portstr, sizeof(portstr), "%d", options.port); | ||||
snprintf(uidstr, sizeof(uidstr), "%llu", | snprintf(uidstr, sizeof(uidstr), "%llu", | ||||
(unsigned long long)pw->pw_uid); | (unsigned long long)pw->pw_uid); | ||||
/* Find canonic host name. */ | |||||
if (strchr(host, '.') == 0) { | |||||
struct addrinfo hints; | |||||
struct addrinfo *ai = NULL; | |||||
int errgai; | |||||
memset(&hints, 0, sizeof(hints)); | |||||
hints.ai_family = options.address_family; | |||||
hints.ai_flags = AI_CANONNAME; | |||||
hints.ai_socktype = SOCK_STREAM; | |||||
errgai = getaddrinfo(host, NULL, &hints, &ai); | |||||
if (errgai == 0) { | |||||
if (ai->ai_canonname != NULL) | |||||
host = xstrdup(ai->ai_canonname); | |||||
freeaddrinfo(ai); | |||||
} | |||||
} | |||||
if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL || | if ((md = ssh_digest_start(SSH_DIGEST_SHA1)) == NULL || | ||||
ssh_digest_update(md, thishost, strlen(thishost)) < 0 || | ssh_digest_update(md, thishost, strlen(thishost)) < 0 || | ||||
ssh_digest_update(md, host, strlen(host)) < 0 || | ssh_digest_update(md, host, strlen(host)) < 0 || | ||||
ssh_digest_update(md, portstr, strlen(portstr)) < 0 || | ssh_digest_update(md, portstr, strlen(portstr)) < 0 || | ||||
ssh_digest_update(md, options.user, strlen(options.user)) < 0 || | ssh_digest_update(md, options.user, strlen(options.user)) < 0 || | ||||
ssh_digest_final(md, conn_hash, sizeof(conn_hash)) < 0) | ssh_digest_final(md, conn_hash, sizeof(conn_hash)) < 0) | ||||
fatal("%s: mux digest failed", __func__); | fatal("%s: mux digest failed", __func__); | ||||
▲ Show 20 Lines • Show All 874 Lines • Show Last 20 Lines |