summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-06-26 05:02:03 +0000
committerDamien Miller <djm@mindrot.org>2020-06-26 15:24:27 +1000
commit74344c3ca42c3f53b00b025daf09ae7f6aa38076 (patch)
tree4952081cdbd6c6f3e6e891cd09a7688f003ea639 /ssh.c
parentc9e24daac6324fcbdba171392c325bf9ccc3c768 (diff)
upstream: Defer creation of ~/.ssh by ssh(1) until we attempt to
write to it so we don't leave an empty .ssh directory when it's not needed. Use the same function to replace the code in ssh-keygen that does the same thing. bz#3156, ok djm@ OpenBSD-Commit-ID: 59c073b569be1a60f4de36f491a4339bc4ae870f
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/ssh.c b/ssh.c
index dfae0a73d..a767a1839 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.529 2020/06/05 03:15:26 dtucker Exp $ */ 1/* $OpenBSD: ssh.c,v 1.530 2020/06/26 05:02:03 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -645,7 +645,7 @@ main(int ac, char **av)
645 struct ssh *ssh = NULL; 645 struct ssh *ssh = NULL;
646 int i, r, opt, exit_status, use_syslog, direct, timeout_ms; 646 int i, r, opt, exit_status, use_syslog, direct, timeout_ms;
647 int was_addr, config_test = 0, opt_terminated = 0, want_final_pass = 0; 647 int was_addr, config_test = 0, opt_terminated = 0, want_final_pass = 0;
648 char *p, *cp, *line, *argv0, buf[PATH_MAX], *logfile; 648 char *p, *cp, *line, *argv0, *logfile;
649 char cname[NI_MAXHOST]; 649 char cname[NI_MAXHOST];
650 struct stat st; 650 struct stat st;
651 struct passwd *pw; 651 struct passwd *pw;
@@ -1572,22 +1572,6 @@ main(int ac, char **av)
1572 } 1572 }
1573 } 1573 }
1574 1574
1575 /* Create ~/.ssh * directory if it doesn't already exist. */
1576 if (config == NULL) {
1577 r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir,
1578 strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
1579 if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) == -1) {
1580#ifdef WITH_SELINUX
1581 ssh_selinux_setfscreatecon(buf);
1582#endif
1583 if (mkdir(buf, 0700) < 0)
1584 error("Could not create directory '%.200s'.",
1585 buf);
1586#ifdef WITH_SELINUX
1587 ssh_selinux_setfscreatecon(NULL);
1588#endif
1589 }
1590 }
1591 /* load options.identity_files */ 1575 /* load options.identity_files */
1592 load_public_identity_files(pw); 1576 load_public_identity_files(pw);
1593 1577