Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7e9b0fd authored by Kevin Chyn's avatar Kevin Chyn
Browse files

setActiveGroup null, 0 length, unwritable dir should fail

with this change, VTS test needs to run in /data/system/
due to SELinux policy + Linux directory permissions

Test: run VTS tests and make sure they all pass
Fixes 37153318

Change-Id: Ib1f19ce7fc0d08ae2941aec5c08c5857c7a9f2fd
parent 5ed47334
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "BiometricsFingerprint.h"

#include <inttypes.h>
#include <unistd.h>

namespace android {
namespace hardware {
@@ -189,7 +190,12 @@ Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
        const hidl_string& storePath) {
    if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
        ALOGE("Bad path length: %zd", storePath.size());
        return RequestStatus::SYS_EINVAL;
    }
    if (access(storePath.c_str(), W_OK)) {
        return RequestStatus::SYS_EINVAL;
    }

    return ErrorFilter(mDevice->set_active_group(mDevice, gid,
                                                    storePath.c_str()));
}
+3 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ namespace {
static const uint32_t kTimeout = 3;
static const std::chrono::seconds kTimeoutInSeconds = std::chrono::seconds(kTimeout);
static const uint32_t kGroupId = 99;
static const std::string kTmpDir = "/data/local/tmp/";
static const std::string kTmpDir = "/data/system/";
static const uint32_t kIterations = 1000;

// Wait for a callback to occur (signaled by the given future) up to the
@@ -186,6 +186,8 @@ class FingerprintHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    ASSERT_FALSE(mService == nullptr);

    // Create an active group
    // FP service can only write to /data/system due to
    // SELinux Policy and Linux Dir Permissions
    Return<RequestStatus> res = mService->setActiveGroup(kGroupId, kTmpDir);
    ASSERT_EQ(RequestStatus::SYS_OK, static_cast<RequestStatus>(res));
  }