Bug 6330 - DFS doesn't work on AIX
Summary: DFS doesn't work on AIX
Alias: None
Product: Samba 3.3
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 3.3.4
Hardware: PPC AIX
: P3 normal
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
Depends on:
Reported: 2009-05-06 01:46 UTC by Miguel Sanders (mail account dead)
Modified: 2009-05-13 04:59 UTC (History)
1 user (show)

See Also:
jra: review+

Proposed patch. (2.33 KB, patch)
2009-05-08 13:34 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Sanders (mail account dead) 2009-05-06 01:46:37 UTC

There appears to be a small bug in Samba concerning the use of DFS on AIX.
In msdfs.c, the char array 'link_target_buf' is defined with size 7 (size of "msdfs:" + 1). Since the DFS link is larger than that, the readlink() system call on AIX returns ERANGE. In order to resolve this issue, the array should be of size PATH_MAX (defined in /usr/include/sys/limits.h). A proposed patch

--- msdfs.c	2009-05-06 08:36:00.000000000 +0200
+++ msdfs.new.c	2009-05-06 08:36:44.000000000 +0200
@@ -400,11 +400,15 @@
 			char **pp_link_target,
 			SMB_STRUCT_STAT *sbufp)
 	int referral_len = 0;
+#ifdef AIX
+	char link_target_buf[PATH_MAX];
 	char link_target_buf[7];
 	size_t bufsize = 0;
 	char *link_target = NULL;
 	if (pp_link_target) {
 		bufsize = 1024;
Comment 1 Volker Lendecke 2009-05-06 02:04:53 UTC
According to our recent discussion on samba-technical@samba.org, this seems to be a correct workaround for an AIX bug. Before this goes in, I think someone (me??) needs to write a configure test for this broken behaviour and not make this depend on the AIX #define. This might only apply to certain versions of AIX, and this bug might also happen on different OSes.

Comment 2 Miguel Sanders (mail account dead) 2009-05-06 02:45:01 UTC

I've been doing some research and so far I found out that AIX is the only OS that complains if the size of the buffer is too small (and returns ERANGE). Other OSes (SunOS,HP-UX,Linux,BSD) don't show this behaviour.
Comment 3 Jeremy Allison 2009-05-06 12:19:22 UTC
So IMHO the patch should be #ifdef BROKEN_READLINK_CALL, not #ifdef AIX, and the real meat of the patch is in a configure test that would set this. I can try and come up with this later this week.
Comment 4 Jeremy Allison 2009-05-08 13:34:19 UTC
Created attachment 4131 [details]
Proposed patch.

Can you test this patch please. It adds the feature test (which passes on Linux and should fail on AIX). Should apply to 3.3.x and 3.4.x.
Comment 5 Miguel Sanders (mail account dead) 2009-05-09 02:21:02 UTC
Hi Jeremy

Patch works fine!

Comment 6 Jeremy Allison 2009-05-12 16:47:58 UTC
I think this will also work for 3.3. Volker, do you want to review for possible 3.3 inclusion ?
Comment 7 Volker Lendecke 2009-05-13 04:25:41 UTC
Looks good to me. Karolin, please put this in for 3.3.5.


Comment 8 Karolin Seeger 2009-05-13 04:59:36 UTC
Will be included in 3.3.5.
Closing out bug report.

Thanks for reporting!