On Thu, Jun 23, 2016 at 2:20 AM, Gert Doering <[email protected]> wrote:
> On Wed, Jun 22, 2016 at 10:42:42PM -0400, Selva Nair wrote:
> > - The process id is returned as a message formatted in the same manner
> > as error messages from the service to the client: i.e., a three-line
> > message with pid formatted as 0x%08x on line 1, "Process Id" on
> > line 2 and a blank line 3.
> >
> > This provides a way for service clients to check the status of openvpn
> > and terminate it without needing management interface or exit event.
> > Useful when the interactive service is used from a launch script, or
> > to force-terminate openvpn from the GUI if/when needed.
>
> How does the GUI currently handle return messages? As in, does this
> need GUI changes, or is the GUI prepared to handle anything that comes
> along?
>
Currently the GUI interpretes two custom error codes (0x2000000 and
0x20000001) and ignores the rest. So it will just a log a message and
ignore this one. Unless the PID happens to match one of those two numbers.
Though I've never seen PIDs that large.
An alternative is to set error = 0 and pass PID as the second line:
"0x00000000\nPID\Process ID"
where PID may be formatted as 0x%08x. May be that is better?
> >
> > +static VOID
> > +ReturnProcessId (HANDLE pipe, DWORD pid, DWORD count, LPHANDLE events)
> > +{
> > + const WCHAR msg[] = L"\nProcess ID\n";
> > + WCHAR buf[10 + _countof(msg)]; /* 10 characters for the pid in 0x%08x
> format */
> > +
> > + /* A 3-line string like an error message but with pid in place of
> error number */
> > + _snwprintf (buf, _countof(buf), L"0x%08x%s", pid, msg);
> > + buf[_countof(buf) - 1] = '\0';
> > +
> > + WritePipeAsync (pipe, buf, wcslen (buf) * 2, count, events);
> > +}
>
> Where does the extra blank line come from? If I'm not all confused
> (this is before my first cup of tea) this will write
>
> %08x\nProcess ID\n
>
> into the buffer, and not \n\n...
May be its my terminology of what is a "line", not your tea. The currently
used format is NUMBER\nLINE2\nLINE3 so there is no \n at the end of line
3. In the present case that would be "%08x\nProcess ID\n"
Thanks for looking into this.
Selva