summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/client/client.c4
-rw-r--r--source/client/clitar.c49
-rw-r--r--source/include/client.h6
-rw-r--r--source/include/libsmb_internal.h15
-rw-r--r--source/include/libsmbclient.h16
-rw-r--r--source/include/rpc_netlogon.h24
-rw-r--r--source/include/rpc_perfcount.h12
-rw-r--r--source/include/rpc_samr.h6
-rw-r--r--source/include/smb.h5
-rw-r--r--source/include/smbprofile.h1047
-rw-r--r--source/intl/lang_tdb.c2
-rw-r--r--source/lib/debug.c2
-rw-r--r--source/lib/substitute.c2
-rw-r--r--source/lib/time.c1557
-rw-r--r--source/lib/util.c2
-rw-r--r--source/lib/util_str.c285
-rw-r--r--source/libads/authdata.c4
-rw-r--r--source/libmsrpc/libmsrpc.c8
-rw-r--r--source/libmsrpc/libmsrpc_internal.c12
-rw-r--r--source/libsmb/cliconnect.c10
-rw-r--r--source/libsmb/clierror.c2
-rw-r--r--source/libsmb/clifile.c43
-rw-r--r--source/libsmb/clifsinfo.c57
-rw-r--r--source/libsmb/clilist.c44
-rw-r--r--source/libsmb/clirap.c58
-rw-r--r--source/libsmb/libsmbclient.c610
-rw-r--r--source/libsmb/trusts_util.c2
-rw-r--r--source/nsswitch/winbindd_cache.c8
-rw-r--r--source/nsswitch/winbindd_pam.c16
-rw-r--r--source/nsswitch/winbindd_rpc.c4
-rw-r--r--source/param/loadparm.c6
-rw-r--r--source/rpc_client/cli_netlogon.c2
-rw-r--r--source/rpc_client/cli_reg.c2
-rw-r--r--source/rpc_parse/parse_lsa.c14
-rw-r--r--source/rpc_parse/parse_misc.c35
-rw-r--r--source/rpc_parse/parse_net.c5
-rw-r--r--source/rpc_parse/parse_ntsvcs.c4
-rw-r--r--source/rpc_parse/parse_prs.c50
-rw-r--r--source/rpc_parse/parse_samr.c19
-rw-r--r--source/rpc_parse/parse_spoolss.c4
-rw-r--r--source/rpc_server/srv_samr_util.c36
-rw-r--r--source/rpc_server/srv_spoolss_nt.c29
-rw-r--r--source/rpcclient/cmd_lsarpc.c10
-rw-r--r--source/rpcclient/cmd_netlogon.c5
-rw-r--r--source/rpcclient/cmd_samr.c61
-rw-r--r--source/rpcclient/cmd_spoolss.c10
-rw-r--r--source/smbd/change_trust_pw.c4
-rw-r--r--source/smbd/trans2.c14
-rw-r--r--source/torture/msgtest.c36
-rw-r--r--source/utils/net_rpc.c2
-rw-r--r--source/utils/net_rpc_samsync.c485
-rw-r--r--source/utils/netlookup.c6
-rw-r--r--source/web/swat.c2
53 files changed, 3037 insertions, 1716 deletions
diff --git a/source/client/client.c b/source/client/client.c
index 522048dc74e..a578608bfff 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -359,7 +359,7 @@ static BOOL do_this_one(file_info *finfo)
return False;
}
- if (newer_than && finfo->mtime < newer_than) {
+ if (newer_than && finfo->mtime_ts.tv_sec < newer_than) {
DEBUG(3,("newer_than %s failed\n", finfo->name));
return(False);
}
@@ -379,7 +379,7 @@ static BOOL do_this_one(file_info *finfo)
static void display_finfo(file_info *finfo)
{
if (do_this_one(finfo)) {
- time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
+ time_t t = finfo->mtime_ts.tv_sec; /* the time is assumed to be passed as GMT */
if (!showacls) {
d_printf(" %-30s%7.7s %8.0f %s",
finfo->name,
diff --git a/source/client/clitar.c b/source/client/clitar.c
index 14c28acfc5a..f228db11998 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -49,9 +49,9 @@ struct file_info_struct {
uid_t uid;
gid_t gid;
/* These times are normally kept in GMT */
- time_t mtime;
- time_t atime;
- time_t ctime;
+ struct timespec mtime_ts;
+ struct timespec atime_ts;
+ struct timespec ctime_ts;
char *name; /* This is dynamically allocate */
file_info2 *next, *prev; /* Used in the stack ... */
@@ -201,7 +201,11 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m
oct_it((SMB_BIG_UINT)0, 8, hb.dbuf.uid);
oct_it((SMB_BIG_UINT)0, 8, hb.dbuf.gid);
oct_it((SMB_BIG_UINT) size, 13, hb.dbuf.size);
+#ifdef HAVE_LONGLONG
if (size > (SMB_BIG_UINT)077777777777LL) {
+#else
+ if (size > (SMB_BIG_UINT)077777777777) {
+#endif
/* This is a non-POSIX compatible extention to store files
greater than 8GB. */
@@ -308,8 +312,9 @@ of link other than a GNUtar Longlink - ignoring\n"));
* We only get the modification time of the file; set the creation time
* from the mod. time, and the access time to current time
*/
- finfo->mtime = finfo->ctime = strtol(hb->dbuf.mtime, NULL, 8);
- finfo->atime = time(NULL);
+ finfo->mtime_ts = finfo->ctime_ts =
+ convert_time_t_to_timespec((time_t)strtol(hb->dbuf.mtime, NULL, 8));
+ finfo->atime_ts = convert_time_t_to_timespec(time(NULL));
finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size));
return True;
@@ -383,7 +388,7 @@ static void initarbuf(void)
{
/* initialize tar buffer */
tbufsiz=blocksize*TBLOCK;
- tarbuf=SMB_MALLOC(tbufsiz); /* FIXME: We might not get the buffer */
+ tarbuf=(char *)SMB_MALLOC(tbufsiz); /* FIXME: We might not get the buffer */
/* reset tar buffer pointer and tar file counter and total dumped */
tp=0; ntarf=0; ttarf=0;
@@ -621,18 +626,18 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
finfo.mode = finfo1 -> mode;
finfo.uid = finfo1 -> uid;
finfo.gid = finfo1 -> gid;
- finfo.mtime = finfo1 -> mtime;
- finfo.atime = finfo1 -> atime;
- finfo.ctime = finfo1 -> ctime;
+ finfo.mtime_ts = finfo1 -> mtime_ts;
+ finfo.atime_ts = finfo1 -> atime_ts;
+ finfo.ctime_ts = finfo1 -> ctime_ts;
finfo.name = finfo1 -> name;
} else {
finfo.size = def_finfo.size;
finfo.mode = def_finfo.mode;
finfo.uid = def_finfo.uid;
finfo.gid = def_finfo.gid;
- finfo.mtime = def_finfo.mtime;
- finfo.atime = def_finfo.atime;
- finfo.ctime = def_finfo.ctime;
+ finfo.mtime_ts = def_finfo.mtime_ts;
+ finfo.atime_ts = def_finfo.atime_ts;
+ finfo.ctime_ts = def_finfo.ctime_ts;
finfo.name = def_finfo.name;
}
@@ -663,11 +668,14 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
safe_strcpy(finfo.name,rname, strlen(rname));
if (!finfo1) {
- if (!cli_getattrE(cli, fnum, &finfo.mode, &finfo.size, NULL, &finfo.atime, &finfo.mtime)) {
+ time_t atime, mtime;
+ if (!cli_getattrE(cli, fnum, &finfo.mode, &finfo.size, NULL, &atime, &mtime)) {
DEBUG(0, ("getattrE: %s\n", cli_errstr(cli)));
return;
}
- finfo.ctime = finfo.mtime;
+ finfo.atime_ts = convert_time_t_to_timespec(atime);
+ finfo.mtime_ts = convert_time_t_to_timespec(mtime);
+ finfo.ctime_ts = finfo.mtime_ts;
}
DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode));
@@ -703,7 +711,8 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
/* Only if the first read succeeds, write out the tar header. */
if (!wrote_tar_header) {
/* write a tar header, don't bother with mode - just set to 100644 */
- writetarheader(tarhandle, rname, finfo.size, finfo.mtime, "100644 \0", ftype);
+ writetarheader(tarhandle, rname, finfo.size,
+ finfo.mtime_ts.tv_sec, "100644 \0", ftype);
wrote_tar_header = True;
}
@@ -832,7 +841,7 @@ strlen(finfo->name)=%d\nname=%s,cur_dir=%s\n",
/* write a tar directory, don't bother with mode - just set it to
* 40755 */
- writetarheader(tarhandle, cur_dir, 0, finfo->mtime, "040755 \0", '5');
+ writetarheader(tarhandle, cur_dir, 0, finfo->mtime_ts.tv_sec, "040755 \0", '5');
if (tar_noisy) {
DEBUG(0,(" directory %s\n", cur_dir));
}
@@ -1030,7 +1039,7 @@ static int get_file(file_info2 finfo)
/* Now we update the creation date ... */
DEBUG(5, ("Updating creation date on %s\n", finfo.name));
- if (!cli_setatr(cli, finfo.name, finfo.mode, finfo.mtime)) {
+ if (!cli_setatr(cli, finfo.name, finfo.mode, finfo.mtime_ts.tv_sec)) {
if (tar_real_noisy) {
DEBUG(0, ("Could not set time on file: %s\n", finfo.name));
/*return(False); */ /* Ignore, as Win95 does not allow changes */
@@ -1066,7 +1075,7 @@ static char *get_longfilename(file_info2 finfo)
/* finfo.size here is the length of the filename as written by the "/./@LongLink" name
* header call. */
int namesize = finfo.size + strlen(cur_dir) + 2;
- char *longname = SMB_MALLOC(namesize);
+ char *longname = (char *)SMB_MALLOC(namesize);
int offset = 0, left = finfo.size;
BOOL first = True;
@@ -1514,7 +1523,7 @@ static int read_inclusion_file(char *filename)
while ((! error) && (x_fgets(buf, sizeof(buf)-1, inclusion))) {
if (inclusion_buffer == NULL) {
inclusion_buffer_size = 1024;
- if ((inclusion_buffer = SMB_MALLOC(inclusion_buffer_size)) == NULL) {
+ if ((inclusion_buffer = (char *)SMB_MALLOC(inclusion_buffer_size)) == NULL) {
DEBUG(0,("failure allocating buffer to read inclusion file\n"));
error = 1;
break;
@@ -1527,7 +1536,7 @@ static int read_inclusion_file(char *filename)
if ((strlen(buf) + 1 + inclusion_buffer_sofar) >= inclusion_buffer_size) {
inclusion_buffer_size *= 2;
- inclusion_buffer = SMB_REALLOC(inclusion_buffer,inclusion_buffer_size);
+ inclusion_buffer = (char *)SMB_REALLOC(inclusion_buffer,inclusion_buffer_size);
if (!inclusion_buffer) {
DEBUG(0,("failure enlarging inclusion buffer to %d bytes\n",
inclusion_buffer_size));
diff --git a/source/include/client.h b/source/include/client.h
index 5ec98606f8d..3b7b19289a7 100644
--- a/source/include/client.h
+++ b/source/include/client.h
@@ -41,9 +41,9 @@ typedef struct file_info
uid_t uid;
gid_t gid;
/* these times are normally kept in GMT */
- time_t mtime;
- time_t atime;
- time_t ctime;
+ struct timespec mtime_ts;
+ struct timespec atime_ts;
+ struct timespec ctime_ts;
pstring name;
pstring dir;
char short_name[13*3]; /* the *3 is to cope with multi-byte */
diff --git a/source/include/libsmb_internal.h b/source/include/libsmb_internal.h
index 5aca12554f3..86e98617558 100644
--- a/source/include/libsmb_internal.h
+++ b/source/include/libsmb_internal.h
@@ -81,6 +81,21 @@ struct smbc_internal_data {
BOOL _debug_stderr;
/*
+ * Support "Create Time" in get/set with the *xattr() functions, if
+ * true. This replaces the dos attribute strings C_TIME, A_TIME and
+ * M_TIME with CHANGE_TIME, ACCESS_TIME and WRITE_TIME, and adds
+ * CREATE_TIME. Default is FALSE, i.e. to use the old-style shorter
+ * names and to not support CREATE time, for backward compatibility.
+ */
+ BOOL _full_time_names;
+
+ /*
+ * The share mode of a file being opened. To match POSIX semantics
+ * (and maintain backward compatibility), DENY_NONE is the default.
+ */
+ smbc_share_mode _share_mode;
+
+ /*
* Authentication function which includes the context. This will be
* used if set; otherwise context->callbacks.auth_fn() will be used.
*/
diff --git a/source/include/libsmbclient.h b/source/include/libsmbclient.h
index ba92259f701..45f2a41b088 100644
--- a/source/include/libsmbclient.h
+++ b/source/include/libsmbclient.h
@@ -141,6 +141,20 @@ struct smbc_dirent
#define SMBC_DOS_MODE_DIRECTORY 0x10
#define SMBC_DOS_MODE_ARCHIVE 0x20
+/*
+ * Valid values for the option "open_share_mode", when calling
+ * smbc_option_set()
+ */
+typedef enum smbc_share_mode
+{
+ SMBC_SHAREMODE_DENY_DOS = 0,
+ SMBC_SHAREMODE_DENY_ALL = 1,
+ SMBC_SHAREMODE_DENY_WRITE = 2,
+ SMBC_SHAREMODE_DENY_READ = 3,
+ SMBC_SHAREMODE_DENY_NONE = 4,
+ SMBC_SHAREMODE_DENY_FCB = 7
+} smbc_share_mode;
+
#ifndef ENOATTR
# define ENOATTR ENOENT /* No such attribute */
@@ -635,7 +649,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
void
smbc_option_set(SMBCCTX *context,
char *option_name,
- void *option_value);
+ ... /* option_value */);
/*
* Retrieve the current value of an option
*
diff --git a/source/include/rpc_netlogon.h b/source/include/rpc_netlogon.h
index 327da45c2bb..d2d5cf2fbb4 100644
--- a/source/include/rpc_netlogon.h
+++ b/source/include/rpc_netlogon.h
@@ -671,8 +671,8 @@ typedef struct account_lockout_string {
uint32 offset;
uint32 length;
/* uint16 *bindata; */
- UINT64_S lockout_duration;
- UINT64_S reset_count;
+ uint64 lockout_duration;
+ uint64 reset_count;
uint32 bad_attempt_lockout;
uint32 dummy;
} LOCKOUT_STRING;
@@ -689,12 +689,12 @@ typedef struct sam_domain_info_info {
UNIHDR hdr_dom_name;
UNIHDR hdr_oem_info;
- UINT64_S force_logoff;
+ uint64 force_logoff;
uint16 min_pwd_len;
uint16 pwd_history_len;
- UINT64_S max_pwd_age;
- UINT64_S min_pwd_age;
- UINT64_S dom_mod_count;
+ uint64 max_pwd_age;
+ uint64 min_pwd_age;
+ uint64 dom_mod_count;
NTTIME creation_time;
uint32 security_information;
@@ -858,7 +858,7 @@ typedef struct sam_alias_mem_info_info {
/* SAM_DELTA_POLICY (0x0D) */
typedef struct {
uint32 max_log_size; /* 0x5000 */
- UINT64_S audit_retention_period; /* 0 */
+ uint64 audit_retention_period; /* 0 */
uint32 auditing_mode; /* 0 */
uint32 num_events;
uint32 ptr_events;
@@ -870,7 +870,7 @@ typedef struct {
uint32 min_workset_size; /* 0x00010000 */
uint32 max_workset_size; /* 0x0f000000 */
uint32 page_file_limit; /* 0 */
- UINT64_S time_limit; /* 0 */
+ uint64 time_limit; /* 0 */
NTTIME modify_time; /* 0x3c*/
NTTIME create_time; /* a7080110 */
BUFHDR2 hdr_sec_desc;
@@ -917,7 +917,7 @@ typedef struct {
uint32 min_workset_size; /* 0x00010000 */
uint32 max_workset_size; /* 0x0f000000 */
uint32 page_file_limit; /* 0 */
- UINT64_S time_limit; /* 0 */
+ uint64 time_limit; /* 0 */
uint32 system_flags; /* 1 */
BUFHDR2 hdr_sec_desc;
@@ -971,7 +971,7 @@ typedef struct {
typedef struct {
uint32 seqnum;
uint32 dom_mod_count_ptr;
- UINT64_S dom_mod_count; /* domain mod count at last sync */
+ uint64 dom_mod_count; /* domain mod count at last sync */
} SAM_DELTA_MOD_COUNT;
typedef union sam_delta_ctr_info {
@@ -1013,7 +1013,7 @@ typedef struct net_q_sam_deltas_info {
DOM_CRED ret_creds;
uint32 database_id;
- UINT64_S dom_mod_count; /* domain mod count at last sync */
+ uint64 dom_mod_count; /* domain mod count at last sync */
uint32 max_size; /* preferred maximum length */
} NET_Q_SAM_DELTAS;
@@ -1022,7 +1022,7 @@ typedef struct net_q_sam_deltas_info {
typedef struct net_r_sam_deltas_info {
DOM_CRED srv_creds;
- UINT64_S dom_mod_count; /* new domain mod count */
+ uint64 dom_mod_count; /* new domain mod count */
uint32 ptr_deltas;
uint32 num_deltas;
diff --git a/source/include/rpc_perfcount.h b/source/include/rpc_perfcount.h
index 0e3a6eb0181..dcf4e0d164a 100644
--- a/source/include/rpc_perfcount.h
+++ b/source/include/rpc_perfcount.h
@@ -59,8 +59,8 @@ typedef struct perf_object_type
uint32 DefaultCounter;
uint32 NumInstances;
uint32 CodePage;
- UINT64_S PerfTime;
- UINT64_S PerfFreq;
+ uint64 PerfTime;
+ uint64 PerfFreq;
PERF_COUNTER_DEFINITION *counters;
PERF_INSTANCE_DEFINITION *instances;
PERF_COUNTER_BLOCK counter_data;
@@ -88,13 +88,13 @@ typedef struct perf_data_block
PerfTime, and having it there will make my offset math much easier. */
uint32 Padding;
/* Now when I'm marshalling this, I'll need to call prs_align_uint64()
- before I start encodint the UINT64_S structs */
+ before I start encodint the uint64 structs */
/* clock rate * seconds uptime */
- UINT64_S PerfTime;
+ uint64 PerfTime;
/* The clock rate of the CPU */
- UINT64_S PerfFreq;
+ uint64 PerfFreq;
/* used for high-res timers -- for now PerfTime * 10e7 */
- UINT64_S PerfTime100nSec;
+ uint64 PerfTime100nSec;
uint32 SystemNameLength;
uint32 SystemNameOffset;
/* The SystemName, in unicode, terminated */
diff --git a/source/include/rpc_samr.h b/source/include/rpc_samr.h
index ad605691791..9a5484598a4 100644
--- a/source/include/rpc_samr.h
+++ b/source/include/rpc_samr.h
@@ -553,7 +553,7 @@ typedef struct sam_unknown_info_2_inf
pointer is referring to
*/
- UINT64_S seq_num;
+ uint64 seq_num;
uint32 unknown_4; /* 0x0000 0001 */
uint32 server_role;
@@ -605,7 +605,7 @@ typedef struct sam_unknown_info_7_info
typedef struct sam_unknown_info_8_info
{
- UINT64_S seq_num;
+ uint64 seq_num;
NTTIME domain_create_time;
} SAM_UNK_INFO_8;
@@ -626,7 +626,7 @@ typedef struct sam_unknown_info_12_inf
typedef struct sam_unknown_info_13_info
{
- UINT64_S seq_num;
+ uint64 seq_num;
NTTIME domain_create_time;
uint32 unknown1;
uint32 unknown2;
diff --git a/source/include/smb.h b/source/include/smb.h
index a91bd9368ea..4dd6028509c 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -216,10 +216,7 @@ typedef uint32 codepoint_t;
#define PI_MAX_PIPES 14
/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
-typedef struct nttime_info {
- uint32 low;
- uint32 high;
-} NTTIME;
+typedef uint64_t NTTIME;
/* Allowable account control bits */
diff --git a/source/include/smbprofile.h b/source/include/smbprofile.h
index ce42d7de8b4..39f02ec9f53 100644
--- a/source/include/smbprofile.h
+++ b/source/include/smbprofile.h
@@ -4,7 +4,8 @@
Unix SMB/CIFS implementation.
store smbd profiling information in shared memory
Copyright (C) Andrew Tridgell 1999
-
+ Copyright (C) James Peach 2006
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -26,104 +27,715 @@
#define PROF_SHMEM_KEY ((key_t)0x07021999)
#define PROF_SHM_MAGIC 0x6349985
-#define PROF_SHM_VERSION 10
+#define PROF_SHM_VERSION 11
/* time values in the following structure are in microseconds */
+#define __profile_stats_value(which, domain) domain[which]
+
+enum profile_stats_values
+{
+ PR_VALUE_SMBD_IDLE = 0,
+#define smbd_idle_count __profile_stats_value(PR_VALUE_SMBD_IDLE, count)
+#define smbd_idle_time __profile_stats_value(PR_VALUE_SMBD_IDLE, time)
+
+/* system call counters */
+ PR_VALUE_SYSCALL_OPENDIR,
+#define syscall_opendir_count __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, count)
+#define syscall_opendir_time __profile_stats_value(PR_VALUE_SYSCALL_OPENDIR, time)
+
+ PR_VALUE_SYSCALL_READDIR,
+#define syscall_readdir_count __profile_stats_value(PR_VALUE_SYSCALL_READDIR, count)
+#define syscall_readdir_time __profile_stats_value(PR_VALUE_SYSCALL_READDIR, time)
+
+ PR_VALUE_SYSCALL_SEEKDIR,
+#define syscall_seekdir_count __profile_stats_value(PR_VALUE_SYSCALL_SEEKDIR, count)
+#define syscall_seekdir_time __profile_stats_value(PR_VALUE_SYSCALL_SEEKDIR, time)
+
+ PR_VALUE_SYSCALL_TELLDIR,
+#define syscall_telldir_count __profile_stats_value(PR_VALUE_SYSCALL_TELLDIR, count)
+#define syscall_telldir_time __profile_stats_value(PR_VALUE_SYSCALL_TELLDIR, time)
+
+ PR_VALUE_SYSCALL_REWINDDIR,
+#define syscall_rewinddir_count __profile_stats_value(PR_VALUE_SYSCALL_REWINDDIR, count)
+#define syscall_rewinddir_time __profile_stats_value(PR_VALUE_SYSCALL_REWINDDIR, time)
+
+ PR_VALUE_SYSCALL_MKDIR,
+#define syscall_mkdir_count __profile_stats_value(PR_VALUE_SYSCALL_MKDIR, count)
+#define syscall_mkdir_time __profile_stats_value(PR_VALUE_SYSCALL_MKDIR, time)
+
+ PR_VALUE_SYSCALL_RMDIR,
+#define syscall_rmdir_count __profile_stats_value(PR_VALUE_SYSCALL_RMDIR, count)
+#define syscall_rmdir_time __profile_stats_value(PR_VALUE_SYSCALL_RMDIR, time)
+
+ PR_VALUE_SYSCALL_CLOSEDIR,
+#define syscall_closedir_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSEDIR, count)
+#define syscall_closedir_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSEDIR, time)
+
+ PR_VALUE_SYSCALL_OPEN,
+#define syscall_open_count __profile_stats_value(PR_VALUE_SYSCALL_OPEN, count)
+#define syscall_open_time __profile_stats_value(PR_VALUE_SYSCALL_OPEN, time)
+
+ PR_VALUE_SYSCALL_CLOSE,
+#define syscall_close_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, count)
+#define syscall_close_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, time)
+
+ PR_VALUE_SYSCALL_READ,
+#define syscall_read_count __profile_stats_value(PR_VALUE_SYSCALL_READ, count)
+#define syscall_read_time __profile_stats_value(PR_VALUE_SYSCALL_READ, time)
+
+ PR_VALUE_SYSCALL_PREAD,
+#define syscall_pread_count __profile_stats_value(PR_VALUE_SYSCALL_PREAD, count)
+#define syscall_pread_time __profile_stats_value(PR_VALUE_SYSCALL_PREAD, time)
+
+ PR_VALUE_SYSCALL_WRITE,
+#define syscall_write_count __profile_stats_value(PR_VALUE_SYSCALL_WRITE, count)
+#define syscall_write_time __profile_stats_value(PR_VALUE_SYSCALL_WRITE, time)
+
+ PR_VALUE_SYSCALL_PWRITE,
+#define syscall_pwrite_count __profile_stats_value(PR_VALUE_SYSCALL_PWRITE, count)
+#define syscall_pwrite_time __profile_stats_value(PR_VALUE_SYSCALL_PWRITE, time)
+
+ PR_VALUE_SYSCALL_LSEEK,
+#define syscall_lseek_count __profile_stats_value(PR_VALUE_SYSCALL_LSEEK, count)
+#define syscall_lseek_time __profile_stats_value(PR_VALUE_SYSCALL_LSEEK, time)
+
+ PR_VALUE_SYSCALL_SENDFILE,
+#define syscall_sendfile_count __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, count)
+#define syscall_sendfile_time __profile_stats_value(PR_VALUE_SYSCALL_SENDFILE, time)
+
+ PR_VALUE_SYSCALL_RENAME,
+#define syscall_rename_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME, count)
+#define syscall_rename_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME, time)
+
+ PR_VALUE_SYSCALL_FSYNC,
+#define syscall_fsync_count __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, count)
+#define syscall_fsync_time __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, time)
+
+ PR_VALUE_SYSCALL_STAT,
+#define syscall_stat_count __profile_stats_value(PR_VALUE_SYSCALL_STAT, count)
+#define syscall_stat_time __profile_stats_value(PR_VALUE_SYSCALL_STAT, time)
+
+ PR_VALUE_SYSCALL_FSTAT,
+#define syscall_fstat_count __profile_stats_value(PR_VALUE_SYSCALL_FSTAT, count)
+#define syscall_fstat_time __profile_stats_value(PR_VALUE_SYSCALL_FSTAT, time)
+
+ PR_VALUE_SYSCALL_LSTAT,
+#define syscall_lstat_count __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, count)
+#define syscall_lstat_time __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, time)
+
+ PR_VALUE_SYSCALL_UNLINK,
+#define syscall_unlink_count __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, count)
+#define syscall_unlink_time __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, time)
+
+ PR_VALUE_SYSCALL_CHMOD,
+#define syscall_chmod_count __profile_stats_value(PR_VALUE_SYSCALL_CHMOD, count)
+#define syscall_chmod_time __profile_stats_value(PR_VALUE_SYSCALL_CHMOD, time)
+
+ PR_VALUE_SYSCALL_FCHMOD,
+#define syscall_fchmod_count __profile_stats_value(PR_VALUE_SYSCALL_FCHMOD, count)
+#define syscall_fchmod_time __profile_stats_value(PR_VALUE_SYSCALL_FCHMOD, time)
+
+ PR_VALUE_SYSCALL_CHOWN,
+#define syscall_chown_count __profile_stats_value(PR_VALUE_SYSCALL_CHOWN, count)
+#define syscall_chown_time __profile_stats_value(PR_VALUE_SYSCALL_CHOWN, time)
+
+ PR_VALUE_SYSCALL_FCHOWN,
+#define syscall_fchown_count __profile_stats_value(PR_VALUE_SYSCALL_FCHOWN, count)
+#define syscall_fchown_time __profile_stats_value(PR_VALUE_SYSCALL_FCHOWN, time)
+
+ PR_VALUE_SYSCALL_CHDIR,
+#define syscall_chdir_count __profile_stats_value(PR_VALUE_SYSCALL_CHDIR, count)
+#define syscall_chdir_time __profile_stats_value(PR_VALUE_SYSCALL_CHDIR, time)
+
+ PR_VALUE_SYSCALL_GETWD,
+#define syscall_getwd_count __profile_stats_value(PR_VALUE_SYSCALL_GETWD, count)
+#define syscall_getwd_time __profile_stats_value(PR_VALUE_SYSCALL_GETWD, time)
+
+ PR_VALUE_SYSCALL_UTIME,
+#define syscall_utime_count __profile_stats_value(PR_VALUE_SYSCALL_UTIME, count)
+#define syscall_utime_time __profile_stats_value(PR_VALUE_SYSCALL_UTIME, time)
+
+ PR_VALUE_SYSCALL_FTRUNCATE,
+#define syscall_ftruncate_count __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, count)
+#define syscall_ftruncate_time __profile_stats_value(PR_VALUE_SYSCALL_FTRUNCATE, time)
+
+ PR_VALUE_SYSCALL_FCNTL_LOCK,
+#define syscall_fcntl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, count)
+#define syscall_fcntl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_LOCK, time)
+
+ PR_VALUE_SYSCALL_KERNEL_FLOCK,
+#define syscall_kernel_flock_count __profile_stats_value(PR_VALUE_SYSCALL_KERNEL_FLOCK, count)
+#define syscall_kernel_flock_time __profile_stats_value(PR_VALUE_SYSCALL_KERNEL_FLOCK, time)
+
+ PR_VALUE_SYSCALL_FCNTL_GETLOCK,
+#define syscall_fcntl_getlock_count __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_GETLOCK, count)
+#define syscall_fcntl_getlock_time __profile_stats_value(PR_VALUE_SYSCALL_FCNTL_GETLOCK, time)
+
+ PR_VALUE_SYSCALL_READLINK,
+#define syscall_readlink_count __profile_stats_value(PR_VALUE_SYSCALL_READLINK, count)
+#define syscall_readlink_time __profile_stats_value(PR_VALUE_SYSCALL_READLINK, time)
+
+ PR_VALUE_SYSCALL_SYMLINK,
+#define syscall_symlink_count __profile_stats_value(PR_VALUE_SYSCALL_SYMLINK, count)
+#define syscall_symlink_time __profile_stats_value(PR_VALUE_SYSCALL_SYMLINK, time)
+
+ PR_VALUE_SYSCALL_LINK,
+#define syscall_link_count __profile_stats_value(PR_VALUE_SYSCALL_LINK, count)
+#define syscall_link_time __profile_stats_value(PR_VALUE_SYSCALL_LINK, time)
+
+ PR_VALUE_SYSCALL_MKNOD,
+#define syscall_mknod_count __profile_stats_value(PR_VALUE_SYSCALL_MKNOD, count)
+#define syscall_mknod_time __profile_stats_value(PR_VALUE_SYSCALL_MKNOD, time)
+
+ PR_VALUE_SYSCALL_REALPATH,
+#define syscall_realpath_count __profile_stats_value(PR_VALUE_SYSCALL_REALPATH, count)
+#define syscall_realpath_time __profile_stats_value(PR_VALUE_SYSCALL_REALPATH, time)
+
+ PR_VALUE_SYSCALL_GET_QUOTA,
+#define syscall_get_quota_count __profile_stats_value(PR_VALUE_SYSCALL_GET_QUOTA, count)
+#define syscall_get_quota_time __profile_stats_value(PR_VALUE_SYSCALL_GET_QUOTA, time)
+
+ PR_VALUE_SYSCALL_SET_QUOTA,
+#define syscall_set_quota_count __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, count)
+#define syscall_set_quota_time __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, time)
+
+/* counters for individual SMB types */
+ PR_VALUE_SMBMKDIR,
+#define SMBmkdir_count __profile_stats_value(PR_VALUE_SMBMKDIR, count)
+#define SMBmkdir_time __profile_stats_value(PR_VALUE_SMBMKDIR, time)
+
+ PR_VALUE_SMBRMDIR,
+#define SMBrmdir_count __profile_stats_value(PR_VALUE_SMBRMDIR, count)
+#define SMBrmdir_time __profile_stats_value(PR_VALUE_SMBRMDIR, time)
+
+ PR_VALUE_SMBOPEN,
+#define SMBopen_count __profile_stats_value(PR_VALUE_SMBOPEN, count)
+#define SMBopen_time __profile_stats_value(PR_VALUE_SMBOPEN, time)
+
+ PR_VALUE_SMBCREATE,
+#define SMBcreate_count __profile_stats_value(PR_VALUE_SMBCREATE, count)
+#define SMBcreate_time __profile_stats_value(PR_VALUE_SMBCREATE, time)
+
+ PR_VALUE_SMBCLOSE,
+#define SMBclose_count __profile_stats_value(PR_VALUE_SMBCLOSE, count)
+#define SMBclose_time __profile_stats_value(PR_VALUE_SMBCLOSE, time)
+
+ PR_VALUE_SMBFLUSH,
+#define SMBflush_count __profile_stats_value(PR_VALUE_SMBFLUSH, count)
+#define SMBflush_time __profile_stats_value(PR_VALUE_SMBFLUSH, time)
+
+ PR_VALUE_SMBUNLINK,
+#define SMBunlink_count __profile_stats_value(PR_VALUE_SMBUNLINK, count)
+#define SMBunlink_time __profile_stats_value(PR_VALUE_SMBUNLINK, time)
+
+ PR_VALUE_SMBMV,
+#define SMBmv_count __profile_stats_value(PR_VALUE_SMBMV, count)
+#define SMBmv_time __profile_stats_value(PR_VALUE_SMBMV, time)
+
+ PR_VALUE_SMBGETATR,
+#define SMBgetatr_count __profile_stats_value(PR_VALUE_SMBGETATR, count)
+#define SMBgetatr_time __profile_stats_value(PR_VALUE_SMBGETATR, time)
+
+ PR_VALUE_SMBSETATR,
+#define SMBsetatr_count __profile_stats_value(PR_VALUE_SMBSETATR, count)
+#define SMBsetatr_time __profile_stats_value(PR_VALUE_SMBSETATR, time)
+
+ PR_VALUE_SMBREAD,
+#define SMBread_count __profile_stats_value(PR_VALUE_SMBREAD, count)
+#define SMBread_time __profile_stats_value(PR_VALUE_SMBREAD, time)
+
+ PR_VALUE_SMBWRITE,
+#define SMBwrite_count __profile_stats_value(PR_VALUE_SMBWRITE, count)
+#define SMBwrite_time __profile_stats_value(PR_VALUE_SMBWRITE, time)
+
+ PR_VALUE_SMBLOCK,
+#define SMBlock_count __profile_stats_value(PR_VALUE_SMBLOCK, count)
+#define SMBlock_time __profile_stats_value(PR_VALUE_SMBLOCK, time)
+
+ PR_VALUE_SMBUNLOCK,
+#define SMBunlock_count __profile_stats_value(PR_VALUE_SMBUNLOCK, count)
+#define SMBunlock_time __profile_stats_value(PR_VALUE_SMBUNLOCK, time)
+
+ PR_VALUE_SMBCTEMP,
+#define SMBctemp_count __profile_stats_value(PR_VALUE_SMBCTEMP, count)
+#define SMBctemp_time __profile_stats_value(PR_VALUE_SMBCTEMP, time)
+
+ /* SMBmknew stats are currently combined with SMBcreate */
+ PR_VALUE_SMBMKNEW,
+#define SMBmknew_count __profile_stats_value(PR_VALUE_SMBMKNEW, count)
+#define SMBmknew_time __profile_stats_value(PR_VALUE_SMBMKNEW, time)
+
+ PR_VALUE_SMBCHKPTH,
+#define SMBchkpth_count __profile_stats_value(PR_VALUE_SMBCHKPTH, count)
+#define SMBchkpth_time __profile_stats_value(PR_VALUE_SMBCHKPTH, time)
+
+ PR_VALUE_SMBEXIT,
+#define SMBexit_count __profile_stats_value(PR_VALUE_SMBEXIT, count)
+#define SMBexit_time __profile_stats_value(PR_VALUE_SMBEXIT, time)
+
+ PR_VALUE_SMBLSEEK,
+#define SMBlseek_count __profile_stats_value(PR_VALUE_SMBLSEEK, count)
+#define SMBlseek_time __profile_stats_value(PR_VALUE_SMBLSEEK, time)
+
+ PR_VALUE_SMBLOCKREAD,
+#define SMBlockread_count __profile_stats_value(PR_VALUE_SMBLOCKREAD, count)
+#define SMBlockread_time __profile_stats_value(PR_VALUE_SMBLOCKREAD, time)
+
+ PR_VALUE_SMBWRITEUNLOCK,
+#define SMBwriteunlock_count __profile_stats_value(PR_VALUE_SMBWRITEUNLOCK, count)
+#define SMBwriteunlock_time __profile_stats_value(PR_VALUE_SMBWRITEUNLOCK, time)
+
+ PR_VALUE_SMBREADBRAW,
+#define SMBreadbraw_count __profile_stats_value(PR_VALUE_SMBREADBRAW, count)
+#define SMBreadbraw_time __profile_stats_value(PR_VALUE_SMBREADBRAW, time)
+
+ PR_VALUE_SMBREADBMPX,
+#define SMBreadBmpx_count __profile_stats_value(PR_VALUE_SMBREADBMPX, count)
+#define SMBreadBmpx_time __profile_stats_value(PR_VALUE_SMBREADBMPX, time)
+
+ PR_VALUE_SMBREADBS,
+#define SMBreadBs_count __profile_stats_value(PR_VALUE_SMBREADBS, count)
+#define SMBreadBs_time __profile_stats_value(PR_VALUE_SMBREADBS, time)
+
+ PR_VALUE_SMBWRITEBRAW,
+#define SMBwritebraw_count __profile_stats_value(PR_VALUE_SMBWRITEBRAW, count)
+#define SMBwritebraw_time __profile_stats_value(PR_VALUE_SMBWRITEBRAW, time)
+
+ PR_VALUE_SMBWRITEBMPX,
+#define SMBwriteBmpx_count __profile_stats_value(PR_VALUE_SMBWRITEBMPX, count)
+#define SMBwriteBmpx_time __profile_stats_value(PR_VALUE_SMBWRITEBMPX, time)
+
+ PR_VALUE_SMBWRITEBS,
+#define SMBwriteBs_count __profile_stats_value(PR_VALUE_SMBWRITEBS, count)
+#define SMBwriteBs_time __profile_stats_value(PR_VALUE_SMBWRITEBS, time)
+
+ PR_VALUE_SMBWRITEC,
+#define SMBwritec_count __profile_stats_value(PR_VALUE_SMBWRITEC, count)
+#define SMBwritec_time __profile_stats_value(PR_VALUE_SMBWRITEC, time)
+
+ PR_VALUE_SMBSETATTRE,
+#define SMBsetattrE_count __profile_stats_value(PR_VALUE_SMBSETATTRE, count)
+#define SMBsetattrE_time __profile_stats_value(PR_VALUE_SMBSETATTRE, time)
+
+ PR_VALUE_SMBGETATTRE,
+#define SMBgetattrE_count __profile_stats_value(PR_VALUE_SMBGETATTRE, count)
+#define SMBgetattrE_time __profile_stats_value(PR_VALUE_SMBGETATTRE, time)
+
+ PR_VALUE_SMBLOCKINGX,
+#define SMBlockingX_count __profile_stats_value(PR_VALUE_SMBLOCKINGX, count)
+#define SMBlockingX_time __profile_stats_value(PR_VALUE_SMBLOCKINGX, time)
+
+ PR_VALUE_SMBTRANS,
+#define SMBtrans_count __profile_stats_value(PR_VALUE_SMBTRANS, count)
+#define SMBtrans_time __profile_stats_value(PR_VALUE_SMBTRANS, time)
+
+ PR_VALUE_SMBTRANSS,
+#define SMBtranss_count __profile_stats_value(PR_VALUE_SMBTRANSS, count)
+#define SMBtranss_time __profile_stats_value(PR_VALUE_SMBTRANSS, time)
+
+ PR_VALUE_SMBIOCTL,
+#define SMBioctl_count __profile_stats_value(PR_VALUE_SMBIOCTL, count)
+#define SMBioctl_time __profile_stats_value(PR_VALUE_SMBIOCTL, time)
+
+ PR_VALUE_SMBIOCTLS,
+#define SMBioctls_count __profile_stats_value(PR_VALUE_SMBIOCTLS, count)
+#define SMBioctls_time __profile_stats_value(PR_VALUE_SMBIOCTLS, time)
+
+ PR_VALUE_SMBCOPY,
+#define SMBcopy_count __profile_stats_value(PR_VALUE_SMBCOPY, count)
+#define SMBcopy_time __profile_stats_value(PR_VALUE_SMBCOPY, time)
+
+ PR_VALUE_SMBMOVE,
+#define SMBmove_count __profile_stats_value(PR_VALUE_SMBMOVE, count)
+#define SMBmove_time __profile_stats_value(PR_VALUE_SMBMOVE, time)
+
+ PR_VALUE_SMBECHO,
+#define SMBecho_count __profile_stats_value(PR_VALUE_SMBECHO, count)
+#define SMBecho_time __profile_stats_value(PR_VALUE_SMBECHO, time)
+
+ PR_VALUE_SMBWRITECLOSE,
+#define SMBwriteclose_count __profile_stats_value(PR_VALUE_SMBWRITECLOSE, count)
+#define SMBwriteclose_time __profile_stats_value(PR_VALUE_SMBWRITECLOSE, time)
+
+ PR_VALUE_SMBOPENX,
+#define SMBopenX_count __profile_stats_value(PR_VALUE_SMBOPENX, count)
+#define SMBopenX_time __profile_stats_value(PR_VALUE_SMBOPENX, time)
+
+ PR_VALUE_SMBREADX,
+#define SMBreadX_count __profile_stats_value(PR_VALUE_SMBREADX, count)
+#define SMBreadX_time __profile_stats_value(PR_VALUE_SMBREADX, time)
+
+ PR_VALUE_SMBWRITEX,
+#define SMBwriteX_count __profile_stats_value(PR_VALUE_SMBWRITEX, count)
+#define SMBwriteX_time __profile_stats_value(PR_VALUE_SMBWRITEX, time)
+
+ PR_VALUE_SMBTRANS2,
+#define SMBtrans2_count __profile_stats_value(PR_VALUE_SMBTRANS2, count)
+#define SMBtrans2_time __profile_stats_value(PR_VALUE_SMBTRANS2, time)
+
+ PR_VALUE_SMBTRANSS2,
+#define SMBtranss2_count __profile_stats_value(PR_VALUE_SMBTRANSS2, count)
+#define SMBtranss2_time __profile_stats_value(PR_VALUE_SMBTRANSS2, time)
+
+ PR_VALUE_SMBFINDCLOSE,
+#define SMBfindclose_count __profile_stats_value(PR_VALUE_SMBFINDCLOSE, count)
+#define SMBfindclose_time __profile_stats_value(PR_VALUE_SMBFINDCLOSE, time)
+
+ PR_VALUE_SMBFINDNCLOSE,
+#define SMBfindnclose_count __profile_stats_value(PR_VALUE_SMBFINDNCLOSE, count)
+#define SMBfindnclose_time __profile_stats_value(PR_VALUE_SMBFINDNCLOSE, time)
+
+ PR_VALUE_SMBTCON,
+#define SMBtcon_count __profile_stats_value(PR_VALUE_SMBTCON, count)
+#define SMBtcon_time __profile_stats_value(PR_VALUE_SMBTCON, time)
+
+ PR_VALUE_SMBTDIS,
+#define SMBtdis_count __profile_stats_value(PR_VALUE_SMBTDIS, count)
+#define SMBtdis_time __profile_stats_value(PR_VALUE_SMBTDIS, time)
+
+ PR_VALUE_SMBNEGPROT,
+#define SMBnegprot_count __profile_stats_value(PR_VALUE_SMBNEGPROT, count)
+#define SMBnegprot_time __profile_stats_value(PR_VALUE_SMBNEGPROT, time)
+
+ PR_VALUE_SMBSESSSETUPX,
+#define SMBsesssetupX_count __profile_stats_value(PR_VALUE_SMBSESSSETUPX, count)
+#define SMBsesssetupX_time __profile_stats_value(PR_VALUE_SMBSESSSETUPX, time)
+
+ PR_VALUE_SMBULOGOFFX,
+#define SMBulogoffX_count __profile_stats_value(PR_VALUE_SMBULOGOFFX, count)
+#define SMBulogoffX_time __profile_stats_value(PR_VALUE_SMBULOGOFFX, time)
+
+ PR_VALUE_SMBTCONX,
+#define SMBtconX_count __profile_stats_value(PR_VALUE_SMBTCONX, count)
+#define SMBtconX_time __profile_stats_value(PR_VALUE_SMBTCONX, time)
+
+ PR_VALUE_SMBDSKATTR,
+#define SMBdskattr_count __profile_stats_value(PR_VALUE_SMBDSKATTR, count)
+#define SMBdskattr_time __profile_stats_value(PR_VALUE_SMBDSKATTR, time)
+
+ PR_VALUE_SMBSEARCH,
+#define SMBsearch_count __profile_stats_value(PR_VALUE_SMBSEARCH, count)
+#define SMBsearch_time __profile_stats_value(PR_VALUE_SMBSEARCH, time)
+
+ /* SBMffirst stats combined with SMBsearch */
+ PR_VALUE_SMBFFIRST,
+#define SMBffirst_count __profile_stats_value(PR_VALUE_SMBFFIRST, count)
+#define SMBffirst_time __profile_stats_value(PR_VALUE_SMBFFIRST, time)
+
+ /* SBMfunique stats combined with SMBsearch */
+ PR_VALUE_SMBFUNIQUE,
+#define SMBfunique_count __profile_stats_value(PR_VALUE_SMBFUNIQUE, count)
+#define SMBfunique_time __profile_stats_value(PR_VALUE_SMBFUNIQUE, time)
+
+ PR_VALUE_SMBFCLOSE,
+#define SMBfclose_count __profile_stats_value(PR_VALUE_SMBFCLOSE, count)
+#define SMBfclose_time __profile_stats_value(PR_VALUE_SMBFCLOSE, time)
+
+ PR_VALUE_SMBNTTRANS,
+#define SMBnttrans_count __profile_stats_value(PR_VALUE_SMBNTTRANS, count)
+#define SMBnttrans_time __profile_stats_value(PR_VALUE_SMBNTTRANS, time)
+
+ PR_VALUE_SMBNTTRANSS,
+#define SMBnttranss_count __profile_stats_value(PR_VALUE_SMBNTTRANSS, count)
+#define SMBnttranss_time __profile_stats_value(PR_VALUE_SMBNTTRANSS, time)
+
+ PR_VALUE_SMBNTCREATEX,
+#define SMBntcreateX_count __profile_stats_value(PR_VALUE_SMBNTCREATEX, count)
+#define SMBntcreateX_time __profile_stats_value(PR_VALUE_SMBNTCREATEX, time)
+
+ PR_VALUE_SMBNTCANCEL,
+#define SMBntcancel_count __profile_stats_value(PR_VALUE_SMBNTCANCEL, count)
+#define SMBntcancel_time __profile_stats_value(PR_VALUE_SMBNTCANCEL, time)
+
+ PR_VALUE_SMBNTRENAME,
+#define SMBntrename_count __profile_stats_value(PR_VALUE_SMBNTRENAME, count)
+#define SMBntrename_time __profile_stats_value(PR_VALUE_SMBNTRENAME, time)
+
+ PR_VALUE_SMBSPLOPEN,
+#define SMBsplopen_count __profile_stats_value(PR_VALUE_SMBSPLOPEN, count)
+#define SMBsplopen_time __profile_stats_value(PR_VALUE_SMBSPLOPEN, time)
+
+ PR_VALUE_SMBSPLWR,
+#define SMBsplwr_count __profile_stats_value(PR_VALUE_SMBSPLWR, count)
+#define SMBsplwr_time __profile_stats_value(PR_VALUE_SMBSPLWR, time)
+
+ PR_VALUE_SMBSPLCLOSE,
+#define SMBsplclose_count __profile_stats_value(PR_VALUE_SMBSPLCLOSE, count)
+#define SMBsplclose_time __profile_stats_value(PR_VALUE_SMBSPLCLOSE, time)
+
+ PR_VALUE_SMBSPLRETQ,
+#define SMBsplretq_count __profile_stats_value(PR_VALUE_SMBSPLRETQ, count)
+#define SMBsplretq_time __profile_stats_value(PR_VALUE_SMBSPLRETQ, time)
+
+ PR_VALUE_SMBSENDS,
+#define SMBsends_count __profile_stats_value(PR_VALUE_SMBSENDS, count)
+#define SMBsends_time __profile_stats_value(PR_VALUE_SMBSENDS, time)
+
+ PR_VALUE_SMBSENDB,
+#define SMBsendb_count __profile_stats_value(PR_VALUE_SMBSENDB, count)
+#define SMBsendb_time __profile_stats_value(PR_VALUE_SMBSENDB, time)
+
+ PR_VALUE_SMBFWDNAME,
+#define SMBfwdname_count __profile_stats_value(PR_VALUE_SMBFWDNAME, count)
+#define SMBfwdname_time __profile_stats_value(PR_VALUE_SMBFWDNAME, time)
+
+ PR_VALUE_SMBCANCELF,
+#define SMBcancelf_count __profile_stats_value(PR_VALUE_SMBCANCELF, count)
+#define SMBcancelf_time __profile_stats_value(PR_VALUE_SMBCANCELF, time)
+
+ PR_VALUE_SMBGETMAC,
+#define SMBgetmac_count __profile_stats_value(PR_VALUE_SMBGETMAC, count)
+#define SMBgetmac_time __profile_stats_value(PR_VALUE_SMBGETMAC, time)
+
+ PR_VALUE_SMBSENDSTRT,
+#define SMBsendstrt_count __profile_stats_value(PR_VALUE_SMBSENDSTRT, count)
+#define SMBsendstrt_time __profile_stats_value(PR_VALUE_SMBSENDSTRT, time)
+
+ PR_VALUE_SMBSENDEND,
+#define SMBsendend_count __profile_stats_value(PR_VALUE_SMBSENDEND, count)
+#define SMBsendend_time __profile_stats_value(PR_VALUE_SMBSENDEND, time)
+
+ PR_VALUE_SMBSENDTXT,
+#define SMBsendtxt_count __profile_stats_value(PR_VALUE_SMBSENDTXT, count)
+#define SMBsendtxt_time __profile_stats_value(PR_VALUE_SMBSENDTXT, time)
+
+ PR_VALUE_SMBINVALID,
+#define SMBinvalid_count __profile_stats_value(PR_VALUE_SMBINVALID, count)
+#define SMBinvalid_time __profile_stats_value(PR_VALUE_SMBINVALID, time)
+
+/* Pathworks setdir command */
+ PR_VALUE_PATHWORKS_SETDIR,
+#define pathworks_setdir_count __profile_stats_value(PR_VALUE_PATHWORKS_SETDIR, count)
+#define pathworks_setdir_time __profile_stats_value(PR_VALUE_PATHWORKS_SETDIR, time)
+
+/* These are the TRANS2 sub commands */
+ PR_VALUE_TRANS2_OPEN,
+#define Trans2_open_count __profile_stats_value(PR_VALUE_TRANS2_OPEN, count)
+#define Trans2_open_time __profile_stats_value(PR_VALUE_TRANS2_OPEN, time)
+
+ PR_VALUE_TRANS2_FINDFIRST,
+#define Trans2_findfirst_count __profile_stats_value(PR_VALUE_TRANS2_FINDFIRST, count)
+#define Trans2_findfirst_time __profile_stats_value(PR_VALUE_TRANS2_FINDFIRST, time)
+
+ PR_VALUE_TRANS2_FINDNEXT,
+#define Trans2_findnext_count __profile_stats_value(PR_VALUE_TRANS2_FINDNEXT, count)
+#define Trans2_findnext_time __profile_stats_value(PR_VALUE_TRANS2_FINDNEXT, time)
+
+ PR_VALUE_TRANS2_QFSINFO,
+#define Trans2_qfsinfo_count __profile_stats_value(PR_VALUE_TRANS2_QFSINFO, count)
+#define Trans2_qfsinfo_time __profile_stats_value(PR_VALUE_TRANS2_QFSINFO, time)
+
+ PR_VALUE_TRANS2_SETFSINFO,
+#define Trans2_setfsinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETFSINFO, count)
+#define Trans2_setfsinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETFSINFO, time)
+
+ PR_VALUE_TRANS2_QPATHINFO,
+#define Trans2_qpathinfo_count __profile_stats_value(PR_VALUE_TRANS2_QPATHINFO, count)
+#define Trans2_qpathinfo_time __profile_stats_value(PR_VALUE_TRANS2_QPATHINFO, time)
+
+ PR_VALUE_TRANS2_SETPATHINFO,
+#define Trans2_setpathinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETPATHINFO, count)
+#define Trans2_setpathinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETPATHINFO, time)
+
+ PR_VALUE_TRANS2_QFILEINFO,
+#define Trans2_qfileinfo_count __profile_stats_value(PR_VALUE_TRANS2_QFILEINFO, count)
+#define Trans2_qfileinfo_time __profile_stats_value(PR_VALUE_TRANS2_QFILEINFO, time)
+
+ PR_VALUE_TRANS2_SETFILEINFO,
+#define Trans2_setfileinfo_count __profile_stats_value(PR_VALUE_TRANS2_SETFILEINFO, count)
+#define Trans2_setfileinfo_time __profile_stats_value(PR_VALUE_TRANS2_SETFILEINFO, time)
+
+ PR_VALUE_TRANS2_FSCTL,
+#define Trans2_fsctl_count __profile_stats_value(PR_VALUE_TRANS2_FSCTL, count)
+#define Trans2_fsctl_time __profile_stats_value(PR_VALUE_TRANS2_FSCTL, time)
+
+ PR_VALUE_TRANS2_IOCTL,
+#define Trans2_ioctl_count __profile_stats_value(PR_VALUE_TRANS2_IOCTL, count)
+#define Trans2_ioctl_time __profile_stats_value(PR_VALUE_TRANS2_IOCTL, time)
+
+ PR_VALUE_TRANS2_FINDNOTIFYFIRST,
+#define Trans2_findnotifyfirst_count __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYFIRST, count)
+#define Trans2_findnotifyfirst_time __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYFIRST, time)
+
+ PR_VALUE_TRANS2_FINDNOTIFYNEXT,
+#define Trans2_findnotifynext_count __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYNEXT, count)
+#define Trans2_findnotifynext_time __profile_stats_value(PR_VALUE_TRANS2_FINDNOTIFYNEXT, time)
+
+ PR_VALUE_TRANS2_MKDIR,
+#define Trans2_mkdir_count __profile_stats_value(PR_VALUE_TRANS2_MKDIR, count)
+#define Trans2_mkdir_time __profile_stats_value(PR_VALUE_TRANS2_MKDIR, time)
+
+ PR_VALUE_TRANS2_SESSION_SETUP,
+#define Trans2_session_setup_count __profile_stats_value(PR_VALUE_TRANS2_SESSION_SETUP, count)
+#define Trans2_session_setup_time __profile_stats_value(PR_VALUE_TRANS2_SESSION_SETUP, time)
+
+ PR_VALUE_TRANS2_GET_DFS_REFERRAL,
+#define Trans2_get_dfs_referral_count __profile_stats_value(PR_VALUE_TRANS2_GET_DFS_REFERRAL, count)
+#define Trans2_get_dfs_referral_time __profile_stats_value(PR_VALUE_TRANS2_GET_DFS_REFERRAL, time)
+
+ PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY,
+#define Trans2_report_dfs_inconsistancy_count __profile_stats_value(PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY, count)
+#define Trans2_report_dfs_inconsistancy_time __profile_stats_value(PR_VALUE_TRANS2_REPORT_DFS_INCONSISTANCY, time)
+
+/* These are the NT transact sub commands. */
+ PR_VALUE_NT_TRANSACT_CREATE,
+#define NT_transact_create_count __profile_stats_value(PR_VALUE_NT_TRANSACT_CREATE, count)
+#define NT_transact_create_time __profile_stats_value(PR_VALUE_NT_TRANSACT_CREATE, time)
+
+ PR_VALUE_NT_TRANSACT_IOCTL,
+#define NT_transact_ioctl_count __profile_stats_value(PR_VALUE_NT_TRANSACT_IOCTL, count)
+#define NT_transact_ioctl_time __profile_stats_value(PR_VALUE_NT_TRANSACT_IOCTL, time)
+
+ PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC,
+#define NT_transact_set_security_desc_count __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC, count)
+#define NT_transact_set_security_desc_time __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_SECURITY_DESC, time)
+
+ PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE,
+#define NT_transact_notify_change_count __profile_stats_value(PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE, count)
+#define NT_transact_notify_change_time __profile_stats_value(PR_VALUE_NT_TRANSACT_NOTIFY_CHANGE, time)
+
+ PR_VALUE_NT_TRANSACT_RENAME,
+#define NT_transact_rename_count __profile_stats_value(PR_VALUE_NT_TRANSACT_RENAME, count)
+#define NT_transact_rename_time __profile_stats_value(PR_VALUE_NT_TRANSACT_RENAME, time)
+
+ PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC,
+#define NT_transact_query_security_desc_count __profile_stats_value(PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC, count)
+#define NT_transact_query_security_desc_time __profile_stats_value(PR_VALUE_NT_TRANSACT_QUERY_SECURITY_DESC, time)
+
+ PR_VALUE_NT_TRANSACT_GET_USER_QUOTA,
+#define NT_transact_get_user_quota_count __profile_stats_value(PR_VALUE_NT_TRANSACT_GET_USER_QUOTA, count)
+#define NT_transact_get_user_quota_time __profile_stats_value(PR_VALUE_NT_TRANSACT_GET_USER_QUOTA, time)
+
+ PR_VALUE_NT_TRANSACT_SET_USER_QUOTA,
+#define NT_transact_set_user_quota_count __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_USER_QUOTA, count)
+#define NT_transact_set_user_quota_time __profile_stats_value(PR_VALUE_NT_TRANSACT_SET_USER_QUOTA, time)
+
+/* These are ACL manipulation calls */
+ PR_VALUE_GET_NT_ACL,
+#define get_nt_acl_count __profile_stats_value(PR_VALUE_GET_NT_ACL, count)
+#define get_nt_acl_time __profile_stats_value(PR_VALUE_GET_NT_ACL, time)
+
+ PR_VALUE_FGET_NT_ACL,
+#define fget_nt_acl_count __profile_stats_value(PR_VALUE_FGET_NT_ACL, count)
+#define fget_nt_acl_time __profile_stats_value(PR_VALUE_FGET_NT_ACL, time)
+
+ PR_VALUE_SET_NT_ACL,
+#define set_nt_acl_count __profile_stats_value(PR_VALUE_SET_NT_ACL, count)
+#define set_nt_acl_time __profile_stats_value(PR_VALUE_SET_NT_ACL, time)
+
+ PR_VALUE_FSET_NT_ACL,
+#define fset_nt_acl_count __profile_stats_value(PR_VALUE_FSET_NT_ACL, count)
+#define fset_nt_acl_time __profile_stats_value(PR_VALUE_FSET_NT_ACL, time)
+
+ PR_VALUE_CHMOD_ACL,
+#define chmod_acl_count __profile_stats_value(PR_VALUE_CHMOD_ACL, count)
+#define chmod_acl_time __profile_stats_value(PR_VALUE_CHMOD_ACL, time)
+
+ PR_VALUE_FCHMOD_ACL,
+#define fchmod_acl_count __profile_stats_value(PR_VALUE_FCHMOD_ACL, count)
+#define fchmod_acl_time __profile_stats_value(PR_VALUE_FCHMOD_ACL, time)
+
+/* These are nmbd stats */
+ PR_VALUE_NAME_RELEASE,
+#define name_release_count __profile_stats_value(PR_VALUE_NAME_RELEASE, count)
+#define name_release_time __profile_stats_value(PR_VALUE_NAME_RELEASE, time)
+
+ PR_VALUE_NAME_REFRESH,
+#define name_refresh_count __profile_stats_value(PR_VALUE_NAME_REFRESH, count)
+#define name_refresh_time __profile_stats_value(PR_VALUE_NAME_REFRESH, time)
+
+ PR_VALUE_NAME_REGISTRATION,
+#define name_registration_count __profile_stats_value(PR_VALUE_NAME_REGISTRATION, count)
+#define name_registration_time __profile_stats_value(PR_VALUE_NAME_REGISTRATION, time)
+
+ PR_VALUE_NODE_STATUS,
+#define node_status_count __profile_stats_value(PR_VALUE_NODE_STATUS, count)
+#define node_status_time __profile_stats_value(PR_VALUE_NODE_STATUS, time)
+
+ PR_VALUE_NAME_QUERY,
+#define name_query_count __profile_stats_value(PR_VALUE_NAME_QUERY, count)
+#define name_query_time __profile_stats_value(PR_VALUE_NAME_QUERY, time)
+
+ PR_VALUE_HOST_ANNOUNCE,
+#define host_announce_count __profile_stats_value(PR_VALUE_HOST_ANNOUNCE, count)
+#define host_announce_time __profile_stats_value(PR_VALUE_HOST_ANNOUNCE, time)
+
+ PR_VALUE_WORKGROUP_ANNOUNCE,
+#define workgroup_announce_count __profile_stats_value(PR_VALUE_WORKGROUP_ANNOUNCE, count)
+#define workgroup_announce_time __profile_stats_value(PR_VALUE_WORKGROUP_ANNOUNCE, time)
+
+ PR_VALUE_LOCAL_MASTER_ANNOUNCE,
+#define local_master_announce_count __profile_stats_value(PR_VALUE_LOCAL_MASTER_ANNOUNCE, count)
+#define local_master_announce_time __profile_stats_value(PR_VALUE_LOCAL_MASTER_ANNOUNCE, time)
+
+ PR_VALUE_MASTER_BROWSER_ANNOUNCE,
+#define master_browser_announce_count __profile_stats_value(PR_VALUE_MASTER_BROWSER_ANNOUNCE, count)
+#define master_browser_announce_time __profile_stats_value(PR_VALUE_MASTER_BROWSER_ANNOUNCE, time)
+
+ PR_VALUE_LM_HOST_ANNOUNCE,
+#define lm_host_announce_count __profile_stats_value(PR_VALUE_LM_HOST_ANNOUNCE, count)
+#define lm_host_announce_time __profile_stats_value(PR_VALUE_LM_HOST_ANNOUNCE, time)
+
+ PR_VALUE_GET_BACKUP_LIST,
+#define get_backup_list_count __profile_stats_value(PR_VALUE_GET_BACKUP_LIST, count)
+#define get_backup_list_time __profile_stats_value(PR_VALUE_GET_BACKUP_LIST, time)
+
+ PR_VALUE_RESET_BROWSER,
+#define reset_browser_count __profile_stats_value(PR_VALUE_RESET_BROWSER, count)
+#define reset_browser_time __profile_stats_value(PR_VALUE_RESET_BROWSER, time)
+
+ PR_VALUE_ANNOUNCE_REQUEST,
+#define announce_request_count __profile_stats_value(PR_VALUE_ANNOUNCE_REQUEST, count)
+#define announce_request_time __profile_stats_value(PR_VALUE_ANNOUNCE_REQUEST, time)
+
+ PR_VALUE_LM_ANNOUNCE_REQUEST,
+#define lm_announce_request_count __profile_stats_value(PR_VALUE_LM_ANNOUNCE_REQUEST, count)
+#define lm_announce_request_time __profile_stats_value(PR_VALUE_LM_ANNOUNCE_REQUEST, time)
+
+ PR_VALUE_DOMAIN_LOGON,
+#define domain_logon_count __profile_stats_value(PR_VALUE_DOMAIN_LOGON, count)
+#define domain_logon_time __profile_stats_value(PR_VALUE_DOMAIN_LOGON, time)
+
+ PR_VALUE_SYNC_BROWSE_LISTS,
+#define sync_browse_lists_count __profile_stats_value(PR_VALUE_SYNC_BROWSE_LISTS, count)
+#define sync_browse_lists_time __profile_stats_value(PR_VALUE_SYNC_BROWSE_LISTS, time)
+
+ PR_VALUE_RUN_ELECTIONS,
+#define run_elections_count __profile_stats_value(PR_VALUE_RUN_ELECTIONS, count)
+#define run_elections_time __profile_stats_value(PR_VALUE_RUN_ELECTIONS, time)
+
+ PR_VALUE_ELECTION,
+#define election_count __profile_stats_value(PR_VALUE_ELECTION, count)
+#define election_time __profile_stats_value(PR_VALUE_ELECTION, time)
+
+ /* This mist remain the last value. */
+ PR_VALUE_MAX
+}; /* enum profile_stats_values */
+
+const char * profile_value_name(enum profile_stats_values val);
+
struct profile_stats {
/* general counters */
unsigned smb_count; /* how many SMB packets we have processed */
unsigned uid_changes; /* how many times we change our effective uid */
-/* system call counters */
- unsigned syscall_opendir_count;
- unsigned syscall_opendir_time;
- unsigned syscall_readdir_count;
- unsigned syscall_readdir_time;
- unsigned syscall_seekdir_count;
- unsigned syscall_seekdir_time;
- unsigned syscall_telldir_count;
- unsigned syscall_telldir_time;
- unsigned syscall_rewinddir_count;
- unsigned syscall_rewinddir_time;
- unsigned syscall_mkdir_count;
- unsigned syscall_mkdir_time;
- unsigned syscall_rmdir_count;
- unsigned syscall_rmdir_time;
- unsigned syscall_closedir_count;
- unsigned syscall_closedir_time;
- unsigned syscall_open_count;
- unsigned syscall_open_time;
- unsigned syscall_close_count;
- unsigned syscall_close_time;
- unsigned syscall_read_count;
- unsigned syscall_read_time;
- unsigned syscall_read_bytes; /* bytes read with read syscall */
- unsigned syscall_pread_count;
- unsigned syscall_pread_time;
- unsigned syscall_pread_bytes; /* bytes read with pread syscall */
- unsigned syscall_write_count;
- unsigned syscall_write_time;
- unsigned syscall_write_bytes; /* bytes written with write syscall */
- unsigned syscall_pwrite_count;
- unsigned syscall_pwrite_time;
- unsigned syscall_pwrite_bytes; /* bytes written with pwrite syscall */
- unsigned syscall_lseek_count;
- unsigned syscall_lseek_time;
- unsigned syscall_sendfile_count;
- unsigned syscall_sendfile_time;
- unsigned syscall_sendfile_bytes; /* bytes read with sendfile syscall */
- unsigned syscall_rename_count;
- unsigned syscall_rename_time;
- unsigned syscall_fsync_count;
- unsigned syscall_fsync_time;
- unsigned syscall_stat_count;
- unsigned syscall_stat_time;
- unsigned syscall_fstat_count;
- unsigned syscall_fstat_time;
- unsigned syscall_lstat_count;
- unsigned syscall_lstat_time;
- unsigned syscall_unlink_count;
- unsigned syscall_unlink_time;
- unsigned syscall_chmod_count;
- unsigned syscall_chmod_time;
- unsigned syscall_fchmod_count;
- unsigned syscall_fchmod_time;
- unsigned syscall_chown_count;
- unsigned syscall_chown_time;
- unsigned syscall_fchown_count;
- unsigned syscall_fchown_time;
- unsigned syscall_chdir_count;
- unsigned syscall_chdir_time;
- unsigned syscall_getwd_count;
- unsigned syscall_getwd_time;
- unsigned syscall_utime_count;
- unsigned syscall_utime_time;
- unsigned syscall_ftruncate_count;
- unsigned syscall_ftruncate_time;
- unsigned syscall_fcntl_lock_count;
- unsigned syscall_kernel_flock_count;
- unsigned syscall_kernel_flock_time;
- unsigned syscall_fcntl_lock_time;
- unsigned syscall_fcntl_getlock_count;
- unsigned syscall_fcntl_getlock_time;
- unsigned syscall_readlink_count;
- unsigned syscall_readlink_time;
- unsigned syscall_symlink_count;
- unsigned syscall_symlink_time;
- unsigned syscall_link_count;
- unsigned syscall_link_time;
- unsigned syscall_mknod_count;
- unsigned syscall_mknod_time;
- unsigned syscall_realpath_count;
- unsigned syscall_realpath_time;
- unsigned syscall_get_quota_count;
- unsigned syscall_get_quota_time;
- unsigned syscall_set_quota_count;
- unsigned syscall_set_quota_time;
+
+/* system call and protocol operation counters and cumulative times */
+ unsigned count[PR_VALUE_MAX];
+ unsigned time[PR_VALUE_MAX];
+
+/* cumulative byte counts */
+ unsigned syscall_pread_bytes;
+ unsigned syscall_pwrite_bytes;
+ unsigned syscall_read_bytes;
+ unsigned syscall_write_bytes;
+ unsigned syscall_sendfile_bytes;
+
/* stat cache counters */
unsigned statcache_lookups;
unsigned statcache_misses;
unsigned statcache_hits;
+
/* write cache counters */
unsigned writecache_read_hits;
unsigned writecache_abutted_writes;
@@ -135,265 +747,6 @@ struct profile_stats {
unsigned writecache_num_perfect_writes;
unsigned writecache_num_write_caches;
unsigned writecache_allocated_write_caches;
-/* counters for individual SMB types */
- unsigned SMBmkdir_count; /* create directory */
- unsigned SMBmkdir_time;
- unsigned SMBrmdir_count; /* delete directory */
- unsigned SMBrmdir_time;
- unsigned SMBopen_count; /* open file */
- unsigned SMBopen_time;
- unsigned SMBcreate_count; /* create file */
- unsigned SMBcreate_time;
- unsigned SMBclose_count; /* close file */
- unsigned SMBclose_time;
- unsigned SMBflush_count; /* flush file */
- unsigned SMBflush_time;
- unsigned SMBunlink_count; /* delete file */
- unsigned SMBunlink_time;
- unsigned SMBmv_count; /* rename file */
- unsigned SMBmv_time;
- unsigned SMBgetatr_count; /* get file attributes */
- unsigned SMBgetatr_time;
- unsigned SMBsetatr_count; /* set file attributes */
- unsigned SMBsetatr_time;
- unsigned SMBread_count; /* read from file */
- unsigned SMBread_time;
- unsigned SMBwrite_count; /* write to file */
- unsigned SMBwrite_time;
- unsigned SMBlock_count; /* lock byte range */
- unsigned SMBlock_time;
- unsigned SMBunlock_count; /* unlock byte range */
- unsigned SMBunlock_time;
- unsigned SMBctemp_count; /* create temporary file */
- unsigned SMBctemp_time;
- /* SMBmknew stats are currently combined with SMBcreate */
- unsigned SMBmknew_count; /* make new file */
- unsigned SMBmknew_time;
- unsigned SMBchkpth_count; /* check directory path */
- unsigned SMBchkpth_time;
- unsigned SMBexit_count; /* process exit */
- unsigned SMBexit_time;
- unsigned SMBlseek_count; /* seek */
- unsigned SMBlseek_time;
- unsigned SMBlockread_count; /* Lock a range and read */
- unsigned SMBlockread_time;
- unsigned SMBwriteunlock_count; /* Unlock a range then write */
- unsigned SMBwriteunlock_time;
- unsigned SMBreadbraw_count; /* read a block of data with no smb header */
- unsigned SMBreadbraw_time;
- unsigned SMBreadBmpx_count; /* read block multiplexed */
- unsigned SMBreadBmpx_time;
- unsigned SMBreadBs_count; /* read block (secondary response) */
- unsigned SMBreadBs_time;
- unsigned SMBwritebraw_count; /* write a block of data with no smb header */
- unsigned SMBwritebraw_time;
- unsigned SMBwriteBmpx_count; /* write block multiplexed */
- unsigned SMBwriteBmpx_time;
- unsigned SMBwriteBs_count; /* write block (secondary request) */
- unsigned SMBwriteBs_time;
- unsigned SMBwritec_count; /* secondary write request */
- unsigned SMBwritec_time;
- unsigned SMBsetattrE_count; /* set file attributes expanded */
- unsigned SMBsetattrE_time;
- unsigned SMBgetattrE_count; /* get file attributes expanded */
- unsigned SMBgetattrE_time;
- unsigned SMBlockingX_count; /* lock/unlock byte ranges and X */
- unsigned SMBlockingX_time;
- unsigned SMBtrans_count; /* transaction - name, bytes in/out */
- unsigned SMBtrans_time;
- unsigned SMBtranss_count; /* transaction (secondary request/response) */
- unsigned SMBtranss_time;
- unsigned SMBioctl_count; /* IOCTL */
- unsigned SMBioctl_time;
- unsigned SMBioctls_count; /* IOCTL (secondary request/response) */
- unsigned SMBioctls_time;
- unsigned SMBcopy_count; /* copy */
- unsigned SMBcopy_time;
- unsigned SMBmove_count; /* move */
- unsigned SMBmove_time;
- unsigned SMBecho_count; /* echo */
- unsigned SMBecho_time;
- unsigned SMBwriteclose_count; /* write a file then close it */
- unsigned SMBwriteclose_time;
- unsigned SMBopenX_count; /* open and X */
- unsigned SMBopenX_time;
- unsigned SMBreadX_count; /* read and X */
- unsigned SMBreadX_time;
- unsigned SMBwriteX_count; /* write and X */
- unsigned SMBwriteX_time;
- unsigned SMBtrans2_count; /* TRANS2 protocol set */
- unsigned SMBtrans2_time;
- unsigned SMBtranss2_count; /* TRANS2 protocol set, secondary command */
- unsigned SMBtranss2_time;
- unsigned SMBfindclose_count; /* Terminate a TRANSACT2_FINDFIRST */
- unsigned SMBfindclose_time;
- unsigned SMBfindnclose_count; /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
- unsigned SMBfindnclose_time;
- unsigned SMBtcon_count; /* tree connect */
- unsigned SMBtcon_time;
- unsigned SMBtdis_count; /* tree disconnect */
- unsigned SMBtdis_time;
- unsigned SMBnegprot_count; /* negotiate protocol */
- unsigned SMBnegprot_time;
- unsigned SMBsesssetupX_count; /* Session Set Up & X (including User Logon) */
- unsigned SMBsesssetupX_time;
- unsigned SMBulogoffX_count; /* user logoff */
- unsigned SMBulogoffX_time;
- unsigned SMBtconX_count; /* tree connect and X*/
- unsigned SMBtconX_time;
- unsigned SMBdskattr_count; /* get disk attributes */
- unsigned SMBdskattr_time;
- unsigned SMBsearch_count; /* search directory */
- unsigned SMBsearch_time;
- /* SBMffirst stats combined with SMBsearch */
- unsigned SMBffirst_count; /* find first */
- unsigned SMBffirst_time;
- /* SBMfunique stats combined with SMBsearch */
- unsigned SMBfunique_count; /* find unique */
- unsigned SMBfunique_time;
- unsigned SMBfclose_count; /* find close */
- unsigned SMBfclose_time;
- unsigned SMBnttrans_count; /* NT transact */
- unsigned SMBnttrans_time;
- unsigned SMBnttranss_count; /* NT transact secondary */
- unsigned SMBnttranss_time;
- unsigned SMBntcreateX_count; /* NT create and X */
- unsigned SMBntcreateX_time;
- unsigned SMBntcancel_count; /* NT cancel */
- unsigned SMBntcancel_time;
- unsigned SMBntrename_count; /* NT rename file */
- unsigned SMBntrename_time;
- unsigned SMBsplopen_count; /* open print spool file */
- unsigned SMBsplopen_time;
- unsigned SMBsplwr_count; /* write to print spool file */
- unsigned SMBsplwr_time;
- unsigned SMBsplclose_count; /* close print spool file */
- unsigned SMBsplclose_time;
- unsigned SMBsplretq_count; /* return print queue */
- unsigned SMBsplretq_time;
- unsigned SMBsends_count; /* send single block message */
- unsigned SMBsends_time;
- unsigned SMBsendb_count; /* send broadcast message */
- unsigned SMBsendb_time;
- unsigned SMBfwdname_count; /* forward user name */
- unsigned SMBfwdname_time;
- unsigned SMBcancelf_count; /* cancel forward */
- unsigned SMBcancelf_time;
- unsigned SMBgetmac_count; /* get machine name */
- unsigned SMBgetmac_time;
- unsigned SMBsendstrt_count; /* send start of multi-block message */
- unsigned SMBsendstrt_time;
- unsigned SMBsendend_count; /* send end of multi-block message */
- unsigned SMBsendend_time;
- unsigned SMBsendtxt_count; /* send text of multi-block message */
- unsigned SMBsendtxt_time;
- unsigned SMBinvalid_count; /* invalid command */
- unsigned SMBinvalid_time;
-/* Pathworks setdir command */
- unsigned pathworks_setdir_count;
- unsigned pathworks_setdir_time;
-/* These are the TRANS2 sub commands */
- unsigned Trans2_open_count;
- unsigned Trans2_open_time;
- unsigned Trans2_findfirst_count;
- unsigned Trans2_findfirst_time;
- unsigned Trans2_findnext_count;
- unsigned Trans2_findnext_time;
- unsigned Trans2_qfsinfo_count;
- unsigned Trans2_qfsinfo_time;
- unsigned Trans2_setfsinfo_count;
- unsigned Trans2_setfsinfo_time;
- unsigned Trans2_qpathinfo_count;
- unsigned Trans2_qpathinfo_time;
- unsigned Trans2_setpathinfo_count;
- unsigned Trans2_setpathinfo_time;
- unsigned Trans2_qfileinfo_count;
- unsigned Trans2_qfileinfo_time;
- unsigned Trans2_setfileinfo_count;
- unsigned Trans2_setfileinfo_time;
- unsigned Trans2_fsctl_count;
- unsigned Trans2_fsctl_time;
- unsigned Trans2_ioctl_count;
- unsigned Trans2_ioctl_time;
- unsigned Trans2_findnotifyfirst_count;
- unsigned Trans2_findnotifyfirst_time;
- unsigned Trans2_findnotifynext_count;
- unsigned Trans2_findnotifynext_time;
- unsigned Trans2_mkdir_count;
- unsigned Trans2_mkdir_time;
- unsigned Trans2_session_setup_count;
- unsigned Trans2_session_setup_time;
- unsigned Trans2_get_dfs_referral_count;
- unsigned Trans2_get_dfs_referral_time;
- unsigned Trans2_report_dfs_inconsistancy_count;
- unsigned Trans2_report_dfs_inconsistancy_time;
-/* These are the NT transact sub commands. */
- unsigned NT_transact_create_count;
- unsigned NT_transact_create_time;
- unsigned NT_transact_ioctl_count;
- unsigned NT_transact_ioctl_time;
- unsigned NT_transact_set_security_desc_count;
- unsigned NT_transact_set_security_desc_time;
- unsigned NT_transact_notify_change_count;
- unsigned NT_transact_notify_change_time;
- unsigned NT_transact_rename_count;
- unsigned NT_transact_rename_time;
- unsigned NT_transact_query_security_desc_count;
- unsigned NT_transact_query_security_desc_time;
- unsigned NT_transact_get_user_quota_count;
- unsigned NT_transact_get_user_quota_time;
- unsigned NT_transact_set_user_quota_count;
- unsigned NT_transact_set_user_quota_time;
-/* These are ACL manipulation calls */
- unsigned get_nt_acl_count;
- unsigned get_nt_acl_time;
- unsigned fget_nt_acl_count;
- unsigned fget_nt_acl_time;
- unsigned set_nt_acl_count;
- unsigned set_nt_acl_time;
- unsigned fset_nt_acl_count;
- unsigned fset_nt_acl_time;
- unsigned chmod_acl_count;
- unsigned chmod_acl_time;
- unsigned fchmod_acl_count;
- unsigned fchmod_acl_time;
-/* These are nmbd stats */
- unsigned name_release_count;
- unsigned name_release_time;
- unsigned name_refresh_count;
- unsigned name_refresh_time;
- unsigned name_registration_count;
- unsigned name_registration_time;
- unsigned node_status_count;
- unsigned node_status_time;
- unsigned name_query_count;
- unsigned name_query_time;
- unsigned host_announce_count;
- unsigned host_announce_time;
- unsigned workgroup_announce_count;
- unsigned workgroup_announce_time;
- unsigned local_master_announce_count;
- unsigned local_master_announce_time;
- unsigned master_browser_announce_count;
- unsigned master_browser_announce_time;
- unsigned lm_host_announce_count;
- unsigned lm_host_announce_time;
- unsigned get_backup_list_count;
- unsigned get_backup_list_time;
- unsigned reset_browser_count;
- unsigned reset_browser_time;
- unsigned announce_request_count;
- unsigned announce_request_time;
- unsigned lm_announce_request_count;
- unsigned lm_announce_request_time;
- unsigned domain_logon_count;
- unsigned domain_logon_time;
- unsigned sync_browse_lists_count;
- unsigned sync_browse_lists_time;
- unsigned run_elections_count;
- unsigned run_elections_time;
- unsigned election_count;
- unsigned election_time;
};
struct profile_header {
diff --git a/source/intl/lang_tdb.c b/source/intl/lang_tdb.c
index 016f64af52a..ddb3d4d65e3 100644
--- a/source/intl/lang_tdb.c
+++ b/source/intl/lang_tdb.c
@@ -197,7 +197,7 @@ const char *lang_msg(const char *msgid)
count++;
}
- if (!(msgid_quoted = SMB_MALLOC(strlen(msgid) + count + 1)))
+ if (!(msgid_quoted = (char *)SMB_MALLOC(strlen(msgid) + count + 1)))
return msgid;
/* string_sub() is unsuitable here as it replaces some punctuation
diff --git a/source/lib/debug.c b/source/lib/debug.c
index c0f4deb0287..00f6b0e72ff 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -981,7 +981,7 @@ BOOL dbghdr( int level, const char *file, const char *func, int line )
/* Print it all out at once to prevent split syslog output. */
(void)Debug1( "[%s, %d%s] %s:%s(%d)\n",
- timestring(lp_debug_hires_timestamp()), level,
+ current_timestring(lp_debug_hires_timestamp()), level,
header_str, file, func, line );
}
diff --git a/source/lib/substitute.c b/source/lib/substitute.c
index ff9deb8a5f0..3e556cebd1e 100644
--- a/source/lib/substitute.c
+++ b/source/lib/substitute.c
@@ -522,7 +522,7 @@ char *alloc_sub_basic(const char *smb_name, const char *str)
a_string = realloc_string_sub(a_string, "%R", remote_proto);
break;
case 'T' :
- a_string = realloc_string_sub(a_string, "%T", timestring(False));
+ a_string = realloc_string_sub(a_string, "%T", current_timestring(False));
break;
case 'a' :
a_string = realloc_string_sub(a_string, "%a", remote_arch);
diff --git a/source/lib/time.c b/source/lib/time.c
index 9a539d415e8..9fe69eb45ac 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -1,8 +1,10 @@
/*
Unix SMB/CIFS implementation.
time handling functions
- Copyright (C) Andrew Tridgell 1992-1998
+
+ Copyright (C) Andrew Tridgell 1992-2004
Copyright (C) Stefan (metze) Metzmacher 2002
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -20,16 +22,11 @@
#include "includes.h"
-/*
- This stuff was largely rewritten by Paul Eggert <eggert@twinsun.com>
- in May 1996
- */
+/**
+ * @file
+ * @brief time handling functions
+ */
-int extra_time_offset = 0;
-
-#ifndef CHAR_BIT
-#define CHAR_BIT 8
-#endif
#ifndef TIME_T_MIN
#define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
@@ -39,19 +36,17 @@ int extra_time_offset = 0;
#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
#endif
-/*******************************************************************
+/**
External access to time_t_min and time_t_max.
-********************************************************************/
-
+**/
time_t get_time_t_max(void)
{
return TIME_T_MAX;
}
-/*******************************************************************
- A gettimeofday wrapper.
-********************************************************************/
-
+/**
+a gettimeofday wrapper
+**/
void GetTimeOfDay(struct timeval *tval)
{
#ifdef HAVE_GETTIMEOFDAY_TZ
@@ -61,220 +56,37 @@ void GetTimeOfDay(struct timeval *tval)
#endif
}
-#define TM_YEAR_BASE 1900
-
-/*******************************************************************
- Yield the difference between *A and *B, in seconds, ignoring leap seconds.
-********************************************************************/
+#define TIME_FIXUP_CONSTANT 11644473600LL
-static int tm_diff(struct tm *a, struct tm *b)
+struct timespec convert_time_t_to_timespec(time_t t)
{
- int ay = a->tm_year + (TM_YEAR_BASE - 1);
- int by = b->tm_year + (TM_YEAR_BASE - 1);
- int intervening_leap_days = (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
- int years = ay - by;
- int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
- int hours = 24*days + (a->tm_hour - b->tm_hour);
- int minutes = 60*hours + (a->tm_min - b->tm_min);
- int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
-
- return seconds;
+ struct timespec ts;
+ ts.tv_sec = t;
+ ts.tv_nsec = 0;
+ return ts;
}
-/*******************************************************************
- Return the UTC offset in seconds west of UTC, or 0 if it cannot be determined.
-******************************************************************/
-
-int get_time_zone(time_t t)
-{
- struct tm *tm = gmtime(&t);
- struct tm tm_utc;
-
- if (!tm) {
- return 0;
- }
- tm_utc = *tm;
- tm = localtime(&t);
- if (!tm) {
- return 0;
- }
- return tm_diff(&tm_utc,tm) + 60*extra_time_offset;
-}
-
-/*******************************************************************
- Accessor function for the server time zone offset.
- set_server_zone_offset() must have been called first.
-******************************************************************/
-
-static int server_zone_offset;
-
-int get_server_zone_offset(void)
-{
- return server_zone_offset;
-}
-
-/*******************************************************************
- Initialize the server time zone offset. Called when a client connects.
-******************************************************************/
-
-int set_server_zone_offset(time_t t)
-{
- server_zone_offset = get_time_zone(t);
- return server_zone_offset;
-}
-
-/*******************************************************************
- Re-read the smb serverzone value.
-******************************************************************/
-
-static struct timeval start_time_hires;
-
-void TimeInit(void)
-{
- set_server_zone_offset(time(NULL));
-
- DEBUG(4,("TimeInit: Serverzone is %d\n", server_zone_offset));
-
- /* Save the start time of this process. */
- if (start_time_hires.tv_sec == 0 && start_time_hires.tv_usec == 0) {
- GetTimeOfDay(&start_time_hires);
- }
-}
-
-/**********************************************************************
- Return a timeval struct of the uptime of this process. As TimeInit is
- done before a daemon fork then this is the start time from the parent
- daemon start. JRA.
-***********************************************************************/
-
-void get_process_uptime(struct timeval *ret_time)
-{
- struct timeval time_now_hires;
-
- GetTimeOfDay(&time_now_hires);
- ret_time->tv_sec = time_now_hires.tv_sec - start_time_hires.tv_sec;
- if (time_now_hires.tv_usec < start_time_hires.tv_usec) {
- ret_time->tv_sec -= 1;
- ret_time->tv_usec = 1000000 + (time_now_hires.tv_usec - start_time_hires.tv_usec);
- } else {
- ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
- }
-}
-
-#if 0
-/****************************************************************************
- Return the UTC offset in seconds west of UTC, adjusted for extra time offset.
-**************************************************************************/
-
-int TimeDiff(time_t t)
-{
- return get_time_zone(t);
-}
+#if (SIZEOF_LONG == 8)
+#define TIME_FIXUP_CONSTANT_INT 11644473600L
+#elif (SIZEOF_LONG_LONG == 8)
+#define TIME_FIXUP_CONSTANT_INT 11644473600LL
#endif
-#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
-
/****************************************************************************
Interpret an 8 byte "filetime" structure to a time_t
It's originally in "100ns units since jan 1st 1601"
- An 8 byte value of 0xffffffffffffffff will be returned as (time_t)0.
+ An 8 byte value of 0xffffffffffffffff will be returned as a timespec of
- Returns GMT.
-****************************************************************************/
-
-time_t nt_time_to_unix(NTTIME *nt)
-{
- double d;
- time_t ret;
- /* The next two lines are a fix needed for the
- broken SCO compiler. JRA. */
- time_t l_time_min = TIME_T_MIN;
- time_t l_time_max = TIME_T_MAX;
-
- if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff)) {
- return(0);
- }
-
- d = ((double)nt->high)*4.0*(double)(1<<30);
- d += (nt->low&0xFFF00000);
- d *= 1.0e-7;
-
- /* now adjust by 369 years to make the secs since 1970 */
- d -= TIME_FIXUP_CONSTANT;
-
- if (d <= l_time_min) {
- return (l_time_min);
- }
-
- if (d >= l_time_max) {
- return (l_time_max);
- }
+ tv_sec = 0
+ tv_nsec = 0;
- ret = (time_t)(d+0.5);
- return(ret);
-}
-
-/****************************************************************************
- Convert a NTTIME structure to a time_t.
- It's originally in "100ns units".
-
- This is an absolute version of the one above.
- By absolute I mean, it doesn't adjust from 1/1/1601 to 1/1/1970
- if the NTTIME was 5 seconds, the time_t is 5 seconds. JFM
-****************************************************************************/
-
-time_t nt_time_to_unix_abs(const NTTIME *nt)
-{
- double d;
- time_t ret;
- /* The next two lines are a fix needed for the
- broken SCO compiler. JRA. */
- time_t l_time_min = TIME_T_MIN;
- time_t l_time_max = TIME_T_MAX;
- NTTIME neg_nt;
-
- if (nt->high == 0) {
- return(0);
- }
-
- if (nt->high==0x80000000 && nt->low==0) {
- return (time_t)-1;
- }
-
- /* reverse the time */
- /* it's a negative value, turn it to positive */
- neg_nt.high=~nt->high;
- neg_nt.low=~nt->low;
-
- d = ((double)neg_nt.high)*4.0*(double)(1<<30);
- d += (neg_nt.low&0xFFF00000);
- d *= 1.0e-7;
-
- if (!(l_time_min <= d && d <= l_time_max)) {
- return(0);
- }
-
- ret = (time_t)(d+0.5);
-
- return(ret);
-}
-
-/****************************************************************************
- Interprets an nt time into a unix time_t.
- Differs from nt_time_to_unix in that an 8 byte value of 0xffffffffffffffff
- will be returned as (time_t)-1, whereas nt_time_to_unix returns 0 in this case.
+ Returns GMT.
****************************************************************************/
-time_t interpret_long_date(char *p)
+time_t nt_time_to_unix(NTTIME nt)
{
- NTTIME nt;
- nt.low = IVAL(p,0);
- nt.high = IVAL(p,4);
- if (nt.low == 0xFFFFFFFF && nt.high == 0xFFFFFFFF) {
- return (time_t)-1;
- }
- return nt_time_to_unix(&nt);
+ return convert_timespec_to_time_t(nt_time_to_unix_timespec(&nt));
}
/****************************************************************************
@@ -283,137 +95,81 @@ time_t interpret_long_date(char *p)
void unix_to_nt_time(NTTIME *nt, time_t t)
{
- double d;
+ uint64_t t2;
- if (t==0) {
- nt->low = 0;
- nt->high = 0;
- return;
- }
- if (t == TIME_T_MAX) {
- nt->low = 0xffffffff;
- nt->high = 0x7fffffff;
- return;
- }
if (t == (time_t)-1) {
- nt->low = 0xffffffff;
- nt->high = 0xffffffff;
+ *nt = (NTTIME)-1LL;
return;
}
-
- d = (double)(t);
- d += TIME_FIXUP_CONSTANT;
- d *= 1.0e7;
-
- nt->high = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
- nt->low = (uint32)(d - ((double)nt->high)*4.0*(double)(1<<30));
-}
-
-/****************************************************************************
- Convert a time_t to a NTTIME structure
-
- This is an absolute version of the one above.
- By absolute I mean, it doesn't adjust from 1/1/1970 to 1/1/1601
- If the nttime_t was 5 seconds, the NTTIME is 5 seconds. JFM
-****************************************************************************/
-
-void unix_to_nt_time_abs(NTTIME *nt, time_t t)
-{
- double d;
-
- if (t==0) {
- nt->low = 0;
- nt->high = 0;
- return;
- }
-
- if (t == TIME_T_MAX) {
- nt->low = 0xffffffff;
- nt->high = 0x7fffffff;
- return;
- }
-
- if (t == (time_t)-1) {
- /* that's what NT uses for infinite */
- nt->low = 0x0;
- nt->high = 0x80000000;
+ if (t == 0) {
+ *nt = 0;
return;
}
- d = (double)(t);
- d *= 1.0e7;
-
- nt->high = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
- nt->low = (uint32)(d - ((double)nt->high)*4.0*(double)(1<<30));
+ t2 = t;
+ t2 += TIME_FIXUP_CONSTANT;
+ t2 *= 1000*1000*10;
- /* convert to a negative value */
- nt->high=~nt->high;
- nt->low=~nt->low;
+ *nt = t2;
}
-/****************************************************************************
- Take a Unix time and convert to an NTTIME structure and place in buffer
- pointed to by p.
-****************************************************************************/
-void put_long_date(char *p, time_t t)
+/**
+check if it's a null unix time
+**/
+BOOL null_time(time_t t)
{
- NTTIME nt;
- unix_to_nt_time(&nt, t);
- SIVAL(p, 0, nt.low);
- SIVAL(p, 4, nt.high);
+ return t == 0 ||
+ t == (time_t)0xFFFFFFFF ||
+ t == (time_t)-1;
}
-/****************************************************************************
- Check if it's a null mtime.
-****************************************************************************/
-BOOL null_mtime(time_t mtime)
+/**
+check if it's a null NTTIME
+**/
+BOOL null_nttime(NTTIME t)
{
- if (mtime == 0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
- return(True);
- return(False);
+ return t == 0 || t == (NTTIME)-1;
}
/*******************************************************************
- Create a 16 bit dos packed date.
+ create a 16 bit dos packed date
********************************************************************/
-
-static uint16 make_dos_date1(struct tm *t)
+static uint16_t make_dos_date1(struct tm *t)
{
- uint16 ret=0;
- ret = (((unsigned)(t->tm_mon+1)) >> 3) | ((t->tm_year-80) << 1);
+ uint16_t ret=0;
+ ret = (((unsigned int)(t->tm_mon+1)) >> 3) | ((t->tm_year-80) << 1);
ret = ((ret&0xFF)<<8) | (t->tm_mday | (((t->tm_mon+1) & 0x7) << 5));
- return(ret);
+ return ret;
}
/*******************************************************************
- Create a 16 bit dos packed time.
+ create a 16 bit dos packed time
********************************************************************/
-
-static uint16 make_dos_time1(struct tm *t)
+static uint16_t make_dos_time1(struct tm *t)
{
- uint16 ret=0;
- ret = ((((unsigned)t->tm_min >> 3)&0x7) | (((unsigned)t->tm_hour) << 3));
+ uint16_t ret=0;
+ ret = ((((unsigned int)t->tm_min >> 3)&0x7) | (((unsigned int)t->tm_hour) << 3));
ret = ((ret&0xFF)<<8) | ((t->tm_sec/2) | ((t->tm_min & 0x7) << 5));
- return(ret);
+ return ret;
}
/*******************************************************************
- Create a 32 bit dos packed date/time from some parameters.
- This takes a GMT time and returns a packed localtime structure.
+ create a 32 bit dos packed date/time from some parameters
+ This takes a GMT time and returns a packed localtime structure
********************************************************************/
-
-static uint32 make_dos_date(time_t unixdate, int zone_offset)
+static uint32_t make_dos_date(time_t unixdate, int zone_offset)
{
struct tm *t;
- uint32 ret=0;
+ uint32_t ret=0;
if (unixdate == 0) {
return 0;
}
unixdate -= zone_offset;
+
t = gmtime(&unixdate);
if (!t) {
return 0xFFFFFFFF;
@@ -422,53 +178,50 @@ static uint32 make_dos_date(time_t unixdate, int zone_offset)
ret = make_dos_date1(t);
ret = ((ret&0xFFFF)<<16) | make_dos_time1(t);
- return(ret);
+ return ret;
}
-/*******************************************************************
- Put a dos date into a buffer (time/date format).
- This takes GMT time and puts local time in the buffer.
-********************************************************************/
-
-static void put_dos_date(char *buf,int offset,time_t unixdate, int zone_offset)
+/**
+put a dos date into a buffer (time/date format)
+This takes GMT time and puts local time in the buffer
+**/
+void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset)
{
- uint32 x = make_dos_date(unixdate, zone_offset);
+ uint32_t x = make_dos_date(unixdate, zone_offset);
SIVAL(buf,offset,x);
}
-/*******************************************************************
- Put a dos date into a buffer (date/time format).
- This takes GMT time and puts local time in the buffer.
-********************************************************************/
-
-static void put_dos_date2(char *buf,int offset,time_t unixdate, int zone_offset)
+/**
+put a dos date into a buffer (date/time format)
+This takes GMT time and puts local time in the buffer
+**/
+void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset)
{
- uint32 x = make_dos_date(unixdate, zone_offset);
+ uint32_t x;
+ x = make_dos_date(unixdate, zone_offset);
x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
SIVAL(buf,offset,x);
}
-/*******************************************************************
- Put a dos 32 bit "unix like" date into a buffer. This routine takes
- GMT and converts it to LOCAL time before putting it (most SMBs assume
- localtime for this sort of date)
-********************************************************************/
-
-static void put_dos_date3(char *buf,int offset,time_t unixdate, int zone_offset)
+/**
+put a dos 32 bit "unix like" date into a buffer. This routine takes
+GMT and converts it to LOCAL time before putting it (most SMBs assume
+localtime for this sort of date)
+**/
+void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset)
{
- if (!null_mtime(unixdate)) {
+ if (!null_time(unixdate)) {
unixdate -= zone_offset;
}
SIVAL(buf,offset,unixdate);
}
/*******************************************************************
- Interpret a 32 bit dos packed date/time to some parameters.
+ interpret a 32 bit dos packed date/time to some parameters
********************************************************************/
-
-static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
+static void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second)
{
- uint32 p0,p1,p2,p3;
+ uint32_t p0,p1,p2,p3;
p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
@@ -481,161 +234,414 @@ static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *ho
*year = ((p3>>1)&0xFF) + 80;
}
-/*******************************************************************
- Create a unix date (int GMT) from a dos date (which is actually in
- localtime).
-********************************************************************/
-
-static time_t make_unix_date(void *date_ptr, int zone_offset)
+/**
+ create a unix date (int GMT) from a dos date (which is actually in
+ localtime)
+**/
+time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset)
{
- uint32 dos_date=0;
+ uint32_t dos_date=0;
struct tm t;
time_t ret;
dos_date = IVAL(date_ptr,0);
- if (dos_date == 0) {
- return 0;
- }
+ if (dos_date == 0) return (time_t)0;
interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
- &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
+ &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
t.tm_isdst = -1;
ret = timegm(&t);
ret += zone_offset;
- return(ret);
+ return ret;
}
-/*******************************************************************
- Like make_unix_date() but the words are reversed.
-********************************************************************/
-
-static time_t make_unix_date2(void *date_ptr, int zone_offset)
+/**
+like make_unix_date() but the words are reversed
+**/
+time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset)
{
- uint32 x,x2;
+ uint32_t x,x2;
x = IVAL(date_ptr,0);
x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
SIVAL(&x,0,x2);
- return(make_unix_date((void *)&x, zone_offset));
+ return pull_dos_date((const uint8_t *)&x, zone_offset);
}
-/*******************************************************************
- Create a unix GMT date from a dos date in 32 bit "unix like" format
- these generally arrive as localtimes, with corresponding DST.
-******************************************************************/
-
-static time_t make_unix_date3(void *date_ptr, int zone_offset)
+/**
+ create a unix GMT date from a dos date in 32 bit "unix like" format
+ these generally arrive as localtimes, with corresponding DST
+**/
+time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset)
{
time_t t = (time_t)IVAL(date_ptr,0);
- if (!null_mtime(t)) {
+ if (!null_time(t)) {
t += zone_offset;
}
- return(t);
+ return t;
}
/***************************************************************************
- Server versions of the above functions.
+ Return a HTTP/1.0 time string.
***************************************************************************/
-void srv_put_dos_date(char *buf,int offset,time_t unixdate)
+char *http_timestring(time_t t)
{
- put_dos_date(buf, offset, unixdate, server_zone_offset);
+ static fstring buf;
+ struct tm *tm = localtime(&t);
+
+ if (!tm) {
+ slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
+ } else {
+#ifndef HAVE_STRFTIME
+ const char *asct = asctime(tm);
+ fstrcpy(buf, asct ? asct : "unknown");
+ }
+ if(buf[strlen(buf)-1] == '\n') {
+ buf[strlen(buf)-1] = 0;
+#else /* !HAVE_STRFTIME */
+ strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
+#endif /* !HAVE_STRFTIME */
+ }
+ return buf;
}
-void srv_put_dos_date2(char *buf,int offset, time_t unixdate)
+
+/**
+ Return the date and time as a string
+**/
+char *timestring(TALLOC_CTX *mem_ctx, time_t t)
{
- put_dos_date2(buf, offset, unixdate, server_zone_offset);
+ char *TimeBuf;
+ char tempTime[80];
+ struct tm *tm;
+
+ tm = localtime(&t);
+ if (!tm) {
+ return talloc_asprintf(mem_ctx,
+ "%ld seconds since the Epoch",
+ (long)t);
+ }
+
+#ifdef HAVE_STRFTIME
+ /* some versions of gcc complain about using %c. This is a bug
+ in the gcc warning, not a bug in this code. See a recent
+ strftime() manual page for details.
+ */
+ strftime(tempTime,sizeof(tempTime)-1,"%c %Z",tm);
+ TimeBuf = talloc_strdup(mem_ctx, tempTime);
+#else
+ TimeBuf = talloc_strdup(mem_ctx, asctime(tm));
+#endif
+
+ return TimeBuf;
}
-void srv_put_dos_date3(char *buf,int offset,time_t unixdate)
+/**
+ return a talloced string representing a NTTIME for human consumption
+*/
+const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt)
{
- put_dos_date3(buf, offset, unixdate, server_zone_offset);
+ time_t t;
+ if (nt == 0) {
+ return "NTTIME(0)";
+ }
+ t = nt_time_to_unix(nt);
+ return timestring(mem_ctx, t);
}
-time_t srv_make_unix_date(void *date_ptr)
+
+/**
+ parse a nttime as a large integer in a string and return a NTTIME
+*/
+NTTIME nttime_from_string(const char *s)
{
- return make_unix_date(date_ptr, server_zone_offset);
+ return strtoull(s, NULL, 0);
}
-time_t srv_make_unix_date2(void *date_ptr)
+/**
+ return (tv1 - tv2) in microseconds
+*/
+int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2)
{
- return make_unix_date2(date_ptr, server_zone_offset);
+ int64_t sec_diff = tv1->tv_sec - tv2->tv_sec;
+ return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec);
}
-time_t srv_make_unix_date3(void *date_ptr)
+
+/**
+ return a zero timeval
+*/
+struct timeval timeval_zero(void)
{
- return make_unix_date3(date_ptr, server_zone_offset);
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ return tv;
}
-/***************************************************************************
- Client versions of the above functions.
-***************************************************************************/
+/**
+ return True if a timeval is zero
+*/
+BOOL timeval_is_zero(const struct timeval *tv)
+{
+ return tv->tv_sec == 0 && tv->tv_usec == 0;
+}
-void cli_put_dos_date(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+/**
+ return a timeval for the current time
+*/
+struct timeval timeval_current(void)
{
- put_dos_date(buf, offset, unixdate, cli->serverzone);
+ struct timeval tv;
+ GetTimeOfDay(&tv);
+ return tv;
}
-void cli_put_dos_date2(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+/**
+ return a timeval struct with the given elements
+*/
+struct timeval timeval_set(uint32_t secs, uint32_t usecs)
{
- put_dos_date2(buf, offset, unixdate, cli->serverzone);
+ struct timeval tv;
+ tv.tv_sec = secs;
+ tv.tv_usec = usecs;
+ return tv;
}
-void cli_put_dos_date3(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+
+/**
+ return a timeval ofs microseconds after tv
+*/
+struct timeval timeval_add(const struct timeval *tv,
+ uint32_t secs, uint32_t usecs)
{
- put_dos_date3(buf, offset, unixdate, cli->serverzone);
+ struct timeval tv2 = *tv;
+ const unsigned int million = 1000000;
+ tv2.tv_sec += secs;
+ tv2.tv_usec += usecs;
+ tv2.tv_sec += tv2.tv_usec / million;
+ tv2.tv_usec = tv2.tv_usec % million;
+ return tv2;
}
-time_t cli_make_unix_date(struct cli_state *cli, void *date_ptr)
+/**
+ return the sum of two timeval structures
+*/
+struct timeval timeval_sum(const struct timeval *tv1,
+ const struct timeval *tv2)
{
- return make_unix_date(date_ptr, cli->serverzone);
+ return timeval_add(tv1, tv2->tv_sec, tv2->tv_usec);
}
-time_t cli_make_unix_date2(struct cli_state *cli, void *date_ptr)
+/**
+ return a timeval secs/usecs into the future
+*/
+struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
{
- return make_unix_date2(date_ptr, cli->serverzone);
+ struct timeval tv = timeval_current();
+ return timeval_add(&tv, secs, usecs);
}
-time_t cli_make_unix_date3(struct cli_state *cli, void *date_ptr)
+/**
+ compare two timeval structures.
+ Return -1 if tv1 < tv2
+ Return 0 if tv1 == tv2
+ Return 1 if tv1 > tv2
+*/
+int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
{
- return make_unix_date3(date_ptr, cli->serverzone);
+ if (tv1->tv_sec > tv2->tv_sec) return 1;
+ if (tv1->tv_sec < tv2->tv_sec) return -1;
+ if (tv1->tv_usec > tv2->tv_usec) return 1;
+ if (tv1->tv_usec < tv2->tv_usec) return -1;
+ return 0;
}
-/***************************************************************************
- Return a HTTP/1.0 time string.
-***************************************************************************/
+/**
+ return True if a timer is in the past
+*/
+BOOL timeval_expired(const struct timeval *tv)
+{
+ struct timeval tv2 = timeval_current();
+ if (tv2.tv_sec > tv->tv_sec) return True;
+ if (tv2.tv_sec < tv->tv_sec) return False;
+ return (tv2.tv_usec >= tv->tv_usec);
+}
-char *http_timestring(time_t t)
+/**
+ return the number of seconds elapsed between two times
+*/
+double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2)
{
- static fstring buf;
- struct tm *tm = localtime(&t);
+ return (tv2->tv_sec - tv1->tv_sec) +
+ (tv2->tv_usec - tv1->tv_usec)*1.0e-6;
+}
- if (!tm) {
- slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
+/**
+ return the number of seconds elapsed since a given time
+*/
+double timeval_elapsed(const struct timeval *tv)
+{
+ struct timeval tv2 = timeval_current();
+ return timeval_elapsed2(tv, &tv2);
+}
+
+/**
+ return the lesser of two timevals
+*/
+struct timeval timeval_min(const struct timeval *tv1,
+ const struct timeval *tv2)
+{
+ if (tv1->tv_sec < tv2->tv_sec) return *tv1;
+ if (tv1->tv_sec > tv2->tv_sec) return *tv2;
+ if (tv1->tv_usec < tv2->tv_usec) return *tv1;
+ return *tv2;
+}
+
+/**
+ return the greater of two timevals
+*/
+struct timeval timeval_max(const struct timeval *tv1,
+ const struct timeval *tv2)
+{
+ if (tv1->tv_sec > tv2->tv_sec) return *tv1;
+ if (tv1->tv_sec < tv2->tv_sec) return *tv2;
+ if (tv1->tv_usec > tv2->tv_usec) return *tv1;
+ return *tv2;
+}
+
+/**
+ return the difference between two timevals as a timeval
+ if tv1 comes after tv2, then return a zero timeval
+ (this is *tv2 - *tv1)
+*/
+struct timeval timeval_until(const struct timeval *tv1,
+ const struct timeval *tv2)
+{
+ struct timeval t;
+ if (timeval_compare(tv1, tv2) >= 0) {
+ return timeval_zero();
+ }
+ t.tv_sec = tv2->tv_sec - tv1->tv_sec;
+ if (tv1->tv_usec > tv2->tv_usec) {
+ t.tv_sec--;
+ t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec);
} else {
-#ifndef HAVE_STRFTIME
- const char *asct = asctime(tm);
- fstrcpy(buf, asct ? asct : "unknown");
+ t.tv_usec = tv2->tv_usec - tv1->tv_usec;
}
- if(buf[strlen(buf)-1] == '\n') {
- buf[strlen(buf)-1] = 0;
-#else /* !HAVE_STRFTIME */
- strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
-#endif /* !HAVE_STRFTIME */
+ return t;
+}
+
+
+/**
+ convert a timeval to a NTTIME
+*/
+NTTIME timeval_to_nttime(const struct timeval *tv)
+{
+ return 10*(tv->tv_usec +
+ ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
+}
+
+/*******************************************************************
+yield the difference between *A and *B, in seconds, ignoring leap seconds
+********************************************************************/
+static int tm_diff(struct tm *a, struct tm *b)
+{
+ int ay = a->tm_year + (1900 - 1);
+ int by = b->tm_year + (1900 - 1);
+ int intervening_leap_days =
+ (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
+ int years = ay - by;
+ int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
+ int hours = 24*days + (a->tm_hour - b->tm_hour);
+ int minutes = 60*hours + (a->tm_min - b->tm_min);
+ int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
+
+ return seconds;
+}
+
+int extra_time_offset=0;
+
+/**
+ return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
+ */
+int get_time_zone(time_t t)
+{
+ struct tm *tm = gmtime(&t);
+ struct tm tm_utc;
+ if (!tm)
+ return 0;
+ tm_utc = *tm;
+ tm = localtime(&t);
+ if (!tm)
+ return 0;
+ return tm_diff(&tm_utc,tm)+60*extra_time_offset;
+}
+
+/****************************************************************************
+ Check if NTTIME is 0.
+****************************************************************************/
+
+BOOL nt_time_is_zero(const NTTIME *nt)
+{
+ return (*nt == 0);
+}
+
+/****************************************************************************
+ Convert ASN.1 GeneralizedTime string to unix-time.
+ Returns 0 on failure; Currently ignores timezone.
+****************************************************************************/
+
+time_t generalized_to_unix_time(const char *str)
+{
+ struct tm tm;
+
+ ZERO_STRUCT(tm);
+
+ if (sscanf(str, "%4d%2d%2d%2d%2d%2d",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ return 0;
}
- return buf;
+ tm.tm_year -= 1900;
+ tm.tm_mon -= 1;
+
+ return timegm(&tm);
+}
+
+/*******************************************************************
+ Accessor function for the server time zone offset.
+ set_server_zone_offset() must have been called first.
+******************************************************************/
+
+static int server_zone_offset;
+
+int get_server_zone_offset(void)
+{
+ return server_zone_offset;
+}
+
+/*******************************************************************
+ Initialize the server time zone offset. Called when a client connects.
+******************************************************************/
+
+int set_server_zone_offset(time_t t)
+{
+ server_zone_offset = get_time_zone(t);
+ return server_zone_offset;
}
/****************************************************************************
Return the date and time as a string
****************************************************************************/
-char *timestring(BOOL hires)
+char *current_timestring(BOOL hires)
{
static fstring TimeBuf;
struct timeval tp;
@@ -690,6 +696,85 @@ char *timestring(BOOL hires)
return(TimeBuf);
}
+
+/*******************************************************************
+ Put a dos date into a buffer (time/date format).
+ This takes GMT time and puts local time in the buffer.
+********************************************************************/
+
+static void put_dos_date(char *buf,int offset,time_t unixdate, int zone_offset)
+{
+ uint32 x = make_dos_date(unixdate, zone_offset);
+ SIVAL(buf,offset,x);
+}
+
+/*******************************************************************
+ Put a dos date into a buffer (date/time format).
+ This takes GMT time and puts local time in the buffer.
+********************************************************************/
+
+static void put_dos_date2(char *buf,int offset,time_t unixdate, int zone_offset)
+{
+ uint32 x = make_dos_date(unixdate, zone_offset);
+ x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
+ SIVAL(buf,offset,x);
+}
+
+/*******************************************************************
+ Put a dos 32 bit "unix like" date into a buffer. This routine takes
+ GMT and converts it to LOCAL time before putting it (most SMBs assume
+ localtime for this sort of date)
+********************************************************************/
+
+static void put_dos_date3(char *buf,int offset,time_t unixdate, int zone_offset)
+{
+ if (!null_mtime(unixdate)) {
+ unixdate -= zone_offset;
+ }
+ SIVAL(buf,offset,unixdate);
+}
+
+
+/***************************************************************************
+ Server versions of the above functions.
+***************************************************************************/
+
+void srv_put_dos_date(char *buf,int offset,time_t unixdate)
+{
+ put_dos_date(buf, offset, unixdate, server_zone_offset);
+}
+
+void srv_put_dos_date2(char *buf,int offset, time_t unixdate)
+{
+ put_dos_date2(buf, offset, unixdate, server_zone_offset);
+}
+
+void srv_put_dos_date3(char *buf,int offset,time_t unixdate)
+{
+ put_dos_date3(buf, offset, unixdate, server_zone_offset);
+}
+
+/****************************************************************************
+ Take a Unix time and convert to an NTTIME structure and place in buffer
+ pointed to by p.
+****************************************************************************/
+
+void put_long_date_timespec(char *p, struct timespec ts)
+{
+ NTTIME nt;
+ unix_timespec_to_nt_time(&nt, ts);
+ SIVAL(p, 0, nt & 0xFFFFFFFF);
+ SIVAL(p, 4, nt >> 32);
+}
+
+void put_long_date(char *p, time_t t)
+{
+ struct timespec ts;
+ ts.tv_sec = t;
+ ts.tv_nsec = 0;
+ put_long_date_timespec(p, ts);
+}
+
/****************************************************************************
Return the best approximation to a 'create time' under UNIX from a stat
structure.
@@ -717,344 +802,485 @@ time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs)
return ret;
}
+struct timespec get_create_timespec(SMB_STRUCT_STAT *st,BOOL fake_dirs)
+{
+ struct timespec ts;
+ ts.tv_sec = get_create_time(st, fake_dirs);
+ ts.tv_nsec = 0;
+ return ts;
+}
+
/****************************************************************************
- Initialise an NTTIME to -1, which means "unknown" or "don't expire".
+ Get/Set all the possible time fields from a stat struct as a timespec.
****************************************************************************/
-void init_nt_time(NTTIME *nt)
+struct timespec get_atimespec(SMB_STRUCT_STAT *pst)
{
- nt->high = 0x7FFFFFFF;
- nt->low = 0xFFFFFFFF;
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+ struct timespec ret;
+
+ /* Old system - no ns timestamp. */
+ ret.tv_sec = pst->st_atime;
+ ret.tv_nsec = 0;
+ return ret;
+#else
+#if defined(HAVE_STAT_ST_ATIM)
+ return pst->st_atim;
+#elif defined(HAVE_STAT_ST_ATIMENSEC)
+ struct timespec ret;
+ ret.tv_sec = pst->st_atime;
+ ret.tv_nsec = pst->st_atimensec;
+ return ret;
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
}
-BOOL nt_time_is_set(const NTTIME *nt)
+void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts)
{
- if ((nt->high == 0x7FFFFFFF) && (nt->low == 0xFFFFFFFF)) {
- return False;
- }
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+ /* Old system - no ns timestamp. */
+ pst->st_atime = ts.tv_sec;
+#else
+#if defined(HAVE_STAT_ST_ATIM)
+ pst->st_atim = ts;
+#elif defined(HAVE_STAT_ST_ATIMENSEC)
+ pst->st_atime = ts.tv_sec;
+ pst->st_atimensec = ts.tv_nsec
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
+}
- if ((nt->high == 0x80000000) && (nt->low == 0)) {
- return False;
- }
+struct timespec get_mtimespec(SMB_STRUCT_STAT *pst)
+{
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+ struct timespec ret;
- return True;
+ /* Old system - no ns timestamp. */
+ ret.tv_sec = pst->st_mtime;
+ ret.tv_nsec = 0;
+ return ret;
+#else
+#if defined(HAVE_STAT_ST_MTIM)
+ return pst->st_mtim;
+#elif defined(HAVE_STAT_ST_MTIMENSEC)
+ struct timespec ret;
+ ret.tv_sec = pst->st_mtime;
+ ret.tv_nsec = pst->st_mtimensec;
+ return ret;
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
}
-/****************************************************************************
- Check if NTTIME is 0.
-****************************************************************************/
+void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts)
+{
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+ /* Old system - no ns timestamp. */
+ pst->st_mtime = ts.tv_sec;
+#else
+#if defined(HAVE_STAT_ST_MTIM)
+ pst->st_mtim = ts;
+#elif defined(HAVE_STAT_ST_MTIMENSEC)
+ pst->st_mtime = ts.tv_sec;
+ pst->st_mtimensec = ts.tv_nsec
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
+}
-BOOL nt_time_is_zero(const NTTIME *nt)
+struct timespec get_ctimespec(SMB_STRUCT_STAT *pst)
{
- if(nt->high==0) {
- return True;
- }
- return False;
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+ struct timespec ret;
+
+ /* Old system - no ns timestamp. */
+ ret.tv_sec = pst->st_ctime;
+ ret.tv_nsec = 0;
+ return ret;
+#else
+#if defined(HAVE_STAT_ST_CTIM)
+ return pst->st_ctim;
+#elif defined(HAVE_STAT_ST_CTIMENSEC)
+ struct timespec ret;
+ ret.tv_sec = pst->st_ctime;
+ ret.tv_nsec = pst->st_ctimensec;
+ return ret;
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
}
-/****************************************************************************
- Check if two NTTIMEs are the same.
-****************************************************************************/
+void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts)
+{
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+ /* Old system - no ns timestamp. */
+ pst->st_ctime = ts.tv_sec;
+#else
+#if defined(HAVE_STAT_ST_CTIM)
+ pst->st_ctim = ts;
+#elif defined(HAVE_STAT_ST_CTIMENSEC)
+ pst->st_ctime = ts.tv_sec;
+ pst->st_ctimensec = ts.tv_nsec
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
+}
-BOOL nt_time_equals(const NTTIME *nt1, const NTTIME *nt2)
+void dos_filetime_timespec(struct timespec *tsp)
{
- return (nt1->high == nt2->high && nt1->low == nt2->low);
+ tsp->tv_sec &= ~1;
+ tsp->tv_nsec = 0;
}
-/****************************************************************************
- Return a timeval difference in usec.
-****************************************************************************/
+/*******************************************************************
+ Create a unix date (int GMT) from a dos date (which is actually in
+ localtime).
+********************************************************************/
-SMB_BIG_INT usec_time_diff(const struct timeval *larget, const struct timeval *smallt)
+static time_t make_unix_date(void *date_ptr, int zone_offset)
{
- SMB_BIG_INT sec_diff = larget->tv_sec - smallt->tv_sec;
- return (sec_diff * 1000000) + (SMB_BIG_INT)(larget->tv_usec - smallt->tv_usec);
+ uint32 dos_date=0;
+ struct tm t;
+ time_t ret;
+
+ dos_date = IVAL(date_ptr,0);
+
+ if (dos_date == 0) {
+ return 0;
+ }
+
+ interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
+ &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
+ t.tm_isdst = -1;
+
+ ret = timegm(&t);
+
+ ret += zone_offset;
+
+ return(ret);
}
-/****************************************************************************
- Return a timeval struct with the given elements.
-****************************************************************************/
+/*******************************************************************
+ Like make_unix_date() but the words are reversed.
+********************************************************************/
-struct timeval timeval_set(uint32_t secs, uint32_t usecs)
+static time_t make_unix_date2(void *date_ptr, int zone_offset)
{
- struct timeval tv;
- tv.tv_sec = secs;
- tv.tv_usec = usecs;
- return tv;
+ uint32 x,x2;
+
+ x = IVAL(date_ptr,0);
+ x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
+ SIVAL(&x,0,x2);
+
+ return(make_unix_date((void *)&x, zone_offset));
}
-/****************************************************************************
- Return a zero timeval.
-****************************************************************************/
+/*******************************************************************
+ Create a unix GMT date from a dos date in 32 bit "unix like" format
+ these generally arrive as localtimes, with corresponding DST.
+******************************************************************/
-struct timeval timeval_zero(void)
+static time_t make_unix_date3(void *date_ptr, int zone_offset)
{
- return timeval_set(0,0);
+ time_t t = (time_t)IVAL(date_ptr,0);
+ if (!null_mtime(t)) {
+ t += zone_offset;
+ }
+ return(t);
}
-/****************************************************************************
- Return True if a timeval is zero.
-****************************************************************************/
+time_t srv_make_unix_date(void *date_ptr)
+{
+ return make_unix_date(date_ptr, server_zone_offset);
+}
-BOOL timeval_is_zero(const struct timeval *tv)
+time_t srv_make_unix_date2(void *date_ptr)
{
- return tv->tv_sec == 0 && tv->tv_usec == 0;
+ return make_unix_date2(date_ptr, server_zone_offset);
}
-/****************************************************************************
- Return a timeval for the current time.
-****************************************************************************/
+time_t srv_make_unix_date3(void *date_ptr)
+{
+ return make_unix_date3(date_ptr, server_zone_offset);
+}
-struct timeval timeval_current(void)
+time_t convert_timespec_to_time_t(struct timespec ts)
{
- struct timeval tv;
- GetTimeOfDay(&tv);
- return tv;
+ /* 1 ns == 1,000,000,000 - one thousand millionths of a second.
+ increment if it's greater than 500 millionth of a second. */
+ if (ts.tv_nsec > 500000000) {
+ return ts.tv_sec + 1;
+ }
+ return ts.tv_sec;
}
/****************************************************************************
- Return a timeval ofs microseconds after tv.
+ Interprets an nt time into a unix struct timespec.
+ Differs from nt_time_to_unix in that an 8 byte value of 0xffffffffffffffff
+ will be returned as (time_t)-1, whereas nt_time_to_unix returns 0 in this case.
****************************************************************************/
-struct timeval timeval_add(const struct timeval *tv,
- uint32_t secs, uint32_t usecs)
+struct timespec interpret_long_date(char *p)
{
- struct timeval tv2 = *tv;
- tv2.tv_sec += secs;
- tv2.tv_usec += usecs;
- tv2.tv_sec += tv2.tv_usec / 1000000;
- tv2.tv_usec = tv2.tv_usec % 1000000;
- return tv2;
+ NTTIME nt;
+ nt = IVAL(p,0) + ((uint64_t)IVAL(p,4) << 32);
+ if (nt == (uint64_t)-1) {
+ struct timespec ret;
+ ret.tv_sec = (time_t)-1;
+ ret.tv_nsec = 0;
+ return ret;
+ }
+ return nt_time_to_unix_timespec(&nt);
}
-/****************************************************************************
- Return the sum of two timeval structures.
-****************************************************************************/
+/***************************************************************************
+ Client versions of the above functions.
+***************************************************************************/
-struct timeval timeval_sum(const struct timeval *tv1,
- const struct timeval *tv2)
+void cli_put_dos_date(struct cli_state *cli, char *buf, int offset, time_t unixdate)
{
- return timeval_add(tv1, tv2->tv_sec, tv2->tv_usec);
+ put_dos_date(buf, offset, unixdate, cli->serverzone);
}
-/****************************************************************************
- Return a timeval secs/usecs into the future.
-****************************************************************************/
+void cli_put_dos_date2(struct cli_state *cli, char *buf, int offset, time_t unixdate)
+{
+ put_dos_date2(buf, offset, unixdate, cli->serverzone);
+}
-struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
+void cli_put_dos_date3(struct cli_state *cli, char *buf, int offset, time_t unixdate)
{
- struct timeval tv = timeval_current();
- return timeval_add(&tv, secs, usecs);
+ put_dos_date3(buf, offset, unixdate, cli->serverzone);
}
-/****************************************************************************
- Compare two timeval structures.
- Return -1 if tv1 < tv2
- Return 0 if tv1 == tv2
- Return 1 if tv1 > tv2
-****************************************************************************/
+time_t cli_make_unix_date(struct cli_state *cli, void *date_ptr)
+{
+ return make_unix_date(date_ptr, cli->serverzone);
+}
-int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
+time_t cli_make_unix_date2(struct cli_state *cli, void *date_ptr)
{
- if (tv1->tv_sec > tv2->tv_sec) {
- return 1;
- }
- if (tv1->tv_sec < tv2->tv_sec) {
- return -1;
+ return make_unix_date2(date_ptr, cli->serverzone);
+}
+
+time_t cli_make_unix_date3(struct cli_state *cli, void *date_ptr)
+{
+ return make_unix_date3(date_ptr, cli->serverzone);
+}
+
+#if (SIZEOF_LONG == 8)
+#define TIME_FIXUP_CONSTANT_INT 11644473600L
+#elif (SIZEOF_LONG_LONG == 8)
+#define TIME_FIXUP_CONSTANT_INT 11644473600LL
+#endif
+
+
+/* Large integer version. */
+struct timespec nt_time_to_unix_timespec(NTTIME *nt)
+{
+ uint64 d;
+ struct timespec ret;
+
+ if (*nt == 0 || *nt == (uint64)-1) {
+ ret.tv_sec = 0;
+ ret.tv_nsec = 0;
+ return ret;
}
- if (tv1->tv_usec > tv2->tv_usec) {
- return 1;
+
+ d = *nt;
+ /* d is now in 100ns units, since jan 1st 1601".
+ Save off the ns fraction. */
+
+ ret.tv_nsec = (long) ((d % 100) * 100);
+
+ /* Convert to seconds */
+ d /= 1000*1000*10;
+
+ /* Now adjust by 369 years to make the secs since 1970 */
+ d -= TIME_FIXUP_CONSTANT_INT;
+
+ if (((time_t)d) <= TIME_T_MIN) {
+ ret.tv_sec = TIME_T_MIN;
+ ret.tv_nsec = 0;
+ return ret;
}
- if (tv1->tv_usec < tv2->tv_usec) {
- return -1;
+
+ if (((time_t)d) >= TIME_T_MAX) {
+ ret.tv_sec = TIME_T_MAX;
+ ret.tv_nsec = 0;
+ return ret;
}
- return 0;
-}
+ ret.tv_sec = (time_t)d;
+ return ret;
+}
/****************************************************************************
- Return the difference between two timevals as a timeval.
- If tv1 comes after tv2, then return a zero timeval
- (this is *tv2 - *tv1).
+ Check if two NTTIMEs are the same.
****************************************************************************/
-struct timeval timeval_until(const struct timeval *tv1,
- const struct timeval *tv2)
+BOOL nt_time_equals(const NTTIME *nt1, const NTTIME *nt2)
{
- struct timeval t;
- if (timeval_compare(tv1, tv2) >= 0) {
- return timeval_zero();
- }
- t.tv_sec = tv2->tv_sec - tv1->tv_sec;
- if (tv1->tv_usec > tv2->tv_usec) {
- t.tv_sec--;
- t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec);
- } else {
- t.tv_usec = tv2->tv_usec - tv1->tv_usec;
- }
- return t;
+ return (*nt1 == *nt2);
}
-/****************************************************************************
- Return the lesser of two timevals.
-****************************************************************************/
+/*******************************************************************
+ Re-read the smb serverzone value.
+******************************************************************/
-struct timeval timeval_min(const struct timeval *tv1,
- const struct timeval *tv2)
+static struct timeval start_time_hires;
+
+void TimeInit(void)
{
- if (tv1->tv_sec < tv2->tv_sec) {
- return *tv1;
- }
- if (tv1->tv_sec > tv2->tv_sec) {
- return *tv2;
+ set_server_zone_offset(time(NULL));
+
+ DEBUG(4,("TimeInit: Serverzone is %d\n", server_zone_offset));
+
+ /* Save the start time of this process. */
+ if (start_time_hires.tv_sec == 0 && start_time_hires.tv_usec == 0) {
+ GetTimeOfDay(&start_time_hires);
}
- if (tv1->tv_usec < tv2->tv_usec) {
- return *tv1;
+}
+
+/**********************************************************************
+ Return a timeval struct of the uptime of this process. As TimeInit is
+ done before a daemon fork then this is the start time from the parent
+ daemon start. JRA.
+***********************************************************************/
+
+void get_process_uptime(struct timeval *ret_time)
+{
+ struct timeval time_now_hires;
+
+ GetTimeOfDay(&time_now_hires);
+ ret_time->tv_sec = time_now_hires.tv_sec - start_time_hires.tv_sec;
+ if (time_now_hires.tv_usec < start_time_hires.tv_usec) {
+ ret_time->tv_sec -= 1;
+ ret_time->tv_usec = 1000000 + (time_now_hires.tv_usec - start_time_hires.tv_usec);
+ } else {
+ ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
}
- return *tv2;
}
/****************************************************************************
- Return the greater of two timevals.
+ Convert a NTTIME structure to a time_t.
+ It's originally in "100ns units".
+
+ This is an absolute version of the one above.
+ By absolute I mean, it doesn't adjust from 1/1/1601 to 1/1/1970
+ if the NTTIME was 5 seconds, the time_t is 5 seconds. JFM
****************************************************************************/
-struct timeval timeval_max(const struct timeval *tv1,
- const struct timeval *tv2)
+time_t nt_time_to_unix_abs(const NTTIME *nt)
{
- if (tv1->tv_sec > tv2->tv_sec) {
- return *tv1;
+ uint64 d;
+
+ if (*nt == 0) {
+ return (time_t)0;
}
- if (tv1->tv_sec < tv2->tv_sec) {
- return *tv2;
+
+ if (*nt == (uint64)-1) {
+ return (time_t)-1;
}
- if (tv1->tv_usec > tv2->tv_usec) {
- return *tv1;
+
+ /* reverse the time */
+ /* it's a negative value, turn it to positive */
+ d=~*nt;
+
+ d += 1000*1000*10/2;
+ d /= 1000*1000*10;
+
+ if (!(TIME_T_MIN <= ((time_t)d) && ((time_t)d) <= TIME_T_MAX)) {
+ return (time_t)0;
}
- return *tv2;
+
+ return (time_t)d;
}
/****************************************************************************
- Convert ASN.1 GeneralizedTime string to unix-time.
- Returns 0 on failure; Currently ignores timezone.
+ Put a 8 byte filetime from a struct timespec. Uses GMT.
****************************************************************************/
-time_t generalized_to_unix_time(const char *str)
-{
- struct tm tm;
-
- ZERO_STRUCT(tm);
+void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts)
+{
+ uint64 d;
- if (sscanf(str, "%4d%2d%2d%2d%2d%2d",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
- return 0;
+ if (ts.tv_sec ==0 && ts.tv_nsec == 0) {
+ *nt = 0;
+ return;
}
- tm.tm_year -= 1900;
- tm.tm_mon -= 1;
+ if (ts.tv_sec == TIME_T_MAX) {
+ *nt = 0x7fffffffffffffffLL;
+ return;
+ }
+ if (ts.tv_sec == (time_t)-1) {
+ *nt = (uint64)-1;
+ return;
+ }
- return timegm(&tm);
+ d = ts.tv_sec;
+ d += TIME_FIXUP_CONSTANT_INT;
+ d *= 1000*1000*10;
+ /* d is now in 100ns units. */
+ d += (ts.tv_nsec / 100);
+
+ *nt = d;
}
/****************************************************************************
- Return all the possible time fields from a stat struct as a timespec.
+ Convert a time_t to a NTTIME structure
+
+ This is an absolute version of the one above.
+ By absolute I mean, it doesn't adjust from 1/1/1970 to 1/1/1601
+ If the nttime_t was 5 seconds, the NTTIME is 5 seconds. JFM
****************************************************************************/
-struct timespec get_atimespec(SMB_STRUCT_STAT *pst)
+void unix_to_nt_time_abs(NTTIME *nt, time_t t)
{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
- struct timespec ret;
+ double d;
- /* Old system - no ns timestamp. */
- ret.tv_sec = pst->st_atime;
- ret.tv_nsec = 0;
- return ret;
-#else
-#if defined(HAVE_STAT_ST_ATIM)
- return pst->st_atim;
-#elif defined(HAVE_STAT_ST_ATIMENSEC)
- struct timespec ret;
- ret.tv_sec = pst->st_atime;
- ret.tv_nsec = pst->st_atimensec;
- return ret;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
-#endif
-#endif
-}
+ if (t==0) {
+ *nt = 0;
+ return;
+ }
-struct timespec get_mtimespec(SMB_STRUCT_STAT *pst)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
- struct timespec ret;
+ if (t == TIME_T_MAX) {
+ *nt = 0x7fffffffffffffffLL;
+ return;
+ }
+
+ if (t == (time_t)-1) {
+ /* that's what NT uses for infinite */
+ *nt = 0x8000000000000000LL;
+ return;
+ }
- /* Old system - no ns timestamp. */
- ret.tv_sec = pst->st_mtime;
- ret.tv_nsec = 0;
- return ret;
-#else
-#if defined(HAVE_STAT_ST_MTIM)
- return pst->st_mtim;
-#elif defined(HAVE_STAT_ST_MTIMENSEC)
- struct timespec ret;
- ret.tv_sec = pst->st_mtime;
- ret.tv_nsec = pst->st_mtimensec;
- return ret;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
-#endif
-#endif
-}
+ d = (double)(t);
+ d *= 1.0e7;
-struct timespec get_ctimespec(SMB_STRUCT_STAT *pst)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
- struct timespec ret;
+ *nt = d;
- /* Old system - no ns timestamp. */
- ret.tv_sec = pst->st_ctime;
- ret.tv_nsec = 0;
- return ret;
-#else
-#if defined(HAVE_STAT_ST_CTIM)
- return pst->st_ctim;
-#elif defined(HAVE_STAT_ST_CTIMENSEC)
- struct timespec ret;
- ret.tv_sec = pst->st_ctime;
- ret.tv_nsec = pst->st_ctimensec;
- return ret;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
-#endif
-#endif
+ /* convert to a negative value */
+ *nt=~*nt;
}
-#if 0
+
/****************************************************************************
- Return the best approximation to a 'create time' under UNIX from a stat
- structure.
+ Check if it's a null mtime.
****************************************************************************/
-struct timespec get_create_timespec(SMB_STRUCT_STAT *st,BOOL fake_dirs)
+BOOL null_mtime(time_t mtime)
{
- time_t ret, ret1;
-
- if(S_ISDIR(st->st_mode) && fake_dirs) {
- return (time_t)315493200L; /* 1/1/1980 */
- }
-
- ret = MIN(st->st_ctime, st->st_mtime);
- ret1 = MIN(ret, st->st_atime);
-
- if(ret1 != (time_t)0) {
- return ret1;
- }
-
- /*
- * One of ctime, mtime or atime was zero (probably atime).
- * Just return MIN(ctime, mtime).
- */
- return ret;
+ if (mtime == 0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
+ return(True);
+ return(False);
}
-#endif
/****************************************************************************
Utility function that always returns a const string even if localtime
@@ -1076,3 +1302,52 @@ const char *time_to_asc(const time_t *t)
}
return asct;
}
+
+const char *display_time(NTTIME nttime)
+{
+ static fstring string;
+
+ float high;
+ float low;
+ int sec;
+ int days, hours, mins, secs;
+
+ if (nttime==0)
+ return "Now";
+
+ if (nttime==0x8000000000000000LL)
+ return "Never";
+
+ high = 65536;
+ high = high/10000;
+ high = high*65536;
+ high = high/1000;
+ high = high * (~(nttime >> 32));
+
+ low = ~(nttime & 0xFFFFFFFF);
+ low = low/(1000*1000*10);
+
+ sec=high+low;
+
+ days=sec/(60*60*24);
+ hours=(sec - (days*60*60*24)) / (60*60);
+ mins=(sec - (days*60*60*24) - (hours*60*60) ) / 60;
+ secs=sec - (days*60*60*24) - (hours*60*60) - (mins*60);
+
+ fstr_sprintf(string, "%u days, %u hours, %u minutes, %u seconds", days, hours, mins, secs);
+ return (string);
+}
+
+BOOL nt_time_is_set(const NTTIME *nt)
+{
+ if (*nt == 0x7FFFFFFFFFFFFFFFLL) {
+ return False;
+ }
+
+ if (*nt == 0x8000000000000000LL) {
+ return False;
+ }
+
+ return True;
+}
+
diff --git a/source/lib/util.c b/source/lib/util.c
index 0095c03d494..dde637cf703 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -61,7 +61,7 @@ extern fstring remote_arch;
enum protocol_types Protocol = PROTOCOL_COREPLUS;
/* a default finfo structure to ensure all fields are sensible */
-file_info def_finfo = {-1,0,0,0,0,0,0,"",""};
+file_info def_finfo;
/* this is used by the chaining code */
int chain_size = 0;
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index c106c4433aa..08be2cd2a11 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -5,6 +5,7 @@
Copyright (C) Andrew Tridgell 1992-2001
Copyright (C) Simo Sorce 2001-2002
Copyright (C) Martin Pool 2003
+ Copyright (C) James Peach 2006
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,13 +30,18 @@
**/
/**
- * Get the next token from a string, return False if none found.
- * Handles double-quotes.
+ * Internal function to get the next token from a string, return False if none
+ * found. Handles double-quotes. This is the work horse function called by
+ * next_token() and next_token_no_ltrim().
*
* Based on a routine by GJC@VILLAGE.COM.
* Extensively modified by Andrew.Tridgell@anu.edu.au
- **/
-BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
+ */
+static BOOL next_token_internal(const char **ptr,
+ char *buff,
+ const char *sep,
+ size_t bufsize,
+ BOOL ltrim)
{
char *s;
char *pbuf;
@@ -51,9 +57,11 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
if (!sep)
sep = " \t\n\r";
- /* find the first non sep char */
+ /* find the first non sep char, if left-trimming is requested */
+ if (ltrim) {
while (*s && strchr_m(sep,*s))
s++;
+ }
/* nothing left? */
if (! *s)
@@ -76,6 +84,29 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
return(True);
}
+/*
+ * Get the next token from a string, return False if none found. Handles
+ * double-quotes. This version trims leading separator characters before
+ * looking for a token.
+ */
+BOOL next_token(const char **ptr, char *buff, const char *sep, size_t bufsize)
+{
+ return next_token_internal(ptr, buff, sep, bufsize, True);
+}
+
+/*
+ * Get the next token from a string, return False if none found. Handles
+ * double-quotes. This version does not trim leading separator characters
+ * before looking for a token.
+ */
+BOOL next_token_no_ltrim(const char **ptr,
+ char *buff,
+ const char *sep,
+ size_t bufsize)
+{
+ return next_token_internal(ptr, buff, sep, bufsize, False);
+}
+
/**
This is like next_token but is not re-entrant and "remembers" the first
parameter so you can pass NULL. This is useful for user interface code
@@ -1043,7 +1074,7 @@ char *realloc_string_sub(char *string, const char *pattern,
while ((p = strstr_m(s,pattern))) {
if (ld > 0) {
int offset = PTR_DIFF(s,string);
- string = SMB_REALLOC(string, ls + ld + 1);
+ string = (char *)SMB_REALLOC(string, ls + ld + 1);
if (!string) {
DEBUG(0, ("realloc_string_sub: out of memory!\n"));
SAFE_FREE(in);
@@ -1112,7 +1143,8 @@ char *talloc_string_sub(TALLOC_CTX *mem_ctx, const char *src,
while ((p = strstr_m(s,pattern))) {
if (ld > 0) {
int offset = PTR_DIFF(s,string);
- string = TALLOC_REALLOC(mem_ctx, string, ls + ld + 1);
+ string = (char *)TALLOC_REALLOC(mem_ctx, string,
+ ls + ld + 1);
if (!string) {
DEBUG(0, ("talloc_string_sub: out of "
"memory!\n"));
@@ -1561,6 +1593,76 @@ void strupper_m(char *s)
}
/**
+ Count the number of UCS2 characters in a string. Normally this will
+ be the same as the number of bytes in a string for single byte strings,
+ but will be different for multibyte.
+**/
+
+size_t strlen_m(const char *s)
+{
+ size_t count = 0;
+
+ if (!s) {
+ return 0;
+ }
+
+ while (*s && !(((uint8_t)*s) & 0x80)) {
+ s++;
+ count++;
+ }
+
+ if (!*s) {
+ return count;
+ }
+
+ while (*s) {
+ size_t c_size;
+ codepoint_t c = next_codepoint(s, &c_size);
+ if (c < 0x10000) {
+ /* Unicode char fits into 16 bits. */
+ count += 1;
+ } else {
+ /* Double-width unicode char - 32 bits. */
+ count += 2;
+ }
+ s += c_size;
+ }
+
+ return count;
+}
+
+/**
+ Count the number of UCS2 characters in a string including the null
+ terminator.
+**/
+
+size_t strlen_m_term(const char *s)
+{
+ if (!s) {
+ return 0;
+ }
+ return strlen_m(s) + 1;
+}
+
+/*
+ * Weird helper routine for the winreg pipe: If nothing is around, return 0,
+ * if a string is there, include the terminator.
+ */
+
+size_t strlen_m_term_null(const char *s)
+{
+ size_t len;
+ if (!s) {
+ return 0;
+ }
+ len = strlen_m(s);
+ if (len == 0) {
+ return 0;
+ }
+
+ return len+1;
+}
+/**
Return a RFC2254 binary string representation of a buffer.
Used in LDAP filters.
Caller must free.
@@ -1571,7 +1673,7 @@ char *binary_string_rfc2254(char *buf, int len)
char *s;
int i, j;
const char *hex = "0123456789ABCDEF";
- s = SMB_MALLOC(len * 3 + 1);
+ s = (char *)SMB_MALLOC(len * 3 + 1);
if (!s)
return NULL;
for (j=i=0;i<len;i++) {
@@ -1589,7 +1691,7 @@ char *binary_string(char *buf, int len)
char *s;
int i, j;
const char *hex = "0123456789ABCDEF";
- s = SMB_MALLOC(len * 2 + 1);
+ s = (char *)SMB_MALLOC(len * 2 + 1);
if (!s)
return NULL;
for (j=i=0;i<len;i++) {
@@ -1631,49 +1733,6 @@ int fstr_sprintf(fstring s, const char *fmt, ...)
return ret;
}
-
-#if !defined(HAVE_STRNDUP) || defined(BROKEN_STRNDUP)
-/**
- Some platforms don't have strndup.
-**/
-#if defined(PARANOID_MALLOC_CHECKER)
-#undef strndup
-#endif
-
- char *strndup(const char *s, size_t n)
-{
- char *ret;
-
- n = strnlen(s, n);
- ret = SMB_MALLOC(n+1);
- if (!ret)
- return NULL;
- memcpy(ret, s, n);
- ret[n] = 0;
-
- return ret;
-}
-
-#if defined(PARANOID_MALLOC_CHECKER)
-#define strndup(s,n) __ERROR_DONT_USE_STRNDUP_DIRECTLY
-#endif
-
-#endif
-
-#if !defined(HAVE_STRNLEN) || defined(BROKEN_STRNLEN)
-/**
- Some platforms don't have strnlen
-**/
-
- size_t strnlen(const char *s, size_t n)
-{
- size_t i;
- for (i=0; i<n && s[i] != '\0'; i++)
- /* noop */ ;
- return i;
-}
-#endif
-
/**
List of Strings manipulation functions
**/
@@ -2210,7 +2269,7 @@ char * base64_encode_data_blob(DATA_BLOB data)
out_cnt = 0;
len = data.length;
output_len = data.length * 2;
- result = SMB_MALLOC(output_len); /* get us plenty of space */
+ result = (char *)SMB_MALLOC(output_len); /* get us plenty of space */
while (len-- && out_cnt < (data.length * 2) - 5) {
int c = (unsigned char) *(data.data++);
@@ -2274,16 +2333,83 @@ SMB_BIG_UINT STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr)
return val;
}
+/* Convert a size specification to a count of bytes. We accept the following
+ * suffixes:
+ * bytes if there is no suffix
+ * kK kibibytes
+ * mM mebibytes
+ * gG gibibytes
+ * tT tibibytes
+ * pP whatever the ISO name for petabytes is
+ *
+ * Returns 0 if the string can't be converted.
+ */
+SMB_OFF_T conv_str_size(const char * str)
+{
+ SMB_OFF_T lval;
+ char * end;
+
+ if (str == NULL || *str == '\0') {
+ return 0;
+ }
+
+#ifdef HAVE_STRTOULL
+ if (sizeof(SMB_OFF_T) == 8) {
+ lval = strtoull(str, &end, 10 /* base */);
+ } else {
+ lval = strtoul(str, &end, 10 /* base */);
+ }
+#else
+ lval = strtoul(str, &end, 10 /* base */);
+#endif
+
+ if (end == NULL || end == str) {
+ return 0;
+ }
+
+ if (*end) {
+ SMB_OFF_T lval_orig = lval;
+
+ if (strwicmp(end, "K") == 0) {
+ lval *= (SMB_OFF_T)1024;
+ } else if (strwicmp(end, "M") == 0) {
+ lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024);
+ } else if (strwicmp(end, "G") == 0) {
+ lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+ (SMB_OFF_T)1024);
+ } else if (strwicmp(end, "T") == 0) {
+ lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+ (SMB_OFF_T)1024 * (SMB_OFF_T)1024);
+ } else if (strwicmp(end, "P") == 0) {
+ lval *= ((SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+ (SMB_OFF_T)1024 * (SMB_OFF_T)1024 *
+ (SMB_OFF_T)1024);
+ } else {
+ return 0;
+ }
+
+ /* Primitive attempt to detect wrapping on platforms with
+ * 4-byte SMB_OFF_T. It's better to let the caller handle
+ * a failure than some random number.
+ */
+ if (lval_orig <= lval) {
+ return 0;
+ }
+ }
+
+ return lval;
+}
+
void string_append(char **left, const char *right)
{
int new_len = strlen(right) + 1;
if (*left == NULL) {
- *left = SMB_MALLOC(new_len);
+ *left = (char *)SMB_MALLOC(new_len);
*left[0] = '\0';
} else {
new_len += strlen(*left);
- *left = SMB_REALLOC(*left, new_len);
+ *left = (char *)SMB_REALLOC(*left, new_len);
}
if (*left == NULL) {
@@ -2426,3 +2552,52 @@ BOOL validate_net_name( const char *name, const char *invalid_chars, int max_len
return True;
}
+
+/**
+return the number of bytes occupied by a buffer in ASCII format
+the result includes the null termination
+limited by 'n' bytes
+**/
+size_t ascii_len_n(const char *src, size_t n)
+{
+ size_t len;
+
+ len = strnlen(src, n);
+ if (len+1 <= n) {
+ len += 1;
+ }
+
+ return len;
+}
+
+/**
+return the number of bytes occupied by a buffer in CH_UTF16 format
+the result includes the null termination
+**/
+size_t utf16_len(const void *buf)
+{
+ size_t len;
+
+ for (len = 0; SVAL(buf,len); len += 2) ;
+
+ return len + 2;
+}
+
+/**
+return the number of bytes occupied by a buffer in CH_UTF16 format
+the result includes the null termination
+limited by 'n' bytes
+**/
+size_t utf16_len_n(const void *src, size_t n)
+{
+ size_t len;
+
+ for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ;
+
+ if (len+2 <= n) {
+ len += 2;
+ }
+
+ return len;
+}
+
diff --git a/source/libads/authdata.c b/source/libads/authdata.c
index c3c160dafba..71294941a60 100644
--- a/source/libads/authdata.c
+++ b/source/libads/authdata.c
@@ -878,9 +878,9 @@ static void dump_pac_logon_info(PAC_LOGON_INFO *logon_info) {
DEBUG(2,("decode_pac_data: Logon time mismatch between ticket and PAC!\n"));
DEBUGADD(2, ("decode_pac_data: PAC: %s\n",
- http_timestring(nt_time_to_unix(&logon_name->logon_time))));
+ http_timestring(nt_time_to_unix(logon_name->logon_time))));
DEBUGADD(2, ("decode_pac_data: Ticket: %s\n",
- http_timestring(nt_time_to_unix(&tgs_authtime_nttime))));
+ http_timestring(nt_time_to_unix(tgs_authtime_nttime))));
nt_status = NT_STATUS_ACCESS_DENIED;
goto out;
diff --git a/source/libmsrpc/libmsrpc.c b/source/libmsrpc/libmsrpc.c
index 789807bb584..adaf89d0feb 100644
--- a/source/libmsrpc/libmsrpc.c
+++ b/source/libmsrpc/libmsrpc.c
@@ -255,19 +255,19 @@ void cac_InitCacTime( CacTime * cactime, NTTIME nttime )
ZERO_STRUCTP( cactime );
/*this code is taken from display_time() found in rpcclient/cmd_samr.c */
- if ( nttime.high == 0 && nttime.low == 0 )
+ if ( nttime == 0 )
return;
- if ( nttime.high == 0x80000000 && nttime.low == 0 )
+ if ( nttime == 0x80000000000000LL )
return;
high = 65536;
high = high / 10000;
high = high * 65536;
high = high / 1000;
- high = high * ( ~nttime.high );
+ high = high * ( ~( nttime >> 32 ) );
- low = ~nttime.low;
+ low = ~( nttime & 0xFFFFFFFF );
low = low / ( 1000 * 1000 * 10 );
sec = high + low;
diff --git a/source/libmsrpc/libmsrpc_internal.c b/source/libmsrpc/libmsrpc_internal.c
index 31c4257095a..1295c510da3 100644
--- a/source/libmsrpc/libmsrpc_internal.c
+++ b/source/libmsrpc/libmsrpc_internal.c
@@ -445,15 +445,15 @@ CacUserInfo *cac_MakeUserInfo( TALLOC_CTX * mem_ctx, SAM_USERINFO_CTR * ctr )
ZERO_STRUCTP( info );
- info->logon_time = nt_time_to_unix( &id21->logon_time );
- info->logoff_time = nt_time_to_unix( &id21->logoff_time );
- info->kickoff_time = nt_time_to_unix( &id21->kickoff_time );
+ info->logon_time = nt_time_to_unix( id21->logon_time );
+ info->logoff_time = nt_time_to_unix( id21->logoff_time );
+ info->kickoff_time = nt_time_to_unix( id21->kickoff_time );
info->pass_last_set_time =
- nt_time_to_unix( &id21->pass_last_set_time );
+ nt_time_to_unix( id21->pass_last_set_time );
info->pass_can_change_time =
- nt_time_to_unix( &id21->pass_can_change_time );
+ nt_time_to_unix( id21->pass_can_change_time );
info->pass_must_change_time =
- nt_time_to_unix( &id21->pass_must_change_time );
+ nt_time_to_unix( id21->pass_must_change_time );
info->username =
talloc_unistr2_to_ascii( mem_ctx, id21->uni_user_name );
diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c
index 366106bce9c..783cf0c1853 100644
--- a/source/libsmb/cliconnect.c
+++ b/source/libsmb/cliconnect.c
@@ -33,6 +33,7 @@ static const struct {
{PROTOCOL_LANMAN1,"LANMAN1.0"},
{PROTOCOL_LANMAN2,"LM1.2X002"},
{PROTOCOL_LANMAN2,"DOS LANMAN2.1"},
+ {PROTOCOL_LANMAN2,"LANMAN2.1"},
{PROTOCOL_LANMAN2,"Samba"},
{PROTOCOL_NT1,"NT LANMAN 1.0"},
{PROTOCOL_NT1,"NT LM 0.12"},
@@ -1143,6 +1144,7 @@ BOOL cli_negprot(struct cli_state *cli)
}
if (cli->protocol >= PROTOCOL_NT1) {
+ struct timespec ts;
/* NT protocol */
cli->sec_mode = CVAL(cli->inbuf,smb_vwv1);
cli->max_mux = SVAL(cli->inbuf, smb_vwv1+1);
@@ -1151,7 +1153,8 @@ BOOL cli_negprot(struct cli_state *cli)
cli->serverzone = SVALS(cli->inbuf,smb_vwv15+1);
cli->serverzone *= 60;
/* this time arrives in real GMT */
- cli->servertime = interpret_long_date(cli->inbuf+smb_vwv11+1);
+ ts = interpret_long_date(cli->inbuf+smb_vwv11+1);
+ cli->servertime = ts.tv_sec;
cli->secblob = data_blob(smb_buf(cli->inbuf),smb_buflen(cli->inbuf));
cli->capabilities = IVAL(cli->inbuf,smb_vwv9+1);
if (cli->capabilities & CAP_RAW_MODE) {
@@ -1562,10 +1565,11 @@ BOOL attempt_netbios_session_request(struct cli_state *cli, const char *srchost,
* then use *SMBSERVER immediately.
*/
- if(is_ipaddress(desthost))
+ if(is_ipaddress(desthost)) {
make_nmb_name(&called, "*SMBSERVER", 0x20);
- else
+ } else {
make_nmb_name(&called, desthost, 0x20);
+ }
if (!cli_session_request(cli, &calling, &called)) {
struct nmb_name smbservername;
diff --git a/source/libsmb/clierror.c b/source/libsmb/clierror.c
index 44573bd29b1..fcedc3bdab1 100644
--- a/source/libsmb/clierror.c
+++ b/source/libsmb/clierror.c
@@ -226,7 +226,7 @@ void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode)
}
/* Return a UNIX errno from a NT status code */
-static struct {
+static const struct {
NTSTATUS status;
int error;
} nt_errno_map[] = {
diff --git a/source/libsmb/clifile.c b/source/libsmb/clifile.c
index ea6501dac89..ad84ec03244 100644
--- a/source/libsmb/clifile.c
+++ b/source/libsmb/clifile.c
@@ -266,9 +266,10 @@ BOOL cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbu
/* assume 512 byte blocks */
sbuf->st_blocks /= 512;
#endif
- sbuf->st_ctime = interpret_long_date(rdata + 16); /* time of last change */
- sbuf->st_atime = interpret_long_date(rdata + 24); /* time of last access */
- sbuf->st_mtime = interpret_long_date(rdata + 32); /* time of last modification */
+ set_ctimespec(sbuf, interpret_long_date(rdata + 16)); /* time of last change */
+ set_atimespec(sbuf, interpret_long_date(rdata + 24)); /* time of last access */
+ set_mtimespec(sbuf, interpret_long_date(rdata + 32)); /* time of last modification */
+
sbuf->st_uid = (uid_t) IVAL(rdata,40); /* user ID of owner */
sbuf->st_gid = (gid_t) IVAL(rdata,48); /* group ID of owner */
sbuf->st_mode |= unix_filetype_from_wire(IVAL(rdata, 56));
@@ -1178,7 +1179,9 @@ BOOL cli_posix_getlock(struct cli_state *cli, int fnum, SMB_BIG_UINT *poffset, S
BOOL cli_getattrE(struct cli_state *cli, int fd,
uint16 *attr, SMB_OFF_T *size,
- time_t *c_time, time_t *a_time, time_t *m_time)
+ time_t *change_time,
+ time_t *access_time,
+ time_t *write_time)
{
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
@@ -1208,16 +1211,16 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
*attr = SVAL(cli->inbuf,smb_vwv10);
}
- if (c_time) {
- *c_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv0);
+ if (change_time) {
+ *change_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv0);
}
- if (a_time) {
- *a_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv2);
+ if (access_time) {
+ *access_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv2);
}
- if (m_time) {
- *m_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv4);
+ if (write_time) {
+ *write_time = cli_make_unix_date2(cli, cli->inbuf+smb_vwv4);
}
return True;
@@ -1228,7 +1231,7 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
****************************************************************************/
BOOL cli_getatr(struct cli_state *cli, const char *fname,
- uint16 *attr, SMB_OFF_T *size, time_t *t)
+ uint16 *attr, SMB_OFF_T *size, time_t *write_time)
{
char *p;
@@ -1260,8 +1263,8 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
*size = IVAL(cli->inbuf, smb_vwv3);
}
- if (t) {
- *t = cli_make_unix_date3(cli, cli->inbuf+smb_vwv1);
+ if (write_time) {
+ *write_time = cli_make_unix_date3(cli, cli->inbuf+smb_vwv1);
}
if (attr) {
@@ -1277,7 +1280,9 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
****************************************************************************/
BOOL cli_setattrE(struct cli_state *cli, int fd,
- time_t c_time, time_t a_time, time_t m_time)
+ time_t change_time,
+ time_t access_time,
+ time_t write_time)
{
char *p;
@@ -1292,9 +1297,9 @@ BOOL cli_setattrE(struct cli_state *cli, int fd,
cli_setup_packet(cli);
SSVAL(cli->outbuf,smb_vwv0, fd);
- cli_put_dos_date2(cli, cli->outbuf,smb_vwv1, c_time);
- cli_put_dos_date2(cli, cli->outbuf,smb_vwv3, a_time);
- cli_put_dos_date2(cli, cli->outbuf,smb_vwv5, m_time);
+ cli_put_dos_date2(cli, cli->outbuf,smb_vwv1, change_time);
+ cli_put_dos_date2(cli, cli->outbuf,smb_vwv3, access_time);
+ cli_put_dos_date2(cli, cli->outbuf,smb_vwv5, write_time);
p = smb_buf(cli->outbuf);
*p++ = 4;
@@ -1509,7 +1514,7 @@ static BOOL cli_set_ea(struct cli_state *cli, uint16 setup, char *param, unsigne
if (ea_namelen == 0 && ea_len == 0) {
data_len = 4;
- data = SMB_MALLOC(data_len);
+ data = (char *)SMB_MALLOC(data_len);
if (!data) {
return False;
}
@@ -1517,7 +1522,7 @@ static BOOL cli_set_ea(struct cli_state *cli, uint16 setup, char *param, unsigne
SIVAL(p,0,data_len);
} else {
data_len = 4 + 4 + ea_namelen + 1 + ea_len;
- data = SMB_MALLOC(data_len);
+ data = (char *)SMB_MALLOC(data_len);
if (!data) {
return False;
}
diff --git a/source/libsmb/clifsinfo.c b/source/libsmb/clifsinfo.c
index 2874ee6ca1c..9c3b6e3aed3 100644
--- a/source/libsmb/clifsinfo.c
+++ b/source/libsmb/clifsinfo.c
@@ -79,6 +79,59 @@ cleanup:
return ret;
}
+/****************************************************************************
+ Set UNIX extensions capabilities.
+****************************************************************************/
+
+BOOL cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor,
+ uint32 caplow, uint32 caphigh)
+{
+ BOOL ret = False;
+ uint16 setup;
+ char param[4];
+ char data[12];
+ char *rparam=NULL, *rdata=NULL;
+ unsigned int rparam_count=0, rdata_count=0;
+
+ setup = TRANSACT2_SETFSINFO;
+
+ SSVAL(param,0,0);
+ SSVAL(param,2,SMB_SET_CIFS_UNIX_INFO);
+
+ SSVAL(data,0,major);
+ SSVAL(data,2,minor);
+ SIVAL(data,4,caplow);
+ SIVAL(data,8,caphigh);
+
+ if (!cli_send_trans(cli, SMBtrans2,
+ NULL,
+ 0, 0,
+ &setup, 1, 0,
+ param, 4, 0,
+ data, 12, 560)) {
+ goto cleanup;
+ }
+
+ if (!cli_receive_trans(cli, SMBtrans2,
+ &rparam, &rparam_count,
+ &rdata, &rdata_count)) {
+ goto cleanup;
+ }
+
+ if (cli_is_error(cli)) {
+ ret = False;
+ goto cleanup;
+ } else {
+ ret = True;
+ }
+
+cleanup:
+ SAFE_FREE(rparam);
+ SAFE_FREE(rdata);
+
+ return ret;
+}
+
BOOL cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr)
{
BOOL ret = False;
@@ -229,7 +282,9 @@ BOOL cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *
}
if (pdate) {
- *pdate = interpret_long_date(rdata);
+ struct timespec ts;
+ ts = interpret_long_date(rdata);
+ *pdate = ts.tv_sec;
}
if (pserial_number) {
*pserial_number = IVAL(rdata,8);
diff --git a/source/libsmb/clilist.c b/source/libsmb/clilist.c
index 536bed5f787..22cb5930c26 100644
--- a/source/libsmb/clilist.c
+++ b/source/libsmb/clilist.c
@@ -49,9 +49,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
case 1: /* OS/2 understands this */
/* these dates are converted to GMT by
make_unix_date */
- finfo->ctime = cli_make_unix_date2(cli, p+4);
- finfo->atime = cli_make_unix_date2(cli, p+8);
- finfo->mtime = cli_make_unix_date2(cli, p+12);
+ finfo->ctime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+4));
+ finfo->atime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+8));
+ finfo->mtime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+12));
finfo->size = IVAL(p,16);
finfo->mode = CVAL(p,24);
len = CVAL(p, 26);
@@ -70,9 +70,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
case 2: /* this is what OS/2 uses mostly */
/* these dates are converted to GMT by
make_unix_date */
- finfo->ctime = cli_make_unix_date2(cli, p+4);
- finfo->atime = cli_make_unix_date2(cli, p+8);
- finfo->mtime = cli_make_unix_date2(cli, p+12);
+ finfo->ctime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+4));
+ finfo->atime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+8));
+ finfo->mtime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+12));
finfo->size = IVAL(p,16);
finfo->mode = CVAL(p,24);
len = CVAL(p, 30);
@@ -96,11 +96,11 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
/* Offset zero is "create time", not "change time". */
p += 8;
- finfo->atime = interpret_long_date(p);
+ finfo->atime_ts = interpret_long_date(p);
p += 8;
- finfo->mtime = interpret_long_date(p);
+ finfo->mtime_ts = interpret_long_date(p);
p += 8;
- finfo->ctime = interpret_long_date(p);
+ finfo->ctime_ts = interpret_long_date(p);
p += 8;
finfo->size = IVAL2_TO_SMB_BIG_UINT(p,0);
p += 8;
@@ -321,7 +321,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
/* grab the data for later use */
/* and add them to the dirlist pool */
- dirlist = SMB_REALLOC(dirlist,dirlist_len + data_len);
+ dirlist = (char *)SMB_REALLOC(dirlist,dirlist_len + data_len);
if (!dirlist) {
DEBUG(0,("cli_list_new: Failed to expand dirlist\n"));
@@ -349,10 +349,17 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
mnt = cli_cm_get_mntpoint( cli );
- for (p=dirlist,i=0;i<total_received;i++) {
- p += interpret_long_filename(cli,info_level,p,&finfo,NULL,NULL,NULL);
- fn( mnt,&finfo, Mask, state );
- }
+ /* see if the server disconnected or the connection otherwise failed */
+ if (cli_is_error(cli)) {
+ total_received = -1;
+ } else {
+ /* no connection problem. let user function add each entry */
+ for (p=dirlist,i=0;i<total_received;i++) {
+ p += interpret_long_filename(cli, info_level, p,
+ &finfo,NULL,NULL,NULL);
+ fn( mnt,&finfo, Mask, state );
+ }
+ }
/* free up the dirlist buffer and last name raw blob */
SAFE_FREE(dirlist);
@@ -373,8 +380,10 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
finfo->mode = CVAL(p,21);
/* this date is converted to GMT by make_unix_date */
- finfo->ctime = cli_make_unix_date(cli, p+22);
- finfo->mtime = finfo->atime = finfo->ctime;
+ finfo->ctime_ts.tv_sec = cli_make_unix_date(cli, p+22);
+ finfo->ctime_ts.tv_nsec = 0;
+ finfo->mtime_ts.tv_sec = finfo->atime_ts.tv_sec = finfo->ctime_ts.tv_sec;
+ finfo->mtime_ts.tv_nsec = finfo->atime_ts.tv_nsec = 0;
finfo->size = IVAL(p,26);
clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_ASCII);
if (strcmp(finfo->name, "..") && strcmp(finfo->name, ".")) {
@@ -447,7 +456,8 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
first = False;
- dirlist = SMB_REALLOC(dirlist,(num_received + received)*DIR_STRUCT_SIZE);
+ dirlist = (char *)SMB_REALLOC(
+ dirlist,(num_received + received)*DIR_STRUCT_SIZE);
if (!dirlist) {
DEBUG(0,("cli_list_old: failed to expand dirlist"));
return 0;
diff --git a/source/libsmb/clirap.c b/source/libsmb/clirap.c
index 2be4da8f7fd..caa23b59d9a 100644
--- a/source/libsmb/clirap.c
+++ b/source/libsmb/clirap.c
@@ -379,7 +379,9 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char
send a qpathinfo call
****************************************************************************/
BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
- time_t *c_time, time_t *a_time, time_t *m_time,
+ time_t *change_time,
+ time_t *access_time,
+ time_t *write_time,
SMB_OFF_T *size, uint16 *mode)
{
unsigned int data_len = 0;
@@ -434,14 +436,14 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
date_fn = cli_make_unix_date2;
}
- if (c_time) {
- *c_time = date_fn(cli, rdata+0);
+ if (change_time) {
+ *change_time = date_fn(cli, rdata+0);
}
- if (a_time) {
- *a_time = date_fn(cli, rdata+4);
+ if (access_time) {
+ *access_time = date_fn(cli, rdata+4);
}
- if (m_time) {
- *m_time = date_fn(cli, rdata+8);
+ if (write_time) {
+ *write_time = date_fn(cli, rdata+8);
}
if (size) {
*size = IVAL(rdata, 12);
@@ -460,7 +462,11 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
send a setpathinfo call
****************************************************************************/
BOOL cli_setpathinfo(struct cli_state *cli, const char *fname,
- time_t c_time, time_t a_time, time_t m_time, uint16 mode)
+ time_t create_time,
+ time_t access_time,
+ time_t write_time,
+ time_t change_time,
+ uint16 mode)
{
unsigned int data_len = 0;
unsigned int param_len = 0;
@@ -495,16 +501,16 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname,
* Add the create, last access, modification, and status change times
*/
- /* Don't set create time, at offset 0 */
+ put_long_date(p, create_time);
p += 8;
- put_long_date(p, a_time);
+ put_long_date(p, access_time);
p += 8;
- put_long_date(p, m_time);
+ put_long_date(p, write_time);
p += 8;
- put_long_date(p, c_time);
+ put_long_date(p, change_time);
p += 8;
/* Add attributes */
@@ -555,8 +561,11 @@ send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
****************************************************************************/
BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
- time_t *create_time, time_t *access_time, time_t *write_time,
- time_t *change_time, SMB_OFF_T *size, uint16 *mode,
+ struct timespec *create_time,
+ struct timespec *access_time,
+ struct timespec *write_time,
+ struct timespec *change_time,
+ SMB_OFF_T *size, uint16 *mode,
SMB_INO_T *ino)
{
unsigned int data_len = 0;
@@ -670,8 +679,11 @@ send a qfileinfo call
****************************************************************************/
BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
uint16 *mode, SMB_OFF_T *size,
- time_t *create_time, time_t *access_time, time_t *write_time,
- time_t *change_time, SMB_INO_T *ino)
+ struct timespec *create_time,
+ struct timespec *access_time,
+ struct timespec *write_time,
+ struct timespec *change_time,
+ SMB_INO_T *ino)
{
unsigned int data_len = 0;
unsigned int param_len = 0;
@@ -794,9 +806,9 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name,
return False;
}
- sbuf->st_atime = interpret_long_date( rdata+8 ); /* Access time. */
- sbuf->st_mtime = interpret_long_date( rdata+16 ); /* Write time. */
- sbuf->st_ctime = interpret_long_date( rdata+24 ); /* Change time. */
+ set_atimespec(sbuf, interpret_long_date( rdata+8 )); /* Access time. */
+ set_mtimespec(sbuf, interpret_long_date( rdata+16 )); /* Write time. */
+ set_ctimespec(sbuf, interpret_long_date( rdata+24 )); /* Change time. */
*attributes = IVAL( rdata, 32 );
@@ -848,7 +860,13 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd
return False;
}
- *poutdata = memdup(rdata, data_len);
+ *poutdata = (char *)memdup(rdata, data_len);
+ if (!*poutdata) {
+ SAFE_FREE(rdata);
+ SAFE_FREE(rparam);
+ return False;
+ }
+
*poutlen = data_len;
SAFE_FREE(rdata);
diff --git a/source/libsmb/libsmbclient.c b/source/libsmb/libsmbclient.c
index 80b09fab1a1..8c6218c6431 100644
--- a/source/libsmb/libsmbclient.c
+++ b/source/libsmb/libsmbclient.c
@@ -33,9 +33,10 @@
typedef struct DOS_ATTR_DESC {
int mode;
SMB_OFF_T size;
- time_t a_time;
- time_t c_time;
- time_t m_time;
+ time_t create_time;
+ time_t access_time;
+ time_t write_time;
+ time_t change_time;
SMB_INO_T inode;
} DOS_ATTR_DESC;
@@ -236,7 +237,7 @@ smbc_urlencode(char * dest, char * src, int max_dest_len)
*
*
* We accept:
- * smb://[[[domain;]user[:password@]]server[/share[/path[/file]]]][?options]
+ * smb://[[[domain;]user[:password]@]server[/share[/path[/file]]]][?options]
*
* Meaning of URLs:
*
@@ -359,19 +360,19 @@ smbc_parse_path(SMBCCTX *context,
pstring username, passwd, domain;
const char *u = userinfo;
- next_token(&p, userinfo, "@", sizeof(fstring));
+ next_token_no_ltrim(&p, userinfo, "@", sizeof(fstring));
username[0] = passwd[0] = domain[0] = 0;
if (strchr_m(u, ';')) {
- next_token(&u, domain, ";", sizeof(fstring));
+ next_token_no_ltrim(&u, domain, ";", sizeof(fstring));
}
if (strchr_m(u, ':')) {
- next_token(&u, username, ":", sizeof(fstring));
+ next_token_no_ltrim(&u, username, ":", sizeof(fstring));
pstrcpy(passwd, u);
@@ -783,8 +784,7 @@ smbc_server(SMBCCTX *context,
if (strcmp(called.name, "*SMBSERVER")) {
make_nmb_name(&called , "*SMBSERVER", 0x20);
goto again;
- }
- else { /* Try one more time, but ensure we don't loop */
+ } else { /* Try one more time, but ensure we don't loop */
/* Only try this if server is an IP address ... */
@@ -793,7 +793,8 @@ smbc_server(SMBCCTX *context,
struct in_addr rem_ip;
if ((rem_ip.s_addr=inet_addr(server)) == INADDR_NONE) {
- DEBUG(4, ("Could not convert IP address %s to struct in_addr\n", server));
+ DEBUG(4, ("Could not convert IP address "
+ "%s to struct in_addr\n", server));
errno = ETIMEDOUT;
return NULL;
}
@@ -834,7 +835,7 @@ smbc_server(SMBCCTX *context,
!cli_session_setup(&c, username_used,
password, 1,
password, 0,
- workgroup)) {
+ workgroup)) {
cli_shutdown(&c);
errno = EPERM;
@@ -1480,14 +1481,16 @@ smbc_getatr(SMBCCTX * context,
char *path,
uint16 *mode,
SMB_OFF_T *size,
- time_t *c_time,
- time_t *a_time,
- time_t *m_time,
+ struct timespec *create_time_ts,
+ struct timespec *access_time_ts,
+ struct timespec *write_time_ts,
+ struct timespec *change_time_ts,
SMB_INO_T *ino)
{
pstring fixedpath;
pstring targetpath;
struct cli_state *targetcli;
+ time_t write_time;
if (!context || !context->internal ||
!context->internal->_initialized) {
@@ -1524,7 +1527,11 @@ smbc_getatr(SMBCCTX * context,
if (!srv->no_pathinfo2 &&
cli_qpathinfo2(targetcli, targetpath,
- NULL, a_time, m_time, c_time, size, mode, ino)) {
+ create_time_ts,
+ access_time_ts,
+ write_time_ts,
+ change_time_ts,
+ size, mode, ino)) {
return True;
}
@@ -1534,10 +1541,26 @@ smbc_getatr(SMBCCTX * context,
return False;
}
- if (cli_getatr(targetcli, targetpath, mode, size, m_time)) {
- if (m_time != NULL) {
- if (a_time != NULL) *a_time = *m_time;
- if (c_time != NULL) *c_time = *m_time;
+ if (cli_getatr(targetcli, targetpath, mode, size, &write_time)) {
+
+ struct timespec w_time_ts;
+
+ w_time_ts = convert_time_t_to_timespec(write_time);
+
+ if (write_time_ts != NULL) {
+ *write_time_ts = w_time_ts;
+ }
+
+ if (create_time_ts != NULL) {
+ *create_time_ts = w_time_ts;
+ }
+
+ if (access_time_ts != NULL) {
+ *access_time_ts = w_time_ts;
+ }
+
+ if (change_time_ts != NULL) {
+ *change_time_ts = w_time_ts;
}
srv->no_pathinfo2 = True;
return True;
@@ -1560,7 +1583,10 @@ smbc_getatr(SMBCCTX * context,
*/
static BOOL
smbc_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
- time_t c_time, time_t a_time, time_t m_time,
+ time_t create_time,
+ time_t access_time,
+ time_t write_time,
+ time_t change_time,
uint16 mode)
{
int fd;
@@ -1573,7 +1599,12 @@ smbc_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
* attributes manipulated.
*/
if (srv->no_pathinfo ||
- ! cli_setpathinfo(&srv->cli, path, c_time, a_time, m_time, mode)) {
+ ! cli_setpathinfo(&srv->cli, path,
+ create_time,
+ access_time,
+ write_time,
+ change_time,
+ mode)) {
/*
* setpathinfo is not supported; go to plan B.
@@ -1595,42 +1626,14 @@ smbc_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
return -1;
}
- /*
- * Get the creat time of the file (if it wasn't provided).
- * We'll need it in the set call
- */
- if (c_time == 0) {
- ret = cli_getattrE(&srv->cli, fd,
- NULL, NULL,
- &c_time, NULL, NULL);
- } else {
- ret = True;
- }
-
- /* If we got create time, set times */
- if (ret) {
- /* Some OS versions don't support create time */
- if (c_time == 0 || c_time == -1) {
- c_time = time(NULL);
- }
-
- /*
- * For sanity sake, since there is no POSIX function
- * to set the create time of a file, if the existing
- * create time is greater than either of access time
- * or modification time, set create time to the
- * smallest of those. This ensure that the create
- * time of a file is never greater than its last
- * access or modification time.
- */
- if (c_time > a_time) c_time = a_time;
- if (c_time > m_time) c_time = m_time;
-
/* Set the new attributes */
- ret = cli_setattrE(&srv->cli, fd,
- c_time, a_time, m_time);
- cli_close(&srv->cli, fd);
- }
+ ret = cli_setattrE(&srv->cli, fd,
+ change_time,
+ access_time,
+ write_time);
+
+ /* Close the file */
+ cli_close(&srv->cli, fd);
/*
* Unfortunately, setattrE() doesn't have a provision for
@@ -1719,11 +1722,17 @@ smbc_unlink_ctx(SMBCCTX *context,
int saverr = errno;
SMB_OFF_T size = 0;
uint16 mode = 0;
- time_t m_time = 0, a_time = 0, c_time = 0;
+ struct timespec write_time_ts;
+ struct timespec access_time_ts;
+ struct timespec change_time_ts;
SMB_INO_T ino = 0;
if (!smbc_getatr(context, srv, path, &mode, &size,
- &c_time, &a_time, &m_time, &ino)) {
+ NULL,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &ino)) {
/* Hmmm, bad error ... What? */
@@ -2059,9 +2068,9 @@ smbc_stat_ctx(SMBCCTX *context,
fstring password;
fstring workgroup;
pstring path;
- time_t m_time = 0;
- time_t a_time = 0;
- time_t c_time = 0;
+ struct timespec write_time_ts;
+ struct timespec access_time_ts;
+ struct timespec change_time_ts;
SMB_OFF_T size = 0;
uint16 mode = 0;
SMB_INO_T ino = 0;
@@ -2105,7 +2114,11 @@ smbc_stat_ctx(SMBCCTX *context,
}
if (!smbc_getatr(context, srv, path, &mode, &size,
- &c_time, &a_time, &m_time, &ino)) {
+ NULL,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &ino)) {
errno = smbc_errno(context, &srv->cli);
return -1;
@@ -2116,9 +2129,9 @@ smbc_stat_ctx(SMBCCTX *context,
smbc_setup_stat(context, st, path, size, mode);
- st->st_atime = a_time;
- st->st_ctime = c_time;
- st->st_mtime = m_time;
+ set_atimespec(st, access_time_ts);
+ set_ctimespec(st, change_time_ts);
+ set_mtimespec(st, write_time_ts);
st->st_dev = srv->dev;
return 0;
@@ -2134,9 +2147,9 @@ smbc_fstat_ctx(SMBCCTX *context,
SMBCFILE *file,
struct stat *st)
{
- time_t c_time;
- time_t a_time;
- time_t m_time;
+ struct timespec change_time_ts;
+ struct timespec access_time_ts;
+ struct timespec write_time_ts;
SMB_OFF_T size;
uint16 mode;
fstring server;
@@ -2192,22 +2205,33 @@ smbc_fstat_ctx(SMBCCTX *context,
/*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/
if (!cli_qfileinfo(targetcli, file->cli_fd, &mode, &size,
- NULL, &a_time, &m_time, &c_time, &ino)) {
+ NULL,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &ino)) {
+
+ time_t change_time, access_time, write_time;
+
if (!cli_getattrE(targetcli, file->cli_fd, &mode, &size,
- &c_time, &a_time, &m_time)) {
+ &change_time, &access_time, &write_time)) {
errno = EINVAL;
return -1;
}
+
+ change_time_ts = convert_time_t_to_timespec(change_time);
+ access_time_ts = convert_time_t_to_timespec(access_time);
+ write_time_ts = convert_time_t_to_timespec(write_time);
}
st->st_ino = ino;
smbc_setup_stat(context, st, file->fname, size, mode);
- st->st_atime = a_time;
- st->st_ctime = c_time;
- st->st_mtime = m_time;
+ set_atimespec(st, access_time_ts);
+ set_ctimespec(st, change_time_ts);
+ set_mtimespec(st, write_time_ts);
st->st_dev = file->srv->dev;
return 0;
@@ -2256,7 +2280,7 @@ add_dirent(SMBCFILE *dir,
size = sizeof(struct smbc_dirent) + name_length + comment_len + 2;
- dirent = SMB_MALLOC(size);
+ dirent = (struct smbc_dirent *)SMB_MALLOC(size);
if (!dirent) {
@@ -2906,7 +2930,7 @@ smbc_opendir_ctx(SMBCCTX *context,
if (smbc_getatr(context, srv, path,
&mode, NULL,
- NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
NULL) &&
! IS_DOS_DIR(mode)) {
@@ -3596,8 +3620,8 @@ smbc_utimes_ctx(SMBCCTX *context,
fstring password;
fstring workgroup;
pstring path;
- time_t a_time;
- time_t m_time;
+ time_t access_time;
+ time_t write_time;
if (!context || !context->internal ||
!context->internal->_initialized) {
@@ -3615,10 +3639,10 @@ smbc_utimes_ctx(SMBCCTX *context,
}
if (tbuf == NULL) {
- a_time = m_time = time(NULL);
+ access_time = write_time = time(NULL);
} else {
- a_time = tbuf[0].tv_sec;
- m_time = tbuf[1].tv_sec;
+ access_time = tbuf[0].tv_sec;
+ write_time = tbuf[1].tv_sec;
}
if (DEBUGLVL(4))
@@ -3627,13 +3651,13 @@ smbc_utimes_ctx(SMBCCTX *context,
char atimebuf[32];
char mtimebuf[32];
- strncpy(atimebuf, ctime(&a_time), sizeof(atimebuf) - 1);
+ strncpy(atimebuf, ctime(&access_time), sizeof(atimebuf) - 1);
atimebuf[sizeof(atimebuf) - 1] = '\0';
if ((p = strchr(atimebuf, '\n')) != NULL) {
*p = '\0';
}
- strncpy(mtimebuf, ctime(&m_time), sizeof(mtimebuf) - 1);
+ strncpy(mtimebuf, ctime(&write_time), sizeof(mtimebuf) - 1);
mtimebuf[sizeof(mtimebuf) - 1] = '\0';
if ((p = strchr(mtimebuf, '\n')) != NULL) {
*p = '\0';
@@ -3664,7 +3688,8 @@ smbc_utimes_ctx(SMBCCTX *context,
return -1; /* errno set by smbc_server */
}
- if (!smbc_setatr(context, srv, path, 0, a_time, m_time, 0)) {
+ if (!smbc_setatr(context, srv, path,
+ 0, access_time, write_time, 0, 0)) {
return -1; /* errno set by smbc_setatr */
}
@@ -3735,7 +3760,7 @@ convert_sid_to_string(struct cli_state *ipc_cli,
{
char **domains = NULL;
char **names = NULL;
- uint32 *types = NULL;
+ enum lsa_SidType *types = NULL;
struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli);
sid_to_string(str, sid);
@@ -3771,7 +3796,7 @@ convert_string_to_sid(struct cli_state *ipc_cli,
DOM_SID *sid,
const char *str)
{
- uint32 *types = NULL;
+ enum lsa_SidType *types = NULL;
DOM_SID *sids = NULL;
BOOL result = True;
struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli);
@@ -4089,7 +4114,10 @@ dos_attr_query(SMBCCTX *context,
const char *filename,
SMBCSRV *srv)
{
- time_t m_time = 0, a_time = 0, c_time = 0;
+ struct timespec create_time_ts;
+ struct timespec write_time_ts;
+ struct timespec access_time_ts;
+ struct timespec change_time_ts;
SMB_OFF_T size = 0;
uint16 mode = 0;
SMB_INO_T inode = 0;
@@ -4104,7 +4132,11 @@ dos_attr_query(SMBCCTX *context,
/* Obtain the DOS attributes */
if (!smbc_getatr(context, srv, CONST_DISCARD(char *, filename),
&mode, &size,
- &c_time, &a_time, &m_time, &inode)) {
+ &create_time_ts,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &inode)) {
errno = smbc_errno(context, &srv->cli);
DEBUG(5, ("dos_attr_query Failed to query old attributes\n"));
@@ -4114,9 +4146,10 @@ dos_attr_query(SMBCCTX *context,
ret->mode = mode;
ret->size = size;
- ret->a_time = a_time;
- ret->c_time = c_time;
- ret->m_time = m_time;
+ ret->create_time = convert_timespec_to_time_t(create_time_ts);
+ ret->access_time = convert_timespec_to_time_t(access_time_ts);
+ ret->write_time = convert_timespec_to_time_t(write_time_ts);
+ ret->change_time = convert_timespec_to_time_t(change_time_ts);
ret->inode = inode;
return ret;
@@ -4130,8 +4163,40 @@ dos_attr_parse(SMBCCTX *context,
SMBCSRV *srv,
char *str)
{
+ int n;
const char *p = str;
fstring tok;
+ struct {
+ const char * create_time_attr;
+ const char * access_time_attr;
+ const char * write_time_attr;
+ const char * change_time_attr;
+ } attr_strings;
+
+ /* Determine whether to use old-style or new-style attribute names */
+ if (context->internal->_full_time_names) {
+ /* new-style names */
+ attr_strings.create_time_attr = "CREATE_TIME";
+ attr_strings.access_time_attr = "ACCESS_TIME";
+ attr_strings.write_time_attr = "WRITE_TIME";
+ attr_strings.change_time_attr = "CHANGE_TIME";
+ } else {
+ /* old-style names */
+ attr_strings.create_time_attr = NULL;
+ attr_strings.access_time_attr = "A_TIME";
+ attr_strings.write_time_attr = "M_TIME";
+ attr_strings.change_time_attr = "C_TIME";
+ }
+
+ /* if this is to set the entire ACL... */
+ if (*str == '*') {
+ /* ... then increment past the first colon if there is one */
+ if ((p = strchr(str, ':')) != NULL) {
+ ++p;
+ } else {
+ p = str;
+ }
+ }
while (next_token(&p, tok, "\t,\r\n", sizeof(tok))) {
@@ -4145,18 +4210,28 @@ dos_attr_parse(SMBCCTX *context,
continue;
}
- if (StrnCaseCmp(tok, "A_TIME:", 7) == 0) {
- dad->a_time = (time_t)strtol(tok+7, NULL, 10);
+ n = strlen(attr_strings.access_time_attr);
+ if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) {
+ dad->access_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
- if (StrnCaseCmp(tok, "C_TIME:", 7) == 0) {
- dad->c_time = (time_t)strtol(tok+7, NULL, 10);
+ n = strlen(attr_strings.change_time_attr);
+ if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) {
+ dad->change_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
- if (StrnCaseCmp(tok, "M_TIME:", 7) == 0) {
- dad->m_time = (time_t)strtol(tok+7, NULL, 10);
+ n = strlen(attr_strings.write_time_attr);
+ if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) {
+ dad->write_time = (time_t)strtol(tok+n+1, NULL, 10);
+ continue;
+ }
+
+ n = strlen(attr_strings.create_time_attr);
+ if (attr_strings.create_time_attr != NULL &&
+ StrnCaseCmp(tok, attr_strings.create_time_attr, n) == 0) {
+ dad->create_time = (time_t)strtol(tok+n+1, NULL, 10);
continue;
}
@@ -4197,9 +4272,10 @@ cacl_get(SMBCCTX *context,
BOOL exclude_nt_acl = False;
BOOL exclude_dos_mode = False;
BOOL exclude_dos_size = False;
- BOOL exclude_dos_ctime = False;
- BOOL exclude_dos_atime = False;
- BOOL exclude_dos_mtime = False;
+ BOOL exclude_dos_create_time = False;
+ BOOL exclude_dos_access_time = False;
+ BOOL exclude_dos_write_time = False;
+ BOOL exclude_dos_change_time = False;
BOOL exclude_dos_inode = False;
BOOL numeric = True;
BOOL determine_size = (bufsize == 0);
@@ -4210,11 +4286,55 @@ cacl_get(SMBCCTX *context,
char *name;
char *pExclude;
char *p;
- time_t m_time = 0, a_time = 0, c_time = 0;
+ struct timespec create_time_ts;
+ struct timespec write_time_ts;
+ struct timespec access_time_ts;
+ struct timespec change_time_ts;
+ time_t create_time = (time_t)0;
+ time_t write_time = (time_t)0;
+ time_t access_time = (time_t)0;
+ time_t change_time = (time_t)0;
SMB_OFF_T size = 0;
uint16 mode = 0;
SMB_INO_T ino = 0;
struct cli_state *cli = &srv->cli;
+ struct {
+ const char * create_time_attr;
+ const char * access_time_attr;
+ const char * write_time_attr;
+ const char * change_time_attr;
+ } attr_strings;
+ struct {
+ const char * create_time_attr;
+ const char * access_time_attr;
+ const char * write_time_attr;
+ const char * change_time_attr;
+ } excl_attr_strings;
+
+ /* Determine whether to use old-style or new-style attribute names */
+ if (context->internal->_full_time_names) {
+ /* new-style names */
+ attr_strings.create_time_attr = "CREATE_TIME";
+ attr_strings.access_time_attr = "ACCESS_TIME";
+ attr_strings.write_time_attr = "WRITE_TIME";
+ attr_strings.change_time_attr = "CHANGE_TIME";
+
+ excl_attr_strings.create_time_attr = "CREATE_TIME";
+ excl_attr_strings.access_time_attr = "ACCESS_TIME";
+ excl_attr_strings.write_time_attr = "WRITE_TIME";
+ excl_attr_strings.change_time_attr = "CHANGE_TIME";
+ } else {
+ /* old-style names */
+ attr_strings.create_time_attr = NULL;
+ attr_strings.access_time_attr = "A_TIME";
+ attr_strings.write_time_attr = "M_TIME";
+ attr_strings.change_time_attr = "C_TIME";
+
+ excl_attr_strings.create_time_attr = NULL;
+ excl_attr_strings.access_time_attr = "dos_attr.A_TIME";
+ excl_attr_strings.write_time_attr = "dos_attr.M_TIME";
+ excl_attr_strings.change_time_attr = "dos_attr.C_TIME";
+ }
/* Copy name so we can strip off exclusions (if any are specified) */
strncpy(name_sandbox, attr_name, sizeof(name_sandbox) - 1);
@@ -4272,14 +4392,22 @@ cacl_get(SMBCCTX *context,
else if (StrCaseCmp(pExclude, "dos_attr.size") == 0) {
exclude_dos_size = True;
}
- else if (StrCaseCmp(pExclude, "dos_attr.c_time") == 0) {
- exclude_dos_ctime = True;
+ else if (excl_attr_strings.create_time_attr != NULL &&
+ StrCaseCmp(pExclude,
+ excl_attr_strings.change_time_attr) == 0) {
+ exclude_dos_create_time = True;
}
- else if (StrCaseCmp(pExclude, "dos_attr.a_time") == 0) {
- exclude_dos_atime = True;
+ else if (StrCaseCmp(pExclude,
+ excl_attr_strings.access_time_attr) == 0) {
+ exclude_dos_access_time = True;
}
- else if (StrCaseCmp(pExclude, "dos_attr.m_time") == 0) {
- exclude_dos_mtime = True;
+ else if (StrCaseCmp(pExclude,
+ excl_attr_strings.write_time_attr) == 0) {
+ exclude_dos_write_time = True;
+ }
+ else if (StrCaseCmp(pExclude,
+ excl_attr_strings.change_time_attr) == 0) {
+ exclude_dos_change_time = True;
}
else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) {
exclude_dos_inode = True;
@@ -4557,13 +4685,22 @@ cacl_get(SMBCCTX *context,
/* Obtain the DOS attributes */
if (!smbc_getatr(context, srv, filename, &mode, &size,
- &c_time, &a_time, &m_time, &ino)) {
+ &create_time_ts,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &ino)) {
errno = smbc_errno(context, &srv->cli);
return -1;
}
+ create_time = convert_timespec_to_time_t(create_time_ts);
+ access_time = convert_timespec_to_time_t(access_time_ts);
+ write_time = convert_timespec_to_time_t(write_time_ts);
+ change_time = convert_timespec_to_time_t(change_time_ts);
+
if (! exclude_dos_mode) {
if (all || all_dos) {
if (determine_size) {
@@ -4655,12 +4792,14 @@ cacl_get(SMBCCTX *context,
bufsize -= n;
}
- if (! exclude_dos_ctime) {
+ if (! exclude_dos_create_time &&
+ attr_strings.create_time_attr != NULL) {
if (all || all_dos) {
if (determine_size) {
p = talloc_asprintf(ctx,
- ",C_TIME:%lu",
- c_time);
+ ",%s:%lu",
+ attr_strings.create_time_attr,
+ create_time);
if (!p) {
errno = ENOMEM;
return -1;
@@ -4668,11 +4807,13 @@ cacl_get(SMBCCTX *context,
n = strlen(p);
} else {
n = snprintf(buf, bufsize,
- ",C_TIME:%lu", c_time);
+ ",%s:%lu",
+ attr_strings.create_time_attr,
+ create_time);
}
} else if (StrCaseCmp(name, "c_time") == 0) {
if (determine_size) {
- p = talloc_asprintf(ctx, "%lu", c_time);
+ p = talloc_asprintf(ctx, "%lu", create_time);
if (!p) {
errno = ENOMEM;
return -1;
@@ -4680,7 +4821,7 @@ cacl_get(SMBCCTX *context,
n = strlen(p);
} else {
n = snprintf(buf, bufsize,
- "%lu", c_time);
+ "%lu", create_time);
}
}
@@ -4693,12 +4834,13 @@ cacl_get(SMBCCTX *context,
bufsize -= n;
}
- if (! exclude_dos_atime) {
+ if (! exclude_dos_access_time) {
if (all || all_dos) {
if (determine_size) {
p = talloc_asprintf(ctx,
- ",A_TIME:%lu",
- a_time);
+ ",%s:%lu",
+ attr_strings.access_time_attr,
+ access_time);
if (!p) {
errno = ENOMEM;
return -1;
@@ -4706,11 +4848,54 @@ cacl_get(SMBCCTX *context,
n = strlen(p);
} else {
n = snprintf(buf, bufsize,
- ",A_TIME:%lu", a_time);
+ ",%s:%lu",
+ attr_strings.access_time_attr,
+ access_time);
}
} else if (StrCaseCmp(name, "a_time") == 0) {
if (determine_size) {
- p = talloc_asprintf(ctx, "%lu", a_time);
+ p = talloc_asprintf(ctx, "%lu", access_time);
+ if (!p) {
+ errno = ENOMEM;
+ return -1;
+ }
+ n = strlen(p);
+ } else {
+ n = snprintf(buf, bufsize,
+ "%lu", access_time);
+ }
+ }
+
+ if (!determine_size && n > bufsize) {
+ errno = ERANGE;
+ return -1;
+ }
+ buf += n;
+ n_used += n;
+ bufsize -= n;
+ }
+
+ if (! exclude_dos_write_time) {
+ if (all || all_dos) {
+ if (determine_size) {
+ p = talloc_asprintf(ctx,
+ ",%s:%lu",
+ attr_strings.write_time_attr,
+ write_time);
+ if (!p) {
+ errno = ENOMEM;
+ return -1;
+ }
+ n = strlen(p);
+ } else {
+ n = snprintf(buf, bufsize,
+ ",%s:%lu",
+ attr_strings.write_time_attr,
+ write_time);
+ }
+ } else if (StrCaseCmp(name, attr_strings.write_time_attr) == 0) {
+ if (determine_size) {
+ p = talloc_asprintf(ctx, "%lu", write_time);
if (!p) {
errno = ENOMEM;
return -1;
@@ -4718,7 +4903,7 @@ cacl_get(SMBCCTX *context,
n = strlen(p);
} else {
n = snprintf(buf, bufsize,
- "%lu", a_time);
+ "%lu", write_time);
}
}
@@ -4731,12 +4916,13 @@ cacl_get(SMBCCTX *context,
bufsize -= n;
}
- if (! exclude_dos_mtime) {
+ if (! exclude_dos_change_time) {
if (all || all_dos) {
if (determine_size) {
p = talloc_asprintf(ctx,
- ",M_TIME:%lu",
- m_time);
+ ",%s:%lu",
+ attr_strings.change_time_attr,
+ change_time);
if (!p) {
errno = ENOMEM;
return -1;
@@ -4744,11 +4930,13 @@ cacl_get(SMBCCTX *context,
n = strlen(p);
} else {
n = snprintf(buf, bufsize,
- ",M_TIME:%lu", m_time);
+ ",%s:%lu",
+ attr_strings.change_time_attr,
+ change_time);
}
- } else if (StrCaseCmp(name, "m_time") == 0) {
+ } else if (StrCaseCmp(name, attr_strings.change_time_attr) == 0) {
if (determine_size) {
- p = talloc_asprintf(ctx, "%lu", m_time);
+ p = talloc_asprintf(ctx, "%lu", change_time);
if (!p) {
errno = ENOMEM;
return -1;
@@ -4756,7 +4944,7 @@ cacl_get(SMBCCTX *context,
n = strlen(p);
} else {
n = snprintf(buf, bufsize,
- "%lu", m_time);
+ "%lu", change_time);
}
}
@@ -5046,6 +5234,12 @@ smbc_setxattr_ctx(SMBCCTX *context,
TALLOC_CTX *ctx;
POLICY_HND pol;
DOS_ATTR_DESC *dad;
+ struct {
+ const char * create_time_attr;
+ const char * access_time_attr;
+ const char * write_time_attr;
+ const char * change_time_attr;
+ } attr_strings;
if (!context || !context->internal ||
!context->internal->_initialized) {
@@ -5135,9 +5329,10 @@ smbc_setxattr_ctx(SMBCCTX *context,
/* Set the new DOS attributes */
if (! smbc_setatr(context, srv, path,
- dad->c_time,
- dad->a_time,
- dad->m_time,
+ dad->create_time,
+ dad->access_time,
+ dad->write_time,
+ dad->change_time,
dad->mode)) {
/* cause failure if NT failed too */
@@ -5245,14 +5440,31 @@ smbc_setxattr_ctx(SMBCCTX *context,
return ret;
}
+ /* Determine whether to use old-style or new-style attribute names */
+ if (context->internal->_full_time_names) {
+ /* new-style names */
+ attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME";
+ attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME";
+ attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME";
+ attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME";
+ } else {
+ /* old-style names */
+ attr_strings.create_time_attr = NULL;
+ attr_strings.access_time_attr = "system.dos_attr.A_TIME";
+ attr_strings.write_time_attr = "system.dos_attr.M_TIME";
+ attr_strings.change_time_attr = "system.dos_attr.C_TIME";
+ }
+
/*
* Are they asking to set a DOS attribute?
*/
if (StrCaseCmp(name, "system.dos_attr.*") == 0 ||
StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
- StrCaseCmp(name, "system.dos_attr.c_time") == 0 ||
- StrCaseCmp(name, "system.dos_attr.a_time") == 0 ||
- StrCaseCmp(name, "system.dos_attr.m_time") == 0) {
+ (attr_strings.create_time_attr != NULL &&
+ StrCaseCmp(name, attr_strings.create_time_attr) == 0) ||
+ StrCaseCmp(name, attr_strings.access_time_attr) == 0 ||
+ StrCaseCmp(name, attr_strings.write_time_attr) == 0 ||
+ StrCaseCmp(name, attr_strings.change_time_attr) == 0) {
/* get a DOS Attribute Descriptor with current attributes */
dad = dos_attr_query(context, ctx, path, srv);
@@ -5269,9 +5481,10 @@ smbc_setxattr_ctx(SMBCCTX *context,
/* Set the new DOS attributes */
ret2 = smbc_setatr(context, srv, path,
- dad->c_time,
- dad->a_time,
- dad->m_time,
+ dad->create_time,
+ dad->access_time,
+ dad->write_time,
+ dad->change_time,
dad->mode);
/* ret2 has True (success) / False (failure) */
@@ -5313,6 +5526,12 @@ smbc_getxattr_ctx(SMBCCTX *context,
pstring path;
TALLOC_CTX *ctx;
POLICY_HND pol;
+ struct {
+ const char * create_time_attr;
+ const char * access_time_attr;
+ const char * write_time_attr;
+ const char * change_time_attr;
+ } attr_strings;
if (!context || !context->internal ||
@@ -5369,6 +5588,21 @@ smbc_getxattr_ctx(SMBCCTX *context,
return -1;
}
+ /* Determine whether to use old-style or new-style attribute names */
+ if (context->internal->_full_time_names) {
+ /* new-style names */
+ attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME";
+ attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME";
+ attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME";
+ attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME";
+ } else {
+ /* old-style names */
+ attr_strings.create_time_attr = NULL;
+ attr_strings.access_time_attr = "system.dos_attr.A_TIME";
+ attr_strings.write_time_attr = "system.dos_attr.M_TIME";
+ attr_strings.change_time_attr = "system.dos_attr.C_TIME";
+ }
+
/* Are they requesting a supported attribute? */
if (StrCaseCmp(name, "system.*") == 0 ||
StrnCaseCmp(name, "system.*!", 9) == 0 ||
@@ -5389,9 +5623,11 @@ smbc_getxattr_ctx(SMBCCTX *context,
StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 ||
StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
StrCaseCmp(name, "system.dos_attr.size") == 0 ||
- StrCaseCmp(name, "system.dos_attr.c_time") == 0 ||
- StrCaseCmp(name, "system.dos_attr.a_time") == 0 ||
- StrCaseCmp(name, "system.dos_attr.m_time") == 0 ||
+ (attr_strings.create_time_attr != NULL &&
+ StrCaseCmp(name, attr_strings.create_time_attr) == 0) ||
+ StrCaseCmp(name, attr_strings.access_time_attr) == 0 ||
+ StrCaseCmp(name, attr_strings.write_time_attr) == 0 ||
+ StrCaseCmp(name, attr_strings.change_time_attr) == 0 ||
StrCaseCmp(name, "system.dos_attr.inode") == 0) {
/* Yup. */
@@ -5536,7 +5772,7 @@ smbc_listxattr_ctx(SMBCCTX *context,
* the complete set of attribute names, always, rather than only those
* attribute names which actually exist for a file. Hmmm...
*/
- const char supported[] =
+ const char supported_old[] =
"system.*\0"
"system.*+\0"
"system.nt_sec_desc.revision\0"
@@ -5555,6 +5791,33 @@ smbc_listxattr_ctx(SMBCCTX *context,
"system.dos_attr.a_time\0"
"system.dos_attr.m_time\0"
;
+ const char supported_new[] =
+ "system.*\0"
+ "system.*+\0"
+ "system.nt_sec_desc.revision\0"
+ "system.nt_sec_desc.owner\0"
+ "system.nt_sec_desc.owner+\0"
+ "system.nt_sec_desc.group\0"
+ "system.nt_sec_desc.group+\0"
+ "system.nt_sec_desc.acl.*\0"
+ "system.nt_sec_desc.acl\0"
+ "system.nt_sec_desc.acl+\0"
+ "system.nt_sec_desc.*\0"
+ "system.nt_sec_desc.*+\0"
+ "system.dos_attr.*\0"
+ "system.dos_attr.mode\0"
+ "system.dos_attr.create_time\0"
+ "system.dos_attr.access_time\0"
+ "system.dos_attr.write_time\0"
+ "system.dos_attr.change_time\0"
+ ;
+ const char * supported;
+
+ if (context->internal->_full_time_names) {
+ supported = supported_new;
+ } else {
+ supported = supported_old;
+ }
if (size == 0) {
return sizeof(supported);
@@ -5880,6 +6143,8 @@ smbc_new_context(void)
context->options.browse_max_lmb_count = 3; /* # LMBs to query */
context->options.urlencode_readdir_entries = False;/* backward compat */
context->options.one_share_per_server = False;/* backward compat */
+ context->internal->_share_mode = SMBC_SHAREMODE_DENY_NONE;
+ /* backward compat */
context->open = smbc_open_ctx;
context->creat = smbc_creat_ctx;
@@ -6011,27 +6276,65 @@ smbc_free_context(SMBCCTX *context,
void
smbc_option_set(SMBCCTX *context,
char *option_name,
- void *option_value)
+ ... /* option_value */)
{
- if (strcmp(option_name, "debug_stderr") == 0) {
+ va_list ap;
+ union {
+ int i;
+ BOOL b;
+ smbc_get_auth_data_with_context_fn auth_fn;
+ void *v;
+ } option_value;
+
+ va_start(ap, option_name);
+
+ if (strcmp(option_name, "debug_to_stderr") == 0) {
/*
* Log to standard error instead of standard output.
*/
- context->internal->_debug_stderr =
- (option_value == NULL ? False : True);
+ option_value.b = (BOOL) va_arg(ap, int);
+ context->internal->_debug_stderr = option_value.b;
+
+ } else if (strcmp(option_name, "full_time_names") == 0) {
+ /*
+ * Use new-style time attribute names, e.g. WRITE_TIME rather
+ * than the old-style names such as M_TIME. This allows also
+ * setting/getting CREATE_TIME which was previously
+ * unimplemented. (Note that the old C_TIME was supposed to
+ * be CHANGE_TIME but was confused and sometimes referred to
+ * CREATE_TIME.)
+ */
+ option_value.b = (BOOL) va_arg(ap, int);
+ context->internal->_full_time_names = option_value.b;
+
+ } else if (strcmp(option_name, "open_share_mode") == 0) {
+ /*
+ * The share mode to use for files opened with
+ * smbc_open_ctx(). The default is SMBC_SHAREMODE_DENY_NONE.
+ */
+ option_value.i = va_arg(ap, int);
+ context->internal->_share_mode =
+ (smbc_share_mode) option_value.i;
+
} else if (strcmp(option_name, "auth_function") == 0) {
/*
* Use the new-style authentication function which includes
* the context.
*/
- context->internal->_auth_fn_with_context = option_value;
+ option_value.auth_fn =
+ va_arg(ap, smbc_get_auth_data_with_context_fn);
+ context->internal->_auth_fn_with_context =
+ option_value.auth_fn;
} else if (strcmp(option_name, "user_data") == 0) {
/*
* Save a user data handle which may be retrieved by the user
* with smbc_option_get()
*/
- context->internal->_user_data = option_value;
+ option_value.v = va_arg(ap, void *);
+ context->internal->_user_data = option_value.v;
}
+
+ va_end(ap);
}
@@ -6051,6 +6354,21 @@ smbc_option_get(SMBCCTX *context,
#else
return (void *) context->internal->_debug_stderr;
#endif
+ } else if (strcmp(option_name, "full_time_names") == 0) {
+ /*
+ * Use new-style time attribute names, e.g. WRITE_TIME rather
+ * than the old-style names such as M_TIME. This allows also
+ * setting/getting CREATE_TIME which was previously
+ * unimplemented. (Note that the old C_TIME was supposed to
+ * be CHANGE_TIME but was confused and sometimes referred to
+ * CREATE_TIME.)
+ */
+#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
+ return (void *) (intptr_t) context->internal->_full_time_names;
+#else
+ return (void *) context->internal->_full_time_names;
+#endif
+
} else if (strcmp(option_name, "auth_function") == 0) {
/*
* Use the new-style authentication function which includes
@@ -6205,7 +6523,7 @@ smbc_init_context(SMBCCTX *context)
* lazy for the moment
*/
pid = sys_getpid();
- context->netbios_name = SMB_MALLOC(17);
+ context->netbios_name = (char *)SMB_MALLOC(17);
if (!context->netbios_name) {
errno = ENOMEM;
return NULL;
diff --git a/source/libsmb/trusts_util.c b/source/libsmb/trusts_util.c
index 55108bf72f2..e4061883eb1 100644
--- a/source/libsmb/trusts_util.c
+++ b/source/libsmb/trusts_util.c
@@ -99,7 +99,7 @@ NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *m
if (NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("%s : trust_pw_change_and_store_it: Changed password.\n",
- timestring(False)));
+ current_timestring(False)));
/*
* Return the result of trying to write the new password
* back into the trust account file.
diff --git a/source/nsswitch/winbindd_cache.c b/source/nsswitch/winbindd_cache.c
index aa519c35a94..baaa5826bbd 100644
--- a/source/nsswitch/winbindd_cache.c
+++ b/source/nsswitch/winbindd_cache.c
@@ -215,9 +215,9 @@ static NTTIME centry_nttime(struct cache_entry *centry)
centry->len - centry->ofs));
smb_panic("centry_nttime");
}
- ret.low = IVAL(centry->data, centry->ofs);
+ ret = IVAL(centry->data, centry->ofs);
centry->ofs += 4;
- ret.high = IVAL(centry->data, centry->ofs);
+ ret += (uint64_t)IVAL(centry->data, centry->ofs) << 32;
centry->ofs += 4;
return ret;
}
@@ -706,9 +706,9 @@ static void centry_put_sid(struct cache_entry *centry, const DOM_SID *sid)
static void centry_put_nttime(struct cache_entry *centry, NTTIME nt)
{
centry_expand(centry, 8);
- SIVAL(centry->data, centry->ofs, nt.low);
+ SIVAL(centry->data, centry->ofs, nt & 0xFFFFFFFF);
centry->ofs += 4;
- SIVAL(centry->data, centry->ofs, nt.high);
+ SIVAL(centry->data, centry->ofs, nt >> 32);
centry->ofs += 4;
}
diff --git a/source/nsswitch/winbindd_pam.c b/source/nsswitch/winbindd_pam.c
index 4e063265fc4..6a13b38b3a4 100644
--- a/source/nsswitch/winbindd_pam.c
+++ b/source/nsswitch/winbindd_pam.c
@@ -35,17 +35,17 @@ static NTSTATUS append_info3_as_txt(TALLOC_CTX *mem_ctx,
fstring str_sid;
state->response.data.auth.info3.logon_time =
- nt_time_to_unix(&info3->logon_time);
+ nt_time_to_unix(info3->logon_time);
state->response.data.auth.info3.logoff_time =
- nt_time_to_unix(&info3->logoff_time);
+ nt_time_to_unix(info3->logoff_time);
state->response.data.auth.info3.kickoff_time =
- nt_time_to_unix(&info3->kickoff_time);
+ nt_time_to_unix(info3->kickoff_time);
state->response.data.auth.info3.pass_last_set_time =
- nt_time_to_unix(&info3->pass_last_set_time);
+ nt_time_to_unix(info3->pass_last_set_time);
state->response.data.auth.info3.pass_can_change_time =
- nt_time_to_unix(&info3->pass_can_change_time);
+ nt_time_to_unix(info3->pass_can_change_time);
state->response.data.auth.info3.pass_must_change_time =
- nt_time_to_unix(&info3->pass_must_change_time);
+ nt_time_to_unix(info3->pass_must_change_time);
state->response.data.auth.info3.logon_count = info3->logon_count;
state->response.data.auth.info3.bad_pw_count = info3->bad_pw_count;
@@ -819,12 +819,12 @@ NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
return NT_STATUS_LOGON_FAILURE;
}
#endif
- kickoff_time = nt_time_to_unix(&my_info3->kickoff_time);
+ kickoff_time = nt_time_to_unix(my_info3->kickoff_time);
if (kickoff_time != 0 && time(NULL) > kickoff_time) {
return NT_STATUS_ACCOUNT_EXPIRED;
}
- must_change_time = nt_time_to_unix(&my_info3->pass_must_change_time);
+ must_change_time = nt_time_to_unix(my_info3->pass_must_change_time);
if (must_change_time != 0 && must_change_time < time(NULL)) {
return NT_STATUS_PASSWORD_EXPIRED;
}
diff --git a/source/nsswitch/winbindd_rpc.c b/source/nsswitch/winbindd_rpc.c
index 61ed71f83cf..2e2b8953522 100644
--- a/source/nsswitch/winbindd_rpc.c
+++ b/source/nsswitch/winbindd_rpc.c
@@ -843,7 +843,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
result = rpccli_samr_query_dom_info(cli, mem_ctx, &dom_pol, 8, &ctr);
if (NT_STATUS_IS_OK(result)) {
- *seq = ctr.info.inf8.seq_num.low;
+ *seq = ctr.info.inf8.seq_num;
got_seq_num = True;
goto seq_num;
}
@@ -854,7 +854,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
result = rpccli_samr_query_dom_info(cli, mem_ctx, &dom_pol, 2, &ctr);
if (NT_STATUS_IS_OK(result)) {
- *seq = ctr.info.inf2.seq_num.low;
+ *seq = ctr.info.inf2.seq_num;
got_seq_num = True;
}
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index bf283355c73..1c3afef1f52 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -2015,9 +2015,9 @@ FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
FN_LOCAL_BOOL(lp_dmapi_support, bDmapiSupport)
-FN_LOCAL_PARM_BOOL(lp_locking, bLocking)
-FN_LOCAL_PARM_INTEGER(lp_strict_locking, iStrictLocking)
-FN_LOCAL_PARM_BOOL(lp_posix_locking, bPosixLocking)
+FN_LOCAL_BOOL(lp_locking, bLocking)
+FN_LOCAL_INTEGER(lp_strict_locking, iStrictLocking)
+FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
FN_LOCAL_BOOL(lp_share_modes, bShareModes)
FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
FN_LOCAL_BOOL(lp_level2_oplocks, bLevel2OpLocks)
diff --git a/source/rpc_client/cli_netlogon.c b/source/rpc_client/cli_netlogon.c
index 7213b9096b4..5396de9bf07 100644
--- a/source/rpc_client/cli_netlogon.c
+++ b/source/rpc_client/cli_netlogon.c
@@ -638,7 +638,7 @@ NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Sam synchronisation */
NTSTATUS rpccli_netlogon_sam_deltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- uint32 database_id, UINT64_S seqnum,
+ uint32 database_id, uint64 seqnum,
uint32 *num_deltas,
SAM_DELTA_HDR **hdr_deltas,
SAM_DELTA_CTR **deltas)
diff --git a/source/rpc_client/cli_reg.c b/source/rpc_client/cli_reg.c
index 87ab5dc9dad..e136df753ad 100644
--- a/source/rpc_client/cli_reg.c
+++ b/source/rpc_client/cli_reg.c
@@ -521,7 +521,7 @@ WERROR rpccli_reg_enum_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
else
fstrcpy( class_name, "" );
- *mod_time = nt_time_to_unix(out.time);
+ *mod_time = nt_time_to_unix(*out.time);
return out.status;
}
diff --git a/source/rpc_parse/parse_lsa.c b/source/rpc_parse/parse_lsa.c
index 0b138aba1b4..e1630f79f48 100644
--- a/source/rpc_parse/parse_lsa.c
+++ b/source/rpc_parse/parse_lsa.c
@@ -664,7 +664,7 @@ BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *out,
if(!prs_uint32("count", ps, depth, &out->count))
return False;
- if ( !prs_pointer("trusted_domains", ps, depth, (void**)&out->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
+ if ( !prs_pointer("trusted_domains", ps, depth, (void*)&out->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
return False;
if(!prs_ntstatus("status", ps, depth, &out->status))
@@ -2922,7 +2922,7 @@ BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *out, p
}
-static void init_lsa_string( LSA_STRING *uni, const char *string )
+void init_lsa_string( LSA_STRING *uni, const char *string )
{
init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
init_uni_hdr(&uni->hdr, &uni->unistring);
@@ -3253,7 +3253,7 @@ BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, pr
if(!prs_uint32("count ", ps, depth, &out->count))
return False;
- if ( !prs_pointer("rights", ps, depth, (void**)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
+ if ( !prs_pointer("rights", ps, depth, (void*)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
if(!prs_align(ps))
@@ -3305,7 +3305,7 @@ BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_s
if(!prs_uint32("count", ps, depth, &in->count))
return False;
- if ( !prs_pointer("rights", ps, depth, (void**)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
+ if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
return True;
@@ -3374,7 +3374,7 @@ BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *in,
if(!prs_uint32("count", ps, depth, &in->count))
return False;
- if ( !prs_pointer("rights", ps, depth, (void**)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
+ if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
return False;
return True;
@@ -4059,7 +4059,7 @@ BOOL lsa_io_r_query_trusted_domain_info(const char *desc,
prs_debug(ps, depth, desc, "lsa_io_r_query_trusted_domain_info");
depth++;
- if (!prs_pointer("trustdom", ps, depth, (void**)&r_q->info,
+ if (!prs_pointer("trustdom", ps, depth, (void*)&r_q->info,
sizeof(LSA_TRUSTED_DOMAIN_INFO),
(PRS_POINTER_CAST)lsa_io_trustdom_query) )
return False;
@@ -4188,7 +4188,7 @@ BOOL lsa_io_r_query_dom_info(const char *desc, LSA_R_QUERY_DOM_INFO_POLICY *out,
prs_debug(ps, depth, desc, "lsa_io_r_query_dom_info");
depth++;
- if (!prs_pointer("dominfo", ps, depth, (void**)&out->info,
+ if (!prs_pointer("dominfo", ps, depth, (void*)&out->info,
sizeof(LSA_DOM_INFO_UNION),
(PRS_POINTER_CAST)lsa_io_dom_info_query) )
return False;
diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c
index 8d7a423bb7b..3b1e9a4f08e 100644
--- a/source/rpc_parse/parse_misc.c
+++ b/source/rpc_parse/parse_misc.c
@@ -115,6 +115,7 @@ static BOOL smb_io_utime(const char *desc, UTIME *t, prs_struct *ps, int depth)
BOOL smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth)
{
+ uint32 low, high;
if (nttime == NULL)
return False;
@@ -124,11 +125,20 @@ BOOL smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth)
if(!prs_align(ps))
return False;
- if(!prs_uint32("low ", ps, depth, &nttime->low)) /* low part */
+ if (MARSHALLING(ps)) {
+ low = *nttime & 0xFFFFFFFF;
+ high = *nttime >> 32;
+ }
+
+ if(!prs_uint32("low ", ps, depth, &low)) /* low part */
return False;
- if(!prs_uint32("high", ps, depth, &nttime->high)) /* high part */
+ if(!prs_uint32("high", ps, depth, &high)) /* high part */
return False;
+ if (UNMARSHALLING(ps)) {
+ *nttime = (((uint64_t)high << 32) + low);
+ }
+
return True;
}
@@ -1756,10 +1766,25 @@ BOOL smb_io_unistr3(const char *desc, UNISTR3 *name, prs_struct *ps, int depth)
/*******************************************************************
Stream a uint64_struct
********************************************************************/
-BOOL prs_uint64(const char *name, prs_struct *ps, int depth, UINT64_S *data64)
+BOOL prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64)
{
- return prs_uint32(name, ps, depth+1, &data64->low) &&
- prs_uint32(name, ps, depth+1, &data64->high);
+ if (UNMARSHALLING(ps)) {
+ uint32 high, low;
+
+ if (!prs_uint32(name, ps, depth+1, &low))
+ return False;
+
+ if (!prs_uint32(name, ps, depth+1, &high))
+ return False;
+
+ *data64 = ((uint64_t)high << 32) + low;
+
+ return True;
+ } else {
+ uint32 high = (*data64) >> 32, low = (*data64) & 0xFFFFFFFF;
+ return prs_uint32(name, ps, depth+1, &low) &&
+ prs_uint32(name, ps, depth+1, &high);
+ }
}
/*******************************************************************
diff --git a/source/rpc_parse/parse_net.c b/source/rpc_parse/parse_net.c
index d0dbbf1c383..6f7c453edf5 100644
--- a/source/rpc_parse/parse_net.c
+++ b/source/rpc_parse/parse_net.c
@@ -3104,7 +3104,7 @@ makes a NET_Q_SAM_DELTAS structure.
********************************************************************/
BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name,
const char *cli_name, DOM_CRED *cli_creds,
- uint32 database_id, UINT64_S dom_mod_count)
+ uint32 database_id, uint64 dom_mod_count)
{
DEBUG(5, ("init_net_q_sam_deltas\n"));
@@ -3115,8 +3115,7 @@ BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name,
memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
q_s->database_id = database_id;
- q_s->dom_mod_count.low = dom_mod_count.low;
- q_s->dom_mod_count.high = dom_mod_count.high;
+ q_s->dom_mod_count = dom_mod_count;
q_s->max_size = 0xffff;
return True;
diff --git a/source/rpc_parse/parse_ntsvcs.c b/source/rpc_parse/parse_ntsvcs.c
index 599257e8020..ab5f3f75e87 100644
--- a/source/rpc_parse/parse_ntsvcs.c
+++ b/source/rpc_parse/parse_ntsvcs.c
@@ -77,7 +77,7 @@ BOOL ntsvcs_io_q_get_device_list_size(const char *desc, NTSVCS_Q_GET_DEVICE_LIST
if(!prs_align(ps))
return False;
- if ( !prs_pointer("devicename", ps, depth, (void**)&q_u->devicename, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2) )
+ if ( !prs_pointer("devicename", ps, depth, (void*)&q_u->devicename, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2) )
return False;
if ( !prs_align(ps) )
return False;
@@ -127,7 +127,7 @@ BOOL ntsvcs_io_q_get_device_list(const char *desc, NTSVCS_Q_GET_DEVICE_LIST *q_u
if(!prs_align(ps))
return False;
- if ( !prs_pointer("devicename", ps, depth, (void**)&q_u->devicename, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2) )
+ if ( !prs_pointer("devicename", ps, depth, (void*)&q_u->devicename, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2) )
return False;
if( !prs_align(ps) )
return False;
diff --git a/source/rpc_parse/parse_prs.c b/source/rpc_parse/parse_prs.c
index 14e190892d7..54bbe3adf6c 100644
--- a/source/rpc_parse/parse_prs.c
+++ b/source/rpc_parse/parse_prs.c
@@ -158,7 +158,8 @@ char *prs_alloc_mem(prs_struct *ps, size_t size, unsigned int count)
if (size) {
/* We can't call the type-safe version here. */
- ret = _talloc_zero_array(ps->mem_ctx, size, count, "parse_prs");
+ ret = (char *)_talloc_zero_array(ps->mem_ctx, size, count,
+ "parse_prs");
}
return ret;
}
@@ -213,7 +214,7 @@ BOOL prs_set_buffer_size(prs_struct *ps, uint32 newsize)
if (newsize == 0) {
SAFE_FREE(ps->data_p);
} else {
- ps->data_p = SMB_REALLOC(ps->data_p, newsize);
+ ps->data_p = (char *)SMB_REALLOC(ps->data_p, newsize);
if (ps->data_p == NULL) {
DEBUG(0,("prs_set_buffer_size: Realloc failure for size %u.\n",
@@ -265,7 +266,7 @@ BOOL prs_grow(prs_struct *ps, uint32 extra_space)
new_size = MAX(RPC_MAX_PDU_FRAG_LEN,extra_space);
- if((ps->data_p = SMB_MALLOC(new_size)) == NULL) {
+ if((ps->data_p = (char *)SMB_MALLOC(new_size)) == NULL) {
DEBUG(0,("prs_grow: Malloc failure for size %u.\n", (unsigned int)new_size));
return False;
}
@@ -277,7 +278,7 @@ BOOL prs_grow(prs_struct *ps, uint32 extra_space)
*/
new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space);
- if ((ps->data_p = SMB_REALLOC(ps->data_p, new_size)) == NULL) {
+ if ((ps->data_p = (char *)SMB_REALLOC(ps->data_p, new_size)) == NULL) {
DEBUG(0,("prs_grow: Realloc failure for size %u.\n",
(unsigned int)new_size));
return False;
@@ -306,7 +307,7 @@ BOOL prs_force_grow(prs_struct *ps, uint32 extra_space)
return False;
}
- if((ps->data_p = SMB_REALLOC(ps->data_p, new_size)) == NULL) {
+ if((ps->data_p = (char *)SMB_REALLOC(ps->data_p, new_size)) == NULL) {
DEBUG(0,("prs_force_grow: Realloc failure for size %u.\n",
(unsigned int)new_size));
return False;
@@ -624,9 +625,10 @@ BOOL prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8)
********************************************************************/
BOOL prs_pointer( const char *name, prs_struct *ps, int depth,
- void **data, size_t data_size,
+ void *dta, size_t data_size,
BOOL(*prs_fn)(const char*, prs_struct*, int, void*) )
{
+ void ** data = (void **)dta;
uint32 data_p;
/* output f000baaa to stream if the pointer is non-zero. */
@@ -1459,7 +1461,7 @@ int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps)
kbuf.dsize = strlen(keystr)+1;
dbuf.dptr = ps->data_p;
dbuf.dsize = prs_offset(ps);
- return tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);
+ return tdb_trans_store(tdb, kbuf, dbuf, TDB_REPLACE);
}
/* useful function to fetch a structure into rpc wire format */
@@ -1624,7 +1626,7 @@ void schannel_encode(struct schannel_auth_struct *a, enum pipe_auth_level auth_l
uchar digest_final[16];
uchar confounder[8];
uchar seq_num[8];
- static const uchar nullbytes[8];
+ static const uchar nullbytes[8] = { 0, };
static const uchar schannel_seal_sig[8] = SCHANNEL_SEAL_SIGNATURE;
static const uchar schannel_sign_sig[8] = SCHANNEL_SIGN_SIGNATURE;
@@ -1793,3 +1795,35 @@ BOOL schannel_decode(struct schannel_auth_struct *a, enum pipe_auth_level auth_l
return (memcmp(digest_final, verf->packet_digest,
sizeof(verf->packet_digest)) == 0);
}
+
+/*******************************************************************
+creates a new prs_struct containing a DATA_BLOB
+********************************************************************/
+BOOL prs_init_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
+{
+ if (!prs_init( prs, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL ))
+ return False;
+
+
+ if (!prs_copy_data_in(prs, (char *)blob->data, blob->length))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+return the contents of a prs_struct in a DATA_BLOB
+********************************************************************/
+BOOL prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
+{
+ blob->length = prs_data_size(prs);
+ blob->data = (uint8 *)talloc_zero_size(mem_ctx, blob->length);
+
+ /* set the pointer at the end of the buffer */
+ prs_set_offset( prs, prs_data_size(prs) );
+
+ if (!prs_copy_all_data_out((char *)blob->data, prs))
+ return False;
+
+ return True;
+}
diff --git a/source/rpc_parse/parse_samr.c b/source/rpc_parse/parse_samr.c
index 4198bf571c9..2781ad0fb96 100644
--- a/source/rpc_parse/parse_samr.c
+++ b/source/rpc_parse/parse_samr.c
@@ -6,7 +6,7 @@
* Copyright (C) Paul Ashton 1997-2000,
* Copyright (C) Elrond 2000,
* Copyright (C) Jeremy Allison 2001,
- * Copyright (C) Jean François Micouleau 1998-2001,
+ * Copyright (C) Jean François Micouleau 1998-2001,
* Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
*
* This program is free software; you can redistribute it and/or modify
@@ -549,15 +549,14 @@ static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
inits a structure.
********************************************************************/
-void init_unk_info2(SAM_UNK_INFO_2 * u_2, const char *comment,
- const char *domain, const char *server,
- uint32 seq_num, uint32 num_users, uint32 num_groups,
- uint32 num_alias, NTTIME nt_logout, uint32 server_role)
+void init_unk_info2(SAM_UNK_INFO_2 * u_2,
+ const char *comment, const char *domain, const char *server,
+ uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
{
u_2->logout = nt_logout;
- u_2->seq_num.low = seq_num;
- u_2->seq_num.high = 0x00000000;
+ u_2->seq_num = seq_num;
+
u_2->unknown_4 = 0x00000001;
u_2->server_role = server_role;
@@ -785,8 +784,7 @@ inits a structure.
void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
{
unix_to_nt_time(&u_8->domain_create_time, 0);
- u_8->seq_num.low = seq_num;
- u_8->seq_num.high = 0x00000000;
+ u_8->seq_num = seq_num;
}
/*******************************************************************
@@ -881,8 +879,7 @@ inits a structure.
void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
{
unix_to_nt_time(&u_13->domain_create_time, 0);
- u_13->seq_num.low = seq_num;
- u_13->seq_num.high = 0x00000000;
+ u_13->seq_num = seq_num;
u_13->unknown1 = 0;
u_13->unknown2 = 0;
}
diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c
index 6737ce8e05a..96a94033ffc 100644
--- a/source/rpc_parse/parse_spoolss.c
+++ b/source/rpc_parse/parse_spoolss.c
@@ -2661,9 +2661,7 @@ BOOL smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_I
if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
return False;
- if (!prs_uint32("date.low", ps, depth, &info->driver_date.low))
- return False;
- if (!prs_uint32("date.high", ps, depth, &info->driver_date.high))
+ if (!prs_uint64("date", ps, depth, &info->driver_date))
return False;
if (!prs_uint32("padding", ps, depth, &info->padding))
diff --git a/source/rpc_server/srv_samr_util.c b/source/rpc_server/srv_samr_util.c
index 216b9f255d9..242d44c6e83 100644
--- a/source/rpc_server/srv_samr_util.c
+++ b/source/rpc_server/srv_samr_util.c
@@ -76,7 +76,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from)
return;
if (from->fields_present & ACCT_LAST_LOGON) {
- unix_time=nt_time_to_unix(&from->logon_time);
+ unix_time=nt_time_to_unix(from->logon_time);
stored_time = pdb_get_logon_time(to);
DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -84,7 +84,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from)
}
if (from->fields_present & ACCT_LAST_LOGOFF) {
- unix_time=nt_time_to_unix(&from->logoff_time);
+ unix_time=nt_time_to_unix(from->logoff_time);
stored_time = pdb_get_logoff_time(to);
DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -92,7 +92,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from)
}
if (from->fields_present & ACCT_EXPIRY) {
- unix_time=nt_time_to_unix(&from->kickoff_time);
+ unix_time=nt_time_to_unix(from->kickoff_time);
stored_time = pdb_get_kickoff_time(to);
DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -100,7 +100,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from)
}
if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
- unix_time=nt_time_to_unix(&from->pass_last_set_time);
+ unix_time=nt_time_to_unix(from->pass_last_set_time);
stored_time = pdb_get_pass_last_set_time(to);
DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -272,10 +272,10 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from)
calculated from policy, not set from the wire */
if (from->fields_present & ACCT_EXPIRED_FLAG) {
- DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
- if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) {
+ DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
+ if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) {
pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
- } else {
+ } else {
pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED);
}
}
@@ -298,7 +298,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from)
return;
if (from->fields_present & ACCT_LAST_LOGON) {
- unix_time=nt_time_to_unix(&from->logon_time);
+ unix_time=nt_time_to_unix(from->logon_time);
stored_time = pdb_get_logon_time(to);
DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -306,7 +306,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from)
}
if (from->fields_present & ACCT_LAST_LOGOFF) {
- unix_time=nt_time_to_unix(&from->logoff_time);
+ unix_time=nt_time_to_unix(from->logoff_time);
stored_time = pdb_get_logoff_time(to);
DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -314,7 +314,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from)
}
if (from->fields_present & ACCT_EXPIRY) {
- unix_time=nt_time_to_unix(&from->kickoff_time);
+ unix_time=nt_time_to_unix(from->kickoff_time);
stored_time = pdb_get_kickoff_time(to);
DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -322,7 +322,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from)
}
if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
- unix_time=nt_time_to_unix(&from->pass_last_set_time);
+ unix_time=nt_time_to_unix(from->pass_last_set_time);
stored_time = pdb_get_pass_last_set_time(to);
DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -485,10 +485,10 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from)
calculated from policy, not set from the wire */
if (from->fields_present & ACCT_EXPIRED_FLAG) {
- DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
- if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) {
+ DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
+ if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) {
pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
- } else {
+ } else {
pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED);
}
}
@@ -510,7 +510,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from)
return;
if (from->fields_present & ACCT_LAST_LOGON) {
- unix_time=nt_time_to_unix(&from->logon_time);
+ unix_time=nt_time_to_unix(from->logon_time);
stored_time = pdb_get_logon_time(to);
DEBUG(10,("INFO_25 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -518,7 +518,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from)
}
if (from->fields_present & ACCT_LAST_LOGOFF) {
- unix_time=nt_time_to_unix(&from->logoff_time);
+ unix_time=nt_time_to_unix(from->logoff_time);
stored_time = pdb_get_logoff_time(to);
DEBUG(10,("INFO_25 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -526,7 +526,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from)
}
if (from->fields_present & ACCT_EXPIRY) {
- unix_time=nt_time_to_unix(&from->kickoff_time);
+ unix_time=nt_time_to_unix(from->kickoff_time);
stored_time = pdb_get_kickoff_time(to);
DEBUG(10,("INFO_25 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
@@ -534,7 +534,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from)
}
if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
- unix_time=nt_time_to_unix(&from->pass_last_set_time);
+ unix_time=nt_time_to_unix(from->pass_last_set_time);
stored_time = pdb_get_pass_last_set_time(to);
DEBUG(10,("INFO_25 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index d9b34fe4e91..fda6f230750 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -715,7 +715,8 @@ static void notify_system_time(struct spoolss_notify_msg *msg,
}
data->notify_data.data.length = prs_offset(&ps);
- data->notify_data.data.string = TALLOC(mem_ctx, prs_offset(&ps));
+ data->notify_data.data.string = (uint16 *)
+ TALLOC(mem_ctx, prs_offset(&ps));
if (!data->notify_data.data.string) {
prs_mem_free(&ps);
return;
@@ -907,7 +908,8 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
/* need to allocate own copy of data */
if ( msg->len != 0 )
- msg_grp->msgs[new_slot].notify.data = TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len );
+ msg_grp->msgs[new_slot].notify.data = (char *)
+ TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len );
return ctr->num_groups;
}
@@ -1216,7 +1218,7 @@ void do_drv_upgrade_printer(int msg_type, struct process_id src, void *buf, size
int n_services = lp_numservices();
len = MIN(len,sizeof(drivername)-1);
- strncpy(drivername, buf, len);
+ strncpy(drivername, (const char *)buf, len);
DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername ));
@@ -1314,7 +1316,7 @@ void reset_all_printerdata(int msg_type, struct process_id src,
int n_services = lp_numservices();
len = MIN( len, sizeof(drivername)-1 );
- strncpy( drivername, buf, len );
+ strncpy( drivername, (const char *)buf, len );
DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername ));
@@ -1377,7 +1379,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode)
/* bulk copy first */
- d = TALLOC_MEMDUP(ctx, devmode, sizeof(DEVICEMODE));
+ d = (DEVICEMODE *)TALLOC_MEMDUP(ctx, devmode, sizeof(DEVICEMODE));
if (!d)
return NULL;
@@ -1404,7 +1406,8 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode)
return NULL;
}
- d->dev_private = TALLOC_MEMDUP(ctx, devmode->dev_private, devmode->driverextra);
+ d->dev_private = (uint8 *)TALLOC_MEMDUP(ctx, devmode->dev_private,
+ devmode->driverextra);
if (!d->dev_private) {
return NULL;
}
@@ -4076,7 +4079,7 @@ static BOOL convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode
Create a DEVMODE struct. Returns malloced memory.
****************************************************************************/
-DEVICEMODE *construct_dev_mode(int snum)
+DEVICEMODE *construct_dev_mode(const char *servicename)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
DEVICEMODE *devmode = NULL;
@@ -4085,7 +4088,7 @@ DEVICEMODE *construct_dev_mode(int snum)
DEBUGADD(8,("getting printer characteristics\n"));
- if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename)))
return NULL;
if ( !printer->info_2->devmode ) {
@@ -4157,7 +4160,8 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p
printer->cjobs = count; /* jobs */
printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */
- if ( !(printer->devmode = construct_dev_mode(snum)) )
+ if ( !(printer->devmode = construct_dev_mode(
+ lp_const_servicename(snum))) )
DEBUG(8, ("Returning NULL Devicemode!\n"));
printer->secdesc = NULL;
@@ -5292,8 +5296,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN
info->previousdrivernames=NULL;
init_unistr_array(&info->previousdrivernames, &nullstr, servername);
- info->driver_date.low=0;
- info->driver_date.high=0;
+ info->driver_date=0;
info->padding=0;
info->driver_version_low=0;
@@ -6549,7 +6552,7 @@ static WERROR enumjobs_level2(const print_queue_struct *queue, int snum,
/* this should not be a failure condition if the devmode is NULL */
- devmode = construct_dev_mode(snum);
+ devmode = construct_dev_mode(lp_const_servicename(snum));
for (i=0; i<*returned; i++)
fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, devmode);
@@ -8781,7 +8784,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum,
*/
if ( !(nt_devmode=print_job_devmode( lp_const_servicename(snum), jobid )) )
- devmode = construct_dev_mode(snum);
+ devmode = construct_dev_mode(lp_const_servicename(snum));
else {
if ((devmode = SMB_MALLOC_P(DEVICEMODE)) != NULL) {
ZERO_STRUCTP( devmode );
diff --git a/source/rpcclient/cmd_lsarpc.c b/source/rpcclient/cmd_lsarpc.c
index 97a707c020a..a130def4f57 100644
--- a/source/rpcclient/cmd_lsarpc.c
+++ b/source/rpcclient/cmd_lsarpc.c
@@ -31,7 +31,7 @@ static NTSTATUS name_to_sid(struct rpc_pipe_client *cli,
DOM_SID *sid, const char *name)
{
POLICY_HND pol;
- uint32 *sid_types;
+ enum lsa_SidType *sid_types;
NTSTATUS result;
DOM_SID *sids;
@@ -63,9 +63,9 @@ static void display_query_info_1(DOM_QUERY_1 d)
{
d_printf("percent_full:\t%d\n", d.percent_full);
d_printf("log_size:\t%d\n", d.log_size);
- d_printf("retention_time:\t%08x %08x\n", d.retention_time.high, d.retention_time.low);
+ d_printf("retention_time:\t%lld\n", (long long)d.retention_time);
d_printf("shutdown_in_progress:\t%d\n", d.shutdown_in_progress);
- d_printf("time_to_shutdown:\t%08x %08x\n", d.time_to_shutdown.high, d.time_to_shutdown.low);
+ d_printf("time_to_shutdown:\t%lld\n", (long long)d.time_to_shutdown);
d_printf("next_audit_record:\t%d\n", d.next_audit_record);
d_printf("unknown:\t%d\n", d.unknown);
}
@@ -223,7 +223,7 @@ static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli,
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_SID *sids;
- uint32 *types;
+ enum lsa_SidType *types;
int i;
if (argc == 1) {
@@ -272,7 +272,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem
DOM_SID *sids;
char **domains;
char **names;
- uint32 *types;
+ enum lsa_SidType *types;
int i;
if (argc == 1) {
diff --git a/source/rpcclient/cmd_netlogon.c b/source/rpcclient/cmd_netlogon.c
index 4608c6b3da3..1a145711cc7 100644
--- a/source/rpcclient/cmd_netlogon.c
+++ b/source/rpcclient/cmd_netlogon.c
@@ -263,7 +263,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
uint32 database_id, num_deltas, tmp;
SAM_DELTA_HDR *hdr_deltas;
SAM_DELTA_CTR *deltas;
- UINT64_S seqnum;
+ uint64 seqnum;
if (argc != 3) {
fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]);
@@ -273,8 +273,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli,
database_id = atoi(argv[1]);
tmp = atoi(argv[2]);
- seqnum.low = tmp & 0xffff;
- seqnum.high = 0;
+ seqnum = tmp & 0xffff;
result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id,
seqnum, &num_deltas,
diff --git a/source/rpcclient/cmd_samr.c b/source/rpcclient/cmd_samr.c
index 59fb882fc1c..d3f72ccba78 100644
--- a/source/rpcclient/cmd_samr.c
+++ b/source/rpcclient/cmd_samr.c
@@ -84,17 +84,17 @@ static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
printf("\tRemote Dial :\t%s\n", temp);
printf("\tLogon Time :\t%s\n",
- http_timestring(nt_time_to_unix(&usr->logon_time)));
+ http_timestring(nt_time_to_unix(usr->logon_time)));
printf("\tLogoff Time :\t%s\n",
- http_timestring(nt_time_to_unix(&usr->logoff_time)));
+ http_timestring(nt_time_to_unix(usr->logoff_time)));
printf("\tKickoff Time :\t%s\n",
- http_timestring(nt_time_to_unix(&usr->kickoff_time)));
+ http_timestring(nt_time_to_unix(usr->kickoff_time)));
printf("\tPassword last set Time :\t%s\n",
- http_timestring(nt_time_to_unix(&usr->pass_last_set_time)));
+ http_timestring(nt_time_to_unix(usr->pass_last_set_time)));
printf("\tPassword can change Time :\t%s\n",
- http_timestring(nt_time_to_unix(&usr->pass_can_change_time)));
+ http_timestring(nt_time_to_unix(usr->pass_can_change_time)));
printf("\tPassword must change Time:\t%s\n",
- http_timestring(nt_time_to_unix(&usr->pass_must_change_time)));
+ http_timestring(nt_time_to_unix(usr->pass_must_change_time)));
printf("\tunknown_2[0..31]...\n"); /* user passwords? */
@@ -114,39 +114,6 @@ static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
}
}
-static const char *display_time(NTTIME nttime)
-{
- static fstring string;
-
- float high;
- float low;
- int sec;
- int days, hours, mins, secs;
-
- if (nttime.high==0 && nttime.low==0)
- return "Now";
-
- if (nttime.high==0x80000000 && nttime.low==0)
- return "Never";
- high = 65536;
- high = high/10000;
- high = high*65536;
- high = high/1000;
- high = high * (~nttime.high);
-
- low = ~nttime.low;
- low = low/(1000*1000*10);
-
- sec=high+low;
-
- days=sec/(60*60*24);
- hours=(sec - (days*60*60*24)) / (60*60);
- mins=(sec - (days*60*60*24) - (hours*60*60) ) / 60;
- secs=sec - (days*60*60*24) - (hours*60*60) - (mins*60);
-
- fstr_sprintf(string, "%u days, %u hours, %u minutes, %u seconds", days, hours, mins, secs);
- return (string);
-}
static void display_password_properties(uint32 password_properties)
{
@@ -198,7 +165,7 @@ static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2)
printf("Total Groups:\t%d\n", info2->num_domain_grps);
printf("Total Aliases:\t%d\n", info2->num_local_grps);
- printf("Sequence No:\t%d\n", info2->seq_num.low);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info2->seq_num);
printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info2->logout));
@@ -243,9 +210,9 @@ static void display_sam_unk_info_7(SAM_UNK_INFO_7 *info7)
static void display_sam_unk_info_8(SAM_UNK_INFO_8 *info8)
{
- printf("Sequence No:\t%d\n", info8->seq_num.low);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info8->seq_num);
printf("Domain Create Time:\t%s\n",
- http_timestring(nt_time_to_unix(&info8->domain_create_time)));
+ http_timestring(nt_time_to_unix(info8->domain_create_time)));
}
static void display_sam_unk_info_9(SAM_UNK_INFO_9 *info9)
@@ -262,9 +229,9 @@ static void display_sam_unk_info_12(SAM_UNK_INFO_12 *info12)
static void display_sam_unk_info_13(SAM_UNK_INFO_13 *info13)
{
- printf("Sequence No:\t%d\n", info13->seq_num.low);
+ printf("Sequence No:\t%llu\n", (unsigned long long)info13->seq_num);
printf("Domain Create Time:\t%s\n",
- http_timestring(nt_time_to_unix(&info13->domain_create_time)));
+ http_timestring(nt_time_to_unix(info13->domain_create_time)));
printf("Unknown1:\t%d\n", info13->unknown1);
printf("Unknown2:\t%d\n", info13->unknown2);
@@ -375,14 +342,14 @@ static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli,
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
SAM_USERINFO_CTR *user_ctr;
fstring server;
- uint32 user_rid;
+ uint32 user_rid = 0;
if ((argc < 2) || (argc > 4)) {
printf("Usage: %s rid [info level] [access mask] \n", argv[0]);
return NT_STATUS_OK;
}
- user_rid = strtoul(argv[1], NULL, 10);
+ sscanf(argv[1], "%i", &user_rid);
if (argc > 2)
sscanf(argv[2], "%i", &info_level);
@@ -820,7 +787,7 @@ static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
goto done;
/* Make sure to wait for our DC's reply */
- old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */
+ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
result = rpccli_samr_query_groupmem(cli, mem_ctx, &group_pol,
&num_members, &group_rids,
diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c
index ed5653eb704..6e6d7986f5a 100644
--- a/source/rpcclient/cmd_spoolss.c
+++ b/source/rpcclient/cmd_spoolss.c
@@ -2012,7 +2012,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", timestring(True));
+ printf("%s\n", current_timestring(True));
printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id);
/* Set the printer data */
@@ -2024,13 +2024,15 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
UNISTR2 data;
init_unistr2(&data, argv[4], UNI_STR_TERMINATE);
value.size = data.uni_str_len * 2;
- value.data_p = TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
+ value.data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, data.buffer,
+ value.size);
break;
}
case REG_DWORD: {
uint32 data = strtoul(argv[4], NULL, 10);
value.size = sizeof(data);
- value.data_p = TALLOC_MEMDUP(mem_ctx, &data, sizeof(data));
+ value.data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, &data,
+ sizeof(data));
break;
}
case REG_BINARY: {
@@ -2088,7 +2090,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", timestring(True));
+ printf("%s\n", current_timestring(True));
printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id);
done:
diff --git a/source/smbd/change_trust_pw.c b/source/smbd/change_trust_pw.c
index 738d12151db..31f03cc7fad 100644
--- a/source/smbd/change_trust_pw.c
+++ b/source/smbd/change_trust_pw.c
@@ -79,17 +79,19 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
DEBUG(0,("modify_trust_password: unable to open the domain client session to machine %s. Error was : %s.\n",
dc_name, nt_errstr(nt_status)));
cli_shutdown(cli);
+ cli = NULL;
goto failed;
}
nt_status = trust_pw_find_change_and_store_it(netlogon_pipe, cli->mem_ctx, domain);
cli_shutdown(cli);
+ cli = NULL;
failed:
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("%s : change_trust_account_password: Failed to change password for domain %s.\n",
- timestring(False), domain));
+ current_timestring(False), domain));
}
else
DEBUG(5,("change_trust_account_password: sucess!\n"));
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 00357c2a35e..068179cd4bb 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -3977,10 +3977,10 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
/* Ignore create time at offset pdata. */
/* access time */
- tvs.actime = interpret_long_date(pdata+8);
+ tvs.actime = convert_timespec_to_time_t(interpret_long_date(pdata+8));
- write_time = interpret_long_date(pdata+16);
- changed_time = interpret_long_date(pdata+24);
+ write_time = convert_timespec_to_time_t(interpret_long_date(pdata+16));
+ changed_time = convert_timespec_to_time_t(interpret_long_date(pdata+24));
tvs.modtime = MIN(write_time, changed_time);
@@ -4206,8 +4206,8 @@ static int call_trans2setfilepathinfo(connection_struct *conn, char *inbuf, char
#endif /* LARGE_SMB_OFF_T */
}
pdata+=24; /* ctime & st_blocks are not changed */
- tvs.actime = interpret_long_date(pdata); /* access_time */
- tvs.modtime = interpret_long_date(pdata+8); /* modification_time */
+ tvs.actime = convert_timespec_to_time_t(interpret_long_date(pdata)); /* access_time */
+ tvs.modtime = convert_timespec_to_time_t(interpret_long_date(pdata+8)); /* modification_time */
pdata+=16;
set_owner = (uid_t)IVAL(pdata,0);
pdata += 8;
@@ -4406,7 +4406,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
case SMB_FILE_RENAME_INFORMATION:
{
BOOL overwrite;
- uint32 root_fid;
+ /* uint32 root_fid; */ /* Not used */
uint32 len;
pstring newname;
pstring base_name;
@@ -4417,7 +4417,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
}
overwrite = (CVAL(pdata,0) ? True : False);
- root_fid = IVAL(pdata,4);
+ /* root_fid = IVAL(pdata,4); */
len = IVAL(pdata,8);
srvstr_get_path(inbuf, newname, &pdata[12], sizeof(newname), len, 0, &status);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source/torture/msgtest.c b/source/torture/msgtest.c
index 035214b3a96..e8db20f4a84 100644
--- a/source/torture/msgtest.c
+++ b/source/torture/msgtest.c
@@ -26,23 +26,6 @@
static int pong_count;
-/* samba4 timeval functions */
-
-double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2)
-{
- return (tv2->tv_sec - tv1->tv_sec) +
- (tv2->tv_usec - tv1->tv_usec)*1.0e-6;
-}
-
-/**
- return the number of seconds elapsed since a given time
-*/
-double timeval_elapsed(const struct timeval *tv)
-{
- struct timeval tv2 = timeval_current();
- return timeval_elapsed2(tv, &tv2);
-}
-
/****************************************************************************
a useful function for testing the message system
****************************************************************************/
@@ -66,7 +49,8 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len)
message_init();
if (argc != 3) {
- fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], argv[0]);
+ fprintf(stderr, "%s: Usage - %s pid count\n", argv[0],
+ argv[0]);
exit(1);
}
@@ -114,12 +98,12 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len)
size_t timelimit = n;
size_t ping_count = 0;
- printf("Sending pings for %d seconds\n", timelimit);
- while (timeval_elapsed(&tv) < timelimit) {
+ printf("Sending pings for %d seconds\n", (int)timelimit);
+ while (timeval_elapsed(&tv) < timelimit) {
if(message_send_pid(pid_to_procid(pid), MSG_PING,
- buf, 11, False)) ping_count++;
+ buf, 11, False)) ping_count++;
if(message_send_pid(pid_to_procid(pid), MSG_PING,
- NULL, 0, False)) ping_count++;
+ NULL, 0, False)) ping_count++;
while (ping_count > pong_count + 20) {
message_dispatch();
@@ -127,18 +111,18 @@ void pong_message(int msg_type, struct process_id src, void *buf, size_t len)
}
printf("waiting for %d remaining replies (done %d)\n",
- ping_count - pong_count, pong_count);
+ (int)(ping_count - pong_count), pong_count);
while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
message_dispatch();
}
if (ping_count != pong_count) {
- fprintf(stderr, "ping test failed! received %d, sent %d\n",
- pong_count, ping_count);
+ fprintf(stderr, "ping test failed! received %d, sent "
+ "%d\n", pong_count, (int)ping_count);
}
printf("ping rate of %.0f messages/sec\n",
- (ping_count+pong_count)/timeval_elapsed(&tv));
+ (ping_count+pong_count)/timeval_elapsed(&tv));
}
return (0);
diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c
index a112643d6de..a122882179f 100644
--- a/source/utils/net_rpc.c
+++ b/source/utils/net_rpc.c
@@ -462,7 +462,7 @@ NTSTATUS rpc_info_internals(const DOM_SID *domain_sid,
TALLOC_CTX *ctx = talloc_init("rpc_info_internals");
d_printf("Domain Name: %s\n", unistr2_tdup(ctx, &ctr.info.inf2.uni_domain));
d_printf("Domain SID: %s\n", sid_str);
- d_printf("Sequence number: %u\n", ctr.info.inf2.seq_num.low);
+ d_printf("Sequence number: %llu\n", (unsigned long long)ctr.info.inf2.seq_num);
d_printf("Num users: %u\n", ctr.info.inf2.num_domain_usrs);
d_printf("Num domain groups: %u\n", ctr.info.inf2.num_domain_grps);
d_printf("Num local groups: %u\n", ctr.info.inf2.num_local_grps);
diff --git a/source/utils/net_rpc_samsync.c b/source/utils/net_rpc_samsync.c
index b29acc8a106..10b9495332b 100644
--- a/source/utils/net_rpc_samsync.c
+++ b/source/utils/net_rpc_samsync.c
@@ -42,44 +42,6 @@ static void display_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *g)
d_printf("\n");
}
-static const char *display_time(NTTIME *nttime)
-{
- static fstring string;
-
- float high;
- float low;
- int sec;
- int days, hours, mins, secs;
- int offset = 1;
-
- if (nttime->high==0 && nttime->low==0)
- return "Now";
-
- if (nttime->high==0x80000000 && nttime->low==0)
- return "Never";
-
- high = 65536;
- high = high/10000;
- high = high*65536;
- high = high/1000;
- high = high * (~nttime->high);
-
- low = ~nttime->low;
- low = low/(1000*1000*10);
-
- sec=high+low;
- sec+=offset;
-
- days=sec/(60*60*24);
- hours=(sec - (days*60*60*24)) / (60*60);
- mins=(sec - (days*60*60*24) - (hours*60*60) ) / 60;
- secs=sec - (days*60*60*24) - (hours*60*60) - (mins*60);
-
- fstr_sprintf(string, "%u days, %u hours, %u minutes, %u seconds", days, hours, mins, secs);
- return (string);
-}
-
-
static void display_alias_info(uint32 rid, SAM_ALIAS_INFO *a)
{
d_printf("Alias '%s' ", unistr2_static(&a->uni_als_name));
@@ -123,11 +85,18 @@ static void display_account_info(uint32 rid, SAM_ACCOUNT_INFO *a)
pdb_encode_acct_ctrl(a->acb_info, NEW_PW_FORMAT_SPACE_PADDED_LEN));
}
+static time_t uint64s_nt_time_to_unix_abs(const uint64 *src)
+{
+ NTTIME nttime;
+ nttime = *src;
+ return nt_time_to_unix_abs(&nttime);
+}
+
static void display_domain_info(SAM_DOMAIN_INFO *a)
{
time_t u_logout;
- u_logout = nt_time_to_unix_abs((NTTIME *)&a->force_logoff);
+ u_logout = uint64s_nt_time_to_unix_abs(&a->force_logoff);
d_printf("Domain name: %s\n", unistr2_static(&a->uni_dom_name));
@@ -136,11 +105,11 @@ static void display_domain_info(SAM_DOMAIN_INFO *a)
d_printf("Force Logoff: %d\n", (int)u_logout);
- d_printf("Max Password Age: %s\n", display_time((NTTIME *)&a->max_pwd_age));
- d_printf("Min Password Age: %s\n", display_time((NTTIME *)&a->min_pwd_age));
+ d_printf("Max Password Age: %s\n", display_time(a->max_pwd_age));
+ d_printf("Min Password Age: %s\n", display_time(a->min_pwd_age));
- d_printf("Lockout Time: %s\n", display_time((NTTIME *)&a->account_lockout.lockout_duration));
- d_printf("Lockout Reset Time: %s\n", display_time((NTTIME *)&a->account_lockout.reset_count));
+ d_printf("Lockout Time: %s\n", display_time(a->account_lockout.lockout_duration));
+ d_printf("Lockout Reset Time: %s\n", display_time(a->account_lockout.reset_count));
d_printf("Bad Attempt Lockout: %d\n", a->account_lockout.bad_attempt_lockout);
d_printf("User must logon to change password: %d\n", a->logon_chgpass);
@@ -412,14 +381,14 @@ static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *d
/* Logon and password information */
if (!nt_time_is_zero(&delta->logon_time)) {
- unix_time = nt_time_to_unix(&delta->logon_time);
+ unix_time = nt_time_to_unix(delta->logon_time);
stored_time = pdb_get_logon_time(account);
if (stored_time != unix_time)
pdb_set_logon_time(account, unix_time, PDB_CHANGED);
}
if (!nt_time_is_zero(&delta->logoff_time)) {
- unix_time = nt_time_to_unix(&delta->logoff_time);
+ unix_time = nt_time_to_unix(delta->logoff_time);
stored_time = pdb_get_logoff_time(account);
if (stored_time != unix_time)
pdb_set_logoff_time(account, unix_time,PDB_CHANGED);
@@ -455,7 +424,7 @@ static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *d
pdb_set_logon_count(account, delta->logon_count, PDB_CHANGED);
if (!nt_time_is_zero(&delta->pwd_last_set_time)) {
- unix_time = nt_time_to_unix(&delta->pwd_last_set_time);
+ unix_time = nt_time_to_unix(delta->pwd_last_set_time);
stored_time = pdb_get_pass_last_set_time(account);
if (stored_time != unix_time)
pdb_set_pass_last_set_time(account, unix_time, PDB_CHANGED);
@@ -861,11 +830,11 @@ static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta)
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
pstring domname;
- u_max_age = nt_time_to_unix_abs((NTTIME *)&delta->max_pwd_age);
- u_min_age = nt_time_to_unix_abs((NTTIME *)&delta->min_pwd_age);
- u_logout = nt_time_to_unix_abs((NTTIME *)&delta->force_logoff);
- u_lockoutreset = nt_time_to_unix_abs((NTTIME *)&delta->account_lockout.reset_count);
- u_lockouttime = nt_time_to_unix_abs((NTTIME *)&delta->account_lockout.lockout_duration);
+ u_max_age = uint64s_nt_time_to_unix_abs(&delta->max_pwd_age);
+ u_min_age = uint64s_nt_time_to_unix_abs(&delta->min_pwd_age);
+ u_logout = uint64s_nt_time_to_unix_abs(&delta->force_logoff);
+ u_lockoutreset = uint64s_nt_time_to_unix_abs(&delta->account_lockout.reset_count);
+ u_lockouttime = uint64s_nt_time_to_unix_abs(&delta->account_lockout.lockout_duration);
unistr2_to_ascii(domname, &delta->uni_dom_name, sizeof(domname) - 1);
@@ -1355,6 +1324,68 @@ static NTSTATUS map_populate_groups(GROUPMAP *groupmap, ACCOUNTMAP *accountmap,
return NT_STATUS_OK;
}
+/*
+ * This is a crap routine, but I think it's the quickest way to solve the
+ * UTF8->base64 problem.
+ */
+
+static int fprintf_attr(FILE *add_fd, const char *attr_name,
+ const char *fmt, ...)
+{
+ va_list ap;
+ char *value, *p, *base64;
+ DATA_BLOB base64_blob;
+ BOOL do_base64 = False;
+ int res;
+
+ va_start(ap, fmt);
+ value = talloc_vasprintf(NULL, fmt, ap);
+ va_end(ap);
+
+ SMB_ASSERT(value != NULL);
+
+ for (p=value; *p; p++) {
+ if (*p & 0x80) {
+ do_base64 = True;
+ break;
+ }
+ }
+
+ if (!do_base64) {
+ BOOL only_whitespace = True;
+ for (p=value; *p; p++) {
+ /*
+ * I know that this not multibyte safe, but we break
+ * on the first non-whitespace character anyway.
+ */
+ if (!isspace(*p)) {
+ only_whitespace = False;
+ break;
+ }
+ }
+ if (only_whitespace) {
+ do_base64 = True;
+ }
+ }
+
+ if (!do_base64) {
+ res = fprintf(add_fd, "%s: %s\n", attr_name, value);
+ TALLOC_FREE(value);
+ return res;
+ }
+
+ base64_blob.data = (unsigned char *)value;
+ base64_blob.length = strlen(value);
+
+ base64 = base64_encode_data_blob(base64_blob);
+ SMB_ASSERT(base64 != NULL);
+
+ res = fprintf(add_fd, "%s:: %s\n", attr_name, base64);
+ TALLOC_FREE(value);
+ SAFE_FREE(base64);
+ return res;
+}
+
static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupmap,
FILE *add_fd, fstring sid, char *suffix)
{
@@ -1397,15 +1428,15 @@ static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma
/* Write the data to the temporary add ldif file */
fprintf(add_fd, "# %s, %s, %s\n", groupname, group_attr,
suffix);
- fprintf(add_fd, "dn: cn=%s,ou=%s,%s\n", groupname, group_attr,
- suffix);
+ fprintf_attr(add_fd, "dn", "cn=%s,ou=%s,%s", groupname, group_attr,
+ suffix);
fprintf(add_fd, "objectClass: posixGroup\n");
fprintf(add_fd, "objectClass: sambaGroupMapping\n");
- fprintf(add_fd, "cn: %s\n", groupname);
+ fprintf_attr(add_fd, "cn", "%s", groupname);
fprintf(add_fd, "gidNumber: %d\n", ldif_gid);
fprintf(add_fd, "sambaSID: %s\n", groupmap->sambaSID);
fprintf(add_fd, "sambaGroupType: %d\n", grouptype);
- fprintf(add_fd, "displayName: %s\n", groupname);
+ fprintf_attr(add_fd, "displayName", "%s", groupname);
fprintf(add_fd, "\n");
fflush(add_fd);
@@ -1414,15 +1445,19 @@ static NTSTATUS fetch_group_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma
return NT_STATUS_OK;
}
-static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupmap,
- ACCOUNTMAP *accountmap, FILE *add_fd,
- fstring sid, char *suffix, int alloced)
+static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta,
+ GROUPMAP *groupmap,
+ ACCOUNTMAP *accountmap,
+ FILE *add_fd,
+ fstring sid, char *suffix,
+ int alloced)
{
fstring username, logonscript, homedrive, homepath = "", homedir = "";
fstring hex_nt_passwd, hex_lm_passwd;
- fstring description, fullname, sambaSID;
+ fstring description, profilepath, fullname, sambaSID;
uchar lm_passwd[16], nt_passwd[16];
char *flags, *user_rdn;
+ const char *ou;
const char* nopasswd = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
static uchar zero_buf[16];
uint32 rid = 0, group_rid = 0, gidNumber = 0;
@@ -1450,27 +1485,36 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *group
} else {
pstr_sprintf(homedir, "/nobodyshomedir");
}
- }
+ ou = lp_ldap_user_suffix();
+ } else {
+ ou = lp_ldap_machine_suffix();
+ pstr_sprintf(homedir, "/machinehomedir");
+ }
/* Get the logon script */
unistr2_to_ascii(logonscript, &(delta->account_info.uni_logon_script),
- sizeof(logonscript)-1);
+ sizeof(logonscript)-1);
/* Get the home drive */
unistr2_to_ascii(homedrive, &(delta->account_info.uni_dir_drive),
- sizeof(homedrive)-1);
+ sizeof(homedrive)-1);
+
+ /* Get the home path */
+ unistr2_to_ascii(homepath, &(delta->account_info.uni_home_dir),
+ sizeof(homepath)-1);
/* Get the description */
unistr2_to_ascii(description, &(delta->account_info.uni_acct_desc),
sizeof(description)-1);
- if (!*description) {
- pstr_sprintf(description, "System User");
- }
/* Get the display name */
unistr2_to_ascii(fullname, &(delta->account_info.uni_full_name),
sizeof(fullname)-1);
+ /* Get the profile path */
+ unistr2_to_ascii(profilepath, &(delta->account_info.uni_profile),
+ sizeof(profilepath)-1);
+
/* Get lm and nt password data */
if (memcmp(delta->account_info.pass.buf_lm_pwd, zero_buf, 16) != 0) {
sam_pwd_hash(delta->account_info.user_rid,
@@ -1484,13 +1528,13 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *group
if (memcmp(delta->account_info.pass.buf_nt_pwd, zero_buf, 16) != 0) {
sam_pwd_hash(delta->account_info.user_rid,
delta->account_info.pass.buf_nt_pwd,
- nt_passwd, 0);
+ nt_passwd, 0);
pdb_sethexpwd(hex_nt_passwd, nt_passwd,
delta->account_info.acb_info);
} else {
pdb_sethexpwd(hex_nt_passwd, NULL, 0);
}
- unix_time = nt_time_to_unix(&(delta->account_info.pwd_last_set_time));
+ unix_time = nt_time_to_unix(delta->account_info.pwd_last_set_time);
/* The nobody user is entered by populate_ldap_for_ldif */
if (strcmp(username, "nobody") == 0) {
@@ -1519,36 +1563,40 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *group
/* Add the user to the temporary add ldif file */
/* this isn't quite right...we can't assume there's just OU=. jmcd */
- user_rdn = sstring_sub(lp_ldap_user_suffix(), '=', ',');
+ user_rdn = sstring_sub(ou, '=', ',');
fprintf(add_fd, "# %s, %s, %s\n", username, user_rdn, suffix);
- fprintf(add_fd, "dn: uid=%s,ou=%s,%s\n", username, user_rdn, suffix);
+ fprintf_attr(add_fd, "dn", "uid=%s,ou=%s,%s", username, user_rdn,
+ suffix);
SAFE_FREE(user_rdn);
fprintf(add_fd, "ObjectClass: top\n");
fprintf(add_fd, "objectClass: inetOrgPerson\n");
fprintf(add_fd, "objectClass: posixAccount\n");
fprintf(add_fd, "objectClass: shadowAccount\n");
fprintf(add_fd, "objectClass: sambaSamAccount\n");
- fprintf(add_fd, "cn: %s\n", username);
- fprintf(add_fd, "sn: %s\n", username);
- fprintf(add_fd, "uid: %s\n", username);
+ fprintf_attr(add_fd, "cn", "%s", username);
+ fprintf_attr(add_fd, "sn", "%s", username);
+ fprintf_attr(add_fd, "uid", "%s", username);
fprintf(add_fd, "uidNumber: %d\n", ldif_uid);
fprintf(add_fd, "gidNumber: %d\n", gidNumber);
- fprintf(add_fd, "homeDirectory: %s\n", homedir);
+ fprintf_attr(add_fd, "homeDirectory", "%s", homedir);
if (*homepath)
- fprintf(add_fd, "SambaHomePath: %s\n", homepath);
+ fprintf_attr(add_fd, "sambaHomePath", "%s", homepath);
if (*homedrive)
- fprintf(add_fd, "SambaHomeDrive: %s\n", homedrive);
+ fprintf_attr(add_fd, "sambaHomeDrive", "%s", homedrive);
if (*logonscript)
- fprintf(add_fd, "SambaLogonScript: %s\n", logonscript);
+ fprintf_attr(add_fd, "sambaLogonScript", "%s", logonscript);
fprintf(add_fd, "loginShell: %s\n",
((delta->account_info.acb_info & ACB_NORMAL) ?
"/bin/bash" : "/bin/false"));
fprintf(add_fd, "gecos: System User\n");
- fprintf(add_fd, "description: %s\n", description);
+ if (*description)
+ fprintf_attr(add_fd, "description", "%s", description);
fprintf(add_fd, "sambaSID: %s-%d\n", sid, rid);
fprintf(add_fd, "sambaPrimaryGroupSID: %s\n", sambaSID);
if(*fullname)
- fprintf(add_fd, "displayName: %s\n", fullname);
+ fprintf_attr(add_fd, "displayName", "%s", fullname);
+ if(*profilepath)
+ fprintf_attr(add_fd, "sambaProfilePath", "%s", profilepath);
if (strcmp(nopasswd, hex_lm_passwd) != 0)
fprintf(add_fd, "sambaLMPassword: %s\n", hex_lm_passwd);
if (strcmp(nopasswd, hex_nt_passwd) != 0)
@@ -1562,9 +1610,11 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *group
return NT_STATUS_OK;
}
-static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupmap,
- FILE *add_fd, fstring sid, char *suffix,
- unsigned db_type)
+static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta,
+ GROUPMAP *groupmap,
+ FILE *add_fd, fstring sid,
+ char *suffix,
+ unsigned db_type)
{
fstring aliasname, description;
uint32 grouptype = 0, g_rid = 0;
@@ -1580,21 +1630,21 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma
/* Set up the group type */
switch (db_type) {
- case SAM_DATABASE_DOMAIN:
- grouptype = 4;
- break;
- case SAM_DATABASE_BUILTIN:
- grouptype = 5;
- break;
- default:
- grouptype = 4;
- break;
+ case SAM_DATABASE_DOMAIN:
+ grouptype = 4;
+ break;
+ case SAM_DATABASE_BUILTIN:
+ grouptype = 5;
+ break;
+ default:
+ grouptype = 4;
+ break;
}
/*
- These groups are entered by populate_ldap_for_ldif
- Note that populate creates a group called Relicators,
- but NT returns a group called Replicator
+ These groups are entered by populate_ldap_for_ldif
+ Note that populate creates a group called Relicators,
+ but NT returns a group called Replicator
*/
if (strcmp(aliasname, "Domain Admins") == 0 ||
strcmp(aliasname, "Domain Users") == 0 ||
@@ -1619,16 +1669,17 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma
/* Write the data to the temporary add ldif file */
fprintf(add_fd, "# %s, %s, %s\n", aliasname, group_attr,
suffix);
- fprintf(add_fd, "dn: cn=%s,ou=%s,%s\n", aliasname, group_attr,
- suffix);
+ fprintf_attr(add_fd, "dn", "cn=%s,ou=%s,%s", aliasname, group_attr,
+ suffix);
fprintf(add_fd, "objectClass: posixGroup\n");
fprintf(add_fd, "objectClass: sambaGroupMapping\n");
fprintf(add_fd, "cn: %s\n", aliasname);
fprintf(add_fd, "gidNumber: %d\n", ldif_gid);
fprintf(add_fd, "sambaSID: %s\n", groupmap->sambaSID);
fprintf(add_fd, "sambaGroupType: %d\n", grouptype);
- fprintf(add_fd, "displayName: %s\n", aliasname);
- fprintf(add_fd, "description: %s\n", description);
+ fprintf_attr(add_fd, "displayName", "%s", aliasname);
+ if (description[0])
+ fprintf_attr(add_fd, "description", "%s", description);
fprintf(add_fd, "\n");
fflush(add_fd);
@@ -1637,9 +1688,11 @@ static NTSTATUS fetch_alias_info_to_ldif(SAM_DELTA_CTR *delta, GROUPMAP *groupma
return NT_STATUS_OK;
}
-static NTSTATUS fetch_groupmem_info_to_ldif(SAM_DELTA_CTR *delta, SAM_DELTA_HDR *hdr_delta,
- GROUPMAP *groupmap, ACCOUNTMAP *accountmap,
- FILE *mod_fd, int alloced)
+static NTSTATUS fetch_groupmem_info_to_ldif(SAM_DELTA_CTR *delta,
+ SAM_DELTA_HDR *hdr_delta,
+ GROUPMAP *groupmap,
+ ACCOUNTMAP *accountmap,
+ FILE *mod_fd, int alloced)
{
fstring group_dn;
uint32 group_rid = 0, rid = 0;
@@ -1666,7 +1719,8 @@ static NTSTATUS fetch_groupmem_info_to_ldif(SAM_DELTA_CTR *delta, SAM_DELTA_HDR
if (accountmap[k].rid == rid) break;
}
if (k == alloced){
- DEBUG(1, ("Could not find rid %d in accountmap array\n", rid));
+ DEBUG(1, ("Could not find rid %d in "
+ "accountmap array\n", rid));
return NT_STATUS_UNSUCCESSFUL;
}
fprintf(mod_fd, "memberUid: %s\n", accountmap[k].cn);
@@ -1680,9 +1734,9 @@ static NTSTATUS fetch_groupmem_info_to_ldif(SAM_DELTA_CTR *delta, SAM_DELTA_HDR
}
static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
- uint32 db_type,
- DOM_SID dom_sid,
- const char *user_file)
+ uint32 db_type,
+ DOM_SID dom_sid,
+ const char *user_file)
{
char *suffix;
const char *builtin_sid = "S-1-5-32";
@@ -1780,7 +1834,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
/* Initial database population */
populate_ldap_for_ldif(sid, suffix, builtin_sid, add_file);
map_populate_groups(groupmap, accountmap, sid, suffix,
- builtin_sid);
+ builtin_sid);
/* Don't do this again */
init_ldap = 0;
@@ -1788,27 +1842,27 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
/* Announce what we are doing */
switch( db_type ) {
- case SAM_DATABASE_DOMAIN:
- d_fprintf(stderr, "Fetching DOMAIN database\n");
- break;
- case SAM_DATABASE_BUILTIN:
- d_fprintf(stderr, "Fetching BUILTIN database\n");
- break;
- case SAM_DATABASE_PRIVS:
- d_fprintf(stderr, "Fetching PRIVS databases\n");
- break;
- default:
- d_fprintf(stderr,
- "Fetching unknown database type %u\n",
- db_type );
- break;
+ case SAM_DATABASE_DOMAIN:
+ d_fprintf(stderr, "Fetching DOMAIN database\n");
+ break;
+ case SAM_DATABASE_BUILTIN:
+ d_fprintf(stderr, "Fetching BUILTIN database\n");
+ break;
+ case SAM_DATABASE_PRIVS:
+ d_fprintf(stderr, "Fetching PRIVS databases\n");
+ break;
+ default:
+ d_fprintf(stderr,
+ "Fetching unknown database type %u\n",
+ db_type );
+ break;
}
do {
result = rpccli_netlogon_sam_sync(pipe_hnd, mem_ctx,
- db_type, sync_context,
- &num_deltas, &hdr_deltas,
- &deltas);
+ db_type, sync_context,
+ &num_deltas, &hdr_deltas,
+ &deltas);
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
ret = NT_STATUS_OK;
@@ -1817,9 +1871,9 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
/* Re-allocate memory for groupmap and accountmap arrays */
groupmap = SMB_REALLOC_ARRAY(groupmap, GROUPMAP,
- num_deltas+num_alloced);
+ num_deltas+num_alloced);
accountmap = SMB_REALLOC_ARRAY(accountmap, ACCOUNTMAP,
- num_deltas+num_alloced);
+ num_deltas+num_alloced);
if (groupmap == NULL || accountmap == NULL) {
DEBUG(1,("GROUPMAP malloc failed\n"));
ret = NT_STATUS_NO_MEMORY;
@@ -1838,72 +1892,73 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
/* Loop through the deltas */
for (k=0; k<num_deltas; k++) {
switch(hdr_deltas[k].type) {
- case SAM_DELTA_DOMAIN_INFO:
- /* Is this case needed? */
- unistr2_to_ascii(domainname,
- &deltas[k].domain_info.uni_dom_name,
- sizeof(domainname)-1);
- break;
-
- case SAM_DELTA_GROUP_INFO:
- fetch_group_info_to_ldif(
- &deltas[k], &groupmap[g_index],
- add_file, sid, suffix);
- g_index++;
- break;
-
- case SAM_DELTA_ACCOUNT_INFO:
- fetch_account_info_to_ldif(
- &deltas[k], groupmap,
- &accountmap[a_index], add_file,
- sid, suffix, num_alloced);
- a_index++;
- break;
-
- case SAM_DELTA_ALIAS_INFO:
- fetch_alias_info_to_ldif(
- &deltas[k], &groupmap[g_index],
- add_file, sid, suffix, db_type);
- g_index++;
- break;
-
- case SAM_DELTA_GROUP_MEM:
- fetch_groupmem_info_to_ldif(
- &deltas[k], &hdr_deltas[k],
- groupmap, accountmap,
- mod_file, num_alloced);
- break;
-
- case SAM_DELTA_ALIAS_MEM:
- break;
- case SAM_DELTA_POLICY_INFO:
- break;
- case SAM_DELTA_PRIVS_INFO:
- break;
- case SAM_DELTA_TRUST_DOMS:
- /* Implemented but broken */
- break;
- case SAM_DELTA_SECRET_INFO:
- /* Implemented but broken */
- break;
- case SAM_DELTA_RENAME_GROUP:
- /* Not yet implemented */
- break;
- case SAM_DELTA_RENAME_USER:
- /* Not yet implemented */
- break;
- case SAM_DELTA_RENAME_ALIAS:
- /* Not yet implemented */
- break;
- case SAM_DELTA_DELETE_GROUP:
- /* Not yet implemented */
- break;
- case SAM_DELTA_DELETE_USER:
- /* Not yet implemented */
- break;
- case SAM_DELTA_MODIFIED_COUNT:
- break;
- default:
+ case SAM_DELTA_DOMAIN_INFO:
+ /* Is this case needed? */
+ unistr2_to_ascii(
+ domainname,
+ &deltas[k].domain_info.uni_dom_name,
+ sizeof(domainname)-1);
+ break;
+
+ case SAM_DELTA_GROUP_INFO:
+ fetch_group_info_to_ldif(
+ &deltas[k], &groupmap[g_index],
+ add_file, sid, suffix);
+ g_index++;
+ break;
+
+ case SAM_DELTA_ACCOUNT_INFO:
+ fetch_account_info_to_ldif(
+ &deltas[k], groupmap,
+ &accountmap[a_index], add_file,
+ sid, suffix, num_alloced);
+ a_index++;
+ break;
+
+ case SAM_DELTA_ALIAS_INFO:
+ fetch_alias_info_to_ldif(
+ &deltas[k], &groupmap[g_index],
+ add_file, sid, suffix, db_type);
+ g_index++;
+ break;
+
+ case SAM_DELTA_GROUP_MEM:
+ fetch_groupmem_info_to_ldif(
+ &deltas[k], &hdr_deltas[k],
+ groupmap, accountmap,
+ mod_file, num_alloced);
+ break;
+
+ case SAM_DELTA_ALIAS_MEM:
+ break;
+ case SAM_DELTA_POLICY_INFO:
+ break;
+ case SAM_DELTA_PRIVS_INFO:
+ break;
+ case SAM_DELTA_TRUST_DOMS:
+ /* Implemented but broken */
+ break;
+ case SAM_DELTA_SECRET_INFO:
+ /* Implemented but broken */
+ break;
+ case SAM_DELTA_RENAME_GROUP:
+ /* Not yet implemented */
+ break;
+ case SAM_DELTA_RENAME_USER:
+ /* Not yet implemented */
+ break;
+ case SAM_DELTA_RENAME_ALIAS:
+ /* Not yet implemented */
+ break;
+ case SAM_DELTA_DELETE_GROUP:
+ /* Not yet implemented */
+ break;
+ case SAM_DELTA_DELETE_USER:
+ /* Not yet implemented */
+ break;
+ case SAM_DELTA_MODIFIED_COUNT:
+ break;
+ default:
break;
} /* end of switch */
} /* end of for loop */
@@ -1947,13 +2002,14 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
transfer_file(fileno(mod_file), fileno(ldif_file), (size_t) -1);
- done:
+ done:
/* Close and delete the ldif files */
if (add_file) {
fclose(add_file);
}
- if ((add_name != NULL) && strcmp(add_name, add_template) && (unlink(add_name))) {
+ if ((add_name != NULL) &&
+ strcmp(add_name, add_template) && (unlink(add_name))) {
DEBUG(1,("unlink(%s) failed, error was (%s)\n",
add_name, strerror(errno)));
}
@@ -1962,7 +2018,8 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
fclose(mod_file);
}
- if ((mod_name != NULL) && strcmp(mod_name, mod_template) && (unlink(mod_name))) {
+ if ((mod_name != NULL) &&
+ strcmp(mod_name, mod_template) && (unlink(mod_name))) {
DEBUG(1,("unlink(%s) failed, error was (%s)\n",
mod_name, strerror(errno)));
}
@@ -1989,10 +2046,11 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
int rpc_vampire_usage(int argc, const char **argv)
{
- d_printf("net rpc vampire [ldif [<ldif-filename>] [options]\n"\
- "\t to pull accounts from a remote PDC where we are a BDC\n"\
- "\t\t no args puts accounts in local passdb from smb.conf\n"\
- "\t\t ldif - put accounts in ldif format (file defaults to /tmp/tmp.ldif\n");
+ d_printf("net rpc vampire [ldif [<ldif-filename>] [options]\n"
+ "\t to pull accounts from a remote PDC where we are a BDC\n"
+ "\t\t no args puts accounts in local passdb from smb.conf\n"
+ "\t\t ldif - put accounts in ldif format (file defaults to "
+ "/tmp/tmp.ldif\n");
net_common_flags_usage(argc, argv);
return -1;
@@ -2016,47 +2074,52 @@ NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid,
d_printf("Cannot import users from %s at this time, "
"as the current domain:\n\t%s: %s\nconflicts "
"with the remote domain\n\t%s: %s\n"
- "Perhaps you need to set: \n\n\tsecurity=user\n\tworkgroup=%s\n\n in your smb.conf?\n",
+ "Perhaps you need to set: \n\n\tsecurity=user\n\t"
+ "workgroup=%s\n\n in your smb.conf?\n",
domain_name,
- get_global_sam_name(), sid_to_string(my_dom_sid_str,
- get_global_sam_sid()),
- domain_name, sid_to_string(rem_dom_sid_str, domain_sid),
+ get_global_sam_name(),
+ sid_to_string(my_dom_sid_str,
+ get_global_sam_sid()),
+ domain_name, sid_to_string(rem_dom_sid_str,
+ domain_sid),
domain_name);
return NT_STATUS_UNSUCCESSFUL;
}
if (argc >= 1 && (strcmp(argv[0], "ldif") == 0)) {
result = fetch_database_to_ldif(pipe_hnd, SAM_DATABASE_DOMAIN,
- *domain_sid, argv[1]);
+ *domain_sid, argv[1]);
} else {
- result = fetch_database(pipe_hnd, SAM_DATABASE_DOMAIN, *domain_sid);
+ result = fetch_database(pipe_hnd, SAM_DATABASE_DOMAIN,
+ *domain_sid);
}
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Failed to fetch domain database: %s\n",
- nt_errstr(result));
+ nt_errstr(result));
if (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED))
- d_fprintf(stderr, "Perhaps %s is a Windows 2000 native "
- "mode domain?\n", domain_name);
+ d_fprintf(stderr, "Perhaps %s is a Windows 2000 "
+ "native mode domain?\n", domain_name);
goto fail;
}
if (argc >= 1 && (strcmp(argv[0], "ldif") == 0)) {
- result = fetch_database_to_ldif(pipe_hnd, SAM_DATABASE_BUILTIN,
- global_sid_Builtin, argv[1]);
+ result = fetch_database_to_ldif(pipe_hnd, SAM_DATABASE_BUILTIN,
+ global_sid_Builtin, argv[1]);
} else {
- result = fetch_database(pipe_hnd, SAM_DATABASE_BUILTIN, global_sid_Builtin);
+ result = fetch_database(pipe_hnd, SAM_DATABASE_BUILTIN,
+ global_sid_Builtin);
}
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Failed to fetch builtin database: %s\n",
- nt_errstr(result));
+ nt_errstr(result));
goto fail;
}
/* Currently we crash on PRIVS somewhere in unmarshalling */
/* Dump_database(cli, SAM_DATABASE_PRIVS, &ret_creds); */
-fail:
+ fail:
return result;
}
diff --git a/source/utils/netlookup.c b/source/utils/netlookup.c
index 3c33e65391a..33b6c4bb257 100644
--- a/source/utils/netlookup.c
+++ b/source/utils/netlookup.c
@@ -41,7 +41,7 @@ static struct con_struct *cs;
Close connection on context destruction.
********************************************************/
-static int cs_destructor(void *p)
+static int cs_destructor(struct con_struct *p)
{
if (cs->cli) {
cli_shutdown(cs->cli);
@@ -157,7 +157,7 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx,
struct con_struct *csp = NULL;
char **domains;
char **names;
- uint32 *types;
+ enum lsa_SidType *types;
*ppdomain = NULL;
*ppname = NULL;
@@ -195,7 +195,7 @@ NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SI
NTSTATUS nt_status;
struct con_struct *csp = NULL;
DOM_SID *sids = NULL;
- uint32 *types = NULL;
+ enum lsa_SidType *types = NULL;
csp = create_cs(ctx, &nt_status);
if (csp == NULL) {
diff --git a/source/web/swat.c b/source/web/swat.c
index d1fd0b4f9bc..d43f8941bc1 100644
--- a/source/web/swat.c
+++ b/source/web/swat.c
@@ -432,7 +432,7 @@ static void write_config(FILE *f, BOOL show_defaults)
{
fprintf(f, "# Samba config file created using SWAT\n");
fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr());
- fprintf(f, "# Date: %s\n\n", timestring(False));
+ fprintf(f, "# Date: %s\n\n", current_timestring(False));
lp_dump(f, show_defaults, iNumNonAutoPrintServices);
}