-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix users import during installation
* Fix users import * Refactor UsersFinishClient as a FinishClient * Add unit tests for UsersFinishClient
- Loading branch information
Showing
19 changed files
with
673 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Makefile | ||
Makefile.am | ||
Makefile.in | ||
aclocal.m4 | ||
autom4te.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# encoding: utf-8 | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2016 SUSE LLC | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as published by the | ||
# Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# ------------------------------------------------------------------------------ | ||
|
||
require "installation/finish_client" | ||
|
||
module Yast | ||
class UsersFinishClient < ::Installation::FinishClient | ||
include Logger | ||
|
||
def initialize | ||
textdomain "users" | ||
|
||
Yast.import "Users" | ||
Yast.import "UsersSimple" | ||
# setup_all_users() | ||
Yast.include self, "users/routines.rb" | ||
end | ||
|
||
# Write users | ||
# | ||
# It relies in different methods depending if it's running | ||
# during autoinst or in a regular installation. | ||
# | ||
# @see write_autoinst | ||
# @see write_install | ||
def write | ||
if Mode.autoinst | ||
write_autoinst | ||
else | ||
write_install | ||
end | ||
end | ||
|
||
protected | ||
|
||
# @see Implements ::Installation::FinishClient#modes | ||
def modes | ||
[:installation, :live_installation, :autoinst] | ||
end | ||
|
||
# @see Implements ::Installation::FinishClient#title | ||
def title | ||
_("Writing Users Configuration...") | ||
end | ||
|
||
# Write imported users during autoinstallation | ||
# | ||
# During installation, some package could add a new user, so we | ||
# need to read them again before writing. | ||
# | ||
# On the other hand, during autoupgrade no changes are performed. | ||
def write_autoinst | ||
# 1. Export users imported in inst_autosetup (and store them) | ||
Users.SetExportAll(false) | ||
saved = Users.Export | ||
log.info("Users to import: #{saved}") | ||
|
||
# 2. Read users and settings from the installed system | ||
# (bsc#965852, bsc#973639, bsc#974220 and bsc#971804) | ||
Users.Read | ||
|
||
# 3. Merge users from the system with new users from | ||
# AutoYaST profile (from step 1) | ||
Users.Import(saved) | ||
|
||
# 4. Write users | ||
Users.SetWriteOnly(true) | ||
@progress_orig = Progress.set(false) | ||
error = Users.Write | ||
log.error(error) unless error.empty? | ||
Progress.set(@progress_orig) | ||
end | ||
|
||
# Write root password a new users during regular installation | ||
def write_install | ||
# write the root password | ||
UsersSimple.Write | ||
# write new users (if any) | ||
Users.Write if setup_all_users | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Tests for users | ||
TESTS = \ | ||
users_finish_test.rb | ||
|
||
TEST_EXTENSIONS = .rb | ||
RB_LOG_COMPILER = rspec | ||
VERBOSE = 1 | ||
EXTRA_DIST = $(TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# useradd defaults file | ||
GROUP=100 | ||
HOME=/home | ||
INACTIVE=-1 | ||
EXPIRE= | ||
SHELL=/bin/bash | ||
SKEL=/etc/skel | ||
CREATE_MAIL_SPOOL=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
root:x:0: | ||
bin:x:1:daemon | ||
daemon:x:2: | ||
sys:x:3: | ||
tty:x:5: | ||
disk:x:6: | ||
lp:x:7: | ||
www:x:8: | ||
kmem:x:9: | ||
wheel:x:10: | ||
mail:x:12: | ||
news:x:13: | ||
uucp:x:14: | ||
shadow:x:15: | ||
dialout:x:16: | ||
audio:x:17: | ||
floppy:x:19: | ||
cdrom:x:20: | ||
console:x:21: | ||
utmp:x:22: | ||
public:x:32: | ||
video:x:33: | ||
games:x:40: | ||
xok:x:41: | ||
trusted:x:42: | ||
modem:x:43: | ||
ftp:x:49: | ||
lock:x:54: | ||
man:x:62: | ||
users:x:100: | ||
nobody:x:65533: | ||
nogroup:x:65534:nobody | ||
messagebus:x:499: | ||
sshd:x:498: | ||
tape:x:497: | ||
polkitd:x:496: | ||
nscd:x:495: |
Oops, something went wrong.