Chromium Code Reviews| Index: sql/connection.cc |
| diff --git a/sql/connection.cc b/sql/connection.cc |
| index ac8c0cd095b00ea666cb4c66a0fbce9b0e475984..ac898ea0818e048f877eb7be8f0a22f28b0485ca 100644 |
| --- a/sql/connection.cc |
| +++ b/sql/connection.cc |
| @@ -168,6 +168,7 @@ Connection::Connection() |
| page_size_(0), |
| cache_size_(0), |
| exclusive_locking_(false), |
| + restrict_to_user_(false), |
| transaction_nesting_(0), |
| needs_rollback_(false), |
| in_memory_(false), |
| @@ -728,6 +729,30 @@ bool Connection::OpenInternal(const std::string& file_name) { |
| return false; |
| } |
| + // TODO(shess): OS_WIN support? |
| +#if defined(OS_POSIX) |
|
Greg Billock
2013/07/15 23:26:06
Should this be treated as a DB version upgrade? Th
Scott Hess - ex-Googler
2013/07/16 18:08:13
Not sure what you mean. If it results in not bein
|
| + if (restrict_to_user_) { |
| + DCHECK_NE(file_name, std::string(":memory")); |
|
Jorge Lucangeli Obes
2013/07/11 23:00:43
Does ":memory" mean a memory-backed database?
Scott Hess - ex-Googler
2013/07/15 20:50:08
Yeah, sql::Connection has separate Open() and Open
|
| + base::FilePath file_path(file_name); |
| + int mode = 0; |
| + // TODO(shess): Arguably, failure to retrieve and change |
| + // permissions should be fatal if the file exists. |
| + if (file_util::GetPosixFilePermissions(file_path, &mode)) { |
| + mode &= file_util::FILE_PERMISSION_USER_MASK; |
|
Greg Billock
2013/07/15 23:26:06
do we need IXUSR?
How about just mode = ... ? We'
Scott Hess - ex-Googler
2013/07/16 18:08:13
I'm aiming for "Adjust what SQLite has done after
|
| + file_util::SetPosixFilePermissions(file_path, mode); |
| + |
| + // SQLite sets the permissions on these files from the main |
| + // database on create. Set them here in case they already exist |
| + // at this point. Failure to set these permissions should not |
| + // be fatal unless the file doesn't exist. |
| + base::FilePath journal_path(file_name + FILE_PATH_LITERAL("-journal")); |
| + base::FilePath wal_path(file_name + FILE_PATH_LITERAL("-wal")); |
| + file_util::SetPosixFilePermissions(journal_path, mode); |
|
Greg Billock
2013/07/15 23:26:06
Do we need the same "if Get { Set }" formulation h
Scott Hess - ex-Googler
2013/07/16 18:08:13
The SQLite code uses the main database permissions
|
| + file_util::SetPosixFilePermissions(wal_path, mode); |
| + } |
| + } |
| +#endif // defined(OS_POSIX) |
| + |
| // SQLite uses a lookaside buffer to improve performance of small mallocs. |
| // Chromium already depends on small mallocs being efficient, so we disable |
| // this to avoid the extra memory overhead. |