Skip to content

Commit

Permalink
clean up function mentioned in previous commit further
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian04 committed Aug 13, 2024
1 parent b23b0db commit 49017c1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ class CharacterDeviceManager private constructor(private val application: Applic
// Get selinux context for app
val commandResult = Shell.cmd("stat -c %C $appDataDirPath").exec()

val contextFromCommand = commandResult.out.joinToString(separator = "\n").trim()
var categories = contextFromCommand
val selinuxContextString = commandResult.out.joinToString(separator = "\n").trim()

// Get the part of the context that I need (categories) by grabbing everything after the last ':'
categories = categories.substring(categories.lastIndexOf(':') + 1)

Timber.d("context (before,after): (%s,%s)", contextFromCommand, categories)
val categories = selinuxContextString.substringAfterLast(':')

// If it hasn't changed, then the previous piece of code failed to get the substring
if (categories == contextFromCommand) {
if (categories == selinuxContextString) {
Timber.wtf("Failed to get app's selinux context")
}

Timber.d("context (before,after): (%s,%s)", selinuxContextString, categories)

return categories
}

Expand Down

0 comments on commit 49017c1

Please sign in to comment.