@@ -281,9 +281,36 @@ s! {
281
281
pub msg_hdr: :: msghdr,
282
282
pub msg_len: :: c_uint,
283
283
}
284
+
285
+ pub struct __exit_status {
286
+ pub e_termination: u16 ,
287
+ pub e_exit: u16 ,
288
+ }
284
289
}
285
290
286
291
s_no_extra_traits ! {
292
+
293
+ pub struct utmpx {
294
+ pub ut_name: [ :: c_char; _UTX_USERSIZE] ,
295
+ pub ut_id: [ :: c_char; _UTX_IDSIZE] ,
296
+ pub ut_line: [ :: c_char; _UTX_LINESIZE] ,
297
+ pub ut_host: [ :: c_char; _UTX_HOSTSIZE] ,
298
+ pub ut_session: u16 ,
299
+ pub ut_type: u16 ,
300
+ pub ut_pid: :: pid_t,
301
+ pub ut_exit: __exit_status,
302
+ pub ut_ss: sockaddr_storage,
303
+ pub ut_tv: :: timeval,
304
+ pub ut_pad: [ u8 ; _UTX_PADSIZE] ,
305
+ }
306
+
307
+ pub struct lastlogx {
308
+ pub ll_tv: :: timeval,
309
+ pub ll_line: [ :: c_char; _UTX_LINESIZE] ,
310
+ pub ll_host: [ :: c_char; _UTX_HOSTSIZE] ,
311
+ pub ll_ss: sockaddr_storage,
312
+ }
313
+
287
314
pub struct in_pktinfo {
288
315
pub ipi_addr: :: in_addr,
289
316
pub ipi_ifindex: :: c_uint,
@@ -377,6 +404,93 @@ s_no_extra_traits! {
377
404
378
405
cfg_if ! {
379
406
if #[ cfg( feature = "extra_traits" ) ] {
407
+ impl PartialEq for utmpx {
408
+ fn eq( & self , other: & utmpx) -> bool {
409
+ self . ut_type == other. ut_type
410
+ && self . ut_pid == other. ut_pid
411
+ && self . ut_name == other. ut_name
412
+ && self . ut_line == other. ut_line
413
+ && self . ut_id == other. ut_id
414
+ && self . ut_exit == other. ut_exit
415
+ && self . ut_session == other. ut_session
416
+ && self . ut_tv == other. ut_tv
417
+ && self . ut_ss == other. ut_ss
418
+ && self . ut_pad == other. ut_pad
419
+ && self
420
+ . ut_host
421
+ . iter( )
422
+ . zip( other. ut_host. iter( ) )
423
+ . all( |( a, b) | a == b)
424
+ }
425
+ }
426
+
427
+ impl Eq for utmpx { }
428
+
429
+ impl :: fmt:: Debug for utmpx {
430
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
431
+ f. debug_struct( "utmpx" )
432
+ . field( "ut_name" , & self . ut_name)
433
+ . field( "ut_id" , & self . ut_id)
434
+ . field( "ut_line" , & self . ut_line)
435
+ . field( "ut_host" , & self . ut_host)
436
+ . field( "ut_session" , & self . ut_session)
437
+ . field( "ut_type" , & self . ut_type)
438
+ . field( "ut_pid" , & self . ut_pid)
439
+ . field( "ut_exit" , & self . ut_exit)
440
+ . field( "ut_ss" , & self . ut_ss)
441
+ . field( "ut_tv" , & self . ut_tv)
442
+ . field( "ut_pad" , & self . ut_pad)
443
+ . finish( )
444
+ }
445
+ }
446
+
447
+ impl :: hash:: Hash for utmpx {
448
+ fn hash<H : :: hash:: Hasher >( & self , state: & mut H ) {
449
+ self . ut_name. hash( state) ;
450
+ self . ut_type. hash( state) ;
451
+ self . ut_pid. hash( state) ;
452
+ self . ut_line. hash( state) ;
453
+ self . ut_id. hash( state) ;
454
+ self . ut_host. hash( state) ;
455
+ self . ut_exit. hash( state) ;
456
+ self . ut_session. hash( state) ;
457
+ self . ut_tv. hash( state) ;
458
+ self . ut_ss. hash( state) ;
459
+ self . ut_pad. hash( state) ;
460
+ }
461
+ }
462
+
463
+ impl PartialEq for lastlogx {
464
+ fn eq( & self , other: & lastlogx) -> bool {
465
+ self . ll_tv == other. ll_tv
466
+ && self . ll_line == other. ll_line
467
+ && self . ll_host == other. ll_host
468
+ && self . ll_ss == other. ll_ss
469
+ }
470
+ }
471
+
472
+ impl Eq for lastlogx { }
473
+
474
+ impl :: fmt:: Debug for lastlogx {
475
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
476
+ f. debug_struct( "lastlogx" )
477
+ . field( "ll_tv" , & self . ll_tv)
478
+ . field( "ll_line" , & self . ll_line)
479
+ . field( "ll_host" , & self . ll_host)
480
+ . field( "ll_ss" , & self . ll_ss)
481
+ . finish( )
482
+ }
483
+ }
484
+
485
+ impl :: hash:: Hash for lastlogx {
486
+ fn hash<H : :: hash:: Hasher >( & self , state: & mut H ) {
487
+ self . ll_tv. hash( state) ;
488
+ self . ll_line. hash( state) ;
489
+ self . ll_host. hash( state) ;
490
+ self . ll_ss. hash( state) ;
491
+ }
492
+ }
493
+
380
494
impl PartialEq for in_pktinfo {
381
495
fn eq( & self , other: & in_pktinfo) -> bool {
382
496
self . ipi_addr == other. ipi_addr
@@ -1378,6 +1492,28 @@ pub const ONLRET: ::tcflag_t = 0x40;
1378
1492
pub const CDTRCTS : :: tcflag_t = 0x00020000 ;
1379
1493
pub const CHWFLOW : :: tcflag_t = :: MDMBUF | :: CRTSCTS | :: CDTRCTS ;
1380
1494
1495
+ // pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx";
1496
+ // pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx";
1497
+ // pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx";
1498
+ // pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update";
1499
+ pub const _UTX_USERSIZE: usize = 32 ;
1500
+ pub const _UTX_LINESIZE: usize = 32 ;
1501
+ pub const _UTX_PADSIZE: usize = 40 ;
1502
+ pub const _UTX_IDSIZE: usize = 4 ;
1503
+ pub const _UTX_HOSTSIZE: usize = 256 ;
1504
+ pub const EMPTY : u16 = 0 ;
1505
+ pub const RUN_LVL : u16 = 1 ;
1506
+ pub const BOOT_TIME : u16 = 2 ;
1507
+ pub const OLD_TIME : u16 = 3 ;
1508
+ pub const NEW_TIME : u16 = 4 ;
1509
+ pub const INIT_PROCESS : u16 = 5 ;
1510
+ pub const LOGIN_PROCESS : u16 = 6 ;
1511
+ pub const USER_PROCESS : u16 = 7 ;
1512
+ pub const DEAD_PROCESS : u16 = 8 ;
1513
+ pub const ACCOUNTING : u16 = 9 ;
1514
+ pub const SIGNATURE : u16 = 10 ;
1515
+ pub const DOWN_TIME : u16 = 11 ;
1516
+
1381
1517
pub const SOCK_CLOEXEC : :: c_int = 0x10000000 ;
1382
1518
pub const SOCK_NONBLOCK : :: c_int = 0x20000000 ;
1383
1519
@@ -1738,6 +1874,28 @@ extern "C" {
1738
1874
buflen : :: size_t ,
1739
1875
result : * mut * mut :: group ,
1740
1876
) -> :: c_int ;
1877
+
1878
+ pub fn updwtmpx ( file : * const :: c_char , ut : * const utmpx ) -> :: c_int ;
1879
+ pub fn getlastlogx (
1880
+ fname : * const :: c_char ,
1881
+ uid : :: uid_t ,
1882
+ ll : * mut lastlogx ,
1883
+ ) -> * mut lastlogx ;
1884
+ pub fn updlastlogx (
1885
+ fname : * const :: c_char ,
1886
+ uid : :: uid_t ,
1887
+ ll : * mut lastlogx ,
1888
+ ) -> :: c_int ;
1889
+ pub fn utmpxname ( file : * const :: c_char ) -> :: c_int ;
1890
+ pub fn getutxent ( ) -> * mut utmpx ;
1891
+ pub fn getutxid ( ut : * const utmpx ) -> * mut utmpx ;
1892
+ pub fn getutxline ( ut : * const utmpx ) -> * mut utmpx ;
1893
+ pub fn pututxline ( ut : * const utmpx ) -> * mut utmpx ;
1894
+ pub fn setutxent ( ) ;
1895
+ pub fn endutxent ( ) ;
1896
+ // TODO: uncomment after utmp implementation
1897
+ // pub fn getutmp(ux: *const utmpx, u: *mut utmp);
1898
+ // pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
1741
1899
}
1742
1900
1743
1901
cfg_if ! {
0 commit comments