summaryrefslogtreecommitdiff
path: root/other/ssharp/contrib/chroot.diff
diff options
context:
space:
mode:
authorSkyperTHC2026-03-03 06:28:55 +0000
committerSkyperTHC2026-03-03 06:28:55 +0000
commit5d3573ef7a109ee70416fe94db098fe6a769a798 (patch)
treedc2d5b294c9db8ab2db7433511f94e1c4bb8b698 /other/ssharp/contrib/chroot.diff
parentc6c59dc73cc4586357f93ab38ecf459e98675cc5 (diff)
packetstorm sync
Diffstat (limited to 'other/ssharp/contrib/chroot.diff')
-rw-r--r--other/ssharp/contrib/chroot.diff63
1 files changed, 63 insertions, 0 deletions
diff --git a/other/ssharp/contrib/chroot.diff b/other/ssharp/contrib/chroot.diff
new file mode 100644
index 0000000..2e9140f
--- /dev/null
+++ b/other/ssharp/contrib/chroot.diff
@@ -0,0 +1,63 @@
1From: Ricardo Cerqueira <rmcc@novis.pt>
2
3A patch to cause sshd to chroot when it encounters the magic token
4'/./' in a users home directory. The directory portion before the
5token is the directory to chroot() to, the portion after the
6token is the user's home directory relative to the new root.
7
8To apply, execute the following command from the OpenSSH source directory:
9
10patch -p0 < contrib/chroot.diff
11
12
13--- session.c Thu Mar 22 01:58:27 2001
14+++ session.c.chroot Thu Apr 5 12:33:23 2001
15@@ -93,6 +93,8 @@
16 # include <uinfo.h>
17 #endif
18
19+#define CHROOT
20+
21 /* types */
22
23 #define TTYSZ 64
24@@ -1012,6 +1014,11 @@
25 extern char **environ;
26 struct stat st;
27 char *argv[10];
28+#ifdef CHROOT
29+ char *user_dir;
30+ char *new_root;
31+#endif /* CHROOT */
32+
33 int do_xauth = s->auth_proto != NULL && s->auth_data != NULL;
34 #ifdef WITH_IRIX_PROJECT
35 prid_t projid;
36@@ -1095,6 +1102,27 @@
37 exit(1);
38 }
39 endgrent();
40+
41+#ifdef CHROOT
42+ user_dir = xstrdup(pw->pw_dir);
43+ new_root = user_dir + 1;
44+
45+ while((new_root = strchr(new_root, '.')) != NULL) {
46+ new_root--;
47+ if(strncmp(new_root, "/./", 3) == 0) {
48+ *new_root = '\0';
49+ new_root += 2;
50+
51+ if(chroot(user_dir) != 0)
52+ fatal("Couldn't chroot to user directory %s", user_dir);
53+
54+ pw->pw_dir = new_root;
55+ break;
56+ }
57+ new_root += 2;
58+ }
59+#endif /* CHROOT */
60+
61 # ifdef WITH_IRIX_JOBS
62 jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive");
63 if (jid == -1) {