Bug 1290 - modtime set to zero when sent timestamp is "no change"
modtime set to zero when sent timestamp is "no change"
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: File Services
3.0.2a
All HP-UX
: P3 normal
: none
Assigned To: Jeremy Allison
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-04-23 14:08 UTC by Terence H Dineen
Modified: 2005-08-24 10:19 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Terence H Dineen 2004-04-23 14:08:11 UTC
When 3.0.2a smbd receives Trans2 SetPathInformation command with the
InformationLevel 1004 (== 1000 + FileBasicInformation), it
misinterprets the timestamp of 0xffffffffffffffff (no change).

Here is the relevant data structure and the smbd.log.

typedef struct _FILE_BASIC_INFORMATION {
    LARGE_INTEGER CreationTime;
    LARGE_INTEGER LastAccessTime;
    LARGE_INTEGER LastWriteTime;
    LARGE_INTEGER ChangeTime;
    ULONG FileAttributes;
} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;

[2004/04/20 19:01:34, 10] lib/util_sock.c:(463)
  got smb length of 116
[2004/04/20 19:01:34, 6] smbd/process.c:(889)
  got message type 0x0 of len 0x74
[2004/04/20 19:01:34, 3] smbd/process.c:(890)
  Transaction 1364 of length 120
[2004/04/20 19:01:34, 5] lib/util.c:(456)
[2004/04/20 19:01:34, 5] lib/util.c:(459)
  size=116
  smb_com=0x32
  smb_rcls=0
  smb_reh=0
  smb_err=0
  smb_flg=24
  smb_flg2=51207
  smb_tid=1
  smb_pid=4028
  smb_uid=100
  smb_mid=64705
  smt_wct=15
  smb_vwv[ 0]=    6 (0x6)
  smb_vwv[ 1]=   40 (0x28)
  smb_vwv[ 2]=    2 (0x2)
  smb_vwv[ 3]=    0 (0x0)
  smb_vwv[ 4]=    0 (0x0)
  smb_vwv[ 5]=    0 (0x0)
  smb_vwv[ 6]=    0 (0x0)
  smb_vwv[ 7]=    0 (0x0)
  smb_vwv[ 8]=    0 (0x0)
  smb_vwv[ 9]=    6 (0x6)
  smb_vwv[10]=   68 (0x44)
  smb_vwv[11]=   40 (0x28)
  smb_vwv[12]=   76 (0x4C)
  smb_vwv[13]=    1 (0x1)
  smb_vwv[14]=    8 (0x8)
  smb_bcc=51
[2004/04/20 19:01:34, 10] lib/util.c:(1830)
  [000] 00 31 00 C3 11 EC 03 00  00 00 00 FF FF FF FF FF  .1...... ........
  [010] FF FF FF FF FF FF FF FF  FF FF FF FF FF FF FF FF  ........ ........
  [020] FF FF FF FF FF FF FF FF  FF FF FF 00 00 00 00 00  ........ ........
  [030] 00 00 00                                          ... 
[2004/04/20 19:01:34, 3] smbd/process.c:(685)
  switch message SMBtrans2 (pid 24663)
[2004/04/20 19:01:34, 4] smbd/uid.c:(122)
  change_to_user: Skipping user change - already user
[2004/04/20 19:01:34, 3] smbd/trans2.c:(2564)
  call_trans2setfilepathinfo(8)
tmp/qhpx200_vob_5934.vbs_1/s/sdft/2a/c/0-ff93e69b0d224237b71c3b9bcb3dd8d2-3k
(fnum 4547) info_level=1004 totdata=40
[2004/04/20 19:01:34, 8] smbd/dosmode.c:(122)
  dos_mode:
tmp/qhpx200_vob_5934.vbs_1/s/sdft/2a/c/0-ff93e69b0d224237b71c3b9bcb3dd8d2-3k
[2004/04/20 19:01:34, 8] lib/util.c:(1474)
  is_in_path:
tmp/qhpx200_vob_5934.vbs_1/s/sdft/2a/c/0-ff93e69b0d224237b71c3b9bcb3dd8d2-3k
[2004/04/20 19:01:34, 8] lib/util.c:(1478)
  is_in_path: no name list.
[2004/04/20 19:01:34, 8] smbd/dosmode.c:(170)
  dos_mode returning r
[2004/04/20 19:01:34, 6] smbd/trans2.c:(3045)
  actime: Tue Apr 20 19:01:02 2004
   modtime: Wed Dec 31 19:00:00 1969
   size: 267 dosmode: 0
[2004/04/20 19:01:34, 9] smbd/trans2.c:(177)
  t2_rep: params_sent_thistime = 2, data_sent_thistime = 0, useable_space = 131012
[2004/04/20 19:01:34, 9] smbd/trans2.c:(179)
  t2_rep: params_to_send = 2, data_to_send = 0, paramsize = 2, datasize = 0
[2004/04/20 19:01:34, 6] lib/util_sock.c:(407)
  write_socket(5,62)
[2004/04/20 19:01:34, 6] lib/util_sock.c:(410)
  write_socket(5,62) wrote 62

smbd received:

 CreationTime:   0xffffffffffffffff
 LastAccessTime: 0xffffffffffffffff
 LastWriteTime:  0xffffffffffffffff
 ChangeTime:     0xffffffffffffffff
 FileAttributes  0x00000000

which basically means to clear all file attributes without changing
any time stamps. However, because of the following codes, it sets the
modtime to 0. I.e., interpret_long_date() returns 0 for 0xffffffffffffffff.

smbd/trans2.c line# 2630

		case SMB_FILE_BASIC_INFORMATION:
		{
			/* Patch to do this correctly from Paul Eggert <eggert@twinsun.com>. */
			time_t write_time;
			time_t changed_time;

			if (total_data < 36)
				return(ERROR_DOS(ERRDOS,ERRinvalidparam));

			/* Ignore create time at offset pdata. */

			/* access time */
			tvs.actime = interpret_long_date(pdata+8);

			write_time = interpret_long_date(pdata+16);
			changed_time = interpret_long_date(pdata+24);

			tvs.modtime = MIN(write_time, changed_time);

			if (write_time > tvs.modtime && write_time != 0xffffffff) {
				tvs.modtime = write_time;
			}
			/* Prefer a defined time to an undefined one. */
			if (tvs.modtime == (time_t)0 || tvs.modtime == (time_t)-1)
				tvs.modtime = (write_time == (time_t)0 || write_time == (time_t)-1
					? changed_time : write_time);

			/* attributes */
			dosmode = IVAL(pdata,32);
			break;
		}

lib/time.c

/****************************************************************************
interprets an nt time into a unix time_t
****************************************************************************/
time_t interpret_long_date(char *p)
{
	NTTIME nt;
	nt.low = IVAL(p,0);
	nt.high = IVAL(p,4);
	return nt_time_to_unix(&nt);
}

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);
Comment 1 Gerald (Jerry) Carter 2005-02-09 06:17:01 UTC
I think this is should be fixed in 3.0.11.  Jeremy, please confirm.
Comment 2 Gerald (Jerry) Carter 2005-04-20 06:47:07 UTC
closing.
Comment 3 Gerald (Jerry) Carter 2005-08-24 10:19:47 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.