Commit
9f60a77e0b updated the check to avoid having files or other
objects instead of a directory. This missed the valid case that there
might be a symlink to a directory. Updated the check accordingly to
allow symlinks to directories.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14166
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
/**
* Try to create the specified directory if it didn't exist.
+ * A symlink to a directory is also accepted as a valid existing directory.
*
* @retval true if the directory already existed
* or was successfully created.
return false;
}
- if (!S_ISDIR(sbuf.st_mode)) {
- return false;
+ if (S_ISDIR(sbuf.st_mode)) {
+ return true;
}
+
+ if (S_ISLNK(sbuf.st_mode)) {
+ ret = stat(dname, &sbuf);
+ if (ret != 0) {
+ return false;
+ }
+
+ if (S_ISDIR(sbuf.st_mode)) {
+ return true;
+ }
+ }
+
+ return false;
}
return true;