]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix compat.cpp times
authorKern Sibbald <kern@sibbald.com>
Sun, 22 Feb 2004 17:41:19 +0000 (17:41 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 22 Feb 2004 17:41:19 +0000 (17:41 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1066 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/findlib/enable_priv.c
bacula/src/findlib/makepath.c
bacula/src/lib/util.c
bacula/src/version.h
bacula/src/win32/.cvsignore [new file with mode: 0644]
bacula/src/win32/compat/.cvsignore [new file with mode: 0644]
bacula/src/win32/compat/compat.cpp

index 4095ef2296175537f58e98341bc133c159721cd9..5a35d842eeb165bdcf729398b2490e739e73a275 100755 (executable)
@@ -37,7 +37,7 @@
 /*                                                            */
 /*=============================================================*/
 
-#if !defined(HAVE_CYGWIN) && !defined(WIN32)
+#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
     
 int enable_backup_privileges(JCR *jcr, int ignore_errors)
  { return 0; }
@@ -53,7 +53,7 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors)
 /*                                                            */
 /*=============================================================*/
 
-#if defined(HAVE_CYGWIN) || defined(WIN32)
+#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
 
 void win_error(JCR *jcr, char *prefix, DWORD lerror);
 
index 2932b83e4aaad665b72eb2c26c966fd7901857b2..69ef9c9e97f942989f83567131ebddc606bdadcd 100644 (file)
@@ -135,7 +135,7 @@ make_dir(JCR *jcr, const char *dir, const char *dirpath, mode_t mode, int *creat
 int
 isAbsolute(const char *path)
 {
-#if defined(HAVE_CYGWIN) || defined(WIN32)
+#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
     return path[1] == ':' || *path == '/' || *path == '\\';     /* drivespec:/blah is absolute */
 #else
     return *path == '/';
index 8f30486689ee05d9a7dec58ff1fbf0c15027a3b7..013c9102d3a6ee1e0387b031894c623969459a2b 100644 (file)
@@ -385,12 +385,15 @@ int do_shell_expansion(char *name, int name_len)
       pm_strcat(&cmd, name);
       pm_strcat(&cmd, "\"");
       Dmsg1(400, "Send: %s\n", cmd);
-      bpipe = open_bpipe(cmd, 0, "r");
-      *line = 0;
-      fgets(line, sizeof(line), bpipe->rfd);
-      strip_trailing_junk(line);
-      stat = close_bpipe(bpipe);
-      Dmsg2(400, "stat=%d got: %s\n", stat, line);
+      if ((bpipe = open_bpipe(cmd, 0, "r"))) {
+        *line = 0;
+        fgets(line, sizeof(line), bpipe->rfd);
+        strip_trailing_junk(line);
+        stat = close_bpipe(bpipe);
+         Dmsg2(400, "stat=%d got: %s\n", stat, line);
+      } else {
+        stat = 1;                    /* error */
+      }
       free_pool_memory(cmd);
       if (stat == 0) {
         bstrncpy(name, line, name_len);
@@ -416,7 +419,7 @@ void make_session_key(char *key, char *seed, int mode)
 
      s[0] = 0;
      if (seed != NULL) {
-       strcat(s, seed);
+       bstrncat(s, seed, sizeof(s));
      }
 
      /* The following creates a seed for the session key generator
@@ -426,11 +429,11 @@ void make_session_key(char *key, char *seed, int mode)
        available on your machine, replace it with something
        equivalent or, if you like, just delete it. */
 
-     sprintf(s + strlen(s), "%lu", (unsigned long) getpid());
-     sprintf(s + strlen(s), "%lu", (unsigned long) getppid());
+     sprintf(s + strlen(s), "%lu", (unsigned long)getpid());
+     sprintf(s + strlen(s), "%lu", (unsigned long)getppid());
      getcwd(s + strlen(s), 256);
-     sprintf(s + strlen(s), "%lu", (unsigned long) clock());
-     sprintf(s + strlen(s), "%lu", (unsigned long) time(NULL));
+     sprintf(s + strlen(s), "%lu", (unsigned long)clock());
+     sprintf(s + strlen(s), "%lu", (unsigned long)time(NULL));
 #ifdef Solaris
      sysinfo(SI_HW_SERIAL,s + strlen(s), 12);
 #endif
@@ -446,27 +449,27 @@ void make_session_key(char *key, char *seed, int mode)
      MD5Init(&md5c);
      MD5Update(&md5c, (unsigned char *)s, strlen(s));
      MD5Final(md5key, &md5c);
-     sprintf(s + strlen(s), "%lu", (unsigned long) ((time(NULL) + 65121) ^ 0x375F));
+     sprintf(s + strlen(s), "%lu", (unsigned long)((time(NULL) + 65121) ^ 0x375F));
      MD5Init(&md5c);
      MD5Update(&md5c, (unsigned char *)s, strlen(s));
      MD5Final(md5key1, &md5c);
 #define nextrand    (md5key[j] ^ md5key1[j])
      if (mode) {
        for (j = k = 0; j < 16; j++) {
-           unsigned char rb = nextrand;
+          unsigned char rb = nextrand;
 
 #define Rad16(x) ((x) + 'A')
-           key[k++] = Rad16((rb >> 4) & 0xF);
-           key[k++] = Rad16(rb & 0xF);
+          key[k++] = Rad16((rb >> 4) & 0xF);
+          key[k++] = Rad16(rb & 0xF);
 #undef Rad16
-           if (j & 1) {
-                 key[k++] = '-';
-           }
+          if (j & 1) {
+              key[k++] = '-';
+          }
        }
        key[--k] = 0;
      } else {
        for (j = 0; j < 16; j++) {
-           key[j] = nextrand;
+          key[j] = nextrand;
        }
      }
 }
index d63412bcd551e2e7176a7df3cc6e93ee31bba88d..55693f240227ce3bc34e78f063f12c51320b68ac 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33.4"
 #define VSTRING "1"
-#define BDATE   "18 Feb 2004"
-#define LSMDATE "18Feb04"
+#define BDATE   "22 Feb 2004"
+#define LSMDATE "22Feb04"
 
 /* Debug flags */
 #undef  DEBUG
diff --git a/bacula/src/win32/.cvsignore b/bacula/src/win32/.cvsignore
new file mode 100644 (file)
index 0000000..0a39878
--- /dev/null
@@ -0,0 +1,2 @@
+install
+install-debug
diff --git a/bacula/src/win32/compat/.cvsignore b/bacula/src/win32/compat/.cvsignore
new file mode 100644 (file)
index 0000000..0a39878
--- /dev/null
@@ -0,0 +1,2 @@
+install
+install-debug
index ebdf82ba8244aac5c48c3208f159273b445a9630..048a11a9852ccb1a5fe2263993c11971a1edda56 100644 (file)
@@ -176,15 +176,18 @@ srandom(unsigned int seed)
 // convert from Windows concept of time to Unix concept of time
 // /////////////////////////////////////////////////////////////////
 time_t
-cvt(const FILETIME &time)
+cvt_ftime_to_utime(const FILETIME &time)
 {
     uint64_t mstime = time.dwHighDateTime;
     mstime <<= 32;
     mstime |= time.dwLowDateTime;
 
-    mstime /= 10000000;         // convert to seconds.
-    mstime -= 3234336I64*3600I64; // difference between jan 1, 1601
+//  mstime /= 10000000;         // convert to seconds.
+//  mstime -= 3234336I64*3600I64; // difference between jan 1, 1601
                                   // and jan, 1 1970
+    mstime -= 116444736000000000; // convert to 1 Jan 1970
+    mstime /= 10000000;         // convert to seconds.
+
 
     return (time_t) (mstime & 0xffffffff);
 }
@@ -211,11 +214,10 @@ static int
 statDir(const char *file, struct stat *sb)
 {
     WIN32_FIND_DATA info;       // window's file info
-    sb->st_mode |= S_IFDIR;
 
-    if (file[1] == ':' && file[2] == 0)
-    {
+    if (file[1] == ':' && file[2] == 0) {
         d_msg(__FILE__, __LINE__, 99, "faking ROOT attrs(%s).\n", file);
+        sb->st_mode = S_IFDIR;
         sb->st_mode |= S_IREAD|S_IEXEC|S_IWRITE;
         time(&sb->st_ctime);
         time(&sb->st_mtime);
@@ -232,22 +234,23 @@ statDir(const char *file, struct stat *sb)
         return -1;
     }
 
-    sb->st_mode |= (S_IREAD | S_IEXEC);
-    if (!(info.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
-        sb->st_mode |= S_IWRITE;
-    
+    sb->st_mode = 0777;               /* start with everything */
+    if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+        sb->st_mode &= ~(S_IRUSR|S_IRGRP|S_IROTH);
     if (info.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
-        sb->st_mode |= S_IRGRP;
+        sb->st_mode &= ~S_IRWXO; /* remove everything for other */
     if (info.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
-        sb->st_mode |= S_IROTH;
+        sb->st_mode |= S_ISVTX; /* use sticky bit -> hidden */
+    sb->st_mode |= S_IFDIR;
+
     sb->st_size = info.nFileSizeHigh;
     sb->st_size <<= 32;
     sb->st_size |= info.nFileSizeLow;
     sb->st_blksize = 4096;
     sb->st_blocks = (uint32_t)(sb->st_size + 4095)/4096;
-    sb->st_atime = cvt(info.ftLastAccessTime);
-    sb->st_mtime = cvt(info.ftLastWriteTime);
-    sb->st_ctime = cvt(info.ftCreationTime);
+    sb->st_atime = cvt_ftime_to_utime(info.ftLastAccessTime);
+    sb->st_mtime = cvt_ftime_to_utime(info.ftLastWriteTime);
+    sb->st_ctime = cvt_ftime_to_utime(info.ftLastWriteTime);
 
     return 0;
 }
@@ -275,8 +278,6 @@ stat2(const char *file, struct stat *sb)
     if (attr & FILE_ATTRIBUTE_DIRECTORY) 
         return statDir(tmpbuf, sb);
 
-    sb->st_mode |= S_IFREG;
-    
     h = CreateFile(tmpbuf, GENERIC_READ,
                    FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
 
@@ -305,22 +306,24 @@ stat2(const char *file, struct stat *sb)
     sb->st_ino <<= 32;
     sb->st_ino |= info.nFileIndexLow;
     sb->st_nlink = (short)info.nNumberOfLinks;
-    sb->st_mode |= (S_IREAD | S_IEXEC);
-    if (!(info.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
-        sb->st_mode |= S_IWRITE;
 
+    sb->st_mode = 0777;               /* start with everything */
+    if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+        sb->st_mode &= ~(S_IRUSR|S_IRGRP|S_IROTH);
     if (info.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
-        sb->st_mode |= S_IRGRP;
+        sb->st_mode &= ~S_IRWXO; /* remove everything for other */
     if (info.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
-        sb->st_mode |= S_IROTH;
+        sb->st_mode |= S_ISVTX; /* use sticky bit -> hidden */
+    sb->st_mode |= S_IFREG;
+
     sb->st_size = info.nFileSizeHigh;
     sb->st_size <<= 32;
     sb->st_size |= info.nFileSizeLow;
     sb->st_blksize = 4096;
     sb->st_blocks = (uint32_t)(sb->st_size + 4095)/4096;
-    sb->st_atime = cvt(info.ftLastAccessTime);
-    sb->st_mtime = cvt(info.ftLastWriteTime);
-    sb->st_ctime = cvt(info.ftCreationTime);
+    sb->st_atime = cvt_ftime_to_utime(info.ftLastAccessTime);
+    sb->st_mtime = cvt_ftime_to_utime(info.ftLastWriteTime);
+    sb->st_ctime = cvt_ftime_to_utime(info.ftLastWriteTime);
 
 error:
     CloseHandle(h);
@@ -341,28 +344,27 @@ stat(const char *file, struct stat *sb)
     if (!GetFileAttributesEx(file, GetFileExInfoStandard, &data))
         return stat2(file, sb);
 
+    sb->st_mode = 0777;               /* start with everything */
+    if (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+        sb->st_mode &= ~(S_IRUSR|S_IRGRP|S_IROTH);
+    if (data.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
+        sb->st_mode &= ~S_IRWXO; /* remove everything for other */
+    if (data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
+        sb->st_mode |= S_ISVTX; /* use sticky bit -> hidden */
     if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
         sb->st_mode |= S_IFDIR;
     else
         sb->st_mode |= S_IFREG;
 
     sb->st_nlink = 1;
-    sb->st_mode |= (S_IREAD | S_IEXEC);
-    if (!(data.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
-        sb->st_mode |= S_IWRITE;
-
-    if (data.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
-        sb->st_mode |= S_IRGRP;
-    if (data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
-        sb->st_mode |= S_IROTH;
     sb->st_size = data.nFileSizeHigh;
     sb->st_size <<= 32;
     sb->st_size |= data.nFileSizeLow;
     sb->st_blksize = 4096;
     sb->st_blocks = (uint32_t)(sb->st_size + 4095)/4096;
-    sb->st_atime = cvt(data.ftLastAccessTime);
-    sb->st_mtime = cvt(data.ftLastWriteTime);
-    sb->st_ctime = cvt(data.ftCreationTime);
+    sb->st_atime = cvt_ftime_to_utime(data.ftLastAccessTime);
+    sb->st_mtime = cvt_ftime_to_utime(data.ftLastWriteTime);
+    sb->st_ctime = cvt_ftime_to_utime(data.ftLastWriteTime);
     return 0;
 }