Greenbone Vulnerability Manager  8.0.1~git
Data Structures | Macros | Functions | Variables
manage_migrators.c File Reference

The Greenbone Vulnerability Manager DB Migrators file. More...

#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib/gstdio.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <ctype.h>
#include <dirent.h>
#include "manage_sql.h"
#include "utils.h"
#include "sql.h"
#include <gvm/base/logging.h>
#include <gvm/util/fileutils.h>
#include <gvm/util/uuidutils.h>

Data Structures

struct  migrator_t
 A migrator. More...
 

Macros

#define _XOPEN_SOURCE
 
#define G_LOG_DOMAIN   "md main"
 GLib log domain.
 
#define CONFIG_ID_FULL_AND_FAST   1
 Database ROWID of 'Full and fast' config.
 
#define CONFIG_ID_FULL_AND_FAST_ULTIMATE   2
 Database ROWID of 'Full and fast ultimate' config.
 
#define CONFIG_ID_FULL_AND_VERY_DEEP   3
 Database ROWID of 'Full and very deep' config.
 
#define CONFIG_ID_FULL_AND_VERY_DEEP_ULTIMATE   4
 Database ROWID of 'Full and very deep ultimate' config.
 
#define MIGRATE_55_TO_56_RANGE(type, start, end)
 Insert a port range. More...
 
#define MIGRATE_79_to_80_DELETE(table)
 Delete table for migrate_79_to_80. More...
 
#define RULES_HEADER   "# This file is managed by the OpenVAS Administrator.\n# Any modifications must keep to the format that the Administrator expects.\n"
 User access rules header for migrate_79_to_80.
 
#define ID_WHEN_WITH_TRASH(type)
 ID SQL for migrate_116_to_117. More...
 
#define ID_WHEN_WITHOUT_TRASH(type)
 ID SQL for migrate_116_to_117. More...
 
#define RESOURCE_TRASH(type)
 Trash SQL for migrate_116_to_117. More...
 
#define RESOURCE_TRASH(type)
 Trash SQL for migrate_116_to_117. More...
 
#define INSERT_PERMISSION(name, role)
 Permission SQL for migrate_150_to_151. More...
 
#define DELETE_PERMISSION(name, role)
 Permission SQL for migrate_152_to_153. More...
 
#define MIGRATE_162_TO_163_CONTROL_DESCRIPTION
 Description for Verinice ISM report format. More...
 
#define UPDATE_CHART_SETTINGS(type, default, left_uuid, right_uuid)
 Chart SQL for migrate_163_to_164. More...
 
#define UPDATE_DASHBOARD_SETTINGS(type, default, uuid_1, uuid_2, uuid_3, uuid_4, filter_1, filter_2, filter_3, filter_4)
 Dashboard SQL for migrate_163_to_164.
 
#define MIGRATE_TO_200_NVT_SELECTOR_UUID_DISCOVERY   "0d9a2738-8fe2-4e22-8f26-bb886179e759"
 UUID of 'Discovery' NVT selector, for migrator.
 
#define MIGRATE_TO_200_NVT_SELECTOR_TYPE_NVT   2
 NVT selector type for "NVT" rule.
 
#define SQLITE_OR_NULL(function)   NULL
 Conditional for database_migrators. More...
 

Functions

int manage_create_migrate_51_to_52_convert ()
 Dummy for SQLite3 compatibility. More...
 
void manage_create_result_indexes ()
 Create result indexes.
 
static void create_tables_version_4 ()
 Create all tables, using the version 4 schema. More...
 
int migrate_0_to_1 ()
 Migrate the database from version 0 to version 1. More...
 
int migrate_1_to_2 ()
 Migrate the database from version 1 to version 2. More...
 
int migrate_2_to_3 ()
 Migrate the database from version 2 to version 3. More...
 
int migrate_3_to_4 ()
 Migrate the database from version 3 to version 4. More...
 
void migrate_4_to_5_copy_data ()
 Move all the data to the new tables for the 4 to 5 migrator.
 
int migrate_4_to_5 ()
 Migrate the database from version 4 to version 5. More...
 
void migrate_5_to_6_move_other_config (const char *predefined_config_name, config_t predefined_config_id)
 Move a config that is using a predefined ID. More...
 
int migrate_5_to_6 ()
 Migrate the database from version 5 to version 6. More...
 
int migrate_6_to_7 ()
 Migrate the database from version 6 to version 7. More...
 
int migrate_7_to_8 ()
 Migrate the database from version 7 to version 8. More...
 
int migrate_8_to_9 ()
 Migrate the database from version 8 to version 9. More...
 
gchar * migrate_9_to_10_user_uuid (const char *name)
 Return the UUID of a user from the GVM user UUID file. More...
 
int migrate_9_to_10 ()
 Migrate the database from version 9 to version 10. More...
 
int migrate_10_to_11 ()
 Migrate the database from version 10 to version 11. More...
 
int migrate_11_to_12 ()
 Migrate the database from version 11 to version 12. More...
 
int migrate_12_to_13 ()
 Migrate the database from version 12 to version 13. More...
 
int migrate_13_to_14 ()
 Migrate the database from version 13 to version 14. More...
 
int migrate_14_to_15 ()
 Migrate the database from version 14 to version 15. More...
 
int migrate_15_to_16 ()
 Migrate the database from version 15 to version 16. More...
 
int migrate_16_to_17 ()
 Migrate the database from version 16 to version 17. More...
 
void migrate_17_to_18_set_pref (config_t config)
 Set the pref for migrate_17_to_18. More...
 
int migrate_17_to_18 ()
 Migrate the database from version 17 to version 18. More...
 
int migrate_18_to_19 ()
 Migrate the database from version 18 to version 19. More...
 
int migrate_19_to_20 ()
 Migrate the database from version 19 to version 20. More...
 
int migrate_20_to_21 ()
 Migrate the database from version 20 to version 21. More...
 
int migrate_21_to_22 ()
 Migrate the report formats from version 21 to version 22. More...
 
int migrate_22_to_23 ()
 Migrate the report formats from version 22 to version 23. More...
 
int migrate_23_to_24 ()
 Migrate the database from version 23 to version 24. More...
 
int migrate_24_to_25 ()
 Migrate the database from version 24 to version 25. More...
 
int migrate_25_to_26 ()
 Migrate the database from version 25 to version 26. More...
 
int migrate_26_to_27 ()
 Migrate the database from version 26 to version 27. More...
 
int migrate_27_to_28 ()
 Migrate the database from version 27 to version 28. More...
 
int migrate_28_to_29 ()
 Migrate the database from version 27 to version 28. More...
 
int migrate_29_to_30 ()
 Migrate the database from version 29 to version 30. More...
 
int migrate_30_to_31 ()
 Migrate the database from version 30 to version 31. More...
 
int migrate_31_to_32 ()
 Migrate the database from version 31 to version 32. More...
 
int migrate_32_to_33 ()
 Migrate the database from version 32 to version 33. More...
 
void migrate_33_to_34_set_pref (config_t config)
 Set the pref for migrate_33_to_34. More...
 
int migrate_33_to_34 ()
 Migrate the database from version 33 to version 34. More...
 
int migrate_34_to_35 ()
 Migrate the database from version 34 to version 35. More...
 
target_t migrate_35_to_36_duplicate_target (target_t target, const char *name)
 Make a copy of a target. More...
 
int migrate_35_to_36 ()
 Migrate the database from version 35 to version 36. More...
 
int migrate_36_to_37 ()
 Migrate the database from version 36 to version 37. More...
 
int migrate_37_to_38 ()
 Migrate the database from version 37 to version 38. More...
 
int migrate_38_to_39 ()
 Migrate the database from version 38 to version 39. More...
 
void migrate_39_to_40_set_pref (config_t config)
 Set the pref for migrate_39_to_40. More...
 
int migrate_39_to_40 ()
 Migrate the database from version 39 to version 40. More...
 
int migrate_40_to_41 ()
 Migrate the database from version 40 to version 41. More...
 
int migrate_41_to_42 ()
 Migrate the database from version 41 to version 42. More...
 
int migrate_42_to_43 ()
 Migrate the database from version 42 to version 43. More...
 
int migrate_43_to_44 ()
 Migrate the database from version 43 to version 44. More...
 
int migrate_44_to_45 ()
 Migrate the database from version 44 to version 45. More...
 
int migrate_45_to_46 ()
 Migrate the database from version 45 to version 46. More...
 
int migrate_46_to_47 ()
 Migrate the database from version 46 to version 47. More...
 
int migrate_47_to_48 ()
 Migrate the database from version 47 to version 48. More...
 
int migrate_48_to_49 ()
 Migrate the database from version 48 to version 49. More...
 
int migrate_49_to_50 ()
 Migrate the database from version 49 to version 50. More...
 
int migrate_50_to_51 ()
 Migrate the database from version 50 to version 51. More...
 
int migrate_51_to_52 ()
 Migrate the database from version 51 to version 52. More...
 
int migrate_52_to_53 ()
 Migrate the database from version 52 to version 53. More...
 
int migrate_53_to_54 ()
 Migrate the database from version 53 to version 54. More...
 
int migrate_54_to_55_format (const char *old_uuid, const char *new_uuid)
 Migrate a report format from version 54 to version 55. More...
 
int migrate_54_to_55 ()
 Migrate the database from version 54 to version 55. More...
 
void migrate_55_to_56_ensure_predefined_port_lists_exist ()
 Ensure that the predefined port lists exist.
 
int migrate_55_to_56 ()
 Migrate the database from version 55 to version 56. More...
 
int migrate_56_to_57 ()
 Migrate the database from version 56 to version 57. More...
 
int migrate_57_to_58 ()
 Migrate the database from version 57 to version 58. More...
 
int migrate_58_to_59 ()
 Migrate the database from version 58 to version 59. More...
 
int migrate_59_to_60 ()
 Migrate the database from version 59 to version 60. More...
 
int migrate_60_to_61 ()
 Migrate the database from version 60 to version 61. More...
 
int migrate_61_to_62 ()
 Migrate the database from version 61 to version 62. More...
 
int migrate_62_to_63 ()
 Migrate the database from version 62 to version 63. More...
 
int migrate_63_to_64 ()
 Migrate the database from version 63 to version 64. More...
 
int migrate_64_to_65 ()
 Migrate the database from version 64 to version 65. More...
 
int migrate_65_to_66 ()
 Migrate the database from version 65 to version 66. More...
 
int migrate_66_to_67 ()
 Migrate the database from version 66 to version 67. More...
 
int migrate_67_to_68 ()
 Migrate the database from version 67 to version 68. More...
 
int migrate_68_to_69 ()
 Migrate the database from version 68 to version 69. More...
 
int migrate_69_to_70 ()
 Migrate the database from version 69 to version 70. More...
 
int migrate_70_to_71 ()
 Migrate the database from version 70 to version 71. More...
 
int migrate_71_to_72 ()
 Migrate the database from version 71 to version 72. More...
 
int migrate_72_to_73 ()
 Migrate the database from version 72 to version 73. More...
 
int migrate_73_to_74 ()
 Migrate the database from version 73 to version 74. More...
 
int migrate_74_to_75 ()
 Migrate the database from version 74 to version 75. More...
 
int migrate_75_to_76 ()
 Migrate the database from version 75 to version 76. More...
 
int migrate_76_to_77 ()
 Migrate the database from version 76 to version 77. More...
 
int migrate_77_to_78 ()
 Migrate the database from version 77 to version 78. More...
 
int migrate_78_to_79 ()
 Migrate the database from version 78 to version 79. More...
 
void migrate_79_to_80_remove_users (const char *where)
 Delete users according to a condition. More...
 
int migrate_79_to_80_user_access (const gchar *user_dir, gchar **hosts, int *hosts_allow)
 Get access information for a user. More...
 
int migrate_79_to_80 ()
 Migrate the database from version 79 to version 80. More...
 
int migrate_80_to_81 ()
 Migrate the database from version 80 to version 81. More...
 
int migrate_81_to_82 ()
 Migrate the database from version 81 to version 82. More...
 
int migrate_82_to_83 ()
 Migrate the database from version 82 to version 83. More...
 
int migrate_83_to_84 ()
 Migrate the database from version 83 to version 84. More...
 
int migrate_84_to_85 ()
 Migrate the database from version 84 to version 85. More...
 
int migrate_85_to_86 ()
 Migrate the database from version 85 to version 86. More...
 
int migrate_86_to_87 ()
 Migrate the database from version 86 to version 87. More...
 
int migrate_87_to_88 ()
 Migrate the database from version 87 to version 88. More...
 
int migrate_88_to_89 ()
 Migrate the database from version 88 to version 89. More...
 
int migrate_89_to_90 ()
 Migrate the database from version 89 to version 90. More...
 
int migrate_90_to_91 ()
 Migrate the database from version 90 to version 91. More...
 
int migrate_91_to_92 ()
 Migrate the database from version 91 to version 92. More...
 
int migrate_92_to_93 ()
 Migrate the database from version 92 to version 93. More...
 
int migrate_93_to_94 ()
 Migrate the database from version 93 to version 94. More...
 
int migrate_94_to_95 ()
 Migrate the database from version 94 to version 95. More...
 
int migrate_95_to_96 ()
 Migrate the database from version 95 to version 96. More...
 
int migrate_96_to_97 ()
 Migrate the database from version 96 to version 97. More...
 
int migrate_97_to_98 ()
 Migrate the database from version 97 to version 98. More...
 
int migrate_98_to_99 ()
 Migrate the database from version 98 to version 99. More...
 
int migrate_99_to_100 ()
 Migrate the database from version 99 to version 100. More...
 
int migrate_100_to_101 ()
 Migrate the database from version 100 to version 101. More...
 
int migrate_101_to_102 ()
 Migrate the database from version 101 to version 102. More...
 
int migrate_102_to_103 ()
 Migrate the database from version 102 to version 103. More...
 
int migrate_103_to_104 ()
 Migrate the database from version 103 to version 104. More...
 
int migrate_104_to_105 ()
 Migrate the database from version 104 to version 105. More...
 
int migrate_105_to_106 ()
 Migrate the database from version 105 to version 106. More...
 
int migrate_106_to_107 ()
 Migrate the database from version 106 to version 107. More...
 
int migrate_107_to_108 ()
 Migrate the database from version 107 to version 108. More...
 
int migrate_108_to_109 ()
 Migrate the database from version 108 to version 109. More...
 
int migrate_109_to_110 ()
 Migrate the database from version 109 to version 110. More...
 
int migrate_110_to_111 ()
 Migrate the database from version 110 to version 111. More...
 
int migrate_111_to_112 ()
 Migrate the database from version 111 to version 112. More...
 
int migrate_112_to_113 ()
 Migrate the database from version 112 to version 113. More...
 
int migrate_113_to_114 ()
 Migrate the database from version 113 to version 114. More...
 
int migrate_114_to_115 ()
 Migrate the database from version 114 to version 115. More...
 
int migrate_115_to_116 ()
 Migrate the database from version 115 to version 116. More...
 
int migrate_116_to_117 ()
 Migrate the database from version 116 to version 117. More...
 
int migrate_117_to_118 ()
 Migrate the database from version 117 to version 118. More...
 
int migrate_118_to_119 ()
 Migrate the database from version 118 to version 119. More...
 
int migrate_119_to_120 ()
 Migrate the database from version 119 to version 120. More...
 
int migrate_120_to_121 ()
 Migrate the database from version 120 to version 121. More...
 
int migrate_121_to_122 ()
 Migrate the database from version 121 to version 122. More...
 
int migrate_122_to_123 ()
 Migrate the database from version 122 to version 123. More...
 
int migrate_123_to_124 ()
 Migrate the database from version 123 to version 124. More...
 
int migrate_124_to_125 ()
 Migrate the database from version 124 to version 125. More...
 
int migrate_125_to_126 ()
 Migrate the database from version 125 to version 126. More...
 
int migrate_126_to_127 ()
 Migrate the database from version 126 to version 127. More...
 
int migrate_127_to_128 ()
 Migrate the database from version 127 to version 128. More...
 
int migrate_128_to_129 ()
 Migrate the database from version 128 to version 129. More...
 
int migrate_129_to_130 ()
 Migrate the database from version 129 to version 130. More...
 
int migrate_130_to_131 ()
 Migrate the database from version 130 to version 131. More...
 
int migrate_131_to_132 ()
 Migrate the database from version 131 to version 132. More...
 
int migrate_132_to_133 ()
 Migrate the database from version 132 to version 133. More...
 
int migrate_133_to_134 ()
 Migrate the database from version 133 to version 134. More...
 
int migrate_134_to_135 ()
 Migrate the database from version 134 to version 135. More...
 
int migrate_135_to_136 ()
 Migrate the database from version 135 to version 136. More...
 
int migrate_136_to_137 ()
 Migrate the database from version 136 to version 137. More...
 
int migrate_137_to_138 ()
 Migrate the database from version 137 to version 138. More...
 
int migrate_138_to_139 ()
 Migrate the database from version 138 to version 139. More...
 
int migrate_139_to_140 ()
 Migrate the database from version 139 to version 140. More...
 
int migrate_140_to_141 ()
 Migrate the database from version 140 to version 141. More...
 
int migrate_141_to_142 ()
 Migrate the database from version 141 to version 142. More...
 
int migrate_142_to_143 ()
 Migrate the database from version 142 to version 143. More...
 
int migrate_143_to_144 ()
 Migrate the database from version 143 to version 144. More...
 
int migrate_144_to_145 ()
 Migrate the database from version 144 to version 145. More...
 
int migrate_145_to_146 ()
 Migrate the database from version 145 to version 146. More...
 
int migrate_146_to_147 ()
 Migrate the database from version 146 to version 147. More...
 
int migrate_147_to_148 ()
 Migrate the database from version 147 to version 148. More...
 
int migrate_148_to_149 ()
 Migrate the database from version 148 to version 149. More...
 
int migrate_149_to_150 ()
 Migrate the database from version 149 to version 150. More...
 
int migrate_150_to_151 ()
 Migrate the database from version 150 to version 151. More...
 
int migrate_151_to_152 ()
 Migrate the database from version 151 to version 152. More...
 
int migrate_152_to_153 ()
 Migrate the database from version 152 to version 153. More...
 
int migrate_153_to_154 ()
 Migrate the database from version 152 to version 153. More...
 
int migrate_154_to_155 ()
 Migrate the database from version 154 to version 155. More...
 
int migrate_155_to_156 ()
 Migrate the database from version 155 to version 156. More...
 
int migrate_156_to_157 ()
 Migrate the database from version 156 to version 157. More...
 
int migrate_157_to_158 ()
 Migrate the database from version 157 to version 158. More...
 
int migrate_158_to_159 ()
 Migrate the database from version 158 to version 159. More...
 
int migrate_159_to_160 ()
 Migrate the database from version 159 to version 160. More...
 
int migrate_160_to_161 ()
 Migrate the database from version 160 to version 161. More...
 
int migrate_161_to_162 ()
 Migrate the database from version 161 to version 162. More...
 
int migrate_162_to_163 ()
 Migrate the database from version 158 to version 162. More...
 
int migrate_163_to_164 ()
 Migrate the database from version 163 to version 164. More...
 
int migrate_164_to_165 ()
 Migrate the database from version 163 to version 164. More...
 
int migrate_165_to_166 ()
 Migrate the database from version 165 to version 166. More...
 
static void insert_predefined (const gchar *uuid)
 Mark a report format predefined. More...
 
int migrate_166_to_167 ()
 Migrate the database from version 166 to version 167. More...
 
int migrate_167_to_168 ()
 Migrate the database from version 167 to version 168. More...
 
static void migrate_168_to_169_copy_target (user_t owner, const gchar *uuid, target_t *new)
 Migrate the database from version 168 to version 169. More...
 
int migrate_168_to_169 ()
 Migrate the database from version 168 to version 169. More...
 
static void migrate_169_to_170_add_permission (const gchar *role, const gchar *permission)
 Add permission to role. More...
 
int migrate_169_to_170 ()
 Migrate the database from version 169 to version 170. More...
 
int migrate_170_to_171 ()
 Migrate the database from version 170 to version 171. More...
 
int migrate_171_to_172 ()
 Migrate the database from version 171 to version 172. More...
 
int migrate_172_to_173 ()
 Migrate the database from version 172 to version 173. More...
 
int migrate_173_to_174 ()
 Migrate the database from version 173 to version 174. More...
 
int migrate_174_to_175 ()
 Migrate the database from version 174 to version 175. More...
 
int migrate_175_to_176 ()
 Migrate the database from version 175 to version 176. More...
 
int migrate_176_to_177 ()
 Migrate the database from version 176 to version 177. More...
 
int migrate_177_to_178 ()
 Migrate the database from version 177 to version 178. More...
 
int migrate_178_to_179 ()
 Migrate the database from version 178 to version 179. More...
 
void migrate_179_to_180_update_ref (const gchar *table, int trash)
 Update a reference for migrate_179_to_180. More...
 
int migrate_179_to_180 ()
 Migrate the database from version 179 to version 180. More...
 
int migrate_180_to_181 ()
 Migrate the database from version 180 to version 181. More...
 
int migrate_181_to_182_move (const char *dest)
 Move signatures. More...
 
int migrate_181_to_182 ()
 Migrate the database from version 181 to version 182. More...
 
int migrate_182_to_183 ()
 Migrate the database from version 182 to version 183. More...
 
int migrate_183_to_184 ()
 Migrate the database from version 183 to version 184. More...
 
int migrate_184_to_185 ()
 Migrate the database from version 184 to version 185. More...
 
int migrate_185_to_186 ()
 Migrate the database from version 185 to version 186. More...
 
int migrate_186_to_187 ()
 Migrate the database from version 186 to version 187. More...
 
int migrate_187_to_188 ()
 Migrate the database from version 187 to version 188. More...
 
int migrate_188_to_189 ()
 Migrate the database from version 188 to version 189. More...
 
int migrate_189_to_190 ()
 Migrate the database from version 189 to version 190. More...
 
int migrate_190_to_191 ()
 Migrate the database from version 190 to version 191. More...
 
int migrate_191_to_192 ()
 Migrate the database from version 191 to version 192. More...
 
int migrate_192_to_193 ()
 Migrate the database from version 192 to version 193. More...
 
int migrate_193_to_194 ()
 Migrate the database from version 193 to version 194. More...
 
int migrate_194_to_195 ()
 Migrate the database from version 194 to version 195. More...
 
int migrate_195_to_196 ()
 Migrate the database from version 195 to version 196. More...
 
int migrate_196_to_197 ()
 Migrate the database from version 196 to version 197. More...
 
int migrate_197_to_198 ()
 Migrate the database from version 197 to version 198. More...
 
int migrate_198_to_199 ()
 Migrate the database from version 198 to version 199. More...
 
int migrate_199_to_200 ()
 Migrate the database from version 199 to version 200. More...
 
int migrate_200_to_201 ()
 Migrate the database from version 200 to version 201. More...
 
int migrate_201_to_202 ()
 Migrate the database from version 201 to version 202. More...
 
static void move (const gchar *table, const gchar *old, const gchar *new)
 Rename a column. More...
 
int migrate_202_to_203 ()
 Migrate the database from version 202 to version 203. More...
 
int migrate_203_to_204 ()
 Migrate the database from version 203 to version 204. More...
 
int migrate_204_to_205 ()
 Migrate the database from version 204 to version 205. More...
 
gboolean manage_migrate_needs_timezone (GSList *log_config, const gchar *database)
 Check whether the migration needs the real timezone. More...
 
static int migrate_is_available (int old_version, int new_version)
 Check whether a migration is available. More...
 
int manage_migrate (GSList *log_config, const gchar *database)
 Migrate database to version supported by this manager. More...
 

Variables

static migrator_t database_migrators []
 Array of database version migrators.
 

Detailed Description

The Greenbone Vulnerability Manager DB Migrators file.

This file defines the functions used by the manager to migrate the DB to the newest version.

Macro Definition Documentation

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE

Procedure for writing a migrator

Every change that affects the database schema or the format of the data in the database must have a migrator so that someone using an older version of the database can update to the newer version.

Simply adding a new table to the database is, however, OK. At startup, the manager will automatically add a table if it is missing from the database.

  • Ensure that the ChangeLog notes the changes to the database and the increase of GVMD_DATABASE_VERSION, with an entry like
    * CMakeLists.txt (GVMD_DATABASE_VERSION): Increase to 6, for...
    
    * src/manage_sql.c (create_tables): Add new table...
    
  • Add the migrator function in the style of the others. In particular, the function must check the version, do the modification and then set the new version, all inside an exclusive transaction. Use the generic iterator (init_iterator, iterator_string, iterator_int64...) because the specialised iterators (like init_target_iterator) can change behaviour across Manager SVN versions. Use copies of any other "manage" interfaces, for example update_all_config_caches, as these may also change in later versions of the Manager.
  • Remember to ensure that tables exist in the migrator before the migrator modifies them. If a migrator modifies a table then the table must either have existed in database version 0 (listed below), or some earlier migrator must have added the table, or the migrator must add the table (using the original schema of the table).
  • Add the migrator to the database_migrators array.
  • Test that everything still works for a database that has been migrated from the previous version.
  • Test that everything still works for a database that has been migrated from version 0.
  • Commit with a ChangeLog heading like
    Add database migration from version 5 to 6.
    

SQL that created database version 0:

CREATE TABLE IF NOT EXISTS config_preferences
  (config INTEGER, type, name, value);

CREATE TABLE IF NOT EXISTS configs
  (name UNIQUE, nvt_selector, comment, family_count INTEGER,
   nvt_count INTEGER, families_growing INTEGER, nvts_growing INTEGER);

CREATE TABLE IF NOT EXISTS meta
  (name UNIQUE, value);

CREATE TABLE IF NOT EXISTS nvt_selectors
  (name, exclude INTEGER, type INTEGER, family_or_nvt);

CREATE TABLE IF NOT EXISTS nvts
  (oid, version, name, summary, description, copyright, cve, bid, xref,
   tag, sign_key_ids, category, family);

CREATE TABLE IF NOT EXISTS report_hosts
  (report INTEGER, host, start_time, end_time, attack_state,
   current_port, max_port);

CREATE TABLE IF NOT EXISTS report_results
  (report INTEGER, result INTEGER);

CREATE TABLE IF NOT EXISTS reports
  (uuid, hidden INTEGER, task INTEGER, date INTEGER, start_time,
   end_time, nbefile, comment);

CREATE TABLE IF NOT EXISTS results
  (task INTEGER, subnet, host, port, nvt, type, description);

CREATE TABLE IF NOT EXISTS targets
  (name, hosts, comment);

CREATE TABLE IF NOT EXISTS tasks
  (uuid, name, hidden INTEGER, time, comment, description, owner,
   run_status, start_time, end_time, config, target);

CREATE TABLE IF NOT EXISTS users
  (name UNIQUE, password);

◆ DELETE_PERMISSION

#define DELETE_PERMISSION (   name,
  role 
)
Value:
sql ("DELETE FROM permissions" \
" WHERE subject_type = 'role'" \
" AND subject_location = " G_STRINGIFY (LOCATION_TABLE) \
" AND subject = (SELECT id FROM roles WHERE uuid = '%s')" \
" AND name = '" G_STRINGIFY (name) "';", \
role)
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:202

Permission SQL for migrate_152_to_153.

Parameters
[in]nameName.
[in]roleRole.

◆ ID_WHEN_WITH_TRASH

#define ID_WHEN_WITH_TRASH (   type)
Value:
" WHEN '" G_STRINGIFY (type) "' THEN" \
" COALESCE ((SELECT id FROM " G_STRINGIFY (type) "s" \
" WHERE uuid = attach_id)," \
" (SELECT id FROM " G_STRINGIFY (type) "s_trash" \
" WHERE uuid = attach_id)," \
" 0)"
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

ID SQL for migrate_116_to_117.

◆ ID_WHEN_WITHOUT_TRASH

#define ID_WHEN_WITHOUT_TRASH (   type)
Value:
" WHEN '" G_STRINGIFY (type) "' THEN" \
" COALESCE ((SELECT id FROM " G_STRINGIFY (type) "s" \
" WHERE uuid = attach_id)," \
" 0)"
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

ID SQL for migrate_116_to_117.

◆ INSERT_PERMISSION

#define INSERT_PERMISSION (   name,
  role 
)
Value:
sql ("INSERT INTO permissions" \
" (uuid, owner, name, comment, resource_type, resource, resource_uuid," \
" resource_location, subject_type, subject, subject_location," \
" creation_time, modification_time)" \
" VALUES" \
" (make_uuid (), NULL, '" G_STRINGIFY (name) "', '', ''," \
" 0, '', " G_STRINGIFY (LOCATION_TABLE) ", 'role'," \
" (SELECT id FROM roles WHERE uuid = '%s')," \
" " G_STRINGIFY (LOCATION_TABLE) ", m_now (), m_now ());", \
role)
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:202

Permission SQL for migrate_150_to_151.

Parameters
[in]nameName.
[in]roleRole.

◆ MIGRATE_162_TO_163_CONTROL_DESCRIPTION

#define MIGRATE_162_TO_163_CONTROL_DESCRIPTION
Value:
"Dear IS Coordinator,\n" \
"\n" \
"A new scan has been carried out and the results are now available in Verinice.\n" \
"If responsible persons are linked to the asset groups, the tasks are already created.\n" \
"\n" \
"Please check the results in a timely manner.\n" \
"\n" \
"Best regards\n" \
"CIS"

Description for Verinice ISM report format.

◆ MIGRATE_55_TO_56_RANGE

#define MIGRATE_55_TO_56_RANGE (   type,
  start,
  end 
)
Value:
sql ("INSERT INTO port_ranges" \
" (uuid, port_list, type, start, \"end\", comment, exclude)" \
" VALUES" \
" (make_uuid (), %llu, %i," \
" '" G_STRINGIFY (start) "'," \
" '" G_STRINGIFY (end) "'," \
" '', 0)", \
list, \
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:202
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

Insert a port range.

◆ MIGRATE_79_to_80_DELETE

#define MIGRATE_79_to_80_DELETE (   table)
Value:
sql ("DELETE FROM " table \
" WHERE owner IN (SELECT id FROM users WHERE %s);", \
where)
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:202

Delete table for migrate_79_to_80.

◆ RESOURCE_TRASH [1/2]

#define RESOURCE_TRASH (   type)
Value:
" WHEN '" G_STRINGIFY (type) "' THEN" \
" (SELECT CASE WHEN " \
" (EXISTS (SELECT * FROM " G_STRINGIFY (type) "s_trash" \
" WHERE uuid = attach_id))" \
" THEN " G_STRINGIFY (LOCATION_TRASH) \
" ELSE " G_STRINGIFY (LOCATION_TABLE) " END)"
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

Trash SQL for migrate_116_to_117.

◆ RESOURCE_TRASH [2/2]

#define RESOURCE_TRASH (   type)
Value:
" WHEN '" G_STRINGIFY (type) "' THEN" \
" (SELECT CASE WHEN " \
" (EXISTS (SELECT * FROM " G_STRINGIFY (type) "s_trash" \
" WHERE uuid = resource_uuid))" \
" THEN " G_STRINGIFY (LOCATION_TRASH) \
" ELSE " G_STRINGIFY (LOCATION_TABLE) " END)"
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

Trash SQL for migrate_116_to_117.

◆ SQLITE_OR_NULL

#define SQLITE_OR_NULL (   function)    NULL

Conditional for database_migrators.

Expands to the given function only if the backend is SQLite3.

◆ UPDATE_CHART_SETTINGS

#define UPDATE_CHART_SETTINGS (   type,
  default,
  left_uuid,
  right_uuid 
)
Value:
sql ("INSERT INTO settings (owner, uuid, name, value)" \
" SELECT owner, '%s', 'Dummy', 'left-' || '%s' FROM settings" \
" WHERE uuid = '%s'" \
" AND NOT EXISTS (SELECT * FROM settings AS old_settings" \
" WHERE old_settings.uuid = '%s'" \
" AND old_settings.owner = settings.owner);", \
left_uuid, default, right_uuid, left_uuid); \
sql ("UPDATE settings" \
" SET name = '%s Top Dashboard Components'," \
" value = coalesce ((SELECT substr (old_settings.value, 6)" \
" FROM settings AS old_settings" \
" WHERE old_settings.uuid = '%s'" \
" AND old_settings.owner = settings.owner)," \
" '" default "')" \
" || '|'" \
" || coalesce ((SELECT substr (old_settings.value, 7)" \
" FROM settings AS old_settings" \
" WHERE old_settings.uuid = '%s'" \
" AND old_settings.owner = settings.owner),"\
" '" default "')" \
" WHERE uuid = '%s';", \
type, left_uuid, right_uuid, left_uuid); \
sql ("DELETE FROM settings" \
" WHERE uuid = '%s';", \
right_uuid);
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:202
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

Chart SQL for migrate_163_to_164.

Parameters
[in]typeType.
[in]defaultDefault
[in]left_uuidLeft UUID.
[in]right_uuidLeft UUID.

Function Documentation

◆ create_tables_version_4()

static void create_tables_version_4 ( )
static

Create all tables, using the version 4 schema.

Todo:
May be better ensure a ROLLBACK when functions like "sql" fail.

Currently the SQL functions abort on failure. This a general problem, not just for migrators, so perhaps the SQL interface should keep track of the transaction, and rollback before aborting.

Todo:
INTEGER

◆ insert_predefined()

static void insert_predefined ( const gchar *  uuid)
static

Mark a report format predefined.

Parameters
[in]uuidUUID of report format.

◆ manage_create_migrate_51_to_52_convert()

int manage_create_migrate_51_to_52_convert ( )

Dummy for SQLite3 compatibility.

Returns
0 success, -1 error.

Dummy for SQLite3 compatibility.

Returns
0 success, -1 error.

◆ manage_migrate()

int manage_migrate ( GSList *  log_config,
const gchar *  database 
)

Migrate database to version supported by this manager.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
Returns
0 success, 1 already on supported version, 2 too hard, 11 cannot migrate SCAP DB, 12 cannot migrate CERT DB, -1 error, -11 error running SCAP migration, -12 error running CERT migration.

◆ manage_migrate_needs_timezone()

gboolean manage_migrate_needs_timezone ( GSList *  log_config,
const gchar *  database 
)

Check whether the migration needs the real timezone.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
Returns
TRUE if yes, else FALSE.

◆ migrate_0_to_1()

int migrate_0_to_1 ( )

Migrate the database from version 0 to version 1.

Returns
0 success, -1 error.

◆ migrate_100_to_101()

int migrate_100_to_101 ( )

Migrate the database from version 100 to version 101.

Returns
0 success, -1 error.

◆ migrate_101_to_102()

int migrate_101_to_102 ( )

Migrate the database from version 101 to version 102.

Returns
0 success, -1 error.

◆ migrate_102_to_103()

int migrate_102_to_103 ( )

Migrate the database from version 102 to version 103.

Returns
0 success, -1 error.

◆ migrate_103_to_104()

int migrate_103_to_104 ( )

Migrate the database from version 103 to version 104.

Returns
0 success, -1 error.

◆ migrate_104_to_105()

int migrate_104_to_105 ( )

Migrate the database from version 104 to version 105.

Returns
0 success, -1 error.

◆ migrate_105_to_106()

int migrate_105_to_106 ( )

Migrate the database from version 105 to version 106.

Returns
0 success, -1 error.

◆ migrate_106_to_107()

int migrate_106_to_107 ( )

Migrate the database from version 106 to version 107.

Returns
0 success, -1 error.

◆ migrate_107_to_108()

int migrate_107_to_108 ( )

Migrate the database from version 107 to version 108.

Returns
0 success, -1 error.

◆ migrate_108_to_109()

int migrate_108_to_109 ( )

Migrate the database from version 108 to version 109.

Returns
0 success, -1 error.

◆ migrate_109_to_110()

int migrate_109_to_110 ( )

Migrate the database from version 109 to version 110.

Returns
0 success, -1 error.

◆ migrate_10_to_11()

int migrate_10_to_11 ( )

Migrate the database from version 10 to version 11.

Returns
0 success, -1 error.

◆ migrate_110_to_111()

int migrate_110_to_111 ( )

Migrate the database from version 110 to version 111.

Returns
0 success, -1 error.

◆ migrate_111_to_112()

int migrate_111_to_112 ( )

Migrate the database from version 111 to version 112.

Returns
0 success, -1 error.

◆ migrate_112_to_113()

int migrate_112_to_113 ( )

Migrate the database from version 112 to version 113.

Returns
0 success, -1 error.

◆ migrate_113_to_114()

int migrate_113_to_114 ( )

Migrate the database from version 113 to version 114.

Returns
0 success, -1 error.

◆ migrate_114_to_115()

int migrate_114_to_115 ( )

Migrate the database from version 114 to version 115.

Returns
0 success, -1 error.

◆ migrate_115_to_116()

int migrate_115_to_116 ( )

Migrate the database from version 115 to version 116.

Returns
0 success, -1 error.

◆ migrate_116_to_117()

int migrate_116_to_117 ( )

Migrate the database from version 116 to version 117.

Returns
0 success, -1 error.

◆ migrate_117_to_118()

int migrate_117_to_118 ( )

Migrate the database from version 117 to version 118.

Returns
0 success, -1 error.

◆ migrate_118_to_119()

int migrate_118_to_119 ( )

Migrate the database from version 118 to version 119.

Returns
0 success, -1 error.

◆ migrate_119_to_120()

int migrate_119_to_120 ( )

Migrate the database from version 119 to version 120.

Returns
0 success, -1 error.

◆ migrate_11_to_12()

int migrate_11_to_12 ( )

Migrate the database from version 11 to version 12.

Returns
0 success, -1 error.

◆ migrate_120_to_121()

int migrate_120_to_121 ( )

Migrate the database from version 120 to version 121.

Returns
0 success, -1 error.

◆ migrate_121_to_122()

int migrate_121_to_122 ( )

Migrate the database from version 121 to version 122.

Returns
0 success, -1 error.

◆ migrate_122_to_123()

int migrate_122_to_123 ( )

Migrate the database from version 122 to version 123.

Returns
0 success, -1 error.

◆ migrate_123_to_124()

int migrate_123_to_124 ( )

Migrate the database from version 123 to version 124.

Returns
0 success, -1 error.

◆ migrate_124_to_125()

int migrate_124_to_125 ( )

Migrate the database from version 124 to version 125.

Returns
0 success, -1 error.

◆ migrate_125_to_126()

int migrate_125_to_126 ( )

Migrate the database from version 125 to version 126.

Returns
0 success, -1 error.

◆ migrate_126_to_127()

int migrate_126_to_127 ( )

Migrate the database from version 126 to version 127.

Returns
0 success, -1 error.

◆ migrate_127_to_128()

int migrate_127_to_128 ( )

Migrate the database from version 127 to version 128.

Returns
0 success, -1 error.

◆ migrate_128_to_129()

int migrate_128_to_129 ( )

Migrate the database from version 128 to version 129.

Returns
0 success, -1 error.

◆ migrate_129_to_130()

int migrate_129_to_130 ( )

Migrate the database from version 129 to version 130.

Returns
0 success, -1 error.

◆ migrate_12_to_13()

int migrate_12_to_13 ( )

Migrate the database from version 12 to version 13.

Returns
0 success, -1 error.

◆ migrate_130_to_131()

int migrate_130_to_131 ( )

Migrate the database from version 130 to version 131.

Returns
0 success, -1 error.

◆ migrate_131_to_132()

int migrate_131_to_132 ( )

Migrate the database from version 131 to version 132.

Returns
0 success, -1 error.

◆ migrate_132_to_133()

int migrate_132_to_133 ( )

Migrate the database from version 132 to version 133.

Returns
0 success, -1 error.

◆ migrate_133_to_134()

int migrate_133_to_134 ( )

Migrate the database from version 133 to version 134.

Returns
0 success, -1 error.

◆ migrate_134_to_135()

int migrate_134_to_135 ( )

Migrate the database from version 134 to version 135.

Returns
0 success, -1 error.

◆ migrate_135_to_136()

int migrate_135_to_136 ( )

Migrate the database from version 135 to version 136.

Returns
0 success, -1 error.

◆ migrate_136_to_137()

int migrate_136_to_137 ( )

Migrate the database from version 136 to version 137.

Returns
0 success, -1 error.

◆ migrate_137_to_138()

int migrate_137_to_138 ( )

Migrate the database from version 137 to version 138.

Returns
0 success, -1 error.

◆ migrate_138_to_139()

int migrate_138_to_139 ( )

Migrate the database from version 138 to version 139.

Returns
0 success, -1 error.

◆ migrate_139_to_140()

int migrate_139_to_140 ( )

Migrate the database from version 139 to version 140.

Returns
0 success, -1 error.

◆ migrate_13_to_14()

int migrate_13_to_14 ( )

Migrate the database from version 13 to version 14.

Returns
0 success, -1 error.

◆ migrate_140_to_141()

int migrate_140_to_141 ( )

Migrate the database from version 140 to version 141.

Returns
0 success, -1 error.

◆ migrate_141_to_142()

int migrate_141_to_142 ( )

Migrate the database from version 141 to version 142.

Returns
0 success, -1 error.

◆ migrate_142_to_143()

int migrate_142_to_143 ( )

Migrate the database from version 142 to version 143.

Returns
0 success, -1 error.

◆ migrate_143_to_144()

int migrate_143_to_144 ( )

Migrate the database from version 143 to version 144.

Returns
0 success, -1 error.

◆ migrate_144_to_145()

int migrate_144_to_145 ( )

Migrate the database from version 144 to version 145.

Returns
0 success, -1 error.

◆ migrate_145_to_146()

int migrate_145_to_146 ( )

Migrate the database from version 145 to version 146.

Returns
0 success, -1 error.

◆ migrate_146_to_147()

int migrate_146_to_147 ( )

Migrate the database from version 146 to version 147.

Returns
0 success, -1 error.

◆ migrate_147_to_148()

int migrate_147_to_148 ( )

Migrate the database from version 147 to version 148.

Returns
0 success, -1 error.

◆ migrate_148_to_149()

int migrate_148_to_149 ( )

Migrate the database from version 148 to version 149.

Returns
0 success, -1 error.

◆ migrate_149_to_150()

int migrate_149_to_150 ( )

Migrate the database from version 149 to version 150.

Returns
0 success, -1 error.

◆ migrate_14_to_15()

int migrate_14_to_15 ( )

Migrate the database from version 14 to version 15.

Returns
0 success, -1 error.

◆ migrate_150_to_151()

int migrate_150_to_151 ( )

Migrate the database from version 150 to version 151.

Returns
0 success, -1 error.

◆ migrate_151_to_152()

int migrate_151_to_152 ( )

Migrate the database from version 151 to version 152.

Returns
0 success, -1 error.

◆ migrate_152_to_153()

int migrate_152_to_153 ( )

Migrate the database from version 152 to version 153.

Returns
0 success, -1 error.

◆ migrate_153_to_154()

int migrate_153_to_154 ( )

Migrate the database from version 152 to version 153.

Returns
0 success, -1 error.

◆ migrate_154_to_155()

int migrate_154_to_155 ( )

Migrate the database from version 154 to version 155.

Returns
0 success, -1 error.

◆ migrate_155_to_156()

int migrate_155_to_156 ( )

Migrate the database from version 155 to version 156.

Returns
0 success, -1 error.

◆ migrate_156_to_157()

int migrate_156_to_157 ( )

Migrate the database from version 156 to version 157.

Returns
0 success, -1 error.

◆ migrate_157_to_158()

int migrate_157_to_158 ( )

Migrate the database from version 157 to version 158.

Returns
0 success, -1 error.

◆ migrate_158_to_159()

int migrate_158_to_159 ( )

Migrate the database from version 158 to version 159.

Returns
0 success, -1 error.

◆ migrate_159_to_160()

int migrate_159_to_160 ( )

Migrate the database from version 159 to version 160.

Returns
0 success, -1 error.

◆ migrate_15_to_16()

int migrate_15_to_16 ( )

Migrate the database from version 15 to version 16.

Returns
0 success, -1 error.

◆ migrate_160_to_161()

int migrate_160_to_161 ( )

Migrate the database from version 160 to version 161.

Returns
0 success, -1 error.

◆ migrate_161_to_162()

int migrate_161_to_162 ( )

Migrate the database from version 161 to version 162.

Returns
0 success, -1 error.

◆ migrate_162_to_163()

int migrate_162_to_163 ( )

Migrate the database from version 158 to version 162.

Returns
0 success, -1 error.

◆ migrate_163_to_164()

int migrate_163_to_164 ( )

Migrate the database from version 163 to version 164.

Returns
0 success, -1 error.

◆ migrate_164_to_165()

int migrate_164_to_165 ( )

Migrate the database from version 163 to version 164.

Returns
0 success, -1 error.

◆ migrate_165_to_166()

int migrate_165_to_166 ( )

Migrate the database from version 165 to version 166.

Returns
0 success, -1 error.

◆ migrate_166_to_167()

int migrate_166_to_167 ( )

Migrate the database from version 166 to version 167.

Returns
0 success, -1 error.

◆ migrate_167_to_168()

int migrate_167_to_168 ( )

Migrate the database from version 167 to version 168.

Returns
0 success, -1 error.

◆ migrate_168_to_169()

int migrate_168_to_169 ( )

Migrate the database from version 168 to version 169.

Returns
0 success, -1 error.

◆ migrate_168_to_169_copy_target()

static void migrate_168_to_169_copy_target ( user_t  owner,
const gchar *  uuid,
target_t *  new 
)
static

Migrate the database from version 168 to version 169.

Parameters
[in]ownerTarget owner.
[in]uuidTarget UUID.
[out]newNew target.
Returns
0 success, -1 error.

◆ migrate_169_to_170()

int migrate_169_to_170 ( )

Migrate the database from version 169 to version 170.

Returns
0 success, -1 error.

◆ migrate_169_to_170_add_permission()

static void migrate_169_to_170_add_permission ( const gchar *  role,
const gchar *  permission 
)
static

Add permission to role.

Caller must ensure args are SQL escaped.

Parameters
[in]roleRole.
[in]permissionPermission.

◆ migrate_16_to_17()

int migrate_16_to_17 ( )

Migrate the database from version 16 to version 17.

Returns
0 success, -1 error.

◆ migrate_170_to_171()

int migrate_170_to_171 ( )

Migrate the database from version 170 to version 171.

Returns
0 success, -1 error.

◆ migrate_171_to_172()

int migrate_171_to_172 ( )

Migrate the database from version 171 to version 172.

Returns
0 success, -1 error.

◆ migrate_172_to_173()

int migrate_172_to_173 ( )

Migrate the database from version 172 to version 173.

Returns
0 success, -1 error.

◆ migrate_173_to_174()

int migrate_173_to_174 ( )

Migrate the database from version 173 to version 174.

Returns
0 success, -1 error.

◆ migrate_174_to_175()

int migrate_174_to_175 ( )

Migrate the database from version 174 to version 175.

Returns
0 success, -1 error.

◆ migrate_175_to_176()

int migrate_175_to_176 ( )

Migrate the database from version 175 to version 176.

Returns
0 success, -1 error.

◆ migrate_176_to_177()

int migrate_176_to_177 ( )

Migrate the database from version 176 to version 177.

Returns
0 success, -1 error.

◆ migrate_177_to_178()

int migrate_177_to_178 ( )

Migrate the database from version 177 to version 178.

Returns
0 success, -1 error.

◆ migrate_178_to_179()

int migrate_178_to_179 ( )

Migrate the database from version 178 to version 179.

Returns
0 success, -1 error.

◆ migrate_179_to_180()

int migrate_179_to_180 ( )

Migrate the database from version 179 to version 180.

Returns
0 success, -1 error.

◆ migrate_179_to_180_update_ref()

void migrate_179_to_180_update_ref ( const gchar *  table,
int  trash 
)

Update a reference for migrate_179_to_180.

Parameters
[in]tableTable.
[in]trashWhether to update from scanners_trash.
Returns
0 success, -1 error.

◆ migrate_17_to_18()

int migrate_17_to_18 ( )

Migrate the database from version 17 to version 18.

Returns
0 success, -1 error.

◆ migrate_17_to_18_set_pref()

void migrate_17_to_18_set_pref ( config_t  config)

Set the pref for migrate_17_to_18.

Parameters
[in]configConfig to set pref on.

◆ migrate_180_to_181()

int migrate_180_to_181 ( )

Migrate the database from version 180 to version 181.

Returns
0 success, -1 error.

◆ migrate_181_to_182()

int migrate_181_to_182 ( )

Migrate the database from version 181 to version 182.

Returns
0 success, -1 error.

◆ migrate_181_to_182_move()

int migrate_181_to_182_move ( const char *  dest)

Move signatures.

Parameters
[in]destDestination directory basename.
Returns
0 success, -1 error.

◆ migrate_182_to_183()

int migrate_182_to_183 ( )

Migrate the database from version 182 to version 183.

Returns
0 success, -1 error.

◆ migrate_183_to_184()

int migrate_183_to_184 ( )

Migrate the database from version 183 to version 184.

Returns
0 success, -1 error.

◆ migrate_184_to_185()

int migrate_184_to_185 ( )

Migrate the database from version 184 to version 185.

Returns
0 success, -1 error.

◆ migrate_185_to_186()

int migrate_185_to_186 ( )

Migrate the database from version 185 to version 186.

Returns
0 success, -1 error.

◆ migrate_186_to_187()

int migrate_186_to_187 ( )

Migrate the database from version 186 to version 187.

Returns
0 success, -1 error.

◆ migrate_187_to_188()

int migrate_187_to_188 ( )

Migrate the database from version 187 to version 188.

Returns
0 success, -1 error.

◆ migrate_188_to_189()

int migrate_188_to_189 ( )

Migrate the database from version 188 to version 189.

Returns
0 success, -1 error.

◆ migrate_189_to_190()

int migrate_189_to_190 ( )

Migrate the database from version 189 to version 190.

Returns
0 success, -1 error.

◆ migrate_18_to_19()

int migrate_18_to_19 ( )

Migrate the database from version 18 to version 19.

Returns
0 success, -1 error.

◆ migrate_190_to_191()

int migrate_190_to_191 ( )

Migrate the database from version 190 to version 191.

Returns
0 success, -1 error.

◆ migrate_191_to_192()

int migrate_191_to_192 ( )

Migrate the database from version 191 to version 192.

Returns
0 success, -1 error.

◆ migrate_192_to_193()

int migrate_192_to_193 ( )

Migrate the database from version 192 to version 193.

Returns
0 success, -1 error.

◆ migrate_193_to_194()

int migrate_193_to_194 ( )

Migrate the database from version 193 to version 194.

Returns
0 success, -1 error.

◆ migrate_194_to_195()

int migrate_194_to_195 ( )

Migrate the database from version 194 to version 195.

Returns
0 success, -1 error.

◆ migrate_195_to_196()

int migrate_195_to_196 ( )

Migrate the database from version 195 to version 196.

Returns
0 success, -1 error.

◆ migrate_196_to_197()

int migrate_196_to_197 ( )

Migrate the database from version 196 to version 197.

Returns
0 success, -1 error.

◆ migrate_197_to_198()

int migrate_197_to_198 ( )

Migrate the database from version 197 to version 198.

Returns
0 success, -1 error.

◆ migrate_198_to_199()

int migrate_198_to_199 ( )

Migrate the database from version 198 to version 199.

Returns
0 success, -1 error.

◆ migrate_199_to_200()

int migrate_199_to_200 ( )

Migrate the database from version 199 to version 200.

Returns
0 success, -1 error.

◆ migrate_19_to_20()

int migrate_19_to_20 ( )

Migrate the database from version 19 to version 20.

Returns
0 success, -1 error.

◆ migrate_1_to_2()

int migrate_1_to_2 ( )

Migrate the database from version 1 to version 2.

Returns
0 success, -1 error.

◆ migrate_200_to_201()

int migrate_200_to_201 ( )

Migrate the database from version 200 to version 201.

Returns
0 success, -1 error.

◆ migrate_201_to_202()

int migrate_201_to_202 ( )

Migrate the database from version 201 to version 202.

Returns
0 success, -1 error.

◆ migrate_202_to_203()

int migrate_202_to_203 ( )

Migrate the database from version 202 to version 203.

Returns
0 success, -1 error.

◆ migrate_203_to_204()

int migrate_203_to_204 ( )

Migrate the database from version 203 to version 204.

Returns
0 success, -1 error.

◆ migrate_204_to_205()

int migrate_204_to_205 ( )

Migrate the database from version 204 to version 205.

Returns
0 success, -1 error.

◆ migrate_20_to_21()

int migrate_20_to_21 ( )

Migrate the database from version 20 to version 21.

Returns
0 success, -1 error.

◆ migrate_21_to_22()

int migrate_21_to_22 ( )

Migrate the report formats from version 21 to version 22.

Returns
0 success, -1 error.

◆ migrate_22_to_23()

int migrate_22_to_23 ( )

Migrate the report formats from version 22 to version 23.

Returns
0 success, -1 error.

◆ migrate_23_to_24()

int migrate_23_to_24 ( )

Migrate the database from version 23 to version 24.

Returns
0 success, -1 error.

◆ migrate_24_to_25()

int migrate_24_to_25 ( )

Migrate the database from version 24 to version 25.

Returns
0 success, -1 error.

◆ migrate_25_to_26()

int migrate_25_to_26 ( )

Migrate the database from version 25 to version 26.

Returns
0 success, -1 error.

◆ migrate_26_to_27()

int migrate_26_to_27 ( )

Migrate the database from version 26 to version 27.

Returns
0 success, -1 error.

◆ migrate_27_to_28()

int migrate_27_to_28 ( )

Migrate the database from version 27 to version 28.

Returns
0 success, -1 error.

◆ migrate_28_to_29()

int migrate_28_to_29 ( )

Migrate the database from version 27 to version 28.

Returns
0 success, -1 error.

◆ migrate_29_to_30()

int migrate_29_to_30 ( )

Migrate the database from version 29 to version 30.

Returns
0 success, -1 error.

◆ migrate_2_to_3()

int migrate_2_to_3 ( )

Migrate the database from version 2 to version 3.

Returns
0 success, -1 error.

◆ migrate_30_to_31()

int migrate_30_to_31 ( )

Migrate the database from version 30 to version 31.

Returns
0 success, -1 error.

◆ migrate_31_to_32()

int migrate_31_to_32 ( )

Migrate the database from version 31 to version 32.

Returns
0 success, -1 error.

◆ migrate_32_to_33()

int migrate_32_to_33 ( )

Migrate the database from version 32 to version 33.

Returns
0 success, -1 error.

◆ migrate_33_to_34()

int migrate_33_to_34 ( )

Migrate the database from version 33 to version 34.

Returns
0 success, -1 error.

◆ migrate_33_to_34_set_pref()

void migrate_33_to_34_set_pref ( config_t  config)

Set the pref for migrate_33_to_34.

Parameters
[in]configConfig to set pref on.

◆ migrate_34_to_35()

int migrate_34_to_35 ( )

Migrate the database from version 34 to version 35.

Returns
0 success, -1 error.

◆ migrate_35_to_36()

int migrate_35_to_36 ( )

Migrate the database from version 35 to version 36.

Returns
0 success, -1 error.

◆ migrate_35_to_36_duplicate_target()

target_t migrate_35_to_36_duplicate_target ( target_t  target,
const char *  name 
)

Make a copy of a target.

Parameters
[in]targetTarget to copy.
[in]nameName for new target.
Returns
Address of matching character, else NULL.

◆ migrate_36_to_37()

int migrate_36_to_37 ( )

Migrate the database from version 36 to version 37.

Returns
0 success, -1 error.

◆ migrate_37_to_38()

int migrate_37_to_38 ( )

Migrate the database from version 37 to version 38.

Returns
0 success, -1 error.

◆ migrate_38_to_39()

int migrate_38_to_39 ( )

Migrate the database from version 38 to version 39.

Returns
0 success, -1 error.

◆ migrate_39_to_40()

int migrate_39_to_40 ( )

Migrate the database from version 39 to version 40.

Returns
0 success, -1 error.

◆ migrate_39_to_40_set_pref()

void migrate_39_to_40_set_pref ( config_t  config)

Set the pref for migrate_39_to_40.

Parameters
[in]configConfig to set pref on.

◆ migrate_3_to_4()

int migrate_3_to_4 ( )

Migrate the database from version 3 to version 4.

Returns
0 success, -1 error.

◆ migrate_40_to_41()

int migrate_40_to_41 ( )

Migrate the database from version 40 to version 41.

Returns
0 success, -1 error.

◆ migrate_41_to_42()

int migrate_41_to_42 ( )

Migrate the database from version 41 to version 42.

Returns
0 success, -1 error.

◆ migrate_42_to_43()

int migrate_42_to_43 ( )

Migrate the database from version 42 to version 43.

Returns
0 success, -1 error.

◆ migrate_43_to_44()

int migrate_43_to_44 ( )

Migrate the database from version 43 to version 44.

Returns
0 success, -1 error.

◆ migrate_44_to_45()

int migrate_44_to_45 ( )

Migrate the database from version 44 to version 45.

Returns
0 success, -1 error.

◆ migrate_45_to_46()

int migrate_45_to_46 ( )

Migrate the database from version 45 to version 46.

Returns
0 success, -1 error.

◆ migrate_46_to_47()

int migrate_46_to_47 ( )

Migrate the database from version 46 to version 47.

Returns
0 success, -1 error.

◆ migrate_47_to_48()

int migrate_47_to_48 ( )

Migrate the database from version 47 to version 48.

Returns
0 success, -1 error.

◆ migrate_48_to_49()

int migrate_48_to_49 ( )

Migrate the database from version 48 to version 49.

Returns
0 success, -1 error.

◆ migrate_49_to_50()

int migrate_49_to_50 ( )

Migrate the database from version 49 to version 50.

Returns
0 success, -1 error.

◆ migrate_4_to_5()

int migrate_4_to_5 ( )

Migrate the database from version 4 to version 5.

Returns
0 success, -1 error.

◆ migrate_50_to_51()

int migrate_50_to_51 ( )

Migrate the database from version 50 to version 51.

Returns
0 success, -1 error.

◆ migrate_51_to_52()

int migrate_51_to_52 ( )

Migrate the database from version 51 to version 52.

Returns
0 success, -1 error.

◆ migrate_52_to_53()

int migrate_52_to_53 ( )

Migrate the database from version 52 to version 53.

Returns
0 success, -1 error.

◆ migrate_53_to_54()

int migrate_53_to_54 ( )

Migrate the database from version 53 to version 54.

Returns
0 success, -1 error.

◆ migrate_54_to_55()

int migrate_54_to_55 ( )

Migrate the database from version 54 to version 55.

Returns
0 success, -1 error.

◆ migrate_54_to_55_format()

int migrate_54_to_55_format ( const char *  old_uuid,
const char *  new_uuid 
)

Migrate a report format from version 54 to version 55.

Parameters
[in]old_uuidOld UUID.
[in]new_uuidNew UUID.
Returns
0 success, -1 error.

◆ migrate_55_to_56()

int migrate_55_to_56 ( )

Migrate the database from version 55 to version 56.

Returns
0 success, -1 error.

◆ migrate_56_to_57()

int migrate_56_to_57 ( )

Migrate the database from version 56 to version 57.

Returns
0 success, -1 error.

◆ migrate_57_to_58()

int migrate_57_to_58 ( )

Migrate the database from version 57 to version 58.

Returns
0 success, -1 error.

◆ migrate_58_to_59()

int migrate_58_to_59 ( )

Migrate the database from version 58 to version 59.

Returns
0 success, -1 error.

◆ migrate_59_to_60()

int migrate_59_to_60 ( )

Migrate the database from version 59 to version 60.

Returns
0 success, -1 error.

◆ migrate_5_to_6()

int migrate_5_to_6 ( )

Migrate the database from version 5 to version 6.

Returns
0 success, -1 error.

◆ migrate_5_to_6_move_other_config()

void migrate_5_to_6_move_other_config ( const char *  predefined_config_name,
config_t  predefined_config_id 
)

Move a config that is using a predefined ID.

Parameters
[in]predefined_config_nameName of the predefined config.
[in]predefined_config_idRow ID of the predefined config.

◆ migrate_60_to_61()

int migrate_60_to_61 ( )

Migrate the database from version 60 to version 61.

Returns
0 success, -1 error.

◆ migrate_61_to_62()

int migrate_61_to_62 ( )

Migrate the database from version 61 to version 62.

Returns
0 success, -1 error.

◆ migrate_62_to_63()

int migrate_62_to_63 ( )

Migrate the database from version 62 to version 63.

Returns
0 success, -1 error.

◆ migrate_63_to_64()

int migrate_63_to_64 ( )

Migrate the database from version 63 to version 64.

Returns
0 success, -1 error.

◆ migrate_64_to_65()

int migrate_64_to_65 ( )

Migrate the database from version 64 to version 65.

Returns
0 success, -1 error.

◆ migrate_65_to_66()

int migrate_65_to_66 ( )

Migrate the database from version 65 to version 66.

Returns
0 success, -1 error.

◆ migrate_66_to_67()

int migrate_66_to_67 ( )

Migrate the database from version 66 to version 67.

Returns
0 success, -1 error.

◆ migrate_67_to_68()

int migrate_67_to_68 ( )

Migrate the database from version 67 to version 68.

Returns
0 success, -1 error.

◆ migrate_68_to_69()

int migrate_68_to_69 ( )

Migrate the database from version 68 to version 69.

Returns
0 success, -1 error.

◆ migrate_69_to_70()

int migrate_69_to_70 ( )

Migrate the database from version 69 to version 70.

Returns
0 success, -1 error.

◆ migrate_6_to_7()

int migrate_6_to_7 ( )

Migrate the database from version 6 to version 7.

Returns
0 success, -1 error.

◆ migrate_70_to_71()

int migrate_70_to_71 ( )

Migrate the database from version 70 to version 71.

Returns
0 success, -1 error.

◆ migrate_71_to_72()

int migrate_71_to_72 ( )

Migrate the database from version 71 to version 72.

Returns
0 success, -1 error.

◆ migrate_72_to_73()

int migrate_72_to_73 ( )

Migrate the database from version 72 to version 73.

Returns
0 success, -1 error.

◆ migrate_73_to_74()

int migrate_73_to_74 ( )

Migrate the database from version 73 to version 74.

Returns
0 success, -1 error.

◆ migrate_74_to_75()

int migrate_74_to_75 ( )

Migrate the database from version 74 to version 75.

Returns
0 success, -1 error.

◆ migrate_75_to_76()

int migrate_75_to_76 ( )

Migrate the database from version 75 to version 76.

Returns
0 success, -1 error.

◆ migrate_76_to_77()

int migrate_76_to_77 ( )

Migrate the database from version 76 to version 77.

Returns
0 success, -1 error.

◆ migrate_77_to_78()

int migrate_77_to_78 ( )

Migrate the database from version 77 to version 78.

Returns
0 success, -1 error.

◆ migrate_78_to_79()

int migrate_78_to_79 ( )

Migrate the database from version 78 to version 79.

Returns
0 success, -1 error.

◆ migrate_79_to_80()

int migrate_79_to_80 ( )

Migrate the database from version 79 to version 80.

Returns
0 success, -1 error.

◆ migrate_79_to_80_remove_users()

void migrate_79_to_80_remove_users ( const char *  where)

Delete users according to a condition.

Parameters
[in]whereWhere clause.

◆ migrate_79_to_80_user_access()

int migrate_79_to_80_user_access ( const gchar *  user_dir,
gchar **  hosts,
int *  hosts_allow 
)

Get access information for a user.

Parameters
[in]user_dirThe directory containing the user.
[out]hostsThe hosts the user is allowed/forbidden to scan.
[out]hosts_allow0 forbidden, 1 allowed, 2 all allowed, 3 custom.
Returns
0 success, -1 error.

◆ migrate_7_to_8()

int migrate_7_to_8 ( )

Migrate the database from version 7 to version 8.

Returns
0 success, -1 error.

◆ migrate_80_to_81()

int migrate_80_to_81 ( )

Migrate the database from version 80 to version 81.

Returns
0 success, -1 error.

◆ migrate_81_to_82()

int migrate_81_to_82 ( )

Migrate the database from version 81 to version 82.

Returns
0 success, -1 error.

◆ migrate_82_to_83()

int migrate_82_to_83 ( )

Migrate the database from version 82 to version 83.

Returns
0 success, -1 error.

◆ migrate_83_to_84()

int migrate_83_to_84 ( )

Migrate the database from version 83 to version 84.

Returns
0 success, -1 error.

◆ migrate_84_to_85()

int migrate_84_to_85 ( )

Migrate the database from version 84 to version 85.

Returns
0 success, -1 error.

◆ migrate_85_to_86()

int migrate_85_to_86 ( )

Migrate the database from version 85 to version 86.

Returns
0 success, -1 error.

◆ migrate_86_to_87()

int migrate_86_to_87 ( )

Migrate the database from version 86 to version 87.

Returns
0 success, -1 error.

◆ migrate_87_to_88()

int migrate_87_to_88 ( )

Migrate the database from version 87 to version 88.

Returns
0 success, -1 error.

◆ migrate_88_to_89()

int migrate_88_to_89 ( )

Migrate the database from version 88 to version 89.

Returns
0 success, -1 error.

◆ migrate_89_to_90()

int migrate_89_to_90 ( )

Migrate the database from version 89 to version 90.

Returns
0 success, -1 error.

◆ migrate_8_to_9()

int migrate_8_to_9 ( )

Migrate the database from version 8 to version 9.

Returns
0 success, -1 error.

◆ migrate_90_to_91()

int migrate_90_to_91 ( )

Migrate the database from version 90 to version 91.

Returns
0 success, -1 error.

◆ migrate_91_to_92()

int migrate_91_to_92 ( )

Migrate the database from version 91 to version 92.

Returns
0 success, -1 error.

◆ migrate_92_to_93()

int migrate_92_to_93 ( )

Migrate the database from version 92 to version 93.

Returns
0 success, -1 error.

◆ migrate_93_to_94()

int migrate_93_to_94 ( )

Migrate the database from version 93 to version 94.

Returns
0 success, -1 error.

◆ migrate_94_to_95()

int migrate_94_to_95 ( )

Migrate the database from version 94 to version 95.

Returns
0 success, -1 error.

◆ migrate_95_to_96()

int migrate_95_to_96 ( )

Migrate the database from version 95 to version 96.

Returns
0 success, -1 error.

◆ migrate_96_to_97()

int migrate_96_to_97 ( )

Migrate the database from version 96 to version 97.

Returns
0 success, -1 error.

◆ migrate_97_to_98()

int migrate_97_to_98 ( )

Migrate the database from version 97 to version 98.

Returns
0 success, -1 error.

◆ migrate_98_to_99()

int migrate_98_to_99 ( )

Migrate the database from version 98 to version 99.

Returns
0 success, -1 error.

◆ migrate_99_to_100()

int migrate_99_to_100 ( )

Migrate the database from version 99 to version 100.

Returns
0 success, -1 error.

◆ migrate_9_to_10()

int migrate_9_to_10 ( )

Migrate the database from version 9 to version 10.

Returns
0 success, -1 error.

◆ migrate_9_to_10_user_uuid()

gchar* migrate_9_to_10_user_uuid ( const char *  name)

Return the UUID of a user from the GVM user UUID file.

Parameters
[in]nameUser name.
Returns
UUID of given user if user exists, else NULL.

◆ migrate_is_available()

static int migrate_is_available ( int  old_version,
int  new_version 
)
static

Check whether a migration is available.

Parameters
[in]old_versionVersion to migrate from.
[in]new_versionVersion to migrate to.
Returns
1 yes, 0 no, -1 error.

◆ move()

static void move ( const gchar *  table,
const gchar *  old,
const gchar *  new 
)
static

Rename a column.

Parameters
[in]tableTable
[in]oldOld column.
[in]newNew column.