-
Notifications
You must be signed in to change notification settings - Fork 697
Add shadow.h
functions
#1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add shadow.h
functions
#1173
Conversation
It looks like you need to set appropriate |
289f189
to
72ed1f1
Compare
|
@asomers Some of the builds were failing on 32-bit systems because I assumed that |
What's wrong with declaring the fields as |
I thought we didn't want to use C types, but now that I think about it, this project does it all the time. I will change it to use |
On another note, I tried GitHub's inbuilt "resolve merge conflict" functionality, and it seems to have merged master into this branch. Should I revert that change manually also? |
Yeah, you should manually rebase rather than use the "resolve conflicts" button. |
I've rebased and squashed. |
/// The minimum password age is the number of days the user will have to | ||
/// wait before she will be allowed to change their password again. | ||
/// An empty field and value 0 mean that there are no minimum password age. | ||
pub min: libc::c_long, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mysterious flag values, how about making this field a NonZeroIsize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, do you mean Option<NonZeroIsize>
, where zero corresponds to None
?
/// | ||
/// An empty field and value 0 mean that there are no password warning | ||
/// period. | ||
pub warn: libc::c_long, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An Option type would also be useful here.
/// | ||
/// The value 0 should not be used as it is interpreted as either an account | ||
/// with no expiration, or as an expiration on Jan 1, 1970. | ||
pub expire: libc::c_long, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like this could be a NonZeroIsize
.
/// | ||
/// A password field which starts with a exclamation mark means that the | ||
/// password is locked. | ||
pub password: CString, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use String
for name, but CString
for password?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of what I read from @ctrlcctrlv here: https://github.com/nix-rust/nix/pull/864/files
Because it's guaranteed that the fields I made
String
will conform toNAME_REGEX
.gecos
("real name") has no such guarantee.
/// ([`getspent()`][1], and [`endspent()`][1]) are not thread safe. | ||
/// | ||
/// [1]: http://man7.org/linux/man-pages/man3/shadow.3.html | ||
#[derive(Debug, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you call setspent
during construction?
/// println!("There are {} shadow entries", shadows.len()); | ||
/// ``` | ||
/// | ||
/// # Safety |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using the reentrant versions getspent_r
etc to solve the thread-safety problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently blocked by rust-lang/libc#1653
The code is adapted from the shadow crate, which is MIT licensed.