[Samba] libsmbclient help

赵晶 yingmu1983 at gmail.com
Wed Jan 13 12:06:23 UTC 2021


Hi Samba team,

We're evaluating the use of libsmbclient API + smbclient utility
combination to back up a CIFS/SMB share from a Linux box. There are some
questions. Please help.

1. There is no way to query Alternate Data Streams for a file in
libsmbclient. So we use smbclient 'allinfo'.

*Is the output format of 'allinfo' guaranteed to be fixed (especially w.r.t
the three stream lines below)?* We need to parse the stream names out of
the allinfo result.

smb: \> allinfo ads.txt
altname: ads.txt
create_time:    Mon Dec 14 08:32:07 AM 2020 EST
access_time:    Mon Dec 14 08:32:18 AM 2020 EST
write_time:     Mon Dec 14 08:33:22 AM 2020 EST
change_time:    Mon Dec 21 03:20:05 AM 2020 EST
attributes: A (20)
stream: [::$DATA], 3 bytes
stream: [:extra:$DATA], 8 bytes
stream: [:extra2:$DATA], 9 bytes

2. We need to get security info (e.g, ACL, owner, groups, etc) of each
file/folder. Right now we query them using smbc_getxattr() and parse the
result. *Is the result format supposed to change (keywords as "OWNER:",
"GROUPS:", "ACL:")*?

ACL info of smb://jingcs2.testlab.commvault.com/share/ads.txt:
REVISION:1,OWNER:S-1-5-32-544,GROUP:S-1-5-21-2539487108-1620125676-1447297442-513,ACL:S-1-5-21-2539487108-1620125676-1447297442-1010:1/16/0x001f01ff,ACL:S-1-5-18:0/16/0x001f01ff,ACL:S-1-5-21-2539487108-1620125676-1447297442-500:0/16/0x001f01ff,ACL:S-1-5-21-3393418607-3554941549-4209072599-1105:0/16/0x001f01ff,ACL:S-1-5-32-544:0/16/0x001f01ff,MODE:0x81e4,SIZE:3,A_TIME:1607952738,M_TIME:1607952802,C_TIME:1607952802,INODE:1143351355398743040

3. *I don't find any API in libsmbclient to get reparse point info, e.g.,
to query allocation ranges for a sparse file. Is there a way to archive
this?*
   Right now smbc_read() gets the file as a complete non-sparse file (so is
smbclient's "get" command).

4. We include libsmbclient.h and links to libsmbclient.so. *Is it good
practice if we ship libsmbclient.so and its dependencies within our
products or use the ones shipped in the client environment? If the latter
case (don't ship ourselves), are the libsmbclient APIs (i.e., smbc_XXX)
guaranteed to be compatible across different Samba versions?* (e.g.,
older/newer versions of libsmbclient.so is installed on customer's clients,
will any API break?)

5. *If we smbc_init() once and use different threads (which share the same
smb context) to access/download the same share (of course different
directories/files), is this supported in current model?*

Thanks,
Eric


More information about the samba mailing list