diff --git a/headers/posix/shadow.h b/headers/posix/shadow.h index d57c5ad0e9..fede78d786 100644 --- a/headers/posix/shadow.h +++ b/headers/posix/shadow.h @@ -11,6 +11,7 @@ struct spwd { char* sp_namp; /* login name */ char* sp_pwdp; /* encrypted password */ + int sp_lstchg; /* date of last change (days since 1970) */ int sp_min; /* min days between password changes */ int sp_max; /* max days between password changes */ int sp_warn; /* days to warn before password expired */ diff --git a/headers/private/libroot/user_group.h b/headers/private/libroot/user_group.h index 858dbd6ad6..a6c1631032 100644 --- a/headers/private/libroot/user_group.h +++ b/headers/private/libroot/user_group.h @@ -128,8 +128,8 @@ status_t parse_group_line(char* line, char*& name, char*& password, gid_t& gid, // shadow password status_t copy_shadow_pwd_to_buffer(const char* name, const char* password, - int min, int max, int warn, int inactive, int expiration, int flags, - spwd* entry, char* buffer, size_t bufferSize); + int lastChanged, int min, int max, int warn, int inactive, int expiration, + int flags, spwd* entry, char* buffer, size_t bufferSize); status_t copy_shadow_pwd_to_buffer(const spwd* from, spwd* entry, char* buffer, size_t bufferSize); diff --git a/src/bin/multiuser/passwd.cpp b/src/bin/multiuser/passwd.cpp index ab08db6cfd..58d86208b7 100644 --- a/src/bin/multiuser/passwd.cpp +++ b/src/bin/multiuser/passwd.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -127,6 +128,7 @@ main(int argc, const char* const* argv) // prepare request for the registrar KMessage message(BPrivate::B_REG_UPDATE_USER); if (message.AddInt32("uid", passwd->pw_uid) != B_OK + || message.AddInt32("last changed", time(NULL)) != B_OK || message.AddString("password", "x") != B_OK || message.AddString("shadow password", encryptedPassword) != B_OK) { fprintf(stderr, "Error: Out of memory!\n"); diff --git a/src/bin/multiuser/useradd.cpp b/src/bin/multiuser/useradd.cpp index aa1e0ac353..45220840a6 100644 --- a/src/bin/multiuser/useradd.cpp +++ b/src/bin/multiuser/useradd.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -169,6 +170,7 @@ main(int argc, const char* const* argv) || message.AddString("shell", shell) != B_OK || message.AddString("real name", realName) != B_OK || message.AddString("shadow password", encryptedPassword) != B_OK + || message.AddInt32("last changed", time(NULL)) != B_OK || message.AddInt32("min", min) != B_OK || message.AddInt32("max", max) != B_OK || message.AddInt32("warn", warn) != B_OK diff --git a/src/servers/registrar/AuthenticationManager.cpp b/src/servers/registrar/AuthenticationManager.cpp index 0726eb62ae..8d27fe77e3 100644 --- a/src/servers/registrar/AuthenticationManager.cpp +++ b/src/servers/registrar/AuthenticationManager.cpp @@ -205,6 +205,9 @@ public: // fLastChanged = now; } + if (message.FindInt32("last changed", &intValue) == B_OK) + fLastChanged = intValue; + if (message.FindInt32("min", &intValue) == B_OK) fMin = intValue; @@ -245,6 +248,7 @@ public: spwd.sp_namp = store.AppendString(fName); spwd.sp_pwdp = store.AppendString(fShadowPassword); + spwd.sp_lstchg = fLastChanged; spwd.sp_min = fMin; spwd.sp_max = fMax; spwd.sp_warn = fWarn; diff --git a/src/system/libroot/posix/shadow.cpp b/src/system/libroot/posix/shadow.cpp index 58c05f19d3..999f6b3cd9 100644 --- a/src/system/libroot/posix/shadow.cpp +++ b/src/system/libroot/posix/shadow.cpp @@ -164,6 +164,7 @@ getspnam_r(const char *name, struct spwd *spwd, char *buffer, return error; const char* password; + int32 lastChanged; int32 min; int32 max; int32 warn; @@ -173,6 +174,7 @@ getspnam_r(const char *name, struct spwd *spwd, char *buffer, if ((error = reply.FindString("name", &name)) != B_OK || (error = reply.FindString("shadow password", &password)) != B_OK + || (error = reply.FindInt32("last changed", &lastChanged)) != B_OK || (error = reply.FindInt32("min", &min)) != B_OK || (error = reply.FindInt32("max", &max)) != B_OK || (error = reply.FindInt32("warn", &warn)) != B_OK @@ -182,8 +184,8 @@ getspnam_r(const char *name, struct spwd *spwd, char *buffer, return error; } - error = BPrivate::copy_shadow_pwd_to_buffer(name, password, min, max, warn, - inactive, expiration, flags, spwd, buffer, bufferSize); + error = BPrivate::copy_shadow_pwd_to_buffer(name, password, lastChanged, + min, max, warn, inactive, expiration, flags, spwd, buffer, bufferSize); if (error == B_OK) *_result = spwd; @@ -233,8 +235,8 @@ sgetspent_r(const char* _line, struct spwd *spwd, char *buffer, if (status != B_OK) return status; - status = BPrivate::copy_shadow_pwd_to_buffer(name, password, min, max, warn, - inactive, expiration, flags, spwd, buffer, bufferSize); + status = BPrivate::copy_shadow_pwd_to_buffer(name, password, lastChanged, + min, max, warn, inactive, expiration, flags, spwd, buffer, bufferSize); if (status != B_OK) return status; diff --git a/src/system/libroot/posix/user_group_common.cpp b/src/system/libroot/posix/user_group_common.cpp index 82327496e5..39f75452c5 100644 --- a/src/system/libroot/posix/user_group_common.cpp +++ b/src/system/libroot/posix/user_group_common.cpp @@ -309,9 +309,10 @@ BPrivate::parse_group_line(char* line, char*& name, char*& password, gid_t& gid, status_t BPrivate::copy_shadow_pwd_to_buffer(const char* name, const char* password, - int min, int max, int warn, int inactive, int expiration, int flags, - spwd* entry, char* buffer, size_t bufferSize) + int lastChanged, int min, int max, int warn, int inactive, int expiration, + int flags, spwd* entry, char* buffer, size_t bufferSize) { + entry->sp_lstchg = lastChanged; entry->sp_min = min; entry->sp_max = max; entry->sp_warn = warn; @@ -334,8 +335,9 @@ BPrivate::copy_shadow_pwd_to_buffer(const spwd* from, spwd* entry, char* buffer, size_t bufferSize) { return copy_shadow_pwd_to_buffer(from->sp_namp, from->sp_pwdp, - from->sp_min, from->sp_max, from->sp_warn, from->sp_inact, - from->sp_expire, from->sp_flag, entry, buffer, bufferSize); + from->sp_lstchg, from->sp_min, from->sp_max, from->sp_warn, + from->sp_inact, from->sp_expire, from->sp_flag, entry, buffer, + bufferSize); }