Added missing spwd::sp_lstchg field.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25560 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-05-19 02:16:12 +00:00
parent 087592136a
commit 89d327d66e
7 changed files with 23 additions and 10 deletions
+1
View File
@@ -11,6 +11,7 @@
struct spwd { struct spwd {
char* sp_namp; /* login name */ char* sp_namp; /* login name */
char* sp_pwdp; /* encrypted password */ 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_min; /* min days between password changes */
int sp_max; /* max days between password changes */ int sp_max; /* max days between password changes */
int sp_warn; /* days to warn before password expired */ int sp_warn; /* days to warn before password expired */
+2 -2
View File
@@ -128,8 +128,8 @@ status_t parse_group_line(char* line, char*& name, char*& password, gid_t& gid,
// shadow password // shadow password
status_t copy_shadow_pwd_to_buffer(const char* name, const char* 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, int lastChanged, int min, int max, int warn, int inactive, int expiration,
spwd* entry, char* buffer, size_t bufferSize); int flags, spwd* entry, char* buffer, size_t bufferSize);
status_t copy_shadow_pwd_to_buffer(const spwd* from, spwd* entry, status_t copy_shadow_pwd_to_buffer(const spwd* from, spwd* entry,
char* buffer, size_t bufferSize); char* buffer, size_t bufferSize);
+2
View File
@@ -10,6 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <time.h>
#include <unistd.h> #include <unistd.h>
#include <OS.h> #include <OS.h>
@@ -127,6 +128,7 @@ main(int argc, const char* const* argv)
// prepare request for the registrar // prepare request for the registrar
KMessage message(BPrivate::B_REG_UPDATE_USER); KMessage message(BPrivate::B_REG_UPDATE_USER);
if (message.AddInt32("uid", passwd->pw_uid) != B_OK 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("password", "x") != B_OK
|| message.AddString("shadow password", encryptedPassword) != B_OK) { || message.AddString("shadow password", encryptedPassword) != B_OK) {
fprintf(stderr, "Error: Out of memory!\n"); fprintf(stderr, "Error: Out of memory!\n");
+2
View File
@@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <time.h>
#include <unistd.h> #include <unistd.h>
#include <OS.h> #include <OS.h>
@@ -169,6 +170,7 @@ main(int argc, const char* const* argv)
|| message.AddString("shell", shell) != B_OK || message.AddString("shell", shell) != B_OK
|| message.AddString("real name", realName) != B_OK || message.AddString("real name", realName) != B_OK
|| message.AddString("shadow password", encryptedPassword) != 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("min", min) != B_OK
|| message.AddInt32("max", max) != B_OK || message.AddInt32("max", max) != B_OK
|| message.AddInt32("warn", warn) != B_OK || message.AddInt32("warn", warn) != B_OK
@@ -205,6 +205,9 @@ public:
// fLastChanged = now; // fLastChanged = now;
} }
if (message.FindInt32("last changed", &intValue) == B_OK)
fLastChanged = intValue;
if (message.FindInt32("min", &intValue) == B_OK) if (message.FindInt32("min", &intValue) == B_OK)
fMin = intValue; fMin = intValue;
@@ -245,6 +248,7 @@ public:
spwd.sp_namp = store.AppendString(fName); spwd.sp_namp = store.AppendString(fName);
spwd.sp_pwdp = store.AppendString(fShadowPassword); spwd.sp_pwdp = store.AppendString(fShadowPassword);
spwd.sp_lstchg = fLastChanged;
spwd.sp_min = fMin; spwd.sp_min = fMin;
spwd.sp_max = fMax; spwd.sp_max = fMax;
spwd.sp_warn = fWarn; spwd.sp_warn = fWarn;
+6 -4
View File
@@ -164,6 +164,7 @@ getspnam_r(const char *name, struct spwd *spwd, char *buffer,
return error; return error;
const char* password; const char* password;
int32 lastChanged;
int32 min; int32 min;
int32 max; int32 max;
int32 warn; int32 warn;
@@ -173,6 +174,7 @@ getspnam_r(const char *name, struct spwd *spwd, char *buffer,
if ((error = reply.FindString("name", &name)) != B_OK if ((error = reply.FindString("name", &name)) != B_OK
|| (error = reply.FindString("shadow password", &password)) != 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("min", &min)) != B_OK
|| (error = reply.FindInt32("max", &max)) != B_OK || (error = reply.FindInt32("max", &max)) != B_OK
|| (error = reply.FindInt32("warn", &warn)) != 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; return error;
} }
error = BPrivate::copy_shadow_pwd_to_buffer(name, password, min, max, warn, error = BPrivate::copy_shadow_pwd_to_buffer(name, password, lastChanged,
inactive, expiration, flags, spwd, buffer, bufferSize); min, max, warn, inactive, expiration, flags, spwd, buffer, bufferSize);
if (error == B_OK) if (error == B_OK)
*_result = spwd; *_result = spwd;
@@ -233,8 +235,8 @@ sgetspent_r(const char* _line, struct spwd *spwd, char *buffer,
if (status != B_OK) if (status != B_OK)
return status; return status;
status = BPrivate::copy_shadow_pwd_to_buffer(name, password, min, max, warn, status = BPrivate::copy_shadow_pwd_to_buffer(name, password, lastChanged,
inactive, expiration, flags, spwd, buffer, bufferSize); min, max, warn, inactive, expiration, flags, spwd, buffer, bufferSize);
if (status != B_OK) if (status != B_OK)
return status; return status;
@@ -309,9 +309,10 @@ BPrivate::parse_group_line(char* line, char*& name, char*& password, gid_t& gid,
status_t status_t
BPrivate::copy_shadow_pwd_to_buffer(const char* name, const char* password, BPrivate::copy_shadow_pwd_to_buffer(const char* name, const char* password,
int min, int max, int warn, int inactive, int expiration, int flags, int lastChanged, int min, int max, int warn, int inactive, int expiration,
spwd* entry, char* buffer, size_t bufferSize) int flags, spwd* entry, char* buffer, size_t bufferSize)
{ {
entry->sp_lstchg = lastChanged;
entry->sp_min = min; entry->sp_min = min;
entry->sp_max = max; entry->sp_max = max;
entry->sp_warn = warn; entry->sp_warn = warn;
@@ -334,8 +335,9 @@ BPrivate::copy_shadow_pwd_to_buffer(const spwd* from, spwd* entry,
char* buffer, size_t bufferSize) char* buffer, size_t bufferSize)
{ {
return copy_shadow_pwd_to_buffer(from->sp_namp, from->sp_pwdp, 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_lstchg, from->sp_min, from->sp_max, from->sp_warn,
from->sp_expire, from->sp_flag, entry, buffer, bufferSize); from->sp_inact, from->sp_expire, from->sp_flag, entry, buffer,
bufferSize);
} }