HomeClusterLabs Projects

API: libcrmservice: Change services_action_user() not-found return code
e47b019e3cffUnpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

API: libcrmservice: Change services_action_user() not-found return code

This is mostly a refactor commit that causes a small change to the
libcrmservice API. See final paragraph.

Create a new pcmk__lookup_user() to replace crm_user_lookup().

This new function calls getpwnam() instead of getpwnam_r(). Since
Pacemaker is single-threaded and doesn't need reentrancy for this call,
I can't think of any good reason why we ever needed getpwnam_r(). It
requires defining a struct passwd and allocating a buffer to copy its
string members into, which makes everything more complicated. getpwnam()
is basically equivalent but returns a pointer and sets errno. All we
need are the uid and gid members.

Most of this commit is actually changes to mocking and unit testing, and
having to remember how the expect and will_return stuff works, due to
using getpwnam() instead of getpwnam_r().

This changes the specific error return codes from services_action_user()
in some cases. The default "no match" return code, if no entry pointer
is returned and errno is 0, is now ENOENT. Previously it was EINVAL. I
think this is acceptable, even though it technically changes the API. We
never documented specific error codes. As long as a caller considers any
nonzero code to be an error, nothing changes. (I'm not sure if there's
any legitimate use case for an external caller to create or modify a
service action directly anyway.)

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Mar 24 2025, 2:24 AM
Parents
rP97d7e46c34d6: API: libcrmcommon: Deprecate pcmk_daemon_user()
Branches
Unknown
Tags
Unknown

Event Timeline