[MDEV-28309] main.mysqld--defaults-file fails on FreeBSD when built from ports Created: 2022-04-13  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Platform FreeBSD, Tests
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: not-10.5, not-10.6


 Description   

10.3 e4835bf5

main.mysqld--defaults-file               w3 [ fail ]
        Test ended at 2022-04-13 07:29:26
 
CURRENT_TEST: main.mysqld--defaults-file
mysqltest: At line 11: command "$MYSQLD --defaults-file=/path/with/no/extension --print-defaults 2>&1" succeeded - should have failed with errno 1...

There is a patch in ports which causes it:

files/patch-mysys_my__default.c

--- mysys/my_default.c.orig	2017-05-14 23:13:17 UTC
+++ mysys/my_default.c
@@ -785,7 +785,7 @@ static int search_default_file_with_ext(
   {
     MY_STAT stat_info;
     if (!my_stat(name,&stat_info,MYF(0)))
-      return 1;
+      return 0;
     /*
       Ignore world-writable regular files.
       This is mainly done to protect us to not read a file created by
@@ -803,6 +803,14 @@ static int search_default_file_with_ext(
   if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
     return 1;					/* Ignore wrong files */
 
+  if (strstr(name, "/etc") == name)
+  {
+    fprintf(stderr,
+             "error: Config file %s in invalid location, please move to or merge with %%PREFIX%%%s\n",
+             name,name);
+      goto err;
+  }
+
   while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
   {
     line++;
@@ -1067,7 +1075,8 @@ void my_print_default_files(const char *
           if (name[0] == FN_HOMELIB)	/* Add . to filenames in home */
             *end++= '.';
           strxmov(end, conf_file, *ext, " ", NullS);
-          fputs(name, stdout);
+          if (strstr(name, "/etc") != name)
+            fputs(name, stdout);
         }
       }
     }
@@ -1192,13 +1201,10 @@ static const char **init_default_directo
 
 #else
 
-#if defined(DEFAULT_SYSCONFDIR)
-  if (DEFAULT_SYSCONFDIR[0])
-    errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
-#else
   errors += add_directory(alloc, "/etc/", dirs);
   errors += add_directory(alloc, "/etc/mysql/", dirs);
-#endif /* DEFAULT_SYSCONFDIR */
+  errors += add_directory(alloc, "%%PREFIX%%/etc/", dirs);
+  errors += add_directory(alloc, "%%PREFIX%%/etc/mysql/", dirs);
 
 #endif
 


Generated at Thu Feb 08 09:59:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.