Skip to content

Commit 8cc2222

Browse files
committed
ancillary fix dragonfly build
1 parent d594910 commit 8cc2222

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -249,46 +249,46 @@ impl SocketCred {
249249
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
250250
#[must_use]
251251
pub fn new() -> SocketCred {
252-
SocketCred(libc::cmsgcred { cmsgcred_pid: 0, cmsgcred_uid: 0, cmsgcred_gid: 0 })
252+
SocketCred(libc::cmsgcred { cmcred_pid: 0, cmcred_uid: 0, cmcred_gid: 0 })
253253
}
254254

255255
/// Set the PID.
256256
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
257257
pub fn set_pid(&mut self, pid: libc::pid_t) {
258-
self.0.cmsgcred_pid = pid;
258+
self.0.cmcred_pid = pid;
259259
}
260260

261261
/// Get the current PID.
262262
#[must_use]
263263
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
264264
pub fn get_pid(&self) -> libc::pid_t {
265-
self.0.cmsgcred_pid
265+
self.0.cmcred_pid
266266
}
267267

268268
/// Set the UID.
269269
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
270270
pub fn set_uid(&mut self, uid: libc::uid_t) {
271-
self.0.cmsgcred_uid = uid;
271+
self.0.cmcred_uid = uid;
272272
}
273273

274274
/// Get the current UID.
275275
#[must_use]
276276
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
277277
pub fn get_uid(&self) -> libc::uid_t {
278-
self.0.cmsgcred_uid
278+
self.0.cmcred_uid
279279
}
280280

281281
/// Set the GID.
282282
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
283283
pub fn set_gid(&mut self, gid: libc::gid_t) {
284-
self.0.cmsgcred_gid = gid;
284+
self.0.cmcred_gid = gid;
285285
}
286286

287287
/// Get the current GID.
288288
#[must_use]
289289
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
290290
pub fn get_gid(&self) -> libc::gid_t {
291-
self.0.cmsgcred_gid
291+
self.0.cmcred_gid
292292
}
293293
}
294294

@@ -340,7 +340,7 @@ pub enum AncillaryError {
340340
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
341341
pub enum AncillaryData<'a> {
342342
ScmRights(ScmRights<'a>),
343-
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
343+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly"))]
344344
ScmCredentials(ScmCredentials<'a>),
345345
}
346346

@@ -363,7 +363,7 @@ impl<'a> AncillaryData<'a> {
363363
///
364364
/// `data` must contain a valid control message and the control message must be type of
365365
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDS`.
366-
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
366+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly"))]
367367
unsafe fn as_credentials(data: &'a [u8]) -> Self {
368368
let ancillary_data_iter = AncillaryDataIter::new(data);
369369
let scm_credentials = ScmCredentials(ancillary_data_iter);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl UnixStream {
415415
/// Ok(())
416416
/// }
417417
/// ```
418-
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
418+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly"))]
419419
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
420420
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
421421
self.0.set_passcred(passcred)
@@ -427,7 +427,7 @@ impl UnixStream {
427427
/// Get the socket option `SO_PASSCRED`.
428428
///
429429
/// [`set_passcred`]: UnixStream::set_passcred
430-
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
430+
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "dragonfly"))]
431431
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
432432
pub fn passcred(&self) -> io::Result<bool> {
433433
self.0.passcred()

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,30 @@ 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(target_os = "dragonfly")]
417+
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
418+
const SO_PASSCRED: libc::c_int = 0x4000;
419+
setsockopt(self, libc::SOL_SOCKET, SO_PASSCRED, passcred as libc::c_int)
420+
}
421+
422+
#[cfg(any(target_os = "android", target_os = "linux"))]
417423
pub fn passcred(&self) -> io::Result<bool> {
418424
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?;
419425
Ok(passcred != 0)
420426
}
421427

428+
#[cfg(target_os = "dragonfly")]
429+
pub fn passcred(&self) -> io::Result<bool> {
430+
const SO_PASSCRED: libc::c_int = 0x4000;
431+
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, SO_PASSCRED)?;
432+
Ok(passcred != 0)
433+
}
434+
422435
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
423436
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
424437
let mut nonblocking = nonblocking as libc::c_int;

0 commit comments

Comments
 (0)