From 80b45dcc28aeba462ee3f87727bbb1d9c426acb5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 16 Jan 2022 15:15:09 -0600 Subject: [PATCH] Cleanup: Rename f_account functions in attempt to be easier to read. I originally tried to group the logic by "name" and "id". This becomes confusing when there is "group name" and "user name" or "group id" and "user id". The function name with the structure "f_account_id_group_by_name" is intended to be understood as get id of group by name for account. However, because account is in front (part of f_account) it could be easily misread as get account id by name with some spurious "group" injected. This is clearly a bad interpretation but that interpretation is easy to think of. Drop "user" because "account" and "user" should be synonymous. Move "group" to the left in all cases to designate that this is about "group" associated with account. Now f_account_group_id_by_name sounds more like get id of group by name for account. --- level_0/f_account/c/account.c | 124 ++++++++++----------- level_0/f_account/c/account.h | 78 ++++++------- level_0/f_account/data/build/settings-tests | 2 +- ...p_by_name.c => test-account-group_id_by_name.c} | 18 +-- ...p_by_name.h => test-account-group_id_by_name.h} | 16 +-- ...oup_by_id.c => test-account-group_name_by_id.c} | 18 +-- ...oup_by_id.h => test-account-group_name_by_id.h} | 16 +-- ...id_user_by_name.c => test-account-id_by_name.c} | 18 +-- ...id_user_by_name.h => test-account-id_by_name.h} | 16 +-- ...name_user_by_id.c => test-account-name_by_id.c} | 18 +-- ...name_user_by_id.h => test-account-name_by_id.h} | 16 +-- level_0/f_account/tests/c/test-account.c | 32 +++--- level_0/f_account/tests/c/test-account.h | 8 +- .../controller/c/controller/private-controller.c | 4 +- .../controller/c/controller/private-controller.h | 8 +- level_3/controller/c/rule/private-rule.c | 2 +- level_3/fake/c/private-make.c | 8 +- 17 files changed, 201 insertions(+), 201 deletions(-) rename level_0/f_account/tests/c/{test-account-id_group_by_name.c => test-account-group_id_by_name.c} (77%) rename level_0/f_account/tests/c/{test-account-id_group_by_name.h => test-account-group_id_by_name.h} (59%) rename level_0/f_account/tests/c/{test-account-name_group_by_id.c => test-account-group_name_by_id.c} (78%) rename level_0/f_account/tests/c/{test-account-name_group_by_id.h => test-account-group_name_by_id.h} (59%) rename level_0/f_account/tests/c/{test-account-id_user_by_name.c => test-account-id_by_name.c} (75%) rename level_0/f_account/tests/c/{test-account-id_user_by_name.h => test-account-id_by_name.h} (56%) rename level_0/f_account/tests/c/{test-account-name_user_by_id.c => test-account-name_by_id.c} (78%) rename level_0/f_account/tests/c/{test-account-name_user_by_id.h => test-account-name_by_id.h} (56%) diff --git a/level_0/f_account/c/account.c b/level_0/f_account/c/account.c index c51c1f3..5088951 100644 --- a/level_0/f_account/c/account.c +++ b/level_0/f_account/c/account.c @@ -5,8 +5,8 @@ extern "C" { #endif -#ifndef _di_f_account_by_name_ - f_status_t f_account_by_name(const f_string_t name, f_account_t *account) { +#ifndef _di_f_account_by_id_ + f_status_t f_account_by_id(const uid_t id, f_account_t *account) { #ifndef _di_level_0_parameter_checking_ if (!account) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -32,11 +32,11 @@ extern "C" { length = F_account_pwd_length_fallback_first_d; } - // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r(). + // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r(). errno = 0; char buffer[length]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getpwuid_r(id, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -65,7 +65,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getpwuid_r(id, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -84,10 +84,10 @@ extern "C" { return private_f_account_from_passwd(password, length, account); } -#endif // _di_f_account_by_name_ +#endif // _di_f_account_by_id_ -#ifndef _di_f_account_by_id_ - f_status_t f_account_by_id(const uid_t id, f_account_t *account) { +#ifndef _di_f_account_by_name_ + f_status_t f_account_by_name(const f_string_t name, f_account_t *account) { #ifndef _di_level_0_parameter_checking_ if (!account) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -113,11 +113,11 @@ extern "C" { length = F_account_pwd_length_fallback_first_d; } - // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r(). + // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r(). errno = 0; char buffer[length]; - const int result = getpwuid_r(id, &password, buffer, length, &pointer); + const int result = getpwnam_r(name, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -146,7 +146,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getpwuid_r(id, &password, buffer, length, &pointer); + const int result = getpwnam_r(name, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -165,10 +165,10 @@ extern "C" { return private_f_account_from_passwd(password, length, account); } -#endif // _di_f_account_by_id_ +#endif // _di_f_account_by_name_ -#ifndef _di_f_account_id_group_by_name_ - f_status_t f_account_id_group_by_name(const f_string_t name, gid_t *id) { +#ifndef _di_f_account_group_id_by_name_ + f_status_t f_account_group_id_by_name(const f_string_t name, gid_t *id) { #ifndef _di_level_0_parameter_checking_ if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -242,32 +242,36 @@ extern "C" { return F_none; } -#endif // _di_f_account_id_group_by_name_ +#endif // _di_f_account_group_id_by_name_ -#ifndef _di_f_account_id_user_by_name_ - f_status_t f_account_id_user_by_name(const f_string_t name, uid_t *id) { +#ifndef _di_f_account_group_name_by_id_ + f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t *name) { #ifndef _di_level_0_parameter_checking_ - if (!id) return F_status_set_error(F_parameter); + if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + name->used = 0; + + f_status_t status = F_none; + const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX); // Pointer seems pointless except that it is used to determine if the name was found. - struct passwd password; - struct passwd *pointer = 0; + struct group group_data; + struct group *pointer = 0; - size_t length = length_max; + size_t length = length_max + 1; { if (length == -1) { length = F_account_pwd_length_fallback_first_d; } - // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r(). + // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r(). errno = 0; char buffer[length]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getgrgid_r(id, &group_data, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -288,7 +292,15 @@ extern "C" { return F_exist_not; } - *id = password.pw_uid; + const f_array_length_t name_length = strnlen(group_data.gr_name, length); + + macro_f_string_dynamic_t_resize(status, (*name), name_length + 1); + if (F_status_is_error(status)) return status; + + memcpy(name->string, group_data.gr_name, name_length); + + name->string[name_length] = 0; + name->used = name_length; return F_none; } @@ -298,7 +310,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getpwnam_r(name, &password, buffer, length, &pointer); + const int result = getgrgid_r(id, &group_data, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -315,40 +327,44 @@ extern "C" { return F_exist_not; } - *id = password.pw_uid; + const f_array_length_t name_length = strnlen(group_data.gr_name, length); + + macro_f_string_dynamic_t_resize(status, (*name), name_length + 1); + if (F_status_is_error(status)) return status; + + memcpy(name->string, group_data.gr_name, name_length); + + name->string[name_length] = 0; + name->used = name_length; return F_none; } -#endif // _di_f_account_id_user_by_name_ +#endif // _di_f_account_group_name_by_id_ -#ifndef _di_f_account_name_group_by_id_ - f_status_t f_account_name_group_by_id(const gid_t id, f_string_dynamic_t *name) { +#ifndef _di_f_account_id_by_name_ + f_status_t f_account_id_by_name(const f_string_t name, uid_t *id) { #ifndef _di_level_0_parameter_checking_ - if (!name) return F_status_set_error(F_parameter); + if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - name->used = 0; - - f_status_t status = F_none; - const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX); // Pointer seems pointless except that it is used to determine if the name was found. - struct group group_data; - struct group *pointer = 0; + struct passwd password; + struct passwd *pointer = 0; - size_t length = length_max + 1; + size_t length = length_max; { if (length == -1) { length = F_account_pwd_length_fallback_first_d; } - // Must be set to 0 to avoid problems due to the design of getpwuid()/getpwuid_r(). + // Must be set to 0 to avoid problems due to the design of getpwnam()/getpwnam_r(). errno = 0; char buffer[length]; - const int result = getgrgid_r(id, &group_data, buffer, length, &pointer); + const int result = getpwnam_r(name, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -369,15 +385,7 @@ extern "C" { return F_exist_not; } - const f_array_length_t name_length = strnlen(group_data.gr_name, length); - - macro_f_string_dynamic_t_resize(status, (*name), name_length + 1); - if (F_status_is_error(status)) return status; - - memcpy(name->string, group_data.gr_name, name_length); - - name->string[name_length] = 0; - name->used = name_length; + *id = password.pw_uid; return F_none; } @@ -387,7 +395,7 @@ extern "C" { char buffer[F_account_pwd_length_fallback_second_d]; - const int result = getgrgid_r(id, &group_data, buffer, length, &pointer); + const int result = getpwnam_r(name, &password, buffer, length, &pointer); if (result) { if (errno == EINTR) return F_status_set_error(F_interrupt); @@ -404,22 +412,14 @@ extern "C" { return F_exist_not; } - const f_array_length_t name_length = strnlen(group_data.gr_name, length); - - macro_f_string_dynamic_t_resize(status, (*name), name_length + 1); - if (F_status_is_error(status)) return status; - - memcpy(name->string, group_data.gr_name, name_length); - - name->string[name_length] = 0; - name->used = name_length; + *id = password.pw_uid; return F_none; } -#endif // _di_f_account_name_group_by_id_ +#endif // _di_f_account_id_by_name_ -#ifndef _di_f_account_name_user_by_id_ - f_status_t f_account_name_user_by_id(const uid_t id, f_string_dynamic_t *name) { +#ifndef _di_f_account_name_by_id_ + f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t *name) { #ifndef _di_level_0_parameter_checking_ if (!name) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -513,7 +513,7 @@ extern "C" { return F_none; } -#endif // _di_f_account_name_user_by_id_ +#endif // _di_f_account_name_by_id_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_account/c/account.h b/level_0/f_account/c/account.h index 9b553ae..bb9770c 100644 --- a/level_0/f_account/c/account.h +++ b/level_0/f_account/c/account.h @@ -33,11 +33,10 @@ extern "C" { #endif /** - * Get the user account by the user name. + * Get the user account by the user id. * - * @param name - * The user name. - * The name must be NULL terminated. + * @param id + * The id of the user. * @param account * This is replaced with by the account information. * All strings will be NULL terminated. @@ -54,17 +53,18 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_failure (with error bit) on any other error. * - * @see getpwnam_r() + * @see getpwuid_r() */ -#ifndef _di_f_account_by_name_ - extern f_status_t f_account_by_name(const f_string_t name, f_account_t *account); -#endif // _di_f_account_by_name_ +#ifndef _di_f_account_by_id_ + extern f_status_t f_account_by_id(const uid_t id, f_account_t *account); +#endif // _di_f_account_by_id_ /** - * Get the user account by the user id. + * Get the user account by the user name. * - * @param id - * The id of the user. + * @param name + * The user name. + * The name must be NULL terminated. * @param account * This is replaced with by the account information. * All strings will be NULL terminated. @@ -81,11 +81,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_failure (with error bit) on any other error. * - * @see getpwuid_r() + * @see getpwnam_r() */ -#ifndef _di_f_account_by_id_ - extern f_status_t f_account_by_id(const uid_t id, f_account_t *account); -#endif // _di_f_account_by_id_ +#ifndef _di_f_account_by_name_ + extern f_status_t f_account_by_name(const f_string_t name, f_account_t *account); +#endif // _di_f_account_by_name_ /** * Get the account group id by the group name. @@ -110,18 +110,18 @@ extern "C" { * * @see getgrnam_r() */ -#ifndef _di_f_account_id_group_by_name_ - extern f_status_t f_account_id_group_by_name(const f_string_t name, gid_t *id); -#endif // _di_f_account_id_group_by_name_ +#ifndef _di_f_account_group_id_by_name_ + extern f_status_t f_account_group_id_by_name(const f_string_t name, gid_t *id); +#endif // _di_f_account_group_id_by_name_ /** - * Get the user account id by the user name. + * Get the account group name by the group id. * - * @param name - * The user name. - * The name must be NULL terminated. * @param id - * The id associated with the given name. + * The id of the group. + * @param name + * This is replaced with by the group name. + * The name will be NULL terminated. * * @return * F_none on success. @@ -135,20 +135,20 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_failure (with error bit) on any other error. * - * @see getpwnam_r() + * @see getgrgid_r() */ -#ifndef _di_f_account_id_user_by_name_ - extern f_status_t f_account_id_user_by_name(const f_string_t name, uid_t *id); -#endif // _di_f_account_id_user_by_name_ +#ifndef _di_f_account_group_name_by_id_ + extern f_status_t f_account_group_name_by_id(const gid_t id, f_string_dynamic_t *name); +#endif // _di_f_account_group_name_by_id_ /** - * Get the account group name by the group id. + * Get the user account id by the user name. * - * @param id - * The id of the group. * @param name - * This is replaced with by the group name. - * The name will be NULL terminated. + * The user name. + * The name must be NULL terminated. + * @param id + * The id associated with the given name. * * @return * F_none on success. @@ -162,11 +162,11 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_failure (with error bit) on any other error. * - * @see getgrgid_r() + * @see getpwnam_r() */ -#ifndef _di_f_account_name_group_by_id_ - extern f_status_t f_account_name_group_by_id(const gid_t id, f_string_dynamic_t *name); -#endif // _di_f_account_name_group_by_id_ +#ifndef _di_f_account_id_by_name_ + extern f_status_t f_account_id_by_name(const f_string_t name, uid_t *id); +#endif // _di_f_account_id_by_name_ /** * Get the user account name by the user id. @@ -191,9 +191,9 @@ extern "C" { * * @see getpwuid_r() */ -#ifndef _di_f_account_name_user_by_id_ - extern f_status_t f_account_name_user_by_id(const uid_t id, f_string_dynamic_t *name); -#endif // _di_f_account_name_user_by_id_ +#ifndef _di_f_account_name_by_id_ + extern f_status_t f_account_name_by_id(const uid_t id, f_string_dynamic_t *name); +#endif // _di_f_account_name_by_id_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_account/data/build/settings-tests b/level_0/f_account/data/build/settings-tests index c623264..7792817 100644 --- a/level_0/f_account/data/build/settings-tests +++ b/level_0/f_account/data/build/settings-tests @@ -19,7 +19,7 @@ build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_account build_libraries-level -lfll_0 build_libraries-monolithic -lfll -build_sources_program test-account-by_id.c test-account-by_name.c test-account-id_group_by_name.c test-account-id_user_by_name.c test-account-name_group_by_id.c test-account-name_user_by_id.c test-account.c +build_sources_program test-account-by_id.c test-account-by_name.c test-account-group_name_by_id.c test-account-group_id_by_name.c test-account-id_by_name.c test-account-name_by_id.c test-account.c build_script no build_shared yes build_static no diff --git a/level_0/f_account/tests/c/test-account-id_group_by_name.c b/level_0/f_account/tests/c/test-account-group_id_by_name.c similarity index 77% rename from level_0/f_account/tests/c/test-account-id_group_by_name.c rename to level_0/f_account/tests/c/test-account-group_id_by_name.c index 0d89003..954e5b3 100644 --- a/level_0/f_account/tests/c/test-account-id_group_by_name.c +++ b/level_0/f_account/tests/c/test-account-group_id_by_name.c @@ -1,11 +1,11 @@ #include "test-account.h" -#include "test-account-id_group_by_name.h" +#include "test-account-group_id_by_name.h" #ifdef __cplusplus extern "C" { #endif -void test__f_account_id_group_by_name__fails(void **state) { +void test__f_account_group_id_by_name__fails(void **state) { const long size = 20; char *name = "name"; @@ -37,13 +37,13 @@ void test__f_account_id_group_by_name__fails(void **state) { will_return(__wrap_getgrnam_r, true); will_return(__wrap_getgrnam_r, errnos[i]); - const f_status_t status = f_account_id_group_by_name(name, &gid); + const f_status_t status = f_account_group_id_by_name(name, &gid); assert_int_equal(F_status_set_fine(status), statuss[i]); } // for } -void test__f_account_id_group_by_name__not_found(void **state) { +void test__f_account_group_id_by_name__not_found(void **state) { const long size = 20; struct group group_data; @@ -56,26 +56,26 @@ void test__f_account_id_group_by_name__not_found(void **state) { will_return(__wrap_getgrnam_r, &group_data); will_return(__wrap_getgrnam_r, (struct group *) 0); - const f_status_t status = f_account_id_group_by_name(name, &gid); + const f_status_t status = f_account_group_id_by_name(name, &gid); assert_int_equal(status, F_exist_not); } } #ifndef _di_level_0_parameter_checking_ - void test__f_account_id_group_by_name__parameter_checking(void **state) { + void test__f_account_group_id_by_name__parameter_checking(void **state) { const f_string_t name = f_string_t_initialize; { - const f_status_t status = f_account_id_group_by_name(name, 0); + const f_status_t status = f_account_group_id_by_name(name, 0); assert_int_equal(F_status_set_fine(status), F_parameter); } } #endif // _di_level_0_parameter_checking_ -void test__f_account_id_group_by_name__works(void **state) { +void test__f_account_group_id_by_name__works(void **state) { const long size = 20; struct group group_data; @@ -94,7 +94,7 @@ void test__f_account_id_group_by_name__works(void **state) { will_return(__wrap_getgrnam_r, &group_data); will_return(__wrap_getgrnam_r, &pointer); - const f_status_t status = f_account_id_group_by_name(group_data.gr_name, &gid); + const f_status_t status = f_account_group_id_by_name(group_data.gr_name, &gid); assert_int_equal(status, F_none); assert_int_equal(gid, group_data.gr_gid); diff --git a/level_0/f_account/tests/c/test-account-id_group_by_name.h b/level_0/f_account/tests/c/test-account-group_id_by_name.h similarity index 59% rename from level_0/f_account/tests/c/test-account-id_group_by_name.h rename to level_0/f_account/tests/c/test-account-group_id_by_name.h index e1fe41d..75121c2 100644 --- a/level_0/f_account/tests/c/test-account-id_group_by_name.h +++ b/level_0/f_account/tests/c/test-account-group_id_by_name.h @@ -13,31 +13,31 @@ /** * Test that function fails. * - * @see f_account_id_group_by_name() + * @see f_account_group_id_by_name() */ -extern void test__f_account_id_group_by_name__fails(void **state); +extern void test__f_account_group_id_by_name__fails(void **state); /** * Test that function works but the group does not exist. * - * @see f_account_id_group_by_name() + * @see f_account_group_id_by_name() */ -extern void test__f_account_id_group_by_name__not_found(void **state); +extern void test__f_account_group_id_by_name__not_found(void **state); /** * Test that parameter checking works as expected. * - * @see f_account_id_group_by_name() + * @see f_account_group_id_by_name() */ #ifndef _di_level_0_parameter_checking_ - extern void test__f_account_id_group_by_name__parameter_checking(void **state); + extern void test__f_account_group_id_by_name__parameter_checking(void **state); #endif // _di_level_0_parameter_checking_ /** * Test that function works. * - * @see f_account_id_group_by_name() + * @see f_account_group_id_by_name() */ -extern void test__f_account_id_group_by_name__works(void **state); +extern void test__f_account_group_id_by_name__works(void **state); #endif // _TEST__F_account_id_group_by_name_ diff --git a/level_0/f_account/tests/c/test-account-name_group_by_id.c b/level_0/f_account/tests/c/test-account-group_name_by_id.c similarity index 78% rename from level_0/f_account/tests/c/test-account-name_group_by_id.c rename to level_0/f_account/tests/c/test-account-group_name_by_id.c index 6103838..f5dccf2 100644 --- a/level_0/f_account/tests/c/test-account-name_group_by_id.c +++ b/level_0/f_account/tests/c/test-account-group_name_by_id.c @@ -1,11 +1,11 @@ #include "test-account.h" -#include "test-account-name_group_by_id.h" +#include "test-account-group_name_by_id.h" #ifdef __cplusplus extern "C" { #endif -void test__f_account_name_group_by_id__fails(void **state) { +void test__f_account_group_name_by_id__fails(void **state) { const long size = 20; gid_t gid = 0; @@ -37,7 +37,7 @@ void test__f_account_name_group_by_id__fails(void **state) { will_return(__wrap_getgrgid_r, true); will_return(__wrap_getgrgid_r, errnos[i]); - const f_status_t status = f_account_name_group_by_id(gid, &name); + const f_status_t status = f_account_group_name_by_id(gid, &name); assert_int_equal(F_status_set_fine(status), statuss[i]); } // for @@ -45,7 +45,7 @@ void test__f_account_name_group_by_id__fails(void **state) { f_string_dynamic_resize(0, &name); } -void test__f_account_name_group_by_id__not_found(void **state) { +void test__f_account_group_name_by_id__not_found(void **state) { const long size = 20; struct group group_data; @@ -58,7 +58,7 @@ void test__f_account_name_group_by_id__not_found(void **state) { will_return(__wrap_getgrgid_r, &group_data); will_return(__wrap_getgrgid_r, (struct group *) 0); - const f_status_t status = f_account_name_group_by_id(gid, &name); + const f_status_t status = f_account_group_name_by_id(gid, &name); assert_int_equal(status, F_exist_not); } @@ -67,17 +67,17 @@ void test__f_account_name_group_by_id__not_found(void **state) { } #ifndef _di_level_0_parameter_checking_ - void test__f_account_name_group_by_id__parameter_checking(void **state) { + void test__f_account_group_name_by_id__parameter_checking(void **state) { { - const f_status_t status = f_account_name_group_by_id(0, 0); + const f_status_t status = f_account_group_name_by_id(0, 0); assert_int_equal(F_status_set_fine(status), F_parameter); } } #endif // _di_level_0_parameter_checking_ -void test__f_account_name_group_by_id__works(void **state) { +void test__f_account_group_name_by_id__works(void **state) { const long size = 20; struct group group_data; @@ -97,7 +97,7 @@ void test__f_account_name_group_by_id__works(void **state) { will_return(__wrap_getgrgid_r, &group_data); will_return(__wrap_getgrgid_r, &pointer); - const f_status_t status = f_account_name_group_by_id(gid, &name); + const f_status_t status = f_account_group_name_by_id(gid, &name); assert_int_equal(status, F_none); assert_string_equal(name.string, group_data.gr_name); diff --git a/level_0/f_account/tests/c/test-account-name_group_by_id.h b/level_0/f_account/tests/c/test-account-group_name_by_id.h similarity index 59% rename from level_0/f_account/tests/c/test-account-name_group_by_id.h rename to level_0/f_account/tests/c/test-account-group_name_by_id.h index d4ff4a1..a5f017d 100644 --- a/level_0/f_account/tests/c/test-account-name_group_by_id.h +++ b/level_0/f_account/tests/c/test-account-group_name_by_id.h @@ -13,31 +13,31 @@ /** * Test that function fails. * - * @see f_account_name_group_by_id() + * @see f_account_group_name_by_id() */ -extern void test__f_account_name_group_by_id__fails(void **state); +extern void test__f_account_group_name_by_id__fails(void **state); /** * Test that function works but the group does not exist. * - * @see f_account_name_group_by_id() + * @see f_account_group_name_by_id() */ -extern void test__f_account_name_group_by_id__not_found(void **state); +extern void test__f_account_group_name_by_id__not_found(void **state); /** * Test that parameter checking works as expected. * - * @see f_account_name_group_by_id() + * @see f_account_group_name_by_id() */ #ifndef _di_level_0_parameter_checking_ - extern void test__f_account_name_group_by_id__parameter_checking(void **state); + extern void test__f_account_group_name_by_id__parameter_checking(void **state); #endif // _di_level_0_parameter_checking_ /** * Test that function works. * - * @see f_account_name_group_by_id() + * @see f_account_group_name_by_id() */ -extern void test__f_account_name_group_by_id__works(void **state); +extern void test__f_account_group_name_by_id__works(void **state); #endif // _TEST__F_account_name_group_by_id_ diff --git a/level_0/f_account/tests/c/test-account-id_user_by_name.c b/level_0/f_account/tests/c/test-account-id_by_name.c similarity index 75% rename from level_0/f_account/tests/c/test-account-id_user_by_name.c rename to level_0/f_account/tests/c/test-account-id_by_name.c index 4549f82..eeea2ae 100644 --- a/level_0/f_account/tests/c/test-account-id_user_by_name.c +++ b/level_0/f_account/tests/c/test-account-id_by_name.c @@ -1,11 +1,11 @@ #include "test-account.h" -#include "test-account-id_user_by_name.h" +#include "test-account-id_by_name.h" #ifdef __cplusplus extern "C" { #endif -void test__f_account_id_user_by_name__fails(void **state) { +void test__f_account_id_by_name__fails(void **state) { const long size = 20; char *name = "name"; @@ -37,13 +37,13 @@ void test__f_account_id_user_by_name__fails(void **state) { will_return(__wrap_getpwnam_r, true); will_return(__wrap_getpwnam_r, errnos[i]); - const f_status_t status = f_account_id_user_by_name(name, &uid); + const f_status_t status = f_account_id_by_name(name, &uid); assert_int_equal(F_status_set_fine(status), statuss[i]); } // for } -void test__f_account_id_user_by_name__not_found(void **state) { +void test__f_account_id_by_name__not_found(void **state) { const long size = 20; struct passwd password; @@ -56,26 +56,26 @@ void test__f_account_id_user_by_name__not_found(void **state) { will_return(__wrap_getpwnam_r, &password); will_return(__wrap_getpwnam_r, (struct passwd *) 0); - const f_status_t status = f_account_id_user_by_name(name, &uid); + const f_status_t status = f_account_id_by_name(name, &uid); assert_int_equal(status, F_exist_not); } } #ifndef _di_level_0_parameter_checking_ - void test__f_account_id_user_by_name__parameter_checking(void **state) { + void test__f_account_id_by_name__parameter_checking(void **state) { const f_string_t name = f_string_t_initialize; { - const f_status_t status = f_account_id_user_by_name(name, 0); + const f_status_t status = f_account_id_by_name(name, 0); assert_int_equal(F_status_set_fine(status), F_parameter); } } #endif // _di_level_0_parameter_checking_ -void test__f_account_id_user_by_name__works(void **state) { +void test__f_account_id_by_name__works(void **state) { const long size = 20; struct passwd password; @@ -96,7 +96,7 @@ void test__f_account_id_user_by_name__works(void **state) { will_return(__wrap_getpwnam_r, &password); will_return(__wrap_getpwnam_r, &pointer); - const f_status_t status = f_account_id_user_by_name(password.pw_name, &uid); + const f_status_t status = f_account_id_by_name(password.pw_name, &uid); assert_int_equal(status, F_none); assert_int_equal(uid, password.pw_uid); diff --git a/level_0/f_account/tests/c/test-account-id_user_by_name.h b/level_0/f_account/tests/c/test-account-id_by_name.h similarity index 56% rename from level_0/f_account/tests/c/test-account-id_user_by_name.h rename to level_0/f_account/tests/c/test-account-id_by_name.h index 7786662..97534c0 100644 --- a/level_0/f_account/tests/c/test-account-id_user_by_name.h +++ b/level_0/f_account/tests/c/test-account-id_by_name.h @@ -13,31 +13,31 @@ /** * Test that function fails. * - * @see f_account_id_user_by_name() + * @see f_account_id_by_name() */ -extern void test__f_account_id_user_by_name__fails(void **state); +extern void test__f_account_id_by_name__fails(void **state); /** * Test that function works but the group does not exist. * - * @see f_account_id_user_by_name() + * @see f_account_id_by_name() */ -extern void test__f_account_id_user_by_name__not_found(void **state); +extern void test__f_account_id_by_name__not_found(void **state); /** * Test that parameter checking works as expected. * - * @see f_account_id_user_by_name() + * @see f_account_id_by_name() */ #ifndef _di_level_0_parameter_checking_ - extern void test__f_account_id_user_by_name__parameter_checking(void **state); + extern void test__f_account_id_by_name__parameter_checking(void **state); #endif // _di_level_0_parameter_checking_ /** * Test that function works. * - * @see f_account_id_user_by_name() + * @see f_account_id_by_name() */ -extern void test__f_account_id_user_by_name__works(void **state); +extern void test__f_account_id_by_name__works(void **state); #endif // _TEST__F_account_id_user_by_name_ diff --git a/level_0/f_account/tests/c/test-account-name_user_by_id.c b/level_0/f_account/tests/c/test-account-name_by_id.c similarity index 78% rename from level_0/f_account/tests/c/test-account-name_user_by_id.c rename to level_0/f_account/tests/c/test-account-name_by_id.c index 80dcc6b..d688912 100644 --- a/level_0/f_account/tests/c/test-account-name_user_by_id.c +++ b/level_0/f_account/tests/c/test-account-name_by_id.c @@ -1,11 +1,11 @@ #include "test-account.h" -#include "test-account-name_user_by_id.h" +#include "test-account-name_by_id.h" #ifdef __cplusplus extern "C" { #endif -void test__f_account_name_user_by_id__fails(void **state) { +void test__f_account_name_by_id__fails(void **state) { const long size = 20; uid_t uid = 0; @@ -37,7 +37,7 @@ void test__f_account_name_user_by_id__fails(void **state) { will_return(__wrap_getpwuid_r, true); will_return(__wrap_getpwuid_r, errnos[i]); - const f_status_t status = f_account_name_user_by_id(uid, &name); + const f_status_t status = f_account_name_by_id(uid, &name); assert_int_equal(F_status_set_fine(status), statuss[i]); } // for @@ -45,7 +45,7 @@ void test__f_account_name_user_by_id__fails(void **state) { f_string_dynamic_resize(0, &name); } -void test__f_account_name_user_by_id__not_found(void **state) { +void test__f_account_name_by_id__not_found(void **state) { const long size = 20; struct passwd password; @@ -58,7 +58,7 @@ void test__f_account_name_user_by_id__not_found(void **state) { will_return(__wrap_getpwuid_r, &password); will_return(__wrap_getpwuid_r, (struct passwd *) 0); - const f_status_t status = f_account_name_user_by_id(uid, &name); + const f_status_t status = f_account_name_by_id(uid, &name); assert_int_equal(status, F_exist_not); } @@ -67,17 +67,17 @@ void test__f_account_name_user_by_id__not_found(void **state) { } #ifndef _di_level_0_parameter_checking_ - void test__f_account_name_user_by_id__parameter_checking(void **state) { + void test__f_account_name_by_id__parameter_checking(void **state) { { - const f_status_t status = f_account_name_user_by_id(0, 0); + const f_status_t status = f_account_name_by_id(0, 0); assert_int_equal(F_status_set_fine(status), F_parameter); } } #endif // _di_level_0_parameter_checking_ -void test__f_account_name_user_by_id__works(void **state) { +void test__f_account_name_by_id__works(void **state) { const long size = 20; struct passwd password; @@ -99,7 +99,7 @@ void test__f_account_name_user_by_id__works(void **state) { will_return(__wrap_getpwuid_r, &password); will_return(__wrap_getpwuid_r, &pointer); - const f_status_t status = f_account_name_user_by_id(uid, &name); + const f_status_t status = f_account_name_by_id(uid, &name); assert_int_equal(status, F_none); assert_string_equal(name.string, password.pw_name); diff --git a/level_0/f_account/tests/c/test-account-name_user_by_id.h b/level_0/f_account/tests/c/test-account-name_by_id.h similarity index 56% rename from level_0/f_account/tests/c/test-account-name_user_by_id.h rename to level_0/f_account/tests/c/test-account-name_by_id.h index e80814a..994763d 100644 --- a/level_0/f_account/tests/c/test-account-name_user_by_id.h +++ b/level_0/f_account/tests/c/test-account-name_by_id.h @@ -13,31 +13,31 @@ /** * Test that function fails. * - * @see f_account_name_user_by_id() + * @see f_account_name_by_id() */ -extern void test__f_account_name_user_by_id__fails(void **state); +extern void test__f_account_name_by_id__fails(void **state); /** * Test that function works but the group does not exist. * - * @see f_account_name_user_by_id() + * @see f_account_name_by_id() */ -extern void test__f_account_name_user_by_id__not_found(void **state); +extern void test__f_account_name_by_id__not_found(void **state); /** * Test that parameter checking works as expected. * - * @see f_account_name_user_by_id() + * @see f_account_name_by_id() */ #ifndef _di_level_0_parameter_checking_ - extern void test__f_account_name_user_by_id__parameter_checking(void **state); + extern void test__f_account_name_by_id__parameter_checking(void **state); #endif // _di_level_0_parameter_checking_ /** * Test that function works. * - * @see f_account_name_user_by_id() + * @see f_account_name_by_id() */ -extern void test__f_account_name_user_by_id__works(void **state); +extern void test__f_account_name_by_id__works(void **state); #endif // _TEST__F_account_name_user_by_id_ diff --git a/level_0/f_account/tests/c/test-account.c b/level_0/f_account/tests/c/test-account.c index 74bbc83..88ba73d 100644 --- a/level_0/f_account/tests/c/test-account.c +++ b/level_0/f_account/tests/c/test-account.c @@ -27,29 +27,29 @@ int main(void) { cmocka_unit_test(test__f_account_by_name__not_found), cmocka_unit_test(test__f_account_by_name__works), - cmocka_unit_test(test__f_account_id_group_by_name__fails), - cmocka_unit_test(test__f_account_id_group_by_name__not_found), - cmocka_unit_test(test__f_account_id_group_by_name__works), + cmocka_unit_test(test__f_account_group_id_by_name__fails), + cmocka_unit_test(test__f_account_group_id_by_name__not_found), + cmocka_unit_test(test__f_account_group_id_by_name__works), - cmocka_unit_test(test__f_account_id_user_by_name__fails), - cmocka_unit_test(test__f_account_id_user_by_name__not_found), - cmocka_unit_test(test__f_account_id_user_by_name__works), + cmocka_unit_test(test__f_account_group_name_by_id__fails), + cmocka_unit_test(test__f_account_group_name_by_id__not_found), + cmocka_unit_test(test__f_account_group_name_by_id__works), - cmocka_unit_test(test__f_account_name_group_by_id__fails), - cmocka_unit_test(test__f_account_name_group_by_id__not_found), - cmocka_unit_test(test__f_account_name_group_by_id__works), + cmocka_unit_test(test__f_account_id_by_name__fails), + cmocka_unit_test(test__f_account_id_by_name__not_found), + cmocka_unit_test(test__f_account_id_by_name__works), - cmocka_unit_test(test__f_account_name_user_by_id__fails), - cmocka_unit_test(test__f_account_name_user_by_id__not_found), - cmocka_unit_test(test__f_account_name_user_by_id__works), + cmocka_unit_test(test__f_account_name_by_id__fails), + cmocka_unit_test(test__f_account_name_by_id__not_found), + cmocka_unit_test(test__f_account_name_by_id__works), #ifndef _di_level_0_parameter_checking_ cmocka_unit_test(test__f_account_by_id__parameter_checking), cmocka_unit_test(test__f_account_by_name__parameter_checking), - cmocka_unit_test(test__f_account_id_group_by_name__parameter_checking), - cmocka_unit_test(test__f_account_id_user_by_name__parameter_checking), - cmocka_unit_test(test__f_account_name_group_by_id__parameter_checking), - cmocka_unit_test(test__f_account_name_user_by_id__parameter_checking), + cmocka_unit_test(test__f_account_group_id_by_name__parameter_checking), + cmocka_unit_test(test__f_account_group_name_by_id__parameter_checking), + cmocka_unit_test(test__f_account_id_by_name__parameter_checking), + cmocka_unit_test(test__f_account_name_by_id__parameter_checking), #endif // _di_level_0_parameter_checking_ }; diff --git a/level_0/f_account/tests/c/test-account.h b/level_0/f_account/tests/c/test-account.h index 030f92f..214002e 100644 --- a/level_0/f_account/tests/c/test-account.h +++ b/level_0/f_account/tests/c/test-account.h @@ -28,10 +28,10 @@ // test includes. #include "test-account-by_id.h" #include "test-account-by_name.h" -#include "test-account-id_group_by_name.h" -#include "test-account-id_user_by_name.h" -#include "test-account-name_group_by_id.h" -#include "test-account-name_user_by_id.h" +#include "test-account-group_id_by_name.h" +#include "test-account-group_name_by_id.h" +#include "test-account-id_by_name.h" +#include "test-account-name_by_id.h" #ifdef __cplusplus extern "C" { diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index 4febf96..b777611 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -326,7 +326,7 @@ extern "C" { status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic); if (F_status_is_error(status)) return status; - status = f_account_id_user_by_name(cache->action.generic.string, id); + status = f_account_id_by_name(cache->action.generic.string, id); if (F_status_is_error(status)) return status; if (status == F_exist_not) { @@ -360,7 +360,7 @@ extern "C" { status = controller_dynamic_rip_nulless_terminated(buffer, range, &cache->action.generic); if (F_status_is_error(status)) return status; - status = f_account_id_group_by_name(cache->action.generic.string, id); + status = f_account_group_id_by_name(cache->action.generic.string, id); if (F_status_is_error(status)) return status; if (status == F_exist_not) { diff --git a/level_3/controller/c/controller/private-controller.h b/level_3/controller/c/controller/private-controller.h index a0fd07b..a79927e 100644 --- a/level_3/controller/c/controller/private-controller.h +++ b/level_3/controller/c/controller/private-controller.h @@ -227,10 +227,10 @@ extern "C" { * F_exist_not (with error bit) if failed to match the name to an ID. * F_number_too_large (with error bit) if the given ID is too large. * - * Errors (with error bit) from: f_account_id_user_by_name(). + * Errors (with error bit) from: f_account_id_by_name(). * Errors (with error bit) from: fl_conversion_string_to_number_unsigned(). * - * @see f_account_id_user_by_name() + * @see f_account_id_by_name() * @see fl_conversion_string_to_number_unsigned() */ #ifndef _di_controller_get_id_user_ @@ -254,10 +254,10 @@ extern "C" { * F_exist_not (with error bit) if failed to match the name to an ID. * F_number_too_large (with error bit) if the given ID is too large. * - * Errors (with error bit) from: f_account_id_group_by_name(). + * Errors (with error bit) from: f_account_group_id_by_name(). * Errors (with error bit) from: fl_conversion_string_to_number_unsigned(). * - * @see f_account_id_group_by_name() + * @see f_account_group_id_by_name() * @see fl_conversion_string_to_number_unsigned() */ #ifndef _di_controller_get_id_group_ diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 2e695be..6dcc56d 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -5017,7 +5017,7 @@ extern "C" { cache->action.line_action = ++cache->action.line_item; - controller_rule_print_error(global.thread, global.main->error, cache->action, status, "f_account_id_group_by_name", F_true, F_false); + controller_rule_print_error(global.thread, global.main->error, cache->action, status, "f_account_group_id_by_name", F_true, F_false); controller_rule_item_print_error(global.thread, global.main->error, cache->action, F_false, F_status_set_fine(status)); } diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index ddd39e4..537b4cc 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -60,10 +60,10 @@ extern "C" { status = F_status_set_fine(status); if (status == F_number) { - status = f_account_id_group_by_name(buffer.string, id); + status = f_account_group_id_by_name(buffer.string, id); if (F_status_is_error(status)) { - fll_error_print(print, F_status_set_fine(status), "f_account_id_group_by_name", F_true); + fll_error_print(print, F_status_set_fine(status), "f_account_group_id_by_name", F_true); return F_status_set_error(status); } @@ -151,10 +151,10 @@ extern "C" { status = F_status_set_fine(status); if (status == F_number) { - status = f_account_id_user_by_name(buffer.string, id); + status = f_account_id_by_name(buffer.string, id); if (F_status_is_error(status)) { - fll_error_print(print, status, "f_account_id_user_by_name", F_true); + fll_error_print(print, status, "f_account_id_by_name", F_true); return F_status_set_error(status); } -- 1.8.3.1