summaryrefslogtreecommitdiffstats
path: root/src/account/LMI_MemberOfGroupProvider.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/account/LMI_MemberOfGroupProvider.c')
-rw-r--r--src/account/LMI_MemberOfGroupProvider.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/account/LMI_MemberOfGroupProvider.c b/src/account/LMI_MemberOfGroupProvider.c
index dddd2e8..06f835c 100644
--- a/src/account/LMI_MemberOfGroupProvider.c
+++ b/src/account/LMI_MemberOfGroupProvider.c
@@ -154,7 +154,6 @@ static CMPIStatus LMI_MemberOfGroupCreateInstance(
{
CMPIStatus status;
CMPIEnumeration *instances = NULL;
- char errmsg[256];
LMI_GroupRef lg_ref;
LMI_IdentityRef li_ref;
@@ -179,9 +178,8 @@ static CMPIStatus LMI_MemberOfGroupCreateInstance(
LMI_IdentityRef_ToObjectPath(&li_ref, NULL),
LMI_AssignedAccountIdentity_ClassName, LMI_Account_ClassName, NULL,
NULL, NULL, &status)) || !CMHasNext(instances, &status)) {
- snprintf(errmsg, 256, "Unable to find user: %s\n",
- status.msg ? CMGetCharsPtr(status.msg, NULL) : "" );
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED, "Unable to find user: %s\n",
+ status.msg ? CMGetCharsPtr(status.msg, NULL) : "" );
}
LMI_Account_InitFromInstance(&la, _cb, CMGetNext(instances, &status).value.inst);
@@ -195,9 +193,8 @@ static CMPIStatus LMI_MemberOfGroupCreateInstance(
}
if (!lu_group_lookup_name(luc, group_name, lue, &error)) {
- snprintf(errmsg, 256, "Group with name %s not found: %s\n", group_name,
- lu_strerror(error));
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED, "Group with name %s not found: %s\n",
+ group_name, lu_strerror(error));
}
memset(&val, 0, sizeof(val));
@@ -205,12 +202,11 @@ static CMPIStatus LMI_MemberOfGroupCreateInstance(
g_value_set_string(&val, user_name);
lu_ent_add(lue, LU_MEMBERNAME, &val);
if(!lu_group_modify(luc, lue, &error)) {
- snprintf(errmsg, 256, "Modification of group %s failed: %s\n",
- group_name, lu_strerror(error));
lu_ent_free(lue);
lu_end(luc);
g_value_unset(&val);
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED, "Modification of group %s failed: %s\n",
+ group_name, lu_strerror(error));
}
g_value_unset(&val);
@@ -254,7 +250,6 @@ static CMPIStatus LMI_MemberOfGroupDeleteInstance(
char *group_name = NULL;
uid_t user_id = -1;
GValueArray *groups = NULL;
- char errmsg[256];
unsigned int i = 0; /* iterator */
int found = 0; /* indicator */
@@ -272,18 +267,16 @@ static CMPIStatus LMI_MemberOfGroupDeleteInstance(
}
if (!lu_user_lookup_id(luc, user_id, lue_u, &error)) {
- snprintf(errmsg, 256, "User with id %d not found: %s\n", user_id,
- lu_strerror(error));
lu_end(luc);
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED, "User with id %d not found: %s\n", user_id,
+ lu_strerror(error));
}
if (!lu_group_lookup_name(luc, group_name, lue_g, &error)) {
- snprintf(errmsg, 256, "Group with name %s not found: %s\n", group_name,
- lu_strerror(error));
lu_ent_free(lue_u);
lu_end(luc);
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED, "Group with name %s not found: %s\n",
+ group_name, lu_strerror(error));
}
groups = lu_ent_get(lue_g, LU_MEMBERNAME);
for (found = 0, i = 0; groups && i < groups->n_values; i++) {
@@ -294,23 +287,22 @@ static CMPIStatus LMI_MemberOfGroupDeleteInstance(
}
}
if (!found) {
- snprintf(errmsg, 256, "User with id %d is not in group %s or is "
- "users' primary group\n", user_id, group_name);
lu_ent_free(lue_u);
lu_ent_free(lue_g);
lu_end(luc);
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED,
+ "User with id %d is not in group %s or is users' primary group\n",
+ user_id, group_name);
} else {
/* And now remove the user from the group */
g_value_array_remove(groups, i);
lu_ent_set(lue_g, LU_MEMBERNAME, groups);
if(!lu_group_modify(luc, lue_g, &error)) {
- snprintf(errmsg, 256, "Modification of group %s failed: %s\n",
- group_name, lu_strerror(error));
lu_ent_free(lue_u);
lu_ent_free(lue_g);
lu_end(luc);
- CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ KReturn2(_cb, ERR_FAILED, "Modification of group %s failed: %s\n",
+ group_name, lu_strerror(error));
}
}