tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_file_perms.cpp (1211B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "storage_test_harness.h"
      8 #include "nsIFile.h"
      9 #include "prio.h"
     10 
     11 /**
     12 * This file tests that the file permissions of the sqlite files match what
     13 * we request they be
     14 */
     15 
     16 TEST(storage_file_perms, Test)
     17 {
     18  nsCOMPtr<mozIStorageConnection> db(getDatabase());
     19  nsCOMPtr<nsIFile> dbFile;
     20  do_check_success(db->GetDatabaseFile(getter_AddRefs(dbFile)));
     21 
     22  uint32_t perms = 0;
     23  do_check_success(dbFile->GetPermissions(&perms));
     24 
     25  // This reflexts the permissions defined by SQLITE_DEFAULT_FILE_PERMISSIONS in
     26  // third_party/sqlite3/src/Makefile.in and must be kept in sync with that
     27 #ifdef ANDROID
     28  do_check_true(perms == (PR_IRUSR | PR_IWUSR));
     29 #elif defined(XP_WIN)
     30  do_check_true(perms == (PR_IRUSR | PR_IWUSR | PR_IRGRP | PR_IWGRP | PR_IROTH |
     31                          PR_IWOTH));
     32 #else
     33  do_check_true(perms == (PR_IRUSR | PR_IWUSR | PR_IRGRP | PR_IROTH));
     34 #endif
     35 }