]> TLD Linux GIT Repositories - packages/zabbix.git/blob - sqlite3_dbname.patch
f6dcd6b52c925091074bc6647adad8953584fa42
[packages/zabbix.git] / sqlite3_dbname.patch
1 diff -ur zabbix-5.4.3.orig/conf/zabbix_proxy.conf zabbix-5.4.3/conf/zabbix_proxy.conf
2 --- zabbix-5.4.3.orig/conf/zabbix_proxy.conf    2021-07-26 15:14:02.107383385 +0200
3 +++ zabbix-5.4.3/conf/zabbix_proxy.conf 2021-07-26 15:18:42.151383385 +0200
4 @@ -160,6 +160,7 @@
5  ### Option: DBName
6  #      Database name.
7  #      For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
8 +#      If provided name does not contain '/' or ':' (no a path or special type) a .db file in /var/lib/zabbix will be used.
9  #      If the Net Service Name connection method is used to connect to Oracle database, specify the service name from
10  #      the tnsnames.ora file or set to empty string; also see the TWO_TASK environment variable if DBName is set to
11  #      empty string.
12 diff -ur zabbix-5.4.3.orig/src/libs/zbxdb/db.c zabbix-5.4.3/src/libs/zbxdb/db.c
13 --- zabbix-5.4.3.orig/src/libs/zbxdb/db.c       2021-07-19 16:04:10.000000000 +0200
14 +++ zabbix-5.4.3/src/libs/zbxdb/db.c    2021-07-26 15:17:02.917383385 +0200
15 @@ -388,6 +388,7 @@
16         unsigned int    i = 0;
17  #elif defined(HAVE_SQLITE3)
18         char            *p, *path = NULL;
19 +       char            dbname_buf[1024];
20  #endif
21  
22  #ifndef HAVE_MYSQL
23 @@ -836,6 +837,10 @@
24         ZBX_UNUSED(ca);
25         ZBX_UNUSED(cipher);
26         ZBX_UNUSED(cipher_13);
27 +       if (!strchr(dbname, '/') && !strchr(dbname, ':')) {
28 +               zbx_snprintf(dbname_buf, sizeof(dbname_buf), "/var/lib/zabbix/%s.db", dbname);
29 +               dbname = dbname_buf;
30 +       }
31  #ifdef HAVE_FUNCTION_SQLITE3_OPEN_V2
32         if (SQLITE_OK != sqlite3_open_v2(dbname, &conn, SQLITE_OPEN_READWRITE, NULL))
33  #else