🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7640

Re: redirect standard consolle input/output and security. Please Mr.Gambit help me!

#7640
From: Remy Lebeau (TeamB)
Date: Wed, 29 Dec 2004 19:13
42 lines
2378 bytes
"Stefano Bonifazi" <stefboombastic@email.it> wrote in message
news:41d2f95b@newsgroups.borland.com...

>   //create pipe for the console stdout
>
if(!CreatePipe(&ChildSTDOUT_ReadPipeHandleTmp,&ChildSTDOUT_WritePipeHandle,&
sa,0))
>       return -1;
>   //create pipe for the console stderr
>
if(!CreatePipe(&ChildSTDERR_ReadPipeHandleTmp,&ChildSTDERR_WritePipeHandle,&
sa,0))
>       return -2;

You don't need separate pipes for stdout and stderr.  You can use the same
pipe for both of them.

>   if(!DuplicateHandle(hProcess, ChildSTDOUT_ReadPipeHandleTmp,hProcess,
> &ChildSTDOUT_ReadPipeHandle, 0, FALSE, DUPLICATE_SAME_ACCESS))
>    return -4;

Why are you duplicating the pipes you just created?

>   si.lpDesktop =  "WinSta0\\Default"; //also tried without anything
here!!!

Are you intending for the user logged into the service's machine to interact
with the console that you are creating?  If not, then get rid of that.  You
only need to specify the Desktop if you are going to make the console visual
for interaction with the user.  Otherwise, CreateProcessAsUser() creates the
console non-visually instead.

>   CloseHandle(TempTokenHandle);

You are closing the token while you are still impersonating the user and
while the console process is still running.  Wait until the console process
is terminated before doing that.  Also, if CreateProcessAsUser() fails, you
are not removing the impersonation.


Gambit
Technical Details
Message-ID: <41d30173@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41d2f95b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,244542df6edac1be
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41d2f95b@newsgroups.borland.com>
Subject: Re: redirect standard consolle input/output and security. Please Mr.Gambit help me!
Date: Wed, 29 Dec 2004 11:13:05 -0800
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <41d30173@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1104347507 68.69.17.41 (29 Dec 2004 11:11:47 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail