mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 22:12:26 +00:00
lib/tcbfuncs.c: rmdir_leading(): Constify input
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
e7771cc196
commit
4cf430b309
@ -254,17 +254,23 @@ static shadowtcb_status unlink_suffs (const char *user)
|
||||
}
|
||||
|
||||
/* path should be a relative existing tcb directory */
|
||||
static shadowtcb_status rmdir_leading (char *path)
|
||||
static shadowtcb_status
|
||||
rmdir_leading(const char *relpath)
|
||||
{
|
||||
char *ind, *dir;
|
||||
char *ind, *dir, *path;
|
||||
shadowtcb_status ret = SHADOWTCB_SUCCESS;
|
||||
|
||||
path = strdup(relpath);
|
||||
if (path == NULL)
|
||||
goto oom;
|
||||
|
||||
|
||||
while ((ind = strrchr (path, '/'))) {
|
||||
stpcpy(ind, "");
|
||||
dir = aprintf(TCB_DIR "/%s", path);
|
||||
if (dir == NULL) {
|
||||
OUT_OF_MEMORY;
|
||||
return SHADOWTCB_FAILURE;
|
||||
}
|
||||
if (dir == NULL)
|
||||
goto free_path;
|
||||
|
||||
if (rmdir (dir) != 0) {
|
||||
if (errno != ENOTEMPTY) {
|
||||
fprintf (shadow_logfd,
|
||||
@ -277,7 +283,15 @@ static shadowtcb_status rmdir_leading (char *path)
|
||||
}
|
||||
free (dir);
|
||||
}
|
||||
|
||||
free(path);
|
||||
return ret;
|
||||
|
||||
free_path:
|
||||
free(path);
|
||||
oom:
|
||||
OUT_OF_MEMORY;
|
||||
return SHADOWTCB_FAILURE;
|
||||
}
|
||||
|
||||
static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user