Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Ask when the added repository is unsigned (bsc#1009127) #230

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/clients/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,10 @@ def Write

success = success && Pkg.SourceRefreshNow(srcid)
end
end

# check if the new addded repo is signed
SourceManager.check_repo_signature(srcid) if added.include?(srcid)
end

success = success && KeyManager.Write

Expand Down
24 changes: 24 additions & 0 deletions src/modules/SourceManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

module Yast
class SourceManagerClass < Module
include Yast::Logger

def main
Yast.import "UI"
Yast.import "Pkg"
Expand Down Expand Up @@ -833,6 +835,28 @@ def InstInitSourceMoveDownloadArea
nil
end

# Check whether the repository is digitally signed, if not ask the user to
# really use it. If user does not agree the repository is deleted.
# The check is skipped when the signature checks are disabled (either via
# sysconfig or a boot parameter).
# @param [Integer] srcid Id of the new added repository to check
# @return [Boolean] true when the repository is signed or user confirmed
# using unsigned repository, false otherwise
def check_repo_signature(srcid)
return true unless SignatureCheckDialogs.CheckSignaturesInYaST

repo_data = Pkg.SourceGeneralData(srcid)
# explicitly check for nil here, true/false means the repo is signed
# and is valid/invalid, unsigned repositories are marked with nil
return true unless repo_data["valid_repo_signature"].nil?

return true if SignatureCheckDialogs.UseUnsignedItem(:repository, nil, nil, srcid)

log.info("Removing untrusted repository")
Pkg.SourceDelete(srcid)
false
end

publish :variable => :newSources, :type => "list <integer>"
publish :variable => :numSources, :type => "integer"
publish :variable => :sourceStates, :type => "list <integer>"
Expand Down