#1 2010-12-17 15:07:32

ysagon
Member
Registered: 2010-12-17
Posts: 4

TSQLRestClientURINamedPipe can't connect to server "Test"

Hello,

I'm currently trying to compile/launch the TestSQL3 project using Delphi XE on Windows Seven swiss/french

I've tried first with Synopse  e1492ec886

I've just added "..\" in the search path and was able to compile the project.

If I launch it, I got this exception (in debug mode):

'TSQLRestClientURINamedPipe can't connect to server "Test"
via "\\.\pipe\Sqlite3_Test":
Le fichier spécifié est introuvable'.
Processus TestSQL3.exe (5280)

Same results if not in debug mode.

I have tested it as well on windows Xp with no luck.

What could be the problem?

ps: I have tried sample no 2 with half success: the db3 file is created and I'm able to add records to it but not to read them. (I have checked that the data are written with sqllitebrowser)

Offline

#2 2010-12-17 16:01:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

There was a problem in the sqlite3_bind_text() official documentation: the SQLite site says that the Text_bytes parameter includes the #0 terminator, but in fact, it excludes it. So a #0 was added to the field content on the database, resulting in an error.

This affected only the source code repository version of the code. The official 1.11 worked as expected.
Since the new version in repository (pre version 1.12) uses prepared statements (parameters are written inlined in the SQL statement - see http://synopse.info/forum/viewtopic.php?pid=982 ), the sqlite3_bind_text() function was used instead of plain SQL. It trigerred the error.

About named pipes problem, what's your account level?
I've added a dedicated security setting for Vista and Seven. See InitializeSecurity() procedure in SQLite3Commons.
And tested the framework with windows 2000, XP, Vista and Seven.

Offline

#3 2010-12-17 16:11:47

ysagon
Member
Registered: 2010-12-17
Posts: 4

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

Thanks for the answer I will have a look at InitializeSecurity. I'm Administrator in Seven. I have tried to launch TestSQL3.exe as normal and as administrator with same results. I have as well tried with the 1.11 version.

Offline

#4 2010-12-17 16:24:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

This is very strange.

I didn't find any issue in my tests.
What is your AntiVirus software? Firewall settings?

See http://synopse.info/forum/viewtopic.php?id=43 to have a description of how I tried to fix security access with named pipes.

The safer way is perhaps to use:
- HTTP/1.1 for network client/server;
- GDI messages for local (same computer) connection.

Offline

#5 2010-12-17 17:39:30

ysagon
Member
Registered: 2010-12-17
Posts: 4

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

I have tried to launch this exe on several other windows:

Seven 64bit english without antivirus: ok
Xp 32 bit french with antivirus: not ok
Xp 32 bit virtual machine french without antivirus: not ok
Xp 32 bit virtual machine english without antivirus: not ok

I have deactivated my antivirus (Avast) on my Seven 32 bit french: not ok

Is it possible that it's somehting 32bit 64 bit related?

Thanks for your help

Offline

#6 2010-12-17 17:42:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

I'm running the test exe on Windows XP 32 bit (+Norton or +Avast) and Windows Seven 64 bit (+NOD32). Compiled with Delphi 6, 7, 2007, and 2010.
Without any problem.

If you start googling about it, you'll find out that there are some security parameters about named pipes access, in the registry.
In the network settings, as far as I remember.

Offline

#7 2010-12-17 17:49:59

ysagon
Member
Registered: 2010-12-17
Posts: 4

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

If you want to try the veresion that I compiled with delphi XE, it's here: http://dev.pvsyst.com/files/TestSQL3.exe

Offline

#8 2010-12-18 09:46:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

Your TestSQL3.exe run without any problem on my Windows Seven 64 bit system with Nod32 antivirus software.
Under Windows XP SP3 with AVAST, it failed.

I just tested a Delphi 7 compiled and a Delphi 2010 compiled version on the same Windows XP SP3. And both run successfully.

I don't understand what could be changed between Delphi 2010 and Delphi XE here... but I'm using only Windows API here, with a TFileName type for pipe name (i.e. an AnsiString before Delphi 2009, and an UnicodeString after, which is correct).

1) Could you debug step by step and try to guess if the PipeName is the same in both TSQLRestServer.ExportServerNamedPipe() and TSQLRestClientURINamedPipe.Create()?
2) Could you try to add some manifest in the TestSQL3.dpr, for instance {$R VISTA.RES} (this vista.res file is available in the latest SynopseSQLite3.zip or in our source code repository)?
3) Could you try to create a GUI application, then run the tests from there (perhaps it's due to some problems about the console application manifest created by XE)?

I don't have access to Delphi XE.

Offline

#9 2010-12-18 11:06:17

moggco
Member
Registered: 2010-09-27
Posts: 9

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

Open SQLite3Commons.pas, in "procedure TSQLRestServerNamedPipe.Execute",  change code as follow:

    aPipe := CreateNamedPipe(pointer(fPipeName),
      PIPE_ACCESS_DUPLEX,
      PIPE_TYPE_BYTE or PIPE_READMODE_BYTE or PIPE_WAIT,
      PIPE_UNLIMITED_INSTANCES, 0, 0, 0, nil{@fPipeSecurityAttributes});

In my XE, its work.

Refer to http://msdn.microsoft.com/en-us/library … S.85).aspx

Offline

#10 2010-12-18 11:30:38

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

This (could) mean(s) that InitializeSecurity() fails to create a valid TSecurityAttributes content.

But there is no reason why it changed with XE...

Could you check out the WIndows.pas unit in XE, to see if those definitions match:

function InitializeSecurityDescriptor(pSecurityDescriptor: PSecurityDescriptor;
  dwRevision: DWORD): BOOL; stdcall;
function SetSecurityDescriptorDacl(pSecurityDescriptor: PSecurityDescriptor;
  bDaclPresent: BOOL; pDacl: PACL; bDaclDefaulted: BOOL): BOOL; stdcall;

type
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: Pointer;
    bInheritHandle: BOOL;
  end;

const
  SECURITY_DESCRIPTOR_REVISION = 1;
  SECURITY_DESCRIPTOR_REVISION1 = 1;
  SECURITY_DESCRIPTOR_MIN_LENGTH = 20;

Offline

#11 2010-12-18 11:41:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

It's not suitable to leave the security parameters to nil.

The MSDN article you quote is outdated and will work only localy.

As I wrote in http://synopse.info/forum/viewtopic.php?id=43 this security parameter is mandatory...

See as reference:

Security Attribute for Named Pipes wrote:

If lpSecurityAttributes of CreateNamedPipe is NULL, the named pipe gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a named pipe grants full control to the LocalSystem account, administrators, and the creator owner. They also grant read access to members of the Everyone group and the anonymous account. In other words, with NULL as the security attribute, the named pipe cannot be connected with WRITE permission across the network, or from a local client running as a lower integrity level. Here, we fill the security attributes to grant EVERYONE all access (not just the connect access) to the server. This solves the cross-network and cross-IL issues, but it creates a security hole right there: the clients have WRITE_OWNER access and then the server just loses the control of the pipe object.
Code - Security Attributes (C++)

SECURITY_ATTRIBUTES sa;
sa.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
InitializeSecurityDescriptor(sa.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
// ACL is set as NULL in order to allow all access to the object.
SetSecurityDescriptorDacl(sa.lpSecurityDescriptor, TRUE, NULL, FALSE);
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;

see http://www.codeproject.com/KB/threads/C … play=Print

We'll have to find out a solution...

Offline

#12 2010-12-18 13:28:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

I've uploaded a modified unit to the source code repository.

Could you check it out under XE?

Offline

#13 2010-12-19 04:23:44

moggco
Member
Registered: 2010-09-27
Posts: 9

Re: TSQLRestClientURINamedPipe can't connect to server "Test"

In XE, those definitions are same as yours.

ab wrote:

This (could) mean(s) that InitializeSecurity() fails to create a valid TSecurityAttributes content.

But there is no reason why it changed with XE...

Could you check out the WIndows.pas unit in XE, to see if those definitions match:

function InitializeSecurityDescriptor(pSecurityDescriptor: PSecurityDescriptor;
  dwRevision: DWORD): BOOL; stdcall;
function SetSecurityDescriptorDacl(pSecurityDescriptor: PSecurityDescriptor;
  bDaclPresent: BOOL; pDacl: PACL; bDaclDefaulted: BOOL): BOOL; stdcall;

type
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: Pointer;
    bInheritHandle: BOOL;
  end;

const
  SECURITY_DESCRIPTOR_REVISION = 1;
  SECURITY_DESCRIPTOR_REVISION1 = 1;
  SECURITY_DESCRIPTOR_MIN_LENGTH = 20;

I try the trunk version, but the createnamepipe is failed.

    aPipe := CreateNamedPipe(Pointer(fPipeName),
      PIPE_ACCESS_DUPLEX,
      PIPE_TYPE_BYTE or PIPE_READMODE_BYTE or PIPE_WAIT,
      PIPE_UNLIMITED_INSTANCES, 0, 0, 0, @fPipeSecurityAttributes);
    if aPipe=INVALID_HANDLE_VALUE then

aPipe==INVALID_HANDLE_VALUE

I review the code, I can't find any wrong code.
TSecurityAttributes  should not use packed record,  in XE's windows.pas

  PSecurityAttributes = ^TSecurityAttributes;
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: Pointer;
    bInheritHandle: BOOL;
  end;

in Jediwinapi,

  PSECURITY_ATTRIBUTES = ^SECURITY_ATTRIBUTES;
  {$EXTERNALSYM PSECURITY_ATTRIBUTES}
  _SECURITY_ATTRIBUTES = record
    nLength: DWORD;
    lpSecurityDescriptor: LPVOID;
    bInheritHandle: BOOL;
  end;

of course, for TSecurityAttributes  , the packed record is same as record.

Offline

Board footer

Powered by FluxBB