From 0dbb9a02c00fd568bf8fb30b7405fea53ac5ade6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 20 Dec 2006 13:59:50 +0000 Subject: [PATCH] kes Fix a couple of compiler warnings in wx-console kes Apply the immutable patch for FreeBSD hardlinked files supplied by Olivier Lehmann. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3822 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ChangeLog | 3 ++ bacula/src/findlib/create_file.c | 37 ++++++++++++++++++++++++ bacula/src/wx-console/wxbconfigpanel.cpp | 4 +-- bacula/technotes-1.39 | 3 ++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 9ee1341f9a..fcc4b88c51 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -4,6 +4,9 @@ General: Version 1.39.32 released: 20Dec06 +kes Fix a couple of compiler warnings in wx-console +kes Apply the immutable patch for FreeBSD hardlinked files supplied + by Olivier Lehmann. kes Add Volume name to Forward spacing message. kes Update migration job start time (so it is not zero) to prevent immediate recycling of the job. This *should* fix bug #733. diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 8b20ff4559..3d08fdcc84 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -289,9 +289,46 @@ int create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace) Dmsg2(130, "Hard link %s => %s\n", attr->ofname, attr->olname); if (link(attr->olname, attr->ofname) != 0) { berrno be; +#ifdef HAVE_CHFLAGS + struct stat s; + + /* + * If using BSD user flags, maybe has a file flag + * preventing this. So attempt to disable, retry link, + * and reset flags. + * Note that BSD securelevel may prevent disabling flag. + */ + + if (stat(attr->olname, &s) == 0 && s.st_flags != 0) { + if (chflags(attr->olname, 0) == 0) { + if (link(attr->olname, attr->ofname) != 0) { + /* restore original file flags even when linking failed */ + if (chflags(attr->olname, s.st_flags) < 0) { + Qmsg2(jcr, M_ERROR, 0, _("Could not restore file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } +#endif /* HAVE_CHFLAGS */ Qmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"), attr->ofname, attr->olname, be.strerror()); return CF_ERROR; +#ifdef HAVE_CHFLAGS + } + /* finally restore original file flags */ + if (chflags(attr->olname, s.st_flags) < 0) { + Qmsg2(jcr, M_ERROR, 0, _("Could not restore file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } + } else { + Qmsg2(jcr, M_ERROR, 0, _("Could not reset file flags for file %s: ERR=%s\n"), + attr->olname, be.strerror()); + } + } else { + Qmsg3(jcr, M_ERROR, 0, _("Could not hard link %s -> %s: ERR=%s\n"), + attr->ofname, attr->olname, be.strerror()); + return CF_ERROR; + } +#endif /* HAVE_CHFLAGS */ + } return CF_CREATED; #endif diff --git a/bacula/src/wx-console/wxbconfigpanel.cpp b/bacula/src/wx-console/wxbconfigpanel.cpp index c6167ae3bb..738112773f 100644 --- a/bacula/src/wx-console/wxbconfigpanel.cpp +++ b/bacula/src/wx-console/wxbconfigpanel.cpp @@ -137,13 +137,13 @@ void wxbConfigParam::SetValue(wxString str) { case choice: if (choicectrl) { int k; - for (k = 0; k < choicectrl->GetCount(); k++) { + for (k = 0; k < (int)choicectrl->GetCount(); k++) { if (str == choicectrl->GetString(k)) { choicectrl->SetSelection(k); break; } } - if (k == choicectrl->GetCount()) { // Should never happen + if (k == (int)choicectrl->GetCount()) { // Should never happen choicectrl->Append(str); choicectrl->SetSelection(k); } diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 7feb40bfe8..0c5bc046ee 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -3,6 +3,9 @@ General: Version 1.39.32 released: 20Dec06 +kes Fix a couple of compiler warnings in wx-console +kes Apply the immutable patch for FreeBSD hardlinked files supplied + by Olivier Lehmann. kes Add Volume name to Forward spacing message. kes Update migration job start time (so it is not zero) to prevent immediate recycling of the job. This *should* fix bug #733. -- 2.39.5