mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: GetSocketClientProcessId under FreeBSD
This commit is contained in:
parent
51c7dfbcaa
commit
ee51398cd4
1 changed files with 29 additions and 29 deletions
|
|
@ -81,11 +81,6 @@ type
|
|||
cmcred_groups: array[0..15] of gid_t; //* groups */
|
||||
end;
|
||||
|
||||
cmsg = record
|
||||
hdr: cmsghdr;
|
||||
cred: cmsgcred;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
const
|
||||
|
|
@ -145,36 +140,38 @@ var
|
|||
buf: Byte;
|
||||
iov: iovec;
|
||||
msg: msghdr;
|
||||
cmsga: cmsg;
|
||||
cmsga: Pcmsghdr;
|
||||
nbytes: ssize_t;
|
||||
data: array[Byte] of Byte;
|
||||
begin
|
||||
cmsga := Pcmsghdr(@data[0]);
|
||||
{*
|
||||
* The backend doesn't care what we send here, but it wants
|
||||
* exactly one character to force recvmsg() to block and wait
|
||||
* for us.
|
||||
*}
|
||||
buf := 0;
|
||||
iov.iov_base := @buf;
|
||||
iov.iov_len := 1;
|
||||
buf := 0;
|
||||
iov.iov_base := @buf;
|
||||
iov.iov_len := 1;
|
||||
|
||||
cmsga.hdr.cmsg_len := sizeof(cmsg);
|
||||
cmsga.hdr.cmsg_level := SOL_SOCKET;
|
||||
cmsga.hdr.cmsg_type := SCM_CREDS;
|
||||
{*
|
||||
* cmsg.cred will get filled in with the correct information
|
||||
* by the kernel when this message is sent.
|
||||
*}
|
||||
msg.msg_name := nil;
|
||||
msg.msg_namelen := 0;
|
||||
msg.msg_iov := @iov;
|
||||
msg.msg_iovlen := 1;
|
||||
msg.msg_control := @cmsga;
|
||||
msg.msg_controllen := sizeof(cmsga);
|
||||
msg.msg_flags := MSG_NOSIGNAL;
|
||||
cmsga^.cmsg_len := CMSG_LEN(SizeOf(cmsgcred));
|
||||
cmsga^.cmsg_level := SOL_SOCKET;
|
||||
cmsga^.cmsg_type := SCM_CREDS;
|
||||
{*
|
||||
* cmsg.cred will get filled in with the correct information
|
||||
* by the kernel when this message is sent.
|
||||
*}
|
||||
msg.msg_name := nil;
|
||||
msg.msg_namelen := 0;
|
||||
msg.msg_iov := @iov;
|
||||
msg.msg_iovlen := 1;
|
||||
msg.msg_control := cmsga;
|
||||
msg.msg_controllen := CMSG_SPACE(SizeOf(cmsgcred));
|
||||
msg.msg_flags := MSG_NOSIGNAL;
|
||||
|
||||
nbytes := SendMessage(fd, @msg, MSG_NOSIGNAL);
|
||||
if (nbytes = -1) then
|
||||
DCDebug('SendMessage: ', SysErrorMessage(fpgetCerrno));
|
||||
DCDebug('SendMessage: ', SysErrorMessage(fpgetCerrno));
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
|
@ -202,15 +199,18 @@ var
|
|||
buf: Byte;
|
||||
iov: iovec;
|
||||
msg: msghdr;
|
||||
cmsga: cmsg;
|
||||
cmsga: Pcmsghdr;
|
||||
nbytes: ssize_t;
|
||||
data: array[Byte] of Byte;
|
||||
begin
|
||||
cmsga := Pcmsghdr(@data[0]);
|
||||
|
||||
msg.msg_name := nil;
|
||||
msg.msg_namelen := 0;
|
||||
msg.msg_iov := @iov;
|
||||
msg.msg_iovlen := 1;
|
||||
msg.msg_control := @cmsga;
|
||||
msg.msg_controllen := sizeof(cmsga);
|
||||
msg.msg_control := cmsga;
|
||||
msg.msg_controllen := CMSG_SPACE(SizeOf(cmsgcred));
|
||||
msg.msg_flags := MSG_NOSIGNAL;
|
||||
{*
|
||||
* The one character which is received here is not meaningful;
|
||||
|
|
@ -224,7 +224,7 @@ begin
|
|||
if (nbytes = -1) then
|
||||
DCDebug('RecvMessage: ', SysErrorMessage(fpgetCerrno));
|
||||
|
||||
Result:= cmsga.cred.cmcred_pid;
|
||||
Result:= Pcmsgcred(CMSG_DATA(cmsga))^.cmcred_pid;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue