Mercurial > dovecot > core-2.2
changeset 22957:1d2167636cc6
fs-posix: Strip trailing "/" from filenames
This is mainly because "doveadm fs delete -R" adds it to indicate to the
fs-driver that the whole directory is wanted to be deleted. This change
fixes fs-posix to work with NFS, where otherwise unlink("symlink-to-dir/")
fails with ENOTDIR. Without NFS the same call succeeds.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 15 May 2018 17:50:27 +0300 |
parents | fc76e2678988 |
children | a8220182eac6 |
files | src/lib-fs/fs-posix.c |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-fs/fs-posix.c Thu May 03 18:33:25 2018 +0300 +++ b/src/lib-fs/fs-posix.c Tue May 15 17:50:27 2018 +0300 @@ -320,6 +320,13 @@ struct posix_fs *fs = (struct posix_fs *)_fs; struct posix_fs_file *file; guid_128_t guid; + size_t path_len = strlen(path); + + if (path_len > 0 && path[path_len-1] == '/') { + /* deleting "path/" (used e.g. by doveadm fs delete) - strip + out the trailing "/" since it doesn't work well with NFS. */ + path = t_strndup(path, path_len-1); + } file = i_new(struct posix_fs_file, 1); file->file.fs = _fs;