]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/pwdutils: use assert to check correct usage.
authorÉrico Nogueira <erico.erc@gmail.com>
Wed, 28 Jul 2021 02:58:26 +0000 (23:58 -0300)
committerÉrico Nogueira <erico.erc@gmail.com>
Thu, 29 Jul 2021 12:58:19 +0000 (09:58 -0300)
commit0a002b6179ec1ffededc4f7f8bdf3b9ee59788b9
treee0f5995f3e9267cca5f1256caad5750c035736c2
parent7f22751bd1fa6693dbe05872551c6f13f6371096
lib/pwdutils: use assert to check correct usage.

Since these functions are only used internally, we can make sure they
are being used correctly, and assert() helps in catching remaining
issues. Usage of each changed function has been reviewed:

For xgetpwnam:

- chsh(1) only calls it if a username has been set
- login(1) only calls it if username has been set and is not empty
- su(1) always initializes new_user to "root"
- unshare(1) calls get_user with optarg, so always set as well

For xgetgrnam:

- unshare(1) calls get_group with optarg

For xgetpwuid:

- chsh(1) passes a stack allocated struct for struct passwd

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
lib/pwdutils.c