File system-user-root.spec of Package system-user-root.11304

# spec file for package system-user-root
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           system-user-root
Version:        20190513
Release:        0
Summary:        System user and group root
License:        MIT
Group:          System/Fhs
Source1:        system-user-root.conf
BuildArch:      noarch
Provides:       group(root)
Provides:       group(shadow)
Provides:       group(trusted)
Provides:       group(users)
Provides:       user(root)
#!BuildIgnore: group(root)
#!BuildIgnore: group(trusted)
#!BuildIgnore: user(root)

This package provides the root account including the groups root,
shadow and users.

%setup -q -c -T


mkdir -p %{buildroot}%{_sysusersdir}
install -m 644 %{SOURCE1} %{buildroot}%{_sysusersdir}/system-user-root.conf

%pre -p <lua>
if not posix.access("/etc", "f") then
if not posix.access("/etc/passwd", "f") then
  file ="/etc/passwd", "a+")
  posix.chmod("/etc/passwd", 0644)
if not posix.access("/etc/group", "f") then
  file ="/etc/group", "a+")
  posix.chmod("/etc/group", 0644)
if not posix.access("/etc/shadow", "f") then
  file ="/etc/shadow", "a+")
  local date = os.time()
  date = math.floor(date / 86400)
  file:write("root:*:", date, "::::::\n")
  posix.chown("/etc/shadow", 0, 15)
  posix.chmod("/etc/shadow", 0640)