aboutsummaryrefslogtreecommitdiffstats
path: root/community/mingetty/0001-check_chroot_chdir_nice.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/mingetty/0001-check_chroot_chdir_nice.patch')
-rw-r--r--community/mingetty/0001-check_chroot_chdir_nice.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/community/mingetty/0001-check_chroot_chdir_nice.patch b/community/mingetty/0001-check_chroot_chdir_nice.patch
new file mode 100644
index 00000000000..2552047262c
--- /dev/null
+++ b/community/mingetty/0001-check_chroot_chdir_nice.patch
@@ -0,0 +1,36 @@
+Check chdir() on chroot() syscalls (and similar) as chroot without proper
+chdir() allows to escape from changed root.
+
+http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597382
+
+Patch-Source: https://src.fedoraproject.org/rpms/mingetty/raw/f35/f/mingetty-1.08-check_chroot_chdir_nice.patch
+--- a/mingetty.c
++++ b/mingetty.c
+@@ -414,12 +431,21 @@
+ while ((logname = get_logname ()) == 0)
+ /* do nothing */ ;
+
+- if (ch_root)
+- chroot (ch_root);
+- if (ch_dir)
+- chdir (ch_dir);
+- if (priority)
+- nice (priority);
++ if (ch_root) {
++ if (chroot (ch_root))
++ error ("chroot(\"%s\") failed: %s", ch_root, strerror (errno));
++ if (chdir("/"))
++ error ("chdir(\"/\") failed: %s", strerror (errno));
++ }
++ if (ch_dir) {
++ if (chdir (ch_dir))
++ error ("chdir(\"%s\") failed: %s", ch_dir, strerror (errno));
++ }
++ if (priority) {
++ errno = 0; /* see the nice(2) NOTES for why we do this */
++ if ((nice(priority) == -1) && (errno != 0))
++ error ("nice(%d) failed: %s", priority, strerror (errno));
++ }
+
+ execl (loginprog, loginprog, autologin? "-f" : "--", logname, NULL);
+ error ("%s: can't exec %s: %s", tty, loginprog, strerror (errno));