1 /*
2 ** Zabbix
3 ** Copyright (C) 2001-2021 Zabbix SIA
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 **/
19 
20 #include "common.h"
21 #include "db.h"
22 #include "zbxdbupgrade.h"
23 #include "dbupgrade.h"
24 #include "sysinfo.h"
25 #include "log.h"
26 
27 /*
28  * 3.0 development database patches
29  */
30 
31 #ifndef HAVE_SQLITE3
32 
DBpatch_2050000(void)33 static int	DBpatch_2050000(void)
34 {
35 	const ZBX_FIELD	field = {"agent", "Zabbix", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
36 
37 	return DBset_default("httptest", &field);
38 }
39 
DBpatch_2050001(void)40 static int	DBpatch_2050001(void)
41 {
42 	DB_RESULT	result;
43 	DB_ROW		row;
44 	char		*oid = NULL;
45 	size_t		oid_alloc = 0;
46 	int		ret = FAIL, rc;
47 
48 	/* flags - ZBX_FLAG_DISCOVERY_RULE                               */
49 	/* type  - ITEM_TYPE_SNMPv1, ITEM_TYPE_SNMPv2c, ITEM_TYPE_SNMPv3 */
50 	if (NULL == (result = DBselect("select itemid,snmp_oid from items where flags=1 and type in (1,4,6)")))
51 		return FAIL;
52 
53 	while (NULL != (row = DBfetch(result)))
54 	{
55 		char	*param, *oid_esc;
56 		size_t	oid_offset = 0;
57 
58 		param = zbx_strdup(NULL, row[1]);
59 		zbx_snprintf_alloc(&oid, &oid_alloc, &oid_offset, "discovery[{#SNMPVALUE},%s]", param);
60 
61 		if (FAIL == quote_key_param(&param, 0))
62 		{
63 			zabbix_log(LOG_LEVEL_WARNING, "cannot convert SNMP discovery OID \"%s\":"
64 					" OID contains invalid character(s)", row[1]);
65 			rc = ZBX_DB_OK;
66 		}
67 		else if (255 < oid_offset && 255 < zbx_strlen_utf8(oid)) /* 255 - ITEM_SNMP_OID_LEN */
68 		{
69 			zabbix_log(LOG_LEVEL_WARNING, "cannot convert SNMP discovery OID \"%s\":"
70 					" resulting OID is too long", row[1]);
71 			rc = ZBX_DB_OK;
72 		}
73 		else
74 		{
75 			oid_esc = DBdyn_escape_string(oid);
76 
77 			rc = DBexecute("update items set snmp_oid='%s' where itemid=%s", oid_esc, row[0]);
78 
79 			zbx_free(oid_esc);
80 		}
81 
82 		zbx_free(param);
83 
84 		if (ZBX_DB_OK > rc)
85 			goto out;
86 	}
87 
88 	ret = SUCCEED;
89 out:
90 	DBfree_result(result);
91 	zbx_free(oid);
92 
93 	return ret;
94 }
95 
DBpatch_2050002(void)96 static int	DBpatch_2050002(void)
97 {
98 	const ZBX_FIELD	field = {"lastlogsize", "0", NULL, NULL, 0, ZBX_TYPE_UINT, ZBX_NOTNULL, 0};
99 
100 	return DBadd_field("proxy_history", &field);
101 }
102 
DBpatch_2050003(void)103 static int	DBpatch_2050003(void)
104 {
105 	const ZBX_FIELD	field = {"mtime", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
106 
107 	return DBadd_field("proxy_history", &field);
108 }
109 
DBpatch_2050004(void)110 static int	DBpatch_2050004(void)
111 {
112 	const ZBX_FIELD	field = {"meta", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
113 
114 	return DBadd_field("proxy_history", &field);
115 }
116 
DBpatch_2050005(void)117 static int	DBpatch_2050005(void)
118 {
119 	return DBdrop_index("triggers", "triggers_2");
120 }
121 
DBpatch_2050006(void)122 static int	DBpatch_2050006(void)
123 {
124 	return DBcreate_index("triggers", "triggers_2", "value,lastchange", 0);
125 }
126 
DBpatch_2050007(void)127 static int	DBpatch_2050007(void)
128 {
129 	const ZBX_FIELD	field = {"error", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
130 
131 	return DBmodify_field_type("hosts", &field);
132 }
133 
DBpatch_2050008(void)134 static int	DBpatch_2050008(void)
135 {
136 	const ZBX_FIELD	field = {"ipmi_error", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
137 
138 	return DBmodify_field_type("hosts", &field);
139 }
140 
DBpatch_2050009(void)141 static int	DBpatch_2050009(void)
142 {
143 	const ZBX_FIELD	field = {"snmp_error", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
144 
145 	return DBmodify_field_type("hosts", &field);
146 }
147 
DBpatch_2050010(void)148 static int	DBpatch_2050010(void)
149 {
150 	const ZBX_FIELD	field = {"jmx_error", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
151 
152 	return DBmodify_field_type("hosts", &field);
153 }
154 
DBpatch_2050011(void)155 static int	DBpatch_2050011(void)
156 {
157 	/* 1 - ITEM_VALUE_TYPE_STR, 2 - ITEM_VALUE_TYPE_LOG, 4 - ITEM_VALUE_TYPE_TEXT */
158 	if (ZBX_DB_OK <= DBexecute("update items set trends=0 where value_type in (1,2,4)"))
159 		return SUCCEED;
160 
161 	return FAIL;
162 }
163 
DBpatch_2050012(void)164 static int	DBpatch_2050012(void)
165 {
166 	DB_RESULT	result;
167 	DB_RESULT	result2;
168 	DB_ROW		row;
169 	char		*key = NULL, *key_esc, *param;
170 	int		ret = SUCCEED;
171 	AGENT_REQUEST	request;
172 
173 	/* type - ITEM_TYPE_ZABBIX, ITEM_TYPE_SIMPLE, ITEM_TYPE_ZABBIX_ACTIVE */
174 	result = DBselect(
175 			"select hostid,itemid,key_"
176 			" from items"
177 			" where type in (0,3,7)"
178 				" and key_ like 'net.tcp.service%%[%%ntp%%'");
179 
180 	while (SUCCEED == ret && NULL != (row = DBfetch(result)))
181 	{
182 		init_request(&request);
183 
184 		if (SUCCEED != parse_item_key(row[2], &request))
185 		{
186 			zabbix_log(LOG_LEVEL_WARNING, "cannot parse item key \"%s\"", row[2]);
187 			continue;
188 		}
189 
190 		param = get_rparam(&request, 0);
191 
192 		if (0 != strcmp("service.ntp", param) && 0 != strcmp("ntp", param))
193 		{
194 			free_request(&request);
195 			continue;
196 		}
197 
198 		key = zbx_strdup(key, row[2]);
199 
200 		if (0 == strcmp("service.ntp", param))
201 		{
202 			/* replace "service.ntp" with "ntp" */
203 
204 			char	*p;
205 
206 			p = strstr(key, "service.ntp");
207 
208 			do
209 			{
210 				*p = *(p + 8);
211 			}
212 			while ('\0' != *(p++));
213 		}
214 
215 		free_request(&request);
216 
217 		/* replace "net.tcp.service" with "net.udp.service" */
218 
219 		key[4] = 'u';
220 		key[5] = 'd';
221 		key[6] = 'p';
222 
223 		key_esc = DBdyn_escape_string(key);
224 
225 		result2 = DBselect("select null from items where hostid=%s and key_='%s'", row[0], key_esc);
226 
227 		if (NULL == DBfetch(result2))
228 		{
229 			if (ZBX_DB_OK > DBexecute("update items set key_='%s' where itemid=%s", key_esc, row[1]))
230 				ret = FAIL;
231 		}
232 		else
233 		{
234 			zabbix_log(LOG_LEVEL_WARNING, "cannot convert item key \"%s\":"
235 					" item with converted key \"%s\" already exists on host ID [%s]",
236 					row[2], key, row[0]);
237 		}
238 		DBfree_result(result2);
239 
240 		zbx_free(key_esc);
241 	}
242 	DBfree_result(result);
243 
244 	zbx_free(key);
245 
246 	return ret;
247 }
248 
DBpatch_2050013(void)249 static int	DBpatch_2050013(void)
250 {
251 	return DBdrop_table("user_history");
252 }
253 
DBpatch_2050014(void)254 static int      DBpatch_2050014(void)
255 {
256 	if (ZBX_DB_OK <= DBexecute(
257 		"update config"
258 		" set default_theme="
259 			"case when default_theme in ('classic', 'originalblue')"
260 			" then 'blue-theme'"
261 			" else 'dark-theme' end"))
262 	{
263 		return SUCCEED;
264 	}
265 
266 	return FAIL;
267 }
268 
DBpatch_2050015(void)269 static int      DBpatch_2050015(void)
270 {
271 	if (ZBX_DB_OK <= DBexecute(
272 		"update users"
273 		" set theme=case when theme in ('classic', 'originalblue') then 'blue-theme' else 'dark-theme' end"
274 		" where theme<>'default'"))
275 	{
276 		return SUCCEED;
277 	}
278 
279 	return FAIL;
280 }
281 
DBpatch_2050019(void)282 static int	DBpatch_2050019(void)
283 {
284 	const ZBX_FIELD	field = {"smtp_port", "25", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
285 
286 	return DBadd_field("media_type", &field);
287 }
288 
DBpatch_2050020(void)289 static int	DBpatch_2050020(void)
290 {
291 	const ZBX_FIELD	field = {"smtp_security", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
292 
293 	return DBadd_field("media_type", &field);
294 }
295 
DBpatch_2050021(void)296 static int	DBpatch_2050021(void)
297 {
298 	const ZBX_FIELD	field = {"smtp_verify_peer", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
299 
300 	return DBadd_field("media_type", &field);
301 }
302 
DBpatch_2050022(void)303 static int	DBpatch_2050022(void)
304 {
305 	const ZBX_FIELD	field = {"smtp_verify_host", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
306 
307 	return DBadd_field("media_type", &field);
308 }
309 
DBpatch_2050023(void)310 static int	DBpatch_2050023(void)
311 {
312 	const ZBX_FIELD	field = {"smtp_authentication", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
313 
314 	return DBadd_field("media_type", &field);
315 }
316 
DBpatch_2050029(void)317 static int	DBpatch_2050029(void)
318 {
319 	const ZBX_FIELD	field = {"default_theme", "blue-theme", NULL, NULL, 128, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
320 
321 	return DBset_default("config", &field);
322 }
323 
DBpatch_2050030(void)324 static int	DBpatch_2050030(void)
325 {
326 	const ZBX_TABLE table =
327 			{"application_prototype", "application_prototypeid", 0,
328 				{
329 					{"application_prototypeid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
330 					{"itemid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
331 					{"templateid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, 0, 0},
332 					{"name", "", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
333 					{0}
334 				},
335 				NULL
336 			};
337 
338 	return DBcreate_table(&table);
339 }
340 
DBpatch_2050031(void)341 static int	DBpatch_2050031(void)
342 {
343 	return DBcreate_index("application_prototype", "application_prototype_1", "itemid", 0);
344 }
345 
DBpatch_2050032(void)346 static int	DBpatch_2050032(void)
347 {
348 	return DBcreate_index("application_prototype", "application_prototype_2", "templateid", 0);
349 }
350 
DBpatch_2050033(void)351 static int	DBpatch_2050033(void)
352 {
353 	const ZBX_FIELD	field = {"itemid", NULL, "items", "itemid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
354 
355 	return DBadd_foreign_key("application_prototype", 1, &field);
356 }
357 
DBpatch_2050034(void)358 static int	DBpatch_2050034(void)
359 {
360 	const ZBX_FIELD	field = {"templateid", NULL, "application_prototype", "application_prototypeid",
361 			0, 0, 0, ZBX_FK_CASCADE_DELETE};
362 
363 	return DBadd_foreign_key("application_prototype", 2, &field);
364 }
365 
DBpatch_2050035(void)366 static int	DBpatch_2050035(void)
367 {
368 	const ZBX_TABLE table =
369 			{"item_application_prototype", "item_application_prototypeid", 0,
370 				{
371 					{"item_application_prototypeid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL,
372 							0},
373 					{"application_prototypeid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
374 					{"itemid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
375 					{0}
376 				},
377 				NULL
378 			};
379 
380 	return DBcreate_table(&table);
381 }
382 
DBpatch_2050036(void)383 static int	DBpatch_2050036(void)
384 {
385 	return DBcreate_index("item_application_prototype", "item_application_prototype_1",
386 			"application_prototypeid,itemid", 1);
387 }
388 
DBpatch_2050037(void)389 static int	DBpatch_2050037(void)
390 {
391 	return DBcreate_index("item_application_prototype", "item_application_prototype_2", "itemid", 0);
392 }
393 
DBpatch_2050038(void)394 static int	DBpatch_2050038(void)
395 {
396 	const ZBX_FIELD	field = {"application_prototypeid", NULL, "application_prototype", "application_prototypeid",
397 			0, 0, 0, ZBX_FK_CASCADE_DELETE};
398 
399 	return DBadd_foreign_key("item_application_prototype", 1, &field);
400 }
401 
DBpatch_2050039(void)402 static int	DBpatch_2050039(void)
403 {
404 	const ZBX_FIELD	field = {"itemid", NULL, "items", "itemid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
405 
406 	return DBadd_foreign_key("item_application_prototype", 2, &field);
407 }
408 
DBpatch_2050040(void)409 static int	DBpatch_2050040(void)
410 {
411 	const ZBX_TABLE table =
412 			{"application_discovery", "application_discoveryid", 0,
413 				{
414 					{"application_discoveryid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
415 					{"applicationid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
416 					{"application_prototypeid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
417 					{"name", "", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
418 					{"lastcheck", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
419 					{"ts_delete", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
420 					{0}
421 				},
422 				NULL
423 			};
424 
425 	return DBcreate_table(&table);
426 }
427 
DBpatch_2050041(void)428 static int	DBpatch_2050041(void)
429 {
430 	return DBcreate_index("application_discovery", "application_discovery_1", "applicationid", 0);
431 }
432 
DBpatch_2050042(void)433 static int	DBpatch_2050042(void)
434 {
435 	return DBcreate_index("application_discovery", "application_discovery_2", "application_prototypeid", 0);
436 }
437 
DBpatch_2050043(void)438 static int	DBpatch_2050043(void)
439 {
440 	const ZBX_FIELD	field = {"applicationid", NULL, "applications", "applicationid", 0, 0, 0,
441 			ZBX_FK_CASCADE_DELETE};
442 
443 	return DBadd_foreign_key("application_discovery", 1, &field);
444 }
445 
DBpatch_2050044(void)446 static int	DBpatch_2050044(void)
447 {
448 	const ZBX_FIELD	field = {"application_prototypeid", NULL, "application_prototype", "application_prototypeid",
449 			0, 0, 0, ZBX_FK_CASCADE_DELETE};
450 
451 	return DBadd_foreign_key("application_discovery", 2, &field);
452 }
453 
DBpatch_2050045(void)454 static int	DBpatch_2050045(void)
455 {
456 	const ZBX_FIELD field = {"flags", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
457 
458 	return DBadd_field("applications", &field);
459 }
460 
DBpatch_2050051(void)461 static int	DBpatch_2050051(void)
462 {
463 	const ZBX_FIELD	field = {"iprange", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
464 
465 	return DBmodify_field_type("drules", &field);
466 }
467 
DBpatch_2050052(void)468 static int	DBpatch_2050052(void)
469 {
470 	const ZBX_FIELD field = {"default_inventory_mode", "-1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
471 
472 	return DBadd_field("config", &field);
473 }
474 
DBpatch_2050053(void)475 static int	DBpatch_2050053(void)
476 {
477 	const ZBX_TABLE table =
478 			{"opinventory", "operationid", 0,
479 				{
480 					{"operationid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
481 					{"inventory_mode", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
482 					{0}
483 				},
484 				NULL
485 			};
486 
487 	return DBcreate_table(&table);
488 }
489 
DBpatch_2050054(void)490 static int	DBpatch_2050054(void)
491 {
492 	const ZBX_FIELD	field = {"operationid", NULL, "operations", "operationid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
493 
494 	return DBadd_foreign_key("opinventory", 1, &field);
495 }
496 
DBpatch_2050055(void)497 static int	DBpatch_2050055(void)
498 {
499 	DB_RESULT	result;
500 	DB_ROW		row;
501 	int		ret = FAIL;
502 
503 	if (NULL == (result = DBselect(
504 			"select severity_color_0,severity_color_1,severity_color_2,severity_color_3,severity_color_4,"
505 				"severity_color_5"
506 			" from config")))
507 	{
508 		return FAIL;
509 	}
510 
511 	if (NULL != (row = DBfetch(result)) &&
512 			0 == strcmp(row[0], "DBDBDB") && 0 == strcmp(row[1], "D6F6FF") &&
513 			0 == strcmp(row[2], "FFF6A5") && 0 == strcmp(row[3], "FFB689") &&
514 			0 == strcmp(row[4], "FF9999") && 0 == strcmp(row[5], "FF3838"))
515 	{
516 		if (ZBX_DB_OK > DBexecute(
517 				"update config set severity_color_0='97AAB3',severity_color_1='7499FF',"
518 					"severity_color_2='FFC859',severity_color_3='FFA059',"
519 					"severity_color_4='E97659',severity_color_5='E45959'"))
520 		{
521 			goto out;
522 		}
523 	}
524 
525 	ret = SUCCEED;
526 out:
527 	DBfree_result(result);
528 
529 	return ret;
530 }
531 
DBpatch_2050056(void)532 static int	DBpatch_2050056(void)
533 {
534 	const ZBX_FIELD field = {"severity_color_0", "97AAB3", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
535 
536 	return DBset_default("config", &field);
537 }
538 
DBpatch_2050057(void)539 static int	DBpatch_2050057(void)
540 {
541 	const ZBX_FIELD field = {"severity_color_1", "7499FF", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
542 
543 	return DBset_default("config", &field);
544 }
545 
DBpatch_2050058(void)546 static int	DBpatch_2050058(void)
547 {
548 	const ZBX_FIELD field = {"severity_color_2", "FFC859", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
549 
550 	return DBset_default("config", &field);
551 }
552 
DBpatch_2050059(void)553 static int	DBpatch_2050059(void)
554 {
555 	const ZBX_FIELD field = {"severity_color_3", "FFA059", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
556 
557 	return DBset_default("config", &field);
558 }
559 
DBpatch_2050060(void)560 static int	DBpatch_2050060(void)
561 {
562 	const ZBX_FIELD field = {"severity_color_4", "E97659", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
563 
564 	return DBset_default("config", &field);
565 }
566 
DBpatch_2050061(void)567 static int	DBpatch_2050061(void)
568 {
569 	const ZBX_FIELD field = {"severity_color_5", "E45959", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
570 
571 	return DBset_default("config", &field);
572 }
573 
DBpatch_2050062(void)574 static int	DBpatch_2050062(void)
575 {
576 	const ZBX_FIELD field = {"exec_params", "", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
577 
578 	return DBadd_field("media_type", &field);
579 }
580 
DBpatch_2050063(void)581 static int	DBpatch_2050063(void)
582 {
583 	/* type=1 -> type=MEDIA_TYPE_EXEC */
584 	if (ZBX_DB_OK > DBexecute("update media_type"
585 			" set exec_params='{ALERT.SENDTO}\n{ALERT.SUBJECT}\n{ALERT.MESSAGE}\n'"
586 			" where type=1"))
587 	{
588 		return FAIL;
589 	}
590 
591 	return SUCCEED;
592 }
593 
DBpatch_2050064(void)594 static int	DBpatch_2050064(void)
595 {
596 	const ZBX_FIELD field = {"tls_connect", "1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
597 
598 	return DBadd_field("hosts", &field);
599 }
600 
DBpatch_2050065(void)601 static int	DBpatch_2050065(void)
602 {
603 	const ZBX_FIELD field = {"tls_accept", "1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
604 
605 	return DBadd_field("hosts", &field);
606 }
607 
DBpatch_2050066(void)608 static int	DBpatch_2050066(void)
609 {
610 	const ZBX_FIELD field = {"tls_issuer", "", NULL, NULL, 1024, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
611 
612 	return DBadd_field("hosts", &field);
613 }
614 
DBpatch_2050067(void)615 static int	DBpatch_2050067(void)
616 {
617 	const ZBX_FIELD field = {"tls_subject", "", NULL, NULL, 1024, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
618 
619 	return DBadd_field("hosts", &field);
620 }
621 
DBpatch_2050068(void)622 static int	DBpatch_2050068(void)
623 {
624 	const ZBX_FIELD field = {"tls_psk_identity", "", NULL, NULL, 128, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
625 
626 	return DBadd_field("hosts", &field);
627 }
628 
DBpatch_2050069(void)629 static int	DBpatch_2050069(void)
630 {
631 	const ZBX_FIELD field = {"tls_psk", "", NULL, NULL, 512, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
632 
633 	return DBadd_field("hosts", &field);
634 }
635 
DBpatch_2050070(void)636 static int	DBpatch_2050070(void)
637 {
638 	const ZBX_FIELD	field = {"macro", "", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
639 
640 	return DBmodify_field_type("globalmacro", &field);
641 }
642 
DBpatch_2050071(void)643 static int	DBpatch_2050071(void)
644 {
645 	const ZBX_FIELD	field = {"macro", "", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
646 
647 	return DBmodify_field_type("hostmacro", &field);
648 }
649 
DBpatch_2050072(void)650 static int	DBpatch_2050072(void)
651 {
652 	return DBdrop_table("graph_theme");
653 }
654 
DBpatch_2050073(void)655 static int	DBpatch_2050073(void)
656 {
657 	const ZBX_TABLE table =
658 		{"graph_theme",	"graphthemeid",	0,
659 			{
660 				{"graphthemeid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
661 				{"theme", "", NULL, NULL, 64, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
662 				{"backgroundcolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
663 				{"graphcolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
664 				{"gridcolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
665 				{"maingridcolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
666 				{"gridbordercolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
667 				{"textcolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
668 				{"highlightcolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
669 				{"leftpercentilecolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
670 				{"rightpercentilecolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
671 				{"nonworktimecolor", "", NULL, NULL, 6, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0},
672 				{0}
673 			},
674 			NULL
675 		};
676 
677 	return DBcreate_table(&table);
678 }
679 
DBpatch_2050074(void)680 static int	DBpatch_2050074(void)
681 {
682 	return DBcreate_index("graph_theme", "graph_theme_1", "theme", 1);
683 }
684 
DBpatch_2050075(void)685 static int	DBpatch_2050075(void)
686 {
687 	if (ZBX_DB_OK <= DBexecute(
688 			"insert into graph_theme"
689 			" values (1,'blue-theme','FFFFFF','FFFFFF','CCD5D9','ACBBC2','ACBBC2','1F2C33','E33734',"
690 				"'429E47','E33734','EBEBEB')"))
691 	{
692 		return SUCCEED;
693 	}
694 
695 	return FAIL;
696 }
697 
DBpatch_2050076(void)698 static int	DBpatch_2050076(void)
699 {
700 	if (ZBX_DB_OK <= DBexecute(
701 			"insert into graph_theme"
702 			" values (2,'dark-theme','2B2B2B','2B2B2B','454545','4F4F4F','4F4F4F','F2F2F2','E45959',"
703 				"'59DB8F','E45959','333333')"))
704 	{
705 		return SUCCEED;
706 	}
707 
708 	return FAIL;
709 }
710 
DBpatch_2050077(void)711 static int	DBpatch_2050077(void)
712 {
713 	const ZBX_FIELD field = {"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, 0, 0};
714 
715 	return DBadd_field("sysmaps", &field);
716 }
717 
DBpatch_2050078(void)718 static int	DBpatch_2050078(void)
719 {
720 	/* type=3 -> type=USER_TYPE_SUPER_ADMIN */
721 	if (ZBX_DB_OK > DBexecute("update sysmaps set userid=(select min(userid) from users where type=3)"))
722 		return FAIL;
723 
724 	return SUCCEED;
725 }
726 
DBpatch_2050079(void)727 static int	DBpatch_2050079(void)
728 {
729 	const ZBX_FIELD	field = {"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0};
730 
731 	return DBset_not_null("sysmaps", &field);
732 }
733 
DBpatch_2050080(void)734 static int	DBpatch_2050080(void)
735 {
736 	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, 0};
737 
738 	return DBadd_foreign_key("sysmaps", 3, &field);
739 }
740 
DBpatch_2050081(void)741 static int	DBpatch_2050081(void)
742 {
743 	const ZBX_FIELD field = {"private", "1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
744 
745 	return DBadd_field("sysmaps", &field);
746 }
747 
DBpatch_2050082(void)748 static int	DBpatch_2050082(void)
749 {
750 	const ZBX_TABLE table =
751 		{"sysmap_user",	"sysmapuserid",	0,
752 			{
753 				{"sysmapuserid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
754 				{"sysmapid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
755 				{"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
756 				{"permission", "2", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
757 				{0}
758 			},
759 			NULL
760 		};
761 
762 	return DBcreate_table(&table);
763 }
764 
DBpatch_2050083(void)765 static int	DBpatch_2050083(void)
766 {
767 	return DBcreate_index("sysmap_user", "sysmap_user_1", "sysmapid,userid", 1);
768 }
769 
DBpatch_2050084(void)770 static int	DBpatch_2050084(void)
771 {
772 	const ZBX_FIELD	field = {"sysmapid", NULL, "sysmaps", "sysmapid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
773 
774 	return DBadd_foreign_key("sysmap_user", 1, &field);
775 }
776 
DBpatch_2050085(void)777 static int	DBpatch_2050085(void)
778 {
779 	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
780 
781 	return DBadd_foreign_key("sysmap_user", 2, &field);
782 }
783 
DBpatch_2050086(void)784 static int	DBpatch_2050086(void)
785 {
786 	const ZBX_TABLE table =
787 		{"sysmap_usrgrp", "sysmapusrgrpid", 0,
788 			{
789 				{"sysmapusrgrpid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
790 				{"sysmapid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
791 				{"usrgrpid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
792 				{"permission", "2", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
793 				{0}
794 			},
795 			NULL
796 		};
797 
798 	return DBcreate_table(&table);
799 }
800 
DBpatch_2050087(void)801 static int	DBpatch_2050087(void)
802 {
803 	return DBcreate_index("sysmap_usrgrp", "sysmap_usrgrp_1", "sysmapid,usrgrpid", 1);
804 }
805 
DBpatch_2050088(void)806 static int	DBpatch_2050088(void)
807 {
808 	const ZBX_FIELD	field = {"sysmapid", NULL, "sysmaps", "sysmapid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
809 
810 	return DBadd_foreign_key("sysmap_usrgrp", 1, &field);
811 }
812 
DBpatch_2050089(void)813 static int	DBpatch_2050089(void)
814 {
815 	const ZBX_FIELD	field = {"usrgrpid", NULL, "usrgrp", "usrgrpid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
816 
817 	return DBadd_foreign_key("sysmap_usrgrp", 2, &field);
818 }
819 
DBpatch_2050090(void)820 static int	DBpatch_2050090(void)
821 {
822 	if (ZBX_DB_OK > DBexecute("update profiles"
823 			" set idx='web.triggers.filter_status',value_int=case when value_int=0 then 0 else -1 end"
824 			" where idx='web.triggers.showdisabled'"))
825 	{
826 		return FAIL;
827 	}
828 
829 	return SUCCEED;
830 }
831 
DBpatch_2050091(void)832 static int	DBpatch_2050091(void)
833 {
834 	if (ZBX_DB_OK > DBexecute("update profiles"
835 			" set idx='web.httpconf.filter_status',value_int=case when value_int=0 then 0 else -1 end"
836 			" where idx='web.httpconf.showdisabled'"))
837 	{
838 		return FAIL;
839 	}
840 
841 	return SUCCEED;
842 }
843 
DBpatch_2050092(void)844 static int	DBpatch_2050092(void)
845 {
846 	DB_RESULT	result;
847 	DB_ROW		row;
848 	const char	*end, *start;
849 	int		len, ret = FAIL, rc;
850 	char		*url = NULL, *url_esc;
851 	size_t		i, url_alloc = 0, url_offset;
852 	char		*url_map[] = {
853 				"dashboard.php", "dashboard.view",
854 				"discovery.php", "discovery.view",
855 				"maps.php", "map.view",
856 				"httpmon.php", "web.view",
857 				"media_types.php", "mediatype.list",
858 				"proxies.php", "proxy.list",
859 				"scripts.php", "script.list",
860 				"report3.php", "report.services",
861 				"report1.php", "report.status"
862 			};
863 
864 	if (NULL == (result = DBselect("select userid,url from users where url<>''")))
865 		return FAIL;
866 
867 	while (NULL != (row = (DBfetch(result))))
868 	{
869 		if (NULL == (end = strchr(row[1], '?')))
870 			end = row[1] + strlen(row[1]);
871 
872 		for (start = end - 1; start > row[1] && '/' != start[-1]; start--)
873 			;
874 
875 		len = end - start;
876 
877 		for (i = 0; ARRSIZE(url_map) > i; i += 2)
878 		{
879 			if (0 == strncmp(start, url_map[i], len))
880 				break;
881 		}
882 
883 		if (ARRSIZE(url_map) == i)
884 			continue;
885 
886 		url_offset = 0;
887 		zbx_strncpy_alloc(&url, &url_alloc, &url_offset, row[1], start - row[1]);
888 		zbx_strcpy_alloc(&url, &url_alloc, &url_offset, "zabbix.php?action=");
889 		zbx_strcpy_alloc(&url, &url_alloc, &url_offset, url_map[i + 1]);
890 
891 		if ('\0' != *end)
892 		{
893 			zbx_chrcpy_alloc(&url, &url_alloc, &url_offset, '&');
894 			zbx_strcpy_alloc(&url, &url_alloc, &url_offset, end + 1);
895 		}
896 
897 		/* 255 - user url field size */
898 		if (url_offset > 255)
899 		{
900 			*url = '\0';
901 			zabbix_log(LOG_LEVEL_WARNING, "Cannot convert URL for user id \"%s\":"
902 					" value is too long. The URL field was reset.", row[0]);
903 		}
904 
905 		url_esc = DBdyn_escape_string(url);
906 		rc = DBexecute("update users set url='%s' where userid=%s", url_esc, row[0]);
907 		zbx_free(url_esc);
908 
909 		if (ZBX_DB_OK > rc)
910 			goto out;
911 	}
912 
913 	ret = SUCCEED;
914 out:
915 	zbx_free(url);
916 	DBfree_result(result);
917 
918 	return ret;
919 }
DBpatch_2050093(void)920 static int	DBpatch_2050093(void)
921 {
922 	const ZBX_FIELD field = {"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, 0, 0};
923 
924 	return DBadd_field("screens", &field);
925 }
926 
DBpatch_2050094(void)927 static int	DBpatch_2050094(void)
928 {
929 	/* type=3 -> type=USER_TYPE_SUPER_ADMIN */
930 	if (ZBX_DB_OK > DBexecute("update screens"
931 			" set userid=(select min(userid) from users where type=3)"
932 			" where templateid is null"))
933 	{
934 		return FAIL;
935 	}
936 
937 	return SUCCEED;
938 }
939 
DBpatch_2050095(void)940 static int	DBpatch_2050095(void)
941 {
942 	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, 0};
943 
944 	return DBadd_foreign_key("screens", 3, &field);
945 }
946 
DBpatch_2050096(void)947 static int	DBpatch_2050096(void)
948 {
949 	const ZBX_FIELD field = {"private", "1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
950 
951 	return DBadd_field("screens", &field);
952 }
953 
DBpatch_2050097(void)954 static int	DBpatch_2050097(void)
955 {
956 	const ZBX_TABLE table =
957 		{"screen_user",	"screenuserid",	0,
958 			{
959 				{"screenuserid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
960 				{"screenid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
961 				{"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
962 				{"permission", "2", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
963 				{0}
964 			},
965 			NULL
966 		};
967 
968 	return DBcreate_table(&table);
969 }
970 
DBpatch_2050098(void)971 static int	DBpatch_2050098(void)
972 {
973 	return DBcreate_index("screen_user", "screen_user_1", "screenid,userid", 1);
974 }
975 
DBpatch_2050099(void)976 static int	DBpatch_2050099(void)
977 {
978 	const ZBX_FIELD	field = {"screenid", NULL, "screens", "screenid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
979 
980 	return DBadd_foreign_key("screen_user", 1, &field);
981 }
982 
DBpatch_2050100(void)983 static int	DBpatch_2050100(void)
984 {
985 	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
986 
987 	return DBadd_foreign_key("screen_user", 2, &field);
988 }
989 
DBpatch_2050101(void)990 static int	DBpatch_2050101(void)
991 {
992 	const ZBX_TABLE table =
993 		{"screen_usrgrp", "screenusrgrpid", 0,
994 			{
995 				{"screenusrgrpid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
996 				{"screenid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
997 				{"usrgrpid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
998 				{"permission", "2", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
999 				{0}
1000 			},
1001 			NULL
1002 		};
1003 
1004 	return DBcreate_table(&table);
1005 }
1006 
DBpatch_2050102(void)1007 static int	DBpatch_2050102(void)
1008 {
1009 	return DBcreate_index("screen_usrgrp", "screen_usrgrp_1", "screenid,usrgrpid", 1);
1010 }
1011 
DBpatch_2050103(void)1012 static int	DBpatch_2050103(void)
1013 {
1014 	const ZBX_FIELD	field = {"screenid", NULL, "screens", "screenid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
1015 
1016 	return DBadd_foreign_key("screen_usrgrp", 1, &field);
1017 }
1018 
DBpatch_2050104(void)1019 static int	DBpatch_2050104(void)
1020 {
1021 	const ZBX_FIELD	field = {"usrgrpid", NULL, "usrgrp", "usrgrpid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
1022 
1023 	return DBadd_foreign_key("screen_usrgrp", 2, &field);
1024 }
1025 
DBpatch_2050105(void)1026 static int	DBpatch_2050105(void)
1027 {
1028 	const ZBX_FIELD	field = {"flags", "0", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
1029 
1030 	return DBrename_field("proxy_history", "meta", &field);
1031 }
1032 
DBpatch_2050106(void)1033 static int	DBpatch_2050106(void)
1034 {
1035 	/* convert meta value (1) to PROXY_HISTORY_FLAG_META | PROXY_HISTORY_FLAG_NOVALUE (0x03) flags */
1036 	if (ZBX_DB_OK > DBexecute("update proxy_history set flags=3 where flags=1"))
1037 	{
1038 		return FAIL;
1039 	}
1040 
1041 	return SUCCEED;
1042 }
1043 
DBpatch_2050107(void)1044 static int	DBpatch_2050107(void)
1045 {
1046 	const ZBX_FIELD field = {"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, 0, 0};
1047 
1048 	return DBadd_field("slideshows", &field);
1049 }
1050 
DBpatch_2050108(void)1051 static int	DBpatch_2050108(void)
1052 {
1053 	/* type=3 -> type=USER_TYPE_SUPER_ADMIN */
1054 	if (ZBX_DB_OK > DBexecute("update slideshows set userid=(select min(userid) from users where type=3)"))
1055 		return FAIL;
1056 
1057 	return SUCCEED;
1058 }
1059 
DBpatch_2050109(void)1060 static int	DBpatch_2050109(void)
1061 {
1062 	const ZBX_FIELD	field = {"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0};
1063 
1064 	return DBset_not_null("slideshows", &field);
1065 }
1066 
DBpatch_2050110(void)1067 static int	DBpatch_2050110(void)
1068 {
1069 	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, 0};
1070 
1071 	return DBadd_foreign_key("slideshows", 3, &field);
1072 }
1073 
DBpatch_2050111(void)1074 static int	DBpatch_2050111(void)
1075 {
1076 	const ZBX_FIELD field = {"private", "1", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0};
1077 
1078 	return DBadd_field("slideshows", &field);
1079 }
1080 
DBpatch_2050112(void)1081 static int	DBpatch_2050112(void)
1082 {
1083 	const ZBX_TABLE table =
1084 		{"slideshow_user", "slideshowuserid", 0,
1085 			{
1086 				{"slideshowuserid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
1087 				{"slideshowid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
1088 				{"userid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
1089 				{"permission", "2", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
1090 				{0}
1091 			},
1092 			NULL
1093 		};
1094 
1095 	return DBcreate_table(&table);
1096 }
1097 
DBpatch_2050113(void)1098 static int	DBpatch_2050113(void)
1099 {
1100 	return DBcreate_index("slideshow_user", "slideshow_user_1", "slideshowid,userid", 1);
1101 }
1102 
DBpatch_2050114(void)1103 static int	DBpatch_2050114(void)
1104 {
1105 	const ZBX_FIELD	field = {"slideshowid", NULL, "slideshows", "slideshowid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
1106 
1107 	return DBadd_foreign_key("slideshow_user", 1, &field);
1108 }
1109 
DBpatch_2050115(void)1110 static int	DBpatch_2050115(void)
1111 {
1112 	const ZBX_FIELD	field = {"userid", NULL, "users", "userid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
1113 
1114 	return DBadd_foreign_key("slideshow_user", 2, &field);
1115 }
1116 
DBpatch_2050116(void)1117 static int	DBpatch_2050116(void)
1118 {
1119 	const ZBX_TABLE table =
1120 		{"slideshow_usrgrp", "slideshowusrgrpid", 0,
1121 			{
1122 				{"slideshowusrgrpid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
1123 				{"slideshowid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
1124 				{"usrgrpid", NULL, NULL, NULL, 0, ZBX_TYPE_ID, ZBX_NOTNULL, 0},
1125 				{"permission", "2", NULL, NULL, 0, ZBX_TYPE_INT, ZBX_NOTNULL, 0},
1126 				{0}
1127 			},
1128 			NULL
1129 		};
1130 
1131 	return DBcreate_table(&table);
1132 }
1133 
DBpatch_2050117(void)1134 static int	DBpatch_2050117(void)
1135 {
1136 	return DBcreate_index("slideshow_usrgrp", "slideshow_usrgrp_1", "slideshowid,usrgrpid", 1);
1137 }
1138 
DBpatch_2050118(void)1139 static int	DBpatch_2050118(void)
1140 {
1141 	const ZBX_FIELD	field = {"slideshowid", NULL, "slideshows", "slideshowid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
1142 
1143 	return DBadd_foreign_key("slideshow_usrgrp", 1, &field);
1144 }
1145 
DBpatch_2050119(void)1146 static int	DBpatch_2050119(void)
1147 {
1148 	const ZBX_FIELD	field = {"usrgrpid", NULL, "usrgrp", "usrgrpid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
1149 
1150 	return DBadd_foreign_key("slideshow_usrgrp", 2, &field);
1151 }
1152 
DBpatch_2050120(void)1153 static int	DBpatch_2050120(void)
1154 {
1155 	/* private=0 -> PUBLIC_SHARING */
1156 	if (ZBX_DB_OK <= DBexecute("update sysmaps set private=0"))
1157 		return SUCCEED;
1158 
1159 	return FAIL;
1160 }
1161 
DBpatch_2050121(void)1162 static int	DBpatch_2050121(void)
1163 {
1164 	/* private=0 -> PUBLIC_SHARING */
1165 	if (ZBX_DB_OK <= DBexecute("update screens set private=0"))
1166 		return SUCCEED;
1167 
1168 	return FAIL;
1169 }
1170 
DBpatch_2050122(void)1171 static int	DBpatch_2050122(void)
1172 {
1173 	/* private=0 -> PUBLIC_SHARING */
1174 	if (ZBX_DB_OK <= DBexecute("update slideshows set private=0"))
1175 		return SUCCEED;
1176 
1177 	return FAIL;
1178 }
1179 
1180 #endif
1181 
1182 DBPATCH_START(2050)
1183 
1184 /* version, duplicates flag, mandatory flag */
1185 
1186 DBPATCH_ADD(2050000, 0, 1)
1187 DBPATCH_ADD(2050001, 0, 1)
1188 DBPATCH_ADD(2050002, 0, 1)
1189 DBPATCH_ADD(2050003, 0, 1)
1190 DBPATCH_ADD(2050004, 0, 1)
1191 DBPATCH_ADD(2050005, 0, 0)
1192 DBPATCH_ADD(2050006, 0, 0)
1193 DBPATCH_ADD(2050007, 0, 1)
1194 DBPATCH_ADD(2050008, 0, 1)
1195 DBPATCH_ADD(2050009, 0, 1)
1196 DBPATCH_ADD(2050010, 0, 1)
1197 DBPATCH_ADD(2050011, 0, 1)
1198 DBPATCH_ADD(2050012, 0, 1)
1199 DBPATCH_ADD(2050013, 0, 0)
1200 DBPATCH_ADD(2050014, 0, 1)
1201 DBPATCH_ADD(2050015, 0, 1)
1202 DBPATCH_ADD(2050019, 0, 1)
1203 DBPATCH_ADD(2050020, 0, 1)
1204 DBPATCH_ADD(2050021, 0, 1)
1205 DBPATCH_ADD(2050022, 0, 1)
1206 DBPATCH_ADD(2050023, 0, 1)
1207 DBPATCH_ADD(2050029, 0, 1)
1208 DBPATCH_ADD(2050030, 0, 1)
1209 DBPATCH_ADD(2050031, 0, 1)
1210 DBPATCH_ADD(2050032, 0, 1)
1211 DBPATCH_ADD(2050033, 0, 1)
1212 DBPATCH_ADD(2050034, 0, 1)
1213 DBPATCH_ADD(2050035, 0, 1)
1214 DBPATCH_ADD(2050036, 0, 1)
1215 DBPATCH_ADD(2050037, 0, 1)
1216 DBPATCH_ADD(2050038, 0, 1)
1217 DBPATCH_ADD(2050039, 0, 1)
1218 DBPATCH_ADD(2050040, 0, 1)
1219 DBPATCH_ADD(2050041, 0, 1)
1220 DBPATCH_ADD(2050042, 0, 1)
1221 DBPATCH_ADD(2050043, 0, 1)
1222 DBPATCH_ADD(2050044, 0, 1)
1223 DBPATCH_ADD(2050045, 0, 1)
1224 DBPATCH_ADD(2050051, 0, 1)
1225 DBPATCH_ADD(2050052, 0, 1)
1226 DBPATCH_ADD(2050053, 0, 1)
1227 DBPATCH_ADD(2050054, 0, 1)
1228 DBPATCH_ADD(2050055, 0, 1)
1229 DBPATCH_ADD(2050056, 0, 1)
1230 DBPATCH_ADD(2050057, 0, 1)
1231 DBPATCH_ADD(2050058, 0, 1)
1232 DBPATCH_ADD(2050059, 0, 1)
1233 DBPATCH_ADD(2050060, 0, 1)
1234 DBPATCH_ADD(2050061, 0, 1)
1235 DBPATCH_ADD(2050062, 0, 1)
1236 DBPATCH_ADD(2050063, 0, 1)
1237 DBPATCH_ADD(2050064, 0, 1)
1238 DBPATCH_ADD(2050065, 0, 1)
1239 DBPATCH_ADD(2050066, 0, 1)
1240 DBPATCH_ADD(2050067, 0, 1)
1241 DBPATCH_ADD(2050068, 0, 1)
1242 DBPATCH_ADD(2050069, 0, 1)
1243 DBPATCH_ADD(2050070, 0, 1)
1244 DBPATCH_ADD(2050071, 0, 1)
1245 DBPATCH_ADD(2050072, 0, 1)
1246 DBPATCH_ADD(2050073, 0, 1)
1247 DBPATCH_ADD(2050074, 0, 1)
1248 DBPATCH_ADD(2050075, 0, 1)
1249 DBPATCH_ADD(2050076, 0, 1)
1250 DBPATCH_ADD(2050077, 0, 1)
1251 DBPATCH_ADD(2050078, 0, 1)
1252 DBPATCH_ADD(2050079, 0, 1)
1253 DBPATCH_ADD(2050080, 0, 1)
1254 DBPATCH_ADD(2050081, 0, 1)
1255 DBPATCH_ADD(2050082, 0, 1)
1256 DBPATCH_ADD(2050083, 0, 1)
1257 DBPATCH_ADD(2050084, 0, 1)
1258 DBPATCH_ADD(2050085, 0, 1)
1259 DBPATCH_ADD(2050086, 0, 1)
1260 DBPATCH_ADD(2050087, 0, 1)
1261 DBPATCH_ADD(2050088, 0, 1)
1262 DBPATCH_ADD(2050089, 0, 1)
1263 DBPATCH_ADD(2050090, 0, 1)
1264 DBPATCH_ADD(2050091, 0, 1)
1265 DBPATCH_ADD(2050092, 0, 1)
1266 DBPATCH_ADD(2050093, 0, 1)
1267 DBPATCH_ADD(2050094, 0, 1)
1268 DBPATCH_ADD(2050095, 0, 1)
1269 DBPATCH_ADD(2050096, 0, 1)
1270 DBPATCH_ADD(2050097, 0, 1)
1271 DBPATCH_ADD(2050098, 0, 1)
1272 DBPATCH_ADD(2050099, 0, 1)
1273 DBPATCH_ADD(2050100, 0, 1)
1274 DBPATCH_ADD(2050101, 0, 1)
1275 DBPATCH_ADD(2050102, 0, 1)
1276 DBPATCH_ADD(2050103, 0, 1)
1277 DBPATCH_ADD(2050104, 0, 1)
1278 DBPATCH_ADD(2050105, 0, 1)
1279 DBPATCH_ADD(2050106, 0, 1)
1280 DBPATCH_ADD(2050107, 0, 1)
1281 DBPATCH_ADD(2050108, 0, 1)
1282 DBPATCH_ADD(2050109, 0, 1)
1283 DBPATCH_ADD(2050110, 0, 1)
1284 DBPATCH_ADD(2050111, 0, 1)
1285 DBPATCH_ADD(2050112, 0, 1)
1286 DBPATCH_ADD(2050113, 0, 1)
1287 DBPATCH_ADD(2050114, 0, 1)
1288 DBPATCH_ADD(2050115, 0, 1)
1289 DBPATCH_ADD(2050116, 0, 1)
1290 DBPATCH_ADD(2050117, 0, 1)
1291 DBPATCH_ADD(2050118, 0, 1)
1292 DBPATCH_ADD(2050119, 0, 1)
1293 DBPATCH_ADD(2050120, 0, 1)
1294 DBPATCH_ADD(2050121, 0, 1)
1295 DBPATCH_ADD(2050122, 0, 1)
1296 
1297 DBPATCH_END()
1298