Show context in polkit prompt
This commit is contained in:
@@ -44,6 +44,10 @@ Item {
|
|||||||
return PolkitModel.promptLooksFingerprint(text)
|
return PolkitModel.promptLooksFingerprint(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function authorizationLabel(message) {
|
||||||
|
return PolkitModel.authorizationLabel(message)
|
||||||
|
}
|
||||||
|
|
||||||
function loadPamConfig(raw) {
|
function loadPamConfig(raw) {
|
||||||
fingerprintFirst = PolkitModel.fingerprintFirstFromPamConfig(raw)
|
fingerprintFirst = PolkitModel.fingerprintFirstFromPamConfig(raw)
|
||||||
}
|
}
|
||||||
@@ -325,5 +329,29 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: Math.min(justificationText.implicitWidth + Style.space(24), panel.width - Style.gapsOut * 2)
|
||||||
|
height: Style.space(28)
|
||||||
|
anchors.horizontalCenter: card.horizontalCenter
|
||||||
|
anchors.bottom: card.top
|
||||||
|
anchors.bottomMargin: Style.space(10)
|
||||||
|
radius: root.cornerRadius
|
||||||
|
color: root.background
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: justificationText
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: Style.space(12)
|
||||||
|
anchors.rightMargin: Style.space(12)
|
||||||
|
text: root.authorizationLabel(root.currentMessage)
|
||||||
|
color: root.foreground
|
||||||
|
font.family: root.fontFamily
|
||||||
|
font.pixelSize: Style.font.bodySmall
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideMiddle
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,16 @@ function fingerprintFirstFromPamConfig(raw) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function authorizationLabel(message) {
|
||||||
|
var text = String(message || "")
|
||||||
|
var match = text.match(/^Authentication is (?:needed|required) to run [`']([^`']+)[`'] as /i)
|
||||||
|
return match ? "Authorize running '" + match[1] + "'" : text
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
promptLooksFingerprint: promptLooksFingerprint,
|
promptLooksFingerprint: promptLooksFingerprint,
|
||||||
fingerprintFirstFromPamConfig: fingerprintFirstFromPamConfig
|
fingerprintFirstFromPamConfig: fingerprintFirstFromPamConfig,
|
||||||
|
authorizationLabel: authorizationLabel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ assert(polkit.promptLooksFingerprint('Swipe your finger'), 'polkit detects finge
|
|||||||
assert(polkit.promptLooksFingerprint('fprintd verification'), 'polkit detects fprint prompts')
|
assert(polkit.promptLooksFingerprint('fprintd verification'), 'polkit detects fprint prompts')
|
||||||
assert(!polkit.promptLooksFingerprint('Password:'), 'polkit ignores password prompts')
|
assert(!polkit.promptLooksFingerprint('Password:'), 'polkit ignores password prompts')
|
||||||
|
|
||||||
|
assertEqual(
|
||||||
|
polkit.authorizationLabel("Authentication is needed to run `/usr/bin/true' as the super user"),
|
||||||
|
"Authorize running '/usr/bin/true'",
|
||||||
|
'polkit shortens the standard pkexec message'
|
||||||
|
)
|
||||||
|
assertEqual(
|
||||||
|
polkit.authorizationLabel('Authentication is required to change system settings'),
|
||||||
|
'Authentication is required to change system settings',
|
||||||
|
'polkit preserves custom authorization messages'
|
||||||
|
)
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
polkit.fingerprintFirstFromPamConfig(`
|
polkit.fingerprintFirstFromPamConfig(`
|
||||||
# comment
|
# comment
|
||||||
|
|||||||
Reference in New Issue
Block a user