summaryrefslogtreecommitdiff
path: root/standalone/android/openssh.patch
blob: 7eb7211f9813faf26d277f446f8b27642b6f5c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
diff --git a/auth.c b/auth.c
index 84fca58..63c3c3e 100644
--- a/auth.c
+++ b/auth.c
@@ -364,7 +364,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);
 
 	/*
@@ -374,7 +374,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");
 	free(file);
@@ -463,7 +463,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
 		    strerror(errno));
 		return -1;
 	}
-	if (pw_dir != NULL && realpath(pw_dir, homedir) != NULL)
+	if (_PATH_ROOT_HOME_PREFIX != NULL && realpath(_PATH_ROOT_HOME_PREFIX, homedir) != NULL)
 		comparehome = 1;
 
 	if (!S_ISREG(stp->st_mode)) {
diff --git a/authfile.c b/authfile.c
index 63ae16b..7b7841a 100644
--- 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;
diff --git a/misc.c b/misc.c
index 3b9792f..516e7ae 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>
@@ -539,8 +540,9 @@ tilde_expand_filename(const char *filename, uid_t uid)
 		fatal("tilde_expand_filename: No such uid %ld", (long)uid);
 
 	/* Make sure directory has a trailing '/' */
-	len = strlen(pw->pw_dir);
-	if (len == 0 || pw->pw_dir[len - 1] != '/')
+	char *pw_dir=_PATH_ROOT_HOME_PREFIX;
+	len = strlen(pw_dir);
+	if (len == 0 || pw_dir[len - 1] != '/')
 		sep = "/";
 	else
 		sep = "";
diff --git a/pathnames.h b/pathnames.h
index 3b7584c..1103266 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/readconf.c b/readconf.c
index e22c952..87c1c8a 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1113,7 +1113,7 @@ read_config_file(const char *filename, const char *host, Options *options,
 	if ((f = fopen(filename, "r")) == NULL)
 		return 0;
 
-	if (flags & SSHCONF_CHECKPERM) {
+	if (0) {
 		struct stat sb;
 
 		if (fstat(fileno(f), &sb) == -1)
diff --git a/ssh-add.c b/ssh-add.c
index 5e8166f..f0edc30 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -496,7 +496,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 40ba5e3..82c2ebf 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -228,7 +228,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);
@@ -2561,7 +2561,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 1e2cdd5..cc48c2d 100644
--- a/ssh.c
+++ b/ssh.c
@@ -707,7 +707,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,
@@ -773,7 +773,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);
@@ -913,7 +913,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
@@ -1565,7 +1565,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 50d20d6..d226cc9 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -28,7 +28,6 @@
 #include "xmalloc.h"
 
 #ifdef ANDROID
-#include <private/android_filesystem_config.h>
 #include <sys/capability.h>
 #include <linux/prctl.h>
 #endif
@@ -216,7 +215,7 @@ permanently_set_uid(struct passwd *pw)
 	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);
 
@@ -281,7 +280,7 @@ permanently_set_uid(struct passwd *pw)
 		    (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;