-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite3_dbname.patch
More file actions
47 lines (44 loc) · 1.93 KB
/
sqlite3_dbname.patch
File metadata and controls
47 lines (44 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- zabbix-5.4.3/conf/zabbix_proxy.conf~ 2021-08-24 12:51:15.000000000 +0300
+++ zabbix-5.4.3/conf/zabbix_proxy.conf 2021-08-24 12:52:01.573388850 +0300
@@ -160,6 +160,7 @@
### Option: DBName
# Database name.
# For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
+# If provided name does not contain '/' or ':' (no a path or special type) a .db file in /var/lib/zabbix will be used.
# If the Net Service Name connection method is used to connect to Oracle database, specify the service name from
# the tnsnames.ora file or set to empty string; also see the TWO_TASK environment variable if DBName is set to
# empty string.
--- zabbix-7.0.3/src/libs/zbxdb/db.c.orig 2024-08-22 14:35:46.382451647 +0200
+++ zabbix-7.0.3/src/libs/zbxdb/db.c 2024-08-22 15:08:36.432915877 +0200
@@ -437,6 +437,7 @@ int zbx_db_connect_basic(const zbx_confi
unsigned int i = 0;
#elif defined(HAVE_SQLITE3)
char *p, *path = NULL;
+ char *dbpath = NULL;
#endif
/* Allow executing statements during a connection initialization. Make sure to mark transaction as failed. */
@@ -851,11 +852,16 @@ int zbx_db_connect_basic(const zbx_confi
out:
#elif defined(HAVE_SQLITE3)
+ if (!strchr(cfg->config_dbname, '/') && !strchr(cfg->config_dbname, ':')) {
+ dbpath = zbx_dsprintf(NULL, "/var/lib/zabbix/%s.db", cfg->config_dbname);
+ } else {
+ dbpath = strdup(cfg->config_dbname);
+ }
#ifdef HAVE_FUNCTION_SQLITE3_OPEN_V2
- if (SQLITE_OK != sqlite3_open_v2(cfg->config_dbname, &conn, SQLITE_OPEN_READWRITE |
+ if (SQLITE_OK != sqlite3_open_v2(dbpath, &conn, SQLITE_OPEN_READWRITE |
SQLITE_OPEN_CREATE, NULL))
#else
- if (SQLITE_OK != sqlite3_open(cfg->config_dbname, &conn))
+ if (SQLITE_OK != sqlite3_open(dbpath, &conn))
#endif
{
zbx_db_errlog(ERR_Z3001, 0, sqlite3_errmsg(conn), cfg->config_dbname);
@@ -895,6 +901,7 @@ out:
zbx_free(path);
out:
+ free(dbpath);
#endif /* HAVE_SQLITE3 */
if (ZBX_DB_OK != ret)
zbx_db_close_basic();