From e1a6f58da6c9b14132f2a92a6e60f67e11474c83 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 10 Jan 2019 20:29:04 +0100
Subject: [PATCH] startup: check that a backup directory is valid also when
 backups are off

When the user switches backups on later (with M-B in the ^O menu),
the specified folder should have been checked for validity.

This fixes https://savannah.gnu.org/bugs/?55423.

Bug existed since the check for a valid backup directory was introduced
in version 2.8.7, commit 751e7f0f.
---
 src/nano.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index a1072b2e..ec0bb038 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2449,9 +2449,9 @@ int main(int argc, char **argv)
 #endif /* ENABLE_HISTORIES */
 
 #ifndef NANO_TINY
-	/* If backups are enabled and a backup directory was specified, make sure
-	 * the path exists and is a folder, so backup files can be saved there. */
-	if (ISSET(BACKUP_FILE) && backup_dir != NULL)
+	/* If a backup directory was specified and we're not in restricted mode,
+	 * verify it is an existing folder, so backup files can be saved there. */
+	if (backup_dir != NULL && !ISSET(RESTRICTED))
 		init_backup_dir();
 #endif
 #ifdef ENABLE_OPERATINGDIR
-- 
GitLab