45
45
m_lastActionWasInsert = false;
46
46
m_lastActionChangedDatabase = false;
49
50
int DatabaseAuthorizer::createTable(const String& tableName)
52
if (m_readOnly && m_securityEnabled)
51
55
m_lastActionChangedDatabase = true;
52
56
return denyBasedOnTableName(tableName);
55
59
int DatabaseAuthorizer::createTempTable(const String& tableName)
61
// SQLITE_CREATE_TEMP_TABLE results in a UPDATE operation, which is not
62
// allowed in read-only transactions or private browsing, so we might as
63
// well disallow SQLITE_CREATE_TEMP_TABLE in these cases
64
if (m_readOnly && m_securityEnabled)
57
67
return denyBasedOnTableName(tableName);
60
70
int DatabaseAuthorizer::dropTable(const String& tableName)
72
if (m_readOnly && m_securityEnabled)
62
75
return denyBasedOnTableName(tableName);
65
78
int DatabaseAuthorizer::dropTempTable(const String& tableName)
80
// SQLITE_DROP_TEMP_TABLE results in a DELETE operation, which is not
81
// allowed in read-only transactions or private browsing, so we might as
82
// well disallow SQLITE_DROP_TEMP_TABLE in these cases
83
if (m_readOnly && m_securityEnabled)
67
86
return denyBasedOnTableName(tableName);
70
89
int DatabaseAuthorizer::allowAlterTable(const String&, const String& tableName)
91
if (m_readOnly && m_securityEnabled)
72
94
m_lastActionChangedDatabase = true;
73
95
return denyBasedOnTableName(tableName);
76
98
int DatabaseAuthorizer::createIndex(const String&, const String& tableName)
100
if (m_readOnly && m_securityEnabled)
78
103
m_lastActionChangedDatabase = true;
79
104
return denyBasedOnTableName(tableName);
82
107
int DatabaseAuthorizer::createTempIndex(const String&, const String& tableName)
109
// SQLITE_CREATE_TEMP_INDEX should result in a UPDATE or INSERT operation,
110
// which is not allowed in read-only transactions or private browsing,
111
// so we might as well disallow SQLITE_CREATE_TEMP_INDEX in these cases
112
if (m_readOnly && m_securityEnabled)
84
115
return denyBasedOnTableName(tableName);
87
118
int DatabaseAuthorizer::dropIndex(const String&, const String& tableName)
120
if (m_readOnly && m_securityEnabled)
89
123
return denyBasedOnTableName(tableName);
92
126
int DatabaseAuthorizer::dropTempIndex(const String&, const String& tableName)
128
// SQLITE_DROP_TEMP_INDEX should result in a DELETE operation, which is
129
// not allowed in read-only transactions or private browsing, so we might
130
// as well disallow SQLITE_DROP_TEMP_INDEX in these cases
131
if (m_readOnly && m_securityEnabled)
94
134
return denyBasedOnTableName(tableName);
97
137
int DatabaseAuthorizer::createTrigger(const String&, const String& tableName)
139
if (m_readOnly && m_securityEnabled)
99
142
m_lastActionChangedDatabase = true;
100
143
return denyBasedOnTableName(tableName);
103
146
int DatabaseAuthorizer::createTempTrigger(const String&, const String& tableName)
148
// SQLITE_CREATE_TEMP_TRIGGER results in a INSERT operation, which is not
149
// allowed in read-only transactions or private browsing, so we might as
150
// well disallow SQLITE_CREATE_TEMP_TRIGGER in these cases
151
if (m_readOnly && m_securityEnabled)
105
154
return denyBasedOnTableName(tableName);
108
157
int DatabaseAuthorizer::dropTrigger(const String&, const String& tableName)
159
if (m_readOnly && m_securityEnabled)
110
162
return denyBasedOnTableName(tableName);
113
165
int DatabaseAuthorizer::dropTempTrigger(const String&, const String& tableName)
167
// SQLITE_DROP_TEMP_TRIGGER results in a DELETE operation, which is not
168
// allowed in read-only transactions or private browsing, so we might as
169
// well disallow SQLITE_DROP_TEMP_TRIGGER in these cases
170
if (m_readOnly && m_securityEnabled)
115
173
return denyBasedOnTableName(tableName);
176
int DatabaseAuthorizer::createView(const String&)
178
return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
181
int DatabaseAuthorizer::createTempView(const String&)
183
// SQLITE_CREATE_TEMP_VIEW results in a UPDATE operation, which is not
184
// allowed in read-only transactions or private browsing, so we might as
185
// well disallow SQLITE_CREATE_TEMP_VIEW in these cases
186
return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
189
int DatabaseAuthorizer::dropView(const String&)
191
return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
194
int DatabaseAuthorizer::dropTempView(const String&)
196
// SQLITE_DROP_TEMP_VIEW results in a DELETE operation, which is not
197
// allowed in read-only transactions or private browsing, so we might as
198
// well disallow SQLITE_DROP_TEMP_VIEW in these cases
199
return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
118
202
int DatabaseAuthorizer::createVTable(const String&, const String&)
204
if (m_readOnly && m_securityEnabled)
120
207
m_lastActionChangedDatabase = true;
121
208
return m_securityEnabled ? SQLAuthDeny : SQLAuthAllow;
124
211
int DatabaseAuthorizer::dropVTable(const String&, const String&)
213
if (m_readOnly && m_securityEnabled)
126
216
return m_securityEnabled ? SQLAuthDeny : SQLAuthAllow;
129
219
int DatabaseAuthorizer::allowDelete(const String& tableName)
221
if (m_readOnly && m_securityEnabled)
131
224
return denyBasedOnTableName(tableName);
134
227
int DatabaseAuthorizer::allowInsert(const String& tableName)
229
if (m_readOnly && m_securityEnabled)
136
232
m_lastActionChangedDatabase = true;
137
233
m_lastActionWasInsert = true;
138
234
return denyBasedOnTableName(tableName);