Skip to content

Commit 2b8ea09

Browse files
authored
Auto merge of #406 - philippkeller:shadowpw, r=alexcrichton
Add shadow password bindings Add shadow password bindings: setspent, endspent, getspent, getspnam plus spwd, the corresponding struct. [Example code](https://github.com/philippkeller/apue-rust/blob/master/src/bin/e06-01-shadow-pw.rs) (tested on Linux 4.4.0-21-generic)
2 parents ae70d3d + 04d0b71 commit 2b8ea09

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ fn main() {
163163
cfg.header("sys/msg.h");
164164
cfg.header("sys/shm.h");
165165
cfg.header("pty.h");
166+
cfg.header("shadow.h");
166167
}
167168

168169
if linux || android {

src/unix/notbsd/linux/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ s! {
118118
pub pw_shell: *mut ::c_char,
119119
}
120120

121+
pub struct spwd {
122+
pub sp_namp: *mut ::c_char,
123+
pub sp_pwdp: *mut ::c_char,
124+
pub sp_lstchg: ::c_long,
125+
pub sp_min: ::c_long,
126+
pub sp_max: ::c_long,
127+
pub sp_warn: ::c_long,
128+
pub sp_inact: ::c_long,
129+
pub sp_expire: ::c_long,
130+
pub sp_flag: ::c_ulong,
131+
}
132+
121133
pub struct statvfs {
122134
pub f_bsize: ::c_ulong,
123135
pub f_frsize: ::c_ulong,
@@ -543,6 +555,11 @@ extern {
543555

544556
pub fn setpwent();
545557
pub fn getpwent() -> *mut passwd;
558+
pub fn setspent();
559+
pub fn endspent();
560+
pub fn getspent() -> *mut spwd;
561+
pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
562+
546563
pub fn shm_open(name: *const c_char, oflag: ::c_int,
547564
mode: mode_t) -> ::c_int;
548565

0 commit comments

Comments
 (0)