xref: /aosp_15_r20/system/vold/VoldNativeServiceValidation.h (revision f40fafd4c6c2594924d919feffc1a1fd6e3b30f3)
1*f40fafd4SAndroid Build Coastguard Worker /*
2*f40fafd4SAndroid Build Coastguard Worker  * Copyright (C) 2020 The Android Open Source Project
3*f40fafd4SAndroid Build Coastguard Worker  *
4*f40fafd4SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*f40fafd4SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*f40fafd4SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*f40fafd4SAndroid Build Coastguard Worker  *
8*f40fafd4SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*f40fafd4SAndroid Build Coastguard Worker  *
10*f40fafd4SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*f40fafd4SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*f40fafd4SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*f40fafd4SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*f40fafd4SAndroid Build Coastguard Worker  * limitations under the License.
15*f40fafd4SAndroid Build Coastguard Worker  */
16*f40fafd4SAndroid Build Coastguard Worker 
17*f40fafd4SAndroid Build Coastguard Worker #pragma once
18*f40fafd4SAndroid Build Coastguard Worker 
19*f40fafd4SAndroid Build Coastguard Worker #include <binder/Status.h>
20*f40fafd4SAndroid Build Coastguard Worker 
21*f40fafd4SAndroid Build Coastguard Worker #include <string>
22*f40fafd4SAndroid Build Coastguard Worker 
23*f40fafd4SAndroid Build Coastguard Worker #include <stdint.h>
24*f40fafd4SAndroid Build Coastguard Worker #include <sys/types.h>
25*f40fafd4SAndroid Build Coastguard Worker 
26*f40fafd4SAndroid Build Coastguard Worker namespace android::vold {
27*f40fafd4SAndroid Build Coastguard Worker 
28*f40fafd4SAndroid Build Coastguard Worker binder::Status Ok();
29*f40fafd4SAndroid Build Coastguard Worker binder::Status Exception(uint32_t code, const std::string& msg);
30*f40fafd4SAndroid Build Coastguard Worker 
31*f40fafd4SAndroid Build Coastguard Worker binder::Status CheckPermission(const char* permission);
32*f40fafd4SAndroid Build Coastguard Worker binder::Status CheckUidOrRoot(uid_t expectedUid);
33*f40fafd4SAndroid Build Coastguard Worker binder::Status CheckArgumentId(const std::string& id);
34*f40fafd4SAndroid Build Coastguard Worker binder::Status CheckArgumentPath(const std::string& path);
35*f40fafd4SAndroid Build Coastguard Worker binder::Status CheckArgumentHex(const std::string& hex);
36*f40fafd4SAndroid Build Coastguard Worker 
37*f40fafd4SAndroid Build Coastguard Worker // Incremental service is only allowed to touch its own directory, and the installed apps dir.
38*f40fafd4SAndroid Build Coastguard Worker // This function ensures the caller isn't doing anything tricky.
39*f40fafd4SAndroid Build Coastguard Worker enum class IncrementalPathKind { MountSource, MountTarget, Bind, Any };
40*f40fafd4SAndroid Build Coastguard Worker binder::Status CheckIncrementalPath(IncrementalPathKind kind, const std::string& path);
41*f40fafd4SAndroid Build Coastguard Worker 
42*f40fafd4SAndroid Build Coastguard Worker }  // namespace android::vold
43