summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-26 08:02:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:19 -0500
commit39a236883ee4015980ff3d3cab8a8e5fec858502 (patch)
tree6d20f1364cf4f1dd0cc9e2237bfc9c96ce301186 /source4
parent0eb7588cc4d1fa423430e61ccbef19ec2453e164 (diff)
downloadsamba-39a236883ee4015980ff3d3cab8a8e5fec858502.tar.gz
samba-39a236883ee4015980ff3d3cab8a8e5fec858502.tar.bz2
samba-39a236883ee4015980ff3d3cab8a8e5fec858502.zip
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 used to be commit 41f9b144f9fe77e92f960bd11b1df397a63fd2d5)
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/auth_sam.c3
-rw-r--r--source4/include/includes.h3
-rw-r--r--source4/lib/time.c6
-rw-r--r--source4/rpc_server/samr/samdb.c16
4 files changed, 18 insertions, 10 deletions
diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c
index af4dc4fbbc..3b51b2f396 100644
--- a/source4/auth/auth_sam.c
+++ b/source4/auth/auth_sam.c
@@ -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)));
diff --git a/source4/include/includes.h b/source4/include/includes.h
index 5aa46c36cf..d067a0d214 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -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 */
diff --git a/source4/lib/time.c b/source4/lib/time.c
index e95d3a8d17..5fd8aa3081 100644
--- a/source4/lib/time.c
+++ b/source4/lib/time.c
@@ -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;
diff --git a/source4/rpc_server/samr/samdb.c b/source4/rpc_server/samr/samdb.c
index 9995f013ae..fd643c7bb0 100644
--- a/source4/rpc_server/samr/samdb.c
+++ b/source4/rpc_server/samr/samdb.c
@@ -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;
}