diff options
author | Joey Hess <joey@kitenet.net> | 2013-02-19 13:08:30 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-02-19 13:08:30 -0400 |
commit | ae3b28eb5bfd70ef6f59069ec59abb13ca193d3d (patch) | |
tree | 48ded21d5a5bd318c0b2ea49f8811857d6638699 | |
parent | dc66858b4c6ace49df56e87e6b60c63f4308fbaf (diff) |
make ssh honour HOME rather than getpwent
-rw-r--r-- | standalone/android/openssh.patch | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/standalone/android/openssh.patch b/standalone/android/openssh.patch index e81c06b25..7305bdafb 100644 --- a/standalone/android/openssh.patch +++ b/standalone/android/openssh.patch @@ -1,3 +1,63 @@ +diff --git a/auth.c b/auth.c +index 6623e0f..dd10253 100644 +--- a/auth.c ++++ b/auth.c +@@ -337,7 +337,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw) + char *file, ret[MAXPATHLEN]; + int i; + +- file = percent_expand(filename, "h", pw->pw_dir, ++ file = percent_expand(filename, "h", _PATH_ROOT_HOME_PREFIX, + "u", pw->pw_name, (char *)NULL); + + /* +@@ -347,7 +347,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw) + if (*file == '/') + return (file); + +- i = snprintf(ret, sizeof(ret), "%s/%s", pw->pw_dir, file); ++ i = snprintf(ret, sizeof(ret), "%s/%s", _PATH_ROOT_HOME_PREFIX, file); + if (i < 0 || (size_t)i >= sizeof(ret)) + fatal("expand_authorized_keys: path too long"); + xfree(file); +@@ -436,7 +436,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, + strerror(errno)); + return -1; + } +- if (realpath(pw->pw_dir, homedir) != NULL) ++ if (realpath(_PATH_ROOT_HOME_PREFIX, homedir) != NULL) + comparehome = 1; + + /* check the open file to avoid races */ +diff --git a/misc.c b/misc.c +index 0bf2db6..4327d03 100644 +--- a/misc.c ++++ b/misc.c +@@ -25,6 +25,7 @@ + */ + + #include "includes.h" ++#include "pathnames.h" + + #include <sys/types.h> + #include <sys/ioctl.h> +@@ -538,12 +539,13 @@ tilde_expand_filename(const char *filename, uid_t uid) + } else if ((pw = getpwuid(uid)) == NULL) /* ~/path */ + fatal("tilde_expand_filename: No such uid %ld", (long)uid); + +- if (strlcpy(ret, pw->pw_dir, sizeof(ret)) >= sizeof(ret)) ++ char *pw_dir=_PATH_ROOT_HOME_PREFIX; ++ if (strlcpy(ret, pw_dir, sizeof(ret)) >= sizeof(ret)) + fatal("tilde_expand_filename: Path too long"); + + /* Make sure directory has a trailing '/' */ +- len = strlen(pw->pw_dir); +- if ((len == 0 || pw->pw_dir[len - 1] != '/') && ++ len = strlen(pw_dir); ++ if ((len == 0 || pw_dir[len - 1] != '/') && + strlcat(ret, "/", sizeof(ret)) >= sizeof(ret)) + fatal("tilde_expand_filename: Path too long"); + diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c index d2bea21..5b5d599 100644 --- a/openbsd-compat/getrrsetbyname.c @@ -12,6 +72,94 @@ index d2bea21..5b5d599 100644 #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO extern int h_errno; +diff --git a/pathnames.h b/pathnames.h +index b7b9d91..3c10b11 100644 +--- a/pathnames.h ++++ b/pathnames.h +@@ -67,7 +67,7 @@ + #endif + + #ifndef _PATH_ROOT_HOME_PREFIX +-#define _PATH_ROOT_HOME_PREFIX "/data" ++#define _PATH_ROOT_HOME_PREFIX getenv("HOME") + #endif + + /* +diff --git a/ssh-add.c b/ssh-add.c +index 738644d..f6fce4a 100644 +--- a/ssh-add.c ++++ b/ssh-add.c +@@ -471,7 +471,7 @@ main(int argc, char **argv) + } + + for (i = 0; default_files[i]; i++) { +- snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, ++ snprintf(buf, sizeof(buf), "%s/%s", _PATH_ROOT_HOME_PREFIX, + default_files[i]); + if (stat(buf, &st) < 0) + continue; +diff --git a/ssh-keygen.c b/ssh-keygen.c +index 4baf7df..ef8bb25 100644 +--- a/ssh-keygen.c ++++ b/ssh-keygen.c +@@ -224,7 +224,7 @@ ask_filename(struct passwd *pw, const char *prompt) + } + } + snprintf(identity_file, sizeof(identity_file), "%s/%s", +- strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX, name); ++ _PATH_ROOT_HOME_PREFIX, name); + fprintf(stderr, "%s (%s): ", prompt, identity_file); + if (fgets(buf, sizeof(buf), stdin) == NULL) + exit(1); +@@ -2268,7 +2268,7 @@ main(int argc, char **argv) + + /* Create ~/.ssh directory if it doesn't already exist. */ + snprintf(dotsshdir, sizeof dotsshdir, "%s/%s", +- strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX, ++ _PATH_ROOT_HOME_PREFIX, + _PATH_SSH_USER_DIR); + if (strstr(identity_file, dotsshdir) != NULL) { + if (stat(dotsshdir, &st) < 0) { +diff --git a/ssh.c b/ssh.c +index 898e966..ef6c858 100644 +--- a/ssh.c ++++ b/ssh.c +@@ -703,7 +703,7 @@ main(int ac, char **av) + fatal("Can't open user config file %.100s: " + "%.100s", config, strerror(errno)); + } else { +- r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, ++ r = snprintf(buf, sizeof buf, "%s/%s", _PATH_ROOT_HOME_PREFIX, + _PATH_SSH_USER_CONFFILE); + if (r > 0 && (size_t)r < sizeof(buf)) + (void)read_config_file(buf, host, &options, 1); +@@ -748,7 +748,7 @@ main(int ac, char **av) + if (options.local_command != NULL) { + debug3("expanding LocalCommand: %s", options.local_command); + cp = options.local_command; +- options.local_command = percent_expand(cp, "d", pw->pw_dir, ++ options.local_command = percent_expand(cp, "d", _PATH_ROOT_HOME_PREFIX, + "h", host, "l", thishost, "n", host_arg, "r", options.user, + "p", portstr, "u", pw->pw_name, "L", shorthost, + (char *)NULL); +@@ -888,7 +888,7 @@ main(int ac, char **av) + */ + if (config == NULL) { + r = snprintf(buf, sizeof buf, "%s/%s", +- strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX, ++ _PATH_ROOT_HOME_PREFIX, + _PATH_SSH_USER_DIR); + if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) { + #ifdef WITH_SELINUX +@@ -1532,7 +1532,7 @@ load_public_identity_files(void) + if ((pw = getpwuid(original_real_uid)) == NULL) + fatal("load_public_identity_files: getpwuid failed"); + pwname = xstrdup(pw->pw_name); +- pwdir = xstrdup(pw->pw_dir); ++ pwdir = xstrdup(_PATH_ROOT_HOME_PREFIX); + if (gethostname(thishost, sizeof(thishost)) == -1) + fatal("load_public_identity_files: gethostname: %s", + strerror(errno)); diff --git a/uidswap.c b/uidswap.c index bc6194e..5cbf5d1 100644 --- a/uidswap.c |