Skip to content

Commit ef261a8

Browse files
committed
build fix
1 parent a2aaa1a commit ef261a8

File tree

4 files changed

+28
-97
lines changed

4 files changed

+28
-97
lines changed

library/std/src/os/freebsd/net.rs

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
#![unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
44

5+
use crate::ffi::CStr;
56
use crate::io;
67
use crate::os::unix::net;
78
use crate::sealed::Sealed;
@@ -40,6 +41,15 @@ pub trait UnixSocketExt: Sealed {
4041
/// ```
4142
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
4243
fn set_local_creds_persistent(&self, local_creds_persistent: bool) -> io::Result<()>;
44+
45+
/// Get a filter name if one had been set previously on the socket.
46+
#[unstable(feature = "acceptfilter", issue = "121891")]
47+
fn acceptfilter(&self) -> io::Result<&CStr>;
48+
49+
/// Set or disable a filter on the socket to filter incoming connections
50+
/// to defer it before accept(2)
51+
#[unstable(feature = "acceptfilter", issue = "121891")]
52+
fn set_acceptfilter(&self, name: &CStr) -> io::Result<()>;
4353
}
4454

4555
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
@@ -51,6 +61,14 @@ impl UnixSocketExt for net::UnixDatagram {
5161
fn set_local_creds_persistent(&self, local_creds_persistent: bool) -> io::Result<()> {
5262
self.as_inner().set_local_creds_persistent(local_creds_persistent)
5363
}
64+
65+
fn acceptfilter(&self) -> io::Result<&CStr> {
66+
self.as_inner().acceptfilter()
67+
}
68+
69+
fn set_acceptfilter(&self, name: &CStr) -> io::Result<()> {
70+
self.as_inner().set_acceptfilter(name)
71+
}
5472
}
5573

5674
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
@@ -62,4 +80,12 @@ impl UnixSocketExt for net::UnixStream {
6280
fn set_local_creds_persistent(&self, local_creds_persistent: bool) -> io::Result<()> {
6381
self.as_inner().set_local_creds_persistent(local_creds_persistent)
6482
}
83+
84+
fn acceptfilter(&self) -> io::Result<&CStr> {
85+
self.as_inner().acceptfilter()
86+
}
87+
88+
fn set_acceptfilter(&self, name: &CStr) -> io::Result<()> {
89+
self.as_inner().set_acceptfilter(name)
90+
}
6591
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
22
use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
33
use super::{sockaddr_un, SocketAddr};
4-
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
5-
use crate::ffi::CStr;
64
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
75
use crate::io::{IoSlice, IoSliceMut};
86
use crate::net::Shutdown;

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

-93
Original file line numberDiff line numberDiff line change
@@ -386,99 +386,6 @@ impl UnixStream {
386386
self.0.set_nonblocking(nonblocking)
387387
}
388388

389-
<<<<<<< HEAD
390-
=======
391-
/// Moves the socket to pass unix credentials as control message in [`SocketAncillary`].
392-
///
393-
/// Set the socket option `SO_PASSCRED`.
394-
///
395-
/// # Examples
396-
///
397-
#[cfg_attr(
398-
any(
399-
target_os = "android",
400-
target_os = "linux",
401-
target_os = "netbsd",
402-
target_os = "freebsd"
403-
),
404-
doc = "```no_run"
405-
)]
406-
#[cfg_attr(
407-
not(any(
408-
target_os = "android",
409-
target_os = "linux",
410-
target_os = "netbsd",
411-
target_os = "freebsd"
412-
)),
413-
doc = "```ignore"
414-
)]
415-
/// #![feature(unix_socket_ancillary_data)]
416-
/// use std::os::unix::net::UnixStream;
417-
///
418-
/// fn main() -> std::io::Result<()> {
419-
/// let socket = UnixStream::connect("/tmp/sock")?;
420-
/// socket.set_passcred(true).expect("Couldn't set passcred");
421-
/// Ok(())
422-
/// }
423-
/// ```
424-
#[cfg(any(
425-
doc,
426-
target_os = "android",
427-
target_os = "linux",
428-
target_os = "netbsd",
429-
target_os = "freebsd"
430-
))]
431-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
432-
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
433-
self.0.set_passcred(passcred)
434-
}
435-
436-
/// Get the current value of the socket for passing unix credentials in [`SocketAncillary`].
437-
/// This value can be change by [`set_passcred`].
438-
///
439-
/// Get the socket option `SO_PASSCRED`.
440-
///
441-
/// [`set_passcred`]: UnixStream::set_passcred
442-
#[cfg(any(
443-
doc,
444-
target_os = "android",
445-
target_os = "linux",
446-
target_os = "netbsd",
447-
target_os = "freebsd"
448-
))]
449-
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
450-
pub fn passcred(&self) -> io::Result<bool> {
451-
self.0.passcred()
452-
}
453-
454-
/// Set a filter name on the socket to filter incoming connections to defer it before accept(2)
455-
///
456-
/// an empty name allows to remove this connection's filter
457-
#[cfg_attr(any(target_os = "freebsd", target_os = "netbsd"), doc = "```no_run")]
458-
#[cfg_attr(not(any(target_os = "freebsd", target_os = "netbsd")), doc = "```ignore")]
459-
/// #![feature(unix_set_mark)]
460-
/// use std::os::unix::net::UnixStream;
461-
///
462-
/// fn main() -> std::io::Result<()> {
463-
/// let sock = UnixStream::connect("/tmp/sock")?;
464-
/// sock.set_acceptfilter(&c"http")?;
465-
/// Ok(())
466-
/// }
467-
/// ```
468-
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
469-
#[unstable(feature = "acceptfilter", issue = "121891")]
470-
pub fn set_acceptfilter(&self, name: &CStr) -> io::Result<()> {
471-
self.0.set_acceptfilter(name)
472-
}
473-
474-
/// Get a filter name if one had been set previously on the socket.
475-
///
476-
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
477-
#[unstable(feature = "acceptfilter", issue = "121891")]
478-
pub fn acceptfilter(&self) -> io::Result<&CStr> {
479-
self.0.acceptfilter()
480-
}
481-
>>>>>>> 3257f18365a (adding the possiblity to remove the filter.)
482389
/// Set the id of the socket for network filtering purpose
483390
///
484391
#[cfg_attr(

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use crate::thread;
88
use crate::time::Duration;
99

1010
#[cfg(target_os = "android")]
11-
use crate::os::android::net::{SocketAddrExt, UnixSocketExt};
11+
use crate::os::android::net::SocketAddrExt;
1212

1313
#[cfg(target_os = "linux")]
14-
use crate::os::linux::net::{SocketAddrExt, UnixSocketExt};
14+
use crate::os::linux::net::SocketAddrExt;
1515

1616
macro_rules! or_panic {
1717
($e:expr) => {

0 commit comments

Comments
 (0)