2013-02-19 17:08:30 +00:00
|
|
|
diff --git a/auth.c b/auth.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index 84fca58..63c3c3e 100644
|
2013-02-19 17:08:30 +00:00
|
|
|
--- a/auth.c
|
|
|
|
+++ b/auth.c
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -364,7 +364,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw)
|
2013-02-19 17:08:30 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
/*
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -374,7 +374,7 @@ expand_authorized_keys(const char *filename, struct passwd *pw)
|
2013-02-19 17:08:30 +00:00
|
|
|
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");
|
2015-05-01 19:33:29 +00:00
|
|
|
free(file);
|
|
|
|
@@ -463,7 +463,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
|
2013-02-19 17:08:30 +00:00
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
2015-05-01 19:33:29 +00:00
|
|
|
- if (pw_dir != NULL && realpath(pw_dir, homedir) != NULL)
|
|
|
|
+ if (_PATH_ROOT_HOME_PREFIX != NULL && realpath(_PATH_ROOT_HOME_PREFIX, homedir) != NULL)
|
2013-02-19 17:08:30 +00:00
|
|
|
comparehome = 1;
|
|
|
|
|
2015-05-01 19:33:29 +00:00
|
|
|
if (!S_ISREG(stp->st_mode)) {
|
2014-03-10 20:50:56 +00:00
|
|
|
diff --git a/authfile.c b/authfile.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index 63ae16b..7b7841a 100644
|
2014-03-10 20:50:56 +00:00
|
|
|
--- a/authfile.c
|
|
|
|
+++ b/authfile.c
|
|
|
|
@@ -613,6 +613,7 @@ int
|
|
|
|
key_perm_ok(int fd, const char *filename)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
+ return 1; /* check doesn't make sense on android */
|
|
|
|
|
|
|
|
if (fstat(fd, &st) < 0)
|
|
|
|
return 0;
|
2013-02-19 17:08:30 +00:00
|
|
|
diff --git a/misc.c b/misc.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index 3b9792f..516e7ae 100644
|
2013-02-19 17:08:30 +00:00
|
|
|
--- a/misc.c
|
|
|
|
+++ b/misc.c
|
|
|
|
@@ -25,6 +25,7 @@
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
+#include "pathnames.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ioctl.h>
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -539,8 +540,9 @@ tilde_expand_filename(const char *filename, uid_t uid)
|
2013-02-19 17:08:30 +00:00
|
|
|
fatal("tilde_expand_filename: No such uid %ld", (long)uid);
|
|
|
|
|
|
|
|
/* Make sure directory has a trailing '/' */
|
|
|
|
- len = strlen(pw->pw_dir);
|
2015-05-01 19:33:29 +00:00
|
|
|
- if (len == 0 || pw->pw_dir[len - 1] != '/')
|
|
|
|
+ char *pw_dir=_PATH_ROOT_HOME_PREFIX;
|
2013-02-19 17:08:30 +00:00
|
|
|
+ len = strlen(pw_dir);
|
2015-05-01 19:33:29 +00:00
|
|
|
+ if (len == 0 || pw_dir[len - 1] != '/')
|
|
|
|
sep = "/";
|
|
|
|
else
|
|
|
|
sep = "";
|
2013-02-19 17:08:30 +00:00
|
|
|
diff --git a/pathnames.h b/pathnames.h
|
2015-05-01 19:33:29 +00:00
|
|
|
index 3b7584c..1103266 100644
|
2013-02-19 17:08:30 +00:00
|
|
|
--- 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
|
|
|
|
|
|
|
|
/*
|
2013-05-04 20:00:02 +00:00
|
|
|
diff --git a/readconf.c b/readconf.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index e22c952..87c1c8a 100644
|
2013-05-04 20:00:02 +00:00
|
|
|
--- a/readconf.c
|
|
|
|
+++ b/readconf.c
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -1113,7 +1113,7 @@ read_config_file(const char *filename, const char *host, Options *options,
|
2013-05-04 20:00:02 +00:00
|
|
|
if ((f = fopen(filename, "r")) == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2015-05-01 19:33:29 +00:00
|
|
|
- if (flags & SSHCONF_CHECKPERM) {
|
|
|
|
+ if (0) {
|
2013-05-04 20:00:02 +00:00
|
|
|
struct stat sb;
|
|
|
|
|
|
|
|
if (fstat(fileno(f), &sb) == -1)
|
2013-02-19 17:08:30 +00:00
|
|
|
diff --git a/ssh-add.c b/ssh-add.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index 5e8166f..f0edc30 100644
|
2013-02-19 17:08:30 +00:00
|
|
|
--- a/ssh-add.c
|
|
|
|
+++ b/ssh-add.c
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -496,7 +496,7 @@ main(int argc, char **argv)
|
2013-02-19 17:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2015-05-01 19:33:29 +00:00
|
|
|
index 40ba5e3..82c2ebf 100644
|
2013-02-19 17:08:30 +00:00
|
|
|
--- a/ssh-keygen.c
|
|
|
|
+++ b/ssh-keygen.c
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -228,7 +228,7 @@ ask_filename(struct passwd *pw, const char *prompt)
|
2013-02-19 17:08:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
snprintf(identity_file, sizeof(identity_file), "%s/%s",
|
2015-05-01 19:33:29 +00:00
|
|
|
- strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX, name);
|
|
|
|
+ _PATH_ROOT_HOME_PREFIX, name);
|
2013-02-19 17:08:30 +00:00
|
|
|
fprintf(stderr, "%s (%s): ", prompt, identity_file);
|
|
|
|
if (fgets(buf, sizeof(buf), stdin) == NULL)
|
|
|
|
exit(1);
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -2561,7 +2561,7 @@ main(int argc, char **argv)
|
2013-02-19 17:08:30 +00:00
|
|
|
|
|
|
|
/* Create ~/.ssh directory if it doesn't already exist. */
|
|
|
|
snprintf(dotsshdir, sizeof dotsshdir, "%s/%s",
|
2015-05-01 19:33:29 +00:00
|
|
|
- strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX,
|
|
|
|
+ _PATH_ROOT_HOME_PREFIX,
|
|
|
|
_PATH_SSH_USER_DIR);
|
2013-02-19 17:08:30 +00:00
|
|
|
if (strstr(identity_file, dotsshdir) != NULL) {
|
|
|
|
if (stat(dotsshdir, &st) < 0) {
|
|
|
|
diff --git a/ssh.c b/ssh.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index 1e2cdd5..cc48c2d 100644
|
2013-02-19 17:08:30 +00:00
|
|
|
--- a/ssh.c
|
|
|
|
+++ b/ssh.c
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -707,7 +707,7 @@ main(int ac, char **av)
|
2013-02-19 17:08:30 +00:00
|
|
|
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))
|
2015-05-01 19:33:29 +00:00
|
|
|
(void)read_config_file(buf, host, &options,
|
|
|
|
@@ -773,7 +773,7 @@ main(int ac, char **av)
|
2013-02-19 17:08:30 +00:00
|
|
|
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);
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -913,7 +913,7 @@ main(int ac, char **av)
|
2013-02-19 17:08:30 +00:00
|
|
|
*/
|
|
|
|
if (config == NULL) {
|
|
|
|
r = snprintf(buf, sizeof buf, "%s/%s",
|
2015-05-01 19:33:29 +00:00
|
|
|
- strcmp(pw->pw_dir, "/") ? pw->pw_dir : _PATH_ROOT_HOME_PREFIX,
|
|
|
|
+ _PATH_ROOT_HOME_PREFIX,
|
|
|
|
_PATH_SSH_USER_DIR);
|
2013-02-19 17:08:30 +00:00
|
|
|
if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) {
|
|
|
|
#ifdef WITH_SELINUX
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -1565,7 +1565,7 @@ load_public_identity_files(void)
|
2013-02-19 17:08:30 +00:00
|
|
|
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));
|
2013-02-18 22:50:28 +00:00
|
|
|
diff --git a/uidswap.c b/uidswap.c
|
2015-05-01 19:33:29 +00:00
|
|
|
index 50d20d6..d226cc9 100644
|
2013-02-18 22:50:28 +00:00
|
|
|
--- a/uidswap.c
|
|
|
|
+++ b/uidswap.c
|
|
|
|
@@ -28,7 +28,6 @@
|
|
|
|
#include "xmalloc.h"
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
-#include <private/android_filesystem_config.h>
|
2015-05-01 19:33:29 +00:00
|
|
|
#include <sys/capability.h>
|
2013-02-18 22:50:28 +00:00
|
|
|
#include <linux/prctl.h>
|
|
|
|
#endif
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -216,7 +215,7 @@ permanently_set_uid(struct passwd *pw)
|
2013-02-18 22:50:28 +00:00
|
|
|
debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid,
|
|
|
|
(u_int)pw->pw_gid);
|
|
|
|
|
|
|
|
-#ifdef ANDROID
|
|
|
|
+#if 0
|
|
|
|
if (pw->pw_uid == AID_SHELL) {
|
|
|
|
prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
|
|
|
|
|
2015-05-01 19:33:29 +00:00
|
|
|
@@ -281,7 +280,7 @@ permanently_set_uid(struct passwd *pw)
|
2013-02-18 22:50:28 +00:00
|
|
|
(u_int)pw->pw_uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
-#ifdef ANDROID
|
|
|
|
+#if 0
|
|
|
|
if (pw->pw_uid == AID_SHELL) {
|
|
|
|
/* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */
|
|
|
|
header.version = _LINUX_CAPABILITY_VERSION;
|