diff options
author | Roman Rakus <rrakus@redhat.com> | 2013-08-28 15:54:26 +0200 |
---|---|---|
committer | Roman Rakus <rrakus@redhat.com> | 2013-09-02 09:33:42 +0200 |
commit | 116a038f697311ceea810b74396055d9dc366f8e (patch) | |
tree | d66b98f414a8c1ba083a097947c931d24176cfe3 /src | |
parent | b512790eef2d754bca546cf73154d4f570a768d6 (diff) | |
download | openlmi-providers-116a038f697311ceea810b74396055d9dc366f8e.tar.gz openlmi-providers-116a038f697311ceea810b74396055d9dc366f8e.tar.xz openlmi-providers-116a038f697311ceea810b74396055d9dc366f8e.zip |
Account: Don't delete home dir if user is not owner
Mark DeleteInstance of LMI_Account as deprecated.
Delete home dir of user only if the user is owner of that directory.
Bugzilla: #999410
Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/account/LMI_AccountProvider.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c index 9727923..6ef0578 100644 --- a/src/account/LMI_AccountProvider.c +++ b/src/account/LMI_AccountProvider.c @@ -23,6 +23,9 @@ #include <time.h> #include <stdbool.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <utmp.h> @@ -442,6 +445,9 @@ static CMPIStatus LMI_AccountModifyInstance( CMReturn(CMPI_RC_OK); } +/* + * DEPRECATED + */ static CMPIStatus LMI_AccountDeleteInstance( CMPIInstanceMI* mi, const CMPIContext* cc, @@ -476,12 +482,23 @@ static CMPIStatus LMI_AccountDeleteInstance( home = aux_lu_get_str(lue, LU_HOMEDIRECTORY); /* Be really safe here, it can delete ANY directory */ - if (!lu_homedir_remove(home, &error)) { + /* Delete home dir only if the directory is owned by the user */ + struct stat buf; + if (stat(home, &buf)) { lu_ent_free(lue); lu_end(luc); KReturn2(_cb, ERR_FAILED, - "User's homedir %s could not be deleted: %s\n", home, - lu_strerror(error)); + "User's homedir %s could not be deleted: %s\n", home, + strerror(errno)); + } + if (buf.st_uid == aux_lu_get_long(lue, LU_UIDNUMBER)) { + if (!lu_homedir_remove(home, &error)) { + lu_ent_free(lue); + lu_end(luc); + KReturn2(_cb, ERR_FAILED, + "User's homedir %s could not be deleted: %s\n", home, + lu_strerror(error)); + } } if (!lu_user_delete(luc, lue, &error)) |