forked from rhinstaller/kickstart-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrootpw.ks.in
50 lines (37 loc) · 1.07 KB
/
rootpw.ks.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
url @KSTEST_URL@
install
network --bootproto=dhcp
bootloader --timeout=1
zerombr
clearpart --all --initlabel
autopart
keyboard us
lang en
timezone America/New_York
rootpw qweqwe
shutdown
# Something ought to pull in python for %post, but ask for it just in case
%packages
python3
%end
%post --interpreter=/usr/bin/python3
import sys
import crypt
with open("/root/RESULT", "w") as result:
# Test that the root password is what we expect it to be
with open("/etc/shadow", "r") as f:
for line in f:
if line.startswith("root:"):
shadow_fields = line.strip().split(":")
break
else:
print("Unable to find root password", file=result)
sys.exit(0)
if crypt.crypt("qweqwe", shadow_fields[1]) != shadow_fields[1]:
print("Root password is not correct: %s" % shadow_fields[1], file=result)
sys.exit(0)
if shadow_fields[2] != "":
print("Date of last password change is not empty: %s" % shadow_fields[2], file=result)
sys.exit(0)
print("SUCCESS", file=result)
%end