diff svr-chansession.c @ 1875:bfa92efd814b

Make missing homedir non-fatal, instead use / Fixes github #146
author Matt Johnston <matt@ucc.asn.au>
date Thu, 24 Feb 2022 11:51:51 +0800
parents 2b3a8026a6ce
children 2839daa507b3
line wrap: on
line diff
--- a/svr-chansession.c	Thu Feb 03 22:13:06 2022 +0800
+++ b/svr-chansession.c	Thu Feb 24 11:51:51 2022 +0800
@@ -1033,9 +1033,14 @@
 
 	/* change directory */
 	if (chdir(ses.authstate.pw_dir) < 0) {
-		dropbear_exit("Error changing directory");
+		int e = errno;
+		if (chdir("/") < 0) {
+			dropbear_exit("chdir(\"/\") failed");
+		}
+		fprintf(stderr, "Failed chdir '%s': %s\n", ses.authstate.pw_dir, strerror(e));
 	}
 
+
 #if DROPBEAR_X11FWD
 	/* set up X11 forwarding if enabled */
 	x11setauth(chansess);