Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
e11508f8
Commit
e11508f8
authored
May 07, 2022
by
vvb2060
Committed by
John Wu
May 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respond deny when pkg name not found
parent
0772f6dc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
SuRequestHandler.kt
...ain/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt
+22
-23
No files found.
app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt
View file @
e11508f8
...
...
@@ -12,7 +12,6 @@ import com.topjohnwu.superuser.Shell
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
timber.log.Timber
import
java.io.Closeable
import
java.io.DataOutputStream
import
java.io.FileOutputStream
import
java.io.IOException
...
...
@@ -21,11 +20,10 @@ import java.util.concurrent.TimeUnit
class
SuRequestHandler
(
val
pm
:
PackageManager
,
private
val
policyDB
:
PolicyDao
)
:
Closeable
{
)
{
private
lateinit
var
output
:
DataOutputStream
lateinit
var
policy
:
SuPolicy
private
set
private
lateinit
var
policy
:
SuPolicy
lateinit
var
pkgInfo
:
PackageInfo
private
set
...
...
@@ -54,35 +52,36 @@ class SuRequestHandler(
return
true
}
overrid
e
fun
close
()
{
privat
e
fun
close
()
{
if
(
::
output
.
isInitialized
)
runCatching
{
output
.
close
()
}
}
private
class
SuRequestError
:
IOException
()
private
suspend
fun
init
(
intent
:
Intent
)
=
withContext
(
Dispatchers
.
IO
)
{
try
{
val
fifo
=
intent
.
getStringExtra
(
"fifo"
)
?:
throw
SuRequestError
()
val
uid
=
intent
.
getIntExtra
(
"uid"
,
-
1
).
also
{
if
(
it
<
0
)
throw
SuRequestError
()
}
val
fifo
=
intent
.
getStringExtra
(
"fifo"
)
?:
throw
IOException
(
"fifo == null"
)
output
=
DataOutputStream
(
FileOutputStream
(
fifo
))
val
uid
=
intent
.
getIntExtra
(
"uid"
,
-
1
)
if
(
uid
<=
0
)
{
throw
IOException
(
"uid == $uid"
)
}
policy
=
SuPolicy
(
uid
)
val
pid
=
intent
.
getIntExtra
(
"pid"
,
-
1
)
try
{
pkgInfo
=
pm
.
getPackageInfo
(
uid
,
pid
)
?:
PackageInfo
().
apply
{
val
name
=
pm
.
getNameForUid
(
uid
)
?:
throw
SuRequestError
()
val
name
=
pm
.
getNameForUid
(
uid
)
?:
throw
PackageManager
.
NameNotFoundException
()
// We only fill in sharedUserId and leave other fields uninitialized
sharedUserId
=
name
.
split
(
":"
)[
0
]
}
output
=
DataOutputStream
(
FileOutputStream
(
fifo
).
buffered
())
policy
=
SuPolicy
(
uid
)
true
}
catch
(
e
:
Exception
)
{
when
(
e
)
{
is
IOException
,
is
PackageManager
.
NameNotFoundException
->
{
return
@withContext
true
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
respond
(
SuPolicy
.
DENY
,
-
1
)
return
@withContext
false
}
}
catch
(
e
:
IOException
)
{
Timber
.
e
(
e
)
close
()
false
}
else
->
throw
e
// Unexpected error
}
return
@withContext
false
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment