hi all, I have a strange problem using the libsmbclient api.. retrieving or stating files named with percents in is for some of them impossible. Example: a file located at "smb://test/test/%7C2.txt" cannot be retrieved with my code, smbc_open fails with the code NT_STATUS_OBJECT_NAME_INVALID.
I am not sure but, url encoding/decoding that would escape strings with "percent" in should be 'internals' of samba right ? At the same time under the same constraints, a file named 'whatever-you-want-except-with-percent' is correctly stated, opened, read. I tested the code on several distributions (debian, gentoo..) with the same results. I tried with several CIFS servers too (Win Xp, linux...). Attached: the source and the trace given by smbc_init with debug = 9. Anyone any idea ? the code: -------------------------------------------------------------------------------------- #include <sys/types.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <time.h> #include <errno.h> #include <libsmbclient.h> static void get_auth_data_fn(const char * pServer, const char * pShare, char * pWorkgroup, int maxLenWorkgroup, char * pUsername, int maxLenUsername, char * pPassword, int maxLenPassword) { sprintf( pWorkgroup, "%s", "WG" ); sprintf( pUsername, "%s", "test" ); sprintf( pPassword, "%s", "test" ); } int main(int argc, char * argv[]) { int fd; int ret; int debug = 9; int savedErrno; char buffer[2048]; char * pSmbPath = NULL; if (argc == 2) { pSmbPath = argv[1]; } else { printf("usage: " "%s [ smb://path/to/file ]\n", argv[0]); return 1; } smbc_init(get_auth_data_fn, debug); printf("Open file %s\n", pSmbPath); if ((fd = smbc_open(pSmbPath, O_RDONLY, 0)) < 0) { perror("smbc_open"); return 1; } do { ret = smbc_read(fd, buffer, sizeof(buffer)); savedErrno = errno; if (ret > 0) fwrite(buffer, 1, ret, stdout); } while (ret > 0); smbc_close(fd); if (ret < 0) { errno = savedErrno; perror("read"); return 1; } return 0; } ------------------------------------------------------------------------------ the tail of the trace: Server connect ok: //regis/dossier: 0x8050508 write_socket(4,88) write_socket(4,88) wrote 88 size=35 smb_com=0x2d smb_rcls=51 smb_reh=0 smb_err=49152 smb_flg=136 smb_flg2=51201 smb_tid=2048 smb_pid=13079 smb_uid=2048 smb_mid=5 smt_wct=0 smb_bcc=0 smbc errno NT_STATUS_OBJECT_NAME_INVALID -> 22 smbc_open: Argument invalide Open file smb://regis/dossier/a%7C2.txt -- Mattieu PUEL Recherche & développement -- Intradot Labs SAS +33 4 78 80 87 90 | www.intradot.com -- Intradot a déménagé ! Notez bien notre nouvelle adresse : 97 rue Racine - 69100 Villeurbanne
lp_load: refreshing parameters Initialising global parameters params.c:OpenConfFile() - Unable to open configuration file "/home/vodmat/.smb/smb.conf": No such file or directory pm_process() returned No lp_servicenumber: couldn't find homes Attempting to register new charset UCS-2LE Registered charset UCS-2LE Attempting to register new charset UTF-16LE Registered charset UTF-16LE Attempting to register new charset UCS-2BE Registered charset UCS-2BE Attempting to register new charset UTF-16BE Registered charset UTF-16BE Attempting to register new charset UTF8 Registered charset UTF8 Attempting to register new charset UTF-8 Registered charset UTF-8 Attempting to register new charset ASCII Registered charset ASCII Attempting to register new charset 646 Registered charset 646 Attempting to register new charset ISO-8859-1 Registered charset ISO-8859-1 Attempting to register new charset UCS2-HEX Registered charset UCS2-HEX Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Substituting charset 'ISO-8859-15' for LOCALE Could not load config file: /home/vodmat/.smb/smb.conf lp_load: refreshing parameters params.c:pm_process() - Processing configuration file "/etc/samba/smb.conf" Processing section "[global]" doing parameter display charset = UTF-8 doing parameter unix charset = ISO8859-15 doing parameter workgroup = INTRADOT doing parameter server string = %h server (Samba %v) doing parameter dns proxy = no doing parameter log file = /var/log/samba/log.%m doing parameter max log size = 1000 doing parameter syslog = 0 doing parameter panic action = /usr/share/samba/panic-action %d doing parameter security = share doing parameter invalid users = root doing parameter passwd program = /usr/bin/passwd %u doing parameter passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n . doing parameter socket options = TCP_NODELAY pm_process() returned Yes lp_servicenumber: couldn't find homes lp_load: refreshing parameters params.c:OpenConfFile() - Unable to open configuration file "/home/vodmat/.smb/smb.conf.append": Aucun fichier ou répertoire de ce type pm_process() returned No lp_servicenumber: couldn't find homes added interface ip=192.168.2.101 bcast=192.168.2.255 nmask=255.255.255.0 Using netbios name VODMAT. Using workgroup INTRADOT. smbc_server: server_n=[regis] server=[regis] -> server_n=[regis] server=[regis] Opening cache file at /var/run/samba/gencache.tdb tdb(unnamed): tdb_open_ex: could not open file /var/run/samba/gencache.tdb: Permission non accordée gencache_init: Opening cache file /var/run/samba/gencache.tdb read-only. no entry for regis#20 found. resolve_lmhosts: Attempting lmhosts lookup for name regis<0x20> startlmhosts: Can't open lmhosts file /etc/samba/lmhosts. Error was Aucun fichier ou répertoire de ce type resolve_wins: Attempting wins lookup for name regis<0x20> resolve_wins: WINS server resolution selected and no WINS servers listed. resolve_hosts: Attempting host lookup for name regis<0x20> namecache_store: storing 1 address for regis#20: 192.168.2.120:0 Connecting to 192.168.2.120 at port 445 socket option SO_KEEPALIVE = 0 socket option SO_REUSEADDR = 0 socket option SO_BROADCAST = 0 socket option TCP_NODELAY = 1 socket option TCP_KEEPCNT = 9 socket option TCP_KEEPIDLE = 7200 socket option TCP_KEEPINTVL = 75 socket option IPTOS_LOWDELAY = 0 socket option IPTOS_THROUGHPUT = 0 socket option SO_SNDBUF = 16384 socket option SO_RCVBUF = 87380 socket option SO_SNDLOWAT = 1 socket option SO_RCVLOWAT = 1 socket option SO_SNDTIMEO = 0 socket option SO_RCVTIMEO = 0 session request ok write_socket(4,183) write_socket(4,183) wrote 183 size=85 smb_com=0x72 smb_rcls=0 smb_reh=0 smb_err=0 smb_flg=136 smb_flg2=51201 smb_tid=0 smb_pid=13079 smb_uid=0 smb_mid=1 smt_wct=17 smb_vwv[ 0]= 8 (0x8) smb_vwv[ 1]= 2563 (0xA03) smb_vwv[ 2]= 256 (0x100) smb_vwv[ 3]= 1024 (0x400) smb_vwv[ 4]= 17 (0x11) smb_vwv[ 5]= 0 (0x0) smb_vwv[ 6]= 256 (0x100) smb_vwv[ 7]= 0 (0x0) smb_vwv[ 8]= 0 (0x0) smb_vwv[ 9]=64768 (0xFD00) smb_vwv[10]= 227 (0xE3) smb_vwv[11]=16512 (0x4080) smb_vwv[12]=24216 (0x5E98) smb_vwv[13]= 2468 (0x9A4) smb_vwv[14]=51091 (0xC793) smb_vwv[15]=34817 (0x8801) smb_vwv[16]= 255 (0xFF) smb_bcc=16 size=85 smb_com=0x72 smb_rcls=0 smb_reh=0 smb_err=0 smb_flg=136 smb_flg2=51201 smb_tid=0 smb_pid=13079 smb_uid=0 smb_mid=1 smt_wct=17 smb_vwv[ 0]= 8 (0x8) smb_vwv[ 1]= 2563 (0xA03) smb_vwv[ 2]= 256 (0x100) smb_vwv[ 3]= 1024 (0x400) smb_vwv[ 4]= 17 (0x11) smb_vwv[ 5]= 0 (0x0) smb_vwv[ 6]= 256 (0x100) smb_vwv[ 7]= 0 (0x0) smb_vwv[ 8]= 0 (0x0) smb_vwv[ 9]=64768 (0xFD00) smb_vwv[10]= 227 (0xE3) smb_vwv[11]=16512 (0x4080) smb_vwv[12]=24216 (0x5E98) smb_vwv[13]= 2468 (0x9A4) smb_vwv[14]=51091 (0xC793) smb_vwv[15]=34817 (0x8801) smb_vwv[16]= 255 (0xFF) smb_bcc=16 Doing spnego session setup (blob length=16) server didn't supply a full spnego negprot write_socket(4,166) write_socket(4,166) wrote 166 size=273 smb_com=0x73 smb_rcls=22 smb_reh=0 smb_err=49152 smb_flg=136 smb_flg2=51201 smb_tid=0 smb_pid=13079 smb_uid=2048 smb_mid=2 smt_wct=4 smb_vwv[ 0]= 255 (0xFF) smb_vwv[ 1]= 273 (0x111) smb_vwv[ 2]= 0 (0x0) smb_vwv[ 3]= 156 (0x9C) smb_bcc=230 size=273 smb_com=0x73 smb_rcls=22 smb_reh=0 smb_err=49152 smb_flg=136 smb_flg2=51201 smb_tid=0 smb_pid=13079 smb_uid=2048 smb_mid=2 smt_wct=4 smb_vwv[ 0]= 255 (0xFF) smb_vwv[ 1]= 273 (0x111) smb_vwv[ 2]= 0 (0x0) smb_vwv[ 3]= 156 (0x9C) smb_bcc=230 Got challenge flags: Got NTLMSSP neg_flags=0x628a0215 NTLMSSP_NEGOTIATE_UNICODE NTLMSSP_REQUEST_TARGET NTLMSSP_NEGOTIATE_SIGN NTLMSSP_NEGOTIATE_NTLM NTLMSSP_CHAL_ACCEPT_RESPONSE NTLMSSP_NEGOTIATE_NTLM2 NTLMSSP_CHAL_TARGET_INFO NTLMSSP_NEGOTIATE_128 NTLMSSP_NEGOTIATE_KEY_EXCH NTLMSSP: Set final flags: Got NTLMSSP neg_flags=0x60080215 NTLMSSP_NEGOTIATE_UNICODE NTLMSSP_REQUEST_TARGET NTLMSSP_NEGOTIATE_SIGN NTLMSSP_NEGOTIATE_NTLM NTLMSSP_NEGOTIATE_NTLM2 NTLMSSP_NEGOTIATE_128 NTLMSSP_NEGOTIATE_KEY_EXCH NTLMSSP challenge set by NTLM2 challenge is: [000] 0C 80 A2 A6 20 69 B3 E0 ..¢Š i³à NTLMSSP Sign/Seal - Initialising with flags: Got NTLMSSP neg_flags=0x60080215 NTLMSSP_NEGOTIATE_UNICODE NTLMSSP_REQUEST_TARGET NTLMSSP_NEGOTIATE_SIGN NTLMSSP_NEGOTIATE_NTLM NTLMSSP_NEGOTIATE_NTLM2 NTLMSSP_NEGOTIATE_128 NTLMSSP_NEGOTIATE_KEY_EXCH write_socket(4,250) write_socket(4,250) wrote 250 size=126 smb_com=0x73 smb_rcls=0 smb_reh=0 smb_err=0 smb_flg=136 smb_flg2=51201 smb_tid=0 smb_pid=13079 smb_uid=2048 smb_mid=3 smt_wct=4 smb_vwv[ 0]= 255 (0xFF) smb_vwv[ 1]= 126 (0x7E) smb_vwv[ 2]= 0 (0x0) smb_vwv[ 3]= 9 (0x9) smb_bcc=83 size=126 smb_com=0x73 smb_rcls=0 smb_reh=0 smb_err=0 smb_flg=136 smb_flg2=51201 smb_tid=0 smb_pid=13079 smb_uid=2048 smb_mid=3 smt_wct=4 smb_vwv[ 0]= 255 (0xFF) smb_vwv[ 1]= 126 (0x7E) smb_vwv[ 2]= 0 (0x0) smb_vwv[ 3]= 9 (0x9) smb_bcc=83 session setup ok write_socket(4,86) write_socket(4,86) wrote 86 size=54 smb_com=0x75 smb_rcls=0 smb_reh=0 smb_err=0 smb_flg=136 smb_flg2=51201 smb_tid=2048 smb_pid=13079 smb_uid=2048 smb_mid=4 smt_wct=3 smb_vwv[ 0]= 255 (0xFF) smb_vwv[ 1]= 54 (0x36) smb_vwv[ 2]= 1 (0x1) smb_bcc=13 tconx ok Server connect ok: //regis/dossier: 0x8050508 write_socket(4,88) write_socket(4,88) wrote 88 size=35 smb_com=0x2d smb_rcls=51 smb_reh=0 smb_err=49152 smb_flg=136 smb_flg2=51201 smb_tid=2048 smb_pid=13079 smb_uid=2048 smb_mid=5 smt_wct=0 smb_bcc=0 smbc errno NT_STATUS_OBJECT_NAME_INVALID -> 22 smbc_open: Argument invalide Open file smb://regis/dossier/a%7C2.txt
-- To unsubscribe from this list go to the following URL and read the instructions: https://lists.samba.org/mailman/listinfo/samba