|
47 | 47 |
|
48 | 48 | #include "selinux.h" |
49 | 49 |
|
| 50 | +#include <android/api-level.h> |
50 | 51 | #include <fcntl.h> |
51 | 52 | #include <stdlib.h> |
52 | 53 | #include <sys/wait.h> |
@@ -470,29 +471,27 @@ void SelinuxSetupKernelLogging() { |
470 | 471 | selinux_set_callback(SELINUX_CB_LOG, cb); |
471 | 472 | } |
472 | 473 |
|
473 | | -// This function checks whether the sepolicy supports vendor init. |
474 | | -bool SelinuxHasVendorInit() { |
| 474 | +// This function returns the Android version with which the vendor SEPolicy was compiled. |
| 475 | +// It is used for version checks such as whether or not vendor_init should be used |
| 476 | +int SelinuxGetVendorAndroidVersion() { |
475 | 477 | if (!IsSplitPolicyDevice()) { |
476 | | - // If this device does not split sepolicy files, vendor_init will be available in the latest |
477 | | - // monolithic sepolicy file. |
478 | | - return true; |
| 478 | + // If this device does not split sepolicy files, it's not a Treble device and therefore, |
| 479 | + // we assume it's always on the latest platform. |
| 480 | + return __ANDROID_API_FUTURE__; |
479 | 481 | } |
480 | 482 |
|
481 | 483 | std::string version; |
482 | 484 | if (!GetVendorMappingVersion(&version)) { |
483 | | - // Return true as the default if we failed to load the vendor sepolicy version. |
484 | | - return true; |
| 485 | + LOG(FATAL) << "Could not read vendor SELinux version"; |
485 | 486 | } |
486 | 487 |
|
487 | 488 | int major_version; |
488 | 489 | std::string major_version_str(version, 0, version.find('.')); |
489 | 490 | if (!ParseInt(major_version_str, &major_version)) { |
490 | | - PLOG(ERROR) << "Failed to parse the vendor sepolicy major version " << major_version_str; |
491 | | - // Return true as the default if we failed to parse the major version. |
492 | | - return true; |
| 491 | + PLOG(FATAL) << "Failed to parse the vendor sepolicy major version " << major_version_str; |
493 | 492 | } |
494 | 493 |
|
495 | | - return major_version >= 28; |
| 494 | + return major_version; |
496 | 495 | } |
497 | 496 |
|
498 | 497 | // selinux_android_file_context_handle() takes on the order of 10+ms to run, so we want to cache |
|
0 commit comments