From a26a1dde3714bd7704329117a36420ebd3495b46 Mon Sep 17 00:00:00 2001 From: Graham Keeling Date: Fri, 7 Oct 2022 11:19:49 +1000 Subject: [PATCH] Experimental: Turn off windows api on remote drives Record whether the windows api was used for a file in the manifest. Allows burp to backup from a remote drive as long as it is visible. + caution: if the drive is not always available, you will back up the same files over and over again And Tweaks for release. Change-Id: I4df8e34fd3f7e185aed30baae166ee404045a669 --- CHANGELOG | 9 ++++++++ DONATIONS | 15 ++++++++++++ configure.ac | 2 +- src/attribs.c | 9 ++++++++ src/bfile.c | 25 +++++++++++++------- src/bfile.h | 20 ++++++++++++---- src/client/backup_phase1.c | 24 +++++++++++-------- src/client/backup_phase2.c | 20 ++++++++++++---- src/client/cvss.c | 46 +++++++++++++++++++++++++++---------- src/client/cvss.h | 9 ++++++-- src/client/find.c | 16 ++++++++++--- src/client/find.h | 7 +++--- src/client/restore.c | 8 +++---- src/cmd.c | 1 - src/conf.c | 2 ++ src/conf.h | 1 + src/conffile.c | 17 ++++++++++++++ src/handy.c | 2 +- src/sbuf.c | 2 ++ src/sbuf.h | 14 +++-------- src/server/restore_sbuf.c | 5 ++-- src/server/sdirs.c | 1 - src/server/sdirs.h | 1 - src/win32/compat/compat.cpp | 16 ++++++++++--- src/win32/compat/compat.h | 1 + src/win32/lib/compat32.def | 1 + src/win32/lib/compat64.def | 1 + utest/client/test_restore.c | 2 +- utest/server/test_restore.c | 2 +- utest/test_conf.c | 1 + 30 files changed, 206 insertions(+), 74 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0f018c7ac..2d90f0ef6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,12 @@ +2022-11-02 burp-3.1.4 + * Experimental: Turn off windows api on remote drives + - record whether the windows api was used for a file in the manifest + - allows burp to backup from a remote drive as long as it is visible + + caution: if the drive is not always available, you will back up + the same files over and over again + * From tassilo: + - libressl>3.5 has X509_REVOKED_get0_serialNumber + 2022-09-01 burp-3.1.2 * 904: openssl3 support - And switch to aes-cbc instead of blowfish, which is deprecated, for diff --git a/DONATIONS b/DONATIONS index ecc60bfb0..ea42dc360 100644 --- a/DONATIONS +++ b/DONATIONS @@ -7,6 +7,21 @@ me via the website contact page and we can talk about alternatives. This is the list of donations received to date. Many thanks to all of you. +Donations for 2022-11: + * £67.18 CompuMatter + * £5.00 Eckart K. + * £2.50 Aaron W. + +Donations for 2022-10: + * £117.18 CompuMatter + * £5.00 Eckart K. + * £2.50 Aaron W. + +Donations for 2022-09: + * £5.00 Eckart K. + * £5.00 Jordi S. + * £2.50 Aaron W. + Donations for 2022-08: * £85.00 CompuMatter * £5.00 Eckart K. diff --git a/configure.ac b/configure.ac index 6716be393..b57ff7204 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. dnl require a recent autoconf AC_PREREQ([2.61]) -AC_INIT([Burp],[3.1.2],[https://github.com/grke/burp/issues],[burp],[http://burp.grke.net/]) +AC_INIT([Burp],[3.1.4],[https://github.com/grke/burp/issues],[burp],[http://burp.grke.net/]) AC_CONFIG_AUX_DIR([autoconf]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/src/attribs.c b/src/attribs.c index 35f3bff91..425ae1ce5 100644 --- a/src/attribs.c +++ b/src/attribs.c @@ -110,6 +110,9 @@ int attribs_encode(struct sbuf *sb) p += to_base64(sb->encryption, p); *p++ = ' '; p += to_base64(sb->salt, p); + *p++ = ' '; + // 0 means winapi is enabled, 1 means it is disabled. + p += to_base64(!sb->use_winapi, p); *p = 0; sb->attr.len=p-sb->attr.buf; @@ -238,6 +241,12 @@ void attribs_decode(struct sbuf *sb) return; p+=eaten; sb->salt=val; + + if(!(eaten=from_base64(&val, p))) + return; + p+=eaten; + // 0 means winapi is enabled, 1 means it is disabled. + sb->use_winapi=!val; } int attribs_set_file_times(struct asfd *asfd, diff --git a/src/bfile.c b/src/bfile.c index 04da3e8db..7e67ddb24 100644 --- a/src/bfile.c +++ b/src/bfile.c @@ -501,10 +501,15 @@ static ssize_t bfile_write(struct BFILE *bfd, void *buf, size_t count) #endif -static int bfile_open_for_send(struct BFILE *bfd, struct asfd *asfd, - const char *fname, int64_t winattr, int atime, - struct cntr *cntr) -{ +static int bfile_open_for_send( + struct BFILE *bfd, + struct asfd *asfd, + const char *fname, + int use_backup_api, + int64_t winattr, + int atime, + struct cntr *cntr +) { if(bfd->mode!=BF_CLOSED) { #ifdef HAVE_WIN32 @@ -525,7 +530,7 @@ static int bfile_open_for_send(struct BFILE *bfd, struct asfd *asfd, #endif } - bfile_init(bfd, winattr, cntr); + bfile_init(bfd, use_backup_api, winattr, cntr); if(bfile_open(bfd, asfd, fname, O_RDONLY|O_BINARY #ifdef O_NOFOLLOW |O_NOFOLLOW @@ -563,15 +568,19 @@ void bfile_setup_funcs(struct BFILE *bfd) bfd->set_vss_strip=bfile_set_vss_strip; } -void bfile_init(struct BFILE *bfd, int64_t winattr, struct cntr *cntr) -{ +void bfile_init( + struct BFILE *bfd, + int use_backup_api, + int64_t winattr, + struct cntr *cntr +) { memset(bfd, 0, sizeof(struct BFILE)); bfd->mode=BF_CLOSED; bfd->winattr=winattr; bfd->cntr=cntr; if(!bfd->open) bfile_setup_funcs(bfd); #ifdef HAVE_WIN32 - bfile_set_win32_api(bfd, 1); + bfile_set_win32_api(bfd, use_backup_api); #else bfd->fd=-1; #endif diff --git a/src/bfile.h b/src/bfile.h index acc270d72..47d5dfdb3 100644 --- a/src/bfile.h +++ b/src/bfile.h @@ -29,7 +29,6 @@ struct BFILE char *path; struct cntr *cntr; // Windows VSS headers tell us how much file data to expect. - // Protocol1 only for now. size_t datalen; #ifdef HAVE_WIN32 uint8_t use_backup_api; /* set if using BackupRead/Write */ @@ -52,9 +51,15 @@ struct BFILE int (*close)(struct BFILE *bfd, struct asfd *asfd); ssize_t (*read)(struct BFILE *bfd, void *buf, size_t count); ssize_t (*write)(struct BFILE *bfd, void *buf, size_t count); - int (*open_for_send)(struct BFILE *bfd, struct asfd *asfd, - const char *fname, int64_t winattr, - int atime, struct cntr *cntr); + int (*open_for_send)( + struct BFILE *bfd, + struct asfd *asfd, + const char *fname, + int use_backup_api, + int64_t winattr, + int atime, + struct cntr *cntr + ); #ifdef HAVE_WIN32 void (*set_win32_api)(struct BFILE *bfd, int on); #endif @@ -65,7 +70,12 @@ extern struct BFILE *bfile_alloc(void); extern void bfile_free(struct BFILE **bfd); // FIX THIS: should be possible to have this as a function pointer too. // Need to sort out the bfd in sbuf. -extern void bfile_init(struct BFILE *bfd, int64_t winattr, struct cntr *cntr); +extern void bfile_init( + struct BFILE *bfd, + int use_backup_api, + int64_t winattr, + struct cntr *cntr +); extern void bfile_setup_funcs(struct BFILE *bfd); #ifdef HAVE_WIN32 diff --git a/src/client/backup_phase1.c b/src/client/backup_phase1.c index 8a9720c25..329abb7f8 100644 --- a/src/client/backup_phase1.c +++ b/src/client/backup_phase1.c @@ -48,7 +48,6 @@ static int encryption=ENCRYPTION_NONE; static enum cmd filesymbol=CMD_FILE; -static enum cmd dirsymbol=CMD_DIRECTORY; #ifdef HAVE_WIN32 static enum cmd metasymbol=CMD_VSS; static enum cmd vss_trail_symbol=CMD_VSS_T; @@ -111,12 +110,13 @@ static int do_to_server(struct asfd *asfd, int strip_vss=0; split_vss=get_int(confs[OPT_SPLIT_VSS]); strip_vss=get_int(confs[OPT_STRIP_VSS]); + sb->use_winapi=ff->use_winapi; + sb->winattr=ff->winattr; #endif struct cntr *cntr=get_cntr(confs); sb->compression=compression; sb->encryption=encryption; sb->statp=ff->statp; - sb->winattr=ff->winattr; attribs_encode(sb); #ifdef HAVE_WIN32 @@ -160,6 +160,9 @@ static int my_send_file(struct asfd *asfd, struct FF_PKT *ff, struct conf **conf { static struct sbuf *sb=NULL; struct cntr *cntr=get_cntr(confs); +#ifdef HAVE_WIN32 + enum cmd dirsymbol=filesymbol; +#endif if(!sb && !(sb=sbuf_alloc())) return -1; @@ -186,7 +189,13 @@ static int my_send_file(struct asfd *asfd, struct FF_PKT *ff, struct conf **conf case FT_DIR: case FT_REPARSE: case FT_JUNCTION: +#ifdef HAVE_WIN32 + if (!ff->use_winapi || get_int(confs[OPT_STRIP_VSS])) + dirsymbol=CMD_DIRECTORY; return to_server(asfd, confs, ff, sb, dirsymbol); +#else + return to_server(asfd, confs, ff, sb, CMD_DIRECTORY); +#endif case FT_LNK_S: return to_server(asfd, confs, ff, sb, CMD_SOFT_LINK); case FT_LNK_H: @@ -231,15 +240,12 @@ int backup_phase1_client(struct asfd *asfd, struct conf **confs) vss_trail_symbol=CMD_ENC_VSS_T; #endif } -#ifdef HAVE_WIN32 - dirsymbol=filesymbol; - if(get_int(confs[OPT_STRIP_VSS])) - dirsymbol=CMD_DIRECTORY; -#endif if(!(ff=find_files_init(my_send_file))) goto end; - for(l=get_strlist(confs[OPT_STARTDIR]); l; l=l->next) if(l->flag) - if(find_files_begin(asfd, ff, confs, l->path)) goto end; + for(l=get_strlist(confs[OPT_STARTDIR]); l; l=l->next) { + if(l->flag && find_files_begin(asfd, ff, confs, l->path)) + goto end; + } ret=0; end: cntr_print_end_phase1(get_cntr(confs)); diff --git a/src/client/backup_phase2.c b/src/client/backup_phase2.c index fb4db2392..16357bf59 100644 --- a/src/client/backup_phase2.c +++ b/src/client/backup_phase2.c @@ -11,6 +11,7 @@ #include "../log.h" #include "../md5.h" #include "../transfer.h" +#include "cvss.h" #include "extrameta.h" #include "find.h" #include "backup_phase2.h" @@ -235,6 +236,10 @@ static int deal_with_data(struct asfd *asfd, struct sbuf *sb, iobuf_init(asfd->rbuf); #ifdef HAVE_WIN32 + sb->use_winapi=get_use_winapi( + get_string(confs[OPT_REMOTE_DRIVES]), + sb->path.buf[0] + ); if(win32_lstat(sb->path.buf, &sb->statp, &sb->winattr)) #else if(lstat(sb->path.buf, &sb->statp)) @@ -259,10 +264,15 @@ static int deal_with_data(struct asfd *asfd, struct sbuf *sb, if(sb->path.cmd!=CMD_METADATA && sb->path.cmd!=CMD_ENC_METADATA) { - if(bfd->open_for_send(bfd, asfd, - sb->path.buf, sb->winattr, - get_int(confs[OPT_ATIME]), cntr)) - { + if(bfd->open_for_send( + bfd, + asfd, + sb->path.buf, + sb->use_winapi, + sb->winattr, + get_int(confs[OPT_ATIME]), + cntr + )) { forget++; goto end; } @@ -436,7 +446,7 @@ static int do_backup_phase2_client(struct asfd *asfd, if(!(bfd=bfile_alloc()) || !(sb=sbuf_alloc())) goto end; - bfile_init(bfd, 0, cntr); + bfile_init(bfd, 0, 0, cntr); if(!resume) { diff --git a/src/client/cvss.c b/src/client/cvss.c index 3af356e5e..8ea25d749 100644 --- a/src/client/cvss.c +++ b/src/client/cvss.c @@ -28,11 +28,28 @@ BOOL CtrlHandler(DWORD fdwCtrlType) } } +static int in_remote_drives(const char *remote_drives, char letter) +{ + int d; + for(d=0; remote_drives && remote_drives[d]; d++) { + if(toupper(letter)==toupper(remote_drives[d])) { + return 1; + } + } + return 0; +} + +int get_use_winapi(const char *remote_drives, char letter) +{ + return !in_remote_drives(remote_drives, letter); +} + int win32_start_vss(struct asfd *asfd, struct conf **confs) { int errors=0; struct cntr *cntr=get_cntr(confs); const char *drives_vss=get_string(confs[OPT_VSS_DRIVES]); + const char *drives_remote=get_string(confs[OPT_REMOTE_DRIVES]); if(SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) logp("Control handler registered.\n"); @@ -45,14 +62,14 @@ int win32_start_vss(struct asfd *asfd, struct conf **confs) if(g_pVSSClient->InitializeForBackup(asfd, cntr)) { - char szWinDriveLetters[27]; + char drive_letters[27]; // Tell vss which drives to snapshot. if(drives_vss) { unsigned int i=0; for(i=0; iGetDriverName(), - szWinDriveLetters); - if(!g_pVSSClient->CreateSnapshots(szWinDriveLetters)) + drive_letters); + if(!g_pVSSClient->CreateSnapshots(drive_letters)) { berrno be; berrno_init(&be); @@ -96,12 +119,11 @@ int win32_start_vss(struct asfd *asfd, struct conf **confs) else { int i; - for(i=0; i<(int)strlen(szWinDriveLetters); i++) + for(i=0; i<(int)strlen(drive_letters); i++) { - logp("VSS drive letters: %d\n", i); - if(islower(szWinDriveLetters[i])) + if(islower(drive_letters[i])) { - logw(asfd, cntr, "Generate VSS snapshot of drive \"%c:\\\" failed.\n", szWinDriveLetters[i]); + logw(asfd, cntr, "Generate VSS snapshot of drive \"%c:\\\" failed.\n", drive_letters[i]); errors++; } } diff --git a/src/client/cvss.h b/src/client/cvss.h index 6ce27cae8..f30883ca5 100644 --- a/src/client/cvss.h +++ b/src/client/cvss.h @@ -2,14 +2,19 @@ #define _CLIENT_VSS_H #if defined(WIN32_VSS) +#include "../bfile.h" extern int win32_start_vss(struct asfd *asfd, struct conf **confs); extern int win32_stop_vss(void); extern int get_vss(BFILE *bfd, char **vssdata, size_t *vlen); extern int set_vss(BFILE *bfd, const char *vssdata, size_t vlen); -#endif // WIN32_VSS +#endif #if defined(HAVE_WIN32) extern int win32_enable_backup_privileges(); -#endif /* HAVE_WIN32 */ +extern int get_use_winapi( + const char *vss_drives, + char letter +); +#endif #endif diff --git a/src/client/find.c b/src/client/find.c index bee127d9b..7a8ab51ee 100644 --- a/src/client/find.c +++ b/src/client/find.c @@ -54,6 +54,7 @@ #include "../prepend.h" #include "../regexp.h" #include "../strlist.h" +#include "cvss.h" #include "find.h" #include "find_logic.h" @@ -636,13 +637,22 @@ static int found_other(struct asfd *asfd, struct FF_PKT *ff_pkt, return my_send_file_w(asfd, ff_pkt, top_level, confs); } -static int find_files(struct asfd *asfd, struct FF_PKT *ff_pkt, struct conf **confs, - char *fname, dev_t parent_device, bool top_level) -{ +static int find_files( + struct asfd *asfd, + struct FF_PKT *ff_pkt, + struct conf **confs, + char *fname, + dev_t parent_device, + bool top_level +) { ff_pkt->fname=fname; ff_pkt->link=fname; #ifdef HAVE_WIN32 + ff_pkt->use_winapi=get_use_winapi( + get_string(confs[OPT_REMOTE_DRIVES]), + ff_pkt->fname[0] + ); if(win32_lstat(fname, &ff_pkt->statp, &ff_pkt->winattr)) #else if(lstat(fname, &ff_pkt->statp)) diff --git a/src/client/find.h b/src/client/find.h index c1c1aab8a..dd8507913 100644 --- a/src/client/find.h +++ b/src/client/find.h @@ -72,9 +72,10 @@ struct FF_PKT char *fname; /* full filename */ long flen; /* length of name component */ char *link; /* link if file linked */ - struct stat statp; /* stat packet */ - uint64_t winattr; /* windows attributes */ - int type; /* FT_ type from above */ + struct stat statp; + uint8_t type; /* FT_ type from above */ + uint8_t use_winapi; + uint64_t winattr; }; struct asfd; diff --git a/src/client/restore.c b/src/client/restore.c index 1bd647474..619bea298 100644 --- a/src/client/restore.c +++ b/src/client/restore.c @@ -163,7 +163,7 @@ enum ofr_e open_for_restore(struct asfd *asfd, sb->winattr |= FILE_ATTRIBUTE_DIRECTORY; #endif - bfile_init(bfd, sb->winattr, cntr); + bfile_init(bfd, sb->use_winapi, sb->winattr, cntr); bfd->set_attribs_on_close=1; switch(vss_restore) { @@ -181,7 +181,7 @@ enum ofr_e open_for_restore(struct asfd *asfd, break; case VSS_RESTORE_ON: #ifdef HAVE_WIN32 - bfd->set_win32_api(bfd, 1); + bfd->set_win32_api(bfd, sb->use_winapi); #endif bfd->set_vss_strip(bfd, 0); break; @@ -712,7 +712,7 @@ static int canonicalise( ret=0; end: // Cannot use free_w() because it was not allocated by alloc.c, and - // I cannot implement realpath() it in alloc.c because I cannot get + // I cannot implement realpath() in alloc.c because I cannot get // Windows code to use alloc.c. if(canonical) free(canonical); free_w(©); @@ -766,7 +766,7 @@ int do_restore_client(struct asfd *asfd, if(!(bfd=bfile_alloc())) goto error; - bfile_init(bfd, 0, cntr); + bfile_init(bfd, 0, 0, cntr); bfd->set_attribs_on_close=1; snprintf(msg, sizeof(msg), "%s%s %s:%s", diff --git a/src/cmd.c b/src/cmd.c index 56e1c55b3..ac1fbe8c7 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -68,7 +68,6 @@ char *cmd_to_text(enum cmd cmd) case CMD_BYTES_SENT: snprintf(buf, len, "Bytes sent"); break; - // Protocol1 only. case CMD_DATAPTH: snprintf(buf, len, "Path to data on the server"); break; case CMD_VSS: diff --git a/src/conf.c b/src/conf.c index 097866fe2..cf7392e56 100644 --- a/src/conf.c +++ b/src/conf.c @@ -807,6 +807,8 @@ static int reset_conf(struct conf **c, enum conf_opt o) return sc_int(c[o], 0, CONF_FLAG_INCEXC, "strip_vss"); case OPT_VSS_DRIVES: return sc_str(c[o], 0, CONF_FLAG_INCEXC, "vss_drives"); + case OPT_REMOTE_DRIVES: + return sc_str(c[o], 0, CONF_FLAG_INCEXC, "remote_drives"); case OPT_ACL: return sc_int(c[o], 1, CONF_FLAG_INCEXC, "acl"); case OPT_XATTR: diff --git a/src/conf.h b/src/conf.h index 59df18e66..e8ba20c5b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -184,6 +184,7 @@ enum conf_opt OPT_SPLIT_VSS, OPT_STRIP_VSS, OPT_VSS_DRIVES, + OPT_REMOTE_DRIVES, OPT_ACL, OPT_XATTR, OPT_ATIME, diff --git a/src/conffile.c b/src/conffile.c index 73f4f1dfc..fe9185703 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -938,6 +938,20 @@ static int finalise_fschg_dirs(struct conf **c) return 0; } +#ifdef HAVE_WIN32 +static void finalise_remote_drives(struct conf **c) { + char *drives=NULL; + if((drives=get_string(c[OPT_REMOTE_DRIVES])) && *drives) { + logp("remote drives configured: %s\n", drives); + return; + } + if((drives=get_remote_drives()) && *drives) { + logp("remote drives detected: %s\n", drives); + set_string(c[OPT_REMOTE_DRIVES], drives); + } +} +#endif + // The glob stuff should only run on the client side. static int finalise_glob(struct conf **c) { @@ -1187,6 +1201,9 @@ static int conf_finalise(struct conf **c) if(burp_mode==BURP_MODE_CLIENT && finalise_glob(c)) return -1; +#ifdef HAVE_WIN32 + finalise_remote_drives(c); +#endif if(finalise_incexc_dirs(c) || finalise_start_dirs(c) diff --git a/src/handy.c b/src/handy.c index ad765640f..9af7d5f9f 100644 --- a/src/handy.c +++ b/src/handy.c @@ -509,7 +509,7 @@ int receive_a_file(struct asfd *asfd, const char *path, struct cntr *cntr) uint64_t sentbytes=0; if(!(bfd=bfile_alloc())) goto end; - bfile_init(bfd, 0, cntr); + bfile_init(bfd, 0, 0, cntr); #ifdef HAVE_WIN32 bfd->set_win32_api(bfd, 0); #else diff --git a/src/sbuf.c b/src/sbuf.c index 7e073d13f..479085dfe 100644 --- a/src/sbuf.c +++ b/src/sbuf.c @@ -21,6 +21,7 @@ struct sbuf *sbuf_alloc() iobuf_init(&sb->link); iobuf_init(&sb->endfile); sb->compression=-1; + sb->use_winapi=1; sb->datapth.cmd=CMD_DATAPTH; return sb; @@ -35,6 +36,7 @@ void sbuf_free_content(struct sbuf *sb) memset(&(sb->statp), 0, sizeof(sb->statp)); sb->compression=-1; sb->winattr=0; + sb->use_winapi=1; sb->flags=0; memset(&sb->rsbuf, 0, sizeof(sb->rsbuf)); diff --git a/src/sbuf.h b/src/sbuf.h index 9c94370ff..8c605d381 100644 --- a/src/sbuf.h +++ b/src/sbuf.h @@ -12,18 +12,9 @@ // Bits in sbuf flags. -// Protocol2 stuff. -// Keep track of what has been sent. -#define SBUF_SENT_STAT 0x0001 -#define SBUF_SENT_PATH 0x0002 -#define SBUF_SENT_LINK 0x0004 // Keep track of what needs to be received. -#define SBUF_NEED_LINK 0x0010 -#define SBUF_NEED_DATA 0x0020 -#define SBUF_HEADER_WRITTEN_TO_MANIFEST 0x0040 -#define SBUF_END_WRITTEN_TO_MANIFEST 0x0080 +#define SBUF_NEED_LINK 0x0010 -// Protocol1 stuff. // Keep track of what needs to be sent. #define SBUF_SEND_STAT 0x0100 #define SBUF_SEND_PATH 0x0200 @@ -48,9 +39,10 @@ struct sbuf struct iobuf endfile; // End file marker. struct stat statp; - uint64_t winattr; int32_t compression; int32_t encryption; + uint64_t winattr; + int8_t use_winapi; uint16_t flags; diff --git a/src/server/restore_sbuf.c b/src/server/restore_sbuf.c index 6a75f8f82..548a3edf9 100644 --- a/src/server/restore_sbuf.c +++ b/src/server/restore_sbuf.c @@ -76,8 +76,9 @@ static int do_send_file(struct asfd *asfd, struct sbuf *sb, struct BFILE bfd; uint64_t bytes=0; // Unused. - bfile_init(&bfd, 0, cntr); - if(bfd.open_for_send(&bfd, asfd, best, sb->winattr, + bfile_init(&bfd, 0, 0, cntr); + if(bfd.open_for_send(&bfd, asfd, best, + sb->use_winapi, sb->winattr, 1 /* no O_NOATIME */, cntr)) return SEND_FATAL; if(asfd->write(asfd, &sb->path)) diff --git a/src/server/sdirs.c b/src/server/sdirs.c index a0c28e427..6d1d02e54 100644 --- a/src/server/sdirs.c +++ b/src/server/sdirs.c @@ -254,7 +254,6 @@ void sdirs_free_content(struct sdirs *sdirs) free_w(&sdirs->lockdir); lock_free(&sdirs->lock_storage_for_write); - // Protocol1 directories. free_w(&sdirs->currentdata); free_w(&sdirs->datadirtmp); free_w(&sdirs->cincexc); diff --git a/src/server/sdirs.h b/src/server/sdirs.h index a68cdde9f..3f6bcc3fd 100644 --- a/src/server/sdirs.h +++ b/src/server/sdirs.h @@ -48,7 +48,6 @@ struct sdirs // backups/deletes. struct lock *lock_storage_for_write; - // Protocol1 directories. char *currentdata; char *datadirtmp; char *cincexc; diff --git a/src/win32/compat/compat.cpp b/src/win32/compat/compat.cpp index 79ab109d2..735799e9d 100644 --- a/src/win32/compat/compat.cpp +++ b/src/win32/compat/compat.cpp @@ -165,7 +165,7 @@ static void conv_unix_to_win32_path( /* Created 02/27/2006 Thorsten Engel. This function expects an UCS-encoded standard wchar_t in pszUCSPath and - will complete the input path to an absolue path of the form \\?\c:\path\file + will complete the input path to an absolute path of the form \\?\c:\path\file With this trick, it is possible to have 32K characters long paths. */ @@ -1605,7 +1605,7 @@ char *realpath(const char *path, char *resolved_path) return ret; } -char *get_fixed_drives(void) +static char *get_drives(uint64_t type) { static char ret[256]=""; size_t r=0; @@ -1626,7 +1626,7 @@ char *get_fixed_drives(void) int l; char u[8]; l=wchar_2_UTF8(u, (const wchar_t *)drive, sizeof(u)); - if(GetDriveTypeW((const wchar_t *)drive)==DRIVE_FIXED) + if(GetDriveTypeW((const wchar_t *)drive)==type) { if(isalpha(*u)) ret[r++]=toupper(*u); @@ -1636,3 +1636,13 @@ char *get_fixed_drives(void) return ret; } + +char *get_fixed_drives(void) +{ + return get_drives(DRIVE_FIXED); +} + +char *get_remote_drives(void) +{ + return get_drives(DRIVE_REMOTE); +} diff --git a/src/win32/compat/compat.h b/src/win32/compat/compat.h index 9e8ab01f0..91854e300 100644 --- a/src/win32/compat/compat.h +++ b/src/win32/compat/compat.h @@ -361,3 +361,4 @@ int win32_getfsname(const char *file, char *fsname, size_t fsname_size); char *realpath(const char *path, char *resolved_path); char *get_fixed_drives(void); +char *get_remote_drives(void); diff --git a/src/win32/lib/compat32.def b/src/win32/lib/compat32.def index 462572c4f..a187b27b3 100644 --- a/src/win32/lib/compat32.def +++ b/src/win32/lib/compat32.def @@ -39,6 +39,7 @@ _Z17forkchild_no_waitPP3fzpS1_S1_PKcPKPc _Z15win32_getfsnamePKcPcj _Z8realpathPKcPc _Z16get_fixed_drivesv +_Z17get_remote_drivesv ; print.o _Z10__snprintfPcjPKcz diff --git a/src/win32/lib/compat64.def b/src/win32/lib/compat64.def index 1139352a8..0f6c7eb4e 100644 --- a/src/win32/lib/compat64.def +++ b/src/win32/lib/compat64.def @@ -39,6 +39,7 @@ _Z17forkchild_no_waitPP3fzpS1_S1_PKcPKPc _Z15win32_getfsnamePKcPcy _Z8realpathPKcPc _Z16get_fixed_drivesv +_Z17get_remote_drivesv ; print.o _Z10__vsprintfPcPKcS_ diff --git a/utest/client/test_restore.c b/utest/client/test_restore.c index 18f45aae5..70d307795 100644 --- a/utest/client/test_restore.c +++ b/utest/client/test_restore.c @@ -142,7 +142,7 @@ static void setup_some_things(struct asfd *asfd, struct slist *slist) asfd_mock_read_iobuf(asfd, &r, 0, &s->attr); asfd_mock_read_iobuf(asfd, &r, 0, &s->path); - // Protocol1 always sends it gzipped. + // It is always sent gzipped. iobuf_set(&rbuf, CMD_APPEND, (char *)gzipped_data, sizeof(gzipped_data)); asfd_mock_read_iobuf(asfd, &r, 0, &rbuf); diff --git a/utest/server/test_restore.c b/utest/server/test_restore.c index 74270648c..b695d49c7 100644 --- a/utest/server/test_restore.c +++ b/utest/server/test_restore.c @@ -243,7 +243,7 @@ static void setup_asfds_stuff(struct asfd *asfd, struct slist *slist) "4:8d777f385d3dfec8815d20f7496026dc"); continue; } - // Protocol1 always sends it gzipped. + // It is always sent gzipped. iobuf_set(&wbuf, CMD_APPEND, (char *)gzipped_data1, sizeof(gzipped_data1)); asfd_assert_write_iobuf(asfd, &w, 0, &wbuf); diff --git a/utest/test_conf.c b/utest/test_conf.c index bf4813751..ed5d57d3e 100644 --- a/utest/test_conf.c +++ b/utest/test_conf.c @@ -67,6 +67,7 @@ static void check_default(struct conf **c, enum conf_opt o) case OPT_N_FAILURE_SCRIPT: case OPT_DEDUP_GROUP: case OPT_VSS_DRIVES: + case OPT_REMOTE_DRIVES: case OPT_REGEX: case OPT_SUPER_CLIENT: case OPT_MONITOR_EXE: