mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
r904: - fixed account expiry testing in auth_sam
- added printf style format attribute checking to samdb varargs fns - fix nt_time_to_unix() for zero and -1 times
This commit is contained in:
parent
8feeecf303
commit
41f9b144f9
@ -90,8 +90,7 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
/* Test account expire time */
|
||||
|
||||
if ((*acct_expiry) != 0 && time(NULL) > nt_time_to_unix(*acct_expiry)) {
|
||||
if ((*acct_expiry) != -1 && time(NULL) > nt_time_to_unix(*acct_expiry)) {
|
||||
DEBUG(1,("sam_account_ok: Account for user '%s' has expired.\n", username));
|
||||
DEBUG(3,("sam_account_ok: Account expired at '%s'.\n",
|
||||
nt_time_string(mem_ctx, *acct_expiry)));
|
||||
|
@ -683,7 +683,10 @@ typedef int (*comparison_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
|
||||
/***** automatically generated prototypes *****/
|
||||
#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
|
||||
#include "proto.h"
|
||||
#undef _PRINTF_ATTRIBUTE
|
||||
#define _PRINTF_ATTRIBUTE(a1, a2)
|
||||
|
||||
/* String routines */
|
||||
|
||||
|
@ -91,6 +91,12 @@ It's originally in "100ns units since jan 1st 1601"
|
||||
****************************************************************************/
|
||||
time_t nt_time_to_unix(NTTIME nt)
|
||||
{
|
||||
if (nt == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (nt == -1LL) {
|
||||
return (time_t)-1;
|
||||
}
|
||||
nt += 1000*1000*10/2;
|
||||
nt /= 1000*1000*10;
|
||||
nt -= TIME_FIXUP_CONSTANT;
|
||||
|
@ -136,7 +136,7 @@ int samdb_search(void *ctx,
|
||||
const char *basedn,
|
||||
struct ldb_message ***res,
|
||||
const char * const *attrs,
|
||||
const char *format, ...)
|
||||
const char *format, ...) _PRINTF_ATTRIBUTE(6,7)
|
||||
{
|
||||
va_list ap;
|
||||
int count;
|
||||
@ -193,7 +193,7 @@ const char *samdb_search_string(void *ctx,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const char *basedn,
|
||||
const char *attr_name,
|
||||
const char *format, ...)
|
||||
const char *format, ...) _PRINTF_ATTRIBUTE(5,6)
|
||||
{
|
||||
va_list ap;
|
||||
const char *str;
|
||||
@ -214,7 +214,7 @@ uint_t samdb_search_uint(void *ctx,
|
||||
uint_t default_value,
|
||||
const char *basedn,
|
||||
const char *attr_name,
|
||||
const char *format, ...)
|
||||
const char *format, ...) _PRINTF_ATTRIBUTE(6,7)
|
||||
{
|
||||
va_list ap;
|
||||
int count;
|
||||
@ -240,7 +240,7 @@ int64_t samdb_search_int64(void *ctx,
|
||||
int64_t default_value,
|
||||
const char *basedn,
|
||||
const char *attr_name,
|
||||
const char *format, ...)
|
||||
const char *format, ...) _PRINTF_ATTRIBUTE(6,7)
|
||||
{
|
||||
va_list ap;
|
||||
int count;
|
||||
@ -267,7 +267,7 @@ int samdb_search_string_multiple(void *ctx,
|
||||
const char *basedn,
|
||||
const char ***strs,
|
||||
const char *attr_name,
|
||||
const char *format, ...)
|
||||
const char *format, ...) _PRINTF_ATTRIBUTE(6,7)
|
||||
{
|
||||
va_list ap;
|
||||
int count, i;
|
||||
@ -406,7 +406,7 @@ NTTIME samdb_result_allow_pwd_change(void *ctx, TALLOC_CTX *mem_ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
minPwdAge = samdb_search_int64(ctx, mem_ctx, 0, "minPwdAge", "dn=%s", domain_dn);
|
||||
minPwdAge = samdb_search_int64(ctx, mem_ctx, 0, NULL, "minPwdAge", "dn=%s", domain_dn);
|
||||
|
||||
/* yes, this is a -= not a += as minPwdAge is stored as the negative
|
||||
of the number of 100-nano-seconds */
|
||||
@ -429,9 +429,9 @@ NTTIME samdb_result_force_pwd_change(void *ctx, TALLOC_CTX *mem_ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
maxPwdAge = samdb_search_int64(ctx, mem_ctx, 0, "maxPwdAge", "dn=%s", domain_dn);
|
||||
maxPwdAge = samdb_search_int64(ctx, mem_ctx, 0, NULL, "maxPwdAge", "dn=%s", domain_dn);
|
||||
if (maxPwdAge == 0) {
|
||||
attr_time = 0;
|
||||
return 0;
|
||||
} else {
|
||||
attr_time -= maxPwdAge;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user