From: Volker Lendecke Date: Wed, 9 Jan 2019 16:24:57 +0000 (+0100) Subject: smbd: Enhance debugging if chdir fails X-Git-Tag: talloc-2.3.1~866 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae3cfa5da9e86a4f379df7bba8e45ef31a28bc4d;p=thirdparty%2Fsamba.git smbd: Enhance debugging if chdir fails This helps admins to figure out which user has a problem Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Volker Lendecke Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 64b638346ae..7b3abe4c3e0 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -152,17 +152,45 @@ bool chdir_current_service(connection_struct *conn) ret = vfs_ChDir(conn, &connectpath_fname); if (ret != 0) { - DEBUG(((errno!=EACCES)?0:3), - ("chdir (%s) failed, reason: %s\n", - conn->connectpath, strerror(errno))); + int saved_errno = errno; + + if (saved_errno == EACCES) { + char *str = utok_string( + talloc_tos(), + conn->session_info->unix_token); + DBG_WARNING("vfs_ChDir(%s) got " + "permission denied, current " + "token: %s\n", + conn->connectpath, str); + TALLOC_FREE(str); + } else { + DBG_ERR("vfs_ChDir(%s) failed: " + "%s!\n", + conn->connectpath, + strerror(saved_errno)); + } return false; } ret = vfs_ChDir(conn, &origpath_fname); if (ret != 0) { - DEBUG(((errno!=EACCES)?0:3), - ("chdir (%s) failed, reason: %s\n", - conn->origpath, strerror(errno))); + int saved_errno = errno; + + if (saved_errno == EACCES) { + char *str = utok_string( + talloc_tos(), + conn->session_info->unix_token); + DBG_WARNING("vfs_ChDir(%s) got " + "permission denied, current " + "token: %s\n", + conn->origpath, str); + TALLOC_FREE(str); + } else { + DBG_ERR("vfs_ChDir(%s) failed: " + "%s!\n", + conn->origpath, + strerror(saved_errno)); + } return false; } diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 5425449d42c..8fa38e459dd 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -445,7 +445,6 @@ static bool change_to_user_internal(connection_struct *conn, if (current_user.need_chdir) { ok = chdir_current_service(conn); if (!ok) { - DBG_ERR("chdir_current_service() failed!\n"); return false; } current_user.done_chdir = true;