mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
Both aarch64 and s390x have a bigger wtmp record size (16 bytes more than x86_64, 400 bytes total). The byte position of the timestamp is also different on each architecture. To make things even more interesting, s390x is big endian. Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1181155
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
#! /usr/bin/python3
|
|
# ------------------------------------------------------------------
|
|
#
|
|
# Copyright (C) 2021 Christian Boltz <apparmor@cboltz.de>
|
|
#
|
|
# 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 published by the Free Software Foundation.
|
|
#
|
|
# ------------------------------------------------------------------
|
|
|
|
import unittest
|
|
from common_test import AATest, setup_all_loops
|
|
|
|
from apparmor.notify import get_last_login_timestamp
|
|
|
|
class TestGet_last_login_timestamp(AATest):
|
|
tests = [
|
|
(['wtmp-x86_64', 'root' ], 1635070346), # Sun Oct 24 12:12:26 CEST 2021
|
|
(['wtmp-x86_64', 'whoever' ], 0),
|
|
(['wtmp-s390x', 'root' ], 1626368763), # Thu Jul 15 19:06:03 CEST 2021
|
|
(['wtmp-s390x', 'linux1' ], 1626368772), # Thu Jul 15 19:06:12 CEST 2021
|
|
(['wtmp-s390x', 'whoever' ], 0),
|
|
(['wtmp-aarch64', 'guillaume' ], 1611562789), # Mon Jan 25 09:19:49 CET 2021
|
|
(['wtmp-aarch64', 'whoever' ], 0),
|
|
]
|
|
|
|
def _run_test(self, params, expected):
|
|
filename, user = params
|
|
filename = 'wtmp-examples/%s' % filename
|
|
self.assertEqual(get_last_login_timestamp(user, filename), expected)
|
|
|
|
|
|
setup_all_loops(__name__)
|
|
if __name__ == '__main__':
|
|
unittest.main(verbosity=1)
|