From 752e0668682f2bd802abf222902dd619db40d8fc Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 15 May 2003 21:42:26 +0000 Subject: [PATCH] BSDI changes, auto Win API detection git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@514 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/acconfig.h | 1 + bacula/autoconf/config.h.in | 1 + bacula/autoconf/configure.in | 3 +- bacula/configure | 281 +++++++++++++++----------- bacula/kernstodo | 17 +- bacula/src/filed/backup.c | 2 +- bacula/src/filed/job.c | 5 +- bacula/src/filed/restore.c | 6 +- bacula/src/filed/verify.c | 2 +- bacula/src/filed/win32/winmain.cpp | 29 ++- bacula/src/filed/win32/winservice.cpp | 198 +++++++----------- bacula/src/findlib/Makefile.in | 4 +- bacula/src/findlib/attribs.c | 6 +- bacula/src/findlib/bfile.c | 14 +- bacula/src/findlib/create_file.c | 4 +- bacula/src/findlib/find.h | 137 ++++++------- bacula/src/findlib/protos.h | 34 ++-- bacula/src/findlib/winapi.c | 44 ++++ bacula/src/findlib/winapi.h | 56 +++++ bacula/src/jcr.h | 1 - bacula/src/lib/protos.h | 208 +++++++++---------- bacula/src/stored/bextract.c | 4 +- bacula/src/stored/dev.c | 6 + 23 files changed, 606 insertions(+), 457 deletions(-) create mode 100644 bacula/src/findlib/winapi.c create mode 100644 bacula/src/findlib/winapi.h diff --git a/bacula/autoconf/acconfig.h b/bacula/autoconf/acconfig.h index 11289bcf5e..38157a5115 100644 --- a/bacula/autoconf/acconfig.h +++ b/bacula/autoconf/acconfig.h @@ -196,6 +196,7 @@ #undef HAVE_STRERROR_R #undef HAVE_GETHOSTBYNAME_R +#undef HAVE_STRTOLL #undef HAVE_INET_PTON #undef HAVE_SOCKLEN_T diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 70ba4bb5d0..bb9b0d6890 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -273,6 +273,7 @@ #undef HAVE_GETOPT_LONG +#undef HAVE_STRTOLL #undef HAVE_INET_PTON #undef HAVE_SOCKLEN_T diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 424edf80df..c927c8097f 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1051,12 +1051,12 @@ AC_CHECK_FUNCS( \ strncmp \ strncpy \ vfprintf \ - strtoll \ ,, [echo 'configure: cannot find needed function.'; exit 1] ) AC_CHECK_FUNCS(fchdir, [AC_DEFINE(HAVE_FCHDIR)]) +AC_CHECK_FUNCS(strtoll, [AC_DEFINE(HAVE_STRTOLL)]) AC_CHECK_FUNCS(chflags) @@ -1382,7 +1382,6 @@ AC_OUTPUT([autoconf/Make.common \ scripts/fd \ scripts/Makefile \ scripts/logrotate \ - scripts/bacula.desktop \ scripts/bacula.desktop.gnome1 \ scripts/bacula.desktop.gnome2 \ doc/Makefile \ diff --git a/bacula/configure b/bacula/configure index bc36f750e1..084e4fb941 100755 --- a/bacula/configure +++ b/bacula/configure @@ -7588,16 +7588,15 @@ for ac_func in \ strncmp \ strncpy \ vfprintf \ - strtoll \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7596: checking for $ac_func" >&5 +echo "configure:7595: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7650,12 +7649,12 @@ done for ac_func in fchdir do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7654: checking for $ac_func" >&5 +echo "configure:7653: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7705,16 +7704,74 @@ else fi done +for ac_func in strtoll +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:7711: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:7739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <> confdefs.h <<\EOF +#define HAVE_STRTOLL 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + for ac_func in chflags do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7713: checking for $ac_func" >&5 +echo "configure:7770: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7765,12 +7822,12 @@ done for ac_func in snprintf vsnprintf gethostid getdomainname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7769: checking for $ac_func" >&5 +echo "configure:7826: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7821,12 +7878,12 @@ done for ac_func in localtime_r readdir_r strerror_r gethostbyname_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7825: checking for $ac_func" >&5 +echo "configure:7882: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7876,12 +7933,12 @@ done # If resolver functions are not in libc check for -lnsl or -lresolv. echo $ac_n "checking for gethostbyname_r""... $ac_c" 1>&6 -echo "configure:7880: checking for gethostbyname_r" >&5 +echo "configure:7937: checking for gethostbyname_r" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname_r'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname_r=yes" else @@ -7922,7 +7979,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname_r`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gethostbyname_r in -lnsl""... $ac_c" 1>&6 -echo "configure:7926: checking for gethostbyname_r in -lnsl" >&5 +echo "configure:7983: checking for gethostbyname_r in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname_r | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7930,7 +7987,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7969,7 +8026,7 @@ else fi echo $ac_n "checking for gethostbyname_r in -lresolv""... $ac_c" 1>&6 -echo "configure:7973: checking for gethostbyname_r in -lresolv" >&5 +echo "configure:8030: checking for gethostbyname_r in -lresolv" >&5 ac_lib_var=`echo resolv'_'gethostbyname_r | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7977,7 +8034,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lresolv $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8021,12 +8078,12 @@ fi # Find where sockets are (especially for Solaris) echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:8025: checking for socket" >&5 +echo "configure:8082: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -8067,7 +8124,7 @@ if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for socket in -lxnet""... $ac_c" 1>&6 -echo "configure:8071: checking for socket in -lxnet" >&5 +echo "configure:8128: checking for socket in -lxnet" >&5 ac_lib_var=`echo xnet'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8075,7 +8132,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lxnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8114,7 +8171,7 @@ else fi echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:8118: checking for socket in -lsocket" >&5 +echo "configure:8175: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8122,7 +8179,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8161,7 +8218,7 @@ else fi echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6 -echo "configure:8165: checking for socket in -linet" >&5 +echo "configure:8222: checking for socket in -linet" >&5 ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8169,7 +8226,7 @@ else ac_save_LIBS="$LIBS" LIBS="-linet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8213,12 +8270,12 @@ fi for ac_func in inet_pton do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8217: checking for $ac_func" >&5 +echo "configure:8274: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8270,12 +8327,12 @@ done echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:8274: checking for strftime" >&5 +echo "configure:8331: checking for strftime" >&5 if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -8320,7 +8377,7 @@ else echo "$ac_t""no" 1>&6 # strftime is in -lintl on SCO UNIX. echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6 -echo "configure:8324: checking for strftime in -lintl" >&5 +echo "configure:8381: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8328,7 +8385,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8366,12 +8423,12 @@ fi fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:8370: checking for vprintf" >&5 +echo "configure:8427: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -8418,12 +8475,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:8422: checking for _doprnt" >&5 +echo "configure:8479: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8507: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -8473,19 +8530,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:8477: checking for working alloca.h" >&5 +echo "configure:8534: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:8489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -8506,12 +8563,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:8510: checking for alloca" >&5 +echo "configure:8567: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -8571,12 +8628,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:8575: checking whether alloca needs Cray hooks" >&5 +echo "configure:8632: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8605: checking for $ac_func" >&5 +echo "configure:8662: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8656,7 +8713,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:8660: checking stack direction for C alloca" >&5 +echo "configure:8717: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8664,7 +8721,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -8706,7 +8763,7 @@ fi # getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX, -lgen on Unixware. echo $ac_n "checking for getmntent in -lsun""... $ac_c" 1>&6 -echo "configure:8710: checking for getmntent in -lsun" >&5 +echo "configure:8767: checking for getmntent in -lsun" >&5 ac_lib_var=`echo sun'_'getmntent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8714,7 +8771,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsun $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8744,7 +8801,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for getmntent in -lseq""... $ac_c" 1>&6 -echo "configure:8748: checking for getmntent in -lseq" >&5 +echo "configure:8805: checking for getmntent in -lseq" >&5 ac_lib_var=`echo seq'_'getmntent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8752,7 +8809,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lseq $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8782,7 +8839,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for getmntent in -lgen""... $ac_c" 1>&6 -echo "configure:8786: checking for getmntent in -lgen" >&5 +echo "configure:8843: checking for getmntent in -lgen" >&5 ac_lib_var=`echo gen'_'getmntent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8790,7 +8847,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lgen $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8826,12 +8883,12 @@ fi fi echo $ac_n "checking for getmntent""... $ac_c" 1>&6 -echo "configure:8830: checking for getmntent" >&5 +echo "configure:8887: checking for getmntent" >&5 if eval "test \"`echo '$''{'ac_cv_func_getmntent'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_getmntent=yes" else @@ -8877,7 +8934,7 @@ else fi echo $ac_n "checking whether closedir returns void""... $ac_c" 1>&6 -echo "configure:8881: checking whether closedir returns void" >&5 +echo "configure:8938: checking whether closedir returns void" >&5 if eval "test \"`echo '$''{'ac_cv_func_closedir_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8885,13 +8942,13 @@ else ac_cv_func_closedir_void=yes else cat > conftest.$ac_ext < #include <$ac_header_dirent> int closedir(); main() { exit(closedir(opendir(".")) != 0); } EOF -if { (eval echo configure:8895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_closedir_void=no else @@ -8914,7 +8971,7 @@ EOF fi echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6 -echo "configure:8918: checking whether setpgrp takes no argument" >&5 +echo "configure:8975: checking whether setpgrp takes no argument" >&5 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8922,7 +8979,7 @@ else { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:9003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setpgrp_void=no else @@ -8965,7 +9022,7 @@ EOF fi echo $ac_n "checking for working fnmatch""... $ac_c" 1>&6 -echo "configure:8969: checking for working fnmatch" >&5 +echo "configure:9026: checking for working fnmatch" >&5 if eval "test \"`echo '$''{'ac_cv_func_fnmatch_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8976,11 +9033,11 @@ if test "$cross_compiling" = yes; then ac_cv_func_fnmatch_works=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:9041: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_fnmatch_works=yes else @@ -9005,7 +9062,7 @@ fi echo $ac_n "checking for setlocale in -lxpg4""... $ac_c" 1>&6 -echo "configure:9009: checking for setlocale in -lxpg4" >&5 +echo "configure:9066: checking for setlocale in -lxpg4" >&5 ac_lib_var=`echo xpg4'_'setlocale | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9013,7 +9070,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lxpg4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9047,7 +9104,7 @@ fi echo $ac_n "checking for getpwnam in -lsun""... $ac_c" 1>&6 -echo "configure:9051: checking for getpwnam in -lsun" >&5 +echo "configure:9108: checking for getpwnam in -lsun" >&5 ac_lib_var=`echo sun'_'getpwnam | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9055,7 +9112,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsun $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9098,17 +9155,17 @@ for ac_hdr in zlib.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:9102: checking for $ac_hdr" >&5 +echo "configure:9159: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:9112: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:9169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -9135,7 +9192,7 @@ fi done echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6 -echo "configure:9139: checking for deflate in -lz" >&5 +echo "configure:9196: checking for deflate in -lz" >&5 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9143,7 +9200,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9185,7 +9242,7 @@ fi PTHREAD_LIB="" echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:9189: checking for pthread_create in -lpthread" >&5 +echo "configure:9246: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9193,7 +9250,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9223,7 +9280,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:9227: checking for pthread_create in -lpthreads" >&5 +echo "configure:9284: checking for pthread_create in -lpthreads" >&5 ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9231,7 +9288,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthreads $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9261,7 +9318,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:9265: checking for pthread_create in -lc_r" >&5 +echo "configure:9322: checking for pthread_create in -lc_r" >&5 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -9269,7 +9326,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc_r $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -9299,12 +9356,12 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create""... $ac_c" 1>&6 -echo "configure:9303: checking for pthread_create" >&5 +echo "configure:9360: checking for pthread_create" >&5 if eval "test \"`echo '$''{'ac_cv_func_pthread_create'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:9388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_pthread_create=yes" else @@ -9732,7 +9789,6 @@ trap 'rm -fr `echo "autoconf/Make.common \ scripts/fd \ scripts/Makefile \ scripts/logrotate \ - scripts/bacula.desktop \ scripts/bacula.desktop.gnome1 \ scripts/bacula.desktop.gnome2 \ doc/Makefile \ @@ -10003,7 +10059,6 @@ CONFIG_FILES=\${CONFIG_FILES-"autoconf/Make.common \ scripts/fd \ scripts/Makefile \ scripts/logrotate \ - scripts/bacula.desktop \ scripts/bacula.desktop.gnome1 \ scripts/bacula.desktop.gnome2 \ doc/Makefile \ diff --git a/bacula/kernstodo b/bacula/kernstodo index 72f57bab49..9ad8906f17 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -26,10 +26,14 @@ For 1.31 release: - Implement MTIOCERRSTAT on FreeBSD to clear tape error conditions. -- BSD (probably) does not have strtoll() -- BSD does not have ioctl() MTEOM -- BSD defines a number of MT_xxx variables which conflict - with those defined by Bacula. +- BSDI + cut: illegal option -- b + usage: cut -c list [file1 ...] + cut -f list [-s] [-d delim] [file ...] + cut: illegal option -- b + usage: cut -c list [file1 ...] + cut -f list [-s] [-d delim] [file ...] + - Add Progress command that periodically reports the progress of @@ -816,3 +820,8 @@ Done: (see kernsdone for more) - The following Re-read last block at EOT failed. ERR=block.c:523 Read zero bytes on device /dev/nrsa0. undef-sd: block.c:523 Read zero bytes on device /dev/nrsa0. apparently masks the standard EOM message. +- BSD (probably) does not have strtoll() +- BSD does not have ioctl() MTEOM +- BSD defines a number of MT_xxx variables which conflict + with those defined by Bacula. + diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 637418524d..2029f4f45b 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -189,7 +189,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr) return 1; } - binit(&ff_pkt->bfd, jcr->use_win_backup_api); + binit(&ff_pkt->bfd); /* Open any file with data that we intend to save */ if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 173da924b8..0a8510df01 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -157,7 +157,6 @@ void *handle_client_request(void *dirp) jcr = new_jcr(sizeof(JCR), filed_free_jcr); /* create JCR */ jcr->dir_bsock = dir; jcr->ff = init_find_files(); - jcr->use_win_backup_api = 0; jcr->start_time = time(NULL); jcr->last_fname = get_pool_memory(PM_FNAME); jcr->last_fname[0] = 0; @@ -289,9 +288,7 @@ static int job_cmd(JCR *jcr) } jcr->sd_auth_key = bstrdup(sd_auth_key); free_pool_memory(sd_auth_key); - if (jcr->use_win_backup_api) { - get_backup_privileges(jcr, 1 /* ignore_errors */); - } + 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); } diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index b32647b872..803b1ac75b 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -64,7 +64,7 @@ void do_restore(JCR *jcr) wherelen = strlen(jcr->where); - binit(&bfd, jcr->use_win_backup_api); + binit(&bfd); sd = jcr->store_bsock; set_jcr_job_status(jcr, JS_Running); @@ -269,8 +269,8 @@ void do_restore(JCR *jcr) Dmsg1(30, "Outfile=%s\n", ofile); extract = FALSE; stat = create_file(jcr, fname, ofile, lname, type, - stream, &statp, attribsEx, &bfd, jcr->replace, - jcr->use_win_backup_api); + stream, &statp, attribsEx, &bfd, + jcr->replace); switch (stat) { case CF_ERROR: case CF_SKIP: diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index a726ae3ad7..0c5faec85d 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -137,7 +137,7 @@ static int verify_file(FF_PKT *ff_pkt, void *pkt) return 1; } - binit(&bfd, jcr->use_win_backup_api); + binit(&bfd); if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) && ff_pkt->statp.st_size > 0) || diff --git a/bacula/src/filed/win32/winmain.cpp b/bacula/src/filed/win32/winmain.cpp index 78eb3db3d5..fa61af1bf5 100755 --- a/bacula/src/filed/win32/winmain.cpp +++ b/bacula/src/filed/win32/winmain.cpp @@ -21,6 +21,8 @@ Copyright (2000) Kern E. Sibbald */ +#define HAVE_CYGWIN 1 + #include #include #include @@ -29,13 +31,14 @@ #include "winservice.h" #include #include +#include "../../findlib/winapi.h" extern int BaculaMain(int argc, char **argv); extern int terminate_filed(int sig); extern DWORD g_error; extern BOOL ReportStatus(DWORD state, DWORD exitcode, DWORD waithint); - +/* Globals */ HINSTANCE hAppInstance; const char *szAppName = "Bacula"; DWORD mainthreadId; @@ -311,6 +314,30 @@ int BaculaAppMain() // DWORD dwThreadID; pthread_t tid; + HINSTANCE hLib = LoadLibrary("KERNEL32.DLL"); + if (hLib) { + p_GetFileAttributesEx = (t_GetFileAttributesEx) + GetProcAddress(hLib, "GetFileFileAttributesExA"); + p_SetProcessShutdownParameters = (t_SetProcessShutdownParameters) + GetProcAddress(hLib, "SetProcessShutdownParameters"); + p_BackupRead = (t_BackupRead) + GetProcAddress(hLib, "BackupRead"); + p_BackupWrite = (t_BackupWrite) + GetProcAddress(hLib, "BackupWrite"); + FreeLibrary(hLib); + } + hLib = LoadLibrary("ADVAPI32.DLL"); + if (hLib) { + p_OpenProcessToken = (t_OpenProcessToken) + GetProcAddress(hLib, "OpenProcessToken"); + p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges) + GetProcAddress(hLib, "AdjustTokenPrivileges"); + p_LookupPrivilegeValue = (t_LookupPrivilegeValue) + GetProcAddress(hLib, "LookupPrivilegeValueA"); + FreeLibrary(hLib); + } + + // Set this process to be the last application to be shut down. SetProcessShutdownParameters(0x100, 0); diff --git a/bacula/src/filed/win32/winservice.cpp b/bacula/src/filed/win32/winservice.cpp index 1f4cefca07..8c1deb6669 100755 --- a/bacula/src/filed/win32/winservice.cpp +++ b/bacula/src/filed/win32/winservice.cpp @@ -41,18 +41,16 @@ #include "winbacula.h" #include "winservice.h" #include "wintray.h" + void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService, LPSTR lpDesc); - // OS-SPECIFIC ROUTINES // Create an instance of the bacService class to cause the static fields to be // initialised properly -extern int NoGetFileAttributesEx; /* set if function no avail -- Win95 */ - bacService init; DWORD g_platform_id; @@ -69,11 +67,14 @@ bacService::bacService() } else { g_platform_id = osversioninfo.dwPlatformId; } +#ifdef xxx + /* Rewritten to lookup entry point */ if (osversioninfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osversioninfo.dwMinorVersion == 0) { /* Running Win95 so no GetFileAttributesEx available */ NoGetFileAttributesEx = 1; } +#endif } @@ -115,13 +116,6 @@ PostToBacula(UINT message, WPARAM wParam, LPARAM lParam) BOOL bacService::ShowProperties() { -#ifdef properties_implemented - // Post to the Bacula menu window - if (!PostToBacula(MENU_PROPERTIES_SHOW, 0, 0)) { - MessageBox(NULL, "No existing instance of Bacula could be contacted", szAppName, MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } -#endif return TRUE; } @@ -131,14 +125,6 @@ bacService::ShowProperties() BOOL bacService::ShowDefaultProperties() { -#ifdef properties_implemented - // Post to the Bacula menu window - if (!PostToBacula(MENU_DEFAULT_PROPERTIES_SHOW, 0, 0)) { - MessageBox(NULL, "No existing instance of Bacula could be contacted", szAppName, MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } - -#endif return TRUE; } @@ -278,43 +264,6 @@ bacService::PostUserHelperMessage() // ROUTINE TO PROCESS AN INCOMING INSTANCE OF THE ABOVE MESSAGE BOOL bacService::ProcessUserHelperMessage(WPARAM wParam, LPARAM lParam) { - // - Check the platform type - if (!IsWinNT() || !bacService::RunningAsService()) { - return TRUE; - } - - // - Close the HKEY_CURRENT_USER key, to force NT to reload it for the new user - // NB: Note that this is _really_ dodgy if ANY other thread is accessing the key! - if (RegCloseKey(HKEY_CURRENT_USER) != ERROR_SUCCESS) { - return FALSE; - } - - // - Revert to our own identity - RevertToSelf(); - g_impersonating_user = FALSE; - - // - Open the specified process - HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, (DWORD)lParam); - if (processHandle == NULL) { - return FALSE; - } - - // - Get the token for the given process - HANDLE userToken = NULL; - if (!OpenProcessToken(processHandle, TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE, &userToken)) { - CloseHandle(processHandle); - return FALSE; - } - CloseHandle(processHandle); - - // - Set this thread to impersonate them - if (!ImpersonateLoggedOnUser(userToken)) { - CloseHandle(userToken); - return FALSE; - } - CloseHandle(userToken); - - g_impersonating_user = TRUE; return TRUE; } @@ -328,7 +277,7 @@ bacService::BaculaServiceMain() // How to run as a service depends upon the OS being used switch (g_platform_id) { - // Windows 95/98 + // Windows 95/98/Me case VER_PLATFORM_WIN32_WINDOWS: { // Obtain a handle to the kernel library @@ -365,13 +314,13 @@ bacService::BaculaServiceMain() } - // Windows NT + // Windows NT, Win2K, WinXP case VER_PLATFORM_WIN32_NT: { // Create a service entry table SERVICE_TABLE_ENTRY dispatchTable[] = { - {BAC_SERVICENAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain}, - {NULL, NULL} + {BAC_SERVICENAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain}, + {NULL, NULL} }; // Call the service control dispatcher with our entry table @@ -431,11 +380,11 @@ DWORD WINAPI ServiceWorkThread(LPVOID lpwThreadParam) // report the status to the service control manager. // if (!ReportStatus( - SERVICE_RUNNING, // service state - NO_ERROR, // exit code - 0)) { // wait hint + SERVICE_RUNNING, // service state + NO_ERROR, // exit code + 0)) { // wait hint MessageBox(NULL, "Report Service failure", "Bacula Service", MB_OK); - log_error_message("ReportStatus RUNNING failed"); + log_error_message("ReportStatus RUNNING failed"); return 0; } @@ -498,7 +447,7 @@ bacService::InstallService() // How to add the Bacula service depends upon the OS switch (g_platform_id) { - // Windows 95/98 + // Windows 95/98/Me case VER_PLATFORM_WIN32_WINDOWS: // Locate the RunService registry entry HKEY runservices; @@ -530,7 +479,7 @@ bacService::InstallService() MB_ICONINFORMATION | MB_OK); break; - // Windows NT + // Windows NT, Win2K, WinXP case VER_PLATFORM_WIN32_NT: SC_HANDLE hservice; SC_HANDLE hsrvmanager; @@ -571,7 +520,7 @@ bacService::InstallService() } set_service_description(hsrvmanager,hservice, -"Provides file backup and restore services. Bacula -- the Network Backup Solution."); +"Provides file backup and restore services. Bacula -- the network backup solution."); CloseServiceHandle(hsrvmanager); CloseServiceHandle(hservice); @@ -628,7 +577,7 @@ bacService::RemoveService() // How to remove the Bacula service depends upon the OS switch (g_platform_id) { - // Windows 95/98 + // Windows 95/98/Me case VER_PLATFORM_WIN32_WINDOWS: // Locate the RunService registry entry HKEY runservices; @@ -660,7 +609,7 @@ bacService::RemoveService() MessageBox(NULL, "The Bacula service has been removed", szAppName, MB_ICONINFORMATION | MB_OK); break; - // Windows NT + // Windows NT, Win2K, WinXP case VER_PLATFORM_WIN32_NT: SC_HANDLE hservice; SC_HANDLE hsrvmanager; @@ -690,11 +639,11 @@ bacService::RemoveService() // Try to stop the Bacula service if (ControlService(hservice, SERVICE_CONTROL_STOP, &status)) { while(QueryServiceStatus(hservice, &status)) { - if (status.dwCurrentState == SERVICE_STOP_PENDING) { - Sleep(1000); - } else { - break; - } + if (status.dwCurrentState == SERVICE_STOP_PENDING) { + Sleep(1000); + } else { + break; + } } if (status.dwCurrentState != SERVICE_STOPPED) { @@ -741,9 +690,8 @@ void WINAPI ServiceCtrl(DWORD ctrlcode) break; default: - // Control code not recognised - break; - + // Control code not recognised + break; } // Tell the control manager what we're up to. @@ -798,19 +746,19 @@ void LogErrorMsg(char *message, char *fname, int lineno) // Get the error code g_error = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER| - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - g_error, - 0, - (LPTSTR)&msg, - 0, - NULL); + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + g_error, + 0, + (LPTSTR)&msg, + 0, + NULL); // Use event logging to log the error heventsrc = RegisterEventSource(NULL, BAC_SERVICENAME); sprintf(msgbuff, "\n\n%s error: %ld at %s:%d", - BAC_SERVICENAME, g_error, fname, lineno); + BAC_SERVICENAME, g_error, fname, lineno); strings[0] = msgbuff; strings[1] = message; strings[2] = msg; @@ -833,8 +781,8 @@ void LogErrorMsg(char *message, char *fname, int lineno) } LocalFree(msg); } +typedef BOOL (*WinAPI)(SC_HANDLE, DWORD, LPVOID); -/* ================== Not yet implemented ===================== */ void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService, LPSTR lpDesc) { @@ -842,63 +790,71 @@ void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService, LPQUERY_SERVICE_LOCK_STATUS lpqslsBuf; SERVICE_DESCRIPTION sdBuf; DWORD dwBytesNeeded; + WinAPI ChangeServiceDescription; + HINSTANCE hLib = LoadLibrary("ADVAPI32.DLL"); + if (!hLib) { + return; + } + ChangeServiceDescription = (WinAPI)GetProcAddress(hLib, + "ChangeServiceConfig2A"); + FreeLibrary(hLib); + if (!ChangeServiceDescription) { + return; + } + // Need to acquire database lock before reconfiguring. - sclLock = LockServiceDatabase(hSCManager); // If the database cannot be locked, report the details. - if (sclLock == NULL) { - // Exit if the database is not locked by another process. + // Exit if the database is not locked by another process. + if (GetLastError() != ERROR_SERVICE_DATABASE_LOCKED) { + log_error_message("LockServiceDatabase"); + return; + } - if (GetLastError() != ERROR_SERVICE_DATABASE_LOCKED) { - log_error_message("LockServiceDatabase"); - return; - } - - // Allocate a buffer to get details about the lock. - lpqslsBuf = (LPQUERY_SERVICE_LOCK_STATUS)LocalAlloc( + // Allocate a buffer to get details about the lock. + lpqslsBuf = (LPQUERY_SERVICE_LOCK_STATUS)LocalAlloc( LPTR, sizeof(QUERY_SERVICE_LOCK_STATUS)+256); - if (lpqslsBuf == NULL) { - log_error_message("LocalAlloc"); - return; - } - - // Get and print the lock status information. + if (lpqslsBuf == NULL) { + log_error_message("LocalAlloc"); + return; + } - if (!QueryServiceLockStatus( - hSCManager, - lpqslsBuf, - sizeof(QUERY_SERVICE_LOCK_STATUS)+256, - &dwBytesNeeded)) { - log_error_message("QueryServiceLockStatus"); - } + // Get and print the lock status information. + if (!QueryServiceLockStatus( + hSCManager, + lpqslsBuf, + sizeof(QUERY_SERVICE_LOCK_STATUS)+256, + &dwBytesNeeded)) { + log_error_message("QueryServiceLockStatus"); + } - if (lpqslsBuf->fIsLocked) { - printf("Locked by: %s, duration: %ld seconds\n", + if (lpqslsBuf->fIsLocked) { + printf("Locked by: %s, duration: %ld seconds\n", lpqslsBuf->lpLockOwner, lpqslsBuf->dwLockDuration); - } else { - printf("No longer locked\n"); - } + } else { + printf("No longer locked\n"); + } - LocalFree(lpqslsBuf); - log_error_message("Could not lock database"); - return; + LocalFree(lpqslsBuf); + log_error_message("Could not lock database"); + return; } // The database is locked, so it is safe to make changes. sdBuf.lpDescription = lpDesc; - if(!ChangeServiceConfig2( - hService, // handle to service - SERVICE_CONFIG_DESCRIPTION, // change: description - &sdBuf) ) { // value: new description + if(!ChangeServiceDescription( + hService, // handle to service + SERVICE_CONFIG_DESCRIPTION, // change: description + &sdBuf) ) { // value: new description log_error_message("ChangeServiceConfig2"); } else { - printf("ChangeServiceConfig2 SUCCESS\n"); + printf("ChangeServiceConfig2 SUCCESS\n"); } // Release the database lock. diff --git a/bacula/src/findlib/Makefile.in b/bacula/src/findlib/Makefile.in index 034dacf9e3..3fb3888f02 100644 --- a/bacula/src/findlib/Makefile.in +++ b/bacula/src/findlib/Makefile.in @@ -21,9 +21,9 @@ dummy: # LIBSRCS = find.c match.c find_one.c attibs.c create_file.c \ - bfile.c get_priv.c makepath.c save-cwd.c + bfile.c get_priv.c makepath.c save-cwd.c winapi.c LIBOBJS = find.o match.o find_one.o attribs.o create_file.o \ - bfile.o get_priv.o makepath.o save-cwd.o + bfile.o get_priv.o makepath.o save-cwd.o winapi.o .SUFFIXES: .c .o .PHONY: diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index 449841b5ce..4fb1070b87 100755 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -285,8 +285,6 @@ int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt) #ifdef HAVE_CYGWIN -int NoGetFileAttributesEx = 0; - int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt) { char *p = attribsEx; @@ -295,12 +293,12 @@ int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt) attribsEx[0] = 0; /* no extended attributes */ - if (NoGetFileAttributesEx) { + if (!p_GetFileAttributesEx) { return STREAM_UNIX_ATTRIBUTES; } unix_name_to_win32(&ff_pkt->sys_fname, ff_pkt->fname); - if (!GetFileAttributesEx(ff_pkt->sys_fname, GetFileExInfoStandard, + if (!p_GetFileAttributesEx(ff_pkt->sys_fname, GetFileExInfoStandard, (LPVOID)&atts)) { win_error(jcr, "GetFileAttributesEx:", ff_pkt->sys_fname); return STREAM_WIN32_ATTRIBUTES; diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index fc8d442458..f3e8f02e1b 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -37,11 +37,11 @@ void unix_name_to_win32(POOLMEM **win32_name, char *name); extern "C" HANDLE get_osfhandle(int fd); -void binit(BFILE *bfd, int use_win_api) +void binit(BFILE *bfd) { bfd->fid = -1; bfd->mode = BF_CLOSED; - bfd->use_win_api = use_win_api; + bfd->use_win_api = p_BackupRead && p_BackupWrite; bfd->errmsg = NULL; bfd->lpContext = NULL; bfd->lerror = 0; @@ -129,7 +129,7 @@ int bclose(BFILE *bfd) } if (bfd->mode == BF_READ) { BYTE buf[10]; - if (!bfd->lpContext && !BackupRead(bfd->fh, + if (!bfd->lpContext && !p_BackupRead(bfd->fh, buf, /* buffer */ (DWORD)0, /* bytes to read */ &bfd->rw_bytes, /* bytes read */ @@ -140,7 +140,7 @@ int bclose(BFILE *bfd) } } else { BYTE buf[10]; - if (!bfd->lpContext && !BackupWrite(bfd->fh, + if (!bfd->lpContext && !p_BackupWrite(bfd->fh, buf, /* buffer */ (DWORD)0, /* bytes to read */ &bfd->rw_bytes, /* bytes written */ @@ -196,7 +196,7 @@ ssize_t bread(BFILE *bfd, void *buf, size_t count) } bfd->rw_bytes = 0; - if (!BackupRead(bfd->fh, + if (!p_BackupRead(bfd->fh, (BYTE *)buf, count, &bfd->rw_bytes, @@ -216,7 +216,7 @@ ssize_t bwrite(BFILE *bfd, void *buf, size_t count) } bfd->rw_bytes = 0; - if (!BackupWrite(bfd->fh, + if (!p_BackupWrite(bfd->fh, (BYTE *)buf, count, &bfd->rw_bytes, @@ -250,7 +250,7 @@ off_t blseek(BFILE *bfd, off_t offset, int whence) * * =============================================================== */ -void binit(BFILE *bfd, int use_win_api) +void binit(BFILE *bfd) { bfd->fid = -1; } diff --git a/bacula/src/findlib/create_file.c b/bacula/src/findlib/create_file.c index 56ab9da7b9..4fef6e50f8 100644 --- a/bacula/src/findlib/create_file.c +++ b/bacula/src/findlib/create_file.c @@ -63,14 +63,14 @@ static int path_already_seen(char *path, int pnl); */ int create_file(void *jcr, char *fname, char *ofile, char *lname, int type, int stream, struct stat *statp, - char *attribsEx, BFILE *ofd, int replace, int win_io) + char *attribsEx, BFILE *ofd, int replace) { int new_mode, parent_mode, mode; uid_t uid; gid_t gid; int pnl; - binit(ofd, win_io); + binit(ofd); new_mode = statp->st_mode; Dmsg2(300, "newmode=%x file=%s\n", new_mode, ofile); parent_mode = S_IWUSR | S_IXUSR | new_mode; diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index f7edc771b9..0ae3042114 100755 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -61,43 +61,43 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); /* * Status codes returned by create_file() */ -#define CF_SKIP 1 /* skip file (not newer or something) */ -#define CF_ERROR 2 /* error creating file */ -#define CF_EXTRACT 3 /* file created, data to extract */ -#define CF_CREATED 4 /* file created, no data to extract */ +#define CF_SKIP 1 /* skip file (not newer or something) */ +#define CF_ERROR 2 /* error creating file */ +#define CF_EXTRACT 3 /* file created, data to extract */ +#define CF_CREATED 4 /* file created, no data to extract */ /* * NOTE!!! These go on the tape, so don't change them. If * need be, add to them. */ -#define FT_LNKSAVED 1 /* hard link to file already saved */ -#define FT_REGE 2 /* Regular file but empty */ -#define FT_REG 3 /* Regular file */ -#define FT_LNK 4 /* Soft Link */ -#define FT_DIR 5 /* Directory */ -#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ -#define FT_NOACCESS 7 /* Not able to access */ -#define FT_NOFOLLOW 8 /* Could not follow link */ -#define FT_NOSTAT 9 /* Could not stat file */ -#define FT_NOCHG 10 /* Incremental option, file not changed */ -#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ -#define FT_ISARCH 12 /* Trying to save archive file */ -#define FT_NORECURSE 13 /* No recursion into directory */ -#define FT_NOFSCHG 14 /* Different file system, prohibited */ -#define FT_NOOPEN 15 /* Could not open directory */ -#define FT_RAW 16 /* Raw block device */ -#define FT_FIFO 17 /* Raw fifo device */ +#define FT_LNKSAVED 1 /* hard link to file already saved */ +#define FT_REGE 2 /* Regular file but empty */ +#define FT_REG 3 /* Regular file */ +#define FT_LNK 4 /* Soft Link */ +#define FT_DIR 5 /* Directory */ +#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ +#define FT_NOACCESS 7 /* Not able to access */ +#define FT_NOFOLLOW 8 /* Could not follow link */ +#define FT_NOSTAT 9 /* Could not stat file */ +#define FT_NOCHG 10 /* Incremental option, file not changed */ +#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ +#define FT_ISARCH 12 /* Trying to save archive file */ +#define FT_NORECURSE 13 /* No recursion into directory */ +#define FT_NOFSCHG 14 /* Different file system, prohibited */ +#define FT_NOOPEN 15 /* Could not open directory */ +#define FT_RAW 16 /* Raw block device */ +#define FT_FIFO 17 /* Raw fifo device */ /* Options saved in "flag" of ff packet */ -#define FO_MD5 0x001 /* Do MD5 checksum */ -#define FO_GZIP 0x002 /* Do Zlib compression */ -#define FO_NO_RECURSION 0x004 /* no recursion in directories */ -#define FO_MULTIFS 0x008 /* multiple file systems */ -#define FO_SPARSE 0x010 /* do sparse file checking */ -#define FO_IF_NEWER 0x020 /* replace if newer */ -#define FO_NOREPLACE 0x040 /* never replace */ -#define FO_READFIFO 0x080 /* read data from fifo */ -#define FO_SHA1 0x100 /* Do SHA1 checksum */ +#define FO_MD5 0x001 /* Do MD5 checksum */ +#define FO_GZIP 0x002 /* Do Zlib compression */ +#define FO_NO_RECURSION 0x004 /* no recursion in directories */ +#define FO_MULTIFS 0x008 /* multiple file systems */ +#define FO_SPARSE 0x010 /* do sparse file checking */ +#define FO_IF_NEWER 0x020 /* replace if newer */ +#define FO_NOREPLACE 0x040 /* never replace */ +#define FO_READFIFO 0x080 /* read data from fifo */ +#define FO_SHA1 0x100 /* Do SHA1 checksum */ /* * Options saved in "options" of include list @@ -109,21 +109,21 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); #define OPT_compute_MD5 0x01 /* compute MD5 of file's data */ #define OPT_GZIP_compression 0x02 /* use GZIP compression */ #define OPT_no_recursion 0x04 /* no recursion in directories */ -#define OPT_multifs 0x08 /* multiple file systems */ -#define OPT_sparse 0x10 /* do sparse file checking */ +#define OPT_multifs 0x08 /* multiple file systems */ +#define OPT_sparse 0x10 /* do sparse file checking */ #define OPT_replace_if_newer 0x20 /* replace file if newer */ #define OPT_never_replace 0x40 /* never replace */ -#define OPT_read_fifo 0x80 /* read data from fifo (named pipe) */ +#define OPT_read_fifo 0x80 /* read data from fifo (named pipe) */ #define OPT_compute_SHA1 0x100 /* compute SHA1 of file's data */ struct s_included_file { struct s_included_file *next; - int options; /* backup options */ - int level; /* compression level */ - int len; /* length of fname */ - int pattern; /* set if pattern */ - char VerifyOpts[20]; /* Options for verify */ + int options; /* backup options */ + int level; /* compression level */ + int len; /* length of fname */ + int pattern; /* set if pattern */ + char VerifyOpts[20]; /* Options for verify */ char fname[1]; }; @@ -136,28 +136,29 @@ struct s_excluded_file { #ifdef HAVE_CYGWIN #include +#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 */ /* Basic low level I/O file packet */ typedef struct s_bfile { - int use_win_api; /* set if using WinAPI */ - 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 */ + int use_win_api; /* set if using WinAPI */ + 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; #else /* Basic low level I/O file packet */ typedef struct s_bfile { - int fid; /* file id on Unix */ + int fid; /* file id on Unix */ } BFILE; #endif @@ -168,30 +169,30 @@ typedef struct s_bfile { * first argument to the find_files callback subroutine. */ typedef struct s_ff { - char *fname; /* filename */ - char *link; /* link if file linked */ - POOLMEM *sys_fname; /* system filename */ - struct stat statp; /* stat packet */ - uint32_t FileIndex; /* FileIndex of this file */ - uint32_t LinkFI; /* FileIndex of main hard linked file */ - struct f_link *linked; /* Set if we are hard linked */ - int type; /* FT_ type from above */ - int flags; /* control flags */ - int ff_errno; /* errno */ - int incremental; /* do incremental save */ - BFILE bfd; /* Bacula file descriptor */ - time_t save_time; /* start of incremental time */ - int mtime_only; /* incremental on mtime_only */ - int dereference; /* follow links */ - int GZIP_level; /* compression level */ - int atime_preserve; /* preserve access times */ - int null_output_device; /* using null output device */ + char *fname; /* filename */ + char *link; /* link if file linked */ + POOLMEM *sys_fname; /* system filename */ + struct stat statp; /* stat packet */ + uint32_t FileIndex; /* FileIndex of this file */ + uint32_t LinkFI; /* FileIndex of main hard linked file */ + struct f_link *linked; /* Set if we are hard linked */ + int type; /* FT_ type from above */ + int flags; /* control flags */ + int ff_errno; /* errno */ + int incremental; /* do incremental save */ + BFILE bfd; /* Bacula file descriptor */ + time_t save_time; /* start of incremental time */ + int mtime_only; /* incremental on mtime_only */ + int dereference; /* follow links */ + int GZIP_level; /* compression level */ + int atime_preserve; /* preserve access times */ + int null_output_device; /* using null output device */ char VerifyOpts[20]; struct s_included_file *included_files_list; struct s_excluded_file *excluded_files_list; struct s_excluded_file *excluded_paths_list; - struct f_link *linklist; /* hard linked files */ + struct f_link *linklist; /* hard linked files */ } FF_PKT; diff --git a/bacula/src/findlib/protos.h b/bacula/src/findlib/protos.h index 0d17d1342e..71e5a3f817 100644 --- a/bacula/src/findlib/protos.h +++ b/bacula/src/findlib/protos.h @@ -24,17 +24,17 @@ */ /* from attribs.c */ -void encode_stat (char *buf, struct stat *statp, uint32_t LinkFI); -void decode_stat (char *buf, struct stat *statp, uint32_t *LinkFI); -int encode_attribsEx (void *jcr, char *attribsEx, FF_PKT *ff_pkt); +void encode_stat (char *buf, struct stat *statp, uint32_t LinkFI); +void decode_stat (char *buf, struct stat *statp, uint32_t *LinkFI); +int encode_attribsEx (void *jcr, char *attribsEx, FF_PKT *ff_pkt); int set_attributes(void *jcr, char *fname, char *ofile, char *lname, - int type, int stream, struct stat *statp, - char *attribsEx, BFILE *ofd); + int type, int stream, struct stat *statp, + char *attribsEx, BFILE *ofd); /* from create_file.c */ int create_file(void *jcr, char *fname, char *ofile, char *lname, - int type, int stream, struct stat *statp, - char *attribsEx, BFILE *ofd, int replace, int win_io); + int type, int stream, struct stat *statp, + char *attribsEx, BFILE *ofd, int replace); /* From find.c */ FF_PKT *init_find_files(); @@ -50,11 +50,11 @@ void add_fname_to_exclude_list(FF_PKT *ff, char *fname); int file_is_excluded(FF_PKT *ff, char *file); int file_is_included(FF_PKT *ff, char *file); struct s_included_file *get_next_included_file(FF_PKT *ff, - struct s_included_file *inc); + struct s_included_file *inc); /* From find_one.c */ int find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt), - void *pkt, char *p, dev_t parent_device, int top_level); + void *pkt, char *p, dev_t parent_device, int top_level); int term_find_one(FF_PKT *ff); @@ -64,16 +64,16 @@ void get_backup_privileges(void *jcr, int ignore_errors); /* from makepath.c */ int make_path(void *jcr, const char *argpath, int mode, - int parent_mode, uid_t owner, gid_t group, - int preserve_existing, char *verbose_fmt_string); + int parent_mode, uid_t owner, gid_t group, + int preserve_existing, char *verbose_fmt_string); /* from file_io.c */ ssize_t bread(BFILE *bfd, void *buf, size_t count); -int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode); -int bclose(BFILE *bfd); +int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode); +int bclose(BFILE *bfd); ssize_t bread(BFILE *bfd, void *buf, size_t count); ssize_t bwrite(BFILE *bfd, void *buf, size_t count); -off_t blseek(BFILE *bfd, off_t offset, int whence); -int is_bopen(BFILE *bfd); -void binit(BFILE *bfd, int use_win_api); -char *berror(BFILE *bfd); +off_t blseek(BFILE *bfd, off_t offset, int whence); +int is_bopen(BFILE *bfd); +void binit(BFILE *bfd); +char *berror(BFILE *bfd); diff --git a/bacula/src/findlib/winapi.c b/bacula/src/findlib/winapi.c new file mode 100644 index 0000000000..6715afdca7 --- /dev/null +++ b/bacula/src/findlib/winapi.c @@ -0,0 +1,44 @@ +/* + * Windows APIs that are different for each system. + * We use pointers to the entry points so that a + * single binary will run on all Windows systems. + * + * Kern Sibbald MMIII + */ +/* + Copyright (C) 2000-2003 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +#include "bacula.h" +#include "find.h" + +#ifdef HAVE_CYGWIN + +/* API Pointers */ + +t_OpenProcessToken p_OpenProcessToken = NULL; +t_AdjustTokenPrivileges p_AdjustTokenPrivileges = NULL; +t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL; + +t_GetFileAttributesEx p_GetFileAttributesEx = NULL; +t_BackupRead p_BackupRead = NULL; +t_BackupWrite p_BackupWrite = NULL; +t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL; + +#endif diff --git a/bacula/src/findlib/winapi.h b/bacula/src/findlib/winapi.h new file mode 100644 index 0000000000..c758eeb017 --- /dev/null +++ b/bacula/src/findlib/winapi.h @@ -0,0 +1,56 @@ +/* + * Windows APIs that are different for each system. + * We use pointers to the entry points so that a + * single binary will run on all Windows systems. + * + * Kern Sibbald MMIII + */ +/* + Copyright (C) 2000-2003 Kern Sibbald and John Walker + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA. + + */ + +#ifndef __WINAPI_H +#define __WINAPI_H + +#ifdef HAVE_CYGWIN +/* In ADVAPI32.DLL */ +typedef BOOL (*t_OpenProcessToken)(HANDLE, DWORD, PHANDLE); +typedef BOOL (*t_AdjustTokenPrivileges)(HANDLE, BOOL, + PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD); +typedef BOOL (*t_LookupPrivilegeValue)(LPCTSTR, LPCTSTR, PLUID); + +extern t_OpenProcessToken p_OpenProcessToken; +extern t_AdjustTokenPrivileges p_AdjustTokenPrivileges; +extern t_LookupPrivilegeValue p_LookupPrivilegeValue; + +/* In KERNEL32.DLL */ +typedef BOOL (*t_GetFileAttributesEx)(LPCTSTR, GET_FILEEX_INFO_LEVELS, + LPVOID); +typedef BOOL (*t_SetProcessShutdownParameters)(DWORD, DWORD); +typedef BOOL (*t_BackupRead)(HANDLE,LPBYTE,DWORD,LPDWORD,BOOL,BOOL,LPVOID*); +typedef BOOL (*t_BackupWrite)(HANDLE,LPBYTE,DWORD,LPDWORD,BOOL,BOOL,LPVOID*); + +extern t_GetFileAttributesEx p_GetFileAttributesEx; +extern t_SetProcessShutdownParameters p_SetProcessShutdownParameters; +extern t_BackupRead p_BackupRead; +extern t_BackupWrite p_BackupWrite; + +#endif + +#endif /* __WINAPI_H */ diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index d65f747c12..53f9686fad 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -178,7 +178,6 @@ struct s_jcr { uint32_t EndFile; uint32_t StartBlock; uint32_t EndBlock; - int use_win_backup_api; /* set to use native Win API */ pthread_t heartbeat_id; /* id of heartbeat thread */ BSOCK *hb_bsock; /* duped SD socket */ #endif /* FILE_DAEMON */ diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 058e9c7a08..e8224b2d8b 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -24,144 +24,144 @@ */ /* base64.c */ -void base64_init (void); -int to_base64 (intmax_t value, char *where); -int from_base64 (intmax_t *value, char *where); -int bin_to_base64 (char *buf, char *bin, int len); +void base64_init (void); +int to_base64 (intmax_t value, char *where); +int from_base64 (intmax_t *value, char *where); +int bin_to_base64 (char *buf, char *bin, int len); /* bmisc.c */ -char *bstrncpy (char *dest, const char *src, int maxlen); -char *bstrncat (char *dest, const char *src, int maxlen); -void *b_malloc (char *file, int line, size_t size); +char *bstrncpy (char *dest, const char *src, int maxlen); +char *bstrncat (char *dest, const char *src, int maxlen); +void *b_malloc (char *file, int line, size_t size); #ifndef DEBUG -void *bmalloc (size_t size); +void *bmalloc (size_t size); #endif -void *brealloc (void *buf, size_t size); -void *bcalloc (size_t size1, size_t size2); -int bsnprintf (char *str, size_t size, const char *format, ...); -int bvsnprintf (char *str, size_t size, const char *format, va_list ap); -int pool_sprintf (char *pool_buf, char *fmt, ...); -void create_pid_file (char *dir, char *progname, int port); -int delete_pid_file (char *dir, char *progname, int port); -void drop (char *uid, char *gid); -int bmicrosleep (time_t sec, long msec); +void *brealloc (void *buf, size_t size); +void *bcalloc (size_t size1, size_t size2); +int bsnprintf (char *str, size_t size, const char *format, ...); +int bvsnprintf (char *str, size_t size, const char *format, va_list ap); +int pool_sprintf (char *pool_buf, char *fmt, ...); +void create_pid_file (char *dir, char *progname, int port); +int delete_pid_file (char *dir, char *progname, int port); +void drop (char *uid, char *gid); +int bmicrosleep (time_t sec, long msec); #ifndef HAVE_STRTOLL -long long int stroll(const char *ptr, char **endptr, int base); +long long int strtoll(const char *ptr, char **endptr, int base); #endif /* bnet.c */ -int32_t bnet_recv (BSOCK *bsock); -int bnet_send (BSOCK *bsock); -int bnet_fsend (BSOCK *bs, char *fmt, ...); -int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); -int bnet_sig (BSOCK *bs, int sig); -int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); -int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); -BSOCK * bnet_connect (void *jcr, int retry_interval, - int max_retry_time, char *name, char *host, char *service, - int port, int verbose); -void bnet_close (BSOCK *bsock); -BSOCK * init_bsock (void *jcr, int sockfd, char *who, char *ip, int port); -BSOCK * dup_bsock (BSOCK *bsock); -void term_bsock (BSOCK *bsock); -char * bnet_strerror (BSOCK *bsock); -char * bnet_sig_to_ascii (BSOCK *bsock); -int bnet_wait_data (BSOCK *bsock, int sec); -int bnet_wait_data_intr (BSOCK *bsock, int sec); -int bnet_despool (BSOCK *bsock); -int is_bnet_stop (BSOCK *bsock); -int is_bnet_error (BSOCK *bsock); -void bnet_suppress_error_messages(BSOCK *bsock, int flag); +int32_t bnet_recv (BSOCK *bsock); +int bnet_send (BSOCK *bsock); +int bnet_fsend (BSOCK *bs, char *fmt, ...); +int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); +int bnet_sig (BSOCK *bs, int sig); +int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); +int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); +BSOCK * bnet_connect (void *jcr, int retry_interval, + int max_retry_time, char *name, char *host, char *service, + int port, int verbose); +void bnet_close (BSOCK *bsock); +BSOCK * init_bsock (void *jcr, int sockfd, char *who, char *ip, int port); +BSOCK * dup_bsock (BSOCK *bsock); +void term_bsock (BSOCK *bsock); +char * bnet_strerror (BSOCK *bsock); +char * bnet_sig_to_ascii (BSOCK *bsock); +int bnet_wait_data (BSOCK *bsock, int sec); +int bnet_wait_data_intr (BSOCK *bsock, int sec); +int bnet_despool (BSOCK *bsock); +int is_bnet_stop (BSOCK *bsock); +int is_bnet_error (BSOCK *bsock); +void bnet_suppress_error_messages(BSOCK *bsock, int flag); /* bget_msg.c */ -int bget_msg(BSOCK *sock); +int bget_msg(BSOCK *sock); /* cram-md5.c */ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need); int cram_md5_auth(BSOCK *bs, char *password, int ssl_need); void hmac_md5(uint8_t* text, int text_len, uint8_t* key, - int key_len, uint8_t *hmac); + int key_len, uint8_t *hmac); /* crc32.c */ uint32_t bcrc32(uint8_t *buf, int len); /* daemon.c */ -void daemon_start (); +void daemon_start (); /* edit.c */ -uint64_t str_to_uint64(char *str); -int64_t str_to_int64(char *str); -char * edit_uint64_with_commas (uint64_t val, char *buf); -char * add_commas (char *val, char *buf); -char * edit_uint64 (uint64_t val, char *buf); -int duration_to_utime (char *str, utime_t *value); -int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); -char *edit_utime (utime_t val, char *buf); -int is_a_number (const char *num); -int is_an_integer (const char *n); +uint64_t str_to_uint64(char *str); +int64_t str_to_int64(char *str); +char * edit_uint64_with_commas (uint64_t val, char *buf); +char * add_commas (char *val, char *buf); +char * edit_uint64 (uint64_t val, char *buf); +int duration_to_utime (char *str, utime_t *value); +int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); +char *edit_utime (utime_t val, char *buf); +int is_a_number (const char *num); +int is_an_integer (const char *n); /* lex.c */ -LEX * lex_close_file (LEX *lf); -LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error); -int lex_get_char (LEX *lf); -void lex_unget_char (LEX *lf); -char * lex_tok_to_str (int token); -int lex_get_token (LEX *lf, int expect); +LEX * lex_close_file (LEX *lf); +LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error); +int lex_get_char (LEX *lf); +void lex_unget_char (LEX *lf); +char * lex_tok_to_str (int token); +int lex_get_token (LEX *lf, int expect); /* message.c */ -void my_name_is (int argc, char *argv[], char *name); -void init_msg (void *jcr, MSGS *msg); -void term_msg (void); -void close_msg (void *jcr); -void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); -void rem_msg_dest (MSGS *msg, int dest, int type, char *where); -void Jmsg (void *jcr, int type, int level, char *fmt, ...); -void dispatch_message (void *jcr, int type, int level, char *buf); -void init_console_msg (char *wd); -void free_msgs_res (MSGS *msgs); -int open_spool_file (void *jcr, BSOCK *bs); -int close_spool_file (void *vjcr, BSOCK *bs); +void my_name_is (int argc, char *argv[], char *name); +void init_msg (void *jcr, MSGS *msg); +void term_msg (void); +void close_msg (void *jcr); +void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); +void rem_msg_dest (MSGS *msg, int dest, int type, char *where); +void Jmsg (void *jcr, int type, int level, char *fmt, ...); +void dispatch_message (void *jcr, int type, int level, char *buf); +void init_console_msg (char *wd); +void free_msgs_res (MSGS *msgs); +int open_spool_file (void *jcr, BSOCK *bs); +int close_spool_file (void *vjcr, BSOCK *bs); /* bnet_server.c */ -void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq, - void *handle_client_request(void *bsock)); -void bnet_server (int port, void handle_client_request(BSOCK *bsock)); -int net_connect (int port); -BSOCK * bnet_bind (int port); -BSOCK * bnet_accept (BSOCK *bsock, char *who); +void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq, + void *handle_client_request(void *bsock)); +void bnet_server (int port, void handle_client_request(BSOCK *bsock)); +int net_connect (int port); +BSOCK * bnet_bind (int port); +BSOCK * bnet_accept (BSOCK *bsock, char *who); /* signal.c */ -void init_signals (void terminate(int sig)); -void init_stack_dump (void); +void init_signals (void terminate(int sig)); +void init_stack_dump (void); /* util.c */ -void lcase (char *str); -void bash_spaces (char *str); -void unbash_spaces (char *str); -void strip_trailing_junk (char *str); -void strip_trailing_slashes (char *dir); -int skip_spaces (char **msg); -int skip_nonspaces (char **msg); -int fstrsch (char *a, char *b); -char * encode_time (time_t time, char *buf); -char * encode_mode (mode_t mode, char *buf); -int do_shell_expansion (char *name); -int is_buf_zero (char *buf, int len); -void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen); -void pm_strcat (POOLMEM **pm, char *str); -void pm_strcpy (POOLMEM **pm, char *str); -int run_program (char *prog, int wait, POOLMEM *results); -char * job_type_to_str (int type); -char * job_status_to_str (int stat); -char * job_level_to_str (int level); -void makeSessionKey (char *key, char *seed, int mode); -BPIPE * open_bpipe(char *prog, int wait, char *mode); -int close_wpipe(BPIPE *bpipe); -int close_bpipe(BPIPE *bpipe); -POOLMEM *edit_job_codes(void *jcr, char *omsg, char *imsg, char *to); +void lcase (char *str); +void bash_spaces (char *str); +void unbash_spaces (char *str); +void strip_trailing_junk (char *str); +void strip_trailing_slashes (char *dir); +int skip_spaces (char **msg); +int skip_nonspaces (char **msg); +int fstrsch (char *a, char *b); +char * encode_time (time_t time, char *buf); +char * encode_mode (mode_t mode, char *buf); +int do_shell_expansion (char *name); +int is_buf_zero (char *buf, int len); +void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen); +void pm_strcat (POOLMEM **pm, char *str); +void pm_strcpy (POOLMEM **pm, char *str); +int run_program (char *prog, int wait, POOLMEM *results); +char * job_type_to_str (int type); +char * job_status_to_str (int stat); +char * job_level_to_str (int level); +void makeSessionKey (char *key, char *seed, int mode); +BPIPE * open_bpipe(char *prog, int wait, char *mode); +int close_wpipe(BPIPE *bpipe); +int close_bpipe(BPIPE *bpipe); +POOLMEM *edit_job_codes(void *jcr, char *omsg, char *imsg, char *to); void parse_command_args(POOLMEM *cmd, POOLMEM *args, int *argc, - char **argk, char **argv); + char **argk, char **argv); char *next_arg(char **s); diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 4730545698..ad2e7ad65a 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -102,7 +102,7 @@ int main (int argc, char *argv[]) memset(ff, 0, sizeof(FF_PKT)); init_include_exclude_files(ff); - binit(&bfd, 0); + binit(&bfd); while ((ch = getopt(argc, argv, "b:c:d:e:i:?")) != -1) { switch (ch) { @@ -374,7 +374,7 @@ static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec) extract = FALSE; stat = create_file(jcr, fname, ofile, lname, type, stream, - &statp, attribsEx, &bfd, REPLACE_ALWAYS, 0); + &statp, attribsEx, &bfd, REPLACE_ALWAYS); switch (stat) { case CF_ERROR: case CF_SKIP: diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 5bccfb6f82..a6c3bee4fd 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -410,6 +410,7 @@ eod_dev(DEVICE *dev) } return 0; } +#ifdef MTEOM if (dev_cap(dev, CAP_EOM)) { mt_com.mt_op = MTEOM; mt_com.mt_count = 1; @@ -434,6 +435,9 @@ eod_dev(DEVICE *dev) * Rewind then use FSF until EOT reached */ } else { +#else + { +#endif if (!rewind_dev(dev)) { return 0; } @@ -980,10 +984,12 @@ clrerror_dev(DEVICE *dev, int func) msg = "WTWEOF"; dev->capabilities &= ~CAP_EOF; /* turn off feature */ break; +#ifdef MTEOM case MTEOM: msg = "WTEOM"; dev->capabilities &= ~CAP_EOM; /* turn off feature */ break; +#endif case MTFSF: msg = "MTFSF"; dev->capabilities &= ~CAP_FSF; /* turn off feature */ -- 2.39.5