- Figure out how to use ssh or stunnel to protect Bacula communications.
For 1.31 release:
+- Find a solution for the multiple FileSet problem (when it is changed).
+ Add date?
- Cancel waiting for Client connect in SD if FD goes away.
- Testing Tibs job erred and hung director on Storage resource.
- Make restore more robust in counting error and not immediately bailing
sd = jcr->store_bsock;
- get_backup_privileges(jcr, 0);
-
set_jcr_job_status(jcr, JS_Running);
Dmsg1(110, "bfiled: opened data connection %d to stored\n", sd->fd);
/* Open any file with data that we intend to save */
if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
ff_pkt->statp.st_size > 0) ||
- ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO) {
+ ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO
+#ifdef HAVE_CYGWIN
+ || ff_pkt->type == FT_DIR
+#endif
+ ) {
btimer_id tid;
if (ff_pkt->type == FT_FIFO) {
tid = start_thread_timer(pthread_self(), 60);
jcr->client_name = get_memory(strlen(my_name) + 1);
pm_strcpy(&jcr->client_name, my_name);
dir->jcr = (void *)jcr;
+ get_backup_privileges(NULL, 1 /* ignore_errors */);
/**********FIXME******* add command handler error code */
}
jcr->sd_auth_key = bstrdup(sd_auth_key);
free_pool_memory(sd_auth_key);
- get_backup_privileges(jcr, 1 /* ignore_errors */);
Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key);
return bnet_fsend(dir, OKjob);
}
extern struct s_last_job last_job;
extern time_t daemon_start_time;
+#ifdef HAVE_CYGWIN
+static int privs = 0;
+#endif
+
/*
* General status generator
*/
len = Mmsg(&msg, _("Daemon started %s, %d Job%s run.\n"), dt, last_job.NumJobs,
last_job.NumJobs == 1 ? "" : "s");
sendit(msg, len, arg);
+#ifdef HAVE_CYGWIN
+ if (!privs) {
+ privs = get_backup_privileges(NULL, 1);
+ }
+ len = Mmsg(&msg,
+ _("Priv 0x%x APIs=%sOPT,%sATP,%sLPV,%sGFAE,%sBR,%sBW,%sSPSP\n"), privs,
+ p_OpenProcessToken?"":"!",
+ p_AdjustTokenPrivileges?"":"!",
+ p_LookupPrivilegeValue?"":"!",
+ p_GetFileAttributesEx?"":"!",
+ p_BackupRead?"":"!",
+ p_BackupWrite?"":"!",
+ p_SetProcessShutdownParameters?"":"!");
+ sendit(msg, len, arg);
+#endif
+
if (last_job.NumJobs > 0) {
char termstat[30];
FreeLibrary(hLib);
}
-#ifdef debug_xxx
- char buf[1000];
- buf[0] = 0;
- strcat(buf, "GetFileAttributesEx ");
- if (p_GetFileAttributesEx)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- strcat(buf, "SetProcessShutdownParamaters ");
- if (p_SetProcessShutdownParameters)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- strcat(buf, "BackupRead ");
- if (p_BackupRead)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- strcat(buf, "BackupWrite ");
- if (p_BackupWrite)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- strcat(buf, "OpenProcessToken ");
- if (p_OpenProcessToken)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- strcat(buf, "AdjustTokenPrivileges ");
- if (p_AdjustTokenPrivileges)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- strcat(buf, "LookupPrivilegeValue ");
- if (p_LookupPrivilegeValue)
- strcat(buf, "OK\n");
- else
- strcat(buf, "NO\n");
-
- MessageBox(NULL, buf, "APIs Available", MB_OK);
-#endif
-
// Set this process to be the last application to be shut down.
if (p_SetProcessShutdownParameters) {
p_SetProcessShutdownParameters(0x100, 0);
}
// And find the RegisterServiceProcess function
- DWORD (*RegisterService)(DWORD, DWORD);
+ DWORD WINAPI (*RegisterService)(DWORD, DWORD);
RegisterService = (DWORD (*)(DWORD, DWORD))
GetProcAddress(kerneldll, "RegisterServiceProcess");
if (RegisterService == NULL) {
}
LocalFree(msg);
}
-typedef BOOL (*WinAPI)(SC_HANDLE, DWORD, LPVOID);
+typedef BOOL WINAPI (*WinAPI)(SC_HANDLE, DWORD, LPVOID);
void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService,
LPSTR lpDesc)
int64_t val;
WIN32_FILE_ATTRIBUTE_DATA atts;
ULARGE_INTEGER li;
- int stat;
POOLMEM *win32_ofile;
if (!p || !*p) { /* we should have attributes */
p += from_base64(&val, p);
atts.nFileSizeLow = val;
- /* At this point, we have reconstructed the WIN32_FILE_ATTRIBUTE_DATA pkt */
-
/* Convert to Windows path format */
win32_ofile = get_pool_memory(PM_FNAME);
unix_name_to_win32(&win32_ofile, ofile);
+
+
+ /* At this point, we have reconstructed the WIN32_FILE_ATTRIBUTE_DATA pkt */
+
+
if (!is_bopen(ofd)) {
Dmsg1(100, "File not open: %s\n", ofile);
bopen(ofd, ofile, O_WRONLY|O_BINARY, 0); /* attempt to open the file */
if (is_bopen(ofd)) {
Dmsg1(100, "SetFileTime %s\n", ofile);
- stat = SetFileTime(bget_handle(ofd),
+ if (!SetFileTime(bget_handle(ofd),
&atts.ftCreationTime,
&atts.ftLastAccessTime,
- &atts.ftLastWriteTime);
- if (stat != 1) {
+ &atts.ftLastWriteTime)) {
win_error(jcr, "SetFileTime:", win32_ofile);
}
bclose(ofd);
}
Dmsg1(100, "SetFileAtts %s\n", ofile);
- stat = SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS);
- if (stat != 1) {
- win_error(jcr, "SetFileAttributes:", win32_ofile);
+ if (!(atts.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ if (!SetFileAttributes(win32_ofile, atts.dwFileAttributes & SET_ATTRS)) {
+ win_error(jcr, "SetFileAttributes:", win32_ofile);
+ }
}
free_pool_memory(win32_ofile);
return 1;
NULL);
Dmsg3(100, "Error in %s on file %s: ERR=%s\n", prefix, win32_ofile, msg);
strip_trailing_junk(msg);
- Jmsg3(jcr, M_INFO, 0, _("Error in %s file %s: ERR=%s\n"), prefix, win32_ofile, msg);
+ Jmsg(jcr, M_INFO, 0, _("Error in %s file %s: ERR=%s\n"), prefix, win32_ofile, msg);
LocalFree(msg);
}
{
bfd->fid = -1;
bfd->mode = BF_CLOSED;
- bfd->use_win_api = 1;
bfd->use_backup_api = p_BackupRead && p_BackupWrite;
bfd->errmsg = NULL;
bfd->lpContext = NULL;
HANDLE bget_handle(BFILE *bfd)
{
+#ifdef xxx
if (!bfd->use_win_api) {
return get_osfhandle(bfd->fid);
}
+#endif
return bfd->fh;
}
{
POOLMEM *win32_fname;
+#ifdef xxx
if (!bfd->use_win_api) {
bfd->fid = open(fname, flags, mode);
if (bfd->fid >= 0) {
}
return bfd->fid;
}
+#endif
/* Convert to Windows path format */
win32_fname = get_pool_memory(PM_FNAME);
unix_name_to_win32(&win32_fname, (char *)fname);
- if (flags & O_WRONLY) { /* creating */
+ if (flags & O_CREAT) {
bfd->fh = CreateFile(win32_fname,
- FILE_ALL_ACCESS|WRITE_DAC|ACCESS_SYSTEM_SECURITY, /* access */
- 0,
- NULL, /* SecurityAttributes */
- CREATE_ALWAYS, /* CreationDisposition */
- FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */
- NULL); /* TemplateFile */
-
- if (bfd->fh == INVALID_HANDLE_VALUE) {
- bfd->lerror = GetLastError();
- bfd->mode = BF_CLOSED;
- } else {
- bfd->mode = BF_WRITE;
- }
+ GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY, /* access */
+ 0,
+ NULL, /* SecurityAttributes */
+ CREATE_ALWAYS, /* CreationDisposition */
+ FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */
+ NULL); /* TemplateFile */
+ bfd->mode = BF_WRITE;
+ } else if (flags & O_WRONLY) { /* creating */
+ bfd->fh = CreateFile(win32_fname,
+ FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY, /* access */
+ 0,
+ NULL, /* SecurityAttributes */
+ OPEN_EXISTING, /* CreationDisposition */
+ FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */
+ NULL);
+ bfd->mode = BF_WRITE;
} else {
bfd->fh = CreateFile(win32_fname,
- GENERIC_READ|ACCESS_SYSTEM_SECURITY, /* access */
- FILE_SHARE_READ, /* shared mode */
- NULL, /* SecurityAttributes */
- OPEN_EXISTING, /* CreationDisposition */
- FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */
- NULL); /* TemplateFile */
-
- if (bfd->fh == INVALID_HANDLE_VALUE) {
- bfd->lerror = GetLastError();
- bfd->mode = BF_CLOSED;
- } else {
- bfd->mode = BF_READ;
- }
+ GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY, /* access */
+ FILE_SHARE_READ, /* shared mode */
+ NULL, /* SecurityAttributes */
+ OPEN_EXISTING, /* CreationDisposition */
+ FILE_FLAG_BACKUP_SEMANTICS, /* Flags and attributes */
+ NULL); /* TemplateFile */
+
+ bfd->mode = BF_READ;
+ }
+ if (bfd->fh == INVALID_HANDLE_VALUE) {
+ bfd->lerror = GetLastError();
+ bfd->mode = BF_CLOSED;
}
bfd->errmsg = NULL;
bfd->lpContext = NULL;
int bclose(BFILE *bfd)
{
int stat = 0;
+#ifdef xxx
if (!bfd->use_win_api) {
int stat = close(bfd->fid);
bfd->fid = -1;
bfd->mode = BF_CLOSED;
return stat;
}
+#endif
if (bfd->errmsg) {
free_pool_memory(bfd->errmsg);
bfd->errmsg = NULL;
char *berror(BFILE *bfd)
{
LPTSTR msg;
-
+#ifdef xxx
if (!bfd->use_win_api) {
return strerror(errno);
}
+#endif
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
*/
ssize_t bread(BFILE *bfd, void *buf, size_t count)
{
+#ifdef xxx
if (!bfd->use_win_api) {
return read(bfd->fid, buf, count);
}
+#endif
bfd->rw_bytes = 0;
if (bfd->use_backup_api) {
ssize_t bwrite(BFILE *bfd, void *buf, size_t count)
{
+#ifdef xxx
if (!bfd->use_win_api) {
return write(bfd->fid, buf, count);
}
+#endif
bfd->rw_bytes = 0;
if (bfd->use_backup_api) {
off_t blseek(BFILE *bfd, off_t offset, int whence)
{
+#ifdef xxx
if (!bfd->use_win_api) {
return lseek(bfd->fid, offset, whence);
}
+#endif
+ /* ****FIXME**** this is needed if we want to read Win32 Archives */
return -1;
}
#include "winapi.h"
#define BF_CLOSED 0
-#define BF_READ 1 /* BackupRead */
-#define BF_WRITE 2 /* BackupWrite */
+#define BF_READ 1 /* BackupRead */
+#define BF_WRITE 2 /* BackupWrite */
/* In bfile.c */
/* Basic low level I/O file packet */
typedef struct s_bfile {
- int use_win_api; /* set if using WinAPI */
- int use_backup_api; /* set if using BackupRead/Write */
- int mode; /* set if file is open */
- HANDLE fh; /* Win32 file handle */
- int fid; /* fd if doing Unix style */
- LPVOID lpContext; /* BackupRead/Write context */
- POOLMEM *errmsg; /* error message buffer */
- DWORD rw_bytes; /* Bytes read or written */
- DWORD lerror; /* Last error code */
+#ifdef xxx
+ int use_win_api; /* set if using WinAPI */
+#endif
+ int use_backup_api; /* set if using BackupRead/Write */
+ int mode; /* set if file is open */
+ HANDLE fh; /* Win32 file handle */
+ int fid; /* fd if doing Unix style */
+ LPVOID lpContext; /* BackupRead/Write context */
+ POOLMEM *errmsg; /* error message buffer */
+ DWORD rw_bytes; /* Bytes read or written */
+ DWORD lerror; /* Last error code */
} BFILE;
HANDLE bget_handle(BFILE *bfd);
-#else /* Linux/Unix systems */
+#else /* Linux/Unix systems */
/* Basic low level I/O file packet */
typedef struct s_bfile {
- int fid; /* file id on Unix */
+ int fid; /* file id on Unix */
int berrno;
} BFILE;
if (make_path(jcr, ofile, new_mode, parent_mode, uid, gid, 0, NULL) != 0) {
return CF_ERROR;
}
+#ifdef HAVE_CYGWIN
+ if ((bopen(ofd, ofile, O_WRONLY|O_BINARY, 0)) < 0) {
+ Jmsg2(jcr, M_ERROR, 0, _("Could not open %s: ERR=%s\n"),
+ ofile, berror(ofd));
+ return CF_ERROR;
+ }
+ return CF_EXTRACT;
+#else
return CF_CREATED;
+#endif
/* The following should not occur */
case FT_NOACCESS:
/* From get_priv.c */
-void get_backup_privileges(void *jcr, int ignore_errors);
+int get_backup_privileges(void *jcr, int ignore_errors);
/* from makepath.c */
int preserve_existing, char *verbose_fmt_string);
/* from bfile.c -- see bfile.h */
-