@@ -386,6 +386,88 @@ impl UnixStream {
386
386
self . 0 . set_nonblocking ( nonblocking)
387
387
}
388
388
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( any( doc, target_os = "netbsd" , target_os = "freebsd" ) ) ]
458
+ #[ unstable( feature = "acceptfilter" , issue = "none" ) ]
459
+ pub fn set_acceptfilter ( & self , name : & CStr ) -> io:: Result < ( ) > {
460
+ self . 0 . set_acceptfilter ( name)
461
+ }
462
+
463
+ /// Get a filter name if one had been set previously on the socket.
464
+ ///
465
+ #[ cfg( any( doc, target_os = "netbsd" , target_os = "freebsd" ) ) ]
466
+ #[ unstable( feature = "acceptfilter" , issue = "none" ) ]
467
+ pub fn acceptfilter ( & self ) -> io:: Result < & CStr > {
468
+ self . 0 . acceptfilter ( )
469
+ }
470
+ >>>>>>> 3257 f18365a ( adding the possiblity to remove the filter. )
389
471
/// Set the id of the socket for network filtering purpose
390
472
///
391
473
#[ cfg_attr(
0 commit comments