bugfix: chdir(/) after chroot
authorMichael Tokarev <mjt@corpit.ru>
Mon, 18 May 2009 12:53:08 +0000 (16:53 +0400)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 18 May 2009 13:05:43 +0000 (15:05 +0200)
Fix the famous chdir(".") vs chdir("/") after chroot(something).

src/tincd.c

index 929e9b9..89bda91 100644 (file)
@@ -465,7 +465,7 @@ static bool drop_privs() {
        }
        if (do_chroot) {
                tzset();        /* for proper timestamps in logs */
        }
        if (do_chroot) {
                tzset();        /* for proper timestamps in logs */
-               if (chroot(confbase) != 0 || chdir(".") != 0) {
+               if (chroot(confbase) != 0 || chdir("/") != 0) {
                        logger(LOG_ERR, _("%s failed"), "chroot()");
                        return false;
                }
                        logger(LOG_ERR, _("%s failed"), "chroot()");
                        return false;
                }