Bug 3262 - In Samba from SVN does not work storing dos attributes to EA.
Summary: In Samba from SVN does not work storing dos attributes to EA.
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.21
Hardware: Other Other
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-15 01:22 UTC by Alex Masterov
Modified: 2005-11-21 23:04 UTC (History)
3 users (show)

See Also:


Attachments
Level 10 Log of executing attrib V:\4\1.txt (58.85 KB, text/plain)
2005-11-15 01:24 UTC, Alex Masterov
no flags Details
Level 10 log after appliing patch (19.99 KB, text/plain)
2005-11-15 21:11 UTC, Alex Masterov
no flags Details
Additional sanity checks for FreeBSD EA emulation (4.71 KB, patch)
2005-11-21 18:37 UTC, Timur Bakeyev
no flags Details
Level 10 log after last patch (49.24 KB, text/plain)
2005-11-21 21:26 UTC, Alex Masterov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Masterov 2005-11-15 01:22:11 UTC
Samba from SVN can not store dos attributes into extattr under FreeBSD.
This appeared after appling patch from bugzilla report #3218
3.0.20b without patch works OK, with patch works as described below.

I make sure that "store dos attributes = yes" with testparm.
...
[share]
        comment = Test Share
        path = /shared
        read only = No
        store dos attributes = Yes
...

There is a file in the share:

-rwxr--r--  1 root  wheel  0 15 ноя 14:07 1.txt
root@testbsd# getextattr user DOSATTRIB 1.txt
1.txt   0x22
(File is Archive & Hidden)

From WinXP computer:

C:\Program Files\Far>attrib V:\4\1.txt
A          V:\4\1.txt

i.e. file attributes was gotten from permission bits (not eas).

In level 10 log:

[2005/11/15 14:12:12, 1] smbd/dosmode.c:get_ea_dos_attribute(200)
  get_ea_dos_attributes: Cannot get attribute from EA on file .: Error = Result too large
Comment 1 Alex Masterov 2005-11-15 01:24:57 UTC
Created attachment 1571 [details]
Level 10 Log of executing attrib V:\4\1.txt
Comment 2 Alex Masterov 2005-11-15 01:32:21 UTC
It's strange but smbclient shows correct attributes:

root@testbsd# smbclient //localhost/share -U rc20
Password:
Domain=[TESTD] OS=[Unix] Server=[Samba 3.0.21pre3-SVN-build-11729]
smb: \> ls 4/1.txt
  1.txt                              AH        0  Tue Nov 15 14:07:28 2005

                33874 blocks of size 262144. 10513 blocks available
Comment 3 Jeremy Allison 2005-11-15 11:03:32 UTC
Ok - this is the code that got added in that bug report (#3218).

	/*
+	 * The BSD implementation has a nasty habit of silently truncating
+	 * the returned value to the size of the buffer, so we have to check
+	 * that the buffer is large enough to fit the returned value.
+	 */
+	retval = extattr_get_file(path, attrnamespace, attrname, NULL, 0);
 
+	if(retval > size) {
+		errno = ERANGE;
+		return -1;
+	}
+

We are calling :

        sizeret = SMB_VFS_GETXATTR(conn, path, SAMBA_XATTR_DOS_ATTRIB, attrstr, sizeof(attrstr));

Where attrstr is defined as an fstring (256 bytes). What I need from you is additional debug statements in your lib/system.c code in the FreeBSD specific part that prints out what retval and size in the above call. Then we need to figure out why 256 bytes isn't enough for FreeBSD to store the string "0x22" in an EA.

Jeremy.
Comment 4 Timur Bakeyev 2005-11-15 11:44:57 UTC
(In reply to comment #3)
> Ok - this is the code that got added in that bug report (#3218).

> +       retval = extattr_get_file(path, attrnamespace, attrname, NULL, 0);
> 
> +       if(retval > size) {
> +               errno = ERANGE;
> +               return -1;
> +       }
> +

Looking again on this code I see that it misses check against retval < 0 - which in this case can give that (retval > size). It's my fault, I  was concentrated on setxattr() code and missed retval check for this part of the functions.

Alex, can you put something like:

      retval = extattr_get_file(path, attrnamespace, attrname, NULL, 0);

      if(retval < 0) {
         DEBUG(1, ("extattr_get_file error: %s\n", strerror(errno));
         return -1;
      }

      if(retval > size) {

Hope, it'll help to figure out, why -1 is returned...

With regards,
Timur.
Comment 5 Alex Masterov 2005-11-15 21:11:16 UTC
Created attachment 1574 [details]
Level 10 log after appliing patch

(In reply to comment #4)
> Alex, can you put something like:
> 
>       retval = extattr_get_file(path, attrnamespace, attrname, NULL, 0);
> 
>       if(retval < 0) {
>          DEBUG(1, ("extattr_get_file error: %s\n", strerror(errno));
>          return -1;
>       }
> 
>       if(retval > size) {
> 
> Hope, it'll help to figure out, why -1 is returned...

I've added this code.
Now attrib shows correct attributes:

C:\>attrib V:\4\1.txt
A  S       V:\4\1.txt

alex@testbsd$ getextattr user DOSATTRIB /shared/4/1.txt
/shared/4/1.txt 0x24
-rwxr--r--  1 root  wheel  0 15 &#1085;&#1086;&#1103; 14:07 /shared/4/1.txt

Level 10 log attached.
Comment 6 Alex Masterov 2005-11-17 20:23:01 UTC
This problem does not appear in SVN build 11739.
Thanks! 
Comment 7 Timur Bakeyev 2005-11-21 18:34:43 UTC
(In reply to comment #6)
> This problem does not appear in SVN build 11739.
> Thanks! 
> 

Hi Alex!

Can you try attached patch? It's supposed to do the same staff, just a bit more sane.

Jerremy, can yo uapply it later on if alex confirm it works ok for him?
Comment 8 Timur Bakeyev 2005-11-21 18:37:00 UTC
Created attachment 1586 [details]
Additional sanity checks for FreeBSD EA emulation
Comment 9 Jeremy Allison 2005-11-21 18:57:17 UTC
Ok, I'll apply it once it gets the ok.
Jeremy.
Comment 10 Alex Masterov 2005-11-21 21:26:58 UTC
Created attachment 1587 [details]
Level 10 log after last patch

Hello Timur, Jeremy!

After last patch from Timur storing dos attributes to EAs works OK.
I've attached level 10 Log to illustrate this.

Thanks again!
Comment 11 Jeremy Allison 2005-11-21 23:04:18 UTC
Applied thanks.
Jeremy.