Skip to content

Commit

Permalink
Merge pull request #205 from yast/keep_permissions
Browse files Browse the repository at this point in the history
Keep the original NCCCredentials file permissions (bsc#943568)
  • Loading branch information
lslezak committed Aug 28, 2015
2 parents 5a11a9a + b71b7ad commit 028d77e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Aug 28 10:31:56 UTC 2015 - lslezak@suse.cz

- Keep the original NCCCredentials file permissions when upgrading
from SLE11 (bsc#943568)
- 3.1.146

-------------------------------------------------------------------
Wed Aug 26 07:33:14 UTC 2015 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.1.145
Version: 3.1.146
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
7 changes: 6 additions & 1 deletion src/lib/registration/sw_mgmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

require "tmpdir"
require "fileutils"
require "shellwords"

require "registration/exceptions"
require "registration/helpers"
Expand Down Expand Up @@ -332,7 +333,11 @@ def self.copy_old_credentials_file(file)
new_file = SUSE::Connect::Credentials::GLOBAL_CREDENTIALS_FILE
log.info "Copying the old credentials from previous installation"
log.info "Copying #{file} to #{new_file}"
::FileUtils.cp(file, new_file)

# SMT uses extra ACL permissions, make sure they are kept in the copied file,
# (use "cp -a ", ::FileUtils.cp(..., preserve: true) cannot be used as it preserves only
# the traditional Unix file permissions, the extended ACLs are NOT copied!)
`cp -a #{Shellwords.escape(file)} #{Shellwords.escape(new_file)}`

credentials = SUSE::Connect::Credentials.read(new_file)
# note: SUSE::Connect::Credentials override #to_s, the password is filtered out
Expand Down
8 changes: 4 additions & 4 deletions test/sw_mgmt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@
expect(File).to receive(:exist?).with(File.join(root_dir, target_dir, "SCCcredentials"))
.and_return(false)

expect(FileUtils).to receive(:cp).with(File.join(root_dir, target_dir, "NCCcredentials"),
File.join(target_dir, "SCCcredentials"))
expect(subject).to receive(:`).with("cp -a " + File.join(root_dir, target_dir,
"NCCcredentials") + " " + File.join(target_dir, "SCCcredentials"))
expect(SUSE::Connect::Credentials).to receive(:read)

expect { subject.copy_old_credentials(root_dir) }.to_not raise_error
Expand All @@ -191,8 +191,8 @@
expect(File).to receive(:exist?).with(File.join(root_dir, target_dir, "SCCcredentials"))
.and_return(true)

expect(FileUtils).to receive(:cp).with(File.join(root_dir, target_dir, "SCCcredentials"),
File.join(target_dir, "SCCcredentials"))
expect(subject).to receive(:`).with("cp -a " + File.join(root_dir, target_dir,
"SCCcredentials") + " " + File.join(target_dir, "SCCcredentials"))
expect(SUSE::Connect::Credentials).to receive(:read)

expect { subject.copy_old_credentials(root_dir) }.to_not raise_error
Expand Down

0 comments on commit 028d77e

Please sign in to comment.