blob: 1a41bfd6fce5cf3bce5d7b65bac898b853b034a2 [file] [log] [blame]
Tom Cherryc3692b32017-08-10 12:22:44 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Vic Yang92c236e2019-05-28 15:58:35 -070017#pragma once
Tom Cherryc3692b32017-08-10 12:22:44 -070018
19namespace android {
20namespace init {
21
Paul Crowleyf831f102019-11-05 09:46:59 -080022// Initialize SELinux, then exec init to run in the init SELinux context.
Tom Cherry7bfea3d2018-11-06 14:12:05 -080023int SetupSelinux(char** argv);
Paul Crowleyf831f102019-11-05 09:46:59 -080024
25// Restore the proper security context to files and directories on ramdisk, and
26// those that were created before initial sepolicy load.
27// This must happen before /dev is populated by ueventd.
Tom Cherryc3692b32017-08-10 12:22:44 -070028void SelinuxRestoreContext();
29
Paul Crowleyf831f102019-11-05 09:46:59 -080030// Set up SELinux logging to be written to kmsg, to match init's logging.
Tom Cherryc3692b32017-08-10 12:22:44 -070031void SelinuxSetupKernelLogging();
Paul Crowleyf831f102019-11-05 09:46:59 -080032
33// Return the Android API level with which the vendor SEPolicy was compiled.
34// Used for version checks such as whether or not vendor_init should be used.
Tom Cherry40acb372018-08-01 13:41:12 -070035int SelinuxGetVendorAndroidVersion();
Tom Cherryc3692b32017-08-10 12:22:44 -070036
Mark Salyzyn44505ec2019-05-08 12:44:50 -070037static constexpr char kEnvSelinuxStartedAt[] = "SELINUX_STARTED_AT";
38
Tom Cherryc3692b32017-08-10 12:22:44 -070039} // namespace init
40} // namespace android