Files
kde-linux/mkosi.extra/usr/lib/fix-pamd
Nate Graham 79c829aae8 Move helper scripts from bin to lib
Also remove the _kde-linux prefix for the two scripts intentionally left
in bin.

Resolves #166
Resolves #391
2025-10-16 17:30:47 -06:00

30 lines
908 B
Python
Executable File

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
# SPDX-FileCopyrightText: 2025 Harald Sitter <sitter@kde.org>
import os
import sys
import hashlib
if not os.path.exists('/etc/pam.d'):
print('No pam.d configs found, nothing to do')
sys.exit(0)
sums = {
'/etc/pam.d/other': '73fa71815a900524c896d5594639f28d24e9f2ec987d2a7a6fde3989a6c94148',
'/etc/pam.d/sshd': '633e24cbfcb045ba777d3e06d5f85dfaa06d44f4727d38c7fb2187c57498221d',
'/etc/pam.d/system-auth': 'cb715cc234dffb914966cf143872f47a8ef177dfed336700dcea6fce40fe6643',
}
for file, sum in sums.items():
if not os.path.exists(file):
continue
print(f'Checking {file}')
with open(file, "rb") as f:
digest = hashlib.file_digest(f, "sha256").hexdigest()
if digest == sum:
print(f'File {file} is bad, removing')
os.remove(file)