Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
78a3078c
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
78a3078c
编写于
12月 16, 2021
作者:
D
David CARLIER
提交者:
GitHub
12月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "socket ancillary data implementation for dragonflybsd."
上级
1d01550f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
92 deletion
+8
-92
library/std/src/os/unix/net/ancillary.rs
library/std/src/os/unix/net/ancillary.rs
+2
-80
library/std/src/os/unix/net/datagram.rs
library/std/src/os/unix/net/datagram.rs
+4
-10
library/std/src/sys/unix/net.rs
library/std/src/sys/unix/net.rs
+2
-2
未找到文件。
library/std/src/os/unix/net/ancillary.rs
浏览文件 @
78a3078c
...
...
@@ -16,8 +16,6 @@ mod libc {
pub
use
libc
::
c_int
;
pub
struct
ucred
;
pub
struct
cmsghdr
;
#[cfg(target_os
=
"dragonfly"
)]
pub
struct
cmsgcred
;
pub
type
pid_t
=
i32
;
pub
type
gid_t
=
u32
;
pub
type
uid_t
=
u32
;
...
...
@@ -185,11 +183,6 @@ fn next(&mut self) -> Option<T> {
#[derive(Clone)]
pub
struct
SocketCred
(
libc
::
ucred
);
#[cfg(target_os
=
"dragonfly"
)]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
#[derive(Clone)]
pub
struct
SocketCred
(
libc
::
cmsgcred
);
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,))]
impl
SocketCred
{
/// Create a Unix credential struct.
...
...
@@ -241,57 +234,6 @@ pub fn get_gid(&self) -> libc::gid_t {
}
}
#[cfg(target_os
=
"dragonfly"
)]
impl
SocketCred
{
/// Create a Unix credential struct.
///
/// PID, UID and GID is set to 0.
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
#[must_use]
pub
fn
new
()
->
SocketCred
{
SocketCred
(
libc
::
cmsgcred
{
cmsgcred_pid
:
0
,
cmsgcred_uid
:
0
,
cmsgcred_gid
:
0
})
}
/// Set the PID.
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
set_pid
(
&
mut
self
,
pid
:
libc
::
pid_t
)
{
self
.0
.cmsgcred_pid
=
pid
;
}
/// Get the current PID.
#[must_use]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
get_pid
(
&
self
)
->
libc
::
pid_t
{
self
.0
.cmsgcred_pid
}
/// Set the UID.
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
set_uid
(
&
mut
self
,
uid
:
libc
::
uid_t
)
{
self
.0
.cmsgcred_uid
=
uid
;
}
/// Get the current UID.
#[must_use]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
get_uid
(
&
self
)
->
libc
::
uid_t
{
self
.0
.cmsgcred_uid
}
/// Set the GID.
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
set_gid
(
&
mut
self
,
gid
:
libc
::
gid_t
)
{
self
.0
.cmsgcred_gid
=
gid
;
}
/// Get the current GID.
#[must_use]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
get_gid
(
&
self
)
->
libc
::
gid_t
{
self
.0
.cmsgcred_gid
}
}
/// This control message contains file descriptors.
///
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
...
...
@@ -314,11 +256,7 @@ fn next(&mut self) -> Option<RawFd> {
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
struct
ScmCredentials
<
'a
>
(
AncillaryDataIter
<
'a
,
libc
::
ucred
>
);
#[cfg(target_os
=
"dragonfly"
)]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
struct
ScmCredentials
<
'a
>
(
AncillaryDataIter
<
'a
,
libc
::
cmsgcred
>
);
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
,))]
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,))]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
impl
<
'a
>
Iterator
for
ScmCredentials
<
'a
>
{
type
Item
=
SocketCred
;
...
...
@@ -362,7 +300,7 @@ unsafe fn as_rights(data: &'a [u8]) -> Self {
/// # Safety
///
/// `data` must contain a valid control message and the control message must be type of
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDS`.
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CRED
ENTIAL
S`.
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,))]
unsafe
fn
as_credentials
(
data
:
&
'a
[
u8
])
->
Self
{
let
ancillary_data_iter
=
AncillaryDataIter
::
new
(
data
);
...
...
@@ -382,9 +320,6 @@ fn try_from_cmsghdr(cmsg: &'a libc::cmsghdr) -> Result<Self, AncillaryError> {
libc
::
SCM_RIGHTS
=>
Ok
(
AncillaryData
::
as_rights
(
data
)),
#[cfg(any(target_os
=
"android"
,
target_os
=
"linux"
,))]
libc
::
SCM_CREDENTIALS
=>
Ok
(
AncillaryData
::
as_credentials
(
data
)),
#[cfg(target_os
=
"dragonfly"
)]
libc
::
SCM_CREDS
=>
Ok
(
AncillaryData
::
as_credentials
(
data
)),
cmsg_type
=>
{
Err
(
AncillaryError
::
Unknown
{
cmsg_level
:
libc
::
SOL_SOCKET
,
cmsg_type
})
}
...
...
@@ -609,19 +544,6 @@ pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool {
)
}
#[cfg(target_os
=
"dragonfly"
)]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
add_creds
(
&
mut
self
,
creds
:
&
[
SocketCred
])
->
bool
{
self
.truncated
=
false
;
add_to_ancillary_data
(
&
mut
self
.buffer
,
&
mut
self
.length
,
creds
,
libc
::
SOL_SOCKET
,
libc
::
SCM_CREDS
,
)
}
/// Clears the ancillary data, removing all values.
///
/// # Example
...
...
library/std/src/os/unix/net/datagram.rs
浏览文件 @
78a3078c
...
...
@@ -854,14 +854,8 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
///
/// # Examples
///
#[cfg_attr(
any(target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
),
doc
=
"```no_run"
)]
#[cfg_attr(
not(any(target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
)),
doc
=
"```ignore"
)]
#[cfg_attr(any(target_os
=
"android"
,
target_os
=
"linux"
),
doc
=
"```no_run"
)]
#[cfg_attr(not(any(target_os
=
"android"
,
target_os
=
"linux"
)),
doc
=
"```ignore"
)]
/// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::UnixDatagram;
///
...
...
@@ -871,7 +865,7 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
/// Ok(())
/// }
/// ```
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
,
))]
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,))]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
set_passcred
(
&
self
,
passcred
:
bool
)
->
io
::
Result
<
()
>
{
self
.0
.set_passcred
(
passcred
)
...
...
@@ -883,7 +877,7 @@ pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
/// Get the socket option `SO_PASSCRED`.
///
/// [`set_passcred`]: UnixDatagram::set_passcred
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
,
))]
#[cfg(any(doc,
target_os
=
"android"
,
target_os
=
"linux"
,))]
#[unstable(feature
=
"unix_socket_ancillary_data"
,
issue
=
"76915"
)]
pub
fn
passcred
(
&
self
)
->
io
::
Result
<
bool
>
{
self
.0
.passcred
()
...
...
library/std/src/sys/unix/net.rs
浏览文件 @
78a3078c
...
...
@@ -408,12 +408,12 @@ pub fn nodelay(&self) -> io::Result<bool> {
Ok
(
raw
!=
0
)
}
#[cfg(any(target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
,
))]
#[cfg(any(target_os
=
"android"
,
target_os
=
"linux"
,))]
pub
fn
set_passcred
(
&
self
,
passcred
:
bool
)
->
io
::
Result
<
()
>
{
setsockopt
(
self
,
libc
::
SOL_SOCKET
,
libc
::
SO_PASSCRED
,
passcred
as
libc
::
c_int
)
}
#[cfg(any(target_os
=
"android"
,
target_os
=
"linux"
,
target_os
=
"dragonfly"
,
))]
#[cfg(any(target_os
=
"android"
,
target_os
=
"linux"
,))]
pub
fn
passcred
(
&
self
)
->
io
::
Result
<
bool
>
{
let
passcred
:
libc
::
c_int
=
getsockopt
(
self
,
libc
::
SOL_SOCKET
,
libc
::
SO_PASSCRED
)
?
;
Ok
(
passcred
!=
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录