Skip to content

Commit e69acda

Browse files
authored
Rollup merge of rust-lang#92025 - devnexen:revert-91553-anc_data_dfbsd, r=kennytm
Revert "socket ancillary data implementation for dragonflybsd." Reverts rust-lang#91553
2 parents d2f2f0b + 78a3078 commit e69acda

File tree

3 files changed

+8
-92
lines changed

3 files changed

+8
-92
lines changed

library/std/src/os/unix/net/ancillary.rs

+2-80
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ mod libc {
1616
pub use libc::c_int;
1717
pub struct ucred;
1818
pub struct cmsghdr;
19-
#[cfg(target_os = "dragonfly")]
20-
pub struct cmsgcred;
2119
pub type pid_t = i32;
2220
pub type gid_t = u32;
2321
pub type uid_t = u32;
@@ -185,11 +183,6 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
185183
#[derive(Clone)]
186184
pub struct SocketCred(libc::ucred);
187185

188-
#[cfg(target_os = "dragonfly")]
189-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
190-
#[derive(Clone)]
191-
pub struct SocketCred(libc::cmsgcred);
192-
193186
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
194187
impl SocketCred {
195188
/// Create a Unix credential struct.
@@ -241,57 +234,6 @@ impl SocketCred {
241234
}
242235
}
243236

244-
#[cfg(target_os = "dragonfly")]
245-
impl SocketCred {
246-
/// Create a Unix credential struct.
247-
///
248-
/// PID, UID and GID is set to 0.
249-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
250-
#[must_use]
251-
pub fn new() -> SocketCred {
252-
SocketCred(libc::cmsgcred { cmsgcred_pid: 0, cmsgcred_uid: 0, cmsgcred_gid: 0 })
253-
}
254-
255-
/// Set the PID.
256-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
257-
pub fn set_pid(&mut self, pid: libc::pid_t) {
258-
self.0.cmsgcred_pid = pid;
259-
}
260-
261-
/// Get the current PID.
262-
#[must_use]
263-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
264-
pub fn get_pid(&self) -> libc::pid_t {
265-
self.0.cmsgcred_pid
266-
}
267-
268-
/// Set the UID.
269-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
270-
pub fn set_uid(&mut self, uid: libc::uid_t) {
271-
self.0.cmsgcred_uid = uid;
272-
}
273-
274-
/// Get the current UID.
275-
#[must_use]
276-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
277-
pub fn get_uid(&self) -> libc::uid_t {
278-
self.0.cmsgcred_uid
279-
}
280-
281-
/// Set the GID.
282-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
283-
pub fn set_gid(&mut self, gid: libc::gid_t) {
284-
self.0.cmsgcred_gid = gid;
285-
}
286-
287-
/// Get the current GID.
288-
#[must_use]
289-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
290-
pub fn get_gid(&self) -> libc::gid_t {
291-
self.0.cmsgcred_gid
292-
}
293-
}
294-
295237
/// This control message contains file descriptors.
296238
///
297239
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
@@ -314,11 +256,7 @@ impl<'a> Iterator for ScmRights<'a> {
314256
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
315257
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::ucred>);
316258

317-
#[cfg(target_os = "dragonfly")]
318-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
319-
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::cmsgcred>);
320-
321-
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly",))]
259+
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
322260
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
323261
impl<'a> Iterator for ScmCredentials<'a> {
324262
type Item = SocketCred;
@@ -362,7 +300,7 @@ impl<'a> AncillaryData<'a> {
362300
/// # Safety
363301
///
364302
/// `data` must contain a valid control message and the control message must be type of
365-
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDS`.
303+
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDENTIALS`.
366304
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
367305
unsafe fn as_credentials(data: &'a [u8]) -> Self {
368306
let ancillary_data_iter = AncillaryDataIter::new(data);
@@ -382,9 +320,6 @@ impl<'a> AncillaryData<'a> {
382320
libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)),
383321
#[cfg(any(target_os = "android", target_os = "linux",))]
384322
libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)),
385-
#[cfg(target_os = "dragonfly")]
386-
libc::SCM_CREDS => Ok(AncillaryData::as_credentials(data)),
387-
388323
cmsg_type => {
389324
Err(AncillaryError::Unknown { cmsg_level: libc::SOL_SOCKET, cmsg_type })
390325
}
@@ -609,19 +544,6 @@ impl<'a> SocketAncillary<'a> {
609544
)
610545
}
611546

612-
#[cfg(target_os = "dragonfly")]
613-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
614-
pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool {
615-
self.truncated = false;
616-
add_to_ancillary_data(
617-
&mut self.buffer,
618-
&mut self.length,
619-
creds,
620-
libc::SOL_SOCKET,
621-
libc::SCM_CREDS,
622-
)
623-
}
624-
625547
/// Clears the ancillary data, removing all values.
626548
///
627549
/// # Example

library/std/src/os/unix/net/datagram.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -854,14 +854,8 @@ impl UnixDatagram {
854854
///
855855
/// # Examples
856856
///
857-
#[cfg_attr(
858-
any(target_os = "android", target_os = "linux", target_os = "dragonfly"),
859-
doc = "```no_run"
860-
)]
861-
#[cfg_attr(
862-
not(any(target_os = "android", target_os = "linux", target_os = "dragonfly")),
863-
doc = "```ignore"
864-
)]
857+
#[cfg_attr(any(target_os = "android", target_os = "linux"), doc = "```no_run")]
858+
#[cfg_attr(not(any(target_os = "android", target_os = "linux")), doc = "```ignore")]
865859
/// #![feature(unix_socket_ancillary_data)]
866860
/// use std::os::unix::net::UnixDatagram;
867861
///
@@ -871,7 +865,7 @@ impl UnixDatagram {
871865
/// Ok(())
872866
/// }
873867
/// ```
874-
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly",))]
868+
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
875869
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
876870
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
877871
self.0.set_passcred(passcred)
@@ -883,7 +877,7 @@ impl UnixDatagram {
883877
/// Get the socket option `SO_PASSCRED`.
884878
///
885879
/// [`set_passcred`]: UnixDatagram::set_passcred
886-
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly",))]
880+
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
887881
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
888882
pub fn passcred(&self) -> io::Result<bool> {
889883
self.0.passcred()

library/std/src/sys/unix/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ impl Socket {
408408
Ok(raw != 0)
409409
}
410410

411-
#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly",))]
411+
#[cfg(any(target_os = "android", target_os = "linux",))]
412412
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
413413
setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int)
414414
}
415415

416-
#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly",))]
416+
#[cfg(any(target_os = "android", target_os = "linux",))]
417417
pub fn passcred(&self) -> io::Result<bool> {
418418
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?;
419419
Ok(passcred != 0)

0 commit comments

Comments
 (0)