diff options
author | Roman Rakus <rrakus@redhat.com> | 2013-05-31 18:01:33 +0200 |
---|---|---|
committer | Roman Rakus <rrakus@redhat.com> | 2013-06-03 10:45:08 +0200 |
commit | 71c900b504cf98bedf765a54b493ac8061f60e65 (patch) | |
tree | 05a2d050a4cbfd907c563bb28c69a48fa35f799c /src/account/LMI_AccountProvider.c | |
parent | 7c23b75d5445988bb40292f7fc85dce8dcfb1bd4 (diff) | |
download | openlmi-providers-71c900b504cf98bedf765a54b493ac8061f60e65.tar.gz openlmi-providers-71c900b504cf98bedf765a54b493ac8061f60e65.tar.xz openlmi-providers-71c900b504cf98bedf765a54b493ac8061f60e65.zip |
Account: Properly create/delete homedirs
Use newly available libuser's functions for homedir manipulation
Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src/account/LMI_AccountProvider.c')
-rw-r--r-- | src/account/LMI_AccountProvider.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c index 27be7e1..8eb538b 100644 --- a/src/account/LMI_AccountProvider.c +++ b/src/account/LMI_AccountProvider.c @@ -467,7 +467,7 @@ static CMPIStatus LMI_AccountDeleteInstance( const CMPIObjectPath* cop) { LMI_Account acc; - const char* username = NULL; + const char* username = NULL, *home = NULL; char errmsg[256]; struct lu_context *luc = NULL; struct lu_error *error = NULL; @@ -493,6 +493,16 @@ static CMPIStatus LMI_AccountDeleteInstance( CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, errmsg); } + home = aux_lu_get_str(lue, LU_HOMEDIRECTORY); + /* Be really safe here, it can delete ANY directory */ + if (!lu_homedir_remove(home, &error)) { + snprintf(errmsg, 256, "User's homedir %s could not be deleted: %s\n", + home, lu_strerror(error)); + lu_ent_free(lue); + lu_end(luc); + CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg); + } + if (!lu_user_delete(luc, lue, &error)) { snprintf(errmsg, 256, "User %s could not be deleted: %s\n", username, @@ -502,6 +512,7 @@ static CMPIStatus LMI_AccountDeleteInstance( CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg); } + lu_ent_free(lue); lu_end(luc); |