~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/storage/DatabaseAuthorizer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
{
45
45
    m_lastActionWasInsert = false;
46
46
    m_lastActionChangedDatabase = false;
 
47
    m_readOnly = false;
47
48
}
48
49
 
49
50
int DatabaseAuthorizer::createTable(const String& tableName)
50
51
{
 
52
    if (m_readOnly && m_securityEnabled)
 
53
        return SQLAuthDeny;
 
54
 
51
55
    m_lastActionChangedDatabase = true;
52
56
    return denyBasedOnTableName(tableName);
53
57
}
54
58
 
55
59
int DatabaseAuthorizer::createTempTable(const String& tableName)
56
60
{
 
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)
 
65
        return SQLAuthDeny;
 
66
 
57
67
    return denyBasedOnTableName(tableName);
58
68
}
59
69
 
60
70
int DatabaseAuthorizer::dropTable(const String& tableName)
61
71
{
 
72
    if (m_readOnly && m_securityEnabled)
 
73
        return SQLAuthDeny;
 
74
 
62
75
    return denyBasedOnTableName(tableName);
63
76
}
64
77
 
65
78
int DatabaseAuthorizer::dropTempTable(const String& tableName)
66
79
{
 
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)
 
84
        return SQLAuthDeny;
 
85
 
67
86
    return denyBasedOnTableName(tableName);
68
87
}
69
88
 
70
89
int DatabaseAuthorizer::allowAlterTable(const String&, const String& tableName)
71
90
{
 
91
    if (m_readOnly && m_securityEnabled)
 
92
        return SQLAuthDeny;
 
93
 
72
94
    m_lastActionChangedDatabase = true;
73
95
    return denyBasedOnTableName(tableName);
74
96
}
75
97
 
76
98
int DatabaseAuthorizer::createIndex(const String&, const String& tableName)
77
99
{
 
100
    if (m_readOnly && m_securityEnabled)
 
101
        return SQLAuthDeny;
 
102
 
78
103
    m_lastActionChangedDatabase = true;
79
104
    return denyBasedOnTableName(tableName);
80
105
}
81
106
 
82
107
int DatabaseAuthorizer::createTempIndex(const String&, const String& tableName)
83
108
{
 
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)
 
113
        return SQLAuthDeny;
 
114
 
84
115
    return denyBasedOnTableName(tableName);
85
116
}
86
117
 
87
118
int DatabaseAuthorizer::dropIndex(const String&, const String& tableName)
88
119
{
 
120
    if (m_readOnly && m_securityEnabled)
 
121
        return SQLAuthDeny;
 
122
 
89
123
    return denyBasedOnTableName(tableName);
90
124
}
91
125
 
92
126
int DatabaseAuthorizer::dropTempIndex(const String&, const String& tableName)
93
127
{
 
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)
 
132
        return SQLAuthDeny;
 
133
 
94
134
    return denyBasedOnTableName(tableName);
95
135
}
96
136
 
97
137
int DatabaseAuthorizer::createTrigger(const String&, const String& tableName)
98
138
{
 
139
    if (m_readOnly && m_securityEnabled)
 
140
        return SQLAuthDeny;
 
141
 
99
142
    m_lastActionChangedDatabase = true;
100
143
    return denyBasedOnTableName(tableName);
101
144
}
102
145
 
103
146
int DatabaseAuthorizer::createTempTrigger(const String&, const String& tableName)
104
147
{
 
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)
 
152
        return SQLAuthDeny;
 
153
 
105
154
    return denyBasedOnTableName(tableName);
106
155
}
107
156
 
108
157
int DatabaseAuthorizer::dropTrigger(const String&, const String& tableName)
109
158
{
 
159
    if (m_readOnly && m_securityEnabled)
 
160
        return SQLAuthDeny;
 
161
 
110
162
    return denyBasedOnTableName(tableName);
111
163
}
112
164
 
113
165
int DatabaseAuthorizer::dropTempTrigger(const String&, const String& tableName)
114
166
{
 
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)
 
171
        return SQLAuthDeny;
 
172
 
115
173
    return denyBasedOnTableName(tableName);
116
174
}
117
175
 
 
176
int DatabaseAuthorizer::createView(const String&)
 
177
{
 
178
    return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
 
179
}
 
180
 
 
181
int DatabaseAuthorizer::createTempView(const String&)
 
182
{
 
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);
 
187
}
 
188
 
 
189
int DatabaseAuthorizer::dropView(const String&)
 
190
{
 
191
    return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
 
192
}
 
193
 
 
194
int DatabaseAuthorizer::dropTempView(const String&)
 
195
{
 
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);
 
200
}
 
201
 
118
202
int DatabaseAuthorizer::createVTable(const String&, const String&)
119
203
{
 
204
    if (m_readOnly && m_securityEnabled)
 
205
        return SQLAuthDeny;
 
206
 
120
207
    m_lastActionChangedDatabase = true;
121
208
    return m_securityEnabled ? SQLAuthDeny : SQLAuthAllow;
122
209
}
123
210
 
124
211
int DatabaseAuthorizer::dropVTable(const String&, const String&)
125
212
{
 
213
    if (m_readOnly && m_securityEnabled)
 
214
        return SQLAuthDeny;
 
215
 
126
216
    return m_securityEnabled ? SQLAuthDeny : SQLAuthAllow;
127
217
}
128
218
 
129
219
int DatabaseAuthorizer::allowDelete(const String& tableName)
130
220
{
 
221
    if (m_readOnly && m_securityEnabled)
 
222
        return SQLAuthDeny;
 
223
 
131
224
    return denyBasedOnTableName(tableName);
132
225
}
133
226
 
134
227
int DatabaseAuthorizer::allowInsert(const String& tableName)
135
228
{
 
229
    if (m_readOnly && m_securityEnabled)
 
230
        return SQLAuthDeny;
 
231
 
136
232
    m_lastActionChangedDatabase = true;
137
233
    m_lastActionWasInsert = true;
138
234
    return denyBasedOnTableName(tableName);
140
236
 
141
237
int DatabaseAuthorizer::allowUpdate(const String& tableName, const String&)
142
238
{
 
239
    if (m_readOnly && m_securityEnabled)
 
240
        return SQLAuthDeny;
 
241
 
143
242
    m_lastActionChangedDatabase = true;
144
243
    return denyBasedOnTableName(tableName);
145
244
}
154
253
    return denyBasedOnTableName(tableName);
155
254
}
156
255
 
 
256
int DatabaseAuthorizer::allowReindex(const String&)
 
257
{
 
258
    return (m_readOnly && m_securityEnabled ? SQLAuthDeny : SQLAuthAllow);
 
259
}
 
260
 
157
261
int DatabaseAuthorizer::allowAnalyze(const String& tableName)
158
262
{
159
263
    return denyBasedOnTableName(tableName);
192
296
    m_securityEnabled = true;
193
297
}
194
298
 
 
299
void DatabaseAuthorizer::setReadOnly()
 
300
{
 
301
    m_readOnly = true;
 
302
}
 
303
 
195
304
int DatabaseAuthorizer::denyBasedOnTableName(const String& tableName)
196
305
{
197
306
    if (!m_securityEnabled)