| ... | ... | @@ -45,6 +45,87 @@ pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_in |
| 45 | 45 | pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void; |
| 46 | 46 | pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void; |
| 47 | 47 | |
| 48 | pub const login_cap_t = extern struct { |
| 49 | lc_class: ?[*:0]const u8, |
| 50 | lc_cap: ?[*:0]const u8, |
| 51 | lc_style: ?[*:0]const u8 |
| 52 | }; |
| 53 | |
| 54 | pub extern "c" fn login_getclass(class: ?[*:0]const u8) ?*login_cap_t; |
| 55 | pub extern "c" fn login_getstyle(lc: *login_cap_t, style: ?[*:0]const u8, atype: ?[*:0]const u8) ?[*:0]const u8; |
| 56 | pub extern "c" fn login_getcapbool(lc: *login_cap_t, cap: [*:0]const u8, def: c_int) c_int; |
| 57 | pub extern "c" fn login_getcapnum(lc: *login_cap_t, cap: [*:0]const u8, def: i64, err: i64) i64; |
| 58 | pub extern "c" fn login_getcapsize(lc: *login_cap_t, cap: [*:0]const u8, def: i64, err: i64) i64; |
| 59 | pub extern "c" fn login_getcapstr(lc: *login_cap_t, cap: [*:0]const u8, def: [*:0]const u8, err: [*:0]const u8) [*:0]const u8; |
| 60 | pub extern "c" fn login_getcaptime(lc: *login_cap_t, cap: [*:0]const u8, def: i64, err: i64) i64; |
| 61 | pub extern "c" fn login_close(lc: *login_cap_t) void; |
| 62 | pub extern "c" fn setclasscontext(class: [*:0]const u8, flags: c_uint) c_int; |
| 63 | pub extern "c" fn setusercontext(lc: *login_cap_t, pwd: *passwd, uid: uid_t, flags: c_uint) c_int; |
| 64 | |
| 65 | pub const auth_session_t = opaque {}; |
| 66 | |
| 67 | pub extern "c" fn auth_userokay(name: [*:0]const u8, style: ?[*:0]const u8, arg_type: ?[*:0]const u8, password: ?[*:0]const u8) c_int; |
| 68 | pub extern "c" fn auth_approval(as: ?*auth_session_t, ?*login_cap_t, name: ?[*:0]const u8, type: ?[*:0]const u8) c_int; |
| 69 | pub extern "c" fn auth_userchallenge(name: [*:0]const u8, style: ?[*:0]const u8, arg_type: ?[*:0]const u8, chappengep: *?[*:0]const u8) ?*auth_session_t; |
| 70 | pub extern "c" fn auth_userresponse(as: *auth_session_t, response: [*:0]const u8, more: c_int) c_int; |
| 71 | pub extern "c" fn auth_usercheck(name: [*:0]const u8, style: ?[*:0]const u8, arg_type: ?[*:0]const u8, password: ?[*:0]const u8) ?*auth_session_t; |
| 72 | pub extern "c" fn auth_open() ?*auth_session_t; |
| 73 | pub extern "c" fn auth_close(as: *auth_session_t) c_int; |
| 74 | pub extern "c" fn auth_setdata(as: *auth_session_t, ptr: *anyopaque, len: usize) c_int; |
| 75 | pub extern "c" fn auth_setitem(as: *auth_session_t, item: auth_item_t, value: [*:0]const u8) c_int; |
| 76 | pub extern "c" fn auth_getitem(as: *auth_session_t, item: auth_item_t) ?[*:0]const u8; |
| 77 | pub extern "c" fn auth_setoption(as: *auth_session_t, n: [*:0]const u8, v: [*:0]const u8) c_int; |
| 78 | pub extern "c" fn auth_setstate(as: *auth_session_t, s: c_int) void; |
| 79 | pub extern "c" fn auth_getstate(as: *auth_session_t) c_int; |
| 80 | pub extern "c" fn auth_clean(as: *auth_session_t) void; |
| 81 | pub extern "c" fn auth_clrenv(as: *auth_session_t) void; |
| 82 | pub extern "c" fn auth_clroption(as: *auth_session_t, option: [*:0]const u8) void; |
| 83 | pub extern "c" fn auth_clroptions(as: *auth_session_t) void; |
| 84 | pub extern "c" fn auth_setenv(as: *auth_session_t) void; |
| 85 | pub extern "c" fn auth_getvalue(as: *auth_session_t, what: [*:0]const u8) ?[*:0]const u8; |
| 86 | pub extern "c" fn auth_verify(as: ?*auth_session_t, style: ?[*:0]const u8, name: ?[*:0]const u8, ...) ?*auth_session_t; |
| 87 | pub extern "c" fn auth_call(as: *auth_session_t, path: [*:0]const u8, ...) c_int; |
| 88 | pub extern "c" fn auth_challenge(as: *auth_session_t) [*:0]const u8; |
| 89 | pub extern "c" fn auth_check_expire(as: *auth_session_t) i64; |
| 90 | pub extern "c" fn auth_check_change(as: *auth_session_t) i64; |
| 91 | pub extern "c" fn auth_getpwd(as: *auth_session_t) ?*passwd; |
| 92 | pub extern "c" fn auth_setpwd(as: *auth_session_t, pwd: *passwd) c_int; |
| 93 | pub extern "c" fn auth_mkvalue(value: [*:0]const u8) ?[*:0]const u8; |
| 94 | pub extern "c" fn auth_cat(file: [*:0]const u8) c_int; |
| 95 | pub extern "c" fn auth_checknologin(lc: *login_cap_t) void; |
| 96 | // TODO: auth_set_va_list requires zig support for va_list type (#515) |
| 97 | |
| 98 | pub const passwd = extern struct { |
| 99 | pw_name: ?[*:0]const u8, // user name |
| 100 | pw_passwd: ?[*:0]const u8, // encrypted password |
| 101 | pw_uid: uid_t, // user uid |
| 102 | pw_gid: gid_t, // user gid |
| 103 | pw_change: time_t, // password change time |
| 104 | pw_class: ?[*:0]const u8, // user access class |
| 105 | pw_gecos: ?[*:0]const u8, // Honeywell login info |
| 106 | pw_dir: ?[*:0]const u8, // home directory |
| 107 | pw_shell: ?[*:0]const u8, // default shell |
| 108 | pw_expire: time_t, // account expiration |
| 109 | }; |
| 110 | |
| 111 | pub extern "c" fn getpwuid(uid: uid_t) ?*passwd; |
| 112 | pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd; |
| 113 | pub extern "c" fn getpwuid_shadow(uid: uid_t) ?*passwd; |
| 114 | pub extern "c" fn getpwnam_shadow(name: [*:0]const u8) ?*passwd; |
| 115 | pub extern "c" fn getpwnam_r(name: [*:0]const u8, pw: *passwd, buf: [*]u8, buflen: usize, pwretp: *?*passwd) c_int; |
| 116 | pub extern "c" fn getpwuid_r(uid: uid_t, pw: *passwd, buf: [*]u8, buflen: usize, pwretp: *?*passwd) c_int; |
| 117 | pub extern "c" fn getpwent() ?*passwd; |
| 118 | pub extern "c" fn setpwent() void; |
| 119 | pub extern "c" fn endpwent() void; |
| 120 | pub extern "c" fn setpassent(stayopen: c_int) c_int; |
| 121 | pub extern "c" fn uid_from_user(name: [*:0]const u8, uid: *uid_t) c_int; |
| 122 | pub extern "c" fn user_from_uid(uid: uid_t, noname: c_int) ?[*:0]const u8; |
| 123 | pub extern "c" fn bcrypt_gensalt(log_rounds: u8) [*:0]const u8; |
| 124 | pub extern "c" fn bcrypt(pass: [*:0]const u8, salt: [*:0]const u8) ?[*:0]const u8; |
| 125 | pub extern "c" fn bcrypt_newhash(pass: [*:0]const u8, log_rounds: c_int, hash: [*]u8, hashlen: usize) c_int; |
| 126 | pub extern "c" fn bcrypt_checkpass(pass: [*:0]const u8, goodhash: [*:0]const u8) c_int; |
| 127 | pub extern "c" fn pw_dup(pw: *const passwd) ?*passwd; |
| 128 | |
| 48 | 129 | pub const blkcnt_t = i64; |
| 49 | 130 | pub const blksize_t = i32; |
| 50 | 131 | pub const clock_t = i64; |