Bug 15508 - While accessing home directory of user, getting error NT_STATUS_OBJECT_NAME_NOT_FOUND
Summary: While accessing home directory of user, getting error NT_STATUS_OBJECT_NAME_N...
Status: RESOLVED INVALID
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.18.3
Hardware: x64 Linux
: P5 major (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-27 05:30 UTC by saurabh.singh
Modified: 2023-11-01 21:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description saurabh.singh 2023-10-27 05:30:50 UTC
While accessing home directory of user, getting error NT_STATUS_OBJECT_NAME_NOT_FOUND

access82mfa-01:~ # smbclient \\\\r7515-141vip29.vxindia.veritas.com\\aduser1 -U aduser1%Password
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Mon Oct 23 06:54:32 2023
  ..                                  D        0  Mon Oct 23 06:46:13 2023
  aduser1                            Dr        0  Mon Oct 23 06:54:32 2023

                1048576 blocks of size 1024. 949036 blocks available
smb: \> cd aduser1\
cd \aduser1\: NT_STATUS_OBJECT_NAME_NOT_FOUND
smb: \>


The below is smb.conf data for home directory.
Node1:
[homes]
  browsable = no
  msdfs root = yes
  path = /shared/links/DOMAIN_%D/%U
  root preexec = /cifs/cifs_agent.sh home_precon "%D" "%U"

Node2:
[homes]
  browsable = no
  msdfs root = yes
  path = /shared/links/DOMAIN_%D/%U
  root preexec = /cifs/cifs_agent.sh home_precon "%D" "%U"

[_home1$]
     path=/vx/cifs_fs/DOMAIN_%D/%U
     read only = no
     root preexec = /cifs/cifs_agent.sh user_precon "%D" "%U"


Home directory symlink path:
access82mfa-01:/var/log/samba # ls -ltrh /shared/links/DOMAIN_NIGHTLY/aduser1/aduser1
lrwxrwxrwx 1 root root 68 Oct 23 06:54 /shared/links/DOMAIN_NIGHTLY/aduser1/aduser1 -> 'msdfs:10.221.34.84\_home1$,10.221.34.85\_home1$,10.221.34.84\_home1$'
access82mfa-01:/var/log/samba #

Error seeing in logs:
[2023/10/23 07:36:18.185218, 10, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/files.c:559(openat_pathref_fsp)
  openat_pathref_fsp: smb_fname [aduser1]
[2023/10/23 07:36:18.185225, 10, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/files.c:459(openat_pathref_fullname)
  openat_pathref_fullname: smb_fname [aduser1]
[2023/10/23 07:36:18.185232,  5, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/files.c:77(fsp_new)
  fsp_new: allocated files structure (2 used)
[2023/10/23 07:36:18.185238, 10, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/files.c:2024(file_name_hash)
  file_name_hash: /shared/links/DOMAIN_NIGHTLY/aduser1/aduser1 hash 0xaa33e994
[2023/10/23 07:36:18.185251, 10, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/open.c:962(fd_openat)
  fd_openat: name aduser1, flags = 04000 mode = 00, fd = -1. NT_STATUS_OBJECT_NAME_NOT_FOUND
[2023/10/23 07:36:18.185259, 10, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/files.c:536(openat_pathref_fullname)
  openat_pathref_fullname: Opening pathref for [aduser1] failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
[2023/10/23 07:36:18.185271,  5, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/files.c:1814(file_free)
  file_free: freed files structure 0 (1 used)
[2023/10/23 07:36:18.185288,  5, pid=1999927, effective(11489, 10513), real(11489, 0), class=vfs] ../../source3/modules/vfs_default.c:513(vfswrap_read_dfs_pathat)
  vfswrap_read_dfs_pathat: aduser1 -> msdfs:
[2023/10/23 07:36:18.185298,  5, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/smb2_trans2.c:964(check_msdfs_link)
  check_msdfs_link: Masquerading msdfs link aduser1 as a directory
[2023/10/23 07:36:18.185304,  8, pid=1999927, effective(11489, 10513), real(11489, 0)] ../../source3/smbd/dosmode.c:537(dos_mode_msdfs)
  dos_mode_msdfs: aduser1


Observation from code:
HAVE_BROKEN_READLINK macro not getting set that’s why vfswrap_read_dfs_pathat function not able read full symlink.


HAVE_BROKEN_READLINK is not getting set because of this commit- https://github.com/samba-team/samba/commit/e225ab70db0cc01454d319eaca5265d7e33f396c

This used to work in the previous version which we were using(4.10).
Comment 1 Volker Lendecke 2023-10-27 07:42:31 UTC
This looks like a pretty involved setup. I think you need someone look at that box directly. See https://www.samba.org/samba/support/ for your options.
Comment 2 saurabh.singh 2023-10-31 05:22:56 UTC
Hi Volker,

I have already posted the analysis why this is not working, I just want to understand why the below change was made? Prior to this change things were working fine on redhat with our samba build. 

/* test whether readlink returns a short buffer correctly. */
/* test whether readlink returns a short buffer incorrectly.
   We need to return 0 in case readlink is *broken* here - this is because our waf
   CHECK_CODE function does only allow generating defines in case the test succeeds
*/

#if defined(HAVE_UNISTD_H)
#include <unistd.h>
@@ -20,14 +23,14 @@ int main(void)
	unlink(FNAME);
	ret = symlink(DATA, FNAME);
	if (ret == -1) {
		exit(1);
		exit(0);
	}

The bugzilla description of this issue in which the above fix was made mentions "DFS fix for AIX broken". (https://bugzilla.samba.org/show_bug.cgi?id=13631)


Since HAVE_BROKEN_READLINK is not getting set to 1 during build, samba code is using buffer of size 7 for links and that is causing the issue.
Comment 3 Björn Jacke 2023-11-01 21:57:06 UTC
HAVE_BROKEN_READLINK should not be set to 1 on a Linux system. As the commit along with the bug report should imply, this is a define required on AIX. If you rely on HAVE_BROKEN_READLINK in your code on a Linux system, then you probably have some special customized code in your Samba build. Someone would have to review your code base to find the problem. https://www.samba.org/samba/support/ might be of help.