From: Bdale Garbee Date: Tue, 20 May 2008 04:47:20 +0000 (-0600) Subject: Imported Upstream version 2.5.1 X-Git-Tag: upstream/2.5.1^0 X-Git-Url: https://git.gag.com/?p=debian%2Famanda;a=commitdiff_plain;h=12179dea039515c06168c0037d048566a3f623de Imported Upstream version 2.5.1 --- diff --git a/ChangeLog b/ChangeLog index 5948c18..c0c9820 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,57 +1,2086 @@ -2006-05-28 Jean-Louis Martineau +2006-09-05 Jean-Louis Martineau + * Amanda 2.5.1 released. + * configure.in: AM_INIT_AUTOMAKE(amanda, 2.5.1). + * NEWS: Change in amanda-2.5.1 + +2006-08-30 Jean-Louis Martineau + * server-src/dumper.c: Typo in error message. + +2006-08-29 Jean-Louis Martineau + * client-src/selfcheck.c: Print error message to stdout before + calling error(). + +2006-08-28 Jean-Louis Martineau + * server-src/dumper.c (log_msgout): Seek to begining of file. + +2006-08-28 Jean-Louis Martineau + * server-src/reporter.c: Report if a dump was successfully retried. + +2006-08-28 Jean-Louis Martineau + * server-src/amstatus.pl.in: Correct size for retried dump. + +2006-08-25 Jean-Louis Martineau + * client-src/runtar.c: Check that strcmp(argv[3], "--create") == 0. + +2006-08-24 Jean-Louis Martineau + * common-src/statfs.c (scale): Macro replaced by a function. + +2006-08-24 Jean-Louis Martineau + * server-src/chunker.c: Use STREAM_BUFSIZE for stream_accept. + * server-src/taper.c: Use STREAM_BUFSIZE for stream_accept. + +2006-08-24 Maitreyee Karmarkar + * man/xml-source/amcheck.8.xml: amcheck xml man page change + +2006-08-23 Kevin Till + * server-src/driver.c: fix typo + +2006-08-23 Jean-Louis Martineau + * server-src/driver.c (dumper_result): Decrement pendings_aborts. + * server-src/driver.c (handle_dumper_result): Don't send duper result + to chunker if we aborted it. + * server-src/driverio.c (dumper_cmd, chunker_cmd): Don't close the fd + on ABORT. + * server-src/dumper.c: Accept ABORT command. + +2006-08-23 Jean-Louis Martineau + * restore-src/restore.c (restore): Set bytes_read to the return value + of read_file_header. + +2006-08-22 Jean-Louis Martineau + * tape-src/output-tape.c: Works if EOVERFLOW is not defined. + +2006-08-21 Jean-Louis Martineau + * amandad-src/amandad.c, common-src/rsh-security.c, + common-src/ssh-security.c, restore-src/restore.c, + server-src/changer.c, server-src/dumper.c: Fix sentinel warning. + +2006-08-21 Jean-Louis Martineau + * example/amanda.conf.in: Typo. + +2006-08-21 Jean-Louis Martineau + * server-src/driverio.c: Fix bogus "(unsigned long)-1". + +2006-08-21 Jean-Louis Martineau + * server-src/driver.c (start_some_dumps): Remove bogus free_assignedhd. + +2006-08-21 Maitreyee Karmarkar + * server-src/amcheck.c: Check specific clients + * man/amcheck.8: add the multiple client check format + +2006-08-18 Ian Turner + * tape-src/amtapetype.c: Don't crash on exit + +2006-08-17 Paddy Sreenivasan + * server-src/driverio.c: + * server-src/changer.c: + * restore-src/amfetchdump.c: + * recover-src/extract_list.c: + * oldrecover-src/extract_list.c: + * common-src/util.c: + * common-src/stream.c: + * common-src/file.c: + * common-src/dgram.c: Fix warnings + +2006-08-17 Kevin Till + * common-src/stream.c: Loop 5 times (ntries > 5) on select error + +2006-08-14 Paddy Sreenivasan + * client-src/sendsize.c: Fix warning + * server-src/reporter.c: Fix warnings + +2006-07-28 Jean-Louis Martineau + * Amanda 2.5.1b2 released. + * configure.in: AM_INIT_AUTOMAKE(amanda, 2.5.1b2). + +2006-07-28 Jean-Louis Martineau + * server-src/driver.c (find_diskspace): Make sure size > 0. + +2006-07-28 Jean-Louis Martineau + * server-src/planner.c: Don't check new disk. + +2006-07-28 Jean-Louis Martineau + * server-src/planner.c: Always log if full size estimate is larger + than the available tape space. + +2006-07-28 Jean-Louis Martineau + * server-src/planner.c: Always log if the latest full dump will be + overwritten soon. + +2006-07-27 Jean-Louis Martineau + * common-src/clock.c (timesub): Don't make a negative time. + +2006-07-27 Jean-Louis Martineau + * man/xml-source/amanda.conf.5.xml: Tell which file are loaded. + * man/xml-source/amanda-client.conf.5.xml: Ditto. + +2006-07-26 Jean-Louis Martineau + * NEWS: for 2.5.1b2. + +2006-07-26 Jean-Louis Martineau + * common-src/util.h (CONFTYPE_HOLDING): New conftype. + * common-src/util.c (conf_init_holding, conf_set_holding, + get_conftype_hold): New fonction. + * example/amanda.conf.in: Example of new holdingdisk value. + * man/xml-source/amanda.8.xml: Example. + * man/xml-source/amanda.conf.5.xml: Document it. + * server-src/amadmin.c (disklist_one): Print holdingdisk value. + * server-src/conffile.c: Parse new CONF_HOLDING type. + * server-src/conffile.h (dumptype_get_to_holdingdisk): Change macro. + * server-src/diskfile.c (parse_diskline): dumptype_get_to_holdingdisk. + * server-src/driver.c: Use new CONFTYPE_HOLDING value. + +2006-07-26 Jean-Louis Martineau + * client-src/selfcheck.c: Fix bug found by coverity. + * common-src/debug.c: Fix bug found by coverity. + +2006-07-25 Jean-Louis Martineau + * server-src/amflush.c: Typo. + +2006-07-25 Jean-Louis Martineau + * server-src/amflush.c: Correct test for driver_stream. + +2006-07-25 Jean-Louis Martineau + * client-src/clientconf.c: Default CLN_AMANDATES to /etc/amandates. + * common-src/util.c (conf_init_size): Type is CONFTYPE_SIZE. + * server-src/conffile.c (getconf_taperalgo): New function. + * server-src/conffile.h (getconf_taperalgo): Prototype. + * server-src/driver.c: Use getconf_taperalgo. + +2006-07-25 Jean-Louis Martineau + * client-src/clientconf.c (client_getconf_boolean): New function. + * client-src/clientconf.h (client_getconf_boolean): Prototype. + * server-src/conffile.c (getconf_boolean): New function. + * server-src/conffile.h (getconf_boolean): Prototype. + * restore-src/amidxtaped.c: Use getconf_boolean. + * server-src/amflush.c: Use getconf_boolean. + * server-src/planner.c: Use getconf_boolean. + +2006-07-25 Jean-Louis Martineau + * server-src/getconf.c: Don't print BUGGY. + * changer-src/chg-chio.pl.in: Don't parse BUGGY. + * changer-src/chg-iomega.pl.in: Don't parse BUGGY. + * changer-src/chg-zd-mtx.sh.in: Don't parse BUGGY. + * man/xml-source/amgetconf.8.xml: Don't parse BUGGY. + * server-src/amverifyrun.sh.in: Don't parse BUGGY. + * server-src/amverify.sh.in: Don't parse BUGGY. + +2006-07-25 Jean-Louis Martineau + * restore-src/restore.c: Cleanup. + * restore-src/amrestore.c: Don't fsf if the last read return 0. + +2006-07-25 Jean-Louis Martineau + * client-src/selfcheck.c: Fix bug found by klocwork. + * common-src/rsh-security.c: Fix bug found by klocwork. + * common-src/ssh-security.c: Fix bug found by klocwork. + * server-src/planner.c: Fix bug found by klocwork. + +2006-07-25 Jean-Louis Martineau + * tape-src/output-tape.c (tape_tape_open): mt is declared inside #ifdef. + +2006-07-25 Jean-Louis Martineau + * server-src/amcheck.c: Fix quoting. + +2006-07-25 Jean-Louis Martineau + * client-src/clientconf.c: client_getconf* validate the type. + * common-src/util.c (get_conftype_*): New function. + * common-src/util.h (get_conftype_*): Prototype. + * server-src/conffile.c: getconf* validate the type. + * server-src/conffile.h: Use get_conftype_* function. + +2006-07-25 Jean-Louis Martineau + * client-src/clientconf.c: New AMANDATES client config option. + * client-src/clientconf.h: New AMANDATES client config option. + * client-src/amandates.c: Use AMANDATES. + * client-src/amandates.h: Use AMANDATES. + * client-src/selfcheck.c: Use AMANDATES. + * client-src/sendbackup-gnutar.c: Use AMANDATES. + * client-src/sendsize.c:: Use AMANDATES. + * common-src/util.h : New CONF_AMANDATES. + * man/xml-source/amanda-client.conf.5.xml: Document it. + +2006-07-25 Jean-Louis Martineau + * client-src/clientconf.c: New GNUTAR_LIST_DIR client config option. + * client-src/clientconf.h: New GNUTAR_LIST_DIR client config option. + * client-src/selfcheck.c: Use GNUTAR_LIST_DIR. + * client-src/sendbackup-gnutar.c: Use GNUTAR_LIST_DIR. + * client-src/sendsize.c: Use GNUTAR_LIST_DIR. + * common-src/util.h: New CONF_GNUTAR_LIST_DIR. + * man/xml-source/amanda-client.conf.5.xml: Document it. + +2006-07-25 Jean-Louis Martineau + * client-src/calcsize.c, client-src/killpgrp.c, + client-src/rundump.c, client-src/runtar.c, + client-src/selfcheck.c, client-src/sendbackup.c, + client-src/sendsize.c, common-src/amanda.h, + common-src/debug.c, oldrecover-src/amrecover.c, + recover-src/amrecover.c, restore-src/amfetchdump.c, + restore-src/amidxtaped.c, server-src/amadmin.c, + server-src/amcheck.c, server-src/amcleanupdisk.c, + server-src/amflush.c, server-src/amindexd.c, + server-src/amlabel.c, server-src/amlogroll.c, + server-src/amtape.c, server-src/amtrmidx.c, + server-src/amtrmlog.c, server-src/chunker.c, + server-src/driver.c, server-src/dumper.c, + server-src/getconf.c, server-src/planner.c, + server-src/reporter.c, server-src/taper.c: dbrename ot the config dir. + +2006-07-25 Jean-Louis Martineau + * common-src/amanda.h: Define DBG_SUBDIR_SERVER, DBG_SUBDIR_CLIENT + and DBG_SUBDIR_CLIENT. + * amandad-src/amandad.c, changer-src/chg-scsi.c, + changer-src/chg-scsi-chio.c, client-src/calcsize.c, + client-src/killpgrp.c, client-src/rundump.c, client-src/runtar.c, + client-src/selfcheck.c, client-src/sendbackup.c, + client-src/sendsize.c, + oldrecover-src/amrecover.c, recover-src/amrecover.c, + restore-src/amfetchdump.c, restore-src/amidxtaped.c, + restore-src/amrestore.c, server-src/amadmin.c, + server-src/amcheck.c, server-src/amcleanupdisk.c, + server-src/amflush.c, server-src/amindexd.c, + server-src/amlabel.c, server-src/amlogroll.c, + server-src/amtape.c, server-src/amtrmidx.c, + server-src/amtrmlog.c, server-src/chunker.c, + server-src/diskfile.c, server-src/driver.c, + server-src/dumper.c, server-src/getconf.c, + server-src/infofile.c, server-src/planner.c, + server-src/reporter.c (dbopen): Use DBG_SUBDIR_SERVER, + DBG_SUBDIR_CLIENT or DBG_SUBDIR_CLIENT. + +2006-07-25 Jean-Louis Martineau + * client-src/calcsize.c: Get config on argument. + * client-src/killpgrp.c: Get config on argument. + * client-src/rundump.c: Get config on argument. + * client-src/runtar.c: Get config on argument. + * client-src/sendbackup.c: Call program with config as argument. + * client-src/sendbackup-dump.c: Call program with config as argument. + * client-src/sendbackup-gnutar.c: Call program with config as argument. + * client-src/sendbackup.h: Add global g_options. + * client-src/sendsize.c: Call program with config as argument. + +2006-07-23 Jean-Louis Martineau + * client-src/sendbackup-gnutar.c: Fix bug found by splint. + * client-src/sendsize.c: Fix bug found by splint. + +2006-07-22 Jean-Louis Martineau + * server-src/taper.c: Fix amfree(mem_splitbuf). + +2006-07-22 Jean-Louis Martineau + * server-src/diskfile.c, server-src/taper.c: Fix memory leak found + by coverity. + +2006-07-22 Jean-Louis Martineau + * server-src/taper.c: Fix split_buffer allocation problem. + +2006-07-22 Jean-Louis Martineau + * client-src/selfcheck.c, common-src/security-util.c, + restore-src/restore.c, server-src/diskfile.c: Fix memory leak found + by coverity. + +2006-07-20 Jean-Louis Martineau + * changer-src/chg-scsi.c, changer-src/scsi-changer-driver.c, + client-src/amandates.c, client-src/calcsize.c, + client-src/selfcheck.c, client-src/sendbackup.c, + client-src/sendsize.c, common-src/security-util.c, + recover-src/extract_list.c, restore-src/restore.c, + server-src/amindexd.c, server-src/diskfile.c, + server-src/driver.c, server-src/reporter.c, + server-src/tapefile.c, server-src/taper.c: Fix memory leak found + by coverity. + +2006-07-19 Jean-Louis Martineau + * client-src/selfcheck.c : Read client config file. + * client-src/sendbackup.c: Read client config file. + * client-src/sendsize.c : Read client config file. + +2006-07-19 Jean-Louis Martineau + * amandad-src/amandad.h (g_option_t): Add 'char *config'; + * amandad-src/amandad_util.c (parse_g_options): Parse 'config='. + * common-src/amfeatures.h (fe_req_options_config): New amfeature. + * common-src/amfeatures.c (am_init_feature_set): + set fe_req_options_config. + * server-src/amcheck.c: Send 'config=' in global options. + * server-src/dumper.c: Send 'config=' in global options. + * server-src/planner.c: Send 'config=' in global options. + +2006-07-19 Jean-Louis Martineau + * amandad-src/amandad.c: Call dbopen("amandad"). + * changer-src/chg-scsi.c: Call dbopen("server"). + * changer-src/chg-scsi-chio.c: Call dbopen("server"). + * client-src/calcsize.c: Call dbopen("client"). + * client-src/getfsent.c: Call dbopen(NULL). + * client-src/killpgrp.c: Call dbopen("client"). + * client-src/rundump.c: Call dbopen("client"). + * client-src/runstar.c: Call dbopen("client"). + * client-src/runtar.c: Call dbopen("client"). + * client-src/selfcheck.c: Call dbopen("client"). + * client-src/sendbackup.c: Call dbopen("client"). + * client-src/sendsize.c: Call dbopen("client"). + * common-src/amanda.h (dbopen, debug_open): Take a 'char * subdir' + argument. + * common-src/bsd-security.c: Call dbopen(NULL). + * common-src/debug.c (debug_open): Call debug_setup_1(subdir) + * common-src/debug.c (debug_setup_1): Take a subdir argument, + add it to dbgdir. + * common-src/file.c: Call dbopen(NULL). + * common-src/statfs.c: Call dbopen(NULL). + * common-src/token.c: Call dbopen(NULL). + * oldrecover-src/amrecover.c: Call dbopen("client"). + * recover-src/amrecover.c: Call dbopen("client"). + * restore-src/amfetchdump.c: Call dbopen("server"). + * restore-src/amidxtaped.c: Call dbopen("server"). + * restore-src/amrestore.c: Call dbopen("server"). + * server-src/amadmin.c: Call dbopen("server"). + * server-src/amcheck.c: Call dbopen("server"). + * server-src/amcleanupdisk.c: Call dbopen("server"). + * server-src/amflush.c: Call dbopen("server"). + * server-src/amindexd.c: Call dbopen("server"). + * server-src/amlabel.c: Call dbopen("server"). + * server-src/amlogroll.c: Call dbopen("server"). + * server-src/amtape.c: Call dbopen("server"). + * server-src/amtrmidx.c: Call dbopen("server"). + * server-src/amtrmlog.c: Call dbopen("server"). + * server-src/chunker.c: Call dbopen("server"). + * server-src/diskfile.c: Call dbopen("server"). + * server-src/driver.c: Call dbopen("server"). + * server-src/dumper.c: Call dbopen("server"). + * server-src/getconf.c: Call dbopen("server"). + * server-src/infofile.c: Call dbopen("server"). + * server-src/planner.c: Call dbopen("server"). + * server-src/reporter.c: Call dbopen("server"). + * server-src/taper.c: Call dbopen("server"). + +2006-07-17 Jean-Louis Martineau + * server-src/chunker.c: Fix rt computation. + * server-src/dumper.c: Fix dumptime computation. + * server-src/taper.c: Fix rt computation. + +2006-07-17 Jean-Louis Martineau + * NEWS: Klocwork defects fixed. + * NEWS: Coverity defect fixed. + +2006-07-14 Jean-Louis Martineau + * Makefile.am (pkgdata_DATA): add ReleaseNotes. + +2006-07-14 Jean-Louis Martineau + * Amanda 2.5.1b1 released. + * configure.in: Remove -Werror. + +2006-07-14 Jean-Louis Martineau + * client-src/sendsize.c: Use read/write to copy tar snapshot file. + * client-src/sendbackup-gnutar.c: Ditto. + +2006-07-13 Jean-Louis Martineau + * common-src/stream.c (stream_accept): Loop 5 times on select error. + +2006-07-13 Jean-Louis Martineau + * server-src/dumper.c: The datafd is not scheduled at start, + add test for it. + * common-src/stream.c (tcpm_recv_token): Set error_msg. + +2006-07-12 Jean-Louis Martineau + * common-src/util.c (free_new_argv): Move out of + #ifndef HAVE_LIBREADLINE. + +2006-07-12 Jean-Louis Martineau + * server-src/amadmin.c (tape): Report the number of new tapes instead + of "a new tape" for each tapes. + * server-src/reporter.c (output_tapeinfo): Ditto. + +2006-07-12 Jean-Louis Martineau + * server-src/taperscan.c (changer_taper_scan): Report error from + changer_find. + +2006-07-11 John Franks jrfranks@zmanda.com + * configure.in: Fix multiple definition of readline during cygwin + compile. + +2006-07-11 Paddy Sreenivasan + * common-src/pipespawn.c : Fixed compiler warning + +2006-07-11 Jean-Louis Martineau + * man/xml-source/amtapetype.8.xml: No default value for -e. + +2006-07-11 Jean-Louis Martineau + * common-src/util.c: Don't conftoken_ungetc(ch) if ch == EOF. + * server-src/reporter.c: Check tp == NULL. + +2006-07-11 Jean-Louis Martineau + * tape-src/tapetype.c: Make -e an needed argument. + * man/xml-source/amtapetype.8.xml: Update man page. + +2006-07-11 Jean-Louis Martineau + * changer-src/chg-zd-mtx.sh.in: Remove .conf from changerfile. + +2006-07-11 Jean-Louis Martineau + * recover-src/extract_list.c (check_file_overwrite): Renamed from + check_file_overwite. + * recover-src/extract_list.c (check_file_overwrite): Do the path check + in the correct order (from left ro right). + +2006-07-11 Jean-Louis Martineau + * common-src/file.c (debug_agets): Remove call to dbprintf. + +2006-07-10 Jean-Louis Martineau + * recover-src/extract_list.c (add_to_unlink_list, do_unlink_list, + free_unlink_list): New function to manage unlink_list. + * recover-src/extract_list.c (check_file_overwite): Check all + component of an EXTRACT_LIST_ITEM, if a component is not a + directory, add it to the unlink_list. + * recover-src/extract_list.c (extract_files): Call do_unlink_list and + free_unlink_list, rename buf to cwd. + +2006-07-10 Jean-Louis Martineau + * common-src/pipespawn.c (pipespawnv_passwd): Add prototype. + * common-src/pipespawn.c (pipespawn, pipespawn): Remove 2 NULL + parameters to the pipespawnv_passwd call. + * common-src/pipespawn.c (pipespawnv_passwd): Remove passwdvar and + passwdfd parameters, add passwdvar and local variable. + Don't use memcpy to set passwdfd. + * common-src/pipespawn.h (pipespawnv_passwd): Remove prototype. + +2006-07-07 Jean-Louis Martineau + * common-src/security-util.c (stream_read_sync_callback): Remove bogus + call of callback. + +2006-07-07 Kevin Till + * common-src/bsd-security.c: use STREAM_BUFSIZE instead of -1 + * common-src/bsdtcp-security.c: ditto + * common-src/krb4-security.c: ditto + * common-src/security-util.c: ditto + * restore-src/amidxtaped.c: ditto + +2006-07-07 Jean-Louis Martineau + * common-src/util.c (get_conftoken): Remove duplicate conftoken_ungetc. + +2006-07-07 Jean-Louis Martineau + * common-src/security-util.c: Validate and report big packet size. + +2006-07-07 Jean-Louis Martineau + * oldrecover-src/Makefile.am: Typo. + +2006-07-07 Jean-Louis Martineau + * client-src/sendsize.c: Typo. + +2006-07-06 John Franks + * common-src/genversion.c: + Remove reference to error(). This causes a compile + error on cygwin. + +2006-07-06 Jean-Louis Martineau + Klocwork bug 128, 170, 182, 470, 517 + * changer-src/chg-scsi.c: Validate drivenum, check count_file. + * client-src/sendsize.c: Validate level. + * oldrecover-src/amrecover.c: Use tm. + * recover-src/amrecover.c: Use tm. + * server-src/infofile.c (delete_txinfofile): Use local variable. + +2006-07-06 Jean-Louis Martineau + * server-src/taper.c: Check for cur_filename. + * tape-src/output-file.c: Use vstrextend. + * tape-src/tapeio.c: Check for r. + +2006-07-06 Jean-Louis Martineau + Fix splint warning + * oldrecover-src/extract_list.c (clean_tape_list): Cleanup for splint. + * recover-src/extract_list.c (clean_tape_list): Cleanup for splint. + * server-src/amindexd.c: Add a /*@i@*/. + * server-src/conffile.c: Cast to off_t for conf_init_am64. + * server-src/driver.c: Cast to unsigned to print pid_t. + * server-src/find.c (strip_failed_chunks): Cleanup for splint. + +2006-07-06 Jean-Louis Martineau + Klocwork bug 114 + * server-src/amindexd.c: Free their_feature_string. + Klocwork bug 130 + * restore-src/amrestore.c: Test maximum value for rst_flags->blocksize. + Klocwork bug 294 + * common-src/genversion.c: Check NULL result of malloc. + Klocwork bug 294 + * client-src/selfcheck.c: Check NULL result of fdopen. + Klocwork bug 539, 542 + * oldrecover-src/extract_list.c: Fix pfn2->next = fn2. + * recover-src/extract_list.c : Ditto + Klocwork bug 268, 272, 543, 544 + * oldrecover-src/extract_list.c: Check for cmd != NULL. + * recover-src/extract_list.c : Ditto + Klocwork bug 510 + * restore-src/amidxtaped.c: Check for argv != NULL. + Klocwork bug 435 + * changer-src/scsi-linux.c: Make buffer one larger. + Klocwork bug 520 + * changer-src/scsi-changer-driver.c (OpenDevice): Validate parameters. + Klocwork bug 182 + * changer-src/chg-scsi.c (clean_tape): Check usagetime != NULL. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 551 + * regex-src/regcomp.c (allocset): Check for p->g->sets + and p->g->setbits + +2006-07-05 Jean-Louis Martineau + Klocwork bug 169, 170, 181 + * changer-src/chg-scsi.c: Validate input. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 282 + * common-src/file.c (rmpdir): Check for p == NULL. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 524 + * common-src/dgram.c (dgram_send_addr): Set addr_save earlier. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 495 + * server-src/taper.c (file_reader_side): Maximum value for + fallback_splitsize. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 532 + * recover-src/display_commands.c: Check for cmd != NULL. + * oldrecover-src/display_commands.c: Ditto + +2006-07-05 Jean-Louis Martineau + Klocwork bug 410 + * restore-src/restore.c (restore): Check for tmp_filename. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 234 + * server-src/driver.c: Check for h and activehd >= 0. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 338 and 390 + * server-src/reporter.c (handle_partial, handle_strange): Check result + of handle_success. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 558 + * client-src/selfcheck.c (check_options, check_disk): Check for + calcprog == NULL + +2006-07-05 Jean-Louis Martineau + Klocwork bug 521 + * client-src/clientconf.c (add_client_conf): Check result of realloc. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 447 and 449 + * restore-src/restore.c: Check for valid sendbackup request. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 407 + * restore-src/restore.c (restore): Set statinfo.st_size. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 189 + * common-src/file.c (sanitise_filename): Never return NULL. + +2006-07-05 Jean-Louis Martineau + * amandad-src/Makefile.am: Remove tape-src and libamtape. + * client-src/Makefile.am: Remove tape-src and libamtape. + * man/Makefile.am: Cleanup. + * oldrecover-src/Makefile.am: Remove tape-src and libamtape. + * recover-src/Makefile.am: Remove tape-src and libamtape. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 236 + * server-src/driver.c (handle_dumper_result): Check for + dumper->ev_read != NULL. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 553 + * restore-src/restore.c (search_a_tape): Check for desired_tape == NULL. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 556 and 557 + * common-src/security-util.c (bsd_recv_security_ok): Check result of + strtok, check service == NULL. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 161 + * client-src/calcsize.c (calc_load_file): Return NULL if fopen fail. + * client-src/calcsize.c (main): check NULL result from calc_load_file. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 84 + * server-src/amflush.c (main): Check return of lookup_disk. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 62, 85, 459, 463, 466, 469, 555, 559 + * common-src/security-util.c: Check result of fdopen. + * client-src/sendsize.c : Ditto. + * server-src/amcheck.c : Ditto. + * server-src/amflush.c : Ditto. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 159, 375, 377, 379, 508, 509, 513, 519 + * common-src/bsd-security.c: Replace malloc by alloc. + * common-src/bsdudp-security.c: Ditto + * common-src/genversion.c: Ditto + * recover-src/amrecover.c: Ditto + * restore-src/amidxtaped.c: Ditto + * server-src/reporter.c: Ditto + +2006-07-05 Jean-Louis Martineau + Klocwork bug 562 and 475 + * recover-src/set_commands.c (cd_dir): Check result of rindex. + * oldrecover-src/set_commands.c (cd_dir): ditto. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 552 + * restore-src/restore.c (load_manual_tape): Alloc space for cur_tapedev. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 406 + * restore-src/restore.c (restore): Check for final_filename. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 318 + * server-src/list_dir.c (add_dir_list_item): Check for cur_list->next. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 17, 32 + * server-src/amadmin.c (disklist_one): Check localtime return NULL. + * server-src/amadmin.c (info_one) : Ditto. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 2, 83, 128, 384, 478, 504, 505, 506, 517, 566, 567 + * server-src/amadmin.c (seqdatestr): Check localtime return NULL. + * common-src/util.c (construct_datestamp, construct_timestamp, + conf_print): Ditto. + * oldrecover-src/amrecover.c (main): Ditto. + * oldrecover-src/uscan.l (ll_parse_date): Ditto. + * recover-src/amrecover.c (main): Ditto. + * recover-src/uscan.l (ll_parse_date): Ditto. + * server-src/amflush.c (main): Ditto. + * server-src/reporter.c (handle_success): Ditto. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 470 + * client-src/sendsize.c (add_diskest): Check for level value. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 372 + * server-src/reporter.c (nicedate): Check month value. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 20 + * server-src/amadmin.c (tape): Limit nb_days to 10000. + +2006-07-05 Jean-Louis Martineau + Klocwork bug 21 + * server-src/amadmin.c (balance): Test 'later' after it is set. + +2006-07-05 Jean-Louis Martineau + * common-src/alloc.c (internal_vstralloc): Don't return NULL. + +2006-07-05 Jean-Louis Martineau + * server-src/infofile.c (open_txinfofile): Use local variable. + +2006-06-29 Jean-Louis Martineau + * restore-src/restore.c (label_of_current_slot): Close the tapefd if + the label mismatch. + +2006-06-29 Jean-Louis Martineau + * server-src/find.c (strip_failed_chunks): + - Get a **output_find as parameter. + - Check the label before remove a valid chunk. + - Memory management fix. + +2006-06-28 Jean-Louis Martineau + * common-src/security-util.c: Improve message for .amandahosts. + +2006-06-27 Ian Turner + * common-src/fileheader.c: Fix a bug where spanned dumps would + always fail. + +2006-06-27 Jean-Louis Martineau + * server-src/amcheck.c: Fix test for holdingdisk negative size. + +2006-06-27 Jean-Louis Martineau + * configure.in: Don't set DEFAULT_TAPE_DEVICE if it is not set. + * client-src/clientconf.c: Work DEFAULT_TAPE_DEVICE not set. + * common-src/genversion.c: Work DEFAULT_TAPE_DEVICE not set. + * recover-src/amrecover.c: Work DEFAULT_TAPE_DEVICE not set. + * server-src/getconf.c: Work DEFAULT_TAPE_DEVICE not set. + +2006-06-27 Jean-Louis Martineau + Patch by Paul Bijnens + * server-src/amcheck.c: Check for access(hdp->diskdir, X_OK). + +2006-06-27 Jean-Louis Martineau + * server-src/conffile.c (getconf_byname): Check for kt->keyword != NULL. + * client-src/clientconf.c (client_getconf_byname): Ditto + +2006-06-22 Jean-Louis Martineau + * recover-src/extract_list.c: check_file_overwite. + +2006-06-22 Jean-Louis Martineau + * recover-src/extract_list.c: Do the cleanup of the extract list + at the extraction time + * oldrecover-src/extract_list.c: Ditto. + +2006-06-22 Jean-Louis Martineau + * NEWS: Add new features. + * ReleasesNotes: New files. + +2006-06-22 Jean-Louis Martineau + * docs/Makefile.am (pkgdata_DATA): Add amaespipe.8.txt amcrypt.8.txt + amcrypt-asym-ossl.8.txt amcrypt-ossl.8.txt amfetchdump.8.txt + * docs/amaespipe.8.txt: New file. + * docs/amcrypt.8.txt: New file. + * docs/amcrypt-asym-ossl.8.txt: New file. + * docs/amcrypt-ossl.8.txt: New file. + * docs/amfetchdump.8.txt: New file. + +2006-06-22 Jean-Louis Martineau + * docs/Makefile.am (pkgdata_DATA): Add howto-auth.txt. + * docs/howto-auth: Documentation on auth. + * docs/*.txt: Update from xml-docs + +2006-06-22 Jean-Louis Martineau + * man/xml-source/amanda.conf.5.xml: Add notes about bsdudp and bsdtcp. + * man/xml-source/amanda-client.conf.5.xml: Ditto. + +2006-06-22 Jean-Louis Martineau + * recover-src/extract_list.c (is_empty_dir): New function. + * recover-src/extract_list.c: Print a warning if cwd is not empty. + +2006-06-22 Jean-Louis Martineau + * server-src/amadmin.c: Allow 'p' and 'P' in --sort argument. + +2006-06-22 Jean-Louis Martineau + * server-src/amadmin.c: Print errstr returned by match_disklist. + * server-src/amcheck.c: Print errstr returned by match_disklist. + * server-src/amflush.c: Print errstr returned by match_disklist. + * server-src/diskfile.c (match_disklist): Return an error str. + * server-src/diskfile.h (match_disklist): New prototype. + * server-src/planner.c: Print errstr returned by match_disklist. + * server-src/reporter.c: Accept host/disk as arguments. + +2006-06-22 Jean-Louis Martineau + * server-src/amindexd.c (uncompress_file): Set LC_ALL=C before + executing sort. + +2006-06-22 Jean-Louis Martineau + * server-src/driver.c (wait_children, kill_children): New function. + * server-src/driver.c (wait_for_children): Use wait_children and + kill_children. + * server-src/driver.c (main): Use wait_children. + * server-src/driverio.c (taper_cmd, chunker_cmd): Close socket on QUIT + or ABORT command. + +2006-06-22 Jean-Louis Martineau + * common-src/amfeatures.c (am_init_feature_set): Set + fe_amrecover_feedme_tape. + * common-src/amfeatures.h (fe_amrecover_feedme_tape): New amfeatures. + * common-src/fileheader.c (print_header): Fix. + * recover-src/extract_list.c: Use fe_amrecover_feedme_tape. + * restore-src/amfetchdump.c: Print error if get_lock == 0. + * restore-src/amidxtaped.c: Call send_message if get_lock == 0. + * restore-src/restore.c: Split search_tapes in 5 functions. + * restore-src/restore.h (send_message): prototype. + +2006-06-22 Jean-Louis Martineau + * man/xml-source/amfetchdump.8.xml: Document -O and new -o. + * restore-src/amfetchdump.c: Replace -o by -O + +2006-06-22 Jean-Louis Martineau + * client-src/clientconf.c (parse_client_conf): Fix segmentation fault. + * server-src/conffile.c (parse_server_conf): Fix segmentation fault. + +2006-06-21 Kevin Till + * changer-src/chg-juke.sh.in + * changer-src/chg-manual.sh.in + * changer-src/chg-mcutil.sh.in + * changer-src/chg-multi.sh.in + * changer-src/chg-mtx.sh.in + * changer-src/chg-rait.sh.in + * changer-src/chg-disk.sh.in + * changer-src/chg-zd-mtx.sh.in + * changer-src/chg-null.sh.in + * changer-src/chg-chs.sh.in + * client-src/patch-system.sh.in + * amplot/amplot.sh.in + * server-src/amcrypt-ossl.sh.in + * server-src/amrmtape.sh.in + * server-src/amcleanup.sh.in + * server-src/amverifyrun.sh.in + * server-src/amaespipe.sh.in + * server-src/amdump.sh.in + * server-src/amcrypt.sh.in + * server-src/amcrypt-ossl-asym.sh.in + * server-src/amcheckdb.sh.in + * server-src/amfreetapes.sh.in + * server-src/amverify.sh.in + change /bin/sh to @SHELL@ for configure to pick up the correct + shell. Sourceforge bug 1466655 + * man/xml-source/amcrypt-ossl-asym.8.xml: it's backup-privkey.pem + +2006-06-20 Kevin Till + * common-src/security-util.c: ignore EINTR in net_writev + patch by Jean-Louis Martineau. + +2006-06-20 John Franks + * server-src/conffile.c: + Remove Duplicate keyword table entries and alphabetize + to make future duplicates easier to spot... + + * server-src/taper.c: + Fix compiler warnings when no mmap function is present. + +2006-06-20 John Franks + * server-src/diskfile.c: + Default boolean values without parameters to yes if + no value is present in configuration file. This + maintains backward compatibility and is logical since + a value such as "index" reads as an assertion of fact. + +2006-06-19 Jean-Louis Martineau + * docs/wishlist.txt: Remove features done in 2.5.0/2.5.1 + +2006-06-19 Jean-Louis Martineau + * man/xml-source/amanda.conf.5.xml: amrecover_check_label and + amrecover_do_fsf default to yes. + * server-src/conffile (init_dumptype_defaults): DUMPTYPE_INDEX set to 1. + * server-src/diskfile.c (parse_diskline): index set from + dumptype_get_index. + +2006-06-16 Jean-Louis Martineau + * server-src/amstatus.pl.in: Match quotes in DONE line. + +2006-06-16 Kevin Till + * example/amanda-client.conf.in: + correct DEFAULT_TAPE_SERVER/DEFAULT_SERVER + * server-src/amcrypt-ossl-asym.sh.in: + set RANDFILE for openssl to place entropy file. + * server-src/amcrypt-ossl.sh.in: ditto + +2006-06-16 Jean-Louis Martineau + * amandad-src/amandad.c : Use strcasecmp to compare auth. + * client-src/selfcheck.c : Ditto + * client-src/sendbackup.c : Ditto + * restore-src/amidxtaped.c: Ditto + * server-src/amindexd.c : Ditto + +2006-06-16 Jean-Louis Martineau + * server-src/amindexd.c (reply, lreply, fast_lreply): Correct use + of arglist_start and arglist_end.. + * server-src/amindexd.c (lreply_backend): Remove function. + +2006-06-16 Jean-Louis Martineau + * common-src/bsd-security.c (stream_read_callback): Send error to the + callback. + +2006-06-16 Jean-Louis Martineau + * recover-src/extract_list.c: Typo. + * restore-src/restore.c: Typo. + +2006-06-16 Jean-Louis Martineau + * client-src/clientconf.c: Allow include. + * client-src/clientconf.c (read_confline): Don't crash. + * server-src/conffile.c (read_confline): Don't crash. + * recover-src/amrecover.c: Exit if error in conf file. + +2006-06-16 Jean-Louis Martineau + * common-src/arglist.h: Typo. + * recover-src/extract_list.c: handle MESSAGE from amidxtaped. + +2006-06-16 Jean-Louis Martineau + * common-src/amfeatures.c (am_init_feature_set): Set + fe_amrecover_message. + * common-src/amfeatures.h (am_feature_e): Add fe_amrecover_message. + * common-src/arglist.h (printf_arglist_function3): Prototype. + +2006-06-16 Jean-Louis Martineau + * restore-src/restore.c (send_message): New function that send message + to stderr and/or amrecover. + * restore-src/restore.c: Call send_message on some error path. + +2006-06-16 Jean-Louis Martineau + * common-src/event.c (event_loop_wait, event_wait): Take an + event_handle_t * as parameter. + * common-src/event.h: New prototype. + * common-src/bsd-security.c: Call event_wait(bs->ev_read). + * common-src/krb4-security.c: Call event_wait(ks->ev_read). + * common-src/krb5-security.c: Call event_wait(ks->ev_read). + * common-src/security-util.c: Call event_wait(ss->ev_read). + +2006-06-15 Kevin Till + * man/xml-source/amcrypt-ossl-asym.8.xml: it's .am_passphrase + * server-src/amcrypt-ossl-asym.sh.in: export PATH + * server-src/amcrypt-ossl.sh.in: export PATH + + +2006-06-15 Jean-Louis Martineau + * server-src/amcheck.c: -w doesn't change the test selection. + * man/xml-source/amcheck.8.xml + +2006-06-15 Jean-Louis Martineau + * server-src/planner.c: Log empty disklist and no DLE selected. + +2006-06-14 Jean-Louis Martineau + * common-src/bsd-security.c: Use %u to print in_port_t data. + * common-src/bsdudp-security.c: Ditto. + +2006-06-14 Jean-Louis Martineau + * changer-src/chg-disk.sh.in: Return the number of slot in output of + the -info command. + * changer-src/chg-zd-mtx.sh.in: Ditto. + +2006-06-14 Jean-Louis Martineau + * changer-src/chg-zd-mtx.sh.in: Accept changerfile that already + have the .conf suffix. + +2006-06-13 Jean-Louis Martineau + * amandad-src/amandad.c (s_ackwait): Resend the REP on receive of a + duplicate REQ. + +2006-06-13 Jean-Louis Martineau + * common-src/security-util.c (bsd_recv_security_ok): Set error only + if we get an error. + +2006-06-12 Jean-Louis Martineau + * server-src/driver.c: usetimestamps is a warning. + +2006-06-12 Kevin Till + * common-src/security-util.c: if host is 127.0.0.1 and either + localhost or localhost.domain is in .amandahost, hostmatch passes. + * common-src/security-util.h: update check_user_amandahosts prototype + +2006-06-12 Jean-Louis Martineau + * amandad-src/amandad.c (process_writenetfd): Close the pipe if the + security_stream is closed. + * recover-src/extract_list.c: Improve message if we don't get thei + FEATURE line from amidxtaped. + +2006-06-12 Jean-Louis Martineau + * recover-src/amrecover.c: Read amanda-client.conf and + /amanda-client.conf. + +2006-06-12 Jean-Louis Martineau + * common-src/security-util.c, common-src/tapelist.c, + restore-src/restore.c, server-src/amcheck.c, server-src/amindexd.c, + server-src/amtape.c, server-src/changer.c, server-src/driver.c, + server-src/planner.c, server-src/taper.c, + server-src/taperscan.c: Fix memory leak. + +2006-06-12 Jean-Louis Martineau + * restore-src/restore.c: Fix Adding at end of list. + +2006-06-12 Jean-Louis Martineau + * server-src/taper.c (syncpipe_putstr): Don't crash if str is NULL. + +2006-06-09 Jean-Louis Martineau + * server-src/holding.c (pick_datestamp): Fix reading user input. + +2006-06-09 Jean-Louis Martineau + * recover-src/amrecover.c (sigint_handler): Call send_command only if + amindexd is alive. + +2006-06-09 Jean-Louis Martineau + * common-src/util.c (connect_port): ETIMEDOUT is a fatal error. + +2006-06-09 Jean-Louis Martineau + * common-src/stream.c (stream_client_internal): Get errno set + correctly. + * server-src/driver.c (handle_chunker_result): Don't assert(0) on + receive of a TRYAGAIN from a chunker, but set + chunker->result. + * server-src/dumper.c: Try gethostbyname("localhost") before calling + stream_client and log appropriate message. + +2006-06-09 Jean-Louis Martineau + * server-src/amcheck.c: Report ERROR if gethostbyname("localhost") + doesn't succeed. + +2006-06-08 Jean-Louis Martineau + * client-src/clientconf.c (add_client_conf): New function to map + normal option to their + -o equivalent. + * client-src/clientconf.h (add_client_conf): Prototype. + * man/xml-source/amrecover.8.xml: Document -o. + * recover-src/amrecover.c: Also read /amanda-client.conf + +2006-06-08 Jean-Louis Martineau + * server-src/diskfile.c (parse_diskline): Only return 0 or -1. + +2006-06-08 Jean-Louis Martineau + * amandad-src/amandad.h (g_option_t): Add auth. + * amandad-src/amandad_util.c (init_g_options): Set auth to NULL. + * amandad-src/amandad_util.c (parse_g_options): Parse auth. + * amandad-src/amandad_util.c (free_g_options): Free auth. + * client-src/sendbackup.c: Get amandad_auth from command line and + compare with REQ packet. + * common-src/amfeatures.h (fe_amindexd_options_hostname, + fe_amindexd_options_features, + fe_amindexd_options_auth, + fe_amidxtaped_options_hostname, + fe_amidxtaped_options_features, + fe_amidxtaped_options_auth): New amfeatures. + * common-src/amfeatures.c (am_init_feature_set): Set new amfeatures. + * recover-src/amrecover.c: Send auth in OPTIONS of req packet. + * recover-src/extract_list.c: Send auth in OPTIONS of req packet. + * restore-src/amidxtaped.c: Parse amandad_auth from command line. + Get auth from OPTIONS line. + Compare them. + * server-src/amindexd.c: Parse amandad_auth from command line. + Get auth from OPTIONS line. + Compare them. + +2006-06-08 Jean-Louis Martineau + * common-src/util.c(connect_port): Return -2 on ECONNREFUSED error + from connect. + +2006-06-07 Jean-Louis Martineau + * amandad-src/amandad.c: exec the service with the auth as parameter. + * amandad-src/amandad.c(writebuf): Do no close fd. + * client-src/selfcheck.c: Read the auth for the command line and + compare with the option string. + * client-src/selfcheck.c(main): Do no close 0,1,2 fd. + +2006-06-07 Jean-Louis Martineau + * man/xml-source/amanda.8.xml(CONFIGURATION OVERWRITE): New section. + * man/xml-source/amadmin.8.xml, man/xml-source/amcheck.8.xml, + man/xml-source/amdump.8.xml, man/xml-source/amflush.8.xml, + man/xml-source/amgetconf.8.xml, man/xml-source/amlabel.8.xml, + man/xml-source/amreport.8.xml, + man/xml-source/amrestore.8.xml: Add -o option. + +2006-06-07 Jean-Louis Martineau + * common-src/util.c(get_conftoken): Merge from zmanda. + +2006-06-07 Jean-Louis Martineau + * common-src/util.c(get_conftoken): Remove a conftoken_ungetc. + +2006-06-07 Jean-Louis Martineau + * common-src/bsd-security.c (stream_read_callback): Merge with zmanda. + +2006-06-07 Jean-Louis Martineau + * amandad-src/amandad.c(process_writenetfd): Call security_stream_read + only if size > 0. + +2006-06-07 Jean-Louis Martineau + * server-src/conffile.c (lookup_interface): Fix merge error. + +2006-06-07 John Franks + * common-src/amanda.h: + Fix isnormal() replacement macro to indirectly + check if a floating point value is != 0.0. + This prevents compiler warnings. + +2006-06-07 John Franks + * common-src/util.c + Put in "/* NOTREACHED */" comments after error() calls. + * server-src/diskfile.c + Change disktype index default to yes for backward compatibility. + +2006-06-06 John Franks + * amandad-src/amandad.c common-src/bsd-security.c: + Correct fix for infinite amandad loop. + +2006-06-06 John Franks + * common-src/stream.c common-src/util.c: + Lint clean again. + * server-src/conffile.c: + Remove replicated line + +2006-06-06 Jean-Louis Martineau + * common-src/util.c (conftoken_ungetc): Return the character. + * common-src/util.c (get_conftoken): Merge to allow escape character. + * common-src/util.c (read_block): Allow STRING as IDENT. + * server-src/conffile.c (getconf_long, getconf_size): New function. + * server-src/conffile.c: Cleanup after Merge. + +2006-06-06 Jean-Louis Martineau + * server-src/amadmin.c, server-src/amcheck.c, server-src/amflush.c, + server-src/amlabel.c, server-src/amlogroll.c, server-src/amtrmidx.c, + server-src/amtrmlog.c, server-src/getconf.c, + server-src/reporter.c: Usage -o + * server-src/amflush.c, server-src/amlogroll.c, server-src/amtrmidx.c, + server-src/amtrmlog.c, server-src/chunker.c, server-src/driver.c, + server-src/dumper.c, server-src/getconf.c, server-src/planner.c, + server-src/reporter.c, + server-src/taper.c: Add call to report_bad_conf_arg. + * server-src/conffile.c(get_comprate, get_compress): Parse CONF_END. + +2006-06-06 John Franks + * configure.in: + Increase checking level from 1 to 2 for SUN lint. + * client-src/amandates.c client-src/clientconf.c + common-src/security-util.c recover-src/amrecover.c + recover-src/extract_list.c regex-src/regcomp.c server-src/amcheck.c + server-src/amlabel.c server-src/chunker.c server-src/conffile.c + server-src/conffile.h server-src/diskfile.c server-src/diskfile.h + server-src/driver.c server-src/holding.c server-src/reporter.c + server-src/tapefile.c server-src/taper.c tape-src/amdd.c: + Lint clean again. + * common-src/util.h common-src/util.c: + Lint clean again. + Add missing conftype size. + * common-src/bsd-security.c + Fix infinte loop which consumes all /tmp space and 1/2 + the CPU time when EOF is reached on socket. + +2006-06-05 Paddy Sreenivasan + * common-src/util.c: Fix warning + +2006-06-05 Jean-Louis Martineau + * restore-src/amfetchdump.c, server-src/amcheck.c, + server-src/amcheckdb.sh.in, server-src/amcleanup.sh.in, + server-src/amdump.sh.in, server-src/amflush.c, + server-src/amlabel.c, server-src/amlogroll.c, + server-src/amtrmidx.c, server-src/amtrmlog.c, + server-src/chunker.c, server-src/conffile.c, + server-src/diskfile.c, server-src/driver.c, + server-src/driverio.c, server-src/dumper.c, + server-src/getconf.c, server-src/planner.c, + server-src/reporter.c, server-src/taper.c, + server-src/taperscan.c: Allow -o options and some memory fix. + * server-src/conffile.c(lookup_dumptype, lookup_tapetype, + lookup_interface): Use strcasecmp. + +2006-06-02 Jean-Louis Martineau + * common-src/stream.c (stream_client_internal): Use connect_portrange. + * common-src/util.c (connect_portrange): First, try to connect with a + port already used. + * common-src/util.c (connect_port): Try to connect with a specific port. + * common-src/util.h: Cleanup. + +2006-06-02 Jean-Louis Martineau + * server-src/reporter.c: Remove empty if. + +2006-06-02 Jean-Louis Martineau + * common-src/util.c (read_block): Don't read CONF_NL aftre the '{'. + * server-src/conffile.c(get_holdingdisk, get_tapetype, get_interface): + Read a CONF_NL after the call to read_block. + * server-src/conffile.c(read_dumptype): Read a CONF_NL if we are not + called from diskfile. + * server-src/diskfile.c: Don't loop on empty line after read_dumptype. + +2006-06-01 Kevin Till + * server-src/amcrypt-ossl.sh.in: symmetric encrypt script using openSSL. + Thanks to Ben Slusky. + * server-src/amcrypt-ossl-asym.sh.in: public-ley encrypt script using openSSL. + * man/xml-source/amcrypt-ossl.8.xml: man page + * man/xml-source/amcrypt-ossl-asym.8.xml: man page + * configure.in: ditto + * man/Makefile.am: ditto + * man/entities/global.entities: ditto + * server-src/Makefile.am: ditto + +2006-06-01 John Franks + Eliminate Cygwin compile warnings. + * client-src/getfsent.c: Quiet unused parameter warnings. + * client-src/selfcheck.c: Quiet unused parameter warnings. + * common-src/security-util.h: Make hostname const char *. + +2006-06-01 Jean-Louis Martineau + * server-src/amcheck.c: holdingdisk_get_disksize() return an off_t. + * server-src/find.c: result should be ssize_t. + +2006-06-01 Jean-Louis Martineau + * common-src/amanda.h: Remove am64_t. + * client-src/clientconf.c, client-src/clientconf.h, common-src/util.c, + common-src/util.h, server-src/conffile.c, server-src/conffile.h: + Second pass of config cleanup, add function to parse -o argument. + * recover-src/amrecover.c: -o command argument. + * restore-src/restore.c: Use off_t instead of am64_t. + * server-src/amadmin.c: New config subcommand. -o command argument. + * server-src/amlabel.c: Fix memory leak. + * server-src/diskfile.c: Fix memory leak. + * server-src/diskfile.h: Rename no_hold to to_holdingdisk. + * server-src/driver.c: Many. + * server-src/planner.c: am64_t to off_t. + +2006-06-01 Jean-Louis Martineau + This is the first pass of a general rewrite of configuration file + parsing, It will now use array to store all options. + + * client-src/clientconf.c: + * client-src/clientconf.h: + * server-src/conffile.c: + * server-src/conffile.h: + * common-src/util.c: Many new functions. + * common-src/util.h: + + * restore-src/amidxtaped.c, server-src/amcheck.c, + server-src/amcleanupdisk.c, server-src/amlabel.c, + server-src/diskfile.c, server-src/driver.c, server-src/driverio.c, + server-src/find.c, server-src/holding.c, server-src/planner.c, + server-src/reporter.c, + server-src/taper.c: Use new macro to get configuration option. + +2006-06-01 Jean-Louis Martineau + * amandad-src/amandad.c, client-src/amandates.c, client-src/noop.c, + client-src/selfcheck.c, client-src/sendsize.c, + common-src/bsd-security.c, common-src/bsdtcp-security.c, + common-src/bsdudp-security.c, common-src/fileheader.c, + common-src/rsh-security.c, common-src/security-util.c, + common-src/security-util.h, common-src/ssh-security.c, + recover-src/extract_list.c, server-src/amcheck.c, + server-src/amindexd.c, server-src/amlogroll.c, + server-src/diskfile.c, server-src/driver.c, server-src/dumper.c, + server-src/find.c, server-src/logfile.c, server-src/planner.c, + server-src/reporter.c, + server-src/tapefile.c: Fix memory and fd leak. + +2006-06-01 Jean-Louis Martineau + * server-src/find.c (search_holding_disk): Take the datestamp from the + file, not the directory name, otherwise usetimestamps=no doesn't + work. + +2006-06-01 Jean-Louis Martineau + * common-src/stream.c (stream_server): New priv parameter if we want + a reserved port. Don't try to + get a reserved port if priv==0. + * common-src/stream.h (stream_server): New prototype. + * common-src/bsd-security.c: Call stream_server with priv==0. + * common-src/krb4-security.c: Call stream_server with priv==1. + * common-src/security-util.c: Call stream_server with priv==0. + * restore-src/amidxtaped.c: Call stream_server with priv==0. + * server-src/chunker.c: Call stream_server with priv==0. + * server-src/taper.c: Call stream_server with priv==0. + +2006-06-01 Jean-Louis Martineau + * server-src/diskfile.c: Return -1 if open of diskfile failed. + * server-src/driver.c: Change message if didn't get a DATE line. + * server-src/reporter.c: Ignore faillure in reading amanda.conf + disklist and tapelist. + +2006-05-29 Jean-Louis Martineau + * man/xml-source/amanda.8.xml: Documents service in .amandahosts. + +2006-05-29 Jean-Louis Martineau + Previous patch doesn't work because 'make -j2' will use fd 3. + * amandad-src/Makefile.am: Use a temporary file for output of + 'make listlibsrc'. + * changer-src/Makefile.am: Ditto. + * client-src/Makefile.am: Ditto. + * common-src/Makefile.am: Ditto. + * oldrecover-src/Makefile.am: Ditto. + * recover-src/Makefile.am: Ditto. + * restore-src/Makefile.am: Ditto. + * server-src/Makefile.am: Ditto. + * tape-src/Makefile.am: Ditto. + +2006-05-29 Jean-Louis Martineau + * amandad-src/Makefile.am: 'make listlibsrc' send it's ouput to fd 3. + * changer-src/Makefile.am: Ditto. + * client-src/Makefile.am: Ditto. + * common-src/Makefile.am: Ditto. + * oldrecover-src/Makefile.am: Ditto. + * recover-src/Makefile.am: Ditto. + * restore-src/Makefile.am: Ditto. + * server-src/Makefile.am: Ditto. + * tape-src/Makefile.am: Ditto. + +2006-05-28 Paddy Sreenivasan + * tape-src/tapeio.c : Fixed warnings + * tape-src/output-rait.c : Fixed warnings + * tape-src/output-null.c : Fixed warnings + * tape-src/output-file.c : Fiexed warnings + * recover-src/amrecover.c: Fixed warnings + * recover-src/extract_list.c : Fixed warnings + * server-src/amadmin.c : Fixed warnings + * server-src/driver.c : Fixed warnings + * server-src/infofile.c : Fixed warnings + +2006-05-26 Jean-Louis Martineau + * server-src/conffile.c (read_dumptype): Parse SSH_KEYS. + +2006-05-26 Jean-Louis Martineau + * common-src/security-util.c (udp_inithandle): Remove bad merge. + * server-src/amindexd.c: Improve error message. + * server-src/planner.c: Add a space in output. + +2006-05-26 Jean-Louis Martineau + * server-src/conffile.c: Set dpcur.no_hold correctly, + Fix for conffile program. + +2006-05-26 Jean-Louis Martineau + Allow many services to share the same tcp connection for + bsdtcp/ssh/rsh. + Add a security_close_connection to the security-api. + * amandad-src/amandad.c (wait_30s, exit_on_qlength): New variable to + control auth specific behaviour. + * common-src/bsd-security.c: Add sec_close_connection_none. + * common-src/bsdudp-security.c: Add sec_close_connection_none. + * common-src/krb4-security.c: Add sec_close_connection_none. + * common-src/krb5-security.c: Add sec_close_connection_none. + * common-src/security.h (security_close_connection): Prototype. + * common-src/security-util.h (sec_close_connection_none, + tcpm_close_connection): Prototype. + * common-src/security-util.h (struct tcp_conn): Add toclose. + * common-src/security-util.h (struct sec_stream): Add closed_by_me and + closed_by_network. + * common-src/security-util.c (sec_close_connection_none, + tcpm_close_connection): New function. + * common-src/security-util.c: Handle many services on one connection. + * common-src/bsdtcp-security.c: Handle many services on one connection. + * common-src/rsh-security.c: Handle many services on one connection. + * common-src/ssh-security.c: Handle many services on one connection. + * recover-src/amrecover.c: Add call security_close_connection. + * recover-src/extract_list.c: Add call security_close_connection. + * server-src/amcheck.c: Add call security_close_connection. + * server-src/dumper.c: Add call security_close_connection. + +2006-05-26 Jean-Louis Martineau + * common-src/security-util.c (bsd_prefix_packet): We need the username + of the getuid() user. + +2006-05-26 Jean-Louis Martineau + * common-src/fileheader.c: Parse datestamp on F_TAPEEND. + * restore-src/amrestore.c: Set read_result to the result of + read_file_header. + * restore-src/restore.c (read_file_header): Return a ssize_t. + Rename bytes_read by read_result. + Set read_result to the result of read_file_header. + * restore-src/restore.h (read_file_header): New prototype. + +2006-05-25 Jean-Louis Martineau + * server-src/taperscan.c: Replace bogus newvstralloc by vstrextend. + +2006-05-25 Jean-Louis Martineau + * client-src/getfsent.c (print_entry): Add prototype. + * common-src/token.c (main): Shut up compiler warning. + * server-src/infofile.c (dump_rec, dump_db): Add prototype. + +2006-05-25 Jean-Louis Martineau + * amandad-src/amandad.c, common-src/bsd-security.c, + common-src/bsdtcp-security.c, common-src/bsdudp-security.c, + common-src/event.c, common-src/krb5-security.c, + common-src/protocol.c, common-src/rsh-security.c, + common-src/security-util.c, common-src/ssh-security.c, + common-src/util.c, server-src/driver.c: comment debugging. + +2006-05-25 Jean-Louis Martineau + * common-src/security-util.c: typo. + * server-src/amcheck.c: Make sure all check are done. + +2006-05-25 Jean-Louis Martineau + Fix for program not compiled by default. + make bsdsecurity still not compile. + * common-src/bsd-security.c(bind_portrange): prototype change. + * common-src/Makefile.am (STANDARD_COMMON_STUFF_NOT_FILE): Add match.o. + * server-src/conffile.c: Many typo. + * tape-src/tapeio.c: Use OFF_T_FMT and SSIZE_T_FMT when needed, typo. + +2006-05-25 Jean-Louis Martineau + * common-src/fileheader.c (validate_datestamp): Works for 8 characters + datestamp. + * common-src/security-util.c (tcpm_send_token): netlength must be + uint32_t. + * common-src/security-util.c (bsd_prefix_packet): Fix typo. + * common-src/util.c (get_time): Don't do computation for starttime. + * server-src/conffile.c (read_dumptype): Do computation for starttime. + +2006-05-25 Jean-Louis Martineau + * common-src/krb5-security.c (krb5_sendpkt, krb5_stream_read_sync, + recv_token): Return ssize_t. + * common-src/krb5-security.c (krb5_accept, krb5_stream_accept,i + krb5_stream_auth): Shut up compiler. + * tape-src/output-file.c: Use SSIZE_MAX instead of SSIZE_T_MAX. + +2006-05-25 Jean-Louis Martineau + * configure.in(AM_INIT_AUTOMAKE): Fix. + +2006-05-25 John Franks + Pass user CFLAGS correctly to machine generated code and do not + enforce code quality checks on them. + * configure.in: + Put compiler code check flags into existing, but previously + unused, AM_CFLAGS for Makefiles to pick up. CFLAGS should + now only contain mandatory flags. + + * recover-src/Makefile.am oldrecover-src/Makefile.am: + Use CFLAGS for compiling C code generated from uparse.y and uscan.l + +2006-05-24 John Franks + Add support for binary path names on disk and in configuration files. + (Allow spaces in filenames.) + + Allow quoted strings for disklist entries. + + Lint clean code using sun lint, splint and strict GCC warnings. + Type / size clean, dead code removal, portibility checks, etc. + Many checks are still turned off. See configure.in for lint flags used. + + Increase debug output in /tmp/amanda/*debug files. + + Set SO_REUSEADDR on sockets help avoid running out of ports. + + * configure.in: + Added lint program discovery with specific targets for SUN lint and splint. + Check each compiler option to see if GCC supports it. + Enable more code quality warnings. + Change missing xsltproc to warning rather than error. + Define _GNU_SOURCES to build flags. + Make size_t and time_t printf format macros. + Check for isnormal() availability. + Don't install man pages if they are not built. + Fix man pages to not attempt build or install if + --without-built-manpages is set. + + * Makefile.am amandad-src/Makefile.am changer-src/Makefile.am + client-src/Makefile.am common-src/Makefile.am + oldrecover-src/Makefile.am recover-src/Makefile.am + restore-src/Makefile.am server-src/Makefile.am tape-src/Makefile.am: + Add lint target. + + * common-src/amanda.h common-src/dgram.c common-src/stream.c + common-src/util.c: + Keep checking for ports on all bind errors. + Delay and retry a few times if all ports are busy. + Retry bind failures after all methods fail. + increase bind checking timeout to 30 minutes. + + * client-src/amandad.c + Issue wait when any child exits. (Get rid of defunct processes) + Stat() index file before using system command. + (shell is not reporting failure if index is not present) + + * recover-src/extract_list.c: + Fix problem of 'add *' not adding directories. + Fix problem of freeing pointer not obtained through malloc. + Touch up file addition to actually use the file names + retrieved when adding a directory and not the directory itself. + + * server-src/taper.c + Strenghten error recovery for broken syncpipes and writer errors. + + * changer-src/chg-scsi-chio.c client-src/amandates.c + client-src/client_util.c client-src/findpass.c client-src/getfsent.c + client-src/selfcheck.c client-src/sendbackup-gnutar.c + client-src/sendbackup-star.c client-src/sendbackup.c + client-src/sendsize.c common-src/bsd-security.c common-src/file.c + common-src/krb5-security.c server-src/amcheck.c server-src/amindexd.c + server-src/diskfile.c server-src/driver.c server-src/dumper.c + server-src/holding.c server-src/infofile.c server-src/logfile.c + server-src/tapefile.c: + allow empty lines in input streams. + + * recover-src/uparse.y + print message when input is garbage. + + * server-src/getconf.c: + Define HOSTNAME_INSTANCE if it was not already defined + for Kerberos. + + * configure.in: Make readline warning less specific. Readline is + used by all input from terminal now. + +2006-05-24 Kevin Till + * client-src/sendbackup.c: ignore SIGINT + * common-src/ssh-security.c: add to total only when n > 0 + * common-src/ssh-security.c: add ssh to error, + retry writev when EINTR, EAGAIN is seen + to STDOUT. exit when options is chosen in template mode. + * server-src/driver.c: make sure timestamp is not null + * amanda/configure.in: remove template.d/amanda.conf which is a dup + of amanda-harddisk.conf + * example/Makefile.am: add template.d/README + * amanda-harddisk.conf.in: set tapedev + * recover-src/amrecover.c: aclose socket before exit. + * recover-src/extract_list.c: ditto + * amanda_enterprise.spec: remove template.d/amanda.conf, add template.d/README + in the failure cases. <> user input field. + * server-src/amcheck.c: no quoted text is a warning + * server-src/driver.c: no need to amfree qname + argument. Search mtx in PATH too. + * example/template.d/advanced.conf.in: fix comment for autoflush + * example/template.d/advanced.conf.in: add usetimestamps + * server-src/diskfile.c: to catch unsupported compress-encryption + combination and abort amdump gracefully. + * man/xml-source/amanda.conf.5.xml: fix syntax, add + dumptype references. + * man/xml-source/amanda.8.xml: fix syntax + * configure.in: ditto + * man/Makefile.am: ditto + * example/amanda.conf.in: tidy up + * man/xml-source/amaespipe.8.xml: add uuencode as requirement + * man/xml-source/amcrypt.8.xml: add uuencode as requirement + * server-src/amcheck.c: catch dumptype misconfiguration + * server-src/diskfile.c: ditto + * server-src/driverio.c: ditto + * server-src/planner.c: ditto + * server-src/conffile.c: check includefile before calling + read_conffile_recursively + * example/amanda.conf.in: add public-key encryption dumptype example + * man/xml-source/amanda.8.xml: fix some formatting + * server-src/planner.c: adjust setuid() calling sequences so that ssh can work + * server-src/dumper.c: ditto + * configure.in: add LOW_TCPPORTRANGE for amrecover + * common-src/stream.c: use LOW_TCPPORTRANGE + * server-src/amdump.sh.in: check if config is supplied + * man/xml-source/amrestore.8.xml: add notes on "-f" option + +2006-05-24 Ian Turner + * configure.in: Properly document --without-xsltproc as itself, + and not the (nonexistant) option --without-built-manpages. + +2006-05-16 John Franks + * amandad-src/amandad.c client-src/clientconf.c common-src/bsd-security.c + common-src/bsdudp-security.c common-src/dgram.c common-src/krb4-security.c + common-src/krb5-security.c common-src/match.c common-src/packet.c + common-src/security-util.c common-src/security-util.h + common-src/security.h common-src/util.c oldrecover-src/Makefile.am + oldrecover-src/set_commands.c recover-src/amrecover.c + recover-src/extract_list.c server-src/conffile.c server-src/driver.c + server-src/dumper.c server-src/planner.c server-src/reporter.c: + Minimal changes to get tree to compile along with some more + debugging output. + +2006-05-15 Jean-Louis Martineau + * server-src/amadmin.c (disklist_one): print spindle. + +2006-05-12 Jean-Louis Martineau + * commmon-src/bsd-security.c: Typo. + +2006-05-12 Jean-Louis Martineau + * common-src/Makefile.am (noinst_HEADERS): Add security-util.h. + +2006-05-12 Jean-Louis Martineau + Build a big tok_t enum for server and client config. + * client-src/clientconf.c: Move many things to util.c. + * client-src/clientconf.h: Remove extern variable. + * common-src/util.c: Add common part of clientconf.c and conffile.c + * common-src/util.h: Prototype. + * server-src/conffile.c: Move many things to util.c. + * server-src/diskfile.c(disk_parserror): Rename from parserror. + * server-src/taper.c: Make many variable static. + +2006-05-12 Jean-Louis Martineau + * restore-src/restore.c: Fix use of possibly NULL input. + +2006-05-12 Jean-Louis Martineau + * common-src/ssh-security.c (ssh_connect): Retrieve ssh_keys from + configuration. + * server-src/amadmin.c(disklist_one): Print ssh_keys. + * server-src/conffile.c(SSH_KEYS): Parse new dumptype option. + * server-src/conffile.h(dumptype_t): Add ssh_keys. + * server-src/diskfile.c(parse_diskline): Copy new field. + * server-src/diskfile.h(disk_t) Add ssh_keys. + * server-src/driverio.c(dumper_cmd): Send dp->ssh_keys in a PORT_DUMP + command to the dumper. + * server-src/dumper.c: Parse ssh_keys in a PORT_DUMP command. + * server-src/dumper.c(dumper_get_security_conf): Return the ssh_keys. + * server-src/server_util.c(amhost_get_security_conf): Return the + ssh_keys. + +2006-05-12 Jean-Louis Martineau + * amandad-src/amandad.c: Set allow_many_services to 0 if auth=bsdtcp. + * common-src/bsd-security.c: Use security-util.c. + * common-src/bsdtcp-security.c: New security-api. + * common-src/bsdudp-security.c: New secutity-api. + * common-src/krb4-security.c: Use security-util.c. + * common-src/krb5-security.c: Use security-util.c. + * common-src/Makefile.am (libamanda_la_SOURCES): Add bsdtcp-security.c, + bsdtcp-security.c + and security-util.c. + * common-src/protocol.c: Debuging cleanup. + * common-src/rsh-security.c Use security-util.c. + * common-src/security.c: Use bsdtcp_security_driver + and bsdudp_security_driver. + * common-src/security.h(accept): New prototype. + * common-src/security-util.c: Many common function for security-api. + * common-src/security-util.h: many prototype for security-api. + * common-src/ssh-security.c Use security-util.c. + * common-src/stream.c (stream_client_internal): Call connect_portrange. + * common-src/util.c (make_socket): Make a socket. + * common-src/util.c (connect_portrange): Make a socket, bind it and + connect. + * common-src/util.h (connect_portrange): Prototype. + * configure.in: new --with-bsdtcp-security and --with-bsdudp-security. + +2006-05-10 Jean-Louis Martineau + Patch by + * man/xml-source/amrecover.8.xml: Document listhost command. + +2006-05-08 Jean-Louis Martineau + Patch by + * server-src/amindexd.c: new LISTHOST command. + * recover-src/set_commands.c (list_host): New function. + * recover-src/amrecover.h (list_host): Prototype. + * recover-src/help.c (list_host): Print help. + * recover-src/uscan.l: Parse listhost command. + * recover-src/uparse.y: LISTHOST command. + * oldrecover-src/set_commands.c (list_host): New function. + * oldrecover-src/amrecover.h (list_host): Prototype. + * oldrecover-src/help.c (list_host): Print help. + * oldrecover-src/uscan.l: Parse listhost command. + * oldrecover-src/uparse.y: LISTHOST command. + +2006-05-08 Ian Turner + * server-src/amcheck.c: Make it an error when the expected new + tape cannot be found. Thanks to Paul Bijnens + for the patch and to Jason L + Tibbitts III for noticing this problem. + +2006-05-08 Jean-Louis Martineau + * driverio.h (shed_s): Add est_nsize, est_csize, degr_nsize, degr_csize + for nativa and compressed estimate size. + * planner.c: Send the native and compressed estimate size to the driver. + * driver.c: log with L_STATS the estimate of a successful dump. + * reporter.c: Parse the L_STATS. + * reporter.c(generate_bad_estimate): New function that will put in the + NOTES section all bad estimate. + +2006-05-08 Jean-Louis Martineau + * configure.in (AC_CONFIG_FILES): Add oldrecover-src/Makefile. + * Makefile.am (RECOVER_SUBDIRS): Add oldrecover-src. + * oldrecover-src/amrecover.c: Copy of old recover-src/amrecover.c + * oldrecover-src/amrecover.h: Copy of old recover-src/amrecover.h + * oldrecover-src/display_commands.c: Copy of old + recover-src/display_commands.c + * oldrecover-src/extract_list.c: Copy of old recover-src/extract_list.c + * oldrecover-src/help.c: Copy of old recover-src/help.c + * oldrecover-src/Makefile.am: Copy of old recover-src/Makefile.am + * oldrecover-src/set_commands.c: Copy of old recover-src/set_commands.c + * oldrecover-src/uparse.y: Copy of old recover-src/uparse.y + * oldrecover-src/uscan.l: Copy of old recover-src/uscan.l + * recover-src/amrecover.c: Works with security-api. + * recover-src/amrecover.h: Works with security-api. + * recover-src/extract_list.c: Works with security-api. + +2006-05-08 Jean-Louis Martineau + * amandad-src/amandad.c: Fixup. + +2006-05-08 Jean-Louis Martineau + * common-src/packet.h: pkt_t.body is now a char*. + * common-src/packet.c (pkt_init): Return an alloced pkt.body. + * common-src/packet.c (pkt_cat): Increade pkt.body size if needed. + * common-src/protocol.c: Free allocated pkt.body. + * common-src/dgram.c (dgram_cat): Return int. + * common-src/dgram.h (dgram_cat): New prototype. + * common-src/krb5-security.c: Work with dynamicaly allocated packet + body. + * common-src/rsh-security.c: Work with dynamicaly allocated packet + body. + * common-src/ssh-security.c: Work with dynamicaly allocated packet + body. + * amandad-src/amandad.c: Work with dynamicaly allocated packet body. + * server-src/amcheck.c: Don't limit packet size. + * server-src/planner.c: Don't limit packet size. + +2006-05-08 Jean-Louis Martineau * amandad-src/amandad.c (service_new): Apply the correct patch. -2006-05-28 Jean-Louis Martineau - * Amanda 2.5.0p2 released. - * configure.in: AM_INIT_AUTOMAKE(amanda, 2.5.0p2). - * NEWS: Changes in release 2.5.0p2. +2006-05-08 Jean-Louis Martineau + * server-src/taper.c: Fix compiler warning. + * common-src/match.c: Many function get const parameters. + * common-src/amanda.h: Prototype change. 2006-05-07 Jean-Louis Martineau - * amandad-src/amandad.c (service_new): Make sure that the 3 data[] fd - are not in the range DATA_FD_OFFSET to + * amandad-src/amandad.c (service_new): Make sur that the 3 data_read[] + and the 3 data_write[] fd are not in the range DATA_FD_OFFSET to DATA_FD_OFFSET+DATA_FD_COUNT-1. +2006-05-05 Jean-Louis Martineau + * common-src/tapelist.c (append_to_tapelist): Remove bad amfree. + +2006-05-05 Nikhil Bandiwadekar + * server-src/conffile.c: fix to correctly handle am64 datatype + 2006-05-04 Jean-Louis Martineau * server-src/taper.c: Write the slot number in the - 'taper: wrote label' line. + 'taper: wrote label' line. * server-src/amverifyrun.sh.in: Parse that line. 2006-05-02 Jean-Louis Martineau * amstatus.pl.in: Limit characters for hostname in setup_estimate line. -2006-04-28 Jean-Louis Martineau - * Amanda 2.5.0p1 released. - * configure.in: AM_INIT_AUTOMAKE(amanda, 2.5.0p1). - * NEWS: Changes in release 2.5.0p1. +2006-04-27 Jean-Louis Martineau + * common-src/rsh-security.c: Pass "amdump amindexd amidxtaped" option + to amandad. + * common-src/ssh-security.c: Ditto. + +2006-04-27 Jean-Louis Martineau + * amandad-src/amandad.c: Accept a list of services on the command line. + +2006-04-27 Jean-Louis Martineau + * common-src/tapelist.c (append_to_tapelist): Fix memory leak. + +2006-04-27 Jean-Louis Martineau + * amandad-src/amandad.c: Fix memory leak. + * amandad-src/amandad.h (free_g_options): Prototype. + * amandad-src/amandad_util.c (free_g_options): New function to free a + g_option_t. + * server-src/amcleanupdisk.c: Fix memory leak. + * server-src/reporter.c: Fix memory leak. + * server-src/tapefile.c: Fix memory leak. + * server-src/taperscan.c: Put message in error_message. + +2006-04-26 Jean-Louis Martineau + * server-src/amcheck.c (start_server_check): Memory leak. + +2006-04-26 Jean-Louis Martineau + * amandad-src/Makefile.am (noinst_HEADERS): Add amandad.h. + * client-src/Makefile.am (noinst_HEADERS): Add clientconf.h. + +2006-04-26 Jean-Louis Martineau + * man/xml-source/amanda-client.conf.5.xml: New file. + +2006-04-26 Jean-Louis Martineau + * common-src/amanda.h (check_user_ruserok, check_user_amandahosts): + Remove prototype. + * common-src/bsd-security.c: Pass the service name across check_user* + function and validate it from the .amandahosts file. + +2006-04-26 Jean-Louis Martineau + * restore-src/amidxtaped.c: Can be launched by amandad. + * server-src/Makefile.am (INCLUDES): Add -I$(top_srcdir)/amandad-src + * server-src/Makefile.am (amidxtaped__LDADD): Link with libamandad. + * restore-src/restore.c: Fix indentation. + +2006-04-26 Jean-Louis Martineau + * server-src/amindexd.c: Can be launched by amandad + * server-src/Makefile.am (INCLUDES): Add -I$(top_srcdir)/amandad-src + * server-src/Makefile.am (amindexd_LDADD): Link with libamandad. + +2006-04-26 Jean-Louis Martineau + * amandad-src/amandad.c: New file. + * amandad-src/amandad.h: New file. + * amandad-src/amandad_util.c: New file, add function init_g_options + parse_g_options. + * amandad-src/Makefile.am: New file. + * client-src/amandad.c: Removed file. + * client-src/amandad.h: Removed file. + * client-src/client_util.c (init_g_options, parse_g_options): Remove. + * client-src/client_util.h (init_g_options, parse_g_options): Remove. + * client-src/Makefile.am (INCLUDES): -I$(top_srcdir)/amandad-src + * client-src/Makefile.am (libexec_PROGRAMS): Remove amandad. + * client-src/Makefile.am (LDADD): Add + ../amandad-src/libamandad.$(LIB_EXTENSION). + * client-src/selfcheck.c: #include "amandad.h". + * client-src/sendsize.c: #include "amandad.h". + * configure.in (AC_CONFIG_FILES): amandad-src/Makefile. + * Makefile.am (SUBDIRS): amandad-src. + +2006-04-26 Jean-Louis Martineau + * docs/security-api.txt: Document security_read_sync. + * common-src/security.h: Typo. + +2006-04-26 Jean-Louis Martineau + * client-src/amandad.c (service_new): Pass the "amandad" argument to + the service. + +2006-04-26 Jean-Louis Martineau + * common-src/bsd-security.c: Allow to run many services on the same + client. Cleanup. + * common-src/rsh-security.c: Ditto. + * common-src/ssh-security.c: Ditto. -2006-04-24 Ian Turner - * server-src/changer.c: Don't crash if we go to taperscan "Plan B". +2006-04-26 Jean-Louis Martineau + * common-src/security.h (security_stream_read_sync): Prototype. + * common-src/bsd-security.c (bsd_stream_read_sync): New function. + * common-src/krb4-security.c (krb4_stream_read_sync): New function. + * common-src/krb5-security.c (krb5_stream_read_sync): New function. + * common-src/rsh-security.c (rsh_stream_read_sync): New function. + * common-src/ssh-security.c (ssh_stream_read_sync): New function. + +2006-04-26 Jean-Louis Martineau + * client-src/amandad.c: Open pipe in both direction to the services. + * client-src/sendbackup.c: Deal with the newer pipe. + +2006-04-26 Jean-Louis Martineau + * client-src/clientconf.c: New file to read the client configuration + file. + * client-src/clientconf.h: Header. + * client-src/Makefile.am: Link clientconf into libamclient. + * configure.in (AC_CONFIG_FILES): example/amanda-client.conf. + * docs/amanda-client.conf.5.txt: New documentation. + * docs/Makefile.am (pkgdata_DATA): amanda-client.conf.5.txt. + * example/amanda-client.conf.in: exemple. + * example/Makefile.am (noinst_DATA): amanda-client.conf. + * man/entities/global.entities: amclientconf. + * man/Makefile.am (COMMON_MAN5_PAGES): amanda-client.conf.5. + * man/xml-source/amanda.8.xml (SEE ALSO): amanda-client.conf(5). + * man/xml-source/amanda.conf.5.xml (SEE ALSO): amanda-client.conf(5). + * man/xml-source/amrecover.8.xml (SEE ALSO): amanda-client.conf(5). + +2006-04-26 K. K. George + * server-src/reporter.c: Fix to untaint the mailto parameter. + * server-src/amcheck.c: Fix to untaint the mailto parameter + * changer-src/chg-scsi.c: Fix to untaint the mailto parameter. + * changer-src/chg-scsi-chio.c: Fix to untaint the mailto parameter. + * common-src/util.h: Added function to check if the mailto + parameter is untainted + * common-src/util.c: Added function to check if the mailto + parameter is untainted + +2006-04-26 Jean-Louis Martineau + * common-src/event.c(event_wait): New function. + * common-src/event.h(event_wait): prototype. + * docs/eventapi.txt: Document event_wait. 2006-04-24 Jean-Louis Martineau * server-src/planner.c: Fix divide by zero if runtapes==0. +2006-04-24 K. K. George + * server-src/reporter.c: Fix to make the mailto parameter in + amanda.conf optional. Added two more commandline options + -i & -Maddress. + * server-src/amcheck.c: Fix to make the mailto parameter in + amanda.conf optional. + * man/xml-source/amreport.8.xml: Modified to document the + -i & -Maddress commandline parameters + * docs/amreport.8.txt: Modified to document the + -i & -Maddress commandline parameters + * changer-src/chg-scsi.c: Fix to make the mailto parameter in + amanda.conf optional. + * changer-src/chg-scsi-chio.c: Fix to make the mailto parameter in + amanda.conf optional. + 2006-04-23 Jean-Louis Martineau * server-src/driver.c (handle_chunker_result): make sure that est_size > act-size. -2006-04-23 Jean-Louis Martineau - * server-src/chunker.c: Read the START command to set the datestamp. - * server-src/driver.c: Send a START command to the chunker. - * server-src/driverio.c (chunker_cmd): Add the START command. - * server-src/server_util.c (cmdstr): Add the START command. - * server-src/server_util.h (cmd_t): Add the START command. +2006-04-21 Jean-Louis Martineau + * server-src/changer.c (changer_command): Make sure fd[0] != 1. + +2006-04-19 Jean-Louis Martineau + * restore-src/amidxtaped.c: Cleanup. + +2006-04-19 Ian Turner + * tape-src/output-tape.c: Do a more thourough check to ensure + that we actually got a tape device, before proceeding to use + it. + +2006-04-18 Ian Turner + * changer-src/chg-disk.sh.in: Check that the virtual device is a + directory with proper permissions. + * server-src/changer.c: Do the right thing (failure) if there is + a problem with the changer. + +2006-04-18 Ian Turner + * recover-src/uscan.l: Accept setdate of the form + yyyy-MM-dd-hh-mm in addition to yyyy-MM-dd-hh-mm-ss. + * man/xml-source/amrecover.8.xml: Document this change. + +2006-04-14 Jean-Louis Martineau + * recover-src/help.c: Document setdate YYYY-MM-DD-HH-MM-SS format. + * man/xml-source/amrecover.8.xml: Ditto. + +2006-04-14 Jean-Louis Martineau + * client-src/amandad.c: Use %p to printf pointer. 2006-04-14 Jean-Louis Martineau * server-src/amtape.c: Add update command. +2006-04-11 Jean-Louis Martineau + * server-src/taper.c: log_add(L_WARNING) the output of taper_scan if + no valid tape are found. + +2006-04-11 Jean-Louis Martineau + * server-src/amcheck.c: Call taper_scan with + (..., FILE_taperscan_output_callback,outf) arguments. + * server-src/amtape.c: Call taper_scan with + (..., FILE_taperscan_output_callback,stderr) arguments. + * server-src/taper.c: Call taper_scan with + (..., CHAR_taperscan_output_callback, &error_msg) arguments. + * server-src/taperscan.h(FILE_taperscan_output_callback, + CHAR_taperscan_output_callback): Protoype. + * server-src/taperscan.h(taper_scan): New protoype, remove + error_message arg, add taperscan_output_callback and data arg. + * server-src/taperscan.c(FILE_taperscan_output_callback): Callback + that print the msg to it's arg, which is FILE*. + * server-src/taperscan.c(CHAR_taperscan_output_callback): Callback + that append the msg to it's arg, which is char*. + * server-src/taperscan.c(taper_scan): Fix for new arguments. + * server-src/taperscan.c(changer_taper_scan): Fix for new arguments. + +2006-04-11 Jean-Louis Martineau + * man/xml-source/amanda.conf.5.xml: Document amandad_path and + client_username dumptype option. + 2006-04-11 Jean-Louis Martineau * common-src/krb4-security.c: Increase timeout to 60 seconds. * common-src/rsh-security.c: Increase timeout to 60 seconds. * common-src/ssh-security.c: Increase timeout to 60 seconds. +2006-04-07 Jean-Louis Martineau + * server-src/conffile.c: New configuration option usetimestamps. + * server-src/conffile.h: New configuration option usetimestamps. + * example/amanda.conf.in: Document new usetimestamps options. + * man/xml-source/amanda.conf.5.xml: Document new usetimestamps options. + * server-src/amflush.c: Use datestamp or timestamp depending of + usetimesstamps. + * server-src/planner.c: Use datestamp or timestamp depending of + usetimesstamps. + * server-src/driver.c: Log an ERROR if many run a day and + usetimestamps us set to no. + +2006-04-07 Ian Turner + * server-src/changer.c: Don't crash if we go to taperscan "Plan + B". + +2006-04-07 Ian Turner + * server-src/changer.c: Only print changer debug messages if + there was a problem. + +2006-04-07 Ian Turner + * recover-src/amrecover.c: Print a more helpful command if mount + point autodetection fails. + * recover-src/display_commands.c: Print a more helpful message + if the user tries to ls without having setdisk earlier. + +2006-04-07 Jean-Louis Martineau + * server-src/amadmin.c: Fix use of datestamp as int. + * server-src/find.c: Ditto. + * server-src/reporter.c: Ditto. + * server-src/tapefile.c: Ditto. + +2006-04-07 Jean-Louis Martineau + * common-src/Makefile.am: Fix dependency between genversion and + versuff.o. + +2006-04-07 Jean-Louis Martineau + * recover-src/amrecover.c: Change initialization of server_name and + tape_server_name. + 2006-04-07 Jean-Louis Martineau * restore-src/amrestore.c: reset count_error to 0 on a restore. +2006-04-06 Kevin Till + * server-src/Makefile.am: always install planner/dumper setuid-root + * server-src/amcheck.c: check planner/dumper for setuid-root + * server-src/dumper.c: drop privilege asap. Switch between bsd + and ssh auth is now possible with the same installation. + * server-src/planner.c: ditto + +2006-04-06 Jean-Louis Martineau + * server-src/taperscan.c (changer_taper_scan): Pass a pointer to the + changer_loadslot call. + +2006-04-06 Jean-Louis Martineau + * server-src/tapefile.c (lookup_last_reusable_tape): Fix a datestamp + test with an int. + +2006-04-06 Ian Turner + * recover-src/amrecover.c (main): Check AMANDA_SERVER and + AMANDA_TAPE_SERVER environment variables before falling back + to compiled-in defaults. Document this new behavior. Thanks to + Malcolm Locke for the idea and patch. + +2006-04-06 Jean-Louis Martineau + * server-src/reporter.c (handle_chunk): CHUNK line always have the + datestamp. + +2006-04-05 Jean-Louis Martineau + * server-src/krb5-security.c: Fix for krb5_connect call in + open_callback. + +2006-04-05 Jean-Louis Martineau + * server-src/driver.c (start_some_dumps): Recover correctly if the + chunker reply with something that is not a PORT command. + * server-src/driver.c (dump_to_tape): remove duplicate free_serial. + * server-src/driverio.c: Improve debugging. + +2006-04-05 Jean-Louis Martineau + * common-src/tapelist.c(unmarshal_tapelist_str): Fix + "value computed is not used" compiler warning. + +2006-04-05 Jean-Louis Martineau + * common-src/bsd-security.c (bsd_connect): New datap argument. + * common-src/krb4-security.c (krb4_connect): New datap argument. + * common-src/krb5-security.c (krb5_connect): New datap argument. + * common-src/rsh-security.c (rsh_connect): New datap argument, + retrieve amanda_path and client_username from configuration. + * common-src/ssh-security.c (ssh_connect): New datap argument, + retrieve amanda_path and client_username from configuration. + * common-src/protocol.c: Pass new datap argument to security_connect. + * common-src/security.h(connect): New prototype. + * common-src/security.h(security_connect): Add datap to macro. + * server-src/amadmin.c(disklist_one): Print amandad_path and + client_username. + * server-src/conffile.c(AMANDAD_PATH, CLIENT_USERNAME): Parse new + dumptype option. + * server-src/conffile.h(dumptype_t): Add amandad_path and + client_username. + * server-src/diskfile.c(parse_diskline): Copy new field. + * server-src/diskfile.h(disk_t) Add amandad_path and client_username. + * server-src/driverio.c(dumper_cmd): Send dp->amandad_path and + dp->client_username in a PORT_DUMP command to the dumper. + * server-src/dumper.c: Parse amandad_path and client_username in a + PORT_DUMP command. + * server-src/dumper.c(dumper_get_security_conf): New function to return + configuration option to the security-api. + * server-src/dumper.c: Use dumper_get_security_conf for the callback + to protocol_sendreq. + * server-src/planner.c Use amhost_get_security_conf for the callback + to protocol_sendreq. + * server-src/amcheck.c: Use amhost_get_security_conf for the callback + to protocol_sendreq. + * server-src/server_util.c(amhost_get_security_conf): New function to + return configuration option to the security-api, + it expect an am_host_t arg. + * server-src/server_util.h(amhost_get_security_conf): Prototype. + +2006-04-05 Jean-Louis Martineau + * server-src/amstatus.pl.in: Remove duplicate instruction. + +2006-04-05 Jean-Louis Martineau + * server-src/amindexd.c: Remove all code that set str_buffer_size, + rename str_buffer_size to reply_buffer_size, + rename buf to reply_buffer, + * server-src/amindexd.c(reply, lreply_backend): Increase reply_buffer + size if required. + +2006-04-05 Jean-Louis Martineau + * common-src/amfeatures.h: Add fe_amrecover_timestamp amfeature. + * common-src/amfeatures.c (am_init_feature_set): + Add fe_amrecover_timestamp. + * server-src/amindexd.c(opaque_ls_one): New function. + * server-src/amindexd.c(disk_history_list,opaque_ls_one): Send only a + datestamp if client doesn't have fe_amrecover_timestamp. + +2006-04-05 Jean-Louis Martineau + * recover-src/uscan.l: Parse "setdate YYYY-MM-DD-HH-MM-SS". + * server-src/amindexd.c (cmp_date): New function to cmp datestamp with + timestamp, use it where needed. + * server-src/amindexd.c (amindexd_nicedate): Fix for timestamp. + * server-src/amtrmidx.c: Fix for timestamp. + * server-src/disk_history.h (DUMP_ITEM): Increase size of date. + +2006-04-05 Jean-Louis Martineau + * server-src/amflush.c: Send DATE line to driver, use timestamp. + * server-src/amindex.c (getindexfname): Increase datebuf size. + * server-src/amtrmlog.c: Fix bug with date_keep computation if + dumpcycle is INF. + * server-src/amtrmlog.c: rotate timestamped log file. + * server-src/chunker.c: Receive START cmd, use timestamp. + * server-src/driver.c: Receive DATE line, send START cmd to chunker, + use timestamp. + * server-src/driverio.c (startup_dump_processes): Send START cmd to + dumper. + * server-src/driverio.c (dumper_cmd, chunker_cmd): Send START command. + * server-src/driverio.h (startup_dump_processes): Prototype change, + need the timestamp. + * server-src/dumper.c: Receive START cmd, use timestamp. + * server-src/find.c (find_nicedate): Fix for timestamp. + * server-src/planner.c: Send DATE line to driver, use timestamp. + * server-src/server_util.c (cmdstr): Add START. + * server-src/server_util.h (cmd_t): Add START. + * server-src/taper.c: Get timestamp from TAPER_START command. + +2006-04-05 Jean-Louis Martineau + * server-src/amindexd.c (amindexd_nicedate): New function. + * server-src/find.h (struct find_result_s): Remove datestamp and + datestamp_aux field, only timestamp will be used. + * restore-src/amfetchdump.c: Convert datestamp to 'char *'. + * restore-src/restore.c: Convert datestamp to 'char *'. + * server-src/amindexd.c: Convert datestamp to 'char *'. + * server-src/amlabel.c: Convert datestamp to 'char *'. + * server-src/amtrmidx.c: Convert datestamp to 'char *'. + * server-src/find.c: Convert datestamp to 'char *'. + * server-src/reporter.c: Convert datestamp to 'char *'. + * server-src/tapefile.c: Convert datestamp to 'char *'. + * server-src/tapefile.h: Convert datestamp to 'char *'. + * server-src/taper.c: Convert datestamp to 'char *'. + +2006-04-05 Jean-Louis Martineau + * configure.in: AM_INIT_AUTOMAKE(amanda, 2.5.1b1). + 2006-04-05 Jean-Louis Martineau * server-src/driver.c: Change expression to remove overflow. @@ -129,11 +2158,11 @@ * restore-src/restore.c: Fix errors found using Coverity tools. 2006-03-09 Jean-Louis Martineau - * server-src/holding.c: Fix John fix. + * server-src/holding.c: Fix errors found using Coverity tools. 2006-03-09 Jean-Louis Martineau * server-src/driverio.c: Fix errors found using Coverity tools. - * server-src/planner.c: Fix John fix. + * server-src/planner.c: Fix errors found using Coverity tools. 2006-03-09 John Franks * changer-src/chg-scsi.c: Fix errors found using Coverity tools. @@ -550,18 +2579,18 @@ syntax, in favor of xx/-1. 2005-12-29 John Franks - * Index: recover-src/display_commands.c + * recover-src/display_commands.c Fix list deletion which did not update list root with NULL pointer. Make free_dir_item() a non-recursive function to prevent stack bloat. Fix list insertion code which inserts item in list initializes entry. - * Index: recover-src/extract_list.c + * recover-src/extract_list.c Fix to initialize lditem before using it... Prevent multiple frees of cmd string. Do not free err which is only initialized with static string pointers. Fix typo which caused newstralloc() to free the wrong memory. - * Index: server-src/amindexd.c + * server-src/amindexd.c Fix Compiler warning of unused variable. - * Index: server-src/taperscan.c + * server-src/taperscan.c Fix Compiler warning of bogus format specifier. 2005-12-29 Kevin Till diff --git a/Makefile.am b/Makefile.am index 9ebd706..fe62a56 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ if WANT_RESTORE RESTORE_SUBDIRS = restore-src endif if WANT_RECOVER -RECOVER_SUBDIRS = recover-src +RECOVER_SUBDIRS = recover-src oldrecover-src endif if WANT_AMPLOT PLOT_SUBDIRS = amplot @@ -28,6 +28,7 @@ endif SUBDIRS = \ config \ common-src \ + amandad-src \ $(TAPE_SUBDIRS) \ $(CLIENT_SUBDIRS) \ $(SERVER_SUBDIRS) \ @@ -37,6 +38,7 @@ SUBDIRS = \ man docs example pkgdata_DATA = \ + ReleaseNotes \ COPYRIGHT \ COPYRIGHT-APACHE \ COPYRIGHT-REGEX @@ -107,6 +109,18 @@ $(CONFIG_STATUS): $(SNAPSHOT_STAMP) SNAPSHOT: : SNAPSHOT file was removed, will reconfigure... +lint: + (cd amandad-src; make lint) + (cd changer-src; make lint) + (cd client-src; make lint) + (cd common-src; make lint) + (cd oldrecover-src; make lint) + (cd recover-src; make lint) + (cd regex-src; make lint) + (cd restore-src; make lint) + (cd server-src; make lint) + (cd tape-src; make lint) + ## Do not release the *.test.c sources. They get built on the fly and ## would contain a path from the distribution machine, which will just ## confuse the target user. diff --git a/Makefile.in b/Makefile.in index cfabcdc..488e39f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -70,9 +70,9 @@ pkgdataDATA_INSTALL = $(INSTALL_DATA) DATA = $(pkgdata_DATA) ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = config common-src tape-src client-src dumper-src \ - server-src changer-src restore-src recover-src amplot man docs \ - example +DIST_SUBDIRS = config common-src amandad-src tape-src client-src \ + dumper-src server-src changer-src restore-src recover-src \ + oldrecover-src amplot man docs example DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -91,11 +91,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -103,6 +106,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -292,12 +297,13 @@ ACINCLUDE_M4_DEPS = $(ACINCLUDE_M4I) $(LIBTOOL_M4I) @WANT_TAPE_TRUE@TAPE_SUBDIRS = tape-src @WANT_SERVER_TRUE@SERVER_SUBDIRS = server-src changer-src @WANT_RESTORE_TRUE@RESTORE_SUBDIRS = restore-src -@WANT_RECOVER_TRUE@RECOVER_SUBDIRS = recover-src +@WANT_RECOVER_TRUE@RECOVER_SUBDIRS = recover-src oldrecover-src @WANT_AMPLOT_TRUE@PLOT_SUBDIRS = amplot # order is significant, don't change it arbitrarily SUBDIRS = \ config \ common-src \ + amandad-src \ $(TAPE_SUBDIRS) \ $(CLIENT_SUBDIRS) \ $(SERVER_SUBDIRS) \ @@ -307,6 +313,7 @@ SUBDIRS = \ man docs example pkgdata_DATA = \ + ReleaseNotes \ COPYRIGHT \ COPYRIGHT-APACHE \ COPYRIGHT-REGEX @@ -817,6 +824,18 @@ $(CONFIG_STATUS): $(SNAPSHOT_STAMP) SNAPSHOT: : SNAPSHOT file was removed, will reconfigure... +lint: + (cd amandad-src; make lint) + (cd changer-src; make lint) + (cd client-src; make lint) + (cd common-src; make lint) + (cd oldrecover-src; make lint) + (cd recover-src; make lint) + (cd regex-src; make lint) + (cd restore-src; make lint) + (cd server-src; make lint) + (cd tape-src; make lint) + dist-hook: find $(distdir)/. -name '*.test.c' -exec rm {} \; # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/NEWS b/NEWS index db2f507..27a49f0 100644 --- a/NEWS +++ b/NEWS @@ -1,13 +1,53 @@ +Changes in release 2.5.1 + + * Defects found by Coverity scan and Klocwork K7 analysis tools fixed. + * Works with GNU tar 1.15.91 - work with new gtar state file format. + * Open SSL encryption support + * Two new authentication methods: bsdtcp, bsdudp. + * Unlimited number of DLEs on a client with bsdtcp, rsh and ssh + authentication methods. + * Recovery process amrecover uses Secure API. amoldrecover command + (same syntax and functionality as amrecover command) is provided for + compatibility with old Amanda releases. amoldrecover command uses old + amidxtaped/amindexd protocol. + * Amanda debug files are separated into client/server/amandad and + are also classified based on Amanda configuration name. + + * Amanda command changes + o amfetchdump -o is replaced by -O. + o amcheck -w option does all tests including the tape writable test. + Use amcheck -t -w to do only the tape writable test. + o -o command option to override Amanda configuration. See amanda man + page for details. + o amgetconf command doesn't write the BUGGY message when a entry + is not found in the configuration file. + + * Amanda configuration file changes + o amanda.conf changes + + amrecover_do_fsf in amanda.conf defaults to yes + + amrecover_check_label in amanda.conf defaults to yes + + usetimestamps in amanda.conf to support multiple + backup runs in a calendar day. + + holdingdisk in amanda.conf supports new values: + NEVER, AUTO, REQUIRED. + + amandad_path, client_username and ssh_keys in + amanda.conf for ssh/rsh authentication. + o New amanda client configuration file - amanda-client.conf. + Different client configuration file can be used for each Amanda + configuration. + + gnutar_list-dir and amandates can be specified in + Amanda client configuration file - amanda-client.conf + o .amandahosts format changes to allow use of secure API for recovery. + o Amanda service entries in xinetd configuration has changed. + + Changes in release 2.5.0p2 -* Fix major bug in amandad. -* amverifyeun works. -* amstatus works with ':' in diskname. +* listhost subcommand in amrecover Changes in release 2.5.0p1 * Add the 'amtape update' command. -* Many small bug fix. Changes in release 2.5.0 diff --git a/ReleaseNotes b/ReleaseNotes new file mode 100644 index 0000000..664194b --- /dev/null +++ b/ReleaseNotes @@ -0,0 +1,48 @@ + Release Notes for amanda-2.5.1 + + +usetimestamps + + This new feature will record all dump with timestamp instead of datestamp, + it will allow to do many dump in a day and recover easily anyone of them. + + If you use this features, you will not be able to downgrade to 2.5.0 or + earlier. + + see the usetimestamps section of 'man amanda.conf' + + +bsdudp/bsdtcp + + These are 2 new auth, they still use bsd authentification like bsd, but + use less port. + + bsdudp is like bsd, it use udp for connecting to client but it will use + only one tcp port for all data stream. + + bsdtcp use tcp to connect the to client and it's the only network + connection use. It doesn't have the udp packet size limit, so you can + have an unlimited number of DLE for a single host. + +amrecover use the security-api + + amrecover now use the security-api, You don't need to configure an + amindexd and an amidxtaped services in your xinetd. + amindexd and amidxtaped will be launched by amandad like any other services. + You must do modification to your xinetd configuration and .amandahosts toi + allow connection to amindexd and amidxtaped. + +new format of xinetd.d/amanda + + amandad get in arguments the list of services it can launch, you must add + theses services in the server_args options. + +new format of .amandahosts + + You must append to each line the services this client can launch, the + default is "amdump" + + +See the AUTHORIZATION section of the amanda man page and the +docs/howto-auth.txt + diff --git a/amandad-src/Makefile.am b/amandad-src/Makefile.am new file mode 100644 index 0000000..3411292 --- /dev/null +++ b/amandad-src/Makefile.am @@ -0,0 +1,59 @@ +# Makefile for Amanda client programs. + +INCLUDES = -I$(top_builddir)/common-src \ + -I$(top_srcdir)/common-src + +LINT=@AMLINT@ +LINTFLAGS=@AMLINTFLAGS@ + +lib_LTLIBRARIES = libamandad.la +LIB_EXTENSION = la + +libexec_PROGRAMS = amandad + +if WANT_RUNTIME_PSEUDO_RELOC +AM_LDFLAGS = -Wl,-enable-runtime-pseudo-reloc +endif + +libamandad_la_SOURCES= amandad_util.c +libamandad_la_LDFLAGS = -release $(VERSION) + +noinst_HEADERS = amandad.h + +### +# Because libamanda includes routines (e.g. regex) provided by some system +# libraries, and because of the way libtool sets up the command line, we +# need to list libamanda twice here, first to override the system library +# routines, and second to pick up any references in the other libraries. +### + +LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \ + libamandad.$(LIB_EXTENSION) \ + ../common-src/libamanda.$(LIB_EXTENSION) + +install-exec-hook: + @list="$(libexec_PROGRAMS) $(libexec_SCRIPTS)"; \ + for p in $$list; do \ + pa=$(DESTDIR)$(libexecdir)/`echo $$p|sed '$(transform)'`; \ + echo chown $(BINARY_OWNER) $$pa; \ + chown $(BINARY_OWNER) $$pa; \ + echo chgrp $(SETUID_GROUP) $$pa; \ + chgrp $(SETUID_GROUP) $$pa; \ + done + +lint: + @ for p in $(libexec_PROGRAMS); do \ + f="$$p.c $(libamandad_la_SOURCES)"; \ + (cd ../common-src; make listlibsrc); \ + f="$$f "`cat ../common-src/listlibsrc.output`; \ + (cd ../server-src; make listlibsrc); \ + f="$$f "`cat ../server-src/listlibsrc.output`; \ + echo $(LINT) $$f; \ + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config \ + $(INCLUDES) $$f; \ + if [ $$? -ne 0 ]; then \ + exit 1; \ + fi; \ + done; \ + exit 0 + diff --git a/amandad-src/Makefile.in b/amandad-src/Makefile.in new file mode 100644 index 0000000..80fd348 --- /dev/null +++ b/amandad-src/Makefile.in @@ -0,0 +1,655 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Makefile for Amanda client programs. + + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +libexec_PROGRAMS = amandad$(EXEEXT) +subdir = amandad-src +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libexecdir)" +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(lib_LTLIBRARIES) +libamandad_la_LIBADD = +am_libamandad_la_OBJECTS = amandad_util.lo +libamandad_la_OBJECTS = $(am_libamandad_la_OBJECTS) +libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(libexec_PROGRAMS) +amandad_SOURCES = amandad.c +amandad_OBJECTS = amandad.$(OBJEXT) +amandad_LDADD = $(LDADD) +amandad_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ + libamandad.$(LIB_EXTENSION) \ + ../common-src/libamanda.$(LIB_EXTENSION) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/config +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libamandad_la_SOURCES) amandad.c +DIST_SOURCES = $(libamandad_la_SOURCES) amandad.c +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMANDA_DBGDIR = @AMANDA_DBGDIR@ +AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ +AMANDA_TMPDIR = @AMANDA_TMPDIR@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ +AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ +AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ +AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ +AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ +BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ +CAT = @CAT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHIO = @CHIO@ +CHS = @CHS@ +CLIENT_LOGIN = @CLIENT_LOGIN@ +CLIENT_SCRIPTS_OPT = @CLIENT_SCRIPTS_OPT@ +COMPRESS = @COMPRESS@ +CONFIGURE_COMMAND = @CONFIGURE_COMMAND@ +CONFIG_DIR = @CONFIG_DIR@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DB_EXT = @DB_EXT@ +DD = @DD@ +DEFAULT_CHANGER_DEVICE = @DEFAULT_CHANGER_DEVICE@ +DEFAULT_CONFIG = @DEFAULT_CONFIG@ +DEFAULT_RAW_TAPE_DEVICE = @DEFAULT_RAW_TAPE_DEVICE@ +DEFAULT_SERVER = @DEFAULT_SERVER@ +DEFAULT_TAPE_DEVICE = @DEFAULT_TAPE_DEVICE@ +DEFAULT_TAPE_SERVER = @DEFAULT_TAPE_SERVER@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOC_BUILD_DATE = @DOC_BUILD_DATE@ +DUMP = @DUMP@ +DUMPER_DIR = @DUMPER_DIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GETCONF = @GETCONF@ +GNUPLOT = @GNUPLOT@ +GNUTAR = @GNUTAR@ +GNUTAR_LISTED_INCREMENTAL_DIR = @GNUTAR_LISTED_INCREMENTAL_DIR@ +GNUTAR_LISTED_INCREMENTAL_DIRX = @GNUTAR_LISTED_INCREMENTAL_DIRX@ +GREP = @GREP@ +GZIP = @GZIP@ +HAVE_XSLTPROC_FALSE = @HAVE_XSLTPROC_FALSE@ +HAVE_XSLTPROC_TRUE = @HAVE_XSLTPROC_TRUE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LL_FMT = @LL_FMT@ +LN_S = @LN_S@ +LTALLOCA = @LTALLOCA@ +LTLIBOBJS = @LTLIBOBJS@ +MAILER = @MAILER@ +MAKEINFO = @MAKEINFO@ +MAXTAPEBLOCKSIZE = @MAXTAPEBLOCKSIZE@ +MCUTIL = @MCUTIL@ +MT = @MT@ +MTX = @MTX@ +MT_FILE_FLAG = @MT_FILE_FLAG@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAT = @PCAT@ +PERL = @PERL@ +PRINT = @PRINT@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +RESTORE = @RESTORE@ +SAMBA_CLIENT = @SAMBA_CLIENT@ +SERVICE_SUFFIX = @SERVICE_SUFFIX@ +SETUID_GROUP = @SETUID_GROUP@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SNAPSHOT_STAMP = @SNAPSHOT_STAMP@ +STRIP = @STRIP@ +USE_VERSION_SUFFIXES = @USE_VERSION_SUFFIXES@ +VDUMP = @VDUMP@ +VERSION = @VERSION@ +VERSION_COMMENT = @VERSION_COMMENT@ +VERSION_MAJOR = @VERSION_MAJOR@ +VERSION_MINOR = @VERSION_MINOR@ +VERSION_PATCH = @VERSION_PATCH@ +VERSION_SUFFIX = @VERSION_SUFFIX@ +VRESTORE = @VRESTORE@ +VXDUMP = @VXDUMP@ +VXRESTORE = @VXRESTORE@ +WANT_AMPLOT_FALSE = @WANT_AMPLOT_FALSE@ +WANT_AMPLOT_TRUE = @WANT_AMPLOT_TRUE@ +WANT_CHG_SCSI_FALSE = @WANT_CHG_SCSI_FALSE@ +WANT_CHG_SCSI_TRUE = @WANT_CHG_SCSI_TRUE@ +WANT_CHIO_SCSI_FALSE = @WANT_CHIO_SCSI_FALSE@ +WANT_CHIO_SCSI_TRUE = @WANT_CHIO_SCSI_TRUE@ +WANT_CLIENT_FALSE = @WANT_CLIENT_FALSE@ +WANT_CLIENT_TRUE = @WANT_CLIENT_TRUE@ +WANT_RECOVER_FALSE = @WANT_RECOVER_FALSE@ +WANT_RECOVER_TRUE = @WANT_RECOVER_TRUE@ +WANT_RESTORE_FALSE = @WANT_RESTORE_FALSE@ +WANT_RESTORE_TRUE = @WANT_RESTORE_TRUE@ +WANT_RUNTIME_PSEUDO_RELOC_FALSE = @WANT_RUNTIME_PSEUDO_RELOC_FALSE@ +WANT_RUNTIME_PSEUDO_RELOC_TRUE = @WANT_RUNTIME_PSEUDO_RELOC_TRUE@ +WANT_SAMBA_FALSE = @WANT_SAMBA_FALSE@ +WANT_SAMBA_TRUE = @WANT_SAMBA_TRUE@ +WANT_SERVER_FALSE = @WANT_SERVER_FALSE@ +WANT_SERVER_TRUE = @WANT_SERVER_TRUE@ +WANT_SETUID_CLIENT_FALSE = @WANT_SETUID_CLIENT_FALSE@ +WANT_SETUID_CLIENT_TRUE = @WANT_SETUID_CLIENT_TRUE@ +WANT_SSH_SECURITY_FALSE = @WANT_SSH_SECURITY_FALSE@ +WANT_SSH_SECURITY_TRUE = @WANT_SSH_SECURITY_TRUE@ +WANT_TAPE_FALSE = @WANT_TAPE_FALSE@ +WANT_TAPE_TRUE = @WANT_TAPE_TRUE@ +XFSDUMP = @XFSDUMP@ +XFSRESTORE = @XFSRESTORE@ +XSLTPROC = @XSLTPROC@ +YACC = @YACC@ +ac_c = @ac_c@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +ac_n = @ac_n@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +INCLUDES = -I$(top_builddir)/common-src \ + -I$(top_srcdir)/common-src + +LINT = @AMLINT@ +LINTFLAGS = @AMLINTFLAGS@ +lib_LTLIBRARIES = libamandad.la +LIB_EXTENSION = la +@WANT_RUNTIME_PSEUDO_RELOC_TRUE@AM_LDFLAGS = -Wl,-enable-runtime-pseudo-reloc +libamandad_la_SOURCES = amandad_util.c +libamandad_la_LDFLAGS = -release $(VERSION) +noinst_HEADERS = amandad.h + +### +# Because libamanda includes routines (e.g. regex) provided by some system +# libraries, and because of the way libtool sets up the command line, we +# need to list libamanda twice here, first to override the system library +# routines, and second to pick up any references in the other libraries. +### +LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \ + libamandad.$(LIB_EXTENSION) \ + ../common-src/libamanda.$(LIB_EXTENSION) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu amandad-src/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu amandad-src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libamandad.la: $(libamandad_la_OBJECTS) $(libamandad_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libamandad_la_LDFLAGS) $(libamandad_la_OBJECTS) $(libamandad_la_LIBADD) $(LIBS) +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(libexecdir)" || $(mkdir_p) "$(DESTDIR)$(libexecdir)" + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(libexecPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(libexecdir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(libexecPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(libexecdir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(libexecdir)/$$f'"; \ + rm -f "$(DESTDIR)$(libexecdir)/$$f"; \ + done + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +amandad$(EXEEXT): $(amandad_OBJECTS) $(amandad_DEPENDENCIES) + @rm -f amandad$(EXEEXT) + $(LINK) $(amandad_LDFLAGS) $(amandad_OBJECTS) $(amandad_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amandad.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amandad_util.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libexecPROGRAMS \ + clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-libLTLIBRARIES install-libexecPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \ + uninstall-libexecPROGRAMS + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libexecPROGRAMS clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-exec-hook \ + install-info install-info-am install-libLTLIBRARIES \ + install-libexecPROGRAMS install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-info-am \ + uninstall-libLTLIBRARIES uninstall-libexecPROGRAMS + + +install-exec-hook: + @list="$(libexec_PROGRAMS) $(libexec_SCRIPTS)"; \ + for p in $$list; do \ + pa=$(DESTDIR)$(libexecdir)/`echo $$p|sed '$(transform)'`; \ + echo chown $(BINARY_OWNER) $$pa; \ + chown $(BINARY_OWNER) $$pa; \ + echo chgrp $(SETUID_GROUP) $$pa; \ + chgrp $(SETUID_GROUP) $$pa; \ + done + +lint: + @ for p in $(libexec_PROGRAMS); do \ + f="$$p.c $(libamandad_la_SOURCES)"; \ + (cd ../common-src; make listlibsrc); \ + f="$$f "`cat ../common-src/listlibsrc.output`; \ + (cd ../server-src; make listlibsrc); \ + f="$$f "`cat ../server-src/listlibsrc.output`; \ + echo $(LINT) $$f; \ + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config \ + $(INCLUDES) $$f; \ + if [ $$? -ne 0 ]; then \ + exit 1; \ + fi; \ + done; \ + exit 0 +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/amandad-src/amandad.c b/amandad-src/amandad.c new file mode 100644 index 0000000..772cd39 --- /dev/null +++ b/amandad-src/amandad.c @@ -0,0 +1,1649 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-1999 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ + +/* + * $Id: amandad.c,v 1.18 2006/08/21 20:17:09 martinea Exp $ + * + * handle client-host side of Amanda network communications, including + * security checks, execution of the proper service, and acking the + * master side + */ + +/*#define AMANDAD_DEBUG*/ + +#include "amanda.h" +#include "amandad.h" +#include "clock.h" +#include "event.h" +#include "amfeatures.h" +#include "packet.h" +#include "version.h" +#include "queue.h" +#include "security.h" +#include "stream.h" +#include "util.h" + +#define REP_TIMEOUT (6*60*60) /* secs for service to reply */ +#define ACK_TIMEOUT 10 /* XXX should be configurable */ +#define MAX_REP_RETRIES 5 + +/* + * These are the actions for entering the state machine + */ +typedef enum { A_START, A_RECVPKT, A_RECVREP, A_PENDING, A_FINISH, A_CONTINUE, + A_SENDNAK, A_TIMEOUT } action_t; + +/* + * This is a state in the state machine. It is a function pointer to + * the function that actually implements the state. + */ +struct active_service; +typedef action_t (*state_t)(struct active_service *, action_t, pkt_t *); + +/* + * This structure describes an active running service. + * + * An active service is something running that we have received + * a request for. This structure holds info on that service, including + * file descriptors for data, etc, as well as the security handle + * for communications with the amanda server. + */ +struct active_service { + char *cmd; /* name of command we ran */ + char *arguments; /* arguments we sent it */ + security_handle_t *security_handle; /* remote server */ + state_t state; /* how far this has progressed */ + pid_t pid; /* pid of subprocess */ + int send_partial_reply; /* send PREP packet */ + int reqfd; /* pipe to write requests */ + int repfd; /* pipe to read replies */ + event_handle_t *ev_repfd; /* read event handle for repfd */ + event_handle_t *ev_reptimeout; /* timeout for rep data */ + pkt_t rep_pkt; /* rep packet we're sending out */ + char *repbuf; /* buffer to read the rep into */ + size_t bufsize; /* length of repbuf */ + size_t repbufsize; /* length of repbuf */ + int repretry; /* times we'll retry sending the rep */ + /* + * General user streams to the process, and their equivalent + * network streams. + */ + struct datafd_handle { + int fd_read; /* pipe to child process */ + int fd_write; /* pipe to child process */ + event_handle_t *ev_read; /* it's read event handle */ + event_handle_t *ev_write; /* it's write event handle */ + security_stream_t *netfd; /* stream to amanda server */ + struct active_service *as; /* pointer back to our enclosure */ + } data[DATA_FD_COUNT]; + char databuf[NETWORK_BLOCK_BYTES]; /* buffer to relay netfd data in */ + TAILQ_ENTRY(active_service) tq; /* queue handle */ +}; + +/* + * Here are the services that we allow. + */ +static struct services { + char *name; + int active; +} services[] = { + { "noop", 1 }, + { "sendsize", 1 }, + { "sendbackup", 1 }, + { "selfcheck", 1 }, + { "amindexd", 0 }, + { "amidxtaped", 0 } +}; +#define NSERVICES (int)(sizeof(services) / sizeof(services[0])) + +/* + * Queue of outstanding requests that we are running. + */ +static struct { + TAILQ_HEAD(, active_service) tailq; + int qlength; +} serviceq = { + TAILQ_HEAD_INITIALIZER(serviceq.tailq), 0 +}; + +/* + * Data for dbmalloc to check for memory leaks + */ +#ifdef USE_DBMALLOC +static struct { + struct { + unsigned long size, hist; + } start, end; +} dbmalloc_info; +#endif + +static int wait_30s = 1; +static int exit_on_qlength = 1; +static char *auth = NULL; + +int main(int argc, char **argv); + +static int allocstream(struct active_service *, int); +static void exit_check(void *); +static void protocol_accept(security_handle_t *, pkt_t *); +static void state_machine(struct active_service *, action_t, pkt_t *); + +static action_t s_sendack(struct active_service *, action_t, pkt_t *); +static action_t s_repwait(struct active_service *, action_t, pkt_t *); +static action_t s_processrep(struct active_service *, action_t, pkt_t *); +static action_t s_sendrep(struct active_service *, action_t, pkt_t *); +static action_t s_ackwait(struct active_service *, action_t, pkt_t *); + +static void repfd_recv(void *); +static void timeout_repfd(void *); +static void protocol_recv(void *, pkt_t *, security_status_t); +static void process_readnetfd(void *); +static void process_writenetfd(void *, void *, ssize_t); +static struct active_service *service_new(security_handle_t *, + const char *, const char *); +static void service_delete(struct active_service *); +static int writebuf(struct active_service *, const void *, size_t); +static ssize_t do_sendpkt(security_handle_t *handle, pkt_t *pkt); + +static void child_signal(int signal); + +#ifdef AMANDAD_DEBUG +static const char *state2str(state_t); +static const char *action2str(action_t); +#endif + +/* + * Harvests defunct processes... + */ + +static void +child_signal( + int signal) +{ + pid_t rp; + + (void)signal; /* Quite compiler warning */ + /* + * Reap and child status and promptly ignore since we don't care... + */ + do { + rp = waitpid(-1, NULL, WNOHANG); + } while (rp > 0); +} + +int +main( + int argc, + char ** argv) +{ + int i, j; + int have_services; + int in, out; + const security_driver_t *secdrv; + int no_exit = 0; + struct sigaction act, oact; + char *pgm = "amandad"; /* in case argv[0] is not set */ +#if defined(AMANDAD_DEBUG) && defined(USE_REUSEADDR) + const int on = 1; + int r; +#endif + + safe_fd(-1, 0); + safe_cd(); + + /* + * When called via inetd, it is not uncommon to forget to put the + * argv[0] value on the config line. On some systems (e.g. Solaris) + * this causes argv and/or argv[0] to be NULL, so we have to be + * careful getting our name. + */ + if ((argv == NULL) || (argv[0] == NULL)) { + pgm = "amandad"; /* in case argv[0] is not set */ + } else { + pgm = basename(argv[0]); /* Strip of leading path get debug name */ + } + set_pname(pgm); + dbopen(DBG_SUBDIR_AMANDAD); + + if(argv == NULL) { + error("argv == NULL\n"); + /*NOTREACHED*/ + } + + /* Don't die when child closes pipe */ + signal(SIGPIPE, SIG_IGN); + + /* Tell me when a child exits or dies... */ + act.sa_handler = child_signal; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; + if(sigaction(SIGCHLD, &act, &oact) != 0) { + error("error setting SIGCHLD handler: %s", strerror(errno)); + /*NOTREACHED*/ + } + +#ifdef USE_DBMALLOC + dbmalloc_info.start.size = malloc_inuse(&dbmalloc_info.start.hist); +#endif + + erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG); + +#ifdef FORCE_USERID + /* we'd rather not run as root */ + if (geteuid() == 0) { + if(client_uid == (uid_t) -1) { + error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN); + /*NOTREACHED*/ + } + initgroups(CLIENT_LOGIN, client_gid); + setgid(client_gid); + setegid(client_gid); + seteuid(client_uid); + } +#endif /* FORCE_USERID */ + + /* + * ad-hoc argument parsing + * + * We accept -auth=[authentication type] + * -no-exit +#ifdef AMANDAD_DEBUG + * -tcp=[port] + * -udp=[port] +#endif + * We also add a list of services that amandad can launch + */ + secdrv = NULL; + in = 0; out = 1; /* default to stdin/stdout */ + have_services = 0; + for (i = 1; i < argc; i++) { + /* + * accept -krb4 as an alias for -auth=krb4 (for compatibility) + */ + if (strcmp(argv[i], "-krb4") == 0) { + argv[i] = "-auth=krb4"; + /* FALLTHROUGH */ + auth = "krb4"; + } + + /* + * Get a driver for a security type specified after -auth= + */ + else if (strncmp(argv[i], "-auth=", strlen("-auth=")) == 0) { + argv[i] += strlen("-auth="); + secdrv = security_getdriver(argv[i]); + auth = argv[i]; + if (secdrv == NULL) { + error("no driver for security type '%s'\n", argv[i]); + /*NOTREACHED*/ + } + continue; + } + + /* + * If -no-exit is specified, always run even after requests have + * been satisfied. + */ + else if (strcmp(argv[i], "-no-exit") == 0) { + no_exit = 1; + continue; + } + +#ifdef AMANDAD_DEBUG + /* + * Allow us to directly bind to a udp port for debugging. + * This may only apply to some security types. + */ + else if (strncmp(argv[i], "-udp=", strlen("-udp=")) == 0) { + struct sockaddr_in sin; + + argv[i] += strlen("-udp="); + in = out = socket(AF_INET, SOCK_DGRAM, 0); + if (in < 0) { + error("can't create dgram socket: %s\n", strerror(errno)); + /*NOTREACHED*/ + } +#ifdef USE_REUSEADDR + r = setsockopt(in, SOL_SOCKET, SO_REUSEADDR, + (void *)&on, (socklen_t)sizeof(on)); + if (r < 0) { + dbprintf(("%s: amandad: setsockopt(SO_REUSEADDR) failed: %s\n", + debug_prefix(NULL), + strerror(errno))); + } +#endif + + sin.sin_family = (sa_family_t)AF_INET; + sin.sin_addr.s_addr = INADDR_ANY; + sin.sin_port = (in_port_t)htons((in_port_t)atoi(argv[i])); + if (bind(in, (struct sockaddr *)&sin, (socklen_t)sizeof(sin)) < 0) { + error("can't bind to port %d: %s\n", atoi(argv[i]), + strerror(errno)); + /*NOTREACHED*/ + } + } + /* + * Ditto for tcp ports. + */ + else if (strncmp(argv[i], "-tcp=", strlen("-tcp=")) == 0) { + struct sockaddr_in sin; + int sock; + socklen_t n; + + argv[i] += strlen("-tcp="); + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) { + error("can't create tcp socket: %s\n", strerror(errno)); + /*NOTREACHED*/ + } + n = 1; +#ifdef USE_REUSEADDR + r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&on, (socklen_t)sizeof(on)); + if (r < 0) { + dbprintf(("%s: amandad: setsockopt(SO_REUSEADDR) failed: %s\n", + debug_prefix(NULL), + strerror(errno))); + } +#endif + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&n, (socklen_t)sizeof(n)); + sin.sin_family = (sa_family_t)AF_INET; + sin.sin_addr.s_addr = INADDR_ANY; + sin.sin_port = (in_port_t)htons((in_port_t)atoi(argv[i])); + if (bind(sock, (struct sockaddr *)&sin, (socklen_t)sizeof(sin)) < 0) { + error("can't bind to port %d: %s\n", atoi(argv[i]), + strerror(errno)); + /*NOTREACHED*/ + } + listen(sock, 10); + n = (socklen_t)sizeof(sin); + in = out = accept(sock, (struct sockaddr *)&sin, &n); + } +#endif + /* + * It must be a service name + */ + else { + /* clear all services */ + if(!have_services) { + for (j = 0; j < (int)NSERVICES; j++) + services[j].active = 0; + } + have_services = 1; + + if(strcmp(argv[i],"amdump") == 0) { + services[0].active = 1; + services[1].active = 1; + services[2].active = 1; + services[3].active = 1; + } + else { + for (j = 0; j < (int)NSERVICES; j++) + if (strcmp(services[j].name, argv[i]) == 0) + break; + if (j == (int)NSERVICES) { + dbprintf(("%s: %s: invalid service\n", + debug_prefix_time(NULL), argv[i])); + exit(1); + } + services[j].active = 1; + } + } + } + + /* + * If no security type specified, use BSD + */ + if (secdrv == NULL) { + secdrv = security_getdriver("BSD"); + auth = "bsd"; + if (secdrv == NULL) { + error("no driver for default security type 'BSD'\n"); + /*NOTREACHED*/ + } + } + + if(strcasecmp(auth, "rsh") == 0 || + strcasecmp(auth, "ssh") == 0 || + strcasecmp(auth, "bsdtcp") == 0) { + wait_30s = 0; + exit_on_qlength = 1; + } + + /* initialize */ + + startclock(); + + dbprintf(("%s: version %s\n", get_pname(), version())); + for (i = 0; version_info[i] != NULL; i++) { + dbprintf(("%s: %s", debug_prefix(NULL), version_info[i])); + } + + if (! (argc >= 1 && argv != NULL && argv[0] != NULL)) { + dbprintf(("%s: WARNING: argv[0] not defined: check inetd.conf\n", + debug_prefix(NULL))); + } + + /* + * Schedule to call protocol_accept() when new security handles + * are created on stdin. + */ + security_accept(secdrv, in, out, protocol_accept); + + /* + * Schedule an event that will try to exit every 30 seconds if there + * are no requests outstanding. + */ + if(wait_30s) + (void)event_register((event_id_t)30, EV_TIME, exit_check, &no_exit); + + /* + * Call event_loop() with an arg of 0, telling it to block until all + * events are completed. + */ + event_loop(0); + + close(in); + close(out); + dbclose(); + return(0); +} + +/* + * This runs periodically and checks to see if we have any active services + * still running. If we don't, then we quit. + */ +static void +exit_check( + void * cookie) +{ + int no_exit; + + assert(cookie != NULL); + no_exit = *(int *)cookie; + + /* + * If things are still running, then don't exit. + */ + if (serviceq.qlength > 0) + return; + + /* + * If the caller asked us to never exit, then we're done + */ + if (no_exit) + return; + +#ifdef USE_DBMALLOC + dbmalloc_info.end.size = malloc_inuse(&dbmalloc_info.end.hist); + + if (dbmalloc_info.start.size != dbmalloc_info.end.size) { + malloc_list(dbfd(), dbmalloc_info.start.hist, + dbmalloc_info.end.hist); + } +#endif + + dbclose(); + exit(0); +} + +/* + * Handles new incoming protocol handles. This is a callback for + * security_accept(), which gets called when new handles are detected. + */ +static void +protocol_accept( + security_handle_t * handle, + pkt_t * pkt) +{ + pkt_t pkt_out; + struct active_service *as; + char *pktbody, *tok, *service, *arguments; + char *service_path = NULL; + int i; + + pkt_out.body = NULL; + + /* + * If handle is NULL, then the connection is closed. + */ + if(handle == NULL) { + return; + } + + /* + * If pkt is NULL, then there was a problem with the new connection. + */ + if (pkt == NULL) { + dbprintf(("%s: accept error: %s\n", + debug_prefix_time(NULL), security_geterror(handle))); + pkt_init(&pkt_out, P_NAK, "ERROR %s\n", security_geterror(handle)); + do_sendpkt(handle, &pkt_out); + amfree(pkt_out.body); + security_close(handle); + return; + } + + dbprintf(("%s: accept recv %s pkt:\n<<<<<\n%s>>>>>\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); + + /* + * If this is not a REQ packet, just forget about it. + */ + if (pkt->type != P_REQ) { + dbprintf(("%s: received unexpected %s packet:\n<<<<<\n%s>>>>>\n\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); + security_close(handle); + return; + } + + pktbody = service = arguments = NULL; + as = NULL; + + /* + * Parse out the service and arguments + */ + + pktbody = stralloc(pkt->body); + + tok = strtok(pktbody, " "); + if (tok == NULL) + goto badreq; + if (strcmp(tok, "SERVICE") != 0) + goto badreq; + + tok = strtok(NULL, " \n"); + if (tok == NULL) + goto badreq; + service = stralloc(tok); + + /* we call everything else 'arguments' */ + tok = strtok(NULL, ""); + if (tok == NULL) + goto badreq; + arguments = stralloc(tok); + + /* see if it's one we allow */ + for (i = 0; i < (int)NSERVICES; i++) + if (services[i].active == 1 && strcmp(services[i].name, service) == 0) + break; + if (i == (int)NSERVICES) { + dbprintf(("%s: %s: invalid service\n", + debug_prefix_time(NULL), service)); + pkt_init(&pkt_out, P_NAK, "ERROR %s: invalid service\n", service); + goto send_pkt_out; + } + + service_path = vstralloc(libexecdir, "/", service, versionsuffix(), NULL); + if (access(service_path, X_OK) < 0) { + dbprintf(("%s: can't execute %s: %s\n", + debug_prefix_time(NULL), service_path, strerror(errno))); + pkt_init(&pkt_out, P_NAK, + "ERROR execute access to \"%s\" denied\n", + service_path); + goto send_pkt_out; + } + + /* see if its already running */ + for (as = TAILQ_FIRST(&serviceq.tailq); as != NULL; + as = TAILQ_NEXT(as, tq)) { + if (strcmp(as->cmd, service_path) == 0 && + strcmp(as->arguments, arguments) == 0) { + dbprintf(("%s: %s %s: already running, acking req\n", + debug_prefix_time(NULL), service, arguments)); + pkt_init(&pkt_out, P_ACK, ""); + goto send_pkt_out_no_delete; + } + } + + /* + * create a new service instance, and send the arguments down + * the request pipe. + */ + dbprintf(("%s: creating new service: %s\n%s\n", + debug_prefix_time(NULL), service, arguments)); + as = service_new(handle, service_path, arguments); + if (writebuf(as, arguments, strlen(arguments)) < 0) { + const char *errmsg = strerror(errno); + dbprintf(("%s: error sending arguments to %s: %s\n", + debug_prefix_time(NULL), service, errmsg)); + pkt_init(&pkt_out, P_NAK, "ERROR error writing arguments to %s: %s\n", + service, errmsg); + goto send_pkt_out; + } + aclose(as->reqfd); + + amfree(pktbody); + amfree(service); + amfree(service_path); + amfree(arguments); + + /* + * Move to the sendack state, and start up the state + * machine. + */ + as->state = s_sendack; + state_machine(as, A_START, NULL); + return; + +badreq: + pkt_init(&pkt_out, P_NAK, "ERROR invalid REQ\n"); + dbprintf(("%s: received invalid %s packet:\n<<<<<\n%s>>>>>\n\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); + +send_pkt_out: + if(as) + service_delete(as); +send_pkt_out_no_delete: + amfree(pktbody); + amfree(service_path); + amfree(service); + amfree(arguments); + do_sendpkt(handle, &pkt_out); + security_close(handle); + amfree(pkt_out.body); +} + +/* + * Handles incoming protocol packets. Routes responses to the proper + * running service. + */ +static void +state_machine( + struct active_service * as, + action_t action, + pkt_t * pkt) +{ + action_t retaction; + state_t curstate; + pkt_t nak; + +#ifdef AMANDAD_DEBUG + dbprintf(("%s: state_machine: %p entering\n", + debug_prefix_time(NULL), as)); +#endif + for (;;) { + curstate = as->state; +#ifdef AMANDAD_DEBUG + dbprintf(("%s: state_machine: %p curstate=%s action=%s\n", + debug_prefix_time(NULL), as, + state2str(curstate), action2str(action))); +#endif + retaction = (*curstate)(as, action, pkt); +#ifdef AMANDAD_DEBUG + dbprintf(("%s: state_machine: %p curstate=%s returned %s (nextstate=%s)\n", + debug_prefix_time(NULL), + as, state2str(curstate), action2str(retaction), + state2str(as->state))); +#endif + + switch (retaction) { + /* + * State has queued up and is now blocking on input. + */ + case A_PENDING: +#ifdef AMANDAD_DEBUG + dbprintf(("%s: state_machine: %p leaving (A_PENDING)\n", + debug_prefix_time(NULL), as)); +#endif + return; + + /* + * service has switched states. Loop. + */ + case A_CONTINUE: + break; + + /* + * state has determined that the packet it received was bogus. + * Send a nak, and return. + */ + case A_SENDNAK: + dbprintf(("%s: received unexpected %s packet\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type))); + dbprintf(("<<<<<\n%s----\n\n", pkt->body)); + pkt_init(&nak, P_NAK, "ERROR unexpected packet type %s\n", + pkt_type2str(pkt->type)); + do_sendpkt(as->security_handle, &nak); + amfree(nak.body); +#ifdef AMANDAD_DEBUG + dbprintf(("%s: state_machine: %p leaving (A_SENDNAK)\n", + debug_prefix_time(NULL), as)); +#endif + return; + + /* + * Service is done. Remove it and finish. + */ + case A_FINISH: + service_delete(as); +#ifdef AMANDAD_DEBUG + dbprintf(("%s: state_machine: %p leaving (A_FINISH)\n", + debug_prefix_time(NULL), as)); +#endif + return; + + default: + assert(0); + break; + } + } + /*NOTREACHED*/ +} + +/* + * This state just sends an ack. After that, we move to the repwait + * state to wait for REP data to arrive from the subprocess. + */ +static action_t +s_sendack( + struct active_service * as, + action_t action, + pkt_t * pkt) +{ + pkt_t ack; + + (void)action; /* Quiet unused parameter warning */ + (void)pkt; /* Quiet unused parameter warning */ + + pkt_init(&ack, P_ACK, ""); + if (do_sendpkt(as->security_handle, &ack) < 0) { + dbprintf(("%s: error sending ACK: %s\n", + debug_prefix_time(NULL), security_geterror(as->security_handle))); + amfree(ack.body); + return (A_FINISH); + } + amfree(ack.body); + + /* + * move to the repwait state + * Setup a listener for data on the reply fd, but also + * listen for packets over the wire, as the server may + * poll us if we take a long time. + * Setup a timeout that will fire if it takes too long to + * receive rep data. + */ + as->state = s_repwait; + as->ev_repfd = event_register((event_id_t)as->repfd, EV_READFD, repfd_recv, as); + as->ev_reptimeout = event_register(REP_TIMEOUT, EV_TIME, + timeout_repfd, as); + security_recvpkt(as->security_handle, protocol_recv, as, -1); + return (A_PENDING); +} + +/* + * This is the repwait state. We have responded to the initial REQ with + * an ACK, and we are now waiting for the process we spawned to pass us + * data to send in a REP. + */ +static action_t +s_repwait( + struct active_service * as, + action_t action, + pkt_t * pkt) +{ + ssize_t n; + char *repbuf_temp; + + /* + * We normally shouldn't receive any packets while waiting + * for our REP data, but in some cases we do. + */ + if (action == A_RECVPKT) { + assert(pkt != NULL); + /* + * Another req for something that's running. Just send an ACK + * and go back and wait for more data. + */ + if (pkt->type == P_REQ) { + dbprintf(("%s: received dup P_REQ packet, ACKing it\n", + debug_prefix_time(NULL))); + amfree(as->rep_pkt.body); + pkt_init(&as->rep_pkt, P_ACK, ""); + do_sendpkt(as->security_handle, &as->rep_pkt); + return (A_PENDING); + } + /* something unexpected. Nak it */ + return (A_SENDNAK); + } + + if (action == A_TIMEOUT) { + amfree(as->rep_pkt.body); + pkt_init(&as->rep_pkt, P_NAK, "ERROR timeout on reply pipe\n"); + dbprintf(("%s: %s timed out waiting for REP data\n", + debug_prefix_time(NULL), as->cmd)); + do_sendpkt(as->security_handle, &as->rep_pkt); + return (A_FINISH); + } + + assert(action == A_RECVREP); + if(as->bufsize == 0) { + as->bufsize = NETWORK_BLOCK_BYTES; + as->repbuf = alloc(as->bufsize); + } + + do { + n = read(as->repfd, as->repbuf + as->repbufsize, + as->bufsize - as->repbufsize - 1); + } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); + if (n < 0) { + const char *errstr = strerror(errno); + dbprintf(("%s: read error on reply pipe: %s\n", + debug_prefix_time(NULL), errstr)); + amfree(as->rep_pkt.body); + pkt_init(&as->rep_pkt, P_NAK, "ERROR read error on reply pipe: %s\n", + errstr); + do_sendpkt(as->security_handle, &as->rep_pkt); + return (A_FINISH); + } + /* + * If we got some data, go back and wait for more, or EOF. Nul terminate + * the buffer first. + */ + as->repbuf[n + as->repbufsize] = '\0'; + if (n > 0) { + as->repbufsize += n; + if(as->repbufsize >= (as->bufsize - 1)) { + as->bufsize *= 2; + repbuf_temp = alloc(as->bufsize); + memcpy(repbuf_temp, as->repbuf, as->repbufsize + 1); + amfree(as->repbuf); + as->repbuf = repbuf_temp; + } + else if(as->send_partial_reply) { + amfree(as->rep_pkt.body); + pkt_init(&as->rep_pkt, P_PREP, "%s", as->repbuf); + do_sendpkt(as->security_handle, &as->rep_pkt); + amfree(as->rep_pkt.body); + pkt_init(&as->rep_pkt, P_REP, ""); + } + + return (A_PENDING); + } + + /* + * If we got 0, then we hit EOF. Process the data and release + * the timeout. + */ + assert(n == 0); + + assert(as->ev_repfd != NULL); + event_release(as->ev_repfd); + as->ev_repfd = NULL; + + assert(as->ev_reptimeout != NULL); + event_release(as->ev_reptimeout); + as->ev_reptimeout = NULL; + + as->state = s_processrep; + aclose(as->repfd); + return (A_CONTINUE); +} + +/* + * After we have read in all of the rep data, we process it and send + * it out as a REP packet. + */ +static action_t +s_processrep( + struct active_service * as, + action_t action, + pkt_t * pkt) +{ + char *tok, *repbuf; + + (void)action; /* Quiet unused parameter warning */ + (void)pkt; /* Quiet unused parameter warning */ + + /* + * Copy the rep lines into the outgoing packet. + * + * If this line is a CONNECT, translate it + * Format is "CONNECT etc... + * Example: + * + * CONNECT DATA 4 MESG 5 INDEX 6 + * + * The tags are arbitrary. The handles are in the DATA_FD pool. + * We need to map these to security streams and pass them back + * to the amanda server. If the handle is -1, then we don't map. + */ + repbuf = stralloc(as->repbuf); + amfree(as->rep_pkt.body); + pkt_init(&as->rep_pkt, P_REP, ""); + tok = strtok(repbuf, " "); + if (tok == NULL) + goto error; + if (strcmp(tok, "CONNECT") == 0) { + char *line, *nextbuf; + + /* Save the entire line */ + line = strtok(NULL, "\n"); + /* Save the buf following the line */ + nextbuf = strtok(NULL, ""); + + if (line == NULL || nextbuf == NULL) + goto error; + + pkt_cat(&as->rep_pkt, "CONNECT"); + + /* loop over the id/handle pairs */ + for (;;) { + /* id */ + tok = strtok(line, " "); + line = NULL; /* keep working from line */ + if (tok == NULL) + break; + pkt_cat(&as->rep_pkt, " %s", tok); + + /* handle */ + tok = strtok(NULL, " \n"); + if (tok == NULL) + goto error; + /* convert the handle into something the server can process */ + pkt_cat(&as->rep_pkt, " %d", allocstream(as, atoi(tok))); + } + pkt_cat(&as->rep_pkt, "\n%s", nextbuf); + } else { +error: + pkt_cat(&as->rep_pkt, "%s", as->repbuf); + } + + /* + * We've setup our REP packet in as->rep_pkt. Now move to the transmission + * state. + */ + as->state = s_sendrep; + as->repretry = MAX_REP_RETRIES; + amfree(repbuf); + return (A_CONTINUE); +} + +/* + * This is the state where we send the REP we just collected from our child. + */ +static action_t +s_sendrep( + struct active_service * as, + action_t action, + pkt_t * pkt) +{ + (void)action; /* Quiet unused parameter warning */ + (void)pkt; /* Quiet unused parameter warning */ + + /* + * Transmit it and move to the ack state. + */ + do_sendpkt(as->security_handle, &as->rep_pkt); + security_recvpkt(as->security_handle, protocol_recv, as, ACK_TIMEOUT); + as->state = s_ackwait; + return (A_PENDING); +} + +/* + * This is the state in which we wait for the server to ACK the REP + * we just sent it. + */ +static action_t +s_ackwait( + struct active_service * as, + action_t action, + pkt_t * pkt) +{ + struct datafd_handle *dh; + int npipes; + + /* + * If we got a timeout, try again, but eventually give up. + */ + if (action == A_TIMEOUT) { + if (--as->repretry > 0) { + as->state = s_sendrep; + return (A_CONTINUE); + } + dbprintf(("%s: timeout waiting for ACK for our REP\n", + debug_prefix_time(NULL))); + return (A_FINISH); + } +#ifdef AMANDAD_DEBUG + dbprintf(("%s: received ACK, now opening streams\n", + debug_prefix_time(NULL))); +#endif + + assert(action == A_RECVPKT); + + if (pkt->type == P_REQ) { + dbprintf(("%s: received dup P_REQ packet, resending REP\n", + debug_prefix_time(NULL))); + as->state = s_sendrep; + return (A_CONTINUE); + } + + if (pkt->type != P_ACK) + return (A_SENDNAK); + + /* + * Got the ack, now open the pipes + */ + for (dh = &as->data[0]; dh < &as->data[DATA_FD_COUNT]; dh++) { + if (dh->netfd == NULL) + continue; + if (security_stream_accept(dh->netfd) < 0) { + dbprintf(("%s: stream %d accept failed: %s\n", + debug_prefix_time(NULL), + dh - &as->data[0], security_geterror(as->security_handle))); + security_stream_close(dh->netfd); + dh->netfd = NULL; + } + /* setup an event for reads from it */ + dh->ev_read = event_register((event_id_t)dh->fd_read, EV_READFD, + process_readnetfd, dh); + + security_stream_read(dh->netfd, process_writenetfd, dh); + + } + + /* + * Pipes are open, so auth them. Count them at the same time. + */ + for (npipes = 0, dh = &as->data[0]; dh < &as->data[DATA_FD_COUNT]; dh++) { + if (dh->netfd == NULL) + continue; + if (security_stream_auth(dh->netfd) < 0) { + security_stream_close(dh->netfd); + dh->netfd = NULL; + event_release(dh->ev_read); + event_release(dh->ev_write); + dh->ev_read = NULL; + dh->ev_write = NULL; + } else { + npipes++; + } + } + + /* + * If no pipes are open, then we're done. Otherwise, just start running. + * The event handlers on all of the pipes will take it from here. + */ +#ifdef AMANDAD_DEBUG + dbprintf(("%s: at end of s_ackwait, npipes is %d\n", + debug_prefix_time(NULL), npipes)); +#endif + if (npipes == 0) + return (A_FINISH); + else { + security_close(as->security_handle); + as->security_handle = NULL; + return (A_PENDING); + } +} + +/* + * Called when a repfd has received data + */ +static void +repfd_recv( + void * cookie) +{ + struct active_service *as = cookie; + + assert(as != NULL); + assert(as->ev_repfd != NULL); + + state_machine(as, A_RECVREP, NULL); +} + +/* + * Called when a repfd has timed out + */ +static void +timeout_repfd( + void * cookie) +{ + struct active_service *as = cookie; + + assert(as != NULL); + assert(as->ev_reptimeout != NULL); + + state_machine(as, A_TIMEOUT, NULL); +} + +/* + * Called when a handle has received data + */ +static void +protocol_recv( + void * cookie, + pkt_t * pkt, + security_status_t status) +{ + struct active_service *as = cookie; + + assert(as != NULL); + + switch (status) { + case S_OK: + dbprintf(("%s: received %s pkt:\n<<<<<\n%s>>>>>\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); + state_machine(as, A_RECVPKT, pkt); + break; + case S_TIMEOUT: + dbprintf(("%s: timeout\n", debug_prefix_time(NULL))); + state_machine(as, A_TIMEOUT, NULL); + break; + case S_ERROR: + dbprintf(("%s: receive error: %s\n", + debug_prefix_time(NULL), security_geterror(as->security_handle))); + break; + } +} + +/* + * This is a generic relay function that just reads data from one of + * the process's pipes and passes it up the equivalent security_stream_t + */ +static void +process_readnetfd( + void * cookie) +{ + pkt_t nak; + struct datafd_handle *dh = cookie; + struct active_service *as = dh->as; + ssize_t n; + + nak.body = NULL; + + do { + n = read(dh->fd_read, as->databuf, SIZEOF(as->databuf)); + } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); + + /* + * Process has died. + */ + if (n < 0) { + pkt_init(&nak, P_NAK, "A ERROR data descriptor %d broken: %s\n", + dh->fd_read, strerror(errno)); + goto sendnak; + } + /* + * Process has closed the pipe. Just remove this event handler. + * If all pipes are closed, shut down this service. + */ + if (n == 0) { + event_release(dh->ev_read); + dh->ev_read = NULL; + if(dh->ev_write == NULL) { + security_stream_close(dh->netfd); + dh->netfd = NULL; + } + for (dh = &as->data[0]; dh < &as->data[DATA_FD_COUNT]; dh++) { + if (dh->netfd != NULL) + return; + } + service_delete(as); + return; + } + if (security_stream_write(dh->netfd, as->databuf, (size_t)n) < 0) { + /* stream has croaked */ + pkt_init(&nak, P_NAK, "ERROR write error on stream %d: %s\n", + security_stream_id(dh->netfd), + security_stream_geterror(dh->netfd)); + goto sendnak; + } + return; + +sendnak: + do_sendpkt(as->security_handle, &nak); + service_delete(as); + amfree(nak.body); +} + +/* + * This is a generic relay function that just read data from one of + * the security_stream_t and passes it up the equivalent process's pipes + */ +static void +process_writenetfd( + void * cookie, + void * buf, + ssize_t size) +{ + struct datafd_handle *dh; + + assert(cookie != NULL); + dh = cookie; + + if (dh->fd_write <= 0) { + dbprintf(("%s: process_writenetfd: dh->fd_write <= 0\n", + debug_prefix_time(NULL))); + } else if (size > 0) { + fullwrite(dh->fd_write, buf, (size_t)size); + security_stream_read(dh->netfd, process_writenetfd, dh); + } + else { + aclose(dh->fd_write); + } +} + + +/* + * Convert a local stream handle (DATA_FD...) into something that + * can be sent to the amanda server. + * + * Returns a number that should be sent to the server in the REP packet. + */ +static int +allocstream( + struct active_service * as, + int handle) +{ + struct datafd_handle *dh; + + /* if the handle is -1, then we don't bother */ + if (handle < 0) + return (-1); + + /* make sure the handle's kosher */ + if (handle < DATA_FD_OFFSET || handle >= DATA_FD_OFFSET + DATA_FD_COUNT) + return (-1); + + /* get a pointer into our handle array */ + dh = &as->data[handle - DATA_FD_OFFSET]; + + /* make sure we're not already using the net handle */ + if (dh->netfd != NULL) + return (-1); + + /* allocate a stream from the security layer and return */ + dh->netfd = security_stream_server(as->security_handle); + if (dh->netfd == NULL) { + dbprintf(("%s: couldn't open stream to server: %s\n", + debug_prefix_time(NULL), security_geterror(as->security_handle))); + return (-1); + } + + /* + * convert the stream into a numeric id that can be sent to the + * remote end. + */ + return (security_stream_id(dh->netfd)); +} + +/* + * Create a new service instance + */ +static struct active_service * +service_new( + security_handle_t * security_handle, + const char * cmd, + const char * arguments) +{ + int i; + int data_read[DATA_FD_COUNT + 1][2]; + int data_write[DATA_FD_COUNT + 1][2]; + struct active_service *as; + pid_t pid; + int newfd; + + assert(security_handle != NULL); + assert(cmd != NULL); + assert(arguments != NULL); + + /* a plethora of pipes */ + for (i = 0; i < DATA_FD_COUNT + 1; i++) { + if (pipe(data_read[i]) < 0) { + error("pipe: %s\n", strerror(errno)); + /*NOTREACHED*/ + } + if (pipe(data_write[i]) < 0) { + error("pipe: %s\n", strerror(errno)); + /*NOTREACHED*/ + } + } + + switch(pid = fork()) { + case -1: + error("could not fork service %s: %s\n", cmd, strerror(errno)); + /*NOTREACHED*/ + default: + /* + * The parent. Close the far ends of our pipes and return. + */ + as = alloc(SIZEOF(*as)); + as->cmd = stralloc(cmd); + as->arguments = stralloc(arguments); + as->security_handle = security_handle; + as->state = NULL; + as->pid = pid; + as->send_partial_reply = 0; + if(strcmp(cmd+(strlen(cmd)-8), "sendsize") == 0) { + g_option_t *g_options; + char *option_str, *p; + + option_str = stralloc(as->arguments+8); + p = strchr(option_str,'\n'); + if(p) *p = '\0'; + + g_options = parse_g_options(option_str, 1); + if(am_has_feature(g_options->features, fe_partial_estimate)) { + as->send_partial_reply = 1; + } + free_g_options(g_options); + amfree(option_str); + } + + /* write to the request pipe */ + aclose(data_read[0][0]); + as->reqfd = data_read[0][1]; + + /* + * read from the reply pipe + */ + as->repfd = data_write[0][0]; + aclose(data_write[0][1]); + as->ev_repfd = NULL; + as->repbuf = NULL; + as->repbufsize = 0; + as->bufsize = 0; + as->repretry = 0; + as->rep_pkt.body = NULL; + + /* + * read from the rest of the general-use pipes + * (netfds are opened as the client requests them) + */ + for (i = 0; i < DATA_FD_COUNT; i++) { + aclose(data_read[i + 1][1]); + aclose(data_write[i + 1][0]); + as->data[i].fd_read = data_read[i + 1][0]; + as->data[i].fd_write = data_write[i + 1][1]; + as->data[i].ev_read = NULL; + as->data[i].ev_write = NULL; + as->data[i].netfd = NULL; + as->data[i].as = as; + } + + /* add it to the service queue */ + /* increment the active service count */ + TAILQ_INSERT_TAIL(&serviceq.tailq, as, tq); + serviceq.qlength++; + + return (as); + case 0: + /* + * The child. Put our pipes in their advertised locations + * and start up. + */ +#ifdef FORCE_USERID + seteuid((uid_t)0); + setuid(client_uid); +#endif + + /* + * The data stream is stdin in the new process + */ + if (dup2(data_read[0][0], 0) < 0) { + error("dup %d to %d failed: %s\n", data_read[0][0], 0, + strerror(errno)); + /*NOTREACHED*/ + } + aclose(data_read[0][0]); + aclose(data_read[0][1]); + + /* + * The reply stream is stdout + */ + if (dup2(data_write[0][1], 1) < 0) { + error("dup %d to %d failed: %s\n", data_write[0][1], 1, + strerror(errno)); + } + aclose(data_write[0][0]); + aclose(data_write[0][1]); + + /* + * Make sure they are not open in the range DATA_FD_OFFSET to + * DATA_FD_OFFSET + DATA_FD_COUNT*2 - 1 + */ + for (i = 0; i < DATA_FD_COUNT; i++) { + while(data_read[i + 1][1] >= DATA_FD_OFFSET && + data_read[i + 1][1] <= DATA_FD_OFFSET + DATA_FD_COUNT*2 - 1) { + newfd = dup(data_read[i + 1][1]); + if(newfd == -1) + error("Can't dup out off DATA_FD range"); + data_read[i + 1][1] = newfd; + } + while(data_write[i + 1][0] >= DATA_FD_OFFSET && + data_write[i + 1][0] <= DATA_FD_OFFSET + DATA_FD_COUNT*2 - 1) { + newfd = dup(data_write[i + 1][0]); + if(newfd == -1) + error("Can't dup out off DATA_FD range"); + data_write[i + 1][0] = newfd; + } + } + for (i = 0; i < DATA_FD_COUNT; i++) + close(DATA_FD_OFFSET + i); + + /* + * The rest start at the offset defined in amandad.h, and continue + * through the internal defined. + */ + for (i = 0; i < DATA_FD_COUNT; i++) { + if (dup2(data_read[i + 1][1], i*2 + DATA_FD_OFFSET) < 0) { + error("dup %d to %d failed: %s\n", data_read[i + 1][1], + i + DATA_FD_OFFSET, strerror(errno)); + } + aclose(data_read[i + 1][0]); + aclose(data_read[i + 1][1]); + + if (dup2(data_write[i + 1][0], i*2 + 1 + DATA_FD_OFFSET) < 0) { + error("dup %d to %d failed: %s\n", data_write[i + 1][0], + i + DATA_FD_OFFSET, strerror(errno)); + } + aclose(data_write[i + 1][0]); + aclose(data_write[i + 1][1]); + } + + /* close all unneeded fd */ + safe_fd(DATA_FD_OFFSET, DATA_FD_COUNT*2); + close(2); + + execle(cmd, cmd, "amandad", auth, (char *)NULL, safe_env()); + error("could not exec service %s: %s\n", cmd, strerror(errno)); + /*NOTREACHED*/ + } + return NULL; +} + +/* + * Unallocate a service instance + */ +static void +service_delete( + struct active_service * as) +{ + int i; + struct datafd_handle *dh; + +#ifdef AMANDAD_DEBUG + dbprintf(("%s: closing service: %s\n", + debug_prefix_time(NULL), (as->cmd)?as->cmd:"??UNKONWN??")); +#endif + + assert(as != NULL); + + assert(as->cmd != NULL); + amfree(as->cmd); + + assert(as->arguments != NULL); + amfree(as->arguments); + + if (as->reqfd != -1) + aclose(as->reqfd); + if (as->repfd != -1) + aclose(as->repfd); + + if (as->ev_repfd != NULL) + event_release(as->ev_repfd); + if (as->ev_reptimeout != NULL) + event_release(as->ev_reptimeout); + + for (i = 0; i < DATA_FD_COUNT; i++) { + dh = &as->data[i]; + + aclose(dh->fd_read); + aclose(dh->fd_write); + + if (dh->netfd != NULL) + security_stream_close(dh->netfd); + + if (dh->ev_read != NULL) + event_release(dh->ev_read); + if (dh->ev_write != NULL) + event_release(dh->ev_write); + } + + if (as->security_handle != NULL) + security_close(as->security_handle); + + assert(as->pid > 0); + kill(as->pid, SIGTERM); + waitpid(as->pid, NULL, WNOHANG); + + TAILQ_REMOVE(&serviceq.tailq, as, tq); + assert(serviceq.qlength > 0); + serviceq.qlength--; + + amfree(as->cmd); + amfree(as->arguments); + amfree(as->repbuf); + amfree(as->rep_pkt.body); + amfree(as); + + if(exit_on_qlength == 0 && serviceq.qlength == 0) { + dbclose(); + exit(0); + } +} + +/* + * Like 'fullwrite', but does the work in a child process so pipelines + * do not hang. + */ +static int +writebuf( + struct active_service * as, + const void * bufp, + size_t size) +{ + pid_t pid; + ssize_t writesize; + + switch (pid=fork()) { + case -1: + break; + + default: + waitpid(pid, NULL, WNOHANG); + return 0; /* this is the parent */ + + case 0: /* this is the child */ + close(as->repfd); + writesize = fullwrite(as->reqfd, bufp, size); + exit(writesize != (ssize_t)size); + /* NOTREACHED */ + } + return -1; +} + +static ssize_t +do_sendpkt( + security_handle_t * handle, + pkt_t * pkt) +{ + dbprintf(("%s: sending %s pkt:\n<<<<<\n%s>>>>>\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); + return security_sendpkt(handle, pkt); +} + +#ifdef AMANDAD_DEBUG +/* + * Convert a state into a string + */ +static const char * +state2str( + state_t state) +{ + static const struct { + state_t state; + const char str[13]; + } states[] = { +#define X(state) { state, stringize(state) } + X(s_sendack), + X(s_repwait), + X(s_processrep), + X(s_sendrep), + X(s_ackwait), +#undef X + }; + int i; + + for (i = 0; i < (int)(sizeof(states) / sizeof(states[0])); i++) + if (state == states[i].state) + return (states[i].str); + return ("INVALID STATE"); +} + +/* + * Convert an action into a string + */ +static const char * +action2str( + action_t action) +{ + static const struct { + action_t action; + const char str[12]; + } actions[] = { +#define X(action) { action, stringize(action) } + X(A_START), + X(A_RECVPKT), + X(A_RECVREP), + X(A_PENDING), + X(A_FINISH), + X(A_CONTINUE), + X(A_SENDNAK), + X(A_TIMEOUT), +#undef X + }; + int i; + + for (i = 0; i < (int)(sizeof(actions) / sizeof(actions[0])); i++) + if (action == actions[i].action) + return (actions[i].str); + return ("UNKNOWN ACTION"); +} +#endif /* AMANDAD_DEBUG */ diff --git a/amandad-src/amandad.h b/amandad-src/amandad.h new file mode 100644 index 0000000..471f73c --- /dev/null +++ b/amandad-src/amandad.h @@ -0,0 +1,56 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-1998 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ +/* + * $Id: amandad.h,v 1.5 2006/07/19 17:46:07 martinea Exp $ + * + */ + +#ifndef AMANDAD_UTIL_H +#define AMANDAD_UTIL_H + +#include "amanda.h" +#include "amfeatures.h" +#include "sl.h" +#include "util.h" /* for bstrncmp() */ + +#define DATA_FD_COUNT 3 /* number of general-use pipes */ +#define DATA_FD_OFFSET 50 + +typedef struct g_option_s { + char *str; + am_feature_t *features; + char *hostname; + char *auth; + int maxdumps; + char *config; +} g_option_t; + + +void init_g_options(g_option_t *g_options); +g_option_t *parse_g_options(char *str, int verbose); +void free_g_options(g_option_t *); + +#endif diff --git a/amandad-src/amandad_util.c b/amandad-src/amandad_util.c new file mode 100644 index 0000000..aef2852 --- /dev/null +++ b/amandad-src/amandad_util.c @@ -0,0 +1,181 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-1998 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ +/* + * $Id: amandad_util.c,v 1.5 2006/07/19 17:46:07 martinea Exp $ + * + */ + +#include "amandad.h" +#include "util.h" + +#define MAXMAXDUMPS 16 + +void +init_g_options( + g_option_t * g_options) +{ + g_options->str = NULL; + g_options->features = NULL; + g_options->hostname = NULL; + g_options->auth = NULL; + g_options->maxdumps = 0; + g_options->config = NULL; +} + + +g_option_t * +parse_g_options( + char * str, + int verbose) +{ + g_option_t *g_options; + char *p, *tok; + int new_maxdumps; + + g_options = alloc(sizeof(g_option_t)); + init_g_options(g_options); + g_options->str = stralloc(str); + + p = stralloc(str); + tok = strtok(p,";"); + + while (tok != NULL) { + if(strncmp(tok,"features=", 9) == 0) { + if(g_options->features != NULL) { + dbprintf(("%s: multiple features option\n", + debug_prefix(NULL))); + if(verbose) { + printf("ERROR [multiple features option]\n"); + } + } + if((g_options->features = am_string_to_feature(tok+9)) == NULL) { + dbprintf(("%s: bad features value \"%s\n", + debug_prefix(NULL), tok+10)); + if(verbose) { + printf("ERROR [bad features value \"%s\"]\n", tok+10); + } + } + } + else if(strncmp(tok,"hostname=", 9) == 0) { + if(g_options->hostname != NULL) { + dbprintf(("%s: multiple hostname option\n", + debug_prefix(NULL))); + if(verbose) { + printf("ERROR [multiple hostname option]\n"); + } + } + g_options->hostname = stralloc(tok+9); + } + else if(strncmp(tok,"auth=", 5) == 0) { + if(g_options->auth != NULL) { + dbprintf(("%s: multiple auth option\n", + debug_prefix(NULL))); + if(verbose) { + printf("ERROR [multiple auth option]\n"); + } + } + g_options->auth = stralloc(tok+5); + } + else if(strncmp(tok,"maxdumps=", 9) == 0) { + if(g_options->maxdumps != 0) { + dbprintf(("%s: multiple maxdumps option\n", + debug_prefix(NULL))); + if(verbose) { + printf("ERROR [multiple maxdumps option]\n"); + } + } + if(sscanf(tok+9, "%d;", &new_maxdumps) == 1) { + if (new_maxdumps > MAXMAXDUMPS) { + g_options->maxdumps = MAXMAXDUMPS; + } + else if (new_maxdumps > 0) { + g_options->maxdumps = new_maxdumps; + } + else { + dbprintf(("%s: bad maxdumps value \"%s\"\n", + debug_prefix(NULL), tok+9)); + if(verbose) { + printf("ERROR [bad maxdumps value \"%s\"]\n", + tok+9); + } + } + } + else { + dbprintf(("%s: bad maxdumps value \"%s\"\n", + debug_prefix(NULL), tok+9)); + if(verbose) { + printf("ERROR [bad maxdumps value \"%s\"]\n", + tok+9); + } + } + } + else if(strncmp(tok,"config=", 7) == 0) { + if(g_options->config != NULL) { + dbprintf(("%s: multiple config option\n", + debug_prefix(NULL))); + if(verbose) { + printf("ERROR [multiple config option]\n"); + } + } + g_options->config = stralloc(tok+7); + if (strchr(g_options->config, '/')) { + amfree(g_options->config); + dbprintf(("%s: invalid character in config option\n", + debug_prefix(NULL))); + if(verbose) { + printf("ERROR [invalid character in config option]\n"); + } + } + } + else { + dbprintf(("%s: unknown option \"%s\"\n", + debug_prefix(NULL), tok)); + if(verbose) { + printf("ERROR [unknown option \"%s\"]\n", tok); + } + } + tok = strtok(NULL, ";"); + } + if(g_options->features == NULL) { + g_options->features = am_set_default_feature_set(); + } + if(g_options->maxdumps == 0) /* default */ + g_options->maxdumps = 1; + amfree(p); + return g_options; +} + +void +free_g_options( + g_option_t * g_options) +{ + amfree(g_options->str); + am_release_feature_set(g_options->features); + amfree(g_options->hostname); + amfree(g_options->auth); + amfree(g_options->config); + amfree(g_options); +} diff --git a/amplot/Makefile.in b/amplot/Makefile.in index 93a4b10..49eb2be 100644 --- a/amplot/Makefile.in +++ b/amplot/Makefile.in @@ -72,11 +72,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -84,6 +87,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ diff --git a/amplot/amplot.sh.in b/amplot/amplot.sh.in index 8ab4d20..05a6ce8 100644 --- a/amplot/amplot.sh.in +++ b/amplot/amplot.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # Amanda, The Advanced Maryland Automatic Network Disk Archiver # Copyright (c) 1992-1998 University of Maryland at College Park # All Rights Reserved. diff --git a/changer-src/Makefile.am b/changer-src/Makefile.am index 490e987..2471aa2 100644 --- a/changer-src/Makefile.am +++ b/changer-src/Makefile.am @@ -5,6 +5,9 @@ INCLUDES = -I$(top_builddir)/common-src \ -I$(top_srcdir)/server-src \ -I$(top_srcdir)/tape-src +LINT=@AMLINT@ +LINTFLAGS=@AMLINTFLAGS@ + LIB_EXTENSION = la if WANT_CHIO_SCSI @@ -36,15 +39,18 @@ CLEANFILES = $(libexec_SCRIPTS) LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \ ../server-src/libamserver.$(LIB_EXTENSION) \ ../tape-src/libamtape.$(LIB_EXTENSION) \ - ../common-src/libamanda.$(LIB_EXTENSION) + ../common-src/libamanda.$(LIB_EXTENSION) \ + $(READLINE_LIBS) SUFFIXES = .pl .sh -chg_scsi_SOURCES = chg-scsi.c libscsi.h scsi-defs.h \ - scsi-aix.c scsi-changer-driver.c scsi-hpux_new.c scsi-irix.c \ - scsi-linux.c scsi-solaris.c scsi-bsd.c scsi-cam.c sense.c +chg_scsi_CSRC = chg-scsi.c scsi-aix.c scsi-changer-driver.c \ + scsi-hpux_new.c scsi-irix.c scsi-linux.c scsi-solaris.c \ + scsi-bsd.c scsi-cam.c sense.c +chg_scsi_SOURCES = libscsi.h scsi-defs.h $(chg_scsi_CSRC) -chg_scsi_chio_SOURCES = chg-scsi-chio.c scsi-hpux.c scsi-chio.c libscsi.h +chg_scsi_chio_CSRC = chg-scsi-chio.c scsi-hpux.c scsi-chio.c +chg_scsi_chio_SOURCES = libscsi.h $(chg_scsi_chio_CSRC) EXTRA_DIST = scsi-proto.c @@ -74,3 +80,21 @@ install-exec-hook: echo chgrp $(SETUID_GROUP) $$pa; \ chgrp $(SETUID_GROUP) $$pa; \ done + +lint: + @ for p in $(libexec_PROGRAMS) $(EXTRA_PROGRAMS); do \ + f="$$p.c $(libamandad_la_SOURCES)"; \ + (cd ../common-src; make listlibsrc); \ + f="$$f "`cat ../common-src/listlibsrc.output`; \ + (cd ../server-src; make listlibsrc); \ + f="$$f "`cat ../server-src/listlibsrc.output`; \ + (cd ../tape-src; make listlibsrc); \ + f="$$f "`cat ../tape-src/listlibsrc.output`; \ + echo $(LINT) $$f; \ + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config \ + $(INCLUDES) $$f; \ + if [ $$? -ne 0 ]; then \ + exit 1; \ + fi; \ + done; \ + exit 0 diff --git a/changer-src/Makefile.in b/changer-src/Makefile.in index d897921..19906e5 100644 --- a/changer-src/Makefile.in +++ b/changer-src/Makefile.in @@ -66,25 +66,28 @@ CONFIG_CLEAN_FILES = chg-manual.sh chg-multi.sh chg-mtx.sh chg-chs.sh \ am__installdirs = "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(libexecdir)" libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(libexec_PROGRAMS) -am_chg_scsi_OBJECTS = chg-scsi.$(OBJEXT) scsi-aix.$(OBJEXT) \ +am__objects_1 = chg-scsi.$(OBJEXT) scsi-aix.$(OBJEXT) \ scsi-changer-driver.$(OBJEXT) scsi-hpux_new.$(OBJEXT) \ scsi-irix.$(OBJEXT) scsi-linux.$(OBJEXT) \ scsi-solaris.$(OBJEXT) scsi-bsd.$(OBJEXT) scsi-cam.$(OBJEXT) \ sense.$(OBJEXT) +am_chg_scsi_OBJECTS = $(am__objects_1) chg_scsi_OBJECTS = $(am_chg_scsi_OBJECTS) chg_scsi_LDADD = $(LDADD) +am__DEPENDENCIES_1 = chg_scsi_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ ../server-src/libamserver.$(LIB_EXTENSION) \ ../tape-src/libamtape.$(LIB_EXTENSION) \ - ../common-src/libamanda.$(LIB_EXTENSION) -am_chg_scsi_chio_OBJECTS = chg-scsi-chio.$(OBJEXT) scsi-hpux.$(OBJEXT) \ + ../common-src/libamanda.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) +am__objects_2 = chg-scsi-chio.$(OBJEXT) scsi-hpux.$(OBJEXT) \ scsi-chio.$(OBJEXT) +am_chg_scsi_chio_OBJECTS = $(am__objects_2) chg_scsi_chio_OBJECTS = $(am_chg_scsi_chio_OBJECTS) chg_scsi_chio_LDADD = $(LDADD) chg_scsi_chio_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ ../server-src/libamserver.$(LIB_EXTENSION) \ ../tape-src/libamtape.$(LIB_EXTENSION) \ - ../common-src/libamanda.$(LIB_EXTENSION) + ../common-src/libamanda.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) libexecSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(libexec_SCRIPTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/config @@ -110,11 +113,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -122,6 +128,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -307,6 +315,8 @@ INCLUDES = -I$(top_builddir)/common-src \ -I$(top_srcdir)/server-src \ -I$(top_srcdir)/tape-src +LINT = @AMLINT@ +LINTFLAGS = @AMLINTFLAGS@ LIB_EXTENSION = la @WANT_CHIO_SCSI_TRUE@CHIO_SCSI = chg-scsi-chio @WANT_CHG_SCSI_TRUE@CHG_SCSI = chg-scsi @@ -327,14 +337,17 @@ CLEANFILES = $(libexec_SCRIPTS) LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \ ../server-src/libamserver.$(LIB_EXTENSION) \ ../tape-src/libamtape.$(LIB_EXTENSION) \ - ../common-src/libamanda.$(LIB_EXTENSION) + ../common-src/libamanda.$(LIB_EXTENSION) \ + $(READLINE_LIBS) SUFFIXES = .pl .sh -chg_scsi_SOURCES = chg-scsi.c libscsi.h scsi-defs.h \ - scsi-aix.c scsi-changer-driver.c scsi-hpux_new.c scsi-irix.c \ - scsi-linux.c scsi-solaris.c scsi-bsd.c scsi-cam.c sense.c +chg_scsi_CSRC = chg-scsi.c scsi-aix.c scsi-changer-driver.c \ + scsi-hpux_new.c scsi-irix.c scsi-linux.c scsi-solaris.c \ + scsi-bsd.c scsi-cam.c sense.c -chg_scsi_chio_SOURCES = chg-scsi-chio.c scsi-hpux.c scsi-chio.c libscsi.h +chg_scsi_SOURCES = libscsi.h scsi-defs.h $(chg_scsi_CSRC) +chg_scsi_chio_CSRC = chg-scsi-chio.c scsi-hpux.c scsi-chio.c +chg_scsi_chio_SOURCES = libscsi.h $(chg_scsi_chio_CSRC) EXTRA_DIST = scsi-proto.c all: all-am @@ -702,6 +715,24 @@ install-exec-hook: echo chgrp $(SETUID_GROUP) $$pa; \ chgrp $(SETUID_GROUP) $$pa; \ done + +lint: + @ for p in $(libexec_PROGRAMS) $(EXTRA_PROGRAMS); do \ + f="$$p.c $(libamandad_la_SOURCES)"; \ + (cd ../common-src; make listlibsrc); \ + f="$$f "`cat ../common-src/listlibsrc.output`; \ + (cd ../server-src; make listlibsrc); \ + f="$$f "`cat ../server-src/listlibsrc.output`; \ + (cd ../tape-src; make listlibsrc); \ + f="$$f "`cat ../tape-src/listlibsrc.output`; \ + echo $(LINT) $$f; \ + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config \ + $(INCLUDES) $$f; \ + if [ $$? -ne 0 ]; then \ + exit 1; \ + fi; \ + done; \ + exit 0 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/changer-src/chg-chio.pl.in b/changer-src/chg-chio.pl.in index fc25b3a..bb9d5a0 100644 --- a/changer-src/chg-chio.pl.in +++ b/changer-src/chg-chio.pl.in @@ -68,11 +68,11 @@ if ( "@USE_VERSION_SUFFIXES@" eq "yes" ) { chomp ($tapeDevice = `$sbindir/amgetconf$SUF tapedev 2>&1`); die "tapedev not found in amanda.conf" - if !$tapeDevice or $tapeDevice =~ m/BUGGY/; + if !$tapeDevice or $tapeDevice =~ m/no such parameter/; chomp ($changerDevice = `$sbindir/amgetconf$SUF changerdev 2>&1`); chomp $changerDevice; die "changerdev not found in amanda.conf" - if !$changerDevice or $changerDevice =~ m/BUGGY/; + if !$changerDevice or $changerDevice =~ m/no such parameter/; # # Initialise a few global variables diff --git a/changer-src/chg-chs.sh.in b/changer-src/chg-chs.sh.in index 063084b..5980436 100644 --- a/changer-src/chg-chs.sh.in +++ b/changer-src/chg-chs.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Amanda, The Advanced Maryland Automatic Network Disk Archiver # Copyright (c) 1991-1998 University of Maryland at College Park diff --git a/changer-src/chg-disk.sh.in b/changer-src/chg-disk.sh.in index 72dc98b..543d96d 100644 --- a/changer-src/chg-disk.sh.in +++ b/changer-src/chg-disk.sh.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @SHELL@ # # Amanda, The Advanced Maryland Automatic Network Disk Archiver # Copyright (c) 1991-1999 University of Maryland at College Park @@ -86,25 +86,36 @@ isinteger() { expr "$1" : '[0-9][0-9]*$' > /dev/null 2>&1 } +# Need rwx access to the virtual tape itself. +if ! test -d $SLOTDIR; then + echo "Virtual-tape directory $SLOTDIR does not exist." 1>&2 + exit 2 +fi +if ! test -w $SLOTDIR; then + echo "Virtual-tape directory $SLOTDIR is not writable." 1>&2 + exit 2 +fi + + # need rwx access to directory of changer file CHANGERFILE=`amgetconf$SUF changerfile` CFDir=`dirname ${CHANGERFILE}` [ -d ${CFDir} -a -r ${CFDir} -a -w ${CFDir} -a -x ${CFDir} ] || - { echo "$MYNAME: need 'rwx' access to '$CFDir'" ; exit 2 ; } + { echo "$MYNAME: need 'rwx' access to '$CFDir'" 1>&2 ; exit 2 ; } # check or create changer metadata files ACCESSFILE=$CHANGERFILE-access [ -f $ACCESSFILE -a -r $ACCESSFILE -a -w $ACCESSFILE ] || echo 0 > $ACCESSFILE || - { echo "$MYNAME: could not access or create '$ACCESSFILE'" ; exit 2 ; } + { echo "$MYNAME: could not access or create '$ACCESSFILE'" 1>&2 ; exit 2 ; } CLEANFILE=$CHANGERFILE-clean [ -f $CLEANFILE -a -r $CLEANFILE -a -w $CLEANFILE ] || echo 0 > $CLEANFILE || - { echo "$MYNAME: could not access or create '$CLEANFILE'" ; exit 2 ; } + { echo "$MYNAME: could not access or create '$CLEANFILE'" 1>&2 ; exit 2 ; } SLOTFILE=$CHANGERFILE-slot [ -f $SLOTFILE -a -r $SLOTFILE -a -w $SLOTFILE ] || echo 0 > $SLOTFILE || - { echo "$MYNAME: could not access or create '$SLOTFILE'" ; exit 2 ; } + { echo "$MYNAME: could not access or create '$SLOTFILE'" 1>&2 ; exit 2 ; } # read and check metadata ACCESSCOUNT=`cat $ACCESSFILE` @@ -116,6 +127,7 @@ FIRSTSLOT=1 LASTSLOT=`amgetconf$SUF tapecycle` CURSLOT=0 CLEANSLOT=$LASTSLOT +NSLOT=`expr $LASTSLOT - $FIRSTSLOT + 1` load() { WHICHSLOT=$1; @@ -165,13 +177,13 @@ loadslot() { if [ $WHICHSLOT -ge $FIRSTSLOT -a $WHICHSLOT -le $LASTSLOT ]; then NEWSLOT=$WHICHSLOT else - echo "0 illegal request" + echo "$WHICHSLOT illegal slot" exit 1 fi elif [ $WHICHSLOT = "clean" ]; then NEWSLOT=$CLEANSLOT else - echo "0 illegal request" + echo "$WHICHSLOT illegal request" exit 1 fi if [ $NEWSLOT = $CURSLOT ]; then @@ -204,7 +216,7 @@ loadslot() { info() { readstatus - echo "$CURSLOT $LASTSLOT $FIRSTSLOT" + echo "$CURSLOT $NSLOT 1" exit 0 } diff --git a/changer-src/chg-iomega.pl.in b/changer-src/chg-iomega.pl.in index 6f946e0..7307399 100644 --- a/changer-src/chg-iomega.pl.in +++ b/changer-src/chg-iomega.pl.in @@ -81,18 +81,18 @@ if ( "@USE_VERSION_SUFFIXES@" eq "yes" ) { chomp ($tapeDevice = `$sbindir/amgetconf$SUF tapedev 2>&1`); die "tapedev not found in amanda.conf" - if !$tapeDevice or $tapeDevice =~ m/BUGGY/; + if !$tapeDevice or $tapeDevice =~ m/no such parameter/; chomp ($changerDevice = `$sbindir/amgetconf$SUF changerdev 2>&1`); chomp $changerDevice; die "changerdev not found in amanda.conf" - if !$changerDevice or $changerDevice =~ m/BUGGY/; + if !$changerDevice or $changerDevice =~ m/no such parameter/; # # Initialise a few global variables # $current_label = ""; -$current_slot = 0; +#$current_slot = 0; $max_slot = 1; @dow = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); diff --git a/changer-src/chg-juke.sh.in b/changer-src/chg-juke.sh.in index abb0a1a..b894623 100755 --- a/changer-src/chg-juke.sh.in +++ b/changer-src/chg-juke.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # chg-juke # diff --git a/changer-src/chg-manual.sh.in b/changer-src/chg-manual.sh.in index 0c966d4..6dcfaa9 100644 --- a/changer-src/chg-manual.sh.in +++ b/changer-src/chg-manual.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Exit Status: # 0 Alles Ok diff --git a/changer-src/chg-mcutil.sh.in b/changer-src/chg-mcutil.sh.in index 934e2f7..d31201f 100644 --- a/changer-src/chg-mcutil.sh.in +++ b/changer-src/chg-mcutil.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Author: Robert Dege # diff --git a/changer-src/chg-mtx.sh.in b/changer-src/chg-mtx.sh.in index ba9f724..2966161 100644 --- a/changer-src/chg-mtx.sh.in +++ b/changer-src/chg-mtx.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Exit Status: # 0 Alles Ok diff --git a/changer-src/chg-multi.sh.in b/changer-src/chg-multi.sh.in index 0103c81..9ac098e 100644 --- a/changer-src/chg-multi.sh.in +++ b/changer-src/chg-multi.sh.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @SHELL@ # # Amanda, The Advanced Maryland Automatic Network Disk Archiver # Copyright (c) 1991-1999 University of Maryland at College Park diff --git a/changer-src/chg-null.sh.in b/changer-src/chg-null.sh.in index 20ee694..60683c7 100644 --- a/changer-src/chg-null.sh.in +++ b/changer-src/chg-null.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Exit Status: # 0 Alles Ok diff --git a/changer-src/chg-rait.sh.in b/changer-src/chg-rait.sh.in index ceeffe7..878996f 100644 --- a/changer-src/chg-rait.sh.in +++ b/changer-src/chg-rait.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # chg-rait # diff --git a/changer-src/chg-scsi-chio.c b/changer-src/chg-scsi-chio.c index b86074d..d6bf467 100644 --- a/changer-src/chg-scsi-chio.c +++ b/changer-src/chg-scsi-chio.c @@ -1,7 +1,7 @@ /* - * $Id: chg-scsi-chio.c,v 1.8 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: chg-scsi-chio.c,v 1.12 2006/07/25 18:18:46 martinea Exp $ * - * chg-scsi.c -- generic SCSI changer driver + * chg-scsi-chio.c -- generic SCSI changer driver * * This program provides a driver to control generic * SCSI changers, no matter what platform. The host/OS @@ -58,32 +58,11 @@ #include "amanda.h" #include "conffile.h" #include "libscsi.h" +#include "scsi-defs.h" char *tapestatfile = NULL; /*----------------------------------------------------------------------------*/ -/* Some stuff for our own configurationfile */ -typedef struct { /* The information we can get for any drive (configuration) */ - int drivenum; /* Which drive to use in the library */ - int start; /* Which is the first slot we may use */ - int end; /* The last slot we are allowed to use */ - int cleanslot; /* Where the cleaningcartridge stays */ - char *scsitapedev; /* Where can we send raw SCSI commands to the tape */ - char *device; /* Which device is associated to the drivenum */ - char *slotfile; /* Where we should have our memory */ - char *cleanfile; /* Where we count how many cleanings we did */ - char *timefile; /* Where we count the time the tape was used*/ - char *tapestatfile;/* Where can we place some drive stats */ -}config_t; - -typedef struct { - int number_of_configs; /* How many different configurations are used */ - int eject; /* Do the drives need an eject-command */ - int sleep; /* How many seconds to wait for the drive to get ready */ - int cleanmax; /* How many runs could be done with one cleaning tape */ - char *device; /* Which device is our changer */ - config_t *conf; -}changer_t; typedef enum{ NUMDRIVE,EJECT,SLEEP,CLEANMAX,DRIVE,START,END,CLEAN,DEVICE,STATFILE,CLEANFILE,DRIVENUM, @@ -92,124 +71,170 @@ typedef enum{ typedef struct { char *word; - int token; + token_t token; } tokentable_t; tokentable_t t_table[]={ - { "number_configs",NUMDRIVE}, - { "eject",EJECT}, - { "sleep",SLEEP}, - { "cleanmax",CLEANMAX}, - { "config",DRIVE}, - { "startuse",START}, - { "enduse",END}, - { "cleancart",CLEAN}, - { "dev",DEVICE}, - { "statfile",STATFILE}, - { "cleanfile",CLEANFILE}, - { "drivenum",DRIVENUM}, - { "changerdev",CHANGERDEV}, - { "usagecount",USAGECOUNT}, - { "scsitapedev", SCSITAPEDEV}, - { "tapestatus", TAPESTATFILE}, - { NULL,-1 } + { "number_configs", NUMDRIVE}, + { "eject", EJECT}, + { "sleep", SLEEP}, + { "cleanmax", CLEANMAX}, + { "config", DRIVE}, + { "startuse", START}, + { "enduse", END}, + { "cleancart", CLEAN}, + { "dev", DEVICE}, + { "statfile", STATFILE}, + { "cleanfile", CLEANFILE}, + { "drivenum", DRIVENUM}, + { "changerdev", CHANGERDEV}, + { "usagecount", USAGECOUNT}, + { "scsitapedev", SCSITAPEDEV}, + { "tapestatus", TAPESTATFILE}, + { NULL, -1 } }; -void init_changer_struct(changer_t *chg,int number_of_config) - /* Initialize datasructures with default values */ +changer_t *changer; + +void init_changer_struct(changer_t *chg, size_t number_of_config); +void dump_changer_struct(changer_t *chg); +void free_changer_struct(changer_t **changer); +void parse_line(char *linebuffer,int *token,char **value); +int read_config(char *configfile, changer_t *chg); +int get_current_slot(char *count_file); +void put_current_slot(char *count_file,int slot); +void usage(char *argv[]); +void parse_args(int argc, char *argv[],command *rval); +int get_relative_target(int fd,int nslots,char *parameter,int loaded, + char *changer_file,int slot_offset,int maxslot); +int is_positive_number(char *tmp); +int ask_clean(char *tapedev); +void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, + int cleancart, int maxclean,char *usagetime); +int main(int argc, char *argv[]); + + +/* + * Initialize data structures with default values +*/ +void +init_changer_struct( + changer_t * chg, + size_t number_of_config) { int i; - + + memset(chg, 0, SIZEOF(*chg)); chg->number_of_configs = number_of_config; chg->eject = 1; chg->sleep = 0; chg->cleanmax = 0; - chg->device = NULL; - chg->conf = malloc(sizeof(config_t)*number_of_config); - if (chg->conf != NULL){ - for (i=0; i < number_of_config; i++){ - chg->conf[i].drivenum = 0; - chg->conf[i].start = -1; - chg->conf[i].end = -1; - chg->conf[i].cleanslot = -1; - chg->conf[i].device = NULL; - chg->conf[i].slotfile = NULL; - chg->conf[i].cleanfile = NULL; - chg->conf[i].timefile = NULL; - chg->conf[i].scsitapedev = NULL; - chg->conf[i].tapestatfile = NULL; - } + chg->device = NULL + chg->conf = alloc(SIZEOF(config_t) * number_of_config); + for (i=0; i < number_of_config; i++){ + chg->conf[i].drivenum = 0; + chg->conf[i].start = -1; + chg->conf[i].end = -1; + chg->conf[i].cleanslot = -1; + chg->conf[i].device = NULL; + chg->conf[i].slotfile = NULL; + chg->conf[i].cleanfile = NULL; + chg->conf[i].timefile = NULL; + chg->conf[i].scsitapedev = NULL; + chg->conf[i].tapestatfile = NULL; + chg->conf[i].changerident = NULL; + chg->conf[i].tapeident = NULL; } } -void dump_changer_struct(changer_t chg) - /* Dump of information for debug */ +/* + * Dump of information for debug +*/ +void +dump_changer_struct( + changer_t * chg) { int i; - dbprintf(("Number of configurations: %d\n",chg.number_of_configs)); - dbprintf(("Tapes need eject: %s\n",(chg.eject>0?"Yes":"No"))); - dbprintf(("Tapes need sleep: %d seconds\n",chg.sleep)); - dbprintf(("Cleancycles : %d\n",chg.cleanmax)); - dbprintf(("Changerdevice : %s\n",chg.device)); - for (i=0; inumber_of_configs)); + dbprintf(("Tapes need eject: %s\n", (chg->eject>0 ? "Yes" : "No"))); + dbprintf(("Tapes need sleep: %d seconds\n", chg->sleep)); + dbprintf(("Cleancycles : %d\n", chg->cleanmax)); + dbprintf(("Changerdevice : %s\n", chg->device)); + for (i = 0; i < chg->number_of_configs; i++){ + dbprintf(("Tapeconfig Nr: %d\n", i)); + dbprintf((" Drivenumber : %d\n", chg->conf[i].drivenum)); + dbprintf((" Startslot : %d\n", chg->conf[i].start)); + dbprintf((" Endslot : %d\n", chg->conf[i].end)); + dbprintf((" Cleanslot : %d\n", chg->conf[i].cleanslot)); + if (chg->conf[i].device != NULL) + dbprintf((" Devicename : %s\n", chg->conf[i].device)); else dbprintf((" Devicename : none\n")); - if (chg.conf[i].scsitapedev != NULL) - dbprintf((" SCSITapedev : %s\n",chg.conf[i].scsitapedev)); + if (chg->conf[i].scsitapedev != NULL) + dbprintf((" SCSITapedev : %s\n", chg->conf[i].scsitapedev)); else dbprintf((" SCSITapedev : none\n")); - if (chg.conf[i].tapestatfile != NULL) - dbprintf((" statfile : %s\n", chg.conf[i].tapestatfile)); + if (chg->conf[i].tapestatfile != NULL) + dbprintf((" statfile : %s\n", chg->conf[i].tapestatfile)); else dbprintf((" statfile : none\n")); - if (chg.conf[i].slotfile != NULL) - dbprintf((" Slotfile : %s\n",chg.conf[i].slotfile)); + if (chg->conf[i].slotfile != NULL) + dbprintf((" Slotfile : %s\n", chg->conf[i].slotfile)); else dbprintf((" Slotfile : none\n")); - if (chg.conf[i].cleanfile != NULL) - dbprintf((" Cleanfile : %s\n",chg.conf[i].cleanfile)); + if (chg->conf[i].cleanfile != NULL) + dbprintf((" Cleanfile : %s\n", chg->conf[i].cleanfile)); else dbprintf((" Cleanfile : none\n")); - if (chg.conf[i].timefile != NULL) - dbprintf((" Usagecount : %s\n",chg.conf[i].timefile)); + if (chg->conf[i].timefile != NULL) + dbprintf((" Usagecount : %s\n", chg->conf[i].timefile)); else dbprintf((" Usagecount : none\n")); } } -void free_changer_struct(changer_t *chg) - /* Free all allocated memory */ +/* + * Free all allocated memory + */ +void +free_changer_struct( +changer_t **changer) { + changer_t *chg; int i; + assert(changer != NULL); + assert(*changer != NULL); + + chg = *changer; if (chg->device != NULL) - free(chg->device); + amfree(chg->device); for (i=0; inumber_of_configs; i++){ if (chg->conf[i].device != NULL) - free(chg->conf[i].device); + amfree(chg->conf[i].device); if (chg->conf[i].slotfile != NULL) - free(chg->conf[i].slotfile); + amfree(chg->conf[i].slotfile); if (chg->conf[i].cleanfile != NULL) - free(chg->conf[i].cleanfile); + amfree(chg->conf[i].cleanfile); if (chg->conf[i].timefile != NULL) - free(chg->conf[i].timefile); + amfree(chg->conf[i].timefile); } if (chg->conf != NULL) - free(chg->conf); + amfree(chg->conf); chg->conf = NULL; chg->device = NULL; + amfree(*changer); } -void parse_line(char *linebuffer,int *token,char **value) - /* This function parses a line, and returns the token an value */ +/* + * This function parses a line, and returns a token and value + */ +void +parse_line( + char * linebuffer, + int * token, + char ** value) { char *tok; int i; @@ -235,14 +260,19 @@ void parse_line(char *linebuffer,int *token,char **value) return; } -int read_config(char *configfile, changer_t *chg) - /* This function reads the specified configfile and fills the structure */ +/* + * This function reads the specified configfile and fills the structure +*/ +int +read_config( + char * configfile, + changer_t * chg) { - int numconf; + size_t numconf; FILE *file; int init_flag = 0; int drivenum=0; - char *linebuffer = NULL; + char *linebuffer; int token; char *value; @@ -253,16 +283,19 @@ int read_config(char *configfile, changer_t *chg) return (-1); } - amfree(linebuffer); - while (NULL!=(linebuffer=agets(file))){ + while (NULL != (linebuffer = agets(file))) { + if (linebuffer[0] == '\0') { + amfree(linebuffer); + continue; + } parse_line(linebuffer,&token,&value); if (token != -1){ if (0==init_flag) { if (token != NUMDRIVE){ - init_changer_struct(chg,numconf); + init_changer_struct(chg, numconf); } else { numconf = atoi(value); - init_changer_struct(chg,numconf); + init_changer_struct(chg, numconf); } init_flag=1; } @@ -387,7 +420,13 @@ int get_current_slot(char *count_file) get_pname(), count_file); return 0; } - fscanf(inf,"%d",&retval); + + if (fscanf(inf, "%d", &retval) != 1) { + fprintf(stderr, "%s: unable to read current slot file (%s)\n", + get_pname(), count_file); + retval = 0; + } + fclose(inf); return retval; } @@ -481,30 +520,48 @@ void usage(char *argv[]) void parse_args(int argc, char *argv[],command *rval) { int i=0; - if ((argc<2)||(argc>3)) + if ((argc < 2) || (argc > 3)) { usage(argv); + /*NOTREACHED*/ + } + while ((icommand_code = argdefs[i].command_code; if (argdefs[i].takesparam) { - if (argc<3) + if (argc < 3) { usage(argv); + /*NOTREACHED*/ + } rval->parameter=argv[2]; } else { - if (argc>2) + if (argc > 2) { usage(argv); + /*NOTREACHED*/ + } rval->parameter=0; } } /* used to find actual slot number from keywords next, prev, first, etc */ -int get_relative_target(int fd,int nslots,char *parameter,int loaded, - char *changer_file,int slot_offset,int maxslot) +int +get_relative_target( + int fd, + int nslots, + char * parameter, + int loaded, + char * changer_file, + int slot_offset, + int maxslot) { int current_slot,i; + + (void)loaded; /* Quiet unused warning */ if (changer_file != NULL) { current_slot=get_current_slot(changer_file); @@ -519,52 +576,67 @@ int get_relative_target(int fd,int nslots,char *parameter,int loaded, } i=0; - while((i no slot `%s'\n",parameter); close(fd); exit(2); - }; + /*NOTREACHED*/ + } + return current_slot; } -int ask_clean(char *tapedev) - /* This function should ask the drive if it wants to be cleaned */ +/* + * This function should ask the drive if it wants to be cleaned + */ +int +ask_clean( + char * tapedev) { return get_clean_state(tapedev); } -void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, - int cleancart, int maxclean,char *usagetime) - /* This function should move the cleaning cartridge into the drive */ +/* + * This function should move the cleaning cartridge into the drive + */ +void +clean_tape( + int fd, + char * tapedev, + char * cnt_file, + int drivenum, + int cleancart, + int maxclean, + char * usagetime) { - int counter=-1; + int counter; + if (cleancart == -1 ){ return; } + /* Now we should increment the counter */ if (cnt_file != NULL){ counter = get_current_slot(cnt_file); @@ -573,25 +645,38 @@ void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, /* Now we should inform the administrator */ char *mail_cmd; FILE *mailf; - mail_cmd = vstralloc(MAILER, + int mail_pipe_opened = 1; + if(getconf_seen(CNF_MAILTO) && strlen(getconf_str(CNF_MAILTO)) > 0 && + validate_mailto(getconf_str(CNF_MAILTO))) { + mail_cmd = vstralloc(MAILER, " -s", " \"", "AMANDA PROBLEM: PLEASE FIX", "\"", " ", getconf_str(CNF_MAILTO), NULL); - if((mailf = popen(mail_cmd, "w")) == NULL){ - error("could not open pipe to \"%s\": %s", - mail_cmd, strerror(errno)); - printf("Mail failed\n"); - return; + if((mailf = popen(mail_cmd, "w")) == NULL){ + printf("Mail failed\n"); + error("could not open pipe to \"%s\": %s", + mail_cmd, strerror(errno)); + /*NOTREACHED*/ + } } + else{ + mail_pipe_opened = 0; + mailf = stderr; + fprintf(mailf, "\nNo mail recipient specified, output redirected to stderr"); + } + fprintf(mailf,"\nThe usage count of your cleaning tape in slot %d", - cleancart); + cleancart); fprintf(mailf,"\nis more than %d. (cleanmax)",maxclean); fprintf(mailf,"\nTapedrive %s needs to be cleaned",tapedev); fprintf(mailf,"\nPlease insert a new cleaning tape and reset"); fprintf(mailf,"\nthe countingfile %s",cnt_file); - if(pclose(mailf) != 0) - error("mail command failed: %s", mail_cmd); + if(mail_pipe_opened == 1 && pclose(mailf) != 0) { + error("mail command failed: %s", mail_cmd); + /*NOTREACHED*/ + } + return; } @@ -605,11 +690,15 @@ void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, } /* ----------------------------------------------------------------------*/ -int main(int argc, char *argv[]) +int +main( + int argc, + char * argv[]) { - int loaded,target,oldtarget; + int loaded; + int target = -1; + int oldtarget; command com; /* a little DOS joke */ - changer_t chg; /* * drive_num really should be something from the config file, but.. @@ -619,7 +708,7 @@ int main(int argc, char *argv[]) */ int drive_num = 0; int need_eject = 0; /* Does the drive need an eject command ? */ - int need_sleep = 0; /* How many seconds to wait for the drive to get ready */ + unsigned need_sleep = 0; /* How many seconds to wait for the drive to get ready */ int clean_slot = -1; int maxclean = 0; char *clean_file=NULL; @@ -629,9 +718,10 @@ int main(int argc, char *argv[]) int slot_offset; int confnum; - int fd, rc, slotcnt, drivecnt; + int fd, slotcnt, drivecnt; int endstatus = 0; - char *changer_dev, *tape_device; + char *changer_dev = NULL; + char *tape_device = NULL; char *changer_file = NULL; char *scsitapedevice = NULL; @@ -640,9 +730,10 @@ int main(int argc, char *argv[]) /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); - dbopen(); + dbopen(DBG_SUBDIR_SERVER); parse_args(argc,argv,&com); + changer = alloc(SIZEOF(changer_t)); if(read_conffile(CONFFILE_NAME)) { fprintf(stderr, "%s: could not find config file \"%s\"", changer_dev, conffile); @@ -654,34 +745,37 @@ int main(int argc, char *argv[]) tape_device = getconf_str(CNF_TAPEDEV); /* Get the configuration parameters */ + if (strlen(tape_device)==1){ - read_config(changer_file,&chg); + read_config(changer_file, changer); confnum=atoi(tape_device); - use_slots = chg.conf[confnum].end-chg.conf[confnum].start+1; - slot_offset = chg.conf[confnum].start; - drive_num = chg.conf[confnum].drivenum; - need_eject = chg.eject; - need_sleep = chg.sleep; - clean_file = stralloc(chg.conf[confnum].cleanfile); - clean_slot = chg.conf[confnum].cleanslot; - maxclean = chg.cleanmax; - if (NULL != chg.conf[confnum].timefile) - time_file = stralloc(chg.conf[confnum].timefile); - if (NULL != chg.conf[confnum].slotfile) - changer_file = stralloc(chg.conf[confnum].slotfile); + use_slots = changer->conf[confnum].end-changer->conf[confnum].start+1; + slot_offset = changer->conf[confnum].start; + drive_num = changer->conf[confnum].drivenum; + need_eject = changer->eject; + need_sleep = changer->sleep; + clean_file = stralloc(changer->conf[confnum].cleanfile); + clean_slot = changer->conf[confnum].cleanslot; + maxclean = changer->cleanmax; + if (NULL != changer->conf[confnum].timefile) + time_file = stralloc(changer->conf[confnum].timefile); + if (NULL != changer->conf[confnum].slotfile) + changer_file = stralloc(changer->conf[confnum].slotfile); else changer_file = NULL; - if (NULL != chg.conf[confnum].device) - tape_device = stralloc(chg.conf[confnum].device); - if (NULL != chg.device) - changer_dev = stralloc(chg.device); - if (NULL != chg.conf[confnum].scsitapedev) - scsitapedevice = stralloc(chg.conf[confnum].scsitapedev); - if (NULL != chg.conf[confnum].tapestatfile) - tapestatfile = stralloc(chg.conf[confnum].tapestatfile); - dump_changer_struct(chg); + if (NULL != changer->conf[confnum].device) + tape_device = stralloc(changer->conf[confnum].device); + if (NULL != changer->device) + changer_dev = stralloc(changer->device); + if (NULL != changer->conf[confnum].scsitapedev) + scsitapedevice = stralloc(changer->conf[confnum].scsitapedev); + if (NULL != changer->conf[confnum].tapestatfile) + tapestatfile = stralloc(changer->conf[confnum].tapestatfile); + dump_changer_struct(changer); /* get info about the changer */ - if (-1 == (fd = OpenDevice(changer_dev, "changer_dev"))) { + fd = OpenDevice(INDEX_CHANGER , changer_dev, + "changer_dev", changer->conf[confnum].changerident); + if (fd == -1) { int localerr = errno; fprintf(stderr, "%s: open: %s: %s\n", get_pname(), changer_dev, strerror(localerr)); @@ -701,15 +795,18 @@ int main(int argc, char *argv[]) scsitapedevice = stralloc(tape_device); } - if ((chg.conf[confnum].end == -1) || (chg.conf[confnum].start == -1)){ + if ((changer->conf[confnum].end == -1) || (changer->conf[confnum].start == -1)){ slotcnt = get_slot_count(fd); use_slots = slotcnt; slot_offset = 0; } - free_changer_struct(&chg); + free_changer_struct(&changer); } else { /* get info about the changer */ - if (-1 == (fd = OpenDevice(changer_dev))) { + confnum = 0; + fd = OpenDevice(INDEX_CHANGER , changer_dev, + "changer_dev", changer->conf[confnum].changerident); + if (fd == -1) { int localerr = errno; fprintf(stderr, "%s: open: %s: %s\n", get_pname(), changer_dev, strerror(localerr)); diff --git a/changer-src/chg-scsi.c b/changer-src/chg-scsi.c index 7bf190f..4282269 100644 --- a/changer-src/chg-scsi.c +++ b/changer-src/chg-scsi.c @@ -1,6 +1,4 @@ -#ifndef lint -static char rcsid[] = "$Id: chg-scsi.c,v 1.44 2006/03/09 20:06:10 johnfranks Exp $"; -#endif +static char rcsid[] = "$Id: chg-scsi.c,v 1.52 2006/07/25 18:18:46 martinea Exp $"; /* * * @@ -12,7 +10,7 @@ static char rcsid[] = "$Id: chg-scsi.c,v 1.44 2006/03/09 20:06:10 johnfranks Exp * The device dependent part is handled by scsi-changer-driver.c * The SCSI OS interface is handled by scsi-ostype.c * - * Original copyrigths: + * Original copyrights: * * This program provides a driver to control generic * SCSI changers, no matter what platform. The host/OS @@ -67,15 +65,7 @@ static char rcsid[] = "$Id: chg-scsi.c,v 1.44 2006/03/09 20:06:10 johnfranks Exp #include "config.h" - - #include "amanda.h" - -#ifdef HAVE_DMALLOC_H -#include -#endif - - #include "conffile.h" #include "libscsi.h" #include "scsi-defs.h" @@ -98,12 +88,10 @@ extern ElementInfo_T *pMTE; /*Medium Transport Element */ extern ElementInfo_T *pSTE; /*Storage Element */ extern ElementInfo_T *pIEE; /*Import Export Element */ extern ElementInfo_T *pDTE; /*Data Transfer Element */ -extern int MTE; /*Counter for the above element types */ -extern int STE; -extern int IEE; -extern int DTE; - -changer_t chg; +extern size_t MTE; /*Counter for the above element types */ +extern size_t STE; +extern size_t IEE; +extern size_t DTE; int do_inventory = 0; /* Set if load/unload functions thinks an inventory should be done */ int clean_slot = -1; @@ -116,167 +104,190 @@ typedef enum{ typedef struct { char *word; - int token; + token_t token; } tokentable_t; -tokentable_t t_table[]={ - { "number_configs",NUMDRIVE}, - { "autoinv", AUTOINV}, - { "eject",EJECT}, - { "sleep",SLEEP}, - { "cleanmax",CLEANMAX}, - { "config",DRIVE}, - { "startuse",START}, - { "enduse",END}, - { "cleancart",CLEAN}, - { "dev",DEVICE}, - { "statfile",STATFILE}, - { "cleanfile",CLEANFILE}, - { "drivenum",DRIVENUM}, - { "changerdev",CHANGERDEV}, - { "usagecount",USAGECOUNT}, - { "scsitapedev", SCSITAPEDEV}, - { "tapestatus", TAPESTATFILE}, - { "labelfile", LABELFILE}, - { "changerident" , CHANGERIDENT}, - { "tapeident", TAPEIDENT}, - { "emubarcode", EMUBARCODE}, - { "havebarcode", HAVEBARCODE}, - { "debuglevel", DEBUGLEVEL}, - { NULL,-1 } +tokentable_t t_table[] = { + { "number_configs", NUMDRIVE}, + { "autoinv", AUTOINV}, + { "eject", EJECT}, + { "sleep", SLEEP}, + { "cleanmax", CLEANMAX}, + { "config", DRIVE}, + { "startuse", START}, + { "enduse", END}, + { "cleancart", CLEAN}, + { "dev", DEVICE}, + { "statfile", STATFILE}, + { "cleanfile", CLEANFILE}, + { "drivenum", DRIVENUM}, + { "changerdev", CHANGERDEV}, + { "usagecount", USAGECOUNT}, + { "scsitapedev", SCSITAPEDEV}, + { "tapestatus", TAPESTATFILE}, + { "labelfile", LABELFILE}, + { "changerident", CHANGERIDENT}, + { "tapeident", TAPEIDENT}, + { "emubarcode", EMUBARCODE}, + { "havebarcode", HAVEBARCODE}, + { "debuglevel", DEBUGLEVEL}, + { NULL, -1 } }; - -void init_changer_struct(changer_t *chg,int number_of_config) - /* Initialize datasructures with default values */ +changer_t *changer; +int ask_clean(char *tapedev); +int get_current_slot(char *count_file); +int get_relative_target(int fd, int nslots, char *parameter, + int param_index, int loaded, char *slot_file, + int slot_offset, int maxslot); +int is_positive_number(char *tmp); +int MapBarCode(char *labelfile, MBC_T *result); +int read_config(char *configfile, changer_t *chg); +void clean_tape(int fd, char *tapedev, char *cnt_file, int drivenum, + int cleancart, int maxclean, char *usagetime); +void dump_changer_struct(changer_t *chg); +void free_changer_struct(changer_t **chg); +void init_changer_struct(changer_t *chg, int number_of_config); +void parse_line(char *linebuffer, int *token,char **value); +void put_current_slot(char *count_file, int slot); +void usage(char *argv[]); + +int main(int argc, char *argv[]); + + +/* Initialize data structures with default values */ +void +init_changer_struct( + changer_t *chg, + int number_of_config) { int i; + memset(chg, 0, SIZEOF(*chg)); chg->number_of_configs = number_of_config; chg->eject = 1; - chg->sleep = 0; - chg->autoinv = 0; - chg->cleanmax = 0; - chg->havebarcode = 0; - chg->emubarcode = 0; - chg->device = NULL; - chg->labelfile = NULL; - chg->debuglevel = NULL; - chg->conf = malloc(sizeof(config_t)*number_of_config); - if (chg->conf != NULL){ - for (i=0; i < number_of_config; i++){ - chg->conf[i].drivenum = 0; - chg->conf[i].start = -1; - chg->conf[i].end = -1; - chg->conf[i].cleanslot = -1; - chg->conf[i].device = NULL; - chg->conf[i].slotfile = NULL; - chg->conf[i].cleanfile = NULL; - chg->conf[i].timefile = NULL; - chg->conf[i].scsitapedev = NULL; - chg->conf[i].tapestatfile = NULL; - chg->conf[i].changerident = NULL; - chg->conf[i].tapeident = NULL; - } - } else { - fprintf(stderr,"init_changer_struct malloc failed\n"); + chg->conf = alloc(SIZEOF(config_t) * (size_t)number_of_config); + for (i=0; i < number_of_config; i++){ + chg->conf[i].drivenum = 0; + chg->conf[i].start = -1; + chg->conf[i].end = -1; + chg->conf[i].cleanslot = -1; + chg->conf[i].device = NULL; + chg->conf[i].slotfile = NULL; + chg->conf[i].cleanfile = NULL; + chg->conf[i].timefile = NULL; + chg->conf[i].scsitapedev = NULL; + chg->conf[i].tapestatfile = NULL; + chg->conf[i].changerident = NULL; + chg->conf[i].tapeident = NULL; } } -void dump_changer_struct(changer_t chg) - /* Dump of information for debug */ +/* Dump of information for debug */ +void +dump_changer_struct( + changer_t *chg) { int i; - dbprintf(("Number of configurations: %d\n",chg.number_of_configs)); - dbprintf(("Tapes need eject: %s\n",(chg.eject>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg.eject)); - dbprintf(("Inv. auto update: %s\n",(chg.autoinv>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg.autoinv)); - dbprintf(("barcode reader : %s\n",(chg.havebarcode>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg.havebarcode)); - dbprintf(("Emulate Barcode : %s\n",(chg.emubarcode>0?"Yes":"No"))); - dbprintf (("\traw: %d\n",chg.emubarcode)); - if (chg.debuglevel != NULL) - dbprintf(("debug level : %s\n", chg.debuglevel)); - dbprintf(("Tapes need sleep: %d seconds\n",chg.sleep)); - dbprintf(("Cleancycles : %d\n",chg.cleanmax)); - dbprintf(("Changerdevice : %s\n",chg.device)); - if (chg.labelfile != NULL) - dbprintf(("Labelfile : %s\n", chg.labelfile)); - for (i=0; inumber_of_configs)); + dbprintf(("Tapes need eject: %s\n",(chg->eject>0?"Yes":"No"))); + dbprintf (("\traw: %d\n",chg->eject)); + dbprintf(("Inv. auto update: %s\n",(chg->autoinv>0?"Yes":"No"))); + dbprintf (("\traw: %d\n",chg->autoinv)); + dbprintf(("barcode reader : %s\n",(chg->havebarcode>0?"Yes":"No"))); + dbprintf (("\traw: %d\n",chg->havebarcode)); + dbprintf(("Emulate Barcode : %s\n",(chg->emubarcode>0?"Yes":"No"))); + dbprintf (("\traw: %d\n",chg->emubarcode)); + if (chg->debuglevel != NULL) + dbprintf(("debug level : %s\n", chg->debuglevel)); + dbprintf(("Tapes need sleep: %d seconds\n",chg->sleep)); + dbprintf(("Cleancycles : %d\n",chg->cleanmax)); + dbprintf(("Changerdevice : %s\n",chg->device)); + if (chg->labelfile != NULL) + dbprintf(("Labelfile : %s\n", chg->labelfile)); + for (i=0; inumber_of_configs; i++){ dbprintf(("Tapeconfig Nr: %d\n",i)); - dbprintf((" Drivenumber : %d\n",chg.conf[i].drivenum)); - dbprintf((" Startslot : %d\n",chg.conf[i].start)); - dbprintf((" Endslot : %d\n",chg.conf[i].end)); - dbprintf((" Cleanslot : %d\n",chg.conf[i].cleanslot)); + dbprintf((" Drivenumber : %d\n",chg->conf[i].drivenum)); + dbprintf((" Startslot : %d\n",chg->conf[i].start)); + dbprintf((" Endslot : %d\n",chg->conf[i].end)); + dbprintf((" Cleanslot : %d\n",chg->conf[i].cleanslot)); - if (chg.conf[i].device != NULL) - dbprintf((" Devicename : %s\n",chg.conf[i].device)); + if (chg->conf[i].device != NULL) + dbprintf((" Devicename : %s\n",chg->conf[i].device)); else dbprintf((" Devicename : none\n")); - if (chg.conf[i].changerident != NULL) - dbprintf((" changerident : %s\n",chg.conf[i].changerident)); + if (chg->conf[i].changerident != NULL) + dbprintf((" changerident : %s\n",chg->conf[i].changerident)); else dbprintf((" changerident : none\n")); - if (chg.conf[i].scsitapedev != NULL) - dbprintf((" SCSITapedev : %s\n",chg.conf[i].scsitapedev)); + if (chg->conf[i].scsitapedev != NULL) + dbprintf((" SCSITapedev : %s\n",chg->conf[i].scsitapedev)); else dbprintf((" SCSITapedev : none\n")); - if (chg.conf[i].tapeident != NULL) - dbprintf((" tapeident : %s\n",chg.conf[i].tapeident)); + if (chg->conf[i].tapeident != NULL) + dbprintf((" tapeident : %s\n",chg->conf[i].tapeident)); else dbprintf((" tapeident : none\n")); - if (chg.conf[i].tapestatfile != NULL) - dbprintf((" statfile : %s\n", chg.conf[i].tapestatfile)); + if (chg->conf[i].tapestatfile != NULL) + dbprintf((" statfile : %s\n", chg->conf[i].tapestatfile)); else dbprintf((" statfile : none\n")); - if (chg.conf[i].slotfile != NULL) - dbprintf((" Slotfile : %s\n",chg.conf[i].slotfile)); + if (chg->conf[i].slotfile != NULL) + dbprintf((" Slotfile : %s\n",chg->conf[i].slotfile)); else dbprintf((" Slotfile : none\n")); - if (chg.conf[i].cleanfile != NULL) - dbprintf((" Cleanfile : %s\n",chg.conf[i].cleanfile)); + if (chg->conf[i].cleanfile != NULL) + dbprintf((" Cleanfile : %s\n",chg->conf[i].cleanfile)); else dbprintf((" Cleanfile : none\n")); - if (chg.conf[i].timefile != NULL) - dbprintf((" Usagecount : %s\n",chg.conf[i].timefile)); + if (chg->conf[i].timefile != NULL) + dbprintf((" Usagecount : %s\n",chg->conf[i].timefile)); else dbprintf((" Usagecount : none\n")); } } -void free_changer_struct(changer_t *chg) - /* Free all allocated memory */ +/* Free all allocated memory */ +void +free_changer_struct( + changer_t **changer) { + changer_t *chg; int i; + chg = *changer; if (chg->device != NULL) - free(chg->device); - for (i=0; inumber_of_configs; i++){ + amfree(chg->device); + for (i = 0; i < chg->number_of_configs; i++){ if (chg->conf[i].device != NULL) - free(chg->conf[i].device); + amfree(chg->conf[i].device); if (chg->conf[i].slotfile != NULL) - free(chg->conf[i].slotfile); + amfree(chg->conf[i].slotfile); if (chg->conf[i].cleanfile != NULL) - free(chg->conf[i].cleanfile); + amfree(chg->conf[i].cleanfile); if (chg->conf[i].timefile != NULL) - free(chg->conf[i].timefile); + amfree(chg->conf[i].timefile); } if (chg->conf != NULL) - free(chg->conf); + amfree(chg->conf); chg->conf = NULL; chg->device = NULL; + amfree(*changer); } -void parse_line(char *linebuffer,int *token,char **value) - /* This function parses a line, and returns a token and value */ +/* This function parses a line, and returns a token and value */ +void +parse_line( + char *linebuffer, + int *token, + char **value) { char *tok; int i; @@ -299,17 +310,19 @@ void parse_line(char *linebuffer,int *token,char **value) } tok=strtok(NULL," \t\n"); } - return; } -int read_config(char *configfile, changer_t *chg) - /* This function reads the specified configfile and fills the structure */ +/* This function reads the specified configfile and fills the structure */ +int +read_config( + char *configfile, + changer_t *chg) { int numconf; FILE *file; int init_flag = 0; int drivenum=0; - char *linebuffer = NULL; + char *linebuffer; int token; char *value; char *p; @@ -317,25 +330,35 @@ int read_config(char *configfile, changer_t *chg) numconf = 1; /* At least one configuration is assumed */ /* If there are more, it should be the first entry in the configurationfile */ - - if (NULL==(file=fopen(configfile,"r"))){ + assert(chg != NULL); + if ((file=fopen(configfile,"r")) == NULL) { return (-1); } - amfree(linebuffer); - while ((NULL!=(linebuffer=agets(file)))) { - parse_line(linebuffer,&token,&value); + while ((NULL != (linebuffer = agets(file)))) { + if (linebuffer[0] == '\0') { + amfree(linebuffer); + continue; + } + parse_line(linebuffer, &token, &value); if (token != -1){ - if (0==init_flag) { + if (value == NULL) + value = "0"; + + if (init_flag == 0) { if (token != NUMDRIVE){ - init_changer_struct(chg,numconf); + init_changer_struct(chg, numconf); } else { numconf = atoi(value); - init_changer_struct(chg,numconf); + if (numconf < 1 || numconf > 100) { + fprintf(stderr,"numconf %d is bad\n", numconf); + numconf = 1; + } + init_changer_struct(chg, numconf); } init_flag=1; } - switch (token){ + switch (token) { case NUMDRIVE: if (atoi(value) != numconf) fprintf(stderr,"Error: number_drives at wrong place, should be "\ "first in file\n"); @@ -356,7 +379,7 @@ int read_config(char *configfile, changer_t *chg) chg->havebarcode = atoi(value); break; case SLEEP: - chg->sleep = atoi(value); + chg->sleep = (unsigned)atoi(value); break; case LABELFILE: chg->labelfile = stralloc(value); @@ -372,6 +395,10 @@ int read_config(char *configfile, changer_t *chg) break; case CHANGERIDENT: chg->conf[drivenum].changerident = stralloc(value); + if (drivenum < 0 || drivenum > 100) { + fprintf(stderr,"drivenum %d is bad\n", drivenum); + drivenum = 0; + } p = chg->conf[drivenum].changerident; while (*p != '\0') { @@ -390,8 +417,12 @@ int read_config(char *configfile, changer_t *chg) break; case DRIVE: drivenum = atoi(value); - if(drivenum >= numconf){ + if (drivenum < 0) { + fprintf(stderr,"Error: drive must be >= 0\n"); + drivenum = 0; + } else if (drivenum >= numconf) { fprintf(stderr,"Error: drive must be less than number_drives\n"); + drivenum = numconf; } break; case DRIVENUM: @@ -477,16 +508,19 @@ int read_config(char *configfile, changer_t *chg) * we use a file to store the current slot. It is not ideal * but it gets the job done */ -int get_current_slot(char *count_file) +int +get_current_slot( + char *count_file) { FILE *inf; - int retval; + int retval = -1; int ret; /* return value for the fscanf function */ if ((inf=fopen(count_file,"r")) == NULL) { fprintf(stderr, "%s: unable to open (%s)\n", get_pname(), count_file); exit(2); } + ret = fscanf(inf,"%d",&retval); fclose(inf); @@ -499,13 +533,22 @@ int get_current_slot(char *count_file) retval = -1; } + if (retval < 0 || retval > 10000) { + retval = -1; + } return retval; } -void put_current_slot(char *count_file,int slot) +void +put_current_slot( + char *count_file, + int slot) { FILE *inf; + if (!count_file) + return; + if ((inf=fopen(count_file,"w")) == NULL) { fprintf(stderr, "%s: unable to open current slot file (%s)\n", get_pname(), count_file); @@ -528,18 +571,21 @@ void put_current_slot(char *count_file,int slot) * The passed struct MBC_T will hold the found entry in the DB */ -int MapBarCode(char *labelfile, MBC_T *result) +int +MapBarCode( + char *labelfile, + MBC_T *result) { FILE *fp; int version; LabelV2_T *plabelv2; - int unusedpos = 0; + long unusedpos= 0; int unusedrec = 0; - int pos = 0; - int record = 0; - int volseen = 0; - int loop = 1; - int rsize = 0; + int record = 0; + int loop = 1; + size_t rsize; + long pos; + int rc; DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : Parameter\n"); DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"labelfile -> %s, vol -> %s, barcode -> %s, action -> %c, slot -> %d, from -> %d\n", @@ -554,6 +600,7 @@ int MapBarCode(char *labelfile, MBC_T *result) { DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"Got empty labelfile (NULL)\n"); ChgExit("MapBarCode", "MapBarCode name of labelfile is not set\n",FATAL); + /*NOTREACHED*/ } if (access(labelfile, F_OK) == -1) { @@ -562,6 +609,7 @@ int MapBarCode(char *labelfile, MBC_T *result) { DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE," failed\n"); ChgExit("MapBarCode", "MapBarCode, creating labelfile failed\n", FATAL); + /*NOTREACHED*/ } fprintf(fp,":%d:", LABEL_DB_VERSION); fclose(fp); @@ -571,29 +619,35 @@ int MapBarCode(char *labelfile, MBC_T *result) { DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"MapBarCode : failed to open %s\n", labelfile); ChgExit("MapBarCode", "MapBarCode, opening labelfile for read/write failed\n", FATAL); + /*NOTREACHED*/ } - fscanf(fp,":%d:", &version); + if (fscanf(fp,":%d:", &version) != 1) { + ChgExit("MapBarCode", "MapBarCode, DB Version unreadable.\n", FATAL); + /*NOTREACHED*/ + } DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : DB version %d\n", version); pos = ftell(fp); if (version != LABEL_DB_VERSION) { ChgExit("MapBarCode", "MapBarCode, DB Version does not match\n", FATAL); + /*NOTREACHED*/ } - if (( plabelv2 = (LabelV2_T *)malloc(sizeof(LabelV2_T))) == NULL) + if (( plabelv2 = (LabelV2_T *)alloc(SIZEOF(LabelV2_T))) == NULL) { - DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"MapBarCode : malloc failed\n"); - ChgExit("MapBarCode", "MapBarCode malloc failed\n", FATAL); + DebugPrint(DEBUG_ERROR,SECTION_MAP_BARCODE,"MapBarCode : alloc failed\n"); + ChgExit("MapBarCode", "MapBarCode alloc failed\n", FATAL); + /*NOTREACHED*/ } - memset(plabelv2, 0, sizeof(LabelV2_T)); + memset(plabelv2, 0, SIZEOF(LabelV2_T)); while(feof(fp) == 0 && loop == 1) { - rsize = fread(plabelv2, 1, sizeof(LabelV2_T), fp); - if (rsize == sizeof(LabelV2_T)) + rsize = fread(plabelv2, 1, SIZEOF(LabelV2_T), fp); + if (rsize == SIZEOF(LabelV2_T)) { record++; DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : (%d) VolTag \"%s\", BarCode %s, inuse %d, slot %d, from %d, loadcount %d\n",record, @@ -609,7 +663,7 @@ int MapBarCode(char *labelfile, MBC_T *result) * Only dump the info */ case BARCODE_DUMP: - printf("Slot -> %d, from -> %d, valid -> %d, Tag -> %s, Barcode -> %s, Loadcount %d\n", + printf("Slot -> %d, from -> %d, valid -> %d, Tag -> %s, Barcode -> %s, Loadcount %u\n", plabelv2->slot, plabelv2->from, plabelv2->valid, @@ -622,9 +676,17 @@ int MapBarCode(char *labelfile, MBC_T *result) * Set all the record to invalid, used by the Inventory function */ case RESET_VALID: - fseek(fp, pos, SEEK_SET); plabelv2->valid = 0; - fwrite(plabelv2, 1, sizeof(LabelV2_T), fp); + if (fseek(fp, pos, SEEK_SET) == -1) { + fclose(fp); + amfree(plabelv2); + return 0; /* Fail */ + } + if (fwrite(plabelv2, 1, SIZEOF(LabelV2_T), fp) < SIZEOF(LabelV2_T)) { + fclose(fp); + amfree(plabelv2); + return 0; /* Fail */ + } break; /* * Add an entry @@ -642,32 +704,31 @@ int MapBarCode(char *labelfile, MBC_T *result) unusedrec = record; } - /* - * Hmm whats that ? - */ - if (strcmp(plabelv2->voltag, result->data.voltag) == 0) - { - volseen = record; - } - /* * OK this record matches the barcode label * so use/update it */ if (strcmp(plabelv2->barcode, result->data.barcode) == 0) { + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : update entry\n"); - fseek(fp, pos, SEEK_SET); + if (fseek(fp, pos, SEEK_SET) == -1) { + fclose(fp); + amfree(plabelv2); + return 0; /* Fail */ + } plabelv2->valid = 1; plabelv2->from = result->data.from; plabelv2->slot = result->data.slot; plabelv2->LoadCount = plabelv2->LoadCount + result->data.LoadCount; - strcpy(plabelv2->voltag, result->data.voltag); - strcpy(plabelv2->barcode, result->data.barcode); - fwrite(plabelv2, 1, sizeof(LabelV2_T), fp); + strncpy(plabelv2->voltag, result->data.voltag, + SIZEOF(plabelv2->voltag)); + strncpy(plabelv2->barcode, result->data.barcode, + SIZEOF(plabelv2->barcode)); + rc = (fwrite(plabelv2, 1, SIZEOF(LabelV2_T), fp) < SIZEOF(LabelV2_T)); fclose(fp); - free(plabelv2); - return(1); + amfree(plabelv2); + return(rc); } break; /* @@ -678,8 +739,8 @@ int MapBarCode(char *labelfile, MBC_T *result) if (strcmp(plabelv2->voltag, result->data.voltag) == 0) { DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode FIND_SLOT : \n"); - memcpy(&(result->data), plabelv2, sizeof(LabelV2_T)); - free(plabelv2); + memcpy(&(result->data), plabelv2, SIZEOF(LabelV2_T)); + amfree(plabelv2); return(1); } break; @@ -692,17 +753,23 @@ int MapBarCode(char *labelfile, MBC_T *result) if (strcmp(plabelv2->voltag, result->data.voltag) == 0) { DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode UPDATE_SLOT : update entry\n"); - fseek(fp, pos, SEEK_SET); - strcpy(plabelv2->voltag, result->data.voltag); - strcpy(plabelv2->barcode, result->data.barcode); + if (fseek(fp, pos, SEEK_SET) == -1) { + fclose(fp); + amfree(plabelv2); + return 0; /* Fail */ + } + strncpy(plabelv2->voltag, result->data.voltag, + SIZEOF(plabelv2->voltag)); + strncpy(plabelv2->barcode, result->data.barcode, + SIZEOF(plabelv2->barcode)); plabelv2->valid = 1; plabelv2->slot = result->data.slot; plabelv2->from = result->data.from; plabelv2->LoadCount = plabelv2->LoadCount + result->data.LoadCount; - fwrite(plabelv2, 1, sizeof(LabelV2_T), fp); + rc = (fwrite(plabelv2, 1, SIZEOF(LabelV2_T), fp) < SIZEOF(LabelV2_T)); fclose(fp); - free(plabelv2); - return(1); + amfree(plabelv2); + return(rc); } break; /* @@ -720,8 +787,8 @@ int MapBarCode(char *labelfile, MBC_T *result) DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : VOL %s match\n", result->data.voltag); fclose(fp); - memcpy(&(result->data), plabelv2, sizeof(LabelV2_T)); - free(plabelv2); + memcpy(&(result->data), plabelv2, SIZEOF(LabelV2_T)); + amfree(plabelv2); return(1); } break; @@ -735,8 +802,8 @@ int MapBarCode(char *labelfile, MBC_T *result) DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : BARCODE %s match\n", result->data.barcode); fclose(fp); - memcpy(&(result->data), plabelv2, sizeof(LabelV2_T)); - free(plabelv2); + memcpy(&(result->data), plabelv2, SIZEOF(LabelV2_T)); + amfree(plabelv2); return(1); } break; @@ -748,7 +815,7 @@ int MapBarCode(char *labelfile, MBC_T *result) pos = ftell(fp); } else { DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : feof (%d)\n", feof(fp)); - DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : error in read record expect %d, got %d\n",sizeof(LabelV2_T), rsize); + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : error in read record expect %d, got %d\n",SIZEOF(LabelV2_T), rsize); loop=0; } } @@ -768,22 +835,28 @@ int MapBarCode(char *labelfile, MBC_T *result) if (unusedpos != 0) { DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE,"MapBarCode : reuse record %d\n", unusedrec); - fseek(fp, unusedpos, SEEK_SET); + if (fseek(fp, unusedpos, SEEK_SET) == -1) { + fclose(fp); + amfree(plabelv2); + return 0; /* Fail */ + } } /* * Set all values to zero */ - memset(plabelv2, 0, sizeof(LabelV2_T)); + memset(plabelv2, 0, SIZEOF(LabelV2_T)); - strcpy(plabelv2->voltag, result->data.voltag); - strncpy(plabelv2->barcode, result->data.barcode, TAG_SIZE); + strncpy(plabelv2->voltag, result->data.voltag, + SIZEOF(plabelv2->voltag)); + strncpy(plabelv2->barcode, result->data.barcode, + SIZEOF(plabelv2->barcode)); plabelv2->valid = 1; plabelv2->from = result->data.from; plabelv2->slot = result->data.slot; - fwrite(plabelv2, 1, sizeof(LabelV2_T), fp); + rc = (fwrite(plabelv2, 1, SIZEOF(LabelV2_T), fp) < SIZEOF(LabelV2_T)); fclose(fp); - free(plabelv2); - return(1); + amfree(plabelv2); + return(rc); } /* @@ -791,7 +864,7 @@ int MapBarCode(char *labelfile, MBC_T *result) * found, so return an 0 */ fclose(fp); - free(plabelv2); + amfree(plabelv2); return(0); } @@ -812,6 +885,7 @@ typedef struct com_stru char *parameter; } command; +void parse_args(int argc, char *argv[],command *rval); /* major command line args */ #define COMCOUNT 13 @@ -858,9 +932,12 @@ argument slotdefs[]={{"current",SLOT_CUR,0}, {"last",SLOT_LAST,0}, {"advance",SLOT_ADVANCE,0}, }; -#define SLOTCOUNT (sizeof(slotdefs) / sizeof(slotdefs[0])) +#define SLOTCOUNT (int)(sizeof(slotdefs) / sizeof(slotdefs[0])) -int is_positive_number(char *tmp) /* is the string a valid positive int? */ +/* is the string a valid positive int? */ +int +is_positive_number( + char *tmp) { int i=0; if ((tmp==NULL)||(tmp[0]==0)) @@ -873,7 +950,9 @@ int is_positive_number(char *tmp) /* is the string a valid positive int? */ return 0; } -void usage(char *argv[]) +void +usage( + char *argv[]) { int cnt; printf("%s: Usage error.\n", argv[0]); @@ -888,9 +967,14 @@ void usage(char *argv[]) } -void parse_args(int argc, char *argv[],command *rval) +void +parse_args( + int argc, + char *argv[], + command *rval) { - int i=0; + int i; + for (i=0; i < argc; i++) dbprintf(("ARG [%d] : %s\n", i, argv[i])); i = 0; @@ -914,55 +998,64 @@ void parse_args(int argc, char *argv[],command *rval) } /* used to find actual slot number from keywords next, prev, first, etc */ -int get_relative_target(int fd,int nslots,char *parameter,int param_index, - int loaded,char *slot_file, - int slot_offset,int maxslot) +int +get_relative_target( + int fd, + int nslots, + char *parameter, + int param_index, + int loaded, + char *slot_file, + int slot_offset, + int maxslot) { int current_slot; + (void)loaded; /* Quiet unused parameter warning */ + current_slot = get_current_slot(slot_file); - if (current_slot > maxslot){ + if (current_slot > maxslot) { current_slot = slot_offset; } - if (current_slot < slot_offset){ + if (current_slot < slot_offset) { current_slot = slot_offset; } switch(param_index) { case SLOT_CUR: return current_slot; - break; + case SLOT_NEXT: case SLOT_ADVANCE: if (++current_slot==nslots+slot_offset) return slot_offset; - else - return current_slot; - break; + return current_slot; + case SLOT_PREV: if (--current_slot no slot `%s'\n",parameter); - close(fd); - exit(2); break; - }; - return(-1); /* never executed */ + } + printf(" no slot `%s'\n",parameter); + close(fd); + exit(2); + /*NOTREACHED*/ } -int ask_clean(char *tapedev) - /* This function should ask the drive if it wants to be cleaned */ +/* This function should ask the drive if it wants to be cleaned */ +int +ask_clean( + char *tapedev) { int ret; @@ -975,32 +1068,50 @@ int ask_clean(char *tapedev) return ret; } -void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, - int cleancart, int maxclean,char *usagetime) - /* This function should move the cleaning cartridge into the drive */ +/* This function should move the cleaning cartridge into the drive */ +void +clean_tape( + int fd, + char *tapedev, + char *cnt_file, + int drivenum, + int cleancart, + int maxclean, + char *usagetime) { - int counter=-1; + int counter; + if (cleancart == -1 ){ return; } + /* Now we should increment the counter */ if (cnt_file != NULL){ counter = get_current_slot(cnt_file); counter++; if (counter>=maxclean){ /* Now we should inform the administrator */ - char *mail_cmd; - FILE *mailf; - mail_cmd = vstralloc(MAILER, + char *mail_cmd = NULL; + FILE *mailf = NULL; + int mail_pipe_opened = 1; + if(getconf_seen(CNF_MAILTO) && strlen(getconf_str(CNF_MAILTO)) > 0 && + validate_mailto(getconf_str(CNF_MAILTO))) { + mail_cmd = vstralloc(MAILER, " -s", " \"", "AMANDA PROBLEM: PLEASE FIX", "\"", " ", getconf_str(CNF_MAILTO), NULL); - if((mailf = popen(mail_cmd, "w")) == NULL){ - error("could not open pipe to \"%s\": %s", - mail_cmd, strerror(errno)); - printf("Mail failed\n"); - return; + if((mailf = popen(mail_cmd, "w")) == NULL){ + printf("Mail failed\n"); + error("could not open pipe to \"%s\": %s", + mail_cmd, strerror(errno)); + /*NOTREACHED*/ + } } + else { + mail_pipe_opened = 0; + mailf = stderr; + fprintf(mailf, "\nNo mail recipient specified, output redirected to stderr"); + } fprintf(mailf,"\nThe usage count of your cleaning tape in slot %d", cleancart); fprintf(mailf,"\nis more than %d. (cleanmax)",maxclean); @@ -1008,12 +1119,13 @@ void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, fprintf(mailf,"\nPlease insert a new cleaning tape and reset"); fprintf(mailf,"\nthe countingfile %s",cnt_file); - if(pclose(mailf) != 0) - error("mail command failed: %s", mail_cmd); - + if(mail_pipe_opened == 1 && pclose(mailf) != 0) { + error("mail command failed: %s", mail_cmd); + /*NOTREACHED*/ + } return; } - put_current_slot(cnt_file,counter); + put_current_slot(cnt_file, counter); } load(fd,drivenum,cleancart); /* @@ -1023,32 +1135,36 @@ void clean_tape(int fd,char *tapedev,char *cnt_file, int drivenum, sleep(60); if (drive_loaded(fd, drivenum)) - unload(fd,drivenum,cleancart); - unlink(usagetime); + unload(fd, drivenum, cleancart); + if (usagetime) + unlink(usagetime); } /* ----------------------------------------------------------------------*/ -int main(int argc, char *argv[]) +int +main( + int argc, + char *argv[]) { - int loaded,target,oldtarget; + int loaded; + int target, oldtarget; command com; /* a little DOS joke */ int x; - - MBC_T *pbarcoderes = malloc(sizeof(MBC_T)); + MBC_T *pbarcoderes; /* * drive_num really should be something from the config file, but.. * for now, it is set to zero, since most of the common changers * used by amanda only have one drive ( until someone wants to * use an EXB60/120, or a Breece Hill Q45.. ) */ - unsigned char emubarcode = 0; - int drive_num = 0; - int need_eject = 0; /* Does the drive need an eject command ? */ - int need_sleep = 0; /* How many seconds to wait for the drive to get ready */ + unsigned char emubarcode; + int drive_num; + int need_eject; /* Does the drive need an eject command ? */ + time_t need_sleep; /* How many seconds to wait for the drive to get ready */ - int maxclean = 0; - char *clean_file=NULL; - char *time_file=NULL; + int maxclean; + char *clean_file; + char *time_file; /* * For the emubarcode stuff @@ -1057,27 +1173,32 @@ int main(int argc, char *argv[]) int slot_offset; int confnum; - int fd, slotcnt, drivecnt; + int fd; + int slotcnt; + int drivecnt; int endstatus = 0; - char *changer_dev = NULL; - char *tape_device = NULL; - char *chg_scsi_conf = NULL; /* The config file for us */ - char *slot_file = NULL; /* Where we will place the info which + char *changer_dev; + char *tape_device; + char *chg_scsi_conf; /* The config file for us */ + char *slot_file; /* Where we will place the info which * slot is loaded */ - char *scsitapedevice = NULL; + char *scsitapedevice; int param_index = 0; - memset(pbarcoderes, 0 , sizeof(MBC_T)); - chg.number_of_configs = 0; - chg.eject = 0; - chg.sleep = 0; - chg.cleanmax = 0; - chg.device = NULL; - chg.labelfile = NULL; - chg.conf = NULL; + changer = alloc(SIZEOF(changer_t)); + pbarcoderes = alloc(SIZEOF(MBC_T)); + + memset(pbarcoderes, 0 , SIZEOF(MBC_T)); + changer->number_of_configs = 0; + changer->eject = 0; + changer->sleep = 0; + changer->cleanmax = 0; + changer->device = NULL; + changer->labelfile = NULL; + changer->conf = NULL; #ifdef CHG_SCSI_STANDALONE printf("Ups standalone\n"); #else @@ -1086,9 +1207,9 @@ int main(int argc, char *argv[]) /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); - dbopen(); + dbopen(DBG_SUBDIR_SERVER); - dbprintf(("chg-scsi: %s\n",rcsid)); + dbprintf(("chg-scsi: %s\n", rcsid)); ChangerDriverVersion(); if (debug_file == NULL) @@ -1098,8 +1219,8 @@ int main(int argc, char *argv[]) parse_args(argc,argv,&com); - pDev = (OpenFiles_T *)malloc(sizeof(OpenFiles_T) * CHG_MAXDEV); - memset(pDev, 0, sizeof(OpenFiles_T) * CHG_MAXDEV ); + pDev = (OpenFiles_T *)alloc(SIZEOF(OpenFiles_T) * CHG_MAXDEV); + memset(pDev, 0, SIZEOF(OpenFiles_T) * CHG_MAXDEV ); switch(com.command_code) @@ -1107,12 +1228,12 @@ int main(int argc, char *argv[]) case COM_SCAN: ScanBus(1); return(0); - break; + case COM_GEN_CONF: ScanBus(0); PrintConf(); return(0); - break; + default: break; } @@ -1120,6 +1241,7 @@ int main(int argc, char *argv[]) if(read_conffile(CONFFILE_NAME)) { perror(CONFFILE_NAME); exit(1); + /*NOTREACHED*/ } chg_scsi_conf = getconf_str(CNF_CHNGRFILE); @@ -1129,51 +1251,70 @@ int main(int argc, char *argv[]) /* Attention, this will not support more than 10 tape devices 0-9 */ /* */ if (strlen(tape_device)==1){ - if (read_config(chg_scsi_conf,&chg) == -1) + if (read_config(chg_scsi_conf, changer) == -1) { fprintf(stderr, "%s open: of %s failed\n", get_pname(), chg_scsi_conf); - return 2; + return (2); } confnum=atoi(tape_device); - if (chg.number_of_configs == 0) + if (changer->number_of_configs == 0) { - fprintf(stderr,"%s: chg.conf[%d] == NULL\n",get_pname(), confnum); - return(2); + fprintf(stderr,"%s: changer->conf[%d] == NULL\n", + get_pname(), confnum); + return (2); + } + if (confnum >= changer->number_of_configs) { + fprintf(stderr,"%s: Configuration %s config # out of range (%d >= %d)\n", + get_pname(), chg_scsi_conf, + confnum, + changer->number_of_configs); + return (2); } - use_slots = chg.conf[confnum].end-chg.conf[confnum].start+1; - slot_offset = chg.conf[confnum].start; - drive_num = chg.conf[confnum].drivenum; - need_eject = chg.eject; - need_sleep = chg.sleep; - - if ( NULL != chg.conf[confnum].cleanfile) - clean_file = stralloc(chg.conf[confnum].cleanfile); + + use_slots = changer->conf[confnum].end-changer->conf[confnum].start+1; + slot_offset = changer->conf[confnum].start; + drive_num = changer->conf[confnum].drivenum; + need_eject = changer->eject; + need_sleep = changer->sleep; + + if ( NULL != changer->conf[confnum].cleanfile) + clean_file = stralloc(changer->conf[confnum].cleanfile); else clean_file = NULL; - clean_slot = chg.conf[confnum].cleanslot; - maxclean = chg.cleanmax; - emubarcode = chg.emubarcode; - if (NULL != chg.conf[confnum].timefile) - time_file = stralloc(chg.conf[confnum].timefile); + clean_slot = changer->conf[confnum].cleanslot; + maxclean = changer->cleanmax; + emubarcode = changer->emubarcode; + if (NULL != changer->conf[confnum].timefile) + time_file = stralloc(changer->conf[confnum].timefile); + else + time_file = NULL; - if (NULL != chg.conf[confnum].slotfile) - slot_file = stralloc(chg.conf[confnum].slotfile); + if (NULL != changer->conf[confnum].slotfile) + slot_file = stralloc(changer->conf[confnum].slotfile); else slot_file = NULL; - if (NULL != chg.conf[confnum].device) - tape_device = stralloc(chg.conf[confnum].device); + if (NULL != changer->conf[confnum].device) + tape_device = stralloc(changer->conf[confnum].device); + else + tape_device = NULL; - if (NULL != chg.device) - changer_dev = stralloc(chg.device); + if (NULL != changer->device) + changer_dev = stralloc(changer->device); + else + changer_dev = NULL; - if (NULL != chg.conf[confnum].scsitapedev) - scsitapedevice = stralloc(chg.conf[confnum].scsitapedev); + if (NULL != changer->conf[confnum].scsitapedev) + scsitapedevice = stralloc(changer->conf[confnum].scsitapedev); + else + scsitapedevice = NULL; - if (NULL != chg.conf[confnum].tapestatfile) - tapestatfile = stralloc(chg.conf[confnum].tapestatfile); - dump_changer_struct(chg); + if (NULL != changer->conf[confnum].tapestatfile) + tapestatfile = stralloc(changer->conf[confnum].tapestatfile); + else + tapestatfile = NULL; + dump_changer_struct(changer); @@ -1182,7 +1323,7 @@ int main(int argc, char *argv[]) * If we can't open it fail with a message */ - if (OpenDevice(INDEX_CHANGER , changer_dev, "changer_dev", chg.conf[confnum].changerident) == 0) + if (OpenDevice(INDEX_CHANGER , changer_dev, "changer_dev", changer->conf[confnum].changerident) == 0) { int localerr = errno; fprintf(stderr, "%s: open: %s: %s\n", get_pname(), @@ -1203,7 +1344,7 @@ int main(int argc, char *argv[]) */ if (tape_device != NULL) { - if (OpenDevice(INDEX_TAPE, tape_device, "tape_device", chg.conf[confnum].tapeident) == 0) + if (OpenDevice(INDEX_TAPE, tape_device, "tape_device", changer->conf[confnum].tapeident) == 0) { dbprintf(("warning open of %s: failed\n", tape_device)); } @@ -1214,7 +1355,7 @@ int main(int argc, char *argv[]) */ if (scsitapedevice != NULL) { - if (OpenDevice(INDEX_TAPECTL, scsitapedevice, "scsitapedevice", chg.conf[confnum].tapeident) == 0) + if (OpenDevice(INDEX_TAPECTL, scsitapedevice, "scsitapedevice", changer->conf[confnum].tapeident) == 0) { dbprintf(("warning open of %s: failed\n", scsitapedevice)); } @@ -1236,7 +1377,7 @@ int main(int argc, char *argv[]) } - if ((chg.conf[confnum].end == -1) || (chg.conf[confnum].start == -1)){ + if ((changer->conf[confnum].end == -1) || (changer->conf[confnum].start == -1)){ slotcnt = get_slot_count(fd); use_slots = slotcnt; slot_offset = 0; @@ -1248,9 +1389,9 @@ int main(int argc, char *argv[]) * we need an label file */ - if ( chg.emubarcode == 1 || BarCode(INDEX_CHANGER) == 1) + if ( changer->emubarcode == 1 || BarCode(INDEX_CHANGER) == 1) { - if (chg.labelfile == NULL) + if (changer->labelfile == NULL) { printf("labelfile param not set in your config\n"); return(2); @@ -1288,7 +1429,7 @@ int main(int argc, char *argv[]) return 2; } - loaded = drive_loaded(fd, drive_num); + loaded = (int)drive_loaded(fd, drive_num); target = -1; switch(com.command_code) { @@ -1300,16 +1441,19 @@ int main(int argc, char *argv[]) */ case COM_DUMPDB: pbarcoderes->action = BARCODE_DUMP; - MapBarCode(chg.labelfile, pbarcoderes); + MapBarCode(changer->labelfile, pbarcoderes); break; case COM_STATUS: - ChangerStatus(com.parameter, chg.labelfile, BarCode(fd),slot_file, changer_dev, tape_device); + ChangerStatus(com.parameter, changer->labelfile, + BarCode(fd), slot_file, changer_dev, tape_device); break; case COM_LABEL: /* Update BarCode/Label mapping file */ pbarcoderes->action = BARCODE_PUT; - strcpy(pbarcoderes->data.voltag, com.parameter); - strcpy( pbarcoderes->data.barcode, pDTE[drive_num].VolTag); - MapBarCode(chg.labelfile, pbarcoderes); + strncpy(pbarcoderes->data.voltag, com.parameter, + SIZEOF(pbarcoderes->data.voltag)); + strncpy(pbarcoderes->data.barcode, pDTE[drive_num].VolTag, + SIZEOF(pbarcoderes->data.barcode)); + MapBarCode(changer->labelfile, pbarcoderes); printf("0 0 0\n"); break; @@ -1341,9 +1485,9 @@ int main(int argc, char *argv[]) (void)unload(fd, drive_num, oldtarget); if (ask_clean(scsitapedevice)) clean_tape(fd,tape_device,clean_file,drive_num, - clean_slot,maxclean,time_file); + clean_slot, maxclean, time_file); } - Inventory(chg.labelfile, drive_num, need_eject, 0, 0, clean_slot); + Inventory(changer->labelfile, drive_num, need_eject, 0, 0, clean_slot); do_inventory = 0; /* If set on exit the labeldb will be set to invalid ..... */ break; @@ -1361,8 +1505,9 @@ int main(int argc, char *argv[]) dbprintf(("search : look for %s\n", com.parameter)); pbarcoderes->action = BARCODE_VOL; pbarcoderes->data.slot = -1; - strcpy(pbarcoderes->data.voltag, com.parameter); - if (MapBarCode(chg.labelfile, pbarcoderes) == 1) + strncpy(pbarcoderes->data.voltag, com.parameter, + SIZEOF(pbarcoderes->data.voltag)); + if (MapBarCode(changer->labelfile, pbarcoderes) == 1) { /* * If both values are unset we have an problem @@ -1384,7 +1529,7 @@ int main(int argc, char *argv[]) if (pbarcoderes->data.barcode != NULL) { - for (x = 0; x < STE; x++) + for (x = 0; x < (int)STE; x++) { if (strcmp(pSTE[x].VolTag, pbarcoderes->data.barcode) == 0) { @@ -1398,7 +1543,7 @@ int main(int argc, char *argv[]) * If we find it check if it is in the right drive * if we have more than one drive. */ - for (x = 0; x < DTE; x++) + for (x = 0; x < (int)DTE; x++) { if (strcmp(pDTE[x].VolTag, pbarcoderes->data.barcode) == 0) { @@ -1407,7 +1552,7 @@ int main(int argc, char *argv[]) */ if (x == drive_num) { oldtarget = get_current_slot(slot_file); - printf("%d %s\n", oldtarget- slot_offset, tape_device); + printf("%d %s\n", oldtarget - slot_offset, tape_device); return(0); } else { printf("LABEL in wrong tape Unit\n"); @@ -1460,9 +1605,10 @@ int main(int argc, char *argv[]) dbprintf(("search : look for %s\n", com.parameter)); pbarcoderes->action = FIND_SLOT; pbarcoderes->data.slot = -1; - strcpy(pbarcoderes->data.voltag, com.parameter); + strncpy(pbarcoderes->data.voltag, com.parameter, + SIZEOF(pbarcoderes->data.voltag)); - if (MapBarCode(chg.labelfile, pbarcoderes) == 1) + if (MapBarCode(changer->labelfile, pbarcoderes) == 1) { if (pbarcoderes->data.valid == 1) { @@ -1494,19 +1640,20 @@ int main(int argc, char *argv[]) endstatus = 2; break; } else { - target = target+slot_offset; + target = target + slot_offset; } } else { param_index=0; - while((param_indexfd); */ @@ -1761,17 +1908,18 @@ int main(int argc, char *argv[]) #endif - if (do_inventory == 1 && endstatus == 0 && chg.labelfile != NULL) + if (do_inventory == 1 && endstatus == 0 && changer->labelfile != NULL) { - if ( chg.autoinv == 1) + if (changer->autoinv == 1) { DebugPrint(DEBUG_INFO,SECTION_INFO, "Do an inventory \n"); - Inventory(chg.labelfile, drive_num , chg.eject, 0, 0, clean_slot); + Inventory(changer->labelfile, drive_num, changer->eject, + 0, 0, clean_slot); } else { DebugPrint(DEBUG_INFO,SECTION_INFO, "Set all entrys in DB to invalid\n"); - memset(pbarcoderes, 0 , sizeof(MBC_T)); + memset(pbarcoderes, 0 , SIZEOF(MBC_T)); pbarcoderes->action = RESET_VALID; - MapBarCode(chg.labelfile,pbarcoderes); + MapBarCode(changer->labelfile,pbarcoderes); } } @@ -1785,4 +1933,3 @@ int main(int argc, char *argv[]) * tab-width: 4 * End: */ - diff --git a/changer-src/chg-zd-mtx.sh.in b/changer-src/chg-zd-mtx.sh.in index 1064eb0..db25d10 100644 --- a/changer-src/chg-zd-mtx.sh.in +++ b/changer-src/chg-zd-mtx.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Exit Status: # 0 Alles Ok @@ -162,8 +162,10 @@ # in amanda.conf. For example, if amanda.conf has: # # changerfile="/etc/amanda/Dailyset1/CHANGER" +# or changerfile="/etc/amanda/Dailyset1/CHANGER.conf" # # the variables must be in "/etc/amanda/Dailyset1/CHANGER.conf". +# The ".conf" is appended only if it's not there". # # If "changerfile" is a relative path, it is relative to the directory # that contains amanda.conf. That also happens to be the directory Amanda @@ -630,20 +632,20 @@ else SUF= fi -DBGFILE=`amgetconf$SUF dbopen.$argv0 2>/dev/null | grep -v BUGGY` +DBGFILE=`amgetconf$SUF dbopen.$argv0 2>/dev/null` if [ -z "$DBGFILE" ] then DBGFILE=/dev/null # will try this again below fi -changerfile=`amgetconf$SUF changerfile 2>/dev/null | grep -v BUGGY` +changerfile=`amgetconf$SUF changerfile 2>/dev/null` if [ -z "$changerfile" ]; then Exit 2 \ "" \ "changerfile must be specified in amanda.conf" fi -tape=`amgetconf$SUF tapedev 2>/dev/null | grep -v BUGGY` +tape=`amgetconf$SUF tapedev 2>/dev/null` if [ -z "$tape" ]; then Exit 2 \ "" \ @@ -653,7 +655,7 @@ elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then "" \ "tapedev ($tape) may not be the null device" fi -TAPE=`amgetconf$SUF changerdev 2>/dev/null | grep -v BUGGY` +TAPE=`amgetconf$SUF changerdev 2>/dev/null` if [ -z "$TAPE" ]; then Exit 2 \ "" \ @@ -667,7 +669,14 @@ export TAPE # for mtx command #### Set up the various config files. -configfile=$changerfile.conf +conf_match=`expr "$changerfile" : .\*\.conf\$` +if [ $conf_match -ge 6 ]; then + configfile=$changerfile + changerfile=`echo $changerfile | sed 's/.conf$//g'` +else + configfile=$changerfile.conf +fi + cleanfile=$changerfile-clean accessfile=$changerfile-access slotfile=$changerfile-slot @@ -1139,9 +1148,7 @@ info() { if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then currentslot=$firstslot # what "current" will get fi - set x $slot_list - shift # get rid of the "x" - numslots=$# + numslots=`expr $lastslot - $firstslot + 1` Exit 0 "$currentslot" "$numslots 1 $reader" return $? # in case we are internal } diff --git a/changer-src/libscsi.h b/changer-src/libscsi.h index e0fe00e..e0d190d 100644 --- a/changer-src/libscsi.h +++ b/changer-src/libscsi.h @@ -1,5 +1,5 @@ /* - * $Id: libscsi.h,v 1.9 2000/06/25 18:48:11 ant Exp $ + * $Id: libscsi.h,v 1.10 2006/05/25 01:47:07 johnfranks Exp $ * * libscsi.h -- library header for routines to handle the changer * support for chio based systems @@ -19,54 +19,54 @@ /* * This function gets the actual cleaning state of the drive */ -int get_clean_state P((char *tape)); +int get_clean_state(char *tape); /* * This function gets the next empty slot from the changer * (From this slot the tape is loaded ...) */ -int GetCurrentSlot P((int fd, int drive)); +int GetCurrentSlot(int fd, int drive); /* * Eject the actual tape from the tapedrive */ -void eject_tape P((char *tape, int type)); +int eject_tape(char *tape, int type); /* * is the specified slot empty? */ -int isempty P((int fd, int slot)); +int isempty(int fd, int slot); /* * find the first empty slot */ -int find_empty P((int fd, int start, int count)); +int find_empty(int fd, int start, int count); /* * returns one if there is a tape loaded in the drive */ -int drive_loaded P((int fd, int drivenum)); +int drive_loaded(int fd, int drivenum); /* * unloads the drive, putting the tape in the specified slot */ -int unload P((int fd, int drive, int slot)); +int unload(int fd, int drive, int slot); /* * moves tape from the specified slot into the drive */ -int load P((int fd, int drive, int slot)); +int load(int fd, int drive, int slot); /* * return the number of slots in the robot */ -int get_slot_count P((int fd)); +int get_slot_count(int fd); /* * return the number of drives in the robot */ -int get_drive_count P((int fd)); +int get_drive_count(int fd); #endif /* !LIBSCSI_H */ diff --git a/changer-src/scsi-aix.c b/changer-src/scsi-aix.c index 4696faf..5e0dba8 100644 --- a/changer-src/scsi-aix.c +++ b/changer-src/scsi-aix.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-aix.c,v 1.22 2005/10/15 13:20:47 martinea Exp $ + * $Id: scsi-aix.c,v 1.23 2006/05/25 01:47:07 johnfranks Exp $ * * Interface to execute SCSI commands on an AIX System * @@ -36,6 +36,8 @@ #ifdef HAVE_AIX_LIKE_SCSI +#include + #ifdef HAVE_SYS_TYPES_H #include #endif @@ -61,10 +63,10 @@ #include #include -void SCSI_OS_Version() +void SCSI_OS_Version(void) { #ifndef lint - static char rcsid[] = "$Id: scsi-aix.c,v 1.22 2005/10/15 13:20:47 martinea Exp $"; + static char rcsid[] = "$Id: scsi-aix.c,v 1.23 2006/05/25 01:47:07 johnfranks Exp $"; DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } @@ -126,12 +128,10 @@ int SCSI_OpenDevice(int ip) free(pDev[ip].inquiry); return(0); } - } else { - free(pDev[ip].inquiry); - pDev[ip].inquiry = NULL; - return(1); } - return(1); + free(pDev[ip].inquiry); + pDev[ip].inquiry = NULL; + return(1); } else { dbprintf(("SCSI_OpenDevice %s failed\n", pDev[ip].dev)); return(0); @@ -161,11 +161,11 @@ int SCSI_CloseDevice(int DeviceFD) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *RequestSenseBuf, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *RequestSenseBuf, + size_t RequestSenseLength) { extern OpenFiles_T *pDev; extern FILE * debug_file; @@ -179,6 +179,12 @@ int SCSI_ExecuteCommand(int DeviceFD, int isbusy = 0; int target = 3; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(RequestSenseBuf, 0, RequestSenseLength); if (pDev[DeviceFD].avail == 0) { @@ -192,7 +198,7 @@ int SCSI_ExecuteCommand(int DeviceFD, scmd.cdblen = CDB_Length; scmd.data_buf = DataBuffer; scmd.datalen = DataBufferLength; - scmd.sense_buf = RequestSenseBuf; + scmd.sense_buf = (unsigned char *)RequestSenseBuf; scmd.senselen = RequestSenseLength; scmd.statusp = &sbyte; scmd.timeval = 60; @@ -212,9 +218,9 @@ int SCSI_ExecuteCommand(int DeviceFD, return(SCSI_OK); } else { - bzero(&ds, sizeof(struct sc_iocmd)); + bzero(&ds, SIZEOF(struct sc_iocmd)); bzero(RequestSenseBuf, RequestSenseLength); - bzero(&ExtendedRequestSense, sizeof(ExtendedRequestSense_T)); + bzero(&ExtendedRequestSense, SIZEOF(ExtendedRequestSense_T)); ds.flags = SC_ASYNC; /* Timeout */ @@ -235,7 +241,7 @@ int SCSI_ExecuteCommand(int DeviceFD, /* Sense Buffer is not available on AIX ?*/ /* ds.req_sense_length = 255; - ds.request_sense_ptr = (char *)RequestSense; + ds.request_sense_ptr = (unsigned char *)RequestSense; */ switch (Direction) { @@ -267,7 +273,7 @@ int SCSI_ExecuteCommand(int DeviceFD, SINQ[5] = 0x80; bcopy(SINQ, ds.scsi_cdb, 6); ds.command_length = 6; - ds.buffer = RequestSenseBuf; + ds.buffer = (unsigned char *)RequestSenseBuf; ds.data_length = RequestSenseLength; if (pDev[DeviceFD].devopen == 0) @@ -276,10 +282,10 @@ int SCSI_ExecuteCommand(int DeviceFD, Result = ioctl(pDev[DeviceFD].fd, STIOCMD, &ds); SCSI_CloseDevice(DeviceFD); return(SCSI_OK); - break; + case SC_BUSY_STATUS: return(SCSI_BUSY); - break; + case SC_CHECK_CONDITION: SINQ[0] = SC_COM_REQUEST_SENSE; SINQ[1] = 0; @@ -289,8 +295,8 @@ int SCSI_ExecuteCommand(int DeviceFD, SINQ[5] = 0x80; bcopy(SINQ, ds.scsi_cdb, 6); ds.command_length = 6; - ds.buffer = RequestSenseBuf; - ds.data_length = RequestSenseLength; + ds.buffer = (unsigned char *)RequestSenseBuf; + ds.data_length = (unsigned char)RequestSenseLength; if (pDev[DeviceFD].devopen == 0) if (SCSI_OpenDevice(DeviceFD) == 0) @@ -298,7 +304,7 @@ int SCSI_ExecuteCommand(int DeviceFD, Result = ioctl(pDev[DeviceFD].fd, STIOCMD, &ds); SCSI_CloseDevice(DeviceFD); return(SCSI_CHECK); - break; + default: /* * Makes no sense yet, may result in an endless loop @@ -325,10 +331,9 @@ int SCSI_ExecuteCommand(int DeviceFD, } } -int SCSI_Scan() +int SCSI_Scan(void) { int fd; - extern int errno; struct sc_inquiry si; u_char buf[255]; int target; @@ -356,7 +361,7 @@ int SCSI_Scan() isbusy = 0; } - bzero(&si, sizeof(si)); + bzero(&si, SIZEOF(si)); si.scsi_id = target; si.lun_id = lun; si.inquiry_len = 255; @@ -366,9 +371,9 @@ int SCSI_Scan() printf("SCIOINQU: %s\n", strerror(errno)); } else { dump_hex(&buf, 255, DEBUG_INFO, SECTION_SCSI); - type = buf[0] & 0x1f; + type = buf[0] & 0x1lf; buf[8+28] = 0; - printf(stdout,"%-28s|Device Type %d\n",buf[8], type); + printf("%-28s|Device Type %d\n",buf[8], type); } if (!isbusy && ioctl(fd, SCIOSTOP, IDLUN(target, lun)) == -1) return(1); diff --git a/changer-src/scsi-bsd.c b/changer-src/scsi-bsd.c index bd01066..0850c9e 100644 --- a/changer-src/scsi-bsd.c +++ b/changer-src/scsi-bsd.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-bsd.c,v 1.17 2005/10/15 13:20:47 martinea Exp $ + * $Id: scsi-bsd.c,v 1.18 2006/05/25 01:47:07 johnfranks Exp $ * * Interface to execute SCSI commands on an BSD System (FreeBSD) * @@ -61,7 +61,7 @@ void SCSI_OS_Version() { #ifndef lint - static char rcsid[] = "$Id: scsi-bsd.c,v 1.17 2005/10/15 13:20:47 martinea Exp $"; + static char rcsid[] = "$Id: scsi-bsd.c,v 1.18 2006/05/25 01:47:07 johnfranks Exp $"; DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } @@ -163,11 +163,11 @@ int SCSI_CloseDevice(int DeviceFD) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *pRequestSense, + size_t RequestSenseLength) { extern OpenFiles_T *pDev; ExtendedRequestSense_T ExtendedRequestSense; @@ -176,14 +176,21 @@ int SCSI_ExecuteCommand(int DeviceFD, int retries = 5; extern int errno; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(pRequestSense, 0, RequestSenseLength); + if (pDev[DeviceFD].avail == 0) { return(SCSI_ERROR); } - memset(&ds, 0, sizeof(scsireq_t)); + memset(&ds, 0, SIZEOF(scsireq_t)); memset(pRequestSense, 0, RequestSenseLength); - memset(&ExtendedRequestSense, 0 , sizeof(ExtendedRequestSense_T)); + memset(&ExtendedRequestSense, 0 , SIZEOF(ExtendedRequestSense_T)); ds.flags = SCCMD_ESCAPE; /* Timeout */ @@ -224,7 +231,7 @@ int SCSI_ExecuteCommand(int DeviceFD, memcpy(pRequestSense, ds.sense, RequestSenseLength); if (Result < 0) { - dbprintf(("errno : %d\n",errno)); + dbprintf(("errno : %s\n",strerror(errno))); return (SCSI_ERROR); } dbprintf(("SCSI_ExecuteCommand(BSD) %02X STATUS(%02X) \n", CDB[0], ds.retsts)); @@ -232,12 +239,13 @@ int SCSI_ExecuteCommand(int DeviceFD, { case SCCMD_BUSY: /* BUSY */ break; + case SCCMD_OK: /* GOOD */ return(SCSI_OK); - break; + case SCCMD_SENSE: /* CHECK CONDITION */ return(SCSI_SENSE); - break; + default: continue; } @@ -271,7 +279,7 @@ int Tape_Ioctl( int DeviceFD, int command) if (ioctl(pDev[DeviceFD].fd , MTIOCTOP, &mtop) != 0) { - dbprintf(("Tape_Ioctl error ioctl %d\n",errno)); + dbprintf(("Tape_Ioctl error ioctl %s\n",strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } diff --git a/changer-src/scsi-cam.c b/changer-src/scsi-cam.c index e159b45..9f0c497 100644 --- a/changer-src/scsi-cam.c +++ b/changer-src/scsi-cam.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-cam.c,v 1.14 2005/10/15 13:20:47 martinea Exp $ + * $Id: scsi-cam.c,v 1.15 2006/05/25 01:47:07 johnfranks Exp $ * * Interface to execute SCSI commands on an system with cam support * Current support is for FreeBSD 4.x @@ -75,7 +75,7 @@ extern FILE *debug_file; void SCSI_OS_Version() { #ifndef lint - static char rcsid[] = "$Id: scsi-cam.c,v 1.14 2005/10/15 13:20:47 martinea Exp $"; + static char rcsid[] = "$Id: scsi-cam.c,v 1.15 2006/05/25 01:47:07 johnfranks Exp $"; DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } @@ -94,18 +94,33 @@ int parse_btl(char *DeviceName, return 0; p = strtok(DeviceName, ":"); - sscanf(p,"%d", path); + if (sscanf(p,"%d", path) != 1) { + free(DeviceName); + ChgExit("SCSI_OpenDevice", + "Path conversion error. Digits expected", FATAL); + } if ((p = strtok(NULL,":")) == NULL) { free(DeviceName); ChgExit("SCSI_OpenDevice", "target in Device Name not found", FATAL); } - sscanf(p,"%d", target); + + if (sscanf(p,"%d", target) != 1) { + free(DeviceName); + ChgExit("SCSI_OpenDevice", + "Target conversion error. Digits expected", FATAL); + } + if ((p = strtok(NULL,":")) == NULL) { free(DeviceName); ChgExit("SCSI_OpenDevice", "lun in Device Name not found", FATAL); } - sscanf(p,"%d", lun); + if (sscanf(p,"%d", lun) != 1) { + free(DeviceName); + ChgExit("SCSI_OpenDevice", + "LUN conversion error. Digits expected", FATAL); + } + return 1; } @@ -179,22 +194,20 @@ int SCSI_OpenDevice(int ip) DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP SCSI_OpenDevice open failed\n"); return(0); } - } else { - if (parse_btl(DeviceName, &path, &target, &lun)) - pDev[ip].curdev = cam_open_btl(path, target, lun, O_RDWR, NULL); - else - pDev[ip].curdev = cam_open_device(DeviceName, O_RDWR); - - free(DeviceName); - - if (pDev[ip].curdev) { - pDev[ip].devopen = 1; - return(1); - } else { - return(0); - } } - return(0); + if (parse_btl(DeviceName, &path, &target, &lun)) + pDev[ip].curdev = cam_open_btl(path, target, lun, O_RDWR, NULL); + else + pDev[ip].curdev = cam_open_device(DeviceName, O_RDWR); + + free(DeviceName); + + if (pDev[ip].curdev) { + pDev[ip].devopen = 1; + return(1); + } else { + return(0); + } } int SCSI_CloseDevice(int DeviceFD) @@ -215,11 +228,11 @@ int SCSI_CloseDevice(int DeviceFD) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *pRequestSense, + size_t RequestSenseLength) { ExtendedRequestSense_T ExtendedRequestSense; extern OpenFiles_T *pDev; @@ -228,6 +241,13 @@ int SCSI_ExecuteCommand(int DeviceFD, uint32_t ccb_flags; OpenFiles_T *pwork = NULL; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(pRequestSense, 0, RequestSenseLength); + if (pDev[DeviceFD].avail == 0) { return(SCSI_ERROR); @@ -243,7 +263,7 @@ int SCSI_ExecuteCommand(int DeviceFD, ccb = cam_getccb(pDev[DeviceFD].curdev); /* Build the CCB */ - bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_scsiio)); + bzero(&(&ccb->ccb_h)[1], SIZEOF(struct ccb_scsiio)); bcopy(&CDB[0], &ccb->csio.cdb_io.cdb_bytes, CDB_Length); switch (Direction) @@ -341,7 +361,7 @@ int Tape_Ioctl( int DeviceFD, int command) if (ioctl(pDev[DeviceFD].fd , MTIOCTOP, &mtop) != 0) { - dbprintf(("Tape_Ioctl error ioctl %d\n",errno)); + dbprintf(("Tape_Ioctl error ioctl %s\n", strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -362,7 +382,7 @@ int Tape_Status( int DeviceFD) if (ioctl(pDev[DeviceFD].fd , MTIOCGET, &mtget) != 0) { - dbprintf(("Tape_Status error ioctl %d\n",errno)); + dbprintf(("Tape_Status error ioctl %s\n", strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -463,6 +483,7 @@ int ScanBus(int print) } } } + return 0; } #endif diff --git a/changer-src/scsi-changer-driver.c b/changer-src/scsi-changer-driver.c index c9dad84..0c274af 100644 --- a/changer-src/scsi-changer-driver.c +++ b/changer-src/scsi-changer-driver.c @@ -1,6 +1,4 @@ -#ifndef lint -static char rcsid[] = "$Id: scsi-changer-driver.c,v 1.49 2006/03/16 00:20:53 paddy_s Exp $"; -#endif +static char rcsid[] = "$Id: scsi-changer-driver.c,v 1.52 2006/07/21 00:25:50 martinea Exp $"; /* * Interface to control a tape robot/library connected to the SCSI bus * @@ -9,10 +7,6 @@ static char rcsid[] = "$Id: scsi-changer-driver.c,v 1.49 2006/03/16 00:20:53 pad #include -#ifdef HAVE_DMALLOC_H -#include -#endif - #include "arglist.h" /* #ifdef HAVE_STDIO_H @@ -47,9 +41,8 @@ static char rcsid[] = "$Id: scsi-changer-driver.c,v 1.49 2006/03/16 00:20:53 pad #include "tapeio.h" -extern int TapeEject(int DeviceFD); - extern FILE *debug_file; +extern changer_t *changer; /* Needed for the infos about emubarcode and labelfile */ int PrintInquiry(SCSIInquiry_T *); int GenericElementStatus(int DeviceFD, int InitStatus); @@ -58,84 +51,90 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus); ElementInfo_T *LookupElement(int addr); int GenericResetStatus(int DeviceFD); int RequestSense(int, ExtendedRequestSense_T *, int ); -void dump_hex(char *, int, int, int); -void TerminateString(char *string, int length); +void dump_hex(u_char *, size_t, int, int); +void TerminateString(char *string, size_t length); void ChgExit(char *, char *, int); int BarCode(int fd); int LogSense(int fd); -int SenseHandler(int fd, unsigned char flag, unsigned char SenseKey, unsigned char AdditionalSenseCode, unsigned char AdditionalSenseCodeQualifier, char *buffer); +int SenseHandler(int fd, u_char flag, u_char SenseKey, u_char AdditionalSenseCode, u_char AdditionalSenseCodeQualifier, RequestSense_T *buffer); + +int SCSI_AlignElements(int DeviceFD, size_t MTE, size_t DTE, size_t STE); -int SCSI_AlignElements(int DeviceFD, int MTE, int DTE, int STE); +int DoNothing0(void); +int DoNothing1(int); +int DoNothing2(int, int); +int DoNothing3(int, int, int); -int DoNothing(); int GenericMove(int, int, int); int SDXMove(int, int, int); int CheckMove(ElementInfo_T *from, ElementInfo_T *to); int GenericRewind(int); -/* int GenericStatus(); */ -int GenericFree(); -int TapeStatus(); /* Is the tape loaded ? */ +/* int GenericStatus(void); */ +int GenericFree(void); +int TapeStatus(void); /* Is the tape loaded ? */ int DLT4000Eject(char *Device, int type); int GenericEject(char *Device, int type); int GenericClean(char *Device); /* Does the tape need a clean */ int GenericBarCode(int DeviceFD); /* Do we have Barcode reader support */ int NoBarCode(int DeviceFD); -int GenericSearch(); +int GenericSearch(void); void Inventory(char *labelfile, int drive, int eject, int start, int stop, int clean); int TreeFrogBarCode(int DeviceFD); int EXB_BarCode(int DeviceFD); -int GenericSenseHandler(int fd, int flags, unsigned char SenseKey, unsigned char AdditionalSenseCode, unsigned char AdditionalSenseCodeQualifier, char *); +int GenericSenseHandler(int fd, u_char flags, u_char SenseKey, u_char AdditionalSenseCode, u_char AdditionalSenseCodeQualifier, RequestSense_T *); ElementInfo_T *LookupElement(int address); int eject_tape(char *tapedev, int type); int unload(int fd, int drive, int slot); int load(int fd, int drive, int slot); int GetElementStatus(int DeviceFD); +int drive_loaded(int fd, int drivenum); /* * Log Pages Decode */ -void WriteErrorCountersPage(LogParameter_T *, int); -void ReadErrorCountersPage(LogParameter_T *, int); -void C1553APage30(LogParameter_T *, int); -void C1553APage37(LogParameter_T *, int); -void EXB85058HEPage39(LogParameter_T *, int); -void EXB85058HEPage3c(LogParameter_T *, int); -int Decode(LogParameter_T *, int *); -int DecodeModeSense(char *buffer, int offset, char *pstring, char block, FILE *out); +void WriteErrorCountersPage(LogParameter_T *, size_t); +void ReadErrorCountersPage(LogParameter_T *, size_t); +void C1553APage30(LogParameter_T *, size_t); +void C1553APage37(LogParameter_T *, size_t); +void EXB85058HEPage39(LogParameter_T *, size_t); +void EXB85058HEPage3c(LogParameter_T *, size_t); +int Decode(LogParameter_T *, unsigned *); +int DecodeModeSense(u_char *buffer, size_t offset, char *pstring, char block, FILE *out); int SCSI_Run(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength); + size_t DataBufferLength, + RequestSense_T *pRequestSense, + size_t RequestSenseLength); -int SCSI_Move(int DeviceFD, unsigned char chm, int from, int to); -int SCSI_LoadUnload(int DeviceFD, RequestSense_T *pRequestSense, unsigned char byte1, unsigned char load); +int SCSI_Move(int DeviceFD, u_char chm, int from, int to); +int SCSI_LoadUnload(int DeviceFD, RequestSense_T *pRequestSense, u_char byte1, u_char load); int SCSI_TestUnitReady(int, RequestSense_T *); -int SCSI_ModeSense(int DeviceFD, char *buffer, u_char size, u_char byte1, u_char byte2); +int SCSI_ModeSense(int DeviceFD, u_char *buffer, u_char size, u_char byte1, u_char byte2); int SCSI_ModeSelect(int DeviceFD, - char *buffer, - unsigned char length, - unsigned char save, - unsigned char mode, - unsigned char lun); + u_char *buffer, + u_char length, + u_char save, + u_char mode, + u_char lun); int SCSI_ReadElementStatus(int DeviceFD, - unsigned char type, - unsigned char lun, - unsigned char VolTag, + u_char type, + u_char lun, + u_char VolTag, int StartAddress, - int NoOfElements, - int DescriptorSize, - char **data); + size_t NoOfElements, + size_t DescriptorSize, + u_char **data); FILE *StatFile; +static int barcode; /* cache the result from the BarCode function */ SC_COM_T SCSICommand[] = { {0x00, @@ -198,7 +197,7 @@ ChangerCMD_T ChangerIO[] = { "HP Auto Loader [C1553A]", GenericMove, GenericElementStatus, - DoNothing, + DoNothing1, GenericFree, GenericEject, GenericClean, @@ -245,10 +244,10 @@ ChangerCMD_T ChangerIO[] = { GenericSenseHandler}, {"EXB-85058HE-0000", "Exabyte Tape [EXB-85058HE-0000]", - DoNothing, - DoNothing, - DoNothing, - DoNothing, + DoNothing3, + DoNothing2, + DoNothing1, + DoNothing0, GenericEject, GenericClean, GenericRewind, @@ -374,10 +373,10 @@ ChangerCMD_T ChangerIO[] = { GenericSenseHandler}, {"DLT8000", "DLT Tape [DLT8000]", - DoNothing, - DoNothing, - DoNothing, - DoNothing, + DoNothing3, + DoNothing2, + DoNothing1, + DoNothing0, DLT4000Eject, GenericClean, GenericRewind, @@ -386,10 +385,10 @@ ChangerCMD_T ChangerIO[] = { GenericSenseHandler}, {"DLT7000", "DLT Tape [DLT7000]", - DoNothing, - DoNothing, - DoNothing, - DoNothing, + DoNothing3, + DoNothing2, + DoNothing1, + DoNothing0, DLT4000Eject, GenericClean, GenericRewind, @@ -398,10 +397,10 @@ ChangerCMD_T ChangerIO[] = { GenericSenseHandler}, {"DLT4000", "DLT Tape [DLT4000]", - DoNothing, - DoNothing, - DoNothing, - DoNothing, + DoNothing3, + DoNothing2, + DoNothing1, + DoNothing0, DLT4000Eject, GenericClean, GenericRewind, @@ -446,10 +445,10 @@ int LibModeSenseValid = 0; /* Set if we did an scussefull MODE SENSE */ char *SlotArgs = 0; /* Pointer to MODE SENSE Pages */ -char *pModePage = NULL; +u_char *pModePage = NULL; EAAPage_T *pEAAPage = NULL; DeviceCapabilitiesPage_T *pDeviceCapabilitiesPage = NULL; -char *pVendorUnique = NULL; +u_char *pVendorUnique = NULL; /* * New way, every element type has its on array @@ -459,10 +458,10 @@ ElementInfo_T *pMTE = NULL; /*Medium Transport Element */ ElementInfo_T *pSTE = NULL; /*Storage Element */ ElementInfo_T *pIEE = NULL; /*Import Export Element */ ElementInfo_T *pDTE = NULL; /*Data Transfer Element */ -int MTE = 0; /*Counter for the above element types */ -int STE = 0; -int IEE = 0; -int DTE = 0; +size_t MTE = 0; /*Counter for the above element types */ +size_t STE = 0; +size_t IEE = 0; +size_t DTE = 0; char *chgscsi_datestamp = NULL; /* Result pointer for tape_rdlabel */ char *chgscsi_label = NULL; /* Result pointer for tape_rdlabel */ @@ -477,7 +476,8 @@ char *chgscsi_result = NULL; /* Needed for the result string of MapBarC * Print the scsi-changer-driver version */ -void ChangerDriverVersion() +void +ChangerDriverVersion(void) { DebugPrint(DEBUG_ERROR, SECTION_INFO, "scsi-changer-driver: %s\n",rcsid); SCSI_OS_Version(); @@ -487,7 +487,8 @@ void ChangerDriverVersion() * Try to generate an template which can be used as an example for the config file * */ -void PrintConf() +void +PrintConf(void) { extern OpenFiles_T *pDev; int count; @@ -581,7 +582,7 @@ void PrintConf() { printf("startuse 0 # Which is the first slot to use\n"); printf(" #\n"); - printf("enduse %d # Which is the last slot to use\n", STE); + printf("enduse " SIZE_T_FMT " # Which is the last slot to use\n", STE); } else { printf("startuse ??? # Which is the first slot to use\n"); printf(" #\n"); @@ -591,7 +592,9 @@ void PrintConf() printf(" # cleaning tape in the last slot\n"); printf(" #\n"); - cwd = getcwd(NULL, 0); + if ((cwd = getcwd(NULL, 0)) == NULL) { + cwd = ""; + } printf("statfile %s/tape0-slot #\n",cwd); printf("cleanfile %s/tape0-clean #\n", cwd); @@ -622,28 +625,33 @@ void PrintConf() * If an tape is loaded unload it and do initialize element status to * get all labels if an bar code reader is installed */ -void Inventory(char *labelfile, int drive, int eject, int start, int stop, int clean) +void +Inventory( + char * labelfile, + int drive, + int eject, + int start, + int stop, + int clean) { extern OpenFiles_T *pDev; - int x; - char *result; /* Used to store the result of MapBarCode */ - int barcode; /* cache the result from the BarCode function */ + size_t x; static int inv_done = 0; /* Inventory function called ?, marker to disable recursion */ MBC_T *pbarcoderes; /* Here we will pass the parameter to MapBarCode and get the result */ + (void)start; /* Quiet unused parameter warning */ + (void)stop; /* Quiet unused parameter warning */ + DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE, "##### START Inventory\n"); - if ((pbarcoderes = malloc(sizeof(MBC_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_MAP_BARCODE,"##### malloc failed (-1)\n"); - return; - } - memset(pbarcoderes, 0 , sizeof(MBC_T)); + pbarcoderes = alloc(SIZEOF(MBC_T)); + memset(pbarcoderes, 0 , SIZEOF(MBC_T)); if (inv_done != 0) { DebugPrint(DEBUG_INFO,SECTION_MAP_BARCODE, "##### STOP inv_done -> %d Inventory\n",inv_done); free(pbarcoderes); return; + /*NOTREACHED*/ } inv_done = 1; barcode = BarCode(INDEX_CHANGER); @@ -661,7 +669,7 @@ void Inventory(char *labelfile, int drive, int eject, int start, int stop, int c { if (eject) { - eject_tape("", eject); + (void)eject_tape("", eject); } (void)unload(INDEX_TAPE, 0, 0); } @@ -670,7 +678,7 @@ void Inventory(char *labelfile, int drive, int eject, int start, int stop, int c for (x = 0; x < STE; x++) { - if (x == clean) + if (x == (size_t)clean) { continue; } @@ -692,16 +700,18 @@ void Inventory(char *labelfile, int drive, int eject, int start, int stop, int c SCSI_CloseDevice(INDEX_TAPE); - if ((result = (char *)tape_rdlabel(pDev[INDEX_TAPE].dev, &chgscsi_datestamp, &chgscsi_label)) == NULL) + if ((chgscsi_result = (char *)tape_rdlabel(pDev[INDEX_TAPE].dev, &chgscsi_datestamp, &chgscsi_label)) == NULL) { pbarcoderes->action = UPDATE_SLOT; - strcpy(pbarcoderes->data.voltag, chgscsi_label); + strncpy(pbarcoderes->data.voltag, chgscsi_label, + SIZEOF(pbarcoderes->data.voltag)); pbarcoderes->data.slot = x; pbarcoderes->data.from = 0; pbarcoderes->data.LoadCount = 1; if (BarCode(INDEX_CHANGER) == 1) { - strcpy(pbarcoderes->data.barcode, pDTE[drive].VolTag); + strncpy(pbarcoderes->data.barcode, pDTE[drive].VolTag, + SIZEOF(pbarcoderes->data.barcode)); MapBarCode(labelfile, pbarcoderes); } else { MapBarCode(labelfile, pbarcoderes); @@ -712,7 +722,7 @@ void Inventory(char *labelfile, int drive, int eject, int start, int stop, int c if (eject) { - eject_tape("", eject); + (void)eject_tape("", eject); } (void)unload(INDEX_TAPE, drive, x); @@ -725,7 +735,10 @@ void Inventory(char *labelfile, int drive, int eject, int start, int stop, int c * Check if the slot ist empty * slot -> slot number to check */ -int isempty(int fd, int slot) +int +isempty( + int fd, + int slot) { extern OpenFiles_T *pDev; DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### START isempty\n"); @@ -736,6 +749,7 @@ int isempty(int fd, int slot) { DebugPrint(DEBUG_ERROR,SECTION_TAPE,"##### STOP isempty [-1]\n"); return(-1); + /*NOTREACHED*/ } } @@ -743,12 +757,15 @@ int isempty(int fd, int slot) { DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### STOP isempty [1]\n"); return(1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### STOP isempty [0]\n"); return(0); } -int get_clean_state(char *tapedev) +int +get_clean_state( + char *tapedev) { extern OpenFiles_T *pDev; /* Return 1 if cleaning is needed */ @@ -760,6 +777,7 @@ int get_clean_state(char *tapedev) { DebugPrint(DEBUG_ERROR,SECTION_TAPE,"##### STOP get_clean_state [-1]\n"); return(-1); + /*NOTREACHED*/ } ret=pDev[INDEX_TAPECTL].functions->function_clean(tapedev); DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### STOP get_clean_state [%d]\n", ret); @@ -772,19 +790,22 @@ int get_clean_state(char *tapedev) * Type describes if we should force the SCSI eject if available * normal eject is done with the ioctl */ -int eject_tape(char *tapedev, int type) - /* This function ejects the tape from the drive */ +/* This function ejects the tape from the drive */ + +int +eject_tape( + char * tapedev, + int type) { extern OpenFiles_T *pDev; - int ret = 0; - extern changer_t chg; /* Needed for the infos about emubarcode and labelfile */ + int ret; DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### START eject_tape\n"); /* * Try to read the label */ - if (pDev[INDEX_TAPE].avail == 1 && (chg.emubarcode == 1 || BarCode(INDEX_CHANGER))) + if (pDev[INDEX_TAPE].avail == 1 && (changer->emubarcode == 1 || BarCode(INDEX_CHANGER))) { if (pDev[INDEX_TAPECTL].SCSI == 1 && pDev[INDEX_TAPECTL].avail) { @@ -806,6 +827,7 @@ int eject_tape(char *tapedev, int type) ret=pDev[INDEX_TAPECTL].functions->function_eject(tapedev, type); DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### STOP (SCSI)eject_tape [%d]\n", ret); return(ret); + /*NOTREACHED*/ } if (pDev[INDEX_TAPE].avail == 1) @@ -813,6 +835,7 @@ int eject_tape(char *tapedev, int type) ret=Tape_Ioctl(INDEX_TAPE, IOCTL_EJECT); DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### STOP (ioctl)eject_tape [%d]\n", ret); return(ret); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO,SECTION_TAPE,"##### STOP eject_tape [-1]\n"); @@ -821,11 +844,15 @@ int eject_tape(char *tapedev, int type) /* Find an empty slot, starting at start, ending at start+count */ -int find_empty(int fd, int start, int count) +int +find_empty( + int fd, + int start, + int count) { extern OpenFiles_T *pDev; - int x; - int end; + size_t x; + size_t end; DebugPrint(DEBUG_INFO,SECTION_ELEMENT,"###### START find_empty\n"); @@ -833,8 +860,10 @@ int find_empty(int fd, int start, int count) { if ( pDev[fd].functions->function_status(fd , 1) != 0) { - DebugPrint(DEBUG_ERROR,SECTION_ELEMENT,"###### END find_empty [%d]\n", -1); - return(-1); + DebugPrint(DEBUG_ERROR,SECTION_ELEMENT, + "###### END find_empty [-1]\n"); + return((ssize_t)-1); + /*NOTREACHED*/ } } @@ -850,18 +879,23 @@ int find_empty(int fd, int start, int count) end = STE; } - DebugPrint(DEBUG_INFO,SECTION_ELEMENT,"start at %d, end at %d\n", start, end); + DebugPrint(DEBUG_INFO, SECTION_ELEMENT, + "start at " SIZE_T_FMT ", end at " SIZE_T_FMT "\n", + (SIZE_T_FMT_TYPE)start, + (SIZE_T_FMT_TYPE)end); for (x = start; x < end; x++) { if (pSTE[x].status == 'E') { - DebugPrint(DEBUG_INFO,SECTION_ELEMENT,"###### END find_empty [%d]\n", x); - return(x); + DebugPrint(DEBUG_INFO,SECTION_ELEMENT, + "###### END find_empty [" SIZE_T_FMT "]\n", x); + return((ssize_t)x); + /*NOTREACHED*/ } } - DebugPrint(DEBUG_ERROR,SECTION_ELEMENT,"###### END find_empty [%d]\n", -1); - return(-1); + DebugPrint(DEBUG_ERROR,SECTION_ELEMENT,"###### END find_empty [-1]\n"); + return((ssize_t)-1); } /* @@ -872,7 +906,10 @@ int find_empty(int fd, int start, int count) * 0 -> drive is empty * 1 -> drive is loaded */ -int drive_loaded(int fd, int drivenum) +int +drive_loaded( + int fd, + int drivenum) { extern OpenFiles_T *pDev; @@ -886,16 +923,17 @@ int drive_loaded(int fd, int drivenum) { DebugPrint(DEBUG_ERROR,SECTION_TAPE,"Fatal error\n"); return(-1); + /*NOTREACHED*/ } } if (pDTE[drivenum].status == 'E') { DebugPrint(DEBUG_INFO,SECTION_TAPE,"###### STOP drive_loaded (empty)\n"); return(0); - } else { - DebugPrint(DEBUG_INFO,SECTION_TAPE,"###### STOP drive_loaded (not empty)\n"); - return(1); + /*NOTREACHED*/ } + DebugPrint(DEBUG_INFO,SECTION_TAPE,"###### STOP drive_loaded (not empty)\n"); + return(1); } @@ -906,22 +944,20 @@ int drive_loaded(int fd, int drivenum) * TODO: * Check if the MTE is empty */ -int unload(int fd, int drive, int slot) +int +unload( + int fd, + int drive, + int slot) { extern OpenFiles_T *pDev; - int ret; - extern changer_t chg; /* Needed for the infos about emubarcode and labelfile */ extern int do_inventory; MBC_T *pbarcoderes; DebugPrint(DEBUG_INFO, SECTION_TAPE,"###### START unload\n"); DebugPrint(DEBUG_INFO, SECTION_TAPE,"%-20s : fd %d, slot %d, drive %d \n", "unload", fd, slot, drive); - if ((pbarcoderes = malloc(sizeof(MBC_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### malloc failed (-1)\n"); - return(-1); - } - memset(pbarcoderes, 0, sizeof(MBC_T)); + pbarcoderes = alloc(SIZEOF(MBC_T)); + memset(pbarcoderes, 0, SIZEOF(MBC_T)); /* * If the Element Status is not valid try to @@ -935,6 +971,7 @@ int unload(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### STOP unload (-1)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } } @@ -954,6 +991,7 @@ int unload(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### STOP unload (-1)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } /* @@ -968,6 +1006,7 @@ int unload(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "unload: Element Status not valid, can't find an empty slot\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } slot = find_empty(fd, 0, 0); @@ -976,6 +1015,7 @@ int unload(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "unload: No Empty slot found\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_TAPE,"unload : found empty one, try to unload to slot %d\n", slot); } @@ -986,9 +1026,9 @@ int unload(int fd, int drive, int slot) * If eject is not set we must read the label info */ - if (chg.eject == 0) + if (changer->eject == 0) { - if (pDev[INDEX_TAPE].avail == 1 && (chg.emubarcode == 1 || BarCode(INDEX_CHANGER))) + if (pDev[INDEX_TAPE].avail == 1 && (changer->emubarcode == 1 || BarCode(INDEX_CHANGER))) { if (pDev[INDEX_TAPECTL].SCSI == 1 && pDev[INDEX_TAPECTL].avail) { @@ -1009,7 +1049,14 @@ int unload(int fd, int drive, int slot) /* * Do the unload/move */ - ret = pDev[INDEX_CHANGER].functions->function_move(INDEX_CHANGER , pDTE[drive].address, pSTE[slot].address); + if (pDev[INDEX_CHANGER].functions->function_move(INDEX_CHANGER, + pDTE[drive].address, pSTE[slot].address) != 0) { + DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### STOP unload (-1 move failed)\n"); + free(pbarcoderes); + return(-1); + /*NOTREACHED*/ + } + /* * Update the Status @@ -1019,6 +1066,7 @@ int unload(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### STOP unload (-1 update status failed)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } /* @@ -1026,14 +1074,14 @@ int unload(int fd, int drive, int slot) * if no update the vol/label mapping * If chgscsi_label is NULL don't do it */ - if (chgscsi_result == NULL && chgscsi_label != NULL && chg.labelfile != NULL) + if (chgscsi_result == NULL && chgscsi_label != NULL && changer->labelfile != NULL) { /* * OK this is only needed if we have emubarcode set * There we need an exact inventory to get the search function working * and returning correct results */ - if (BarCode(INDEX_CHANGER) == 0 && chg.emubarcode == 1) + if (BarCode(INDEX_CHANGER) == 0 && changer->emubarcode == 1) { /* * We got something, update the db @@ -1041,14 +1089,16 @@ int unload(int fd, int drive, int slot) * to where we placed the tape, if no force an inventory */ pbarcoderes->action = FIND_SLOT; - strcpy(pbarcoderes->data.voltag, chgscsi_label); - strcpy(pbarcoderes->data.barcode, pSTE[slot].VolTag ); + strncpy(pbarcoderes->data.voltag, chgscsi_label, + SIZEOF(pbarcoderes->data.voltag)); + strncpy(pbarcoderes->data.barcode, pSTE[slot].VolTag, + SIZEOF(pbarcoderes->data.barcode)); pbarcoderes->data.slot = 0; pbarcoderes->data.from = 0; pbarcoderes->data.LoadCount = 0; - if ( MapBarCode(chg.labelfile, pbarcoderes) == 0) /* Nothing known about this, do an Inventory */ + if ( MapBarCode(changer->labelfile, pbarcoderes) == 0) /* Nothing known about this, do an Inventory */ { do_inventory = 1; } else { @@ -1077,9 +1127,12 @@ int unload(int fd, int drive, int slot) * return -> 0 = success * !0 = failure */ -int load(int fd, int drive, int slot) +int +load( + int fd, + int drive, + int slot) { - extern changer_t chg; /* Needed for the infos about emubarcode and labelfile */ char *result = NULL; /* Needed for the result of tape_rdlabel */ int ret; extern OpenFiles_T *pDev; @@ -1088,12 +1141,8 @@ int load(int fd, int drive, int slot) DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"###### START load\n"); DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"%-20s : fd %d, drive %d, slot %d \n", "load", fd, drive, slot); - if ((pbarcoderes = malloc(sizeof(MBC_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"##### malloc failed (-1)\n"); - return(-1); - } - memset(pbarcoderes, 0 , sizeof(MBC_T)); + pbarcoderes = alloc(SIZEOF(MBC_T)); + memset(pbarcoderes, 0 , SIZEOF(MBC_T)); if (ElementStatusValid == 0) { @@ -1103,6 +1152,7 @@ int load(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"##### STOP load (-1 update status failed)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } } @@ -1112,19 +1162,21 @@ int load(int fd, int drive, int slot) * is ge than the value we got from the ModeSense fail with an return value * of 2 */ - if (slot >= STE) + if ((size_t)slot >= STE) { DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"load : slot %d ge STE %d\n",slot, STE); ChgExit("load", "slot >= STE", FATAL); + /*NOTREACHED*/ } /* * And the same for the tape drives */ - if (drive >= DTE) + if (drive >= (int)DTE) { DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"load : drive %d ge DTE %d\n",drive, DTE); ChgExit("load", "drive >= DTE", FATAL); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"load : load drive %d[%d] slot %d[%d]\n",drive, @@ -1138,6 +1190,7 @@ int load(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"##### STOP load (-1 update status failed)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } if (pSTE[slot].status == 'E') @@ -1146,6 +1199,7 @@ int load(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"##### STOP load (-1 update status failed)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } ret = pDev[fd].functions->function_move(fd, pSTE[slot].address, pDTE[drive].address); @@ -1158,13 +1212,14 @@ int load(int fd, int drive, int slot) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"##### STOP load (-1 update status failed)\n"); free(pbarcoderes); return(-1); + /*NOTREACHED*/ } /* * Try to read the label * and update the label/slot database */ - if (pDev[INDEX_TAPE].avail == 1 && (chg.emubarcode == 1 || BarCode(INDEX_CHANGER))) + if (pDev[INDEX_TAPE].avail == 1 && (changer->emubarcode == 1 || BarCode(INDEX_CHANGER))) { if (pDev[INDEX_TAPECTL].SCSI == 1 && pDev[INDEX_TAPECTL].avail) { @@ -1185,14 +1240,15 @@ int load(int fd, int drive, int slot) * Did we get an error from tape_rdlabel * if no update the vol/label mapping */ - if (result == NULL && chg.labelfile != NULL && chgscsi_label != NULL ) + if (result == NULL && changer->labelfile != NULL && chgscsi_label != NULL ) { /* * We got something, update the db * but before check if the db has as entry the slot * to where we placed the tape, if no force an inventory */ - strcpy(pbarcoderes->data.voltag, chgscsi_label); + strncpy(pbarcoderes->data.voltag, chgscsi_label, + SIZEOF(pbarcoderes->data.voltag)); pbarcoderes->data.slot = 0; pbarcoderes->data.from = 0; pbarcoderes->data.LoadCount = 0; @@ -1204,19 +1260,20 @@ int load(int fd, int drive, int slot) * info in the DB is up to date, if no we set the do_inventory flag */ - if (BarCode(INDEX_CHANGER) == 1 && chg.emubarcode == 0) + if (BarCode(INDEX_CHANGER) == 1 && changer->emubarcode == 0) { pbarcoderes->action = UPDATE_SLOT; - strcpy(pbarcoderes->data.barcode, pDTE[drive].VolTag); + strncpy(pbarcoderes->data.barcode, pDTE[drive].VolTag, + SIZEOF(pbarcoderes->data.barcode)); pbarcoderes->data.LoadCount = 1; pbarcoderes->data.slot = slot; - MapBarCode(chg.labelfile, pbarcoderes); + MapBarCode(changer->labelfile, pbarcoderes); } - if (BarCode(INDEX_CHANGER) == 0 && chg.emubarcode == 1) + if (BarCode(INDEX_CHANGER) == 0 && changer->emubarcode == 1) { pbarcoderes->action = FIND_SLOT; - if (MapBarCode(chg.labelfile, pbarcoderes) == 0) /* Nothing found, do an inventory */ + if (MapBarCode(changer->labelfile, pbarcoderes) == 0) /* Nothing found, do an inventory */ { do_inventory = 1; } else { /* We got something, is it correct ? */ @@ -1224,23 +1281,26 @@ int load(int fd, int drive, int slot) { DebugPrint(DEBUG_ERROR, SECTION_TAPE,"Slot DB out of sync, slot %d != map %d",slot, pbarcoderes->data.slot); ChgExit("Load", "Label DB out of sync", FATAL); + /*NOTREACHED*/ } else { /* OK, so increment the load count */ pbarcoderes->action = UPDATE_SLOT; pbarcoderes->data.LoadCount = 1; pbarcoderes->data.slot = slot; - MapBarCode(chg.labelfile, pbarcoderes); + MapBarCode(changer->labelfile, pbarcoderes); } } } - if (BarCode(INDEX_CHANGER) == 1 && chg.emubarcode == 1) + if (BarCode(INDEX_CHANGER) == 1 && changer->emubarcode == 1) { ChgExit("Load", "BarCode == 1 and emubarcode == 1", FATAL); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"##### STOP load (%d)\n",ret); free(pbarcoderes); return(ret); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"##### STOP load (%d)\n",ret); free(pbarcoderes); @@ -1252,7 +1312,9 @@ int load(int fd, int drive, int slot) * fd -> pointer to the internal devie structure pDev * return -> Number of slots */ -int get_slot_count(int fd) +int +get_slot_count( + int fd) { extern OpenFiles_T *pDev; @@ -1263,13 +1325,14 @@ int get_slot_count(int fd) { pDev[fd].functions->function_status(fd, 1); } - DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"##### STOP get_slot_count (%d)\n",STE); - return(STE); + DebugPrint(DEBUG_INFO, SECTION_ELEMENT, + "##### STOP get_slot_count (" SIZE_T_FMT ")\n", + (SIZE_T_FMT_TYPE)STE); + return((ssize_t)STE); /* * return the number of slots in the robot * to the caller */ - } @@ -1278,7 +1341,9 @@ int get_slot_count(int fd) * fd -> pointer to the internal devie structure pDev * return -> -1 on failure */ -int get_drive_count(int fd) +int +get_drive_count( + int fd) { extern OpenFiles_T *pDev; @@ -1286,7 +1351,6 @@ int get_drive_count(int fd) DebugPrint(DEBUG_INFO, SECTION_SCSI,"###### START get_drive_count\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI,"%-20s : fd %d\n", "get_drive_count", fd); - if (ElementStatusValid == 0) { if ( pDev[fd].functions->function_status(fd, 1) != 0) @@ -1294,10 +1358,13 @@ int get_drive_count(int fd) DebugPrint(DEBUG_ERROR, SECTION_SCSI, "Error getting drive count\n"); DebugPrint(DEBUG_ERROR, SECTION_SCSI, "##### STOP get_drive_count (-1)\n"); return(-1); + /*NOTREACHED*/ } } - DebugPrint(DEBUG_INFO, SECTION_SCSI,"###### STOP get_drive_count (%d drives)\n",DTE); - return(DTE); + DebugPrint(DEBUG_INFO, SECTION_SCSI, + "###### STOP get_drive_count (" SIZE_T_FMT " drives)\n", + (SIZE_T_FMT_TYPE)DTE); + return((ssize_t)DTE); } /* @@ -1309,12 +1376,22 @@ int get_drive_count(int fd) * The OS has to decide if it is an SCSI Commands capable device */ -int OpenDevice(int ip , char *DeviceName, char *ConfigName, char *ident) +int +OpenDevice( + int ip, + char * DeviceName, + char * ConfigName, + char * ident) { extern OpenFiles_T *pDev; char tmpstr[15]; ChangerCMD_T *p = (ChangerCMD_T *)&ChangerIO; + if (!ConfigName) + return 1; + if (!DeviceName) + return 1; + DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START OpenDevice\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI,"OpenDevice : %s\n", DeviceName); @@ -1334,10 +1411,12 @@ int OpenDevice(int ip , char *DeviceName, char *ConfigName, char *ident) DebugPrint(DEBUG_INFO, SECTION_SCSI,"override using ident = %s, type = %s\n",p->ident, p->type); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP OpenDevice\n"); return(1); + /*NOTREACHED*/ } p++; } ChgExit("OpenDevice", "ident not found", FATAL); + /*NOTREACHED*/ } else { while(p->ident != NULL) { @@ -1347,6 +1426,7 @@ int OpenDevice(int ip , char *DeviceName, char *ConfigName, char *ident) DebugPrint(DEBUG_INFO, SECTION_SCSI,"using ident = %s, type = %s\n",p->ident, p->type); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP OpenDevice\n"); return(1); + /*NOTREACHED*/ } p++; } @@ -1355,7 +1435,7 @@ int OpenDevice(int ip , char *DeviceName, char *ConfigName, char *ident) /* divide generic in generic_type, where type is the */ /* num returned by the inquiry command */ p = (ChangerCMD_T *)&ChangerIO; - sprintf(&tmpstr[0],"%s_%s","generic",pDev[0].type); + snprintf(&tmpstr[0], SIZEOF(tmpstr), "%s_%s","generic",pDev[0].type); while(p->ident != NULL) { if (strcmp(tmpstr, p->ident) == 0) @@ -1364,6 +1444,7 @@ int OpenDevice(int ip , char *DeviceName, char *ConfigName, char *ident) DebugPrint(DEBUG_INFO, SECTION_SCSI,"using ident = %s, type = %s\n",p->ident, p->type); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP OpenDevice\n"); return(1); + /*NOTREACHED*/ } p++; } @@ -1379,9 +1460,11 @@ int OpenDevice(int ip , char *DeviceName, char *ConfigName, char *ident) * This functions checks if the library has an barcode reader. * fd -> pointer to the internal devie structure pDev */ -int BarCode(int fd) +int +BarCode( + int fd) { - int ret = 0; + int ret; extern OpenFiles_T *pDev; DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### START BarCode\n"); @@ -1402,12 +1485,15 @@ int BarCode(int fd) * wait -> time to wait for the ready status * */ -int Tape_Ready(int fd, int wait_time) +int +Tape_Ready( + int fd, + time_t wait_time) { extern OpenFiles_T *pDev; - int true = 1; + int done; int ret; - int cnt = 0; + time_t cnt = 0; RequestSense_T *pRequestSense; DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### START Tape_Ready\n"); @@ -1453,6 +1539,7 @@ int Tape_Ready(int fd, int wait_time) DebugPrint(DEBUG_INFO, SECTION_TAPE,"Tape_Ready : Ready after %d seconds\n",cnt); DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP Tape_Ready\n"); return(0); + /*NOTREACHED*/ } cnt++; sleep(1); @@ -1462,21 +1549,17 @@ int Tape_Ready(int fd, int wait_time) DebugPrint(DEBUG_INFO, SECTION_TAPE,"Tape_Ready : not ready, stop after %d seconds\n",cnt); DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP Tape_Ready\n"); return(0); + /*NOTREACHED*/ - } else { - DebugPrint(DEBUG_INFO, SECTION_TAPE,"Tape_Ready : no ioctl interface, will sleep for %d seconds\n", wait_time); - sleep(wait_time); - DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP Tape_Ready\n"); - return(0); } + DebugPrint(DEBUG_INFO, SECTION_TAPE,"Tape_Ready : no ioctl interface, will sleep for %d seconds\n", wait_time); + sleep(wait_time); + DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP Tape_Ready\n"); + return(0); + /*NOTREACHED*/ } - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_INFO, SECTION_TAPE,"Tape_Ready : malloc failed\n"); - DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP Tape_Ready\n"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); /* * Ignore errors at this point @@ -1487,39 +1570,40 @@ int Tape_Ready(int fd, int wait_time) * Wait until we get an ready condition */ - while (true && cnt < wait_time) + done = 0; + while (!done && (cnt < wait_time)) { ret = SCSI_TestUnitReady(fd, pRequestSense ); switch (ret) { case SCSI_OK: - true = 0; + done = 1; break; case SCSI_SENSE: - switch (SenseHandler(fd, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(fd, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeReady (TestUnitReady) SENSE_NO\n"); - true=0; + done = 1; break; case SENSE_TAPE_NOT_ONLINE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeReady (TestUnitReady) SENSE_TAPE_NOT_ONLINE\n"); break; case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeReady (TestUnitReady) SENSE_IGNORE\n"); - true = 0; + done = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"TapeReady (TestUnitReady) SENSE_ABORT\n"); - free(pRequestSense); + amfree(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeReady (TestUnitReady) SENSE_RETRY\n"); break; default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeReady (TestUnitReady) default (SENSE)\n"); - true=0; + done = 1; break; } break; @@ -1527,7 +1611,7 @@ int Tape_Ready(int fd, int wait_time) DebugPrint(DEBUG_ERROR, SECTION_SCSI,"TapeReady (TestUnitReady) SCSI_ERROR\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeReady (TestUnitReady) SCSI_BUSY\n"); break; @@ -1542,14 +1626,17 @@ int Tape_Ready(int fd, int wait_time) cnt++; } + amfree(pRequestSense); DebugPrint(DEBUG_INFO, SECTION_TAPE,"Tape_Ready after %d sec\n", cnt); DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP Tape_Ready\n"); - free(pRequestSense); return(0); } -int DecodeSCSI(CDB_T CDB, char *string) +int +DecodeSCSI( + CDB_T CDB, + char * string) { SC_COM_T *pSCSICommand; int x; @@ -1569,6 +1656,7 @@ int DecodeSCSI(CDB_T CDB, char *string) DebugPrint(DEBUG_INFO, SECTION_SCSI,"\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP DecodeSCSI\n"); return(0); + /*NOTREACHED*/ } pSCSICommand++; } @@ -1577,11 +1665,19 @@ int DecodeSCSI(CDB_T CDB, char *string) return(0); } -int DecodeModeSense(char *buffer, int offset, char *pstring, char block, FILE *out) +int +DecodeModeSense( + u_char * buffer, + size_t offset, + char * pstring, + char block, + FILE * out) { ReadWriteErrorRecoveryPage_T *prp; DisconnectReconnectPage_T *pdrp; - int length = (unsigned char)*buffer - 4 - offset; + size_t length = (size_t)buffer[0] - 4 - offset; + + (void)pstring; /* Quiet unused parameter warning */ DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START DecodeModeSense\n"); @@ -1598,7 +1694,7 @@ int DecodeModeSense(char *buffer, int offset, char *pstring, char block, FILE *o if (block) /* Do we have an block descriptor page ?*/ { if (out != NULL) - fprintf(out, "DecodeModeSense : Density Code %x\n", buffer[0]); + fprintf(out, "DecodeModeSense : Density Code %x\n", (unsigned)buffer[0]); buffer++; if (out != NULL) @@ -1731,18 +1827,24 @@ int DecodeModeSense(char *buffer, int offset, char *pstring, char block, FILE *o /* EAAPage = NULL; */ /* DeviceCapabilitiesPage = NULL; */ return(-1); + /*NOTREACHED*/ } - length = length - *buffer - 2; - buffer = buffer + *buffer + 1; + length = length - (size_t)*buffer - 2; + buffer = buffer + (size_t)*buffer + 1; } return(0); } -int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out) +int +DecodeSense( + RequestSense_T * sense, + char * pstring, + FILE * out) { if (out == NULL) { return(0); + /*NOTREACHED*/ } fprintf(out,"##### START DecodeSense\n"); fprintf(out,"%sSense Keys\n", pstring); @@ -1810,7 +1912,11 @@ int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out) return(0); } -int DecodeExtSense(ExtendedRequestSense_T *sense, char *pstring, FILE *out) +int +DecodeExtSense( + ExtendedRequestSense_T * sense, + char * pstring, + FILE * out) { ExtendedRequestSense_T *p; @@ -1823,7 +1929,7 @@ int DecodeExtSense(ExtendedRequestSense_T *sense, char *pstring, FILE *out) fprintf(out,"\tLog Parameter Code %02X\n", sense->LogParameterCode); fprintf(out,"\tUnderrun/Overrun Counter %02X\n", sense->UnderrunOverrunCounter); fprintf(out,"\tRead/Write Error Counter %d\n", V3((char *)sense->ReadWriteDataErrorCounter)); - if (sense->AdditionalSenseLength > sizeof(RequestSense_T)) + if (sense->AdditionalSenseLength > (u_char)sizeof(RequestSense_T)) { if (sense->PF) fprintf(out,"\tPower Fail\n"); @@ -1877,7 +1983,9 @@ int DecodeExtSense(ExtendedRequestSense_T *sense, char *pstring, FILE *out) return(0); } -int PrintInquiry(SCSIInquiry_T *SCSIInquiry) +int +PrintInquiry( + SCSIInquiry_T * SCSIInquiry) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START PrintInquiry\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI,"%-15s %x\n", "qualifier", SCSIInquiry->qualifier); @@ -1896,25 +2004,66 @@ int PrintInquiry(SCSIInquiry_T *SCSIInquiry) } -int DoNothing() +int +DoNothing0(void) +{ + dbprintf(("##### START DoNothing\n")); + return(0); +} + +int +DoNothing1( + int unused1) +{ + (void)unused1; /* Quiet unused parameter warning */ + + dbprintf(("##### START DoNothing\n")); + return(0); +} + +int +DoNothing2( + int unused1, + int unused2) +{ + (void)unused1; /* Quiet unused parameter warning */ + (void)unused2; /* Quiet unused parameter warning */ + + dbprintf(("##### START DoNothing\n")); + return(0); +} + +int +DoNothing3( + int unused1, + int unused2, + int unused3) { + (void)unused1; /* Quiet unused parameter warning */ + (void)unused2; /* Quiet unused parameter warning */ + (void)unused3; /* Quiet unused parameter warning */ + dbprintf(("##### START DoNothing\n")); return(0); } -int GenericFree() +int +GenericFree(void) { dbprintf(("##### START GenericFree\n")); return(0); } -int GenericSearch() +int +GenericSearch(void) { dbprintf(("##### START GenericSearch\n")); return(0); } -int TreeFrogBarCode(int DeviceFD) +int +TreeFrogBarCode( + int DeviceFD) { extern OpenFiles_T *pDev; @@ -1923,11 +2072,7 @@ int TreeFrogBarCode(int DeviceFD) dbprintf(("##### START TreeFrogBarCode\n")); if (pModePage == NULL) { - if ((pModePage = malloc(0xff)) == NULL) - { - dbprintf(("TreeFrogBarCode : malloc failed\n")); - return(-1); - } + pModePage = alloc(0xff); } if (SCSI_ModeSense(DeviceFD, pModePage, 0xff, 0x0, 0x3f) == 0) @@ -1938,33 +2083,34 @@ int TreeFrogBarCode(int DeviceFD) { dbprintf(("TreeFrogBarCode : no pVendorUnique\n")); return(0); + /*NOTREACHED*/ } pVendor = ( ModePageTreeFrogVendorUnique_T *)pVendorUnique; dbprintf(("TreeFrogBarCode : EBARCO %d\n", pVendor->EBARCO)); dbprintf(("TreeFrogCheckSum : CHKSUM %d\n", pVendor->CHKSUM)); - dump_hex((char *)pDev[INDEX_CHANGER].inquiry, INQUIRY_SIZE, DEBUG_INFO, SECTION_ELEMENT); + dump_hex((u_char *)pDev[INDEX_CHANGER].inquiry, INQUIRY_SIZE, DEBUG_INFO, SECTION_ELEMENT); return(pVendor->EBARCO); + /*NOTREACHED*/ } return(0); } -int EXB_BarCode(int DeviceFD) +int +EXB_BarCode( + int DeviceFD) { extern OpenFiles_T *pDev; ModePageEXB120VendorUnique_T *pVendor; - ModePageEXB120VendorUnique_T *pVendorWork = NULL; + ModePageEXB120VendorUnique_T *pVendorWork; DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### START EXB_BarCode\n"); if (pModePage == NULL && LibModeSenseValid == 0) { - if ((pModePage = malloc(0xff)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_BARCODE,"EXB_BarCode : malloc failed\n"); - return(-1); - } + pModePage = alloc(0xff); + if (SCSI_ModeSense(DeviceFD, pModePage, 0xff, 0x8, 0x3f) == 0) { DecodeModeSense(pModePage, 0, "EXB_BarCode :", 0, debug_file); @@ -1980,6 +2126,7 @@ int EXB_BarCode(int DeviceFD) { DebugPrint(DEBUG_INFO, SECTION_BARCODE,"EXB_BarCode : no pVendorUnique\n"); return(0); + /*NOTREACHED*/ } pVendor = ( ModePageEXB120VendorUnique_T *)pVendorUnique; @@ -1987,17 +2134,13 @@ int EXB_BarCode(int DeviceFD) DebugPrint(DEBUG_INFO, SECTION_BARCODE,"EXB_BarCode : PS %d\n", pVendor->PS); if (pVendor->NBL == 1 && pVendor->PS == 1 ) { - if ((pVendorWork = ( ModePageEXB120VendorUnique_T *)malloc(pVendor->ParameterListLength + 2)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_BARCODE,"EXB_BarCode : malloc failed\n"); - return(-1); - } + pVendorWork = alloc((size_t)pVendor->ParameterListLength + 2); DebugPrint(DEBUG_INFO, SECTION_BARCODE,"EXB_BarCode : setting NBL to 1\n"); - memcpy(pVendorWork, pVendor, pVendor->ParameterListLength + 2); + memcpy(pVendorWork, pVendor, (size_t)pVendor->ParameterListLength + 2); pVendorWork->NBL = 0; pVendorWork->PS = 0; pVendorWork->RSVD0 = 0; - if (SCSI_ModeSelect(DeviceFD, (char *)pVendorWork, pVendorWork->ParameterListLength + 2, 0, 1, 0) == 0) + if (SCSI_ModeSelect(DeviceFD, (u_char *)pVendorWork, (u_char)(pVendorWork->ParameterListLength + 2), 0, 1, 0) == 0) { DebugPrint(DEBUG_INFO, SECTION_BARCODE,"EXB_BarCode : SCSI_ModeSelect OK\n"); /* Hack !!!!!! @@ -2010,38 +2153,51 @@ int EXB_BarCode(int DeviceFD) } else { DebugPrint(DEBUG_INFO, SECTION_BARCODE,"EXB_BarCode : SCSI_ModeSelect failed\n"); } - amfree(pVendorWork); + amfree(pVendorWork); } - dump_hex((char *)pDev[INDEX_CHANGER].inquiry, INQUIRY_SIZE, DEBUG_INFO, SECTION_BARCODE); + dump_hex((u_char *)pDev[INDEX_CHANGER].inquiry, INQUIRY_SIZE, DEBUG_INFO, SECTION_BARCODE); DebugPrint(DEBUG_INFO, SECTION_BARCODE,"EXB_BarCode : vendor_specific[19] %x\n", pDev[INDEX_CHANGER].inquiry->vendor_specific[19]); } - return(1); } -int NoBarCode(int DeviceFD) +int +NoBarCode( + int DeviceFD) { + (void)DeviceFD; /* Quiet unused parameter warning */ + DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### START NoBarCode\n"); DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### STOP NoBarCode\n"); return(0); } -int GenericBarCode(int DeviceFD) +int +GenericBarCode( + int DeviceFD) { - extern changer_t chg; + (void)DeviceFD; /* Quiet unused parameter warning */ DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### START GenericBarCode\n"); - if ( chg.havebarcode >= 1) + if ( changer->havebarcode >= 1) { - DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### STOP GenericBarCode (havebarcode) => %d\n",chg.havebarcode); + DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### STOP GenericBarCode (havebarcode) => %d\n",changer->havebarcode); return(1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_BARCODE,"##### STOP GenericBarCode => 0\n"); return(0); } -int SenseHandler(int DeviceFD, unsigned char flag, unsigned char SenseKey, unsigned char AdditionalSenseCode, unsigned char AdditionalSenseCodeQualifier, char *buffer) +int +SenseHandler( + int DeviceFD, + u_char flag, + u_char SenseKey, + u_char AdditionalSenseCode, + u_char AdditionalSenseCodeQualifier, + RequestSense_T * buffer) { extern OpenFiles_T *pDev; int ret = 0; @@ -2069,13 +2225,14 @@ int SenseHandler(int DeviceFD, unsigned char flag, unsigned char SenseKey, unsig * if there are more than one * Implement the SCSI path if available */ -int TapeStatus() +int +TapeStatus(void) { extern OpenFiles_T *pDev; int ret; - int true = 1; - int cnt = 0; - RequestSense_T *pRequestSense = NULL; + int done; + int cnt; + RequestSense_T *pRequestSense; DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### START TapeStatus\n"); @@ -2086,13 +2243,10 @@ int TapeStatus() */ if (pDev[INDEX_TAPECTL].SCSI == 1) { - if ((pRequestSense = malloc(sizeof(RequestSense_T))) == NULL) - { - dbprintf(("%-20s : malloc failed\n","TapeStatus")); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); + memset(pRequestSense, 0, SIZEOF(RequestSense_T)); - while (true && cnt < 60) + for (done = 0, cnt = 0; !done && (cnt < 60); cnt++) { ret = SCSI_TestUnitReady(INDEX_TAPECTL, pRequestSense); DebugPrint(DEBUG_INFO, SECTION_SCSI, "TapeStatus TestUnitReady ret %d\n",ret); @@ -2100,49 +2254,58 @@ int TapeStatus() { case SCSI_OK: case SCSI_SENSE: - switch (SenseHandler(INDEX_TAPECTL, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(INDEX_TAPECTL, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeStatus (TestUnitReady) SENSE_NO\n"); pDTE[0].status = 'F'; DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### FULL\n"); - true = 0; + done = 1; break; + case SENSE_TAPE_NOT_ONLINE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeStatus (TestUnitReady) SENSE_TAPE_NOT_ONLINE\n"); pDTE[0].status = 'E'; DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### EMPTY\n"); - true = 0; + done = 1; break; + case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"TapeStatus (TestUnitReady) SENSE_ABORT\n"); - true = 0; + done = 1; break; + case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeStatus (TestUnitReady) SENSE_RETRY\n"); break; + default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeStatus (TestUnitReady) default (SENSE)\n"); break; } break; + case SCSI_ERROR: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"TapeStatus (TestUnitReady) SCSI_ERROR\n"); - true = 0; + done = 1; break; + case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeStatus (TestUnitReady) SCSI_BUSY\n"); break; + case SCSI_CHECK: DebugPrint(DEBUG_INFO, SECTION_SCSI,"TapeStatus (TestUnitReady) SCSI_CHECK\n"); break; + default: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"TapeStatus (TestUnitReady) unknown (%d)\n",ret); break; + } - sleep(2); - cnt++; + if (!done) + sleep(2); } amfree(pRequestSense); } else { @@ -2160,7 +2323,10 @@ int TapeStatus() return(0); } -int DLT4000Eject(char *Device, int type) +int +DLT4000Eject( + char * Device, + int type) { extern OpenFiles_T *pDev; @@ -2168,22 +2334,14 @@ int DLT4000Eject(char *Device, int type) ExtendedRequestSense_T *pExtendedRequestSense; int ret; int cnt = 0; - int true = 1; + int done; - dbprintf(("##### START DLT4000Eject\n")); + (void)Device; /* Quiet unused parameter warning */ - if ((pRequestSense = malloc(sizeof(RequestSense_T))) == NULL) - { - dbprintf(("%-20s : malloc failed\n","DLT4000Eject")); - return(-1); - } + dbprintf(("##### START DLT4000Eject\n")); - if ((pExtendedRequestSense = malloc(sizeof(ExtendedRequestSense_T))) == NULL) - { - dbprintf(("%-20s : malloc failed\n","DLT4000Eject")); - free(pRequestSense); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); + pExtendedRequestSense = alloc(SIZEOF(ExtendedRequestSense_T)); if ( type > 1) { @@ -2191,6 +2349,7 @@ int DLT4000Eject(char *Device, int type) free(pExtendedRequestSense); free(pRequestSense); return(Tape_Ioctl(INDEX_TAPE, IOCTL_EJECT)); + /*NOTREACHED*/ } @@ -2201,6 +2360,7 @@ int DLT4000Eject(char *Device, int type) free(pExtendedRequestSense); free(pRequestSense); return(Tape_Ioctl(INDEX_TAPE, IOCTL_EJECT)); + /*NOTREACHED*/ } @@ -2221,44 +2381,46 @@ int DLT4000Eject(char *Device, int type) free(pExtendedRequestSense); free(pRequestSense); return(-1); + /*NOTREACHED*/ } - true = 1; - while (true && cnt < 300) + done = 0; + while (!done && cnt < 300) { ret = SCSI_TestUnitReady(INDEX_TAPECTL, pRequestSense); DebugPrint(DEBUG_INFO, SECTION_SCSI, "DLT4000Eject TestUnitReady ret %d\n",ret); switch (ret) { case SCSI_OK: - true = 0; + done = 1; break; case SCSI_SENSE: - switch (SenseHandler(INDEX_TAPECTL, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(INDEX_TAPECTL, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"DLT4000Eject (TestUnitReady) SENSE_NO\n"); - true = 0; + done = 1; break; case SENSE_TAPE_NOT_ONLINE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"DLT4000Eject (TestUnitReady) SENSE_TAPE_NOT_ONLINE\n"); - true = 0; + done = 1; break; case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"DLT4000Eject (TestUnitReady) SENSE_IGNORE\n"); - true = 0; + done = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"DLT4000Eject (TestUnitReady) SENSE_ABORT\n"); free(pExtendedRequestSense); free(pRequestSense); return(-1); + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"DLT4000Eject (TestUnitReady) SENSE_RETRY\n"); break; default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"DLT4000Eject (TestUnitReady) default (SENSE)\n"); - true = 0; + done = 1; break; } break; @@ -2267,6 +2429,7 @@ int DLT4000Eject(char *Device, int type) free(pExtendedRequestSense); free(pRequestSense); return(-1); + /*NOTREACHED*/ case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"DLT4000Eject (TestUnitReady) SCSI_BUSY\n"); break; @@ -2282,7 +2445,7 @@ int DLT4000Eject(char *Device, int type) sleep(2); } - dbprintf(("DLT4000Eject : Ready after %d sec, true = %d\n", cnt * 2, true)); + dbprintf(("DLT4000Eject : Ready after %d sec, done = %d\n", cnt * 2, done)); free(pExtendedRequestSense); free(pRequestSense); @@ -2298,21 +2461,23 @@ int DLT4000Eject(char *Device, int type) * Before unload check if there is an tape in the drive * */ -int GenericEject(char *Device, int type) +int +GenericEject( + char * Device, + int type) { extern OpenFiles_T *pDev; RequestSense_T *pRequestSense; int ret; int cnt = 0; - int true = 1; + int done; + + (void)Device; /* Quiet unused parameter warning */ + (void)type; /* Quiet unused parameter warning */ DebugPrint(DEBUG_INFO, SECTION_TAPE, "##### START GenericEject\n"); - if ((pRequestSense = malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_TAPE, "%-20s : malloc failed\n","GenericEject"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericEject : SCSI eject on %s = %s\n", pDev[INDEX_TAPECTL].dev, pDev[INDEX_TAPECTL].ConfigName); @@ -2333,10 +2498,11 @@ int GenericEject(char *Device, int type) if (ret < 0) { free(pRequestSense); return(-1); + /*NOTREACHED*/ } - true = 1; - while (true && cnt < 300) + done = 0; + while (!done && cnt < 300) { ret = SCSI_TestUnitReady(INDEX_TAPECTL, pRequestSense); DebugPrint(DEBUG_INFO, SECTION_SCSI, "GenericEject TestUnitReady ret %d\n",ret); @@ -2344,14 +2510,14 @@ int GenericEject(char *Device, int type) { case SCSI_OK: case SCSI_SENSE: - switch (SenseHandler(INDEX_TAPECTL, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(INDEX_TAPECTL, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericEject (TestUnitReady) SENSE_NO\n"); break; case SENSE_TAPE_NOT_ONLINE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericEject (TestUnitReady) SENSE_TAPE_NOT_ONLINE\n"); - true = 0; + done = 1; break; case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericEject (TestUnitReady) SENSE_IGNORE\n"); @@ -2360,6 +2526,7 @@ int GenericEject(char *Device, int type) DebugPrint(DEBUG_ERROR, SECTION_SCSI,"GenericEject (TestUnitReady) SENSE_ABORT\n"); free(pRequestSense); return(-1); + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericEject (TestUnitReady) SENSE_RETRY\n"); break; @@ -2372,6 +2539,7 @@ int GenericEject(char *Device, int type) DebugPrint(DEBUG_ERROR, SECTION_SCSI,"GenericEject (TestUnitReady) SCSI_ERROR\n"); free(pRequestSense); return(-1); + /*NOTREACHED*/ case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericEject (TestUnitReady) SCSI_BUSY\n"); break; @@ -2389,7 +2557,8 @@ int GenericEject(char *Device, int type) DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericEject : Device can't understand SCSI try ioctl\n"); Tape_Ioctl(INDEX_TAPECTL, IOCTL_EJECT); } - DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericEject : Ready after %d sec, true = %d\n", cnt * 2, true); + DebugPrint(DEBUG_INFO, SECTION_TAPE, + "GenericEject : Ready after %d sec\n", cnt * 2); free(pRequestSense); return(0); } @@ -2404,15 +2573,17 @@ int GenericEject(char *Device, int type) * -1 -> error * 0 -> success */ -int GenericRewind(int DeviceFD) +int +GenericRewind( + int DeviceFD) { CDB_T CDB; extern OpenFiles_T *pDev; - RequestSense_T *pRequestSense = NULL; + RequestSense_T *pRequestSense; char *errstr; /* Used by tape_rewind */ int ret; int cnt = 0; - int true = 1; + int done; DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### START GenericRewind pDEV -> %d\n",DeviceFD); @@ -2423,51 +2594,49 @@ int GenericRewind(int DeviceFD) */ if (pDev[DeviceFD].SCSI == 1) { - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_TAPE,"GenericRewind : malloc failed\n"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); + /* * Before doing the rewind check if the tape is ready to accept commands */ - while (true == 1) + done = 0; + while (!done) { ret = SCSI_TestUnitReady(DeviceFD, (RequestSense_T *)pRequestSense ); DebugPrint(DEBUG_INFO, SECTION_TAPE, "GenericRewind (TestUnitReady) ret %d\n",ret); switch (ret) { case SCSI_OK: - true= 0; + done = 1; break; case SCSI_SENSE: - switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_NO\n"); - true = 0; + done = 1; break; case SENSE_TAPE_NOT_ONLINE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_TAPE_NOT_ONLINE\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_IGNORE\n"); - true = 0; + done = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_ABORT\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_RETRY\n"); break; default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) default (SENSE)\n"); - true = 0; + done = 1; break; } /* switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey.... */ break; @@ -2476,7 +2645,8 @@ int GenericRewind(int DeviceFD) DebugPrint(DEBUG_ERROR, SECTION_SCSI,"GenericRewind (TestUnitReady) SCSI_ERROR\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ + case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SCSI_BUSY\n"); break; @@ -2495,11 +2665,11 @@ int GenericRewind(int DeviceFD) DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### STOP GenericRewind (-1)\n"); free(pRequestSense); return(-1); + /*NOTREACHED*/ } - } /* while true == 1 */ + } /* while !done */ cnt = 0; - true = 1; CDB[0] = SC_COM_REWIND; CDB[1] = 1; @@ -2508,12 +2678,13 @@ int GenericRewind(int DeviceFD) CDB[4] = 0; CDB[5] = 0; - while (true) + done = 0; + while (!done) { ret = SCSI_Run(DeviceFD, Input, CDB, 6, NULL, 0, - (char *) pRequestSense, - sizeof(RequestSense_T)); + pRequestSense, + SIZEOF(RequestSense_T)); DecodeSense(pRequestSense, "GenericRewind : ", debug_file); @@ -2521,66 +2692,65 @@ int GenericRewind(int DeviceFD) { if (pRequestSense->SenseKey != UNIT_ATTENTION) { - true = 0; + done = 1; } } if (ret == 0) { - true = 0; + done = 1; } if (ret < 0) { DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericRewind : failed %d\n", ret); - true = 0; + done = 1; } } - true = 1; - - while (true && cnt < 300) + done = 0; + while (!done && (cnt < 300)) { ret = SCSI_TestUnitReady(DeviceFD, pRequestSense); DebugPrint(DEBUG_INFO, SECTION_SCSI, "GenericRewind TestUnitReady ret %d\n",ret); switch (ret) { case SCSI_OK: - true = 0; + done = 1; break; case SCSI_SENSE: - switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_NO\n"); - true = 0; + done = 1; break; case SENSE_TAPE_NOT_ONLINE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_TAPE_NOT_ONLINE\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_IGNORE\n"); - true = 0; + done = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_ABORT\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SENSE_RETRY\n"); break; default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) default (SENSE)\n"); - true = 0; + done = 1; break; } break; case SCSI_ERROR: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"GenericRewind (TestUnitReady) SCSI_ERROR\n"); - free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ + case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"GenericRewind (TestUnitReady) SCSI_BUSY\n"); break; @@ -2598,7 +2768,8 @@ int GenericRewind(int DeviceFD) amfree(pRequestSense); - DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericRewind : Ready after %d sec, true = %d\n", cnt * 2, true); + DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericRewind : Ready after %d sec, " + "done = %d\n", cnt * 2, done); DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP GenericRewind (0)\n"); } else { DebugPrint(DEBUG_INFO, SECTION_TAPE,"GenericRewind : use ioctl rewind\n"); @@ -2609,18 +2780,16 @@ int GenericRewind(int DeviceFD) } /* We don't retry if it fails; that is left to the vtape driver. */ if ((errstr = tape_rewind(pDev[DeviceFD].dev)) == NULL) { - true = 0; DebugPrint(DEBUG_INFO, SECTION_TAPE,"Rewind OK,\n", cnt); } else { DebugPrint(DEBUG_ERROR, SECTION_TAPE,"Rewind failed %s\n",errstr); DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP GenericRewind (-1)\n"); - amfree(pRequestSense); return(-1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP GenericRewind (0)\n"); } - amfree(pRequestSense); return(0); } @@ -2630,18 +2799,23 @@ int GenericRewind(int DeviceFD) * bit set in the return of an request sense * */ -int GenericClean(char * Device) +int +GenericClean( + char * Device) { extern OpenFiles_T *pDev; ExtendedRequestSense_T ExtRequestSense; int ret = 0; + (void)Device; /* Quiet unused parameter warning */ + DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### START GenericClean\n"); if (pDev[INDEX_TAPECTL].SCSI == 0) { DebugPrint(DEBUG_ERROR, SECTION_TAPE,"GenericClean : can't send SCSI commands\n"); DebugPrint(DEBUG_ERROR, SECTION_TAPE,"##### STOP GenericClean\n"); return(0); + /*NOTREACHED*/ } /* @@ -2663,7 +2837,9 @@ int GenericClean(char * Device) return(ret); } -int GenericResetStatus(int DeviceFD) +int +GenericResetStatus( + int DeviceFD) { CDB_T CDB; RequestSense_T *pRequestSense; @@ -2672,11 +2848,7 @@ int GenericResetStatus(int DeviceFD) DebugPrint(DEBUG_INFO, SECTION_ELEMENT, "##### START GenericResetStatus\n"); - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericResetStatus : malloc failed\n"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); while (retry) { @@ -2690,31 +2862,32 @@ int GenericResetStatus(int DeviceFD) ret = SCSI_Run(DeviceFD, Input, CDB, 6, NULL, 0, - (char *) pRequestSense, - sizeof(RequestSense_T)); + pRequestSense, + SIZEOF(RequestSense_T)); if (ret < 0) { /* fprintf(stderr, "%s: Request Sense[Inquiry]: %02X", */ - /* "chs", ((unsigned char *) &pRequestSense)[0]); */ - /* for (i = 1; i < sizeof(RequestSense_T); i++) */ - /* fprintf(stderr, " %02X", ((unsigned char *) &pRequestSense)[i]); */ + /* "chs", ((u_char *) &pRequestSense)[0]); */ + /* for (i = 1; i < SIZEOF(RequestSense_T); i++) */ + /* fprintf(stderr, " %02X", ((u_char *) &pRequestSense)[i]); */ /* fprintf(stderr, "\n"); */ free(pRequestSense); return(ret); + /*NOTREACHED*/ } if ( ret > 0 ) { - switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch (SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: free(pRequestSense); return(0); - break; + /*NOTREACHED*/ case SENSE_ABORT: free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ case SENSE_RETRY: retry++; if (retry < MAX_RETRIES ) @@ -2725,13 +2898,14 @@ int GenericResetStatus(int DeviceFD) DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericResetStatus : return (-1)\n"); free(pRequestSense); return(-1); + /*NOTREACHED*/ } break; default: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericResetStatus : (default) return (-1)\n"); free(pRequestSense); return(-1); - break; + /*NOTREACHED*/ } } if (ret == 0) @@ -2756,12 +2930,18 @@ int GenericResetStatus(int DeviceFD) * TODO: * Limit recursion, may run in an infinite loop */ -int GenericSenseHandler(int ip, int flag, unsigned char SenseKey, unsigned char AdditionalSenseCode, unsigned char AdditionalSenseCodeQualifier, char *buffer) +int +GenericSenseHandler( + int ip, + u_char flag, + u_char SenseKey, + u_char AdditionalSenseCode, + u_char AdditionalSenseCodeQualifier, + RequestSense_T * pRequestSense) { extern OpenFiles_T *pDev; - RequestSense_T *pRequestSense = (RequestSense_T *)buffer; - int ret = 0; - unsigned char *info = NULL; + int ret; + char *info = NULL; dbprintf(("##### START GenericSenseHandler\n")); @@ -2772,7 +2952,7 @@ int GenericSenseHandler(int ip, int flag, unsigned char SenseKey, unsigned char flag, SenseKey, AdditionalSenseCode, AdditionalSenseCodeQualifier, - (char **)&info); + &info); dbprintf(("##### STOP GenericSenseHandler\n")); return(ret); @@ -2790,14 +2970,18 @@ int GenericSenseHandler(int ip, int flag, unsigned char SenseKey, unsigned char * the element handling * TODO: */ -int SDXMove(int DeviceFD, int from, int to) +int +SDXMove( + int DeviceFD, + int from, + int to) { extern OpenFiles_T *pDev; ElementInfo_T *pfrom; ElementInfo_T *pto; int ret; int tapestat; - int moveok = 0; + int moveok; int SDX_MTE = 0; /* This are parameters passed */ int SDX_STE = -1; /* to */ int SDX_DTE = -1; /* AlignElements */ @@ -2812,6 +2996,7 @@ int SDXMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE,"SDXMove : ElementInfo for %d not found\n", from); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(-1); + /*NOTREACHED*/ } if ((pto = LookupElement(to)) == NULL) @@ -2819,6 +3004,7 @@ int SDXMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE,"SDXMove : ElementInfo for %d not found\n", to); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(-1); + /*NOTREACHED*/ } if (pfrom->status == 'E') @@ -2826,6 +3012,7 @@ int SDXMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE,"SDXMove : from %d is empty\n", from); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(-1); + /*NOTREACHED*/ } if (pto->status == 'F') @@ -2842,6 +3029,7 @@ int SDXMove(int DeviceFD, int from, int to) { DebugPrint(DEBUG_ERROR, SECTION_MOVE,"SDXMove : no empty slot found for unload\n"); return(-1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_MOVE,"SDXMove : Unload to %d\n", to); if ((pto = LookupElement(to)) == NULL) @@ -2849,6 +3037,7 @@ int SDXMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE, "SDXMove : ElementInfo for %d not found\n", to); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(-1); + /*NOTREACHED*/ } break; case IMPORT: @@ -2894,11 +3083,13 @@ int SDXMove(int DeviceFD, int from, int to) { DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(-1); + /*NOTREACHED*/ } } else { DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### Error setting STE/DTE %d/%d\n", SDX_STE, SDX_DTE); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(-1); + /*NOTREACHED*/ } /* @@ -2919,12 +3110,13 @@ int SDXMove(int DeviceFD, int from, int to) } } - if ( ret == 0) + if ((ret == 0) && moveok) { ret = SCSI_Move(DeviceFD, 0, from, to); } else { DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(ret); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP SDXMove\n"); return(ret); @@ -2940,7 +3132,11 @@ int SDXMove(int DeviceFD, int from, int to) * the element handling * TODO: */ -int GenericMove(int DeviceFD, int from, int to) +int +GenericMove( + int DeviceFD, + int from, + int to) { ElementInfo_T *pfrom; ElementInfo_T *pto; @@ -2956,6 +3152,7 @@ int GenericMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE, "GenericMove : ElementInfo for %d not found\n", from); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP GenericMove\n"); return(-1); + /*NOTREACHED*/ } if ((pto = LookupElement(to)) == NULL) @@ -2963,6 +3160,7 @@ int GenericMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE, "GenericMove : ElementInfo for %d not found\n", to); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP GenericMove\n"); return(-1); + /*NOTREACHED*/ } if (pfrom->status == 'E') @@ -2970,6 +3168,7 @@ int GenericMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_INFO, SECTION_MOVE, "GenericMove : from %d is empty\n", from); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP GenericMove\n"); return(-1); + /*NOTREACHED*/ } if (pto->status == 'F') @@ -2981,6 +3180,7 @@ int GenericMove(int DeviceFD, int from, int to) { DebugPrint(DEBUG_ERROR, SECTION_MOVE, "GenericMove : no empty slot found\n"); return(-1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_MOVE, "GenericMove : Unload to %d\n", to); if ((pto = LookupElement(to)) == NULL) @@ -2988,6 +3188,7 @@ int GenericMove(int DeviceFD, int from, int to) DebugPrint(DEBUG_ERROR, SECTION_MOVE, " Ups should not happen\n"); DebugPrint(DEBUG_INFO, SECTION_MOVE,"##### STOP GenericMove\n"); return(-1); + /*NOTREACHED*/ } } @@ -3009,7 +3210,10 @@ int GenericMove(int DeviceFD, int from, int to) * 0 => Not OK */ -int CheckMove(ElementInfo_T *from, ElementInfo_T *to) +int +CheckMove( + ElementInfo_T * from, + ElementInfo_T * to) { int moveok = 0; @@ -3181,16 +3385,22 @@ int CheckMove(ElementInfo_T *from, ElementInfo_T *to) /* */ -int GetCurrentSlot(int fd, int drive) +int +GetCurrentSlot( + int fd, + int drive) { extern OpenFiles_T *pDev; - int x; + size_t x; dbprintf(("##### START GetCurrentSlot\n")); + (void)fd; /* Quiet unused parameter warning */ + if (pDev[0].SCSI == 0) { dbprintf(("GetCurrentSlot : can't send SCSI commands\n")); return(-1); + /*NOTREACHED*/ } if (ElementStatusValid == 0) @@ -3198,6 +3408,7 @@ int GetCurrentSlot(int fd, int drive) if (pDev[0].functions->function_status(0, 1) != 0) { return(-1); + /*NOTREACHED*/ } } @@ -3208,14 +3419,18 @@ int GetCurrentSlot(int fd, int drive) { if (pSTE[x].address == pDTE[drive].from) return(x); + /*NOTREACHED*/ } return(-1); + /*NOTREACHED*/ } for (x = 0; x < STE;x++) { - if (pSTE[x].status == 'E') - return(x); + if (pSTE[x].status == 'E') { + return(x); + /*NOTREACHED*/ + } } /* Ups nothing loaded */ @@ -3233,19 +3448,23 @@ int GetCurrentSlot(int fd, int drive) * If there are error conditions try to fix them * */ -int GenericElementStatus(int DeviceFD, int InitStatus) +int +GenericElementStatus( + int DeviceFD, + int InitStatus) { int MTEError = 0; int STEError = 0; int IEEError = 0; int DTEError = 0; - int STEEmpty = 0; extern OpenFiles_T *pDev; - int error = 0; /* If set do an INIT ELEMENT STATUS */ - int x; /* The standard loop counter :-) */ - int loop = 2; /* Redo it if an error has been reset */ + int error = 0; /* If set do an INIT ELEMENT STATUS */ + size_t x; /* The standard loop counter :-) */ + int retry = 2; /* Redo it if an error has been reset */ + + (void)InitStatus; /* Quiet unused parameter warning */ DebugPrint(DEBUG_INFO, SECTION_ELEMENT, "##### START GenericElementStatus\n"); @@ -3258,11 +3477,8 @@ int GenericElementStatus(int DeviceFD, int InitStatus) */ if (pModePage == NULL && LibModeSenseValid == 0) { - if ((pModePage = malloc(0xff)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - return(-1); - } + pModePage = alloc(0xff); + if (SCSI_ModeSense(DeviceFD, pModePage, 0xff, 0x8, 0x3f) == 0) { LibModeSenseValid = 1; @@ -3274,14 +3490,13 @@ int GenericElementStatus(int DeviceFD, int InitStatus) } } - if (GetElementStatus(DeviceFD) == 0 && loop > 0) + while ((GetElementStatus(DeviceFD) == 0) && (retry-- > 0)) { - loop--; for (x = 0; x < MTE; x++) { if (pMTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pMTE[x].ASC, pMTE[x].ASCQ, (char *)&pMTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pMTE[x].ASC, pMTE[x].ASCQ, (RequestSense_T *)&pMTE[x])) { case SENSE_IES: MTEError = 1; @@ -3290,7 +3505,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericElementStatus : Abort on MTE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3299,7 +3514,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) { if (pIEE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pIEE[x].ASC, pIEE[x].ASCQ, (char *)&pIEE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pIEE[x].ASC, pIEE[x].ASCQ, (RequestSense_T *)&pIEE[x])) { case SENSE_IES: IEEError = 1; @@ -3308,7 +3523,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericElementStatus : Abort on IEE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3316,18 +3531,9 @@ int GenericElementStatus(int DeviceFD, int InitStatus) for (x = 0; x < STE; x++) { - /* - * Needed for the hack to guess the tape status if an error - * for the tape is pending - */ - if (pSTE[x].status == 'E') - { - STEEmpty = 1; - } - if (pSTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pSTE[x].ASC, pSTE[x].ASCQ, (char *)&pSTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pSTE[x].ASC, pSTE[x].ASCQ, (RequestSense_T *)&pSTE[x])) { case SENSE_IES: STEError = 1; @@ -3336,7 +3542,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericElementStatus : Abort on IES\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3345,7 +3551,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) { if (pDTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pDTE[x].ASC, pDTE[x].ASCQ, (char *)&pDTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pDTE[x].ASC, pDTE[x].ASCQ, (RequestSense_T *)&pDTE[x])) { case SENSE_IES: DTEError = 1; @@ -3354,7 +3560,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericElementStatus : Abort on DTE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3371,6 +3577,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) ElementStatusValid = 0; DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericElementStatus : Can't init status STEError(%d) MTEError(%d) DTEError(%d) IEEError(%d)\n", STEError, MTEError, DTEError, IEEError); return(-1); + /*NOTREACHED*/ } error = 0; } @@ -3395,6 +3602,7 @@ int GenericElementStatus(int DeviceFD, int InitStatus) { DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "GenericElementStatus : Can't init status (after loop)\n"); return(-1); + /*NOTREACHED*/ } ElementStatusValid = 1; @@ -3407,20 +3615,21 @@ int GenericElementStatus(int DeviceFD, int InitStatus) * This is for the ADIC changer, it seems that they have an diferent * offset in the mode sense data before the first mode page (+12) */ -int DLT448ElementStatus(int DeviceFD, int InitStatus) +int +DLT448ElementStatus( + int DeviceFD, + int InitStatus) { - int MTEError = 0; - int STEError = 0; - int IEEError = 0; int DTEError = 0; - int STEEmpty = 0; extern OpenFiles_T *pDev; int error = 0; /* If set do an INIT ELEMENT STATUS */ - int x; /* The standard loop counter :-) */ + size_t x; /* The standard loop counter :-) */ int loop = 2; /* Redo it if an error has been reset */ + (void)InitStatus; /* Quiet unused parameter warning */ + DebugPrint(DEBUG_INFO, SECTION_ELEMENT, "##### START DLT448ElementStatus\n"); if (pEAAPage == NULL) @@ -3432,11 +3641,8 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) */ if (pModePage == NULL && LibModeSenseValid == 0) { - if ((pModePage = malloc(0xff)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"DLT448ElementStatus : malloc failed\n"); - return(-1); - } + pModePage = alloc(0xff); + if (SCSI_ModeSense(DeviceFD, pModePage, 0xff, 0x8, 0x3f) == 0) { LibModeSenseValid = 1; @@ -3448,23 +3654,21 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) } } - if (GetElementStatus(DeviceFD) == 0 && loop > 0) + while (GetElementStatus(DeviceFD) == 0 && loop-- > 0) { - loop--; for (x = 0; x < MTE; x++) { if (pMTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pMTE[x].ASC, pMTE[x].ASCQ, (char *)&pMTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pMTE[x].ASC, pMTE[x].ASCQ, (RequestSense_T *)&pMTE[x])) { case SENSE_IES: - MTEError = 1; error = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "DLT448ElementStatus : Abort on MTE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3473,16 +3677,15 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) { if (pIEE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pIEE[x].ASC, pIEE[x].ASCQ, (char *)&pIEE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pIEE[x].ASC, pIEE[x].ASCQ, (RequestSense_T *)&pIEE[x])) { case SENSE_IES: - IEEError = 1; error = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "DLT448ElementStatus : Abort on IEE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3494,23 +3697,17 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) * Needed for the hack to guess the tape status if an error * for the tape is pending */ - if (pSTE[x].status == 'E') - { - STEEmpty = 1; - } - if (pSTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pSTE[x].ASC, pSTE[x].ASCQ, (char *)&pSTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pSTE[x].ASC, pSTE[x].ASCQ, (RequestSense_T *)&pSTE[x])) { case SENSE_IES: - STEError = 1; error = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "DLT448ElementStatus : Abort on IES\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3519,7 +3716,7 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) { if (pDTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pDTE[x].ASC, pDTE[x].ASCQ, (char *)&pDTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pDTE[x].ASC, pDTE[x].ASCQ, (RequestSense_T *)&pDTE[x])) { case SENSE_IES: DTEError = 1; @@ -3528,7 +3725,7 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "DLT448ElementStatus : Abort on DTE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3545,6 +3742,7 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) ElementStatusValid = 0; DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "DLT448ElementStatus : Can't init status\n"); return(-1); + /*NOTREACHED*/ } error = 0; } @@ -3569,6 +3767,7 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) { DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "DLT448ElementStatus : Can't init status (after loop)\n"); return(-1); + /*NOTREACHED*/ } ElementStatusValid = 1; @@ -3582,17 +3781,17 @@ int DLT448ElementStatus(int DeviceFD, int InitStatus) * it seemes that for the STE Elements ASC/ASCQ is not set * on an error, only the except bit is set */ -int SDXElementStatus(int DeviceFD, int InitStatus) +int +SDXElementStatus( + int DeviceFD, + int InitStatus) { - int MTEError = 0; - int STEError = 0; - int IEEError = 0; - int DTEError = 0; - int error = 0; /* If set do an INIT ELEMENT STATUS */ - int x; /* The standard loop counter :-) */ + size_t x; /* The standard loop counter :-) */ int loop = 2; /* Redo it if an error has been reset */ + (void)InitStatus; /* Quiet unused parameter warning */ + DebugPrint(DEBUG_INFO, SECTION_ELEMENT, "##### START SDXElementStatus\n"); if (pEAAPage == NULL) @@ -3604,11 +3803,8 @@ int SDXElementStatus(int DeviceFD, int InitStatus) */ if (pModePage == NULL && LibModeSenseValid == 0) { - if ((pModePage = malloc(0xff)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"SDXElementStatus : malloc failed\n"); - return(-1); - } + pModePage = alloc(0xff); + if (SCSI_ModeSense(DeviceFD, pModePage, 0xff, 0x8, 0x3f) == 0) { LibModeSenseValid = 1; @@ -3620,24 +3816,22 @@ int SDXElementStatus(int DeviceFD, int InitStatus) } } - if (GetElementStatus(DeviceFD) == 0 && loop) + while (GetElementStatus(DeviceFD) == 0 && loop--) { - loop--; error = 0; for (x = 0; x < MTE; x++) { if (pMTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pMTE[x].ASC, pMTE[x].ASCQ, (char *)&pMTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pMTE[x].ASC, pMTE[x].ASCQ, (RequestSense_T *)&pMTE[x])) { case SENSE_IES: - MTEError = 1; error = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "SDXElementStatus : Abort on MTE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3646,16 +3840,15 @@ int SDXElementStatus(int DeviceFD, int InitStatus) { if (pIEE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pIEE[x].ASC, pIEE[x].ASCQ, (char *)&pIEE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pIEE[x].ASC, pIEE[x].ASCQ, (RequestSense_T *)&pIEE[x])) { case SENSE_IES: - IEEError = 1; error = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "SDXElementStatus : Abort on IEE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3663,23 +3856,17 @@ int SDXElementStatus(int DeviceFD, int InitStatus) for (x = 0; x < STE; x++) { - if (pSTE[x].except != 0) - { - STEError = 1; - } - if (pSTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pSTE[x].ASC, pSTE[x].ASCQ, (char *)&pSTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pSTE[x].ASC, pSTE[x].ASCQ, (RequestSense_T *)&pSTE[x])) { case SENSE_IES: - STEError = 1; error = 1; break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "SDXElementStatus : Abort on IES\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3688,10 +3875,9 @@ int SDXElementStatus(int DeviceFD, int InitStatus) { if (pDTE[x].ASC > 0) { - switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pDTE[x].ASC, pDTE[x].ASCQ, (char *)&pDTE[x])) + switch(SenseHandler(DeviceFD, 0, SENSE_CHG_ELEMENT_STATUS, pDTE[x].ASC, pDTE[x].ASCQ, (RequestSense_T *)&pDTE[x])) { case SENSE_IES: - DTEError = 1; /* error = 1; */ @@ -3699,7 +3885,7 @@ int SDXElementStatus(int DeviceFD, int InitStatus) case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "SDXElementStatus : Abort on DTE\n"); return(-1); - break; + /*NOTREACHED*/ } } } @@ -3716,6 +3902,7 @@ int SDXElementStatus(int DeviceFD, int InitStatus) ElementStatusValid = 0; DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "SDXElementStatus : Can't init status\n"); return(-1); + /*NOTREACHED*/ } } @@ -3726,6 +3913,7 @@ int SDXElementStatus(int DeviceFD, int InitStatus) { DebugPrint(DEBUG_ERROR, SECTION_ELEMENT, "SDXElementStatus : Can't init status\n"); return(-1); + /*NOTREACHED*/ } ElementStatusValid = 1; @@ -3749,21 +3937,22 @@ int SDXElementStatus(int DeviceFD, int InitStatus) * * TODO: */ -int GetElementStatus(int DeviceFD) +int +GetElementStatus( + int DeviceFD) { - unsigned char *DataBuffer = NULL; - int DataBufferLength; + u_char *DataBuffer = NULL; + size_t DataBufferLength; ElementStatusData_T *ElementStatusData; ElementStatusPage_T *ElementStatusPage; MediumTransportElementDescriptor_T *MediumTransportElementDescriptor; StorageElementDescriptor_T *StorageElementDescriptor; DataTransferElementDescriptor_T *DataTransferElementDescriptor; ImportExportElementDescriptor_T *ImportExportElementDescriptor; - int x = 0; - int offset = 0; - int length = 0; /* Length of an Element */ - int barcode = 0; /* To store the result of the BarCode function */ - int NoOfElements; + size_t x; + size_t offset; + size_t length; /* Length of an Element */ + size_t NoOfElements; DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"##### START GetElementStatus\n"); @@ -3778,35 +3967,31 @@ int GetElementStatus(int DeviceFD) /* First the Medim Transport*/ if (V2(pEAAPage->NoMediumTransportElements) > 0) { - free(pMTE); MTE = V2(pEAAPage->NoMediumTransportElements) ; - if ((pMTE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * MTE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - return(-1); - } - memset(pMTE, 0, sizeof(ElementInfo_T) * MTE); + pMTE = alloc(SIZEOF(ElementInfo_T) * MTE); + memset(pMTE, 0, SIZEOF(ElementInfo_T) * MTE); if (SCSI_ReadElementStatus(DeviceFD, CHANGER, 0, - barcode, + (u_char)barcode, V2(pEAAPage->MediumTransportElementAddress), - MTE+1, - sizeof(MediumTransportElementDescriptor_T), - (char **)&DataBuffer) != 0) + (MTE + (size_t)1), + SIZEOF(MediumTransportElementDescriptor_T), + &DataBuffer) != 0) { - free(pMTE); - free(DataBuffer); ChgExit("genericElementStatus","Can't read MTE status", FATAL); + /*NOTREACHED*/ } - ElementStatusData = (ElementStatusData_T *)DataBuffer; - offset = sizeof(ElementStatusData_T); + // ElementStatusData = (ElementStatusData_T *)DataBuffer; + offset = SIZEOF(ElementStatusData_T); ElementStatusPage = (ElementStatusPage_T *)&DataBuffer[offset]; - offset = offset + sizeof(ElementStatusPage_T); + offset = offset + SIZEOF(ElementStatusPage_T); length = V2(ElementStatusPage->length); - DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"MTE Length %d(%d)\n",length,sizeof(MediumTransportElementDescriptor_T)); + + DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"MTE Length %d(%d)\n", length, + SIZEOF(MediumTransportElementDescriptor_T)); for (x = 0; x < MTE; x++) { @@ -3823,8 +4008,13 @@ int GetElementStatus(int DeviceFD) pMTE[x].type = ElementStatusPage->type; pMTE[x].address = V2(MediumTransportElementDescriptor->address); pMTE[x].except = MediumTransportElementDescriptor->except; - pMTE[x].status = (MediumTransportElementDescriptor->full > 0) ? 'F':'E'; pMTE[x].full = MediumTransportElementDescriptor->full; + if (MediumTransportElementDescriptor->full > 0) + { + pMTE[x].status = 'F'; + } else { + pMTE[x].status = 'E'; + } if (length >= 5) { @@ -3853,6 +4043,8 @@ int GetElementStatus(int DeviceFD) } offset = offset + length; } + free(DataBuffer); + DataBuffer = NULL; } /* * Storage Elements @@ -3861,32 +4053,28 @@ int GetElementStatus(int DeviceFD) { free(pSTE); STE = V2(pEAAPage->NoStorageElements); - if ((pSTE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * STE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(pMTE); - return(-1); - } - memset(pSTE, 0, sizeof(ElementInfo_T) * STE); + pSTE = alloc(SIZEOF(ElementInfo_T) * STE); + memset(pSTE, 0, SIZEOF(ElementInfo_T) * STE); if (SCSI_ReadElementStatus(DeviceFD, STORAGE, 0, - barcode, + (u_char)barcode, V2(pEAAPage->FirstStorageElementAddress), STE, - sizeof(StorageElementDescriptor_T), - (char **)&DataBuffer) != 0) + SIZEOF(StorageElementDescriptor_T), + &DataBuffer) != 0) { - free(DataBuffer); ChgExit("GetElementStatus", "Can't read STE status", FATAL); + /*NOTREACHED*/ } + assert(DataBuffer != NULL); - ElementStatusData = (ElementStatusData_T *)DataBuffer; - offset = sizeof(ElementStatusData_T); + // ElementStatusData = (ElementStatusData_T *)DataBuffer; + offset = SIZEOF(ElementStatusData_T); ElementStatusPage = (ElementStatusPage_T *)&DataBuffer[offset]; - offset = offset + sizeof(ElementStatusPage_T); + offset = offset + SIZEOF(ElementStatusPage_T); length = V2(ElementStatusPage->length); DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"STE Length %d\n",length); @@ -3905,8 +4093,13 @@ int GetElementStatus(int DeviceFD) pSTE[x].type = ElementStatusPage->type; pSTE[x].address = V2(StorageElementDescriptor->address); pSTE[x].except = StorageElementDescriptor->except; - pSTE[x].status = (StorageElementDescriptor->full > 0) ? 'F':'E'; pSTE[x].full = StorageElementDescriptor->full; + if (StorageElementDescriptor->full > 0) + { + pSTE[x].status = 'F'; + } else { + pSTE[x].status = 'E'; + } if (length >= 5) { @@ -3936,7 +4129,8 @@ int GetElementStatus(int DeviceFD) offset = offset + length; } - + free(DataBuffer); + DataBuffer = NULL; } /* * Import/Export Elements @@ -3945,35 +4139,28 @@ int GetElementStatus(int DeviceFD) { free(pIEE); IEE = V2(pEAAPage->NoImportExportElements); - if ((pIEE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * IEE)) == NULL) - { - DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(DataBuffer); - return(-1); - } - memset(pIEE, 0, sizeof(ElementInfo_T) * IEE); + pIEE = alloc(SIZEOF(ElementInfo_T) * IEE); + memset(pIEE, 0, SIZEOF(ElementInfo_T) * IEE); if (SCSI_ReadElementStatus(DeviceFD, IMPORT, 0, - barcode, + (u_char)barcode, V2(pEAAPage->FirstImportExportElementAddress), IEE, - sizeof(ImportExportElementDescriptor_T), - (char **)&DataBuffer) != 0) + SIZEOF(ImportExportElementDescriptor_T), + &DataBuffer) != 0) { - if (DataBuffer != 0) - { - free(DataBuffer); - } ChgExit("GetElementStatus", "Can't read IEE status", FATAL); + /*NOTREACHED*/ } + assert(DataBuffer != NULL); - ElementStatusData = (ElementStatusData_T *)DataBuffer; - offset = sizeof(ElementStatusData_T); + // ElementStatusData = (ElementStatusData_T *)DataBuffer; + offset = SIZEOF(ElementStatusData_T); ElementStatusPage = (ElementStatusPage_T *)&DataBuffer[offset]; - offset = offset + sizeof(ElementStatusPage_T); + offset = offset + SIZEOF(ElementStatusPage_T); length = V2(ElementStatusPage->length); DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"IEE Length %d\n",length); @@ -3990,8 +4177,13 @@ int GetElementStatus(int DeviceFD) pIEE[x].type = ElementStatusPage->type; pIEE[x].address = V2(ImportExportElementDescriptor->address); pIEE[x].except = ImportExportElementDescriptor->except; - pIEE[x].status = (ImportExportElementDescriptor->full > 0) ? 'F':'E'; pIEE[x].full = ImportExportElementDescriptor->full; + if (ImportExportElementDescriptor->full > 0) + { + pIEE[x].status = 'F'; + } else { + pIEE[x].status = 'E'; + } if (length >= 5) { @@ -4021,7 +4213,8 @@ int GetElementStatus(int DeviceFD) offset = offset + length; } - + free(DataBuffer); + DataBuffer = NULL; } /* * Data Transfer Elements @@ -4030,32 +4223,28 @@ int GetElementStatus(int DeviceFD) { free(pDTE); DTE = V2(pEAAPage->NoDataTransferElements) ; - if ((pDTE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * DTE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(DataBuffer); - return(-1); - } - memset(pDTE, 0, sizeof(ElementInfo_T) * DTE); + pDTE = alloc(SIZEOF(ElementInfo_T) * DTE); + memset(pDTE, 0, SIZEOF(ElementInfo_T) * DTE); if (SCSI_ReadElementStatus(DeviceFD, TAPETYPE, 0, - barcode, + (u_char)barcode, V2(pEAAPage->FirstDataTransferElementAddress), DTE, - sizeof(DataTransferElementDescriptor_T), - (char **)&DataBuffer) != 0) + SIZEOF(DataTransferElementDescriptor_T), + &DataBuffer) != 0) { - free(DataBuffer); ChgExit("GenericElementStatus", "Can't read DTE status", FATAL); + /*NOTREACHED*/ } + assert(DataBuffer != NULL); - ElementStatusData = (ElementStatusData_T *)DataBuffer; - offset = sizeof(ElementStatusData_T); + // ElementStatusData = (ElementStatusData_T *)DataBuffer; + offset = SIZEOF(ElementStatusData_T); ElementStatusPage = (ElementStatusPage_T *)&DataBuffer[offset]; - offset = offset + sizeof(ElementStatusPage_T); + offset = offset + SIZEOF(ElementStatusPage_T); length = V2(ElementStatusPage->length); DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"DTE Length %d\n",length); @@ -4073,8 +4262,13 @@ int GetElementStatus(int DeviceFD) pDTE[x].address = V2(DataTransferElementDescriptor->address); pDTE[x].except = DataTransferElementDescriptor->except; pDTE[x].scsi = DataTransferElementDescriptor->scsi; - pDTE[x].status = (DataTransferElementDescriptor->full > 0) ? 'F':'E'; pDTE[x].full = DataTransferElementDescriptor->full; + if (DataTransferElementDescriptor->full > 0) + { + pDTE[x].status = 'F'; + } else { + pDTE[x].status = 'E'; + } if (length >= 5) { @@ -4104,6 +4298,8 @@ int GetElementStatus(int DeviceFD) offset = offset + length; } + free(DataBuffer); + DataBuffer = NULL; } } else { /* @@ -4113,36 +4309,27 @@ int GetElementStatus(int DeviceFD) if (SCSI_ReadElementStatus(DeviceFD, 0, 0, - barcode, + (u_char)barcode, 0, - 0xff, - 0x7f, - (char **)&DataBuffer) != 0) + (size_t)0xff, + (size_t)0x7f, + &DataBuffer) != 0) { - if (DataBuffer != 0) - { - free(DataBuffer); - } ChgExit("GenericElementStatus","Can't get ElementStatus", FATAL); + /*NOTREACHED*/ } + assert(DataBuffer != NULL); ElementStatusData = (ElementStatusData_T *)DataBuffer; DataBufferLength = V3(ElementStatusData->count); - offset = sizeof(ElementStatusData_T); - - if (DataBufferLength <= 0) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"DataBufferLength %d\n",DataBufferLength); - free(DataBuffer); - return(1); - } + offset = SIZEOF(ElementStatusData_T); while (offset < DataBufferLength) { ElementStatusPage = (ElementStatusPage_T *)&DataBuffer[offset]; NoOfElements = V3(ElementStatusPage->count) / V2(ElementStatusPage->length); - offset = offset + sizeof(ElementStatusPage_T); + offset = offset + SIZEOF(ElementStatusPage_T); length = V2(ElementStatusPage->length); switch (ElementStatusPage->type) @@ -4150,13 +4337,8 @@ int GetElementStatus(int DeviceFD) case CHANGER: free(pMTE); MTE = NoOfElements; - if ((pMTE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * MTE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(DataBuffer); - return(-1); - } - memset(pMTE, 0, sizeof(ElementInfo_T) * MTE); + pMTE = alloc(SIZEOF(ElementInfo_T) * MTE); + memset(pMTE, 0, SIZEOF(ElementInfo_T) * MTE); for (x = 0; x < NoOfElements; x++) { @@ -4171,9 +4353,13 @@ int GetElementStatus(int DeviceFD) pMTE[x].type = ElementStatusPage->type; pMTE[x].address = V2(MediumTransportElementDescriptor->address); pMTE[x].except = MediumTransportElementDescriptor->except; - pMTE[x].status = (MediumTransportElementDescriptor->full > 0) ? 'F':'E'; pMTE[x].full = MediumTransportElementDescriptor->full; - + if (MediumTransportElementDescriptor->full > 0) + { + pMTE[x].status = 'F'; + } else { + pMTE[x].status = 'E'; + } if (length >= 5) { @@ -4207,13 +4393,8 @@ int GetElementStatus(int DeviceFD) case STORAGE: free(pSTE); STE = NoOfElements; - if ((pSTE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * STE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(DataBuffer); - return(-1); - } - memset(pSTE, 0, sizeof(ElementInfo_T) * STE); + pSTE = alloc(SIZEOF(ElementInfo_T) * STE); + memset(pSTE, 0, SIZEOF(ElementInfo_T) * STE); for (x = 0; x < NoOfElements; x++) { @@ -4229,8 +4410,13 @@ int GetElementStatus(int DeviceFD) pSTE[x].type = ElementStatusPage->type; pSTE[x].address = V2(StorageElementDescriptor->address); pSTE[x].except = StorageElementDescriptor->except; - pSTE[x].status = (StorageElementDescriptor->full > 0) ? 'F':'E'; pSTE[x].full = StorageElementDescriptor->full; + if (StorageElementDescriptor->full > 0) + { + pSTE[x].status = 'F'; + } else { + pSTE[x].status = 'E'; + } if (length >= 5) { @@ -4264,13 +4450,8 @@ int GetElementStatus(int DeviceFD) case IMPORT: free(pIEE); IEE = NoOfElements; - if ((pIEE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * IEE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(DataBuffer); - return(-1); - } - memset(pIEE, 0, sizeof(ElementInfo_T) * IEE); + pIEE = alloc(SIZEOF(ElementInfo_T) * IEE); + memset(pIEE, 0, SIZEOF(ElementInfo_T) * IEE); for (x = 0; x < NoOfElements; x++) { @@ -4286,8 +4467,13 @@ int GetElementStatus(int DeviceFD) pIEE[x].type = ElementStatusPage->type; pIEE[x].address = V2(ImportExportElementDescriptor->address); pIEE[x].except = ImportExportElementDescriptor->except; - pIEE[x].status = (ImportExportElementDescriptor->full > 0) ? 'F':'E'; pIEE[x].full = ImportExportElementDescriptor->full; + if (ImportExportElementDescriptor->full > 0) + { + pIEE[x].status = 'F'; + } else { + pIEE[x].status = 'E'; + } if (length >= 5) { @@ -4321,13 +4507,8 @@ int GetElementStatus(int DeviceFD) case TAPETYPE: free(pDTE); DTE = NoOfElements; - if ((pDTE = (ElementInfo_T *)malloc(sizeof(ElementInfo_T) * DTE)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"GenericElementStatus : malloc failed\n"); - free(DataBuffer); - return(-1); - } - memset(pDTE, 0, sizeof(ElementInfo_T) * DTE); + pDTE = alloc(SIZEOF(ElementInfo_T) * DTE); + memset(pDTE, 0, SIZEOF(ElementInfo_T) * DTE); for (x = 0; x < NoOfElements; x++) { @@ -4343,8 +4524,13 @@ int GetElementStatus(int DeviceFD) pDTE[x].address = V2(DataTransferElementDescriptor->address); pDTE[x].except = DataTransferElementDescriptor->except; pDTE[x].scsi = DataTransferElementDescriptor->scsi; - pDTE[x].status = (DataTransferElementDescriptor->full > 0) ? 'F':'E'; pDTE[x].full = DataTransferElementDescriptor->full; + if (DataTransferElementDescriptor->full > 0) + { + pDTE[x].status = 'F'; + } else { + pDTE[x].status = 'E'; + } if (length >= 5) { @@ -4381,6 +4567,7 @@ int GetElementStatus(int DeviceFD) break; } } + free(DataBuffer); } DebugPrint(DEBUG_INFO, SECTION_ELEMENT,"\n\n\tMedia Transport Elements (robot arms) :\n"); @@ -4413,7 +4600,6 @@ int GetElementStatus(int DeviceFD) - free(DataBuffer); return(0); } @@ -4424,7 +4610,11 @@ int GetElementStatus(int DeviceFD) * * TODO */ -int RequestSense(int DeviceFD, ExtendedRequestSense_T *ExtendedRequestSense, int ClearErrorCounters ) +int +RequestSense( + int DeviceFD, + ExtendedRequestSense_T * ExtendedRequestSense, + int ClearErrorCounters) { CDB_T CDB; int ret; @@ -4435,21 +4625,23 @@ int RequestSense(int DeviceFD, ExtendedRequestSense_T *ExtendedRequestSense, int CDB[1] = 0; /* Logical Unit Number = 0, Reserved */ CDB[2] = 0; /* Reserved */ CDB[3] = 0; /* Reserved */ - CDB[4] = sizeof(ExtendedRequestSense_T); /* Allocation Length */ - CDB[5] = (ClearErrorCounters << 7) & 0x80; /* */ + CDB[4] = (u_char)sizeof(ExtendedRequestSense_T); /* Allocation Length */ + CDB[5] = (u_char)((ClearErrorCounters << 7) & 0x80); /* */ - memset(ExtendedRequestSense, 0, sizeof(ExtendedRequestSense_T)); + memset(ExtendedRequestSense, 0, SIZEOF(ExtendedRequestSense_T)); ret = SCSI_Run(DeviceFD, Input, CDB, 6, (char *) ExtendedRequestSense, - sizeof(ExtendedRequestSense_T), - (char *) ExtendedRequestSense, sizeof(ExtendedRequestSense_T)); + SIZEOF(ExtendedRequestSense_T), + (RequestSense_T *) ExtendedRequestSense, + SIZEOF(ExtendedRequestSense_T)); if (ret < 0) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP RequestSense (%d)\n",ret); return(ret); + /*NOTREACHED*/ } if ( ret > 0) @@ -4457,9 +4649,12 @@ int RequestSense(int DeviceFD, ExtendedRequestSense_T *ExtendedRequestSense, int DecodeExtSense(ExtendedRequestSense, "RequestSense : ",debug_file); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP RequestSense (%d)\n", ExtendedRequestSense->SenseKey); return(ExtendedRequestSense->SenseKey); + /*NOTREACHED*/ } - dump_hex((char *)ExtendedRequestSense , sizeof(ExtendedRequestSense_T) , DEBUG_INFO, SECTION_SCSI); + dump_hex((u_char *)ExtendedRequestSense , + SIZEOF(ExtendedRequestSense_T), + DEBUG_INFO, SECTION_SCSI); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP RequestSense (0)\n"); return(0); } @@ -4470,9 +4665,11 @@ int RequestSense(int DeviceFD, ExtendedRequestSense_T *ExtendedRequestSense, int */ -ElementInfo_T *LookupElement(int address) +ElementInfo_T * +LookupElement( + int address) { - int x; + size_t x; dbprintf(("##### START LookupElement\n")); @@ -4484,6 +4681,7 @@ ElementInfo_T *LookupElement(int address) { dbprintf(("##### STOP LookupElement (DTE)\n")); return(&pDTE[x]); + /*NOTREACHED*/ } } } @@ -4496,6 +4694,7 @@ ElementInfo_T *LookupElement(int address) { dbprintf(("##### STOP LookupElement (MTE)\n")); return(&pMTE[x]); + /*NOTREACHED*/ } } } @@ -4508,6 +4707,7 @@ ElementInfo_T *LookupElement(int address) { dbprintf(("##### STOP LookupElement (STE)\n")); return(&pSTE[x]); + /*NOTREACHED*/ } } } @@ -4520,11 +4720,13 @@ ElementInfo_T *LookupElement(int address) { dbprintf(("##### STOP LookupElement (IEE)\n")); return(&pIEE[x]); + /*NOTREACHED*/ } } } return(NULL); } + /* * Here comes everything what decode the log Pages * @@ -4532,7 +4734,9 @@ ElementInfo_T *LookupElement(int address) * Fix the result handling from TestUnitReady * */ -int LogSense(DeviceFD) +int +LogSense( + int DeviceFD) { extern OpenFiles_T *pDev; CDB_T CDB; @@ -4543,26 +4747,23 @@ int LogSense(DeviceFD) int found; extern char *tapestatfile; int i; - int ParameterCode; - unsigned int value; - int length; + unsigned ParameterCode; + unsigned value; + size_t length; int count; - char *buffer; - char *logpages; - int nologpages; - int size = 128; + u_char *buffer; + u_char *logpages; + size_t nologpages; + size_t size = 128; + + (void)DeviceFD; /* Quiet unused parameter warning */ DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### START LogSense\n"); if ((tapestatfile != NULL) && (pDev[INDEX_TAPECTL].SCSI == 1) && ((StatFile = fopen(tapestatfile,"a")) != NULL)) { - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_TAPE,"LogSense : malloc failed\n"); - fclose(StatFile); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); if (GenericRewind(INDEX_TAPECTL) < 0) { @@ -4570,6 +4771,7 @@ int LogSense(DeviceFD) free(pRequestSense); fclose(StatFile); return(0); + /*NOTREACHED*/ } /* * Try to read the tape label @@ -4589,13 +4791,7 @@ int LogSense(DeviceFD) } } - if ((buffer = (char *)malloc(size)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_TAPE,"LogSense : malloc failed\n"); - free(pRequestSense); - fclose(StatFile); - return(-1); - } + buffer = alloc(size); memset(buffer, 0, size); /* * Get the known log pages @@ -4611,38 +4807,32 @@ int LogSense(DeviceFD) MSB2(&CDB[7], size); CDB[9] = 0; - if (SCSI_Run(INDEX_TAPECTL, Input, CDB, 10, + if (SCSI_Run(INDEX_TAPECTL, Input, CDB, 10, buffer, size, - (char *)pRequestSense, - sizeof(RequestSense_T)) != 0) + pRequestSense, + SIZEOF(RequestSense_T)) != 0) { DecodeSense(pRequestSense, "LogSense : ",debug_file); free(pRequestSense); free(buffer); fclose(StatFile); return(0); + /*NOTREACHED*/ } LogSenseHeader = (LogSenseHeader_T *)buffer; nologpages = V2(LogSenseHeader->PageLength); - if ((logpages = (char *)malloc(nologpages)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_TAPE,"LogSense : malloc failed\n"); - free(pRequestSense); - free(buffer); - fclose(StatFile); - return(-1); - } + logpages = alloc(nologpages); - memcpy(logpages, buffer + sizeof(LogSenseHeader_T), nologpages); + memcpy(logpages, buffer + SIZEOF(LogSenseHeader_T), nologpages); - for (count = 0; count < nologpages; count++) { + for (count = 0; count < (int)nologpages; count++) { if (logpages[count] != 0 ) { memset(buffer, 0, size); CDB[0] = SC_COM_LOG_SENSE; CDB[1] = 0; - CDB[2] = 0x40 | logpages[count]; /* 0x40 for current values */ + CDB[2] = (u_char)(0x40 | logpages[count]);/* 0x40 for current values */ CDB[3] = 0; CDB[4] = 0; CDB[5] = 0; @@ -4653,8 +4843,8 @@ int LogSense(DeviceFD) if (SCSI_Run(INDEX_TAPECTL, Input, CDB, 10, buffer, size, - (char *)pRequestSense, - sizeof(RequestSense_T)) != 0) + pRequestSense, + SIZEOF(RequestSense_T)) != 0) { DecodeSense(pRequestSense, "LogSense : ",debug_file); free(pRequestSense); @@ -4662,17 +4852,18 @@ int LogSense(DeviceFD) free(buffer); fclose(StatFile); return(0); + /*NOTREACHED*/ } LogSenseHeader = (LogSenseHeader_T *)buffer; length = V2(LogSenseHeader->PageLength); - LogParameter = (LogParameter_T *)(buffer + sizeof(LogSenseHeader_T)); + LogParameter = (LogParameter_T *)(buffer + SIZEOF(LogSenseHeader_T)); /* * Decode the log pages */ p = (struct LogPageDecode *)&DecodePages; found = 0; - dump_hex((char *)LogParameter, 64, DEBUG_INFO, SECTION_SCSI); + dump_hex((u_char *)LogParameter, 64, DEBUG_INFO, SECTION_SCSI); while(p->ident != NULL) { if ((strcmp(pDev[INDEX_TAPECTL].ident, p->ident) == 0 ||strcmp("*", p->ident) == 0) && p->LogPage == logpages[count]) { @@ -4687,34 +4878,34 @@ int LogSense(DeviceFD) if (!found) { fprintf(StatFile, "Logpage No %d = %x\n", count ,logpages[count]); - while ((char *)LogParameter < (buffer + length)) { + while ((u_char *)LogParameter < (buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); switch (i) { case 1: - value = V1((char *)LogParameter + sizeof(LogParameter_T)); + value = V1((u_char *)LogParameter + SIZEOF(LogParameter_T)); fprintf(StatFile, "ParameterCode %02X = %u(%d)\n", ParameterCode, value, i); break; case 2: - value = V2((char *)LogParameter + sizeof(LogParameter_T)); + value = V2((u_char *)LogParameter + SIZEOF(LogParameter_T)); fprintf(StatFile, "ParameterCode %02X = %u(%d)\n", ParameterCode, value, i); break; case 3: - value = V3((char *)LogParameter + sizeof(LogParameter_T)); + value = V3((u_char *)LogParameter + SIZEOF(LogParameter_T)); fprintf(StatFile, "ParameterCode %02X = %u(%d)\n", ParameterCode, value, i); break; case 4: - value = V4((char *)LogParameter + sizeof(LogParameter_T)); + value = V4((u_char *)LogParameter + SIZEOF(LogParameter_T)); fprintf(StatFile, "ParameterCode %02X = %u(%d)\n", ParameterCode, value, i); break; case 5: - value = V5((char *)LogParameter + sizeof(LogParameter_T)); + value = V5((u_char *)LogParameter + SIZEOF(LogParameter_T)); fprintf(StatFile, "ParameterCode %02X = %u(%d)\n", ParameterCode, value, i); break; default: fprintf(StatFile, "ParameterCode %02X size %d\n", ParameterCode, i); } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } fprintf(StatFile, "\n"); } @@ -4736,40 +4927,48 @@ int LogSense(DeviceFD) CDB[8] = 0; CDB[9] = 0; - if (SCSI_Run(INDEX_TAPECTL, Input, CDB, 10, + if (SCSI_Run(INDEX_TAPECTL, Input, CDB, 10, buffer, size, - (char *)pRequestSense, - sizeof(RequestSense_T)) != 0) + pRequestSense, + SIZEOF(RequestSense_T)) != 0) { DecodeSense(pRequestSense, "LogSense : ",debug_file); free(pRequestSense); free(logpages); + /*@ignore@*/ free(buffer); + /*@end@*/ fclose(StatFile); return(0); + /*NOTREACHED*/ } free(pRequestSense); free(logpages); + /*@ignore@*/ free(buffer); + /*@end@*/ fclose(StatFile); } DebugPrint(DEBUG_INFO, SECTION_TAPE,"##### STOP LogSense\n"); return(0); } -void WriteErrorCountersPage(LogParameter_T *buffer, int length) +void +WriteErrorCountersPage( + LogParameter_T * buffer, + size_t length) { int i; - int value; + unsigned value; LogParameter_T *LogParameter; - int ParameterCode; + unsigned ParameterCode; LogParameter = buffer; fprintf(StatFile, "\tWrite Error Counters Page\n"); - while ((char *)LogParameter < ((char *)buffer + length)) { + while ((u_char *)LogParameter < ((u_char *)buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); @@ -4810,24 +5009,28 @@ void WriteErrorCountersPage(LogParameter_T *buffer, int length) } else { fprintf(StatFile, "Error decoding Result\n"); } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } } -void ReadErrorCountersPage(LogParameter_T *buffer, int length) +void +ReadErrorCountersPage( + LogParameter_T * buffer, + size_t length) { int i; - int value; + unsigned value; LogParameter_T *LogParameter; - int ParameterCode; + unsigned ParameterCode; LogParameter = buffer; fprintf(StatFile, "\tRead Error Counters Page\n"); - while ((char *)LogParameter < ((char *)buffer + length)) { + while ((u_char *)LogParameter < ((u_char *)buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); + value = 0; if (Decode(LogParameter, &value) == 0) { switch (ParameterCode) { case 2: @@ -4864,24 +5067,28 @@ void ReadErrorCountersPage(LogParameter_T *buffer, int length) } else { fprintf(StatFile, "Error decoding Result\n"); } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } } -void C1553APage30(LogParameter_T *buffer, int length) +void +C1553APage30( + LogParameter_T * buffer, + size_t length) { int i; - int value; + unsigned value; LogParameter_T *LogParameter; - int ParameterCode; + unsigned ParameterCode; LogParameter = buffer; fprintf(StatFile, "\tData compression transfer Page\n"); - while ((char *)LogParameter < ((char *)buffer + length)) { + while ((u_char *)LogParameter < ((u_char *)buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); + value = 0; if (Decode(LogParameter, &value) == 0) { switch (ParameterCode) { default: @@ -4891,24 +5098,28 @@ void C1553APage30(LogParameter_T *buffer, int length) break; } } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } } -void C1553APage37(LogParameter_T *buffer, int length) +void +C1553APage37( + LogParameter_T * buffer, + size_t length) { int i; - int value; + unsigned value; LogParameter_T *LogParameter; - int ParameterCode; + unsigned ParameterCode; LogParameter = buffer; fprintf(StatFile, "\tDrive Counters Page\n"); - while ((char *)LogParameter < ((char *)buffer + length)) { + while ((u_char *)LogParameter < ((unsigned char *)buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); + value = 0; if (Decode(LogParameter, &value) == 0) { switch (ParameterCode) { case 1: @@ -4933,24 +5144,28 @@ void C1553APage37(LogParameter_T *buffer, int length) break; } } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } } -void EXB85058HEPage39(LogParameter_T *buffer, int length) +void +EXB85058HEPage39( + LogParameter_T * buffer, + size_t length) { int i; - int value; + unsigned value; LogParameter_T *LogParameter; - int ParameterCode; + unsigned ParameterCode; LogParameter = buffer; fprintf(StatFile, "\tData Compression Page\n"); - while ((char *)LogParameter < ((char *)buffer + length)) { + while ((u_char *)LogParameter < ((unsigned char *)buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); + value = 0; if (Decode(LogParameter, &value) == 0) { switch (ParameterCode) { case 5: @@ -4970,24 +5185,28 @@ void EXB85058HEPage39(LogParameter_T *buffer, int length) break; } } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } } -void EXB85058HEPage3c(LogParameter_T *buffer, int length) +void +EXB85058HEPage3c( + LogParameter_T * buffer, + size_t length) { int i; - int value; + unsigned value; LogParameter_T *LogParameter; - int ParameterCode; + unsigned ParameterCode; LogParameter = buffer; fprintf(StatFile, "\tDrive Usage Information Page\n"); - while ((char *)LogParameter < ((char *)buffer + length)) { + while ((u_char *)LogParameter < ((unsigned char *)buffer + length)) { i = LogParameter->ParameterLength; ParameterCode = V2(LogParameter->ParameterCode); + value = 0; if (Decode(LogParameter, &value) == 0) { switch (ParameterCode) { case 1: @@ -5037,46 +5256,55 @@ void EXB85058HEPage3c(LogParameter_T *buffer, int length) break; } } - LogParameter = (LogParameter_T *)((char *)LogParameter + sizeof(LogParameter_T) + i); + LogParameter = (LogParameter_T *)((u_char *)LogParameter + SIZEOF(LogParameter_T) + i); } } -int Decode(LogParameter_T *LogParameter, int *value) +int +Decode( + LogParameter_T * LogParameter, + unsigned * value) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START Decode\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI,"Decode Parameter with length %d\n", LogParameter->ParameterLength); + + *value = 0; switch (LogParameter->ParameterLength) { case 1: - *value = V1((char *)LogParameter + sizeof(LogParameter_T)); + *value = V1((u_char *)LogParameter + SIZEOF(LogParameter_T)); break; case 2: - *value = V2((char *)LogParameter + sizeof(LogParameter_T)); + *value = V2((u_char *)LogParameter + SIZEOF(LogParameter_T)); break; case 3: - *value = V3((char *)LogParameter + sizeof(LogParameter_T)); + *value = V3((u_char *)LogParameter + SIZEOF(LogParameter_T)); break; case 4: - *value = V4((char *)LogParameter + sizeof(LogParameter_T)); + *value = V4((u_char *)LogParameter + SIZEOF(LogParameter_T)); break; case 5: - *value = V5((char *)LogParameter + sizeof(LogParameter_T)); + *value = V5((u_char *)LogParameter + SIZEOF(LogParameter_T)); break; case 6: - *value = V6((char *)LogParameter + sizeof(LogParameter_T)); + *value = V6((u_char *)LogParameter + SIZEOF(LogParameter_T)); break; default: fprintf(StatFile, "Can't decode ParameterCode %02X size %d\n", V2(LogParameter->ParameterCode), LogParameter->ParameterLength); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP Decode (1)\n"); return(1); + /*NOTREACHED*/ } DebugPrint(DEBUG_INFO, SECTION_SCSI,"Result = %d\n", *value); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP Decode(0)\n"); return(0); } -void DumpDev(OpenFiles_T *p, char *device) +void +DumpDev( + OpenFiles_T * p, + char * device) { if (p != NULL) { @@ -5090,21 +5318,31 @@ void DumpDev(OpenFiles_T *p, char *device) printf("\n"); } -void ChangerReplay(char *option) +void +ChangerReplay( + char * option) { - char buffer[1024]; + u_char buffer[1024]; FILE *ip; - int x = 0, bufferx; + int x; + unsigned bufferx; + + (void)option; /* Quiet unused parameter warning */ if ((ip=fopen("/tmp/chg-scsi-trace", "r")) == NULL) { exit(1); } - while (fscanf(ip, "%2x", &bufferx) != EOF) + for (x = 0; x < 1024; x++) { - buffer[x] = bufferx; - x++; + if (fscanf(ip, "%2x", &bufferx) == EOF) + { + break; + /*NOTREACHED*/ + } + buffer[x] = (u_char)bufferx; + x++; } DecodeModeSense(&buffer[0], 12, "DLT448ElementStatus :", 0, debug_file); @@ -5114,35 +5352,35 @@ void ChangerReplay(char *option) /* * Display all Information we can get about the library.... */ -void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device) +void +ChangerStatus( + char * option, + char * labelfile, + int HasBarCode, + char * changer_file, + char * changer_dev, + char * tape_device) { extern OpenFiles_T *pDev; - int x; + size_t x; FILE *out; ExtendedRequestSense_T ExtRequestSense; MBC_T *pbarcoderes; ChangerCMD_T *p = (ChangerCMD_T *)&ChangerIO; - if ((pbarcoderes = malloc(sizeof(MBC_T))) == NULL) - { - printf("malloc failed \n"); - return; - } - memset(pbarcoderes, 0, sizeof(MBC_T)); + pbarcoderes = alloc(SIZEOF(MBC_T)); + memset(pbarcoderes, 0, SIZEOF(MBC_T)); - if ((pModePage == NULL) && ((pModePage = (char *)malloc(0xff)) == NULL)) - { - DebugPrint(DEBUG_ERROR, SECTION_ELEMENT,"##### malloc failed (-1)\n"); - printf("malloc failed \n"); - free(pbarcoderes); - return; - } + if (pModePage == NULL) { + pModePage = alloc(0xff); + } if ((out = fdopen(1 , "w")) == NULL) { printf("Error fdopen stdout\n"); free(pbarcoderes); return; + /*NOTREACHED*/ } if (strcmp("types", option) == 0 || strcmp("all", option) == 0) @@ -5165,6 +5403,7 @@ void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer free(pbarcoderes); fclose(out); return; + /*NOTREACHED*/ } } /* 0123456789012345678901234567890123456789012 */ @@ -5187,7 +5426,8 @@ void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer if (pMTE[x].full == 1) { pbarcoderes->action = BARCODE_BARCODE; - strcpy(pbarcoderes->data.barcode, pMTE[x].VolTag); + strncpy(pbarcoderes->data.barcode, pMTE[x].VolTag, + SIZEOF(pbarcoderes->data.barcode)); if (MapBarCode(labelfile, pbarcoderes) == 0 ) { @@ -5215,7 +5455,8 @@ void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer if (pSTE[x].full == 1) { pbarcoderes->action = BARCODE_BARCODE; - strcpy(pbarcoderes->data.barcode, pSTE[x].VolTag); + strncpy(pbarcoderes->data.barcode, pSTE[x].VolTag, + SIZEOF(pbarcoderes->data.barcode)); if (MapBarCode(labelfile, pbarcoderes) == 0 ) { @@ -5243,7 +5484,8 @@ void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer if (pDTE[x].full == 1) { pbarcoderes->action = BARCODE_BARCODE; - strcpy(pbarcoderes->data.barcode, pDTE[x].VolTag); + strncpy(pbarcoderes->data.barcode, pDTE[x].VolTag, + SIZEOF(pbarcoderes->data.barcode)); if (MapBarCode(labelfile, pbarcoderes) == 0 ) { @@ -5271,7 +5513,8 @@ void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer if (pIEE[x].full == 1) { pbarcoderes->action = BARCODE_BARCODE; - strcpy(pbarcoderes->data.barcode, pIEE[x].VolTag); + strncpy(pbarcoderes->data.barcode, pIEE[x].VolTag, + SIZEOF(pbarcoderes->data.barcode)); if (MapBarCode(labelfile, pbarcoderes) == 0 ) { @@ -5355,24 +5598,29 @@ void ChangerStatus(char *option, char * labelfile, int HasBarCode, char *changer fclose(out); } -void dump_hex(char *p, int size, int level, int section) +void +dump_hex( + u_char * p, + size_t size, + int level, + int section) { - int row_count = 0; - int x = 0; + size_t row_count = 0; + int x; while (row_count < size) { - DebugPrint(level, section,"%02X ", (unsigned char)p[row_count]); - if (((row_count + 1) % 16) == 0 ) + DebugPrint(level, section,"%02X ", (u_char)p[row_count]); + if (((row_count + 1) % 16) == 0) { dbprintf((" ")); - for (x = 16; x>0;x--) + for (x = 16; x > 0; x--) { - if (isalnum((unsigned char)p[row_count - x + 1 ])) - DebugPrint(level, section,"%c",(unsigned char)p[row_count - x + 1]); - else - DebugPrint(level, section,"."); - } + if (isalnum((u_char)p[row_count - x + 1 ])) + DebugPrint(level, section,"%c",(u_char)p[row_count - x + 1]); + else + DebugPrint(level, section,"."); + } DebugPrint(level, section,"\n"); } row_count++; @@ -5380,16 +5628,25 @@ void dump_hex(char *p, int size, int level, int section) DebugPrint(level, section,"\n"); } -void TerminateString(char *string, int length) +void +TerminateString( + char * string, + size_t length) { - int x; + ssize_t x; - for (x = length; x >= 0 && !isalnum((int)string[x]); x--) + for (x = (ssize_t)length; x >= 0 && !isalnum((int)string[x]); x--) string[x] = '\0'; } -void ChgExit(char *where, char *reason, int level) +void +ChgExit( + char * where, + char * reason, + int level) { + (void)level; /* Quiet unused parameter warning */ + dbprintf(("ChgExit in %s, reason %s\n", where, reason)); fprintf(stderr,"%s\n",reason); exit(2); @@ -5406,20 +5663,26 @@ void ChgExit(char *where, char *reason, int level) * is ready for accepting commands, and if this is true send * the command */ -int SCSI_Run(int DeviceFD, - Direction_T Direction, - CDB_T CDB, - int CDB_Length, - void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength) +int +SCSI_Run( + int DeviceFD, + Direction_T Direction, + CDB_T CDB, + size_t CDB_Length, + void * DataBuffer, + size_t DataBufferLength, + RequestSense_T * pRequestSense, + size_t RequestSenseLength) { int ret = 0; int ok = 0; int maxtries = 0; RequestSense_T *pRqS; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + pRqS = (RequestSense_T *)pRequestSense; DebugPrint(DEBUG_INFO, SECTION_SCSI, "SCSI_Run TestUnitReady\n"); @@ -5433,7 +5696,7 @@ int SCSI_Run(int DeviceFD, ok=1; break; case SCSI_SENSE: - switch (SenseHandler(DeviceFD, 0, pRqS->SenseKey, pRqS->AdditionalSenseCode, pRqS->AdditionalSenseCodeQualifier, pRequestSense)) + switch (SenseHandler(DeviceFD, 0, pRqS->SenseKey, pRqS->AdditionalSenseCode, pRqS->AdditionalSenseCodeQualifier, pRqS)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Run (TestUnitReady) SENSE_NO\n"); @@ -5450,7 +5713,7 @@ int SCSI_Run(int DeviceFD, case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Run (TestUnitReady) SENSE_ABORT\n"); return(-1); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Run (TestUnitReady) SENSE_RETRY\n"); break; @@ -5463,7 +5726,7 @@ int SCSI_Run(int DeviceFD, case SCSI_ERROR: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Run (TestUnitReady) SCSI_ERROR\n"); return(-1); - break; + /*NOTREACHED*/ case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Run (TestUnitReady) SCSI_BUSY\n"); break; @@ -5487,6 +5750,7 @@ int SCSI_Run(int DeviceFD, { DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Run Exit %d\n",ret); return(-1); + /*NOTREACHED*/ } ok = 0; @@ -5509,7 +5773,7 @@ int SCSI_Run(int DeviceFD, ok=1; break; case SCSI_SENSE: - switch (SenseHandler(DeviceFD, 0, pRqS->SenseKey, pRqS->AdditionalSenseCode, pRqS->AdditionalSenseCodeQualifier, pRequestSense)) + switch (SenseHandler(DeviceFD, 0, pRqS->SenseKey, pRqS->AdditionalSenseCode, pRqS->AdditionalSenseCodeQualifier, pRqS)) { case SENSE_NO: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Run SENSE_NO\n"); @@ -5526,7 +5790,7 @@ int SCSI_Run(int DeviceFD, case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Run SENSE_ABORT\n"); return(-1); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Run SENSE_RETRY\n"); break; @@ -5539,7 +5803,7 @@ int SCSI_Run(int DeviceFD, case SCSI_ERROR: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Run SCSI_ERROR\n"); return(-1); - break; + /*NOTREACHED*/ case SCSI_BUSY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Run SCSI_BUSY\n"); break; @@ -5557,30 +5821,31 @@ int SCSI_Run(int DeviceFD, if (ok == 1) { return(0); - } else { - return(-1); + /*NOTREACHED*/ } + return(-1); } /* * This a vendor specific command !!!!!! * First seen at AIT :-) */ -int SCSI_AlignElements(int DeviceFD, int AE_MTE, int AE_DTE, int AE_STE) +int +SCSI_AlignElements( + int DeviceFD, + size_t AE_MTE, + size_t AE_DTE, + size_t AE_STE) { RequestSense_T *pRequestSense; int retry; CDB_T CDB; - int ret = -1; + int ret; int i; DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START SCSI_AlignElements\n"); - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_AlignElements : malloc failed\n"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); for (retry = 0; retry < MAX_RETRIES; retry++) { @@ -5595,7 +5860,7 @@ int SCSI_AlignElements(int DeviceFD, int AE_MTE, int AE_DTE, int AE_STE) CDB[11] = 0; ret = SCSI_Run(DeviceFD, Input, CDB, 12, - NULL, 0, (char *)pRequestSense, sizeof(RequestSense_T)); + NULL, 0, pRequestSense, SIZEOF(RequestSense_T)); DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_AlignElements : SCSI_Run = %d\n", ret); DecodeSense(pRequestSense, "SCSI_AlignElements :",debug_file); @@ -5603,41 +5868,43 @@ int SCSI_AlignElements(int DeviceFD, int AE_MTE, int AE_DTE, int AE_STE) if (ret < 0) { DebugPrint(DEBUG_ERROR, SECTION_SCSI,"%s: Request Sense[Inquiry]: %02X", - "chs", ((unsigned char *) &pRequestSense)[0]); - for (i = 1; i < sizeof(RequestSense_T); i++) - DebugPrint(DEBUG_ERROR, SECTION_SCSI," %02X", ((unsigned char *) &pRequestSense)[i]); + "chs", ((u_char *) &pRequestSense)[0]); + for (i = 1; i < (int)sizeof(RequestSense_T); i++) + DebugPrint(DEBUG_ERROR, SECTION_SCSI," %02X", ((u_char *) &pRequestSense)[i]); DebugPrint(DEBUG_ERROR, SECTION_SCSI,"\n"); return(ret); + /*NOTREACHED*/ } if ( ret > 0) { - switch(SenseHandler(DeviceFD, 0 , pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch(SenseHandler(DeviceFD, 0 , pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_AlignElements : SENSE_IGNORE\n"); return(0); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_AlignElements : SENSE_RETRY no %d\n", retry); break; case SENSE_ABORT: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_AlignElements : SENSE_ABORT\n"); return(-1); - break; + /*NOTREACHED*/ case SENSE_TAPE_NOT_UNLOADED: DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_AlignElements : Tape still loaded, eject failed\n"); return(-1); - break; + /*NOTREACHED*/ default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_AlignElements : end %d\n", pRequestSense->SenseKey); return(pRequestSense->SenseKey); - break; + /*NOTREACHED*/ } } if (ret == 0) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_AlignElements : end %d\n", ret); return(ret); + /*NOTREACHED*/ } } DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_AlignElements :" @@ -5646,7 +5913,12 @@ int SCSI_AlignElements(int DeviceFD, int AE_MTE, int AE_DTE, int AE_STE) } -int SCSI_Move(int DeviceFD, unsigned char chm, int from, int to) +int +SCSI_Move( + int DeviceFD, + u_char chm, + int from, + int to) { RequestSense_T *pRequestSense; int retry; @@ -5656,11 +5928,7 @@ int SCSI_Move(int DeviceFD, unsigned char chm, int from, int to) DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START SCSI_Move\n"); - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Move : malloc failed\n"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); for (retry = 0; (ret != 0) && (retry < MAX_RETRIES); retry++) { @@ -5676,7 +5944,7 @@ int SCSI_Move(int DeviceFD, unsigned char chm, int from, int to) CDB[11] = 0; ret = SCSI_Run(DeviceFD, Input, CDB, 12, - NULL, 0, (char *)pRequestSense, sizeof(RequestSense_T)); + NULL, 0, pRequestSense, SIZEOF(RequestSense_T)); DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Move : SCSI_Run = %d\n", ret); DecodeSense(pRequestSense, "SCSI_Move :",debug_file); @@ -5684,35 +5952,36 @@ int SCSI_Move(int DeviceFD, unsigned char chm, int from, int to) if (ret < 0) { DebugPrint(DEBUG_ERROR, SECTION_SCSI,"%s: Request Sense[Inquiry]: %02X", - "chs", ((unsigned char *) &pRequestSense)[0]); - for (i = 1; i < sizeof(RequestSense_T); i++) - DebugPrint(DEBUG_ERROR, SECTION_SCSI," %02X", ((unsigned char *) &pRequestSense)[i]); + "chs", ((u_char *) &pRequestSense)[0]); + for (i = 1; i < (int)sizeof(RequestSense_T); i++) + DebugPrint(DEBUG_ERROR, SECTION_SCSI," %02X", ((u_char *) &pRequestSense)[i]); DebugPrint(DEBUG_INFO, SECTION_SCSI,"\n"); return(ret); + /*NOTREACHED*/ } if ( ret > 0) { - switch(SenseHandler(DeviceFD, 0 , pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch(SenseHandler(DeviceFD, 0 , pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: dbprintf(("SCSI_Move : SENSE_IGNORE\n")); return(0); - break; + /*NOTREACHED*/ case SENSE_RETRY: dbprintf(("SCSI_Move : SENSE_RETRY no %d\n", retry)); break; case SENSE_ABORT: dbprintf(("SCSI_Move : SENSE_ABORT\n")); return(-1); - break; + /*NOTREACHED*/ case SENSE_TAPE_NOT_UNLOADED: dbprintf(("SCSI_Move : Tape still loaded, eject failed\n")); return(-1); - break; + /*NOTREACHED*/ default: dbprintf(("SCSI_Move : end %d\n", pRequestSense->SenseKey)); return(pRequestSense->SenseKey); - break; + /*NOTREACHED*/ } } } @@ -5720,7 +5989,12 @@ int SCSI_Move(int DeviceFD, unsigned char chm, int from, int to) return(ret); } -int SCSI_LoadUnload(int DeviceFD, RequestSense_T *pRequestSense, unsigned char byte1, unsigned char load) +int +SCSI_LoadUnload( + int DeviceFD, + RequestSense_T * pRequestSense, + u_char byte1, + u_char load) { CDB_T CDB; int ret; @@ -5737,19 +6011,23 @@ int SCSI_LoadUnload(int DeviceFD, RequestSense_T *pRequestSense, unsigned char b ret = SCSI_Run(DeviceFD, Input, CDB, 6, NULL, 0, - (char *) pRequestSense, - sizeof(RequestSense_T)); + pRequestSense, + SIZEOF(RequestSense_T)); if (ret < 0) { dbprintf(("SCSI_Unload : failed %d\n", ret)); return(-1); + /*NOTREACHED*/ } return(ret); } -int SCSI_TestUnitReady(int DeviceFD, RequestSense_T *pRequestSense) +int +SCSI_TestUnitReady( + int DeviceFD, + RequestSense_T * pRequestSense) { CDB_T CDB; int ret; @@ -5764,9 +6042,9 @@ int SCSI_TestUnitReady(int DeviceFD, RequestSense_T *pRequestSense) CDB[5] = 0; ret = SCSI_ExecuteCommand(DeviceFD, Input, CDB, 6, - NULL, 0, - (char *) pRequestSense, - sizeof(RequestSense_T)); + NULL, (size_t)0, + pRequestSense, + SIZEOF(RequestSense_T)); /* * We got an error, so let the calling function handle this @@ -5775,6 +6053,7 @@ int SCSI_TestUnitReady(int DeviceFD, RequestSense_T *pRequestSense) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"###### STOP SCSI_TestUnitReady (1)\n"); return(ret); + /*NOTREACHED*/ } /* @@ -5785,6 +6064,7 @@ int SCSI_TestUnitReady(int DeviceFD, RequestSense_T *pRequestSense) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"###### STOP SCSI_TestUnitReady (1)\n"); return(0); + /*NOTREACHED*/ } /* @@ -5795,57 +6075,51 @@ int SCSI_TestUnitReady(int DeviceFD, RequestSense_T *pRequestSense) } -int SCSI_ModeSelect(int DeviceFD, char *buffer, unsigned char length, unsigned char save, unsigned char mode, unsigned char lun) +int +SCSI_ModeSelect( + int DeviceFD, + u_char * buffer, + u_char length, + u_char save, + u_char mode, + u_char lun) { CDB_T CDB; RequestSense_T *pRequestSense; int ret = -1; - int retry = 1; - char *sendbuf; + int retry; + u_char *sendbuf; dbprintf(("##### START SCSI_ModeSelect\n")); - dbprintf(("SCSI_ModeSelect start length = %d:\n", length)); - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - dbprintf(("SCSI_ModeSelect : malloc failed\n")); - return(-1); - } - - - if ((sendbuf = (char *)malloc(length + 4)) == NULL) - { - dbprintf(("SCSI_ModeSelect : malloc failed\n")); - free(pRequestSense); - return(-1); - } - - memset(sendbuf, 0 , length + 4); + dbprintf(("SCSI_ModeSelect start length = %u:\n", (unsigned)length)); + pRequestSense = alloc(SIZEOF(RequestSense_T)); + sendbuf = alloc((size_t)length + 4); + memset(sendbuf, 0 , (size_t)length + 4); - memcpy(&sendbuf[4], buffer, length); - dump_hex(sendbuf, length+4, DEBUG_INFO, SECTION_SCSI); + memcpy(&sendbuf[4], buffer, (size_t)length); + dump_hex(sendbuf, (size_t)length+4, DEBUG_INFO, SECTION_SCSI); for (retry = 0; (ret != 0) && (retry < MAX_RETRIES); retry++) { - memset(pRequestSense, 0, sizeof(RequestSense_T)); + memset(pRequestSense, 0, SIZEOF(RequestSense_T)); CDB[0] = SC_COM_MODE_SELECT; - CDB[1] = ((lun << 5) & 0xF0) | ((mode << 4) & 0x10) | (save & 1); + CDB[1] = (u_char)(((lun << 5) & 0xF0) | ((mode << 4) & 0x10) | (save & 1)); CDB[2] = 0; CDB[3] = 0; - CDB[4] = length + 4; + CDB[4] = (u_char)(length + 4); CDB[5] = 0; ret = SCSI_Run(DeviceFD, Output, CDB, 6, sendbuf, - length + 4, - (char *) pRequestSense, - sizeof(RequestSense_T)); + (size_t)length + 4, + pRequestSense, + SIZEOF(RequestSense_T)); if (ret < 0) { dbprintf(("SCSI_ModeSelect : ret %d\n", ret)); - free(pRequestSense); - free(sendbuf); - return(ret); + goto done; + /*NOTREACHED*/ } if ( ret > 0) @@ -5853,27 +6127,27 @@ int SCSI_ModeSelect(int DeviceFD, char *buffer, unsigned char length, unsigned c switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, - (char *)pRequestSense)) + pRequestSense)) { case SENSE_IGNORE: dbprintf(("SCSI_ModeSelect : SENSE_IGNORE\n")); - free(pRequestSense); - free(sendbuf); - return(0); - break; + goto done; + /*NOTREACHED*/ + case SENSE_RETRY: dbprintf(("SCSI_ModeSelect : SENSE_RETRY no %d\n", retry)); break; + default: - dbprintf(("SCSI_ModeSelect : end %d\n", pRequestSense->SenseKey)); - free(pRequestSense); - free(sendbuf); - return(pRequestSense->SenseKey); - break; + ret = pRequestSense->SenseKey; + goto end; } } } +end: dbprintf(("SCSI_ModeSelect end: %d\n", ret)); + +done: free(pRequestSense); free(sendbuf); return(ret); @@ -5881,7 +6155,13 @@ int SCSI_ModeSelect(int DeviceFD, char *buffer, unsigned char length, unsigned c -int SCSI_ModeSense(int DeviceFD, char *buffer, u_char size, u_char byte1, u_char byte2) +int +SCSI_ModeSense( + int DeviceFD, + u_char * buffer, + u_char size, + u_char byte1, + u_char byte2) { CDB_T CDB; RequestSense_T *pRequestSense; @@ -5891,15 +6171,11 @@ int SCSI_ModeSense(int DeviceFD, char *buffer, u_char size, u_char byte1, u_char DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START SCSI_ModeSense\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense start length = %d:\n", size); - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_ModeSense : malloc failed\n"); - return(-1); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); while (ret && retry < MAX_RETRIES) { - memset(pRequestSense, 0, sizeof(RequestSense_T)); + memset(pRequestSense, 0, SIZEOF(RequestSense_T)); memset(buffer, 0, size); CDB[0] = SC_COM_MODE_SENSE; @@ -5911,28 +6187,29 @@ int SCSI_ModeSense(int DeviceFD, char *buffer, u_char size, u_char byte1, u_char ret = SCSI_Run(DeviceFD, Input, CDB, 6, buffer, size, - (char *) pRequestSense, - sizeof(RequestSense_T)); + pRequestSense, + SIZEOF(RequestSense_T)); if (ret < 0) { return(ret); + /*NOTREACHED*/ } if ( ret > 0) { - switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : SENSE_IGNORE\n"); return(0); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : SENSE_RETRY no %d\n", retry); break; default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : end %d\n", pRequestSense->SenseKey); return(pRequestSense->SenseKey); - break; + /*NOTREACHED*/ } } retry++; @@ -5942,23 +6219,25 @@ int SCSI_ModeSense(int DeviceFD, char *buffer, u_char size, u_char byte1, u_char return(ret); } -int SCSI_Inquiry(int DeviceFD, SCSIInquiry_T *buffer, u_char size) +int +SCSI_Inquiry( + int DeviceFD, + SCSIInquiry_T * buffer, + size_t size) { CDB_T CDB; RequestSense_T *pRequestSense; int i; - int ret; + int ret = -1; int retry = 1; + assert(size <= UCHAR_MAX); + DebugPrint(DEBUG_INFO, SECTION_SCSI, "##### START SCSI_Inquiry\n"); DebugPrint(DEBUG_INFO, SECTION_SCSI, "SCSI_Inquiry start length = %d:\n", size); - if ((pRequestSense = (RequestSense_T *)malloc(size)) == NULL) - { - DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_Inquiry : malloc failed\n"); - return(-1); - } + pRequestSense = alloc((size_t)size); while (retry > 0 && retry < MAX_RETRIES) { @@ -5967,47 +6246,49 @@ int SCSI_Inquiry(int DeviceFD, SCSIInquiry_T *buffer, u_char size) CDB[1] = 0; CDB[2] = 0; CDB[3] = 0; - CDB[4] = size; + CDB[4] = (u_char)size; CDB[5] = 0; ret = SCSI_ExecuteCommand(DeviceFD, Input, CDB, 6, buffer, size, - (char *) pRequestSense, - sizeof(RequestSense_T)); + pRequestSense, + SIZEOF(RequestSense_T)); if (ret < 0) { DebugPrint(DEBUG_ERROR, SECTION_SCSI,"%s: Request Sense[Inquiry]: %02X", - "chs", ((unsigned char *) pRequestSense)[0]); - for (i = 1; i < sizeof(RequestSense_T); i++) - DebugPrint(DEBUG_ERROR, SECTION_SCSI," %02X", ((unsigned char *) pRequestSense)[i]); + "chs", ((u_char *) pRequestSense)[0]); + for (i = 1; i < (int)sizeof(RequestSense_T); i++) + DebugPrint(DEBUG_ERROR, SECTION_SCSI," %02X", ((u_char *) pRequestSense)[i]); DebugPrint(DEBUG_ERROR, SECTION_SCSI, "\n"); - DebugPrint(DEBUG_ERROR, SECTION_SCSI, "Inquiry end: %d\n", ret); - return(ret); + DebugPrint(DEBUG_ERROR, SECTION_SCSI, "Inquiry end: %d\n", ret); + return(ret); + /*NOTRACHED*/ } if ( ret > 0) { - switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_Inquiry : SENSE_IGNORE\n"); return(0); - break; + /*NOTREACHED*/ case SENSE_RETRY: DebugPrint(DEBUG_INFO, SECTION_SCSI, "SCSI_Inquiry : SENSE_RETRY no %d\n", retry); break; default: DebugPrint(DEBUG_ERROR, SECTION_SCSI, "SCSI_Inquiry : end %d\n", pRequestSense->SenseKey); return(pRequestSense->SenseKey); - break; + /*NOTREACHED*/ } } retry++; if (ret == 0) { - dump_hex((char *)buffer, size, DEBUG_INFO, SECTION_SCSI); + dump_hex((u_char *)buffer, size, DEBUG_INFO, SECTION_SCSI); DebugPrint(DEBUG_INFO, SECTION_SCSI, "SCSI_Inquiry : end %d\n", ret); return(ret); + /*NOTRACHED*/ } } @@ -6026,17 +6307,19 @@ int SCSI_Inquiry(int DeviceFD, SCSIInquiry_T *buffer, u_char size) * 3. do again an Read Element Status with the result from 2. * */ -int SCSI_ReadElementStatus(int DeviceFD, - unsigned char type, - unsigned char lun, - unsigned char VolTag, - int StartAddress, - int NoOfElements, - int DescriptorSize, - char **data) +int +SCSI_ReadElementStatus( + int DeviceFD, + u_char type, + u_char lun, + u_char VolTag, + int StartAddress, + size_t NoOfElements, + size_t DescriptorSize, + u_char ** data) { CDB_T CDB; - int DataBufferLength; + size_t DataBufferLength; ElementStatusData_T *ElementStatusData; RequestSense_T *pRequestSense; int retry = 1; @@ -6044,47 +6327,35 @@ int SCSI_ReadElementStatus(int DeviceFD, DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### START SCSI_ReadElementStatus\n"); - if ((pRequestSense = (RequestSense_T *)malloc(sizeof(RequestSense_T))) == NULL) - { - DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ReadElementStatus : malloc failed\n"); - ChgExit("SCSI_ReadElementStatus","malloc failed", FATAL); - } + pRequestSense = alloc(SIZEOF(RequestSense_T)); /* * How many elements, if <= 0 than exit with an fatal error */ - if (NoOfElements <= 0) + if (NoOfElements == 0) { ChgExit("SCSI_ReadElementStatus","No of Elements passed are le 0",FATAL); + /*NOTREACHED*/ } - VolTag = (VolTag << 4) & 0x10; - type = type & 0xf; - lun = (lun << 5) & 0xe0; - + VolTag = (u_char)((VolTag << 4) & 0x10); + type = (u_char)(type & 0xf); + lun = (u_char)((lun << 5) & 0xe0); /* if DescriptorSize == 0 * try to get the allocation length for the second call */ if (DescriptorSize == 0) { - if (*data != NULL) - { - *data = realloc(*data, 8); - } else { - *data = malloc(8); - } - + *data = newalloc(*data, 8); memset(*data, 0, 8); - - while (retry > 0 && retry < MAX_RETRIES) { - memset(pRequestSense, 0, sizeof(RequestSense_T) ); + memset(pRequestSense, 0, SIZEOF(RequestSense_T) ); CDB[0] = SC_COM_RES; /* READ ELEMENT STATUS */ - CDB[1] = VolTag | type | lun; /* Element Type Code , VolTag, LUN */ + CDB[1] = (u_char)(VolTag | type | lun); /* Element Type Code , VolTag, LUN */ MSB2(&CDB[2], StartAddress); /* Starting Element Address */ MSB2(&CDB[4], NoOfElements); /* Number Of Element */ CDB[6] = 0; /* Reserved */ @@ -6094,8 +6365,7 @@ int SCSI_ReadElementStatus(int DeviceFD, ret = SCSI_Run(DeviceFD, Input, CDB, 12, *data, 8, - (char *)pRequestSense, sizeof(RequestSense_T)); - + pRequestSense, SIZEOF(RequestSense_T)); DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ReadElementStatus : (1) SCSI_Run %d\n", ret); if (ret < 0) @@ -6103,10 +6373,11 @@ int SCSI_ReadElementStatus(int DeviceFD, DecodeSense(pRequestSense, "SCSI_ReadElementStatus :",debug_file); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP SCSI_ReadElementStatus (%d)\n",ret); return(ret); + /*NOTRACHED*/ } if ( ret > 0) { - switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : SENSE_IGNORE\n"); @@ -6119,7 +6390,7 @@ int SCSI_ReadElementStatus(int DeviceFD, default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : end %d\n", pRequestSense->SenseKey); return(pRequestSense->SenseKey); - break; + /*NOTREACHED*/ } } retry++; @@ -6132,6 +6403,7 @@ int SCSI_ReadElementStatus(int DeviceFD, { DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP SCSI_ReadElementStatus (%d)\n",ret); return(ret); + /*NOTRACHED*/ } ElementStatusData = (ElementStatusData_T *)*data; @@ -6145,16 +6417,16 @@ int SCSI_ReadElementStatus(int DeviceFD, } DataBufferLength = DataBufferLength + 8; - *data = realloc(*data, DataBufferLength); + *data = newalloc(*data, DataBufferLength); memset(*data, 0, DataBufferLength); retry = 1; while (retry > 0 && retry < MAX_RETRIES) { - memset(pRequestSense, 0, sizeof(RequestSense_T) ); + memset(pRequestSense, 0, SIZEOF(RequestSense_T) ); CDB[0] = SC_COM_RES; /* READ ELEMENT STATUS */ - CDB[1] = VolTag | type | lun; /* Element Type Code, VolTag, LUN */ + CDB[1] = (u_char)(VolTag | type | lun); /* Element Type Code, VolTag, LUN */ MSB2(&CDB[2], StartAddress); /* Starting Element Address */ MSB2(&CDB[4], NoOfElements); /* Number Of Element */ CDB[6] = 0; /* Reserved */ @@ -6164,7 +6436,7 @@ int SCSI_ReadElementStatus(int DeviceFD, ret = SCSI_Run(DeviceFD, Input, CDB, 12, *data, DataBufferLength, - (char *)pRequestSense, sizeof(RequestSense_T)); + pRequestSense, SIZEOF(RequestSense_T)); DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ReadElementStatus : (2) SCSI_Run %d\n", ret); @@ -6173,10 +6445,11 @@ int SCSI_ReadElementStatus(int DeviceFD, DecodeSense(pRequestSense, "SCSI_ReadElementStatus :",debug_file); DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP SCSI_ReadElementStatus (%d)\n",ret); return(ret); + /*NOTRACHED*/ } if ( ret > 0) { - switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, (char *)pRequestSense)) + switch(SenseHandler(DeviceFD, 0, pRequestSense->SenseKey, pRequestSense->AdditionalSenseCode, pRequestSense->AdditionalSenseCodeQualifier, pRequestSense)) { case SENSE_IGNORE: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : SENSE_IGNORE\n"); @@ -6189,7 +6462,7 @@ int SCSI_ReadElementStatus(int DeviceFD, default: DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_ModeSense : end %d\n", pRequestSense->SenseKey); return(pRequestSense->SenseKey); - break; + /*NOTREACHED*/ } } retry++; @@ -6203,6 +6476,7 @@ int SCSI_ReadElementStatus(int DeviceFD, { DebugPrint(DEBUG_INFO, SECTION_SCSI,"##### STOP SCSI_ReadElementStatus (%d)\n",ret); return(ret); + /*NOTRACHED*/ } dump_hex(*data, DataBufferLength, DEBUG_INFO, SECTION_SCSI); @@ -6214,22 +6488,25 @@ printf_arglist_function2(void DebugPrint, int, level, int, section, char *, fmt) { va_list argp; char buf[1024]; - extern changer_t chg; - int dlevel,dsection; + int dlevel; + int dsection = -1; + time_t ti = time(NULL); - time_t ti; - - time(&ti); - if (chg.debuglevel) + if (changer->debuglevel) { - sscanf(chg.debuglevel,"%d:%d", &dlevel, &dsection); + if (sscanf(changer->debuglevel,"%d:%d", &dlevel, &dsection) != 2) { + dbprintf(("Parse error: line is '%s' expected [0-9]*:[0-9]*\n", + changer->debuglevel)); + dlevel=1; + dsection=1; + } } else { dlevel=1; dsection=1; } arglist_start(argp, fmt); - vsnprintf(buf, sizeof(buf), fmt, argp); + vsnprintf(buf, SIZEOF(buf), fmt, argp); if (dlevel >= level) { if (section == dsection || dsection == 0) diff --git a/changer-src/scsi-chio.c b/changer-src/scsi-chio.c index fd8d3ee..87c6157 100644 --- a/changer-src/scsi-chio.c +++ b/changer-src/scsi-chio.c @@ -1,5 +1,5 @@ /* - * $Id: scsi-chio.c,v 1.13 2000/06/25 18:48:11 ant Exp $ + * $Id: scsi-chio.c,v 1.14 2006/05/25 01:47:07 johnfranks Exp $ * * scsi-chio.c -- library routines to handle the changer * support for chio based systems @@ -12,6 +12,7 @@ #include "config.h" #include "amanda.h" +#include "scsi-defs.h" #if (defined(HAVE_CHIO_H) || defined(HAVE_SYS_CHIO_H)) \ && !defined(HAVE_CAMLIB_H) @@ -305,6 +306,7 @@ int CloseDevice (char *device, int DeviceFD) { int ret; + dbprintf(("%s: CloseDevice(%s)\n", device, get_pname())); ret = close(DeviceFD); return ret; diff --git a/changer-src/scsi-defs.h b/changer-src/scsi-defs.h index 3b8a36c..b32a180 100644 --- a/changer-src/scsi-defs.h +++ b/changer-src/scsi-defs.h @@ -2,6 +2,9 @@ /* * Copyright (c) 1998 T.Hepper */ +#ifndef SCSIDEFS_H +#define SCSIDEFS_H + #ifndef WORDS_BIGENDIAN #define LITTLE_ENDIAN_BITFIELDS #endif @@ -53,7 +56,7 @@ typedef unsigned char PackedBit; #define MAX_RETRIES 100 -#define INQUIRY_SIZE sizeof(SCSIInquiry_T) +#define INQUIRY_SIZE SIZEOF(SCSIInquiry_T) /* * Return values from the OS dependent part @@ -134,10 +137,10 @@ typedef unsigned char PackedBit; /* macros for building scsi msb array parameter lists */ #ifndef B -#define B(s,i) ((unsigned char)((s) >> i)) +#define B(s,i) ((unsigned char)(((s) >> (i)) & 0xff)) #endif #ifndef B1 -#define B1(s) ((unsigned char)(s)) +#define B1(s) ((unsigned char)((s) & 0xff)) #endif #define B2(s) B((s),8), B1(s) #define B3(s) B((s),16), B((s),8), B1(s) @@ -152,10 +155,10 @@ typedef unsigned char PackedBit; #define V6(s) (((((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4]) << 8) | (s)[5]) /* macros for converting binary into scsi msb array */ -#define MSB1(s,v) *(s)=B1(v) -#define MSB2(s,v) *(s)=B(v,8), (s)[1]=B1(v) -#define MSB3(s,v) *(s)=B(v,16), (s)[1]=B(v,8), (s)[2]=B1(v) -#define MSB4(s,v) *(s)=B(v,24),(s)[1]=B(v,16), (s)[2]=B(v,8), (s)[3]=B1(v) +#define MSB1(s,v) (s)[0]=B1(v) +#define MSB2(s,v) (s)[0]=B(v,8), (s)[1]=B1(v) +#define MSB3(s,v) (s)[0]=B(v,16), (s)[1]=B(v,8), (s)[2]=B1(v) +#define MSB4(s,v) (s)[0]=B(v,24), (s)[1]=B(v,16), (s)[2]=B(v,8), (s)[3]=B1(v) #define LABEL_DB_VERSION 2 @@ -174,17 +177,17 @@ typedef unsigned char PackedBit; /*----------------------------------------------------------------------------*/ /* Some stuff for our own configurationfile */ typedef struct { /* The information we can get for any drive (configuration) */ - int drivenum; /* Which drive to use in the library */ - int start; /* Which is the first slot we may use */ - int end; /* The last slot we are allowed to use */ - int cleanslot; /* Where the cleaningcartridge stays */ + int drivenum; /* Which drive to use in the library */ + int start; /* Which is the first slot we may use */ + int end; /* The last slot we are allowed to use */ + int cleanslot; /* Where the cleaningcartridge stays */ char *scsitapedev; /* Where can we send raw SCSI commands to the tape */ char *device; /* Which device is associated to the drivenum */ char *slotfile; /* Where we should have our memory */ char *cleanfile; /* Where we count how many cleanings we did */ char *timefile; /* Where we count the time the tape was used*/ char *tapestatfile;/* Where can we place some drive stats */ - char *changerident;/* Config to use foe changer control, ovverride result from inquiry */ + char *changerident;/* Config to use for changer control, ovverride result from inquiry */ char *tapeident; /* Same as above for the tape device */ }config_t; @@ -195,7 +198,7 @@ typedef struct { int havebarcode; /* Do we have an barcode reader installed */ char *debuglevel; /* How many debug info to print */ unsigned char emubarcode; /* Emulate the barcode feature, used for keeping an inventory of the lib */ - int sleep; /* How many seconds to wait for the drive to get ready */ + time_t sleep; /* How many seconds to wait for the drive to get ready */ int cleanmax; /* How many runs could be done with one cleaning tape */ char *device; /* Which device is our changer */ char *labelfile; /* Mapping from Barcode labels to volume labels */ @@ -211,10 +214,10 @@ typedef struct { typedef struct { char voltag[128]; /* Tape volume label */ char barcode[TAG_SIZE]; /* Barcode of the tape */ - unsigned int slot; /* in which slot is the tape */ - unsigned int from; /* from where it comes, needed to move - * a tape back to the right slot from the drive - */ + int slot; /* in which slot is the tape */ + int from; /* from where it comes, needed to move a tape + * back to the right slot from the drive + */ unsigned int LoadCount; /* How many times has the tape been loaded */ unsigned int RecovError; /* How many recovered errors */ @@ -1053,8 +1056,8 @@ typedef struct ElementInfo int from; /* From where did it come */ char status; /* F -> Full, E -> Empty */ char VolTag[TAG_SIZE+1]; /* Label Info if Barcode reader exsist */ - int ASC; /* Additional Sense Code from read element status */ - int ASCQ; /* */ + unsigned char ASC; /* Additional Sense Code from read element status */ + unsigned char ASCQ; /* */ unsigned char scsi; /* if DTE, which scsi address */ PackedBit svalid : 1; @@ -1076,13 +1079,13 @@ typedef struct { int (*function_move)(int, int, int); int (*function_status)(int, int); int (*function_reset_status)(int); - int (*function_free)(); + int (*function_free)(void); int (*function_eject)(char *, int); int (*function_clean)(char *); int (*function_rewind)(int); int (*function_barcode)(int); - int (*function_search)(); - int (*function_error)(int, int, unsigned char, unsigned char, unsigned char, char *); + int (*function_search)(void); + int (*function_error)(int, unsigned char, unsigned char, unsigned char, unsigned char, RequestSense_T *); } ChangerCMD_T ; typedef struct { @@ -1112,71 +1115,90 @@ typedef struct OpenFiles { typedef struct LogPageDecode { int LogPage; char *ident; - void (*decode)(LogParameter_T *, int); + void (*decode)(LogParameter_T *, size_t); } LogPageDecode_T; typedef struct { - char *ident; /* Ident as returned from the inquiry */ - char *vendor; /* Vendor as returned from the inquiry */ - int type; /* removable .... */ - int sense; /* Sense key as returned from the device */ - int asc; /* ASC as set in the sense struct */ - int ascq; /* ASCQ as set in the sense struct */ - int ret; /* What we think that we should return on this conditon */ - char text[80]; /* A short text describing this condition */ + char *ident; /* Ident as returned from the inquiry */ + char *vendor; /* Vendor as returned from the inquiry */ + unsigned char type; /* removable .... */ + unsigned char sense;/* Sense key as returned from the device */ + unsigned char asc; /* ASC as set in the sense struct */ + unsigned char ascq; /* ASCQ as set in the sense struct */ + int ret; /* What we think that we should return on this conditon */ + char text[80]; /* A short text describing this condition */ } SenseType_T; /* ======================================================= */ -/* Funktion-Declaration */ +/* Function-Declaration */ /* ======================================================= */ -int SCSI_OpenDevice(int ); -int OpenDevice(int ,char *DeviceName, char *ConfigName, char *ident); +int SCSI_OpenDevice(int); +int OpenDevice(int, char *DeviceName, char *ConfigName, char *ident); int SCSI_CloseDevice(int DeviceFD); -int CloseDevice(int ); +int CloseDevice(char *, int); int Tape_Eject(int); int Tape_Status(int); -void DumpSense(); -int Sense2Action(char *ident, unsigned char type, unsigned char ignsense, unsigned char sense, unsigned -char asc, unsigned char ascq, char **text) ; +void DumpSense(void); +int Sense2Action(char *ident, + unsigned char type, + unsigned char ignsense, + unsigned char sense, + unsigned char asc, + unsigned char ascq, + char **text); int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *RequestSense, - int RequestSenseLength); - -int Tape_Ioctl( int DeviceFD, int command); -void ChangerStatus(char * option, char * labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device); - -int SCSI_Inquiry(int, SCSIInquiry_T *, unsigned char); + size_t DataBufferLength, + RequestSense_T *RequestSense, + size_t RequestSenseLength); + +int Tape_Ioctl(int DeviceFD, int command); +void ChangerStatus(char * option, + char * labelfile, + int HasBarCode, + char *changer_file, + char *changer_dev, + char *tape_device); + +int SCSI_Inquiry(int, SCSIInquiry_T *, size_t); int PrintInquiry(SCSIInquiry_T *); int DecodeSCSI(CDB_T CDB, char *string); -int RequestSense P((int fd, ExtendedRequestSense_T *s, int ClearErrorCounters)); -int DecodeSense P((RequestSense_T *sense, char *pstring, FILE *out)); -int DecodeExtSense P((ExtendedRequestSense_T *sense, char *pstring, FILE *out)); +int RequestSense(int fd, ExtendedRequestSense_T *s, int ClearErrorCounters); +int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out); +int DecodeExtSense(ExtendedRequestSense_T *sense, char *pstring, FILE *out); void ChgExit(char *, char *, int); void ChangerReplay(char *option); -void ChangerStatus(char * option, char * labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device); +void ChangerStatus(char *option, char *labelfile, int HasBarCode, char *changer_file, char *changer_dev, char *tape_device); int BarCode(int fd); int MapBarCode(char *labelfile, MBC_T *); -int Tape_Ready(int fd, int wait_time); +int Tape_Ready(int fd, time_t wait_time); void Inventory(char *labelfile, int drive, int eject, int start, int stop, int clean); -void ChangerDriverVersion(); -void PrintConf(); +void ChangerDriverVersion(void); +void PrintConf(void); int LogSense(int fd); int ScanBus(int print); void DebugPrint(int level, int section, char * fmt, ...); int DecodeSense(RequestSense_T *sense, char *pstring, FILE *out); -void SCSI_OS_Version(); +void SCSI_OS_Version(void); +int get_clean_state(char *tapedev); +int find_empty(int fd, int start, int count); +int get_slot_count(int fd); +int get_drive_count(int fd); +int GetCurrentSlot(int fd, int drive); +void DumpDev(OpenFiles_T *p, char *device); +int isempty(int fd, int slot); + +#endif /* !SCSIDEFS_H */ /* * Local variables: * indent-tabs-mode: nil diff --git a/changer-src/scsi-hpux.c b/changer-src/scsi-hpux.c index d7ae82f..56179b1 100644 --- a/changer-src/scsi-hpux.c +++ b/changer-src/scsi-hpux.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-hpux.c,v 1.14 2001/02/08 19:19:08 ant Exp $ + * $Id: scsi-hpux.c,v 1.15 2006/05/25 01:47:07 johnfranks Exp $ * * scsi-chio.c -- library routines to handle the changer * support for chio based systems @@ -64,7 +64,7 @@ int GetCurrentSlot(int fd) static int get_changer_info(fd) { -int rc = 0; + int rc = 0; if (!changer_info_init) { rc = ioctl(fd, SIOC_ELEMENT_ADDRESSES, &changer_info); @@ -89,7 +89,7 @@ int get_clean_state(char *dev) perror(dev); return 0; } - memset(buffer, 0, sizeof(buffer)); + memset(buffer, 0, SIZEOF(buffer)); *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = 100; /* length of output buffer */ @@ -168,7 +168,7 @@ int rc; /* * find the first empty slot */ -int find_empty(int fd) +int find_empty(int fd, int start, int count) { struct element_status es; int i, rc; @@ -326,14 +326,16 @@ int OpenDevice(char * tapedev) int DeviceFD; DeviceFD = open(tapedev, O_RDWR); + dbprintf(("%s: OpenDevice(%s) returns %d\n", get_pname(), tapedev, DeviceFD)); return(DeviceFD); } -int CloseDevice(int DeviceFD) +int CloseDevice(char *device, int DeviceFD) { int ret; ret = close(DeviceFD); + dbprintf(("%s: CloseDevice(%s) returns %d\n", get_pname(), device, ret)); return(ret); } diff --git a/changer-src/scsi-hpux_new.c b/changer-src/scsi-hpux_new.c index c046734..e96ed47 100644 --- a/changer-src/scsi-hpux_new.c +++ b/changer-src/scsi-hpux_new.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-hpux_new.c,v 1.18 2005/10/15 13:20:47 martinea Exp $ + * $Id: scsi-hpux_new.c,v 1.19 2006/05/25 01:47:08 johnfranks Exp $ * * Interface to execute SCSI commands on an HP-UX Workstation * @@ -49,10 +49,8 @@ #ifdef HAVE_SYS_IOCTL_H #include #endif -#ifdef HAVE_SYS_SCSI_H -#include -#endif +#include #include #include @@ -60,7 +58,7 @@ void SCSI_OS_Version() { #ifndef lint - static char rcsid[] = "$Id: scsi-hpux_new.c,v 1.18 2005/10/15 13:20:47 martinea Exp $"; + static char rcsid[] = "$Id: scsi-hpux_new.c,v 1.19 2006/05/25 01:47:08 johnfranks Exp $"; DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } @@ -111,13 +109,11 @@ int SCSI_OpenDevice(int ip) free(pDev[ip].inquiry); return(0); } - } else { - close(DeviceFD); - free(pDev[ip].inquiry); - pDev[ip].inquiry = NULL; - return(1); } - return(1); + close(DeviceFD); + free(pDev[ip].inquiry); + pDev[ip].inquiry = NULL; + return(1); } } else { if ((DeviceFD = open(pDev[ip].dev, O_RDWR| O_NDELAY)) >= 0) @@ -144,25 +140,31 @@ int SCSI_CloseDevice(int DeviceFD) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *RequestSense, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *RequestSenseBuf, + size_t RequestSenseLength) { extern OpenFiles_T *pDev; struct sctl_io sctl_io; - extern int errno; int Retries = 3; int Zero = 0, Result; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(RequestSenseBuf, 0, RequestSenseLength); + if (pDev[DeviceFD].avail == 0) { return(SCSI_ERROR); } - memset(&sctl_io, '\0', sizeof(struct sctl_io)); + memset(&sctl_io, '\0', SIZEOF(struct sctl_io)); sctl_io.flags = 0; sctl_io.max_msecs = 240000; @@ -206,18 +208,18 @@ int SCSI_ExecuteCommand(int DeviceFD, SCSI_CloseDevice(DeviceFD); - memcpy(RequestSense, sctl_io.sense, RequestSenseLength); + memcpy(RequestSenseBuf, sctl_io.sense, RequestSenseLength); switch(sctl_io.cdb_status) { case S_GOOD: return(SCSI_OK); + case S_CHECK_CONDITION: return(SCSI_CHECK); - break; + default: return(SCSI_ERROR); - break; } } return(SCSI_ERROR); @@ -242,13 +244,14 @@ int Tape_Ioctl( int DeviceFD, int command) mtop.mt_op = MTOFFL; mtop.mt_count = 1; break; + default: break; } if (ioctl(pDev[DeviceFD].fd , MTIOCTOP, &mtop) != 0) { - dbprintf(("Tape_Ioctl error ioctl %d\n",errno)); + dbprintf(("Tape_Ioctl error ioctl %s\n", strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -271,7 +274,7 @@ int Tape_Status( int DeviceFD) if (ioctl(pDev[DeviceFD].fd, MTIOCGET, &mtget) != 0) { - dbprintf(("Tape_Status error ioctl %d\n",errno)); + dbprintf(("Tape_Status error ioctl %s\n", strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } diff --git a/changer-src/scsi-irix.c b/changer-src/scsi-irix.c index b747884..f018ceb 100644 --- a/changer-src/scsi-irix.c +++ b/changer-src/scsi-irix.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-irix.c,v 1.22 2005/10/15 13:20:47 martinea Exp $ + * $Id: scsi-irix.c,v 1.23 2006/05/25 01:47:08 johnfranks Exp $ * * Interface to execute SCSI commands on an SGI Workstation * @@ -62,7 +62,7 @@ void SCSI_OS_Version() { #ifndef lint - static char rcsid[] = "$Id: scsi-irix.c,v 1.22 2005/10/15 13:20:47 martinea Exp $"; + static char rcsid[] = "$Id: scsi-irix.c,v 1.23 2006/05/25 01:47:08 johnfranks Exp $"; DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } @@ -116,23 +116,13 @@ int SCSI_OpenDevice(int ip) pDev[ip].avail = 0; return(0); } - } else { /* inquiry failed */ - close(DeviceFD); - free(pDev[ip].inquiry); - pDev[ip].inquiry = NULL; - pDev[ip].avail = 0; - return(0); } - - /* - * Open ok, but no SCSI communication available - */ - - free(pDev[ip].inquiry); - pDev[ip].inquiry = NULL; - close(DeviceFD); - pDev[ip].avail = 0; - return(0); + /* inquiry failed or no SCSI communication available */ + close(DeviceFD); + free(pDev[ip].inquiry); + pDev[ip].inquiry = NULL; + pDev[ip].avail = 0; + return(0); } } else { if ((DeviceFD = open(pDev[ip].dev, O_RDWR | O_EXCL)) >= 0) @@ -165,11 +155,11 @@ int SCSI_CloseDevice(int DeviceFD) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *pRequestSense, + size_t RequestSenseLength) { extern OpenFiles_T *pDev; ExtendedRequestSense_T ExtendedRequestSense; @@ -177,14 +167,21 @@ int SCSI_ExecuteCommand(int DeviceFD, int Result; int retries = 5; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(pRequestSense, 0, RequestSenseLength); + if (pDev[DeviceFD].avail == 0) { return(SCSI_ERROR); } - memset(&ds, 0, sizeof(struct dsreq)); + memset(&ds, 0, SIZEOF(struct dsreq)); memset(pRequestSense, 0, RequestSenseLength); - memset(&ExtendedRequestSense, 0 , sizeof(ExtendedRequestSense_T)); + memset(&ExtendedRequestSense, 0 , SIZEOF(ExtendedRequestSense_T)); ds.ds_flags = DSRQ_SENSE|DSRQ_TRACE|DSRQ_PRINT; /* Timeout */ @@ -236,35 +233,28 @@ int SCSI_ExecuteCommand(int DeviceFD, { case ST_BUSY: /* BUSY */ break; + case STA_RESERV: /* RESERV CONFLICT */ if (retries > 0) sleep(2); continue; + case ST_GOOD: /* GOOD 0x00 */ switch (RET(&ds)) { case DSRT_SENSE: return(SCSI_SENSE); - break; - case DSRT_SHORT: - return(SCSI_OK); - break; - case DSRT_OK: - default: - return(SCSI_OK); } + return(SCSI_OK); + case ST_CHECK: /* CHECK CONDITION 0x02 */ switch (RET(&ds)) { case DSRT_SENSE: return(SCSI_SENSE); - break; - default: - return(SCSI_CHECK); - break; } return(SCSI_CHECK); - break; + case ST_COND_MET: /* INTERM/GOOD 0x10 */ default: continue; @@ -313,7 +303,7 @@ int Tape_Status( int DeviceFD) if (ioctl(pDev[DeviceFD].fd , MTIOCGET, &mtget) != 0) { - dbprintf(("Tape_Status error ioctl %d\n",errno)); + dbprintf(("Tape_Status error ioctl %s\n",strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } diff --git a/changer-src/scsi-linux.c b/changer-src/scsi-linux.c index 750bd62..9885349 100644 --- a/changer-src/scsi-linux.c +++ b/changer-src/scsi-linux.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-linux.c,v 1.28 2006/03/09 20:06:10 johnfranks Exp $ + * $Id: scsi-linux.c,v 1.30 2006/07/06 11:57:28 martinea Exp $ * * Interface to execute SCSI commands on Linux * @@ -78,18 +78,18 @@ #include +extern OpenFiles_T *pDev; -void SCSI_OS_Version() +void SCSI_OS_Version(void) { #ifndef lint - static char rcsid[] = "$Id: scsi-linux.c,v 1.28 2006/03/09 20:06:10 johnfranks Exp $"; + static char rcsid[] = "$Id: scsi-linux.c,v 1.30 2006/07/06 11:57:28 martinea Exp $"; DebugPrint(DEBUG_ERROR, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } int SCSI_CloseDevice(int DeviceFD) { - extern OpenFiles_T *pDev; int ret = 0; if (pDev[DeviceFD].devopen == 1) @@ -114,7 +114,6 @@ int SCSI_CloseDevice(int DeviceFD) #ifdef LINUX_SG int SCSI_OpenDevice(int ip) { - extern OpenFiles_T *pDev; int DeviceFD; int i; int timeout; @@ -134,12 +133,12 @@ int SCSI_OpenDevice(int ip) if (S_ISLNK(pstat.st_mode) == 1) { DebugPrint(DEBUG_INFO, SECTION_SCSI,"SCSI_OpenDevice : is a link, checking destination\n"); - if ((buffer = (char *)malloc(512)) == NULL) + if ((buffer = (char *)malloc(513)) == NULL) { DebugPrint(DEBUG_ERROR, SECTION_SCSI,"SCSI_OpenDevice : malloc failed\n"); return(0); } - memset(buffer, 0, 512); + memset(buffer, 0, 513); if (( i = readlink(pDev[ip].dev, buffer, 512)) == -1) { if (errno == ENAMETOOLONG ) @@ -206,7 +205,7 @@ int SCSI_OpenDevice(int ip) } } pDev[ip].inquiry = (SCSIInquiry_T *)malloc(INQUIRY_SIZE); - if (SCSI_Inquiry(ip, pDev[ip].inquiry, INQUIRY_SIZE) == 0) + if (SCSI_Inquiry(ip, pDev[ip].inquiry, (u_char)INQUIRY_SIZE) == 0) { if (pDev[ip].inquiry->type == TYPE_TAPE || pDev[ip].inquiry->type == TYPE_CHANGER) { @@ -288,21 +287,27 @@ int SCSI_OpenDevice(int ip) return(0); } -#define SCSI_OFF sizeof(struct sg_header) +#define SCSI_OFF SIZEOF(struct sg_header) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *pRequestSense, + size_t RequestSenseLength) { - extern OpenFiles_T *pDev; struct sg_header *psg_header; char *buffer; - int osize = 0; - int status; + size_t osize = 0; + ssize_t status; + + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(pRequestSense, 0, RequestSenseLength); if (pDev[DeviceFD].avail == 0) { @@ -337,7 +342,7 @@ int SCSI_ExecuteCommand(int DeviceFD, psg_header->twelve_byte = 0; } psg_header->result = 0; - psg_header->reply_len = SCSI_OFF + DataBufferLength; + psg_header->reply_len = (int)(SCSI_OFF + DataBufferLength); switch (Direction) { @@ -352,8 +357,9 @@ int SCSI_ExecuteCommand(int DeviceFD, DecodeSCSI(CDB, "SCSI_ExecuteCommand : "); status = write(pDev[DeviceFD].fd, buffer, SCSI_OFF + CDB_Length + osize); - if ( status < 0 || status != SCSI_OFF + CDB_Length + osize || - psg_header->result ) + if ( (status < (ssize_t)0) || + (status != (ssize_t)(SCSI_OFF + CDB_Length + osize)) || + (psg_header->result != 0)) { dbprintf(("SCSI_ExecuteCommand error send \n")); SCSI_CloseDevice(DeviceFD); @@ -366,8 +372,9 @@ int SCSI_ExecuteCommand(int DeviceFD, memset(pRequestSense, 0, RequestSenseLength); memcpy(pRequestSense, psg_header->sense_buffer, 16); - if ( status < 0 || status != SCSI_OFF + DataBufferLength || - psg_header->result ) + if ( (status < 0) || + (status != (ssize_t)(SCSI_OFF + DataBufferLength)) || + (psg_header->result != 0)) { dbprintf(("SCSI_ExecuteCommand error read \n")); dbprintf(("Status %d (%d) %2X\n", status, SCSI_OFF + DataBufferLength,psg_header->result )); @@ -401,7 +408,6 @@ static inline int max(int x, int y) int SCSI_OpenDevice(int ip) { - extern OpenFiles_T *pDev; int DeviceFD; int i; @@ -415,7 +421,7 @@ int SCSI_OpenDevice(int ip) pDev[ip].SCSI = 0; pDev[ip].inquiry = (SCSIInquiry_T *)malloc(INQUIRY_SIZE); dbprintf(("SCSI_OpenDevice : use ioctl interface\n")); - if (SCSI_Inquiry(ip, pDev[ip].inquiry, INQUIRY_SIZE) == 0) + if (SCSI_Inquiry(ip, pDev[ip].inquiry, (u_char)INQUIRY_SIZE) == 0) { if (pDev[ip].inquiry->type == TYPE_TAPE || pDev[ip].inquiry->type == TYPE_CHANGER) { @@ -457,10 +463,9 @@ int SCSI_ExecuteCommand(int DeviceFD, int CDB_Length, void *DataBuffer, int DataBufferLength, - char *pRequestSense, + RequestSense_T *pRequestSense, int RequestSenseLength) { - extern OpenFiles_T *pDev; unsigned char *Command; int Zero = 0, Result; @@ -523,7 +528,6 @@ int SCSI_ExecuteCommand(int DeviceFD, */ int Tape_Ioctl( int DeviceFD, int command) { - extern OpenFiles_T *pDev; struct mtop mtop; int ret = 0; @@ -545,7 +549,7 @@ int Tape_Ioctl( int DeviceFD, int command) if (ioctl(pDev[DeviceFD].fd , MTIOCTOP, &mtop) != 0) { - dbprintf(("Tape_Ioctl error ioctl %d\n",errno)); + dbprintf(("Tape_Ioctl error ioctl %s\n",strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -556,10 +560,10 @@ int Tape_Ioctl( int DeviceFD, int command) int Tape_Status( int DeviceFD) { - extern OpenFiles_T *pDev; struct mtget mtget; int ret = 0; + memset(&mtget, 0, SIZEOF(mtget)); if (pDev[DeviceFD].devopen == 0) { if (SCSI_OpenDevice(DeviceFD) == 0) @@ -568,7 +572,8 @@ int Tape_Status( int DeviceFD) if (ioctl(pDev[DeviceFD].fd , MTIOCGET, &mtget) != 0) { - DebugPrint(DEBUG_ERROR, SECTION_TAPE,"Tape_Status error ioctl %d\n",errno); + DebugPrint(DEBUG_ERROR, SECTION_TAPE,"Tape_Status error ioctl %s\n", + strerror(errno)); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -612,8 +617,6 @@ int ScanBus(int print) { DIR *dir; struct dirent *dirent; - extern OpenFiles_T *pDev; - extern int errno; int count = 0; if ((dir = opendir("/dev/")) == NULL) @@ -628,7 +631,8 @@ int ScanBus(int print) { pDev[count].dev = malloc(10); pDev[count].inqdone = 0; - sprintf(pDev[count].dev,"/dev/%s", dirent->d_name); + snprintf(pDev[count].dev, SIZEOF(pDev[count].dev), + "/dev/%s", dirent->d_name); if (OpenDevice(count,pDev[count].dev, "Scan", NULL )) { SCSI_CloseDevice(count); diff --git a/changer-src/scsi-proto.c b/changer-src/scsi-proto.c index 7aa6f86..8f6fd77 100644 --- a/changer-src/scsi-proto.c +++ b/changer-src/scsi-proto.c @@ -1,5 +1,5 @@ /* - * $Id: scsi-proto.c,v 1.3 1998/06/13 06:13:25 oliva Exp $ + * $Id: scsi-proto.c,v 1.4 2006/05/25 01:47:10 johnfranks Exp $ * * scsi-proto.c -- library routines to handle the changer * Prototype file for customization @@ -55,7 +55,7 @@ void eject_tape(char *tape) /* * find the first empty slot */ -int find_empty(int fd) +int find_empty( int fd, int start, int end) { /* * find an empty slot to insert a tape into (if required) diff --git a/changer-src/scsi-solaris.c b/changer-src/scsi-solaris.c index c20003f..eb9bd77 100644 --- a/changer-src/scsi-solaris.c +++ b/changer-src/scsi-solaris.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: scsi-solaris.c,v 1.25 2005/10/15 13:20:47 martinea Exp $ + * $Id: scsi-solaris.c,v 1.26 2006/05/25 01:47:10 johnfranks Exp $ * * Interface to execute SCSI commands on an Sun Workstation * @@ -60,7 +60,7 @@ void SCSI_OS_Version() { #ifndef lint - static char rcsid[] = "$Id: scsi-solaris.c,v 1.25 2005/10/15 13:20:47 martinea Exp $"; + static char rcsid[] = "$Id: scsi-solaris.c,v 1.26 2006/05/25 01:47:10 johnfranks Exp $"; DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid); #endif } @@ -82,7 +82,7 @@ int SCSI_OpenDevice(int ip) pDev[ip].devopen = 1; pDev[ip].inquiry = (SCSIInquiry_T *)malloc(INQUIRY_SIZE); - if (SCSI_Inquiry(ip, pDev[ip].inquiry, INQUIRY_SIZE) == 0) + if (SCSI_Inquiry(ip, pDev[ip].inquiry, (unsigned char)INQUIRY_SIZE) == 0) { if (pDev[ip].inquiry->type == TYPE_TAPE || pDev[ip].inquiry->type == TYPE_CHANGER) { @@ -111,12 +111,10 @@ int SCSI_OpenDevice(int ip) free(pDev[ip].inquiry); return(0); } - } else { - free(pDev[ip].inquiry); - pDev[ip].inquiry = NULL; - return(1); } - return(1); + free(pDev[ip].inquiry); + pDev[ip].inquiry = NULL; + return(1); } else { dbprintf(("SCSI_OpenDevice %s failed\n", pDev[ip].dev)); return(0); @@ -147,11 +145,11 @@ int SCSI_CloseDevice(int DeviceFD) int SCSI_ExecuteCommand(int DeviceFD, Direction_T Direction, CDB_T CDB, - int CDB_Length, + size_t CDB_Length, void *DataBuffer, - int DataBufferLength, - char *pRequestSense, - int RequestSenseLength) + size_t DataBufferLength, + RequestSense_T *RequestSense, + size_t RequestSenseLength) { extern OpenFiles_T *pDev; extern FILE * debug_file; @@ -159,11 +157,15 @@ int SCSI_ExecuteCommand(int DeviceFD, int retries = 1; extern int errno; struct uscsi_cmd Command; -#if 0 - ExtendedRequestSense_T pExtendedRequestSense; -#endif static int depth = 0; + /* Basic sanity checks */ + assert(CDB_Length <= UCHAR_MAX); + assert(RequestSenseLength <= UCHAR_MAX); + + /* Clear buffer for cases where sense is not returned */ + memset(RequestSense, 0, RequestSenseLength); + if (pDev[DeviceFD].avail == 0) { return(SCSI_ERROR); @@ -175,8 +177,8 @@ int SCSI_ExecuteCommand(int DeviceFD, SCSI_CloseDevice(DeviceFD); return SCSI_ERROR; } - memset(&Command, 0, sizeof(struct uscsi_cmd)); - memset(pRequestSense, 0, RequestSenseLength); + memset(&Command, 0, SIZEOF(struct uscsi_cmd)); + memset(RequestSense, 0, RequestSenseLength); switch (Direction) { case Input: @@ -196,7 +198,7 @@ int SCSI_ExecuteCommand(int DeviceFD, /* Set timeout to 5 minutes. */ Command.uscsi_timeout = 300; Command.uscsi_cdb = (caddr_t) CDB; - Command.uscsi_cdblen = CDB_Length; + Command.uscsi_cdblen = (u_char)CDB_Length; if (DataBufferLength > 0) { @@ -211,8 +213,8 @@ int SCSI_ExecuteCommand(int DeviceFD, | USCSI_WRITE | USCSI_RQENABLE; } - Command.uscsi_rqbuf = (caddr_t) pRequestSense; - Command.uscsi_rqlen = RequestSenseLength; + Command.uscsi_rqbuf = (caddr_t)RequestSense; + Command.uscsi_rqlen = (u_char)RequestSenseLength; DecodeSCSI(CDB, "SCSI_ExecuteCommand : "); while (retries > 0) { @@ -228,24 +230,19 @@ int SCSI_ExecuteCommand(int DeviceFD, ret = Command.uscsi_status; break; } - dbprintf(("ioctl on %d failed, errno %d, ret %d\n",pDev[DeviceFD].fd, errno, ret)); + dbprintf(("ioctl on %d failed, errno %s, ret %d\n", + pDev[DeviceFD].fd, strerror(errno), ret)); #if 0 RequestSense(DeviceFD, &pExtendedRequestSense, 0); #endif - DecodeSense((RequestSense_T *)pRequestSense, - "SCSI_ExecuteCommand:", debug_file); + DecodeSense(RequestSense, "SCSI_ExecuteCommand:", debug_file); retries--; } --depth; SCSI_CloseDevice(DeviceFD); - switch (ret) - { - default: - DebugPrint(DEBUG_INFO, SECTION_SCSI,"ioctl ret (%d)\n",ret); - return(SCSI_OK); - break; - } + DebugPrint(DEBUG_INFO, SECTION_SCSI,"ioctl ret (%d)\n",ret); + return(SCSI_OK); } /* @@ -274,7 +271,7 @@ int Tape_Ioctl( int DeviceFD, int command) if (ioctl(pDev[DeviceFD].fd , MTIOCTOP, &mtop) != 0) { - dbprintf(("Tape_Ioctl error ioctl %d\n",errno)); + dbprintf(("Tape_Ioctl error ioctl %s\n", strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -289,13 +286,14 @@ int Tape_Status( int DeviceFD) struct mtget mtget; int ret = -1; + memset(&mtget, 0, SIZEOF(mtget)); if (pDev[DeviceFD].devopen == 0) if (SCSI_OpenDevice(DeviceFD) == 0) return(-1); if (ioctl(pDev[DeviceFD].fd , MTIOCGET, &mtget) != 0) { - dbprintf(("Tape_Status error ioctl %d\n",errno)); + dbprintf(("Tape_Status error ioctl %s\n", strerror(errno))); SCSI_CloseDevice(DeviceFD); return(-1); } @@ -326,6 +324,7 @@ int Tape_Status( int DeviceFD) int ScanBus(int print) { + (void)print; /* Quiet unused parameter warning */ return(-1); } diff --git a/changer-src/sense.c b/changer-src/sense.c index 9550847..e5bbc13 100644 --- a/changer-src/sense.c +++ b/changer-src/sense.c @@ -8,7 +8,7 @@ #include #endif -#include "scsi-defs.h" +#include "scsi-defs.h" /* Handling of Sense codes which are returned from the device At the moment the following status us returned @@ -28,93 +28,93 @@ * Generic one, this is used if not information is found based on the ident of the device */ { "generic", "", TYPE_TAPE, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "generic", "", TYPE_TAPE, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "generic", "", TYPE_TAPE, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "generic", "", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "generic", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "generic", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "generic", "", TYPE_TAPE , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, { "generic", "", TYPE_TAPE , SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "The drive is not ready, but it is in the process of becoming ready"}, { "generic", "", TYPE_TAPE , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "generic", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "generic", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "generic", "", TYPE_TAPE , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "generic", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "generic", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "generic", "", TYPE_TAPE , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "generic", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "generic", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "generic", "", TYPE_TAPE , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "generic", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "generic", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, { "generic", "", TYPE_TAPE , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "generic", "", TYPE_TAPE, SENSE_UNIT_ATTENTION, -1, -1, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, + { "generic", "", TYPE_TAPE, SENSE_UNIT_ATTENTION, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, - { "generic", "", TYPE_TAPE , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "generic", "", TYPE_TAPE , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, { "generic", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "generic", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "generic", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "generic", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "generic", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "generic", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "generic", "", TYPE_CHANGER , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, { "generic", "", TYPE_CHANGER , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "generic", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "generic", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "generic", "", TYPE_CHANGER , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "generic", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "generic", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "generic", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "generic", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "generic", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "generic", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "generic", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "generic", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, { "generic", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "generic", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, -1, -1, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, + { "generic", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, - { "generic", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "generic", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "generic", "", TYPE_CHANGER , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, -/* + { "generic", "", TYPE_CHANGER , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, +/* * * ADIC DAT Autochanger * */ { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, { "DAT AutoChanger", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x28, 0x01, SENSE_IES, "Door opend"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, -1, -1, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, - { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "DAT AutoChanger", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "DAT AutoChanger", "", TYPE_CHANGER , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "DAT AutoChanger", "", TYPE_CHANGER , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * * L500 (for the L500 ATL library) * */ - + { "L500", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "L500", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "L500", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "L500", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, { "L500", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x0a, 0x0, SENSE_IGNORE, "Error Log overflow"}, @@ -122,18 +122,18 @@ { "L500", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x44, 0xc2, SENSE_IGNORE, "EEPROM Copy 2 bad"}, { "L500", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x47, 0x0, SENSE_IGNORE, "SCSI parity error"}, { "L500", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x48, 0x0, SENSE_IGNORE, "SCSI IDE message received"}, - { "L500", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "L500", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "L500", "", TYPE_CHANGER , SENSE_NOT_READY, 0x0, 0x0, SENSE_ABORT, "Scsi port not initialized"}, { "L500", "", TYPE_CHANGER , SENSE_NOT_READY, 0x04, 0x01, SENSE_RETRY, "Becoming ready, scanning magazines, etc"}, { "L500", "", TYPE_CHANGER , SENSE_NOT_READY, 0x04, 0x03, SENSE_ABORT, "Unit not ready: manual intervention required: Door Open"}, /* needed? */ { "L500", "", TYPE_CHANGER , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "L500", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "L500", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, /* Not used by L500 { "L500", "", TYPE_CHANGER , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "L500", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "L500", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, */ { "L500", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, { "L500", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x3a, 0x80, SENSE_ABORT, "Media not present"}, @@ -159,7 +159,7 @@ { "L500", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x80, 0x83, SENSE_ABORT, "Slot empty during LOAD CARTRIDGE"}, { "L500", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x80, 0x84, SENSE_ABORT, "Cleaning Tape expired"}, { "L500", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x80, 0x85, SENSE_ABORT, "Cleaning Failed"}, - { "L500", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR, -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "L500", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "L500", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, { "L500", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0x1a, 0x0, SENSE_ABORT, "Parameter length error"}, @@ -189,150 +189,149 @@ { "L500", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0x53, 0x01, SENSE_ABORT, "Cartridge failed to unload"}, { "L500", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0xf1, 0x0, SENSE_ABORT, "Command unspecified"}, { "L500", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0xf1, 0x02, SENSE_ABORT, "Unrecognized loader command"}, - { "L500", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "L500", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, { "L500", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, { "L500", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x28, 0x0, SENSE_RETRY, "Not ready to Ready transition"}, { "L500", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x29, 0x0, SENSE_RETRY, "Reset occured"}, { "L500", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x2a, 0x01, SENSE_ABORT, "Mode parameters changed"}, { "L500", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x3f, 0x01, SENSE_ABORT, "Microcode has changed"}, - { "L500", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, -1, -1, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, + { "L500", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, /* Not used by L500 - { "L500", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "L500", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, */ { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, 0x43, 0x0, SENSE_ABORT, "SCSI message error"}, { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, 0x47, 0x0, SENSE_ABORT, "SCSI parity error"}, { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, 0x48, 0x0, SENSE_ABORT, "SCSI IDE message received"}, { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, 0x49, 0x0, SENSE_ABORT, "SCSI invalid message"}, { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, 0x4e, 0x0, SENSE_ABORT, "SCSI overlapped commands"}, - - { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, -1, -1, SENSE_ABORT, "Default for SENSE_ABORTED_COMMAND"}, - { "L500", "", TYPE_CHANGER , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + + { "L500", "", TYPE_CHANGER, SENSE_ABORTED_COMMAND, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ABORTED_COMMAND"}, + { "L500", "", TYPE_CHANGER , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * HP C1553A Tape */ { "C1553A", "", TYPE_TAPE, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "C1553A", "", TYPE_TAPE, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "C1553A", "", TYPE_TAPE, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "C1553A", "", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "C1553A", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "C1553A", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "C1553A", "", TYPE_TAPE , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, { "C1553A", "", TYPE_TAPE , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "C1553A", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "C1553A", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "C1553A", "", TYPE_TAPE , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "C1553A", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "C1553A", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "C1553A", "", TYPE_TAPE , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "C1553A", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "C1553A", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "C1553A", "", TYPE_TAPE , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "C1553A", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "C1553A", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, { "C1553A", "", TYPE_TAPE , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "C1553A", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "C1553A", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - { "C1553A", "", TYPE_TAPE , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "C1553A", "", TYPE_TAPE , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, { "C1553A", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "C1553A", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "C1553A", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "C1553A", "", TYPE_CHANGER , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "C1553A", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "C1553A", "", TYPE_CHANGER, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "C1553A", "", TYPE_CHANGER , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, { "C1553A", "", TYPE_CHANGER , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "C1553A", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "C1553A", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "C1553A", "", TYPE_CHANGER , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "C1553A", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "C1553A", "", TYPE_CHANGER, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "C1553A", "", TYPE_CHANGER , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "C1553A", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "C1553A", "", TYPE_CHANGER, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "C1553A", "", TYPE_CHANGER , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "C1553A", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - + { "C1553A", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "C1553A", "", TYPE_CHANGER , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "C1553A", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - - { "C1553A", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "C1553A", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - { "C1553A", "", TYPE_CHANGER , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "C1553A", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + + { "C1553A", "", TYPE_CHANGER , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * HP C1537A Tape */ { "C1537A", "", TYPE_TAPE, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "C1537A", "", TYPE_TAPE, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "C1537A", "", TYPE_TAPE, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "C1537A", "", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "C1537A", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "C1537A", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "C1537A", "", TYPE_TAPE , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, { "C1537A", "", TYPE_TAPE , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, { "C1537A", "", TYPE_TAPE , SENSE_NOT_READY, 0x04, 0x0, SENSE_RETRY, "tape is being ejected"}, { "C1537A", "", TYPE_TAPE , SENSE_NOT_READY, 0x04, 0x01, SENSE_RETRY, "tape is being loaded"}, - { "C1537A", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "C1537A", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "C1537A", "", TYPE_TAPE , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "C1537A", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "C1537A", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "C1537A", "", TYPE_TAPE , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "C1537A", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "C1537A", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "C1537A", "", TYPE_TAPE , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "C1537A", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - + { "C1537A", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "C1537A", "", TYPE_TAPE , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, { "C1537A", "", TYPE_TAPE , SENSE_UNIT_ATTENTION, 0x28, 0x0, SENSE_RETRY, "Not Ready to Ready Transition"}, - { "C1537A", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , -1, -1, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, - - { "C1537A", "", TYPE_TAPE, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "C1537A", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, + + { "C1537A", "", TYPE_TAPE, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "C1537A", "", TYPE_TAPE , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "C1537A", "", TYPE_TAPE , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * Tandberg Tape */ { "TDS 1420", "", TYPE_TAPE, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "TDS 1420", "", TYPE_TAPE, SENSE_IES, 0x83, 0x0, SENSE_IES, "IES"}, { "TDS 1420", "", TYPE_TAPE, SENSE_IES, 0x83, 0x1, SENSE_IES, "IES"}, { "TDS 1420", "", TYPE_TAPE, SENSE_IES, 0x83, 0x4, SENSE_IGNORE, "IES"}, { "TDS 1420", "", TYPE_TAPE, SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "TDS 1420", "", TYPE_TAPE, SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready"}, { "TDS 1420", "", TYPE_TAPE, SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "TDS 1420", "", TYPE_TAPE, SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "TDS 1420", "", TYPE_TAPE, SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "TDS 1420", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - + { "TDS 1420", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "TDS 1420", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - - { "TDS 1420", "", TYPE_TAPE, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "TDS 1420", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + + { "TDS 1420", "", TYPE_TAPE, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * DLT 8000 Tape - * - * */ + */ { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense"}, { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL, 0x0, 0x01, SENSE_NO, "Unexpected FM encountered"}, { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL, 0x0, 0x02, SENSE_NO, "EOM encountered"}, { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL, 0x0, 0x04, SENSE_NO, "BOM encountered"}, { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL, 0x5d, 0x00, SENSE_NO, "Failure prediction threshold exceeded"}, { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL, 0x27, 0x82, SENSE_NO, "Data safety write protect"}, - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x0, 0x0, SENSE_IGNORE, "Recovered Error"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x0, 0x17, SENSE_IGNORE, "Cleaning requested"}, @@ -351,29 +350,29 @@ { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x80, 0x02, SENSE_IGNORE, "Cleaning requested"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x80, 0x03, SENSE_IGNORE, "Softe error exceeds threshold"}, /* { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_RECOVERED_ERROR, 0x47, 0x0, SENSE_IGNORE, "Scsi Parity Error"}, */ - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_RECOVERED_ERROR , -1, -1, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_RECOVERED_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_RECOVERED_ERROR"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_NOT_READY, 0x0, 0x0, SENSE_IGNORE, "Not Ready (this shouldn't happen should it?)"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "The drive is not ready, but it is in the process of becoming ready"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_NOT_READY, 0x30,0x02, SENSE_ABORT, "Incompatible tape format"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_NOT_READY, 0x30,0x03, SENSE_ABORT, "Cleaning Cartridge in drive"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_NOT_READY, 0x5a,0x01, SENSE_ABORT, "Asynchronous eject occurred"}, - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_MEDIUM_ERROR, 0x0, 0x0, SENSE_ABORT, "Medium Error"}, - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_MEDIUM_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_MEDIUM_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_MEDIUM_ERROR"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_HARDWARE_ERROR, 0x0, 0x0, SENSE_ABORT, "Hardware Error"}, - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_HARDWARE_ERROR , -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_HARDWARE_ERROR , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, { "DLT8000", "QUANTUM", TYPE_TAPE , SENSE_UNIT_ATTENTION, 0x28, 0x0, SENSE_RETRY, "Not ready to ready transition"}, - { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_UNIT_ATTENTION, -1, -1, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, + { "DLT8000", "QUANTUM", TYPE_TAPE, SENSE_UNIT_ATTENTION, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_UNIT_ATTENTION"}, - { "DLT8000", "QUANTUM", TYPE_TAPE , -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "DLT8000", "QUANTUM", TYPE_TAPE , UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * DLT 7000 Tape @@ -381,64 +380,64 @@ { "DLT7000", "", TYPE_TAPE, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "DLT7000", "", TYPE_TAPE, SENSE_NOT_READY, 0x4, 0x2, SENSE_TAPE_NOT_ONLINE, "Logical Unit not ready, in progress becoming ready"}, { "DLT7000", "", TYPE_TAPE, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, - { "DLT7000", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "DLT7000", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "DLT7000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "DLT7000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "DLT7000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "DLT7000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "DLT7000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - - { "DLT7000", "", TYPE_TAPE, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "DLT7000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + + { "DLT7000", "", TYPE_TAPE, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * DLT 4000 Tape */ { "DLT4000", "", TYPE_TAPE, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "DLT4000", "", TYPE_TAPE, SENSE_NOT_READY, 0x4, 0x2, SENSE_TAPE_NOT_ONLINE, "Logical Unit not ready, in progress becoming ready"}, { "DLT4000", "", TYPE_TAPE, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, - { "DLT4000", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "DLT4000", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "DLT4000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "DLT4000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "DLT4000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "DLT4000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "DLT4000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - - { "DLT4000", "", TYPE_TAPE, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "DLT4000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + + { "DLT4000", "", TYPE_TAPE, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * AIT VLS DLT Library */ { "VLS_DLT", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "VLS_DLT", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x2, SENSE_TAPE_NOT_ONLINE, "Logical Unit not ready, in progress becoming ready"}, { "VLS_DLT", "", TYPE_CHANGER, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, - { "VLS_DLT", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "VLS_DLT", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "VLS_DLT", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "VLS_DLT", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "VLS_DLT", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "VLS_DLT", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "VLS_DLT", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "VLS_DLT", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + + { "VLS_DLT", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "VLS_DLT", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - - { "VLS_DLT", "", TYPE_CHANGER, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "VLS_DLT", "", TYPE_CHANGER, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * AIT VLS SDX Library */ { "VLS_SDX", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "VLS_SDX", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x2, SENSE_TAPE_NOT_ONLINE, "Logical Unit not ready, in progress becoming ready"}, { "VLS_SDX", "", TYPE_CHANGER, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, - { "VLS_SDX", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "VLS_SDX", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "VLS_SDX", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "VLS_SDX", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "VLS_SDX", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "VLS_SDX", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "VLS_SDX", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - - { "VLS_SDX", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "VLS_SDX", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + + { "VLS_SDX", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "VLS_SDX", "", TYPE_CHANGER, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "VLS_SDX", "", TYPE_CHANGER, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * Exabyte 85058 Tape */ @@ -446,21 +445,21 @@ { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "Logical Unit not ready, in progress becoming ready"}, { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, - { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - { "EXB-85058HE-0000", "", TYPE_TAPE, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, + { "EXB-85058HE-0000", "", TYPE_TAPE, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + { "EXB-85058HE-0000", "", TYPE_TAPE, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found"}, /* * Exabyte 10e Library (Robot) */ { "EXB-10e", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_RETRY, "Retry, no sense"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_NULL, 0x90, 0x2, SENSE_ABORT, "Illegal Request"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_NULL , 0x90, 0x3, SENSE_IES, "IES"}, - { "EXB-10e", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "EXB-10e", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "Logical Unit not ready, in progress becoming ready"}, @@ -472,19 +471,19 @@ { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x8E, SENSE_ABORT, "The library is in Sequential mode"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, - { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-10e", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "EXB-10e", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "EXB-10e", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "EXB-10e", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, { "EXB-10e", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x91, 0x0, SENSE_CHM_FULL, "CHM full during reset"}, - { "EXB-10e", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_RETRY, "Default for SENSE_ILLEGAL_REQUEST"}, - - { "EXB-10e", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "EXB-10e", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_ILLEGAL_REQUEST"}, + + { "EXB-10e", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "EXB-10e", "", TYPE_CHANGER, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found for EXB-10e"}, + { "EXB-10e", "", TYPE_CHANGER, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found for EXB-10e"}, /* * Exabyte 210 Library (Robot) @@ -492,7 +491,7 @@ { "EXB-210", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_RETRY, "Retry, no sense"}, { "EXB-210", "", TYPE_CHANGER, SENSE_NULL, 0x90, 0x2, SENSE_ABORT, "Illegal Request"}, { "EXB-210", "", TYPE_CHANGER, SENSE_NULL , 0x90, 0x3, SENSE_IES, "IES"}, - { "EXB-210", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "EXB-210", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "Logical Unit not ready, in progress becoming ready"}, @@ -504,12 +503,12 @@ { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x8E, SENSE_ABORT, "The library is in Sequential mode"}, { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, - { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-210", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "EXB-210", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "EXB-210", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "EXB-210", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x91, 0x0, SENSE_CHM_FULL, "CHM full during reset"}, { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x21, 0x01, SENSE_ABORT, "Invalid element address"}, @@ -522,9 +521,9 @@ { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x80, 0x04, SENSE_ABORT, "Destination magazine no installed"}, { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x80, 0x05, SENSE_ABORT, "Source tape drive not installed"}, { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x80, 0x06, SENSE_ABORT, "Destination tape drive not installed"}, - - { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_RETRY, "Default for SENSE_ILLEGAL_REQUEST"}, - + + { "EXB-210", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_ILLEGAL_REQUEST"}, + { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, 0x83, 0x0, SENSE_IES, "Label questionable"}, { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, 0x83, 0x1, SENSE_IGNORE, "Cannot read bar code label"}, { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, 0x83, 0x2, SENSE_ABORT, "Cartzridge magazine not present"}, @@ -534,9 +533,9 @@ { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, 0x83, 0x8, SENSE_IGNORE, "Bar code label upside down"}, { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, 0x83, 0x9, SENSE_IGNORE, "No bar code label"}, { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, 0x83, 0xa, SENSE_IGNORE, ""}, - { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "EXB-210", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "EXB-210", "", TYPE_CHANGER, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found for EXB-10e"}, + { "EXB-210", "", TYPE_CHANGER, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found for EXB-10e"}, /* * Exabyte 230D Library (Robot) @@ -544,7 +543,7 @@ { "EXB-230D", "", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_RETRY, "Retry, no sense"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_NULL, 0x90, 0x2, SENSE_ABORT, "Illegal Request"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_NULL , 0x90, 0x3, SENSE_IES, "IES"}, - { "EXB-230D", "", TYPE_CHANGER, SENSE_NULL , -1, -1, SENSE_RETRY, "Default for SENSE_NULL"}, + { "EXB-230D", "", TYPE_CHANGER, SENSE_NULL , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NULL"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Logical Unit not ready, no additional sense"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "Logical Unit not ready, in progress becoming ready"}, @@ -556,30 +555,30 @@ { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x8E, SENSE_ABORT, "The library is in Sequential mode"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY, 0x30, 0x3, SENSE_RETRY, "The tape drive is being cleaned"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY, 0x3A, 0x0, SENSE_TAPE_NOT_ONLINE, "No Tape online"}, - { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, - { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY , -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "EXB-230D", "", TYPE_CHANGER, SENSE_NOT_READY , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x0, 0x0, SENSE_RETRY, "Unit Attention"}, - { "EXB-230D", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , -1, -1, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, - + { "EXB-230D", "", TYPE_CHANGER, SENSE_UNIT_ATTENTION , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_UNIT_ATTENTION"}, + { "EXB-230D", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x0, 0x0, SENSE_ABORT, "Illegal Request"}, { "EXB-230D", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x91, 0x0, SENSE_CHM_FULL, "CHM full during reset"}, - { "EXB-230D", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , -1, -1, SENSE_RETRY, "Default for SENSE_ILLEGAL_REQUEST"}, - - { "EXB-230D", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + { "EXB-230D", "", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST , UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_ILLEGAL_REQUEST"}, - { "EXB-230D", "", TYPE_CHANGER, -1, 0x0, 0x0, SENSE_ABORT, "Nothing Found for EXB-10e"}, + { "EXB-230D", "", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + + { "EXB-230D", "", TYPE_CHANGER, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing Found for EXB-10e"}, /* * Spectra TreeFrog library */ { "215", "SPECTRA", TYPE_CHANGER, SENSE_NULL, 0x0, 0x0, SENSE_NO, "No Sense, Unit Ready"}, - { "215", "SPECTRA", TYPE_CHANGER, SENSE_NULL, -1, -1, SENSE_NO, "No Sense, Unit Ready"}, - + { "215", "SPECTRA", TYPE_CHANGER, SENSE_NULL, UCHAR_MAX, UCHAR_MAX, SENSE_NO, "No Sense, Unit Ready"}, + { "215", "SPECTRA", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x0, SENSE_RETRY, "Unit Not Ready"}, { "215", "SPECTRA", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x1, SENSE_RETRY, "Unit is Becoming Ready"}, { "215", "SPECTRA", TYPE_CHANGER, SENSE_NOT_READY, 0x4, 0x83, SENSE_ABORT, "Door is open, Robot is Disabled"}, - { "215", "SPECTRA", TYPE_CHANGER, SENSE_NOT_READY, -1, -1, SENSE_RETRY, "Default for SENSE_NOT_READY"}, - + { "215", "SPECTRA", TYPE_CHANGER, SENSE_NOT_READY, UCHAR_MAX, UCHAR_MAX, SENSE_RETRY, "Default for SENSE_NOT_READY"}, + { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, 0x4C, 0x0, SENSE_ABORT, "Unit Failed Initialization"}, { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, 0x84, 0x4, SENSE_ABORT, "DRAM Memory Failure"}, { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, 0x84, 0x4, SENSE_ABORT, "Two ore More SCSI ID's in the library are tehe same"}, @@ -592,8 +591,8 @@ { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, 0x85, 0x2, SENSE_ABORT, "Long Axis Robotics Error"}, { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, 0x85, 0x3, SENSE_ABORT, "Short Axis Robotics Error"}, { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, 0x85, 0x4, SENSE_ABORT, "Ambient Light Detected"}, - { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, -1, -1, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, - + { "215", "SPECTRA", TYPE_CHANGER, SENSE_HARDWARE_ERROR, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_HARDWARE_ERROR"}, + {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x1A, 0x0, SENSE_ABORT, "Parameter List Length Error"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x20, 0x0, SENSE_ABORT, "Invalid Command Code"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x21, 0x01, SENSE_ABORT, "Invalid Element Address"}, @@ -606,13 +605,13 @@ {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x80, 0x18, SENSE_ABORT, "Conflict, Element is Reserved"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x81, 0x2, SENSE_ABORT, "Library is Full of Tapes"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, 0x81, 0x3, SENSE_ABORT, "Grip Arm not Empty"}, - {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, -1 , -1, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, - + {"215", "SPECTRA", TYPE_CHANGER, SENSE_ILLEGAL_REQUEST, UCHAR_MAX , UCHAR_MAX, SENSE_ABORT, "Default for SENSE_ILLEGAL_REQUEST"}, + {"215", "SPECTRA", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x28, 0x0, SENSE_IES, "Inventory possible Altered"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x29, 0x0, SENSE_RETRY, "A Reset Has Occured"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_UNIT_ATTENTION, 0x24, 0x1, SENSE_IGNORE, "Mode Parameter Have CHanged"}, - {"215", "SPECTRA", TYPE_CHANGER, SENSE_UNIT_ATTENTION, -1, -1, SENSE_IGNORE, "Default for SENSE_UNIT_ATTENTION"}, - + {"215", "SPECTRA", TYPE_CHANGER, SENSE_UNIT_ATTENTION, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_UNIT_ATTENTION"}, + {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, 0x83, 0x00, SENSE_ABORT, "Barcode Label is Unread"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, 0x83, 0x01, SENSE_ABORT, "Problem Reading Barcode"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, 0x83, 0x11, SENSE_ABORT, "Tape in Drive & Unmounted"}, @@ -622,24 +621,25 @@ {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, 0x84, 0x03, SENSE_ABORT, "SCSI ID Same as Library's ID"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, 0x84, 0x08, SENSE_ABORT, "Busy Condition from Target"}, {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, 0x84, 0x18, SENSE_ABORT, "SCSI Reservation Conflict"}, - {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, -1, -1, SENSE_ABORT, "Default for SENSE_VENDOR_SPECIFIC"}, - - { "215", "SPECTRA", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, -1, -1, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, + {"215", "SPECTRA", TYPE_CHANGER, SENSE_VENDOR_SPECIFIC, UCHAR_MAX, UCHAR_MAX, SENSE_ABORT, "Default for SENSE_VENDOR_SPECIFIC"}, + + { "215", "SPECTRA", TYPE_CHANGER, SENSE_CHG_ELEMENT_STATUS, UCHAR_MAX, UCHAR_MAX, SENSE_IGNORE, "Default for SENSE_CHG_ELEMENT_STATUS"}, - { "215", "SPECTRA", TYPE_CHANGER, -1, 0x0, 0x0, SENSE_ABORT, "Nothing found for Spectra/215"}, - - { NULL, "", 0x0, -1, 0x0, 0x0, 0x0, ""}, + { "215", "SPECTRA", TYPE_CHANGER, UCHAR_MAX, 0x0, 0x0, SENSE_ABORT, "Nothing found for Spectra/215"}, + + { NULL, "", 0x0, UCHAR_MAX, 0x0, 0x0, 0x0, ""}, }; -void DumpSense() +void +DumpSense(void) { SenseType_T *pwork = (SenseType_T *)&SenseType; - while (pwork->ident != NULL) + while (pwork->ident != NULL) { - if (pwork->sense == -1) + if (pwork->sense == UCHAR_MAX) { printf("\n"); } else { @@ -664,17 +664,19 @@ void DumpSense() * ASC is the ASC value returned by the scsi command * ASCQ is the ASCQ value returned by the scsi command * text is a pointer to store the clear text reason from the table. - * + * * TODO: - * + * */ -int Sense2Action(char *ident, - unsigned char type, - unsigned char ignsense, - unsigned char sense, - unsigned char asc, - unsigned char ascq, - char **text) +int +Sense2Action( + char * ident, + unsigned char type, + unsigned char ignsense, + unsigned char sense, + unsigned char asc, + unsigned char ascq, + char ** text) { /* * Decode the combination of sense key, ASC, ASCQ and return what to do with this @@ -692,15 +694,15 @@ int Sense2Action(char *ident, sense, asc, ascq)); - - while (pwork->ident != NULL) + + while (pwork->ident != NULL) { if (strcmp(pwork->ident, "generic") == 0 && pwork->type == type && generic == NULL) { generic = pwork; } - - if (strcmp(pwork->ident, ident) == 0 && pwork->type == type) + + if (strcmp((char *)pwork->ident, (char *)ident) == 0 && pwork->type == type) { in = 1; } else { @@ -716,31 +718,31 @@ int Sense2Action(char *ident, if (in == 1) { /* End of definitions for this device */ - if (pwork->sense == -1) + if (pwork->sense == UCHAR_MAX) { - *text = (char *)stralloc(pwork->text); + *text = stralloc(pwork->text); dbprintf(("Sense2Action END : no match for %s %s\n", pwork->ident, pwork->vendor)); return(pwork->ret); } - + if (ignsense) { if (pwork->asc == asc && pwork->ascq == ascq) { - *text = (char *)stralloc(pwork->text); + *text = stralloc(pwork->text); dbprintf(("Sense2Action END(IGN) : match for %s %s return -> %d/%s\n", pwork->ident, pwork->vendor, pwork->ret, - *text)); + *text)); return(pwork->ret); } pwork++; continue; - } - + } + if (pwork->sense == sense) { /* Matching ASC/ASCQ, if yes return the defined result code */ @@ -751,45 +753,47 @@ int Sense2Action(char *ident, pwork->ident, pwork->vendor, pwork->ret, - *text)); + *text)); return(pwork->ret); } - + /* End of definitions for this sense type, if yes return the default * for this type */ - if ( pwork->asc == -1 && pwork->ascq == -1) + if ( pwork->asc == UCHAR_MAX && pwork->ascq == UCHAR_MAX) { *text = (char *)stralloc(pwork->text); dbprintf(("Sense2Action END : no match for %s %s return -> %d/%s\n", pwork->ident, pwork->vendor, pwork->ret, - *text)); + *text)); return(pwork->ret); - } + } } } pwork++; } - /* + /* * Ok no match found, so lets return the values from the generic table */ dbprintf(("Sense2Action generic start :\n")); - while ((generic != NULL) && generic->ident != NULL) - { - if (generic->sense == -1) + while (generic != NULL) { + if (generic->ident == NULL) + break; + + if (generic->sense == UCHAR_MAX) { *text = (char *)stralloc(generic->text); dbprintf(("Sense2Action generic END : match for %s %s return -> %d/%s\n", generic->ident, generic->vendor, generic->ret, - *text)); + *text)); return(generic->ret); } - + if (ignsense) { if (generic->asc == asc && generic->ascq == ascq) @@ -799,13 +803,13 @@ int Sense2Action(char *ident, generic->ident, generic->vendor, generic->ret, - *text)); + *text)); return(generic->ret); } generic++; continue; - } - + } + if (generic->sense == sense) { /* Matching ASC/ASCQ, if yes return the defined result code */ @@ -816,28 +820,28 @@ int Sense2Action(char *ident, generic->ident, generic->vendor, generic->ret, - *text)); + *text)); return(generic->ret); } - + /* End of definitions for this sense type, if yes return the default * for this type */ - if ( generic->asc == -1 && generic->ascq == -1) + if ( generic->asc == UCHAR_MAX && generic->ascq == UCHAR_MAX) { *text = (char *)stralloc(generic->text); dbprintf(("Sense2Action generic END : no match for %s %s return -> %d/%s\n", generic->ident, generic->vendor, generic->ret, - *text)); + *text)); return(generic->ret); - } + } generic++; continue; } generic++; - } + } dbprintf(("Sense2Action END:\n")); *text = (char *)stralloc("No match found"); diff --git a/client-src/Makefile.am b/client-src/Makefile.am index a7f5b91..b479e12 100644 --- a/client-src/Makefile.am +++ b/client-src/Makefile.am @@ -1,12 +1,16 @@ # Makefile for Amanda client programs. INCLUDES = -I$(top_builddir)/common-src \ - -I$(top_srcdir)/common-src + -I$(top_srcdir)/common-src \ + -I$(top_srcdir)/amandad-src + +LINT=@AMLINT@ +LINTFLAGS=@AMLINTFLAGS@ lib_LTLIBRARIES = libamclient.la LIB_EXTENSION = la -libexec_PROGRAMS = amandad noop calcsize killpgrp rundump runtar selfcheck sendbackup sendsize versionsuffix +libexec_PROGRAMS = noop calcsize killpgrp rundump runtar selfcheck sendbackup sendsize versionsuffix sbin_SCRIPTS = @CLIENT_SCRIPTS_OPT@ @@ -22,7 +26,7 @@ endif libamclient_la_SOURCES= amandates.c getfsent.c \ unctime.c client_util.c \ - $(samba_sources) + clientconf.c $(samba_sources) libamclient_la_LDFLAGS = -release $(VERSION) @@ -34,11 +38,9 @@ libamclient_la_LDFLAGS = -release $(VERSION) ### LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) -if WANT_SERVER -LDADD += ../tape-src/libamtape.$(LIB_EXTENSION) -endif -LDADD += ../common-src/libamanda.$(LIB_EXTENSION) + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ + ../common-src/libamanda.$(LIB_EXTENSION) SUFFIXES = .sh .pl @@ -64,11 +66,12 @@ DISTCLEANFILES = $(EXTRA_SCRIPTS) EXTRA_DIST = amhpfixdevs.sh amsinixfixdevs.sh -sendbackup_SOURCES = sendbackup.c sendbackup.h \ +sendbackup_SOURCES = sendbackup.c sendbackup.h \ sendbackup-dump.c sendbackup-gnutar.c -noinst_HEADERS = amandad.h amandates.h getfsent.h \ - findpass.h client_util.h +noinst_HEADERS = amandates.h getfsent.h \ + findpass.h client_util.h \ + clientconf.h install-exec-hook: @list="$(sbin_SCRIPTS)"; \ @@ -101,6 +104,20 @@ if WANT_SETUID_CLIENT done endif +lint: + @ for p in $(libexec_PROGRAMS); do \ + f="$$p.c $(libamclient_la_SOURCES)"; \ + (cd ../common-src; make listlibsrc); \ + f="$$f "`cat ../common-src/listlibsrc.output`; \ + echo $(LINT) $$f; \ + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config \ + $(INCLUDES) $$f; \ + if [ $$? -ne 0 ]; then \ + exit 1; \ + fi; \ + done; \ + exit 0 + getfsent_SOURCES = getfsent.test.c %.test.c: $(srcdir)/%.c diff --git a/client-src/Makefile.in b/client-src/Makefile.in index aa86788..f30f2ac 100644 --- a/client-src/Makefile.in +++ b/client-src/Makefile.in @@ -42,11 +42,9 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -libexec_PROGRAMS = amandad$(EXEEXT) noop$(EXEEXT) calcsize$(EXEEXT) \ - killpgrp$(EXEEXT) rundump$(EXEEXT) runtar$(EXEEXT) \ - selfcheck$(EXEEXT) sendbackup$(EXEEXT) sendsize$(EXEEXT) \ - versionsuffix$(EXEEXT) -@WANT_SERVER_TRUE@am__append_1 = ../tape-src/libamtape.$(LIB_EXTENSION) +libexec_PROGRAMS = noop$(EXEEXT) calcsize$(EXEEXT) killpgrp$(EXEEXT) \ + rundump$(EXEEXT) runtar$(EXEEXT) selfcheck$(EXEEXT) \ + sendbackup$(EXEEXT) sendsize$(EXEEXT) versionsuffix$(EXEEXT) EXTRA_PROGRAMS = $(am__EXEEXT_1) subdir = client-src DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ @@ -71,82 +69,84 @@ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libamclient_la_LIBADD = am__libamclient_la_SOURCES_DIST = amandates.c getfsent.c unctime.c \ - client_util.c findpass.c + client_util.c clientconf.c findpass.c @WANT_SAMBA_TRUE@am__objects_1 = findpass.lo am_libamclient_la_OBJECTS = amandates.lo getfsent.lo unctime.lo \ - client_util.lo $(am__objects_1) + client_util.lo clientconf.lo $(am__objects_1) libamclient_la_OBJECTS = $(am_libamclient_la_OBJECTS) am__EXEEXT_1 = getfsent$(EXEEXT) libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(libexec_PROGRAMS) -amandad_SOURCES = amandad.c -amandad_OBJECTS = amandad.$(OBJEXT) -amandad_LDADD = $(LDADD) -@WANT_SERVER_TRUE@am__DEPENDENCIES_1 = \ -@WANT_SERVER_TRUE@ ../tape-src/libamtape.$(LIB_EXTENSION) -amandad_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ - ../common-src/libamanda.$(LIB_EXTENSION) calcsize_SOURCES = calcsize.c calcsize_OBJECTS = calcsize.$(OBJEXT) calcsize_LDADD = $(LDADD) calcsize_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) am_getfsent_OBJECTS = getfsent.test.$(OBJEXT) getfsent_OBJECTS = $(am_getfsent_OBJECTS) getfsent_LDADD = $(LDADD) getfsent_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) killpgrp_SOURCES = killpgrp.c killpgrp_OBJECTS = killpgrp.$(OBJEXT) killpgrp_LDADD = $(LDADD) killpgrp_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) noop_SOURCES = noop.c noop_OBJECTS = noop.$(OBJEXT) noop_LDADD = $(LDADD) noop_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) rundump_SOURCES = rundump.c rundump_OBJECTS = rundump.$(OBJEXT) rundump_LDADD = $(LDADD) rundump_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) runtar_SOURCES = runtar.c runtar_OBJECTS = runtar.$(OBJEXT) runtar_LDADD = $(LDADD) runtar_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) selfcheck_SOURCES = selfcheck.c selfcheck_OBJECTS = selfcheck.$(OBJEXT) selfcheck_LDADD = $(LDADD) selfcheck_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) am_sendbackup_OBJECTS = sendbackup.$(OBJEXT) sendbackup-dump.$(OBJEXT) \ sendbackup-gnutar.$(OBJEXT) sendbackup_OBJECTS = $(am_sendbackup_OBJECTS) sendbackup_LDADD = $(LDADD) sendbackup_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) sendsize_SOURCES = sendsize.c sendsize_OBJECTS = sendsize.$(OBJEXT) sendsize_LDADD = $(LDADD) sendsize_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) versionsuffix_SOURCES = versionsuffix.c versionsuffix_OBJECTS = versionsuffix.$(OBJEXT) versionsuffix_LDADD = $(LDADD) versionsuffix_DEPENDENCIES = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__DEPENDENCIES_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) libexecSCRIPT_INSTALL = $(INSTALL_SCRIPT) sbinSCRIPT_INSTALL = $(INSTALL_SCRIPT) @@ -162,10 +162,10 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libamclient_la_SOURCES) amandad.c calcsize.c \ - $(getfsent_SOURCES) killpgrp.c noop.c rundump.c runtar.c \ - selfcheck.c $(sendbackup_SOURCES) sendsize.c versionsuffix.c -DIST_SOURCES = $(am__libamclient_la_SOURCES_DIST) amandad.c calcsize.c \ +SOURCES = $(libamclient_la_SOURCES) calcsize.c $(getfsent_SOURCES) \ + killpgrp.c noop.c rundump.c runtar.c selfcheck.c \ + $(sendbackup_SOURCES) sendsize.c versionsuffix.c +DIST_SOURCES = $(am__libamclient_la_SOURCES_DIST) calcsize.c \ $(getfsent_SOURCES) killpgrp.c noop.c rundump.c runtar.c \ selfcheck.c $(sendbackup_SOURCES) sendsize.c versionsuffix.c HEADERS = $(noinst_HEADERS) @@ -179,11 +179,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -191,6 +194,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -372,8 +377,11 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ INCLUDES = -I$(top_builddir)/common-src \ - -I$(top_srcdir)/common-src + -I$(top_srcdir)/common-src \ + -I$(top_srcdir)/amandad-src +LINT = @AMLINT@ +LINTFLAGS = @AMLINTFLAGS@ lib_LTLIBRARIES = libamclient.la LIB_EXTENSION = la sbin_SCRIPTS = @CLIENT_SCRIPTS_OPT@ @@ -382,7 +390,7 @@ libexec_SCRIPTS = patch-system @WANT_RUNTIME_PSEUDO_RELOC_TRUE@AM_LDFLAGS = -Wl,-enable-runtime-pseudo-reloc libamclient_la_SOURCES = amandates.c getfsent.c \ unctime.c client_util.c \ - $(samba_sources) + clientconf.c $(samba_sources) libamclient_la_LDFLAGS = -release $(VERSION) @@ -393,8 +401,10 @@ libamclient_la_LDFLAGS = -release $(VERSION) # routines, and second to pick up any references in the other libraries. ### LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \ - libamclient.$(LIB_EXTENSION) $(am__append_1) \ + libamclient.$(LIB_EXTENSION) \ + ../amandad-src/libamandad.$(LIB_EXTENSION) \ ../common-src/libamanda.$(LIB_EXTENSION) + SUFFIXES = .sh .pl # these are used for testing only: @@ -403,11 +413,12 @@ CLEANFILES = *.test.c patch-system EXTRA_SCRIPTS = amhpfixdevs amsinixfixdevs DISTCLEANFILES = $(EXTRA_SCRIPTS) EXTRA_DIST = amhpfixdevs.sh amsinixfixdevs.sh -sendbackup_SOURCES = sendbackup.c sendbackup.h \ +sendbackup_SOURCES = sendbackup.c sendbackup.h \ sendbackup-dump.c sendbackup-gnutar.c -noinst_HEADERS = amandad.h amandates.h getfsent.h \ - findpass.h client_util.h +noinst_HEADERS = amandates.h getfsent.h \ + findpass.h client_util.h \ + clientconf.h getfsent_SOURCES = getfsent.test.c all: all-am @@ -502,9 +513,6 @@ clean-libexecPROGRAMS: echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done -amandad$(EXEEXT): $(amandad_OBJECTS) $(amandad_DEPENDENCIES) - @rm -f amandad$(EXEEXT) - $(LINK) $(amandad_LDFLAGS) $(amandad_OBJECTS) $(amandad_LDADD) $(LIBS) calcsize$(EXEEXT): $(calcsize_OBJECTS) $(calcsize_DEPENDENCIES) @rm -f calcsize$(EXEEXT) $(LINK) $(calcsize_LDFLAGS) $(calcsize_OBJECTS) $(calcsize_LDADD) $(LIBS) @@ -580,10 +588,10 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amandad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amandates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calcsize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client_util.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clientconf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/findpass.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getfsent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getfsent.test.Po@am__quote@ @@ -849,6 +857,20 @@ install-exec-hook: @WANT_SETUID_CLIENT_TRUE@ fi; \ @WANT_SETUID_CLIENT_TRUE@ done +lint: + @ for p in $(libexec_PROGRAMS); do \ + f="$$p.c $(libamclient_la_SOURCES)"; \ + (cd ../common-src; make listlibsrc); \ + f="$$f "`cat ../common-src/listlibsrc.output`; \ + echo $(LINT) $$f; \ + $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config \ + $(INCLUDES) $$f; \ + if [ $$? -ne 0 ]; then \ + exit 1; \ + fi; \ + done; \ + exit 0 + %.test.c: $(srcdir)/%.c echo '#define TEST' >$@ echo '#include "$<"' >>$@ diff --git a/client-src/amandad.c b/client-src/amandad.c deleted file mode 100644 index 9090c30..0000000 --- a/client-src/amandad.c +++ /dev/null @@ -1,1408 +0,0 @@ -/* - * Amanda, The Advanced Maryland Automatic Network Disk Archiver - * Copyright (c) 1991-1999 University of Maryland at College Park - * All Rights Reserved. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of U.M. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. U.M. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Authors: the Amanda Development Team. Its members are listed in a - * file named AUTHORS, in the root directory of this distribution. - */ - -/* - * $Id: amandad.c,v 1.62.2.2 2006/05/08 11:50:16 martinea Exp $ - * - * handle client-host side of Amanda network communications, including - * security checks, execution of the proper service, and acking the - * master side - */ - -/*#define AMANDAD_DEBUG*/ - -#include "amanda.h" -#include "amandad.h" -#include "clock.h" -#include "event.h" -#include "amfeatures.h" -#include "packet.h" -#include "version.h" -#include "queue.h" -#include "security.h" -#include "stream.h" -#include "util.h" -#include "client_util.h" - -#define REP_TIMEOUT (6*60*60) /* secs for service to reply */ -#define ACK_TIMEOUT 10 /* XXX should be configurable */ -#define MAX_REP_RETRIES 5 - -/* - * These are the actions for entering the state machine - */ -typedef enum { A_START, A_RECVPKT, A_RECVREP, A_PENDING, A_FINISH, A_CONTINUE, - A_SENDNAK, A_TIMEOUT } action_t; - -/* - * This is a state in the state machine. It is a function pointer to - * the function that actually implements the state. - */ -struct active_service; -typedef action_t (*state_t) P((struct active_service *, action_t, pkt_t *)); - -/* - * This structure describes an active running service. - * - * An active service is something running that we have received - * a request for. This structure holds info on that service, including - * file descriptors for data, etc, as well as the security handle - * for communications with the amanda server. - */ -struct active_service { - char *cmd; /* name of command we ran */ - char *arguments; /* arguments we sent it */ - security_handle_t *security_handle; /* remote server */ - state_t state; /* how far this has progressed */ - pid_t pid; /* pid of subprocess */ - int send_partial_reply; /* send PREP packet */ - int reqfd; /* pipe to write requests */ - int repfd; /* pipe to read replies */ - event_handle_t *ev_repfd; /* read event handle for repfd */ - event_handle_t *ev_reptimeout; /* timeout for rep data */ - pkt_t rep_pkt; /* rep packet we're sending out */ - char repbuf[MAX_PACKET]; /* buffer to read the rep into */ - int repbufsize; /* length of repbuf */ - int repretry; /* times we'll retry sending the rep */ - /* - * General user streams to the process, and their equivalent - * network streams. - */ - struct datafd_handle { - int fd; /* pipe to child process */ - event_handle_t *ev_handle; /* it's read event handle */ - security_stream_t *netfd; /* stream to amanda server */ - struct active_service *as; /* pointer back to our enclosure */ - } data[DATA_FD_COUNT]; - char databuf[NETWORK_BLOCK_BYTES]; /* buffer to relay netfd data in */ - TAILQ_ENTRY(active_service) tq; /* queue handle */ -}; - -/* - * Here are the services that we allow. - */ -static const char *services[] = { - "noop", - "sendsize", - "sendbackup", - "selfcheck", -}; -#define NSERVICES (sizeof(services) / sizeof(services[0])) - -/* - * Queue of outstanding requests that we are running. - */ -static struct { - TAILQ_HEAD(, active_service) tailq; - int qlength; -} serviceq = { - TAILQ_HEAD_INITIALIZER(serviceq.tailq), 0 -}; - -/* - * Data for dbmalloc to check for memory leaks - */ -#ifdef USE_DBMALLOC -static struct { - struct { - unsigned long size, hist; - } start, end; -} dbmalloc_info; -#endif - -int ack_timeout = ACK_TIMEOUT; - -int main P((int argc, char **argv)); - -static int allocstream P((struct active_service *, int)); -static void exit_check P((void *)); -static void protocol_accept P((security_handle_t *, pkt_t *)); -static void state_machine P((struct active_service *, action_t, pkt_t *)); - -static action_t s_sendack P((struct active_service *, action_t, pkt_t *)); -static action_t s_repwait P((struct active_service *, action_t, pkt_t *)); -static action_t s_processrep P((struct active_service *, action_t, pkt_t *)); -static action_t s_sendrep P((struct active_service *, action_t, pkt_t *)); -static action_t s_ackwait P((struct active_service *, action_t, pkt_t *)); - -static void repfd_recv P((void *)); -static void timeout_repfd P((void *)); -static void protocol_recv P((void *, pkt_t *, security_status_t)); -static void process_netfd P((void *)); -static struct active_service *service_new P((security_handle_t *, - const char *, const char *)); -static void service_delete P((struct active_service *)); -static int writebuf P((struct active_service *, const void *, size_t)); -static int do_sendpkt P((security_handle_t *handle, pkt_t *pkt)); - -#ifdef AMANDAD_DEBUG -static const char *state2str P((state_t)); -static const char *action2str P((action_t)); -#endif - -int -main(argc, argv) - int argc; - char **argv; -{ - int i, in, out; - const security_driver_t *secdrv; - int no_exit = 0; - char *pgm = "amandad"; /* in case argv[0] is not set */ - - safe_fd(-1, 0); - safe_cd(); - - if(argv == NULL) { - error("argv == NULL\n"); - } - - /* - * When called via inetd, it is not uncommon to forget to put the - * argv[0] value on the config line. On some systems (e.g. Solaris) - * this causes argv and/or argv[0] to be NULL, so we have to be - * careful getting our name. - */ - if (argc >= 1 && argv != NULL && argv[0] != NULL) { - if((pgm = strrchr(argv[0], '/')) != NULL) { - pgm++; - } else { - pgm = argv[0]; - } - } - - set_pname(pgm); - - /* Don't die when child closes pipe */ - signal(SIGPIPE, SIG_IGN); - -#ifdef USE_DBMALLOC - dbmalloc_info.start.size = malloc_inuse(&dbmalloc_info.start.hist); -#endif - - erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG); - -#ifdef FORCE_USERID - /* we'd rather not run as root */ - if (geteuid() == 0) { - if(client_uid == (uid_t) -1) { - error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN); - } - initgroups(CLIENT_LOGIN, client_gid); - setgid(client_gid); - setegid(client_gid); - seteuid(client_uid); - } -#endif /* FORCE_USERID */ - - /* - * ad-hoc argument parsing - * - * We accept -auth=[authentication type] - * -no-exit -#ifdef AMANDAD_DEBUG - * -tcp=[port] - * -udp=[port] -#endif - */ - secdrv = NULL; - in = 0; out = 1; /* default to stdin/stdout */ - for (i = 1; i < argc; i++) { - /* - * accept -krb4 as an alias for -auth=krb4 (for compatibility) - */ - if (strcmp(argv[i], "-krb4") == 0) { - argv[i] = "-auth=krb4"; - /* FALLTHROUGH */ - } - - /* - * Get a driver for a security type specified after -auth= - */ - if (strncmp(argv[i], "-auth=", strlen("-auth=")) == 0) { - argv[i] += strlen("-auth="); - secdrv = security_getdriver(argv[i]); - if (secdrv == NULL) - error("no driver for security type '%s'", argv[i]); - continue; - } - - /* - * If -no-exit is specified, always run even after requests have - * been satisfied. - */ - if (strcmp(argv[i], "-no-exit") == 0) { - no_exit = 1; - continue; - } - -#ifdef AMANDAD_DEBUG - /* - * Allow us to directly bind to a udp port for debugging. - * This may only apply to some security types. - */ - if (strncmp(argv[i], "-udp=", strlen("-udp=")) == 0) { - struct sockaddr_in sin; - - argv[i] += strlen("-udp="); - in = out = socket(AF_INET, SOCK_DGRAM, 0); - if (in < 0) - error("can't create dgram socket: %s\n", strerror(errno)); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = htons(atoi(argv[i])); - if (bind(in, (struct sockaddr *)&sin, sizeof(sin)) < 0) - error("can't bind to port %d: %s\n", atoi(argv[i]), - strerror(errno)); - } - /* - * Ditto for tcp ports. - */ - if (strncmp(argv[i], "-tcp=", strlen("-tcp=")) == 0) { - struct sockaddr_in sin; - int sock, n; - - argv[i] += strlen("-tcp="); - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) - error("can't create tcp socket: %s\n", strerror(errno)); - n = 1; - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&n, sizeof(n)); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = htons(atoi(argv[i])); - if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) - error("can't bind to port %d: %s\n", atoi(argv[i]), - strerror(errno)); - listen(sock, 10); - n = sizeof(sin); - in = out = accept(sock, (struct sockaddr *)&sin, &n); - } -#endif - } - - /* - * If no security type specified, use BSD - */ - if (secdrv == NULL) { - secdrv = security_getdriver("BSD"); - if (secdrv == NULL) - error("no driver for default security type 'BSD'"); - } - - /* initialize */ - - dbopen(); - { - /* this lameness is for error() */ - int db_fd = dbfd(); - if(db_fd != -1) { - dup2(db_fd, 2); - } - } - - startclock(); - - dbprintf(("%s: version %s\n", get_pname(), version())); - for (i = 0; version_info[i] != NULL; i++) { - dbprintf(("%s: %s", debug_prefix(NULL), version_info[i])); - } - - if (! (argc >= 1 && argv != NULL && argv[0] != NULL)) { - dbprintf(("%s: WARNING: argv[0] not defined: check inetd.conf\n", - debug_prefix(NULL))); - } - - /* - * Schedule to call protocol_accept() when new security handles - * are created on stdin. - */ - security_accept(secdrv, in, out, protocol_accept); - - /* - * Schedule an event that will try to exit every 30 seconds if there - * are no requests outstanding. - */ - (void)event_register(30, EV_TIME, exit_check, &no_exit); - - /* - * Call event_loop() with an arg of 0, telling it to block until all - * events are completed. - */ - event_loop(0); - - /* NOTREACHED */ - exit(1); /* appease gcc/lint */ -} - -/* - * This runs periodically and checks to see if we have any active services - * still running. If we don't, then we quit. - */ -static void -exit_check(cookie) - void *cookie; -{ - int no_exit; - - assert(cookie != NULL); - no_exit = *(int *)cookie; - - /* - * If things are still running, then don't exit. - */ - if (serviceq.qlength > 0) - return; - - /* - * If the caller asked us to never exit, then we're done - */ - if (no_exit) - return; - -#ifdef USE_DBMALLOC - dbmalloc_info.end.size = malloc_inuse(&dbmalloc_info.end.hist); - - if (dbmalloc_info.start.size != dbmalloc_info.end.size) { - malloc_list(dbfd(), dbmalloc_info.start.hist, - dbmalloc_info.end.hist); - } -#endif - - dbclose(); - exit(0); -} - -/* - * Handles new incoming protocol handles. This is a callback for - * security_accept(), which gets called when new handles are detected. - */ -static void -protocol_accept(handle, pkt) - security_handle_t *handle; - pkt_t *pkt; -{ - pkt_t pkt_out; - struct active_service *as; - char *pktbody, *tok, *service, *arguments; - int i; - - /* - * If pkt is NULL, then there was a problem with the new connection. - */ - if (pkt == NULL) { - dbprintf(("%s: accept error: %s\n", - debug_prefix_time(NULL), security_geterror(handle))); - pkt_init(&pkt_out, P_NAK, "ERROR %s\n", security_geterror(handle)); - do_sendpkt(handle, &pkt_out); - security_close(handle); - return; - } - - dbprintf(("%s: accept recv %s pkt:\n<<<<<\n%s>>>>>\n", - debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); - - /* - * If this is not a REQ packet, just forget about it. - */ - if (pkt->type != P_REQ) { - dbprintf(("%s: received unexpected %s packet:\n<<<<<\n%s>>>>>\n\n", - debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); - security_close(handle); - return; - } - - pktbody = service = arguments = NULL; - as = NULL; - - /* - * Parse out the service and arguments - */ - - pktbody = stralloc(pkt->body); - - tok = strtok(pktbody, " "); - if (tok == NULL) - goto badreq; - if (strcmp(tok, "SERVICE") != 0) - goto badreq; - - tok = strtok(NULL, " \n"); - if (tok == NULL) - goto badreq; - service = stralloc(tok); - - /* we call everything else 'arguments' */ - tok = strtok(NULL, ""); - if (tok == NULL) - goto badreq; - arguments = stralloc(tok); - - /* see if it's one we allow */ - for (i = 0; i < NSERVICES; i++) - if (strcmp(services[i], service) == 0) - break; - if (i == NSERVICES) { - dbprintf(("%s: %s: invalid service\n", - debug_prefix_time(NULL), service)); - pkt_init(&pkt_out, P_NAK, "ERROR %s: invalid service\n", service); - goto send_pkt_out; - } - - service = newvstralloc(service, - libexecdir, "/", service, versionsuffix(), - NULL); - if (access(service, X_OK) < 0) { - dbprintf(("%s: can't execute %s: %s\n", - debug_prefix_time(NULL), service, strerror(errno))); - pkt_init(&pkt_out, P_NAK, "ERROR execute access to \"%s\" denied\n", - service); - goto send_pkt_out; - } - - /* see if its already running */ - for (as = TAILQ_FIRST(&serviceq.tailq); as != NULL; - as = TAILQ_NEXT(as, tq)) { - if (strcmp(as->cmd, service) == 0 && - strcmp(as->arguments, arguments) == 0) { - dbprintf(("%s: %s %s: already running, acking req\n", - debug_prefix_time(NULL), service, arguments)); - pkt_init(&pkt_out, P_ACK, ""); - goto send_pkt_out; - } - } - - /* - * create a new service instance, and send the arguments down - * the request pipe. - */ - dbprintf(("%s: creating new service: %s\n%s\n", - debug_prefix_time(NULL), service, arguments)); - as = service_new(handle, service, arguments); - if (writebuf(as, arguments, strlen(arguments)) < 0) { - const char *errmsg = strerror(errno); - dbprintf(("%s: error sending arguments to %s: %s\n", - debug_prefix_time(NULL), service, errmsg)); - pkt_init(&pkt_out, P_NAK, "ERROR error writing arguments to %s: %s\n", - service, errmsg); - goto send_pkt_out; - } - aclose(as->reqfd); - - amfree(pktbody); - amfree(service); - amfree(arguments); - - /* - * Move to the sendack state, and start up the state - * machine. - */ - as->state = s_sendack; - state_machine(as, A_START, NULL); - return; - -badreq: - pkt_init(&pkt_out, P_NAK, "ERROR invalid REQ\n"); - dbprintf(("%s: received invalid %s packet:\n<<<<<\n%s>>>>>\n\n", - debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); - -send_pkt_out: - amfree(pktbody); - amfree(service); - amfree(arguments); - if(as) service_delete(as); - do_sendpkt(handle, &pkt_out); - security_close(handle); -} - -/* - * Handles incoming protocol packets. Routes responses to the proper - * running service. - */ -static void -state_machine(as, action, pkt) - struct active_service *as; - action_t action; - pkt_t *pkt; -{ - action_t retaction; - state_t curstate; - pkt_t nak; - -#ifdef AMANDAD_DEBUG - dbprintf(("%s: state_machine: %X entering\n", - debug_prefix_time(NULL), (unsigned int)as)); -#endif - for (;;) { - curstate = as->state; -#ifdef AMANDAD_DEBUG - dbprintf(("%s: state_machine: %X curstate=%s action=%s\n", - debug_prefix_time(NULL), (unsigned int)as, - state2str(curstate), action2str(action))); -#endif - retaction = (*curstate)(as, action, pkt); -#ifdef AMANDAD_DEBUG - dbprintf(("%s: state_machine: %X curstate=%s returned %s (nextstate=%s)\n", - debug_prefix_time(NULL), - (unsigned int)as, state2str(curstate), action2str(retaction), - state2str(as->state))); -#endif - - switch (retaction) { - /* - * State has queued up and is now blocking on input. - */ - case A_PENDING: -#ifdef AMANDAD_DEBUG - dbprintf(("%s: state_machine: %X leaving (A_PENDING)\n", - debug_prefix_time(NULL), (unsigned int)as)); -#endif - return; - - /* - * service has switched states. Loop. - */ - case A_CONTINUE: - break; - - /* - * state has determined that the packet it received was bogus. - * Send a nak, and return. - */ - case A_SENDNAK: - dbprintf(("%s: received unexpected %s packet\n", - debug_prefix_time(NULL), pkt_type2str(pkt->type))); - dbprintf(("<<<<<\n%s----\n\n", pkt->body)); - pkt_init(&nak, P_NAK, "ERROR unexpected packet type %s\n", - pkt_type2str(pkt->type)); - do_sendpkt(as->security_handle, &nak); -#ifdef AMANDAD_DEBUG - dbprintf(("%s: state_machine: %X leaving (A_SENDNAK)\n", - debug_prefix_time(NULL), (unsigned int)as)); -#endif - return; - - /* - * Service is done. Remove it and finish. - */ - case A_FINISH: - service_delete(as); -#ifdef AMANDAD_DEBUG - dbprintf(("%s: state_machine: %X leaving (A_FINISH)\n", - debug_prefix_time(NULL), (unsigned int)as)); -#endif - return; - - default: - assert(0); - break; - } - } - /* NOTREACHED */ -} - -/* - * This state just sends an ack. After that, we move to the repwait - * state to wait for REP data to arrive from the subprocess. - */ -static action_t -s_sendack(as, action, pkt) - struct active_service *as; - action_t action; - pkt_t *pkt; -{ - pkt_t ack; - - pkt_init(&ack, P_ACK, ""); - if (do_sendpkt(as->security_handle, &ack) < 0) { - dbprintf(("%s: error sending ACK: %s\n", - debug_prefix_time(NULL), security_geterror(as->security_handle))); - return (A_FINISH); - } - - /* - * move to the repwait state - * Setup a listener for data on the reply fd, but also - * listen for packets over the wire, as the server may - * poll us if we take a long time. - * Setup a timeout that will fire if it takes too long to - * receive rep data. - */ - as->state = s_repwait; - as->ev_repfd = event_register(as->repfd, EV_READFD, repfd_recv, as); - as->ev_reptimeout = event_register(REP_TIMEOUT, EV_TIME, - timeout_repfd, as); - security_recvpkt(as->security_handle, protocol_recv, as, -1); - return (A_PENDING); -} - -/* - * This is the repwait state. We have responded to the initial REQ with - * an ACK, and we are now waiting for the process we spawned to pass us - * data to send in a REP. - */ -static action_t -s_repwait(as, action, pkt) - struct active_service *as; - action_t action; - pkt_t *pkt; -{ - int n; - - /* - * We normally shouldn't receive any packets while waiting - * for our REP data, but in some cases we do. - */ - if (action == A_RECVPKT) { - assert(pkt != NULL); - /* - * Another req for something that's running. Just send an ACK - * and go back and wait for more data. - */ - if (pkt->type == P_REQ) { - dbprintf(("%s: received dup P_REQ packet, ACKing it\n", - debug_prefix_time(NULL))); - pkt_init(&as->rep_pkt, P_ACK, ""); - do_sendpkt(as->security_handle, &as->rep_pkt); - return (A_PENDING); - } - /* something unexpected. Nak it */ - return (A_SENDNAK); - } - - if (action == A_TIMEOUT) { - pkt_init(&as->rep_pkt, P_NAK, "ERROR timeout on reply pipe\n"); - dbprintf(("%s: %s timed out waiting for REP data\n", - debug_prefix_time(NULL), as->cmd)); - do_sendpkt(as->security_handle, &as->rep_pkt); - return (A_FINISH); - } - - assert(action == A_RECVREP); - - /* - * If the read fails, consider the process dead, and remove it. - * Always save room for nul termination. - */ - if (as->repbufsize + 1 >= sizeof(as->repbuf)) { - dbprintf(("%s: more than %d bytes in reply\n", - debug_prefix_time(NULL), sizeof(as->repbuf))); - dbprintf(("%s: reply so far:\n%s\n", debug_prefix(NULL), as->repbuf)); - pkt_init(&as->rep_pkt, P_NAK, "ERROR more than %d bytes in reply\n", - sizeof(as->repbuf)); - do_sendpkt(as->security_handle, &as->rep_pkt); - return (A_FINISH); - } - do { - n = read(as->repfd, as->repbuf + as->repbufsize, - sizeof(as->repbuf) - as->repbufsize - 1); - } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); - if (n < 0) { - const char *errstr = strerror(errno); - dbprintf(("%s: read error on reply pipe: %s\n", - debug_prefix_time(NULL), errstr)); - pkt_init(&as->rep_pkt, P_NAK, "ERROR read error on reply pipe: %s\n", - errstr); - do_sendpkt(as->security_handle, &as->rep_pkt); - return (A_FINISH); - } - /* - * If we got some data, go back and wait for more, or EOF. Nul terminate - * the buffer first. - */ - as->repbuf[n + as->repbufsize] = '\0'; - if (n > 0) { - as->repbufsize += n; - if(as->send_partial_reply) { - pkt_init(&as->rep_pkt, P_PREP, "%s", as->repbuf); - do_sendpkt(as->security_handle, &as->rep_pkt); - pkt_init(&as->rep_pkt, P_REP, ""); - } - - return (A_PENDING); - } - - /* - * If we got 0, then we hit EOF. Process the data and release - * the timeout. - */ - assert(n == 0); - - assert(as->ev_repfd != NULL); - event_release(as->ev_repfd); - as->ev_repfd = NULL; - - assert(as->ev_reptimeout != NULL); - event_release(as->ev_reptimeout); - as->ev_reptimeout = NULL; - - as->state = s_processrep; - aclose(as->repfd); - return (A_CONTINUE); -} - -/* - * After we have read in all of the rep data, we process it and send - * it out as a REP packet. - */ -static action_t -s_processrep(as, action, pkt) - struct active_service *as; - action_t action; - pkt_t *pkt; -{ - char *tok, *repbuf; - - /* - * Copy the rep lines into the outgoing packet. - * - * If this line is a CONNECT, translate it - * Format is "CONNECT etc... - * Example: - * - * CONNECT DATA 4 MESG 5 INDEX 6 - * - * The tags are arbitrary. The handles are in the DATA_FD pool. - * We need to map these to security streams and pass them back - * to the amanda server. If the handle is -1, then we don't map. - */ - repbuf = stralloc(as->repbuf); - pkt_init(&as->rep_pkt, P_REP, ""); - tok = strtok(repbuf, " "); - if (tok == NULL) - goto error; - if (strcmp(tok, "CONNECT") == 0) { - char *line, *nextbuf; - - /* Save the entire line */ - line = strtok(NULL, "\n"); - /* Save the buf following the line */ - nextbuf = strtok(NULL, ""); - - if (line == NULL || nextbuf == NULL) - goto error; - - pkt_cat(&as->rep_pkt, "CONNECT"); - - /* loop over the id/handle pairs */ - for (;;) { - /* id */ - tok = strtok(line, " "); - line = NULL; /* keep working from line */ - if (tok == NULL) - break; - pkt_cat(&as->rep_pkt, " %s", tok); - - /* handle */ - tok = strtok(NULL, " \n"); - if (tok == NULL) - goto error; - /* convert the handle into something the server can process */ - pkt_cat(&as->rep_pkt, " %d", allocstream(as, atoi(tok))); - } - pkt_cat(&as->rep_pkt, "\n%s", nextbuf); - } else { -error: - pkt_cat(&as->rep_pkt, "%s", as->repbuf); - } - - /* - * We've setup our REP packet in as->rep_pkt. Now move to the transmission - * state. - */ - as->state = s_sendrep; - as->repretry = MAX_REP_RETRIES; - amfree(repbuf); - return (A_CONTINUE); -} - -/* - * This is the state where we send the REP we just collected from our child. - */ -static action_t -s_sendrep(as, action, pkt) - struct active_service *as; - action_t action; - pkt_t *pkt; -{ - - /* - * Transmit it and move to the ack state. - */ - do_sendpkt(as->security_handle, &as->rep_pkt); - security_recvpkt(as->security_handle, protocol_recv, as, ACK_TIMEOUT); - as->state = s_ackwait; - return (A_PENDING); -} - -/* - * This is the state in which we wait for the server to ACK the REP - * we just sent it. - */ -static action_t -s_ackwait(as, action, pkt) - struct active_service *as; - action_t action; - pkt_t *pkt; -{ - struct datafd_handle *dh; - int npipes; - - /* - * If we got a timeout, try again, but eventually give up. - */ - if (action == A_TIMEOUT) { - if (--as->repretry > 0) { - as->state = s_sendrep; - return (A_CONTINUE); - } - dbprintf(("%s: timeout waiting for ACK for our REP\n", - debug_prefix_time(NULL))); - return (A_FINISH); - } -#ifdef AMANDAD_DEBUG - dbprintf(("%s: received ACK, now opening streams\n", - debug_prefix_time(NULL))); -#endif - - assert(action == A_RECVPKT); - if (pkt->type != P_ACK) - return (A_SENDNAK); - - /* - * Got the ack, now open the pipes - */ - for (dh = &as->data[0]; dh < &as->data[DATA_FD_COUNT]; dh++) { - if (dh->netfd == NULL) - continue; - if (security_stream_accept(dh->netfd) < 0) { - dbprintf(("%s: stream %d accept failed: %s\n", - debug_prefix_time(NULL), - dh - &as->data[0], security_geterror(as->security_handle))); - security_stream_close(dh->netfd); - dh->netfd = NULL; - } - /* setup an event for reads from it */ - dh->ev_handle = event_register(dh->fd, EV_READFD, process_netfd, dh); - } - - /* - * Pipes are open, so auth them. Count them at the same time. - */ - for (npipes = 0, dh = &as->data[0]; dh < &as->data[DATA_FD_COUNT]; dh++) { - if (dh->netfd == NULL) - continue; - if (security_stream_auth(dh->netfd) < 0) { - security_stream_close(dh->netfd); - dh->netfd = NULL; - event_release(dh->ev_handle); - dh->ev_handle = NULL; - } else { - npipes++; - } - } - - /* - * If no pipes are open, then we're done. Otherwise, just start running. - * The event handlers on all of the pipes will take it from here. - */ -#ifdef AMANDAD_DEBUG - dbprintf(("%s: at end of s_ackwait, npipes is %d\n", - debug_prefix_time(NULL), npipes)); -#endif - if (npipes == 0) - return (A_FINISH); - else { - security_close(as->security_handle); - as->security_handle = NULL; - return (A_PENDING); - } -} - -/* - * Called when a repfd has received data - */ -static void -repfd_recv(cookie) - void *cookie; -{ - struct active_service *as = cookie; - - assert(as != NULL); - assert(as->ev_repfd != NULL); - - state_machine(as, A_RECVREP, NULL); -} - -/* - * Called when a repfd has timed out - */ -static void -timeout_repfd(cookie) - void *cookie; -{ - struct active_service *as = cookie; - - assert(as != NULL); - assert(as->ev_reptimeout != NULL); - - state_machine(as, A_TIMEOUT, NULL); -} - -/* - * Called when a handle has received data - */ -static void -protocol_recv(cookie, pkt, status) - void *cookie; - pkt_t *pkt; - security_status_t status; -{ - struct active_service *as = cookie; - - assert(as != NULL); - - switch (status) { - case S_OK: - dbprintf(("%s: received %s pkt:\n<<<<<\n%s>>>>>\n", - debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); - state_machine(as, A_RECVPKT, pkt); - break; - case S_TIMEOUT: - dbprintf(("%s: timeout\n", debug_prefix_time(NULL))); - state_machine(as, A_TIMEOUT, NULL); - break; - case S_ERROR: - dbprintf(("%s: receive error: %s\n", - debug_prefix_time(NULL), security_geterror(as->security_handle))); - break; - } -} - -/* - * This is a generic relay function that just reads data from one of - * the process's pipes and passes it up the equivalent security_stream_t - */ -static void -process_netfd(cookie) - void *cookie; -{ - pkt_t nak; - struct datafd_handle *dh = cookie; - struct active_service *as = dh->as; - int n; - - do { - n = read(dh->fd, as->databuf, sizeof(as->databuf)); - } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); - - /* - * Process has died. - */ - if (n < 0) { - pkt_init(&nak, P_NAK, "ERROR data descriptor %d broken: %s\n", - dh->fd, strerror(errno)); - goto sendnak; - } - /* - * Process has closed the pipe. Just remove this event handler. - * If all pipes are closed, shut down this service. - */ - if (n == 0) { - event_release(dh->ev_handle); - dh->ev_handle = NULL; - security_stream_close(dh->netfd); - dh->netfd = NULL; - for (dh = &as->data[0]; dh < &as->data[DATA_FD_COUNT]; dh++) { - if (dh->netfd != NULL) - return; - } - service_delete(as); - return; - } - if (security_stream_write(dh->netfd, as->databuf, n) < 0) { - /* stream has croaked */ - pkt_init(&nak, P_NAK, "ERROR write error on stream %d: %s\n", - security_stream_id(dh->netfd), - security_stream_geterror(dh->netfd)); - goto sendnak; - } - return; - -sendnak: - do_sendpkt(as->security_handle, &nak); - service_delete(as); -} - - -/* - * Convert a local stream handle (DATA_FD...) into something that - * can be sent to the amanda server. - * - * Returns a number that should be sent to the server in the REP packet. - */ -static int -allocstream(as, handle) - struct active_service *as; - int handle; -{ - struct datafd_handle *dh; - - /* if the handle is -1, then we don't bother */ - if (handle < 0) - return (-1); - - /* make sure the handle's kosher */ - if (handle < DATA_FD_OFFSET || handle >= DATA_FD_OFFSET + DATA_FD_COUNT) - return (-1); - - /* get a pointer into our handle array */ - dh = &as->data[handle - DATA_FD_OFFSET]; - - /* make sure we're not already using the net handle */ - if (dh->netfd != NULL) - return (-1); - - /* allocate a stream from the security layer and return */ - dh->netfd = security_stream_server(as->security_handle); - if (dh->netfd == NULL) { - dbprintf(("%s: couldn't open stream to server: %s\n", - debug_prefix_time(NULL), security_geterror(as->security_handle))); - return (-1); - } - - /* - * convert the stream into a numeric id that can be sent to the - * remote end. - */ - return (security_stream_id(dh->netfd)); -} - -/* - * Create a new service instance - */ -static struct active_service * -service_new(security_handle, cmd, arguments) - security_handle_t *security_handle; - const char *cmd, *arguments; -{ - int data[DATA_FD_COUNT + 2][2], i; - struct active_service *as; - pid_t pid; - int newfd; - - assert(security_handle != NULL); - assert(cmd != NULL); - assert(arguments != NULL); - - /* a plethora of pipes */ - for (i = 0; i < DATA_FD_COUNT + 2; i++) - if (pipe(data[i]) < 0) - error("pipe: %s", strerror(errno)); - - switch(pid = fork()) { - case -1: - error("could not fork service %s: %s", cmd, strerror(errno)); - default: - /* - * The parent. Close the far ends of our pipes and return. - */ - as = alloc(sizeof(*as)); - as->cmd = stralloc(cmd); - as->arguments = stralloc(arguments); - as->security_handle = security_handle; - as->state = NULL; - as->pid = pid; - as->send_partial_reply = 0; - if(strcmp(cmd+(strlen(cmd)-8), "sendsize") == 0) { - g_option_t *g_options; - char *option_str, *p; - - option_str = stralloc(as->arguments+8); - p = strchr(option_str,'\n'); - if(p) *p = '\0'; - - g_options = parse_g_options(option_str, 1); - if(am_has_feature(g_options->features, fe_partial_estimate)) { - as->send_partial_reply = 1; - } - amfree(g_options); - amfree(option_str); - } - - /* write to the request pipe */ - aclose(data[0][0]); - as->reqfd = data[0][1]; - - /* - * read from the reply pipe - */ - as->repfd = data[1][0]; - aclose(data[1][1]); - as->ev_repfd = NULL; - as->repbufsize = 0; - as->repretry = 0; - - /* - * read from the rest of the general-use pipes - * (netfds are opened as the client requests them) - */ - for (i = 0; i < DATA_FD_COUNT; i++) { - aclose(data[i + 2][1]); - as->data[i].fd = data[i + 2][0]; - as->data[i].ev_handle = NULL; - as->data[i].netfd = NULL; - as->data[i].as = as; - } - - /* add it to the service queue */ - /* increment the active service count */ - TAILQ_INSERT_TAIL(&serviceq.tailq, as, tq); - serviceq.qlength++; - - return (as); - case 0: - /* - * The child. Put our pipes in their advertised locations - * and start up. - */ -#ifdef FORCE_USERID - seteuid((uid_t)0); - setuid(client_uid); -#endif - - /* - * The data stream is stdin in the new process - */ - if (dup2(data[0][0], 0) < 0) { - error("dup %d to %d failed: %s\n", data[0][0], 0, - strerror(errno)); - } - aclose(data[0][0]); - aclose(data[0][1]); - - /* - * The reply stream is stdout - */ - if (dup2(data[1][1], 1) < 0) { - error("dup %d to %d failed: %s\n", data[1][1], 1, - strerror(errno)); - } - aclose(data[1][0]); - aclose(data[1][1]); - - /* - * The rest start at the offset defined in amandad.h, and continue - * through the internal defined. - */ - for (i = 0; i < DATA_FD_COUNT; i++) - aclose(data[i + 2][0]); - - /* - * Make sure they are not open in the range DATA_FD_OFFSET to - * DATA_FD_OFFSET + DATA_FD_COUNT - 1 - */ - for (i = 0; i < DATA_FD_COUNT; i++) { - while(data[i + 2][1] >= DATA_FD_OFFSET && - data[i + 2][1] <= DATA_FD_OFFSET + DATA_FD_COUNT - 1) { - newfd = dup(data[i + 2][1]); - if(newfd == -1) - error("Can't dup out off DATA_FD range"); - data[i + 2][1] = newfd; - } - } - for (i = 0; i < DATA_FD_COUNT; i++) - close(DATA_FD_OFFSET + i); - - for (i = 0; i < DATA_FD_COUNT; i++) { - if (dup2(data[i + 2][1], i + DATA_FD_OFFSET) < 0) { - error("dup %d to %d failed: %s\n", data[i + 2][1], - i + DATA_FD_OFFSET, strerror(errno)); - } - aclose(data[i + 2][1]); - } - - execle(cmd, cmd, NULL, safe_env()); - error("could not exec service %s: %s", cmd, strerror(errno)); - } - /* NOTREACHED */ - return NULL; -} - -/* - * Unallocate a service instance - */ -static void -service_delete(as) - struct active_service *as; -{ - int i; - struct datafd_handle *dh; - -#ifdef AMANDAD_DEBUG - dbprintf(("%s: closing service: %s\n", - debug_prefix_time(NULL), (as->cmd)?as->cmd:"??UNKONWN??")); -#endif - - assert(as != NULL); - - assert(as->cmd != NULL); - amfree(as->cmd); - - assert(as->arguments != NULL); - amfree(as->arguments); - - if (as->reqfd != -1) - aclose(as->reqfd); - if (as->repfd != -1) - aclose(as->repfd); - - if (as->ev_repfd != NULL) - event_release(as->ev_repfd); - if (as->ev_reptimeout != NULL) - event_release(as->ev_reptimeout); - - for (i = 0; i < DATA_FD_COUNT; i++) { - dh = &as->data[i]; - - aclose(dh->fd); - - if (dh->netfd != NULL) - security_stream_close(dh->netfd); - - if (dh->ev_handle != NULL) - event_release(dh->ev_handle); - } - - if (as->security_handle != NULL) - security_close(as->security_handle); - - assert(as->pid > 0); - kill(as->pid, SIGTERM); - waitpid(as->pid, NULL, WNOHANG); - - TAILQ_REMOVE(&serviceq.tailq, as, tq); - assert(serviceq.qlength > 0); - serviceq.qlength--; - - amfree(as); -} - -/* - * Like 'fullwrite', but does the work in a child process so pipelines - * do not hang. - */ -static int -writebuf(as, bufp, size) - struct active_service *as; - const void *bufp; - size_t size; -{ - int pid; - - switch (pid=fork()) { - case -1: - return -1; - - default: - waitpid(pid, NULL, WNOHANG); - return 0; /* this is the parent */ - - case 0: - break; /* this is the child */ - } - aclose (as->repfd); /* make sure we are not a reader */ - exit (fullwrite(as->reqfd, bufp, size) != size); -} - -static int -do_sendpkt(handle, pkt) - security_handle_t *handle; - pkt_t *pkt; -{ - dbprintf(("%s: sending %s pkt:\n<<<<<\n%s>>>>>\n", - debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->body)); - return security_sendpkt(handle, pkt); -} - -#ifdef AMANDAD_DEBUG -/* - * Convert a state into a string - */ -static const char * -state2str(state) - state_t state; -{ - static const struct { - state_t state; - const char str[13]; - } states[] = { -#define X(state) { state, stringize(state) } - X(s_sendack), - X(s_repwait), - X(s_processrep), - X(s_sendrep), - X(s_ackwait), -#undef X - }; - int i; - - for (i = 0; i < sizeof(states) / sizeof(states[0]); i++) - if (state == states[i].state) - return (states[i].str); - return ("INVALID STATE"); -} - -/* - * Convert an action into a string - */ -static const char * -action2str(action) - action_t action; -{ - static const struct { - action_t action; - const char str[12]; - } actions[] = { -#define X(action) { action, stringize(action) } - X(A_START), - X(A_RECVPKT), - X(A_RECVREP), - X(A_PENDING), - X(A_FINISH), - X(A_CONTINUE), - X(A_SENDNAK), - X(A_TIMEOUT), -#undef X - }; - int i; - - for (i = 0; i < sizeof(actions) / sizeof(actions[0]); i++) - if (action == actions[i].action) - return (actions[i].str); - return ("UNKNOWN ACTION"); -} -#endif /* AMANDAD_DEBUG */ diff --git a/client-src/amandad.h b/client-src/amandad.h deleted file mode 100644 index 054f6bd..0000000 --- a/client-src/amandad.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Amanda, The Advanced Maryland Automatic Network Disk Archiver - * Copyright (c) 1999 University of Maryland at College Park - * All Rights Reserved. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of U.M. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. U.M. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Authors: the Amanda Development Team. Its members are listed in a - * file named AUTHORS, in the root directory of this distribution. - */ -/* - * $Id: amandad.h,v 1.2 1999/04/16 05:12:39 kashmir Exp $ - */ -#ifndef AMANDAD_H -#define AMANDAD_H - -/* - * General-use pipes inherited by sendbackup that are connected to the - * data, mesg, index, etc connections on the server. amandad sets these - * up before calling sendbackup, and will relay data sent on them - * back to the server. - */ -#define DATA_FD_COUNT 3 /* number of general-use pipes */ -#define DATA_FD_OFFSET 50 /* fd at which they start */ - -#endif /* AMANDAD_H */ diff --git a/client-src/amandates.c b/client-src/amandates.c index e1aad26..b800520 100644 --- a/client-src/amandates.c +++ b/client-src/amandates.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: amandates.c,v 1.16 2003/10/22 17:43:20 martinea Exp $ + * $Id: amandates.c,v 1.21 2006/07/25 18:35:21 martinea Exp $ * * manage amandates file, that mimics /etc/dumpdates, but stores * GNUTAR dates @@ -32,24 +32,33 @@ #include "amanda.h" #include "getfsent.h" +#include "util.h" #include "amandates.h" static amandates_t *amandates_list = NULL; static FILE *amdf = NULL; static int updated, readonly; -static void import_dumpdates P((amandates_t *)); -static void enter_record P((char *, int , time_t)); -static amandates_t *lookup P((char *name, int import)); - -int start_amandates(open_readwrite) -int open_readwrite; +static char *g_amandates_file = NULL; +static void import_dumpdates(amandates_t *); +static void enter_record(char *, int , time_t); +static amandates_t *lookup(char *name, int import); + +int +start_amandates( + char *amandates_file, + int open_readwrite) { - int rc, level; - long ldate; - char *line = NULL, *name = NULL; + int rc, level = 0; + long ldate = 0L; + char *line; + char *name; char *s; int ch; + char *qname; + + if (amandates_file == NULL) + return 0; /* clean up from previous invocation */ @@ -57,6 +66,7 @@ int open_readwrite; finish_amandates(); if(amandates_list != NULL) free_amandates(); + amfree(g_amandates_file); /* initialize state */ @@ -64,37 +74,41 @@ int open_readwrite; readonly = !open_readwrite; amdf = NULL; amandates_list = NULL; - + g_amandates_file = stralloc(amandates_file); /* open the file */ - if (access(AMANDATES_FILE,F_OK)) + if (access(amandates_file,F_OK)) /* not yet existing */ - if ( (rc = open(AMANDATES_FILE,(O_CREAT|O_RDWR),0644)) != -1 ) + if ( (rc = open(amandates_file,(O_CREAT|O_RDWR),0644)) != -1 ) /* open/create successfull */ aclose(rc); if(open_readwrite) - amdf = fopen(AMANDATES_FILE, "r+"); + amdf = fopen(amandates_file, "r+"); else - amdf = fopen(AMANDATES_FILE, "r"); + amdf = fopen(amandates_file, "r"); /* create it if we need to */ if(amdf == NULL && (errno == EINTR || errno == ENOENT) && open_readwrite) - amdf = fopen(AMANDATES_FILE, "w"); + amdf = fopen(amandates_file, "w"); if(amdf == NULL) return 0; if(open_readwrite) - rc = amflock(fileno(amdf), "amandates"); + rc = amflock(fileno(amdf), amandates_file); else - rc = amroflock(fileno(amdf), "amandates"); + rc = amroflock(fileno(amdf), amandates_file); - if(rc == -1) - error("could not lock %s: %s", AMANDATES_FILE, strerror(errno)); + if(rc == -1) { + error("could not lock %s: %s", amandates_file, strerror(errno)); + /*NOTREACHED*/ + } for(; (line = agets(amdf)) != NULL; free(line)) { + if (line[0] == '\0') + continue; s = line; ch = *s++; @@ -102,59 +116,76 @@ int open_readwrite; if(ch == '\0') { continue; /* no name field */ } - name = s - 1; - skip_non_whitespace(s, ch); + qname = s - 1; + skip_quoted_string(s, ch); s[-1] = '\0'; /* terminate the name */ + name = unquote_string(qname); skip_whitespace(s, ch); if(ch == '\0' || sscanf(s - 1, "%d %ld", &level, &ldate) != 2) { + amfree(name); continue; /* no more fields */ } if(level < 0 || level >= DUMP_LEVELS) { + amfree(name); continue; } enter_record(name, level, (time_t) ldate); + amfree(name); } - if(ferror(amdf)) - error("reading %s: %s", AMANDATES_FILE, strerror(errno)); + if(ferror(amdf)) { + error("reading %s: %s", amandates_file, strerror(errno)); + /*NOTREACHED*/ + } updated = 0; /* reset updated flag */ return 1; } -void finish_amandates() +void +finish_amandates(void) { amandates_t *amdp; int level; + char *qname; if(amdf == NULL) return; if(updated) { - if(readonly) + if(readonly) { error("updated amandates after opening readonly"); + /*NOTREACHED*/ + } rewind(amdf); for(amdp = amandates_list; amdp != NULL; amdp = amdp->next) { for(level = 0; level < DUMP_LEVELS; level++) { if(amdp->dates[level] == EPOCH) continue; + qname = quote_string(amdp->name); fprintf(amdf, "%s %d %ld\n", - amdp->name, level, (long) amdp->dates[level]); + qname, level, (long) amdp->dates[level]); + amfree(qname); } } } - if(amfunlock(fileno(amdf), "amandates") == -1) - error("could not unlock %s: %s", AMANDATES_FILE, strerror(errno)); - if (fclose(amdf) == EOF) - error("error [closing %s: %s]", AMANDATES_FILE, strerror(errno)); + if(amfunlock(fileno(amdf), g_amandates_file) == -1) { + error("could not unlock %s: %s", g_amandates_file, strerror(errno)); + /*NOTREACHED*/ + } + if (fclose(amdf) == EOF) { + error("error [closing %s: %s]", g_amandates_file, strerror(errno)); + /*NOTREACHED*/ + } amdf = NULL; } -void free_amandates() +void +free_amandates(void) { amandates_t *amdp, *nextp; @@ -166,54 +197,70 @@ void free_amandates() amandates_list = NULL; } -static amandates_t *lookup(name, import) -char *name; -int import; +static amandates_t * +lookup( + char * name, + int import) { - amandates_t *prevp, *amdp, *newp; + amandates_t *prevp, *amdp; int rc, level; + (void)import; /* Quiet unused parameter warning */ rc = 0; - for(prevp=NULL,amdp=amandates_list;amdp!=NULL;prevp=amdp,amdp=amdp->next) - if((rc = strcmp(name, amdp->name)) <= 0) + prevp = NULL; + amdp = amandates_list; + while (amdp != NULL) { + if ((rc = strcmp(name, amdp->name)) <= 0) break; - - if(amdp && rc == 0) - return amdp; - - newp = alloc(sizeof(amandates_t)); - newp->name = stralloc(name); - for(level = 0; level < DUMP_LEVELS; level++) - newp->dates[level] = EPOCH; - newp->next = amdp; - if(prevp) prevp->next = newp; - else amandates_list = newp; - - import_dumpdates(newp); - - return newp; + prevp = amdp; + amdp = amdp->next; + } + if (!(amdp && (rc == 0))) { + amandates_t *newp = alloc(SIZEOF(amandates_t)); + newp->name = stralloc(name); + for (level = 0; level < DUMP_LEVELS; level++) + newp->dates[level] = EPOCH; + newp->next = amdp; + if (prevp != NULL) { +#ifndef __lint /* Remove complaint about NULL pointer assignment */ + prevp->next = newp; +#else + (void)prevp; +#endif + } else { + amandates_list = newp; + } + import_dumpdates(newp); + return newp; + } + return amdp; } -amandates_t *amandates_lookup(name) -char *name; +amandates_t * +amandates_lookup( + char * name) { return lookup(name, 1); } -static void enter_record(name, level, dumpdate) -char *name; -int level; -time_t dumpdate; +static void +enter_record( + char * name, + int level, + time_t dumpdate) { amandates_t *amdp; + char *qname; amdp = lookup(name, 0); if(level < 0 || level >= DUMP_LEVELS || dumpdate < amdp->dates[level]) { + qname = quote_string(name); /* this is not allowed, but we can ignore it */ dbprintf(("amandates botch: %s lev %d: new dumpdate %ld old %ld\n", - name, level, (long) dumpdate, (long) amdp->dates[level])); + qname, level, (long) dumpdate, (long) amdp->dates[level])); + amfree(qname); return; } @@ -221,12 +268,14 @@ time_t dumpdate; } -void amandates_updateone(name, level, dumpdate) -char *name; -int level; -time_t dumpdate; +void +amandates_updateone( + char * name, + int level, + time_t dumpdate) { amandates_t *amdp; + char *qname; assert(!readonly); @@ -234,8 +283,10 @@ time_t dumpdate; if(level < 0 || level >= DUMP_LEVELS || dumpdate < amdp->dates[level]) { /* this is not allowed, but we can ignore it */ + qname = quote_string(name); dbprintf(("amandates updateone: %s lev %d: new dumpdate %ld old %ld", name, level, (long) dumpdate, (long) amdp->dates[level])); + amfree(qname); return; } @@ -246,11 +297,14 @@ time_t dumpdate; /* -------------------------- */ -static void import_dumpdates(amdp) -amandates_t *amdp; +static void +import_dumpdates( + amandates_t * amdp) { - char *devname = NULL, *line = NULL, *fname = NULL; - int level; + char *devname; + char *line; + char *fname; + int level = 0; time_t dumpdate; FILE *dumpdf; char *s; @@ -264,6 +318,8 @@ amandates_t *amdp; } for(; (line = agets(dumpdf)) != NULL; free(line)) { + if (line[0] == '\0') + continue; s = line; ch = *s++; diff --git a/client-src/amandates.h b/client-src/amandates.h index 8cf5bba..7cc0f5d 100644 --- a/client-src/amandates.h +++ b/client-src/amandates.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: amandates.h,v 1.3 1998/07/04 00:18:10 oliva Exp $ + * $Id: amandates.h,v 1.5 2006/07/25 18:35:21 martinea Exp $ * * interface for amandates file */ @@ -46,10 +46,10 @@ typedef struct amandates_s { time_t dates[DUMP_LEVELS]; /* dump dates */ } amandates_t; -int start_amandates P((int open_readwrite)); -void finish_amandates P((void)); -void free_amandates P((void)); -amandates_t *amandates_lookup P((char *name)); -void amandates_updateone P((char *name, int level, time_t dumpdate)); +int start_amandates (char *amandates_file, int open_readwrite); +void finish_amandates (void); +void free_amandates (void); +amandates_t *amandates_lookup (char *name); +void amandates_updateone (char *name, int level, time_t dumpdate); #endif /* ! AMANDATES_H */ diff --git a/client-src/calcsize.c b/client-src/calcsize.c index 0f174e8..662dfd0 100644 --- a/client-src/calcsize.c +++ b/client-src/calcsize.c @@ -24,28 +24,40 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: calcsize.c,v 1.37 2006/03/29 15:45:08 martinea Exp $ + * $Id: calcsize.c,v 1.44 2006/07/25 18:27:56 martinea Exp $ * * traverse directory tree to get backup size estimates + * + * argv[0] is the calcsize program name + * argv[1] is the config name or NOCONFIG */ #include "amanda.h" #include "statfs.h" +#include "version.h" #include "sl.h" +#include "util.h" #define ROUND(n,x) ((x) + (n) - 1 - (((x) + (n) - 1) % (n))) /* -static unsigned long round_function(n, x) -unsigned long n, x; +static off_t +round_function(n, x) + off_t n, + off_t x) { unsigned long remainder = x % n; if (remainder) - x += n-remainder; + x += n - remainder; return x; } */ -#define ST_BLOCKS(s) ((((s).st_blocks * 512) <= (s).st_size) ? (s).st_blocks+1 : ((s).st_size / 512 + (((s).st_size % 512) ? 1 : 0))) +#define ST_BLOCKS(s) \ + (((((off_t)(s).st_blocks * (off_t)512) <= (s).st_size)) ? \ + ((off_t)(s).st_blocks + (off_t)1) : \ + ((s).st_size / (off_t)512 + \ + (off_t)((((s).st_size % (off_t)512) != (off_t)0) ? \ + (off_t)1 : (off_t)0))) #define FILETYPES (S_IFREG|S_IFLNK|S_IFDIR) @@ -62,50 +74,57 @@ struct { int max_inode; int total_dirs; int total_files; - long total_size; - long total_size_name; + off_t total_size; + off_t total_size_name; } dumpstats[MAXDUMPS]; time_t dumpdate[MAXDUMPS]; int dumplevel[MAXDUMPS]; int ndumps; -void (*add_file_name) P((int, char *)); -void (*add_file) P((int, struct stat *)); -long (*final_size) P((int, char *)); +void (*add_file_name)(int, char *); +void (*add_file)(int, struct stat *); +off_t (*final_size)(int, char *); + +int main(int, char **); +void traverse_dirs(char *, char *); -int main P((int, char **)); -void traverse_dirs P((char *, char *)); +void add_file_name_dump(int, char *); +void add_file_dump(int, struct stat *); +off_t final_size_dump(int, char *); -void add_file_name_dump P((int, char *)); -void add_file_dump P((int, struct stat *)); -long final_size_dump P((int, char *)); +void add_file_name_star(int, char *); +void add_file_star(int, struct stat *); +off_t final_size_star(int, char *); -void add_file_name_gnutar P((int, char *)); -void add_file_gnutar P((int, struct stat *)); -long final_size_gnutar P((int, char *)); +void add_file_name_gnutar(int, char *); +void add_file_gnutar(int, struct stat *); +off_t final_size_gnutar(int, char *); -void add_file_name_unknown P((int, char *)); -void add_file_unknown P((int, struct stat *)); -long final_size_unknown P((int, char *)); +void add_file_name_unknown(int, char *); +void add_file_unknown(int, struct stat *); +off_t final_size_unknown(int, char *); -sl_t *calc_load_file P((char *filename)); -int calc_check_exclude P((char *filename)); +sl_t *calc_load_file(char *filename); +int calc_check_exclude(char *filename); +int use_star_excl = 0; int use_gtar_excl = 0; sl_t *include_sl=NULL, *exclude_sl=NULL; -int main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char ** argv) { #ifdef TEST /* standalone test to ckeck wether the calculated file size is ok */ struct stat finfo; int i; - unsigned long dump_total=0, gtar_total=0; + off_t dump_total = (off_t)0; + off_t gtar_total = (off_t)0; char *d; int l, w; @@ -113,6 +132,8 @@ char **argv; set_pname("calcsize"); + dbopen(NULL); + /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); @@ -126,16 +147,16 @@ char **argv; continue; } printf("%s: st_size=%lu", argv[i],(unsigned long)finfo.st_size); - printf(": blocks=%lu\n", (unsigned long)ST_BLOCKS(finfo)); - dump_total += (ST_BLOCKS(finfo) + 1)/2 + 1; - gtar_total += ROUND(4,(ST_BLOCKS(finfo) + 1)); + printf(": blocks=%llu\n", ST_BLOCKS(finfo)); + dump_total += (ST_BLOCKS(finfo) + (off_t)1) / (off_t)2 + (off_t)1; + gtar_total += ROUND(4,(ST_BLOCKS(finfo) + (off_t)1)); } printf(" gtar dump\n"); printf("total %-9lu %-9lu\n",gtar_total,dump_total); return 0; #else int i; - char *dirname=NULL, *amname=NULL, *filename=NULL; + char *dirname=NULL, *amname=NULL, *filename=NULL, *qfilename = NULL; unsigned long malloc_hist_1, malloc_size_1; unsigned long malloc_hist_2, malloc_size_2; @@ -144,6 +165,9 @@ char **argv; set_pname("calcsize"); + dbopen(DBG_SUBDIR_CLIENT); + dbprintf(("%s: version %s\n", debug_prefix(NULL), version())); + malloc_size_1 = malloc_inuse(&malloc_hist_1); #if 0 @@ -154,18 +178,25 @@ char **argv; /* need at least program, amname, and directory name */ - if(argc < 3) { - error("Usage: %s [DUMP|GNUTAR] name dir [-X exclude-file] [-I include-file] [level date]*", + if(argc < 4) { + error("Usage: %s config [DUMP|GNUTAR] name dir [-X exclude-file] [-I include-file] [level date]*", get_pname()); - return 1; + /*NOTREACHED*/ + } + + dbprintf(("config: %s\n", *argv)); + if (strcmp(*argv, "NOCONFIG") != 0) { + dbrename(*argv, DBG_SUBDIR_CLIENT); } + argc--; + argv++; /* parse backup program name */ if(strcmp(*argv, "DUMP") == 0) { #if !defined(DUMP) && !defined(XFSDUMP) error("dump not available on this system"); - return 1; + /*NOTREACHED*/ #else add_file_name = add_file_name_dump; add_file = add_file_dump; @@ -175,7 +206,7 @@ char **argv; else if(strcmp(*argv, "GNUTAR") == 0) { #ifndef GNUTAR error("gnutar not available on this system"); - return 1; + /*NOTREACHED*/ #else add_file_name = add_file_name_gnutar; add_file = add_file_gnutar; @@ -195,47 +226,66 @@ char **argv; if (argc > 0) { amname = *argv; argc--, argv++; - } else + } else { error("missing "); + /*NOTREACHED*/ + } /* the toplevel directory name to search from */ if (argc > 0) { dirname = *argv; argc--, argv++; - } else + } else { error("missing "); + /*NOTREACHED*/ + } if ((argc > 1) && strcmp(*argv,"-X") == 0) { argv++; - if (!use_gtar_excl) { + if (!(use_gtar_excl || use_star_excl)) { error("exclusion specification not supported"); - return 1; + /*NOTREACHED*/ } filename = stralloc(*argv); + qfilename = quote_string(filename); if (access(filename, R_OK) != 0) { - fprintf(stderr,"Cannot open exclude file %s\n",filename); - use_gtar_excl = 0; + fprintf(stderr,"Cannot open exclude file %s\n", qfilename); + use_gtar_excl = use_star_excl = 0; } else { - exclude_sl = calc_load_file(filename); + exclude_sl = calc_load_file(filename); + if (!exclude_sl) { + fprintf(stderr,"Cannot open exclude file %s: %s\n", qfilename, + strerror(errno)); + use_gtar_excl = use_star_excl = 0; + } } + amfree(qfilename); amfree(filename); argc -= 2; argv++; - } else - use_gtar_excl = 0; + } else { + use_gtar_excl = use_star_excl = 0; + } if ((argc > 1) && strcmp(*argv,"-I") == 0) { argv++; filename = stralloc(*argv); + qfilename = quote_string(filename); if (access(filename, R_OK) != 0) { - fprintf(stderr,"Cannot open include file %s\n",filename); - use_gtar_excl = 0; + fprintf(stderr,"Cannot open include file %s\n", qfilename); + use_gtar_excl = use_star_excl = 0; } else { - include_sl = calc_load_file(filename); + include_sl = calc_load_file(filename); + if (!include_sl) { + fprintf(stderr,"Cannot open include file %s: %s\n", qfilename, + strerror(errno)); + use_gtar_excl = use_star_excl = 0; + } } + amfree(qfilename); amfree(filename); argc -= 2; argv++; @@ -253,8 +303,10 @@ char **argv; } } - if(argc) + if(argc) { error("leftover arg \"%s\", expected and ", *argv); + /*NOTREACHED*/ + } if(is_empty_sl(include_sl)) { traverse_dirs(dirname,"."); @@ -275,11 +327,18 @@ char **argv; amflock(1, "size"); - lseek(1, (off_t)0, SEEK_END); + if (fseek(stderr, 0L, SEEK_END) < 0) { + dbprintf(("calcsize: warning - seek failed: %s\n", + strerror(errno))); + } - fprintf(stderr, "%s %d SIZE %ld\n", - amname, dumplevel[i], final_size(i, dirname)); - fflush(stdout); + dbprintf(("calcsize: %s %d SIZE " OFF_T_FMT "\n", + amname, dumplevel[i], + (OFF_T_FMT_TYPE)final_size(i, dirname))); + fprintf(stderr, "%s %d SIZE " OFF_T_FMT "\n", + amname, dumplevel[i], + (OFF_T_FMT_TYPE)final_size(i, dirname)); + fflush(stderr); amfunlock(1, "size"); } @@ -299,10 +358,10 @@ char **argv; */ #if !defined(HAVE_BASENAME) && defined(BUILTIN_EXCLUDE_SUPPORT) -static char *basename P((char *)); -static char *basename(file) -char *file; +static char * +basename( + char * file) { char *cp; @@ -312,27 +371,30 @@ char *file; } #endif -void push_name P((char *str)); -char *pop_name P((void)); +void push_name(char *str); +char *pop_name(void); -void traverse_dirs(parent_dir, include) -char *parent_dir; -char *include; +void +traverse_dirs( + char * parent_dir, + char * include) { DIR *d; struct dirent *f; struct stat finfo; char *dirname, *newname = NULL; char *newbase = NULL; - dev_t parent_dev = 0; + dev_t parent_dev = (dev_t)0; int i; - int l; - int parent_len; - int has_exclude = !is_empty_sl(exclude_sl) && use_gtar_excl; + size_t l; + size_t parent_len; + int has_exclude; char *aparent; - if(parent_dir == NULL || include == NULL) return; + if(parent_dir == NULL || include == NULL) + return; + has_exclude = !is_empty_sl(exclude_sl) && (use_gtar_excl || use_star_excl); aparent = vstralloc(parent_dir, "/", include, NULL); if(stat(parent_dir, &finfo) != -1) @@ -342,7 +404,7 @@ char *include; push_name(aparent); - for(dirname = pop_name(); dirname; free(dirname), dirname = pop_name()) { + for(; (dirname = pop_name()) != NULL; free(dirname)) { if(has_exclude && calc_check_exclude(dirname+parent_len+1)) { continue; } @@ -390,7 +452,7 @@ char *include; int is_excluded = -1; for(i = 0; i < ndumps; i++) { add_file_name(i, newname); - if(is_file && finfo.st_ctime >= dumpdate[i]) { + if(is_file && (time_t)finfo.st_ctime >= dumpdate[i]) { if(has_exclude) { if(is_excluded == -1) @@ -424,19 +486,21 @@ char *include; amfree(aparent); } -void push_name(str) -char *str; +void +push_name( + char * str) { Name *newp; - newp = alloc(sizeof(*newp)); + newp = alloc(SIZEOF(*newp)); newp->str = stralloc(str); newp->next = name_stack; name_stack = newp; } -char *pop_name() +char * +pop_name(void) { Name *newp = name_stack; char *str; @@ -466,28 +530,35 @@ char *pop_name() * requirements for files with holes, nor the dumping of directories that * are not themselves modified. */ -void add_file_name_dump(level, name) -int level; -char *name; +void +add_file_name_dump( + int level, + char * name) { + (void)level; /* Quiet unused parameter warning */ + (void)name; /* Quiet unused parameter warning */ + return; } -void add_file_dump(level, sp) -int level; -struct stat *sp; +void +add_file_dump( + int level, + struct stat * sp) { /* keep the size in kbytes, rounded up, plus a 1k header block */ if((sp->st_mode & S_IFMT) == S_IFREG || (sp->st_mode & S_IFMT) == S_IFDIR) - dumpstats[level].total_size += (ST_BLOCKS(*sp) + 1)/2 + 1; + dumpstats[level].total_size += + (ST_BLOCKS(*sp) + (off_t)1) / (off_t)2 + (off_t)1; } -long final_size_dump(level, topdir) -int level; -char *topdir; +off_t +final_size_dump( + int level, + char * topdir) { generic_fs_stats_t stats; - int mapsize; + off_t mapsize; char *s; /* calculate the map sizes */ @@ -495,15 +566,16 @@ char *topdir; s = stralloc2(topdir, "/."); if(get_fs_stats(s, &stats) == -1) { error("statfs %s: %s", s, strerror(errno)); + /*NOTREACHED*/ } amfree(s); - mapsize = (stats.files + 7) / 8; /* in bytes */ - mapsize = (mapsize + 1023) / 1024; /* in kbytes */ + mapsize = (stats.files + (off_t)7) / (off_t)8; /* in bytes */ + mapsize = (mapsize + (off_t)1023) / (off_t)1024; /* in kbytes */ /* the dump contains three maps plus the files */ - return 3*mapsize + dumpstats[level].total_size; + return (mapsize * (off_t)3) + dumpstats[level].total_size; } /* @@ -517,29 +589,37 @@ char *topdir; * * As with DUMP, we only need a reasonable estimate, not an exact figure. */ -void add_file_name_gnutar(level, name) -int level; -char *name; +void +add_file_name_gnutar( + int level, + char * name) { -/* dumpstats[level].total_size_name += strlen(name) + 64;*/ - dumpstats[level].total_size += 1; + (void)name; /* Quiet unused parameter warning */ + +/* dumpstats[level].total_size_name += strlen(name) + 64;*/ + dumpstats[level].total_size += (off_t)1; } -void add_file_gnutar(level, sp) -int level; -struct stat *sp; +void +add_file_gnutar( + int level, + struct stat * sp) { /* the header takes one additional block */ dumpstats[level].total_size += ST_BLOCKS(*sp); } -long final_size_gnutar(level, topdir) -int level; -char *topdir; +off_t +final_size_gnutar( + int level, + char * topdir) { + (void)topdir; /* Quiet unused parameter warning */ + /* divide by two to get kbytes, rounded up */ /* + 4 blocks for security */ - return (dumpstats[level].total_size + 5 + (dumpstats[level].total_size_name/512)) / 2; + return (dumpstats[level].total_size + (off_t)5 + + (dumpstats[level].total_size_name/(off_t)512)) / (off_t)2; } /* @@ -549,42 +629,57 @@ char *topdir; * Here we'll just add up the file sizes and output that. */ -void add_file_name_unknown(level, name) -int level; -char *name; +void +add_file_name_unknown( + int level, + char * name) { + (void)level; /* Quiet unused parameter warning */ + (void)name; /* Quiet unused parameter warning */ + return; } -void add_file_unknown(level, sp) -int level; -struct stat *sp; +void +add_file_unknown( + int level, + struct stat * sp) { /* just add up the block counts */ if((sp->st_mode & S_IFMT) == S_IFREG || (sp->st_mode & S_IFMT) == S_IFDIR) dumpstats[level].total_size += ST_BLOCKS(*sp); } -long final_size_unknown(level, topdir) -int level; -char *topdir; +off_t +final_size_unknown( + int level, + char * topdir) { + (void)topdir; /* Quiet unused parameter warning */ + /* divide by two to get kbytes, rounded up */ - return (dumpstats[level].total_size + 1) / 2; + return (dumpstats[level].total_size + (off_t)1) / (off_t)2; } /* * ========================================================================= */ -sl_t *calc_load_file(filename) -char *filename; +sl_t * +calc_load_file( + char * filename) { char pattern[1025]; - sl_t *sl_list = new_sl(); + sl_t *sl_list; FILE *file = fopen(filename, "r"); + if (!file) { + return NULL; + } + + sl_list = new_sl(); + while(fgets(pattern, 1025, file)) { if(strlen(pattern)>0 && pattern[strlen(pattern)-1] == '\n') pattern[strlen(pattern)-1] = '\0'; @@ -595,8 +690,9 @@ char *filename; return sl_list; } -int calc_check_exclude(filename) -char *filename; +int +calc_check_exclude( + char * filename) { sle_t *an_exclude; if(is_empty_sl(exclude_sl)) return 0; diff --git a/client-src/client_util.c b/client-src/client_util.c index f766845..71ce4b4 100644 --- a/client-src/client_util.c +++ b/client-src/client_util.c @@ -24,19 +24,27 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: client_util.c,v 1.32 2006/03/09 16:51:41 martinea Exp $ + * $Id: client_util.c,v 1.34 2006/05/25 01:47:11 johnfranks Exp $ * */ +#include "amanda.h" #include "client_util.h" #include "getfsent.h" #include "util.h" #define MAXMAXDUMPS 16 -static char *fixup_relative(name, device) -char *name; -char *device; +static int add_exclude(FILE *file_exclude, char *aexc, int verbose); +static int add_include(char *disk, char *device, FILE *file_include, char *ainc, int verbose); +static char *build_name(char *disk, char *exin, int verbose); +static char *get_name(char *diskname, char *exin, time_t t, int n); + + +char * +fixup_relative( + char * name, + char * device) { char *newname; if(*name != '/') { @@ -51,10 +59,12 @@ char *device; } -static char *get_name(diskname, exin, t, n) -char *diskname, *exin; -time_t t; -int n; +static char * +get_name( + char * diskname, + char * exin, + time_t t, + int n) { char number[NUM_STR_SIZE]; char *filename; @@ -64,7 +74,7 @@ int n; if(n == 0) number[0] = '\0'; else - snprintf(number, sizeof(number), "%03d", n - 1); + snprintf(number, SIZEOF(number), "%03d", n - 1); filename = vstralloc(get_pname(), ".", diskname, ".", ts, number, ".", exin, NULL); @@ -73,22 +83,25 @@ int n; } -static char *build_name(disk, exin, verbose) -char *disk, *exin; -int verbose; +static char * +build_name( + char * disk, + char * exin, + int verbose) { - int n=0, fd=-1; + int n; + int fd; char *filename = NULL; char *afilename = NULL; char *diskname; time_t curtime; - char *dbgdir = NULL; + char *dbgdir; char *e = NULL; DIR *d; struct dirent *entry; - char *test_name = NULL; - int match_len, d_name_len; - + char *test_name; + size_t match_len, d_name_len; + char *quoted; time(&curtime); diskname = sanitise_filename(disk); @@ -96,7 +109,8 @@ int verbose; dbgdir = stralloc2(AMANDA_TMPDIR, "/"); if((d = opendir(AMANDA_TMPDIR)) == NULL) { error("open debug directory \"%s\": %s", - AMANDA_TMPDIR, strerror(errno)); + AMANDA_TMPDIR, strerror(errno)); + /*NOTREACHED*/ } test_name = get_name(diskname, exin, curtime - (AMANDA_DEBUG_DAYS * 24 * 60 * 60), 0); @@ -124,7 +138,7 @@ int verbose; do { filename = get_name(diskname, exin, curtime, n); afilename = newvstralloc(afilename, dbgdir, filename, NULL); - if((fd=open(afilename, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0600)) < 0){ + if((fd=open(afilename, O_WRONLY|O_CREAT|O_APPEND, 0600)) < 0){ amfree(afilename); n++; } @@ -137,11 +151,16 @@ int verbose; if(afilename == NULL) { filename = get_name(diskname, exin, curtime, 0); afilename = newvstralloc(afilename, dbgdir, filename, NULL); - dbprintf(("%s: Cannot create '%s'\n", debug_prefix(NULL), afilename)); - if(verbose) - printf("ERROR [cannot create: %s]\n", afilename); - amfree(filename); + quoted = quote_string(afilename); + dbprintf(("%s: Cannot create %s (%s)\n", + debug_prefix(NULL), quoted, strerror(errno))); + if(verbose) { + printf("ERROR [cannot create %s (%s)]\n", + quoted, strerror(errno)); + } + amfree(quoted); amfree(afilename); + amfree(filename); } amfree(dbgdir); @@ -151,54 +170,71 @@ int verbose; } -static int add_exclude(file_exclude, aexc, verbose) -FILE *file_exclude; -char *aexc; -int verbose; +static int +add_exclude( + FILE * file_exclude, + char * aexc, + int verbose) { - int l; + size_t l; + char *quoted, *file; + + (void)verbose; /* Quiet unused parameter warning */ l = strlen(aexc); if(aexc[l-1] == '\n') { aexc[l-1] = '\0'; l--; } - fprintf(file_exclude, "%s\n", aexc); + file = quoted = quote_string(aexc); + if (*file == '"') { + file[strlen(file) - 1] = '\0'; + file++; + } + fprintf(file_exclude, "%s\n", file); + amfree(quoted); return 1; } -static int add_include(disk, device, file_include, ainc, verbose) -char *disk, *device; -FILE *file_include; -char *ainc; -int verbose; +static int +add_include( + char * disk, + char * device, + FILE * file_include, + char * ainc, + int verbose) { - int l; + size_t l; int nb_exp=0; + char *quoted, *file; + + (void)disk; /* Quiet unused parameter warning */ l = strlen(ainc); if(ainc[l-1] == '\n') { ainc[l-1] = '\0'; l--; } - if(l < 3) { - dbprintf(("%s: include must be at least 3 character long: %s\n", - debug_prefix(NULL), ainc)); - if(verbose) - printf("ERROR [include must be at least 3 character long: %s]\n", ainc); - return 0; - } - else if(ainc[0] != '.' && ainc[0] != '\0' && ainc[1] != '/') { - dbprintf(("%s: include must start with './': %s\n", - debug_prefix(NULL), ainc)); - if(verbose) - printf("ERROR [include must start with './': %s]\n", ainc); - return 0; + if (strncmp(ainc, "./", 2) != 0) { + quoted = quote_string(ainc); + dbprintf(("%s: include must start with './' (%s)\n", + debug_prefix(NULL), quoted)); + if(verbose) { + printf("ERROR [include must start with './' (%s)]\n", quoted); + } + amfree(quoted); } else { char *incname = ainc+2; + if(strchr(incname, '/')) { - fprintf(file_include, "./%s\n", incname); + file = quoted = quote_string(ainc); + if (*file == '"') { + file[strlen(file) - 1] = '\0'; + file++; + } + fprintf(file_include, "%s\n", file); + amfree(quoted); nb_exp++; } else { @@ -208,12 +244,13 @@ int verbose; regex = glob_to_regex(incname); if((d = opendir(device)) == NULL) { - dbprintf(("%s: Can't open disk '%s']\n", - debug_prefix(NULL), device)); - if(verbose) - printf("ERROR [Can't open disk '%s']\n", device); - amfree(regex); - return 0; + quoted = quote_string(device); + dbprintf(("%s: Can't open disk %s\n", + debug_prefix(NULL), quoted)); + if(verbose) { + printf("ERROR [Can't open disk %s]\n", quoted); + } + amfree(quoted); } else { while((entry = readdir(d)) != NULL) { @@ -221,7 +258,15 @@ int verbose; continue; } if(match(regex, entry->d_name)) { - fprintf(file_include, "./%s\n", entry->d_name); + incname = vstralloc("./", entry->d_name, NULL); + file = quoted = quote_string(incname); + if (*file == '"') { + file[strlen(file) - 1] = '\0'; + file++; + } + fprintf(file_include, "%s\n", file); + amfree(quoted); + amfree(incname); nb_exp++; } } @@ -233,17 +278,20 @@ int verbose; return nb_exp; } -char *build_exclude(disk, device, options, verbose) -char *disk, *device; -option_t *options; -int verbose; +char * +build_exclude( + char * disk, + char * device, + option_t * options, + int verbose) { char *filename; FILE *file_exclude; FILE *exclude; - char *aexc = NULL; + char *aexc; sle_t *excl; int nb_exclude = 0; + char *quoted; if(options->exclude_file) nb_exclude += options->exclude_file->nb_element; if(options->exclude_list) nb_exclude += options->exclude_list->nb_element; @@ -267,6 +315,10 @@ int verbose; char *exclname = fixup_relative(excl->name, device); if((exclude = fopen(exclname, "r")) != NULL) { while ((aexc = agets(exclude)) != NULL) { + if (aexc[0] == '\0') { + amfree(aexc); + continue; + } add_exclude(file_exclude, aexc, verbose && options->exclude_optional == 0); amfree(aexc); @@ -274,13 +326,16 @@ int verbose; fclose(exclude); } else { - dbprintf(("%s: Can't open exclude file '%s': %s\n", + quoted = quote_string(exclname); + dbprintf(("%s: Can't open exclude file %s (%s)\n", debug_prefix(NULL), - exclname, strerror(errno))); + quoted, strerror(errno))); if(verbose && (options->exclude_optional == 0 || - errno != ENOENT)) - printf("ERROR [Can't open exclude file '%s': %s]\n", - exclname, strerror(errno)); + errno != ENOENT)) { + printf("ERROR [Can't open exclude file %s (%s)]\n", + quoted, strerror(errno)); + } + amfree(quoted); } amfree(exclname); } @@ -288,23 +343,27 @@ int verbose; fclose(file_exclude); } else { - dbprintf(("%s: Can't create exclude file '%s': %s\n", + quoted = quote_string(filename); + dbprintf(("%s: Can't create exclude file %s (%s)\n", debug_prefix(NULL), - filename, strerror(errno))); - if(verbose) - printf("ERROR [Can't create exclude file '%s': %s]\n", filename, - strerror(errno)); + quoted, strerror(errno))); + if(verbose) { + printf("ERROR [Can't create exclude file %s (%s)]\n", + quoted, strerror(errno)); + } + amfree(quoted); } } return filename; } -char *build_include(disk, device, options, verbose) -char *disk; -char *device; -option_t *options; -int verbose; +char * +build_include( + char * disk, + char * device, + option_t * options, + int verbose) { char *filename; FILE *file_include; @@ -313,6 +372,7 @@ int verbose; sle_t *incl; int nb_include = 0; int nb_exp = 0; + char *quoted; if(options->include_file) nb_include += options->include_file->nb_element; if(options->include_list) nb_include += options->include_list->nb_element; @@ -327,7 +387,7 @@ int verbose; incl = incl->next) { nb_exp += add_include(disk, device, file_include, incl->name, - verbose && options->include_optional == 0); + verbose && options->include_optional == 0); } } @@ -337,6 +397,10 @@ int verbose; char *inclname = fixup_relative(incl->name, device); if((include = fopen(inclname, "r")) != NULL) { while ((ainc = agets(include)) != NULL) { + if (ainc[0] == '\0') { + amfree(ainc); + continue; + } nb_exp += add_include(disk, device, file_include, ainc, verbose && options->include_optional == 0); @@ -345,13 +409,15 @@ int verbose; fclose(include); } else { - dbprintf(("%s: Can't open include file '%s': %s\n", - debug_prefix(NULL), - inclname, strerror(errno))); + quoted = quote_string(inclname); + dbprintf(("%s: Can't open include file %s (%s)\n", + debug_prefix(NULL), quoted, strerror(errno))); if(verbose && (options->include_optional == 0 || - errno != ENOENT)) - printf("ERROR [Can't open include file '%s': %s]\n", - inclname, strerror(errno)); + errno != ENOENT)) { + printf("ERROR [Can't open include file %s (%s)]\n", + quoted, strerror(errno)); + } + amfree(quoted); } amfree(inclname); } @@ -359,27 +425,33 @@ int verbose; fclose(file_include); } else { - dbprintf(("%s: Can't create include file '%s': %s\n", - debug_prefix(NULL), - filename, strerror(errno))); - if(verbose) - printf("ERROR [Can't create include file '%s': %s]\n", filename, - strerror(errno)); + quoted = quote_string(filename); + dbprintf(("%s: Can't create include file %s (%s)\n", + debug_prefix(NULL), quoted, strerror(errno))); + if(verbose) { + printf("ERROR [Can't create include file %s (%s)]\n", + quoted, strerror(errno)); + } + amfree(quoted); } } if(nb_exp == 0) { - dbprintf(("%s: No include for '%s'\n", debug_prefix(NULL), disk)); - if(verbose && options->include_optional == 0) - printf("ERROR [No include for '%s']\n", disk); + quoted = quote_string(disk); + dbprintf(("%s: No include for %s\n", debug_prefix(NULL), quoted)); + if(verbose && options->include_optional == 0) { + printf("ERROR [No include for %s]\n", quoted); + } + amfree(quoted); } return filename; } -void init_options(options) -option_t *options; +void +init_options( + option_t *options) { options->str = NULL; options->compress = NO_COMPR; @@ -402,17 +474,24 @@ option_t *options; } -option_t *parse_options(str, disk, device, fs, verbose) -char *str; -char *disk, *device; -am_feature_t *fs; -int verbose; +option_t * +parse_options( + char *str, + char *disk, + char *device, + am_feature_t *fs, + int verbose) { char *exc; + char *inc; option_t *options; char *p, *tok; + char *quoted; + + (void)disk; /* Quiet unused parameter warning */ + (void)device; /* Quiet unused parameter warning */ - options = alloc(sizeof(option_t)); + options = alloc(SIZEOF(option_t)); init_options(options); options->str = stralloc(str); @@ -423,21 +502,23 @@ int verbose; if(am_has_feature(fs, fe_options_auth) && BSTRNCMP(tok,"auth=") == 0) { if(options->auth != NULL) { - dbprintf(("%s: multiple auth option \"%s\"\n", - debug_prefix(NULL), tok+5)); + quoted = quote_string(tok + 5); + dbprintf(("%s: multiple auth option %s\n", + debug_prefix(NULL), quoted)); if(verbose) { - printf("ERROR [multiple auth option \"%s\"\n", tok+5); + printf("ERROR [multiple auth option %s]\n", quoted); } + amfree(quoted); } options->auth = stralloc(&tok[5]); } else if(am_has_feature(fs, fe_options_bsd_auth) && BSTRNCMP(tok, "bsd-auth") == 0) { if(options->auth != NULL) { - dbprintf(("%s: multiple auth option \n", + dbprintf(("%s: multiple auth option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple auth option \n"); + printf("ERROR [multiple auth option]\n"); } } options->auth = stralloc("bsd"); @@ -445,50 +526,50 @@ int verbose; else if(am_has_feature(fs, fe_options_krb4_auth) && BSTRNCMP(tok, "krb4-auth") == 0) { if(options->auth != NULL) { - dbprintf(("%s: multiple auth option \n", + dbprintf(("%s: multiple auth option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple auth option \n"); + printf("ERROR [multiple auth option]\n"); } } options->auth = stralloc("krb4"); } else if(BSTRNCMP(tok, "compress-fast") == 0) { if(options->compress != NO_COMPR) { - dbprintf(("%s: multiple compress option \n", + dbprintf(("%s: multiple compress option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple compress option \n"); + printf("ERROR [multiple compress option]\n"); } } options->compress = COMPR_FAST; } else if(BSTRNCMP(tok, "compress-best") == 0) { if(options->compress != NO_COMPR) { - dbprintf(("%s: multiple compress option \n", + dbprintf(("%s: multiple compress option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple compress option \n"); + printf("ERROR [multiple compress option]\n"); } } options->compress = COMPR_BEST; } else if(BSTRNCMP(tok, "srvcomp-fast") == 0) { if(options->compress != NO_COMPR) { - dbprintf(("%s: multiple compress option \n", + dbprintf(("%s: multiple compress option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple compress option \n"); + printf("ERROR [multiple compress option]\n"); } } options->compress = COMPR_SERVER_FAST; } else if(BSTRNCMP(tok, "srvcomp-best") == 0) { if(options->compress != NO_COMPR) { - dbprintf(("%s: multiple compress option \n", + dbprintf(("%s: multiple compress option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple compress option \n"); + printf("ERROR [multiple compress option]\n"); } } options->compress = COMPR_SERVER_BEST; @@ -501,7 +582,7 @@ int verbose; printf("ERROR [multiple compress option]\n"); } } - options->srvcompprog = stralloc(tok + sizeof("srvcomp-cust=") -1); + options->srvcompprog = stralloc(tok + SIZEOF("srvcomp-cust=") -1); options->compress = COMPR_SERVER_CUST; } else if(BSTRNCMP(tok, "comp-cust=") == 0) { @@ -512,7 +593,7 @@ int verbose; printf("ERROR [multiple compress option]\n"); } } - options->clntcompprog = stralloc(tok + sizeof("comp-cust=") -1); + options->clntcompprog = stralloc(tok + SIZEOF("comp-cust=") -1); options->compress = COMPR_CUST; /* parse encryption options */ } @@ -524,7 +605,7 @@ int verbose; printf("ERROR [multiple encrypt option]\n"); } } - options->srv_encrypt = stralloc(tok + sizeof("encrypt-serv-cust=") -1); + options->srv_encrypt = stralloc(tok + SIZEOF("encrypt-serv-cust=") -1); options->encrypt = ENCRYPT_SERV_CUST; } else if(BSTRNCMP(tok, "encrypt-cust=") == 0) { @@ -535,184 +616,86 @@ int verbose; printf("ERROR [multiple encrypt option]\n"); } } - options->clnt_encrypt= stralloc(tok + sizeof("encrypt-cust=") -1); + options->clnt_encrypt= stralloc(tok + SIZEOF("encrypt-cust=") -1); options->encrypt = ENCRYPT_CUST; } else if(BSTRNCMP(tok, "server-decrypt-option=") == 0) { - options->srv_decrypt_opt = stralloc(tok + sizeof("server-decrypt-option=") -1); + options->srv_decrypt_opt = stralloc(tok + SIZEOF("server-decrypt-option=") -1); } else if(BSTRNCMP(tok, "client-decrypt-option=") == 0) { - options->clnt_decrypt_opt = stralloc(tok + sizeof("client-decrypt-option=") -1); + options->clnt_decrypt_opt = stralloc(tok + SIZEOF("client-decrypt-option=") -1); } else if(BSTRNCMP(tok, "no-record") == 0) { if(options->no_record != 0) { - dbprintf(("%s: multiple no-record option \n", + dbprintf(("%s: multiple no-record option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple no-record option \n"); + printf("ERROR [multiple no-record option]\n"); } } options->no_record = 1; } else if(BSTRNCMP(tok, "index") == 0) { if(options->createindex != 0) { - dbprintf(("%s: multiple index option \n", + dbprintf(("%s: multiple index option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple index option \n"); + printf("ERROR [multiple index option]\n"); } } options->createindex = 1; } else if(BSTRNCMP(tok, "exclude-optional") == 0) { if(options->exclude_optional != 0) { - dbprintf(("%s: multiple exclude-optional option \n", + dbprintf(("%s: multiple exclude-optional option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple exclude-optional option \n"); + printf("ERROR [multiple exclude-optional option]\n"); } } options->exclude_optional = 1; } else if(strcmp(tok, "include-optional") == 0) { if(options->include_optional != 0) { - dbprintf(("%s: multiple include-optional option \n", + dbprintf(("%s: multiple include-optional option\n", debug_prefix(NULL))); if(verbose) { - printf("ERROR [multiple include-optional option \n"); + printf("ERROR [multiple include-optional option]\n"); } } options->include_optional = 1; } else if(BSTRNCMP(tok,"exclude-file=") == 0) { - exc = &tok[13]; - options->exclude_file = append_sl(options->exclude_file,exc); + exc = unquote_string(&tok[13]); + options->exclude_file = append_sl(options->exclude_file, exc); + amfree(exc); } else if(BSTRNCMP(tok,"exclude-list=") == 0) { - exc = &tok[13]; + exc = unquote_string(&tok[13]); options->exclude_list = append_sl(options->exclude_list, exc); + amfree(exc); } else if(BSTRNCMP(tok,"include-file=") == 0) { - exc = &tok[13]; - options->include_file = append_sl(options->include_file,exc); + inc = unquote_string(&tok[13]); + options->include_file = append_sl(options->include_file, inc); + amfree(inc); } else if(BSTRNCMP(tok,"include-list=") == 0) { - exc = &tok[13]; - options->include_list = append_sl(options->include_list, exc); - } - else if(strcmp(tok,"|") == 0) { - } - else { - dbprintf(("%s: unknown option \"%s\"\n", debug_prefix(NULL), tok)); + inc = unquote_string(&tok[13]); + options->include_list = append_sl(options->include_list, inc); + amfree(inc); + } + else if(strcmp(tok,"|") != 0) { + quoted = quote_string(tok); + dbprintf(("%s: unknown option %s\n", + debug_prefix(NULL), quoted)); if(verbose) { - printf("ERROR [unknown option \"%s\"]\n", tok); + printf("ERROR [unknown option: %s]\n", quoted); } + amfree(quoted); } tok = strtok(NULL, ";"); } amfree(p); return options; } - - -void init_g_options(g_options) -g_option_t *g_options; -{ - g_options->features = NULL; - g_options->hostname = NULL; - g_options->maxdumps = 0; -} - - -g_option_t *parse_g_options(str, verbose) -char *str; -int verbose; -{ - g_option_t *g_options; - char *p, *tok; - int new_maxdumps; - - g_options = alloc(sizeof(g_option_t)); - init_g_options(g_options); - g_options->str = stralloc(str); - - p = stralloc(str); - tok = strtok(p,";"); - - while (tok != NULL) { - if(strncmp(tok,"features=", 9) == 0) { - if(g_options->features != NULL) { - dbprintf(("%s: multiple features option\n", - debug_prefix(NULL))); - if(verbose) { - printf("ERROR [multiple features option]\n"); - } - } - if((g_options->features = am_string_to_feature(tok+9)) == NULL) { - dbprintf(("%s: bad features value \"%s\n", - debug_prefix(NULL), tok+10)); - if(verbose) { - printf("ERROR [bad features value \"%s\"]\n", tok+10); - } - } - } - else if(strncmp(tok,"hostname=", 9) == 0) { - if(g_options->hostname != NULL) { - dbprintf(("%s: multiple hostname option\n", - debug_prefix(NULL))); - if(verbose) { - printf("ERROR [multiple hostname option]\n"); - } - } - g_options->hostname = stralloc(tok+9); - } - else if(strncmp(tok,"maxdumps=", 9) == 0) { - if(g_options->maxdumps != 0) { - dbprintf(("%s: multiple maxdumps option\n", - debug_prefix(NULL))); - if(verbose) { - printf("ERROR [multiple maxdumps option]\n"); - } - } - if(sscanf(tok+9, "%d;", &new_maxdumps) == 1) { - if (new_maxdumps > MAXMAXDUMPS) { - g_options->maxdumps = MAXMAXDUMPS; - } - else if (new_maxdumps > 0) { - g_options->maxdumps = new_maxdumps; - } - else { - dbprintf(("%s: bad maxdumps value \"%s\"\n", - debug_prefix(NULL), tok+9)); - if(verbose) { - printf("ERROR [bad maxdumps value \"%s\"]\n", - tok+9); - } - } - } - else { - dbprintf(("%s: bad maxdumps value \"%s\"\n", - debug_prefix(NULL), tok+9)); - if(verbose) { - printf("ERROR [bad maxdumps value \"%s\"]\n", - tok+9); - } - } - } - else { - dbprintf(("%s: unknown option \"%s\"\n", - debug_prefix(NULL), tok)); - if(verbose) { - printf("ERROR [unknown option \"%s\"]\n", tok); - } - } - tok = strtok(NULL, ";"); - } - if(g_options->features == NULL) { - g_options->features = am_set_default_feature_set(); - } - if(g_options->maxdumps == 0) /* default */ - g_options->maxdumps = 1; - amfree(p); - return g_options; -} diff --git a/client-src/client_util.h b/client-src/client_util.h index ef8ef8e..0745a31 100644 --- a/client-src/client_util.h +++ b/client-src/client_util.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: client_util.h,v 1.12 2005/12/09 03:22:52 paddy_s Exp $ + * $Id: client_util.h,v 1.14 2006/05/25 01:47:11 johnfranks Exp $ * */ @@ -57,13 +57,6 @@ typedef struct option_s { int include_optional; } option_t; -typedef struct g_option_s { - char *str; - am_feature_t *features; - char *hostname; - int maxdumps; -} g_option_t; - #define NO_COMPR 0 #define COMPR_FAST 1 #define COMPR_BEST 2 @@ -76,16 +69,15 @@ typedef struct g_option_s { #define ENCRYPT_CUST 1 /* client-side custom encryption */ #define ENCRYPT_SERV_CUST 2 /* server-side custom encryption */ -char *build_exclude P((char *disk, char *device, option_t *options, int verbose)); -char *build_include P((char *disk, char *device, option_t *options, int verbose)); -void init_options P((option_t *options)); -option_t *parse_options P((char *str, +char *build_exclude(char *disk, char *device, option_t *options, int verbose); +char *build_include(char *disk, char *device, option_t *options, int verbose); +void init_options(option_t *options); +option_t *parse_options(char *str, char *disk, char *device, am_feature_t *features, - int verbose)); + int verbose); -void init_g_options P((g_option_t *g_options)); -g_option_t *parse_g_options P((char *str, int verbose)); +char *fixup_relative(char *name, char *device); #endif diff --git a/client-src/clientconf.c b/client-src/clientconf.c new file mode 100644 index 0000000..e2a2246 --- /dev/null +++ b/client-src/clientconf.c @@ -0,0 +1,648 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-2000 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: James da Silva, Systems Design and Analysis Group + * Computer Science Department + * University of Maryland at College Park + */ +/* + * $Id: clientconf.c,v 1.17 2006/07/25 19:36:48 martinea Exp $ + * + * read configuration file + */ +/* + * + * XXX - I'm not happy *at all* with this implementation, but I don't + * think YACC would be any easier. A more table based implementation + * would be better. Also clean up memory leaks. + */ +#include "amanda.h" +#include "arglist.h" +#include "util.h" +#include "clientconf.h" +#include "clock.h" + +/* configuration parameters */ +static char *cln_config_dir = NULL; + +val_t client_conf[CLN_CLN]; + +command_option_t *client_options = NULL; +int client_options_size = 0; + +/* predeclare local functions */ + +static void init_defaults(void); +static void read_conffile_recursively(char *filename); + +static int read_confline(void); + +keytab_t client_keytab[] = { + { "CONF", CONF_CONF }, + { "INDEX_SERVER", CONF_INDEX_SERVER }, + { "TAPE_SERVER", CONF_TAPE_SERVER }, + { "TAPEDEV", CONF_TAPEDEV }, + { "AUTH", CONF_AUTH }, + { "SSH_KEYS", CONF_SSH_KEYS }, + { "AMANDAD_PATH", CONF_AMANDAD_PATH }, + { "CLIENT_USERNAME", CONF_CLIENT_USERNAME }, + { "GNUTAR_LIST_DIR", CONF_GNUTAR_LIST_DIR }, + { "AMANDATES", CONF_AMANDATES }, + { "INCLUDEFILE", CONF_INCLUDEFILE }, + { NULL, CONF_UNKNOWN }, +}; + +t_conf_var client_var [] = { + { CONF_CONF , CONFTYPE_STRING, read_string, CLN_CONF , NULL }, + { CONF_INDEX_SERVER , CONFTYPE_STRING, read_string, CLN_INDEX_SERVER , NULL }, + { CONF_TAPE_SERVER , CONFTYPE_STRING, read_string, CLN_TAPE_SERVER , NULL }, + { CONF_TAPEDEV , CONFTYPE_STRING, read_string, CLN_TAPEDEV , NULL }, + { CONF_AUTH , CONFTYPE_STRING, read_string, CLN_AUTH , NULL }, + { CONF_SSH_KEYS , CONFTYPE_STRING, read_string, CLN_SSH_KEYS , NULL }, + { CONF_AMANDAD_PATH , CONFTYPE_STRING, read_string, CLN_AMANDAD_PATH , NULL }, + { CONF_CLIENT_USERNAME, CONFTYPE_STRING, read_string, CLN_CLIENT_USERNAME, NULL }, + { CONF_GNUTAR_LIST_DIR, CONFTYPE_STRING, read_string, CLN_GNUTAR_LIST_DIR, NULL }, + { CONF_AMANDATES , CONFTYPE_STRING, read_string, CLN_AMANDATES , NULL }, + { CONF_UNKNOWN , CONFTYPE_INT , NULL , CLN_CLN , NULL } +}; + +static int first_file = 1; + +/* +** ------------------------ +** External entry points +** ------------------------ +*/ + +/* return 0 on success */ +/* return 1 on error */ +/* return -1 if file not found */ + +int read_clientconf( + char *filename) +{ + if(first_file == 1) { + init_defaults(); + first_file = 0; + } else { + allow_overwrites = 1; + } + + /* We assume that conf_confname & conf are initialized to NULL above */ + read_conffile_recursively(filename); + + command_overwrite(client_options, client_var, client_keytab, client_conf, + ""); + + return got_parserror; +} + + +char * +client_getconf_byname( + char * str) +{ + static char *tmpstr; + char number[NUM_STR_SIZE]; + t_conf_var *np; + keytab_t *kt; + char *s; + char ch; + + tmpstr = stralloc(str); + s = tmpstr; + while((ch = *s++) != '\0') { + if(islower((int)ch)) + s[-1] = (char)toupper(ch); + } + + for(kt = client_keytab; kt->token != CONF_UNKNOWN; kt++) + if(kt->keyword && strcmp(kt->keyword, tmpstr) == 0) break; + + if(kt->token == CONF_UNKNOWN) return NULL; + + for(np = client_var; np->token != CONF_UNKNOWN; np++) + if(np->token == kt->token) break; + + if(np->type == CONFTYPE_INT) { + snprintf(number, SIZEOF(number), "%d", client_getconf_int(np->parm)); + tmpstr = newstralloc(tmpstr, number); + } else if(np->type == CONFTYPE_BOOL) { + if(client_getconf_boolean(np->parm) == 0) { + tmpstr = newstralloc(tmpstr, "off"); + } + else { + tmpstr = newstralloc(tmpstr, "on"); + } + } else if(np->type == CONFTYPE_REAL) { + snprintf(number, SIZEOF(number), "%lf", client_getconf_real(np->parm)); + tmpstr = newstralloc(tmpstr, number); + } else { + tmpstr = newstralloc(tmpstr, client_getconf_str(np->parm)); + } + + return tmpstr; +} + +int +client_getconf_seen( + cconfparm_t parm) +{ + t_conf_var *np; + np = get_np(client_var, parm); + return(client_conf[np->parm].seen); +} + +int +client_getconf_boolean( + cconfparm_t parm) +{ + t_conf_var *np; + np = get_np(client_var, parm); + if (np->type != CONFTYPE_BOOL) { + error("client_getconf_boolean: np is not a CONFTYPE_BOOL"); + /*NOTREACHED*/ + } + return(client_conf[np->parm].v.i != 0); +} + +int +client_getconf_int( + cconfparm_t parm) +{ + t_conf_var *np; + np = get_np(client_var, parm); + if (np->type != CONFTYPE_INT) { + error("client_getconf_int: np is not a CONFTYPE_INT"); + /*NOTREACHED*/ + } + + return(client_conf[np->parm].v.i); +} + +off_t +client_getconf_am64( + cconfparm_t parm) +{ + t_conf_var *np; + np = get_np(client_var, parm); + if (np->type != CONFTYPE_AM64) { + error("client_getconf_am64: np is not a CONFTYPE_AM64"); + /*NOTREACHED*/ + } + return(client_conf[np->parm].v.am64); +} + +double +client_getconf_real( + cconfparm_t parm) +{ + t_conf_var *np; + np = get_np(client_var, parm); + if (np->type != CONFTYPE_REAL) { + error("client_getconf_real: np is not a CONFTYPE_REAL"); + /*NOTREACHED*/ + } + return(client_conf[np->parm].v.r); +} + +char * +client_getconf_str( + cconfparm_t parm) +{ + t_conf_var *np; + np = get_np(client_var, parm); + if (np->type != CONFTYPE_STRING) { + error("client_getconf_string: np is not a CONFTYPE_STRING"); + /*NOTREACHED*/ + } + return(client_conf[np->parm].v.s); +} + +/* +** ------------------------ +** Internal routines +** ------------------------ +*/ + + +static void +init_defaults(void) +{ + char *s; + + /* defaults for exported variables */ + +#ifdef DEFAULT_CONFIG + s = DEFAULT_CONFIG; +#else + s = ""; +#endif + conf_init_string(&client_conf[CLN_CONF], s); + +#ifdef DEFAULT_SERVER + s = DEFAULT_SERVER; +#else + s = ""; +#endif + conf_init_string(&client_conf[CLN_INDEX_SERVER], s); + + +#ifdef DEFAULT_TAPE_SERVER + s = DEFAULT_TAPE_SERVER; +#else +#ifdef DEFAULT_SERVER + s = DEFAULT_SERVER; +#else + s = ""; +#endif +#endif + conf_init_string(&client_conf[CLN_TAPE_SERVER], s); + +#ifdef DEFAULT_TAPE_DEVICE + s = DEFAULT_TAPE_DEVICE; +#else + s = NULL; +#endif + conf_init_string(&client_conf[CLN_TAPEDEV], s); + + conf_init_string(&client_conf[CLN_AUTH], "bsd"); + conf_init_string(&client_conf[CLN_SSH_KEYS], ""); + conf_init_string(&client_conf[CLN_AMANDAD_PATH], ""); + conf_init_string(&client_conf[CLN_CLIENT_USERNAME], ""); +#ifdef GNUTAR_LISTED_INCREMENTAL_DIR + conf_init_string(&client_conf[CLN_GNUTAR_LIST_DIR], + GNUTAR_LISTED_INCREMENTAL_DIR); +#else + conf_init_string(&client_conf[CLN_GNUTAR_LIST_DIR], NULL); +#endif + conf_init_string(&client_conf[CLN_AMANDATES], "/etc/amandates"); + /* defaults for internal variables */ + + conf_line_num = got_parserror = 0; + allow_overwrites = 0; + token_pushed = 0; + +} + +static void +read_conffile_recursively( + char * filename) +{ + /* Save globals used in read_confline(), elsewhere. */ + int save_line_num = conf_line_num; + FILE *save_conf = conf_conf; + char *save_confname = conf_confname; + int rc; + + if (*filename == '/' || cln_config_dir == NULL) { + conf_confname = stralloc(filename); + } else { + conf_confname = stralloc2(cln_config_dir, filename); + } + + if((conf_conf = fopen(conf_confname, "r")) == NULL) { + dbprintf(("Could not open conf file \"%s\": %s\n", conf_confname, + strerror(errno))); + amfree(conf_confname); + got_parserror = -1; + return; + } + dbprintf(("Reading conf file \"%s\".\n", conf_confname)); + + conf_line_num = 0; + + /* read_confline() can invoke us recursively via "includefile" */ + do { + rc = read_confline(); + } while (rc != 0); + afclose(conf_conf); + + amfree(conf_confname); + + /* Restore globals */ + conf_line_num = save_line_num; + conf_conf = save_conf; + conf_confname = save_confname; +} + + +/* ------------------------ */ + + +static int +read_confline(void) +{ + t_conf_var *np; + + keytable = client_keytab; + + conf_line_num += 1; + get_conftoken(CONF_ANY); + switch(tok) { + case CONF_INCLUDEFILE: + { + char *fn; + + get_conftoken(CONF_STRING); + fn = tokenval.v.s; + read_conffile_recursively(fn); + } + break; + + case CONF_NL: /* empty line */ + break; + + case CONF_END: /* end of file */ + return 0; + + default: + { + for(np = client_var; np->token != CONF_UNKNOWN; np++) + if(np->token == tok) break; + + if(np->token == CONF_UNKNOWN) { + conf_parserror("configuration keyword expected"); + } else { + np->read_function(np, &client_conf[np->parm]); + if(np->validate) + np->validate(np, &client_conf[np->parm]); + } + } + } + if(tok != CONF_NL) + get_conftoken(CONF_NL); + return 1; +} + + + +/* ------------------------ */ + +#ifdef TEST + +static char *cln_config_name = NULL; +static char *cln_config_dir = NULL; + +void +dump_client_configuration( + char *filename) +{ + printf("AMANDA CLIENT CONFIGURATION FROM FILE \"%s\":\n\n", filename); + + printf("cln_conf = \"%s\"\n", client_getconf_str(CLN_CONF)); + printf("cln_index_server = \"%s\"\n", client_getconf_str(CLN_INDEX_SERVER)); + printf("cln_tape_server = \"%s\"\n", client_getconf_str(CLN_TAPE_SERVER)); + printf("cln_tapedev = \"%s\"\n", client_getconf_str(CLN_TAPEDEV)); + printf("cln_auth = \"%s\"\n", client_getconf_str(CLN_AUTH)); + printf("cln_ssh_keys = \"%s\"\n", client_getconf_str(CLN_SSH_KEYS)); +} + +int +main( + int argc, + char ** argv) +{ + char *conffile; + char *diskfile; + disklist_t lst; + int result; + unsigned long malloc_hist_1, malloc_size_1; + unsigned long malloc_hist_2, malloc_size_2; + + safe_fd(-1, 0); + + set_pname("conffile"); + + /* Don't die when child closes pipe */ + signal(SIGPIPE, SIG_IGN); + + malloc_size_1 = malloc_inuse(&malloc_hist_1); + + startclock(); + + if (argc > 1) { + if (argv[1][0] == '/') { + cln_config_dir = stralloc(argv[1]); + cln_config_name = strrchr(cln_config_dir, '/') + 1; + cln_config_name[-1] = '\0'; + cln_config_dir = newstralloc2(cln_config_dir, cln_config_dir, "/"); + } else { + cln_config_name = stralloc(argv[1]); + cln_config_dir = vstralloc(CONFIG_DIR, "/", cln_config_name, "/", NULL); + } + } else { + char my_cwd[STR_SIZE]; + + if (getcwd(my_cwd, SIZEOF(my_cwd)) == NULL) { + error("cannot determine current working directory"); + } + cln_config_dir = stralloc2(my_cwd, "/"); + if ((cln_config_name = strrchr(my_cwd, '/')) != NULL) { + cln_config_name = stralloc(cln_config_name + 1); + } + } + + conffile = stralloc2(cln_config_dir, CONFFILE_NAME); + result = read_conffile(conffile); + if (result == 0) { + diskfile = client_getconf_str(CNF_DISKFILE); + if (diskfile != NULL && access(diskfile, R_OK) == 0) { + result = read_diskfile(diskfile, &lst); + } + } + dump_client_configuration(CONFFILE_NAME); + amfree(conffile); + + malloc_size_2 = malloc_inuse(&malloc_hist_2); + + if(malloc_size_1 != malloc_size_2) { + malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2); + } + + return result; +} + +#endif /* TEST */ + +char * +generic_client_get_security_conf( + char * string, + void * arg) +{ + (void)arg; /* Quiet unused parameter warning */ + + if(!string || !*string) + return(NULL); + + if(strcmp(string, "conf")==0) { + return(client_getconf_str(CLN_CONF)); + } else if(strcmp(string, "index_server")==0) { + return(client_getconf_str(CLN_INDEX_SERVER)); + } else if(strcmp(string, "tape_server")==0) { + return(client_getconf_str(CLN_TAPE_SERVER)); + } else if(strcmp(string, "tapedev")==0) { + return(client_getconf_str(CLN_TAPEDEV)); + } else if(strcmp(string, "auth")==0) { + return(client_getconf_str(CLN_AUTH)); + } else if(strcmp(string, "ssh_keys")==0) { + return(client_getconf_str(CLN_SSH_KEYS)); + } else if(strcmp(string, "amandad_path")==0) { + return(client_getconf_str(CLN_AMANDAD_PATH)); + } else if(strcmp(string, "client_username")==0) { + return(client_getconf_str(CLN_CLIENT_USERNAME)); + } else if(strcmp(string, "gnutar_list_dir")==0) { + return(client_getconf_str(CLN_GNUTAR_LIST_DIR)); + } else if(strcmp(string, "amandates")==0) { + return(client_getconf_str(CLN_AMANDATES)); +/* + } else if(strcmp(string, "krb5principal")==0) { + return(client_getconf_str(CNF_KRB5PRINCIPAL)); + } else if(strcmp(string, "krb5keytab")==0) { + return(client_getconf_str(CNF_KRB5KEYTAB)); +*/ + } + return(NULL); +} + + +void +parse_client_conf( + int parse_argc, + char **parse_argv, + int *new_argc, + char ***new_argv) +{ + int i; + char **my_argv; + char *myarg, *value; + command_option_t *client_option; + + client_options = alloc((size_t)(parse_argc+1) * SIZEOF(*client_options)); + client_options_size = parse_argc+1; + client_option = client_options; + client_option->name = NULL; + + my_argv = alloc((size_t)parse_argc * SIZEOF(char *)); + *new_argv = my_argv; + *new_argc = 0; + i=0; + while(i 2) + myarg = &parse_argv[i][2]; + else { + i++; + if(i >= parse_argc) + error("expect something after -o"); + myarg = parse_argv[i]; + } + value = index(myarg,'='); + if (value == NULL) { + conf_parserror("Must specify a value for %s.\n", myarg); + } else { + *value = '\0'; + value++; + client_option->used = 0; + client_option->name = stralloc(myarg); + client_option->value = stralloc(value); + client_option++; + client_option->name = NULL; + } + } + else { + my_argv[*new_argc] = stralloc(parse_argv[i]); + *new_argc += 1; + } + i++; + } +} + +/* return 0 on success */ +/* return -1 if it is already there */ +/* return -2 if other failure */ +int +add_client_conf( + cconfparm_t parm, + char *value) +{ + t_conf_var *np; + keytab_t *kt; + command_option_t *command_option; + int nb_option; + + for(np = client_var; np->token != CONF_UNKNOWN; np++) + if(np->parm == (int)parm) break; + + if(np->token == CONF_UNKNOWN) return -2; + + for(kt = client_keytab; kt->token != CONF_UNKNOWN; kt++) + if(kt->token == np->token) break; + + if(kt->token == CONF_UNKNOWN) return -2; + + /* Try to find it */ + nb_option = 0; + for(command_option = client_options; command_option->name != NULL; + command_option++) { + if(strcasecmp(command_option->name, kt->keyword) == 0) { + return -1; + } + nb_option++; + } + + /* Increase size of client_options if needed */ + if(nb_option >= client_options_size-1) { + client_options_size *= 2; + client_options = realloc(client_options, + client_options_size * SIZEOF(*client_options)); + if (client_options == NULL) { + error("Can't realloc client_options: %s\n", strerror(errno)); + /*NOTREACHED*/ + } + for(command_option = client_options; command_option->name != NULL; + command_option++) { + } + } + + /* add it */ + command_option->used = 0; + command_option->name = stralloc(kt->keyword); + command_option->value = stralloc(value); + command_option++; + command_option->name = NULL; + return 0; +} + +void +report_bad_client_arg(void) +{ + command_option_t *command_option; + + for(command_option = client_options; command_option->name != NULL; + command_option++) { + if(command_option->used == 0) { + fprintf(stderr,"argument -o%s=%s not used\n", + command_option->name, command_option->value); + } + } +} diff --git a/client-src/clientconf.h b/client-src/clientconf.h new file mode 100644 index 0000000..d9157ac --- /dev/null +++ b/client-src/clientconf.h @@ -0,0 +1,70 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-2000 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: James da Silva, Systems Design and Analysis Group + * Computer Science Department + * University of Maryland at College Park + */ +/* + * $Id: clientconf.h,v 1.9 2006/07/25 19:06:46 martinea Exp $ + * + * interface for client config file reading code + */ +#ifndef CLIENTCONF_H +#define CLIENTCONF_H + +#include "sl.h" + +#define CLIENTCONFFILE_NAME "client.conf" + +typedef enum conf_e { + CLN_CONF, + CLN_INDEX_SERVER, + CLN_TAPE_SERVER, + CLN_TAPEDEV, + CLN_AUTH, + CLN_SSH_KEYS, + CLN_AMANDAD_PATH, + CLN_CLIENT_USERNAME, + CLN_GNUTAR_LIST_DIR, + CLN_AMANDATES, + CLN_CLN +} cconfparm_t; + +extern char *config_name; +extern char *config_dir; + +void parse_client_conf(int, char **, int *, char ***); +int add_client_conf(cconfparm_t parm, char *value); +void report_bad_client_arg(void); +int read_clientconf(char *filename); +int client_getconf_seen(cconfparm_t parameter); +int client_getconf_boolean(cconfparm_t parameter); +int client_getconf_int(cconfparm_t parameter); +off_t client_getconf_am64(cconfparm_t parameter); +double client_getconf_real(cconfparm_t parameter); +char *client_getconf_str(cconfparm_t parameter); +char *client_getconf_byname(char *confname); + +/* this is in securityconf.h */ +char *generic_client_get_security_conf(char *, void *); +#endif /* ! CONFFILE_H */ diff --git a/client-src/findpass.c b/client-src/findpass.c index 301c2c1..d33e64f 100644 --- a/client-src/findpass.c +++ b/client-src/findpass.c @@ -24,12 +24,14 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: findpass.c,v 1.12 2001/08/01 22:37:32 jrjackson Exp $ + * $Id: findpass.c,v 1.13 2006/05/25 01:47:11 johnfranks Exp $ * * Support routines for Amanda SAMBA support */ +#include "amanda.h" #include "findpass.h" +#include "util.h" /* * Find the Samba password and optional domain for a given disk. @@ -37,28 +39,34 @@ * as soon as reasonable. */ -char *findpass(disk, domain) -char *disk, **domain; +char * +findpass( + char * disk, + char ** domain) { FILE *fp; static char *buffer = NULL; char *s, *d, *pw = NULL; int ch; + char *qname; *domain = NULL; /* just to be sure */ if ( (fp = fopen("/etc/amandapass", "r")) ) { amfree(buffer); for (; (buffer = agets(fp)) != NULL; free(buffer)) { + if (buffer[0] == '\0') + continue; s = buffer; ch = *s++; skip_whitespace(s, ch); /* find start of disk name */ if (!ch || ch == '#') { continue; } - d = s-1; /* start of disk name */ - skip_non_whitespace_cs(s, ch); + qname = s-1; /* start of disk name */ + skip_quoted_string(s, ch); if (ch && ch != '#') { s[-1] = '\0'; /* terminate disk name */ + d = unquote_string(qname); if ((strcmp(d,"*") == 0) || (strcmp(disk, d) == 0)) { skip_whitespace(s, ch); /* find start of password */ if (ch && ch != '#') { @@ -74,8 +82,10 @@ char *disk, **domain; *domain = stralloc(*domain); } } + amfree(d); break; } + amfree(d); } } afclose(fp); @@ -89,12 +99,13 @@ char *disk, **domain; * Returns a new name alloc-d that the caller is responsible * for free-ing. */ -char *makesharename(disk, shell) -char *disk; -int shell; +char * +makesharename( + char * disk, + int shell) { char *buffer; - int buffer_size; + size_t buffer_size; char *s; int ch; @@ -125,10 +136,11 @@ int shell; * * the caller is expected to release share & subdir */ -void parsesharename (disk, share, subdir) -char *disk; -char **share; -char **subdir; +void +parsesharename( + char * disk, + char ** share, + char ** subdir) { char *ch=NULL; int slashcnt=0; diff --git a/client-src/findpass.h b/client-src/findpass.h index 2696699..3b5b907 100644 --- a/client-src/findpass.h +++ b/client-src/findpass.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: findpass.h,v 1.6 2001/08/01 22:37:32 jrjackson Exp $ + * $Id: findpass.h,v 1.7 2006/05/25 01:47:11 johnfranks Exp $ * * interface to findpass module */ @@ -33,8 +33,8 @@ #include "amanda.h" -extern char *findpass P((char *disk, char **domain)); -extern char *makesharename P((char *disk, int shell)); -void parsesharename P((char *disk, char **share, char **subdir)); +extern char *findpass(char *disk, char **domain); +extern char *makesharename(char *disk, int shell); +void parsesharename(char *disk, char **share, char **subdir); #endif diff --git a/client-src/getfsent.c b/client-src/getfsent.c index 516cf4e..d29953b 100644 --- a/client-src/getfsent.c +++ b/client-src/getfsent.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: getfsent.c,v 1.34 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: getfsent.c,v 1.38 2006/07/19 17:41:14 martinea Exp $ * * generic version of code to read fstab */ @@ -34,14 +34,11 @@ #ifdef TEST # include # include -# undef P -# define P(x) x #endif #include "getfsent.h" -static char *dev2rdev P((char *)); -static int samefile P((struct stat[3], struct stat *)); +static char *dev2rdev(char *); /* * You are in a twisty maze of passages, all alike. @@ -56,19 +53,22 @@ static int samefile P((struct stat[3], struct stat *)); #include -int open_fstab() +int +open_fstab(void) { return setfsent(); } -void close_fstab() +void +close_fstab(void) { endfsent(); } -int get_fstab_nextentry(fsent) -generic_fsent_t *fsent; +int +get_fstab_nextentry( + generic_fsent_t * fsent) { struct fstab *sys_fsent = getfsent(); static char *xfsname = NULL, *xmntdir = NULL; @@ -106,24 +106,28 @@ generic_fsent_t *fsent; static FILE *fstabf = NULL; -int open_fstab() +int +open_fstab(void) { close_fstab(); return (fstabf = fopen(VFSTAB, "r")) != NULL; } -void close_fstab() +void +close_fstab(void) { if(fstabf) afclose(fstabf); fstabf = NULL; } -int get_fstab_nextentry(fsent) -generic_fsent_t *fsent; +int +get_fstab_nextentry( + generic_fsent_t * fsent) { struct vfstab sys_fsent; + memset(&sys_fsent, 0, SIZEOF(sys_fsent)); if(getvfsent(fstabf, &sys_fsent) != 0) return 0; @@ -156,7 +160,8 @@ static FILE *fstabf1 = NULL; /* /proc/mounts */ static FILE *fstabf2 = NULL; /* MOUNTED */ static FILE *fstabf3 = NULL; /* MNTTAB */ -int open_fstab() +int +open_fstab(void) { close_fstab(); #if defined(HAVE_SETMNTENT) @@ -175,7 +180,8 @@ int open_fstab() return (fstabf1 != NULL || fstabf2 != NULL || fstabf3 != NULL); } -void close_fstab() +void +close_fstab(void) { if (fstabf1) { AMCLOSE_MNTENT(fstabf1); @@ -191,8 +197,9 @@ void close_fstab() } } -int get_fstab_nextentry(fsent) -generic_fsent_t *fsent; +int +get_fstab_nextentry( + generic_fsent_t * fsent) { struct mntent *sys_fsent = NULL; @@ -245,13 +252,15 @@ generic_fsent_t *fsent; static FILE *fstabf = NULL; -int open_fstab() +int +open_fstab(void) { close_fstab(); return (fstabf = fopen(FSTAB, "r")) != NULL; } -void close_fstab() +void +close_fstab(void) { if(fstabf) afclose(fstabf); @@ -260,8 +269,9 @@ void close_fstab() static generic_fsent_t _fsent; -int get_fstab_nextentry(fsent) -generic_fsent_t *fsent; +int +get_fstab_nextentry( + generic_fsent_t * fsent) { static char *lfsnam = NULL; static char *opts = NULL; @@ -271,6 +281,8 @@ generic_fsent_t *fsent; amfree(cp); for (; (cp = agets(fstabf)) != NULL; free(cp)) { + if (cp[0] == '\0') + continue; fsent->fsname = strtok(cp, " \t"); if ( fsent->fsname && *fsent->fsname != '#' ) break; @@ -303,7 +315,7 @@ generic_fsent_t *fsent; fsent->fstype = lfsnam; #define sc "hs" - if (strncmp(fsent->fstype, sc, sizeof(sc)-1) == 0) + if (strncmp(fsent->fstype, sc, SIZEOF(sc)-1) == 0) fsent->fstype = "iso9660"; #undef sc @@ -333,13 +345,15 @@ generic_fsent_t *fsent; static FILE *fstabf = NULL; -int open_fstab() +int +open_fstab(void) { close_fstab(); return (fstabf = fopen(MNTTAB, "r")) != NULL; } -void close_fstab() +void +close_fstab(void) { if(fstabf) afclose(fstabf); @@ -348,22 +362,23 @@ void close_fstab() static generic_fsent_t _fsent; -int get_fstab_nextentry(fsent) -generic_fsent_t *fsent; +int +get_fstab_nextentry( + generic_fsent_t *fsent) { struct statfs fsd; char typebuf[FSTYPSZ]; static struct mnttab mnt; char *dp, *ep; - if(!fread (&mnt, sizeof mnt, 1, fstabf)) + if(!fread (&mnt, SIZEOF(mnt), 1, fstabf)) return 0; fsent->fsname = mnt.mt_dev; fsent->mntdir = mnt.mt_filsys; fsent->fstype = ""; - if (statfs (fsent->mntdir, &fsd, sizeof fsd, 0) != -1 + if (statfs (fsent->mntdir, &fsd, SIZEOF(fsd), 0) != -1 && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) { dp = typebuf; ep = fsent->fstype = malloc(strlen(typebuf)+2); @@ -411,8 +426,9 @@ generic_fsent_t *fsent; *===================================================================== */ -static char *dev2rdev(name) -char *name; +static char * +dev2rdev( + char * name) { char *fname = NULL; struct stat st; @@ -443,7 +459,7 @@ char *name; if (ch == '/') { s[-1] = '\0'; fname = newvstralloc(fname, name, "/r", s, NULL); - s[-1] = ch; + s[-1] = (char)ch; if(stat(fname, &st) == 0 && S_ISCHR(st.st_mode)) return fname; } ch = *s++; @@ -452,8 +468,13 @@ char *name; return stralloc(name); /* no match */ } -static int samefile(stats, estat) -struct stat stats[3], *estat; +#ifndef IGNORE_FSTAB +static int samefile(struct stat[3], struct stat *); + +static int +samefile( + struct stat stats[3], + struct stat *estat) { int i; for(i = 0; i < 3; ++i) { @@ -463,16 +484,21 @@ struct stat stats[3], *estat; } return 0; } +#endif /* !IGNORE_FSTAB */ -int search_fstab(name, fsent, check_dev) - char *name; - generic_fsent_t *fsent; - int check_dev; +int +search_fstab( + char * name, + generic_fsent_t * fsent, + int check_dev) { #ifdef IGNORE_FSTAB /* There is no real mount table so this will always fail and * we are using GNU tar so we can just return here. */ + (void)name; /* Quiet unused parameter warning */ + (void)fsent; /* Quiet unused parameter warning */ + (void)check_dev; /* Quiet unused parameter warning */ return 0; #else struct stat stats[3]; @@ -483,21 +509,22 @@ int search_fstab(name, fsent, check_dev) if (!name) return 0; - stats[0].st_dev = stats[1].st_dev = stats[2].st_dev = -1; + memset(stats, 0, SIZEOF(stats)); + stats[0].st_dev = stats[1].st_dev = stats[2].st_dev = (dev_t)-1; if (stat(name, &stats[0]) == -1) - stats[0].st_dev = -1; + stats[0].st_dev = (dev_t)-1; if (name[0] != '/') { fullname = stralloc2(DEV_PREFIX, name); if (stat(fullname, &stats[1]) == -1) - stats[1].st_dev = -1; + stats[1].st_dev = (dev_t)-1; fullname = newstralloc2(fullname, RDEV_PREFIX, name); if (stat(fullname, &stats[2]) == -1) - stats[2].st_dev = -1; + stats[2].st_dev = (dev_t)-1; amfree(fullname); } else if (stat((rdev = dev2rdev(name)), &stats[1]) == -1) - stats[1].st_dev = -1; + stats[1].st_dev = (dev_t)-1; amfree(rdev); @@ -543,8 +570,9 @@ int search_fstab(name, fsent, check_dev) #endif /* !IGNORE_FSTAB */ } -int is_local_fstype(fsent) -generic_fsent_t *fsent; +int +is_local_fstype( + generic_fsent_t * fsent) { if(fsent->fstype == NULL) /* unknown, assume local */ return 1; @@ -560,8 +588,9 @@ generic_fsent_t *fsent; } -char *amname_to_devname(str) -char *str; +char * +amname_to_devname( + char * str) { generic_fsent_t fsent; @@ -573,8 +602,9 @@ char *str; return dev2rdev(str); } -char *amname_to_dirname(str) -char *str; +char * +amname_to_dirname( + char * str) { generic_fsent_t fsent; @@ -586,8 +616,8 @@ char *str; return stralloc(str); } -char *amname_to_fstype(str) -char *str; +char *amname_to_fstype( + char * str) { generic_fsent_t fsent; @@ -599,9 +629,11 @@ char *str; #ifdef TEST +void print_entry(generic_fsent_t *fsent); + void -print_entry(fsent) -generic_fsent_t *fsent; +print_entry( + generic_fsent_t * fsent) { #define nchk(s) ((s)? (s) : "") printf("%-20.20s %-14.14s %-7.7s %4d %5d %s\n", @@ -609,9 +641,10 @@ generic_fsent_t *fsent; fsent->freq, fsent->passno, nchk(fsent->mntopts)); } -int main(argc, argv) - int argc; - char **argv; +int +main( + int argc, + char ** argv) { generic_fsent_t fsent; char *s; @@ -623,6 +656,8 @@ int main(argc, argv) set_pname("getfsent"); + dbopen(NULL); + /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); diff --git a/client-src/getfsent.h b/client-src/getfsent.h index a8b37b0..6b857bf 100644 --- a/client-src/getfsent.h +++ b/client-src/getfsent.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: getfsent.h,v 1.7 2002/10/27 22:58:33 martinea Exp $ + * $Id: getfsent.h,v 1.8 2006/05/25 01:47:11 johnfranks Exp $ * * interfaces for obtaining filesystem information */ @@ -50,16 +50,16 @@ typedef struct generic_fsent_s { int passno; } generic_fsent_t; -int open_fstab P((void)); -void close_fstab P((void)); +int open_fstab(void); +void close_fstab(void); -int get_fstab_nextentry P((generic_fsent_t *fsent)); -int search_fstab P((char *name, generic_fsent_t *fsent, int check_dev)); -int is_local_fstype P((generic_fsent_t *fsent)); +int get_fstab_nextentry(generic_fsent_t *fsent); +int search_fstab(char *name, generic_fsent_t *fsent, int check_dev); +int is_local_fstype(generic_fsent_t *fsent); -char *amname_to_devname P((char *str)); -char *amname_to_dirname P((char *str)); +char *amname_to_devname(char *str); +char *amname_to_dirname(char *str); -char *amname_to_fstype P((char *str)); +char *amname_to_fstype(char *str); #endif /* ! GETFSENT_H */ diff --git a/client-src/killpgrp.c b/client-src/killpgrp.c index 1837409..3777d7d 100644 --- a/client-src/killpgrp.c +++ b/client-src/killpgrp.c @@ -24,10 +24,14 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: killpgrp.c,v 1.12 2005/09/20 21:32:25 jrjackson Exp $ + * $Id: killpgrp.c,v 1.17 2006/07/25 18:27:56 martinea Exp $ * * if it is the process group leader, it kills all processes in its * process group when it is killed itself. + * + * argv[0] is the killpgrp program name + * argv[1] is the config name or NOCONFIG + * */ #include "amanda.h" #include "version.h" @@ -43,14 +47,15 @@ #define AM_GETPGRP() getpid() #endif -int main P((int argc, char **argv)); -static void term_kill_soft P((int sig)); -static void term_kill_hard P((int sig)); +int main(int argc, char **argv); +static void term_kill_soft(int sig); +static void term_kill_hard(int sig); -int main(argc, argv) -int argc; -char **argv; +int main( + int argc, + char **argv) { + int ch; amwait_t status; safe_fd(-1, 0); @@ -58,19 +63,30 @@ char **argv; set_pname("killpgrp"); - dbopen(); - dbprintf(("%s: version %s\n", argv[0], version())); + dbopen(DBG_SUBDIR_CLIENT); + if (argc < 2) { + error("%s: Need at least 2 arguments\n", debug_prefix(NULL)); + /*NOTREACHED*/ + } + dbprintf(("%s: version %s\n", debug_prefix(NULL), version())); + dbprintf(("config: %s\n", argv[1])); + if (strcmp(argv[1], "NOCONFIG") != 0) + dbrename(argv[1], DBG_SUBDIR_CLIENT); if(client_uid == (uid_t) -1) { error("error [cannot find user %s in passwd file]", CLIENT_LOGIN); + /*NOTREACHED*/ } #ifdef FORCE_USERID - if (getuid() != client_uid) + if (getuid() != client_uid) { error("error [must be invoked by %s]", CLIENT_LOGIN); - - if (geteuid() != 0) + /*NOTREACHED*/ + } + if (geteuid() != 0) { error("error [must be setuid root]"); + /*NOTREACHED*/ + } #endif /* FORCE_USERID */ #if !defined (DONT_SUID_ROOT) @@ -79,13 +95,16 @@ char **argv; if (AM_GETPGRP() != getpid()) { error("error [must be the process group leader]"); + /*NOTREACHED*/ } + /* Consume any extranious input */ signal(SIGTERM, term_kill_soft); - while (getchar() != EOF) { + do { + ch = getchar(); /* wait until EOF */ - } + } while (ch != EOF); term_kill_soft(0); @@ -94,21 +113,25 @@ char **argv; break; if (errno != EINTR) { error("error [wait() failed: %s]", strerror(errno)); - return -1; + /*NOTREACHED*/ } } + /*@ignore@*/ dbprintf(("child process exited with status %d\n", WEXITSTATUS(status))); return WEXITSTATUS(status); + /*@end@*/ } -static void term_kill_soft(sig) -int sig; +static void term_kill_soft( + int sig) { pid_t dumppid = getpid(); int killerr; + (void)sig; /* Quiet unused parameter warning */ + signal(SIGTERM, SIG_IGN); signal(SIGALRM, term_kill_hard); alarm(3); @@ -123,12 +146,14 @@ int sig; } } -static void term_kill_hard(sig) -int sig; +static void term_kill_hard( + int sig) { pid_t dumppid = getpid(); int killerr; + (void)sig; /* Quiet unused parameter warning */ + dbprintf(("it won\'t die with SIGTERM, but SIGKILL should do\n")); dbprintf(("do\'t expect any further output, this will be suicide\n")); killerr = kill(-dumppid, SIGKILL); diff --git a/client-src/noop.c b/client-src/noop.c index 3700852..a0c4105 100644 --- a/client-src/noop.c +++ b/client-src/noop.c @@ -25,7 +25,7 @@ */ /* - * $Id: noop.c,v 1.3 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: noop.c,v 1.5 2006/06/01 14:54:39 martinea Exp $ * * send back features. This was pulled out to it's own program for * consistancy and because it's a hell of a lot easier to code in @@ -36,22 +36,26 @@ #include "amfeatures.h" #include "util.h" -int main P((int argc, char **argv)); +int main(int argc, char **argv); int -main(argc, argv) - int argc; - char **argv; +main( + int argc, + char ** argv) { char ch; am_feature_t *our_features = NULL; char *our_feature_string = NULL; char *options; - int n; + ssize_t n; + + (void)argc; /* Quiet unused parameter warning */ + (void)argv; /* Quiet unused parameter warning */ /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); + safe_fd(-1, 0); do { /* soak up any stdin */ n = read(0, &ch, 1); @@ -67,7 +71,11 @@ main(argc, argv) our_features = NULL; if (fullwrite(1, options, strlen(options)) < 0) { error("error sending noop response: %s", strerror(errno)); + /*NOTREACHED*/ } amfree(options); - exit(0); + close(0); + close(1); + close(2); + return (0); /* exit */ } diff --git a/client-src/patch-system.sh.in b/client-src/patch-system.sh.in index a2d7cfb..f96f72e 100644 --- a/client-src/patch-system.sh.in +++ b/client-src/patch-system.sh.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! @SHELL@ # # patch inetd.conf and services # originally by Axel Zinser (fifi@hiss.han.de) diff --git a/client-src/rundump.c b/client-src/rundump.c index 347da0a..f42ed27 100644 --- a/client-src/rundump.c +++ b/client-src/rundump.c @@ -24,14 +24,19 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: rundump.c,v 1.28 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: rundump.c,v 1.33 2006/07/25 18:27:56 martinea Exp $ * * runs DUMP program as root + * + * argv[0] is the rundump program name + * argv[1] is the config name or NOCONFIG + * argv[2] will be argv[0] of the DUMP program + * ... */ #include "amanda.h" #include "version.h" -int main P((int argc, char **argv)); +int main(int argc, char **argv); #if defined(VDUMP) || defined(XFSDUMP) # undef USE_RUNDUMP @@ -48,9 +53,10 @@ int main P((int argc, char **argv)); # endif #endif -int main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char ** argv) { #ifndef ERRMSG char *dump_program; @@ -66,8 +72,13 @@ char **argv; /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); - dbopen(); - dbprintf(("%s: version %s\n", argv[0], version())); + dbopen(DBG_SUBDIR_CLIENT); + if (argc < 3) { + error("%s: Need at least 3 arguments\n", debug_prefix(NULL)); + /*NOTREACHED*/ + } + + dbprintf(("%s: version %s\n", debug_prefix(NULL), version())); #ifdef ERRMSG /* { */ @@ -80,20 +91,35 @@ char **argv; if(client_uid == (uid_t) -1) { error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN); + /*NOTREACHED*/ } #ifdef FORCE_USERID - if (getuid() != client_uid) + if (getuid() != client_uid) { error("error [must be invoked by %s]\n", CLIENT_LOGIN); + /*NOTREACHED*/ + } - if (geteuid() != 0) + if (geteuid() != 0) { error("error [must be setuid root]\n"); + /*NOTREACHED*/ + } #endif /* FORCE_USERID */ #if !defined (DONT_SUID_ROOT) setuid(0); #endif + /* skip argv[0] */ + argc--; + argv++; + + dbprintf(("config: %s\n", argv[0])); + if (strcmp(argv[0], "NOCONFIG") != 0) + dbrename(argv[0], DBG_SUBDIR_CLIENT); + argc--; + argv++; + #ifdef XFSDUMP if (strcmp(argv[0], "xfsdump") == 0) diff --git a/client-src/runtar.c b/client-src/runtar.c index d24352b..5d46111 100644 --- a/client-src/runtar.c +++ b/client-src/runtar.c @@ -24,18 +24,25 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: runtar.c,v 1.17 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: runtar.c,v 1.24 2006/08/25 11:41:31 martinea Exp $ * * runs GNUTAR program as root + * + * argv[0] is the runtar program name + * argv[1] is the config name or NOCONFIG + * argv[2] will be argv[0] of the gtar program + * ... */ #include "amanda.h" #include "version.h" +#include "util.h" -int main P((int argc, char **argv)); +int main(int argc, char **argv); -int main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char ** argv) { #ifdef GNUTAR int i; @@ -51,8 +58,19 @@ char **argv; /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); - dbopen(); - dbprintf(("%s: version %s\n", argv[0], version())); + dbopen(DBG_SUBDIR_CLIENT); + if (argc < 3) { + error("%s: Need at least 3 arguments\n", debug_prefix(NULL)); + /*NOTREACHED*/ + } + + dbprintf(("%s: version %s\n", debug_prefix(NULL), version())); + + if (strcmp(argv[3], "--create") != 0) { + error("%s: Can only be used to create tar archives\n", + debug_prefix(NULL)); + /*NOTREACHED*/ + } #ifndef GNUTAR @@ -63,25 +81,68 @@ char **argv; #else + /* + * Print out version information for tar. + */ + do { + FILE * version_file; + char version_buf[80]; + + if ((version_file = popen(GNUTAR " --version 2>&1", "r")) != NULL) { + if (fgets(version_buf, (int)sizeof(version_buf), version_file) != NULL) { + dbprintf((GNUTAR " version: %s\n", version_buf)); + } else { + if (ferror(version_file)) { + dbprintf((GNUTAR " version: Read failure: %s\n", strerror(errno))); + } else { + dbprintf((GNUTAR " version: Read failure; EOF\n")); + } + } + } else { + dbprintf((GNUTAR " version: unavailable: %s\n", strerror(errno))); + } + } while(0); + if(client_uid == (uid_t) -1) { error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN); + /*NOTREACHED*/ } #ifdef FORCE_USERID - if (getuid() != client_uid) + if (getuid() != client_uid) { error("error [must be invoked by %s]\n", CLIENT_LOGIN); + /*NOTREACHED*/ + } - if (geteuid() != 0) + if (geteuid() != 0) { error("error [must be setuid root]\n"); + /*NOTREACHED*/ + } #endif #if !defined (DONT_SUID_ROOT) setuid(0); #endif + /* skip argv[0] */ + argc--; + argv++; + + dbprintf(("config: %s\n", argv[0])); + if (strcmp(argv[0], "NOCONFIG") != 0) + dbrename(argv[0], DBG_SUBDIR_CLIENT); + argc--; + argv++; + + dbprintf(("running: %s: ",GNUTAR)); - for (i=0; argv[i]; i++) - dbprintf(("%s ", argv[i])); + for (i=0; argv[i]; i++) { + char *quoted; + + quoted = quote_string(argv[i]); + dbprintf(("'%s' ", quoted)); + amfree(quoted); + } dbprintf(("\n")); dbf = dbfn(); if (dbf) { diff --git a/client-src/selfcheck.c b/client-src/selfcheck.c index 49306d4..8d8ae75 100644 --- a/client-src/selfcheck.c +++ b/client-src/selfcheck.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: selfcheck.c,v 1.76 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: selfcheck.c,v 1.95 2006/08/29 11:21:00 martinea Exp $ * * do self-check and send back any error messages */ @@ -40,6 +40,8 @@ #include "pipespawn.h" #include "amfeatures.h" #include "client_util.h" +#include "clientconf.h" +#include "amandad.h" #ifdef SAMBA_CLIENT #include "findpass.h" @@ -61,39 +63,46 @@ int need_compress_path=0; int need_calcsize=0; int program_is_wrapper=0; +static char *amandad_auth = NULL; static am_feature_t *our_features = NULL; static char *our_feature_string = NULL; static g_option_t *g_options = NULL; /* local functions */ -int main P((int argc, char **argv)); - -static void check_options P((char *program, char *calcprog, char *disk, char *amdevice, option_t *options)); -static void check_disk P((char *program, char *calcprog, char *disk, char *amdevice, int level, char *optstr)); -static void check_overall P((void)); -static void check_access P((char *filename, int mode)); -static void check_file P((char *filename, int mode)); -static void check_dir P((char *dirname, int mode)); -static void check_suid P((char *filename)); -static void check_space P((char *dir, long kbytes)); - -int main(argc, argv) -int argc; -char **argv; +int main(int argc, char **argv); + +static void check_options(char *program, char *calcprog, char *disk, char *amdevice, option_t *options); +static void check_disk(char *program, char *calcprog, char *disk, char *amdevice, int level, char *optstr); +static void check_overall(void); +static void check_access(char *filename, int mode); +static void check_file(char *filename, int mode); +static void check_dir(char *dirname, int mode); +static void check_suid(char *filename); +static void check_space(char *dir, off_t kbytes); + +int +main( + int argc, + char ** argv) { int level; char *line = NULL; char *program = NULL; char *calcprog = NULL; char *disk = NULL; + char *qdisk = NULL; char *amdevice = NULL; + char *qamdevice = NULL; char *optstr = NULL; char *err_extra = NULL; char *s, *fp; + char *conffile; + option_t *options; int ch; +#if defined(USE_DBMALLOC) unsigned long malloc_hist_1, malloc_size_1; unsigned long malloc_hist_2, malloc_size_2; - option_t *options; +#endif /* initialize */ @@ -105,21 +114,40 @@ char **argv; /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); +#if defined(USE_DBMALLOC) malloc_size_1 = malloc_inuse(&malloc_hist_1); +#endif erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG); - dbopen(); + dbopen(DBG_SUBDIR_CLIENT); startclock(); dbprintf(("%s: version %s\n", get_pname(), version())); + if(argc > 2 && strcmp(argv[1], "amandad") == 0) { + amandad_auth = stralloc(argv[2]); + } + + conffile = vstralloc(CONFIG_DIR, "/", "amanda-client.conf", NULL); + if (read_clientconf(conffile) > 0) { + printf("ERROR [reading conffile: %s]\n", conffile); + error("error reading conffile: %s", conffile); + /*NOTREACHED*/ + } + amfree(conffile); + our_features = am_init_feature_set(); our_feature_string = am_feature_to_string(our_features); /* handle all service requests */ + /*@ignore@*/ for(; (line = agets(stdin)) != NULL; free(line)) { + /*@end@*/ + if (line[0] == '\0') + continue; + #define sc "OPTIONS " - if(strncmp(line, sc, sizeof(sc)-1) == 0) { + if(strncmp(line, sc, SIZEOF(sc)-1) == 0) { #undef sc g_options = parse_g_options(line+8, 1); if(!g_options->hostname) { @@ -137,6 +165,20 @@ char **argv; } printf("\n"); fflush(stdout); + + if (g_options->config) { + conffile = vstralloc(CONFIG_DIR, "/", g_options->config, "/", + "amanda-client.conf", NULL); + if (read_clientconf(conffile) > 0) { + printf("ERROR [reading conffile: %s]\n", conffile); + error("error reading conffile: %s", conffile); + /*NOTREACHED*/ + } + amfree(conffile); + + dbrename(g_options->config, DBG_SUBDIR_CLIENT); + } + continue; } @@ -180,9 +222,10 @@ char **argv; if (ch == '\0') { goto err; /* no disk */ } - disk = s - 1; - skip_non_whitespace(s, ch); + qdisk = s - 1; + skip_quoted_string(s, ch); s[-1] = '\0'; /* terminate the disk name */ + disk = unquote_string(qdisk); skip_whitespace(s, ch); /* find the device or level */ if (ch == '\0') { @@ -190,9 +233,10 @@ char **argv; } if(!isdigit((int)s[-1])) { fp = s - 1; - skip_non_whitespace(s, ch); + skip_quoted_string(s, ch); s[-1] = '\0'; /* terminate the device */ - amdevice = stralloc(fp); + qamdevice = stralloc(fp); + amdevice = unquote_string(qamdevice); skip_whitespace(s, ch); /* find level number */ } else { @@ -207,8 +251,8 @@ char **argv; skip_whitespace(s, ch); #define sc "OPTIONS " - if (ch && strncmp (s - 1, sc, sizeof(sc)-1) == 0) { - s += sizeof(sc)-1; + if (ch && strncmp (s - 1, sc, SIZEOF(sc)-1) == 0) { + s += SIZEOF(sc)-1; ch = s[-1]; #undef sc skip_whitespace(s, ch); /* find the option string */ @@ -216,11 +260,13 @@ char **argv; goto err; /* bad options string */ } optstr = s - 1; - skip_non_whitespace(s, ch); + skip_quoted_string(s, ch); s[-1] = '\0'; /* terminate the options */ options = parse_options(optstr, disk, amdevice, g_options->features, 1); + /*@ignore@*/ check_options(program, calcprog, disk, amdevice, options); check_disk(program, calcprog, disk, amdevice, level, &optstr[2]); + /*@end@*/ free_sl(options->exclude_file); free_sl(options->exclude_list); free_sl(options->include_file); @@ -244,10 +290,13 @@ char **argv; need_gnutar=1; need_compress_path=1; need_calcsize=1; + /*@ignore@*/ check_disk(program, calcprog, disk, amdevice, level, ""); + /*@end@*/ } else { goto err; /* bad syntax */ } + amfree(disk); amfree(amdevice); } @@ -263,15 +312,15 @@ char **argv; amfree(g_options->hostname); amfree(g_options); +#if defined(USE_DBMALLOC) malloc_size_2 = malloc_inuse(&malloc_hist_2); if(malloc_size_1 != malloc_size_2) { -#if defined(USE_DBMALLOC) extern int dbfd; malloc_list(dbfd(), malloc_hist_1, malloc_hist_2); -#endif } +#endif dbclose(); return 0; @@ -288,9 +337,12 @@ char **argv; static void -check_options(program, calcprog, disk, amdevice, options) - char *program, *calcprog, *disk, *amdevice; - option_t *options; +check_options( + char * program, + char * calcprog, + char * disk, + char * amdevice, + option_t * options) { char *myprogram = program; @@ -312,7 +364,11 @@ check_options(program, calcprog, disk, amdevice, options) amfree(file_include); need_calcsize=1; - myprogram = calcprog; + if (calcprog == NULL) { + printf("ERROR [no program name for calcsize]\n"); + } else { + myprogram = calcprog; + } } if(strcmp(myprogram,"GNUTAR") == 0) { @@ -425,27 +481,45 @@ check_options(program, calcprog, disk, amdevice, options) need_restore=1; #endif } - if(program_is_wrapper==1) { - } - if(options->compress == COMPR_BEST || options->compress == COMPR_FAST || options->compress == COMPR_CUST) + if ((options->compress == COMPR_BEST) || (options->compress == COMPR_FAST) + || (options->compress == COMPR_CUST)) { need_compress_path=1; + } + if(options->auth && amandad_auth) { + if(strcasecmp(options->auth, amandad_auth) != 0) { + fprintf(stdout,"ERROR [client configured for auth=%s while server requested '%s']\n", + amandad_auth, options->auth); + } + } } -static void check_disk(program, calcprog, disk, amdevice, level, optstr) -char *program, *calcprog, *disk, *amdevice; -int level; -char *optstr; +static void +check_disk( + char * program, + char * calcprog, + char * disk, + char * amdevice, + int level, + char * optstr) { - char *device = NULL; + char *device = stralloc("nodevice"); char *err = NULL; - char *user_and_password = NULL, *domain = NULL; + char *user_and_password = NULL; + char *domain = NULL; char *share = NULL, *subdir = NULL; - int lpass = 0; + size_t lpass = 0; int amode; int access_result; char *access_type; char *extra_info = NULL; char *myprogram = program; + char *qdisk = quote_string(disk); + char *qamdevice = quote_string(amdevice); + char *qdevice = NULL; + + (void)level; /* Quiet unused parameter warning */ + + dbprintf(("%s: checking disk %s\n", debug_prefix_time(NULL), qdisk)); if(strcmp(myprogram,"CALCSIZE") == 0) { if(amdevice[0] == '/' && amdevice[1] == '/') { @@ -458,19 +532,17 @@ char *optstr; myprogram = calcprog; } - dbprintf(("%s: checking disk %s\n", debug_prefix_time(NULL), disk)); - - if (strcmp(myprogram, "GNUTAR") == 0) { + if (strcmp(myprogram, "GNUTAR")==0) { if(amdevice[0] == '/' && amdevice[1] == '/') { #ifdef SAMBA_CLIENT int nullfd, checkerr; int passwdfd; char *pwtext; - int pwtext_len; - int checkpid; + size_t pwtext_len; + pid_t checkpid; amwait_t retstat; char number[NUM_STR_SIZE]; - int wpid; + pid_t wpid; int ret, sig, rc; char *line; char *sep; @@ -500,7 +572,8 @@ char *optstr; goto common_exit; } *pwtext++ = '\0'; - pwtext_len = strlen(pwtext); + pwtext_len = (size_t)strlen(pwtext); + amfree(device); if ((device = makesharename(share, 0)) == NULL) { err = stralloc2("cannot make share name of ", share); goto common_exit; @@ -532,12 +605,11 @@ char *optstr; #endif "-c", "quit", NULL); - if (domain) { - memset(domain, '\0', strlen(domain)); - amfree(domain); - } + amfree(domain); aclose(nullfd); - if (pwtext_len > 0 && fullwrite(passwdfd, pwtext, pwtext_len) < 0) { + /*@ignore@*/ + if ((pwtext_len > 0) + && fullwrite(passwdfd, pwtext, (size_t)pwtext_len) < 0) { err = vstralloc("password write failed: ", amdevice, ": ", @@ -546,13 +618,21 @@ char *optstr; aclose(passwdfd); goto common_exit; } - memset(user_and_password, '\0', lpass); + /*@end@*/ + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); aclose(passwdfd); ferr = fdopen(checkerr, "r"); + if (!ferr) { + printf("ERROR [Can't fdopen: %s]\n", strerror(errno)); + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } sep = ""; errdos = 0; for(sep = ""; (line = agets(ferr)) != NULL; free(line)) { + if (line[0] == '\0') + continue; strappend(extra_info, sep); strappend(extra_info, line); sep = ": "; @@ -579,7 +659,7 @@ char *optstr; } else { strappend(err, "returned "); } - snprintf(number, sizeof(number), "%d", ret); + snprintf(number, (size_t)sizeof(number), "%d", ret); strappend(err, number); } } @@ -594,17 +674,18 @@ char *optstr; amfree(extra_info); } #else - err = stralloc2("This client is not configured for samba: ", disk); + err = stralloc2("This client is not configured for samba: ", qdisk); #endif goto common_exit; } amode = F_OK; + amfree(device); device = amname_to_dirname(amdevice); } else if (strcmp(program, "DUMP") == 0) { if(amdevice[0] == '/' && amdevice[1] == '/') { err = vstralloc("The DUMP program cannot handle samba shares,", " use GNUTAR: ", - disk, + qdisk, NULL); goto common_exit; } @@ -615,11 +696,13 @@ char *optstr; if (1) #endif /* } */ { + amfree(device); device = amname_to_dirname(amdevice); amode = F_OK; } else #endif /* } */ { + amfree(device); device = amname_to_devname(amdevice); #ifdef USE_RUNDUMP amode = F_OK; @@ -629,10 +712,14 @@ char *optstr; } } else { /* program_is_wrapper==1 */ - int pid_wrapper; + pid_t pid_wrapper; fflush(stdout);fflush(stdin); switch (pid_wrapper = fork()) { - case -1: error("fork: %s", strerror(errno)); + case -1: + printf("ERROR [fork: %s]\n", strerror(errno)); + error("fork: %s", strerror(errno)); + /*NOTREACHED*/ + case 0: /* child */ { char *argvchild[6]; @@ -653,10 +740,14 @@ char *optstr; } } fflush(stdout);fflush(stdin); + amfree(device); + amfree(qamdevice); + amfree(qdisk); return; } - dbprintf(("%s: device %s\n", debug_prefix_time(NULL), device)); + qdevice = quote_string(device); + dbprintf(("%s: device %s\n", debug_prefix_time(NULL), qdevice)); /* skip accessability test if this is an AFS entry */ if(strncmp(device, "afs:", 4) != 0) { @@ -668,8 +759,8 @@ char *optstr; access_type = "access"; #endif if(access_result == -1) { - err = vstralloc("could not ", access_type, " ", device, - " (", disk, "): ", strerror(errno), NULL); + err = vstralloc("could not ", access_type, " ", qdevice, + " (", qdisk, "): ", strerror(errno), NULL); } #ifdef CHECK_FOR_ACCESS_WITH_OPEN aclose(access_result); @@ -681,41 +772,44 @@ common_exit: amfree(share); amfree(subdir); if(user_and_password) { - memset(user_and_password, '\0', lpass); + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); } - if(domain) { - memset(domain, '\0', strlen(domain)); - amfree(domain); - } + amfree(domain); if(err) { printf("ERROR [%s]\n", err); dbprintf(("%s: %s\n", debug_prefix_time(NULL), err)); amfree(err); } else { - printf("OK %s\n", disk); - dbprintf(("%s: disk \"%s\" OK\n", debug_prefix_time(NULL), disk)); - printf("OK %s\n", amdevice); - dbprintf(("%s: amdevice \"%s\" OK\n", - debug_prefix_time(NULL), amdevice)); - printf("OK %s\n", device); - dbprintf(("%s: device \"%s\" OK\n", debug_prefix_time(NULL), device)); + printf("OK %s\n", qdisk); + dbprintf(("%s: disk %s OK\n", debug_prefix_time(NULL), qdisk)); + printf("OK %s\n", qamdevice); + dbprintf(("%s: amdevice %s OK\n", + debug_prefix_time(NULL), qamdevice)); + printf("OK %s\n", qdevice); + dbprintf(("%s: device %s OK\n", debug_prefix_time(NULL), qdevice)); } if(extra_info) { dbprintf(("%s: extra info: %s\n", debug_prefix_time(NULL), extra_info)); amfree(extra_info); } + amfree(qdisk); + amfree(qdevice); + amfree(qamdevice); amfree(device); /* XXX perhaps do something with level: read dumpdates and sanity check */ } -static void check_overall() +static void +check_overall(void) { char *cmd; struct stat buf; int testfd; + char *gnutar_list_dir; + int need_amandates = 0; if( need_runtar ) { @@ -803,14 +897,19 @@ static void check_overall() #else printf("ERROR [GNUTAR program not available]\n"); #endif -#ifdef AMANDATES_FILE - check_file(AMANDATES_FILE, R_OK|W_OK); -#endif -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR - check_dir(GNUTAR_LISTED_INCREMENTAL_DIR,R_OK|W_OK); -#endif + need_amandates = 1; + gnutar_list_dir = client_getconf_str(CLN_GNUTAR_LIST_DIR); + if (strlen(gnutar_list_dir) == 0) + gnutar_list_dir = NULL; + if (gnutar_list_dir) + check_dir(gnutar_list_dir, R_OK|W_OK); } + if (need_amandates) { + char *amandates_file; + amandates_file = client_getconf_str(CLN_AMANDATES); + check_file(amandates_file, R_OK|W_OK); + } if( need_calcsize ) { char *cmd; @@ -862,35 +961,44 @@ static void check_overall() check_file("/etc/vdumpdates", F_OK); check_access("/dev/null", R_OK|W_OK); - check_space(AMANDA_TMPDIR, 64); /* for amandad i/o */ + check_space(AMANDA_TMPDIR, (off_t)64); /* for amandad i/o */ #ifdef AMANDA_DBGDIR - check_space(AMANDA_DBGDIR, 64); /* for amandad i/o */ + check_space(AMANDA_DBGDIR, (off_t)64); /* for amandad i/o */ #endif - check_space("/etc", 64); /* for /etc/dumpdates writing */ + check_space("/etc", (off_t)64); /* for /etc/dumpdates writing */ } -static void check_space(dir, kbytes) -char *dir; -long kbytes; +static void +check_space( + char * dir, + off_t kbytes) { generic_fs_stats_t statp; - - if(get_fs_stats(dir, &statp) == -1) - printf("ERROR [cannot statfs %s: %s]\n", dir, strerror(errno)); - else if(statp.avail < kbytes) - printf("ERROR [dir %s needs %ldKB, only has %ldKB available.]\n", - dir, kbytes, statp.avail); - else - printf("OK %s has more than %ld KB available.\n", dir, kbytes); + char *quoted = quote_string(dir); + + if(get_fs_stats(dir, &statp) == -1) { + printf("ERROR [cannot statfs %s: %s]\n", quoted, strerror(errno)); + } else if(statp.avail < kbytes) { + printf("ERROR [dir %s needs " OFF_T_FMT "KB, only has " + OFF_T_FMT "KB available.]\n", quoted, + (OFF_T_FMT_TYPE)kbytes, + (OFF_T_FMT_TYPE)statp.avail); + } else { + printf("OK %s has more than " OFF_T_FMT " KB available.\n", + quoted, (OFF_T_FMT_TYPE)kbytes); + } + amfree(quoted); } -static void check_access(filename, mode) -char *filename; -int mode; +static void +check_access( + char * filename, + int mode) { char *noun, *adjective; + char *quoted = quote_string(filename); if(mode == F_OK) noun = "find", adjective = "exists"; @@ -902,34 +1010,44 @@ int mode; noun = "access", adjective = "accessible"; if(access(filename, mode) == -1) - printf("ERROR [can not %s %s: %s]\n", noun, filename, strerror(errno)); + printf("ERROR [can not %s %s: %s]\n", noun, quoted, strerror(errno)); else - printf("OK %s %s\n", filename, adjective); + printf("OK %s %s\n", quoted, adjective); + amfree(quoted); } -static void check_file(filename, mode) -char *filename; -int mode; +static void +check_file( + char * filename, + int mode) { struct stat stat_buf; + char *quoted; + if(!stat(filename, &stat_buf)) { if(!S_ISREG(stat_buf.st_mode)) { - printf("ERROR [%s is not a file]\n", filename); + quoted = quote_string(filename); + printf("ERROR [%s is not a file]\n", quoted); + amfree(quoted); } } check_access(filename, mode); } -static void check_dir(dirname, mode) -char *dirname; -int mode; +static void +check_dir( + char * dirname, + int mode) { struct stat stat_buf; + char *quoted; char *dir; if(!stat(dirname, &stat_buf)) { if(!S_ISDIR(stat_buf.st_mode)) { - printf("ERROR [%s is not a directory]\n", dirname); + quoted = quote_string(dirname); + printf("ERROR [%s is not a directory]\n", quoted); + amfree(quoted); } } dir = stralloc2(dirname, "/."); @@ -937,22 +1055,28 @@ int mode; amfree(dir); } -static void check_suid(filename) -char *filename; +static void +check_suid( + char * filename) { /* The following is only valid for real Unixs */ #ifndef IGNORE_UID_CHECK struct stat stat_buf; + char *quoted = quote_string(filename); + if(!stat(filename, &stat_buf)) { if(stat_buf.st_uid != 0 ) { - printf("ERROR [%s is not owned by root]\n",filename); + printf("ERROR [%s is not owned by root]\n", quoted); } if((stat_buf.st_mode & S_ISUID) != S_ISUID) { - printf("ERROR [%s is not SUID root]\n",filename); + printf("ERROR [%s is not SUID root]\n", quoted); } } else { - printf("ERROR [can not stat %s]\n",filename); + printf("ERROR [can not stat %s]\n", quoted); } + amfree(quoted); +#else + (void)filename; /* Quiet unused parameter warning */ #endif } diff --git a/client-src/sendbackup-dump.c b/client-src/sendbackup-dump.c index 470aff8..c762394 100644 --- a/client-src/sendbackup-dump.c +++ b/client-src/sendbackup-dump.c @@ -24,11 +24,12 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: sendbackup-dump.c,v 1.88 2006/03/09 20:06:11 johnfranks Exp $ + * $Id: sendbackup-dump.c,v 1.90 2006/07/25 18:10:07 martinea Exp $ * * send backup data using BSD dump */ +#include "amanda.h" #include "sendbackup.h" #include "getfsent.h" #include "clock.h" @@ -36,7 +37,7 @@ #define LEAF_AND_DIRS "sed -e \'\ns/^leaf[ \t]*[0-9]*[ \t]*\\.//\nt\n/^dir[ \t]/ {\ns/^dir[ \t]*[0-9]*[ \t]*\\.//\ns%$%/%\nt\n}\nd\n\'" -static regex_t re_table[] = { +static amregex_t re_table[] = { /* the various encodings of dump size */ /* this should also match BSDI pre-3.0's buggy dump program, that produced doubled DUMP: DUMP: messages */ @@ -111,15 +112,24 @@ static regex_t re_table[] = { AM_STRANGE_RE(NULL) }; +static void start_backup(char *host, char *disk, char *amdevice, int level, + char *dumpdate, int dataf, int mesgf, int indexf); +static void end_backup(int status); + /* * doing similar to $ dump | compression | encryption */ -static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf) - char *host; - char *disk, *amdevice; - int level, dataf, mesgf, indexf; - char *dumpdate; +static void +start_backup( + char * host, + char * disk, + char * amdevice, + int level, + char * dumpdate, + int dataf, + int mesgf, + int indexf) { int dumpin, dumpout, compout; char *dumpkeys = NULL; @@ -130,25 +140,33 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in char level_str[NUM_STR_SIZE]; char *compopt = NULL; char *encryptopt = skip_argument; + char *qdisk; + char *config; + + (void)dumpdate; /* Quiet unused parameter warning */ + snprintf(level_str, SIZEOF(level_str), "%d", level); - snprintf(level_str, sizeof(level_str), "%d", level); + qdisk = quote_string(disk); + dbprintf(("%s: start: %s:%s lev %d\n", + get_pname(), host, qdisk, level)); fprintf(stderr, "%s: start [%s:%s level %d]\n", - get_pname(), host, disk, level); + get_pname(), host, qdisk, level); + amfree(qdisk); - /* apply client-side encryption here */ - if ( options->encrypt == ENCRYPT_CUST ) { - encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE, + /* apply client-side encryption here */ + if ( options->encrypt == ENCRYPT_CUST ) { + encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE, &compout, &dataf, &mesgf, options->clnt_encrypt, encryptopt, NULL); - dbprintf(("%s: pid %ld: %s\n", + dbprintf(("%s: pid %ld: %s\n", debug_prefix_time("-gnutar"), (long)encpid, options->clnt_encrypt)); - } else { + } else { compout = dataf; encpid = -1; - } - /* now do the client-side compression */ + } + /* now do the client-side compression */ if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) { @@ -195,8 +213,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in #if defined(USE_RUNDUMP) || !defined(DUMP) cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL); + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; #else cmd = stralloc(DUMP); + config = skip_argument; #endif #ifndef AIX_BACKUP /* { */ @@ -210,6 +233,11 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in { char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump", versionsuffix(), NULL); + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; + program->backup_name = XFSDUMP; program->restore_name = XFSRESTORE; @@ -228,6 +256,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in dumpkeys = stralloc(level_str); dumppid = pipespawn(progname, STDIN_PIPE, &dumpin, &dumpout, &mesgf, + config, /* JLM */ "xfsdump", options->no_record ? "-J" : skip_argument, "-F", @@ -248,8 +277,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in #ifdef USE_RUNDUMP char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump", versionsuffix(), NULL); + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; #else char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL); + config = skip_argument; #endif program->backup_name = VXDUMP; program->restore_name = VXRESTORE; @@ -272,6 +306,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in dumppid = pipespawn(progname, STDIN_PIPE, &dumpin, &dumpout, &mesgf, + progname, config, /* JLM */ "vxdump", dumpkeys, "1048576", @@ -291,6 +326,10 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in { char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump", versionsuffix(), NULL); + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; device = newstralloc(device, amname_to_dirname(amdevice)); program->backup_name = VDUMP; program->restore_name = VRESTORE; @@ -313,6 +352,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in dumppid = pipespawn(cmd, STDIN_PIPE, &dumpin, &dumpout, &mesgf, + cmd, config, "vdump", dumpkeys, "60", @@ -350,6 +390,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in dumppid = pipespawn(cmd, STDIN_PIPE, &dumpin, &dumpout, &mesgf, + cmd, config, "dump", dumpkeys, "1048576", @@ -381,6 +422,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in dumppid = pipespawn(cmd, STDIN_PIPE, &dumpin, &dumpout, &mesgf, + cmd, config, "backup", dumpkeys, "-", @@ -405,9 +447,12 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in aclose(indexf); } -static void end_backup(status) -int status; +static void +end_backup( + int status) { + (void)status; /* Quiet unused parameter warning */ + /* don't need to do anything for dump */ } diff --git a/client-src/sendbackup-gnutar.c b/client-src/sendbackup-gnutar.c index f3c74fc..b1bda6d 100644 --- a/client-src/sendbackup-gnutar.c +++ b/client-src/sendbackup-gnutar.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: sendbackup-gnutar.c,v 1.92 2005/12/09 03:22:52 paddy_s Exp $ + * $Id: sendbackup-gnutar.c,v 1.98 2006/07/25 18:35:21 martinea Exp $ * * send backup data using GNU tar */ @@ -36,12 +36,13 @@ #include "util.h" #include "getfsent.h" /* for amname_to_dirname lookup */ #include "version.h" +#include "clientconf.h" #ifdef SAMBA_CLIENT #include "findpass.h" #endif -static regex_t re_table[] = { +static amregex_t re_table[] = { /* tar prints the size in bytes */ AM_SIZE_RE("^ *Total bytes written: [0-9][0-9]*", 1), AM_NORMAL_RE("^Elapsed time:"), @@ -123,17 +124,22 @@ int cur_level; char *cur_disk; time_t cur_dumptime; -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR +static char *gnutar_list_dir = NULL; static char *incrname = NULL; -#endif +static char *amandates_file; /* * doing similar to $ gtar | compression | encryption */ -static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf) - char *host; - char *disk, *amdevice; - int level, dataf, mesgf, indexf; - char *dumpdate; +static void +start_backup( + char * host, + char * disk, + char * amdevice, + int level, + char * dumpdate, + int dataf, + int mesgf, + int indexf) { int dumpin, dumpout, compout; char *cmd = NULL; @@ -147,18 +153,29 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in char *error_pn = NULL; char *compopt = NULL; char *encryptopt = skip_argument; + char *quoted; + char *qdisk; + int infd, outfd; + ssize_t nb; + char buf[32768]; + + (void)dumpdate; /* Quiet unused parameter warning */ error_pn = stralloc2(get_pname(), "-smbclient"); + qdisk = quote_string(disk); + dbprintf(("%s: start: %s:%s lev %d\n", + get_pname(), host, qdisk, level)); fprintf(stderr, "%s: start [%s:%s level %d]\n", - get_pname(), host, disk, level); + get_pname(), host, qdisk, level); + /* apply client-side encryption here */ if ( options->encrypt == ENCRYPT_CUST ) { - encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE, + encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE, &compout, &dataf, &mesgf, options->clnt_encrypt, encryptopt, NULL); - dbprintf(("%s: pid %ld: %s\n", + dbprintf(("%s: pid %ld: %s\n", debug_prefix_time("-gnutar"), (long)encpid, options->clnt_encrypt)); } else { compout = dataf; @@ -199,24 +216,24 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in comppid = -1; } -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR /* { */ + gnutar_list_dir = client_getconf_str(CLN_GNUTAR_LIST_DIR); + if (strlen(gnutar_list_dir) == 0) + gnutar_list_dir = NULL; + #ifdef SAMBA_CLIENT /* { */ if (amdevice[0] == '/' && amdevice[1]=='/') amfree(incrname); else #endif /* } */ - { + if (gnutar_list_dir) { char *basename = NULL; char number[NUM_STR_SIZE]; char *s; int ch; char *inputname = NULL; - FILE *in = NULL; - FILE *out; int baselevel; - char *line = NULL; - basename = vstralloc(GNUTAR_LISTED_INCREMENTAL_DIR, + basename = vstralloc(gnutar_list_dir, "/", host, disk, @@ -225,83 +242,98 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in * The loop starts at the first character of the host name, * not the '/'. */ - s = basename + sizeof(GNUTAR_LISTED_INCREMENTAL_DIR); + s = basename + strlen(gnutar_list_dir) + 1; while((ch = *s++) != '\0') { - if(ch == '/' || isspace(ch)) s[-1] = '_'; + if(ch == '/') + s[-1] = '_'; } - snprintf(number, sizeof(number), "%d", level); + snprintf(number, SIZEOF(number), "%d", level); incrname = vstralloc(basename, "_", number, ".new", NULL); unlink(incrname); /* - * Open the listed incremental file for the previous level. Search + * Open the listed incremental file from the previous level. Search * backward until one is found. If none are found (which will also * be true for a level 0), arrange to read from /dev/null. */ baselevel = level; - while (in == NULL) { + infd = -1; + while (infd == -1) { if (--baselevel >= 0) { - snprintf(number, sizeof(number), "%d", baselevel); + snprintf(number, SIZEOF(number), "%d", baselevel); inputname = newvstralloc(inputname, basename, "_", number, NULL); } else { inputname = newstralloc(inputname, "/dev/null"); } - if ((in = fopen(inputname, "r")) == NULL) { + if ((infd = open(inputname, O_RDONLY)) == -1) { int save_errno = errno; + char *qname = quote_string(inputname); - dbprintf(("%s: error opening %s: %s\n", + dbprintf(("%s: error opening '%s': %s\n", debug_prefix_time("-gnutar"), - inputname, + qname, strerror(save_errno))); if (baselevel < 0) { - error("error [opening %s: %s]", inputname, strerror(save_errno)); + error("error [opening '%s': %s]", qname, strerror(save_errno)); + /*NOTREACHED*/ } + amfree(qname); } } /* * Copy the previous listed incremental file to the new one. */ - if ((out = fopen(incrname, "w")) == NULL) { - error("error [opening %s: %s]", incrname, strerror(errno)); + if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) { + error("error [opening '%s': %s]", incrname, strerror(errno)); + /*NOTREACHED*/ } - for (; (line = agets(in)) != NULL; free(line)) { - if(fputs(line, out) == EOF || putc('\n', out) == EOF) { - error("error [writing to %s: %s]", incrname, strerror(errno)); + while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) { + if (fullwrite(outfd, &buf, (size_t)nb) < nb) { + error("error [writing to '%s': %s]", incrname, + strerror(errno)); + /*NOTREACHED*/ } } - amfree(line); - if (ferror(in)) { - error("error [reading from %s: %s]", inputname, strerror(errno)); + if (nb < 0) { + error("error [reading from '%s': %s]", inputname, strerror(errno)); + /*NOTREACHED*/ } - if (fclose(in) == EOF) { - error("error [closing %s: %s]", inputname, strerror(errno)); + + if (close(infd) != 0) { + error("error [closing '%s': %s]", inputname, strerror(errno)); + /*NOTREACHED*/ } - in = NULL; - if (fclose(out) == EOF) { - error("error [closing %s: %s]", incrname, strerror(errno)); + if (close(outfd) != 0) { + error("error [closing '%s': %s]", incrname, strerror(errno)); + /*NOTREACHED*/ } - out = NULL; dbprintf(("%s: doing level %d dump as listed-incremental", debug_prefix_time("-gnutar"), level)); if(baselevel >= 0) { - dbprintf((" from %s", inputname)); + quoted = quote_string(inputname); + dbprintf((" from '%s'", quoted)); + amfree(quoted); } - dbprintf((" to %s\n", incrname)); + quoted = quote_string(incrname); + dbprintf((" to '%s'\n", quoted)); + amfree(quoted); amfree(inputname); amfree(basename); } -#endif /* } */ /* find previous dump time */ - if(!start_amandates(0)) - error("error [opening %s: %s]", AMANDATES_FILE, strerror(errno)); + amandates_file = client_getconf_str(CLN_AMANDATES); + if(!start_amandates(amandates_file, 0)) { + error("error [opening %s: %s]", amandates_file, strerror(errno)); + /*NOTREACHED*/ + } amdates = amandates_lookup(disk); @@ -315,7 +347,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in free_amandates(); gmtm = gmtime(&prev_dumptime); - snprintf(dumptimestr, sizeof(dumptimestr), + snprintf(dumptimestr, SIZEOF(dumptimestr), "%04d-%02d-%02d %2d:%02d:%02d GMT", gmtm->tm_year + 1900, gmtm->tm_mon+1, gmtm->tm_mday, gmtm->tm_hour, gmtm->tm_min, gmtm->tm_sec); @@ -345,11 +377,11 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in if (amdevice[0] == '/' && amdevice[1]=='/') { char *sharename = NULL, *user_and_password = NULL, *domain = NULL; char *share = NULL, *subdir = NULL; - char *pwtext; + char *pwtext = NULL; char *taropt; - int passwdf; - int lpass; - int pwtext_len; + int passwdf = -1; + size_t lpass; + size_t pwtext_len; char *pw_fd_env; parsesharename(amdevice, &share, &subdir); @@ -358,14 +390,16 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in amfree(subdir); set_pname(error_pn); amfree(error_pn); - error("cannot parse disk entry '%s' for share/subdir", disk); + error("cannot parse disk entry %s for share/subdir", qdisk); + /*NOTREACHED*/ } if ((subdir) && (SAMBA_VERSION < 2)) { amfree(share); amfree(subdir); set_pname(error_pn); amfree(error_pn); - error("subdirectory specified for share '%s' but samba not v2 or better", disk); + error("subdirectory specified for share %s but samba not v2 or better", qdisk); + /*NOTREACHED*/ } if ((user_and_password = findpass(share, &domain)) == NULL) { if(domain) { @@ -375,6 +409,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in set_pname(error_pn); amfree(error_pn); error("error [invalid samba host or password not found?]"); + /*NOTREACHED*/ } lpass = strlen(user_and_password); if ((pwtext = strchr(user_and_password, '%')) == NULL) { @@ -386,7 +421,8 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in } set_pname(error_pn); amfree(error_pn); - error("password field not \'user%%pass\' for %s", disk); + error("password field not \'user%%pass\' for %s", qdisk); + /*NOTREACHED*/ } *pwtext++ = '\0'; pwtext_len = strlen(pwtext); @@ -400,6 +436,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in set_pname(error_pn); amfree(error_pn); error("error [can't make share name of %s]", share); + /*NOTREACHED*/ } taropt = stralloc("-T"); @@ -465,6 +502,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in set_pname(error_pn); amfree(error_pn); error("error [password write failed: %s]", strerror(save_errno)); + /*NOTREACHED*/ } memset(user_and_password, '\0', lpass); amfree(user_and_password); @@ -493,13 +531,18 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in if(nb_exclude > 0) file_exclude = build_exclude(disk, amdevice, options, 0); if(nb_include > 0) file_include = build_include(disk, amdevice, options, 0); - my_argv = alloc(sizeof(char *) * (17 + (nb_exclude*2)+(nb_include*2))); + my_argv = alloc(SIZEOF(char *) * (22 + (nb_exclude*2)+(nb_include*2))); cmd = vstralloc(libexecdir, "/", "runtar", versionsuffix(), NULL); info_tapeheader(); start_index(options->createindex, dumpout, mesgf, indexf, indexcmd); + my_argv[i++] = "runtar"; + if (g_options->config) + my_argv[i++] = g_options->config; + else + my_argv[i++] = "NOCONFIG"; my_argv[i++] = "gtar"; my_argv[i++] = "--create"; my_argv[i++] = "--file"; @@ -507,14 +550,14 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in my_argv[i++] = "--directory"; my_argv[i++] = dirname; my_argv[i++] = "--one-file-system"; -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR - my_argv[i++] = "--listed-incremental"; - my_argv[i++] = incrname; -#else - my_argv[i++] = "--incremental"; - my_argv[i++] = "--newer"; - my_argv[i++] = dumptimestr; -#endif + if (gnutar_list_dir && incrname) { + my_argv[i++] = "--listed-incremental"; + my_argv[i++] = incrname; + } else { + my_argv[i++] = "--incremental"; + my_argv[i++] = "--newer"; + my_argv[i++] = dumptimestr; + } #ifdef ENABLE_GNUTAR_ATIME_PRESERVE /* --atime-preserve causes gnutar to call * utime() after reading files in order to @@ -552,6 +595,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in cmd, (long)dumppid)); + amfree(qdisk); amfree(dirname); amfree(cmd); amfree(indexcmd); @@ -568,11 +612,11 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in aclose(indexf); } -static void end_backup(goterror) -int goterror; +static void +end_backup( + int goterror) { if(!options->no_record && !goterror) { -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR if (incrname != NULL && strlen(incrname) > 4) { char *nodotnew; @@ -585,11 +629,10 @@ int goterror; amfree(nodotnew); amfree(incrname); } -#endif - if(!start_amandates(1)) { + if(!start_amandates(amandates_file, 1)) { fprintf(stderr, "%s: warning [opening %s: %s]", get_pname(), - AMANDATES_FILE, strerror(errno)); + amandates_file, strerror(errno)); } else { amandates_updateone(cur_disk, cur_level, cur_dumptime); diff --git a/client-src/sendbackup.c b/client-src/sendbackup.c index e824e1e..5af8dce 100644 --- a/client-src/sendbackup.c +++ b/client-src/sendbackup.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: sendbackup.c,v 1.77 2006/03/09 16:51:41 martinea Exp $ + * $Id: sendbackup.c,v 1.88 2006/07/25 18:27:56 martinea Exp $ * * common code for the sendbackup-* programs. */ @@ -38,14 +38,15 @@ #include "arglist.h" #include "getfsent.h" #include "version.h" +#include "clientconf.h" #define TIMEOUT 30 -int comppid = -1; -int dumppid = -1; -int tarpid = -1; -int encpid = -1; -int indexpid = -1; +pid_t comppid = (pid_t)-1; +pid_t dumppid = (pid_t)-1; +pid_t tarpid = (pid_t)-1; +pid_t encpid = (pid_t)-1; +pid_t indexpid = (pid_t)-1; char *errorstr = NULL; int datafd; @@ -53,6 +54,7 @@ int mesgfd; int indexfd; option_t *options; +g_option_t *g_options = NULL; long dump_size = -1; @@ -60,22 +62,27 @@ backup_program_t *program = NULL; static am_feature_t *our_features = NULL; static char *our_feature_string = NULL; -static g_option_t *g_options = NULL; +static char *amandad_auth = NULL; /* local functions */ -int main P((int argc, char **argv)); -char *optionstr P((option_t *options)); -char *childstr P((int pid)); -int check_status P((int pid, amwait_t w)); - -int pipefork P((void (*func) P((void)), char *fname, int *stdinfd, - int stdoutfd, int stderrfd)); -void parse_backup_messages P((int mesgin)); -static void process_dumpline P((char *str)); -static void save_fd P((int *, int)); - -char *optionstr(options) -option_t *options; +int main(int argc, char **argv); +char *optionstr(option_t *options); +char *childstr(pid_t pid); +int check_status(pid_t pid, amwait_t w); + +pid_t pipefork(void (*func)(void), char *fname, int *stdinfd, + int stdoutfd, int stderrfd); +void parse_backup_messages(int mesgin); +static void process_dumpline(char *str); +static void save_fd(int *, int); + +double first_num(char *str); + + + +char * +optionstr( + option_t * options) { static char *optstr = NULL; char *compress_opt; @@ -142,6 +149,7 @@ option_t *options; strappend(exclude_list_opt, exc); } } + amfree(exc); optstr = newvstralloc(optstr, compress_opt, encrypt_opt, @@ -162,16 +170,23 @@ option_t *options; } -int main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char ** argv) { int interactive = 0; - int level, mesgpipe[2]; - char *prog, *disk, *amdevice, *dumpdate, *stroptions; + int level = 0; + int mesgpipe[2]; + char *prog, *dumpdate, *stroptions; + char *disk = NULL; + char *qdisk = NULL; + char *amdevice = NULL; + char *qamdevice = NULL; char *line = NULL; char *err_extra = NULL; char *s; + char *conffile; int i; int ch; unsigned long malloc_hist_1, malloc_size_1; @@ -179,7 +194,8 @@ char **argv; /* initialize */ - safe_fd(DATA_FD_OFFSET, DATA_FD_COUNT); + safe_fd(DATA_FD_OFFSET, DATA_FD_COUNT*2); + safe_cd(); set_pname("sendbackup"); @@ -187,17 +203,38 @@ char **argv; /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); + /* Don't die when interrupt received */ + signal(SIGINT, SIG_IGN); + malloc_size_1 = malloc_inuse(&malloc_hist_1); - interactive = (argc > 1 && strcmp(argv[1],"-t") == 0); + if(argc > 1 && strcmp(argv[1],"-t") == 0) { + interactive = 1; + argc--; + argv++; + } else { + interactive = 0; + } + erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG); - dbopen(); + dbopen(DBG_SUBDIR_CLIENT); startclock(); dbprintf(("%s: version %s\n", get_pname(), version())); + if(argc > 2 && strcmp(argv[1], "amandad") == 0) { + amandad_auth = stralloc(argv[2]); + } + our_features = am_init_feature_set(); our_feature_string = am_feature_to_string(our_features); + conffile = vstralloc(CONFIG_DIR, "/", "amanda-client.conf", NULL); + if (read_clientconf(conffile) > 0) { + error("error reading conffile: %s", conffile); + /*NOTREACHED*/ + } + amfree(conffile); + if(interactive) { /* * In interactive (debug) mode, the backup data is sent to @@ -211,17 +248,20 @@ char **argv; prog = NULL; disk = NULL; + qdisk = NULL; amdevice = NULL; dumpdate = NULL; stroptions = NULL; for(; (line = agets(stdin)) != NULL; free(line)) { + if (line[0] == '\0') + continue; if(interactive) { fprintf(stderr, "%s> ", get_pname()); fflush(stderr); } #define sc "OPTIONS " - if(strncmp(line, sc, sizeof(sc)-1) == 0) { + if(strncmp(line, sc, SIZEOF(sc)-1) == 0) { #undef sc g_options = parse_g_options(line+8, 1); if(!g_options->hostname) { @@ -229,6 +269,18 @@ char **argv; gethostname(g_options->hostname, MAX_HOSTNAME_LENGTH); g_options->hostname[MAX_HOSTNAME_LENGTH] = '\0'; } + + if (g_options->config) { + conffile = vstralloc(CONFIG_DIR, "/", g_options->config, "/", + "amanda-client.conf", NULL); + if (read_clientconf(conffile) > 0) { + error("error reading conffile: %s", conffile); + /*NOTREACHED*/ + } + amfree(conffile); + + dbrename(g_options->config, DBG_SUBDIR_CLIENT); + } continue; } @@ -237,6 +289,7 @@ char **argv; goto err; } + dbprintf((" sendbackup req: <%s>\n", line)); s = line; ch = *s++; @@ -255,11 +308,15 @@ char **argv; err_extra = "no disk name"; goto err; /* no disk name */ } + amfree(disk); - disk = s - 1; - skip_non_whitespace(s, ch); + amfree(qdisk); + qdisk = s - 1; + ch = *qdisk; + skip_quoted_string(s, ch); s[-1] = '\0'; - disk = stralloc(disk); + qdisk = stralloc(qdisk); + disk = unquote_string(qdisk); skip_whitespace(s, ch); /* find the device or level */ if (ch == '\0') { @@ -269,6 +326,7 @@ char **argv; if(!isdigit((int)s[-1])) { amfree(amdevice); + amfree(qamdevice); amdevice = s - 1; skip_non_whitespace(s, ch); s[-1] = '\0'; @@ -278,7 +336,7 @@ char **argv; else { amdevice = stralloc(disk); } - + qamdevice = quote_string(amdevice); /* find the level number */ if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) { err_extra = "bad level"; @@ -303,11 +361,11 @@ char **argv; goto err; /* no options */ } #define sc "OPTIONS " - if(strncmp(s - 1, sc, sizeof(sc)-1) != 0) { + if(strncmp(s - 1, sc, SIZEOF(sc)-1) != 0) { err_extra = "no OPTIONS keyword"; goto err; /* no options */ } - s += sizeof(sc)-1; + s += SIZEOF(sc)-1; ch = s[-1]; #undef sc skip_whitespace(s, ch); /* find the options string */ @@ -320,9 +378,18 @@ char **argv; } amfree(line); + if (prog == NULL || + disk == NULL || + amdevice == NULL || + dumpdate == NULL || + stroptions == NULL) { + err_extra = "no valid sendbackup request"; + goto err; + } + dbprintf((" parsed request as: program `%s'\n", prog)); - dbprintf((" disk `%s'\n", disk)); - dbprintf((" device `%s'\n", amdevice)); + dbprintf((" disk `%s'\n", qdisk)); + dbprintf((" device `%s'\n", qamdevice)); dbprintf((" level %d\n", level)); dbprintf((" since %s\n", dumpdate)); dbprintf((" options `%s'\n", stroptions)); @@ -334,6 +401,7 @@ char **argv; } if (programs[i] == NULL) { error("ERROR [%s: unknown program %s]", get_pname(), prog); + /*NOTREACHED*/ } program = programs[i]; @@ -341,14 +409,23 @@ char **argv; if(!interactive) { datafd = DATA_FD_OFFSET + 0; - mesgfd = DATA_FD_OFFSET + 1; - indexfd = DATA_FD_OFFSET + 2; + mesgfd = DATA_FD_OFFSET + 2; + indexfd = DATA_FD_OFFSET + 4; } if (!options->createindex) indexfd = -1; + if(options->auth && amandad_auth) { + if(strcasecmp(options->auth, amandad_auth) != 0) { + printf("ERROR [client configured for auth=%s while server requested '%s']\n", + amandad_auth, options->auth); + exit(-1); + } + } + printf("CONNECT DATA %d MESG %d INDEX %d\n", - datafd, mesgfd, indexfd); + DATA_FD_OFFSET, DATA_FD_OFFSET+1, + indexfd == -1 ? -1 : DATA_FD_OFFSET+2); printf("OPTIONS "); if(am_has_feature(g_options->features, fe_rep_options_features)) { printf("features=%s;", our_feature_string); @@ -372,6 +449,7 @@ char **argv; s = strerror(errno); error("ERROR [%s: open of /dev/null for debug data stream: %s]\n", get_pname(), s); + /*NOTREACHED*/ } mesgfd = 2; indexfd = 1; @@ -396,6 +474,7 @@ char **argv; if(pipe(mesgpipe) == -1) { error("error [opening mesg pipe: %s]", strerror(errno)); + /*NOTREACHED*/ } program->start_backup(g_options->hostname, disk, amdevice, level, dumpdate, datafd, mesgpipe[1], @@ -406,7 +485,9 @@ char **argv; amfree(prog); amfree(disk); + amfree(qdisk); amfree(amdevice); + amfree(qamdevice); amfree(dumpdate); amfree(stroptions); amfree(our_feature_string); @@ -438,12 +519,15 @@ char **argv; return 1; } -char *childstr(pid) -int pid; + /* * Returns a string for a child process. Checks the saved dump and * compress pids to see which it is. */ + +char * +childstr( + pid_t pid) { if(pid == dumppid) return program->backup_name; if(pid == comppid) return "compress"; @@ -453,14 +537,16 @@ int pid; } -int check_status(pid, w) -int pid; -amwait_t w; /* * Determine if the child return status really indicates an error. * If so, add the error message to the error string; more than one * child can have an error. */ + +int +check_status( + pid_t pid, + amwait_t w) { char *thiserr = NULL; char *str; @@ -527,10 +613,10 @@ amwait_t w; } if(ret == 0) { - snprintf(number, sizeof(number), "%d", sig); + snprintf(number, SIZEOF(number), "%d", sig); thiserr = vstralloc(str, " got signal ", number, NULL); } else { - snprintf(number, sizeof(number), "%d", ret); + snprintf(number, SIZEOF(number), "%d", ret); thiserr = vstralloc(str, " returned ", number, NULL); } @@ -546,9 +632,11 @@ amwait_t w; } -/* Send header info to the message file. -*/ -void info_tapeheader() +/* + *Send header info to the message file. + */ +void +info_tapeheader(void) { fprintf(stderr, "%s: info BACKUP=%s\n", get_pname(), program->backup_name); @@ -562,7 +650,7 @@ void info_tapeheader() #endif ); - fprintf(stderr, "%s -f... -\n", program->restore_name); + fprintf(stderr, "%s -f - ...\n", program->restore_name); if (options->compress == COMPR_FAST || options->compress == COMPR_BEST) fprintf(stderr, "%s: info COMPRESS_SUFFIX=%s\n", @@ -571,24 +659,29 @@ void info_tapeheader() fprintf(stderr, "%s: info end\n", get_pname()); } -int pipefork(func, fname, stdinfd, stdoutfd, stderrfd) -void (*func) P((void)); -char *fname; -int *stdinfd; -int stdoutfd, stderrfd; +pid_t +pipefork( + void (*func)(void), + char * fname, + int * stdinfd, + int stdoutfd, + int stderrfd) { - int pid, inpipe[2]; + int inpipe[2]; + pid_t pid; dbprintf(("%s: forking function %s in pipeline\n", debug_prefix_time(NULL), fname)); if(pipe(inpipe) == -1) { error("error [open pipe to %s: %s]", fname, strerror(errno)); + /*NOTREACHED*/ } switch(pid = fork()) { case -1: error("error [fork %s: %s]", fname, strerror(errno)); + /*NOTREACHED*/ default: /* parent process */ aclose(inpipe[0]); /* close input side of pipe */ *stdinfd = inpipe[1]; @@ -599,27 +692,32 @@ int stdoutfd, stderrfd; if(dup2(inpipe[0], 0) == -1) { error("error [fork %s: dup2(%d, in): %s]", fname, inpipe[0], strerror(errno)); + /*NOTRACHED*/ } if(dup2(stdoutfd, 1) == -1) { error("error [fork %s: dup2(%d, out): %s]", fname, stdoutfd, strerror(errno)); + /*NOTRACHED*/ } if(dup2(stderrfd, 2) == -1) { error("error [fork %s: dup2(%d, err): %s]", fname, stderrfd, strerror(errno)); + /*NOTRACHED*/ } func(); exit(0); - /* NOTREACHED */ + /*NOTREACHED*/ } return pid; } -void parse_backup_messages(mesgin) -int mesgin; +void +parse_backup_messages( + int mesgin) { - int goterror, wpid; + int goterror; + pid_t wpid; amwait_t retstat; char *line; @@ -632,6 +730,7 @@ int mesgin; if(errno) { error("error [read mesg pipe: %s]", strerror(errno)); + /*NOTREACHED*/ } while((wpid = wait(&retstat)) != -1) { @@ -640,8 +739,10 @@ int mesgin; if(errorstr) { error("error [%s]", errorstr); + /*NOTREACHED*/ } else if(dump_size == -1) { error("error [no backup size line]"); + /*NOTREACHED*/ } program->end_backup(goterror); @@ -651,13 +752,13 @@ int mesgin; } -double first_num P((char *str)); - -double first_num(str) -char *str; /* * Returns the value of the first integer in a string. */ + +double +first_num( + char * str) { char *num; int ch; @@ -669,15 +770,16 @@ char *str; while(isdigit(ch) || ch == '.') ch = *str++; str[-1] = '\0'; d = atof(num); - str[-1] = ch; + str[-1] = (char)ch; return d; } -static void process_dumpline(str) -char *str; +static void +process_dumpline( + char * str) { - regex_t *rp; + amregex_t *rp; char *type; char startchr; @@ -724,30 +826,30 @@ char *str; } -/* start_index. Creates an index file from the output of dump/tar. - It arranges that input is the fd to be written by the dump process. - If createindex is not enabled, it does nothing. If it is not, a - new process will be created that tees input both to a pipe whose - read fd is dup2'ed input and to a program that outputs an index - file to `index'. - - make sure that the chat from restore doesn't go to stderr cause - this goes back to amanda which doesn't expect to see it - (2>/dev/null should do it) - - Originally by Alan M. McIvor, 13 April 1996 - - Adapted by Alexandre Oliva, 1 May 1997 - - This program owes a lot to tee.c from GNU sh-utils and dumptee.c - from the DeeJay backup package. - -*/ - -static volatile int index_finished = 0; +/* + * start_index. Creates an index file from the output of dump/tar. + * It arranges that input is the fd to be written by the dump process. + * If createindex is not enabled, it does nothing. If it is not, a + * new process will be created that tees input both to a pipe whose + * read fd is dup2'ed input and to a program that outputs an index + * file to `index'. + * + * make sure that the chat from restore doesn't go to stderr cause + * this goes back to amanda which doesn't expect to see it + * (2>/dev/null should do it) + * + * Originally by Alan M. McIvor, 13 April 1996 + * + * Adapted by Alexandre Oliva, 1 May 1997 + * + * This program owes a lot to tee.c from GNU sh-utils and dumptee.c + * from the DeeJay backup package. + */ -static void save_fd(fd, min) -int *fd, min; +static void +save_fd( + int * fd, + int min) { int origfd = *fd; @@ -763,9 +865,13 @@ int *fd, min; debug_prefix_time(NULL), origfd, *fd)); } -void start_index(createindex, input, mesg, index, cmd) -int createindex, input, mesg, index; -char *cmd; +void +start_index( + int createindex, + int input, + int mesg, + int index, + char * cmd) { int pipefd[2]; FILE *pipe_fp; @@ -776,16 +882,19 @@ char *cmd; if (pipe(pipefd) != 0) { error("creating index pipe: %s", strerror(errno)); + /*NOTREACHED*/ } switch(indexpid = fork()) { case -1: error("forking index tee process: %s", strerror(errno)); + /*NOTREACHED*/ default: aclose(pipefd[0]); if (dup2(pipefd[1], input) == -1) { error("dup'ping index tee output: %s", strerror(errno)); + /*NOTREACHED*/ } aclose(pipefd[1]); return; @@ -811,22 +920,24 @@ char *cmd; if ((pipe_fp = popen(cmd, "w")) == NULL) { error("couldn't start index creator [%s]", strerror(errno)); + /*NOTREACHED*/ } dbprintf(("%s: started index creator: \"%s\"\n", debug_prefix_time(NULL), cmd)); while(1) { char buffer[BUFSIZ], *ptr; - int bytes_read; - int bytes_written; - int just_written; + ssize_t bytes_read; + size_t bytes_written; + ssize_t just_written; do { - bytes_read = read(0, buffer, sizeof(buffer)); + bytes_read = read(0, buffer, SIZEOF(buffer)); } while ((bytes_read < 0) && ((errno == EINTR) || (errno == EAGAIN))); if (bytes_read < 0) { error("index tee cannot read [%s]", strerror(errno)); + /*NOTREACHED*/ } if (bytes_read == 0) @@ -835,9 +946,9 @@ char *cmd; /* write the stuff to the subprocess */ ptr = buffer; bytes_written = 0; - just_written = fullwrite(fileno(pipe_fp), ptr, bytes_read); + just_written = fullwrite(fileno(pipe_fp), ptr, (size_t)bytes_read); if (just_written < 0) { - /* the signal handler may have assigned to index_finished + /* * just as we waited for write() to complete. */ if (errno != EPIPE) { @@ -853,10 +964,10 @@ char *cmd; occurs */ ptr = buffer; bytes_written = 0; - just_written = fullwrite(3, ptr, bytes_read); + just_written = fullwrite(3, ptr, (size_t)bytes_read); if (just_written < 0) { error("index tee cannot write [%s]", strerror(errno)); - /* NOTREACHED */ + /*NOTREACHED*/ } else { bytes_written += just_written; ptr += just_written; diff --git a/client-src/sendbackup.h b/client-src/sendbackup.h index ee2a836..2a4cdb8 100644 --- a/client-src/sendbackup.h +++ b/client-src/sendbackup.h @@ -24,17 +24,21 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: sendbackup.h,v 1.18 2005/12/09 03:22:52 paddy_s Exp $ + * $Id: sendbackup.h,v 1.20 2006/07/25 18:10:07 martinea Exp $ * * a few common decls for the sendbackup-* sources */ +#ifndef SENDBACKUP_H +#define SENDBACKUP_H + #include "amanda.h" #include "pipespawn.h" #include "client_util.h" +#include "amandad.h" -void info_tapeheader P((void)); -void start_index P((int createindex, int input, int mesg, - int index, char *cmd)); +void info_tapeheader(void); +void start_index(int createindex, int input, int mesg, + int index, char *cmd); /* * Dump output lines are scanned for two types of regex matches. @@ -61,24 +65,25 @@ typedef struct regex_s { int srcline; int scale; /* only used for size lines */ dmpline_t typ; -} regex_t; +} amregex_t; #define AM_NORMAL_RE(re) {(re), __LINE__, 0, DMP_NORMAL} #define AM_STRANGE_RE(re) {(re), __LINE__, 0, DMP_STRANGE} #define AM_SIZE_RE(re,s) {(re), __LINE__, (s), DMP_SIZE} #define AM_ERROR_RE(re) {(re), __LINE__, 0, DMP_ERROR} -extern int comppid, dumppid, encpid, tarpid; -extern int indexpid; +extern pid_t comppid, dumppid, encpid, tarpid; +extern pid_t indexpid; extern option_t *options; +extern g_option_t *g_options; typedef struct backup_program_s { char *name, *backup_name, *restore_name; - regex_t *re_table; - void (*start_backup) P((char *host, char *disk, char *amdevice, int level, char *dumpdate, - int dataf, int mesgf, int indexf)); - void (*end_backup) P((int goterror)); + amregex_t *re_table; + void (*start_backup)(char *host, char *disk, char *amdevice, int level, char *dumpdate, int dataf, int mesgf, int indexf); + void (*end_backup)(int goterror); } backup_program_t; extern backup_program_t *programs[], *program; +#endif /* !SENDBACKUP_H */ diff --git a/client-src/sendsize.c b/client-src/sendsize.c index dc8a67d..bf3595a 100644 --- a/client-src/sendsize.c +++ b/client-src/sendsize.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: sendsize.c,v 1.152 2006/03/09 16:51:41 martinea Exp $ + * $Id: sendsize.c,v 1.171 2006/08/24 01:57:15 paddy_s Exp $ * * send estimated backup sizes using dump */ @@ -38,6 +38,8 @@ #include "getfsent.h" #include "version.h" #include "client_util.h" +#include "clientconf.h" +#include "amandad.h" #ifdef SAMBA_CLIENT #include "findpass.h" @@ -76,8 +78,11 @@ typedef struct level_estimates_s { typedef struct disk_estimates_s { struct disk_estimates_s *next; char *amname; + char *qamname; char *amdevice; + char *qamdevice; char *dirname; + char *qdirname; char *program; char *calcprog; int program_is_wrapper; @@ -95,25 +100,27 @@ static char *our_feature_string = NULL; static g_option_t *g_options = NULL; /* local functions */ -int main P((int argc, char **argv)); -void add_diskest P((char *disk, char *amdevice, int level, int spindle, +int main(int argc, char **argv); +void add_diskest(char *disk, char *amdevice, int level, int spindle, int program_is_wrapper, char *prog, char *calcprog, - option_t *options)); -void calc_estimates P((disk_estimates_t *est)); -void free_estimates P((disk_estimates_t *est)); -void dump_calc_estimates P((disk_estimates_t *)); -void smbtar_calc_estimates P((disk_estimates_t *)); -void gnutar_calc_estimates P((disk_estimates_t *)); -void wrapper_calc_estimates P((disk_estimates_t *)); -void generic_calc_estimates P((disk_estimates_t *)); - - -int main(argc, argv) -int argc; -char **argv; + option_t *options); +void calc_estimates(disk_estimates_t *est); +void free_estimates(disk_estimates_t *est); +void dump_calc_estimates(disk_estimates_t *); +void star_calc_estimates(disk_estimates_t *); +void smbtar_calc_estimates(disk_estimates_t *); +void gnutar_calc_estimates(disk_estimates_t *); +void wrapper_calc_estimates(disk_estimates_t *); +void generic_calc_estimates(disk_estimates_t *); + + +int +main( + int argc, + char ** argv) { int level, spindle; - char *prog, *calcprog, *disk, *amdevice, *dumpdate; + char *prog, *calcprog, *dumpdate; option_t *options = NULL; int program_is_wrapper; disk_estimates_t *est; @@ -123,12 +130,23 @@ char **argv; char *s, *fp; int ch; char *err_extra = NULL; - unsigned long malloc_hist_1, malloc_size_1; - unsigned long malloc_hist_2, malloc_size_2; int done; int need_wait; int dumpsrunning; + char *disk = NULL; + char *qdisk = NULL; + char *qlist = NULL; + char *amdevice = NULL; + char *qamdevice = NULL; + char *conffile; + char *amandates_file; +#if defined(USE_DBMALLOC) + unsigned long malloc_hist_1, malloc_size_1; + unsigned long malloc_hist_2, malloc_size_2; +#endif + (void)argc; /* Quiet unused parameter warning */ + (void)argv; /* Quiet unused parameter warning */ /* initialize */ @@ -140,10 +158,12 @@ char **argv; /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); +#if defined(USE_DBMALLOC) malloc_size_1 = malloc_inuse(&malloc_hist_1); +#endif erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG); - dbopen(); + dbopen(DBG_SUBDIR_CLIENT); startclock(); dbprintf(("%s: version %s\n", get_pname(), version())); @@ -152,13 +172,24 @@ char **argv; set_debug_prefix_pid(getpid()); + conffile = vstralloc(CONFIG_DIR, "/", "amanda-client.conf", NULL); + if (read_clientconf(conffile) > 0) { + error("error reading conffile: %s", conffile); + /*NOTREACHED*/ + } + amfree(conffile); + /* handle all service requests */ - start_amandates(0); + amandates_file = client_getconf_str(CLN_AMANDATES); + if(!start_amandates(amandates_file, 0)) + error("error [opening %s: %s]", amandates_file, strerror(errno)); for(; (line = agets(stdin)) != NULL; free(line)) { + if (line[0] == '\0') + continue; #define sc "OPTIONS " - if(strncmp(line, sc, sizeof(sc)-1) == 0) { + if(strncmp(line, sc, SIZEOF(sc)-1) == 0) { #undef sc g_options = parse_g_options(line+8, 1); if(!g_options->hostname) { @@ -179,6 +210,19 @@ char **argv; } printf("\n"); fflush(stdout); + + if (g_options->config) { + conffile = vstralloc(CONFIG_DIR, "/", g_options->config, "/", + "amanda-client.conf", NULL); + if (read_clientconf(conffile) > 0) { + error("error reading conffile: %s", conffile); + /*NOTREACHED*/ + } + amfree(conffile); + + dbrename(g_options->config, DBG_SUBDIR_CLIENT); + } + continue; } @@ -187,7 +231,7 @@ char **argv; skip_whitespace(s, ch); /* find the program name */ if(ch == '\0') { - err_extra = "no program name"; + err_extra = stralloc("no program name"); goto err; /* no program name */ } prog = s - 1; @@ -209,7 +253,7 @@ char **argv; if(strncmp(prog, "CALCSIZE", 8) == 0) { skip_whitespace(s, ch); /* find the program name */ if(ch == '\0') { - err_extra = "no program name"; + err_extra = stralloc("no program name"); goto err; } calcprog = s - 1; @@ -222,56 +266,71 @@ char **argv; skip_whitespace(s, ch); /* find the disk name */ if(ch == '\0') { - err_extra = "no disk name"; + err_extra = stralloc("no disk name"); goto err; /* no disk name */ } - disk = s - 1; - skip_non_whitespace(s, ch); - s[-1] = '\0'; + + if (qdisk != NULL) + amfree(qdisk); + if (disk != NULL) + amfree(disk); + + fp = s - 1; + skip_quoted_string(s, ch); + s[-1] = '\0'; /* terminate the disk name */ + qdisk = stralloc(fp); + disk = unquote_string(qdisk); skip_whitespace(s, ch); /* find the device or level */ if (ch == '\0') { - err_extra = "bad level"; + err_extra = stralloc("bad level"); goto err; } if(!isdigit((int)s[-1])) { fp = s - 1; - skip_non_whitespace(s, ch); + skip_quoted_string(s, ch); s[-1] = '\0'; - amdevice = stralloc(fp); + qamdevice = stralloc(fp); + amdevice = unquote_string(qamdevice); skip_whitespace(s, ch); /* find level number */ } else { amdevice = stralloc(disk); + qamdevice = stralloc(qdisk); } /* find the level number */ if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) { - err_extra = "bad level"; + err_extra = stralloc("bad level"); goto err; /* bad level */ } + if (level < 0 || level >= DUMP_LEVELS) { + err_extra = stralloc("bad level"); + goto err; + } skip_integer(s, ch); skip_whitespace(s, ch); /* find the dump date */ if(ch == '\0') { - err_extra = "no dumpdate"; + err_extra = stralloc("no dumpdate"); goto err; /* no dumpdate */ } dumpdate = s - 1; skip_non_whitespace(s, ch); s[-1] = '\0'; + (void)dumpdate; /* XXX: Set but not used */ spindle = 0; /* default spindle */ skip_whitespace(s, ch); /* find the spindle */ if(ch != '\0') { if(sscanf(s - 1, "%d", &spindle) != 1) { - err_extra = "bad spindle"; + err_extra = stralloc("bad spindle"); goto err; /* bad spindle */ } skip_integer(s, ch); - skip_whitespace(s, ch); /* find the exclusion list */ + skip_whitespace(s, ch); /* find the parameters */ if(ch != '\0') { if(strncmp(s-1, "OPTIONS |;",10) == 0) { options = parse_options(s + 8, @@ -281,32 +340,61 @@ char **argv; 0); } else { - options = alloc(sizeof(option_t)); + options = alloc(SIZEOF(option_t)); init_options(options); - if(strncmp(s-1, "exclude-file=", 13) == 0) { - options->exclude_file = - append_sl(options->exclude_file, s+12); - } - if(strncmp(s-1, "exclude-list=", 13) == 0) { - options->exclude_list = - append_sl(options->exclude_list, s+12); - } - - skip_non_whitespace(s, ch); - if(ch) { - err_extra = "extra text at end"; - goto err; /* should have gotten to end */ + while (ch != '\0') { + if(strncmp(s-1, "exclude-file=", 13) == 0) { + qlist = unquote_string(s+12); + options->exclude_file = + append_sl(options->exclude_file, qlist); + amfree(qlist); + } else if(strncmp(s-1, "exclude-list=", 13) == 0) { + options->exclude_list = + append_sl(options->exclude_list, qlist); + qlist = unquote_string(s+12); + amfree(qlist); + } else if(strncmp(s-1, "include-file=", 13) == 0) { + options->include_file = + append_sl(options->include_file, qlist); + qlist = unquote_string(s+12); + amfree(qlist); + } else if(strncmp(s-1, "include-list=", 13) == 0) { + options->include_list = + append_sl(options->include_list, qlist); + qlist = unquote_string(s+12); + amfree(qlist); + } else { + err_extra = vstralloc("Invalid parameter (", + s-1, ")", NULL); + goto err; /* should have gotten to end */ + } + skip_quoted_string(s, ch); + skip_whitespace(s, ch); /* find the inclusion list */ + amfree(qlist); } } } else { - options = alloc(sizeof(option_t)); + options = alloc(SIZEOF(option_t)); init_options(options); } } + else { + options = alloc(SIZEOF(option_t)); + init_options(options); + } + /*@ignore@*/ add_diskest(disk, amdevice, level, spindle, program_is_wrapper, prog, calcprog, options); + /*@end@*/ + amfree(disk); + amfree(qdisk); amfree(amdevice); + amfree(qamdevice); + } + if (g_options == NULL) { + error("Missing OPTIONS line in sendsize input\n"); + /*NOTREACHED*/ } amfree(line); @@ -333,6 +421,7 @@ char **argv; child_pid = wait(&child_status); if(child_pid == -1) { error("wait failed: %s", strerror(errno)); + /*NOTREACHED*/ } if(WIFSIGNALED(child_status)) { dbprintf(("%s: child %ld terminated with signal %d\n", @@ -419,6 +508,7 @@ char **argv; exit(0); } else if(est->child == -1) { error("calc_estimates fork failed: %s", strerror(errno)); + /*NOTREACHED*/ } dumpsrunning++; /* parent */ } @@ -440,13 +530,13 @@ char **argv; amfree(g_options->str); amfree(g_options); +#if defined(USE_DBMALLOC) malloc_size_2 = malloc_inuse(&malloc_hist_2); if(malloc_size_1 != malloc_size_2) { -#if defined(USE_DBMALLOC) malloc_list(dbfd(), malloc_hist_1, malloc_hist_2); -#endif } +#endif dbclose(); return 0; @@ -456,21 +546,33 @@ char **argv; debug_prefix_time(NULL), err_extra ? ": " : "", err_extra ? err_extra : "")); + amfree(err_extra); dbclose(); return 1; } -void add_diskest(disk, amdevice, level, spindle, program_is_wrapper, prog, calcprog, options) -char *disk, *amdevice, *prog, *calcprog; -int level, spindle, program_is_wrapper; -option_t *options; +void +add_diskest( + char * disk, + char * amdevice, + int level, + int spindle, + int program_is_wrapper, + char * prog, + char * calcprog, + option_t * options) { disk_estimates_t *newp, *curp; amandates_t *amdp; int dumplev, estlev; time_t dumpdate; + if (level < 0) + level = 0; + if (level >= DUMP_LEVELS) + level = DUMP_LEVELS - 1; + for(curp = est_list; curp != NULL; curp = curp->next) { if(strcmp(curp->amname, disk) == 0) { /* already have disk info, just note the level request */ @@ -488,13 +590,16 @@ option_t *options; } } - newp = (disk_estimates_t *) alloc(sizeof(disk_estimates_t)); - memset(newp, 0, sizeof(*newp)); + newp = (disk_estimates_t *) alloc(SIZEOF(disk_estimates_t)); + memset(newp, 0, SIZEOF(*newp)); newp->next = est_list; est_list = newp; newp->amname = stralloc(disk); + newp->qamname = quote_string(disk); newp->amdevice = stralloc(amdevice); + newp->qamdevice = quote_string(amdevice); newp->dirname = amname_to_dirname(newp->amdevice); + newp->qdirname = quote_string(newp->dirname); newp->program = stralloc(prog); if(calcprog != NULL) newp->calcprog = stralloc(calcprog); @@ -520,12 +625,16 @@ option_t *options; } -void free_estimates(est) -disk_estimates_t *est; +void +free_estimates( + disk_estimates_t * est) { amfree(est->amname); + amfree(est->qamname); amfree(est->amdevice); + amfree(est->qamdevice); amfree(est->dirname); + amfree(est->qdirname); amfree(est->program); if(est->options) { free_sl(est->options->exclude_file); @@ -543,13 +652,14 @@ disk_estimates_t *est; * */ -void calc_estimates(est) -disk_estimates_t *est; +void +calc_estimates( + disk_estimates_t * est) { - dbprintf(("%s: calculating for amname '%s', dirname '%s', spindle %d\n", + dbprintf(("%s: calculating for amname %s, dirname %s, spindle %d\n", debug_prefix_time(NULL), - est->amname, est->dirname, est->spindle)); - + est->qamname, est->qdirname, est->spindle)); + if(est->program_is_wrapper == 1) wrapper_calc_estimates(est); else @@ -573,14 +683,14 @@ disk_estimates_t *est; if (est->amdevice[0] == '/' && est->amdevice[1] == '/') dbprintf(("%s: Can't use CALCSIZE for samba estimate: %s %s\n", debug_prefix_time(NULL), - est->amname, est->dirname)); + est->qamname, est->qdirname)); else #endif generic_calc_estimates(est); - dbprintf(("%s: done with amname '%s', dirname '%s', spindle %d\n", + dbprintf(("%s: done with amname %s dirname %s spindle %d\n", debug_prefix_time(NULL), - est->amname, est->dirname, est->spindle)); + est->qamname, est->qdirname, est->spindle)); } /* @@ -589,33 +699,40 @@ disk_estimates_t *est; */ /* local functions */ -long getsize_dump P((char *disk, char *amdevice, int level, option_t *options)); -long getsize_smbtar P((char *disk, char *amdevice, int level, option_t *options)); -long getsize_gnutar P((char *disk, char *amdevice, int level, - option_t *options, time_t dumpsince)); -long getsize_wrapper P((char *program, char *disk, char *amdevice, int level, - option_t *options, time_t dumpsince)); -long handle_dumpline P((char *str)); -double first_num P((char *str)); - -void wrapper_calc_estimates(est) -disk_estimates_t *est; +off_t getsize_dump(char *disk, char *amdevice, int level, option_t *options); +off_t getsize_star(char *disk, char *amdevice, int level, + option_t *options, time_t dumpsince); +off_t getsize_smbtar(char *disk, char *amdevice, int level, option_t *options); +off_t getsize_gnutar(char *disk, char *amdevice, int level, + option_t *options, time_t dumpsince); +off_t getsize_wrapper(char *program, char *disk, char *amdevice, int level, + option_t *options, time_t dumpsince); +off_t handle_dumpline(char *str); +double first_num(char *str); + +void +wrapper_calc_estimates( + disk_estimates_t * est) { int level; - long size; + off_t size; for(level = 0; level < DUMP_LEVELS; level++) { if (est->est[level].needestimate) { dbprintf(("%s: getting size via wrapper for %s level %d\n", - debug_prefix_time(NULL), est->amname, level)); - size = getsize_wrapper(est->program, est->amname, est->amdevice, level, est->options, - est->est[level].dumpsince); + debug_prefix_time(NULL), est->qamname, level)); + size = getsize_wrapper(est->program, est->amname, est->amdevice, + level, est->options, est->est[level].dumpsince); amflock(1, "size"); - fseek(stdout, (off_t)0, SEEK_SET); + if (fseek(stdout, 0L, SEEK_END) < 0) { + dbprintf(("wrapper_calc_estimates: warning - seek failed: %s\n", + strerror(errno))); + } - printf("%s %d SIZE %ld\n", est->amname, level, size); + printf("%s %d SIZE " OFF_T_FMT "\n", est->qamname, level, + (OFF_T_FMT_TYPE)size); fflush(stdout); amfunlock(1, "size"); @@ -624,28 +741,36 @@ disk_estimates_t *est; } -void generic_calc_estimates(est) -disk_estimates_t *est; +void +generic_calc_estimates( + disk_estimates_t * est) { int pipefd = -1, nullfd = -1; char *cmd; - char *my_argv[DUMP_LEVELS*2+20]; + char *my_argv[DUMP_LEVELS*2+22]; char number[NUM_STR_SIZE]; - int i, level, my_argc, calcpid; + int i, level, my_argc, status; + pid_t calcpid; int nb_exclude = 0; int nb_include = 0; char *file_exclude = NULL; char *file_include = NULL; times_t start_time; FILE *dumpout = NULL; - long size = 1; + off_t size = (off_t)1; char *line = NULL; char *match_expr; cmd = vstralloc(libexecdir, "/", "calcsize", versionsuffix(), NULL); my_argc = 0; + my_argv[my_argc++] = stralloc("calcsize"); + if (g_options->config) + my_argv[my_argc++] = stralloc(g_options->config); + else + my_argv[my_argc++] = stralloc("NOCONFIG"); + my_argv[my_argc++] = stralloc(est->calcprog); my_argv[my_argc++] = stralloc(est->amname); @@ -662,9 +787,11 @@ disk_estimates_t *est; nb_include += est->options->include_list->nb_element; if(nb_exclude > 0) - file_exclude = build_exclude(est->amname, est->amdevice,est->options,0); + file_exclude = build_exclude(est->amname, + est->amdevice, est->options, 0); if(nb_include > 0) - file_include = build_include(est->amname, est->amdevice,est->options,0); + file_include = build_include(est->amname, + est->amdevice, est->options, 0); if(file_exclude) { my_argv[my_argc++] = stralloc("-X"); @@ -683,10 +810,10 @@ disk_estimates_t *est; for(level = 0; level < DUMP_LEVELS; level++) { if(est->est[level].needestimate) { - snprintf(number, sizeof(number), "%d", level); + snprintf(number, SIZEOF(number), "%d", level); my_argv[my_argc++] = stralloc(number); dbprintf((" %s", number)); - snprintf(number, sizeof(number), + snprintf(number, SIZEOF(number), "%ld", (long)est->est[level].dumpsince); my_argv[my_argc++] = stralloc(number); dbprintf((" %s", number)); @@ -706,29 +833,36 @@ disk_estimates_t *est; amfree(cmd); dumpout = fdopen(pipefd,"r"); - match_expr = vstralloc(est->amname," %d SIZE %ld", NULL); - for(size = -1; (line = agets(dumpout)) != NULL; free(line)) { + if (!dumpout) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } + match_expr = vstralloc(est->qamname," %d SIZE " OFF_T_FMT, NULL); + for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { + if (line[0] == '\0') + continue; if(sscanf(line, match_expr, &level, &size) == 2) { printf("%s\n", line); /* write to amandad */ - dbprintf(("%s: estimate size for %s level %d: %ld KB\n", + dbprintf(("%s: estimate size for %s level %d: " OFF_T_FMT " KB\n", debug_prefix(NULL), - est->amname, + est->qamname, level, size)); } } amfree(match_expr); - dbprintf(("%s: waiting for %s \"%s\" child\n", - debug_prefix_time(NULL), my_argv[0], est->amdevice)); - wait(NULL); - dbprintf(("%s: after %s \"%s\" wait\n", - debug_prefix_time(NULL), my_argv[0], est->amdevice)); + dbprintf(("%s: waiting for %s %s child (pid=%d)\n", + debug_prefix_time(NULL), my_argv[0], est->qamdevice, calcpid)); + wait(&status); + dbprintf(("%s: after %s %s wait: child pid=%d status=%d\n", + debug_prefix_time(NULL), my_argv[0], est->qamdevice, + calcpid, WEXITSTATUS(status))); dbprintf(("%s: .....\n", debug_prefix_time(NULL))); dbprintf(("%s: estimate time for %s: %s\n", debug_prefix(NULL), - est->amname, + est->qamname, walltime_str(timessub(curclock(), start_time)))); common_exit: @@ -739,23 +873,29 @@ common_exit: } -void dump_calc_estimates(est) -disk_estimates_t *est; +void +dump_calc_estimates( + disk_estimates_t * est) { int level; - long size; + off_t size; for(level = 0; level < DUMP_LEVELS; level++) { if(est->est[level].needestimate) { dbprintf(("%s: getting size via dump for %s level %d\n", - debug_prefix_time(NULL), est->amname, level)); - size = getsize_dump(est->amname, est->amdevice,level, est->options); + debug_prefix_time(NULL), est->qamname, level)); + size = getsize_dump(est->amname, est->amdevice, + level, est->options); amflock(1, "size"); - fseek(stdout, (off_t)0, SEEK_SET); + if (fseek(stdout, 0L, SEEK_END) < 0) { + dbprintf(("dump_calc_estimates: warning - seek failed: %s\n", + strerror(errno))); + } - printf("%s %d SIZE %ld\n", est->amname, level, size); + printf("%s %d SIZE " OFF_T_FMT "\n", + est->qamname, level, (OFF_T_FMT_TYPE)size); fflush(stdout); amfunlock(1, "size"); @@ -764,23 +904,28 @@ disk_estimates_t *est; } #ifdef SAMBA_CLIENT -void smbtar_calc_estimates(est) -disk_estimates_t *est; +void +smbtar_calc_estimates( + disk_estimates_t * est) { int level; - long size; + off_t size; for(level = 0; level < DUMP_LEVELS; level++) { if(est->est[level].needestimate) { dbprintf(("%s: getting size via smbclient for %s level %d\n", - debug_prefix_time(NULL), est->amname, level)); + debug_prefix_time(NULL), est->qamname, level)); size = getsize_smbtar(est->amname, est->amdevice, level, est->options); amflock(1, "size"); - fseek(stdout, (off_t)0, SEEK_SET); + if (fseek(stdout, 0L, SEEK_END) < 0) { + dbprintf(("smbtar_calc_estimates: warning - seek failed: %s\n", + strerror(errno))); + } - printf("%s %d SIZE %ld\n", est->amname, level, size); + printf("%s %d SIZE " OFF_T_FMT "\n", + est->qamname, level, (OFF_T_FMT_TYPE)size); fflush(stdout); amfunlock(1, "size"); @@ -790,24 +935,29 @@ disk_estimates_t *est; #endif #ifdef GNUTAR -void gnutar_calc_estimates(est) -disk_estimates_t *est; +void +gnutar_calc_estimates( + disk_estimates_t * est) { int level; - long size; + off_t size; for(level = 0; level < DUMP_LEVELS; level++) { if (est->est[level].needestimate) { dbprintf(("%s: getting size via gnutar for %s level %d\n", - debug_prefix_time(NULL), est->amname, level)); + debug_prefix_time(NULL), est->qamname, level)); size = getsize_gnutar(est->amname, est->amdevice, level, est->options, est->est[level].dumpsince); amflock(1, "size"); - fseek(stdout, (off_t)0, SEEK_SET); + if (fseek(stdout, 0L, SEEK_END) < 0) { + dbprintf(("gnutar_calc_estimates: warning - seek failed: %s\n", + strerror(errno))); + } - printf("%s %d SIZE %ld\n", est->amname, level, size); + printf("%s %d SIZE " OFF_T_FMT "\n", + est->qamname, level, (OFF_T_FMT_TYPE)size); fflush(stdout); amfunlock(1, "size"); @@ -821,12 +971,13 @@ typedef struct regex_s { int scale; } regex_t; +/*@ignore@*/ regex_t re_size[] = { #ifdef DUMP {" DUMP: estimated -*[0-9][0-9]* tape blocks", 1024}, {" DUMP: [Ee]stimated [0-9][0-9]* blocks", 512}, - {" DUMP: [Ee]stimated [0-9][0-9]* bytes", 1}, /* Ultrix 4.4 */ - {" UFSDUMP: estimated [0-9][0-9]* blocks", 512}, /* NEC EWS-UX */ + {" DUMP: [Ee]stimated [0-9][0-9]* bytes", 1}, /* Ultrix 4.4 */ + {" UFSDUMP: estimated [0-9][0-9]* blocks", 512}, /* NEC EWS-UX */ {"dump: Estimate: [0-9][0-9]* tape blocks", 1024}, /* OSF/1 */ {"backup: There are an estimated [0-9][0-9]* tape blocks.",1024}, /* AIX */ {"backup: estimated [0-9][0-9]* 1k blocks", 1024}, /* AIX */ @@ -834,27 +985,27 @@ regex_t re_size[] = { {"backup: [0-9][0-9]* tape blocks on [0-9][0-9]* tape(s)",1024}, /* AIX */ {"backup: [0-9][0-9]* 1k blocks on [0-9][0-9]* volume(s)",1024}, /* AIX */ {"dump: Estimate: [0-9][0-9]* blocks being output to pipe",1024}, - /* DU 4.0 dump */ - {"dump: Dumping [0-9][0-9]* bytes, ", 1}, /* DU 4.0 vdump */ - {"DUMP: estimated [0-9][0-9]* KB output", 1024}, /* HPUX */ - {"DUMP: estimated [0-9][0-9]* KB\\.", 1024}, /* NetApp */ - {" UFSDUMP: estimated [0-9][0-9]* blocks", 512}, /* Sinix */ + /* DU 4.0 dump */ + {"dump: Dumping [0-9][0-9]* bytes, ", 1}, /* DU 4.0 vdump */ + {"DUMP: estimated [0-9][0-9]* KB output", 1024}, /* HPUX */ + {"DUMP: estimated [0-9][0-9]* KB\\.", 1024}, /* NetApp */ + {" UFSDUMP: estimated [0-9][0-9]* blocks", 512}, /* Sinix */ #ifdef HAVE_DUMP_ESTIMATE {"[0-9][0-9]* blocks, [0-9][0-9]*.[0-9][0-9]* volumes", 1024}, - /* DU 3.2g dump -E */ - {"^[0-9][0-9]* blocks$", 1024}, /* DU 4.0 dump -E */ - {"^[0-9][0-9]*$", 1}, /* Solaris ufsdump -S */ + /* DU 3.2g dump -E */ + {"^[0-9][0-9]* blocks$", 1024}, /* DU 4.0 dump -E */ + {"^[0-9][0-9]*$", 1}, /* Solaris ufsdump -S */ #endif #endif #ifdef VDUMP - {"vdump: Dumping [0-9][0-9]* bytes, ", 1}, /* OSF/1 vdump */ + {"vdump: Dumping [0-9][0-9]* bytes, ", 1}, /* OSF/1 vdump */ #endif #ifdef VXDUMP - {"vxdump: estimated [0-9][0-9]* blocks", 512}, /* HPUX's vxdump */ - {" VXDUMP: estimated [0-9][0-9]* blocks", 512}, /* Sinix */ + {"vxdump: estimated [0-9][0-9]* blocks", 512}, /* HPUX's vxdump */ + {" VXDUMP: estimated [0-9][0-9]* blocks", 512}, /* Sinix */ #endif #ifdef XFSDUMP @@ -877,16 +1028,18 @@ regex_t re_size[] = { { NULL, 0 } }; - - -long getsize_dump(disk, amdevice, level, options) - char *disk, *amdevice; - int level; - option_t *options; +/*@end@*/ + +off_t +getsize_dump( + char *disk, + char *amdevice, + int level, + option_t * options) { int pipefd[2], nullfd, stdoutfd, killctl[2]; pid_t dumppid; - long size; + off_t size; FILE *dumpout; char *dumpkeys = NULL; char *device = NULL; @@ -898,29 +1051,55 @@ long getsize_dump(disk, amdevice, level, options) char level_str[NUM_STR_SIZE]; int s; times_t start_time; + char *qdisk = quote_string(disk); + char *qdevice; + char *config; +#ifdef DUMP + int is_rundump = 1; +#endif + + (void)options; /* Quiet unused parameter warning */ - snprintf(level_str, sizeof(level_str), "%d", level); + (void)getsize_smbtar; /* Quiet unused parameter warning */ + + snprintf(level_str, SIZEOF(level_str), "%d", level); device = amname_to_devname(amdevice); + qdevice = quote_string(device); fstype = amname_to_fstype(amdevice); - dbprintf(("%s: calculating for device '%s' with '%s'\n", - debug_prefix_time(NULL), device, fstype)); + dbprintf(("%s: calculating for device %s with %s\n", + debug_prefix_time(NULL), qdevice, fstype)); cmd = vstralloc(libexecdir, "/rundump", versionsuffix(), NULL); rundump_cmd = stralloc(cmd); - + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; if ((stdoutfd = nullfd = open("/dev/null", O_RDWR)) == -1) { dbprintf(("getsize_dump could not open /dev/null: %s\n", - strerror(errno))); + strerror(errno))); amfree(cmd); amfree(rundump_cmd); amfree(fstype); amfree(device); + amfree(qdevice); + amfree(qdisk); return(-1); } pipefd[0] = pipefd[1] = killctl[0] = killctl[1] = -1; - pipe(pipefd); + if (pipe(pipefd) < 0) { + dbprintf(("getsize_dump could create data pipes: %s\n", + strerror(errno))); + amfree(cmd); + amfree(rundump_cmd); + amfree(fstype); + amfree(device); + amfree(qdevice); + amfree(qdisk); + return(-1); + } #ifdef XFSDUMP /* { */ #ifdef DUMP /* { */ @@ -929,9 +1108,9 @@ long getsize_dump(disk, amdevice, level, options) if (1) #endif /* } */ { - name = stralloc(" (xfsdump)"); + name = stralloc(" (xfsdump)"); dbprintf(("%s: running \"%s%s -F -J -l %s - %s\"\n", - debug_prefix_time(NULL), cmd, name, level_str, device)); + debug_prefix_time(NULL), cmd, name, level_str, qdevice)); } else #endif /* } */ @@ -943,14 +1122,16 @@ long getsize_dump(disk, amdevice, level, options) #endif /* } */ { #ifdef USE_RUNDUMP - name = stralloc(" (vxdump)"); + name = stralloc(" (vxdump)"); #else name = stralloc(""); cmd = newstralloc(cmd, VXDUMP); + config = skip_argument; + is_rundump = 0; #endif dumpkeys = vstralloc(level_str, "s", "f", NULL); - dbprintf(("%s: running \"%s%s %s 1048576 - %s\"\n", - debug_prefix_time(NULL), cmd, name, dumpkeys, device)); + dbprintf(("%s: running \"%s%s %s 1048576 - %s\"\n", + debug_prefix_time(NULL), cmd, name, dumpkeys, qdevice)); } else #endif /* } */ @@ -963,10 +1144,12 @@ long getsize_dump(disk, amdevice, level, options) { name = stralloc(" (vdump)"); amfree(device); + amfree(qdevice); device = amname_to_dirname(amdevice); + qdevice = quote_string(device); dumpkeys = vstralloc(level_str, "b", "f", NULL); dbprintf(("%s: running \"%s%s %s 60 - %s\"\n", - debug_prefix_time(NULL), cmd, name, dumpkeys, device)); + debug_prefix_time(NULL), cmd, name, dumpkeys, qdevice)); } else #endif /* } */ @@ -981,12 +1164,14 @@ long getsize_dump(disk, amdevice, level, options) # else /* } { */ name = stralloc(""); cmd = newstralloc(cmd, DUMP); + config = skip_argument; + is_rundump = 0; # endif /* } */ # ifdef AIX_BACKUP /* { */ dumpkeys = vstralloc("-", level_str, "f", NULL); dbprintf(("%s: running \"%s%s %s - %s\"\n", - debug_prefix_time(NULL), cmd, name, dumpkeys, device)); + debug_prefix_time(NULL), cmd, name, dumpkeys, qdevice)); # else /* } { */ dumpkeys = vstralloc(level_str, # ifdef HAVE_DUMP_ESTIMATE /* { */ @@ -1003,10 +1188,10 @@ long getsize_dump(disk, amdevice, level, options) # ifdef HAVE_HONOR_NODUMP /* { */ dbprintf(("%s: running \"%s%s %s 0 1048576 - %s\"\n", - debug_prefix_time(NULL), cmd, name, dumpkeys, device)); + debug_prefix_time(NULL), cmd, name, dumpkeys, qdevice)); # else /* } { */ dbprintf(("%s: running \"%s%s %s 1048576 - %s\"\n", - debug_prefix_time(NULL), cmd, name, dumpkeys, device)); + debug_prefix_time(NULL), cmd, name, dumpkeys, qdevice)); # endif /* } */ # endif /* } */ } @@ -1014,9 +1199,15 @@ long getsize_dump(disk, amdevice, level, options) #endif /* } */ { error("no dump program available"); + /*NOTREACHED*/ } - pipe(killctl); + if (pipe(killctl) < 0) { + dbprintf(("%s: Could not create pipe: %s\n", + debug_prefix(NULL), strerror(errno))); + /* Message will be printed later... */ + killctl[0] = killctl[1] = -1; + } start_time = curclock(); switch(dumppid = fork()) { @@ -1027,6 +1218,8 @@ long getsize_dump(disk, amdevice, level, options) amfree(cmd); amfree(rundump_cmd); amfree(device); + amfree(qdevice); + amfree(qdisk); amfree(name); amfree(fstype); return -1; @@ -1036,8 +1229,7 @@ long getsize_dump(disk, amdevice, level, options) if(SETPGRP == -1) SETPGRP_FAILED(); else if (killctl[0] == -1 || killctl[1] == -1) - dbprintf(("%s: pipe for killpgrp failed, trying without killpgrp\n", - debug_prefix(NULL))); + dbprintf(("%s: Trying without killpgrp\n", debug_prefix(NULL))); else { switch(fork()) { case -1: @@ -1047,6 +1239,7 @@ long getsize_dump(disk, amdevice, level, options) default: { + char *config; char *killpgrp_cmd = vstralloc(libexecdir, "/killpgrp", versionsuffix(), NULL); dbprintf(("%s: running %s\n", @@ -1058,7 +1251,12 @@ long getsize_dump(disk, amdevice, level, options) close(pipefd[1]); close(killctl[1]); close(nullfd); - execle(killpgrp_cmd, killpgrp_cmd, (char *)0, safe_env()); + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; + execle(killpgrp_cmd, killpgrp_cmd, config, (char *)0, + safe_env()); dbprintf(("%s: cannot execute %s: %s\n", debug_prefix(NULL), killpgrp_cmd, strerror(errno))); exit(-1); @@ -1084,8 +1282,12 @@ long getsize_dump(disk, amdevice, level, options) #else if (1) #endif - execle(cmd, "xfsdump", "-F", "-J", "-l", level_str, "-", device, - (char *)0, safe_env()); + if (is_rundump) + execle(cmd, "rundump", config, "xfsdump", "-F", "-J", "-l", + level_str, "-", device, (char *)0, safe_env()); + else + execle(cmd, "xfsdump", "-F", "-J", "-l", + level_str, "-", device, (char *)0, safe_env()); else #endif #ifdef VXDUMP @@ -1094,8 +1296,12 @@ long getsize_dump(disk, amdevice, level, options) #else if (1) #endif - execle(cmd, "vxdump", dumpkeys, "1048576", "-", device, (char *)0, - safe_env()); + if (is_rundump) + execle(cmd, "rundump", config, "vxdump", dumpkeys, "1048576", + "-", device, (char *)0, safe_env()); + else + execle(cmd, "vxdump", dumpkeys, "1048576", "-", + device, (char *)0, safe_env()); else #endif #ifdef VDUMP @@ -1104,24 +1310,42 @@ long getsize_dump(disk, amdevice, level, options) #else if (1) #endif - execle(cmd, "vdump", dumpkeys, "60", "-", device, (char *)0, - safe_env()); + if (is_rundump) + execle(cmd, "rundump", config, "vdump", dumpkeys, "60", "-", + device, (char *)0, safe_env()); + else + execle(cmd, "vdump", dumpkeys, "60", "-", + device, (char *)0, safe_env()); else #endif #ifdef DUMP # ifdef AIX_BACKUP - execle(cmd, "backup", dumpkeys, "-", device, (char *)0, safe_env()); + if (is_rundump) + execle(cmd, "rundump", config, "backup", dumpkeys, "-", + device, (char *)0, safe_env()); + else + execle(cmd, "backup", dumpkeys, "-", + device, (char *)0, safe_env()); # else - execle(cmd, "dump", dumpkeys, + if (is_rundump) { + execle(cmd, "rundump", config, "dump", dumpkeys, #ifdef HAVE_HONOR_NODUMP - "0", + "0", #endif - "1048576", "-", device, (char *)0, safe_env()); + "1048576", "-", device, (char *)0, safe_env()); + } else { + execle(cmd, "dump", dumpkeys, +#ifdef HAVE_HONOR_NODUMP + "0", +#endif + "1048576", "-", device, (char *)0, safe_env()); # endif + } #endif { error("exec %s failed or no dump program available: %s", cmd, strerror(errno)); + /*NOTREACHED*/ } } @@ -1132,13 +1356,24 @@ long getsize_dump(disk, amdevice, level, options) if (killctl[0] != -1) aclose(killctl[0]); dumpout = fdopen(pipefd[0],"r"); + if (!dumpout) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } - for(size = -1; (line = agets(dumpout)) != NULL; free(line)) { + for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { + if (line[0] == '\0') + continue; dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); size = handle_dumpline(line); - if(size > -1) { + if(size > (off_t)-1) { amfree(line); - if((line = agets(dumpout)) != NULL) { + while ((line = agets(dumpout)) != NULL) { + if (line[0] != '\0') + break; + amfree(line); + } + if (line != NULL) { dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); } break; @@ -1149,23 +1384,23 @@ long getsize_dump(disk, amdevice, level, options) dbprintf(("%s: .....\n", debug_prefix_time(NULL))); dbprintf(("%s: estimate time for %s level %d: %s\n", debug_prefix(NULL), - disk, + qdisk, level, walltime_str(timessub(curclock(), start_time)))); - if(size == -1) { + if(size == (off_t)-1) { dbprintf(("%s: no size line match in %s%s output for \"%s\"\n", debug_prefix(NULL), cmd, name, disk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); dbprintf(("%s: Run %s%s manually to check for errors\n", debug_prefix(NULL), cmd, name)); - } else if(size == 0 && level == 0) { + } else if(size == (off_t)0 && level == 0) { dbprintf(("%s: possible %s%s problem -- is \"%s\" really empty?\n", debug_prefix(NULL), cmd, name, disk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); } else { dbprintf(("%s: estimate size for %s level %d: %ld KB\n", debug_prefix(NULL), - disk, + qdisk, level, size)); } @@ -1211,10 +1446,10 @@ long getsize_dump(disk, amdevice, level, options) } dbprintf(("%s: waiting for %s%s \"%s\" child\n", - debug_prefix_time(NULL), cmd, name, disk)); + debug_prefix_time(NULL), cmd, name, qdisk)); wait(NULL); - dbprintf(("%s: after %s%s \"%s\" wait\n", - debug_prefix_time(NULL), cmd, name, disk)); + dbprintf(("%s: after %s%s %s wait\n", + debug_prefix_time(NULL), cmd, name, qdisk)); terminated: @@ -1222,6 +1457,8 @@ long getsize_dump(disk, amdevice, level, options) afclose(dumpout); amfree(device); + amfree(qdevice); + amfree(qdisk); amfree(fstype); amfree(cmd); @@ -1231,24 +1468,29 @@ long getsize_dump(disk, amdevice, level, options) } #ifdef SAMBA_CLIENT -long getsize_smbtar(disk, amdevice, level, optionns) - char *disk, *amdevice; - int level; - option_t *optionns; +off_t +getsize_smbtar( + char *disk, + char *amdevice, + int level, + option_t * options) { int pipefd = -1, nullfd = -1, passwdfd = -1; - int dumppid; - long size; + pid_t dumppid; + off_t size; FILE *dumpout; char *tarkeys, *sharename, *user_and_password = NULL, *domain = NULL; char *share = NULL, *subdir = NULL; - int lpass; + size_t lpass; char *pwtext; - int pwtext_len; + size_t pwtext_len; char *line; char *pw_fd_env; times_t start_time; char *error_pn = NULL; + char *qdisk = quote_string(disk); + + (void)options; /* Quiet unused parameter warning */ error_pn = stralloc2(get_pname(), "-smbclient"); @@ -1258,14 +1500,16 @@ long getsize_smbtar(disk, amdevice, level, optionns) amfree(subdir); set_pname(error_pn); amfree(error_pn); - error("cannot parse disk entry '%s' for share/subdir", disk); + error("cannot parse disk entry %s for share/subdir", qdisk); + /*NOTREACHED*/ } if ((subdir) && (SAMBA_VERSION < 2)) { amfree(share); amfree(subdir); set_pname(error_pn); amfree(error_pn); - error("subdirectory specified for share '%s' but samba not v2 or better", disk); + error("subdirectory specified for share %s but samba not v2 or better", qdisk); + /*NOTREACHED*/ } if ((user_and_password = findpass(share, &domain)) == NULL) { @@ -1276,10 +1520,11 @@ long getsize_smbtar(disk, amdevice, level, optionns) set_pname(error_pn); amfree(error_pn); error("cannot find password for %s", disk); + /*NOTREACHED*/ } lpass = strlen(user_and_password); if ((pwtext = strchr(user_and_password, '%')) == NULL) { - memset(user_and_password, '\0', lpass); + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); if(domain) { memset(domain, '\0', strlen(domain)); @@ -1288,11 +1533,12 @@ long getsize_smbtar(disk, amdevice, level, optionns) set_pname(error_pn); amfree(error_pn); error("password field not \'user%%pass\' for %s", disk); + /*NOTREACHED*/ } *pwtext++ = '\0'; pwtext_len = strlen(pwtext); if ((sharename = makesharename(share, 0)) == NULL) { - memset(user_and_password, '\0', lpass); + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); if(domain) { memset(domain, '\0', strlen(domain)); @@ -1301,9 +1547,10 @@ long getsize_smbtar(disk, amdevice, level, optionns) set_pname(error_pn); amfree(error_pn); error("cannot make share name of %s", share); + /*NOTREACHED*/ } if ((nullfd = open("/dev/null", O_RDWR)) == -1) { - memset(user_and_password, '\0', lpass); + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); if(domain) { memset(domain, '\0', strlen(domain)); @@ -1314,6 +1561,7 @@ long getsize_smbtar(disk, amdevice, level, optionns) amfree(sharename); error("could not open /dev/null: %s\n", strerror(errno)); + /*NOTREACHED*/ } #if SAMBA_VERSION >= 2 @@ -1357,17 +1605,18 @@ long getsize_smbtar(disk, amdevice, level, optionns) amfree(domain); } aclose(nullfd); - if(pwtext_len > 0 && fullwrite(passwdfd, pwtext, pwtext_len) < 0) { + if(pwtext_len > 0 && fullwrite(passwdfd, pwtext, (size_t)pwtext_len) < 0) { int save_errno = errno; - memset(user_and_password, '\0', lpass); + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); aclose(passwdfd); set_pname(error_pn); amfree(error_pn); error("password write failed: %s", strerror(save_errno)); + /*NOTREACHED*/ } - memset(user_and_password, '\0', lpass); + memset(user_and_password, '\0', (size_t)lpass); amfree(user_and_password); aclose(passwdfd); amfree(sharename); @@ -1375,13 +1624,24 @@ long getsize_smbtar(disk, amdevice, level, optionns) amfree(subdir); amfree(error_pn); dumpout = fdopen(pipefd,"r"); + if (!dumpout) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } - for(size = -1; (line = agets(dumpout)) != NULL; free(line)) { + for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { + if (line[0] == '\0') + continue; dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); size = handle_dumpline(line); if(size > -1) { amfree(line); - if((line = agets(dumpout)) != NULL) { + while ((line = agets(dumpout)) != NULL) { + if (line[0] != '\0') + break; + amfree(line); + } + if(line != NULL) { dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); } break; @@ -1392,50 +1652,54 @@ long getsize_smbtar(disk, amdevice, level, optionns) dbprintf(("%s: .....\n", debug_prefix_time(NULL))); dbprintf(("%s: estimate time for %s level %d: %s\n", debug_prefix(NULL), - disk, + qdisk, level, walltime_str(timessub(curclock(), start_time)))); - if(size == -1) { + if(size == (off_t)-1) { dbprintf(("%s: no size line match in %s output for \"%s\"\n", debug_prefix(NULL), SAMBA_CLIENT, disk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); - } else if(size == 0 && level == 0) { + } else if(size == (off_t)0 && level == 0) { dbprintf(("%s: possible %s problem -- is \"%s\" really empty?\n", debug_prefix(NULL), SAMBA_CLIENT, disk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); } dbprintf(("%s: estimate size for %s level %d: %ld KB\n", debug_prefix(NULL), - disk, + qdisk, level, size)); kill(-dumppid, SIGTERM); dbprintf(("%s: waiting for %s \"%s\" child\n", - debug_prefix_time(NULL), SAMBA_CLIENT, disk)); + debug_prefix_time(NULL), SAMBA_CLIENT, qdisk)); wait(NULL); - dbprintf(("%s: after %s \"%s\" wait\n", - debug_prefix_time(NULL), SAMBA_CLIENT, disk)); + dbprintf(("%s: after %s %s wait\n", + debug_prefix_time(NULL), SAMBA_CLIENT, qdisk)); afclose(dumpout); pipefd = -1; amfree(error_pn); + amfree(qdisk); return size; } #endif #ifdef GNUTAR -long getsize_gnutar(disk, amdevice, level, options, dumpsince) -char *disk, *amdevice; -int level; -option_t *options; -time_t dumpsince; +off_t +getsize_gnutar( + char *disk, + char *amdevice, + int level, + option_t * options, + time_t dumpsince) { - int pipefd = -1, nullfd = -1, dumppid; - long size = -1; + int pipefd = -1, nullfd = -1; + pid_t dumppid; + off_t size = (off_t)-1; FILE *dumpout = NULL; char *incrname = NULL; char *basename = NULL; @@ -1454,6 +1718,11 @@ time_t dumpsince; char *file_exclude = NULL; char *file_include = NULL; times_t start_time; + int infd, outfd; + ssize_t nb; + char buf[32768]; + char *qdisk = quote_string(disk); + char *gnutar_list_dir; if(options->exclude_file) nb_exclude += options->exclude_file->nb_element; if(options->exclude_list) nb_exclude += options->exclude_list->nb_element; @@ -1463,17 +1732,19 @@ time_t dumpsince; if(nb_exclude > 0) file_exclude = build_exclude(disk, amdevice, options, 0); if(nb_include > 0) file_include = build_include(disk, amdevice, options, 0); - my_argv = alloc(sizeof(char *) * 21); + my_argv = alloc(SIZEOF(char *) * 22); i = 0; -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR - { + gnutar_list_dir = client_getconf_str(CLN_GNUTAR_LIST_DIR); + if (strlen(gnutar_list_dir) == 0) + gnutar_list_dir = NULL; + if (gnutar_list_dir) { char number[NUM_STR_SIZE]; char *s; int ch; int baselevel; - basename = vstralloc(GNUTAR_LISTED_INCREMENTAL_DIR, + basename = vstralloc(gnutar_list_dir, "/", g_options->hostname, disk, @@ -1482,12 +1753,12 @@ time_t dumpsince; * The loop starts at the first character of the host name, * not the '/'. */ - s = basename + sizeof(GNUTAR_LISTED_INCREMENTAL_DIR); + s = basename + strlen(gnutar_list_dir) + 1; while((ch = *s++) != '\0') { if(ch == '/' || isspace(ch)) s[-1] = '_'; } - snprintf(number, sizeof(number), "%d", level); + snprintf(number, SIZEOF(number), "%d", level); incrname = vstralloc(basename, "_", number, ".new", NULL); unlink(incrname); @@ -1497,15 +1768,16 @@ time_t dumpsince; * be true for a level 0), arrange to read from /dev/null. */ baselevel = level; - while (in == NULL) { + infd = -1; + while (infd == -1) { if (--baselevel >= 0) { - snprintf(number, sizeof(number), "%d", baselevel); + snprintf(number, SIZEOF(number), "%d", baselevel); inputname = newvstralloc(inputname, basename, "_", number, NULL); } else { inputname = newstralloc(inputname, "/dev/null"); } - if ((in = fopen(inputname, "r")) == NULL) { + if ((infd = open(inputname, O_RDONLY)) == -1) { int save_errno = errno; dbprintf(("%s: gnutar: error opening %s: %s\n", @@ -1519,59 +1791,57 @@ time_t dumpsince; /* * Copy the previous listed incremental file to the new one. */ - if ((out = fopen(incrname, "w")) == NULL) { + if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) { dbprintf(("%s: opening %s: %s\n", debug_prefix(NULL), incrname, strerror(errno))); goto common_exit; } - for (; (line = agets(in)) != NULL; free(line)) { - if (fputs(line, out) == EOF || putc('\n', out) == EOF) { + while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) { + if (fullwrite(outfd, &buf, (size_t)nb) < nb) { dbprintf(("%s: writing to %s: %s\n", debug_prefix(NULL), incrname, strerror(errno))); goto common_exit; } } - amfree(line); - if (ferror(in)) { + if (nb < 0) { dbprintf(("%s: reading from %s: %s\n", debug_prefix(NULL), inputname, strerror(errno))); goto common_exit; } - if (fclose(in) == EOF) { + + if (close(infd) != 0) { dbprintf(("%s: closing %s: %s\n", debug_prefix(NULL), inputname, strerror(errno))); - in = NULL; goto common_exit; } - in = NULL; - if (fclose(out) == EOF) { + if (close(outfd) != 0) { dbprintf(("%s: closing %s: %s\n", debug_prefix(NULL), incrname, strerror(errno))); - out = NULL; goto common_exit; } - out = NULL; amfree(inputname); amfree(basename); } -#endif gmtm = gmtime(&dumpsince); - snprintf(dumptimestr, sizeof(dumptimestr), + snprintf(dumptimestr, SIZEOF(dumptimestr), "%04d-%02d-%02d %2d:%02d:%02d GMT", gmtm->tm_year + 1900, gmtm->tm_mon+1, gmtm->tm_mday, gmtm->tm_hour, gmtm->tm_min, gmtm->tm_sec); dirname = amname_to_dirname(amdevice); - - -#ifdef GNUTAR cmd = vstralloc(libexecdir, "/", "runtar", versionsuffix(), NULL); + my_argv[i++] = "runtar"; + if (g_options->config) + my_argv[i++] = g_options->config; + else + my_argv[i++] = "NOCONFIG"; +#ifdef GNUTAR my_argv[i++] = GNUTAR; #else my_argv[i++] = "tar"; @@ -1582,14 +1852,14 @@ time_t dumpsince; my_argv[i++] = "--directory"; my_argv[i++] = dirname; my_argv[i++] = "--one-file-system"; -#ifdef GNUTAR_LISTED_INCREMENTAL_DIR - my_argv[i++] = "--listed-incremental"; - my_argv[i++] = incrname; -#else - my_argv[i++] = "--incremental"; - my_argv[i++] = "--newer"; - my_argv[i++] = dumptimestr; -#endif + if (gnutar_list_dir) { + my_argv[i++] = "--listed-incremental"; + my_argv[i++] = incrname; + } else { + my_argv[i++] = "--incremental"; + my_argv[i++] = "--newer"; + my_argv[i++] = dumptimestr; + } #ifdef ENABLE_GNUTAR_ATIME_PRESERVE /* --atime-preserve causes gnutar to call * utime() after reading files in order to @@ -1618,21 +1888,35 @@ time_t dumpsince; start_time = curclock(); - nullfd = open("/dev/null", O_RDWR); + if ((nullfd = open("/dev/null", O_RDWR)) == -1) { + dbprintf(("Cannot access /dev/null : %s\n", strerror(errno))); + goto common_exit; + } + dumppid = pipespawnv(cmd, STDERR_PIPE, &nullfd, &nullfd, &pipefd, my_argv); - amfree(cmd); - amfree(file_exclude); - amfree(file_include); dumpout = fdopen(pipefd,"r"); + if (!dumpout) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } - for(size = -1; (line = agets(dumpout)) != NULL; free(line)) { + for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { + if (line[0] == '\0') + continue; dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); size = handle_dumpline(line); - if(size > -1) { + if(size > (off_t)-1) { amfree(line); - if((line = agets(dumpout)) != NULL) { + while ((line = agets(dumpout)) != NULL) { + if (line[0] != '\0') { + break; + } + amfree(line); + } + if (line != NULL) { dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); + break; } break; } @@ -1642,31 +1926,31 @@ time_t dumpsince; dbprintf(("%s: .....\n", debug_prefix_time(NULL))); dbprintf(("%s: estimate time for %s level %d: %s\n", debug_prefix(NULL), - disk, + qdisk, level, walltime_str(timessub(curclock(), start_time)))); - if(size == -1) { + if(size == (off_t)-1) { dbprintf(("%s: no size line match in %s output for \"%s\"\n", debug_prefix(NULL), my_argv[0], disk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); - } else if(size == 0 && level == 0) { + } else if(size == (off_t)0 && level == 0) { dbprintf(("%s: possible %s problem -- is \"%s\" really empty?\n", debug_prefix(NULL), my_argv[0], disk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); } dbprintf(("%s: estimate size for %s level %d: %ld KB\n", debug_prefix(NULL), - disk, + qdisk, level, size)); kill(-dumppid, SIGTERM); dbprintf(("%s: waiting for %s \"%s\" child\n", - debug_prefix_time(NULL), my_argv[0], disk)); + debug_prefix_time(NULL), my_argv[0], qdisk)); wait(NULL); - dbprintf(("%s: after %s \"%s\" wait\n", - debug_prefix_time(NULL), my_argv[0], disk)); + dbprintf(("%s: after %s %s wait\n", + debug_prefix_time(NULL), my_argv[0], qdisk)); common_exit: @@ -1678,6 +1962,10 @@ common_exit: amfree(dirname); amfree(inputname); amfree(my_argv); + amfree(qdisk); + amfree(cmd); + amfree(file_exclude); + amfree(file_include); aclose(nullfd); afclose(dumpout); @@ -1688,14 +1976,18 @@ common_exit: } #endif -long getsize_wrapper(program, disk, amdevice, level, options, dumpsince) -char *program, *disk, *amdevice; -int level; -option_t *options; -time_t dumpsince; +off_t +getsize_wrapper( + char *program, + char *disk, + char *amdevice, + int level, + option_t * options, + time_t dumpsince) { - int pipefd[2], nullfd, dumppid; - long size; + int pipefd[2], nullfd; + pid_t dumppid; + off_t size = (off_t)-1; FILE *dumpout; char *line = NULL; char *cmd = NULL; @@ -1704,11 +1996,13 @@ time_t dumpsince; int i, j; char *argvchild[10]; char *newoptstr = NULL; - long size1, size2; + off_t size1, size2; times_t start_time; + char *qdisk = quote_string(disk); + char *qamdevice = quote_string(amdevice); gmtm = gmtime(&dumpsince); - snprintf(dumptimestr, sizeof(dumptimestr), + snprintf(dumptimestr, SIZEOF(dumptimestr), "%04d-%02d-%02d %2d:%02d:%02d GMT", gmtm->tm_year + 1900, gmtm->tm_mon+1, gmtm->tm_mday, gmtm->tm_hour, gmtm->tm_min, gmtm->tm_sec); @@ -1722,7 +2016,7 @@ time_t dumpsince; argvchild[i++] = "full"; else { char levelstr[NUM_STR_SIZE]; - snprintf(levelstr,sizeof(levelstr),"%d",level); + snprintf(levelstr,SIZEOF(levelstr),"%d",level); argvchild[i++] = "level"; argvchild[i++] = levelstr; } @@ -1736,14 +2030,23 @@ time_t dumpsince; dbprintf((" %s", argvchild[j])); } dbprintf(("\n")); - nullfd = open("/dev/null", O_RDWR); - pipe(pipefd); + + if ((nullfd = open("/dev/null", O_RDWR)) == -1) { + dbprintf(("Cannot access /dev/null : %s\n", strerror(errno))); + goto common_exit; + } + + if (pipe(pipefd) < 0) { + dbprintf(("getsize_wrapper could create data pipes: %s\n", + strerror(errno))); + goto common_exit; + } start_time = curclock(); switch(dumppid = fork()) { case -1: - size = -1; + size = (off_t)-1; goto common_exit; default: break; /* parent */ @@ -1755,21 +2058,35 @@ time_t dumpsince; execve(cmd, argvchild, safe_env()); error("exec %s failed: %s", cmd, strerror(errno)); + /*NOTREACHED*/ } amfree(newoptstr); aclose(pipefd[1]); dumpout = fdopen(pipefd[0],"r"); + if (!dumpout) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } - for(size = -1; (line = agets(dumpout)) != NULL; free(line)) { + for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) { + if (line[0] == '\0') + continue; dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); - i = sscanf(line,"%ld %ld",&size1, &size2); + i = sscanf(line, OFF_T_FMT " " OFF_T_FMT, + (OFF_T_FMT_TYPE *)&size1, + (OFF_T_FMT_TYPE *)&size2); if(i == 2) { size = size1 * size2; } if(size > -1) { amfree(line); - if((line = agets(dumpout)) != NULL) { + while ((line = agets(dumpout)) != NULL) { + if (line[0] != '\0') + break; + amfree(line); + } + if(line != NULL) { dbprintf(("%s: %s\n", debug_prefix_time(NULL), line)); } break; @@ -1780,31 +2097,31 @@ time_t dumpsince; dbprintf(("%s: .....\n", debug_prefix_time(NULL))); dbprintf(("%s: estimate time for %s level %d: %s\n", debug_prefix(NULL), - amdevice, + qamdevice, level, walltime_str(timessub(curclock(), start_time)))); - if(size == -1) { + if(size == (off_t)-1) { dbprintf(("%s: no size line match in %s output for \"%s\"\n", - debug_prefix(NULL), cmd, disk)); + debug_prefix(NULL), cmd, qdisk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); - } else if(size == 0 && level == 0) { + } else if(size == (off_t)0 && level == 0) { dbprintf(("%s: possible %s problem -- is \"%s\" really empty?\n", - debug_prefix(NULL), cmd, disk)); + debug_prefix(NULL), cmd, qdisk)); dbprintf(("%s: .....\n", debug_prefix(NULL))); } - dbprintf(("%s: estimate size for %s level %d: %ld KB\n", + dbprintf(("%s: estimate size for %s level %d: " OFF_T_FMT " KB\n", debug_prefix(NULL), - amdevice, + qamdevice, level, size)); kill(-dumppid, SIGTERM); dbprintf(("%s: waiting for %s \"%s\" child\n", - debug_prefix_time(NULL), cmd, disk)); + debug_prefix_time(NULL), cmd, qdisk)); wait(NULL); - dbprintf(("%s: after %s \"%s\" wait\n", - debug_prefix_time(NULL), cmd, disk)); + dbprintf(("%s: after %s %s wait\n", + debug_prefix_time(NULL), cmd, qdisk)); aclose(nullfd); afclose(dumpout); @@ -1813,15 +2130,19 @@ common_exit: amfree(cmd); amfree(newoptstr); + amfree(qdisk); + amfree(qamdevice); return size; } -double first_num(str) -char *str; /* * Returns the value of the first integer in a string. */ + +double +first_num( + char * str) { char *start; int ch; @@ -1833,27 +2154,32 @@ char *str; while(isdigit(ch) || (ch == '.')) ch = *str++; str[-1] = '\0'; d = atof(start); - str[-1] = ch; + str[-1] = (char)ch; return d; } -long handle_dumpline(str) -char *str; /* * Checks the dump output line against the error and size regex tables. */ + +off_t +handle_dumpline( + char * str) { regex_t *rp; double size; /* check for size match */ + /*@ignore@*/ for(rp = re_size; rp->regex != NULL; rp++) { if(match(rp->regex, str)) { size = ((first_num(str)*rp->scale+1023.0)/1024.0); - if(size < 0) size = 1; /* found on NeXT -- sigh */ - return (long) size; + if(size < 0.0) + size = 1.0; /* found on NeXT -- sigh */ + return (off_t)size; } } - return -1; + /*@end@*/ + return (off_t)-1; } diff --git a/client-src/unctime.c b/client-src/unctime.c index d2ee5ea..3e99a98 100644 --- a/client-src/unctime.c +++ b/client-src/unctime.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: unctime.c,v 1.2 1997/08/27 08:11:44 amcore Exp $ */ +/* $Id: unctime.c,v 1.3 2006/05/25 01:47:11 johnfranks Exp $ */ #include "amanda.h" @@ -53,18 +53,18 @@ #define E_SECOND 17 #define E_YEAR 20 -static int lookup P((char *)); +static int lookup(char *); time_t -unctime(str) - char *str; +unctime( + char *str) { struct tm then; char dbuf[26]; - (void) strncpy(dbuf, str, sizeof(dbuf) - 1); - dbuf[sizeof(dbuf) - 1] = '\0'; + (void) strncpy(dbuf, str, SIZEOF(dbuf) - 1); + dbuf[SIZEOF(dbuf) - 1] = '\0'; dbuf[E_MONTH+3] = '\0'; if ((then.tm_mon = lookup(&dbuf[E_MONTH])) < 0) return -1; @@ -81,13 +81,13 @@ static char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; static int -lookup(str) - char *str; +lookup( + char * str) { register char *cp, *cp2; for (cp = months, cp2 = str; *cp != '\0'; cp += 3) if (strncmp(cp, cp2, 3) == 0) - return ((cp-months) / 3); + return ((int)(cp-months) / 3); return -1; } diff --git a/client-src/versionsuffix.c b/client-src/versionsuffix.c index d0ed70f..91d0700 100644 --- a/client-src/versionsuffix.c +++ b/client-src/versionsuffix.c @@ -24,19 +24,22 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: versionsuffix.c,v 1.8 2005/09/20 21:32:25 jrjackson Exp $ + * $Id: versionsuffix.c,v 1.9 2006/05/25 01:47:11 johnfranks Exp $ * * prints the (possibly empty) suffix appended to amanda program names */ #include "amanda.h" #include "version.h" -int main P((void)); +int main(int argc, char **argv); -int main() +int main(int argc, char **argv) { safe_fd(-1, 0); + (void)argc; /* Quiet unused parameter warning */ + (void)argv; /* Quiet unused parameter warning */ + set_pname("versionsuffix"); printf("%s\n", versionsuffix()); diff --git a/common-src/Makefile.am b/common-src/Makefile.am index 1d237ea..7f25d62 100644 --- a/common-src/Makefile.am +++ b/common-src/Makefile.am @@ -7,42 +7,71 @@ REGsrcdir = $(srcdir)/$(REGDIR) INCLUDES = -I$(REGsrcdir) -libamanda_la_SOURCES = \ - alloc.c amflock.c \ - bsd-security.c \ - clock.c \ - debug.c dgram.c \ - event.c error.c \ - amfeatures.c \ - file.c fileheader.c \ - krb4-security.c krb5-security.c \ - match.c \ - packet.c pipespawn.c protocol.c \ - regcomp.c regerror.c regexec.c regfree.c \ - rsh-security.c \ - security.c sl.c ssh-security.c statfs.c \ - stream.c tapelist.c \ - token.c \ - util.c \ - versuff.c version.c +LINT=@AMLINT@ +LINTFLAGS=@AMLINTFLAGS@ + +libamanda_la_SOURCES = \ + alloc.c \ + amfeatures.c \ + amflock.c \ + bsd-security.c \ + bsdtcp-security.c \ + bsdudp-security.c \ + clock.c \ + debug.c \ + dgram.c \ + error.c \ + event.c \ + file.c \ + fileheader.c \ + krb4-security.c \ + krb5-security.c \ + match.c \ + packet.c \ + pipespawn.c \ + protocol.c \ + regcomp.c \ + regerror.c \ + regexec.c \ + regfree.c \ + rsh-security.c \ + security.c \ + security-util.c \ + sl.c \ + ssh-security.c \ + statfs.c \ + stream.c \ + tapelist.c \ + token.c \ + util.c \ + version.c \ + versuff.c libamanda_la_LIBADD = @LTLIBOBJS@ @LTALLOCA@ libamanda_la_LDFLAGS = -release $(VERSION) -noinst_HEADERS = amanda.h amregex.h arglist.h \ - clock.h \ - dgram.h \ - event.h \ - amfeatures.h \ - packet.h pipespawn.h protocol.h \ - queue.h \ - sl.h security.h statfs.h \ - stream.h \ - tapelist.h \ - token.h \ - util.h \ - version.h \ - fileheader.h +noinst_HEADERS = \ + amanda.h \ + amfeatures.h \ + amregex.h \ + arglist.h \ + clock.h \ + dgram.h \ + event.h \ + fileheader.h \ + packet.h \ + pipespawn.h \ + protocol.h \ + queue.h \ + security.h \ + security-util.h \ + sl.h \ + statfs.h \ + stream.h \ + tapelist.h \ + token.h \ + util.h \ + version.h .sh: cat $< > $@ @@ -51,7 +80,7 @@ noinst_HEADERS = amanda.h amregex.h arglist.h \ EXTRA_PROGRAMS = genversion $(TEST_PROGS) genversion_SOURCES = genversion.c -genversion_LDADD = $(libamanda_la_LIBADD) versuff.o +genversion_LDADD = $(libamanda_la_LIBADD) versuff.lo genversion.@OBJEXT@: genversion.h genversion.h: $(top_builddir)/config.status @@ -71,12 +100,14 @@ regexec.@OBJEXT@ regexec.lo: regex.h engine.ih regerror.@OBJEXT@ regerror.lo: regex.h regerror.ih regfree.@OBJEXT@ regfree.lo: regex.h -REGEXHSRC = $(REGsrcdir)/regex2.h \ - $(REGsrcdir)/regcomp.c \ - $(REGsrcdir)/regexec.c \ - $(REGsrcdir)/regerror.c \ +REGEXCSRC = $(REGsrcdir)/regcomp.c \ + $(REGsrcdir)/regexec.c \ + $(REGsrcdir)/regerror.c \ $(REGsrcdir)/regfree.c +REGEXHSRC = $(REGsrcdir)/regex2.h \ + $(REGEXCSRC) + # these are used for testing only: TEST_PROGS = statfs token file bsdsecurity amfeatures @@ -85,16 +116,16 @@ CLEANFILES = regex.h regcomp.ih engine.ih regerror.ih *.test.c DISTCLEANFILES = version.c genversion.h genversion amanda-int.h regex.h: $(REGEXHSRC) $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -i _REGEX_H_ $(REGEXHSRC) >$@ + sh $(REGsrcdir)/mkh -i _REGEX_H_ $(REGEXHSRC) >$@ regcomp.ih: $(REGsrcdir)/regcomp.c $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -p $(REGsrcdir)/regcomp.c >$@ + sh $(REGsrcdir)/mkh -p $(REGsrcdir)/regcomp.c >$@ engine.ih: $(REGsrcdir)/engine.c $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -p $(REGsrcdir)/engine.c >$@ + sh $(REGsrcdir)/mkh -p $(REGsrcdir)/engine.c >$@ regerror.ih: $(REGsrcdir)/regerror.c $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -p $(REGsrcdir)/regerror.c >$@ + sh $(REGsrcdir)/mkh -p $(REGsrcdir)/regerror.c >$@ # used for testing only @@ -103,7 +134,8 @@ STANDARD_COMMON_STUFF_NOT_FILE = \ clock.$(OBJEXT) \ debug.$(OBJEXT) \ error.$(OBJEXT) \ - util.$(OBJEXT) + util.$(OBJEXT) \ + match.$(OBJEXT) STANDARD_COMMON_STUFF = \ $(STANDARD_COMMON_STUFF_NOT_FILE) \ @@ -135,6 +167,18 @@ bsdsecurity_LDADD = $(libamanda_a_LIBADD) \ amfeatures_SOURCES = amfeatures.test.c amfeatures_LDADD = $(libamanda_la_LIBADD) $(STANDARD_COMMON_STUFF) +lint: + @echo $(LINT) $(libamanda_la_SOURCES) + @$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config $(INCLUDES) $(libamanda_la_SOURCES) + @echo $(LINT) $(genversion_SOURCES) + @$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config $(INCLUDES) $(genversion_SOURCES) + +listlibsrc: + @ for p in $(libamanda_la_SOURCES) $(REGEXCSRC); do \ + listlibsrcs="$$listlibsrcs `pwd`/$$p"; \ + done; \ + echo $$listlibsrcs >listlibsrc.output + %.test.c: $(srcdir)/%.c echo '#define TEST' >$@ echo '#include "$<"' >>$@ diff --git a/common-src/Makefile.in b/common-src/Makefile.in index 18a4431..4672c53 100644 --- a/common-src/Makefile.in +++ b/common-src/Makefile.in @@ -64,13 +64,14 @@ am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libamanda_la_DEPENDENCIES = @LTLIBOBJS@ @LTALLOCA@ -am_libamanda_la_OBJECTS = alloc.lo amflock.lo bsd-security.lo clock.lo \ - debug.lo dgram.lo event.lo error.lo amfeatures.lo file.lo \ - fileheader.lo krb4-security.lo krb5-security.lo match.lo \ - packet.lo pipespawn.lo protocol.lo regcomp.lo regerror.lo \ - regexec.lo regfree.lo rsh-security.lo security.lo sl.lo \ +am_libamanda_la_OBJECTS = alloc.lo amfeatures.lo amflock.lo \ + bsd-security.lo bsdtcp-security.lo bsdudp-security.lo clock.lo \ + debug.lo dgram.lo error.lo event.lo file.lo fileheader.lo \ + krb4-security.lo krb5-security.lo match.lo packet.lo \ + pipespawn.lo protocol.lo regcomp.lo regerror.lo regexec.lo \ + regfree.lo rsh-security.lo security.lo security-util.lo sl.lo \ ssh-security.lo statfs.lo stream.lo tapelist.lo token.lo \ - util.lo versuff.lo version.lo + util.lo version.lo versuff.lo libamanda_la_OBJECTS = $(am_libamanda_la_OBJECTS) am__EXEEXT_1 = statfs$(EXEEXT) token$(EXEEXT) file$(EXEEXT) \ bsdsecurity$(EXEEXT) amfeatures$(EXEEXT) @@ -78,7 +79,7 @@ am_amfeatures_OBJECTS = amfeatures.test.$(OBJEXT) amfeatures_OBJECTS = $(am_amfeatures_OBJECTS) am__DEPENDENCIES_1 = @LTLIBOBJS@ @LTALLOCA@ am__DEPENDENCIES_2 = alloc.$(OBJEXT) clock.$(OBJEXT) debug.$(OBJEXT) \ - error.$(OBJEXT) util.$(OBJEXT) + error.$(OBJEXT) util.$(OBJEXT) match.$(OBJEXT) am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) file.$(OBJEXT) amfeatures_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3) am_bsdsecurity_OBJECTS = bsd-security.test.$(OBJEXT) @@ -92,7 +93,7 @@ file_OBJECTS = $(am_file_OBJECTS) file_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_genversion_OBJECTS = genversion.$(OBJEXT) genversion_OBJECTS = $(am_genversion_OBJECTS) -genversion_DEPENDENCIES = $(am__DEPENDENCIES_1) versuff.o +genversion_DEPENDENCIES = $(am__DEPENDENCIES_1) versuff.lo am_statfs_OBJECTS = statfs.test.$(OBJEXT) statfs_OBJECTS = $(am_statfs_OBJECTS) statfs_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3) @@ -127,11 +128,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -139,6 +143,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -323,50 +329,80 @@ lib_LTLIBRARIES = libamanda.la REGDIR = ../regex-src REGsrcdir = $(srcdir)/$(REGDIR) INCLUDES = -I$(REGsrcdir) +LINT = @AMLINT@ +LINTFLAGS = @AMLINTFLAGS@ libamanda_la_SOURCES = \ - alloc.c amflock.c \ - bsd-security.c \ - clock.c \ - debug.c dgram.c \ - event.c error.c \ - amfeatures.c \ - file.c fileheader.c \ - krb4-security.c krb5-security.c \ - match.c \ - packet.c pipespawn.c protocol.c \ - regcomp.c regerror.c regexec.c regfree.c \ - rsh-security.c \ - security.c sl.c ssh-security.c statfs.c \ - stream.c tapelist.c \ - token.c \ - util.c \ - versuff.c version.c + alloc.c \ + amfeatures.c \ + amflock.c \ + bsd-security.c \ + bsdtcp-security.c \ + bsdudp-security.c \ + clock.c \ + debug.c \ + dgram.c \ + error.c \ + event.c \ + file.c \ + fileheader.c \ + krb4-security.c \ + krb5-security.c \ + match.c \ + packet.c \ + pipespawn.c \ + protocol.c \ + regcomp.c \ + regerror.c \ + regexec.c \ + regfree.c \ + rsh-security.c \ + security.c \ + security-util.c \ + sl.c \ + ssh-security.c \ + statfs.c \ + stream.c \ + tapelist.c \ + token.c \ + util.c \ + version.c \ + versuff.c libamanda_la_LIBADD = @LTLIBOBJS@ @LTALLOCA@ libamanda_la_LDFLAGS = -release $(VERSION) -noinst_HEADERS = amanda.h amregex.h arglist.h \ - clock.h \ - dgram.h \ - event.h \ - amfeatures.h \ - packet.h pipespawn.h protocol.h \ - queue.h \ - sl.h security.h statfs.h \ - stream.h \ - tapelist.h \ - token.h \ - util.h \ - version.h \ - fileheader.h +noinst_HEADERS = \ + amanda.h \ + amfeatures.h \ + amregex.h \ + arglist.h \ + clock.h \ + dgram.h \ + event.h \ + fileheader.h \ + packet.h \ + pipespawn.h \ + protocol.h \ + queue.h \ + security.h \ + security-util.h \ + sl.h \ + statfs.h \ + stream.h \ + tapelist.h \ + token.h \ + util.h \ + version.h genversion_SOURCES = genversion.c -genversion_LDADD = $(libamanda_la_LIBADD) versuff.o -REGEXHSRC = $(REGsrcdir)/regex2.h \ - $(REGsrcdir)/regcomp.c \ - $(REGsrcdir)/regexec.c \ - $(REGsrcdir)/regerror.c \ +genversion_LDADD = $(libamanda_la_LIBADD) versuff.lo +REGEXCSRC = $(REGsrcdir)/regcomp.c \ + $(REGsrcdir)/regexec.c \ + $(REGsrcdir)/regerror.c \ $(REGsrcdir)/regfree.c +REGEXHSRC = $(REGsrcdir)/regex2.h \ + $(REGEXCSRC) + # these are used for testing only: TEST_PROGS = statfs token file bsdsecurity amfeatures @@ -379,7 +415,8 @@ STANDARD_COMMON_STUFF_NOT_FILE = \ clock.$(OBJEXT) \ debug.$(OBJEXT) \ error.$(OBJEXT) \ - util.$(OBJEXT) + util.$(OBJEXT) \ + match.$(OBJEXT) STANDARD_COMMON_STUFF = \ $(STANDARD_COMMON_STUFF_NOT_FILE) \ @@ -514,6 +551,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amflock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd-security.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd-security.test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsdtcp-security.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsdudp-security.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dgram.Plo@am__quote@ @@ -534,6 +573,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regfree.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsh-security.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/security-util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/security.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh-security.Plo@am__quote@ @@ -774,16 +814,28 @@ regerror.@OBJEXT@ regerror.lo: regex.h regerror.ih regfree.@OBJEXT@ regfree.lo: regex.h regex.h: $(REGEXHSRC) $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -i _REGEX_H_ $(REGEXHSRC) >$@ + sh $(REGsrcdir)/mkh -i _REGEX_H_ $(REGEXHSRC) >$@ regcomp.ih: $(REGsrcdir)/regcomp.c $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -p $(REGsrcdir)/regcomp.c >$@ + sh $(REGsrcdir)/mkh -p $(REGsrcdir)/regcomp.c >$@ engine.ih: $(REGsrcdir)/engine.c $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -p $(REGsrcdir)/engine.c >$@ + sh $(REGsrcdir)/mkh -p $(REGsrcdir)/engine.c >$@ regerror.ih: $(REGsrcdir)/regerror.c $(REGsrcdir)/mkh - sh $(REGsrcdir)/mkh -o -p $(REGsrcdir)/regerror.c >$@ + sh $(REGsrcdir)/mkh -p $(REGsrcdir)/regerror.c >$@ + +lint: + @echo $(LINT) $(libamanda_la_SOURCES) + @$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config $(INCLUDES) $(libamanda_la_SOURCES) + @echo $(LINT) $(genversion_SOURCES) + @$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config $(INCLUDES) $(genversion_SOURCES) + +listlibsrc: + @ for p in $(libamanda_la_SOURCES) $(REGEXCSRC); do \ + listlibsrcs="$$listlibsrcs `pwd`/$$p"; \ + done; \ + echo $$listlibsrcs >listlibsrc.output %.test.c: $(srcdir)/%.c echo '#define TEST' >$@ diff --git a/common-src/alloc.c b/common-src/alloc.c index 0a0cdef..81670ea 100644 --- a/common-src/alloc.c +++ b/common-src/alloc.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: alloc.c,v 1.35 2005/12/21 19:07:49 paddy_s Exp $ + * $Id: alloc.c,v 1.37 2006/07/05 10:41:32 martinea Exp $ * * Memory allocators with error handling. If the allocation fails, * errordump() is called, relieving the caller from checking the return @@ -34,7 +34,7 @@ #include "arglist.h" #include "queue.h" -static char *internal_vstralloc P((const char *, va_list)); +static char *internal_vstralloc(const char *, va_list); /* *===================================================================== @@ -63,10 +63,11 @@ static char *internal_vstralloc P((const char *, va_list)); */ const char * -debug_caller_loc(file, line) - const char *file; - int line; +debug_caller_loc( + const char *file, + int line) { + /*@keep@*/ struct loc_str { char *str; LIST_ENTRY(loc_str) le; @@ -78,7 +79,7 @@ debug_caller_loc(file, line) if ((p = strrchr(file, '/')) != NULL) file = p + 1; /* just the last path element */ - snprintf(loc, sizeof(loc), "%s@%d", file, line); + snprintf(loc, SIZEOF(loc), "%s@%d", file, line); for (ls = LIST_FIRST(&root); ls != NULL; ls = LIST_NEXT(ls, le)) { if (strcmp(loc, ls->str) == 0) { @@ -97,7 +98,7 @@ debug_caller_loc(file, line) /* * This is a new entry. Put it at the head of the list. */ - ls = malloc(sizeof(*ls)); + ls = malloc(SIZEOF(*ls)); if (ls == NULL) return ("??"); /* not much better than abort */ ls->str = malloc(strlen(loc) + 1); @@ -138,9 +139,9 @@ static char *saved_file; static int saved_line; int -debug_alloc_push (s, l) - char *s; - int l; +debug_alloc_push( + char *s, + int l) { debug_alloc_loc_info[debug_alloc_ptr].file = s; debug_alloc_loc_info[debug_alloc_ptr].line = l; @@ -162,7 +163,7 @@ debug_alloc_push (s, l) */ void -debug_alloc_pop () +debug_alloc_pop(void) { debug_alloc_ptr = (debug_alloc_ptr + DEBUG_ALLOC_SAVE_MAX - 1) % DEBUG_ALLOC_SAVE_MAX; @@ -174,20 +175,21 @@ debug_alloc_pop () * alloc - a wrapper for malloc. */ void * -debug_alloc(s, l, size) - const char *s; - int l; - size_t size; +debug_alloc( + const char *s, + int l, + size_t size) { void *addr; malloc_enter(debug_caller_loc(s, l)); addr = (void *)malloc(max(size, 1)); if (addr == NULL) { - errordump("%s@%d: memory allocation failed (%u bytes requested)", + errordump("%s@%d: memory allocation failed (" SIZE_T_FMT " bytes requested)", s ? s : "(unknown)", s ? l : -1, - size); + (SIZE_T_FMT_TYPE)size); + /*NOTREACHED*/ } malloc_leave(debug_caller_loc(s, l)); return addr; @@ -198,11 +200,11 @@ debug_alloc(s, l, size) * newalloc - free existing buffer and then alloc a new one. */ void * -debug_newalloc(s, l, old, size) - const char *s; - int l; - void *old; - size_t size; +debug_newalloc( + const char *s, + int l, + void *old, + size_t size) { char *addr; @@ -219,10 +221,10 @@ debug_newalloc(s, l, old, size) * Just like strdup()! */ char * -debug_stralloc(s, l, str) - const char *s; - int l; - const char *str; +debug_stralloc( + const char *s, + int l, + const char *str) { char *addr; @@ -235,9 +237,10 @@ debug_stralloc(s, l, str) /* vstrextend -- Extends the existing string by appending the other * arguments. */ -arglist_function(char *vstrextend, - char **, - oldstr) +/*@ignore@*/ +arglist_function( + char *vstrextend, + char **, oldstr) { char *keep = *oldstr; va_list ap; @@ -252,6 +255,7 @@ arglist_function(char *vstrextend, arglist_end(ap); return *oldstr; } +/*@end@*/ /* * internal_vstralloc - copies up to MAX_STR_ARGS strings into newly @@ -264,21 +268,21 @@ arglist_function(char *vstrextend, #define MAX_VSTRALLOC_ARGS 32 static char * -internal_vstralloc(str, argp) - const char *str; - va_list argp; +internal_vstralloc( + const char *str, + va_list argp) { char *next; char *result; - int a; + int a, b; size_t total_len; const char *arg[MAX_VSTRALLOC_ARGS+1]; size_t len[MAX_VSTRALLOC_ARGS+1]; size_t l; - const char *s; if (str == NULL) { - return NULL; /* probably will not happen */ + errordump("internal_vstralloc: str is NULL"); + /*NOTREACHED*/ } a = 0; @@ -292,24 +296,24 @@ internal_vstralloc(str, argp) continue; /* minor optimisation */ } if (a >= MAX_VSTRALLOC_ARGS) { - errordump("%s@%d: more than %d arg%s to vstralloc", + errordump("%s@%d: more than %d args to vstralloc", saved_file ? saved_file : "(unknown)", saved_file ? saved_line : -1, - MAX_VSTRALLOC_ARGS, - (MAX_VSTRALLOC_ARGS == 1) ? "" : "s"); + MAX_VSTRALLOC_ARGS); + /*NOTREACHED*/ } arg[a] = next; len[a] = l; total_len += l; a++; } - arg[a] = NULL; - len[a] = 0; - next = result = debug_alloc(saved_file, saved_line, total_len+1); - for (a = 0; (s = arg[a]) != NULL; a++) { - memcpy(next, s, len[a]); - next += len[a]; + result = debug_alloc(saved_file, saved_line, total_len+1); + + next = result; + for (b = 0; b < a; b++) { + memcpy(next, arg[b], len[b]); + next += len[b]; } *next = '\0'; @@ -320,7 +324,9 @@ internal_vstralloc(str, argp) /* * vstralloc - copies multiple strings into newly allocated memory. */ -arglist_function(char *debug_vstralloc, const char *, str) +arglist_function( + char *debug_vstralloc, + const char *, str) { va_list argp; char *result; @@ -339,11 +345,11 @@ arglist_function(char *debug_vstralloc, const char *, str) * newstralloc - free existing string and then stralloc a new one. */ char * -debug_newstralloc(s, l, oldstr, newstr) - const char *s; - int l; - char *oldstr; - const char *newstr; +debug_newstralloc( + const char *s, + int l, + char *oldstr, + const char *newstr) { char *addr; @@ -358,11 +364,10 @@ debug_newstralloc(s, l, oldstr, newstr) /* * newvstralloc - free existing string and then vstralloc a new one. */ -arglist_function1(char *debug_newvstralloc, - char *, - oldstr, - const char *, - newstr) +arglist_function1( + char *debug_newvstralloc, + char *, oldstr, + const char *, newstr) { va_list argp; char *result; @@ -382,7 +387,7 @@ arglist_function1(char *debug_newvstralloc, * safe_env - build a "safe" environment list. */ char ** -safe_env() +safe_env(void) { static char *safe_env_list[] = { "TZ", @@ -402,7 +407,7 @@ safe_env() * safe_env_list so our result is always a valid, although possibly * empty, environment list. */ -#define SAFE_ENV_CNT (sizeof(safe_env_list) / sizeof(*safe_env_list)) +#define SAFE_ENV_CNT (size_t)(sizeof(safe_env_list) / sizeof(*safe_env_list)) char **envp = safe_env_list + SAFE_ENV_CNT - 1; char **p; @@ -411,7 +416,7 @@ safe_env() char *v; size_t l1, l2; - if ((q = (char **)malloc(sizeof(safe_env_list))) != NULL) { + if ((q = (char **)malloc(SIZEOF(safe_env_list))) != NULL) { envp = q; for (p = safe_env_list; *p != NULL; p++) { if ((v = getenv(*p)) == NULL) { @@ -447,19 +452,19 @@ safe_env() */ int -debug_amtable_alloc(s, l, table, current, elsize, count, bump, init_func) - const char *s; - int l; - void **table; - int *current; - size_t elsize; - int count; - int bump; - void (*init_func)(void *); +debug_amtable_alloc( + const char *s, + int l, + void **table, + size_t *current, + size_t elsize, + size_t count, + int bump, + void (*init_func)(void *)) { void *table_new; - int table_count_new; - int i; + size_t table_count_new; + size_t i; if (count >= *current) { table_count_new = ((count + bump) / bump) * bump; @@ -492,9 +497,9 @@ debug_amtable_alloc(s, l, table, current, elsize, count, bump, init_func) */ void -amtable_free(table, current) - void **table; - int *current; +amtable_free( + void **table, + size_t *current) { amfree(*table); *current = 0; diff --git a/common-src/alloca.c b/common-src/alloca.c index ad10087..c6664b7 100644 --- a/common-src/alloca.c +++ b/common-src/alloca.c @@ -21,9 +21,7 @@ allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include "amanda.h" #ifndef HAVE_ALLOCA @@ -131,7 +129,7 @@ find_stack_direction () alignment chunk size. The following default should work okay. */ #ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) +#define ALIGN_SIZE SIZEOF(double) #endif typedef union hdr @@ -193,7 +191,7 @@ alloca (size) /* Allocate combined header + user data storage. */ { - register pointer new = malloc (sizeof (header) + size); + register pointer new = malloc (SIZEOF (header) + size); /* Address of header. */ ((header *) new)->h.next = last_alloca_header; @@ -203,7 +201,7 @@ alloca (size) /* User storage begins just after header. */ - return (pointer) ((char *) new + sizeof (header)); + return (pointer) ((char *) new + SIZEOF (header)); } } diff --git a/common-src/amanda.h b/common-src/amanda.h index 66cff1d..ccea175 100644 --- a/common-src/amanda.h +++ b/common-src/amanda.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: amanda.h,v 1.123 2006/03/03 15:05:15 vectro Exp $ + * $Id: amanda.h,v 1.131 2006/07/25 18:27:56 martinea Exp $ * * the central header file included by all amanda sources */ @@ -35,6 +35,25 @@ #include "config.h" #endif +/* + * Force large file source even if configure guesses wrong. + */ +#ifndef _LARGE_FILE_SOURCE +#define _LARGE_FILES 1 +#endif + +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE 1 +#endif + +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 +#endif + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + /* * I would prefer that each Amanda module include only those system headers * that are locally needed, but on most Unixes the system header files are not @@ -47,18 +66,6 @@ # include #endif -#if 0 -/* an explanation for this is available in the CHANGES file for - amanda-2.4.0b5 */ -#ifdef HAVE_ASM_BYTEORDER_H -# include -#endif -#endif - -#ifdef HAVE_SYS_TYPES_H -# include -#endif - /* from the autoconf documentation */ #ifdef HAVE_DIRENT_H # include @@ -124,6 +131,10 @@ # include #endif +#ifdef HAVE_LIBGEN_H +# include +#endif + #ifdef HAVE_STRING_H # include #endif @@ -136,6 +147,10 @@ # include #endif +#ifdef HAVE_MATH_H +# include +#endif + #ifdef HAVE_SYS_FILE_H # include #endif @@ -186,6 +201,10 @@ struct iovec { # include #endif +#ifdef HAVE_STDARG_H +#include +#endif + #ifdef WAIT_USES_INT typedef int amwait_t; # ifndef WEXITSTATUS @@ -275,12 +294,12 @@ struct iovec { #ifdef USE_DBMALLOC #include "dbmalloc.h" #else -#define malloc_enter(func) -#define malloc_leave(func) -#define malloc_mark(ptr) -#define malloc_chain_check() -#define malloc_dump(fd) -#define malloc_list(a,b,c) +#define malloc_enter(func) ((void)0) +#define malloc_leave(func) ((void)0) +#define malloc_mark(ptr) ((void)0) +#define malloc_chain_check() ((void)0) +#define malloc_dump(fd) ((void)0) +#define malloc_list(a,b,c) ((void)0) #define malloc_inuse(hist) (*(hist) = 0, 0) #define dbmalloc_caller_loc(x,y) (x) #endif @@ -302,20 +321,35 @@ struct iovec { extern int errno; #endif +/* + * Some compilers have int for type of sizeof() some use size_t. + * size_t is the one we want... + */ +#define SIZEOF(x) (size_t)sizeof(x) + /* * Some older BSD systems don't have these FD_ macros, so if not, provide them. */ -#ifndef FD_SET -# define FD_SETSIZE (sizeof(fd_set) * 8) -# define FD_SET(n, p) (((fd_set *) (p))->fds_bits[0] |= (1 << ((n) % 32))) -# define FD_CLR(n, p) (((fd_set *) (p))->fds_bits[0] &= ~(1 << ((n) % 32))) -# define FD_ISSET(n, p) (((fd_set *) (p))->fds_bits[0] & (1 << ((n) % 32))) -# define FD_ZERO(p) memset((p), 0, sizeof(*(p))) +#if !defined(FD_SET) || defined(LINT) || defined(__lint) +# undef FD_SETSIZE +# define FD_SETSIZE (int)(SIZEOF(fd_set) * CHAR_BIT) + +# undef FD_SET +# define FD_SET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] |= (int)((1 << ((n) % WORD_BIT)))) + +# undef FD_CLR +# define FD_CLR(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] &= (int)(~(1 << ((n) % WORD_BIT)))) + +# undef FD_ISSET +# define FD_ISSET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] & (1 << ((n) % WORD_BIT))) + +# undef FD_ZERO +# define FD_ZERO(p) memset((p), 0, SIZEOF(*(p))) #endif #ifndef FD_COPY -# define FD_COPY(p, q) memcpy((q), (p), sizeof(fd_set)) +# define FD_COPY(p, q) memcpy((q), (p), SIZEOF(*(p))) #endif @@ -332,30 +366,16 @@ extern int errno; # define void char #endif -/* - * Macros to allow code to adapt to both ANSI and class C environments. - * - * P(): prototype argument macro - removes arguments from prototypes in - * class C environments - * stringize(): turn a bare word or words into a quoted string - * stringconcat(): turn two quoted strings into one - */ -#if STDC_HEADERS -# define P(parms) parms -# define stringize(x) #x -# define stringconcat(x, y) x ## y -#else -# define P(parms) () -# define stringize(x) "x" -# define stringconcat(x, y) x/**/y -#endif +#define stringize(x) #x +#define stringconcat(x, y) x ## y /* * So that we can use GNUC attributes (such as to get -Wall warnings * for printf-like functions). Only do this in gcc 2.7 or later ... * it may work on earlier stuff, but why chance it. */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 7 +#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 7 || defined(S_SPLINT_S) || defined(LINT) || defined(__lint) +#undef __attribute__ #define __attribute__(__x) #endif @@ -373,6 +393,7 @@ extern int errno; onerror(abort); \ error("assert: %s false, file %s, line %d", \ stringize(exp), __FILE__, __LINE__); \ + /*NOTREACHED*/ \ } \ } while (0) @@ -383,27 +404,29 @@ extern int errno; */ #ifdef DEBUG_CODE /* { */ -# define dbopen() debug_open() +# define dbopen(a) debug_open(a) # define dbreopen(a,b) debug_reopen(a,b) +# define dbrename(a,b) debug_rename(a,b) # define dbclose() debug_close() -# define dbprintf(p) (debug? (debug_printf p, 0) : 0) +# define dbprintf(p) (debug_printf p) # define dbfd() debug_fd() # define dbfp() debug_fp() # define dbfn() debug_fn() -extern void debug_open P((void)); -extern void debug_reopen P((char *file, char *notation)); -extern void debug_close P((void)); -extern void debug_printf P((const char *format, ...)) +extern void debug_open(char *subdir); +extern void debug_reopen(char *file, char *notation); +extern void debug_rename(char *config, char *subdir); +extern void debug_close(void); +extern void debug_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -extern int debug_fd P((void)); -extern FILE * debug_fp P((void)); -extern char * debug_fn P((void)); -extern void set_debug_prefix_pid P((pid_t)); -extern char *debug_prefix P((char *)); -extern char *debug_prefix_time P((char *)); +extern int debug_fd(void); +extern FILE * debug_fp(void); +extern char * debug_fn(void); +extern void set_debug_prefix_pid(pid_t); +extern char *debug_prefix(char *); +extern char *debug_prefix_time(char *); #else /* }{ */ -# define dbopen() +# define dbopen(a) # define dbreopen(a,b) # define dbclose() # define dbprintf(p) @@ -418,7 +441,7 @@ extern char *debug_prefix_time P((char *)); /* amanda #days calculation, with roundoff */ #define SECS_PER_DAY (24*60*60) -#define days_diff(a, b) (((b) - (a) + SECS_PER_DAY/2) / SECS_PER_DAY) +#define days_diff(a, b) (int)(((b) - (a) + SECS_PER_DAY/2) / SECS_PER_DAY) /* Global constants. */ #ifndef AMANDA_SERVICE_NAME @@ -431,10 +454,10 @@ extern char *debug_prefix_time P((char *)); #define SERVICE_SUFFIX "" #endif #ifndef AMANDA_SERVICE_DEFAULT -#define AMANDA_SERVICE_DEFAULT 10080 +#define AMANDA_SERVICE_DEFAULT ((in_port_t)10080) #endif #ifndef KAMANDA_SERVICE_DEFAULT -#define KAMANDA_SERVICE_DEFAULT 10081 +#define KAMANDA_SERVICE_DEFAULT ((in_port_t)10081) #endif #define am_round(v,u) ((((v) + (u) - 1) / (u)) * (u)) @@ -452,30 +475,31 @@ extern char *debug_prefix_time P((char *)); /* Maximum length of tape label, plus one for null-terminator. */ #define MAX_TAPE_LABEL_LEN (10240) #define MAX_TAPE_LABEL_BUF (MAX_TAPE_LABEL_LEN+1) +#define MAX_TAPE_LABEL_FMT "%10240s" /* Define miscellaneous amanda functions. */ #define ERR_INTERACTIVE 1 #define ERR_SYSLOG 2 #define ERR_AMANDALOG 4 -extern void set_logerror P((void (*f)(char *))); -extern void set_pname P((char *pname)); -extern char *get_pname P((void)); +extern void set_logerror(void (*f)(char *)); +extern void set_pname(char *pname); +extern char *get_pname(void); extern int erroutput_type; -extern void error P((const char *format, ...)) +extern void error(const char *format, ...) __attribute__ ((format (printf, 1, 2), noreturn)); -extern void errordump P((const char *format, ...)) +extern void errordump(const char *format, ...) __attribute__ ((format (printf, 1, 2), noreturn)); -extern int onerror P((void (*errf)(void))); +extern int onerror(void (*errf)(void)); -extern void *debug_alloc P((const char *c, int l, size_t size)); -extern void *debug_newalloc P((const char *c, int l, void *old, size_t size)); -extern char *debug_stralloc P((const char *c, int l, const char *str)); -extern char *debug_newstralloc P((const char *c, int l, char *oldstr, - const char *newstr)); -extern const char *debug_caller_loc P((const char *file, int line)); -extern int debug_alloc_push P((char *file, int line)); -extern void debug_alloc_pop P((void)); +extern void *debug_alloc (const char *c, int l, size_t size); +extern void *debug_newalloc (const char *c, int l, void *old, size_t size); +extern char *debug_stralloc (const char *c, int l, const char *str); +extern char *debug_newstralloc(const char *c, int l, char *oldstr, + const char *newstr); +extern const char *debug_caller_loc (const char *file, int line); +extern int debug_alloc_push (char *file, int line); +extern void debug_alloc_pop (void); #define alloc(s) debug_alloc(__FILE__, __LINE__, (s)) #define newalloc(p,s) debug_newalloc(__FILE__, __LINE__, (p), (s)) @@ -515,29 +539,30 @@ extern void debug_alloc_pop P((void)); #define vstralloc debug_alloc_push(__FILE__,__LINE__)?0:debug_vstralloc #define newvstralloc debug_alloc_push(__FILE__,__LINE__)?0:debug_newvstralloc -extern char *debug_vstralloc P((const char *str, ...)); -extern char *debug_newvstralloc P((char *oldstr, const char *newstr, ...)); +extern char *debug_vstralloc(const char *str, ...); +extern char *debug_newvstralloc(char *oldstr, const char *newstr, ...); #define stralloc2(s1,s2) vstralloc((s1),(s2),NULL) #define newstralloc2(p,s1,s2) newvstralloc((p),(s1),(s2),NULL) /* Usage: vstrextend(foo, "bar, "baz", NULL). Extends the existing * string, or allocates a brand new one. */ -extern char *vstrextend P((char **oldstr, ...)); +extern char *vstrextend(char **oldstr, ...); -extern char *debug_agets P((const char *c, int l, FILE *file)); -extern char *debug_areads P((const char *c, int l, int fd)); +extern /*@only@*/ /*@null@*/ char *debug_agets(const char *c, int l, FILE *file); +extern /*@only@*/ /*@null@*/ char *debug_areads(const char *c, int l, int fd); #define agets(f) debug_agets(__FILE__,__LINE__,(f)) #define areads(f) debug_areads(__FILE__,__LINE__,(f)) -extern int debug_amtable_alloc P((const char *file, +extern int debug_amtable_alloc(const char *file, int line, void **table, - int *current, + size_t *current, size_t elsize, - int count, + size_t count, int bump, - void (*init_func)(void *))); + void (*init_func)(void *)); + #define amtable_alloc(t,c,s,n,b,f) debug_amtable_alloc(__FILE__, \ __LINE__, \ (t), \ @@ -547,29 +572,30 @@ extern int debug_amtable_alloc P((const char *file, (b), \ (f)) -extern void amtable_free P((void **table, int *current)); +extern void amtable_free(void **table, size_t *current); extern uid_t client_uid; extern gid_t client_gid; -extern void safe_fd P((int fd_start, int fd_count)); -extern void safe_cd P((void)); -extern void save_core P((void)); -extern char **safe_env P((void)); -extern char *validate_regexp P((char *regex)); -extern char *validate_glob P((char *glob)); -extern char *clean_regex P((char *regex)); -extern int match P((char *regex, char *str)); -extern int match_glob P((char *glob, char *str)); -extern char *glob_to_regex P((char *glob)); -extern int match_tar P((char *glob, char *str)); -extern char *tar_to_regex P((char *glob)); -extern int match_host P((char *glob, char *host)); -extern int match_disk P((char *glob, char *disk)); -extern int match_datestamp P((char *dateexp, char *datestamp)); -extern int match_level P((char *levelexp, char *level)); -extern time_t unctime P((char *timestr)); -extern ssize_t areads_dataready P((int fd)); -extern void areads_relbuf P((int fd)); + +void safe_fd(int fd_start, int fd_count); +void safe_cd(void); +void save_core(void); +char ** safe_env(void); +char * validate_regexp(const char *regex); +char * validate_glob(const char *glob); +char * clean_regex(const char *regex); +int match(const char *regex, const char *str); +int match_glob(const char *glob, const char *str); +char * glob_to_regex(const char *glob); +int match_tar(const char *glob, const char *str); +char * tar_to_regex(const char *glob); +int match_host(const char *glob, const char *host); +int match_disk(const char *glob, const char *disk); +int match_datestamp(const char *dateexp, const char *datestamp); +int match_level(const char *levelexp, const char *level); +time_t unctime(char *timestr); +ssize_t areads_dataready(int fd); +void areads_relbuf(int fd); /* * amfree(ptr) -- if allocated, release space and set ptr to NULL. @@ -579,13 +605,14 @@ extern void areads_relbuf P((int fd)); */ #define amfree(ptr) do { \ - if(ptr) { \ + if((ptr) != NULL) { \ int e__errno = errno; \ free(ptr); \ (ptr) = NULL; \ errno = e__errno; \ + (void)(ptr); /* Fix value never used warning at end of routines */ \ } \ -} while(0) +} while (0) #define strappend(s1,s2) do { \ char *t_t_t = (s1) ? stralloc2((s1),(s2)) : stralloc((s2)); \ @@ -620,26 +647,29 @@ extern void areads_relbuf P((int fd)); areads_relbuf(fd); \ } \ (fd) = -1; \ + (void)(fd); /* Fix value never used warning at end of routines */ \ } while(0) #define afclose(f) do { \ if((f) != NULL) { \ fclose(f); \ + (f) = NULL; \ + (void)(f); /* Fix value never used warning at end of routines */ \ } \ - (f) = NULL; \ } while(0) #define apclose(p) do { \ if((p) != NULL) { \ pclose(p); \ + (p) = NULL; \ + (void)(p); /* Fix value never used warning at end of routines */ \ } \ - (p) = NULL; \ } while(0) /* * Return the number of elements in an array. */ -#define am_countof(a) (sizeof(a) / sizeof((a)[0])) +#define am_countof(a) (int)(SIZEOF(a) / SIZEOF((a)[0])) /* * min/max. Don't do something like @@ -725,7 +755,7 @@ extern void areads_relbuf P((int fd)); */ #define STR_SIZE 4096 /* a generic string buffer size */ -#define NUM_STR_SIZE 32 /* a generic number buffer size */ +#define NUM_STR_SIZE 128 /* a generic number buffer size */ #define skip_whitespace(ptr,c) do { \ while((c) != '\n' && isspace(c)) (c) = *(ptr)++; \ @@ -748,9 +778,34 @@ extern void areads_relbuf P((int fd)); while(isdigit(c)) (c) = *(ptr)++; \ } while(0) +#define skip_quoted_string(ptr, c) do { \ + int iq = 0; \ + while (((c) != '\0') && !((iq == 0) && isspace(c))) { \ + if ((c) == '"') { \ + iq = !iq; \ + } else if (((c) == '\\') && (*(ptr) == '"')) { \ + (ptr)++; \ + } \ + (c) = *(ptr)++; \ + } \ +} while (0) + +#define skip_quoted_line(ptr, c) do { \ + int iq = 0; \ + while((c) && !((iq == 0) && ((c) == '\n'))) { \ + if ((c) == '"') \ + iq = !iq; \ + (c) = *(ptr)++; \ + } \ + if(c) \ + (c) = *(ptr)++; \ +} while(0) + #define skip_line(ptr,c) do { \ - while((c) && (c) != '\n') (c) = *(ptr)++; \ - if(c) (c) = *(ptr)++; \ + while((c) && (c) != '\n') \ + (c) = *(ptr)++; \ + if(c) \ + (c) = *(ptr)++; \ } while(0) #define copy_string(ptr,c,f,l,fp) do { \ @@ -759,12 +814,14 @@ extern void areads_relbuf P((int fd)); if((fp) >= (f) + (l) - 1) { \ *(fp) = '\0'; \ (fp) = NULL; \ + (void)(fp); /* Fix value never used warning at end of routines */ \ break; \ } \ *(fp)++ = (c); \ (c) = *(ptr)++; \ } \ - if(fp) *fp = '\0'; \ + if(fp) \ + *fp = '\0'; \ } while(0) #define copy_string_cs(ptr,c,f,l,fp) do { \ @@ -787,27 +844,18 @@ extern void areads_relbuf P((int fd)); || ((s)[1] == '.' && (s)[2] == '\0'))) /* from amflock.c */ -extern int amflock P((int fd, char *resource)); -extern int amroflock P((int fd, char *resource)); -extern int amfunlock P((int fd, char *resource)); +extern int amflock(int fd, char *resource); +extern int amroflock(int fd, char *resource); +extern int amfunlock(int fd, char *resource); /* from file.c */ -extern int mkpdir P((char *file, int mode, uid_t uid, gid_t gid)); -extern int rmpdir P((char *file, char *topdir)); -extern char *sanitise_filename P((char *inp)); - -/* from bsd-security.c */ -extern char *check_user_ruserok P((const char *host, - struct passwd *pwd, - const char *user)); -extern char *check_user_amandahosts P((const char *host, - struct passwd *pwd, - const char *user)); +extern int mkpdir(char *file, mode_t mode, uid_t uid, gid_t gid); +extern int rmpdir(char *file, char *topdir); +extern char *sanitise_filename(char *inp); +/* from old bsd-security.c */ extern int debug; -extern int check_security P((struct sockaddr_in *, char *, unsigned long, - char **)); - +extern int check_security(struct sockaddr_in *, char *, unsigned long, char **); /* * Handle functions which are not always declared on all systems. This @@ -816,39 +864,39 @@ extern int check_security P((struct sockaddr_in *, char *, unsigned long, /* AIX #defines accept, and provides a prototype for the alternate name */ #if !defined(HAVE_ACCEPT_DECL) && !defined(accept) -extern int accept P((int s, struct sockaddr *addr, int *addrlen)); +extern int accept(int s, struct sockaddr *addr, socklen_t *addrlen); #endif #ifndef HAVE_ATOF_DECL -extern double atof P((const char *ptr)); +extern double atof(const char *ptr); #endif #ifndef HAVE_BCOPY # define bcopy(from,to,n) ((void)memmove((to), (from), (n))) #else # ifndef HAVE_BCOPY_DECL -extern void bcopy P((const void *s1, void *s2, size_t n)); +extern void bcopy(const void *s1, void *s2, size_t n); # endif #endif #ifndef HAVE_BIND_DECL -extern int bind P((int s, const struct sockaddr *name, int namelen)); +extern int bind(int s, const struct sockaddr *name, socklen_t namelen); #endif #ifndef HAVE_BZERO #define bzero(s,n) ((void)memset((s),0,(n))) #else # ifndef HAVE_BZERO_DECL -extern void bzero P((void *s, size_t n)); +extern void bzero(void *s, size_t n); # endif #endif #ifndef HAVE_CLOSELOG_DECL -extern void closelog P((void)); +extern void closelog(void); #endif #ifndef HAVE_CONNECT_DECL -extern int connect P((int s, struct sockaddr *name, int namelen)); +extern int connect(int s, struct sockaddr *name, socklen_t namelen); #endif #if !defined(TEXTDB) && !defined(HAVE_DBM_OPEN_DECL) @@ -869,77 +917,77 @@ extern int connect P((int s, struct sockaddr *name, int namelen)); } datum; #endif - extern DBM *dbm_open P((char *file, int flags, int mode)); - extern void dbm_close P((DBM *db)); - extern datum dbm_fetch P((DBM *db, datum key)); - extern datum dbm_firstkey P((DBM *db)); - extern datum dbm_nextkey P((DBM *db)); - extern int dbm_delete P((DBM *db, datum key)); - extern int dbm_store P((DBM *db, datum key, datum content, int flg)); + extern DBM *dbm_open(char *file, int flags, int mode); + extern void dbm_close(DBM *db); + extern datum dbm_fetch(DBM *db, datum key); + extern datum dbm_firstkey(DBM *db); + extern datum dbm_nextkey(DBM *db); + extern int dbm_delete(DBM *db, datum key); + extern int dbm_store(DBM *db, datum key, datum content, int flg); #endif #ifndef HAVE_FCLOSE_DECL -extern int fclose P((FILE *stream)); +extern int fclose(FILE *stream); #endif #ifndef HAVE_FFLUSH_DECL -extern int fflush P((FILE *stream)); +extern int fflush(FILE *stream); #endif #ifndef HAVE_FPRINTF_DECL -extern int fprintf P((FILE *stream, const char *format, ...)); +extern int fprintf(FILE *stream, const char *format, ...); #endif #ifndef HAVE_FPUTC_DECL -extern int fputc P((int c, FILE *stream)); +extern int fputc(int c, FILE *stream); #endif #ifndef HAVE_FPUTS_DECL -extern int fputs P((const char *s, FILE *stream)); +extern int fputs(const char *s, FILE *stream); #endif #ifndef HAVE_FREAD_DECL -extern size_t fread P((void *ptr, size_t size, size_t nitems, FILE *stream)); +extern size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); #endif #ifndef HAVE_FSEEK_DECL -extern int fseek P((FILE *stream, long offset, int ptrname)); +extern int fseek(FILE *stream, long offset, int ptrname); #endif #ifndef HAVE_FWRITE_DECL -extern size_t fwrite P((const void *ptr, size_t size, size_t nitems, - FILE *stream)); +extern size_t fwrite(const void *ptr, size_t size, size_t nitems, + FILE *stream); #endif #ifndef HAVE_GETHOSTNAME_DECL -extern int gethostname P((char *name, int namelen)); +extern int gethostname(char *name, int namelen); #endif #ifndef HAVE_GETOPT_DECL extern char *optarg; -extern int getopt P((int argc, char * const *argv, const char *optstring)); +extern int getopt(int argc, char * const *argv, const char *optstring); #endif /* AIX #defines getpeername, and provides a prototype for the alternate name */ #if !defined(HAVE_GETPEERNAME_DECL) && !defined(getpeername) -extern int getpeername P((int s, struct sockaddr *name, int *namelen)); +extern int getpeername(int s, struct sockaddr *name, socklen_t *namelen); #endif /* AIX #defines getsockname, and provides a prototype for the alternate name */ #if !defined(HAVE_GETSOCKNAME_DECL) && !defined(getsockname) -extern int getsockname P((int s, struct sockaddr *name, int *namelen)); +extern int getsockname(int s, struct sockaddr *name, socklen_t *namelen); #endif #ifndef HAVE_GETSOCKOPT_DECL -extern int getsockopt P((int s, int level, int optname, char *optval, - int *optlen)); +extern int getsockopt(int s, int level, int optname, char *optval, + socklen_t *optlen); #endif #ifndef HAVE_GETTIMEOFDAY_DECL # ifdef HAVE_TWO_ARG_GETTIMEOFDAY -extern int gettimeofday P((struct timeval *tp, struct timezone *tzp)); +extern int gettimeofday(struct timeval *tp, struct timezone *tzp); # else -extern int gettimeofday P((struct timeval *tp)); +extern int gettimeofday(struct timeval *tp); # endif #endif @@ -947,245 +995,251 @@ extern int gettimeofday P((struct timeval *tp)); # define initgroups(name,basegid) 0 #else # ifndef HAVE_INITGROUPS_DECL -extern int initgroups P((const char *name, gid_t basegid)); +extern int initgroups(const char *name, gid_t basegid); # endif #endif #ifndef HAVE_IOCTL_DECL -extern int ioctl P((int fildes, int request, ...)); +extern int ioctl(int fildes, int request, ...); +#endif + +#ifndef isnormal +#ifndef HAVE_ISNORMAL +#define isnormal(f) (((f) < 0.0) || ((f) > 0.0)) +#endif #endif #ifndef HAVE_LISTEN_DECL -extern int listen P((int s, int backlog)); +extern int listen(int s, int backlog); #endif #ifndef HAVE_LSTAT_DECL -extern int lstat P((const char *path, struct stat *buf)); +extern int lstat(const char *path, struct stat *buf); #endif #ifndef HAVE_MALLOC_DECL -extern void *malloc P((size_t size)); +extern void *malloc (size_t size); #endif #ifndef HAVE_MEMMOVE_DECL #ifdef HAVE_MEMMOVE -extern void *memmove P((void *to, const void *from, size_t n)); +extern void *memmove(void *to, const void *from, size_t n); #else -extern char *memmove P((char *to, /*const*/ char *from, size_t n)); +extern char *memmove(char *to, /*const*/ char *from, size_t n); #endif #endif #ifndef HAVE_MEMSET_DECL -extern void *memset P((void *s, int c, size_t n)); +extern void *memset(void *s, int c, size_t n); #endif #ifndef HAVE_MKTEMP_DECL -extern char *mktemp P((char *template)); +extern char *mktemp(char *template); #endif #ifndef HAVE_MKSTEMP_DECL -extern int mkstemp P((char *template)); +extern int mkstemp(char *template); #endif #ifndef HAVE_MKTIME_DECL -extern time_t mktime P((struct tm *timeptr)); +extern time_t mktime(struct tm *timeptr); #endif #ifndef HAVE_OPENLOG_DECL #ifdef LOG_AUTH -extern void openlog P((const char *ident, int logopt, int facility)); +extern void openlog(const char *ident, int logopt, int facility); #else -extern void openlog P((const char *ident, int logopt)); +extern void openlog(const char *ident, int logopt); #endif #endif #ifndef HAVE_PCLOSE_DECL -extern int pclose P((FILE *stream)); +extern int pclose(FILE *stream); #endif #ifndef HAVE_PERROR_DECL -extern void perror P((const char *s)); +extern void perror(const char *s); #endif #ifndef HAVE_PRINTF_DECL -extern int printf P((const char *format, ...)); +extern int printf(const char *format, ...); #endif #ifndef HAVE_PUTS_DECL -extern int puts P((const char *s)); +extern int puts(const char *s); #endif #ifndef HAVE_REALLOC_DECL -extern void *realloc P((void *ptr, size_t size)); +extern void *realloc(void *ptr, size_t size); #endif /* AIX #defines recvfrom, and provides a prototype for the alternate name */ #if !defined(HAVE_RECVFROM_DECL) && !defined(recvfrom) -extern int recvfrom P((int s, char *buf, int len, int flags, - struct sockaddr *from, int *fromlen)); +extern int recvfrom(int s, char *buf, int len, int flags, + struct sockaddr *from, socklen_t *fromlen); #endif #ifndef HAVE_REMOVE_DECL -extern int remove P((const char *path)); +extern int remove(const char *path); #endif #ifndef HAVE_RENAME_DECL -extern int rename P((const char *old, const char *new)); +extern int rename(const char *old, const char *new); #endif #ifndef HAVE_REWIND_DECL -extern void rewind P((FILE *stream)); +extern void rewind(FILE *stream); #endif #ifndef HAVE_RUSEROK_DECL -extern int ruserok P((const char *rhost, int suser, - const char *ruser, const char *luser)); +extern int ruserok(const char *rhost, int suser, + const char *ruser, const char *luser); #endif #ifndef HAVE_SELECT_DECL -extern int select P((int nfds, +extern int select(int nfds, SELECT_ARG_TYPE *readfds, SELECT_ARG_TYPE *writefds, SELECT_ARG_TYPE *exceptfds, - struct timeval *timeout)); + struct timeval *timeout); #endif #ifndef HAVE_SENDTO_DECL -extern int sendto P((int s, const char *msg, int len, int flags, - const struct sockaddr *to, int tolen)); +extern int sendto(int s, const char *msg, int len, int flags, + const struct sockaddr *to, int tolen); #endif #ifdef HAVE_SETRESGID -#define setegid(x) setresgid(-1,(x),-1) +#define setegid(x) setresgid((gid_t)-1,(x),(gid_t)-1) #ifndef HAVE_SETRESGID_DECL -extern int setresgid P((gid_t rgid, gid_t egid, gid_t sgid)); +extern int setresgid(gid_t rgid, gid_t egid, gid_t sgid); #endif #else #ifndef HAVE_SETEGID_DECL -extern int setegid P((gid_t egid)); +extern int setegid(gid_t egid); #endif #endif #ifdef HAVE_SETRESUID -#define seteuid(x) setresuid(-1,(x),-1) +#define seteuid(x) setresuid((uid_t)-1,(x),(uid_t)-1) #ifndef HAVE_SETRESUID_DECL -extern int setresuid P((uid_t ruid, uid_t euid, uid_t suid)); +extern int setresuid(uid_t ruid, uid_t euid, uid_t suid); #endif #else #ifndef HAVE_SETEUID_DECL -extern int seteuid P((uid_t euid)); +extern int seteuid(uid_t euid); #endif #endif #ifndef HAVE_SETPGID_DECL #ifdef HAVE_SETPGID -extern int setpgid P((int pid, int pgid)); +extern int setpgid(pid_t pid, pid_t pgid); #endif #endif #ifndef HAVE_SETPGRP_DECL #ifdef SETPGRP_VOID -extern pid_t setpgrp P((void)); +extern pid_t setpgrp(void); #else -extern pid_t setpgrp P((int pgrp, int pid)); +extern pid_t setpgrp(pid_t pgrp, pid_t pid); #endif #endif #ifndef HAVE_SETSOCKOPT_DECL -extern int setsockopt P((int s, int level, int optname, - const char *optval, int optlen)); +extern int setsockopt(int s, int level, int optname, + const char *optval, int optlen); #endif #ifdef HAVE_SHMGET #ifndef HAVE_SHMAT_DECL -extern void *shmat P((int shmid, const SHM_ARG_TYPE *shmaddr, int shmflg)); +extern void *shmat(int shmid, const SHM_ARG_TYPE *shmaddr, int shmflg); #endif #ifndef HAVE_SHMCTL_DECL -extern int shmctl P((int shmid, int cmd, struct shmid_ds *buf)); +extern int shmctl(int shmid, int cmd, struct shmid_ds *buf); #endif #ifndef HAVE_SHMDT_DECL -extern int shmdt P((SHM_ARG_TYPE *shaddr)); +extern int shmdt(SHM_ARG_TYPE *shaddr); #endif #ifndef HAVE_SHMGET_DECL -extern int shmget P((key_t key, size_t size, int shmflg)); +extern int shmget(key_t key, size_t size, int shmflg); #endif #endif #ifndef HAVE_SNPRINTF_DECL #include "arglist.h" -int snprintf P((char *buf, size_t len, const char *format,...)) +int snprintf(char *buf, size_t len, const char *format,...) __attribute__((format(printf,3,4))); #endif #ifndef HAVE_VSNPRINTF_DECL #include "arglist.h" -int vsnprintf P((char *buf, size_t len, const char *format, va_list ap)); +int vsnprintf(char *buf, size_t len, const char *format, va_list ap); #endif #ifndef HAVE_SOCKET_DECL -extern int socket P((int domain, int type, int protocol)); +extern int socket(int domain, int type, int protocol); #endif #ifndef HAVE_SOCKETPAIR_DECL -extern int socketpair P((int domain, int type, int protocol, int sv[2])); +extern int socketpair(int domain, int type, int protocol, int sv[2]); #endif #ifndef HAVE_SSCANF_DECL -extern int sscanf P((const char *s, const char *format, ...)); +extern int sscanf(const char *s, const char *format, ...); #endif #ifndef HAVE_STRCASECMP_DECL -extern int strcasecmp P((const char *s1, const char *s2)); +extern int strcasecmp(const char *s1, const char *s2); #endif #ifndef HAVE_STRERROR_DECL -extern char *strerror P((int errnum)); +extern char *strerror(int errnum); #endif #ifndef HAVE_STRFTIME_DECL -extern size_t strftime P((char *s, size_t maxsize, const char *format, - const struct tm *timeptr)); +extern size_t strftime(char *s, size_t maxsize, const char *format, + const struct tm *timeptr); #endif #ifndef HAVE_STRNCASECMP_DECL -extern int strncasecmp P((const char *s1, const char *s2, int n)); +extern int strncasecmp(const char *s1, const char *s2, int n); #endif #ifndef HAVE_SYSLOG_DECL -extern void syslog P((int priority, const char *logstring, ...)) +extern void syslog(int priority, const char *logstring, ...) __attribute__ ((format (printf, 2, 3))); #endif #ifndef HAVE_SYSTEM_DECL -extern int system P((const char *string)); +extern int system(const char *string); #endif #ifndef HAVE_TIME_DECL -extern time_t time P((time_t *tloc)); +extern time_t time(time_t *tloc); #endif #ifndef HAVE_TOLOWER_DECL -extern int tolower P((int c)); +extern int tolower(int c); #endif #ifndef HAVE_TOUPPER_DECL -extern int toupper P((int c)); +extern int toupper(int c); #endif #ifndef HAVE_UNGETC_DECL -extern int ungetc P((int c, FILE *stream)); +extern int ungetc(int c, FILE *stream); #endif #ifndef HAVE_VFPRINTF_DECL #include "arglist.h" -extern int vfprintf P((FILE *stream, const char *format, va_list ap)); +extern int vfprintf(FILE *stream, const char *format, va_list ap); #endif #ifndef HAVE_VPRINTF_DECL #include "arglist.h" -extern int vprintf P((const char *format, va_list ap)); +extern int vprintf(const char *format, va_list ap); #endif #if !defined(S_ISCHR) && defined(_S_IFCHR) && defined(_S_IFMT) @@ -1200,12 +1254,12 @@ extern int vprintf P((const char *format, va_list ap)); #ifdef HAVE_WAIT4 #define waitpid(pid,status,options) wait4(pid,status,options,0) #else -extern pid_t waitpid P((pid_t pid, amwait_t *stat_loc, int options)); +extern pid_t waitpid(pid_t pid, amwait_t *stat_loc, int options); #endif #endif #ifndef HAVE_WRITEV_DECL -extern ssize_t writev P((int fd, const struct iovec *iov, int iovcnt)); +extern ssize_t writev(int fd, const struct iovec *iov, int iovcnt); #endif #ifndef STDIN_FILENO @@ -1225,82 +1279,147 @@ extern ssize_t writev P((int fd, const struct iovec *iov, int iovcnt)); #if defined(_S_IFMT) && defined(_S_IFDIR) #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) #else -error: Don t know how to define S_ISDIR +#error Don t know how to define S_ISDIR +#endif +#endif + +#if SIZEOF_SIZE_T == SIZEOF_INT +# define SIZE_T_FMT "%u" +# define SIZE_T_FMT_TYPE unsigned +# define SIZE_T_ATOI (size_t)atoi +# ifndef SIZE_MAX +# define SIZE_MAX UINT_MAX +# endif +#else +# define SIZE_T_FMT "%lu" +# define SIZE_T_FMT_TYPE unsigned long +# define SIZE_T_ATOI (size_t)atol +# ifndef SIZE_MAX +# define SIZE_MAX ULONG_MAX +# endif +#endif + +#if SIZEOF_SSIZE_T == SIZEOF_INT +# define SSIZE_T_FMT "%d" +# define SSIZE_T_FMT_TYPE int +# define SSIZE_T_ATOI (ssize_t)atoi +# ifndef SSIZE_MAX +# define SSIZE_MAX INT_MAX +# endif +# ifndef SSIZE_MIN +# define SSIZE_MIN INT_MIN +# endif +#else +# define SSIZE_T_FMT "%ld" +# define SSIZE_T_FMT_TYPE long +# define SSIZE_T_ATOI (ssize_t)atol +# ifndef SSIZE_MAX +# define SSIZE_MAX LONG_MAX +# endif +# ifndef SSIZE_MIN +# define SSIZE_MIN LONG_MIN +# endif #endif + +#if SIZEOF_TIME_T == SIZEOF_INT +# define TIME_T_FMT "%u" +# define TIME_T_FMT_TYPE unsigned +# define TIME_T_ATOI (time_t)atoi +# ifndef TIME_MAX +# define TIME_MAX UINT_MAX +# endif +#else +# define TIME_T_FMT "%lu" +# define TIME_T_FMT_TYPE unsigned long +# define TIME_T_ATOI (time_t)atol +# ifndef TIME_MAX +# define TIME_MAX ULONG_MAX +# endif #endif #if SIZEOF_OFF_T > SIZEOF_LONG -# define OFF_T_FMT LL_FMT +# define OFF_T_FMT "%lld" +# define OFF_T_RFMT "lld" +# define OFF_T_FMT_TYPE long long +# define OFF_T_ATOI (off_t)atoll +# define OFF_T_STRTOL (off_t)strtoll #else -# define OFF_T_FMT "%ld" +# if SIZEOF_OFF_T == SIZEOF_LONG +# define OFF_T_FMT "%ld" +# define OFF_T_RFMT "ld" +# define OFF_T_FMT_TYPE long +# define OFF_T_ATOI (off_t)atol +# define OFF_T_STRTOL (off_t)strtol +# else +# define OFF_T_FMT "%d" +# define OFF_T_RFMT "d" +# define OFF_T_FMT_TYPE int +# define OFF_T_ATOI (off_t)atoi +# define OFF_T_STRTOL (off_t)strtol +# endif #endif +#if SIZEOF_OFF_T == 8 +# ifdef OFF_MAX +# define AM64_MAX (off_t)(OFF_MAX) +# else +# define AM64_MAX (off_t)(9223372036854775807LL) +# endif +# ifdef OFF_MIN +# define AM64_MIN (off_t)(OFF_MIN) +# else +# define AM64_MIN (off_t)(-9223372036854775807LL -1LL) +# endif +# define AM64_FMT OFF_T_FMT +#else #if SIZEOF_LONG == 8 - typedef long am64_t; # ifdef LONG_MAX -# define AM64_MAX LONG_MAX +# define AM64_MAX (off_t)(LONG_MAX) # else -# define AM64_MAX 9223372036854775807L +# define AM64_MAX (off_t)9223372036854775807L # endif # ifdef LONG_MIN -# define AM64_MIN LONG_MIN +# define AM64_MIN (off_t)(LONG_MIN) # else -# define AM64_MIN -9223372036854775807L -1L +# define AM64_MIN (off_t)(-9223372036854775807L -1L) # endif # define AM64_FMT "%ld" #else #if SIZEOF_LONG_LONG == 8 - typedef long long am64_t; # ifdef LONG_LONG_MAX -# define AM64_MAX LONG_LONG_MAX +# define AM64_MAX (off_t)(LONG_LONG_MAX) # else -# define AM64_MAX 9223372036854775807LL +# define AM64_MAX (off_t)9223372036854775807LL # endif # ifdef LONG_LONG_MIN -# define AM64_MIN LONG_LONG_MIN +# define AM64_MIN (off_t)(LONG_LONG_MIN) # else -# define AM64_MIN -9223372036854775807LL -1LL +# define AM64_MIN (off_t)(-9223372036854775807LL -1LL) # endif # define AM64_FMT LL_FMT #else #if SIZEOF_INTMAX_T == 8 - typedef intmax_t am64_t; # ifdef INTMAX_MAX -# define AM64_MAX INTMAX_MAX +# define AM64_MAX (off_t)(INTMAX_MAX) # else -# define AM64_MAX 9223372036854775807LL +# define AM64_MAX (off_t)9223372036854775807LL # endif # ifdef INTMAX_MIN -# define AM64_MIN INTMAX_MIN +# define AM64_MIN (off_t)(INTMAX_MIN) # else -# define AM64_MIN -9223372036854775807LL -1LL +# define AM64_MIN (off_t)(-9223372036854775807LL -1LL) # endif # define AM64_FMT LL_FMT -#else -#if SIZEOF_OFF_T == 8 - typedef off_t am64_t; -# ifdef OFF_MAX -# define AM64_MAX OFF_MAX -# else -# define AM64_MAX 9223372036854775807LL -# endif -# ifdef OFF_MIN -# define AM64_MIN OFF_MIN -# else -# define AM64_MIN -9223372036854775807LL -1LL -# endif -# define AM64_FMT OFF_T_FMT -#else /* no 64 bits tyupe found, use long. */ - typedef long am64_t; +#else /* no 64 bits type found, use long. */ # ifdef LONG_MAX -# define AM64_MAX LONG_MAX +# define AM64_MAX (off_t)(LONG_MAX) # else -# define AM64_MAX 2147483647 +# define AM64_MAX (off_t)2147483647 # endif # ifdef LONG_MIN -# define AM64_MIN LONG_MIN +# define AM64_MIN (off_t)(LONG_MIN) # else -# define AM64_MIN -2147483647 -1 +# define AM64_MIN (off_t)(-2147483647 -1) # endif # define AM64_FMT "%ld" #endif @@ -1308,4 +1427,33 @@ error: Don t know how to define S_ISDIR #endif #endif +#ifdef HAVE_LIBREADLINE +# ifdef HAVE_READLINE_READLINE_H +# include +# ifdef HAVE_READLINE_HISTORY_H +# include +# endif +# else +# ifdef HAVE_READLINE_H +# include +# ifdef HAVE_HISTORY_H +# include +# endif +# else +# undef HAVE_LIBREADLINE +# endif +# endif +#else + +char * readline(const char *prompt); +void add_history(const char *line); + +#endif + +#define BIND_CYCLE_RETRIES 120 /* Total of 30 minutes */ + +#define DBG_SUBDIR_SERVER "server" +#define DBG_SUBDIR_CLIENT "client" +#define DBG_SUBDIR_AMANDAD "amandad" + #endif /* !AMANDA_H */ diff --git a/common-src/amfeatures.c b/common-src/amfeatures.c index 94fad87..89a1c38 100644 --- a/common-src/amfeatures.c +++ b/common-src/amfeatures.c @@ -25,7 +25,7 @@ */ /* - * $Id: amfeatures.c,v 1.18 2006/03/14 13:11:58 martinea Exp $ + * $Id: amfeatures.c,v 1.24 2006/07/19 17:46:07 martinea Exp $ * * Feature test related code. */ @@ -45,9 +45,9 @@ */ am_feature_t * -am_init_feature_set() +am_init_feature_set(void) { - am_feature_t *f = NULL; + am_feature_t *f; if ((f = am_allocate_feature_set()) != NULL) { /* @@ -109,13 +109,11 @@ am_init_feature_set() am_add_feature(f, fe_amidxtaped_nargs); am_add_feature(f, fe_amidxtaped_config); - am_add_feature(f, fe_recover_splits); - am_add_feature(f, fe_amidxtaped_exchange_features); - + am_add_feature(f, fe_recover_splits); + am_add_feature(f, fe_amidxtaped_exchange_features); am_add_feature(f, fe_partial_estimate); am_add_feature(f, fe_calcsize_estimate); am_add_feature(f, fe_selfcheck_calcsize); - am_add_feature(f, fe_options_compress_cust); am_add_feature(f, fe_options_srvcomp_cust); am_add_feature(f, fe_options_encrypt_cust); @@ -123,11 +121,30 @@ am_init_feature_set() am_add_feature(f, fe_options_client_decrypt_option); am_add_feature(f, fe_options_server_decrypt_option); - am_add_feature(f, fe_amindexd_marshall_in_OLSD); - am_add_feature(f, fe_amindexd_marshall_in_ORLD); - am_add_feature(f, fe_amindexd_marshall_in_DHST); + am_add_feature(f, fe_amindexd_marshall_in_OLSD); + am_add_feature(f, fe_amindexd_marshall_in_ORLD); + am_add_feature(f, fe_amindexd_marshall_in_DHST); am_add_feature(f, fe_amrecover_FEEDME); + am_add_feature(f, fe_amrecover_timestamp); + + am_add_feature(f, fe_interface_quoted_text); + + am_add_feature(f, fe_program_star); + + am_add_feature(f, fe_amindexd_options_hostname); + am_add_feature(f, fe_amindexd_options_features); + am_add_feature(f, fe_amindexd_options_auth); + + am_add_feature(f, fe_amidxtaped_options_hostname); + am_add_feature(f, fe_amidxtaped_options_features); + am_add_feature(f, fe_amidxtaped_options_auth); + + am_add_feature(f, fe_amrecover_message); + am_add_feature(f, fe_amrecover_feedme_tape); + + am_add_feature(f, fe_req_options_config); + } return f; } @@ -192,13 +209,13 @@ am_set_default_feature_set(void) */ am_feature_t * -am_allocate_feature_set() +am_allocate_feature_set(void) { size_t nbytes; am_feature_t *result; - result = (am_feature_t *)alloc(sizeof(*result)); - memset(result, 0, sizeof(*result)); + result = (am_feature_t *)alloc(SIZEOF(*result)); + memset(result, 0, SIZEOF(*result)); nbytes = (((size_t)last_feature) + 8) >> 3; result->size = nbytes; result->bytes = (unsigned char *)alloc(nbytes); @@ -218,8 +235,8 @@ am_allocate_feature_set() */ void -am_release_feature_set(f) - am_feature_t *f; +am_release_feature_set( + am_feature_t *f) { if (f != NULL) { amfree(f->bytes); @@ -242,9 +259,9 @@ am_release_feature_set(f) */ int -am_add_feature(f, n) - am_feature_t *f; - am_feature_e n; +am_add_feature( + am_feature_t *f, + am_feature_e n) { size_t byte; int bit; @@ -254,7 +271,7 @@ am_add_feature(f, n) byte = ((size_t)n) >> 3; if (byte < f->size) { bit = ((int)n) & 0x7; - f->bytes[byte] |= (1 << bit); + f->bytes[byte] = (unsigned char)((int)f->bytes[byte] | (unsigned char)(1 << bit)); result = 1; } } @@ -275,9 +292,9 @@ am_add_feature(f, n) */ int -am_remove_feature(f, n) - am_feature_t *f; - am_feature_e n; +am_remove_feature( + am_feature_t *f, + am_feature_e n) { size_t byte; int bit; @@ -287,7 +304,7 @@ am_remove_feature(f, n) byte = ((size_t)n) >> 3; if (byte < f->size) { bit = ((int)n) & 0x7; - f->bytes[byte] &= ~(1 << bit); + f->bytes[byte] = (unsigned char)((int)f->bytes[byte] & (unsigned char)~(1 << bit)); result = 1; } } @@ -307,9 +324,9 @@ am_remove_feature(f, n) */ int -am_has_feature(f, n) - am_feature_t *f; - am_feature_e n; +am_has_feature( + am_feature_t *f, + am_feature_e n) { size_t byte; int bit; @@ -337,8 +354,8 @@ am_has_feature(f, n) */ char * -am_feature_to_string(f) - am_feature_t *f; +am_feature_to_string( + am_feature_t *f) { char *result; size_t i; @@ -376,8 +393,8 @@ am_feature_to_string(f) */ am_feature_t * -am_string_to_feature(s) - char *s; +am_string_to_feature( + char *s) { am_feature_t *f = NULL; size_t i; @@ -410,7 +427,7 @@ am_string_to_feature(s) amfree(f); /* bad conversion */ break; } - f->bytes[i] = (ch1 << 4) | ch2; + f->bytes[i] = (unsigned char)((ch1 << 4) | ch2); } } return f; @@ -418,9 +435,9 @@ am_string_to_feature(s) #if defined(TEST) int -main(argc, argv) - int argc; - char **argv; +main( + int argc, + char **argv) { am_feature_t *f; am_feature_t *f1; diff --git a/common-src/amfeatures.h b/common-src/amfeatures.h index 8d9e9bd..562ca21 100644 --- a/common-src/amfeatures.h +++ b/common-src/amfeatures.h @@ -25,7 +25,7 @@ */ /* - * $Id: amfeatures.h,v 1.15 2006/03/14 13:11:58 martinea Exp $ + * $Id: amfeatures.h,v 1.21 2006/07/19 17:46:07 martinea Exp $ * * Define feature test related items. */ @@ -152,6 +152,24 @@ typedef enum { fe_amindexd_marshall_in_ORLD, fe_amindexd_marshall_in_DHST, fe_amrecover_FEEDME, + fe_amrecover_timestamp, + + fe_interface_quoted_text, + + fe_program_star, + + fe_amindexd_options_hostname, + fe_amindexd_options_features, + fe_amindexd_options_auth, + + fe_amidxtaped_options_hostname, + fe_amidxtaped_options_features, + fe_amidxtaped_options_auth, + + fe_amrecover_message, + fe_amrecover_feedme_tape, + + fe_req_options_config, /* * All new features must be inserted immediately *before* this entry. @@ -167,14 +185,14 @@ typedef struct am_feature_s { /* * Functions. */ -extern am_feature_t *am_init_feature_set P((void)); -extern am_feature_t *am_set_default_feature_set P((void)); -extern am_feature_t *am_allocate_feature_set P((void)); -extern void am_release_feature_set P((am_feature_t *)); -extern int am_add_feature P((am_feature_t *f, am_feature_e n)); -extern int am_remove_feature P((am_feature_t *f, am_feature_e n)); -extern int am_has_feature P((am_feature_t *f, am_feature_e n)); -extern char *am_feature_to_string P((am_feature_t *f)); -extern am_feature_t *am_string_to_feature P((char *s)); +extern am_feature_t *am_init_feature_set(void); +extern am_feature_t *am_set_default_feature_set(void); +extern am_feature_t *am_allocate_feature_set(void); +extern void am_release_feature_set(am_feature_t *); +extern int am_add_feature(am_feature_t *f, am_feature_e n); +extern int am_remove_feature(am_feature_t *f, am_feature_e n); +extern int am_has_feature(am_feature_t *f, am_feature_e n); +extern char *am_feature_to_string(am_feature_t *f); +extern am_feature_t *am_string_to_feature(char *s); #endif /* !AMFEATURES_H */ diff --git a/common-src/amflock.c b/common-src/amflock.c index 9fe27c7..2a00b38 100644 --- a/common-src/amflock.c +++ b/common-src/amflock.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: amflock.c,v 1.27 2005/10/06 17:26:21 martinea Exp $ + * $Id: amflock.c,v 1.28 2006/05/25 01:47:11 johnfranks Exp $ * * file locking routines, put here to hide the system dependant stuff * from the rest of the code @@ -57,7 +57,7 @@ # endif # if !defined(HAVE_FLOCK_DECL) && !defined(CONFIGURE_TEST) - extern int flock P((int fd, int operation)); + extern int flock(int fd, int operation); # endif #endif @@ -74,9 +74,10 @@ ** - returns errors for some non-files like pipes. ** - probably only works for files open for writing. */ -int use_lockf(fd, op) -int fd; /* fd of file to operate on */ -int op; /* true to lock; false to unlock */ +int +use_lockf( + int fd, /* fd of file to operate on */ + int op) /* true to lock; false to unlock */ { off_t pos; @@ -109,8 +110,9 @@ int op; /* true to lock; false to unlock */ /* Delete a lock file. */ -int delete_lock(fn) -char *fn; +int +delete_lock( + char *fn) { int rc; @@ -122,9 +124,10 @@ char *fn; /* Create a lock file. */ -int create_lock(fn, pid) -char *fn; -long pid; +int +create_lock( + char *fn, + pid_t pid) { int fd; FILE *f; @@ -133,7 +136,7 @@ long pid; (void)delete_lock(fn); /* that's MY file! */ mask = umask(0027); - fd = open(fn, O_WRONLY|O_CREAT|O_EXCL, 0640); + fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0640); umask(mask); if (fd == -1) return -1; @@ -150,8 +153,9 @@ long pid; /* Read the pid out of a lock file. ** -1=error, otherwise pid. */ -long read_lock(fn) -char *fn; /* name of lock file */ +long +read_lock( + char * fn) /* name of lock file */ { int save_errno; FILE *f; @@ -175,9 +179,10 @@ char *fn; /* name of lock file */ /* Link a lock if we can. ** 0=done, 1=already locked, -1=error. */ -int link_lock(lk, tlk) -char *lk; /* real lock file */ -char *tlk; /* temp lock file */ +int +link_lock( + char * lk, /* real lock file */ + char * tlk) /* temp lock file */ { int rc; int serrno; /* saved errno */ @@ -205,10 +210,11 @@ char *tlk; /* temp lock file */ /* Steal a lock if we can. ** 0=done; 1=still in use; -1 = error. */ -int steal_lock(fn, mypid, sres) -char *fn; /* name of lock file to steal */ -long mypid; /* my process id */ -char *sres; /* name of steal-resource to lock */ +int +steal_lock( + char * fn, /* name of lock file to steal */ + pid_t mypid, /* my process id */ + char * sres) /* name of steal-resource to lock */ { int fd; char buff[64]; @@ -258,9 +264,10 @@ error: /* Locking using existance of a file. */ -int ln_lock(res, op) -char *res; /* name of resource to lock */ -int op; /* true to lock; false to unlock */ +int +ln_lock( + char * res, /* name of resource to lock */ + int op) /* true to lock; false to unlock */ { long mypid; char *lockfile = NULL; @@ -284,7 +291,7 @@ int op; /* true to lock; false to unlock */ /* lock the resource */ - snprintf(pid_str, sizeof(pid_str), "%ld", mypid); + snprintf(pid_str, SIZEOF(pid_str), "%ld", mypid); tlockfile = vstralloc(AMANDA_TMPDIR, "am", res, ".", pid_str, NULL); (void)create_lock(tlockfile, mypid); @@ -313,19 +320,23 @@ int op; /* true to lock; false to unlock */ #endif -/* Get a file lock (for read-only files). -*/ -int amroflock(fd, resource) -int fd; -char *resource; +/* + * Get a file lock (for read-only files). + */ +int +amroflock( + int fd, + char * resource) { int r; #ifdef USE_POSIX_FCNTL + (void)resource; /* Quiet unused paramater warning */ lock.l_type = F_RDLCK; lock.l_whence = SEEK_SET; r = fcntl(fd, F_SETLKW, &lock); #else + (void)fd; /* Quiet unused paramater warning */ r = amflock(fd, resource); #endif @@ -335,26 +346,33 @@ char *resource; /* Get a file lock (for read/write files). */ -int amflock(fd, resource) -int fd; -char *resource; +int +amflock( + int fd, + char * resource) { int r; #ifdef USE_POSIX_FCNTL + (void)resource; /* Quiet unused paramater warning */ lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; r = fcntl(fd, F_SETLKW, &lock); #else #ifdef USE_FLOCK + (void)resource; /* Quiet unused paramater warning */ r = flock(fd, LOCK_EX); #else #ifdef USE_LOCKF + (void)resource; /* Quiet unused paramater warning */ r = use_lockf(fd, 1); #else #ifdef USE_LNLOCK + (void)fd; /* Quiet unused paramater warning */ r = ln_lock(resource, 1); #else + (void)fd; /* Quiet unused paramater warning */ + (void)resource; /* Quiet unused paramater warning */ r = 0; #endif #endif @@ -367,26 +385,33 @@ char *resource; /* Release a file lock. */ -int amfunlock(fd, resource) -int fd; -char *resource; +int +amfunlock( + int fd, + char * resource) { int r; #ifdef USE_POSIX_FCNTL + (void)resource; /* Quiet unused paramater warning */ lock.l_type = F_UNLCK; lock.l_whence = SEEK_SET; r = fcntl(fd, F_SETLK, &lock); #else #ifdef USE_FLOCK + (void)resource; /* Quiet unused paramater warning */ r = flock(fd, LOCK_UN); #else #ifdef USE_LOCKF + (void)fd; /* Quiet unused paramater warning */ r = use_lockf(fd, 0); #else #ifdef USE_LNLOCK + (void)fd; /* Quiet unused paramater warning */ r = ln_lock(resource, 0); #else + (void)fd; /* Quiet unused paramater warning */ + (void)resource; /* Quiet unused paramater warning */ r = 0; #endif #endif @@ -407,15 +432,21 @@ char *resource; ** for ever. */ #ifdef CONFIGURE_TEST -main() +int +main( + int argc, + char **argv) { int lockfd; char *filen = "/tmp/conftest.lock"; char *resn = "test"; int fd; + (void)argc; /* Quiet compiler warning */ + (void)argv; /* Quiet compiler warning */ + unlink(filen); - if ((lockfd = open(filen, O_RDONLY|O_CREAT|O_EXCL, 0600)) == -1) { + if ((lockfd = open(filen, O_RDONLY | O_CREAT | O_EXCL, 0600)) == -1) { perror (filen); exit(10); } @@ -437,7 +468,7 @@ main() close(lockfd); unlink(filen); - if ((lockfd = open(filen, O_WRONLY|O_CREAT|O_EXCL, 0600)) == -1) { + if ((lockfd = open(filen, O_WRONLY | O_CREAT | O_EXCL, 0600)) == -1) { perror (filen); exit(20); } diff --git a/common-src/amregex.h b/common-src/amregex.h index 6aa54c6..dfbc3b4 100644 --- a/common-src/amregex.h +++ b/common-src/amregex.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: amregex.h,v 1.10 1999/04/10 06:18:44 kashmir Exp $ + * $Id: amregex.h,v 1.11 2006/05/25 01:47:11 johnfranks Exp $ * * compatibility header file for Henry Spencer's regex library. */ @@ -61,12 +61,6 @@ #define CHAR_BIT 8 #endif -#if STDC_HEADERS -# define P(parms) parms -#else -# define P(parms) () -#endif - /* * So that we can use GNUC attributes (such as to get -Wall warnings * for printf-like functions). Only do this in gcc 2.7 or later ... @@ -77,15 +71,15 @@ #endif #ifndef HAVE_BCOPY_DECL -extern void bcopy P((const void *from, void *to, size_t n)); +extern void bcopy(const void *from, void *to, size_t n); #endif #ifndef HAVE_MEMMOVE_DECL -extern char *memmove P((char *to, char *from, size_t n)); +extern char *memmove(char *to, char *from, size_t n); #endif #ifndef HAVE_MEMSET_DECL -extern void *memset P((void *s, int c, size_t n)); +extern void *memset(void *s, int c, size_t n); #endif #if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) @@ -94,12 +88,12 @@ extern void *memset P((void *s, int c, size_t n)); #ifndef HAVE_SNPRINTF_DECL #include "arglist.h" -int snprintf P((char *buf, size_t len, const char *format,...)) +int snprintf (char *buf, size_t len, const char *format,...) __attribute__((format(printf,3,4))); #endif #ifndef HAVE_VSNPRINTF_DECL #include "arglist.h" -int vsnprintf P((char *buf, size_t len, const char *format, va_list ap)); +int vsnprintf(char *buf, size_t len, const char *format, va_list ap); #endif #define POSIX_MISTAKE diff --git a/common-src/arglist.h b/common-src/arglist.h index 1c87202..e18b4a7 100644 --- a/common-src/arglist.h +++ b/common-src/arglist.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: arglist.h,v 1.7 2002/12/03 21:36:39 martinea Exp $ + * $Id: arglist.h,v 1.9 2006/06/16 11:33:43 martinea Exp $ * * support macros for variable argument list declaration and definition */ @@ -57,6 +57,17 @@ arg2_type arg2_name, \ hook_type hook_name, ...) +#define printf_arglist_function3(fdecl, \ + arg1_type, arg1_name, \ + arg2_type, arg2_name, \ + arg3_type, arg3_name, \ + hook_type, hook_name) \ + __attribute__ ((format (printf, 4, 0))) \ + fdecl(arg1_type arg1_name, \ + arg2_type arg2_name, \ + arg3_type arg3_name, \ + hook_type hook_name, ...) + #define arglist_function(fdecl, \ hook_type, hook_name) \ fdecl(hook_type hook_name, ...) diff --git a/common-src/bsd-security.c b/common-src/bsd-security.c index 60e63d3..2d0766d 100644 --- a/common-src/bsd-security.c +++ b/common-src/bsd-security.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: bsd-security.c,v 1.54 2006/03/09 16:51:41 martinea Exp $ + * $Id: bsd-security.c,v 1.75 2006/07/19 17:41:14 martinea Exp $ * * "BSD" security module */ @@ -36,6 +36,7 @@ #include "event.h" #include "packet.h" #include "security.h" +#include "security-util.h" #include "stream.h" #include "version.h" @@ -65,130 +66,24 @@ #define bsdprintf(p) printf p #endif /* } */ -/* - * This is the private handle data - */ -struct bsd_handle { - /* - * This must be first. Instances of bsd_handle will be cast to - * security_handle_t's. - */ - security_handle_t sech; - - /* - * protocol handle for this request. Each request gets its own - * handle, so we differentiate packets for them with a "handle" header - * in each packet. - * - */ - int event_id; /* unique event_id */ - char *proto_handle; - - /* - * sequence number. - */ - int sequence; - - /* - * The remote host we're transmitting to - */ - char hostname[256]; - struct sockaddr_in peer; - - /* - * Function to call when recvpkt detects new incoming data for this - * handle - */ - void (*fn) P((void *, pkt_t *, security_status_t)); - - /* - * Argument for previous function - */ - void *arg; - - /* - * read (EV_WAIT) handle for a recv - */ - event_handle_t *ev_read; - - /* - * Timeout handle for a recv - */ - event_handle_t *ev_timeout; - - struct bsd_handle *prev, *next; -}; - -struct bsd_handle *bh_first=NULL, *bh_last=NULL; - -/* - * This is the internal security_stream data - */ -struct bsd_stream { - /* - * This must be first, because instances of this will be cast - * to security_stream_t's outside of this module. - */ - security_stream_t secstr; - - /* - * This is the file descriptor which we will do io on - */ - int fd; - - /* - * This is the file descriptor which we will listen for incoming - * connections on (for streams which receive connections) - */ - int socket; - - /* - * This is the local port this stream is bound to - */ - int port; - - /* - * This is the read event handle for this data stream - */ - event_handle_t *ev_read; - - /* - * This is the function and argument that is called when this stream - * is readable. It is passed a buffer of data read. - */ - void (*fn) P((void *, void *, ssize_t)); - void *arg; - - /* - * This is the buffer that we read data into that will be passed - * to the read callback. - */ - char databuf[NETWORK_BLOCK_BYTES]; -}; - /* * Interface functions */ -static void bsd_connect P((const char *, - char *(*)(char *, void *), - void (*)(void *, security_handle_t *, security_status_t), void *)); -static void bsd_accept P((int, int, void (*)(security_handle_t *, pkt_t *))); -static void bsd_close P((void *)); -static int bsd_sendpkt P((void *, pkt_t *)); -static void bsd_recvpkt P((void *, - void (*)(void *, pkt_t *, security_status_t), void *, int)); -static void bsd_recvpkt_cancel P((void *)); - -static void *bsd_stream_server P((void *)); -static int bsd_stream_accept P((void *)); -static void *bsd_stream_client P((void *, int)); -static void bsd_stream_close P((void *)); -static int bsd_stream_auth P((void *)); -static int bsd_stream_id P((void *)); -static int bsd_stream_write P((void *, const void *, size_t)); -static void bsd_stream_read P((void *, void (*)(void *, void *, ssize_t), - void *)); -static void bsd_stream_read_cancel P((void *)); +static void bsd_connect(const char *, char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), + void *, void *); +static void bsd_accept(const struct security_driver *, int, int, + void (*)(security_handle_t *, pkt_t *)); +static void bsd_close(void *); +static void * bsd_stream_server(void *); +static int bsd_stream_accept(void *); +static void * bsd_stream_client(void *, int); +static void bsd_stream_close(void *); +static int bsd_stream_auth(void *); +static int bsd_stream_id(void *); +static void bsd_stream_read(void *, void (*)(void *, void *, ssize_t), void *); +static ssize_t bsd_stream_read_sync(void *, void **); +static void bsd_stream_read_cancel(void *); /* * This is our interface to the outside world @@ -198,142 +93,54 @@ const security_driver_t bsd_security_driver = { bsd_connect, bsd_accept, bsd_close, - bsd_sendpkt, - bsd_recvpkt, - bsd_recvpkt_cancel, + udpbsd_sendpkt, + udp_recvpkt, + udp_recvpkt_cancel, bsd_stream_server, bsd_stream_accept, bsd_stream_client, bsd_stream_close, bsd_stream_auth, bsd_stream_id, - bsd_stream_write, + tcp_stream_write, bsd_stream_read, + bsd_stream_read_sync, bsd_stream_read_cancel, + sec_close_connection_none, }; /* * This is data local to the datagram socket. We have one datagram * per process, so it is global. */ -static struct { - dgram_t dgram; /* datagram to read/write from */ - struct sockaddr_in peer; /* who sent it to us */ - pkt_t pkt; /* parsed form of dgram */ - char *handle; /* handle from recvd packet */ - int sequence; /* seq no of packet */ - event_handle_t *ev_read; /* read event handle from dgram */ - int refcnt; /* number of handles blocked for reading */ -} netfd; +static udp_handle_t netfd; +static int not_init = 1; /* generate new handles from here */ static int newhandle = 0; -static int newevent = 0; - -/* - * We register one event handler for our network fd which takes - * care of all of our async requests. When all async requests - * have either been satisfied or cancelled, we unregister our - * network event handler. - */ -#define netfd_addref() do { \ - if (netfd.refcnt++ == 0) { \ - assert(netfd.ev_read == NULL); \ - netfd.ev_read = event_register(netfd.dgram.socket, EV_READFD, \ - netfd_read_callback, NULL); \ - } \ - assert(netfd.refcnt > 0); \ -} while (0) - -/* - * If this is the last request to be removed, then remove the - * reader event from the netfd. - */ -#define netfd_delref() do { \ - assert(netfd.refcnt > 0); \ - if (--netfd.refcnt == 0) { \ - assert(netfd.ev_read != NULL); \ - event_release(netfd.ev_read); \ - netfd.ev_read = NULL; \ - } \ -} while (0) - -/* - * This is the function and argument that is called when new requests - * arrive on the netfd. - */ -static void (*accept_fn) P((security_handle_t *, pkt_t *)); /* * These are the internal helper functions */ -static char *check_user P((struct bsd_handle *, const char *)); -static int inithandle P((struct bsd_handle *, struct hostent *, - int, char *, int)); -static const char *pkthdr2str P((const struct bsd_handle *, const pkt_t *)); -static int str2pkthdr P((void)); -static void netfd_read_callback P((void *)); -static void recvpkt_callback P((void *)); -static void recvpkt_timeout P((void *)); -static int recv_security_ok P((struct bsd_handle *)); -static void stream_read_callback P((void *)); - - -#if defined(SHOW_SECURITY_DETAIL) /* { */ -/* - * Display stat() information about a file. - */ -void show_stat_info(a, b) - char *a, *b; -{ - char *name = vstralloc(a, b, NULL); - struct stat sbuf; - struct passwd *pwptr; - char *owner; - struct group *grptr; - char *group; - - if (stat(name, &sbuf) != 0) { - bsdprintf(("%s: cannot stat %s: %s\n", - debug_prefix_time(NULL), name, strerror(errno))); - amfree(name); - return; - } - if ((pwptr = getpwuid(sbuf.st_uid)) == NULL) { - owner = alloc(NUM_STR_SIZE + 1); - snprintf(owner, NUM_STR_SIZE, "%ld", (long)sbuf.st_uid); - } else { - owner = stralloc(pwptr->pw_name); - } - if ((grptr = getgrgid(sbuf.st_gid)) == NULL) { - group = alloc(NUM_STR_SIZE + 1); - snprintf(owner, NUM_STR_SIZE, "%ld", (long)sbuf.st_gid); - } else { - group = stralloc(grptr->gr_name); - } - bsdprintf(("%s: processing file: %s\n", debug_prefix(NULL), name)); - bsdprintf(("%s: owner=%s group=%s mode=%03o\n", - debug_prefix(NULL), owner, group, (int) (sbuf.st_mode & 0777))); - amfree(name); - amfree(owner); - amfree(group); -} -#endif /* } */ +static void stream_read_callback(void *); +static void stream_read_sync_callback(void *); /* * Setup and return a handle outgoing to a client */ + static void -bsd_connect(hostname, conf_fn, fn, arg) - const char *hostname; - char *(*conf_fn) P((char *, void *)); - void (*fn) P((void *, security_handle_t *, security_status_t)); - void *arg; -{ - struct bsd_handle *bh; +bsd_connect( + const char * hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) +{ + struct sec_handle *bh; struct servent *se; struct hostent *he; - int port; + in_port_t port = 0; struct timeval sequence_time; amanda_timezone dontcare; int sequence; @@ -341,31 +148,40 @@ bsd_connect(hostname, conf_fn, fn, arg) assert(hostname != NULL); - bh = alloc(sizeof(*bh)); + (void)conf_fn; /* Quiet unused parameter warning */ + (void)datap; /* Quiet unused parameter warning */ + + bh = alloc(SIZEOF(*bh)); bh->proto_handle=NULL; + bh->udp = &netfd; security_handleinit(&bh->sech, &bsd_security_driver); /* * Only init the socket once */ - if (netfd.dgram.socket == 0) { + if (not_init == 1) { uid_t euid; dgram_zero(&netfd.dgram); - + euid = geteuid(); - seteuid(0); + seteuid((uid_t)0); dgram_bind(&netfd.dgram, &port); seteuid(euid); + netfd.handle = NULL; + netfd.pkt.body = NULL; + netfd.recv_security_ok = &bsd_recv_security_ok; + netfd.prefix_packet = &bsd_prefix_packet; /* * We must have a reserved port. Bomb if we didn't get one. */ if (port >= IPPORT_RESERVED) { security_seterror(&bh->sech, - "unable to bind to a reserved port (got port %d)", - port); + "unable to bind to a reserved port (got port %u)", + (unsigned int)port); (*fn)(arg, &bh->sech, S_ERROR); return; } + not_init = 0; } if ((he = gethostbyname(hostname)) == NULL) { @@ -374,32 +190,42 @@ bsd_connect(hostname, conf_fn, fn, arg) (*fn)(arg, &bh->sech, S_ERROR); return; } + bsdprintf(("Resolved hostname=%s\n", hostname)); if ((se = getservbyname(AMANDA_SERVICE_NAME, "udp")) == NULL) - port = htons(AMANDA_SERVICE_DEFAULT); + port = (in_port_t)htons(AMANDA_SERVICE_DEFAULT); else - port = se->s_port; + port = (in_port_t)se->s_port; amanda_gettimeofday(&sequence_time, &dontcare); sequence = (int)sequence_time.tv_sec ^ (int)sequence_time.tv_usec; - handle=malloc(15); - snprintf(handle,14,"000-%08x", newhandle++); - if (inithandle(bh, he, port, handle, sequence) < 0) + handle=alloc(15); + snprintf(handle, 14, "000-%08x", (unsigned)newhandle++); + if (udp_inithandle(&netfd, bh, he, port, handle, sequence) < 0) { (*fn)(arg, &bh->sech, S_ERROR); + amfree(bh->hostname); + amfree(bh); + } else (*fn)(arg, &bh->sech, S_OK); + amfree(handle); } /* * Setup to accept new incoming connections */ static void -bsd_accept(in, out, fn) - int in, out; - void (*fn) P((security_handle_t *, pkt_t *)); +bsd_accept( + const struct security_driver * driver, + int in, + int out, + void (*fn)(security_handle_t *, pkt_t *)) { assert(in >= 0 && out >= 0); assert(fn != NULL); + (void)out; /* Quiet unused parameter warning */ + (void)driver; /* Quiet unused parameter warning */ + /* * We assume in and out point to the same socket, and just use * in. @@ -411,983 +237,67 @@ bsd_accept(in, out, fn) * the recvpkt callback will call this function when it discovers * new incoming connections */ - accept_fn = fn; - - netfd_addref(); -} - -/* - * Given a hostname and a port, setup a bsd_handle - */ -static int -inithandle(bh, he, port, handle, sequence) - struct bsd_handle *bh; - struct hostent *he; - int port; - char *handle; - int sequence; -{ - int i; - - assert(he != NULL); - assert(port > 0); - - /* - * Save the hostname and port info - */ - strncpy(bh->hostname, he->h_name, sizeof(bh->hostname) - 1); - bh->hostname[sizeof(bh->hostname) - 1] = '\0'; - bh->peer.sin_addr = *(struct in_addr *)he->h_addr; - bh->peer.sin_port = port; - bh->peer.sin_family = AF_INET; - - bh->prev = bh_last; - if(bh_last) {bh->prev->next = bh;} - if(!bh_first) {bh_first = bh;} - bh->next = NULL; - bh_last = bh; - - /* - * Do a forward lookup of the hostname. This is unnecessary if we - * are initiating the connection, but is very serious if we are - * receiving. We want to make sure the hostname - * resolves back to the remote ip for security reasons. - */ - if ((he = gethostbyname(bh->hostname)) == NULL) { - security_seterror(&bh->sech, - "%s: could not resolve hostname", bh->hostname); - return (-1); - } - /* - * Make sure the hostname matches. This should always work. - */ - if (strncasecmp(bh->hostname, he->h_name, strlen(bh->hostname)) != 0) { - security_seterror(&bh->sech, - "%s: did not resolve to %s", bh->hostname, bh->hostname); - return (-1); - } - - /* - * Now look for a matching ip address. - */ - for (i = 0; he->h_addr_list[i] != NULL; i++) { - if (memcmp(&bh->peer.sin_addr, he->h_addr_list[i], - sizeof(struct in_addr)) == 0) { - break; - } - } - - /* - * If we didn't find it, try the aliases. This is a workaround for - * Solaris if DNS goes over NIS. - */ - if (he->h_addr_list[i] == NULL) { - const char *ipstr = inet_ntoa(bh->peer.sin_addr); - for (i = 0; he->h_aliases[i] != NULL; i++) { - if (strcmp(he->h_aliases[i], ipstr) == 0) - break; - } - /* - * No aliases either. Failure. Someone is fooling with us or - * DNS is messed up. - */ - if (he->h_aliases[i] == NULL) { - security_seterror(&bh->sech, - "DNS check failed: no matching ip address for %s", - bh->hostname); - return (-1); - } - } - - bh->sequence = sequence; - bh->event_id = newevent++; - bh->proto_handle = handle; - bh->fn = NULL; - bh->arg = NULL; - bh->ev_read = NULL; - bh->ev_timeout = NULL; - - bsdprintf(("%s: adding handle '%s'\n", - debug_prefix_time(NULL), bh->proto_handle)); + netfd.accept_fn = fn; + netfd.recv_security_ok = &bsd_recv_security_ok; + netfd.prefix_packet = &bsd_prefix_packet; + netfd.driver = &bsd_security_driver; - return(0); + udp_addref(&netfd, &udp_netfd_read_callback); } /* * Frees a handle allocated by the above */ static void -bsd_close(cookie) - void *cookie; +bsd_close( + void * cookie) { - struct bsd_handle *bh = cookie; + struct sec_handle *bh = cookie; if(bh->proto_handle == NULL) { return; } - bsdprintf(("%s: close handle '%s'\n", + bsdprintf(("%s: bsd: close handle '%s'\n", debug_prefix_time(NULL), bh->proto_handle)); - bsd_recvpkt_cancel(bh); + udp_recvpkt_cancel(bh); if(bh->next) { bh->next->prev = bh->prev; } else { - bh_last = bh->prev; + netfd.bh_last = bh->prev; } if(bh->prev) { bh->prev->next = bh->next; } else { - bh_first = bh->next; + netfd.bh_first = bh->next; } + amfree(bh->proto_handle); + amfree(bh->hostname); amfree(bh); } -/* - * Transmit a packet. Add security information first. - */ -static int -bsd_sendpkt(cookie, pkt) - void *cookie; - pkt_t *pkt; -{ - struct bsd_handle *bh = cookie; - struct passwd *pwd; - - assert(bh != NULL); - assert(pkt != NULL); - - /* - * Initialize this datagram, and add the header - */ - dgram_zero(&netfd.dgram); - dgram_cat(&netfd.dgram, pkthdr2str(bh, pkt)); - - /* - * Add the security info. This depends on which kind of packet we're - * sending. - */ - switch (pkt->type) { - case P_REQ: - /* - * Requests get sent with our username in the body - */ - if ((pwd = getpwuid(geteuid())) == NULL) { - security_seterror(&bh->sech, - "can't get login name for my uid %ld", (long)getuid()); - return (-1); - } - dgram_cat(&netfd.dgram, "SECURITY USER %s\n", pwd->pw_name); - break; - - default: - break; - } - - /* - * Add the body, and send it - */ - dgram_cat(&netfd.dgram, pkt->body); - if (dgram_send_addr(bh->peer, &netfd.dgram) != 0) { - security_seterror(&bh->sech, - "send %s to %s failed: %s", pkt_type2str(pkt->type), - bh->hostname, strerror(errno)); - return (-1); - } - return (0); -} - -/* - * Set up to receive a packet asynchronously, and call back when it has - * been read. - */ -static void -bsd_recvpkt(cookie, fn, arg, timeout) - void *cookie, *arg; - void (*fn) P((void *, pkt_t *, security_status_t)); - int timeout; -{ - struct bsd_handle *bh = cookie; - - assert(bh != NULL); - assert(fn != NULL); - - - /* - * Subsequent recvpkt calls override previous ones - */ - if (bh->ev_read == NULL) { - netfd_addref(); - bh->ev_read = event_register(bh->event_id, EV_WAIT, - recvpkt_callback, bh); - } - if (bh->ev_timeout != NULL) - event_release(bh->ev_timeout); - if (timeout < 0) - bh->ev_timeout = NULL; - else - bh->ev_timeout = event_register(timeout, EV_TIME, recvpkt_timeout, bh); - bh->fn = fn; - bh->arg = arg; -} - -/* - * Remove a async receive request on this handle from the queue. - * If it is the last one to be removed, then remove the event - * handler for our network fd - */ -static void -bsd_recvpkt_cancel(cookie) - void *cookie; -{ - struct bsd_handle *bh = cookie; - - assert(bh != NULL); - - if (bh->ev_read != NULL) { - netfd_delref(); - event_release(bh->ev_read); - bh->ev_read = NULL; - } - - if (bh->ev_timeout != NULL) { - event_release(bh->ev_timeout); - bh->ev_timeout = NULL; - } -} - -/* - * Callback for received packets. This is the function bsd_recvpkt - * registers with the event handler. It is called when the event handler - * realizes that data is waiting to be read on the network socket. - */ -static void -netfd_read_callback(cookie) - void *cookie; -{ - struct bsd_handle *bh; - struct hostent *he; - int a; - - assert(cookie == NULL); - -#ifndef TEST /* { */ - /* - * Receive the packet. - */ - dgram_zero(&netfd.dgram); - if (dgram_recv(&netfd.dgram, 0, &netfd.peer) < 0) - return; -#endif /* !TEST */ /* } */ - - /* - * Parse the packet. - */ - if (str2pkthdr() < 0) - return; - - /* - * If there are events waiting on this handle, we're done - */ - bh = bh_first; - while(bh != NULL && (strcmp(bh->proto_handle, netfd.handle) != 0 || - bh->sequence != netfd.sequence || - bh->peer.sin_addr.s_addr != netfd.peer.sin_addr.s_addr || - bh->peer.sin_port != netfd.peer.sin_port)) { - bh = bh->next; - } - if (bh && event_wakeup(bh->event_id) > 0) - return; - - /* - * If we didn't find a handle, then check for a new incoming packet. - * If no accept handler was setup, then just return. - */ - if (accept_fn == NULL) - return; - - he = gethostbyaddr((void *)&netfd.peer.sin_addr, - (int)sizeof(netfd.peer.sin_addr), AF_INET); - if (he == NULL) - return; - bh = alloc(sizeof(*bh)); - bh->proto_handle=NULL; - security_handleinit(&bh->sech, &bsd_security_driver); - a = inithandle(bh, - he, - netfd.peer.sin_port, - netfd.handle, - netfd.sequence); - if (a < 0) { - if(bh->next) { - bh->next->prev = bh->prev; - } - else { - bh_last = bh->prev; - } - if(bh->prev) { - bh->prev->next = bh->next; - } - else { - bh_first = bh->prev; - } - - bsdprintf(("%s: closeX handle '%s'\n", - debug_prefix_time(NULL), bh->proto_handle)); - - amfree(bh); - return; - } - /* - * Check the security of the packet. If it is bad, then pass NULL - * to the accept function instead of a packet. - */ - if (recv_security_ok(bh) < 0) - (*accept_fn)(&bh->sech, NULL); - else - (*accept_fn)(&bh->sech, &netfd.pkt); -} - -/* - * This is called when a handle is woken up because data read off of the - * net is for it. - */ -static void -recvpkt_callback(cookie) - void *cookie; -{ - struct bsd_handle *bh = cookie; - void (*fn) P((void *, pkt_t *, security_status_t)); - void *arg; - - assert(bh != NULL); - bsdprintf(("%s: receive handle '%s' netfd '%s'\n", - debug_prefix_time(NULL), bh->proto_handle,netfd.handle)); - - if(strcmp(bh->proto_handle,netfd.handle) != 0) assert(1); - - /* if it didn't come from the same host/port, forget it */ - if (memcmp(&bh->peer.sin_addr, &netfd.peer.sin_addr, - sizeof(netfd.peer.sin_addr)) != 0 || - bh->peer.sin_port != netfd.peer.sin_port) { - netfd.handle = NULL; - return; - } - - /* - * We need to cancel the recvpkt request before calling the callback - * because the callback may reschedule us. - */ - fn = bh->fn; - arg = bh->arg; - bsd_recvpkt_cancel(bh); - - /* - * Check the security of the packet. If it is bad, then pass NULL - * to the packet handling function instead of a packet. - */ - if (recv_security_ok(bh) < 0) - (*fn)(arg, NULL, S_ERROR); - else - (*fn)(arg, &netfd.pkt, S_OK); -} - -/* - * This is called when a handle times out before receiving a packet. - */ -static void -recvpkt_timeout(cookie) - void *cookie; -{ - struct bsd_handle *bh = cookie; - void (*fn) P((void *, pkt_t *, security_status_t)); - void *arg; - - assert(bh != NULL); - - assert(bh->ev_timeout != NULL); - fn = bh->fn; - arg = bh->arg; - bsd_recvpkt_cancel(bh); - (*fn)(arg, NULL, S_TIMEOUT); - -} - -/* - * Check the security of a received packet. Returns negative on security - * violation, or returns 0 if ok. Removes the security info from the pkt_t. - */ -static int -recv_security_ok(bh) - struct bsd_handle *bh; -{ - char *tok, *security, *body, *result; - pkt_t *pkt = &netfd.pkt; - - /* - * Set this preempively before we mangle the body. - */ - security_seterror(&bh->sech, - "bad SECURITY line: '%s'", pkt->body); - - /* - * Now, find the SECURITY line in the body, and parse it out - * into an argv. - */ - if (strncmp(pkt->body, "SECURITY", sizeof("SECURITY") - 1) == 0) { - tok = strtok(pkt->body, " "); - assert(strcmp(tok, "SECURITY") == 0); - /* security info goes until the newline */ - security = strtok(NULL, "\n"); - body = strtok(NULL, ""); - /* - * If the body is f-ked, then try to recover - */ - if (body == NULL) { - if (security != NULL) - body = security + strlen(security) + 2; - else - body = pkt->body; - } - } else { - security = NULL; - body = pkt->body; - } - - /* - * We need to do different things depending on which type of packet - * this is. - */ - switch (pkt->type) { - case P_REQ: - /* - * Request packets must come from a reserved port - */ - if (ntohs(bh->peer.sin_port) >= IPPORT_RESERVED) { - security_seterror(&bh->sech, - "host %s: port %d not secure", bh->hostname, - ntohs(bh->peer.sin_port)); - return (-1); - } - - /* - * Request packets contain a remote username. We need to check - * that we allow it in. - * - * They will look like: - * SECURITY USER [username] - */ - - /* there must be some security info */ - if (security == NULL) { - security_seterror(&bh->sech, - "no bsd SECURITY for P_REQ"); - return (-1); - } - - /* second word must be USER */ - if ((tok = strtok(security, " ")) == NULL) - return (-1); /* default errmsg */ - if (strcmp(tok, "USER") != 0) { - security_seterror(&bh->sech, - "REQ SECURITY line parse error, expecting USER, got %s", tok); - return (-1); - } - - /* the third word is the username */ - if ((tok = strtok(NULL, "")) == NULL) - return (-1); /* default errmsg */ - if ((result = check_user(bh, tok)) != NULL) { - security_seterror(&bh->sech, "%s", result); - amfree(result); - return (-1); - } - - /* we're good to go */ - break; - default: - break; - } - - /* - * If there is security info at the front of the packet, we need to - * shift the rest of the data up and nuke it. - */ - if (body != pkt->body) - memmove(pkt->body, body, strlen(body) + 1); - return (0); -} - -static char * -check_user(bh, remoteuser) - struct bsd_handle *bh; - const char *remoteuser; -{ - struct passwd *pwd; - char *r; - char *result = NULL; - char *localuser = NULL; - - /* lookup our local user name */ - if ((pwd = getpwnam(CLIENT_LOGIN)) == NULL) { - return vstralloc("getpwnam(", CLIENT_LOGIN, ") fails", NULL); - } - - /* - * Make a copy of the user name in case getpw* is called by - * any of the lower level routines. - */ - localuser = stralloc(pwd->pw_name); - -#ifndef USE_AMANDAHOSTS - r = check_user_ruserok(bh->hostname, pwd, remoteuser); -#else - r = check_user_amandahosts(bh->hostname, pwd, remoteuser); -#endif - if (r != NULL) { - result = vstralloc("access as ", localuser, " not allowed", - " from ", remoteuser, "@", bh->hostname, - ": ", r, - NULL); - amfree(r); - } - amfree(localuser); - return result; -} - -/* - * See if a remote user is allowed in. This version uses ruserok() - * and friends. - * - * Returns 0 on success, or negative on error. - */ -char * -check_user_ruserok(host, pwd, remoteuser) - const char *host; - struct passwd *pwd; - const char *remoteuser; -{ - int saved_stderr; - int fd[2]; - FILE *fError; - amwait_t exitcode; - pid_t ruserok_pid; - pid_t pid; - char *es; - char *result; - int ok; - char number[NUM_STR_SIZE]; - uid_t myuid = getuid(); - - /* - * note that some versions of ruserok (eg SunOS 3.2) look in - * "./.rhosts" rather than "~CLIENT_LOGIN/.rhosts", so we have to - * chdir ourselves. Sigh. - * - * And, believe it or not, some ruserok()'s try an initgroup just - * for the hell of it. Since we probably aren't root at this point - * it'll fail, and initgroup "helpfully" will blatt "Setgroups: Not owner" - * into our stderr output even though the initgroup failure is not a - * problem and is expected. Thanks a lot. Not. - */ - if (pipe(fd) != 0) { - return stralloc2("pipe() fails: ", strerror(errno)); - } - if ((ruserok_pid = fork()) < 0) { - return stralloc2("fork() fails: ", strerror(errno)); - } else if (ruserok_pid == 0) { - int ec; - - close(fd[0]); - fError = fdopen(fd[1], "w"); - /* pamper braindead ruserok's */ - if (chdir(pwd->pw_dir) != 0) { - fprintf(fError, "chdir(%s) failed: %s", - pwd->pw_dir, strerror(errno)); - fclose(fError); - exit(1); - } - -#if defined(SHOW_SECURITY_DETAIL) /* { */ - { - char *dir = stralloc(pwd->pw_dir); - - bsdprintf(("%s: calling ruserok(%s, %d, %s, %s)\n", - debug_prefix_time(NULL), - host, myuid == 0, remoteuser, pwd->pw_name)); - if (myuid == 0) { - bsdprintf(("%s: because you are running as root, ", - debug_prefix(NULL))); - bsdprintf(("/etc/hosts.equiv will not be used\n")); - } else { - show_stat_info("/etc/hosts.equiv", NULL); - } - show_stat_info(dir, "/.rhosts"); - amfree(dir); - } -#endif /* } */ - - saved_stderr = dup(2); - close(2); - if (open("/dev/null", O_RDWR) == -1) { - dbprintf(("Could not open /dev/null: %s\n", - strerror(errno))); - ec = 1; - } else { - ok = ruserok(host, myuid == 0, remoteuser, CLIENT_LOGIN); - if (ok < 0) { - ec = 1; - } else { - ec = 0; - } - } - (void)dup2(saved_stderr,2); - close(saved_stderr); - exit(ec); - } - close(fd[1]); - fError = fdopen(fd[0], "r"); - - result = NULL; - while ((es = agets(fError)) != NULL) { - if (result == NULL) { - result = stralloc(""); - } else { - strappend(result, ": "); - } - strappend(result, es); - } - close(fd[0]); - - while (1) { - if ((pid = wait(&exitcode)) == (pid_t) -1) { - if (errno == EINTR) { - continue; - } - amfree(result); - return stralloc2("ruserok wait failed: %s", strerror(errno)); - } - if (pid == ruserok_pid) { - break; - } - } - if (WIFSIGNALED(exitcode)) { - amfree(result); - snprintf(number, sizeof(number), "%d", WTERMSIG(exitcode)); - return stralloc2("ruserok child got signal ", number); - } - if (WEXITSTATUS(exitcode) == 0) { - amfree(result); - } else if (result == NULL) { - result = stralloc("ruserok failed"); - } - - return result; -} - -/* - * Check to see if a user is allowed in. This version uses .amandahosts - * Returns -1 on failure, or 0 on success. - */ -char * -check_user_amandahosts(host, pwd, remoteuser) - const char *host; - struct passwd *pwd; - const char *remoteuser; -{ - char *line = NULL; - char *filehost; - const char *fileuser; - char *ptmp = NULL; - char *result = NULL; - FILE *fp = NULL; - int found; - struct stat sbuf; - char n1[NUM_STR_SIZE]; - char n2[NUM_STR_SIZE]; - int hostmatch; - int usermatch; - uid_t localuid; - char *localuser = NULL; - - /* - * Save copies of what we need from the passwd structure in case - * any other code calls getpw*. - */ - localuid = pwd->pw_uid; - localuser = stralloc(pwd->pw_name); - - ptmp = stralloc2(pwd->pw_dir, "/.amandahosts"); -#if defined(SHOW_SECURITY_DETAIL) /* { */ - show_stat_info(ptmp, "");; -#endif /* } */ - if ((fp = fopen(ptmp, "r")) == NULL) { - result = vstralloc("cannot open ", ptmp, ": ", strerror(errno), NULL); - amfree(ptmp); - amfree(localuser); - return result; - } - - /* - * Make sure the file is owned by the Amanda user and does not - * have any group/other access allowed. - */ - if (fstat(fileno(fp), &sbuf) != 0) { - result = vstralloc("cannot fstat ", ptmp, ": ", strerror(errno), NULL); - goto common_exit; - } - if (sbuf.st_uid != localuid) { - snprintf(n1, sizeof(n1), "%ld", (long)sbuf.st_uid); - snprintf(n2, sizeof(n2), "%ld", (long)localuid); - result = vstralloc(ptmp, ": ", - "owned by id ", n1, - ", should be ", n2, - NULL); - goto common_exit; - } - if ((sbuf.st_mode & 077) != 0) { - result = stralloc2(ptmp, - ": incorrect permissions; file must be accessible only by its owner"); - goto common_exit; - } - - /* - * Now, scan the file for the host/user. - */ - found = 0; - while ((line = agets(fp)) != NULL) { -#if defined(SHOW_SECURITY_DETAIL) /* { */ - bsdprintf(("%s: processing line: <%s>\n", debug_prefix(NULL), line)); -#endif /* } */ - /* get the host out of the file */ - if ((filehost = strtok(line, " \t")) == NULL) { - amfree(line); - continue; - } - - /* get the username. If no user specified, then use the local user */ - if ((fileuser = strtok(NULL, " \t")) == NULL) { - fileuser = localuser; - } - - hostmatch = (strcasecmp(filehost, host) == 0); - usermatch = (strcasecmp(fileuser, remoteuser) == 0); -#if defined(SHOW_SECURITY_DETAIL) /* { */ - bsdprintf(("%s: comparing \"%s\" with\n", debug_prefix(NULL), filehost)); - bsdprintf(("%s: \"%s\" (%s)\n", host, - debug_prefix(NULL), hostmatch ? "match" : "no match")); - bsdprintf(("%s: and \"%s\" with\n", fileuser, debug_prefix(NULL))); - bsdprintf(("%s: \"%s\" (%s)\n", remoteuser, - debug_prefix(NULL), usermatch ? "match" : "no match")); -#endif /* } */ - amfree(line); - /* compare */ - if (hostmatch && usermatch) { - /* success */ - found = 1; - break; - } - } - if (! found) { - result = vstralloc(ptmp, ": ", - "\"", host, " ", remoteuser, "\"", - " entry not found", - NULL); - } - -common_exit: - - afclose(fp); - amfree(ptmp); - amfree(line); - amfree(localuser); - - return result; -} - -/* return 1 on success, 0 on failure */ -int -check_security(addr, str, cksum, errstr) -struct sockaddr_in *addr; -char *str; -unsigned long cksum; -char **errstr; -{ - char *remotehost = NULL, *remoteuser = NULL; - char *bad_bsd = NULL; - struct hostent *hp; - struct passwd *pwptr; - int myuid, i, j; - char *s, *fp; - int ch; - - *errstr = NULL; - - /* what host is making the request? */ - - hp = gethostbyaddr((char *)&addr->sin_addr, sizeof(addr->sin_addr), - AF_INET); - if(hp == NULL) { - /* XXX include remote address in message */ - *errstr = vstralloc("[", - "addr ", inet_ntoa(addr->sin_addr), ": ", - "hostname lookup failed", - "]", NULL); - return 0; - } - remotehost = stralloc(hp->h_name); - - /* Now let's get the hostent for that hostname */ - hp = gethostbyname( remotehost ); - if(hp == NULL) { - /* XXX include remote hostname in message */ - *errstr = vstralloc("[", - "host ", remotehost, ": ", - "hostname lookup failed", - "]", NULL); - amfree(remotehost); - return 0; - } - - /* Verify that the hostnames match -- they should theoretically */ - if( strncasecmp( remotehost, hp->h_name, strlen(remotehost)+1 ) != 0 ) { - *errstr = vstralloc("[", - "hostnames do not match: ", - remotehost, " ", hp->h_name, - "]", NULL); - amfree(remotehost); - return 0; - } - - /* Now let's verify that the ip which gave us this hostname - * is really an ip for this hostname; or is someone trying to - * break in? (THIS IS THE CRUCIAL STEP) - */ - for (i = 0; hp->h_addr_list[i]; i++) { - if (memcmp(hp->h_addr_list[i], - (char *) &addr->sin_addr, sizeof(addr->sin_addr)) == 0) - break; /* name is good, keep it */ - } - - /* If we did not find it, your DNS is messed up or someone is trying - * to pull a fast one on you. :( - */ - - /* Check even the aliases list. Work around for Solaris if dns goes over NIS */ - - if( !hp->h_addr_list[i] ) { - for (j = 0; hp->h_aliases[j] !=0 ; j++) { - if ( strcmp(hp->h_aliases[j],inet_ntoa(addr->sin_addr)) == 0) - break; /* name is good, keep it */ - } - if( !hp->h_aliases[j] ) { - *errstr = vstralloc("[", - "ip address ", inet_ntoa(addr->sin_addr), - " is not in the ip list for ", remotehost, - "]", - NULL); - amfree(remotehost); - return 0; - } - } - - /* next, make sure the remote port is a "reserved" one */ - - if(ntohs(addr->sin_port) >= IPPORT_RESERVED) { - char number[NUM_STR_SIZE]; - - snprintf(number, sizeof(number), "%d", ntohs(addr->sin_port)); - *errstr = vstralloc("[", - "host ", remotehost, ": ", - "port ", number, " not secure", - "]", NULL); - amfree(remotehost); - return 0; - } - - /* extract the remote user name from the message */ - - s = str; - ch = *s++; - - bad_bsd = vstralloc("[", - "host ", remotehost, ": ", - "bad bsd security line", - "]", NULL); - -#define sc "USER " - if(strncmp(s - 1, sc, sizeof(sc)-1) != 0) { - *errstr = bad_bsd; - bad_bsd = NULL; - amfree(remotehost); - return 0; - } - s += sizeof(sc)-1; - ch = s[-1]; -#undef sc - - skip_whitespace(s, ch); - if(ch == '\0') { - *errstr = bad_bsd; - bad_bsd = NULL; - amfree(remotehost); - return 0; - } - fp = s - 1; - skip_non_whitespace(s, ch); - s[-1] = '\0'; - remoteuser = stralloc(fp); - s[-1] = ch; - amfree(bad_bsd); - - /* lookup our local user name */ - - myuid = getuid(); - if((pwptr = getpwuid(myuid)) == NULL) - error("error [getpwuid(%d) fails]", myuid); - - dbprintf(("bsd security: remote host %s user %s local user %s\n", - remotehost, remoteuser, pwptr->pw_name)); - -#ifndef USE_AMANDAHOSTS - s = check_user_ruserok(remotehost, pwptr, remoteuser); -#else - s = check_user_amandahosts(remotehost, pwptr, remoteuser); -#endif - - if (s != NULL) { - *errstr = vstralloc("[", - "access as ", pwptr->pw_name, " not allowed", - " from ", remoteuser, "@", remotehost, - ": ", s, "]", NULL); - } - amfree(s); - amfree(remotehost); - amfree(remoteuser); - return *errstr == NULL; -} - - /* * Create the server end of a stream. For bsd, this means setup a tcp * socket for receiving a connection. */ static void * -bsd_stream_server(h) - void *h; +bsd_stream_server( + void * h) { - struct bsd_stream *bs = NULL; #ifndef TEST /* { */ - struct bsd_handle *bh = h; + struct sec_stream *bs = NULL; + struct sec_handle *bh = h; assert(bh != NULL); - bs = alloc(sizeof(*bs)); + bs = alloc(SIZEOF(*bs)); security_streaminit(&bs->secstr, &bsd_security_driver); - bs->socket = stream_server(&bs->port, STREAM_BUFSIZE, STREAM_BUFSIZE); + bs->socket = stream_server(&bs->port, (size_t)STREAM_BUFSIZE, + (size_t)STREAM_BUFSIZE, 0); if (bs->socket < 0) { security_seterror(&bh->sech, "can't create server stream: %s", strerror(errno)); @@ -1396,8 +306,10 @@ bsd_stream_server(h) } bs->fd = -1; bs->ev_read = NULL; -#endif /* !TEST */ /* } */ return (bs); +#else + return (NULL); +#endif /* !TEST */ /* } */ } /* @@ -1405,17 +317,17 @@ bsd_stream_server(h) * block on accept() */ static int -bsd_stream_accept(s) - void *s; +bsd_stream_accept( + void * s) { #ifndef TEST /* { */ - struct bsd_stream *bs = s; + struct sec_stream *bs = s; assert(bs != NULL); assert(bs->socket != -1); assert(bs->fd < 0); - bs->fd = stream_accept(bs->socket, 30, -1, -1); + bs->fd = stream_accept(bs->socket, 30, STREAM_BUFSIZE, STREAM_BUFSIZE); if (bs->fd < 0) { security_stream_seterror(&bs->secstr, "can't accept new stream connection: %s", strerror(errno)); @@ -1429,32 +341,26 @@ bsd_stream_accept(s) * Return a connected stream */ static void * -bsd_stream_client(h, id) - void *h; - int id; +bsd_stream_client( + void * h, + int id) { - struct bsd_stream *bs = NULL; + struct sec_stream *bs = NULL; #ifndef TEST /* { */ - struct bsd_handle *bh = h; + struct sec_handle *bh = h; #ifdef DUMPER_SOCKET_BUFFERING - int rcvbuf = sizeof(bs->databuf) * 2; + size_t rcvbuf = SIZEOF(bs->databuf) * 2; #endif assert(bh != NULL); - if (id < 0) { - security_seterror(&bh->sech, - "%d: invalid security stream id", id); - return (NULL); - } - - bs = alloc(sizeof(*bs)); + bs = alloc(SIZEOF(*bs)); security_streaminit(&bs->secstr, &bsd_security_driver); - bs->fd = stream_client(bh->hostname, id, STREAM_BUFSIZE, STREAM_BUFSIZE, - &bs->port, 0); + bs->fd = stream_client(bh->hostname, (in_port_t)id, + STREAM_BUFSIZE, STREAM_BUFSIZE, &bs->port, 0); if (bs->fd < 0) { security_seterror(&bh->sech, - "can't connect stream to %s port %d: %s", bh->hostname, + "can't connect stream to %s port %hd: %s", bh->hostname, id, strerror(errno)); amfree(bs); return (NULL); @@ -1462,7 +368,7 @@ bsd_stream_client(h, id) bs->socket = -1; /* we're a client */ bs->ev_read = NULL; #ifdef DUMPER_SOCKET_BUFFERING - setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (void *)&rcvbuf, sizeof(rcvbuf)); + setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (void *)&rcvbuf, SIZEOF(rcvbuf)); #endif #endif /* !TEST */ /* } */ return (bs); @@ -1472,10 +378,10 @@ bsd_stream_client(h, id) * Close and unallocate resources for a stream */ static void -bsd_stream_close(s) - void *s; +bsd_stream_close( + void * s) { - struct bsd_stream *bs = s; + struct sec_stream *bs = s; assert(bs != NULL); @@ -1491,9 +397,10 @@ bsd_stream_close(s) * Authenticate a stream. bsd streams have no authentication */ static int -bsd_stream_auth(s) - void *s; +bsd_stream_auth( + void * s) { + (void)s; /* Quiet unused parameter warning */ return (0); /* success */ } @@ -1502,37 +409,14 @@ bsd_stream_auth(s) * Returns the stream id for this stream. This is just the local port. */ static int -bsd_stream_id(s) - void *s; +bsd_stream_id( + void * s) { - struct bsd_stream *bs = s; + struct sec_stream *bs = s; assert(bs != NULL); - return (bs->port); -} - -/* - * Write a chunk of data to a stream. Blocks until completion. - */ -static int -bsd_stream_write(s, buf, size) - void *s; - const void *buf; - size_t size; -{ -#ifndef TEST /* { */ - struct bsd_stream *bs = s; - - assert(bs != NULL); - - if (fullwrite(bs->fd, buf, size) < 0) { - security_stream_seterror(&bs->secstr, - "write error on stream %d: %s", bs->port, strerror(errno)); - return (-1); - } -#endif /* !TEST */ /* } */ - return (0); + return ((int)bs->port); } /* @@ -1540,11 +424,12 @@ bsd_stream_write(s, buf, size) * and arg when completed. */ static void -bsd_stream_read(s, fn, arg) - void *s, *arg; - void (*fn) P((void *, void *, ssize_t)); +bsd_stream_read( + void * s, + void (*fn)(void *, void *, ssize_t), + void * arg) { - struct bsd_stream *bs = s; + struct sec_stream *bs = s; /* * Only one read request can be active per stream. @@ -1552,41 +437,52 @@ bsd_stream_read(s, fn, arg) if (bs->ev_read != NULL) event_release(bs->ev_read); - bs->ev_read = event_register(bs->fd, EV_READFD, stream_read_callback, bs); + bs->ev_read = event_register((event_id_t)bs->fd, EV_READFD, stream_read_callback, bs); bs->fn = fn; bs->arg = arg; } /* - * Cancel a previous stream read request. It's ok if we didn't - * have a read scheduled. + * Read a chunk of data to a stream. Blocks until completion. */ -static void -bsd_stream_read_cancel(s) - void *s; +static ssize_t +bsd_stream_read_sync( + void * s, + void ** buf) { - struct bsd_stream *bs = s; + struct sec_stream *bs = s; assert(bs != NULL); - if (bs->ev_read != NULL) { - event_release(bs->ev_read); - bs->ev_read = NULL; + /* + * Only one read request can be active per stream. + */ + if(bs->ev_read != NULL) { + return -1; } + bs->ev_read = event_register((event_id_t)bs->fd, EV_READFD, + stream_read_sync_callback, bs); + event_wait(bs->ev_read); + *buf = bs->databuf; + return (bs->len); } + /* - * Callback for bsd_stream_read + * Callback for bsd_stream_read_sync */ static void -stream_read_callback(arg) - void *arg; +stream_read_sync_callback( + void * s) { - struct bsd_stream *bs = arg; + struct sec_stream *bs = s; ssize_t n; assert(bs != NULL); + bsdprintf(("%s: bsd: stream_read_callback_sync: fd %d\n", + debug_prefix_time(NULL), bs->fd)); + /* * Remove the event first, in case they reschedule it in the callback. */ @@ -1595,101 +491,51 @@ stream_read_callback(arg) n = read(bs->fd, bs->databuf, sizeof(bs->databuf)); } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); if (n < 0) - security_stream_seterror(&bs->secstr, strerror(errno)); - (*bs->fn)(bs->arg, bs->databuf, n); + security_stream_seterror(&bs->secstr, strerror(errno)); + bs->len = n; } /* - * Convert a packet header into a string + * Cancel a previous stream read request. It's ok if we didn't + * have a read scheduled. */ -static const char * -pkthdr2str(bh, pkt) - const struct bsd_handle *bh; - const pkt_t *pkt; +static void +bsd_stream_read_cancel( + void * s) { - static char retbuf[256]; - - assert(bh != NULL); - assert(pkt != NULL); + struct sec_stream *bs = s; - snprintf(retbuf, sizeof(retbuf), "Amanda %d.%d %s HANDLE %s SEQ %d\n", - VERSION_MAJOR, VERSION_MINOR, pkt_type2str(pkt->type), - bh->proto_handle, bh->sequence); - - bsdprintf(("%s: pkthdr2str handle '%s'\n", - debug_prefix_time(NULL), bh->proto_handle)); - - /* check for truncation. If only we had asprintf()... */ - assert(retbuf[strlen(retbuf) - 1] == '\n'); - - return (retbuf); + assert(bs != NULL); + if (bs->ev_read != NULL) { + event_release(bs->ev_read); + bs->ev_read = NULL; + } } /* - * Parses out the header line in 'str' into the pkt and handle - * Returns negative on parse error. + * Callback for bsd_stream_read */ -static int -str2pkthdr() +static void +stream_read_callback( + void * arg) { - char *str; - const char *tok; - pkt_t *pkt; - - pkt = &netfd.pkt; - - assert(netfd.dgram.cur != NULL); - str = stralloc(netfd.dgram.cur); - - /* "Amanda %d.%d HANDLE %s SEQ %d\n" */ - - /* Read in "Amanda" */ - if ((tok = strtok(str, " ")) == NULL || strcmp(tok, "Amanda") != 0) - goto parse_error; - - /* nothing is done with the major/minor numbers currently */ - if ((tok = strtok(NULL, " ")) == NULL || strchr(tok, '.') == NULL) - goto parse_error; - - /* Read in the packet type */ - if ((tok = strtok(NULL, " ")) == NULL) - goto parse_error; - pkt_init(pkt, pkt_str2type(tok), ""); - if (pkt->type == (pktype_t)-1) - goto parse_error; - - /* Read in "HANDLE" */ - if ((tok = strtok(NULL, " ")) == NULL || strcmp(tok, "HANDLE") != 0) - goto parse_error; - - /* parse the handle */ - if ((tok = strtok(NULL, " ")) == NULL) - goto parse_error; - netfd.handle = stralloc(tok); - - /* Read in "SEQ" */ - if ((tok = strtok(NULL, " ")) == NULL || strcmp(tok, "SEQ") != 0) - goto parse_error; + struct sec_stream *bs = arg; + ssize_t n; - /* parse the sequence number */ - if ((tok = strtok(NULL, "\n")) == NULL) - goto parse_error; - netfd.sequence = atoi(tok); + assert(bs != NULL); - /* Save the body, if any */ - if ((tok = strtok(NULL, "")) != NULL) - pkt_cat(pkt, "%s", tok); + /* + * Remove the event first, in case they reschedule it in the callback. + */ + bsd_stream_read_cancel(bs); + do { + n = read(bs->fd, bs->databuf, SIZEOF(bs->databuf)); + } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); - amfree(str); - return (0); + if (n < 0) + security_stream_seterror(&bs->secstr, strerror(errno)); -parse_error: -#if 0 /* XXX we have no way of passing this back up */ - security_seterror(&bh->sech, - "parse error in packet header : '%s'", origstr); -#endif - amfree(str); - return (-1); + (*bs->fn)(bs->arg, bs->databuf, n); } #endif /* BSD_SECURITY */ /* } */ @@ -1701,12 +547,19 @@ parse_error: * drag in util.o just for the test program. */ int -bind_portrange(s, addrp, first_port, last_port, proto) - int s; - struct sockaddr_in *addrp; - int first_port, last_port; - char *proto; -{ +bind_portrange( + int s, + struct sockaddr_in *addrp, + in_port_t first_port, + in_port_t last_port, + char * proto) +{ + (void)s; /* Quiet unused parameter warning */ + (void)addrp; /* Quiet unused parameter warning */ + (void)first_port; /* Quiet unused parameter warning */ + (void)last_port; /* Quiet unused parameter warning */ + (void)proto; /* Quiet unused parameter warning */ + return 0; } @@ -1714,8 +567,8 @@ bind_portrange(s, addrp, first_port, last_port, proto) * Construct a datestamp (YYYYMMDD) from a time_t. */ char * -construct_datestamp(t) - time_t *t; +construct_datestamp( + time_t * t) { struct tm *tm; char datestamp[3*NUM_STR_SIZE]; @@ -1727,7 +580,7 @@ construct_datestamp(t) when = *t; } tm = localtime(&when); - snprintf(datestamp, sizeof(datestamp), + snprintf(datestamp, SIZEOF(datestamp), "%04d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday); return stralloc(datestamp); } @@ -1736,8 +589,8 @@ construct_datestamp(t) * Construct a timestamp (YYYYMMDDHHMMSS) from a time_t. */ char * -construct_timestamp(t) - time_t *t; +construct_timestamp( + time_t * t) { struct tm *tm; char timestamp[6*NUM_STR_SIZE]; @@ -1749,7 +602,7 @@ construct_timestamp(t) when = *t; } tm = localtime(&when); - snprintf(timestamp, sizeof(timestamp), + snprintf(timestamp, SIZEOF(timestamp), "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -1763,14 +616,17 @@ construct_timestamp(t) const security_driver_t krb4_security_driver = {}; const security_driver_t krb5_security_driver = {}; const security_driver_t rsh_security_driver = {}; +const security_driver_t ssh_security_driver = {}; +const security_driver_t bsdtcp_security_driver = {}; +const security_driver_t bsdudp_security_driver = {}; /* * This function will be called to accept the connection and is used * to report success or failure. */ -static void fake_accept_function(handle, pkt) - security_handle_t *handle; - pkt_t *pkt; +static void fake_accept_function( + security_handle_t * handle, + pkt_t * pkt) { if (pkt == NULL) { fputs(handle->error, stdout); @@ -1781,12 +637,14 @@ static void fake_accept_function(handle, pkt) } int -main (argc, argv) +main ( + int argc, + char ** argv) { char *remoteuser; char *remotehost; struct hostent *hp; - struct bsd_handle *bh; + struct sec_handle *bh; void *save_cur; struct passwd *pwent; @@ -1808,6 +666,7 @@ main (argc, argv) if (geteuid() == 0) { if(client_uid == (uid_t) -1) { error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN); + /*NOTREACHED*/ } initgroups(CLIENT_LOGIN, client_gid); setgid(client_gid); @@ -1820,19 +679,28 @@ main (argc, argv) fputs("Remote user: ", stdout); fflush(stdout); } - if ((remoteuser = agets(stdin)) == NULL) { - return 0; - } + do { + amfree(remoteuser); + remoteuser = agets(stdin); + if (remoteuser == NULL) + return 0; + } while (remoteuser[0] == '\0'); if (isatty(0)) { fputs("Remote host: ", stdout); fflush(stdout); } - if ((remotehost = agets(stdin)) == NULL) { - return 0; - } + + do { + amfree(remotehost); + remotehost = agets(stdin); + if (remotehost == NULL) + return 0; + } while (remotehost[0] == '\0'); set_pname("security"); + dbopen(NULL); + startclock(); if ((hp = gethostbyname(remotehost)) == NULL) { @@ -1841,14 +709,15 @@ main (argc, argv) } memcpy((char *)&netfd.peer.sin_addr, (char *)hp->h_addr, - sizeof(hp->h_addr)); + SIZEOF(hp->h_addr)); /* * Fake that it is coming from a reserved port. */ netfd.peer.sin_port = htons(IPPORT_RESERVED - 1); - bh = alloc(sizeof(*bh)); + bh = alloc(SIZEOF(*bh)); bh->proto_handle=NULL; + bh->udp = &netfd; netfd.pkt.type = P_REQ; dgram_zero(&netfd.dgram); save_cur = netfd.dgram.cur; /* cheating */ @@ -1856,8 +725,10 @@ main (argc, argv) dgram_cat(&netfd.dgram, "SECURITY USER %s\n", remoteuser); netfd.dgram.cur = save_cur; /* cheating */ - accept_fn = fake_accept_function; - netfd_read_callback(NULL); + netfd.accept_fn = fake_accept_function; + netfd.recv_security_ok = &bsd_recv_security_ok; + netfd.prefix_packet = &bsd_prefix_packet; + udp_netfd_read_callback(&netfd); return 0; } diff --git a/common-src/bsdtcp-security.c b/common-src/bsdtcp-security.c new file mode 100644 index 0000000..9ddf90c --- /dev/null +++ b/common-src/bsdtcp-security.c @@ -0,0 +1,261 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1999 University of Maryland + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ + +/* + * $Id: bsdtcp-security.c,v 1.7 2006/07/13 03:22:20 paddy_s Exp $ + * + * bsdtcp-security.c - security and transport over bsdtcp or a bsdtcp-like command. + * + * XXX still need to check for initial keyword on connect so we can skip + * over shell garbage and other stuff that bsdtcp might want to spew out. + */ + +#include "amanda.h" +#include "util.h" +#include "event.h" +#include "packet.h" +#include "queue.h" +#include "security.h" +#include "security-util.h" +#include "stream.h" +#include "version.h" + +#ifdef BSDTCP_SECURITY + +/*#define BSDTCP_DEBUG*/ + +#ifdef BSDTCP_DEBUG +#define bsdtcpprintf(x) dbprintf(x) +#else +#define bsdtcpprintf(x) +#endif + + +/* + * Number of seconds bsdtcp has to start up + */ +#define CONNECT_TIMEOUT 20 + +/* + * Interface functions + */ +static void bsdtcp_accept(const struct security_driver *, int, int, + void (*)(security_handle_t *, pkt_t *)); +static void bsdtcp_connect(const char *, + char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), void *, void *); + +/* + * This is our interface to the outside world. + */ +const security_driver_t bsdtcp_security_driver = { + "BSDTCP", + bsdtcp_connect, + bsdtcp_accept, + sec_close, + stream_sendpkt, + stream_recvpkt, + stream_recvpkt_cancel, + tcpma_stream_server, + tcpma_stream_accept, + tcpma_stream_client, + tcpma_stream_close, + sec_stream_auth, + sec_stream_id, + tcpm_stream_write, + tcpm_stream_read, + tcpm_stream_read_sync, + tcpm_stream_read_cancel, + tcpm_close_connection, +}; + +static int newhandle = 1; + +/* + * Local functions + */ +static int runbsdtcp(struct sec_handle *); + + +/* + * bsdtcp version of a security handle allocator. Logically sets + * up a network "connection". + */ +static void +bsdtcp_connect( + const char *hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) +{ + struct sec_handle *rh; + struct hostent *he; + + assert(fn != NULL); + assert(hostname != NULL); + (void)conf_fn; /* Quiet unused parameter warning */ + (void)datap; /* Quiet unused parameter warning */ + + bsdtcpprintf(("%s: bsdtcp: bsdtcp_connect: %s\n", debug_prefix_time(NULL), + hostname)); + + rh = alloc(sizeof(*rh)); + security_handleinit(&rh->sech, &bsdtcp_security_driver); + rh->hostname = NULL; + rh->rs = NULL; + rh->ev_timeout = NULL; + rh->rc = NULL; + + if ((he = gethostbyname(hostname)) == NULL) { + security_seterror(&rh->sech, + "%s: could not resolve hostname", hostname); + (*fn)(arg, &rh->sech, S_ERROR); + return; + } + rh->hostname = stralloc(he->h_name); /* will be replaced */ + rh->rs = tcpma_stream_client(rh, newhandle++); + rh->rc->recv_security_ok = &bsd_recv_security_ok; + rh->rc->prefix_packet = &bsd_prefix_packet; + + if (rh->rs == NULL) + goto error; + + amfree(rh->hostname); + rh->hostname = stralloc(rh->rs->rc->hostname); + + /* + * We need to open a new connection. + * + * XXX need to eventually limit number of outgoing connections here. + */ + if(rh->rc->read == -1) { + if (runbsdtcp(rh) < 0) + goto error; + rh->rc->refcnt++; + } + + /* + * The socket will be opened async so hosts that are down won't + * block everything. We need to register a write event + * so we will know when the socket comes alive. + * + * Overload rh->rs->ev_read to provide a write event handle. + * We also register a timeout. + */ + rh->fn.connect = fn; + rh->arg = arg; + rh->rs->ev_read = event_register((event_id_t)(rh->rs->rc->write), + EV_WRITEFD, sec_connect_callback, rh); + rh->ev_timeout = event_register(CONNECT_TIMEOUT, EV_TIME, + sec_connect_timeout, rh); + + return; + +error: + (*fn)(arg, &rh->sech, S_ERROR); +} + +/* + * Setup to handle new incoming connections + */ +static void +bsdtcp_accept( + const struct security_driver *driver, + int in, + int out, + void (*fn)(security_handle_t *, pkt_t *)) +{ + struct sockaddr_in sin; + socklen_t len; + struct tcp_conn *rc; + struct hostent *he; + + len = sizeof(sin); + if (getpeername(in, (struct sockaddr *)&sin, &len) < 0) + return; + he = gethostbyaddr((void *)&sin.sin_addr, sizeof(sin.sin_addr), AF_INET); + if (he == NULL) + return; + + rc = sec_tcp_conn_get(he->h_name, 0); + rc->recv_security_ok = &bsd_recv_security_ok; + rc->prefix_packet = &bsd_prefix_packet; + memcpy(&rc->peer.sin_addr, he->h_addr, sizeof(rc->peer.sin_addr)); + rc->peer.sin_port = sin.sin_port; + rc->read = in; + rc->write = out; + rc->accept_fn = fn; + rc->driver = driver; + sec_tcp_conn_read(rc); +} + +/* + * Forks a bsdtcp to the host listed in rc->hostname + * Returns negative on error, with an errmsg in rc->errmsg. + */ +static int +runbsdtcp( + struct sec_handle * rh) +{ + struct servent * sp; + int server_socket; + in_port_t my_port; + uid_t euid; + struct tcp_conn * rc = rh->rc; + + if ((sp = getservbyname("amanda", "tcp")) == NULL) { + error("%s/tcp unknown protocol", "amanda"); + } + + euid = geteuid(); + seteuid(0); + + server_socket = stream_client_privileged(rc->hostname, + (in_port_t)(ntohs((in_port_t)sp->s_port)), + STREAM_BUFSIZE, + STREAM_BUFSIZE, + &my_port, + 0); + + if(server_socket < 0) { + security_seterror(&rh->sech, + "%s", strerror(errno)); + + return -1; + } + seteuid(euid); + + if(my_port >= IPPORT_RESERVED) { + security_seterror(&rh->sech, + "did not get a reserved port: %d", my_port); + } + + rc->read = rc->write = server_socket; + return 0; +} + +#endif /* BSDTCP_SECURITY */ diff --git a/common-src/bsdudp-security.c b/common-src/bsdudp-security.c new file mode 100644 index 0000000..ae2325f --- /dev/null +++ b/common-src/bsdudp-security.c @@ -0,0 +1,266 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1991-1999 University of Maryland at College Park + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ +/* + * $Id: bsdudp-security.c,v 1.7 2006/07/05 13:18:20 martinea Exp $ + * + * "BSD" security module + */ + +#include "amanda.h" +#include "util.h" +#include "clock.h" +#include "dgram.h" +#include "event.h" +#include "packet.h" +#include "security.h" +#include "security-util.h" +#include "stream.h" +#include "version.h" + +#ifdef BSDUDP_SECURITY + +/*#define BSDUDP_DEBUG*/ + +#ifdef BSDUDP_DEBUG +#define bsdudpprintf(x) dbprintf(x) +#else +#define bsdudpprintf(x) +#endif + +#ifndef SO_RCVBUF +#undef DUMPER_SOCKET_BUFFERING +#endif + +/* + * Change the following from #undef to #define to cause detailed logging + * of the security steps, e.g. into /tmp/amanda/amandad*debug. + */ +#undef SHOW_SECURITY_DETAIL + +#if defined(TEST) /* { */ +#define SHOW_SECURITY_DETAIL +#undef bsdudpprintf +#define bsdudpprintf(p) printf p +#endif /* } */ + +/* + * Interface functions + */ +static void bsdudp_connect(const char *, + char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), void *, void *); +static void bsdudp_accept(const struct security_driver *, int, int, void (*)(security_handle_t *, pkt_t *)); +static void bsdudp_close(void *); + +/* + * This is our interface to the outside world + */ +const security_driver_t bsdudp_security_driver = { + "BSDUDP", + bsdudp_connect, + bsdudp_accept, + bsdudp_close, + udpbsd_sendpkt, + udp_recvpkt, + udp_recvpkt_cancel, + tcp1_stream_server, + tcp1_stream_accept, + tcp1_stream_client, + tcpma_stream_close, + sec_stream_auth, + sec_stream_id, + tcpm_stream_write, + tcpm_stream_read, + tcpm_stream_read_sync, + tcpm_stream_read_cancel, + sec_close_connection_none, +}; + +/* + * This is data local to the datagram socket. We have one datagram + * per process, so it is global. + */ +static udp_handle_t netfd; +static int not_init = 1; + +/* generate new handles from here */ +static unsigned int newhandle = 0; + +/* + * Setup and return a handle outgoing to a client + */ +static void +bsdudp_connect( + const char *hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) +{ + struct sec_handle *bh; + struct servent *se; + struct hostent *he; + in_port_t port; + struct timeval sequence_time; + amanda_timezone dontcare; + int sequence; + char *handle; + + (void)conf_fn; /* Quiet unused parameter warning */ + (void)datap; /* Quiet unused parameter warning */ + assert(hostname != NULL); + + bh = alloc(sizeof(*bh)); + bh->proto_handle=NULL; + bh->udp = &netfd; + bh->rc = NULL; + security_handleinit(&bh->sech, &bsdudp_security_driver); + + /* + * Only init the socket once + */ + if (not_init == 1) { + uid_t euid; + dgram_zero(&netfd.dgram); + + euid = geteuid(); + seteuid(0); + dgram_bind(&netfd.dgram, &port); + seteuid(euid); + netfd.handle = NULL; + netfd.pkt.body = NULL; + netfd.recv_security_ok = &bsd_recv_security_ok; + netfd.prefix_packet = &bsd_prefix_packet; + /* + * We must have a reserved port. Bomb if we didn't get one. + */ + if (port >= IPPORT_RESERVED) { + security_seterror(&bh->sech, + "unable to bind to a reserved port (got port %u)", + (unsigned int)port); + (*fn)(arg, &bh->sech, S_ERROR); + return; + } + not_init = 0; + } + + if ((he = gethostbyname(hostname)) == NULL) { + security_seterror(&bh->sech, + "%s: could not resolve hostname", hostname); + (*fn)(arg, &bh->sech, S_ERROR); + return; + } + if ((se = getservbyname(AMANDA_SERVICE_NAME, "udp")) == NULL) + port = (in_port_t)htons(AMANDA_SERVICE_DEFAULT); + else + port = (in_port_t)se->s_port; + amanda_gettimeofday(&sequence_time, &dontcare); + sequence = (int)sequence_time.tv_sec ^ (int)sequence_time.tv_usec; + handle=alloc(15); + snprintf(handle,14,"000-%08x", newhandle++); + if (udp_inithandle(&netfd, bh, he, port, handle, sequence) < 0) { + (*fn)(arg, &bh->sech, S_ERROR); + amfree(bh->hostname); + amfree(bh); + } else { + (*fn)(arg, &bh->sech, S_OK); + } + amfree(handle); +} + +/* + * Setup to accept new incoming connections + */ +static void +bsdudp_accept( + const struct security_driver *driver, + int in, + int out, + void (*fn)(security_handle_t *, pkt_t *)) +{ + (void)driver; /* Quiet unused parameter warning */ + (void)out; /* Quiet unused parameter warning */ + + assert(in >= 0 && out >= 0); + assert(fn != NULL); + + /* + * We assume in and out point to the same socket, and just use + * in. + */ + dgram_socket(&netfd.dgram, in); + + /* + * Assign the function and return. When they call recvpkt later, + * the recvpkt callback will call this function when it discovers + * new incoming connections + */ + netfd.accept_fn = fn; + netfd.recv_security_ok = &bsd_recv_security_ok; + netfd.prefix_packet = &bsd_prefix_packet; + netfd.driver = &bsdudp_security_driver; + + + udp_addref(&netfd, &udp_netfd_read_callback); +} + +/* + * Frees a handle allocated by the above + */ +static void +bsdudp_close( + void *cookie) +{ + struct sec_handle *bh = cookie; + + if(bh->proto_handle == NULL) { + return; + } + + bsdudpprintf(("%s: bsdudp: close handle '%s'\n", + debug_prefix_time(NULL), bh->proto_handle)); + + udp_recvpkt_cancel(bh); + if(bh->next) { + bh->next->prev = bh->prev; + } + else { + netfd.bh_last = bh->prev; + } + if(bh->prev) { + bh->prev->next = bh->next; + } + else { + netfd.bh_first = bh->next; + } + + amfree(bh->proto_handle); + amfree(bh->hostname); + amfree(bh); +} + +#endif /* BSDUDP_SECURITY */ /* } */ + diff --git a/common-src/clock.c b/common-src/clock.c index 732b4ef..905c68e 100644 --- a/common-src/clock.c +++ b/common-src/clock.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: clock.c,v 1.5 2002/04/08 00:16:18 jrjackson Exp $ + * $Id: clock.c,v 1.7 2006/07/27 18:12:10 martinea Exp $ * * timing functions */ @@ -34,19 +34,21 @@ #include "clock.h" /* local functions */ -static struct timeval timesub P((struct timeval end, struct timeval start)); -static struct timeval timeadd P((struct timeval a, struct timeval b)); +static struct timeval timesub(struct timeval end, struct timeval start); +static struct timeval timeadd(struct timeval a, struct timeval b); -times_t times_zero = {{0,0}}; +times_t times_zero; times_t start_time; static int clock_running = 0; -int clock_is_running() +int +clock_is_running(void) { return clock_running; } -void startclock() +void +startclock(void) { amanda_timezone dontcare; @@ -54,7 +56,8 @@ void startclock() amanda_gettimeofday(&start_time.r, &dontcare); } -times_t stopclock() +times_t +stopclock(void) { times_t diff; struct timeval end_time; @@ -70,7 +73,8 @@ times_t stopclock() return diff; } -times_t curclock() +times_t +curclock(void) { times_t diff; struct timeval end_time; @@ -85,8 +89,10 @@ times_t curclock() return diff; } -times_t timesadd(a,b) -times_t a,b; +times_t +timesadd( + times_t a, + times_t b) { times_t sum; @@ -94,8 +100,10 @@ times_t a,b; return sum; } -times_t timessub(a,b) -times_t a,b; +times_t +timessub( + times_t a, + times_t b) { times_t dif; @@ -103,43 +111,50 @@ times_t a,b; return dif; } -char *times_str(t) -times_t t; +char * +times_str( + times_t t) { static char str[10][NUM_STR_SIZE+10]; - static int n = 0; + static size_t n = 0; char *s; /* tv_sec/tv_usec are longs on some systems */ - snprintf(str[n], sizeof(str[n]), - "rtime %d.%03d", (int)t.r.tv_sec, (int)t.r.tv_usec/1000); + snprintf(str[n], SIZEOF(str[n]), "rtime %lu.%03lu", + (unsigned long)t.r.tv_sec, + (unsigned long)t.r.tv_usec / 1000); s = str[n++]; n %= am_countof(str); return s; } -char *walltime_str(t) -times_t t; +char * +walltime_str( + times_t t) { static char str[10][NUM_STR_SIZE+10]; - static int n = 0; + static size_t n = 0; char *s; /* tv_sec/tv_usec are longs on some systems */ - snprintf(str[n], sizeof(str[n]), - "%d.%03d", (int)t.r.tv_sec, (int)t.r.tv_usec/1000); + snprintf(str[n], SIZEOF(str[n]), "%lu.%03lu", + (unsigned long)t.r.tv_sec, + (unsigned long)t.r.tv_usec/1000); s = str[n++]; n %= am_countof(str); return s; } -static struct timeval timesub(end,start) -struct timeval end,start; +static struct timeval +timesub( + struct timeval end, + struct timeval start) { struct timeval diff; if(end.tv_usec < start.tv_usec) { /* borrow 1 sec */ - end.tv_sec -= 1; + if (end.tv_sec > 0) + end.tv_sec -= 1; end.tv_usec += 1000000; } diff.tv_usec = end.tv_usec - start.tv_usec; @@ -147,8 +162,10 @@ struct timeval end,start; return diff; } -static struct timeval timeadd(a,b) -struct timeval a,b; +static struct timeval +timeadd( + struct timeval a, + struct timeval b) { struct timeval sum; diff --git a/common-src/clock.h b/common-src/clock.h index 4da1cfc..391b383 100644 --- a/common-src/clock.h +++ b/common-src/clock.h @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: clock.h,v 1.5 2002/04/08 00:16:18 jrjackson Exp $ + * $Id: clock.h,v 1.6 2006/05/25 01:47:11 johnfranks Exp $ * * interface for timing functions */ @@ -52,13 +52,13 @@ extern times_t times_zero, start_time; # define amanda_gettimeofday(x, y) gettimeofday((x)) #endif -void startclock P((void)); -times_t stopclock P((void)); -times_t curclock P((void)); -times_t timesadd P((times_t a, times_t b)); -times_t timessub P((times_t a, times_t b)); -char * times_str P((times_t t)); -char * walltime_str P((times_t t)); -int clock_is_running P((void)); +void startclock(void); +times_t stopclock(void); +times_t curclock(void); +times_t timesadd(times_t a, times_t b); +times_t timessub(times_t a, times_t b); +char * times_str(times_t t); +char * walltime_str(times_t t); +int clock_is_running(void); #endif /* CLOCK_H */ diff --git a/common-src/debug.c b/common-src/debug.c index 66d31bd..b958b63 100644 --- a/common-src/debug.c +++ b/common-src/debug.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: debug.c,v 1.36 2006/01/12 01:57:05 paddy_s Exp $ + * $Id: debug.c,v 1.40 2006/07/26 11:49:32 martinea Exp $ * * debug log subroutines */ @@ -47,9 +47,13 @@ int debug = 1; static int db_fd = 2; /* default is stderr */ static FILE *db_file = NULL; /* stderr may not be a constant */ -static char *db_filename = NULL; +static char *db_name = NULL; /* filename */ +static char *db_filename = NULL; /* /path/to/filename */ static pid_t debug_prefix_pid = 0; +static char *get_debug_name(time_t t, int n); +static void debug_setup_1(char *config, char *subdir); +static void debug_setup_2(char *s, int fd, char *notation); /* * Format and write a debug message to the process debug file. @@ -57,7 +61,6 @@ static pid_t debug_prefix_pid = 0; printf_arglist_function(void debug_printf, const char *, format) { va_list argp; - int save_errno; /* * It is common in the code to call dbprintf to write out @@ -65,19 +68,21 @@ printf_arglist_function(void debug_printf, const char *, format) * with errno (e.g. printf() or log()), so we make sure errno goes * back out with the same value it came in with. */ - save_errno = errno; + if (debug != 0) { + int save_errno; - if(db_file == NULL && db_fd == 2) { - db_file = stderr; - } - if(db_file != NULL) { - arglist_start(argp, format); - vfprintf(db_file, format, argp); - fflush(db_file); - arglist_end(argp); + save_errno = errno; + if(db_file == NULL && db_fd == 2) { + db_file = stderr; + } + if(db_file != NULL) { + arglist_start(argp, format); + vfprintf(db_file, format, argp); + fflush(db_file); + arglist_end(argp); + } + errno = save_errno; } - - errno = save_errno; } /* @@ -85,9 +90,9 @@ printf_arglist_function(void debug_printf, const char *, format) * followed by a timestamp, an optional sequence number, and ".debug". */ static char * -get_debug_name(t, n) - time_t t; - int n; +get_debug_name( + time_t t, + int n) { char number[NUM_STR_SIZE]; char *ts; @@ -100,7 +105,7 @@ get_debug_name(t, n) if(n == 0) { number[0] = '\0'; } else { - snprintf(number, sizeof(number), "%03d", n - 1); + snprintf(number, SIZEOF(number), "%03d", n - 1); } result = vstralloc(get_pname(), ".", ts, number, ".debug", NULL); amfree(ts); @@ -110,7 +115,8 @@ get_debug_name(t, n) static char *dbgdir = NULL; static time_t curtime; -static void debug_setup_1() +static void +debug_setup_1(char *config, char *subdir) { struct passwd *pwent; char *pname; @@ -120,13 +126,15 @@ static void debug_setup_1() DIR *d; struct dirent *entry; int do_rename; - char *test_name = NULL; + char *test_name; size_t test_name_len; size_t d_name_len; struct stat sbuf; char *dbfilename = NULL; + char *sane_config = NULL; int i; + memset(&sbuf, 0, SIZEOF(sbuf)); if(client_uid == (uid_t) -1 && (pwent = getpwnam(CLIENT_LOGIN)) != NULL) { client_uid = pwent->pw_uid; client_gid = pwent->pw_gid; @@ -140,11 +148,23 @@ static void debug_setup_1() * Create the debug directory if it does not yet exist. */ amfree(dbgdir); - dbgdir = stralloc2(AMANDA_DBGDIR, "/"); + if (config) + sane_config = sanitise_filename(config); + if (sane_config && subdir) + dbgdir = vstralloc(AMANDA_DBGDIR, "/", subdir, "/", sane_config, + "/", NULL); + else if (sane_config) + dbgdir = vstralloc(AMANDA_DBGDIR, "/", sane_config, "/", NULL); + else if (subdir) + dbgdir = vstralloc(AMANDA_DBGDIR, "/", subdir, "/", NULL); + else + dbgdir = stralloc2(AMANDA_DBGDIR, "/"); if(mkpdir(dbgdir, 02700, client_uid, client_gid) == -1) { error("create debug directory \"%s\": %s", AMANDA_DBGDIR, strerror(errno)); + /*NOTREACHED*/ } + amfree(sane_config); /* * Clean out old debug files. We also rename files with old style @@ -155,6 +175,7 @@ static void debug_setup_1() if((d = opendir(AMANDA_DBGDIR)) == NULL) { error("open debug directory \"%s\": %s", AMANDA_DBGDIR, strerror(errno)); + /*NOTREACHED*/ } time(&curtime); test_name = get_debug_name(curtime - (AMANDA_DEBUG_DAYS * 24 * 60 * 60), 0); @@ -202,6 +223,7 @@ static void debug_setup_1() } if(dbfilename == NULL) { error("cannot rename old debug file \"%s\"", entry->d_name); + /*NOTREACHED*/ } } } @@ -212,33 +234,40 @@ static void debug_setup_1() closedir(d); } -static void debug_setup_2(s, fd, notation) - char *s; - int fd; - char *notation; +static void +debug_setup_2( + char * s, + int fd, + char * notation) { int saved_debug; - int i; + int i, rc; int fd_close[MIN_DB_FD+1]; amfree(db_filename); db_filename = s; s = NULL; - (void) chown(db_filename, client_uid, client_gid); + if ((rc = chown(db_filename, client_uid, client_gid)) < 0) { + dbprintf(("chown(%s, %d, %d) failed. <%s>", + db_filename, client_uid, client_gid, strerror(errno))); + (void)rc; + } amfree(dbgdir); /* * Move the file descriptor up high so it stays out of the way * of other processing, e.g. sendbackup. */ - i = 0; - fd_close[i++] = fd; - while((db_fd = dup(fd)) < MIN_DB_FD) { - fd_close[i++] = db_fd; - } - while(--i >= 0) { - close(fd_close[i]); + if (fd >= 0) { + i = 0; + fd_close[i++] = fd; + while((db_fd = dup(fd)) < MIN_DB_FD) { + fd_close[i++] = db_fd; + } + while(--i >= 0) { + close(fd_close[i]); + } + db_file = fdopen(db_fd, "a"); } - db_file = fdopen(db_fd, "a"); if (notation) { /* @@ -254,9 +283,9 @@ static void debug_setup_2(s, fd, notation) } } -void debug_open() +void +debug_open(char *subdir) { - char *dbfilename = NULL; int fd = -1; int i; char *s = NULL; @@ -265,29 +294,29 @@ void debug_open() /* * Do initial setup. */ - debug_setup_1(); + debug_setup_1(NULL, subdir); /* * Create the new file with a unique sequence number. */ - mask = umask(0037); /* Allow the group read bit through */ + mask = (mode_t)umask((mode_t)0037); /* Allow the group read bit through */ for(i = 0; fd < 0; i++) { - if ((dbfilename = get_debug_name(curtime, i)) == NULL) { + amfree(db_name); + if ((db_name = get_debug_name(curtime, i)) == NULL) { error("Cannot create %s debug file", get_pname()); - /* NOTREACHED */ + /*NOTREACHED*/ } - if ((s = newvstralloc(s, dbgdir, dbfilename, NULL)) == NULL) { + if ((s = newvstralloc(s, dbgdir, db_name, NULL)) == NULL) { error("Cannot allocate %s debug file name memory", get_pname()); - /* NOTREACHED */ - } - amfree(dbfilename); + /*NOTREACHED*/ + } if ((fd = open(s, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0640)) < 0) { if (errno != EEXIST) { error("Cannot create %s debug file: %s", get_pname(), strerror(errno)); - /* NOTREACHED */ + /*NOTREACHED*/ } amfree(s); } @@ -302,12 +331,13 @@ void debug_open() debug_setup_2(s, fd, "start"); } -void debug_reopen(dbfilename, notation) - char *dbfilename; - char *notation; +void +debug_reopen( + char * dbfilename, + char * notation) { char *s = NULL; - int fd = -1; + int fd; if (dbfilename == NULL) { return; @@ -316,7 +346,7 @@ void debug_reopen(dbfilename, notation) /* * Do initial setup. */ - debug_setup_1(); + debug_setup_1(NULL, NULL); /* * Reopen the file. @@ -328,6 +358,7 @@ void debug_reopen(dbfilename, notation) } if ((fd = open(s, O_RDWR|O_APPEND)) < 0) { error("cannot reopen %s debug file %s", get_pname(), dbfilename); + /*NOTREACHED*/ } /* @@ -338,7 +369,67 @@ void debug_reopen(dbfilename, notation) debug_setup_2(s, fd, notation); } -void debug_close() +void +debug_rename( + char *config, + char *subdir) +{ + int fd = -1; + int i; + char *s = NULL; + mode_t mask; + + if (!db_filename) + return; + + /* + * Do initial setup. + */ + debug_setup_1(config, subdir); + + s = newvstralloc(s, dbgdir, db_name, NULL); + + if (strcmp(db_filename, s) == 0) { + amfree(s); + return; + } + + mask = (mode_t)umask((mode_t)0037); + /* check if a file with the same name already exist */ + if ((fd = open(s, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0640)) < 0) { + for(i = 0; fd < 0; i++) { + amfree(db_name); + if ((db_name = get_debug_name(curtime, i)) == NULL) { + dbprintf(("Cannot create %s debug file", get_pname())); + break; + } + + s = newvstralloc(s, dbgdir, db_name, NULL); + if ((fd = open(s, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0640)) < 0) { + if (errno != EEXIST) { + dbprintf(("Cannot create %s debug file: %s", get_pname(), + strerror(errno))); + break; + } + } + } + } + + if (fd >= 0) { + rename(db_filename, s); + } + (void)umask(mask); /* Restore mask */ + close(fd); + /* + * Finish setup. + * + * Note: we release control of the string 's' points to. + */ + debug_setup_2(s, -1, "rename"); +} + +void +debug_close(void) { time_t curtime; int save_debug; @@ -360,24 +451,28 @@ void debug_close() int save_errno = errno; db_file = NULL; /* prevent recursion */ - error("close debug file: %s", strerror(save_errno)); + fprintf(stderr, "close debug file: %s", strerror(save_errno)); + /*NOTREACHED*/ } db_fd = -1; db_file = NULL; amfree(db_filename); } -int debug_fd() +int +debug_fd(void) { return db_fd; } -FILE *debug_fp() +FILE * +debug_fp(void) { return db_file; } -char *debug_fn() +char * +debug_fn(void) { return db_filename; } @@ -389,14 +484,16 @@ char *debug_fn() * time indicator. */ -void set_debug_prefix_pid(p) - pid_t p; +void +set_debug_prefix_pid( + pid_t p) { debug_prefix_pid = p; } -char *debug_prefix(suffix) - char *suffix; +char * +debug_prefix( + char * suffix) { int save_errno; static char *s = NULL; @@ -405,7 +502,7 @@ char *debug_prefix(suffix) save_errno = errno; s = newvstralloc(s, get_pname(), suffix, NULL); if (debug_prefix_pid != (pid_t) 0) { - snprintf(debug_pid, sizeof(debug_pid), + snprintf(debug_pid, SIZEOF(debug_pid), "%ld", (long) debug_prefix_pid); s = newvstralloc(s, s, "[", debug_pid, "]", NULL); @@ -414,8 +511,9 @@ char *debug_prefix(suffix) return s; } -char *debug_prefix_time(suffix) - char *suffix; +char * +debug_prefix_time( + char * suffix) { int save_errno; static char *s = NULL; diff --git a/common-src/dgram.c b/common-src/dgram.c index cdf8a09..5df3a57 100644 --- a/common-src/dgram.c +++ b/common-src/dgram.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: dgram.c,v 1.29 2006/01/12 01:57:05 paddy_s Exp $ + * $Id: dgram.c,v 1.32 2006/07/05 19:54:20 martinea Exp $ * * library routines to marshall/send, recv/unmarshall UDP packets */ @@ -34,27 +34,35 @@ #include "dgram.h" #include "util.h" -void dgram_socket(dgram, socket) -dgram_t *dgram; -int socket; +void +dgram_socket( + dgram_t * dgram, + int socket) { if(socket < 0 || socket >= FD_SETSIZE) { error("dgram_socket: socket %d out of range (0 .. %d)\n", socket, FD_SETSIZE-1); + /*NOTREACHED*/ } dgram->socket = socket; } -int dgram_bind(dgram, portp) -dgram_t *dgram; -int *portp; +int +dgram_bind( + dgram_t * dgram, + in_port_t * portp) { - int s; + int s, retries; socklen_t len; struct sockaddr_in name; int save_errno; +#if defined(USE_REUSEADDR) + const int on = 1; + int r; +#endif + *portp = (in_port_t)0; if((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { save_errno = errno; dbprintf(("%s: dgram_bind: socket() failed: %s\n", @@ -63,7 +71,7 @@ int *portp; errno = save_errno; return -1; } - if(s < 0 || s >= FD_SETSIZE) { + if(s < 0 || s >= (int)FD_SETSIZE) { dbprintf(("%s: dgram_bind: socket out of range: %d\n", debug_prefix(NULL), s)); @@ -72,10 +80,20 @@ int *portp; return -1; } - memset(&name, 0, sizeof(name)); - name.sin_family = AF_INET; + memset(&name, 0, SIZEOF(name)); + name.sin_family = (sa_family_t)AF_INET; name.sin_addr.s_addr = INADDR_ANY; +#ifdef USE_REUSEADDR + r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + (void *)&on, (socklen_t)sizeof(on)); + if (r < 0) { + dbprintf(("%s: dgram_bind: setsockopt(SO_REUSEADDR) failed: %s\n", + debug_prefix(NULL), + strerror(errno))); + } +#endif + /* * If a port range was specified, we try to get a port in that * range first. Next, we try to get a reserved port. If that @@ -87,29 +105,48 @@ int *portp; * to get the desired port, and to make sure we return a port that * is within the range it requires. */ + for (retries = 0; ; retries++) { #ifdef UDPPORTRANGE - if (bind_portrange(s, &name, UDPPORTRANGE, "udp") == 0) - goto out; + if (bind_portrange(s, &name, UDPPORTRANGE, "udp") == 0) + goto out; + dbprintf(("%s: dgram_bind: Could to bind to port in range: %d - %d.\n", + debug_prefix(NULL), UDPPORTRANGE)); #endif - if (bind_portrange(s, &name, 512, IPPORT_RESERVED - 1, "udp") == 0) - goto out; + if (bind_portrange(s, &name, (in_port_t)512, + (in_port_t)(IPPORT_RESERVED - 1), "udp") == 0) + goto out; + dbprintf(("%s: dgram_bind: Could to bind to port in range: 512 - %d.\n", + debug_prefix(NULL), IPPORT_RESERVED - 1)); + + name.sin_port = INADDR_ANY; + if (bind(s, (struct sockaddr *)&name, (socklen_t)sizeof(name)) == 0) + goto out; + dbprintf(("%s: dgram_bind: Could to bind to any port: %s\n", + debug_prefix(NULL), strerror(errno))); + + if (retries >= BIND_CYCLE_RETRIES) { + dbprintf(("%s: dgram_bind: Giving up...\n", debug_prefix(NULL))); + break; + } - name.sin_port = INADDR_ANY; - if (bind(s, (struct sockaddr *)&name, (socklen_t)sizeof name) == -1) { - save_errno = errno; - dbprintf(("%s: dgram_bind: bind(INADDR_ANY) failed: %s\n", + dbprintf(("%s: dgram_bind: Retrying entire range after 10 second delay.\n", + debug_prefix(NULL))); + sleep(15); + } + + save_errno = errno; + dbprintf(("%s: dgram_bind: bind(INADDR_ANY) failed: %s\n", debug_prefix(NULL), strerror(save_errno))); - errno = save_errno; - aclose(s); - return -1; - } + aclose(s); + errno = save_errno; + return -1; out: /* find out what name was actually used */ - len = (socklen_t) sizeof name; + len = (socklen_t)sizeof(name); if(getsockname(s, (struct sockaddr *)&name, &len) == -1) { save_errno = errno; dbprintf(("%s: dgram_bind: getsockname() failed: %s\n", @@ -119,7 +156,7 @@ out: aclose(s); return -1; } - *portp = ntohs(name.sin_port); + *portp = (in_port_t)ntohs(name.sin_port); dgram->socket = s; dbprintf(("%s: dgram_bind: socket bound to %s.%d\n", @@ -130,17 +167,27 @@ out: } -int dgram_send_addr(addr, dgram) -struct sockaddr_in addr; -dgram_t *dgram; +int +dgram_send_addr( + struct sockaddr_in addr, + dgram_t * dgram) { - int s; + int s, rc; int socket_opened; struct sockaddr_in addr_save; int save_errno; int max_wait; int wait_count; +#if defined(USE_REUSEADDR) + const int on = 1; + int r; +#endif + dbprintf(("%s: dgram_send_addr(addr=%p, dgram=%p)\n", + debug_prefix(NULL), &addr, dgram)); + dump_sockaddr(&addr); + dbprintf(("%s: dgram_send_addr: %p->socket = %d\n", + debug_prefix(NULL), dgram, dgram->socket)); if(dgram->socket != -1) { s = dgram->socket; socket_opened = 0; @@ -154,82 +201,93 @@ dgram_t *dgram; return -1; } socket_opened = 1; +#ifdef USE_REUSEADDR + r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + (void *)&on, (socklen_t)sizeof(on)); + if (r < 0) { + dbprintf(("%s: dgram_send_addr: setsockopt(SO_REUSEADDR) failed: %s\n", + debug_prefix(NULL), + strerror(errno))); + } +#endif } + memcpy(&addr_save, &addr, SIZEOF(addr)); if(s < 0 || s >= FD_SETSIZE) { dbprintf(("%s: dgram_send_addr: socket out of range: %d\n", debug_prefix(NULL), s)); - if(socket_opened) { - aclose(s); - } errno = EMFILE; /* out of range */ - return -1; - } - - memcpy(&addr_save, &addr, sizeof(addr)); - max_wait = 300 / 5; /* five minutes */ - wait_count = 0; - while(sendto(s, + rc = -1; + } else { + max_wait = 300 / 5; /* five minutes */ + wait_count = 0; + rc = 0; + while(sendto(s, dgram->data, dgram->len, 0, (struct sockaddr *)&addr, - (socklen_t) sizeof(struct sockaddr_in)) == -1) { + (int)sizeof(struct sockaddr_in)) == -1) { #ifdef ECONNREFUSED - if(errno == ECONNREFUSED && wait_count++ < max_wait) { - sleep(5); - dbprintf(("%s: dgram_send_addr: sendto(%s.%d): retry %d after ECONNREFUSED\n", + if(errno == ECONNREFUSED && wait_count++ < max_wait) { + sleep(5); + dbprintf(("%s: dgram_send_addr: sendto(%s.%hu): retry %d after ECONNREFUSED\n", debug_prefix_time(NULL), inet_ntoa(addr_save.sin_addr), - (int) ntohs(addr.sin_port), + (in_port_t)ntohs(addr.sin_port), wait_count)); - continue; - } + continue; + } #endif #ifdef EAGAIN - if(errno == EAGAIN && wait_count++ < max_wait) { - sleep(5); - dbprintf(("%s: dgram_send_addr: sendto(%s.%d): retry %d after EAGAIN\n", + if(errno == EAGAIN && wait_count++ < max_wait) { + sleep(5); + dbprintf(("%s: dgram_send_addr: sendto(%s.%hu): retry %d after EAGAIN\n", debug_prefix_time(NULL), inet_ntoa(addr_save.sin_addr), - (int) ntohs(addr.sin_port), + (in_port_t)ntohs(addr.sin_port), wait_count)); - continue; - } + continue; + } #endif - save_errno = errno; - dbprintf(("%s: dgram_send_addr: sendto(%s.%d) failed: %s \n", + save_errno = errno; + dbprintf(("%s: dgram_send_addr: sendto(%s.%d) failed: %s \n", debug_prefix_time(NULL), inet_ntoa(addr_save.sin_addr), (int) ntohs(addr.sin_port), strerror(save_errno))); - errno = save_errno; - return -1; + errno = save_errno; + rc = -1; + break; + } } if(socket_opened) { + save_errno = errno; if(close(s) == -1) { - save_errno = errno; dbprintf(("%s: dgram_send_addr: close(%s.%d): failed: %s\n", debug_prefix(NULL), inet_ntoa(addr_save.sin_addr), (int) ntohs(addr.sin_port), - strerror(save_errno))); - errno = save_errno; - return -1; + strerror(errno))); + /* + * Calling function should not care that the close failed. + * It does care about the send results though. + */ } - s = -1; + errno = save_errno; } - return 0; + return rc; } -int dgram_send(hostname, port, dgram) -char *hostname; -int port; -dgram_t *dgram; +int +dgram_send( + char * hostname, + in_port_t port, + dgram_t * dgram) { struct sockaddr_in name; struct hostent *hp; @@ -243,25 +301,26 @@ dgram_t *dgram; errno = save_errno; return -1; } - memcpy(&name.sin_addr, hp->h_addr, hp->h_length); - name.sin_family = AF_INET; - name.sin_port = htons(port); + memcpy(&name.sin_addr, hp->h_addr, (size_t)hp->h_length); + name.sin_family = (sa_family_t)AF_INET; + name.sin_port = (in_port_t)htons(port); return dgram_send_addr(name, dgram); } -int dgram_recv(dgram, timeout, fromaddr) -dgram_t *dgram; -int timeout; -struct sockaddr_in *fromaddr; +ssize_t +dgram_recv( + dgram_t * dgram, + int timeout, + struct sockaddr_in *fromaddr) { - fd_set ready; + SELECT_ARG_TYPE ready; struct timeval to; ssize_t size; int sock; socklen_t addrlen; - int nfound; + ssize_t nfound; int save_errno; sock = dgram->socket; @@ -271,7 +330,11 @@ struct sockaddr_in *fromaddr; to.tv_sec = timeout; to.tv_usec = 0; - nfound = select(sock+1, (SELECT_ARG_TYPE *)&ready, NULL, NULL, &to); + dbprintf(("%s: dgram_recv(dgram=%p, timeout=%u, fromaddr=%p)\n", + debug_prefix_time(NULL), timeout, fromaddr)); + dump_sockaddr(fromaddr); + + nfound = (ssize_t)select(sock+1, &ready, NULL, NULL, &to); if(nfound <= 0 || !FD_ISSET(sock, &ready)) { save_errno = errno; if(nfound < 0) { @@ -302,8 +365,8 @@ struct sockaddr_in *fromaddr; return nfound; } - addrlen = (socklen_t) sizeof(struct sockaddr_in); - size = recvfrom(sock, dgram->data, MAX_DGRAM, 0, + addrlen = (socklen_t)sizeof(struct sockaddr_in); + size = recvfrom(sock, dgram->data, (size_t)MAX_DGRAM, 0, (struct sockaddr *)fromaddr, &addrlen); if(size == -1) { save_errno = errno; @@ -313,49 +376,65 @@ struct sockaddr_in *fromaddr; errno = save_errno; return -1; } - dgram->len = size; + dgram->len = (size_t)size; dgram->data[size] = '\0'; dgram->cur = dgram->data; return size; } -void dgram_zero(dgram) -dgram_t *dgram; +void +dgram_zero( + dgram_t * dgram) { dgram->cur = dgram->data; dgram->len = 0; *(dgram->cur) = '\0'; } -printf_arglist_function1(void dgram_cat, dgram_t *, dgram, const char *, fmt) +printf_arglist_function1(int dgram_cat, dgram_t *, dgram, const char *, fmt) { - size_t bufsize; + ssize_t bufsize; va_list argp; + int len; assert(dgram != NULL); assert(fmt != NULL); - assert(dgram->len == dgram->cur - dgram->data); - assert(dgram->len >= 0 && dgram->len < sizeof(dgram->data)); + assert(dgram->len == (size_t)(dgram->cur - dgram->data)); + assert(dgram->len < SIZEOF(dgram->data)); - bufsize = sizeof(dgram->data) - dgram->len; + bufsize = (ssize_t)(sizeof(dgram->data) - dgram->len); if (bufsize <= 0) - return; + return -1; arglist_start(argp, fmt); - dgram->len += vsnprintf(dgram->cur, bufsize, fmt, argp); - dgram->cur = dgram->data + dgram->len; + len = vsnprintf(dgram->cur, (size_t)bufsize, fmt, argp); arglist_end(argp); + if((ssize_t)len > bufsize) { + dgram->len = sizeof(dgram->data); + dgram->cur = dgram->data + dgram->len; + return -1; + } + else { + arglist_start(argp, fmt); + dgram->len += vsnprintf(dgram->cur, (size_t)bufsize, fmt, argp); + arglist_end(argp); + dgram->cur = dgram->data + dgram->len; + } + return 0; } -void dgram_eatline(dgram) -dgram_t *dgram; +void +dgram_eatline( + dgram_t * dgram) { char *p = dgram->cur; char *end = dgram->data + dgram->len; - while(p < end && *p && *p != '\n') p++; - if(*p == '\n') p++; + while(p < end && *p && *p != '\n') + p++; + if(*p == '\n') + p++; dgram->cur = p; } diff --git a/common-src/dgram.h b/common-src/dgram.h index 01edece..dbacc9f 100644 --- a/common-src/dgram.h +++ b/common-src/dgram.h @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: dgram.h,v 1.13 2001/07/13 22:38:05 jrjackson Exp $ + * $Id: dgram.h,v 1.15 2006/05/25 01:47:11 johnfranks Exp $ * * interface for datagram module */ @@ -44,18 +44,18 @@ typedef struct dgram_s { char *cur; int socket; - int len; + size_t len; char data[MAX_DGRAM+1]; } dgram_t; -int dgram_bind P((dgram_t *dgram, int *portp)); -void dgram_socket P((dgram_t *dgram, int sock)); -int dgram_send P((char *hostname, int port, dgram_t *dgram)); -int dgram_send_addr P((struct sockaddr_in addr, dgram_t *dgram)); -int dgram_recv P((dgram_t *dgram, int timeout, struct sockaddr_in *fromaddr)); -void dgram_zero P((dgram_t *dgram)); -void dgram_cat P((dgram_t *dgram, const char *fmt, ...)) +int dgram_bind(dgram_t *dgram, in_port_t *portp); +void dgram_socket(dgram_t *dgram, int sock); +int dgram_send(char *hostname, in_port_t port, dgram_t *dgram); +int dgram_send_addr(struct sockaddr_in addr, dgram_t *dgram); +ssize_t dgram_recv(dgram_t *dgram, int timeout, struct sockaddr_in *fromaddr); +void dgram_zero(dgram_t *dgram); +int dgram_cat(dgram_t *dgram, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); -void dgram_eatline P((dgram_t *dgram)); +void dgram_eatline(dgram_t *dgram); #endif /* ! DGRAM_H */ diff --git a/common-src/error.c b/common-src/error.c index 1b6f947..ade2e40 100644 --- a/common-src/error.c +++ b/common-src/error.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: error.c,v 1.18 2003/04/27 01:17:19 martinea Exp $ + * $Id: error.c,v 1.19 2006/05/25 01:47:11 johnfranks Exp $ * * error handling common to Amanda programs */ @@ -34,7 +34,7 @@ #define MAXFUNCS 8 -typedef void (*voidfunc) P((void)); +typedef void (*voidfunc)(void); static voidfunc onerr[MAXFUNCS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; @@ -42,28 +42,34 @@ int erroutput_type = ERR_INTERACTIVE; static char *pname = "unknown"; -static void (*logerror) P((char *)) = NULL; +static void output_error_message(char *msg); -void set_pname(p) -char *p; +static void (*logerror)(char *) = NULL; + +void +set_pname( + char * p) { pname = p; } -char *get_pname() +char * +get_pname(void) { return pname; } -void set_logerror(f) -void (*f) P((char *)); +void +set_logerror( + void (*f)(char *)) { logerror = f; } -static void output_error_message(msg) -char *msg; +static void +output_error_message( + char * msg) { /* print and/or log message */ @@ -75,7 +81,7 @@ char *msg; #ifdef LOG_AUTH openlog(get_pname(), LOG_PID, LOG_AUTH); #else - openlog(get_pname(), LOG_PID); + openlog(get_pname(), LOG_PID, 0); #endif syslog(LOG_NOTICE, "%s", msg); closelog(); @@ -107,7 +113,7 @@ printf_arglist_function(void error, const char *, format) /* format and output the error message */ arglist_start(argp, format); - vsnprintf(linebuf, sizeof(linebuf), format, argp); + vsnprintf(linebuf, SIZEOF(linebuf), format, argp); arglist_end(argp); output_error_message(linebuf); @@ -135,7 +141,7 @@ printf_arglist_function(void errordump, const char *, format) /* format error message */ arglist_start(argp, format); - vsnprintf(linebuf, sizeof(linebuf), format, argp); + vsnprintf(linebuf, SIZEOF(linebuf), format, argp); arglist_end(argp); output_error_message(linebuf); @@ -150,8 +156,6 @@ printf_arglist_function(void errordump, const char *, format) } -int onerror(errf) -void (*errf) P((void)); /* * Register function to be called when error is called. Up to MAXFUNCS * functions can be registered. If there isn't room in the table, onerror @@ -160,6 +164,10 @@ void (*errf) P((void)); * The resemblance to atexit() is on purpose. I wouldn't need onerror() * if everyone had atexit(). Bummer. */ + +int +onerror( + void (*errf)(void)) { int i; diff --git a/common-src/event.c b/common-src/event.c index 6809ca1..4ebdfef 100644 --- a/common-src/event.c +++ b/common-src/event.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: event.c,v 1.20 2005/10/02 15:31:07 martinea Exp $ + * $Id: event.c,v 1.24 2006/06/16 10:55:05 martinea Exp $ * * Event handler. Serializes different kinds of events to allow for * a uniform interface, central state storage, and centralized @@ -86,53 +86,52 @@ static struct { static struct sigtabent { event_handle_t *handle; /* handle for this signal */ int score; /* number of signals recvd since last checked */ - void (*oldhandler) P((int));/* old handler (for unsetting) */ + void (*oldhandler)(int);/* old handler (for unsetting) */ } sigtable[NSIG]; #ifdef EVENT_DEBUG -static const char *event_type2str P((event_type_t)); +static const char *event_type2str(event_type_t); #endif #define fire(eh) (*(eh)->fn)((eh)->arg) -static void signal_handler P((int)); -static event_handle_t *gethandle P((void)); -static void puthandle P((event_handle_t *)); +static void signal_handler(int); +static event_handle_t *gethandle(void); +static void puthandle(event_handle_t *); +static int event_loop_wait (event_handle_t *, const int); /* * Add a new event. See the comment in event.h for what the arguments * mean. */ event_handle_t * -event_register(data, type, fn, arg) - event_id_t data; - event_type_t type; - event_fn_t fn; - void *arg; +event_register( + event_id_t data, + event_type_t type, + event_fn_t fn, + void *arg) { event_handle_t *handle; - switch (type) { - case EV_READFD: - case EV_WRITEFD: + if ((type == EV_READFD) || (type == EV_WRITEFD)) { /* make sure we aren't given a high fd that will overflow a fd_set */ - assert(data < FD_SETSIZE); - break; - - case EV_SIG: + if (data >= FD_SETSIZE) { + error("event_register: Invalid file descriptor %d", data); + /*NOTREACHED*/ + } +#if !defined(__lint) /* Global checking knows that these are never called */ + } else if (type == EV_SIG) { /* make sure signals are within range */ - assert(data < NSIG); - /* make sure we don't double-register a signal */ - assert(sigtable[data].handle == NULL); - break; - - case EV_TIME: - case EV_WAIT: - break; - - case EV_DEAD: - default: - /* callers can't register EV_DEAD */ - assert(0); - break; + if (data >= NSIG) { + error("event_register: Invalid signal %d", data); + /*NOTREACHED*/ + } + if (sigtable[data].handle != NULL) { + error("event_register: signal %d already registered", data); + /*NOTREACHED*/ + } + } else if (type >= EV_DEAD) { + error("event_register: Invalid event type %d", type); + /*NOTREACHED*/ +#endif } handle = gethandle(); @@ -144,8 +143,9 @@ event_register(data, type, fn, arg) eventq_add(eventq, handle); eventq.qlength++; - eventprintf(("%s: event: register: %X data=%lu, type=%s\n", debug_prefix_time(NULL), (int)handle, - handle->data, event_type2str(handle->type))); + eventprintf(("%s: event: register: %p->data=%lu, type=%s\n", + debug_prefix_time(NULL), handle, handle->data, + event_type2str(handle->type))); return (handle); } @@ -155,14 +155,15 @@ event_register(data, type, fn, arg) * the event. */ void -event_release(handle) - event_handle_t *handle; +event_release( + event_handle_t *handle) { assert(handle != NULL); - eventprintf(("%s: event: release (mark): %X data=%lu, type=%s\n", debug_prefix_time(NULL), - (int)handle, handle->data, event_type2str(handle->type))); + eventprintf(("%s: event: release (mark): %p data=%lu, type=%s\n", + debug_prefix_time(NULL), handle, handle->data, + event_type2str(handle->type))); assert(handle->type != EV_DEAD); /* @@ -173,7 +174,7 @@ event_release(handle) struct sigtabent *se = &sigtable[handle->data]; assert(se->handle == handle); - signal(handle->data, se->oldhandler); + signal((int)handle->data, se->oldhandler); se->handle = NULL; se->score = 0; } @@ -194,20 +195,20 @@ event_release(handle) * Fire all EV_WAIT events waiting on the specified id. */ int -event_wakeup(id) - event_id_t id; +event_wakeup( + event_id_t id) { event_handle_t *eh; int nwaken = 0; - eventprintf(("%s: event: wakeup: enter (%lu)\n", debug_prefix_time(NULL), id)); - - assert(id >= 0); + eventprintf(("%s: event: wakeup: enter (%lu)\n", + debug_prefix_time(NULL), id)); for (eh = eventq_first(eventq); eh != NULL; eh = eventq_next(eh)) { if (eh->type == EV_WAIT && eh->data == id) { - eventprintf(("%s: event: wakeup: %X id=%lu\n", debug_prefix_time(NULL), (int)eh, id)); + eventprintf(("%s: event: wakeup: %p id=%lu\n", + debug_prefix_time(NULL), eh, id)); fire(eh); nwaken++; } @@ -222,27 +223,53 @@ event_wakeup(id) * we need to make sure we don't end up referencing a dead event handle. */ void -event_loop(dontblock) - const int dontblock; +event_loop( + const int dontblock) +{ + event_loop_wait((event_handle_t *)NULL, dontblock); +} + + + +int +event_wait( + event_handle_t *eh) +{ + return event_loop_wait(eh, 0); +} + +/* + * The event loop. We need to be specially careful here with adds and + * deletes. Since adds and deletes will often happen while this is running, + * we need to make sure we don't end up referencing a dead event handle. + */ +static int +event_loop_wait( + event_handle_t *wait_eh, + const int dontblock) { #ifdef ASSERTIONS static int entry = 0; #endif fd_set readfds, writefds, errfds, werrfds; struct timeval timeout, *tvptr; - int ntries, maxfd, rc, interval; + int ntries, maxfd, rc; + long interval; time_t curtime; event_handle_t *eh, *nexteh; struct sigtabent *se; + int event_wait_fired = 0; + int see_event; - eventprintf(("%s: event: loop: enter: dontblock=%d, qlength=%d\n", debug_prefix_time(NULL), - dontblock, eventq.qlength)); + eventprintf(("%s: event: loop: enter: dontblock=%d, qlength=%d, eh=%p\n", + debug_prefix_time(NULL), + dontblock, eventq.qlength, wait_eh)); /* * If we have no events, we have nothing to do */ if (eventq.qlength == 0) - return; + return 0; /* * We must not be entered twice @@ -259,11 +286,14 @@ event_loop(dontblock) do { #ifdef EVENT_DEBUG - eventprintf(("%s: event: loop: dontblock=%d, qlength=%d\n", debug_prefix_time(NULL), dontblock, - eventq.qlength)); + eventprintf(("%s: event: loop: dontblock=%d, qlength=%d eh=%p\n", + debug_prefix_time(NULL), dontblock, eventq.qlength, + wait_eh)); for (eh = eventq_first(eventq); eh != NULL; eh = eventq_next(eh)) { - eventprintf(("%s: %X: %s data=%lu fn=0x%x arg=0x%x\n", debug_prefix_time(NULL), (int)eh, - event_type2str(eh->type), eh->data, (int)eh->fn, (int)eh->arg)); + eventprintf(("%s: %p): %s data=%lu fn=%p arg=%p\n", + debug_prefix_time(NULL), eh, + event_type2str(eh->type), eh->data, eh->fn, + eh->arg)); } #endif /* @@ -294,6 +324,7 @@ event_loop(dontblock) FD_ZERO(&errfds); maxfd = 0; + see_event = (wait_eh == (event_handle_t *)NULL); /* * Run through each event handle and setup the events. * We save our next pointer early in case we GC some dead @@ -308,18 +339,20 @@ event_loop(dontblock) * Read fds just get set into the select bitmask */ case EV_READFD: - FD_SET(eh->data, &readfds); - FD_SET(eh->data, &errfds); - maxfd = max(maxfd, eh->data); + FD_SET((int)eh->data, &readfds); + FD_SET((int)eh->data, &errfds); + maxfd = max(maxfd, (int)eh->data); + see_event |= (eh == wait_eh); break; /* * Likewise with write fds */ case EV_WRITEFD: - FD_SET(eh->data, &writefds); - FD_SET(eh->data, &errfds); - maxfd = max(maxfd, eh->data); + FD_SET((int)eh->data, &writefds); + FD_SET((int)eh->data, &errfds); + maxfd = max(maxfd, (int)eh->data); + see_event |= (eh == wait_eh); break; /* @@ -328,6 +361,7 @@ event_loop(dontblock) */ case EV_SIG: se = &sigtable[eh->data]; + see_event |= (eh == wait_eh); if (se->handle == eh) break; @@ -336,7 +370,9 @@ event_loop(dontblock) assert(se->handle == NULL); se->handle = eh; se->score = 0; - se->oldhandler = signal(eh->data, signal_handler); + /*@ignore@*/ + se->oldhandler = signal((int)eh->data, signal_handler); + /*@end@*/ break; /* @@ -350,7 +386,7 @@ event_loop(dontblock) if (eh->lastfired == -1) eh->lastfired = curtime; - interval = eh->data - (curtime - eh->lastfired); + interval = (long)(eh->data - (curtime - eh->lastfired)); if (interval < 0) interval = 0; @@ -361,12 +397,14 @@ event_loop(dontblock) tvptr = &timeout; timeout.tv_sec = interval; } + see_event |= (eh == wait_eh); break; /* * Wait events are processed immediately by event_wakeup() */ case EV_WAIT: + see_event |= (eh == wait_eh); break; /* @@ -383,13 +421,21 @@ event_loop(dontblock) } } + if(!see_event) { + assert(--entry == 0); + return 0; + } + /* * Let 'er rip */ - eventprintf(("%s: event: select: dontblock=%d, maxfd=%d, timeout=%ld\n", debug_prefix_time(NULL), - dontblock, maxfd, tvptr != NULL ? timeout.tv_sec : -1)); + eventprintf(( + "%s: event: select: dontblock=%d, maxfd=%d, timeout=%ld\n", + debug_prefix_time(NULL), dontblock, maxfd, + tvptr != NULL ? timeout.tv_sec : -1)); rc = select(maxfd + 1, &readfds, &writefds, &errfds, tvptr); - eventprintf(("%s: event: select returns %d\n", debug_prefix_time(NULL), rc)); + eventprintf(("%s: event: select returns %d\n", + debug_prefix_time(NULL), rc)); /* * Select errors can mean many things. Interrupted events should @@ -398,8 +444,10 @@ event_loop(dontblock) */ if (rc < 0) { if (errno != EINTR) { - if (++ntries > 5) + if (++ntries > 5) { error("select failed: %s", strerror(errno)); + /*NOTREACHED*/ + } continue; } /* proceed if errno == EINTR, we may have caught a signal */ @@ -420,24 +468,26 @@ event_loop(dontblock) * that are being polled for both reading and writing have * both of their poll events 'see' the error. */ - memcpy(&werrfds, &errfds, sizeof(werrfds)); + memcpy(&werrfds, &errfds, SIZEOF(werrfds)); /* * Now run through the events and fire the ones that are ready. * Don't handle file descriptor events if the select failed. */ for (eh = eventq_first(eventq); eh != NULL; eh = eventq_next(eh)) { + switch (eh->type) { /* * Read fds: just fire the event if set in the bitmask */ case EV_READFD: - if (FD_ISSET(eh->data, &readfds) || - FD_ISSET(eh->data, &errfds)) { - FD_CLR(eh->data, &readfds); - FD_CLR(eh->data, &errfds); + if (FD_ISSET((int)eh->data, &readfds) || + FD_ISSET((int)eh->data, &errfds)) { + FD_CLR((int)eh->data, &readfds); + FD_CLR((int)eh->data, &errfds); fire(eh); + if(eh == wait_eh) event_wait_fired = 1; } break; @@ -445,11 +495,12 @@ event_loop(dontblock) * Write fds: same as Read fds */ case EV_WRITEFD: - if (FD_ISSET(eh->data, &writefds) || - FD_ISSET(eh->data, &werrfds)) { - FD_CLR(eh->data, &writefds); - FD_CLR(eh->data, &werrfds); + if (FD_ISSET((int)eh->data, &writefds) || + FD_ISSET((int)eh->data, &werrfds)) { + FD_CLR((int)eh->data, &writefds); + FD_CLR((int)eh->data, &werrfds); fire(eh); + if(eh == wait_eh) event_wait_fired = 1; } break; @@ -463,6 +514,7 @@ event_loop(dontblock) assert(se->handle == eh); se->score = 0; fire(eh); + if(eh == wait_eh) event_wait_fired = 1; } break; @@ -473,9 +525,10 @@ event_loop(dontblock) case EV_TIME: if (eh->lastfired == -1) eh->lastfired = curtime; - if (curtime - eh->lastfired >= eh->data) { + if ((curtime - eh->lastfired) >= (time_t)eh->data) { eh->lastfired = curtime; fire(eh); + if(eh == wait_eh) event_wait_fired = 1; } break; @@ -492,9 +545,11 @@ event_loop(dontblock) break; } } - } while (!dontblock && eventq.qlength > 0); + } while (!dontblock && eventq.qlength > 0 && event_wait_fired == 0); assert(--entry == 0); + + return (event_wait_fired == 1); } /* @@ -502,11 +557,11 @@ event_loop(dontblock) * loop. */ static void -signal_handler(signo) - int signo; +signal_handler( + int signo) { - assert(signo >= 0 && signo < sizeof(sigtable) / sizeof(sigtable[0])); + assert((signo >= 0) && ((size_t)signo < (size_t)(sizeof(sigtable) / sizeof(sigtable[0])))); sigtable[signo].score++; } @@ -515,7 +570,7 @@ signal_handler(signo) * alloc a new one. */ static event_handle_t * -gethandle() +gethandle(void) { event_handle_t *eh; @@ -526,7 +581,7 @@ gethandle() return (eh); } assert(cache.qlength == 0); - return (alloc(sizeof(*eh))); + return (alloc(SIZEOF(*eh))); } /* @@ -534,8 +589,8 @@ gethandle() * Otherwise, free it. */ static void -puthandle(eh) - event_handle_t *eh; +puthandle( + event_handle_t *eh) { if (cache.qlength > CACHEDEPTH) { @@ -551,8 +606,8 @@ puthandle(eh) * Convert an event type into a string */ static const char * -event_type2str(type) - event_type_t type; +event_type2str( + event_type_t type) { static const struct { event_type_t type; @@ -567,9 +622,9 @@ event_type2str(type) X(EV_DEAD), #undef X }; - int i; + size_t i; - for (i = 0; i < sizeof(event_types) / sizeof(event_types[0]); i++) + for (i = 0; i < (size_t)(sizeof(event_types) / sizeof(event_types[0])); i++) if (type == event_types[i].type) return (event_types[i].name); return ("BOGUS EVENT TYPE"); diff --git a/common-src/event.h b/common-src/event.h index 367f3b5..be64f89 100644 --- a/common-src/event.h +++ b/common-src/event.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: event.h,v 1.6 2005/11/30 22:35:11 martinea Exp $ + * $Id: event.h,v 1.9 2006/06/16 10:55:05 martinea Exp $ */ #ifndef EVENT_H #define EVENT_H @@ -66,7 +66,7 @@ typedef enum { * The function signature for functions that get called when an event * fires. */ -typedef void (*event_fn_t) P((void *)); +typedef void (*event_fn_t)(void *); /* * Register an event handler. @@ -82,23 +82,27 @@ typedef void (*event_fn_t) P((void *)); * count on the time events being too accurate. They depend on the * caller calling event_loop() often enough. */ -event_handle_t *event_register P((event_id_t, event_type_t, - event_fn_t, void *)); +event_handle_t *event_register(event_id_t, event_type_t, event_fn_t, void *); /* * Release an event handler. */ -void event_release P((event_handle_t *)); +void event_release(event_handle_t *); /* * Wake up all EV_WAIT events waiting on a specific id */ -int event_wakeup P((event_id_t)); +int event_wakeup(event_id_t); + +/* + * Block until the event is terminated. + */ +int event_wait(event_handle_t *); /* * Process events. If the argument is nonzero, then the loop does * not block. */ -void event_loop P((const int)); +void event_loop(const int); #endif /* EVENT_H */ diff --git a/common-src/file.c b/common-src/file.c index ce4d28b..a03197e 100644 --- a/common-src/file.c +++ b/common-src/file.c @@ -23,7 +23,7 @@ * Author: AMANDA core development group. */ /* - * $Id: file.c,v 1.35 2006/03/09 16:51:41 martinea Exp $ + * $Id: file.c,v 1.40 2006/07/19 17:41:15 martinea Exp $ * * file and directory bashing routines */ @@ -31,7 +31,9 @@ #include "amanda.h" #include "util.h" -static int mk1dir P((const char *, int, uid_t, gid_t)); +void amanda_setup(int argc, char **argv, int setup_flags); +static int mk1dir(const char *, mode_t, uid_t, gid_t); +static void areads_getbuf(const char *s, int l, int fd); uid_t client_uid = (uid_t) -1; gid_t client_gid = (gid_t) -1; @@ -42,24 +44,25 @@ gid_t client_gid = (gid_t) -1; ** it will do nothing - only root is permitted to change the owner ** of a file. */ -static int mk1dir(dir, mode, uid, gid) -const char *dir; /* directory to create */ -int mode; /* mode for new directory */ -uid_t uid; /* uid for new directory */ -gid_t gid; /* gid for new directory */ +static int +mk1dir( + const char *dir, /* directory to create */ + mode_t mode, /* mode for new directory */ + uid_t uid, /* uid for new directory */ + gid_t gid) /* gid for new directory */ { int rc; /* return code */ - rc = 0; /* assume the best */ - - if(mkdir(dir, mode) == 0) { - chmod(dir, mode); /* mkdir() is affected by the umask */ - chown(dir, uid, gid); /* XXX - no-op on most systems? */ + if((rc = mkdir(dir, mode)) == 0) { + if ((rc = chmod(dir, mode)) == 0) { /* mkdir() affected by the umask */ + rc = chown(dir, uid, gid); + } } else { /* maybe someone beat us to it */ int serrno; serrno = errno; - if(access(dir, F_OK) != 0) rc = -1; + if(access(dir, F_OK) != 0) + rc = -1; errno = serrno; /* pass back the real error */ } @@ -73,19 +76,20 @@ gid_t gid; /* gid for new directory */ * the last element, but not the last element. So a (potential) file name * may be passed to mkpdir and all the parents of that file will be created. */ -int mkpdir(file, mode, uid, gid) -char *file; /* file to create parent directories for */ -int mode; /* mode for new directories */ -uid_t uid; /* uid for new directories */ -gid_t gid; /* gid for new directories */ +int +mkpdir( + char * file, /* file to create parent directories for */ + mode_t mode, /* mode for new directories */ + uid_t uid, /* uid for new directories */ + gid_t gid) /* gid for new directories */ { - char *dir = NULL, *p; + char *dir; + char *p; int rc; /* return code */ rc = 0; dir = stralloc(file); /* make a copy we can play with */ - p = strrchr(dir, '/'); if(p != dir && p != NULL) { /* got a '/' or a simple name */ *p = '\0'; @@ -107,12 +111,13 @@ gid_t gid; /* gid for new directories */ ** - stops deleting before topdir, ie: topdir will not be removed ** - if file is not under topdir this routine will not notice */ -int rmpdir(file, topdir) -char *file; /* directory hierarchy to remove */ -char *topdir; /* where to stop removing */ +int +rmpdir( + char * file, /* directory hierarchy to remove */ + char * topdir) /* where to stop removing */ { int rc; - char *p, *dir = NULL; + char *p, *dir; if(strcmp(file, topdir) == 0) return 0; /* all done */ @@ -138,10 +143,10 @@ char *topdir; /* where to stop removing */ dir = stralloc(file); p = strrchr(dir, '/'); - if(p == dir) rc = 0; /* no /'s */ - else { + if (p == NULL || p == dir) { + rc = 0; + } else { *p = '\0'; - rc = rmpdir(dir, topdir); } @@ -163,11 +168,14 @@ char *topdir; /* where to stop removing */ */ void -amanda_setup (argc, argv, setup_flags) - int argc; - char **argv; - int setup_flags; +amanda_setup ( + int argc, + char ** argv, + int setup_flags) { + (void)argc; /* Quiet unused parameter warning */ + (void)argv; /* Quiet unused parameter warning */ + (void)setup_flags; /* Quiet unused parameter warning */ } /* @@ -197,7 +205,7 @@ amanda_setup (argc, argv, setup_flags) */ void -safe_cd() +safe_cd(void) { int cd_ok = 0; struct stat sbuf; @@ -215,11 +223,11 @@ safe_cd() if (client_uid != (uid_t) -1) { #if defined(AMANDA_DBGDIR) d = stralloc2(AMANDA_DBGDIR, "/."); - (void) mkpdir(d, 02700, client_uid, client_gid); + (void) mkpdir(d, (mode_t)02700, client_uid, client_gid); amfree(d); #endif d = stralloc2(AMANDA_TMPDIR, "/."); - (void) mkpdir(d, 02700, client_uid, client_gid); + (void) mkpdir(d, (mode_t)02700, client_uid, client_gid); amfree(d); } @@ -241,7 +249,9 @@ safe_cd() if(cd_ok) { save_core(); /* save any old core file */ } else { - (void) chdir("/"); /* assume this works */ + if ((cd_ok = chdir("/")) == -1) { + (void)cd_ok; /* Quiet compiler warning if DEBUG disabled */ + } } } @@ -263,9 +273,9 @@ safe_cd() */ void -safe_fd(fd_start, fd_count) - int fd_start; - int fd_count; +safe_fd( + int fd_start, + int fd_count) { int fd; @@ -299,7 +309,6 @@ safe_fd(fd_start, fd_count) } } } - } /* @@ -324,7 +333,7 @@ safe_fd(fd_start, fd_count) */ void -save_core() +save_core(void) { struct stat sbuf; @@ -360,46 +369,32 @@ save_core() /* ** Sanitise a file name. ** -** Convert all funny characters to '_' so that we can use, +** Convert all '/' characters to '_' so that we can use, ** for example, disk names as part of file names. ** Notes: ** - there is a many-to-one mapping between input and output -** XXX - We only look for '/' and ' ' at the moment. May -** XXX - be we should also do all unprintables. +** - Only / and '\0' are disallowed in filenames by POSIX... */ -char *sanitise_filename(inp) -char *inp; +char * +sanitise_filename( + char * inp) { char *buf; - int buf_size; + size_t buf_size; char *s, *d; int ch; - buf_size = 2 * strlen(inp) + 1; /* worst case */ + buf_size = strlen(inp) + 1; /* worst case */ buf = alloc(buf_size); d = buf; s = inp; while((ch = *s++) != '\0') { - if(ch == '_') { - if(d >= buf + buf_size) { - amfree(buf); - return NULL; /* cannot happen */ - } - *d++ = '_'; /* convert _ to __ to try */ - /* and ensure unique output */ - } else if(ch == '/' || isspace(ch)) { + if(ch == '/') { ch = '_'; /* convert "bad" to "_" */ } - if(d >= buf + buf_size) { - amfree(buf); - return NULL; /* cannot happen */ - } - *d++ = ch; - } - if(d >= buf + buf_size) { - amfree(buf); - return NULL; /* cannot happen */ + *d++ = (char)ch; } + assert(d < buf + buf_size); *d = '\0'; return buf; @@ -409,84 +404,98 @@ char *inp; *===================================================================== * Get the next line of input from a stdio file. * - * char *agets (FILE *f) + * char *agets (FILE *stream) * - * entry: f = stdio stream to read - * exit: returns a pointer to an alloc'd string or NULL at EOF - * or error (errno will be zero on EOF). + * entry: stream - stream to read + * exit: returns a pointer to an alloc'd string or NULL + * at EOF or error. The functions ferror(stream) and + * feof(stream) should be checked by caller to determine + * stream status. * - * Notes: the newline, if read, is removed from the string + * Notes: the newline at the end of a line, if read, is removed from + * the string. Quoted newlines are left intact. * the caller is responsible for free'ing the string + * *===================================================================== */ +#define AGETS_LINE_INCR 128 + char * -debug_agets(s, l, file) - const char *s; - int l; - FILE *file; +debug_agets( + const char *sourcefile, + int lineno, + FILE * stream) { - char *line = NULL, *line_ptr; - size_t line_size, size_save; - int line_free, line_len; - char *cp; - char *f; - - malloc_enter(dbmalloc_caller_loc(s, l)); + int ch; + char *line = alloc(AGETS_LINE_INCR); + size_t line_size = 0; + size_t loffset = 0; + int inquote = 0; + int escape = 0; + + (void)sourcefile; /* Quiet unused parameter warning if not debugging */ + (void)lineno; /* Quiet unused parameter warning if not debugging */ + + while ((ch = fgetc(stream)) != EOF) { + if (ch == '\n') { + if (!inquote) { + if (escape) { + escape = 0; + loffset--; /* Consume escape in buffer */ + continue; + } + /* Reached end of line so exit without passing on LF */ + break; + } + } -#define AGETS_LINE_INCR 128 + if (ch == '\\') { + escape = 1; + } else { + if (ch == '"') { + if (!escape) + inquote = !inquote; + } + escape = 0; + } - line_size = AGETS_LINE_INCR; - line = debug_alloc (s, l, line_size); - line_free = line_size; - line_ptr = line; - line_len = 0; + if ((loffset + 1) >= line_size) { + char *tmpline; - while ((f = fgets(line_ptr, line_free, file)) != NULL) { - /* - * Note that we only have to search what we just read, not - * the whole buffer. - */ - if ((cp = strchr (line_ptr, '\n')) != NULL) { - line_len += cp - line_ptr; - *cp = '\0'; /* zap the newline */ - break; /* got to end of line */ - } - line_len += line_free - 1; /* bytes read minus '\0' */ - size_save = line_size; - if (line_size < 256 * AGETS_LINE_INCR) { - line_size *= 2; - } else { - line_size += 256 * AGETS_LINE_INCR; + /* + * Reallocate input line. + * alloc() never return NULL pointer. + */ + tmpline = alloc(line_size + AGETS_LINE_INCR); + memcpy(tmpline, line, line_size); + amfree(line); + line = tmpline; + line_size = line_size + AGETS_LINE_INCR; } - cp = debug_alloc (s, l, line_size); /* get more space */ - memcpy (cp, line, size_save); /* copy old to new */ - free (line); /* and release the old */ - line = cp; - line_ptr = line + size_save - 1; /* start at the null byte */ - line_free = line_size - line_len; /* and we get to use it */ + line[loffset++] = (char)ch; } + + if ((ch == EOF) && (loffset == 0)) { + amfree(line); /* amfree zeros line... */ + } else { + line[loffset] = '\0'; + } + /* - * Return what we got even if there was not a newline. Only - * report done (NULL) when no data was processed. + * Return what we got even if there was not a newline. + * Only report done (NULL) when no data was processed. */ - if (f == NULL && line_len == 0) { - amfree (line); - line = NULL; /* redundant, but clear */ - if(!ferror(file)) { - errno = 0; /* flag EOF vs error */ - } - } - malloc_leave(dbmalloc_caller_loc(s, l)); return line; } + /* *===================================================================== * Find/create a buffer for a particular file descriptor for use with * areads(). * - * void areads_getbuf (const char *file, int line, int fd) + * void areads_getbuf (const char *file, size_t line, int fd) * * entry: file, line = caller source location * fd = file descriptor to look up @@ -497,27 +506,27 @@ debug_agets(s, l, file) static struct areads_buffer { char *buffer; char *endptr; - ssize_t bufsize; + size_t bufsize; } *areads_buffer = NULL; static int areads_bufcount = 0; -static ssize_t areads_bufsize = BUFSIZ; /* for the test program */ +static size_t areads_bufsize = BUFSIZ; /* for the test program */ static void -areads_getbuf(s, l, fd) - const char *s; - int l; - int fd; +areads_getbuf( + const char *s, + int l, + int fd) { struct areads_buffer *new; - ssize_t size; + size_t size; assert(fd >= 0); if(fd >= areads_bufcount) { - size = (fd + 1) * sizeof(*areads_buffer); + size = (size_t)(fd + 1) * SIZEOF(*areads_buffer); new = (struct areads_buffer *) debug_alloc(s, l, size); memset((char *)new, 0, size); if(areads_buffer) { - size = areads_bufcount * sizeof(*areads_buffer); + size = areads_bufcount * SIZEOF(*areads_buffer); memcpy(new, areads_buffer, size); } amfree(areads_buffer); @@ -545,8 +554,8 @@ areads_getbuf(s, l, fd) */ ssize_t -areads_dataready(fd) - int fd; +areads_dataready( + int fd) { ssize_t r = 0; @@ -568,8 +577,8 @@ areads_dataready(fd) */ void -areads_relbuf(fd) - int fd; +areads_relbuf( + int fd) { if(fd >= 0 && fd < areads_bufcount) { amfree(areads_buffer[fd].buffer); @@ -594,18 +603,18 @@ areads_relbuf(fd) */ char * -debug_areads (s, l, fd) - const char *s; - int l; - int fd; +debug_areads ( + const char *s, + int l, + int fd) { char *nl; char *line; char *buffer; char *endptr; char *newbuf; - ssize_t buflen; - ssize_t size; + size_t buflen; + size_t size; ssize_t r; malloc_enter(dbmalloc_caller_loc(s, l)); @@ -617,7 +626,7 @@ debug_areads (s, l, fd) areads_getbuf(s, l, fd); buffer = areads_buffer[fd].buffer; endptr = areads_buffer[fd].endptr; - buflen = areads_buffer[fd].bufsize - (endptr - buffer); + buflen = areads_buffer[fd].bufsize - (size_t)(endptr - buffer); while((nl = strchr(buffer, '\n')) == NULL) { /* * No newline yet, so get more data. @@ -631,13 +640,12 @@ debug_areads (s, l, fd) newbuf = debug_alloc(s, l, size + 1); memcpy (newbuf, buffer, areads_buffer[fd].bufsize + 1); amfree(areads_buffer[fd].buffer); - buffer = NULL; areads_buffer[fd].buffer = newbuf; areads_buffer[fd].endptr = newbuf + areads_buffer[fd].bufsize; areads_buffer[fd].bufsize = size; buffer = areads_buffer[fd].buffer; endptr = areads_buffer[fd].endptr; - buflen = areads_buffer[fd].bufsize - (endptr - buffer); + buflen = areads_buffer[fd].bufsize - (size_t)(endptr - buffer); } if ((r = read(fd, endptr, buflen)) <= 0) { if(r == 0) { @@ -652,7 +660,7 @@ debug_areads (s, l, fd) } *nl++ = '\0'; line = stralloc(buffer); - size = endptr - nl; /* data still left in buffer */ + size = (size_t)(endptr - nl); /* data still left in buffer */ memmove(buffer, nl, size); areads_buffer[fd].endptr = buffer + size; areads_buffer[fd].endptr[0] = '\0'; @@ -662,9 +670,10 @@ debug_areads (s, l, fd) #ifdef TEST -int main(argc, argv) - int argc; - char **argv; +int +main( + int argc, + char ** argv) { int rc; int fd; @@ -677,6 +686,8 @@ int main(argc, argv) set_pname("file test"); + dbopen(NULL); + /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); @@ -694,7 +705,7 @@ int main(argc, argv) } fprintf(stderr, "Create parent directories of %s ...", name); - rc = mkpdir(name, 02777, (uid_t)-1, (gid_t)-1); + rc = mkpdir(name, (mode_t)02777, (uid_t)-1, (gid_t)-1); if (rc == 0) fprintf(stderr, " done\n"); else { diff --git a/common-src/fileheader.c b/common-src/fileheader.c index ede3479..f6786a8 100644 --- a/common-src/fileheader.c +++ b/common-src/fileheader.c @@ -24,48 +24,95 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: fileheader.c,v 1.34 2006/03/09 16:51:41 martinea Exp $ + * $Id: fileheader.c,v 1.40 2006/07/01 00:10:38 paddy_s Exp $ */ #include "amanda.h" #include "fileheader.h" -static const char *filetype2str P((filetype_t)); -static filetype_t str2filetype P((const char *)); +static const char * filetype2str(filetype_t); +static filetype_t str2filetype(const char *); +static void strange_header(dumpfile_t *, const char *, + size_t, const char *, const char *); void -fh_init(file) - dumpfile_t *file; +fh_init( + dumpfile_t *file) { - memset(file, '\0', sizeof(*file)); + memset(file, '\0', SIZEOF(*file)); file->blocksize = DISK_BLOCK_BYTES; } +static void +strange_header( + dumpfile_t *file, + const char *buffer, + size_t buflen, + const char *expected, + const char *actual) +{ + if (actual == NULL) + actual = ""; + if (expected == NULL) + expected = ""; + + fprintf(stderr, "%s: strange amanda header: \"%.*s\"\n", get_pname(), + (int)buflen, buffer); + + fprintf(stderr, "%s: Expected: \"%s\" Actual: \"%s\"\n", get_pname(), + expected, actual); + + file->type = F_WEIRD; +} + + void -parse_file_header(buffer, file, buflen) - const char *buffer; - dumpfile_t *file; - size_t buflen; +parse_file_header( + const char *buffer, + dumpfile_t *file, + size_t buflen) { - char *buf, *line, *tok, *line1=NULL; - int lsize; + char *buf, *line, *tok, *line1; + size_t lsize; + char *uqname; + int in_quotes; + /* put the buffer into a writable chunk of memory and nul-term it */ buf = alloc(buflen + 1); memcpy(buf, buffer, buflen); buf[buflen] = '\0'; - fh_init(file); - for(line=buf,lsize=0; *line != '\n' && lsize < buflen; line++) {lsize++;}; + in_quotes = 0; + for (line = buf, lsize = 0; lsize < buflen; line++) { + if ((*line == '\n') && !in_quotes) + break; + + if (*line == '"') { + in_quotes = !in_quotes; + } else if ((*line == '\\') && (*(line + 1) == '"')) { + line++; + lsize++; + } + lsize++; + } *line = '\0'; - line1 = alloc(lsize+1); - strncpy(line1,buf,lsize); + line1 = alloc(lsize + 1); + strncpy(line1, buf, lsize); line1[lsize] = '\0'; *line = '\n'; tok = strtok(line1, " "); - if (tok == NULL) - goto weird_header; + if (tok == NULL) { + fprintf(stderr, "%s: Empty amanda header: buflen=" SIZE_T_FMT + " lsize=" SIZE_T_FMT "\n", get_pname(), + (SIZE_T_FMT_TYPE)buflen, + (SIZE_T_FMT_TYPE)lsize); + hexdump(buffer, lsize); + strange_header(file, buffer, buflen, "", tok); + goto out; + } + if (strcmp(tok, "NETDUMP:") != 0 && strcmp(tok, "AMANDA:") != 0) { amfree(buf); file->type = F_UNKNOWN; @@ -74,91 +121,119 @@ parse_file_header(buffer, file, buflen) } tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } file->type = str2filetype(tok); - + switch (file->type) { case F_TAPESTART: tok = strtok(NULL, " "); - if (tok == NULL || strcmp(tok, "DATE") != 0) - goto weird_header; + if ((tok == NULL) || (strcmp(tok, "DATE") != 0)) { + strange_header(file, buffer, buflen, "DATE", tok); + goto out; + } tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->datestamp, tok, sizeof(file->datestamp) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + strncpy(file->datestamp, tok, SIZEOF(file->datestamp) - 1); tok = strtok(NULL, " "); - if (tok == NULL || strcmp(tok, "TAPE") != 0) - goto weird_header; + if ((tok == NULL) || (strcmp(tok, "TAPE") != 0)) { + strange_header(file, buffer, buflen, "TAPE", tok); + goto out; + } tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->name, tok, sizeof(file->name) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + strncpy(file->name, tok, SIZEOF(file->name) - 1); break; case F_DUMPFILE: case F_CONT_DUMPFILE: case F_SPLIT_DUMPFILE: tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->datestamp, tok, sizeof(file->datestamp) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + strncpy(file->datestamp, tok, SIZEOF(file->datestamp) - 1); tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->name, tok, sizeof(file->name) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + strncpy(file->name, tok, SIZEOF(file->name) - 1); - tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->disk, tok, sizeof(file->disk) - 1); + tok = strquotedstr(); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + uqname = unquote_string(tok); + strncpy(file->disk, uqname, SIZEOF(file->disk) - 1); + amfree(uqname); - if(file->type == F_SPLIT_DUMPFILE){ + if(file->type == F_SPLIT_DUMPFILE) { tok = strtok(NULL, " "); - if (tok == NULL || strcmp(tok, "part") != 0) - goto weird_header; + if (tok == NULL || strcmp(tok, "part") != 0) { + strange_header(file, buffer, buflen, "part", tok); + goto out; + } tok = strtok(NULL, "/"); - if (tok == NULL || sscanf(tok, "%d", &file->partnum) != 1) - goto weird_header; + if ((tok == NULL) || (sscanf(tok, "%d", &file->partnum) != 1)) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } - tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; /* If totalparts == -1, then the original dump was done in streaming mode (no holding disk), thus we don't know how many parts there are. */ - if(sscanf(tok, "%d", &file->totalparts) != 1){ - goto weird_header; + tok = strtok(NULL, " "); + if((tok == NULL) || (sscanf(tok, "%d", &file->totalparts) != 1)) { + strange_header(file, buffer, buflen, "", tok); + goto out; } } - tok = strtok(NULL, " "); - if (tok == NULL || strcmp(tok, "lev") != 0) - goto weird_header; + if ((tok == NULL) || (strcmp(tok, "lev") != 0)) { + strange_header(file, buffer, buflen, "lev", tok); + goto out; + } tok = strtok(NULL, " "); - if (tok == NULL || sscanf(tok, "%d", &file->dumplevel) != 1) - goto weird_header; + if ((tok == NULL) || (sscanf(tok, "%d", &file->dumplevel) != 1)) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } tok = strtok(NULL, " "); - if (tok == NULL || strcmp(tok, "comp") != 0) - goto weird_header; + if ((tok == NULL) || (strcmp(tok, "comp") != 0)) { + strange_header(file, buffer, buflen, "comp", tok); + goto out; + } tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->comp_suffix, tok, sizeof(file->comp_suffix) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + strncpy(file->comp_suffix, tok, SIZEOF(file->comp_suffix) - 1); file->compressed = strcmp(file->comp_suffix, "N"); /* compatibility with pre-2.2 amanda */ if (strcmp(file->comp_suffix, "C") == 0) - strncpy(file->comp_suffix, ".Z", sizeof(file->comp_suffix) - 1); + strncpy(file->comp_suffix, ".Z", SIZEOF(file->comp_suffix) - 1); tok = strtok(NULL, " "); /* "program" is optional */ @@ -169,22 +244,26 @@ parse_file_header(buffer, file, buflen) } tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->program, tok, sizeof(file->program) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } + strncpy(file->program, tok, SIZEOF(file->program) - 1); if (file->program[0] == '\0') - strncpy(file->program, "RESTORE", sizeof(file->program) - 1); + strncpy(file->program, "RESTORE", SIZEOF(file->program) - 1); if ((tok = strtok(NULL, " ")) == NULL) - break; /* reach the end of the buf */ + break; /* reached the end of the buffer */ /* "encryption" is optional */ if (BSTRNCMP(tok, "crypt") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; + if (tok == NULL) { + strange_header(file, buffer, buflen, "", tok); + goto out; + } strncpy(file->encrypt_suffix, tok, - sizeof(file->encrypt_suffix) - 1); + SIZEOF(file->encrypt_suffix) - 1); file->encrypted = BSTRNCMP(file->encrypt_suffix, "N"); if ((tok = strtok(NULL, " ")) == NULL) break; @@ -193,9 +272,12 @@ parse_file_header(buffer, file, buflen) /* "srvcompprog" is optional */ if (BSTRNCMP(tok, "server_custom_compress") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->srvcompprog, tok, sizeof(file->srvcompprog) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, + "", tok); + goto out; + } + strncpy(file->srvcompprog, tok, SIZEOF(file->srvcompprog) - 1); if ((tok = strtok(NULL, " ")) == NULL) break; } @@ -203,9 +285,12 @@ parse_file_header(buffer, file, buflen) /* "clntcompprog" is optional */ if (BSTRNCMP(tok, "client_custom_compress") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->clntcompprog, tok, sizeof(file->clntcompprog) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, + "", tok); + goto out; + } + strncpy(file->clntcompprog, tok, SIZEOF(file->clntcompprog) - 1); if ((tok = strtok(NULL, " ")) == NULL) break; } @@ -213,9 +298,12 @@ parse_file_header(buffer, file, buflen) /* "srv_encrypt" is optional */ if (BSTRNCMP(tok, "server_encrypt") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->srv_encrypt, tok, sizeof(file->srv_encrypt) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, + "", tok); + goto out; + } + strncpy(file->srv_encrypt, tok, SIZEOF(file->srv_encrypt) - 1); if ((tok = strtok(NULL, " ")) == NULL) break; } @@ -223,9 +311,12 @@ parse_file_header(buffer, file, buflen) /* "clnt_encrypt" is optional */ if (BSTRNCMP(tok, "client_encrypt") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; - strncpy(file->clnt_encrypt, tok, sizeof(file->clnt_encrypt) - 1); + if (tok == NULL) { + strange_header(file, buffer, buflen, + "", tok); + goto out; + } + strncpy(file->clnt_encrypt, tok, SIZEOF(file->clnt_encrypt) - 1); if ((tok = strtok(NULL, " ")) == NULL) break; } @@ -233,10 +324,13 @@ parse_file_header(buffer, file, buflen) /* "srv_decrypt_opt" is optional */ if (BSTRNCMP(tok, "server_decrypt_option") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; + if (tok == NULL) { + strange_header(file, buffer, buflen, + "", tok); + goto out; + } strncpy(file->srv_decrypt_opt, tok, - sizeof(file->srv_decrypt_opt) - 1); + SIZEOF(file->srv_decrypt_opt) - 1); if ((tok = strtok(NULL, " ")) == NULL) break; } @@ -244,10 +338,13 @@ parse_file_header(buffer, file, buflen) /* "clnt_decrypt_opt" is optional */ if (BSTRNCMP(tok, "client_decrypt_option") == 0) { tok = strtok(NULL, " "); - if (tok == NULL) - goto weird_header; + if (tok == NULL) { + strange_header(file, buffer, buflen, + "", tok); + goto out; + } strncpy(file->clnt_decrypt_opt, tok, - sizeof(file->clnt_decrypt_opt) - 1); + SIZEOF(file->clnt_decrypt_opt) - 1); if ((tok = strtok(NULL, " ")) == NULL) break; } @@ -257,52 +354,61 @@ parse_file_header(buffer, file, buflen) case F_TAPEEND: tok = strtok(NULL, " "); /* DATE is optional */ - if (tok == NULL || strcmp(tok, "DATE") != 0) { - amfree(buf); - amfree(line1); - return; + if (tok != NULL) { + if (strcmp(tok, "DATE") == 0) { + tok = strtok(NULL, " "); + if(tok == NULL) + file->datestamp[0] = '\0'; + else + strncpy(file->datestamp, tok, SIZEOF(file->datestamp) - 1); + } else { + strange_header(file, buffer, buflen, "", tok); + } + } else { + file->datestamp[0] = '\0'; } - strncpy(file->datestamp, tok, sizeof(file->datestamp) - 1); break; default: - goto weird_header; + strange_header(file, buffer, buflen, + "TAPESTART|DUMPFILE|CONT_DUMPFILE|SPLIT_DUMPFILE|TAPEEND", tok); + goto out; } - line = strtok(buf, "\n"); /* this is the first line */ + (void)strtok(buf, "\n"); /* this is the first line */ /* iterate through the rest of the lines */ while ((line = strtok(NULL, "\n")) != NULL) { #define SC "CONT_FILENAME=" - if (strncmp(line, SC, sizeof(SC) - 1) == 0) { - line += sizeof(SC) - 1; + if (strncmp(line, SC, SIZEOF(SC) - 1) == 0) { + line += SIZEOF(SC) - 1; strncpy(file->cont_filename, line, - sizeof(file->cont_filename) - 1); + SIZEOF(file->cont_filename) - 1); continue; } #undef SC #define SC "PARTIAL=" - if (strncmp(line, SC, sizeof(SC) - 1) == 0) { - line += sizeof(SC) - 1; + if (strncmp(line, SC, SIZEOF(SC) - 1) == 0) { + line += SIZEOF(SC) - 1; file->is_partial = !strcasecmp(line, "yes"); continue; } #undef SC #define SC "To restore, position tape at start of file and run:" - if (strncmp(line, SC, sizeof(SC) - 1) == 0) + if (strncmp(line, SC, SIZEOF(SC) - 1) == 0) continue; #undef SC #define SC "\tdd if= bs=" - if (strncmp(line, SC, sizeof(SC) - 1) == 0) { - char *cmd1=NULL, *cmd2=NULL, *cmd3=NULL; + if (strncmp(line, SC, SIZEOF(SC) - 1) == 0) { + char *cmd1, *cmd2, *cmd3=NULL; /* skip over dd command */ if ((cmd1 = strchr(line, '|')) == NULL) { strncpy(file->recover_cmd, "BUG", - sizeof(file->recover_cmd) - 1); + SIZEOF(file->recover_cmd) - 1); continue; } *cmd1++ = '\0'; @@ -323,72 +429,174 @@ parse_file_header(buffer, file, buflen) * one cmds: recover */ - if (cmd3 == NULL) { + if ( cmd3 == NULL) { if (cmd2 == NULL) { strncpy(file->recover_cmd, cmd1, - sizeof(file->recover_cmd) - 1); + SIZEOF(file->recover_cmd) - 1); } else { snprintf(file->uncompress_cmd, - sizeof(file->uncompress_cmd), "%s|", cmd1); + SIZEOF(file->uncompress_cmd), "%s|", cmd1); strncpy(file->recover_cmd, cmd2, - sizeof(file->recover_cmd) - 1); + SIZEOF(file->recover_cmd) - 1); } } else { /* cmd3 presents: decrypt | uncompress | recover */ snprintf(file->decrypt_cmd, - sizeof(file->decrypt_cmd), "%s|", cmd1); + SIZEOF(file->decrypt_cmd), "%s|", cmd1); snprintf(file->uncompress_cmd, - sizeof(file->uncompress_cmd), "%s|", cmd2); + SIZEOF(file->uncompress_cmd), "%s|", cmd2); strncpy(file->recover_cmd, cmd3, - sizeof(file->recover_cmd) - 1); + SIZEOF(file->recover_cmd) - 1); } continue; } #undef SC /* XXX complain about weird lines? */ } - amfree(buf); - amfree(line1); - return; -weird_header: - fprintf(stderr, "%s: strange amanda header: \"%.*s\"\n", get_pname(), - (int) buflen, buffer); - file->type = F_WEIRD; +out: amfree(buf); amfree(line1); } void -build_header(buffer, file, buflen) - char *buffer; - const dumpfile_t *file; - size_t buflen; +dump_dumpfile_t( + const dumpfile_t *file) +{ + const char *pname = get_pname(); + + dbprintf(("%s: Contents of *(dumpfile_t *)%p:\n", pname, file)); + dbprintf(("%s: type = %d (%s)\n", pname, + file->type, filetype2str(file->type))); + dbprintf(("%s: datestamp = '%s'\n", pname, + file->datestamp)); + dbprintf(("%s: dumplevel = %d\n", pname, file->dumplevel)); + dbprintf(("%s: compressed = %d\n", pname, file->compressed)); + dbprintf(("%s: encrypted = %d\n", pname, file->encrypted)); + dbprintf(("%s: comp_suffix = '%s'\n", pname, + file->comp_suffix)); + dbprintf(("%s: encrypt_suffix = '%s'\n", pname, + file->encrypt_suffix)); + dbprintf(("%s: name = '%s'\n", pname, file->name)); + dbprintf(("%s: disk = '%s'\n", pname, file->disk)); + dbprintf(("%s: program = '%s'\n", pname, file->program)); + dbprintf(("%s: srvcompprog = '%s'\n", pname, + file->srvcompprog)); + dbprintf(("%s: clntcompprog = '%s'\n", pname, + file->clntcompprog)); + dbprintf(("%s: srv_encrypt = '%s'\n", pname, + file->srv_encrypt)); + dbprintf(("%s: clnt_encrypt = '%s'\n", pname, + file->clnt_encrypt)); + dbprintf(("%s: recover_cmd = '%s'\n", pname, + file->recover_cmd)); + dbprintf(("%s: uncompress_cmd = '%s'\n", pname, + file->uncompress_cmd)); + dbprintf(("%s: encrypt_cmd = '%s'\n", pname, + file->encrypt_cmd)); + dbprintf(("%s: decrypt_cmd = '%s'\n", pname, + file->decrypt_cmd)); + dbprintf(("%s: srv_decrypt_opt = '%s'\n", pname, + file->srv_decrypt_opt)); + dbprintf(("%s: clnt_decrypt_opt = '%s'\n", pname, + file->clnt_decrypt_opt)); + dbprintf(("%s: cont_filename = '%s'\n", pname, + file->cont_filename)); + dbprintf(("%s: is_partial = %d\n", pname, file->is_partial)); + dbprintf(("%s: partnum = %d\n", pname, file->partnum)); + dbprintf(("%s: totalparts = %d\n", pname, file->totalparts)); + dbprintf(("%s: blocksize = " SIZE_T_FMT "\n", pname, + (SIZE_T_FMT_TYPE)file->blocksize)); +} + +static void +validate_name( + const char *name) +{ + if (strlen(name) == 0) { + error("Invalid name '%s'\n", name); + /*NOTREACHED*/ + } +} + +static void +validate_datestamp( + const char *datestamp) +{ + if (strcmp(datestamp, "X") == 0) { + return; + } + + if ((strlen(datestamp) == 8) && match("^[0-9]{8}$", datestamp)) { + return; + } + if ((strlen(datestamp) == 14) && match("^[0-9]{14}$", datestamp)) { + return; + } + error("Invalid datestamp '%s'\n", datestamp); + /*NOTREACHED*/ +} + +static void +validate_parts( + const int partnum, + const int totalparts) +{ + if (partnum < 1) { + error("Invalid partnum (%d)\n", partnum); + /*NOTREACHED*/ + } + + if (partnum > totalparts && totalparts >= 0) { + error("Invalid partnum (%d) > totalparts (%d)\n", + partnum, totalparts); + /*NOTREACHED*/ + } +} + +void +build_header( + char * buffer, + const dumpfile_t * file, + size_t buflen) { int n; + char *qname; char split_data[128] = ""; + dbprintf(("%s: Building type %d (%s) header of size " SIZE_T_FMT " using:\n", + get_pname(), file->type, filetype2str(file->type), + (SIZE_T_FMT_TYPE)buflen)); + dump_dumpfile_t(file); + memset(buffer,'\0',buflen); switch (file->type) { case F_TAPESTART: + validate_name(file->name); + validate_datestamp(file->datestamp); snprintf(buffer, buflen, "AMANDA: TAPESTART DATE %s TAPE %s\n014\n", file->datestamp, file->name); break; case F_SPLIT_DUMPFILE: - snprintf(split_data, sizeof(split_data), + validate_parts(file->partnum, file->totalparts); + snprintf(split_data, SIZEOF(split_data), " part %d/%d ", file->partnum, file->totalparts); - /* FALLTHROUGH */ + /*FALLTHROUGH*/ case F_CONT_DUMPFILE: case F_DUMPFILE : + validate_name(file->name); + validate_datestamp(file->datestamp); + qname = quote_string(file->disk); n = snprintf(buffer, buflen, "AMANDA: %s %s %s %s %s lev %d comp %s program %s", filetype2str(file->type), - file->datestamp, file->name, file->disk, + file->datestamp, file->name, qname, split_data, file->dumplevel, file->comp_suffix, file->program); + amfree(qname); if ( n ) { buffer += n; buflen -= n; @@ -461,22 +669,26 @@ build_header(buffer, file, buflen) buffer += n; buflen -= n; - /* \014 == ^L */ + /* \014 == ^L == form feed */ n = snprintf(buffer, buflen, - "\tdd if= bs=%ldk skip=1 |%s %s %s\n\014\n", - file->blocksize / 1024, file->decrypt_cmd, file->uncompress_cmd, file->recover_cmd); - buffer += n; - buflen -= n; + "\tdd if= bs=" SIZE_T_FMT "k skip=1 | %s %s %s\n\014\n", + (SIZE_T_FMT_TYPE)file->blocksize / 1024, file->decrypt_cmd, + file->uncompress_cmd, file->recover_cmd); break; case F_TAPEEND: + validate_datestamp(file->datestamp); snprintf(buffer, buflen, "AMANDA: TAPEEND DATE %s\n\014\n", file->datestamp); break; case F_UNKNOWN: + case F_EMPTY: case F_WEIRD: - break; + default: + error("Invalid header type: %d (%s)", + file->type, filetype2str(file->type)); + /*NOTREACHED*/ } } @@ -484,27 +696,37 @@ build_header(buffer, file, buflen) * Prints the contents of the file structure. */ void -print_header(outf, file) - FILE *outf; - const dumpfile_t *file; +print_header( + FILE * outf, + const dumpfile_t * file) { + char *qdisk; char number[NUM_STR_SIZE*2]; + switch(file->type) { + case F_EMPTY: + fprintf(outf, "EMPTY file\n"); + break; + case F_UNKNOWN: fprintf(outf, "UNKNOWN file\n"); break; + case F_WEIRD: fprintf(outf, "WEIRD file\n"); break; + case F_TAPESTART: fprintf(outf, "start of tape: date %s label %s\n", file->datestamp, file->name); break; + case F_DUMPFILE: case F_CONT_DUMPFILE: + qdisk = quote_string(file->disk); fprintf(outf, "%s: date %s host %s disk %s lev %d comp %s", filetype2str(file->type), file->datestamp, file->name, - file->disk, file->dumplevel, file->comp_suffix); + qdisk, file->dumplevel, file->comp_suffix); if (*file->program) fprintf(outf, " program %s",file->program); if (strcmp(file->encrypt_suffix, "enc") == 0) @@ -522,14 +744,17 @@ print_header(outf, file) if (*file->clnt_decrypt_opt) fprintf(outf, " client_decrypt_option %s", file->clnt_decrypt_opt); fprintf(outf, "\n"); + amfree(qdisk); break; + case F_SPLIT_DUMPFILE: if(file->totalparts > 0){ - snprintf(number, sizeof(number), "%d", file->totalparts); + snprintf(number, SIZEOF(number), "%d", file->totalparts); } - else snprintf(number, sizeof(number), "UNKNOWN"); + else snprintf(number, SIZEOF(number), "UNKNOWN"); + qdisk = quote_string(file->disk); fprintf(outf, "split dumpfile: date %s host %s disk %s part %d/%s lev %d comp %s", - file->datestamp, file->name, file->disk, file->partnum, + file->datestamp, file->name, qdisk, file->partnum, number, file->dumplevel, file->comp_suffix); if (*file->program) fprintf(outf, " program %s",file->program); @@ -548,7 +773,9 @@ print_header(outf, file) if (*file->clnt_decrypt_opt) fprintf(outf, " client_decrypt_option %s", file->clnt_decrypt_opt); fprintf(outf, "\n"); + amfree(qdisk); break; + case F_TAPEEND: fprintf(outf, "end of tape: date %s\n", file->datestamp); break; @@ -556,8 +783,8 @@ print_header(outf, file) } int -known_compress_type(file) - const dumpfile_t *file; +known_compress_type( + const dumpfile_t * file) { if(strcmp(file->comp_suffix, ".Z") == 0) return 1; @@ -582,27 +809,27 @@ static const struct { { F_CONT_DUMPFILE, "CONT_FILE" }, { F_SPLIT_DUMPFILE, "SPLIT_FILE" } }; -#define NFILETYPES (sizeof(filetypetab) / sizeof(filetypetab[0])) +#define NFILETYPES (size_t)(sizeof(filetypetab) / sizeof(filetypetab[0])) static const char * -filetype2str(type) - filetype_t type; +filetype2str( + filetype_t type) { int i; - for (i = 0; i < NFILETYPES; i++) + for (i = 0; i < (int)NFILETYPES; i++) if (filetypetab[i].type == type) return (filetypetab[i].str); return ("UNKNOWN"); } static filetype_t -str2filetype(str) - const char *str; +str2filetype( + const char *str) { int i; - for (i = 0; i < NFILETYPES; i++) + for (i = 0; i < (int)NFILETYPES; i++) if (strcmp(filetypetab[i].str, str) == 0) return (filetypetab[i].type); return (F_UNKNOWN); diff --git a/common-src/fileheader.h b/common-src/fileheader.h index 8398aea..c6213fe 100644 --- a/common-src/fileheader.h +++ b/common-src/fileheader.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: fileheader.h,v 1.15 2005/12/09 03:22:52 paddy_s Exp $ + * $Id: fileheader.h,v 1.16 2006/05/25 01:47:12 johnfranks Exp $ * */ @@ -39,7 +39,7 @@ typedef char string_t[STRMAX]; typedef enum { F_UNKNOWN, F_WEIRD, F_TAPESTART, F_TAPEEND, - F_DUMPFILE, F_CONT_DUMPFILE, F_SPLIT_DUMPFILE + F_DUMPFILE, F_CONT_DUMPFILE, F_SPLIT_DUMPFILE, F_EMPTY } filetype_t; typedef struct file_s { @@ -67,17 +67,16 @@ typedef struct file_s { int is_partial; int partnum; int totalparts; /* -1 == UNKNOWN */ - long blocksize; + size_t blocksize; } dumpfile_t; /* local functions */ -void fh_init P((dumpfile_t *file)); -void parse_file_header P((const char *buffer, dumpfile_t *file, size_t buflen)); -void build_header P((char *buffer, - const dumpfile_t *file, - size_t buflen)); -void print_header P((FILE *outf, const dumpfile_t *file)); -int known_compress_type P((const dumpfile_t *file)); +void fh_init(dumpfile_t *file); +void parse_file_header(const char *buffer, dumpfile_t *file, size_t buflen); +void build_header(char *buffer, const dumpfile_t *file, size_t buflen); +void print_header(FILE *outf, const dumpfile_t *file); +int known_compress_type(const dumpfile_t *file); +void dump_dumpfile_t(const dumpfile_t *file); #endif /* !FILEHEADER_H */ diff --git a/common-src/genversion.c b/common-src/genversion.c index 074296b..21243b9 100644 --- a/common-src/genversion.c +++ b/common-src/genversion.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: genversion.c,v 1.31 2003/10/07 17:09:46 martinea Exp $ + * $Id: genversion.c,v 1.36 2006/07/13 03:22:20 paddy_s Exp $ * * dump the current Amanda version info */ @@ -35,19 +35,22 @@ #define LMARGIN 6 #define RMARGIN 70 -static int linelen; +static size_t linelen; #define startline(title) printf(" \"%-*s", LMARGIN, title); linelen = 0 #define endline() printf("\\n\",\n") -static void prstr P((const char *)); -static void prvar P((const char *, const char *)); -int main P((void)); +static void prstr(const char *); +static void prvar(const char *, const char *); +static void prundefvar(const char *var); +static void prnum(const char *var, long val); + +int main(int, char **); /* Print a string */ static void -prstr(string) - const char *string; +prstr( + const char *string) { size_t len = strlen(string) + 1; @@ -68,82 +71,108 @@ static size_t buf_len = 0; /* Print a text variable */ static void -prvar(var, val) - const char *var, *val; +prvar( + const char *var, + const char *val) { size_t new_len; new_len = strlen(var) - + sizeof("=\\\"") + + SIZEOF("=\\\"") + strlen(val) - + sizeof("\\\"") + + SIZEOF("\\\"") + 1; if(new_len > buf_len) { free(buf); buf_len = new_len; - buf = malloc(new_len); /* let it die if malloc() fails */ + buf = malloc(new_len); + if (!buf) { + fprintf(stderr, "genversion: Not enough memory"); + abort(); + /*NOTREACHED*/ + } } - sprintf(buf, "%s=\\\"%s\\\"", var, val); /* safe */ + snprintf(buf, buf_len, "%s=\\\"%s\\\"", var, val); /* safe */ prstr(buf); } /* Print a undef variable */ static void -prundefvar(var) - const char *var; +prundefvar( + const char *var) { size_t new_len; new_len = strlen(var) - + sizeof("=UNDEF") + + SIZEOF("=UNDEF") + 1; if(new_len > buf_len) { free(buf); buf_len = new_len; buf = malloc(new_len); /* let it die if malloc() fails */ + if (!buf) { + fprintf(stderr, "genversion: Not enough memory"); + abort(); + /*NOTREACHED*/ + } } - sprintf(buf, "%s=UNDEF", var); /* safe */ + snprintf(buf, buf_len, "%s=UNDEF", var); /* safe */ prstr(buf); } /* Print a numeric variable */ static void -prnum(var, val) - const char *var; - long val; +prnum( + const char *var, + long val) { static char number[NUM_STR_SIZE]; size_t new_len; - snprintf(number, sizeof(number), "%ld", val); + snprintf(number, SIZEOF(number), "%ld", val); new_len = strlen(var) - + sizeof("=") + + SIZEOF("=") + strlen(number) + 1; if(new_len > buf_len) { free(buf); buf_len = new_len; buf = malloc(new_len); /* let it die if malloc() fails */ + if (!buf) { + fprintf(stderr, "genversion: Not enough memory"); + abort(); + /*NOTREACHED*/ + } } - sprintf(buf, "%s=%s", var, number); /* safe */ + snprintf(buf, buf_len, "%s=%s", var, number); /* safe */ prstr(buf); } int -main() +main( + int argc, + char ** argv) { const char *v; char *verstr; size_t v_len; + (void)argc; /* Quiet unused parameter warning */ + (void)argv; /* Quiet unused parameter warning */ + printf("/* version.c - generated by genversion.c - DO NOT EDIT! */\n"); printf("const char * const version_info[] = {\n"); startline("build:"); v = version(); - v_len = sizeof("Amanda-") + strlen(v) + 1; + v_len = SIZEOF("Amanda-") + strlen(v) + 1; verstr = malloc(v_len); - sprintf(verstr, "Amanda-%s", v); /* safe */ + if (!verstr) { + fprintf(stderr, "genversion: Not enough memory"); + abort(); + /*NOTREACHED*/ + } + snprintf(verstr, v_len, "Amanda-%s", v); /* safe */ prvar("VERSION", verstr); free(verstr); @@ -275,7 +304,10 @@ main() prvar("DEFAULT_SERVER", DEFAULT_SERVER); prvar("DEFAULT_CONFIG", DEFAULT_CONFIG); prvar("DEFAULT_TAPE_SERVER", DEFAULT_TAPE_SERVER); + +#ifdef DEFAULT_TAPE_DEVICE prvar("DEFAULT_TAPE_DEVICE", DEFAULT_TAPE_DEVICE); +#endif #ifdef AIX_BACKUP prstr("AIX_BACKUP"); @@ -411,5 +443,5 @@ main() printf(" 0\n};\n"); - exit(0); + return (0); /* exit */ } diff --git a/common-src/getcwd.c b/common-src/getcwd.c index a7601c6..74baeb9 100644 --- a/common-src/getcwd.c +++ b/common-src/getcwd.c @@ -25,15 +25,13 @@ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -/* $Id: getcwd.c,v 1.4 2002/02/11 01:32:10 jrjackson Exp $ */ +/* $Id: getcwd.c,v 1.5 2006/05/25 01:47:12 johnfranks Exp $ */ #ifndef lint -static char rcsid[] = "$Header: /cvsroot/amanda/amanda/common-src/getcwd.c,v 1.4 2002/02/11 01:32:10 jrjackson Exp $ SPRITE (Berkeley)"; +static char rcsid[] = "$Header: /cvsroot/amanda/amanda/common-src/getcwd.c,v 1.5 2006/05/25 01:47:12 johnfranks Exp $ SPRITE (Berkeley)"; #endif /* not lint */ -#include -#include -#include +#include "amanda.h" extern char *getwd(); extern int errno; diff --git a/common-src/krb4-security.c b/common-src/krb4-security.c index db6e702..6a3dad3 100644 --- a/common-src/krb4-security.c +++ b/common-src/krb4-security.c @@ -25,7 +25,7 @@ */ /* - * $Id: krb4-security.c,v 1.9.2.1 2006/04/11 11:11:16 martinea Exp $ + * $Id: krb4-security.c,v 1.18 2006/07/13 03:22:20 paddy_s Exp $ * * krb4-security.c - helper functions for kerberos v4 security. */ @@ -42,6 +42,7 @@ #include "packet.h" #include "queue.h" #include "security.h" +#include "security-util.h" #include "protocol.h" #include "stream.h" #include "version.h" @@ -60,8 +61,8 @@ #endif /* HAVE_ON_EXIT */ #endif /* ! HAVE_ATEXIT */ -int krb_set_lifetime P((int)); -int kuserok P((AUTH_DAT *, char *)); +int krb_set_lifetime(int); +int kuserok(AUTH_DAT *, char *); /* * This is the private handle data @@ -81,7 +82,7 @@ struct krb4_handle { * The rest is used for the async recvpkt/recvpkt_cancel * interface. */ - void (*fn) P((void *, pkt_t *, security_status_t)); + void (*fn)(void *, pkt_t *, security_status_t); /* func to call when packet recvd */ void *arg; /* argument to pass function */ event_handle_t *ev_timeout; /* timeout handle for recv */ @@ -99,7 +100,8 @@ struct krb4_stream { int socket; /* fd for server-side accepts */ event_handle_t *ev_read; /* read event handle */ char databuf[MAX_TAPE_BLOCK_BYTES]; /* read buffer */ - void (*fn) P((void *, void *, int)); /* read event fn */ + int len; /* */ + void (*fn)(void *, void *, ssize_t);/* read event fn */ void *arg; /* arg for previous */ }; @@ -111,26 +113,25 @@ struct krb4_stream { /* * Interface functions */ -static void krb4_connect P((const char *, - char *(*)(char *, void *), - void (*)(void *, security_handle_t *, security_status_t), void *)); -static void krb4_accept P((int, int, void (*)(security_handle_t *, pkt_t *))); -static void krb4_close P((void *)); -static int krb4_sendpkt P((void *, pkt_t *)); -static void krb4_recvpkt P((void *, - void (*)(void *, pkt_t *, security_status_t), void *, int)); -static void krb4_recvpkt_cancel P((void *)); - -static void *krb4_stream_server P((void *)); -static int krb4_stream_accept P((void *)); -static void *krb4_stream_client P((void *, int)); -static void krb4_stream_close P((void *)); -static int krb4_stream_auth P((void *)); -static int krb4_stream_id P((void *)); -static int krb4_stream_write P((void *, const void *, size_t)); -static void krb4_stream_read P((void *, void (*)(void *, void *, int), - void *)); -static void krb4_stream_read_cancel P((void *)); +static void krb4_connect(const char *, char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), + void *, void *); +static void krb4_accept(const struct security_driver *, int, int, void (*)(security_handle_t *, pkt_t *)); +static void krb4_close(void *); +static int krb4_sendpkt(void *, pkt_t *); +static void krb4_recvpkt(void *, void (*)(void *, pkt_t *, security_status_t), + void *, int); +static void krb4_recvpkt_cancel(void *); +static void * krb4_stream_server(void *); +static int krb4_stream_accept(void *); +static void * krb4_stream_client(void *, int); +static void krb4_stream_close(void *); +static int krb4_stream_auth(void *); +static int krb4_stream_id(void *); +static int krb4_stream_write(void *, const void *, size_t); +static void krb4_stream_read(void *, void (*)(void *, void *, int), void *); +static int krb4_stream_read_sync(void *, void **); +static void krb4_stream_read_cancel(void *); /* @@ -152,7 +153,9 @@ const security_driver_t krb4_security_driver = { krb4_stream_id, krb4_stream_write, krb4_stream_read, + krb4_stream_read_sync, krb4_stream_read_cancel, + sec_close_connection_none, }; /* @@ -196,7 +199,7 @@ static struct { #define handleq_first() TAILQ_FIRST(&handleq.tailq) #define handleq_next(kh) TAILQ_NEXT(kh, tq) - + /* * This is the event manager's handle for our netfd @@ -208,7 +211,7 @@ static event_handle_t *ev_netfd; * created. If NULL, no new handles are created. * It is passed the new handle and the received pkt */ -static void (*accept_fn) P((security_handle_t *, pkt_t *)); +static void (*accept_fn)(security_handle_t *, pkt_t *); /* @@ -219,41 +222,42 @@ static void (*accept_fn) P((security_handle_t *, pkt_t *)); */ union mutual { char pad[8]; - unsigned long cksum; + long cksum; }; /* * Private functions */ -static unsigned long krb4_cksum P((const char *)); -static void krb4_getinst P((const char *, char *, size_t)); -static void host2key P((const char *, const char *, des_cblock *)); -static void init P((void)); -static void inithandle P((struct krb4_handle *, struct hostent *, int, - const char *)); -static void get_tgt P((void)); -static void killtickets P((void)); -static void recvpkt_callback P((void *)); -static void recvpkt_timeout P((void *)); -static int recv_security_ok P((struct krb4_handle *, pkt_t *)); -static void stream_read_callback P((void *)); -static int net_write P((int, const void *, size_t)); -static int net_read P((int, void *, size_t, int)); - -static int add_ticket P((struct krb4_handle *, const pkt_t *, dgram_t *)); -static void add_mutual_auth P((struct krb4_handle *, dgram_t *)); -static int check_ticket P((struct krb4_handle *, const pkt_t *, - const char *, unsigned long)); -static int check_mutual_auth P((struct krb4_handle *, const char *)); - -static const char *pkthdr2str P((const struct krb4_handle *, const pkt_t *)); -static int str2pkthdr P((const char *, pkt_t *, char *, size_t, int *)); - -static const char *bin2astr P((const unsigned char *, int)); -static void astr2bin P((const char *, unsigned char *, int *)); - -static void encrypt_data P((void *, int, des_cblock *)); -static void decrypt_data P((void *, int, des_cblock *)); +static unsigned long krb4_cksum(const char *); +static void krb4_getinst(const char *, char *, size_t); +static void host2key(const char *, const char *, des_cblock *); +static void init(void); +static void inithandle(struct krb4_handle *, struct hostent *, int, + const char *); +static void get_tgt(void); +static void killtickets(void); +static void recvpkt_callback(void *); +static void recvpkt_timeout(void *); +static int recv_security_ok(struct krb4_handle *, pkt_t *); +static void stream_read_callback(void *); +static void stream_read_sync_callback(void *); +static int net_write(int, const void *, size_t); +static int net_read(int, void *, size_t, int); + +static int add_ticket(struct krb4_handle *, const pkt_t *, dgram_t *); +static void add_mutual_auth(struct krb4_handle *, dgram_t *); +static int check_ticket(struct krb4_handle *, const pkt_t *, + const char *, unsigned long); +static int check_mutual_auth(struct krb4_handle *, const char *); + +static const char *pkthdr2str(const struct krb4_handle *, const pkt_t *); +static int str2pkthdr(const char *, pkt_t *, char *, size_t, int *); + +static const char *bin2astr(const unsigned char *, int); +static void astr2bin(const unsigned char *, unsigned char *, int *); + +static void encrypt_data(void *, size_t, des_cblock *); +static void decrypt_data(void *, size_t, des_cblock *); #define HOSTNAME_INSTANCE inst @@ -271,7 +275,7 @@ killtickets(void) * Setup some things about krb4. This should only be called once. */ static void -init() +init(void) { char tktfile[256]; int port; @@ -281,8 +285,8 @@ init() return; beenhere = 1; - gethostname(hostname, sizeof(hostname) - 1); - hostname[sizeof(hostname) - 1] = '\0'; + gethostname(hostname, SIZEOF(hostname) - 1); + hostname[SIZEOF(hostname) - 1] = '\0'; if (atexit(killtickets) < 0) error("could not setup krb4 exit handler: %s", strerror(errno)); @@ -293,7 +297,7 @@ init() * This file also needs to be removed so that no extra tickets are * hanging around. */ - snprintf(tktfile, sizeof(tktfile), "/tmp/tkt%ld-%ld.amanda", + snprintf(tktfile, SIZEOF(tktfile), "/tmp/tkt%ld-%ld.amanda", (long)getuid(), (long)getpid()); ticketfilename = stralloc(tktfile); unlink(ticketfilename); @@ -315,13 +319,13 @@ init() * Get a ticket granting ticket and stuff it in the cache */ static void -get_tgt() +get_tgt(void) { char realm[REALM_SZ]; int rc; - strncpy(realm, krb_realmofhost(hostname), sizeof(realm) - 1); - realm[sizeof(realm) - 1] = '\0'; + strncpy(realm, krb_realmofhost(hostname), SIZEOF(realm) - 1); + realm[SIZEOF(realm) - 1] = '\0'; rc = krb_get_svc_in_tkt(SERVER_HOST_PRINCIPLE, SERVER_HOST_INSTANCE, realm, "krbtgt", realm, TICKET_LIFETIME, SERVER_HOST_KEY_FILE); @@ -341,11 +345,12 @@ get_tgt() * up a network "connection". */ static void -krb4_connect(hostname, conf_fn, fn, arg) - const char *hostname; - char *(*conf_fn) P((char *, void *)); - void (*fn) P((void *, security_handle_t *, security_status_t)); - void *arg; +krb4_connect( + const char *hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) { struct krb4_handle *kh; char handle[32]; @@ -360,7 +365,7 @@ krb4_connect(hostname, conf_fn, fn, arg) */ init(); - kh = alloc(sizeof(*kh)); + kh = alloc(SIZEOF(*kh)); security_handleinit(&kh->sech, &krb4_security_driver); if ((he = gethostbyname(hostname)) == NULL) { @@ -370,11 +375,11 @@ krb4_connect(hostname, conf_fn, fn, arg) return; } if ((se = getservbyname(KAMANDA_SERVICE_NAME, "udp")) == NULL) - port = htons(KAMANDA_SERVICE_DEFAULT); + port = (int)htons(KAMANDA_SERVICE_DEFAULT); else port = se->s_port; - snprintf(handle, sizeof(handle), "%ld", (long)time(NULL)); - inithandle(kh, he, port, handle); + snprintf(handle, SIZEOF(handle), "%ld", (long)time(NULL)); + inithandle(kh, he, (int)port, handle); (*fn)(arg, &kh->sech, S_OK); } @@ -382,9 +387,11 @@ krb4_connect(hostname, conf_fn, fn, arg) * Setup to handle new incoming connections */ static void -krb4_accept(in, out, fn) - int in, out; - void (*fn) P((security_handle_t *, pkt_t *)); +krb4_accept( + const struct security_driver *driver, + int in, + int out, + void (*fn)(security_handle_t *, pkt_t *)) { /* @@ -405,50 +412,50 @@ krb4_accept(in, out, fn) accept_fn = fn; if (ev_netfd == NULL) - ev_netfd = event_register(netfd.socket, EV_READFD, - recvpkt_callback, NULL); + ev_netfd = event_register((event_id_t)netfd.socket, EV_READFD, + recvpkt_callback, NULL); } /* * Given a hostname and a port, setup a krb4_handle */ static void -inithandle(kh, he, port, handle) - struct krb4_handle *kh; - struct hostent *he; - int port; - const char *handle; +inithandle( + struct krb4_handle *kh, + struct hostent * he, + int port, + const char * handle) { /* * Get the instance and realm for this host * (krb_realmofhost always returns something) */ - krb4_getinst(he->h_name, kh->inst, sizeof(kh->inst)); - strncpy(kh->realm, krb_realmofhost(he->h_name), sizeof(kh->realm) - 1); - kh->realm[sizeof(kh->realm) - 1] = '\0'; + krb4_getinst(he->h_name, kh->inst, SIZEOF(kh->inst)); + strncpy(kh->realm, krb_realmofhost(he->h_name), SIZEOF(kh->realm) - 1); + kh->realm[SIZEOF(kh->realm) - 1] = '\0'; /* * Save a copy of the hostname */ - strncpy(kh->hostname, he->h_name, sizeof(kh->hostname) - 1); - kh->hostname[sizeof(kh->hostname) - 1] = '\0'; + strncpy(kh->hostname, he->h_name, SIZEOF(kh->hostname) - 1); + kh->hostname[SIZEOF(kh->hostname) - 1] = '\0'; /* * We have no checksum or session key at this point */ kh->cksum = 0; - memset(kh->session_key, 0, sizeof(kh->session_key)); + memset(kh->session_key, 0, SIZEOF(kh->session_key)); /* * Setup our peer info. We don't do anything with the sequence yet, * so just leave it at 0. */ - kh->peer.sin_family = AF_INET; - kh->peer.sin_port = port; + kh->peer.sin_family = (sa_family_t)AF_INET; + kh->peer.sin_port = (in_port_t)port; kh->peer.sin_addr = *(struct in_addr *)he->h_addr; - strncpy(kh->proto_handle, handle, sizeof(kh->proto_handle) - 1); - kh->proto_handle[sizeof(kh->proto_handle) - 1] = '\0'; + strncpy(kh->proto_handle, handle, SIZEOF(kh->proto_handle) - 1); + kh->proto_handle[SIZEOF(kh->proto_handle) - 1] = '\0'; kh->sequence = 0; kh->fn = NULL; kh->arg = NULL; @@ -459,8 +466,8 @@ inithandle(kh, he, port, handle) * frees a handle allocated by the above */ static void -krb4_close(inst) - void *inst; +krb4_close( + void * inst) { krb4_recvpkt_cancel(inst); @@ -470,10 +477,10 @@ krb4_close(inst) /* * Transmit a packet. Add security information first. */ -static int -krb4_sendpkt(cookie, pkt) - void *cookie; - pkt_t *pkt; +static ssize_t +krb4_sendpkt( + void * cookie, + pkt_t * pkt) { struct krb4_handle *kh = cookie; @@ -539,10 +546,11 @@ krb4_sendpkt(cookie, pkt) * it has been read. */ static void -krb4_recvpkt(cookie, fn, arg, timeout) - void *cookie, *arg; - void (*fn) P((void *, pkt_t *, security_status_t)); - int timeout; +krb4_recvpkt( + void * cookie, + void (*fn)(void *, pkt_t *, security_status_t), + void * arg, + int timeout) { struct krb4_handle *kh = cookie; @@ -557,8 +565,8 @@ krb4_recvpkt(cookie, fn, arg, timeout) */ if (ev_netfd == NULL) { assert(handleq.qlength == 0); - ev_netfd = event_register(netfd.socket, EV_READFD, - recvpkt_callback, NULL); + ev_netfd = event_register((event_id_t)netfd.socket, EV_READFD, + recvpkt_callback, NULL); } /* @@ -572,7 +580,8 @@ krb4_recvpkt(cookie, fn, arg, timeout) if (timeout < 0) kh->ev_timeout = NULL; else - kh->ev_timeout = event_register(timeout, EV_TIME, recvpkt_timeout, kh); + kh->ev_timeout = event_register((event_id_t)timeout, EV_TIME, + recvpkt_timeout, kh); kh->fn = fn; kh->arg = arg; } @@ -583,8 +592,8 @@ krb4_recvpkt(cookie, fn, arg, timeout) * for our network fd. */ static void -krb4_recvpkt_cancel(cookie) - void *cookie; +krb4_recvpkt_cancel( + void * cookie) { struct krb4_handle *kh = cookie; @@ -611,17 +620,17 @@ krb4_recvpkt_cancel(cookie) * socket for receiving a connection. */ static void * -krb4_stream_server(h) - void *h; +krb4_stream_server( + void * h) { struct krb4_handle *kh = h; struct krb4_stream *ks; assert(kh != NULL); - ks = alloc(sizeof(*ks)); + ks = alloc(SIZEOF(*ks)); security_streaminit(&ks->secstr, &krb4_security_driver); - ks->socket = stream_server(&ks->port, STREAM_BUFSIZE, STREAM_BUFSIZE); + ks->socket = stream_server(&ks->port, STREAM_BUFSIZE, STREAM_BUFSIZE, 1); if (ks->socket < 0) { security_seterror(&kh->sech, "can't create server stream: %s", strerror(errno)); @@ -638,8 +647,8 @@ krb4_stream_server(h) * Accept an incoming connection on a stream_server socket */ static int -krb4_stream_accept(s) - void *s; +krb4_stream_accept( + void * s) { struct krb4_stream *ks = s; struct krb4_handle *kh; @@ -650,7 +659,7 @@ krb4_stream_accept(s) assert(ks->socket >= 0); assert(ks->fd == -1); - ks->fd = stream_accept(ks->socket, 30, -1, -1); + ks->fd = stream_accept(ks->socket, 30, STREAM_BUFSIZE, STREAM_BUFSIZE); if (ks->fd < 0) { security_stream_seterror(&ks->secstr, "can't accept new stream connection: %s", strerror(errno)); @@ -663,22 +672,16 @@ krb4_stream_accept(s) * Return a connected stream. */ static void * -krb4_stream_client(h, id) - void *h; - int id; +krb4_stream_client( + void * h, + int id) { struct krb4_handle *kh = h; struct krb4_stream *ks; assert(kh != NULL); - if (id < 0) { - security_seterror(&kh->sech, - "%d: invalid security stream id", id); - return (NULL); - } - - ks = alloc(sizeof(*ks)); + ks = alloc(SIZEOF(*ks)); security_streaminit(&ks->secstr, &krb4_security_driver); ks->fd = stream_client(kh->hostname, id, STREAM_BUFSIZE, STREAM_BUFSIZE, &ks->port, 0); @@ -700,8 +703,8 @@ krb4_stream_client(h, id) * Close and unallocate resources for a stream. */ static void -krb4_stream_close(s) - void *s; +krb4_stream_close( + void * s) { struct krb4_stream *ks = s; @@ -723,8 +726,8 @@ krb4_stream_close(s) * into byte arrays and send those. */ static int -krb4_stream_auth(s) - void *s; +krb4_stream_auth( + void * s) { struct krb4_stream *ks = s; struct krb4_handle *kh; @@ -742,17 +745,17 @@ krb4_stream_auth(s) assert(fd >= 0); /* make sure our timeval is what we're expecting, see above */ - assert(sizeof(struct timeval) == 8); + assert(SIZEOF(struct timeval) == 8); /* * Get the current time, put it in network byte order, encrypt it * and present it to the other side. */ gettimeofday(&local, &tz); - enc.tv_sec = htonl(local.tv_sec); - enc.tv_usec = htonl(local.tv_usec); - encrypt_data(&enc, sizeof(enc), &kh->session_key); - if (net_write(fd, &enc, sizeof(enc)) < 0) { + enc.tv_sec = (long)htonl((uint32_t)local.tv_sec); + enc.tv_usec = (long)htonl((uint32_t)local.tv_usec); + encrypt_data(&enc, SIZEOF(enc), &kh->session_key); + if (net_write(fd, &enc, SIZEOF(enc)) < 0) { security_stream_seterror(&ks->secstr, "krb4 stream handshake write error: %s", strerror(errno)); return (-1); @@ -763,18 +766,18 @@ krb4_stream_auth(s) * and useconds by one. Reencrypt, and present to the other side. * Timeout in 10 seconds. */ - if (net_read(fd, &enc, sizeof(enc), 60) < 0) { + if (net_read(fd, &enc, SIZEOF(enc), 60) < 0) { security_stream_seterror(&ks->secstr, "krb4 stream handshake read error: %s", strerror(errno)); return (-1); } - decrypt_data(&enc, sizeof(enc), &kh->session_key); + decrypt_data(&enc, SIZEOF(enc), &kh->session_key); /* XXX do timestamp checking here */ - enc.tv_sec = htonl(ntohl(enc.tv_sec) + 1); - enc.tv_usec = htonl(ntohl(enc.tv_usec) + 1); - encrypt_data(&enc, sizeof(enc), &kh->session_key); + enc.tv_sec = (long)htonl(ntohl((uint32_t)enc.tv_sec) + 1); + enc.tv_usec =(long)htonl(ntohl((uint32_t)enc.tv_usec) + 1); + encrypt_data(&enc, SIZEOF(enc), &kh->session_key); - if (net_write(fd, &enc, sizeof(enc)) < 0) { + if (net_write(fd, &enc, SIZEOF(enc)) < 0) { security_stream_seterror(&ks->secstr, "krb4 stream handshake write error: %s", strerror(errno)); return (-1); @@ -785,20 +788,21 @@ krb4_stream_auth(s) * If they incremented it properly, then succeed. * Timeout in 10 seconds. */ - if (net_read(fd, &enc, sizeof(enc), 60) < 0) { + if (net_read(fd, &enc, SIZEOF(enc), 60) < 0) { security_stream_seterror(&ks->secstr, "krb4 stream handshake read error: %s", strerror(errno)); return (-1); } - decrypt_data(&enc, sizeof(enc), &kh->session_key); - if (ntohl(enc.tv_sec) == local.tv_sec + 1 && - ntohl(enc.tv_usec) == local.tv_usec + 1) + decrypt_data(&enc, SIZEOF(enc), &kh->session_key); + if ((ntohl((uint32_t)enc.tv_sec) == (uint32_t)(local.tv_sec + 1)) && + (ntohl((uint32_t)enc.tv_usec) == (uint32_t)(local.tv_usec + 1))) return (0); security_stream_seterror(&ks->secstr, "krb4 handshake failed: sent %ld,%ld - recv %ld,%ld", (long)(local.tv_sec + 1), (long)(local.tv_usec + 1), - (long)ntohl(enc.tv_sec), (long)ntohl(enc.tv_usec)); + (long)ntohl((uint32_t)enc.tv_sec), + (long)ntohl((uint32_t)enc.tv_usec)); return (-1); } @@ -807,8 +811,8 @@ krb4_stream_auth(s) * port. */ static int -krb4_stream_id(s) - void *s; +krb4_stream_id( + void * s) { struct krb4_stream *ks = s; @@ -821,10 +825,10 @@ krb4_stream_id(s) * Write a chunk of data to a stream. Blocks until completion. */ static int -krb4_stream_write(s, buf, size) - void *s; - const void *buf; - size_t size; +krb4_stream_write( + void * s, + const void *buf, + size_t size) { struct krb4_stream *ks = s; struct krb4_handle *kh = ks->krb4_handle; @@ -845,9 +849,10 @@ krb4_stream_write(s, buf, size) * function and arg when completed. */ static void -krb4_stream_read(s, fn, arg) - void *s, *arg; - void (*fn) P((void *, void *, int)); +krb4_stream_read( + void * s, + void (*fn)(void *, void *, ssize_t), + void * arg) { struct krb4_stream *ks = s; @@ -859,18 +864,67 @@ krb4_stream_read(s, fn, arg) if (ks->ev_read != NULL) event_release(ks->ev_read); - ks->ev_read = event_register(ks->fd, EV_READFD, stream_read_callback, ks); + ks->ev_read = event_register((event_id_t)ks->fd, EV_READFD, + stream_read_callback, ks); ks->fn = fn; ks->arg = arg; } +/* + * Write a chunk of data to a stream. Blocks until completion. + */ +static ssize_t +krb4_stream_read_sync( + void * s, + void ** buf) +{ + struct krb4_stream *ks = s; + + (void)buf; /* Quiet unused variable warning */ + assert(ks != NULL); + + if (ks->ev_read != NULL) + event_release(ks->ev_read); + + ks->ev_read = event_register((event_id_t)ks->fd, EV_READFD, + stream_read_sync_callback, ks); + event_wait(ks->ev_read); + return((ssize_t)ks->len); +} + +/* + * Callback for krb4_stream_read_sync + */ +static void +stream_read_sync_callback( + void * arg) +{ + struct krb4_stream *ks = arg; + ssize_t n; + + assert(ks != NULL); + assert(ks->fd != -1); + + /* + * Remove the event first, and then call the callback. + * We remove it first because we don't want to get in their + * way if they reschedule it. + */ + krb4_stream_read_cancel(ks); + n = read(ks->fd, ks->databuf, sizeof(ks->databuf)); + if (n < 0) + security_stream_seterror(&ks->secstr, + strerror(errno)); + ks->len = (int)n; +} + /* * Cancel a previous stream read request. It's ok if we didn't have a read * scheduled. */ static void -krb4_stream_read_cancel(s) - void *s; +krb4_stream_read_cancel( + void * s) { struct krb4_stream *ks = s; @@ -886,11 +940,11 @@ krb4_stream_read_cancel(s) * Callback for krb4_stream_read */ static void -stream_read_callback(arg) - void *arg; +stream_read_callback( + void * arg) { struct krb4_stream *ks = arg; - int n; + ssize_t n; assert(ks != NULL); assert(ks->fd != -1); @@ -901,7 +955,7 @@ stream_read_callback(arg) * way if they reschedule it. */ krb4_stream_read_cancel(ks); - n = read(ks->fd, ks->databuf, sizeof(ks->databuf)); + n = read(ks->fd, ks->databuf, SIZEOF(ks->databuf)); if (n < 0) security_stream_seterror(&ks->secstr, strerror(errno)); @@ -914,8 +968,8 @@ stream_read_callback(arg) * and does the real callback if so. */ static void -recvpkt_callback(cookie) - void *cookie; +recvpkt_callback( + void * cookie) { char handle[32]; struct sockaddr_in peer; @@ -923,7 +977,7 @@ recvpkt_callback(cookie) int sequence; struct krb4_handle *kh; struct hostent *he; - void (*fn) P((void *, pkt_t *, security_status_t)); + void (*fn)(void *, pkt_t *, security_status_t); void *arg; assert(cookie == NULL); @@ -936,13 +990,13 @@ recvpkt_callback(cookie) dgram_zero(&netfd); if (dgram_recv(&netfd, 0, &peer) < 0) return; - if (str2pkthdr(netfd.cur, &pkt, handle, sizeof(handle), &sequence) < 0) + if (str2pkthdr(netfd.cur, &pkt, handle, SIZEOF(handle), &sequence) < 0) return; for (kh = handleq_first(); kh != NULL; kh = handleq_next(kh)) { if (strcmp(kh->proto_handle, handle) == 0 && memcmp(&kh->peer.sin_addr, &peer.sin_addr, - sizeof(peer.sin_addr)) == 0 && + SIZEOF(peer.sin_addr)) == 0 && kh->peer.sin_port == peer.sin_port) { kh->sequence = sequence; @@ -967,12 +1021,12 @@ recvpkt_callback(cookie) if (accept_fn == NULL) return; - he = gethostbyaddr((void *)&peer.sin_addr, sizeof(peer.sin_addr), AF_INET); + he = gethostbyaddr((void *)&peer.sin_addr, SIZEOF(peer.sin_addr), AF_INET); if (he == NULL) return; - kh = alloc(sizeof(*kh)); + kh = alloc(SIZEOF(*kh)); security_handleinit(&kh->sech, &krb4_security_driver); - inithandle(kh, he, peer.sin_port, handle); + inithandle(kh, he, (int)peer.sin_port, handle); /* * Check the security of the packet. If it is bad, then pass NULL @@ -988,11 +1042,11 @@ recvpkt_callback(cookie) * This is called when a handle times out before receiving a packet. */ static void -recvpkt_timeout(cookie) - void *cookie; +recvpkt_timeout( + void * cookie) { struct krb4_handle *kh = cookie; - void (*fn) P((void *, pkt_t *, security_status_t)); + void (*fn)(void *, pkt_t *, security_status_t); void *arg; assert(kh != NULL); @@ -1008,30 +1062,30 @@ recvpkt_timeout(cookie) * Add a ticket to the message */ static int -add_ticket(kh, pkt, msg) - struct krb4_handle *kh; - const pkt_t *pkt; - dgram_t *msg; +add_ticket( + struct krb4_handle *kh, + const pkt_t * pkt, + dgram_t * msg) { char inst[INST_SZ]; KTEXT_ST ticket; char *security; int rc; - kh->cksum = krb4_cksum(pkt->body); + kh->cksum = (long)krb4_cksum(pkt->body); #if CLIENT_HOST_INSTANCE == HOSTNAME_INSTANCE /* * User requested that all instances be based on the target * hostname. */ - strncpy(inst, kh->inst, sizeof(inst) - 1); + strncpy(inst, kh->inst, SIZEOF(inst) - 1); #else /* * User requested a fixed instance. */ - strncpy(inst, CLIENT_HOST_INSTANCE, sizeof(inst) - 1); + strncpy(inst, CLIENT_HOST_INSTANCE, SIZEOF(inst) - 1); #endif - inst[sizeof(inst) - 1] = '\0'; + inst[SIZEOF(inst) - 1] = '\0'; /* * Get a ticket with the user-defined service and instance, @@ -1067,9 +1121,9 @@ add_ticket(kh, pkt, msg) * the req, + 1 */ static void -add_mutual_auth(kh, msg) - struct krb4_handle *kh; - dgram_t *msg; +add_mutual_auth( + struct krb4_handle *kh, + dgram_t * msg) { union mutual mutual; char *security; @@ -1079,12 +1133,13 @@ add_mutual_auth(kh, msg) assert(kh->cksum != 0); assert(kh->session_key[0] != '\0'); - memset(&mutual, 0, sizeof(mutual)); - mutual.cksum = htonl(kh->cksum + 1); - encrypt_data(&mutual, sizeof(mutual), &kh->session_key); + memset(&mutual, 0, SIZEOF(mutual)); + mutual.cksum = (unsigned long)htonl((uint32_t)kh->cksum + 1); + encrypt_data(&mutual, SIZEOF(mutual), &kh->session_key); security = vstralloc("SECURITY MUTUAL-AUTH ", - bin2astr(mutual.pad, sizeof(mutual.pad)), "\n", NULL); + bin2astr((unsigned char *)mutual.pad, + (int)sizeof(mutual.pad)), "\n", NULL); dgram_cat(msg, security); amfree(security); } @@ -1095,9 +1150,9 @@ add_mutual_auth(kh, msg) * passed packet. */ static int -recv_security_ok(kh, pkt) - struct krb4_handle *kh; - pkt_t *pkt; +recv_security_ok( + struct krb4_handle *kh, + pkt_t * pkt) { char *tok, *security, *body; unsigned long cksum; @@ -1121,7 +1176,7 @@ recv_security_ok(kh, pkt) * Increment the cur pointer past it to the data section after * parsing is finished. */ - if (strncmp(pkt->body, "SECURITY", sizeof("SECURITY") - 1) == 0) { + if (strncmp(pkt->body, "SECURITY", SIZEOF("SECURITY") - 1) == 0) { tok = strtok(pkt->body, " "); assert(strcmp(tok, "SECURITY") == 0); /* security info goes until the newline */ @@ -1142,7 +1197,7 @@ recv_security_ok(kh, pkt) } /* - * Get a checksum of the non-security parts of the body + * Get a checksum of the non-security parts of the body */ cksum = krb4_cksum(body); @@ -1229,11 +1284,11 @@ recv_security_ok(kh, pkt) * Check the ticket in a REQ packet for authenticity */ static int -check_ticket(kh, pkt, ticket_str, cksum) - struct krb4_handle *kh; - const pkt_t *pkt; - const char *ticket_str; - unsigned long cksum; +check_ticket( + struct krb4_handle *kh, + const pkt_t * pkt, + const char * ticket_str, + unsigned long cksum) { char inst[INST_SZ]; KTEXT_ST ticket; @@ -1246,17 +1301,17 @@ check_ticket(kh, pkt, ticket_str, cksum) assert(pkt != NULL); assert(ticket_str != NULL); - ticket.length = sizeof(ticket.dat); - astr2bin(ticket_str, ticket.dat, &ticket.length); + ticket.length = (int)sizeof(ticket.dat); + astr2bin((unsigned char *)ticket_str, ticket.dat, &ticket.length); assert(ticket.length > 0); /* get a copy of the instance into writable memory */ #if CLIENT_HOST_INSTANCE == HOSTNAME_INSTANCE - strncpy(inst, krb_get_phost(hostname), sizeof(inst) - 1); + strncpy(inst, krb_get_phost(hostname), SIZEOF(inst) - 1); #else - strncpy(inst, CLIENT_HOST_INSTANCE, sizeof(inst) - 1); + strncpy(inst, CLIENT_HOST_INSTANCE, SIZEOF(inst) - 1); #endif - inst[sizeof(inst) - 1] = '\0'; + inst[SIZEOF(inst) - 1] = '\0'; /* get the checksum out of the ticket */ rc = krb_rd_req(&ticket, CLIENT_HOST_PRINCIPLE, inst, @@ -1275,8 +1330,8 @@ check_ticket(kh, pkt, ticket_str, cksum) kh->hostname, (long)auth.checksum, cksum); return (-1); } - kh->cksum = cksum; - memcpy(kh->session_key, auth.session, sizeof(kh->session_key)); + kh->cksum = (unsigned long)cksum; + memcpy(kh->session_key, auth.session, SIZEOF(kh->session_key)); /* * If FORCE_USERID is set, then we need to specifically @@ -1313,9 +1368,9 @@ check_ticket(kh, pkt, ticket_str, cksum) * the same checksum as our request + 1. */ static int -check_mutual_auth(kh, mutual_auth_str) - struct krb4_handle *kh; - const char *mutual_auth_str; +check_mutual_auth( + struct krb4_handle *kh, + const char * mutual_auth_str) { union mutual mutual; int len; @@ -1327,16 +1382,16 @@ check_mutual_auth(kh, mutual_auth_str) assert(kh->cksum != 0); /* convert the encoded string into binary data */ - len = sizeof(mutual); - astr2bin(mutual_auth_str, (unsigned char *)&mutual, &len); + len = (int)sizeof(mutual); + astr2bin((unsigned char *)mutual_auth_str, (unsigned char *)&mutual, &len); /* unencrypt the string using the key in the ticket file */ host2key(kh->hostname, kh->inst, &kh->session_key); - decrypt_data(&mutual, len, &kh->session_key); - mutual.cksum = ntohl(mutual.cksum); + decrypt_data(&mutual, (size_t)len, &kh->session_key); + mutual.cksum = (unsigned long)ntohl((uint32_t)mutual.cksum); /* the data must be the same as our request cksum + 1 */ - if (mutual.cksum != kh->cksum + 1) { + if (mutual.cksum != (kh->cksum + 1)) { security_seterror(&kh->sech, "krb4 checksum mismatch from %s (remote=%lu, local=%lu)", kh->hostname, mutual.cksum, kh->cksum + 1); @@ -1350,16 +1405,16 @@ check_mutual_auth(kh, mutual_auth_str) * Convert a pkt_t into a header string for our packet */ static const char * -pkthdr2str(kh, pkt) - const struct krb4_handle *kh; - const pkt_t *pkt; +pkthdr2str( + const struct krb4_handle * kh, + const pkt_t * pkt) { static char retbuf[256]; assert(kh != NULL); assert(pkt != NULL); - snprintf(retbuf, sizeof(retbuf), "Amanda %d.%d %s HANDLE %s SEQ %d\n", + snprintf(retbuf, SIZEOF(retbuf), "Amanda %d.%d %s HANDLE %s SEQ %d\n", VERSION_MAJOR, VERSION_MINOR, pkt_type2str(pkt->type), kh->proto_handle, kh->sequence); @@ -1374,12 +1429,12 @@ pkthdr2str(kh, pkt) * Returns negative on parse error. */ static int -str2pkthdr(origstr, pkt, handle, handlesize, sequence) - const char *origstr; - pkt_t *pkt; - char *handle; - size_t handlesize; - int *sequence; +str2pkthdr( + const char *origstr, + pkt_t * pkt, + char * handle, + size_t handlesize, + int * sequence) { char *str; const char *tok; @@ -1442,20 +1497,21 @@ parse_error: } static void -host2key(hostname, inst, key) - const char *hostname, *inst; - des_cblock *key; +host2key( + const char *hostname, + const char *inst, + des_cblock *key) { char realm[256]; CREDENTIALS cred; - strncpy(realm, krb_realmofhost((char *)hostname), sizeof(realm) - 1); - realm[sizeof(realm) - 1] = '\0'; + strncpy(realm, krb_realmofhost((char *)hostname), SIZEOF(realm) - 1); + realm[SIZEOF(realm) - 1] = '\0'; #if CLIENT_HOST_INSTANCE != HOSTNAME_INSTANCE inst = CLIENT_HOST_INSTANCE #endif krb_get_cred(CLIENT_HOST_PRINCIPLE, (char *)inst, realm, &cred); - memcpy(key, cred.session, sizeof(des_cblock)); + memcpy(key, cred.session, SIZEOF(des_cblock)); } @@ -1463,22 +1519,23 @@ host2key(hostname, inst, key) * Convert a chunk of data into a string. */ static const char * -bin2astr(buf, len) - const unsigned char *buf; - int len; +bin2astr( + const unsigned char *buf, + int len) { static const char tohex[] = "0123456789ABCDEF"; static char *str = NULL; char *q; const unsigned char *p; - int slen, i; + size_t slen; + int i; /* * calculate output string len * We quote everything, so each input byte == 3 output chars, plus * two more for quotes */ - slen = (len * 3) + 2; + slen = ((size_t)len * 3) + 2; /* allocate string and fill it in */ if (str != NULL) @@ -1497,7 +1554,7 @@ bin2astr(buf, len) *q = '\0'; /* make sure we didn't overrun our allocated buffer */ - assert(q - str == slen); + assert((size_t)(q - str) == slen); return (str); } @@ -1506,12 +1563,12 @@ bin2astr(buf, len) * Convert an encoded string into a block of data bytes */ static void -astr2bin(astr, buf, lenp) - const char *astr; - unsigned char *buf; - int *lenp; +astr2bin( + const unsigned char *astr, + unsigned char * buf, + int * lenp) { - const char *p; + const unsigned char *p; unsigned char *q; #define fromhex(h) (isdigit((int)h) ? (h) - '0' : (h) - 'A' + 10) @@ -1532,32 +1589,32 @@ astr2bin(astr, buf, lenp) *q++ = (fromhex(p[1]) << 4) + fromhex(p[2]); p += 3; } - if (q - buf >= *lenp) + if ((int)(q - buf) >= *lenp) break; } *lenp = q - buf; } static unsigned long -krb4_cksum(str) - const char *str; +krb4_cksum( + const char *str) { des_cblock seed; - memset(seed, 0, sizeof(seed)); + memset(seed, 0, SIZEOF(seed)); /* * The first arg is an unsigned char * in some krb4 implementations, * and in others, it's a des_cblock *. Just make it void here * to shut them all up. */ - return (quad_cksum((void *)str, NULL, strlen(str), 1, &seed)); + return (quad_cksum((void *)str, NULL, (long)strlen(str), 1, &seed)); } static void -krb4_getinst(hname, inst, size) - const char *hname; - char *inst; - size_t size; +krb4_getinst( + const char *hname, + char * inst, + size_t size) { /* @@ -1573,10 +1630,10 @@ krb4_getinst(hname, inst, size) } static void -encrypt_data(data, length, key) - void *data; - int length; - des_cblock *key; +encrypt_data( + void * data, + size_t length, + des_cblock *key) { des_key_schedule sched; @@ -1587,33 +1644,33 @@ encrypt_data(data, length, key) * arrays should be outlawed. */ des_key_sched((void *)key, sched); - des_pcbc_encrypt(data, data, length, sched, key, DES_ENCRYPT); + des_pcbc_encrypt(data, data, (long)length, sched, key, DES_ENCRYPT); } static void -decrypt_data(data, length, key) - void *data; - int length; - des_cblock *key; +decrypt_data( + void * data, + size_t length, + des_cblock *key) { des_key_schedule sched; des_key_sched((void *)key, sched); - des_pcbc_encrypt(data, data, length, sched, key, DES_DECRYPT); + des_pcbc_encrypt(data, data, (long)length, sched, key, DES_DECRYPT); } /* * like write(), but always writes out the entire buffer. */ static int -net_write(fd, vbuf, size) - int fd; - const void *vbuf; - size_t size; +net_write( + int fd, + const void *vbuf, + size_t size) { const char *buf = vbuf; /* so we can do ptr arith */ - int n; + ssize_t n; while (size > 0) { n = write(fd, buf, size); @@ -1629,14 +1686,15 @@ net_write(fd, vbuf, size) * Like read(), but waits until the entire buffer has been filled. */ static int -net_read(fd, vbuf, size, timeout) - int fd; - void *vbuf; - size_t size; - int timeout; +net_read( + int fd, + void * vbuf, + size_t size, + int timeout) { char *buf = vbuf; /* ptr arith */ - int n, neof = 0; + ssize_t n; + int neof = 0; fd_set readfds; struct timeval tv; @@ -1677,10 +1735,10 @@ net_read(fd, vbuf, size, timeout) /* debug routines */ static void -print_hex(str,buf,len) -const char *str; -const unsigned char *buf; -int len; +print_hex( + const char * str, + const unsigned char * buf, + size_t len) { int i; @@ -1693,9 +1751,9 @@ int len; } static void -print_ticket(str, tktp) -const char *str; -KTEXT tktp; +print_ticket( + const char *str, + KTEXT tktp) { dbprintf(("%s: length %d chk %lX\n", str, tktp->length, tktp->mbz)); print_hex("ticket data", tktp->dat, tktp->length); @@ -1703,32 +1761,39 @@ KTEXT tktp; } static void -print_auth(authp) -AUTH_DAT *authp; +print_auth( + AUTH_DAT *authp) { printf("\nAuth Data:\n"); printf(" Principal \"%s\" Instance \"%s\" Realm \"%s\"\n", authp->pname, authp->pinst, authp->prealm); printf(" cksum %d life %d keylen %ld\n", authp->checksum, - authp->life, sizeof(authp->session)); - print_hex("session key", authp->session, sizeof(authp->session)); + authp->life, SIZEOF(authp->session)); + print_hex("session key", authp->session, SIZEOF(authp->session)); fflush(stdout); } static void -print_credentials(credp) -CREDENTIALS *credp; +print_credentials( + CREDENTIALS *credp) { printf("\nCredentials:\n"); printf(" service \"%s\" instance \"%s\" realm \"%s\" life %d kvno %d\n", credp->service, credp->instance, credp->realm, credp->lifetime, credp->kvno); - print_hex("session key", credp->session, sizeof(credp->session)); + print_hex("session key", credp->session, SIZEOF(credp->session)); print_hex("ticket", credp->ticket_st.dat, credp->ticket_st.length); fflush(stdout); } #endif #else -void krb4_security_dummy (void) {} + +void krb4_security_dummy(void); + +void +krb4_security_dummy(void) +{ +} + #endif /* KRB4_SECURITY */ diff --git a/common-src/krb5-security.c b/common-src/krb5-security.c index e1e78a0..b7e6e71 100644 --- a/common-src/krb5-security.c +++ b/common-src/krb5-security.c @@ -25,7 +25,7 @@ */ /* - * $Id: krb5-security.c,v 1.12 2006/02/21 04:13:55 ktill Exp $ + * $Id: krb5-security.c,v 1.22 2006/06/16 10:55:05 martinea Exp $ * * krb5-security.c - kerberos V5 security module */ @@ -33,11 +33,13 @@ #include "config.h" #ifdef KRB5_SECURITY #include "amanda.h" +#include "util.h" #include "arglist.h" #include "event.h" #include "packet.h" #include "queue.h" #include "security.h" +#include "security-util.h" #include "stream.h" #include "version.h" @@ -192,14 +194,15 @@ struct krb5_handle { struct krb5_stream *ks; /* virtual stream we xmit over */ union { - void (*recvpkt) P((void *, pkt_t *, security_status_t)); + void (*recvpkt)(void *, pkt_t *, security_status_t); /* func to call when packet recvd */ - void (*connect) P((void *, security_handle_t *, security_status_t)); + void (*connect)(void *, security_handle_t *, security_status_t); /* func to call when connected */ } fn; void *arg; /* argument to pass function */ + void *datap; /* argument to pass function */ event_handle_t *ev_wait; /* wait handle for connects */ - char *(*conf_fn) P((char *, void *)); /* used to get config info */ + char *(*conf_fn)(char *, void *); /* used to get config info */ event_handle_t *ev_timeout; /* timeout handle for recv */ }; @@ -211,33 +214,35 @@ struct krb5_stream { struct krb5_conn *kc; /* physical connection */ int handle; /* protocol handle */ event_handle_t *ev_read; /* read (EV_WAIT) event handle */ - void (*fn) P((void *, void *, int)); /* read event fn */ + void (*fn)(void *, void *, ssize_t);/* read event fn */ void *arg; /* arg for previous */ + char buf[KRB5_STREAM_BUFSIZE]; + ssize_t len; }; /* * Interface functions */ -static int krb5_sendpkt P((void *, pkt_t *)); -static int krb5_stream_accept P((void *)); -static int krb5_stream_auth P((void *)); -static int krb5_stream_id P((void *)); -static int krb5_stream_write P((void *, const void *, size_t)); -static void *krb5_stream_client P((void *, int)); -static void *krb5_stream_server P((void *)); -static void krb5_accept P((int, int, - void (*)(security_handle_t *, pkt_t *))); -static void krb5_close P((void *)); -static void krb5_connect P((const char *, - char *(*)(char *, void *), - void (*)(void *, security_handle_t *, security_status_t), void *)); -static void krb5_recvpkt P((void *, - void (*)(void *, pkt_t *, security_status_t), void *, int)); -static void krb5_recvpkt_cancel P((void *)); -static void krb5_stream_close P((void *)); -static void krb5_stream_read P((void *, void (*)(void *, void *, int), - void *)); -static void krb5_stream_read_cancel P((void *)); +static ssize_t krb5_sendpkt(void *, pkt_t *); +static int krb5_stream_accept(void *); +static int krb5_stream_auth(void *); +static int krb5_stream_id(void *); +static int krb5_stream_write(void *, const void *, size_t); +static void * krb5_stream_client(void *, int); +static void * krb5_stream_server(void *); +static void krb5_accept(const struct security_driver *, int, int, + void (*)(security_handle_t *, pkt_t *)); +static void krb5_close(void *); +static void krb5_connect(const char *, char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), + void *, void *); +static void krb5_recvpkt(void *, void (*)(void *, pkt_t *, security_status_t), + void *, int); +static void krb5_recvpkt_cancel(void *); +static void krb5_stream_close(void *); +static void krb5_stream_read(void *, void (*)(void *, void *, ssize_t), void *); +static ssize_t krb5_stream_read_sync(void *, void **); +static void krb5_stream_read_cancel(void *); /* * This is our interface to the outside world. @@ -258,7 +263,9 @@ const security_driver_t krb5_security_driver = { krb5_stream_id, krb5_stream_write, krb5_stream_read, + krb5_stream_read_sync, krb5_stream_read_cancel, + sec_close_connection_none, }; /* @@ -272,19 +279,19 @@ static char hostname[MAX_HOSTNAME_LENGTH+1]; static struct { TAILQ_HEAD(, krb5_conn) tailq; int qlength; -} connq = { - TAILQ_HEAD_INITIALIZER(connq.tailq), 0 +} krb5_connq = { + TAILQ_HEAD_INITIALIZER(krb5_connq.tailq), 0 }; -#define connq_first() TAILQ_FIRST(&connq.tailq) -#define connq_next(kc) TAILQ_NEXT(kc, tq) -#define connq_append(kc) do { \ - TAILQ_INSERT_TAIL(&connq.tailq, kc, tq); \ - connq.qlength++; \ +#define krb5_connq_first() TAILQ_FIRST(&krb5_connq.tailq) +#define krb5_connq_next(kc) TAILQ_NEXT(kc, tq) +#define krb5_connq_append(kc) do { \ + TAILQ_INSERT_TAIL(&krb5_connq.tailq, kc, tq); \ + krb5_connq.qlength++; \ } while (0) -#define connq_remove(kc) do { \ - assert(connq.qlength > 0); \ - TAILQ_REMOVE(&connq.tailq, kc, tq); \ - connq.qlength--; \ +#define krb5_connq_remove(kc) do { \ + assert(krb5_connq.qlength > 0); \ + TAILQ_REMOVE(&krb5_connq.tailq, kc, tq); \ + krb5_connq.qlength--; \ } while (0) static int newhandle = 1; @@ -294,45 +301,40 @@ static int newhandle = 1; * created. If NULL, no new handles are created. * It is passed the new handle and the received pkt */ -static void (*accept_fn) P((security_handle_t *, pkt_t *)); +static void (*accept_fn)(security_handle_t *, pkt_t *); /* * Local functions */ -static void init P((void)); +static void init(void); #ifdef BROKEN_MEMORY_CCACHE -static void cleanup P((void)); +static void cleanup(void); #endif -static const char *get_tgt P((char *, char *)); -static void open_callback P((void *)); -static void connect_callback P((void *)); -static void connect_timeout P((void *)); -static int send_token P((struct krb5_conn *, int, const gss_buffer_desc *)); -static int recv_token P((struct krb5_conn *, int *, gss_buffer_desc *, int)); -static void recvpkt_callback P((void *, void *, ssize_t)); -static void recvpkt_timeout P((void *)); -static void stream_read_callback P((void *)); -static int gss_server P((struct krb5_conn *)); -static int gss_client P((struct krb5_handle *)); -static const char *gss_error P((OM_uint32, OM_uint32)); +static const char *get_tgt(char *, char *); +static void open_callback(void *); +static void connect_callback(void *); +static void connect_timeout(void *); +static int send_token(struct krb5_conn *, int, const gss_buffer_desc *); +static ssize_t recv_token(struct krb5_conn *, int *, gss_buffer_desc *, int); +static void recvpkt_callback(void *, void *, ssize_t); +static void recvpkt_timeout(void *); +static void stream_read_callback(void *); +static void stream_read_sync_callback2(void *, void *, ssize_t); +static int gss_server(struct krb5_conn *); +static int gss_client(struct krb5_handle *); +static const char *gss_error(OM_uint32, OM_uint32); #ifdef AMANDA_KRB5_ENCRYPT -static int kdecrypt P((struct krb5_stream *, gss_buffer_desc *, - gss_buffer_desc *)); -static int kencrypt P((struct krb5_stream *, gss_buffer_desc *, - gss_buffer_desc *)); +static int kdecrypt(struct krb5_stream *, gss_buffer_desc *, gss_buffer_desc *); +static int kencrypt(struct krb5_stream *, gss_buffer_desc *, gss_buffer_desc *); #endif -static struct krb5_conn *conn_get P((const char *)); -static void conn_put P((struct krb5_conn *)); -static void conn_read P((struct krb5_conn *)); -static void conn_read_cancel P((struct krb5_conn *)); -static void conn_read_callback P((void *)); -static int conn_run_frameq P((struct krb5_conn *, struct krb5_stream *)); -static int net_writev P((int, struct iovec *, int)); -static ssize_t net_read P((struct krb5_conn *, void *, size_t, int)); -static int net_read_fillbuf P((struct krb5_conn *, int)); -static char *krb5_checkuser(char *, char *, char *); -static void parse_pkt P((pkt_t *, const void *, size_t)); +static struct krb5_conn *conn_get(const char *); +static void conn_put(struct krb5_conn *); +static void conn_read(struct krb5_conn *); +static void conn_read_cancel(struct krb5_conn *); +static void conn_read_callback(void *); +static int conn_run_frameq(struct krb5_conn *, struct krb5_stream *); +static char * krb5_checkuser(char *, char *, char *); /* @@ -340,16 +342,18 @@ static void parse_pkt P((pkt_t *, const void *, size_t)); * up a network "connection". */ static void -krb5_connect(hostname, conf_fn, fn, arg) - const char *hostname; - char *(*conf_fn) P((char *, void *)); - void (*fn) P((void *, security_handle_t *, security_status_t)); - void *arg; +krb5_connect( + const char *hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) { struct krb5_handle *kh; struct hostent *he; struct servent *se; - int port, fd; + int fd; + int port; const char *err; char *keytab_name = NULL; char *principal_name = NULL; @@ -363,7 +367,7 @@ krb5_connect(hostname, conf_fn, fn, arg) */ init(); - kh = alloc(sizeof(*kh)); + kh = alloc(SIZEOF(*kh)); security_handleinit(&kh->sech, &krb5_security_driver); kh->hostname = NULL; kh->ks = NULL; @@ -374,14 +378,14 @@ krb5_connect(hostname, conf_fn, fn, arg) keytab_name = AMANDA_KEYTAB; #else if(conf_fn) { - keytab_name = conf_fn("krb5keytab", arg); + keytab_name = conf_fn("krb5keytab", datap); } #endif #ifdef AMANDA_PRINCIPAL principal_name = AMANDA_PRINCIPAL; #else if(conf_fn) { - principal_name = conf_fn("krb5principal", arg); + principal_name = conf_fn("krb5principal", datap); } #endif @@ -401,6 +405,7 @@ krb5_connect(hostname, conf_fn, fn, arg) kh->fn.connect = fn; kh->conf_fn = conf_fn; kh->arg = arg; + kh->datap = datap; kh->hostname = stralloc(he->h_name); kh->ks = krb5_stream_client(kh, newhandle++); @@ -414,9 +419,9 @@ krb5_connect(hostname, conf_fn, fn, arg) * We need to open a new connection. See if we have too * many connections open. */ - if (connq.qlength > AMANDA_KRB5_MAXCONN) { + if (krb5_connq.qlength > AMANDA_KRB5_MAXCONN) { k5printf(("krb5_connect: too many conections (%d), delaying %s\n", - connq.qlength, kh->hostname)); + krb5_connq.qlength, kh->hostname)); krb5_stream_close(kh->ks); kh->ev_wait = event_register((event_id_t)open_callback, EV_WAIT, open_callback, kh); @@ -447,8 +452,10 @@ krb5_connect(hostname, conf_fn, fn, arg) * so we will know when the socket comes alive. * We also register a timeout. */ - kh->ev_wait = event_register(fd, EV_WRITEFD, connect_callback, kh); - kh->ev_timeout = event_register(GSS_TIMEOUT, EV_TIME, connect_timeout, kh); + kh->ev_wait = event_register((event_id_t)fd, EV_WRITEFD, + connect_callback, kh); + kh->ev_timeout = event_register((event_id_t)GSS_TIMEOUT, EV_TIME, + connect_timeout, kh); return; @@ -461,8 +468,8 @@ error: * we can open more. */ static void -open_callback(cookie) - void *cookie; +open_callback( + void * cookie) { struct krb5_handle *kh = cookie; @@ -470,7 +477,7 @@ open_callback(cookie) k5printf(("krb5: open_callback: possible connections available, retry %s\n", kh->hostname)); - krb5_connect(kh->hostname, kh->conf_fn, kh->fn.connect, kh->arg); + krb5_connect(kh->hostname, kh->conf_fn, kh->fn.connect, kh->arg,kh->datap); amfree(kh->hostname); amfree(kh); } @@ -480,8 +487,8 @@ open_callback(cookie) * to be authenticated. */ static void -connect_callback(cookie) - void *cookie; +connect_callback( + void * cookie) { struct krb5_handle *kh = cookie; @@ -506,8 +513,8 @@ connect_callback(cookie) * Called if a connection times out before completion. */ static void -connect_timeout(cookie) - void *cookie; +connect_timeout( + void * cookie) { struct krb5_handle *kh = cookie; @@ -523,12 +530,14 @@ connect_timeout(cookie) * Setup to handle new incoming connections */ static void -krb5_accept(in, out, fn) - int in, out; - void (*fn) P((security_handle_t *, pkt_t *)); +krb5_accept( + const struct security_driver *driver, + int in, + int out, + void (*fn)(security_handle_t *, pkt_t *)) { struct sockaddr_in sin; - size_t len; + socklen_t len; struct krb5_conn *kc; struct hostent *he; @@ -537,10 +546,14 @@ krb5_accept(in, out, fn) */ init(); - len = sizeof(sin); + /* shut up compiler */ + driver=driver; + out=out; + + len = SIZEOF(sin); if (getpeername(in, (struct sockaddr *)&sin, &len) < 0) return; - he = gethostbyaddr((void *)&sin.sin_addr, sizeof(sin.sin_addr), AF_INET); + he = gethostbyaddr((void *)&sin.sin_addr, SIZEOF(sin.sin_addr), AF_INET); if (he == NULL) return; @@ -559,14 +572,14 @@ krb5_accept(in, out, fn) * for the lack of a connection (kc->fd == -1) and set one up. */ static struct krb5_conn * -conn_get(hostname) - const char *hostname; +conn_get( + const char * hostname) { struct krb5_conn *kc; k5printf(("krb5: conn_get: %s\n", hostname)); - for (kc = connq_first(); kc != NULL; kc = connq_next(kc)) { + for (kc = krb5_connq_first(); kc != NULL; kc = krb5_connq_next(kc)) { if (strcasecmp(hostname, kc->hostname) == 0) break; } @@ -583,14 +596,14 @@ conn_get(hostname) * We can't be creating a new handle if we are the client */ assert(accept_fn == NULL); - kc = alloc(sizeof(*kc)); + kc = alloc(SIZEOF(*kc)); kc->fd = -1; kc->readbuf.left = 0; kc->readbuf.size = 0; kc->state = unauthed; kc->ev_read = NULL; - strncpy(kc->hostname, hostname, sizeof(kc->hostname) - 1); - kc->hostname[sizeof(kc->hostname) - 1] = '\0'; + strncpy(kc->hostname, hostname, SIZEOF(kc->hostname) - 1); + kc->hostname[SIZEOF(kc->hostname) - 1] = '\0'; kc->errmsg = NULL; kc->gss_context = GSS_C_NO_CONTEXT; /* @@ -601,7 +614,7 @@ conn_get(hostname) */ kc->refcnt = 2; TAILQ_INIT(&kc->frameq); - connq_append(kc); + krb5_connq_append(kc); return (kc); } @@ -610,8 +623,8 @@ conn_get(hostname) * reference. */ static void -conn_put(kc) - struct krb5_conn *kc; +conn_put( + struct krb5_conn * kc) { OM_uint32 min_stat; struct krb5_frame *kf; @@ -636,7 +649,7 @@ conn_put(kc) amfree(kf->tok.value); amfree(kf); } - connq_remove(kc); + krb5_connq_remove(kc); amfree(kc); /* signal that a connection is available */ event_wakeup((event_id_t)open_callback); @@ -647,8 +660,8 @@ conn_put(kc) * already receiving read events. */ static void -conn_read(kc) - struct krb5_conn *kc; +conn_read( + struct krb5_conn *kc) { if (kc->ev_read != NULL) { @@ -659,13 +672,13 @@ conn_read(kc) } k5printf(("krb5: conn_read registering event handler for %s\n", kc->hostname)); - kc->ev_read = event_register(kc->fd, EV_READFD, conn_read_callback, kc); + kc->ev_read = event_register((event_id_t)kc->fd, EV_READFD, conn_read_callback, kc); kc->ev_read_refcnt = 1; } static void -conn_read_cancel(kc) - struct krb5_conn *kc; +conn_read_cancel( + struct krb5_conn * kc) { if (--kc->ev_read_refcnt > 0) { @@ -683,8 +696,8 @@ conn_read_cancel(kc) * frees a handle allocated by the above */ static void -krb5_close(inst) - void *inst; +krb5_close( + void * inst) { struct krb5_handle *kh = inst; @@ -704,15 +717,15 @@ krb5_close(inst) /* * Transmit a packet. Encrypt first. */ -static int -krb5_sendpkt(cookie, pkt) - void *cookie; - pkt_t *pkt; +static ssize_t +krb5_sendpkt( + void * cookie, + pkt_t * pkt) { struct krb5_handle *kh = cookie; gss_buffer_desc tok; int rval; - unsigned char c, *buf; + unsigned char *buf; assert(kh != NULL); assert(pkt != NULL); @@ -720,15 +733,15 @@ krb5_sendpkt(cookie, pkt) k5printf(("krb5: sendpkt: enter\n")); if (pkt->body[0] == '\0') { - c = (unsigned char)pkt->type; tok.length = 1; - tok.value = &c; + tok.value = alloc(SIZEOF(pkt->type)); + memcpy(tok.value, &pkt->type, sizeof(unsigned char)); } else { tok.length = strlen(pkt->body) + 2; tok.value = alloc(tok.length); buf = tok.value; *buf++ = (unsigned char)pkt->type; - strncpy(buf, pkt->body, tok.length - 2); + strncpy((char *)buf, pkt->body, tok.length - 2); buf[tok.length - 2] = '\0'; } @@ -738,8 +751,9 @@ krb5_sendpkt(cookie, pkt) rval = krb5_stream_write(kh->ks, tok.value, tok.length); if (rval < 0) security_seterror(&kh->sech, security_stream_geterror(&kh->ks->secstr)); - if (tok.length > 1) - amfree(tok.value); + /*@ignore@*/ + amfree(tok.value); + /*@end@*/ return (rval); } @@ -748,10 +762,11 @@ krb5_sendpkt(cookie, pkt) * it has been read. */ static void -krb5_recvpkt(cookie, fn, arg, timeout) - void *cookie, *arg; - void (*fn) P((void *, pkt_t *, security_status_t)); - int timeout; +krb5_recvpkt( + void * cookie, + void (*fn)(void *, pkt_t *, security_status_t), + void * arg, + int timeout) { struct krb5_handle *kh = cookie; @@ -771,7 +786,8 @@ krb5_recvpkt(cookie, fn, arg, timeout) if (timeout < 0) kh->ev_timeout = NULL; else - kh->ev_timeout = event_register(timeout, EV_TIME, recvpkt_timeout, kh); + kh->ev_timeout = event_register((event_id_t)timeout, EV_TIME, + recvpkt_timeout, kh); kh->fn.recvpkt = fn; kh->arg = arg; @@ -782,8 +798,8 @@ krb5_recvpkt(cookie, fn, arg, timeout) * Remove a async receive request from the queue */ static void -krb5_recvpkt_cancel(cookie) - void *cookie; +krb5_recvpkt_cancel( + void * cookie) { struct krb5_handle *kh = cookie; @@ -803,9 +819,10 @@ krb5_recvpkt_cancel(cookie) * net is for it. */ static void -recvpkt_callback(cookie, buf, bufsize) - void *cookie, *buf; - ssize_t bufsize; +recvpkt_callback( + void *cookie, + void *buf, + ssize_t bufsize) { pkt_t pkt; struct krb5_handle *kh = cookie; @@ -829,7 +846,7 @@ recvpkt_callback(cookie, buf, bufsize) (*kh->fn.recvpkt)(kh->arg, NULL, S_ERROR); return; default: - parse_pkt(&pkt, buf, bufsize); + parse_pkt(&pkt, buf, (size_t)bufsize); k5printf(("krb5: received %s pkt (%d) from %s, contains:\n\n\"%s\"\n\n", pkt_type2str(pkt.type), pkt.type, kh->hostname, pkt.body)); (*kh->fn.recvpkt)(kh->arg, &pkt, S_OK); @@ -841,8 +858,8 @@ recvpkt_callback(cookie, buf, bufsize) * This is called when a handle times out before receiving a packet. */ static void -recvpkt_timeout(cookie) - void *cookie; +recvpkt_timeout( + void * cookie) { struct krb5_handle *kh = cookie; @@ -859,15 +876,15 @@ recvpkt_timeout(cookie) * object and allocate a new handle for it. */ static void * -krb5_stream_server(h) - void *h; +krb5_stream_server( + void * h) { struct krb5_handle *kh = h; struct krb5_stream *ks; assert(kh != NULL); - ks = alloc(sizeof(*ks)); + ks = alloc(SIZEOF(*ks)); security_streaminit(&ks->secstr, &krb5_security_driver); ks->kc = conn_get(kh->hostname); /* @@ -883,7 +900,7 @@ krb5_stream_server(h) * so as not to conflict with the amanda server's handle numbers, * we start at 5000 and work down */ - ks->handle = 5000 - newhandle++; + ks->handle = (int)(5000 - newhandle++); ks->ev_read = NULL; k5printf(("krb5: stream_server: created stream %d\n", ks->handle)); return (ks); @@ -894,10 +911,13 @@ krb5_stream_server(h) * Nothing needed for krb5. */ static int -krb5_stream_accept(s) - void *s; +krb5_stream_accept( + void * s) { + /* shut up compiler */ + s = s; + return (0); } @@ -906,9 +926,9 @@ krb5_stream_accept(s) * with the supplied handle. */ static void * -krb5_stream_client(h, id) - void *h; - int id; +krb5_stream_client( + void * h, + int id) { struct krb5_handle *kh = h; struct krb5_stream *ks; @@ -921,9 +941,9 @@ krb5_stream_client(h, id) return (NULL); } - ks = alloc(sizeof(*ks)); + ks = alloc(SIZEOF(*ks)); security_streaminit(&ks->secstr, &krb5_security_driver); - ks->handle = id; + ks->handle = (int)id; ks->ev_read = NULL; ks->kc = conn_get(kh->hostname); @@ -936,8 +956,8 @@ krb5_stream_client(h, id) * Close and unallocate resources for a stream. */ static void -krb5_stream_close(s) - void *s; +krb5_stream_close( + void * s) { struct krb5_stream *ks = s; @@ -956,9 +976,11 @@ krb5_stream_close(s) * on startup. */ static int -krb5_stream_auth(s) - void *s; +krb5_stream_auth( + void * s) { + /* shut up compiler */ + s = s; return (0); } @@ -968,8 +990,8 @@ krb5_stream_auth(s) * port. */ static int -krb5_stream_id(s) - void *s; +krb5_stream_id( + void * s) { struct krb5_stream *ks = s; @@ -982,10 +1004,10 @@ krb5_stream_id(s) * Write a chunk of data to a stream. Blocks until completion. */ static int -krb5_stream_write(s, buf, size) - void *s; - const void *buf; - size_t size; +krb5_stream_write( + void * s, + const void *buf, + size_t size) { struct krb5_stream *ks = s; gss_buffer_desc tok; @@ -1022,9 +1044,10 @@ krb5_stream_write(s, buf, size) * function and arg when completed. */ static void -krb5_stream_read(s, fn, arg) - void *s, *arg; - void (*fn) P((void *, void *, int)); +krb5_stream_read( + void * s, + void (*fn)(void *, void *, ssize_t), + void * arg) { struct krb5_stream *ks = s; @@ -1050,13 +1073,70 @@ krb5_stream_read(s, fn, arg) } } +/* + * Submit a request to read some data. Calls back with the given + * function and arg when completed. + */ +static ssize_t +krb5_stream_read_sync( + void * s, + void **buf) +{ + struct krb5_stream *ks = s; + + assert(ks != NULL); + + /* + * Only one read request can be active per stream. + */ + ks->fn = stream_read_sync_callback2; + ks->arg = ks; + + /* + * First see if there's any queued frames for this stream. + * If so, we're done. + */ + if (conn_run_frameq(ks->kc, ks) > 0) + return ks->len; + + if (ks->ev_read != NULL) + event_release(ks->ev_read); + + ks->ev_read = event_register((event_id_t)ks->kc, EV_WAIT, + stream_read_callback, ks); + conn_read(ks->kc); + event_wait(ks->ev_read); + buf = (void **)&ks->buf; + return ks->len; +} + + +/* + * Callback for krb5_stream_read_sync + */ +static void +stream_read_sync_callback2( + void * arg, + void * buf, + ssize_t size) +{ + struct krb5_stream *ks = arg; + + assert(ks != NULL); + + k5printf(("krb5: stream_read_sync_callback2: handle %d\n", ks->handle)); + + memcpy(ks->buf, buf, (size_t)size); + ks->len = size; +} + /* * Cancel a previous stream read request. It's ok if we didn't have a read * scheduled. */ static void -krb5_stream_read_cancel(s) - void *s; +krb5_stream_read_cancel( + void * s) { struct krb5_stream *ks = s; @@ -1073,8 +1153,8 @@ krb5_stream_read_cancel(s) * Callback for krb5_stream_read */ static void -stream_read_callback(arg) - void *arg; +stream_read_callback( + void * arg) { struct krb5_stream *ks = arg; @@ -1093,9 +1173,9 @@ stream_read_callback(arg) * Returns 1 if a frame was found and processed. */ static int -conn_run_frameq(kc, ks) - struct krb5_conn *kc; - struct krb5_stream *ks; +conn_run_frameq( + /*@keep@*/ struct krb5_conn * kc, + /*@keep@*/ struct krb5_stream * ks) { struct krb5_frame *kf, *nextkf; gss_buffer_desc *enctok, *dectok; @@ -1154,7 +1234,7 @@ conn_run_frameq(kc, ks) { k5printf(("krb5: stream_read_callback: read %d bytes from %s:%d\n", dectok->length, ks->kc->hostname, ks->handle)); - (*ks->fn)(ks->arg, dectok->value, dectok->length); + (*ks->fn)(ks->arg, dectok->value, (ssize_t)dectok->length); #ifdef AMANDA_KRB5_ENCRYPT gss_release_buffer(&min_stat, dectok); #endif @@ -1172,8 +1252,8 @@ conn_run_frameq(kc, ks) * and does the real callback if so. */ static void -conn_read_callback(cookie) - void *cookie; +conn_read_callback( + void * cookie) { struct krb5_conn *kc = cookie; struct krb5_handle *kh; @@ -1190,7 +1270,7 @@ conn_read_callback(cookie) k5printf(("krb5: conn_read_callback\n")); - kf = alloc(sizeof(*kf)); + kf = alloc(SIZEOF(*kf)); TAILQ_INSERT_TAIL(&kc->frameq, kf, tq); /* Read the data off the wire. If we get errors, shut down. */ @@ -1221,7 +1301,7 @@ conn_read_callback(cookie) return; } - kh = alloc(sizeof(*kh)); + kh = alloc(SIZEOF(*kh)); security_handleinit(&kh->sech, &krb5_security_driver); kh->hostname = stralloc(kc->hostname); kh->ks = krb5_stream_client(kh, kf->handle); @@ -1274,8 +1354,8 @@ conn_read_callback(cookie) * Negotiate a krb5 gss context from the client end. */ static int -gss_client(kh) - struct krb5_handle *kh; +gss_client( + struct krb5_handle *kh) { struct krb5_stream *ks = kh->ks; struct krb5_conn *kc = ks->kc; @@ -1291,7 +1371,7 @@ gss_client(kh) send_tok.length = strlen(send_tok.value) + 1; maj_stat = gss_import_name(&min_stat, &send_tok, GSS_C_NULL_OID, &gss_name); - if (maj_stat != GSS_S_COMPLETE) { + if (maj_stat != (OM_uint32)GSS_S_COMPLETE) { security_seterror(&kh->sech, "can't import name %s: %s", (char *)send_tok.value, gss_error(maj_stat, min_stat)); amfree(send_tok.value); @@ -1314,6 +1394,7 @@ gss_client(kh) * and only if the server has another token to send us. */ + recv_tok.value = NULL; for (recv_tok.length = 0;;) { min_stat = 0; maj_stat = gss_init_sec_context(&min_stat, @@ -1321,7 +1402,7 @@ gss_client(kh) &kc->gss_context, gss_name, GSS_C_NULL_OID, - GSS_C_MUTUAL_FLAG|GSS_C_REPLAY_FLAG, + (OM_uint32)GSS_C_MUTUAL_FLAG|GSS_C_REPLAY_FLAG, 0, NULL, /* no channel bindings */ (recv_tok.length == 0 ? GSS_C_NO_BUFFER : &recv_tok), NULL, /* ignore mech type */ @@ -1334,7 +1415,7 @@ gss_client(kh) recv_tok.length = 0; } - if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) { + if (maj_stat != (OM_uint32)GSS_S_COMPLETE && maj_stat != (OM_uint32)GSS_S_CONTINUE_NEEDED) { security_seterror(&kh->sech, "error getting gss context: %s", gss_error(maj_stat, min_stat)); @@ -1354,7 +1435,7 @@ gss_client(kh) /* * If we need to continue, then register for more packets */ - if (maj_stat != GSS_S_CONTINUE_NEEDED) + if (maj_stat != (OM_uint32)GSS_S_CONTINUE_NEEDED) break; if ((rc = recv_token(kc, NULL, &recv_tok, GSS_TIMEOUT)) <= 0) { @@ -1377,8 +1458,8 @@ done: * Negotiate a krb5 gss context from the server end. */ static int -gss_server(kc) - struct krb5_conn *kc; +gss_server( + struct krb5_conn * kc) { OM_uint32 maj_stat, min_stat, ret_flags; gss_buffer_desc send_tok, recv_tok; @@ -1401,13 +1482,13 @@ gss_server(kc) */ euid = geteuid(); if (getuid() != 0) { - snprintf(errbuf, sizeof(errbuf), + snprintf(errbuf, SIZEOF(errbuf), "real uid is %ld, needs to be 0 to read krb5 host key", (long)getuid()); goto out; } if (seteuid(0) < 0) { - snprintf(errbuf, sizeof(errbuf), + snprintf(errbuf, SIZEOF(errbuf), "can't seteuid to uid 0: %s", strerror(errno)); goto out; } @@ -1420,9 +1501,9 @@ gss_server(kc) } maj_stat = gss_import_name(&min_stat, &send_tok, GSS_C_NULL_OID, &gss_name); - if (maj_stat != GSS_S_COMPLETE) { + if (maj_stat != (OM_uint32)GSS_S_COMPLETE) { seteuid(euid); - snprintf(errbuf, sizeof(errbuf), + snprintf(errbuf, SIZEOF(errbuf), "can't import name %s: %s", (char *)send_tok.value, gss_error(maj_stat, min_stat)); amfree(send_tok.value); @@ -1432,8 +1513,8 @@ gss_server(kc) maj_stat = gss_acquire_cred(&min_stat, gss_name, 0, GSS_C_NULL_OID_SET, GSS_C_ACCEPT, &gss_creds, NULL, NULL); - if (maj_stat != GSS_S_COMPLETE) { - snprintf(errbuf, sizeof(errbuf), + if (maj_stat != (OM_uint32)GSS_S_COMPLETE) { + snprintf(errbuf, SIZEOF(errbuf), "can't acquire creds for host key host/%s: %s", hostname, gss_error(maj_stat, min_stat)); gss_release_name(&min_stat, &gss_name); @@ -1445,11 +1526,11 @@ gss_server(kc) for (recv_tok.length = 0;;) { if ((rc = recv_token(kc, NULL, &recv_tok, GSS_TIMEOUT)) <= 0) { if (rc < 0) { - snprintf(errbuf, sizeof(errbuf), + snprintf(errbuf, SIZEOF(errbuf), "recv error in gss loop: %s", kc->errmsg); amfree(kc->errmsg); } else - snprintf(errbuf, sizeof(errbuf), "EOF in gss loop"); + snprintf(errbuf, SIZEOF(errbuf), "EOF in gss loop"); goto out; } @@ -1457,9 +1538,9 @@ gss_server(kc) gss_creds, &recv_tok, GSS_C_NO_CHANNEL_BINDINGS, &gss_name, &doid, &send_tok, &ret_flags, NULL, NULL); - if (maj_stat != GSS_S_COMPLETE && - maj_stat != GSS_S_CONTINUE_NEEDED) { - snprintf(errbuf, sizeof(errbuf), + if (maj_stat != (OM_uint32)GSS_S_COMPLETE && + maj_stat != (OM_uint32)GSS_S_CONTINUE_NEEDED) { + snprintf(errbuf, SIZEOF(errbuf), "error accepting context: %s", gss_error(maj_stat, min_stat)); amfree(recv_tok.value); goto out; @@ -1467,8 +1548,8 @@ gss_server(kc) amfree(recv_tok.value); if (send_tok.length > 0 && send_token(kc, 0, &send_tok) < 0) { - strncpy(errbuf, kc->errmsg, sizeof(errbuf) - 1); - errbuf[sizeof(errbuf) - 1] = '\0'; + strncpy(errbuf, kc->errmsg, SIZEOF(errbuf) - 1); + errbuf[SIZEOF(errbuf) - 1] = '\0'; amfree(kc->errmsg); gss_release_buffer(&min_stat, &send_tok); goto out; @@ -1480,13 +1561,13 @@ gss_server(kc) * If we need to get more from the client, then register for * more packets. */ - if (maj_stat != GSS_S_CONTINUE_NEEDED) + if (maj_stat != (OM_uint32)GSS_S_CONTINUE_NEEDED) break; } maj_stat = gss_display_name(&min_stat, gss_name, &send_tok, &doid); - if (maj_stat != GSS_S_COMPLETE) { - snprintf(errbuf, sizeof(errbuf), + if (maj_stat != (OM_uint32)GSS_S_COMPLETE) { + snprintf(errbuf, SIZEOF(errbuf), "can't display gss name: %s", gss_error(maj_stat, min_stat)); gss_release_name(&min_stat, &gss_name); goto out; @@ -1495,7 +1576,7 @@ gss_server(kc) /* get rid of the realm */ if ((p = strchr(send_tok.value, '@')) == NULL) { - snprintf(errbuf, sizeof(errbuf), + snprintf(errbuf, SIZEOF(errbuf), "malformed gss name: %s", (char *)send_tok.value); amfree(send_tok.value); goto out; @@ -1507,7 +1588,7 @@ gss_server(kc) * If the principal doesn't match, complain */ if ((msg = krb5_checkuser(kc->hostname, send_tok.value, realm)) != NULL) { - snprintf(errbuf, sizeof(errbuf), + snprintf(errbuf, SIZEOF(errbuf), "access not allowed from %s: %s", (char *)send_tok.value, msg); amfree(send_tok.value); goto out; @@ -1527,19 +1608,18 @@ out: * Setup some things about krb5. This should only be called once. */ static void -init() +init(void) { static int beenhere = 0; struct hostent *he; char *p; - int krb5_setenv P((const char *, const char *, int)); if (beenhere) return; beenhere = 1; #ifndef BROKEN_MEMORY_CCACHE - krb5_setenv(KRB5_ENV_CCNAME, "MEMORY:amanda_ccache", 1); + setenv(KRB5_ENV_CCNAME, "MEMORY:amanda_ccache", 1); #else /* * MEMORY ccaches seem buggy and cause a lot of internal heap @@ -1552,19 +1632,19 @@ init() atexit(cleanup); { char ccache[64]; - snprintf(ccache, sizeof(ccache), "FILE:/tmp/amanda_ccache.%ld.%ld", + snprintf(ccache, SIZEOF(ccache), "FILE:/tmp/amanda_ccache.%ld.%ld", (long)geteuid(), (long)getpid()); - krb5_setenv(KRB5_ENV_CCNAME, ccache, 1); + setenv(KRB5_ENV_CCNAME, ccache, 1); } #endif - gethostname(hostname, sizeof(hostname) - 1); - hostname[sizeof(hostname) - 1] = '\0'; + gethostname(hostname, SIZEOF(hostname) - 1); + hostname[SIZEOF(hostname) - 1] = '\0'; /* * In case it isn't fully qualified, do a DNS lookup. */ if ((he = gethostbyname(hostname)) != NULL) - strncpy(hostname, he->h_name, sizeof(hostname) - 1); + strncpy(hostname, he->h_name, SIZEOF(hostname) - 1); /* * Lowercase the results. We assume all host/ principals will be @@ -1578,11 +1658,11 @@ init() #ifdef BROKEN_MEMORY_CCACHE static void -cleanup() +cleanup(void) { #ifdef KDESTROY_VIA_UNLINK char ccache[64]; - snprintf(ccache, sizeof(ccache), "/tmp/amanda_ccache.%ld.%ld", + snprintf(ccache, SIZEOF(ccache), "/tmp/amanda_ccache.%ld.%ld", (long)geteuid(), (long)getpid()); unlink(ccache); #else @@ -1595,8 +1675,9 @@ cleanup() * Get a ticket granting ticket and stuff it in the cache */ static const char * -get_tgt(keytab_name, principal_name) - char *keytab_name, *principal_name; +get_tgt( + char * keytab_name, + char * principal_name) { krb5_context context; krb5_error_code ret; @@ -1619,7 +1700,7 @@ get_tgt(keytab_name, principal_name) return (error); } - krb5_init_ets(context); + /*krb5_init_ets(context);*/ if(!keytab_name) { error = vstralloc("error -- no krb5 keytab defined", NULL); @@ -1671,7 +1752,7 @@ get_tgt(keytab_name, principal_name) return (error); } - memset(&creds, 0, sizeof(creds)); + memset(&creds, 0, SIZEOF(creds)); creds.times.starttime = 0; creds.times.endtime = now + AMANDA_TKT_LIFETIME; @@ -1720,7 +1801,8 @@ cleanup2: /* * get rid of tickets */ -kdestroy() +static void +kdestroy(void) { krb5_context context; krb5_ccache ccache; @@ -1740,39 +1822,13 @@ cleanup: return; } -static void -parse_pkt(pkt, buf, bufsize) - pkt_t *pkt; - const void *buf; - size_t bufsize; -{ - const unsigned char *bufp = buf; - - k5printf(("krb5: parse_pkt: parsing buffer of %d bytes\n", bufsize)); - - pkt->type = (pktype_t)*bufp++; - bufsize--; - - if (bufsize == 0) { - pkt->body[0] = '\0'; - } else { - if (bufsize > sizeof(pkt->body) - 1) - bufsize = sizeof(pkt->body) - 1; - memcpy(pkt->body, bufp, bufsize); - pkt->body[sizeof(pkt->body) - 1] = '\0'; - } - - k5printf(("krb5: parse_pkt: %s (%d): \"%s\"\n", pkt_type2str(pkt->type), - pkt->type, pkt->body)); -} - - /* * Formats an error from the gss api */ static const char * -gss_error(major, minor) - OM_uint32 major, minor; +gss_error( + OM_uint32 major, + OM_uint32 minor) { static gss_buffer_desc msg; OM_uint32 min_stat, msg_ctx; @@ -1796,10 +1852,10 @@ gss_error(major, minor) * Encryption must be done by the caller. */ static int -send_token(kc, handle, tok) - struct krb5_conn *kc; - int handle; - const gss_buffer_desc *tok; +send_token( + struct krb5_conn * kc, + int handle, + const gss_buffer_desc * tok) { OM_uint32 netlength, nethandle; struct iovec iov[3]; @@ -1819,13 +1875,13 @@ send_token(kc, handle, tok) * 32 bit handle (network byte order) * data */ - netlength = htonl(tok->length); + netlength = (OM_uint32)htonl(tok->length); iov[0].iov_base = (void *)&netlength; - iov[0].iov_len = sizeof(netlength); + iov[0].iov_len = SIZEOF(netlength); - nethandle = htonl(handle); + nethandle = (OM_uint32)htonl((uint32_t)handle); iov[1].iov_base = (void *)&nethandle; - iov[1].iov_len = sizeof(nethandle); + iov[1].iov_len = SIZEOF(nethandle); iov[2].iov_base = (void *)tok->value; iov[2].iov_len = tok->length; @@ -1838,21 +1894,21 @@ send_token(kc, handle, tok) return (0); } -static int -recv_token(kc, handle, gtok, timeout) - struct krb5_conn *kc; - int *handle; - gss_buffer_desc *gtok; - int timeout; +static ssize_t +recv_token( + struct krb5_conn * kc, + int * handle, + gss_buffer_desc * gtok, + int timeout) { - OM_uint32 netint; + OM_uint32 netint[2]; assert(kc->fd >= 0); assert(gtok != NULL); k5printf(("krb5: recv_token: reading from %s\n", kc->hostname)); - switch (net_read(kc, &netint, sizeof(netint), timeout)) { + switch (net_read(kc->fd, &netint, SIZEOF(netint), timeout)) { case -1: kc->errmsg = newvstralloc(kc->errmsg, "recv error: ", strerror(errno), NULL); @@ -1864,7 +1920,7 @@ recv_token(kc, handle, gtok, timeout) default: break; } - gtok->length = ntohl(netint); + gtok->length = ntohl(netint[0]); if (gtok->length > AMANDA_MAX_TOK_SIZE) { kc->errmsg = newstralloc(kc->errmsg, "recv error: buffer too large"); @@ -1872,23 +1928,11 @@ recv_token(kc, handle, gtok, timeout) return (-1); } - switch (net_read(kc, &netint, sizeof(netint), timeout)) { - case -1: - kc->errmsg = newvstralloc(kc->errmsg, "recv error: ", strerror(errno), - NULL); - k5printf(("krb5 recv_token error return: %s\n", kc->errmsg)); - return (-1); - case 0: - gtok->length = 0; - return (0); - default: - break; - } if (handle != NULL) - *handle = ntohl(netint); + *handle = ntohl(netint[1]); gtok->value = alloc(gtok->length); - switch (net_read(kc, gtok->value, gtok->length, timeout)) { + switch (net_read(kc->fd, gtok->value, gtok->length, timeout)) { case -1: kc->errmsg = newvstralloc(kc->errmsg, "recv error: ", strerror(errno), NULL); @@ -1905,14 +1949,15 @@ recv_token(kc, handle, gtok, timeout) k5printf(("krb5: recv_token: read %d bytes from %s\n", gtok->length, kc->hostname)); - return (gtok->length); + return ((ssize_t)gtok->length); } #ifdef AMANDA_KRB5_ENCRYPT static int -kencrypt(ks, tok, enctok) - struct krb5_stream *ks; - gss_buffer_desc *tok, *enctok; +kencrypt( + struct krb5_stream *ks, + gss_buffer_desc * tok, + gss_buffer_desc * enctok) { int conf_state; OM_uint32 maj_stat, min_stat; @@ -1920,7 +1965,7 @@ kencrypt(ks, tok, enctok) assert(ks->kc->gss_context != GSS_C_NO_CONTEXT); maj_stat = gss_seal(&min_stat, ks->kc->gss_context, 1, GSS_C_QOP_DEFAULT, tok, &conf_state, enctok); - if (maj_stat != GSS_S_COMPLETE || conf_state == 0) { + if (maj_stat != (OM_uint32)GSS_S_COMPLETE || conf_state == 0) { security_stream_seterror(&ks->secstr, "krb5 encryption failed to %s: %s", ks->kc->hostname, gss_error(maj_stat, min_stat)); @@ -1930,9 +1975,10 @@ kencrypt(ks, tok, enctok) } static int -kdecrypt(ks, enctok, tok) - struct krb5_stream *ks; - gss_buffer_desc *enctok, *tok; +kdecrypt( + struct krb5_stream *ks, + gss_buffer_desc * enctok, + gss_buffer_desc * tok) { OM_uint32 maj_stat, min_stat; int conf_state, qop_state; @@ -1942,7 +1988,7 @@ kdecrypt(ks, enctok, tok) assert(ks->kc->gss_context != GSS_C_NO_CONTEXT); maj_stat = gss_unseal(&min_stat, ks->kc->gss_context, enctok, tok, &conf_state, &qop_state); - if (maj_stat != GSS_S_COMPLETE) { + if (maj_stat != (OM_uint32)GSS_S_COMPLETE) { security_stream_seterror(&ks->secstr, "krb5 decrypt error from %s: %s", ks->kc->hostname, gss_error(maj_stat, min_stat)); return (-1); @@ -1951,121 +1997,6 @@ kdecrypt(ks, enctok, tok) } #endif -/* - * Writes out the entire iovec - */ -static int -net_writev(fd, iov, iovcnt) - int fd, iovcnt; - struct iovec *iov; -{ - int delta, n, total; - - assert(iov != NULL); - - total = 0; - while (iovcnt > 0) { - /* - * Write the iovec - */ - total += n = writev(fd, iov, iovcnt); - if (n < 0) - return (-1); - if (n == 0) { - errno = EIO; - return (-1); - } - /* - * Iterate through each iov. Figure out what we still need - * to write out. - */ - for (; n > 0; iovcnt--, iov++) { - /* 'delta' is the bytes written from this iovec */ - delta = n < iov->iov_len ? n : iov->iov_len; - /* subtract from the total num bytes written */ - n -= delta; - assert(n >= 0); - /* subtract from this iovec */ - iov->iov_len -= delta; - (char *)iov->iov_base += delta; - /* if this iovec isn't empty, run the writev again */ - if (iov->iov_len > 0) - break; - } - } - return (total); -} - -/* - * Like read(), but waits until the entire buffer has been filled. - */ -static ssize_t -net_read(kc, vbuf, origsize, timeout) - struct krb5_conn *kc; - void *vbuf; - size_t origsize; - int timeout; -{ - char *buf = vbuf, *off; /* ptr arith */ - int nread; - size_t size = origsize; - - while (size > 0) { - if (kc->readbuf.left == 0) { - if (net_read_fillbuf(kc, timeout) < 0) - return (-1); - if (kc->readbuf.size == 0) - return (0); - } - nread = min(kc->readbuf.left, size); - off = kc->readbuf.buf + kc->readbuf.size - kc->readbuf.left; - memcpy(buf, off, nread); - - buf += nread; - size -= nread; - kc->readbuf.left -= nread; - } - return ((ssize_t)origsize); -} - -/* - * net_read likes to do a lot of little reads. Buffer it. - */ -static int -net_read_fillbuf(kc, timeout) - struct krb5_conn *kc; - int timeout; -{ - fd_set readfds; - struct timeval tv; - - FD_ZERO(&readfds); - FD_SET(kc->fd, &readfds); - tv.tv_sec = timeout; - tv.tv_usec = 0; - switch (select(kc->fd + 1, &readfds, NULL, NULL, &tv)) { - case 0: - errno = ETIMEDOUT; - /* FALLTHROUGH */ - case -1: - return (-1); - case 1: - assert(FD_ISSET(kc->fd, &readfds)); - break; - default: - assert(0); - break; - } - kc->readbuf.left = 0; - kc->readbuf.size = read(kc->fd, kc->readbuf.buf, - sizeof(kc->readbuf.buf)); -k5printf(("net_read_fillbuf: read %d characters w/ errno %d\n", kc->readbuf.size, errno)); - if (kc->readbuf.size < 0) - return (-1); - kc->readbuf.left = kc->readbuf.size; - return (0); -} - /* * hackish, but you can #undef AMANDA_PRINCIPAL here, and you can both * hardcode a principal in your build and use the .k5amandahosts. This is @@ -2080,8 +2011,9 @@ k5printf(("net_read_fillbuf: read %d characters w/ errno %d\n", kc->readbuf.size * hardcoded, then we don't check the realm */ static char * -krb5_checkuser(host, name, realm) - char *host, *name, *realm; +krb5_checkuser( char * host, + char * name, + char * realm) { #ifdef AMANDA_PRINCIPAL if(strcmp(name, AMANDA_PRINCIPAL) == 0) { @@ -2131,7 +2063,7 @@ krb5_checkuser(host, name, realm) if(strcmp(name, CLIENT_LOGIN) != 0) { result = vstralloc(name, " does not match ", CLIENT_LOGIN, NULL); - goto common_exit; + return result; } result = NULL; goto common_exit; @@ -2140,19 +2072,18 @@ krb5_checkuser(host, name, realm) k5printf(("opening ptmp: %s\n", (ptmp)?ptmp: "NULL!")); if((fp = fopen(ptmp, "r")) == NULL) { result = vstralloc("can not open ", ptmp, NULL); - goto common_exit; + return result; } k5printf(("opened ptmp\n")); if (fstat(fileno(fp), &sbuf) != 0) { result = vstralloc("cannot fstat ", ptmp, ": ", strerror(errno), NULL); goto common_exit; - } if (sbuf.st_uid != localuid) { - snprintf(n1, sizeof(n1), "%ld", (long) sbuf.st_uid); - snprintf(n2, sizeof(n2), "%ld", (long) localuid); + snprintf(n1, SIZEOF(n1), "%ld", (long) sbuf.st_uid); + snprintf(n2, SIZEOF(n2), "%ld", (long) localuid); result = vstralloc(ptmp, ": ", "owned by id ", n1, ", should be ", n2, @@ -2165,7 +2096,12 @@ krb5_checkuser(host, name, realm) goto common_exit; } - while((line = agets(fp)) != NULL) { + while ((line = agets(fp)) != NULL) { + if (line[0] == '\0') { + amfree(line); + continue; + } + #if defined(SHOW_SECURITY_DETAIL) /* { */ k5printf(("%s: processing line: <%s>\n", debug_prefix(NULL), line)); #endif /* } */ @@ -2211,23 +2147,26 @@ krb5_checkuser(host, name, realm) continue; } result = NULL; + amfree(line); goto common_exit; } - amfree(line); } - result = vstralloc("no match in ", ptmp, NULL); common_exit: - if(fp) - afclose(fp); - if(line) - amfree(line); + afclose(fp); return(result); #endif /* AMANDA_PRINCIPAL */ } #else -void krb5_security_dummy (void) {} + +void krb5_security_dummy(void); + +void +krb5_security_dummy(void) +{ +} + #endif /* KRB5_SECURITY */ diff --git a/common-src/match.c b/common-src/match.c index fbe0c22..5ddc1da 100644 --- a/common-src/match.c +++ b/common-src/match.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: match.c,v 1.21 2005/10/11 01:17:00 vectro Exp $ + * $Id: match.c,v 1.23 2006/05/25 01:47:12 johnfranks Exp $ * * functions for checking and matching regular expressions */ @@ -32,8 +32,11 @@ #include "amanda.h" #include "regex.h" -char *validate_regexp(regex) -char *regex; +static int match_word(const char *glob, const char *word, const char separator); + +char * +validate_regexp( + const char * regex) { regex_t regc; int result; @@ -41,7 +44,7 @@ char *regex; if ((result = regcomp(®c, regex, REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) != 0) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); return errmsg; } @@ -50,8 +53,9 @@ char *regex; return NULL; } -char *clean_regex(regex) -char *regex; +char * +clean_regex( + const char * regex) { char *result; int j; @@ -63,12 +67,14 @@ char *regex; result[j++]='\\'; result[j++]=regex[i]; } - result[j++] = '\0'; + result[j] = '\0'; return result; } -int match(regex, str) -char *regex, *str; +int +match( + const char * regex, + const char * str) { regex_t regc; int result; @@ -76,14 +82,16 @@ char *regex, *str; if((result = regcomp(®c, regex, REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) != 0) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); error("regex \"%s\": %s", regex, errmsg); + /*NOTREACHED*/ } if((result = regexec(®c, str, 0, 0, 0)) != 0 && result != REG_NOMATCH) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); error("regex \"%s\": %s", regex, errmsg); + /*NOTREACHED*/ } regfree(®c); @@ -91,10 +99,11 @@ char *regex, *str; return result == 0; } -char *validate_glob(glob) -char *glob; +char * +validate_glob( + const char * glob) { - char *regex = NULL; + char *regex; regex_t regc; int result; static char errmsg[STR_SIZE]; @@ -102,7 +111,7 @@ char *glob; regex = glob_to_regex(glob); if ((result = regcomp(®c, regex, REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) != 0) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); amfree(regex); return errmsg; } @@ -113,10 +122,12 @@ char *glob; return NULL; } -int match_glob(glob, str) -char *glob, *str; +int +match_glob( + const char * glob, + const char * str) { - char *regex = NULL; + char *regex; regex_t regc; int result; char errmsg[STR_SIZE]; @@ -124,14 +135,16 @@ char *glob, *str; regex = glob_to_regex(glob); if((result = regcomp(®c, regex, REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) != 0) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); error("glob \"%s\" -> regex \"%s\": %s", glob, regex, errmsg); + /*NOTREACHED*/ } if((result = regexec(®c, str, 0, 0, 0)) != 0 && result != REG_NOMATCH) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); error("glob \"%s\" -> regex \"%s\": %s", glob, regex, errmsg); + /*NOTREACHED*/ } regfree(®c); @@ -140,8 +153,9 @@ char *glob, *str; return result == 0; } -char *glob_to_regex(glob) -char *glob; +char * +glob_to_regex( + const char * glob) { char *regex; char *r; @@ -178,12 +192,12 @@ char *glob; last_ch = '\0'; for (ch = *glob++; ch != '\0'; last_ch = ch, ch = *glob++) { if (last_ch == '\\') { - *r++ = ch; + *r++ = (char)ch; ch = '\0'; /* so last_ch != '\\' next time */ } else if (last_ch == '[' && ch == '!') { *r++ = '^'; } else if (ch == '\\') { - *r++ = ch; + *r++ = (char)ch; } else if (ch == '*' || ch == '?') { *r++ = '['; *r++ = '^'; @@ -202,9 +216,9 @@ char *glob; || ch == '$' || ch == '|') { *r++ = '\\'; - *r++ = ch; + *r++ = (char)ch; } else { - *r++ = ch; + *r++ = (char)ch; } } if (last_ch != '\\') { @@ -216,10 +230,12 @@ char *glob; } -int match_tar(glob, str) -char *glob, *str; +int +match_tar( + const char * glob, + const char * str) { - char *regex = NULL; + char *regex; regex_t regc; int result; char errmsg[STR_SIZE]; @@ -227,14 +243,16 @@ char *glob, *str; regex = tar_to_regex(glob); if((result = regcomp(®c, regex, REG_EXTENDED|REG_NOSUB|REG_NEWLINE)) != 0) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); error("glob \"%s\" -> regex \"%s\": %s", glob, regex, errmsg); + /*NOTREACHED*/ } if((result = regexec(®c, str, 0, 0, 0)) != 0 && result != REG_NOMATCH) { - regerror(result, ®c, errmsg, sizeof(errmsg)); + regerror(result, ®c, errmsg, SIZEOF(errmsg)); error("glob \"%s\" -> regex \"%s\": %s", glob, regex, errmsg); + /*NOTREACHED*/ } regfree(®c); @@ -243,8 +261,9 @@ char *glob, *str; return result == 0; } -char *tar_to_regex(glob) -char *glob; +char * +tar_to_regex( + const char * glob) { char *regex; char *r; @@ -281,12 +300,12 @@ char *glob; last_ch = '\0'; for (ch = *glob++; ch != '\0'; last_ch = ch, ch = *glob++) { if (last_ch == '\\') { - *r++ = ch; + *r++ = (char)ch; ch = '\0'; /* so last_ch != '\\' next time */ } else if (last_ch == '[' && ch == '!') { *r++ = '^'; } else if (ch == '\\') { - *r++ = ch; + *r++ = (char)ch; } else if (ch == '*') { *r++ = '.'; *r++ = '*'; @@ -305,9 +324,9 @@ char *glob; || ch == '$' || ch == '|') { *r++ = '\\'; - *r++ = ch; + *r++ = (char)ch; } else { - *r++ = ch; + *r++ = (char)ch; } } if (last_ch != '\\') { @@ -319,9 +338,11 @@ char *glob; } -int match_word(glob, word, separator) -char *glob, *word; -char separator; +static int +match_word( + const char * glob, + const char * word, + const char separator) { char *regex; char *r; @@ -332,7 +353,8 @@ char separator; size_t lenword; char *nword; char *nglob; - char *g, *w; + char *g; + const char *w; int i; lenword = strlen(word); @@ -410,12 +432,12 @@ char separator; for (ch = *g++; ch != '\0'; last_ch = ch, ch = *g++) { next_ch = *g; if (last_ch == '\\') { - *r++ = ch; + *r++ = (char)ch; ch = '\0'; /* so last_ch != '\\' next time */ } else if (last_ch == '[' && ch == '!') { *r++ = '^'; } else if (ch == '\\') { - *r++ = ch; + *r++ = (char)ch; } else if (ch == '*' || ch == '?') { if(ch == '*' && next_ch == '*') { *r++ = '.'; @@ -436,7 +458,7 @@ char separator; *r++ = '\\'; *r++ = separator; } - *r++ = ch; + *r++ = (char)ch; } else if ( ch == '(' || ch == ')' || ch == '{' @@ -447,9 +469,9 @@ char separator; || ch == '$' || ch == '|') { *r++ = '\\'; - *r++ = ch; + *r++ = (char)ch; } else { - *r++ = ch; + *r++ = (char)ch; } } if(last_ch != '\\') { @@ -470,51 +492,59 @@ char separator; } -int match_host(glob, host) -char *glob, *host; +int +match_host( + const char * glob, + const char * host) { char *lglob, *lhost; - char *c, *d; + char *c; + const char *d; int i; lglob = (char *)alloc(strlen(glob)+1); c = lglob, d=glob; while( *d != '\0') - *c++ = tolower(*d++); + *c++ = (char)tolower(*d++); *c = *d; lhost = (char *)alloc(strlen(host)+1); c = lhost, d=host; while( *d != '\0') - *c++ = tolower(*d++); + *c++ = (char)tolower(*d++); *c = *d; - i = match_word(lglob, lhost, '.'); + i = match_word(lglob, lhost, (int)'.'); amfree(lglob); amfree(lhost); return i; } -int match_disk(glob, disk) -char *glob, *disk; +int +match_disk( + const char * glob, + const char * disk) { return match_word(glob, disk, '/'); } -int match_datestamp(dateexp, datestamp) -char *dateexp, *datestamp; +int +match_datestamp( + const char * dateexp, + const char * datestamp) { char *dash; size_t len, len_suffix; - int len_prefix; + size_t len_prefix; char firstdate[100], lastdate[100]; char mydateexp[100]; int match_exact; if(strlen(dateexp) >= 100 || strlen(dateexp) < 1) { error("Illegal datestamp expression %s",dateexp); + /*NOTREACHED*/ } if(dateexp[0] == '^') { @@ -536,15 +566,12 @@ char *dateexp, *datestamp; if((dash = strchr(mydateexp,'-'))) { if(match_exact == 1) { error("Illegal datestamp expression %s",dateexp); + /*NOTREACHED*/ } - len = dash - mydateexp; + len = (size_t)(dash - mydateexp); len_suffix = strlen(dash) - 1; len_prefix = len - len_suffix; - if(len_prefix < 0) { - error("Illegal datestamp expression %s",dateexp); - } - dash++; strncpy(firstdate, mydateexp, len); firstdate[len] = '\0'; @@ -565,18 +592,21 @@ char *dateexp, *datestamp; } -int match_level(levelexp, level) -char *levelexp, *level; +int +match_level( + const char * levelexp, + const char * level) { char *dash; size_t len, len_suffix; - int len_prefix; + size_t len_prefix; char lowend[100], highend[100]; char mylevelexp[100]; int match_exact; if(strlen(levelexp) >= 100 || strlen(levelexp) < 1) { error("Illegal level expression %s",levelexp); + /*NOTREACHED*/ } if(levelexp[0] == '^') { @@ -598,15 +628,12 @@ char *levelexp, *level; if((dash = strchr(mylevelexp,'-'))) { if(match_exact == 1) { error("Illegal level expression %s",levelexp); + /*NOTREACHED*/ } - len = dash - mylevelexp; + len = (size_t)(dash - mylevelexp); len_suffix = strlen(dash) - 1; len_prefix = len - len_suffix; - if(len_prefix < 0) { - error("Illegal level expression %s",levelexp); - } - dash++; strncpy(lowend, mylevelexp, len); lowend[len] = '\0'; diff --git a/common-src/mktime.c b/common-src/mktime.c index 8aebb02..5d4373d 100644 --- a/common-src/mktime.c +++ b/common-src/mktime.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ /*static char *sccsid = "from: @(#)ctime.c 5.26 (Berkeley) 2/23/91";*/ -/*static char *rcsid = "$Id: mktime.c,v 1.4 1998/03/18 10:00:49 amcore Exp $";*/ +/*static char *rcsid = "$Id: mktime.c,v 1.5 2006/05/25 01:47:12 johnfranks Exp $";*/ /* * This implementation of mktime is lifted straight from the NetBSD (BSD 4.4) @@ -60,6 +60,8 @@ * by hand. Sorry about that. */ +#include "amanda.h" + #ifndef DSTMINUTES #define DSTMINUTES 60 #endif @@ -80,11 +82,6 @@ #define TM_YEAR_BASE 1900 #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) -#include -#include - -extern time_t time(); - static int mon_lengths[2][MONSPERYEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } diff --git a/common-src/packet.c b/common-src/packet.c index 32a2d31..7ebda61 100644 --- a/common-src/packet.c +++ b/common-src/packet.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: packet.c,v 1.6 2004/02/13 14:00:35 martinea Exp $ + * $Id: packet.c,v 1.8 2006/05/25 01:47:12 johnfranks Exp $ * * Routines for modifying the amanda protocol packet type */ @@ -45,7 +45,7 @@ static const struct { { "ACK", P_ACK }, { "NAK", P_NAK } }; -#define NPKTYPES (sizeof(pktypes) / sizeof(pktypes[0])) +#define NPKTYPES (int)(SIZEOF(pktypes) / SIZEOF(pktypes[0])) /* * Initialize a packet @@ -53,17 +53,24 @@ static const struct { printf_arglist_function2(void pkt_init, pkt_t *, pkt, pktype_t, type, const char *, fmt) { - va_list argp; + va_list argp; assert(pkt != NULL); assert(strcmp(pkt_type2str(type), "BOGUS") != 0); assert(fmt != NULL); pkt->type = type; - + pkt->packet_size = 1000; + pkt->body = alloc(pkt->packet_size); arglist_start(argp, fmt); - vsnprintf(pkt->body, sizeof(pkt->body), fmt, argp); + while (vsnprintf(pkt->body, pkt->packet_size, fmt, argp) >= + (int)(pkt->packet_size - 1)) { + pkt->packet_size *= 2; + amfree(pkt->body); + pkt->body = alloc(pkt->packet_size); + } arglist_end(argp); + pkt->size = strlen(pkt->body); } /* @@ -71,36 +78,43 @@ printf_arglist_function2(void pkt_init, pkt_t *, pkt, pktype_t, type, */ printf_arglist_function1(void pkt_cat, pkt_t *, pkt, const char *, fmt) { - size_t len, bufsize; - va_list argp; + size_t len; + va_list argp; + char * pktbody; assert(pkt != NULL); assert(fmt != NULL); len = strlen(pkt->body); - assert(len < sizeof(pkt->body)); - - bufsize = sizeof(pkt->body) - len; - if (bufsize <= 0) - return; arglist_start(argp, fmt); - vsnprintf(pkt->body + len, bufsize, fmt, argp); + while (vsnprintf(pkt->body + len, pkt->packet_size - len, fmt,argp) >= + (int)(pkt->packet_size - len - 1)) { + pkt->packet_size *= 2; + pktbody = alloc(pkt->packet_size); + strncpy(pktbody, pkt->body, len); + pktbody[len] = '\0'; + amfree(pkt->body); + pkt->body = pktbody; + arglist_end(argp); + arglist_start(argp, fmt); + } arglist_end(argp); + pkt->size = strlen(pkt->body); } /* * Converts a string into a packet type */ pktype_t -pkt_str2type(typestr) - const char *typestr; +pkt_str2type( + const char *typestr) { int i; assert(typestr != NULL); - for (i = 0; i < NPKTYPES; i++) + for (i = 0; i < (int)NPKTYPES; i++) if (strcmp(typestr, pktypes[i].name) == 0) return (pktypes[i].type); return ((pktype_t)-1); @@ -110,12 +124,12 @@ pkt_str2type(typestr) * Converts a packet type into a string */ const char * -pkt_type2str(type) - pktype_t type; +pkt_type2str( + pktype_t type) { int i; - for (i = 0; i < NPKTYPES; i++) + for (i = 0; i < (int)NPKTYPES; i++) if (pktypes[i].type == type) return (pktypes[i].name); return ("BOGUS"); diff --git a/common-src/packet.h b/common-src/packet.h index fb12626..f508b3f 100644 --- a/common-src/packet.h +++ b/common-src/packet.h @@ -24,40 +24,37 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: packet.h,v 1.6 2004/02/13 14:00:35 martinea Exp $ + * $Id: packet.h,v 1.8 2006/05/25 01:47:12 johnfranks Exp $ * * interfaces for modifying amanda protocol packet type */ #ifndef PACKET_H #define PACKET_H -/* - * We limit our body length to 50k. - */ -#define MAX_PACKET (50*1024) - typedef enum { P_REQ = 0, P_REP = 1, P_PREP = 2, P_ACK = 3, P_NAK = 4 } pktype_t; typedef struct { - pktype_t type; /* type of packet */ - char body[MAX_PACKET]; /* body of packet */ + pktype_t type; /* type of packet */ + char * body; /* body of packet */ + size_t size; + size_t packet_size; } pkt_t; /* * Initialize a packet */ -void pkt_init P((pkt_t *, pktype_t, const char *, ...)) +void pkt_init(pkt_t *, pktype_t, const char *, ...) __attribute__ ((format (printf, 3, 4))); /* * Append data to a packet */ -void pkt_cat P((pkt_t *, const char *, ...)) +void pkt_cat(pkt_t *, const char *, ...) __attribute__ ((format (printf, 2, 3))); /* * Convert the packet type to and from a string */ -const char *pkt_type2str P((pktype_t)); -pktype_t pkt_str2type P((const char *)); +const char *pkt_type2str(pktype_t); +pktype_t pkt_str2type(const char *); #endif /* PACKET_H */ diff --git a/common-src/pipespawn.c b/common-src/pipespawn.c index d960c97..a56a1d4 100644 --- a/common-src/pipespawn.c +++ b/common-src/pipespawn.c @@ -2,26 +2,31 @@ #include "pipespawn.h" #include "arglist.h" #include "clock.h" +#include "util.h" char skip_argument[1]; +pid_t pipespawnv_passwd(char *prog, int pipedef, + int *stdinfd, int *stdoutfd, int *stderrfd, + char **my_argv); + + /* * this used to be a function in it's own write but became a wrapper around * pipespawnv to eliminate redundancy... */ -#ifdef STDC_HEADERS -int pipespawn(char *prog, int pipedef, int *stdinfd, int *stdoutfd, - int *stderrfd, ...) -#else -int pipespawn(prog, pipedef, stdinfd, stdoutfd, stderrfd, va_alist) -char *prog; -int pipedef; -int *stdinfd, *stdoutfd, *stderrfd; -va_dcl -#endif +pid_t +pipespawn( + char * prog, + int pipedef, + int * stdinfd, + int * stdoutfd, + int * stderrfd, + ...) { va_list ap; - int argc = 0, pid, i; + int argc = 0, i; + pid_t pid; char **argv; /* count args */ @@ -35,7 +40,7 @@ va_dcl * Create the argument vector. */ arglist_start(ap, stderrfd); - argv = (char **)alloc((argc + 1) * sizeof(*argv)); + argv = (char **)alloc((argc + 1) * SIZEOF(*argv)); i = 0; while((argv[i] = arglist_val(ap, char *)) != NULL) { if (argv[i] != skip_argument) { @@ -44,37 +49,43 @@ va_dcl } arglist_end(ap); - pid = pipespawnv_passwd(prog, pipedef, stdinfd, stdoutfd, stderrfd, NULL, NULL, argv); + pid = pipespawnv_passwd(prog, pipedef, stdinfd, stdoutfd, stderrfd, argv); amfree(argv); return pid; } -int pipespawnv(prog, pipedef, stdinfd, stdoutfd, stderrfd, my_argv) -char *prog; -int pipedef; -int *stdinfd, *stdoutfd, *stderrfd; -char **my_argv; +pid_t +pipespawnv( + char * prog, + int pipedef, + int * stdinfd, + int * stdoutfd, + int * stderrfd, + char ** my_argv) { return pipespawnv_passwd(prog, pipedef, stdinfd, stdoutfd, stderrfd, - NULL, NULL, my_argv); + my_argv); } -int pipespawnv_passwd(prog, pipedef, stdinfd, stdoutfd, stderrfd, passwdvar, passwdfd, my_argv) -char *prog; -int pipedef; -int *stdinfd, *stdoutfd, *stderrfd; -char *passwdvar; -int *passwdfd; -char **my_argv; +pid_t +pipespawnv_passwd( + char * prog, + int pipedef, + int * stdinfd, + int * stdoutfd, + int * stderrfd, + char ** my_argv) { int argc; - int pid, i, inpipe[2], outpipe[2], errpipe[2], passwdpipe[2]; + pid_t pid; + int i, inpipe[2], outpipe[2], errpipe[2], passwdpipe[2]; char number[NUM_STR_SIZE]; char **arg; char *e; - int ch; char **env; char **newenv; + char *passwdvar = NULL; + int *passwdfd = NULL; /* * Log the command line and count the args. @@ -83,22 +94,21 @@ char **my_argv; dbprintf(("%s: argument list:", debug_prefix(NULL))); if ((pipedef & PASSWD_PIPE) != 0) { passwdvar = *my_argv++; - passwdfd = (int *)*my_argv++; + passwdfd = (int *)*my_argv++; } + memset(inpipe, -1, SIZEOF(inpipe)); + memset(outpipe, -1, SIZEOF(outpipe)); + memset(errpipe, -1, SIZEOF(errpipe)); + memset(passwdpipe, -1, SIZEOF(passwdpipe)); argc = 0; for(arg = my_argv; *arg != NULL; arg++) { - if (*arg == skip_argument) { - continue; - } - argc++; - dbprintf((" ")); - for(i = 0; (ch = (*arg)[i]) != '\0' && isprint(ch) && ch != ' '; i++) {} - if(ch != '\0' || i == 0) { - dbprintf(("\"")); - } - dbprintf(("%s", *arg)); - if(ch != '\0' || i == 0) { - dbprintf(("\"")); + char *quoted; + + if (*arg != skip_argument) { + argc++; + quoted = quote_string(*arg); + dbprintf((" %s", quoted)); + amfree(quoted); } } dbprintf(("\n")); @@ -109,21 +119,25 @@ char **my_argv; if ((pipedef & STDIN_PIPE) != 0) { if(pipe(inpipe) == -1) { error("error [open pipe to %s: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } } if ((pipedef & STDOUT_PIPE) != 0) { if(pipe(outpipe) == -1) { error("error [open pipe to %s: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } } if ((pipedef & STDERR_PIPE) != 0) { if(pipe(errpipe) == -1) { error("error [open pipe to %s: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } } if ((pipedef & PASSWD_PIPE) != 0) { if(pipe(passwdpipe) == -1) { error("error [open pipe to %s: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } } @@ -134,6 +148,8 @@ char **my_argv; case -1: e = strerror(errno); error("error [fork %s: %s]", prog, e); + /*NOTREACHED*/ + default: /* parent process */ if ((pipedef & STDIN_PIPE) != 0) { aclose(inpipe[0]); /* close input side of pipe */ @@ -177,12 +193,15 @@ char **my_argv; */ if(dup2(inpipe[0], 0) == -1) { error("error [spawn %s: dup2 in: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } if(dup2(outpipe[1], 1) == -1) { error("error [spawn %s: dup2 out: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } if(dup2(errpipe[1], 2) == -1) { error("error [spawn %s: dup2 err: %s]", prog, strerror(errno)); + /*NOTREACHED*/ } /* @@ -191,11 +210,14 @@ char **my_argv; */ env = safe_env(); if ((pipedef & PASSWD_PIPE) != 0) { - for(i = 0; env[i] != NULL; i++) {} - newenv = (char **)alloc((i + 1 + 1) * sizeof(*newenv)); - snprintf(number, sizeof(number), "%d", passwdpipe[0]); + for (i = 0; env[i] != NULL; i++) + (void)i; /* make lint happy and do nothing */ + newenv = (char **)alloc((i + 1 + 1) * SIZEOF(*newenv)); + snprintf(number, SIZEOF(number), "%d", passwdpipe[0]); newenv[0] = vstralloc(passwdvar, "=", number, NULL); - for(i = 0; (newenv[i + 1] = env[i]) != NULL; i++) {} + for(i = 0; env[i] != NULL; i++) + newenv[i + 1] = env[i]; + newenv[i + 1] = NULL; amfree(env); env = newenv; } @@ -203,7 +225,7 @@ char **my_argv; execve(prog, my_argv, env); e = strerror(errno); error("error [exec %s: %s]", prog, e); - /* NOTREACHED */ + /*NOTREACHED*/ } return pid; } diff --git a/common-src/pipespawn.h b/common-src/pipespawn.h index 4a8a9e9..8b81f58 100644 --- a/common-src/pipespawn.h +++ b/common-src/pipespawn.h @@ -12,16 +12,11 @@ extern char skip_argument[1]; #define STDERR_PIPE (1 << 2) #define PASSWD_PIPE (1 << 3) -int pipespawn P((char *prog, int pipedef, +pid_t pipespawn(char *prog, int pipedef, int *stdinfd, int *stdoutfd, int *stderrfd, - ...)); -int pipespawnv P((char *prog, int pipedef, + ...); +pid_t pipespawnv(char *prog, int pipedef, int *stdinfd, int *stdoutfd, int *stderrfd, - char **my_argv)); -int pipespawnv_passwd P((char *prog, int pipedef, - int *stdinfd, int *stdoutfd, int *stderrfd, - char *passwdvar, int *passwdfd, - char **my_argv)); - + char **my_argv); #endif /* PIPESPAWN_H */ diff --git a/common-src/protocol.c b/common-src/protocol.c index 4274e70..c997f3c 100644 --- a/common-src/protocol.c +++ b/common-src/protocol.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: protocol.c,v 1.39 2006/02/28 16:36:13 martinea Exp $ + * $Id: protocol.c,v 1.45 2006/05/25 17:07:31 martinea Exp $ * * implements amanda protocol */ @@ -40,16 +40,23 @@ * Valid actions that can be passed to the state machine */ typedef enum { - A_START, A_TIMEOUT, A_ERROR, A_RCVDATA, A_CONTPEND, A_PENDING, - A_CONTINUE, A_FINISH, A_ABORT -} action_t; + PA_START, + PA_TIMEOUT, + PA_ERROR, + PA_RCVDATA, + PA_CONTPEND, + PA_PENDING, + PA_CONTINUE, + PA_FINISH, + PA_ABORT +} p_action_t; /* * The current state type. States are represented as function * vectors. */ struct proto; -typedef action_t (*pstate_t) P((struct proto *, action_t, pkt_t *)); +typedef p_action_t (*pstate_t)(struct proto *, p_action_t, pkt_t *); /* * This is a request structure that is wrapped around a packet while it @@ -71,7 +78,7 @@ typedef struct proto { pkt_t req; /* the actual wire request */ protocol_sendreq_callback continuation; /* call when req dies/finishes */ void *datap; /* opaque cookie passed to above */ - char *(*conf_fn) P((char *, void *));/* configuration function */ + char *(*conf_fn)(char *, void *); /* configuration function */ } proto_t; #define CONNECT_TRIES 3 /* num retries after connect errors */ @@ -85,7 +92,7 @@ typedef struct proto { #define DROP_DEAD_TIME(t) (CURTIME - (t) > (60 * 60)) /* get the size of an array */ -#define ASIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#define ASIZE(arr) (int)(sizeof(arr) / sizeof((arr)[0])) /* * Initialization time @@ -95,19 +102,18 @@ static time_t proto_init_time; /* local functions */ #ifdef PROTO_DEBUG -static const char *action2str P((action_t)); -static const char *pstate2str P((pstate_t)); +static const char *action2str(p_action_t); +static const char *pstate2str(pstate_t); #endif -static void connect_callback P((void *, security_handle_t *, - security_status_t)); -static void connect_wait_callback P((void *)); -static void recvpkt_callback P((void *, pkt_t *, security_status_t)); +static void connect_callback(void *, security_handle_t *, security_status_t); +static void connect_wait_callback(void *); +static void recvpkt_callback(void *, pkt_t *, security_status_t); -static action_t s_sendreq P((proto_t *, action_t, pkt_t *)); -static action_t s_ackwait P((proto_t *, action_t, pkt_t *)); -static action_t s_repwait P((proto_t *, action_t, pkt_t *)); -static void state_machine P((proto_t *, action_t, pkt_t *)); +static p_action_t s_sendreq(proto_t *, p_action_t, pkt_t *); +static p_action_t s_ackwait(proto_t *, p_action_t, pkt_t *); +static p_action_t s_repwait(proto_t *, p_action_t, pkt_t *); +static void state_machine(proto_t *, p_action_t, pkt_t *); /* * ------------------- @@ -118,7 +124,7 @@ static void state_machine P((proto_t *, action_t, pkt_t *)); * Initialize globals. */ void -protocol_init() +protocol_init(void) { proto_init_time = time(NULL); @@ -129,18 +135,18 @@ protocol_init() * for transmission. */ void -protocol_sendreq(hostname, security_driver, conf_fn, req, repwait, continuation, datap) - const char *hostname; - const security_driver_t *security_driver; - char *(*conf_fn) P((char *, void *)); - const char *req; - time_t repwait; - protocol_sendreq_callback continuation; - void *datap; +protocol_sendreq( + const char * hostname, + const security_driver_t * security_driver, + char * (*conf_fn)(char *, void *), + const char * req, + time_t repwait, + protocol_sendreq_callback continuation, + void * datap) { proto_t *p; - p = alloc(sizeof(proto_t)); + p = alloc(SIZEOF(proto_t)); p->state = s_sendreq; p->hostname = stralloc(hostname); p->security_driver = security_driver; @@ -164,11 +170,12 @@ protocol_sendreq(hostname, security_driver, conf_fn, req, repwait, continuation, p->datap = datap; #ifdef PROTO_DEBUG - dbprintf(("%s: security_connect: host %s -> p %X\n", - debug_prefix_time(": protocol"), hostname, (int)p)); + dbprintf(("%s: security_connect: host %s -> p %p\n", + debug_prefix_time(": protocol"), hostname, p)); #endif - security_connect(p->security_driver, p->hostname, conf_fn, connect_callback, p); + security_connect(p->security_driver, p->hostname, conf_fn, connect_callback, + p, p->datap); } /* @@ -180,10 +187,10 @@ protocol_sendreq(hostname, security_driver, conf_fn, req, repwait, continuation, * be had via security_geterror on the handle. */ static void -connect_callback(cookie, security_handle, status) - void *cookie; - security_handle_t *security_handle; - security_status_t status; +connect_callback( + void * cookie, + security_handle_t * security_handle, + security_status_t status) { proto_t *p = cookie; @@ -191,13 +198,13 @@ connect_callback(cookie, security_handle, status) p->security_handle = security_handle; #ifdef PROTO_DEBUG - dbprintf(("%s: connect_callback: p %X\n", - debug_prefix_time(": protocol"), (int)p)); + dbprintf(("%s: connect_callback: p %p\n", + debug_prefix_time(": protocol"), p)); #endif switch (status) { case S_OK: - state_machine(p, A_START, NULL); + state_machine(p, PA_START, NULL); break; case S_TIMEOUT: @@ -211,11 +218,11 @@ connect_callback(cookie, security_handle, status) * an error back to the caller. */ if (--p->connecttries == 0) { - state_machine(p, A_ABORT, NULL); + state_machine(p, PA_ABORT, NULL); } else { #ifdef PROTO_DEBUG - dbprintf(("%s: connect_callback: p %X: retrying %s\n", - debug_prefix_time(": protocol"), (int)p, p->hostname)); + dbprintf(("%s: connect_callback: p %p: retrying %s\n", + debug_prefix_time(": protocol"), p, p->hostname)); #endif security_close(p->security_handle); /* XXX overload p->security handle to hold the event handle */ @@ -236,14 +243,14 @@ connect_callback(cookie, security_handle, status) * initial connection attempts failed. */ static void -connect_wait_callback(cookie) - void *cookie; +connect_wait_callback( + void * cookie) { proto_t *p = cookie; event_release((event_handle_t *)p->security_handle); security_connect(p->security_driver, p->hostname, p->conf_fn, - connect_callback, p); + connect_callback, p, p->datap); } @@ -256,7 +263,7 @@ connect_wait_callback(cookie) * requests if they plan on doing a lot of work. */ void -protocol_check() +protocol_check(void) { /* arg == 1 means don't block */ @@ -272,7 +279,7 @@ protocol_check() * and are just waiting for all of the answers to come back. */ void -protocol_run() +protocol_run(void) { /* arg == 0 means block forever until no more events are left */ @@ -291,29 +298,29 @@ protocol_run() * with timeouts and successfull replies. */ static void -state_machine(p, action, pkt) - proto_t *p; - action_t action; - pkt_t *pkt; +state_machine( + proto_t * p, + p_action_t action, + pkt_t * pkt) { pstate_t curstate; - action_t retaction; + p_action_t retaction; #ifdef PROTO_DEBUG - dbprintf(("%s: state_machine: initial: p %X action %s pkt %X\n", + dbprintf(("%s: state_machine: initial: p %p action %s pkt %p\n", debug_prefix_time(": protocol"), - (int)p, action2str(action), NULL)); + p, action2str(action), NULL)); #endif assert(p != NULL); - assert(action == A_RCVDATA || pkt == NULL); + assert(action == PA_RCVDATA || pkt == NULL); assert(p->state != NULL); for (;;) { #ifdef PROTO_DEBUG - dbprintf(("%s: state_machine: p %X state %s action %s\n", + dbprintf(("%s: state_machine: p %p state %s action %s\n", debug_prefix_time(": protocol"), - (int)p, pstate2str(p->state), action2str(action))); + p, pstate2str(p->state), action2str(action))); if (pkt != NULL) { dbprintf(("%s: pkt: %s (t %d) orig REQ (t %d cur %d)\n", debug_prefix(": protocol"), @@ -329,17 +336,17 @@ state_machine(p, action, pkt) * is in. * * We keep track of the last state we were in so we can make - * sure states which return A_CONTINUE really have transitioned + * sure states which return PA_CONTINUE really have transitioned * the request to a new state. */ curstate = p->state; - if (action == A_ABORT) + if (action == PA_ABORT) /* * If the passed action indicates a terminal error, then we * need to move to abort right away. */ - retaction = A_ABORT; + retaction = PA_ABORT; else /* * Else we run the state and perform the action it @@ -348,14 +355,14 @@ state_machine(p, action, pkt) retaction = (*curstate)(p, action, pkt); #ifdef PROTO_DEBUG - dbprintf(("%s: state_machine: p %X state %s returned %s\n", + dbprintf(("%s: state_machine: p %p state %s returned %s\n", debug_prefix_time(": protocol"), - (int)p, pstate2str(p->state), action2str(retaction))); + p, pstate2str(p->state), action2str(retaction))); #endif /* * The state function is expected to return one of the following - * action_t's. + * p_action_t's. */ switch (retaction) { @@ -364,15 +371,15 @@ state_machine(p, action, pkt) * Setup to receive another pkt, and wait for the recv event * to occur. */ - case A_CONTPEND: + case PA_CONTPEND: (*p->continuation)(p->datap, pkt, p->security_handle); /* FALLTHROUGH */ - case A_PENDING: + case PA_PENDING: #ifdef PROTO_DEBUG - dbprintf(("%s: state_machine: p %X state %s: timeout %d\n", + dbprintf(("%s: state_machine: p %p state %s: timeout %d\n", debug_prefix_time(": protocol"), - (int)p, pstate2str(p->state), (int)p->timeout)); + p, pstate2str(p->state), (int)p->timeout)); #endif /* * Get the security layer to register a receive event for this @@ -380,19 +387,19 @@ state_machine(p, action, pkt) * seconds. */ security_recvpkt(p->security_handle, recvpkt_callback, p, - p->timeout); + (int)p->timeout); return; /* * Request has moved to another state. Loop and run it again. */ - case A_CONTINUE: + case PA_CONTINUE: assert(p->state != curstate); #ifdef PROTO_DEBUG - dbprintf(("%s: state_machine: p %X: moved from %s to %s\n", + dbprintf(("%s: state_machine: p %p: moved from %s to %s\n", debug_prefix_time(": protocol"), - (unsigned int)p, pstate2str(curstate), + p, pstate2str(curstate), pstate2str(p->state))); #endif continue; @@ -403,10 +410,10 @@ state_machine(p, action, pkt) * pkt to NULL to indicate failure to the callback, and then * fall through to the common finish code. * - * Note that remote failures finish via A_FINISH, because they did + * Note that remote failures finish via PA_FINISH, because they did * complete successfully locally. */ - case A_ABORT: + case PA_ABORT: pkt = NULL; /* FALLTHROUGH */ @@ -415,10 +422,11 @@ state_machine(p, action, pkt) * Free up resources the request has used, call the continuation * function specified by the caller and quit. */ - case A_FINISH: + case PA_FINISH: (*p->continuation)(p->datap, pkt, p->security_handle); security_close(p->security_handle); amfree(p->hostname); + amfree(p->req.body); amfree(p); return; @@ -426,9 +434,9 @@ state_machine(p, action, pkt) assert(0); break; /* in case asserts are turned off */ } - /* NOTREACHED */ + /*NOTREACHED*/ } - /* NOTREACHED */ + /*NOTREACHED*/ } /* @@ -437,20 +445,22 @@ state_machine(p, action, pkt) * moves to the acknowledgement wait state. We return from the state * machine at this point, and let the request be received from the network. */ -static action_t -s_sendreq(p, action, pkt) - proto_t *p; - action_t action; - pkt_t *pkt; +static p_action_t +s_sendreq( + proto_t * p, + p_action_t action, + pkt_t * pkt) { assert(p != NULL); + (void)action; /* Quiet unused parameter warning */ + (void)pkt; /* Quiet unused parameter warning */ if (security_sendpkt(p->security_handle, &p->req) < 0) { /* XXX should retry */ security_seterror(p->security_handle, "error sending REQ: %s", security_geterror(p->security_handle)); - return (A_ABORT); + return (PA_ABORT); } /* @@ -463,27 +473,27 @@ s_sendreq(p, action, pkt) */ p->state = s_ackwait; p->timeout = ACK_WAIT; - return (A_PENDING); + return (PA_PENDING); } /* * The acknowledge wait state. We can enter here two ways: * * - the caller has received a packet, located the request for - * that packet, and called us with an action of A_RCVDATA. + * that packet, and called us with an action of PA_RCVDATA. * * - the caller has determined that a request has timed out, - * and has called us with A_TIMEOUT. + * and has called us with PA_TIMEOUT. * * Here we process the acknowledgment, which usually means that * the client has agreed to our request and is working on it. * It will later send a reply when finished. */ -static action_t -s_ackwait(p, action, pkt) - proto_t *p; - action_t action; - pkt_t *pkt; +static p_action_t +s_ackwait( + proto_t * p, + p_action_t action, + pkt_t * pkt) { assert(p != NULL); @@ -493,19 +503,19 @@ s_ackwait(p, action, pkt) * fail this request. Otherwise, move to the send state * to retry the request. */ - if (action == A_TIMEOUT) { + if (action == PA_TIMEOUT) { assert(pkt == NULL); if (--p->acktries == 0) { security_seterror(p->security_handle, "timeout waiting for ACK"); - return (A_ABORT); + return (PA_ABORT); } p->state = s_sendreq; - return (A_CONTINUE); + return (PA_CONTINUE); } - assert(action == A_RCVDATA); + assert(action == PA_RCVDATA); assert(pkt != NULL); /* @@ -522,16 +532,16 @@ s_ackwait(p, action, pkt) case P_ACK: p->state = s_repwait; p->timeout = p->repwait; - return (A_PENDING); + return (PA_PENDING); /* * Received a NAK. The request failed, so free up the * resources associated with it and return. * - * This should NOT return A_ABORT because it is not a local failure. + * This should NOT return PA_ABORT because it is not a local failure. */ case P_NAK: - return (A_FINISH); + return (PA_FINISH); /* * The client skipped the ACK, and replied right away. @@ -540,32 +550,32 @@ s_ackwait(p, action, pkt) case P_REP: case P_PREP: p->state = s_repwait; - return (A_CONTINUE); + return (PA_CONTINUE); /* * Unexpected packet. Requeue this request and hope * we get what we want later. */ default: - return (A_PENDING); + return (PA_PENDING); } } /* * The reply wait state. We enter here much like we do with s_ackwait. */ -static action_t -s_repwait(p, action, pkt) - proto_t *p; - action_t action; - pkt_t *pkt; +static p_action_t +s_repwait( + proto_t * p, + p_action_t action, + pkt_t * pkt) { pkt_t ack; /* * Timeout waiting for a reply. */ - if (action == A_TIMEOUT) { + if (action == PA_TIMEOUT) { assert(pkt == NULL); /* @@ -574,7 +584,7 @@ s_repwait(p, action, pkt) */ if (p->reqtries == 0 || DROP_DEAD_TIME(p->origtime)) { security_seterror(p->security_handle, "timeout waiting for REP"); - return (A_ABORT); + return (PA_ABORT); } /* @@ -583,10 +593,10 @@ s_repwait(p, action, pkt) p->reqtries--; p->state = s_sendreq; p->acktries = ACK_TRIES; - return (A_CONTINUE); + return (PA_CONTINUE); } - assert(action == A_RCVDATA); + assert(action == PA_RCVDATA); /* * We've received some data. If we didn't get a reply, @@ -594,35 +604,37 @@ s_repwait(p, action, pkt) * the reply, cleanup this packet, and return. */ if (pkt->type != P_REP && pkt->type != P_PREP) - return (A_PENDING); + return (PA_PENDING); if(pkt->type == P_REP) { pkt_init(&ack, P_ACK, ""); if (security_sendpkt(p->security_handle, &ack) < 0) { /* XXX should retry */ + amfree(ack.body); security_seterror(p->security_handle, "error sending ACK: %s", security_geterror(p->security_handle)); - return (A_ABORT); + return (PA_ABORT); } - return (A_FINISH); + amfree(ack.body); + return (PA_FINISH); } else if(pkt->type == P_PREP) { p->timeout = p->repwait - CURTIME + p->curtime + 1; - return (A_CONTPEND); + return (PA_CONTPEND); } /* should never go here, shut up compiler warning */ - return (A_FINISH); + return (PA_FINISH); } /* * event callback that receives a packet */ static void -recvpkt_callback(cookie, pkt, status) - void *cookie; - pkt_t *pkt; - security_status_t status; +recvpkt_callback( + void * cookie, + pkt_t * pkt, + security_status_t status) { proto_t *p = cookie; @@ -630,13 +642,13 @@ recvpkt_callback(cookie, pkt, status) switch (status) { case S_OK: - state_machine(p, A_RCVDATA, pkt); + state_machine(p, PA_RCVDATA, pkt); break; case S_TIMEOUT: - state_machine(p, A_TIMEOUT, NULL); + state_machine(p, PA_TIMEOUT, NULL); break; case S_ERROR: - state_machine(p, A_ABORT, NULL); + state_machine(p, PA_ABORT, NULL); break; default: assert(0); @@ -654,8 +666,8 @@ recvpkt_callback(cookie, pkt, status) * Convert a pstate_t into a printable form. */ static const char * -pstate2str(pstate) - pstate_t pstate; +pstate2str( + pstate_t pstate) { static const struct { pstate_t type; @@ -676,26 +688,26 @@ pstate2str(pstate) } /* - * Convert an action_t into a printable form + * Convert an p_action_t into a printable form */ static const char * -action2str(action) - action_t action; +action2str( + p_action_t action) { static const struct { - action_t type; + p_action_t type; const char name[12]; } actions[] = { #define X(s) { s, stringize(s) } - X(A_START), - X(A_TIMEOUT), - X(A_ERROR), - X(A_RCVDATA), - X(A_CONTPEND), - X(A_PENDING), - X(A_CONTINUE), - X(A_FINISH), - X(A_ABORT), + X(PA_START), + X(PA_TIMEOUT), + X(PA_ERROR), + X(PA_RCVDATA), + X(PA_CONTPEND), + X(PA_PENDING), + X(PA_CONTINUE), + X(PA_FINISH), + X(PA_ABORT), #undef X }; int i; diff --git a/common-src/protocol.h b/common-src/protocol.h index d4116a9..215d35b 100644 --- a/common-src/protocol.h +++ b/common-src/protocol.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: protocol.h,v 1.10 2003/04/26 02:02:18 kovert Exp $ + * $Id: protocol.h,v 1.11 2006/05/25 01:47:12 johnfranks Exp $ * * server-side interfaces for amanda protocol state machine */ @@ -33,14 +33,13 @@ #include "security.h" -void protocol_init P((void)); -typedef void (*protocol_sendreq_callback) P((void *, pkt_t *, - security_handle_t *)); -void protocol_sendreq P((const char *, const security_driver_t *, - char *(*) P((char *, void *)), - const char *, - time_t, protocol_sendreq_callback, void *)); -void protocol_check P((void)); -void protocol_run P((void)); +void protocol_init(void); +typedef void (*protocol_sendreq_callback)(void *, pkt_t *, + security_handle_t *); +void protocol_sendreq(const char *, const security_driver_t *, + char *(*)(char *, void *), const char *, time_t, + protocol_sendreq_callback, void *); +void protocol_check(void); +void protocol_run(void); #endif /* PROTOCOL_H */ diff --git a/common-src/regcomp.c b/common-src/regcomp.c index fbdc7b1..01a86da 100644 --- a/common-src/regcomp.c +++ b/common-src/regcomp.c @@ -23,10 +23,11 @@ * Authors: the Amanda Development Team. Its members are listed in a * file named AUTHORS, in the root directory of this distribution. */ -/* $Id: regcomp.c,v 1.3 1998/07/04 00:18:51 oliva Exp $ +/* $Id: regcomp.c,v 1.4 2006/05/25 01:47:12 johnfranks Exp $ * * wrapper file for Henry Spencer's regcomp.c */ +#include "amanda.h" #include "amregex.h" #include "../regex-src/regcomp.c" diff --git a/common-src/rsh-security.c b/common-src/rsh-security.c index c24e329..9761f81 100644 --- a/common-src/rsh-security.c +++ b/common-src/rsh-security.c @@ -25,7 +25,7 @@ */ /* - * $Id: rsh-security.c,v 1.18.2.1 2006/04/11 11:11:16 martinea Exp $ + * $Id: rsh-security.c,v 1.31 2006/08/21 20:17:10 martinea Exp $ * * rsh-security.c - security and transport over rsh or a rsh-like command. * @@ -34,10 +34,12 @@ */ #include "amanda.h" +#include "util.h" #include "event.h" #include "packet.h" #include "queue.h" #include "security.h" +#include "security-util.h" #include "stream.h" #include "version.h" @@ -59,7 +61,7 @@ /* * Arguments to rsh. This should also be configurable */ -#define RSH_ARGS "-l", CLIENT_LOGIN +/*#define RSH_ARGS */ /* * Number of seconds rsh has to start up @@ -72,85 +74,12 @@ #define H_TAKEN -1 /* rsh_conn->tok was already read */ #define H_EOF -2 /* this connection has been shut down */ -/* - * This is a rsh connection to a host. We should only have - * one connection per host. - */ -struct rsh_conn { - int read, write; /* pipes to rsh */ - pid_t pid; /* pid of rsh process */ - char pkt[NETWORK_BLOCK_BYTES]; /* last pkt read */ - unsigned long pktlen; /* len of above */ - struct { /* buffer read() calls */ - char buf[STREAM_BUFSIZE]; /* buffer */ - size_t left; /* unread data */ - ssize_t size; /* size of last read */ - } readbuf; - event_handle_t *ev_read; /* read (EV_READFD) handle */ - int ev_read_refcnt; /* number of readers */ - char hostname[MAX_HOSTNAME_LENGTH+1]; /* host we're talking to */ - char *errmsg; /* error passed up */ - int refcnt; /* number of handles using */ - int handle; /* last proto handle read */ - TAILQ_ENTRY(rsh_conn) tq; /* queue handle */ -}; - - -struct rsh_stream; - -/* - * This is the private handle data. - */ -struct rsh_handle { - security_handle_t sech; /* MUST be first */ - char *hostname; /* ptr to rc->hostname */ - struct rsh_stream *rs; /* virtual stream we xmit over */ - - union { - void (*recvpkt) P((void *, pkt_t *, security_status_t)); - /* func to call when packet recvd */ - void (*connect) P((void *, security_handle_t *, security_status_t)); - /* func to call when connected */ - } fn; - void *arg; /* argument to pass function */ - event_handle_t *ev_timeout; /* timeout handle for recv */ -}; - -/* - * This is the internal security_stream data for rsh. - */ -struct rsh_stream { - security_stream_t secstr; /* MUST be first */ - struct rsh_conn *rc; /* physical connection */ - int handle; /* protocol handle */ - event_handle_t *ev_read; /* read (EV_WAIT) event handle */ - void (*fn) P((void *, void *, ssize_t)); /* read event fn */ - void *arg; /* arg for previous */ -}; - /* * Interface functions */ -static int rsh_sendpkt P((void *, pkt_t *)); -static int rsh_stream_accept P((void *)); -static int rsh_stream_auth P((void *)); -static int rsh_stream_id P((void *)); -static int rsh_stream_write P((void *, const void *, size_t)); -static void *rsh_stream_client P((void *, int)); -static void *rsh_stream_server P((void *)); -static void rsh_accept P((int, int, - void (*)(security_handle_t *, pkt_t *))); -static void rsh_close P((void *)); -static void rsh_connect P((const char *, - char *(*)(char *, void *), - void (*)(void *, security_handle_t *, security_status_t), void *)); -static void rsh_recvpkt P((void *, - void (*)(void *, pkt_t *, security_status_t), void *, int)); -static void rsh_recvpkt_cancel P((void *)); -static void rsh_stream_close P((void *)); -static void rsh_stream_read P((void *, void (*)(void *, void *, ssize_t), - void *)); -static void rsh_stream_read_cancel P((void *)); +static void rsh_connect(const char *, char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), + void *, void *); /* * This is our interface to the outside world. @@ -158,73 +87,30 @@ static void rsh_stream_read_cancel P((void *)); const security_driver_t rsh_security_driver = { "RSH", rsh_connect, - rsh_accept, - rsh_close, - rsh_sendpkt, - rsh_recvpkt, - rsh_recvpkt_cancel, - rsh_stream_server, - rsh_stream_accept, - rsh_stream_client, - rsh_stream_close, - rsh_stream_auth, - rsh_stream_id, - rsh_stream_write, - rsh_stream_read, - rsh_stream_read_cancel, -}; - -/* - * This is a queue of open connections - */ -static struct { - TAILQ_HEAD(, rsh_conn) tailq; - int qlength; -} connq = { - TAILQ_HEAD_INITIALIZER(connq.tailq), 0 + sec_accept, + sec_close, + stream_sendpkt, + stream_recvpkt, + stream_recvpkt_cancel, + tcpma_stream_server, + tcpma_stream_accept, + tcpma_stream_client, + tcpma_stream_close, + sec_stream_auth, + sec_stream_id, + tcpm_stream_write, + tcpm_stream_read, + tcpm_stream_read_sync, + tcpm_stream_read_cancel, + tcpm_close_connection, }; -#define connq_first() TAILQ_FIRST(&connq.tailq) -#define connq_next(rc) TAILQ_NEXT(rc, tq) -#define connq_append(rc) do { \ - TAILQ_INSERT_TAIL(&connq.tailq, rc, tq); \ - connq.qlength++; \ -} while (0) -#define connq_remove(rc) do { \ - assert(connq.qlength > 0); \ - TAILQ_REMOVE(&connq.tailq, rc, tq); \ - connq.qlength--; \ -} while (0) static int newhandle = 1; -/* - * This is a function that should be called if a new security_handle_t is - * created. If NULL, no new handles are created. - * It is passed the new handle and the received pkt - */ -static void (*accept_fn) P((security_handle_t *, pkt_t *)); - /* * Local functions */ -static void connect_callback P((void *)); -static void connect_timeout P((void *)); -static int send_token P((struct rsh_conn *, int, const void *, size_t)); -static int recv_token P((struct rsh_conn *, int)); -static void recvpkt_callback P((void *, void *, ssize_t)); -static void recvpkt_timeout P((void *)); -static void stream_read_callback P((void *)); - -static int runrsh P((struct rsh_conn *)); -static struct rsh_conn *conn_get P((const char *)); -static void conn_put P((struct rsh_conn *)); -static void conn_read P((struct rsh_conn *)); -static void conn_read_cancel P((struct rsh_conn *)); -static void conn_read_callback P((void *)); -static int net_writev P((int, struct iovec *, int)); -static ssize_t net_read P((struct rsh_conn *, void *, size_t, int)); -static int net_read_fillbuf P((struct rsh_conn *, int, int)); -static void parse_pkt P((pkt_t *, const void *, size_t)); +static int runrsh(struct tcp_conn *, const char *, const char *); /* @@ -232,21 +118,24 @@ static void parse_pkt P((pkt_t *, const void *, size_t)); * up a network "connection". */ static void -rsh_connect(hostname, conf_fn, fn, arg) - const char *hostname; - char *(*conf_fn) P((char *, void *)); - void (*fn) P((void *, security_handle_t *, security_status_t)); - void *arg; -{ - struct rsh_handle *rh; +rsh_connect( + const char * hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) +{ + struct sec_handle *rh; struct hostent *he; + char *amandad_path=NULL, *client_username=NULL; assert(fn != NULL); assert(hostname != NULL); - rshprintf(("rsh_connect: %s\n", hostname)); + rshprintf(("%s: rsh: rsh_connect: %s\n", debug_prefix_time(NULL), + hostname)); - rh = alloc(sizeof(*rh)); + rh = alloc(SIZEOF(*rh)); security_handleinit(&rh->sech, &rsh_security_driver); rh->hostname = NULL; rh->rs = NULL; @@ -258,26 +147,33 @@ rsh_connect(hostname, conf_fn, fn, arg) (*fn)(arg, &rh->sech, S_ERROR); return; } - rh->hostname = he->h_name; /* will be replaced */ - rh->rs = rsh_stream_client(rh, newhandle++); + rh->hostname = stralloc(he->h_name); /* will be replaced */ + rh->rs = tcpma_stream_client(rh, newhandle++); if (rh->rs == NULL) goto error; - rh->hostname = rh->rs->rc->hostname; + amfree(rh->hostname); + rh->hostname = stralloc(rh->rs->rc->hostname); - if (rh->rs->rc->pid < 0) { - /* - * We need to open a new connection. - * - * XXX need to eventually limit number of outgoing connections here. - */ - if (runrsh(rh->rs->rc) < 0) { - security_seterror(&rh->sech, - "can't connect to %s: %s", hostname, rh->rs->rc->errmsg); + /* + * We need to open a new connection. + * + * XXX need to eventually limit number of outgoing connections here. + */ + if(conf_fn) { + amandad_path = conf_fn("amandad_path", datap); + client_username = conf_fn("client_username", datap); + } + if(rh->rc->read == -1) { + if (runrsh(rh->rs->rc, amandad_path, client_username) < 0) { + security_seterror(&rh->sech, "can't connect to %s: %s", + hostname, rh->rs->rc->errmsg); goto error; } + rh->rc->refcnt++; } + /* * The socket will be opened async so hosts that are down won't * block everything. We need to register a write event @@ -288,10 +184,10 @@ rsh_connect(hostname, conf_fn, fn, arg) */ rh->fn.connect = fn; rh->arg = arg; - rh->rs->ev_read = event_register(rh->rs->rc->write, EV_WRITEFD, - connect_callback, rh); - rh->ev_timeout = event_register(CONNECT_TIMEOUT, EV_TIME, - connect_timeout, rh); + rh->rs->ev_read = event_register((event_id_t)rh->rs->rc->write, EV_WRITEFD, + sec_connect_callback, rh); + rh->ev_timeout = event_register((event_id_t)CONNECT_TIMEOUT, EV_TIME, + sec_connect_timeout, rh); return; @@ -299,213 +195,30 @@ error: (*fn)(arg, &rh->sech, S_ERROR); } -/* - * Called when a rsh connection is finished connecting and is ready - * to be authenticated. - */ -static void -connect_callback(cookie) - void *cookie; -{ - struct rsh_handle *rh = cookie; - - event_release(rh->rs->ev_read); - rh->rs->ev_read = NULL; - event_release(rh->ev_timeout); - rh->ev_timeout = NULL; - - (*rh->fn.connect)(rh->arg, &rh->sech, S_OK); -} - -/* - * Called if a connection times out before completion. - */ -static void -connect_timeout(cookie) - void *cookie; -{ - struct rsh_handle *rh = cookie; - - event_release(rh->rs->ev_read); - rh->rs->ev_read = NULL; - event_release(rh->ev_timeout); - rh->ev_timeout = NULL; - - (*rh->fn.connect)(rh->arg, &rh->sech, S_TIMEOUT); -} - -/* - * Setup to handle new incoming connections - */ -static void -rsh_accept(in, out, fn) - int in, out; - void (*fn) P((security_handle_t *, pkt_t *)); -{ - struct rsh_conn *rc; - - rc = conn_get("unknown"); - rc->read = in; - rc->write = out; - accept_fn = fn; - conn_read(rc); -} - -/* - * Locate an existing connection to the given host, or create a new, - * unconnected entry if none exists. The caller is expected to check - * for the lack of a connection (rc->read == -1) and set one up. - */ -static struct rsh_conn * -conn_get(hostname) - const char *hostname; -{ - struct rsh_conn *rc; - - rshprintf(("rsh: conn_get: %s\n", hostname)); - - for (rc = connq_first(); rc != NULL; rc = connq_next(rc)) { - if (strcasecmp(hostname, rc->hostname) == 0) - break; - } - - if (rc != NULL) { - rc->refcnt++; - rshprintf(("rsh: conn_get: exists, refcnt to %s is now %d\n", - rc->hostname, rc->refcnt)); - return (rc); - } - - rshprintf(("rsh: conn_get: creating new handle\n")); - /* - * We can't be creating a new handle if we are the client - */ - assert(accept_fn == NULL); - rc = alloc(sizeof(*rc)); - rc->read = rc->write = -1; - rc->pid = -1; - rc->readbuf.left = 0; - rc->readbuf.size = 0; - rc->ev_read = NULL; - strncpy(rc->hostname, hostname, sizeof(rc->hostname) - 1); - rc->hostname[sizeof(rc->hostname) - 1] = '\0'; - rc->errmsg = NULL; - rc->refcnt = 1; - rc->handle = -1; - connq_append(rc); - return (rc); -} - -/* - * Delete a reference to a connection, and close it if it is the last - * reference. - */ -static void -conn_put(rc) - struct rsh_conn *rc; -{ - amwait_t status; - - assert(rc->refcnt > 0); - if (--rc->refcnt > 0) { - rshprintf(("rsh: conn_put: decrementing refcnt for %s to %d\n", - rc->hostname, rc->refcnt)); - return; - } - rshprintf(("rsh: conn_put: closing connection to %s\n", rc->hostname)); - if (rc->read != -1) - aclose(rc->read); - if (rc->write != -1) - aclose(rc->write); - if (rc->pid != -1) { - waitpid(rc->pid, &status, WNOHANG); - } - if (rc->ev_read != NULL) - event_release(rc->ev_read); - if (rc->errmsg != NULL) - amfree(rc->errmsg); - connq_remove(rc); - amfree(rc); -} - -/* - * Turn on read events for a conn. Or, increase a refcnt if we are - * already receiving read events. - */ -static void -conn_read(rc) - struct rsh_conn *rc; -{ - - if (rc->ev_read != NULL) { - rc->ev_read_refcnt++; - rshprintf(("rsh: conn_read: incremented refcnt to %d for %s\n", - rc->ev_read_refcnt, rc->hostname)); - return; - } - rshprintf(("rsh: conn_read registering event handler for %s\n", - rc->hostname)); - rc->ev_read = event_register(rc->read, EV_READFD, conn_read_callback, rc); - rc->ev_read_refcnt = 1; -} - -static void -conn_read_cancel(rc) - struct rsh_conn *rc; -{ - - if (--rc->ev_read_refcnt > 0) { - rshprintf(("rsh: conn_read_cancel: decremented refcnt to %d for %s\n", - rc->ev_read_refcnt, rc->hostname)); - return; - } - rshprintf(("rsh: conn_read_cancel: releasing event handler for %s\n", - rc->hostname)); - event_release(rc->ev_read); - rc->ev_read = NULL; -} - -/* - * frees a handle allocated by the above - */ -static void -rsh_close(inst) - void *inst; -{ - struct rsh_handle *rh = inst; - - assert(rh != NULL); - - rshprintf(("rsh: closing handle to %s\n", rh->hostname)); - - if (rh->rs != NULL) { - /* This may be null if we get here on an error */ - rsh_recvpkt_cancel(rh); - security_stream_close(&rh->rs->secstr); - } - /* keep us from getting here again */ - rh->sech.driver = NULL; - amfree(rh); -} - /* * Forks a rsh to the host listed in rc->hostname * Returns negative on error, with an errmsg in rc->errmsg. */ static int -runrsh(rc) - struct rsh_conn *rc; +runrsh( + struct tcp_conn * rc, + const char * amandad_path, + const char * client_username) { int rpipe[2], wpipe[2]; - char *amandad_path; + char *xamandad_path = (char *)amandad_path; + char *xclient_username = (char *)client_username; + memset(rpipe, -1, SIZEOF(rpipe)); + memset(wpipe, -1, SIZEOF(wpipe)); if (pipe(rpipe) < 0 || pipe(wpipe) < 0) { - rc->errmsg = newvstralloc("pipe: ", strerror(errno), NULL); + rc->errmsg = newvstralloc(rc->errmsg, "pipe: ", strerror(errno), NULL); return (-1); } + switch (rc->pid = fork()) { case -1: - rc->errmsg = newvstralloc("fork: ", strerror(errno), NULL); + rc->errmsg = newvstralloc(rc->errmsg, "fork: ", strerror(errno), NULL); aclose(rpipe[0]); aclose(rpipe[1]); aclose(wpipe[0]); @@ -514,7 +227,6 @@ runrsh(rc) case 0: dup2(wpipe[0], 0); dup2(rpipe[1], 1); - dup2(rpipe[1], 2); break; default: rc->read = rpipe[0]; @@ -526,693 +238,19 @@ runrsh(rc) safe_fd(-1, 0); - amandad_path = vstralloc(libexecdir, "/", "amandad", versionsuffix(), - NULL); - execlp(RSH_PATH, RSH_PATH, RSH_ARGS, rc->hostname, amandad_path, - "-auth=rsh", NULL); + if(!xamandad_path || strlen(xamandad_path) <= 1) + xamandad_path = vstralloc(libexecdir, "/", "amandad", + versionsuffix(), NULL); + if(!xclient_username || strlen(xclient_username) <= 1) + xclient_username = CLIENT_LOGIN; + + execlp(RSH_PATH, RSH_PATH, "-l", xclient_username, + rc->hostname, xamandad_path, "-auth=rsh", "amdump", "amindexd", + "amidxtaped", (char *)NULL); error("error: couldn't exec %s: %s", RSH_PATH, strerror(errno)); - /* should nerver go here, shut up compiler warning */ + /* should never go here, shut up compiler warning */ return(-1); } -/* - * Transmit a packet. - */ -static int -rsh_sendpkt(cookie, pkt) - void *cookie; - pkt_t *pkt; -{ - char buf[sizeof(pkt_t)]; - struct rsh_handle *rh = cookie; - size_t len; - - assert(rh != NULL); - assert(pkt != NULL); - - rshprintf(("rsh: sendpkt: enter\n")); - - len = strlen(pkt->body) + 2; - buf[0] = (char)pkt->type; - strcpy(&buf[1], pkt->body); - - rshprintf(("rsh: sendpkt: %s (%d) pkt_t (len %d) contains:\n\n\"%s\"\n\n", - pkt_type2str(pkt->type), pkt->type, strlen(pkt->body), pkt->body)); - - if (rsh_stream_write(rh->rs, buf, len) < 0) { - security_seterror(&rh->sech, security_stream_geterror(&rh->rs->secstr)); - return (-1); - } - return (0); -} - -/* - * Set up to receive a packet asyncronously, and call back when - * it has been read. - */ -static void -rsh_recvpkt(cookie, fn, arg, timeout) - void *cookie, *arg; - void (*fn) P((void *, pkt_t *, security_status_t)); - int timeout; -{ - struct rsh_handle *rh = cookie; - - assert(rh != NULL); - - rshprintf(("rsh: recvpkt registered for %s\n", rh->hostname)); - - /* - * Reset any pending timeout on this handle - */ - if (rh->ev_timeout != NULL) - event_release(rh->ev_timeout); - - /* - * Negative timeouts mean no timeout - */ - if (timeout < 0) - rh->ev_timeout = NULL; - else - rh->ev_timeout = event_register(timeout, EV_TIME, recvpkt_timeout, rh); - - rh->fn.recvpkt = fn; - rh->arg = arg; - rsh_stream_read(rh->rs, recvpkt_callback, rh); -} - -/* - * Remove a async receive request from the queue - */ -static void -rsh_recvpkt_cancel(cookie) - void *cookie; -{ - struct rsh_handle *rh = cookie; - - rshprintf(("rsh: cancelling recvpkt for %s\n", rh->hostname)); - - assert(rh != NULL); - - rsh_stream_read_cancel(rh->rs); - if (rh->ev_timeout != NULL) { - event_release(rh->ev_timeout); - rh->ev_timeout = NULL; - } -} - -/* - * This is called when a handle is woken up because data read off of the - * net is for it. - */ -static void -recvpkt_callback(cookie, buf, bufsize) - void *cookie, *buf; - ssize_t bufsize; -{ - pkt_t pkt; - struct rsh_handle *rh = cookie; - - assert(rh != NULL); - - /* - * We need to cancel the recvpkt request before calling - * the callback because the callback may reschedule us. - */ - rsh_recvpkt_cancel(rh); - - switch (bufsize) { - case 0: - security_seterror(&rh->sech, - "EOF on read from %s", rh->hostname); - (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); - return; - case -1: - security_seterror(&rh->sech, security_stream_geterror(&rh->rs->secstr)); - (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); - return; - default: - break; - } - - parse_pkt(&pkt, buf, bufsize); - rshprintf(("rsh: received %s packet (%d) from %s, contains:\n\n\"%s\"\n\n", - pkt_type2str(pkt.type), pkt.type, rh->hostname, pkt.body)); - (*rh->fn.recvpkt)(rh->arg, &pkt, S_OK); -} - -/* - * This is called when a handle times out before receiving a packet. - */ -static void -recvpkt_timeout(cookie) - void *cookie; -{ - struct rsh_handle *rh = cookie; - - assert(rh != NULL); - - rshprintf(("rsh: recvpkt timeout for %s\n", rh->hostname)); - - rsh_recvpkt_cancel(rh); - (*rh->fn.recvpkt)(rh->arg, NULL, S_TIMEOUT); -} - -/* - * Create the server end of a stream. For rsh, this means setup a stream - * object and allocate a new handle for it. - */ -static void * -rsh_stream_server(h) - void *h; -{ - struct rsh_handle *rh = h; - struct rsh_stream *rs; - - assert(rh != NULL); - - rs = alloc(sizeof(*rs)); - security_streaminit(&rs->secstr, &rsh_security_driver); - rs->rc = conn_get(rh->hostname); - /* - * Stream should already be setup! - */ - if (rs->rc->read < 0) { - conn_put(rs->rc); - amfree(rs); - security_seterror(&rh->sech, "lost connection to %s", rh->hostname); - return (NULL); - } - rh->hostname = rs->rc->hostname; - /* - * so as not to conflict with the amanda server's handle numbers, - * we start at 5000 and work down - */ - rs->handle = 5000 - newhandle++; - rs->ev_read = NULL; - rshprintf(("rsh: stream_server: created stream %d\n", rs->handle)); - return (rs); -} - -/* - * Accept an incoming connection on a stream_server socket - * Nothing needed for rsh. - */ -static int -rsh_stream_accept(s) - void *s; -{ - - return (0); -} - -/* - * Return a connected stream. For rsh, this means setup a stream - * with the supplied handle. - */ -static void * -rsh_stream_client(h, id) - void *h; - int id; -{ - struct rsh_handle *rh = h; - struct rsh_stream *rs; - - assert(rh != NULL); - - if (id <= 0) { - security_seterror(&rh->sech, - "%d: invalid security stream id", id); - return (NULL); - } - - rs = alloc(sizeof(*rs)); - security_streaminit(&rs->secstr, &rsh_security_driver); - rs->handle = id; - rs->ev_read = NULL; - rs->rc = conn_get(rh->hostname); - - rshprintf(("rsh: stream_client: connected to stream %d\n", id)); - - return (rs); -} - -/* - * Close and unallocate resources for a stream. - */ -static void -rsh_stream_close(s) - void *s; -{ - struct rsh_stream *rs = s; - - assert(rs != NULL); - - rshprintf(("rsh: stream_close: closing stream %d\n", rs->handle)); - - rsh_stream_read_cancel(rs); - conn_put(rs->rc); - amfree(rs); -} - -/* - * Authenticate a stream - * Nothing needed for rsh. The connection is authenticated by rshd - * on startup. - */ -static int -rsh_stream_auth(s) - void *s; -{ - - return (0); -} - -/* - * Returns the stream id for this stream. This is just the local - * port. - */ -static int -rsh_stream_id(s) - void *s; -{ - struct rsh_stream *rs = s; - - assert(rs != NULL); - - return (rs->handle); -} - -/* - * Write a chunk of data to a stream. Blocks until completion. - */ -static int -rsh_stream_write(s, buf, size) - void *s; - const void *buf; - size_t size; -{ - struct rsh_stream *rs = s; - - assert(rs != NULL); - - rshprintf(("rsh: stream_write: writing %d bytes to %s:%d\n", size, - rs->rc->hostname, rs->handle)); - - if (send_token(rs->rc, rs->handle, buf, size) < 0) { - security_stream_seterror(&rs->secstr, rs->rc->errmsg); - return (-1); - } - return (0); -} - -/* - * Submit a request to read some data. Calls back with the given - * function and arg when completed. - */ -static void -rsh_stream_read(s, fn, arg) - void *s, *arg; - void (*fn) P((void *, void *, ssize_t)); -{ - struct rsh_stream *rs = s; - - assert(rs != NULL); - - /* - * Only one read request can be active per stream. - */ - if (rs->ev_read == NULL) { - rs->ev_read = event_register((event_id_t)rs->rc, EV_WAIT, - stream_read_callback, rs); - conn_read(rs->rc); - } - rs->fn = fn; - rs->arg = arg; -} - -/* - * Cancel a previous stream read request. It's ok if we didn't have a read - * scheduled. - */ -static void -rsh_stream_read_cancel(s) - void *s; -{ - struct rsh_stream *rs = s; - - assert(rs != NULL); - - if (rs->ev_read != NULL) { - event_release(rs->ev_read); - rs->ev_read = NULL; - conn_read_cancel(rs->rc); - } -} - -/* - * Callback for rsh_stream_read - */ -static void -stream_read_callback(arg) - void *arg; -{ - struct rsh_stream *rs = arg; - assert(rs != NULL); - - rshprintf(("rsh: stream_read_callback: handle %d\n", rs->handle)); - - /* - * Make sure this was for us. If it was, then blow away the handle - * so it doesn't get claimed twice. Otherwise, leave it alone. - * - * If the handle is EOF, pass that up to our callback. - */ - if (rs->rc->handle == rs->handle) { - rshprintf(("rsh: stream_read_callback: it was for us\n")); - rs->rc->handle = H_TAKEN; - } else if (rs->rc->handle != H_EOF) { - rshprintf(("rsh: stream_read_callback: not for us\n")); - return; - } - - /* - * Remove the event first, and then call the callback. - * We remove it first because we don't want to get in their - * way if they reschedule it. - */ - rsh_stream_read_cancel(rs); - - if (rs->rc->pktlen == 0) { - rshprintf(("rsh: stream_read_callback: EOF\n")); - (*rs->fn)(rs->arg, NULL, 0); - return; - } - rshprintf(("rsh: stream_read_callback: read %ld bytes from %s:%d\n", - rs->rc->pktlen, rs->rc->hostname, rs->handle)); - (*rs->fn)(rs->arg, rs->rc->pkt, rs->rc->pktlen); -} - -/* - * The callback for the netfd for the event handler - * Determines if this packet is for this security handle, - * and does the real callback if so. - */ -static void -conn_read_callback(cookie) - void *cookie; -{ - struct rsh_conn *rc = cookie; - struct rsh_handle *rh; - pkt_t pkt; - int rval; - - assert(cookie != NULL); - - rshprintf(("rsh: conn_read_callback\n")); - - /* Read the data off the wire. If we get errors, shut down. */ - rval = recv_token(rc, 60); - rshprintf(("rsh: conn_read_callback: recv_token returned %d\n", rval)); - if (rval <= 0) { - rc->pktlen = 0; - rc->handle = H_EOF; - rval = event_wakeup((event_id_t)rc); - rshprintf(("rsh: conn_read_callback: event_wakeup return %d\n", rval)); - /* delete our 'accept' reference */ - if (accept_fn != NULL) - conn_put(rc); - accept_fn = NULL; - return; - } - - /* If there are events waiting on this handle, we're done */ - rval = event_wakeup((event_id_t)rc); - rshprintf(("rsh: conn_read_callback: event_wakeup return %d\n", rval)); - if (rval > 0) - return; - - /* If there is no accept fn registered, then drop the packet */ - if (accept_fn == NULL) - return; - - rh = alloc(sizeof(*rh)); - security_handleinit(&rh->sech, &rsh_security_driver); - rh->hostname = rc->hostname; - rh->rs = rsh_stream_client(rh, rc->handle); - rh->ev_timeout = NULL; - - rshprintf(("rsh: new connection\n")); - parse_pkt(&pkt, rc->pkt, rc->pktlen); - rshprintf(("rsh: calling accept_fn\n")); - (*accept_fn)(&rh->sech, &pkt); -} - -static void -parse_pkt(pkt, buf, bufsize) - pkt_t *pkt; - const void *buf; - size_t bufsize; -{ - const unsigned char *bufp = buf; - - rshprintf(("rsh: parse_pkt: parsing buffer of %d bytes\n", bufsize)); - - pkt->type = (pktype_t)*bufp++; - bufsize--; - - if (bufsize == 0) { - pkt->body[0] = '\0'; - } else { - if (bufsize > sizeof(pkt->body) - 1) - bufsize = sizeof(pkt->body) - 1; - memcpy(pkt->body, bufp, bufsize); - pkt->body[sizeof(pkt->body) - 1] = '\0'; - } - - rshprintf(("rsh: parse_pkt: %s (%d): \"%s\"\n", pkt_type2str(pkt->type), - pkt->type, pkt->body)); -} - - -/* - * Transmits a chunk of data over a rsh_handle, adding - * the necessary headers to allow the remote end to decode it. - */ -static int -send_token(rc, handle, buf, len) - struct rsh_conn *rc; - int handle; - const void *buf; - size_t len; -{ - unsigned int netlength, nethandle; - struct iovec iov[3]; - - rshprintf(("rsh: send_token: writing %d bytes to %s\n", len, - rc->hostname)); - - assert(sizeof(netlength) == 4); - - /* - * Format is: - * 32 bit length (network byte order) - * 32 bit handle (network byte order) - * data - */ - netlength = htonl(len); - iov[0].iov_base = (void *)&netlength; - iov[0].iov_len = sizeof(netlength); - - nethandle = htonl(handle); - iov[1].iov_base = (void *)&nethandle; - iov[1].iov_len = sizeof(nethandle); - - iov[2].iov_base = (void *)buf; - iov[2].iov_len = len; - - if (net_writev(rc->write, iov, 3) < 0) { - rc->errmsg = newvstralloc(rc->errmsg, "rsh write error to ", - rc->hostname, ": ", strerror(errno), NULL); - return (-1); - } - return (0); -} - -static int -recv_token(rc, timeout) - struct rsh_conn *rc; - int timeout; -{ - unsigned int netint; - - assert(sizeof(netint) == 4); - - assert(rc->read >= 0); - - rshprintf(("rsh: recv_token: reading from %s\n", rc->hostname)); - - switch (net_read(rc, &netint, sizeof(netint), timeout)) { - case -1: - rc->errmsg = newvstralloc(rc->errmsg, "recv error: ", strerror(errno), - NULL); - return (-1); - case 0: - rc->pktlen = 0; - return (0); - default: - break; - } - rc->pktlen = ntohl(netint); - if (rc->pktlen > sizeof(rc->pkt)) { - rc->errmsg = newstralloc(rc->errmsg, "recv error: huge packet"); - return (-1); - } - - switch (net_read(rc, &netint, sizeof(netint), timeout)) { - case -1: - rc->errmsg = newvstralloc(rc->errmsg, "recv error: ", strerror(errno), - NULL); - return (-1); - case 0: - rc->pktlen = 0; - return (0); - default: - break; - } - rc->handle = ntohl(netint); - - switch (net_read(rc, rc->pkt, rc->pktlen, timeout)) { - case -1: - rc->errmsg = newvstralloc(rc->errmsg, "recv error: ", strerror(errno), - NULL); - return (-1); - case 0: - rc->pktlen = 0; - break; - default: - break; - } - - rshprintf(("rsh: recv_token: read %ld bytes from %s\n", rc->pktlen, - rc->hostname)); - return (rc->pktlen); -} - -/* - * Writes out the entire iovec - */ -static int -net_writev(fd, iov, iovcnt) - int fd, iovcnt; - struct iovec *iov; -{ - int delta, n, total; - - assert(iov != NULL); - - total = 0; - while (iovcnt > 0) { - /* - * Write the iovec - */ - total += n = writev(fd, iov, iovcnt); - if (n < 0) - return (-1); - if (n == 0) { - errno = EIO; - return (-1); - } - /* - * Iterate through each iov. Figure out what we still need - * to write out. - */ - for (; n > 0; iovcnt--, iov++) { - /* 'delta' is the bytes written from this iovec */ - delta = n < iov->iov_len ? n : iov->iov_len; - /* subtract from the total num bytes written */ - n -= delta; - assert(n >= 0); - /* subtract from this iovec */ - iov->iov_len -= delta; - iov->iov_base = (char *)iov->iov_base + delta; - /* if this iovec isn't empty, run the writev again */ - if (iov->iov_len > 0) - break; - } - } - return (total); -} - -/* - * Like read(), but waits until the entire buffer has been filled. - */ -static ssize_t -net_read(rc, vbuf, origsize, timeout) - struct rsh_conn *rc; - void *vbuf; - size_t origsize; - int timeout; -{ - char *buf = vbuf, *off; /* ptr arith */ - int nread; - size_t size = origsize; - - while (size > 0) { - if (rc->readbuf.left == 0) { - if (net_read_fillbuf(rc, timeout, size) < 0) - return (-1); - if (rc->readbuf.size == 0) - return (0); - } - nread = min(rc->readbuf.left, size); - off = rc->readbuf.buf + rc->readbuf.size - rc->readbuf.left; - memcpy(buf, off, nread); - - buf += nread; - size -= nread; - rc->readbuf.left -= nread; - } - return ((ssize_t)origsize); -} - -/* - * net_read likes to do a lot of little reads. Buffer it. - */ -static int -net_read_fillbuf(rc, timeout, size) - struct rsh_conn *rc; - int timeout; - int size; -{ - fd_set readfds; - struct timeval tv; - if(size > sizeof(rc->readbuf.buf)) size = sizeof(rc->readbuf.buf); - - FD_ZERO(&readfds); - FD_SET(rc->read, &readfds); - tv.tv_sec = timeout; - tv.tv_usec = 0; - switch (select(rc->read + 1, &readfds, NULL, NULL, &tv)) { - case 0: - errno = ETIMEDOUT; - /* FALLTHROUGH */ - case -1: - return (-1); - case 1: - assert(FD_ISSET(rc->read, &readfds)); - break; - default: - assert(0); - break; - } - rc->readbuf.left = 0; - rc->readbuf.size = read(rc->read, rc->readbuf.buf, size); - if (rc->readbuf.size < 0) - return (-1); - rc->readbuf.left = rc->readbuf.size; - return (0); -} - #endif /* RSH_SECURITY */ diff --git a/common-src/security-util.c b/common-src/security-util.c new file mode 100644 index 0000000..531ec86 --- /dev/null +++ b/common-src/security-util.c @@ -0,0 +1,2630 @@ +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1999 University of Maryland + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ + +/* + * $Id: security-util.c,v 1.25 2006/07/22 12:04:47 martinea Exp $ + * + * sec-security.c - security and transport over sec or a sec-like command. + * + * XXX still need to check for initial keyword on connect so we can skip + * over shell garbage and other stuff that sec might want to spew out. + */ + +#include "amanda.h" +#include "util.h" +#include "event.h" +#include "packet.h" +#include "queue.h" +#include "security.h" +#include "security-util.h" +#include "stream.h" +#include "version.h" + +/* #define SEC_DEBUG */ +#define SHOW_SECURITY_DETAIL + +#ifdef SEC_DEBUG +# define secprintf(x) dbprintf(x) +#else +# ifdef __lint +# define secprintf(x) (void)(x) +# else +# define secprintf(x) +# endif +#endif + +/* + * Magic values for sec_conn->handle + */ +#define H_TAKEN -1 /* sec_conn->tok was already read */ +#define H_EOF -2 /* this connection has been shut down */ + +/* + * This is a queue of open connections + */ +struct connq_s connq = { + TAILQ_HEAD_INITIALIZER(connq.tailq), 0 +}; +static int newhandle = 1; +static int newevent = 1; + +/* + * Local functions + */ +static void recvpkt_callback(void *, void *, ssize_t); +static void stream_read_callback(void *); +static void stream_read_sync_callback(void *); + +static void sec_tcp_conn_read_cancel(struct tcp_conn *); +static void sec_tcp_conn_read_callback(void *); + + +/* + * Authenticate a stream + * Nothing needed for sec. The connection is authenticated by secd + * on startup. + */ +int +sec_stream_auth( + void * s) +{ + (void)s; /* Quiet unused parameter warning */ + return (0); +} + +/* + * Returns the stream id for this stream. This is just the local + * port. + */ +int +sec_stream_id( + void * s) +{ + struct sec_stream *rs = s; + + assert(rs != NULL); + + return (rs->handle); +} + +/* + * Setup to handle new incoming connections + */ +void +sec_accept( + const security_driver_t *driver, + int in, + int out, + void (*fn)(security_handle_t *, pkt_t *)) +{ + struct tcp_conn *rc; + + rc = sec_tcp_conn_get("unknown",0); + rc->read = in; + rc->write = out; + rc->accept_fn = fn; + rc->driver = driver; + sec_tcp_conn_read(rc); +} + +/* + * frees a handle allocated by the above + */ +void +sec_close( + void * inst) +{ + struct sec_handle *rh = inst; + + assert(rh != NULL); + + secprintf(("%s: sec: closing handle to %s\n", debug_prefix_time(NULL), + rh->hostname)); + + if (rh->rs != NULL) { + /* This may be null if we get here on an error */ + stream_recvpkt_cancel(rh); + security_stream_close(&rh->rs->secstr); + } + /* keep us from getting here again */ + rh->sech.driver = NULL; + amfree(rh->hostname); + amfree(rh); +} + +/* + * Called when a sec connection is finished connecting and is ready + * to be authenticated. + */ +void +sec_connect_callback( + void * cookie) +{ + struct sec_handle *rh = cookie; + + event_release(rh->rs->ev_read); + rh->rs->ev_read = NULL; + event_release(rh->ev_timeout); + rh->ev_timeout = NULL; + + (*rh->fn.connect)(rh->arg, &rh->sech, S_OK); +} + +/* + * Called if a connection times out before completion. + */ +void +sec_connect_timeout( + void * cookie) +{ + struct sec_handle *rh = cookie; + + event_release(rh->rs->ev_read); + rh->rs->ev_read = NULL; + event_release(rh->ev_timeout); + rh->ev_timeout = NULL; + + (*rh->fn.connect)(rh->arg, &rh->sech, S_TIMEOUT); +} + +void +sec_close_connection_none( + void *h, + char *hostname) +{ + h = h; + hostname = hostname; + + return; +} + + + +/* + * Transmit a packet. + */ +ssize_t +stream_sendpkt( + void * cookie, + pkt_t * pkt) +{ + char *buf; + struct sec_handle *rh = cookie; + size_t len; + char *s; + + assert(rh != NULL); + assert(pkt != NULL); + + secprintf(("%s: sec: stream_sendpkt: enter\n", debug_prefix_time(NULL))); + + if (rh->rc->prefix_packet) + s = rh->rc->prefix_packet(rh, pkt); + else + s = ""; + len = strlen(pkt->body) + strlen(s) + 2; + buf = alloc(len); + buf[0] = (char)pkt->type; + strncpy(&buf[1], s, len - 1); + strncpy(&buf[1 + strlen(s)], pkt->body, (len - strlen(s) - 1)); + if (strlen(s) > 0) + amfree(s); + + secprintf(( + "%s: sec: stream_sendpkt: %s (%d) pkt_t (len %d) contains:\n\n\"%s\"\n\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->type, + strlen(pkt->body), pkt->body)); + + if (security_stream_write(&rh->rs->secstr, buf, len) < 0) { + security_seterror(&rh->sech, security_stream_geterror(&rh->rs->secstr)); + return (-1); + } + amfree(buf); + return (0); +} + +/* + * Set up to receive a packet asyncronously, and call back when + * it has been read. + */ +void +stream_recvpkt( + void * cookie, + void (*fn)(void *, pkt_t *, security_status_t), + void * arg, + int timeout) +{ + struct sec_handle *rh = cookie; + + assert(rh != NULL); + + secprintf(("%s: sec: recvpkt registered for %s\n", + debug_prefix_time(NULL), rh->hostname)); + + /* + * Reset any pending timeout on this handle + */ + if (rh->ev_timeout != NULL) + event_release(rh->ev_timeout); + + /* + * Negative timeouts mean no timeout + */ + if (timeout < 0) { + rh->ev_timeout = NULL; + } else { + rh->ev_timeout = event_register((event_id_t)timeout, EV_TIME, + stream_recvpkt_timeout, rh); + } + rh->fn.recvpkt = fn; + rh->arg = arg; + security_stream_read(&rh->rs->secstr, recvpkt_callback, rh); +} + +/* + * This is called when a handle times out before receiving a packet. + */ +void +stream_recvpkt_timeout( + void * cookie) +{ + struct sec_handle *rh = cookie; + + assert(rh != NULL); + + secprintf(("%s: sec: recvpkt timeout for %s\n", + debug_prefix_time(NULL), rh->hostname)); + + stream_recvpkt_cancel(rh); + (*rh->fn.recvpkt)(rh->arg, NULL, S_TIMEOUT); +} + +/* + * Remove a async receive request from the queue + */ +void +stream_recvpkt_cancel( + void * cookie) +{ + struct sec_handle *rh = cookie; + + secprintf(("%s: sec: cancelling recvpkt for %s\n", + debug_prefix_time(NULL), rh->hostname)); + + assert(rh != NULL); + + security_stream_read_cancel(&rh->rs->secstr); + if (rh->ev_timeout != NULL) { + event_release(rh->ev_timeout); + rh->ev_timeout = NULL; + } +} + +/* + * Write a chunk of data to a stream. Blocks until completion. + */ +int +tcpm_stream_write( + void * s, + const void *buf, + size_t size) +{ + struct sec_stream *rs = s; + + assert(rs != NULL); + assert(rs->rc != NULL); + + secprintf(("%s: sec: stream_write: writing %d bytes to %s:%d %d\n", + debug_prefix_time(NULL), size, rs->rc->hostname, rs->handle, + rs->rc->write)); + + if (tcpm_send_token(rs->rc->write, rs->handle, &rs->rc->errmsg, + buf, size)) { + security_stream_seterror(&rs->secstr, rs->rc->errmsg); + return (-1); + } + return (0); +} + +/* + * Submit a request to read some data. Calls back with the given + * function and arg when completed. + */ +void +tcpm_stream_read( + void * s, + void (*fn)(void *, void *, ssize_t), + void * arg) +{ + struct sec_stream *rs = s; + + assert(rs != NULL); + + /* + * Only one read request can be active per stream. + */ + if (rs->ev_read == NULL) { + rs->ev_read = event_register((event_id_t)rs->rc, EV_WAIT, + stream_read_callback, rs); + sec_tcp_conn_read(rs->rc); + } + rs->fn = fn; + rs->arg = arg; +} + +/* + * Write a chunk of data to a stream. Blocks until completion. + */ +ssize_t +tcpm_stream_read_sync( + void * s, + void ** buf) +{ + struct sec_stream *rs = s; + + assert(rs != NULL); + + /* + * Only one read request can be active per stream. + */ + if (rs->ev_read != NULL) { + return -1; + } + rs->ev_read = event_register((event_id_t)rs->rc, EV_WAIT, + stream_read_sync_callback, rs); + sec_tcp_conn_read(rs->rc); + event_wait(rs->ev_read); + *buf = rs->rc->pkt; + return (rs->rc->pktlen); +} + +/* + * Cancel a previous stream read request. It's ok if we didn't have a read + * scheduled. + */ +void +tcpm_stream_read_cancel( + void * s) +{ + struct sec_stream *rs = s; + + assert(rs != NULL); + + if (rs->ev_read != NULL) { + event_release(rs->ev_read); + rs->ev_read = NULL; + sec_tcp_conn_read_cancel(rs->rc); + } +} + +/* + * Transmits a chunk of data over a rsh_handle, adding + * the necessary headers to allow the remote end to decode it. + */ +ssize_t +tcpm_send_token( + int fd, + int handle, + char ** errmsg, + const void *buf, + size_t len) +{ + uint32_t nethandle; + uint32_t netlength; + struct iovec iov[3]; + int nb_iov = 3; + + assert(SIZEOF(netlength) == 4); + + /* + * Format is: + * 32 bit length (network byte order) + * 32 bit handle (network byte order) + * data + */ + netlength = htonl(len); + iov[0].iov_base = (void *)&netlength; + iov[0].iov_len = SIZEOF(netlength); + + nethandle = htonl((uint32_t)handle); + iov[1].iov_base = (void *)&nethandle; + iov[1].iov_len = SIZEOF(nethandle); + + if(len == 0) { + nb_iov = 2; + } + else { + iov[2].iov_base = (void *)buf; + iov[2].iov_len = len; + nb_iov = 3; + } + + if (net_writev(fd, iov, nb_iov) < 0) { + if (errmsg) + *errmsg = newvstralloc(*errmsg, "write error to ", + ": ", strerror(errno), NULL); + return (-1); + } + return (0); +} + +/* + * return -1 on error + * return 0 on EOF: *handle = H_EOF && *size = 0 if socket closed + * return 0 on EOF: *handle = handle && *size = 0 if stream closed + * return size : *handle = handle && *size = size for data read + */ + +ssize_t +tcpm_recv_token( + int fd, + int * handle, + char ** errmsg, + char ** buf, + ssize_t * size, + int timeout) +{ + unsigned int netint[2]; + + assert(SIZEOF(netint) == 8); + + switch (net_read(fd, &netint, SIZEOF(netint), timeout)) { + case -1: + if (errmsg) + *errmsg = newvstralloc(*errmsg, "recv error: ", strerror(errno), + NULL); + secprintf(("%s: tcpm_recv_token: A return(-1)\n", + debug_prefix_time(NULL))); + return (-1); + case 0: + *size = 0; + *handle = H_EOF; + *errmsg = newvstralloc(*errmsg, "SOCKET_EOF", NULL); + secprintf(("%s: tcpm_recv_token: A return(0)\n", + debug_prefix_time(NULL))); + return (0); + default: + break; + } + + *size = (ssize_t)ntohl(netint[0]); + if (*size > NETWORK_BLOCK_BYTES) { + *errmsg = newvstralloc(*errmsg, "tcpm_recv_token: invalid size", + NULL); + dbprintf(("%s: tcpm_recv_token: invalid size %d\n", + debug_prefix_time(NULL), *size)); + *size = -1; + return -1; + } + amfree(*buf); + *buf = alloc((size_t)*size); + *handle = (int)ntohl(netint[1]); + + if(*size == 0) { + secprintf(("%s: tcpm_recv_token: read EOF from %d\n", + debug_prefix_time(NULL), *handle)); + *errmsg = newvstralloc(*errmsg, "EOF", + NULL); + return 0; + } + switch (net_read(fd, *buf, (size_t)*size, timeout)) { + case -1: + if (errmsg) + *errmsg = newvstralloc(*errmsg, "recv error: ", strerror(errno), + NULL); + secprintf(("%s: tcpm_recv_token: B return(-1)\n", + debug_prefix_time(NULL))); + return (-1); + case 0: + *size = 0; + *errmsg = newvstralloc(*errmsg, "SOCKET_EOF", NULL); + secprintf(("%s: tcpm_recv_token: B return(0)\n", + debug_prefix_time(NULL))); + return (0); + default: + break; + } + + secprintf(("%s: tcpm_recv_token: read %ld bytes from %d\n", + debug_prefix_time(NULL), *size, *handle)); + return((*size)); +} + +void +tcpm_close_connection( + void *h, + char *hostname) +{ + struct sec_handle *rh = h; + + hostname = hostname; + + if(rh->rc->toclose == 0) { + rh->rc->toclose = 1; + sec_tcp_conn_put(rh->rc); + } +} + + + +/* + * Accept an incoming connection on a stream_server socket + * Nothing needed for tcpma. + */ +int +tcpma_stream_accept( + void * s) +{ + (void)s; /* Quiet unused parameter warning */ + + return (0); +} + +/* + * Return a connected stream. For sec, this means setup a stream + * with the supplied handle. + */ +void * +tcpma_stream_client( + void * h, + int id) +{ + struct sec_handle *rh = h; + struct sec_stream *rs; + + assert(rh != NULL); + + if (id <= 0) { + security_seterror(&rh->sech, + "%hd: invalid security stream id", id); + return (NULL); + } + + rs = alloc(SIZEOF(*rs)); + security_streaminit(&rs->secstr, rh->sech.driver); + rs->handle = id; + rs->ev_read = NULL; + rs->closed_by_me = 0; + rs->closed_by_network = 0; + if (rh->rc) { + rs->rc = rh->rc; + rh->rc->refcnt++; + } + else { + rs->rc = sec_tcp_conn_get(rh->hostname, 0); + rs->rc->driver = rh->sech.driver; + rh->rc = rs->rc; + } + + secprintf(("%s: sec: stream_client: connected to stream %hd\n", + debug_prefix_time(NULL), id)); + + return (rs); +} + +/* + * Create the server end of a stream. For sec, this means setup a stream + * object and allocate a new handle for it. + */ +void * +tcpma_stream_server( + void * h) +{ + struct sec_handle *rh = h; + struct sec_stream *rs; + + assert(rh != NULL); + + rs = alloc(SIZEOF(*rs)); + security_streaminit(&rs->secstr, rh->sech.driver); + rs->closed_by_me = 0; + rs->closed_by_network = 0; + if (rh->rc) { + rs->rc = rh->rc; + rs->rc->refcnt++; + } + else { + rs->rc = sec_tcp_conn_get(rh->hostname, 0); + rs->rc->driver = rh->sech.driver; + rh->rc = rs->rc; + } + /* + * Stream should already be setup! + */ + if (rs->rc->read < 0) { + sec_tcp_conn_put(rs->rc); + amfree(rs); + security_seterror(&rh->sech, "lost connection to %s", rh->hostname); + return (NULL); + } + assert(strcmp(rh->hostname, rs->rc->hostname) == 0); + //amfree(rh->hostname); + //rh->hostname = stralloc(rs->rc->hostname); + /* + * so as not to conflict with the amanda server's handle numbers, + * we start at 500000 and work down + */ + rs->handle = 500000 - newhandle++; + rs->ev_read = NULL; + secprintf(("%s: sec: stream_server: created stream %d\n", + debug_prefix_time(NULL), rs->handle)); + return (rs); +} + +/* + * Close and unallocate resources for a stream. + */ +void +tcpma_stream_close( + void * s) +{ + struct sec_stream *rs = s; + char buf = 0; + + assert(rs != NULL); + + secprintf(("%s: sec: tcpma_stream_close: closing stream %d\n", + debug_prefix_time(NULL), rs->handle)); + + if(rs->closed_by_network == 0 && rs->rc->write != -1) + tcpm_stream_write(rs, &buf, 0); + security_stream_read_cancel(&rs->secstr); + if(rs->closed_by_network == 0) + sec_tcp_conn_put(rs->rc); + amfree(rs); +} + +/* + * Create the server end of a stream. For bsdudp, this means setup a tcp + * socket for receiving a connection. + */ +void * +tcp1_stream_server( + void * h) +{ + struct sec_stream *rs = NULL; + struct sec_handle *rh = h; + + assert(rh != NULL); + + rs = alloc(SIZEOF(*rs)); + security_streaminit(&rs->secstr, rh->sech.driver); + rs->closed_by_me = 0; + rs->closed_by_network = 0; + if (rh->rc) { + rs->rc = rh->rc; + rs->handle = 500000 - newhandle++; + rs->rc->refcnt++; + rs->socket = 0; /* the socket is already opened */ + } + else { + rh->rc = sec_tcp_conn_get(rh->hostname, 1); + rh->rc->driver = rh->sech.driver; + rs->rc = rh->rc; + rs->socket = stream_server(&rs->port, STREAM_BUFSIZE, + STREAM_BUFSIZE, 0); + if (rs->socket < 0) { + security_seterror(&rh->sech, + "can't create server stream: %s", strerror(errno)); + amfree(rs); + return (NULL); + } + rh->rc->read = rs->socket; + rh->rc->write = rs->socket; + rs->handle = (int)rs->port; + } + rs->fd = -1; + rs->ev_read = NULL; + return (rs); +} + +/* + * Accepts a new connection on unconnected streams. Assumes it is ok to + * block on accept() + */ +int +tcp1_stream_accept( + void * s) +{ + struct sec_stream *bs = s; + + assert(bs != NULL); + assert(bs->socket != -1); + assert(bs->fd < 0); + + if (bs->socket > 0) { + bs->fd = stream_accept(bs->socket, 30, STREAM_BUFSIZE, STREAM_BUFSIZE); + if (bs->fd < 0) { + security_stream_seterror(&bs->secstr, + "can't accept new stream connection: %s", + strerror(errno)); + return (-1); + } + bs->rc->read = bs->fd; + bs->rc->write = bs->fd; + } + return (0); +} + +/* + * Return a connected stream + */ +void * +tcp1_stream_client( + void * h, + int id) +{ + struct sec_stream *rs = NULL; + struct sec_handle *rh = h; + + assert(rh != NULL); + + rs = alloc(SIZEOF(*rs)); + security_streaminit(&rs->secstr, rh->sech.driver); + rs->handle = id; + rs->ev_read = NULL; + rs->closed_by_me = 0; + rs->closed_by_network = 0; + if (rh->rc) { + rs->rc = rh->rc; + rh->rc->refcnt++; + } + else { + rh->rc = sec_tcp_conn_get(rh->hostname, 1); + rs->rc = rh->rc; + rh->rc->read = stream_client(rh->hostname, (in_port_t)id, + STREAM_BUFSIZE, STREAM_BUFSIZE, &rs->port, 0); + if (rh->rc->read < 0) { + security_seterror(&rh->sech, + "can't connect stream to %s port %d: %s", + rh->hostname, id, strerror(errno)); + amfree(rs); + return (NULL); + } + rh->rc->write = rh->rc->read; + } + rs->socket = -1; /* we're a client */ + rh->rs = rs; + return (rs); +} + +int +tcp_stream_write( + void * s, + const void *buf, + size_t size) +{ + struct sec_stream *rs = s; + + assert(rs != NULL); + + if (fullwrite(rs->fd, buf, size) < 0) { + security_stream_seterror(&rs->secstr, + "write error on stream %d: %s", rs->port, strerror(errno)); + return (-1); + } + return (0); +} + +char * +bsd_prefix_packet( + void * h, + pkt_t * pkt) +{ + struct sec_handle *rh = h; + struct passwd *pwd; + char *buf; + + if (pkt->type != P_REQ) + return ""; + + if ((pwd = getpwuid(getuid())) == NULL) { + security_seterror(&rh->sech, + "can't get login name for my uid %ld", + (long)getuid()); + return(NULL); + } + buf = alloc(16+strlen(pwd->pw_name)); + strncpy(buf, "SECURITY USER ", (16 + strlen(pwd->pw_name))); + strncpy(&buf[14], pwd->pw_name, (16 + strlen(pwd->pw_name) - 14)); + buf[14 + strlen(pwd->pw_name)] = '\n'; + buf[15 + strlen(pwd->pw_name)] = '\0'; + + return (buf); +} + + +/* + * Check the security of a received packet. Returns negative on security + * violation, or returns 0 if ok. Removes the security info from the pkt_t. + */ +int +bsd_recv_security_ok( + struct sec_handle * rh, + pkt_t * pkt) +{ + char *tok, *security, *body, *result; + char *service = NULL, *serviceX, *serviceY; + char *security_line; + size_t len; + + /* + * Now, find the SECURITY line in the body, and parse it out + * into an argv. + */ + if (strncmp(pkt->body, "SECURITY ", SIZEOF("SECURITY ") - 1) == 0) { + security = pkt->body; + len = 0; + while(*security != '\n' && len < pkt->size) { + security++; + len++; + } + if(*security == '\n') { + body = security+1; + *security = '\0'; + security_line = stralloc(pkt->body); + security = pkt->body + strlen("SECURITY "); + } else { + body = pkt->body; + security_line = NULL; + security = NULL; + } + } else { + body = pkt->body; + security_line = NULL; + security = NULL; + } + + /* + * Now, find the SERVICE line in the body, and parse it out + * into an argv. + */ + if (strncmp(body, "SERVICE", SIZEOF("SERVICE") - 1) == 0) { + serviceX = stralloc(body + strlen("SERVICE ")); + serviceY = strtok(serviceX, "\n"); + if (serviceY) + service = stralloc(serviceY); + amfree(serviceX); + } + + /* + * We need to do different things depending on which type of packet + * this is. + */ + switch (pkt->type) { + case P_REQ: + /* + * Request packets must come from a reserved port + */ + if (ntohs(rh->peer.sin_port) >= IPPORT_RESERVED) { + security_seterror(&rh->sech, + "host %s: port %d not secure", rh->hostname, + ntohs(rh->peer.sin_port)); + amfree(service); + amfree(security_line); + return (-1); + } + + if (!service) { + security_seterror(&rh->sech, + "packet as no SERVICE line"); + amfree(security_line); + return (-1); + } + + /* + * Request packets contain a remote username. We need to check + * that we allow it in. + * + * They will look like: + * SECURITY USER [username] + */ + + /* there must be some security info */ + if (security == NULL) { + security_seterror(&rh->sech, + "no bsd SECURITY for P_REQ"); + amfree(service); + return (-1); + } + + /* second word must be USER */ + if ((tok = strtok(security, " ")) == NULL) { + security_seterror(&rh->sech, + "SECURITY line: %s", security_line); + amfree(service); + amfree(security_line); + return (-1); /* default errmsg */ + } + if (strcmp(tok, "USER") != 0) { + security_seterror(&rh->sech, + "REQ SECURITY line parse error, expecting USER, got %s", tok); + amfree(service); + amfree(security_line); + return (-1); + } + + /* the third word is the username */ + if ((tok = strtok(NULL, "")) == NULL) { + security_seterror(&rh->sech, + "SECURITY line: %s", security_line); + amfree(security_line); + return (-1); /* default errmsg */ + } + if ((result = check_user(rh, tok, service)) != NULL) { + security_seterror(&rh->sech, "%s", result); + amfree(service); + amfree(result); + amfree(security_line); + return (-1); + } + + /* we're good to go */ + break; + default: + break; + } + amfree(service); + amfree(security_line); + + /* + * If there is security info at the front of the packet, we need to + * shift the rest of the data up and nuke it. + */ + if (body != pkt->body) + memmove(pkt->body, body, strlen(body) + 1); + return (0); +} + +/* + * Transmit a packet. Add security information first. + */ +ssize_t +udpbsd_sendpkt( + void * cookie, + pkt_t * pkt) +{ + struct sec_handle *rh = cookie; + struct passwd *pwd; + + assert(rh != NULL); + assert(pkt != NULL); + + secprintf(("%s: udpbsd_sendpkt: enter\n", get_pname())); + /* + * Initialize this datagram, and add the header + */ + dgram_zero(&rh->udp->dgram); + dgram_cat(&rh->udp->dgram, pkthdr2str(rh, pkt)); + + /* + * Add the security info. This depends on which kind of packet we're + * sending. + */ + switch (pkt->type) { + case P_REQ: + /* + * Requests get sent with our username in the body + */ + if ((pwd = getpwuid(geteuid())) == NULL) { + security_seterror(&rh->sech, + "can't get login name for my uid %ld", (long)getuid()); + return (-1); + } + dgram_cat(&rh->udp->dgram, "SECURITY USER %s\n", pwd->pw_name); + break; + + default: + break; + } + + /* + * Add the body, and send it + */ + dgram_cat(&rh->udp->dgram, pkt->body); + + secprintf(( + "%s: sec: udpbsd_sendpkt: %s (%d) pkt_t (len %d) contains:\n\n\"%s\"\n\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), pkt->type, + strlen(pkt->body), pkt->body)); + + if (dgram_send_addr(rh->peer, &rh->udp->dgram) != 0) { + security_seterror(&rh->sech, + "send %s to %s failed: %s", pkt_type2str(pkt->type), + rh->hostname, strerror(errno)); + return (-1); + } + return (0); +} + +void +udp_close( + void * cookie) +{ + struct sec_handle *rh = cookie; + + if (rh->proto_handle == NULL) { + return; + } + + secprintf(("%s: udp: close handle '%s'\n", + debug_prefix_time(NULL), rh->proto_handle)); + + udp_recvpkt_cancel(rh); + if (rh->next) { + rh->next->prev = rh->prev; + } + else { + rh->udp->bh_last = rh->prev; + } + if (rh->prev) { + rh->prev->next = rh->next; + } + else { + rh->udp->bh_first = rh->next; + } + + amfree(rh->proto_handle); + amfree(rh->hostname); + amfree(rh); +} + +/* + * Set up to receive a packet asynchronously, and call back when it has + * been read. + */ +void +udp_recvpkt( + void * cookie, + void (*fn)(void *, pkt_t *, security_status_t), + void * arg, + int timeout) +{ + struct sec_handle *rh = cookie; + + secprintf(("%s: udp_recvpkt(cookie=%p, fn=%p, arg=%p, timeout=%u)\n", + debug_prefix(NULL), cookie, fn, arg, timeout)); + assert(rh != NULL); + assert(fn != NULL); + + + /* + * Subsequent recvpkt calls override previous ones + */ + if (rh->ev_read == NULL) { + udp_addref(rh->udp, &udp_netfd_read_callback); + rh->ev_read = event_register(rh->event_id, EV_WAIT, + udp_recvpkt_callback, rh); + } + if (rh->ev_timeout != NULL) + event_release(rh->ev_timeout); + if (timeout < 0) + rh->ev_timeout = NULL; + else + rh->ev_timeout = event_register((event_id_t)timeout, EV_TIME, + udp_recvpkt_timeout, rh); + rh->fn.recvpkt = fn; + rh->arg = arg; +} + +/* + * Remove a async receive request on this handle from the queue. + * If it is the last one to be removed, then remove the event + * handler for our network fd + */ +void +udp_recvpkt_cancel( + void * cookie) +{ + struct sec_handle *rh = cookie; + + assert(rh != NULL); + + if (rh->ev_read != NULL) { + udp_delref(rh->udp); + event_release(rh->ev_read); + rh->ev_read = NULL; + } + + if (rh->ev_timeout != NULL) { + event_release(rh->ev_timeout); + rh->ev_timeout = NULL; + } +} + +/* + * This is called when a handle is woken up because data read off of the + * net is for it. + */ +void +udp_recvpkt_callback( + void * cookie) +{ + struct sec_handle *rh = cookie; + void (*fn)(void *, pkt_t *, security_status_t); + void *arg; + + secprintf(("%s: udp: receive handle '%s' netfd '%s'\n", + debug_prefix_time(NULL), rh->proto_handle, rh->udp->handle)); + assert(rh != NULL); + + if (strcmp(rh->proto_handle, rh->udp->handle) != 0) assert(1); + /* if it didn't come from the same host/port, forget it */ + if (memcmp(&rh->peer.sin_addr, &rh->udp->peer.sin_addr, + SIZEOF(rh->udp->peer.sin_addr)) != 0 || + rh->peer.sin_port != rh->udp->peer.sin_port) { + amfree(rh->udp->handle); + //rh->udp->handle = NULL; + return; + } + + /* + * We need to cancel the recvpkt request before calling the callback + * because the callback may reschedule us. + */ + fn = rh->fn.recvpkt; + arg = rh->arg; + udp_recvpkt_cancel(rh); + + /* + * Check the security of the packet. If it is bad, then pass NULL + * to the packet handling function instead of a packet. + */ + if (rh->udp->recv_security_ok && + rh->udp->recv_security_ok(rh, &rh->udp->pkt) < 0) + (*fn)(arg, NULL, S_ERROR); + else + (*fn)(arg, &rh->udp->pkt, S_OK); +} + +/* + * This is called when a handle times out before receiving a packet. + */ +void +udp_recvpkt_timeout( + void * cookie) +{ + struct sec_handle *rh = cookie; + void (*fn)(void *, pkt_t *, security_status_t); + void *arg; + + assert(rh != NULL); + + assert(rh->ev_timeout != NULL); + fn = rh->fn.recvpkt; + arg = rh->arg; + udp_recvpkt_cancel(rh); + (*fn)(arg, NULL, S_TIMEOUT); +} + +/* + * Given a hostname and a port, setup a udp_handle + */ +int +udp_inithandle( + udp_handle_t * udp, + struct sec_handle * rh, + struct hostent * he, + in_port_t port, + char * handle, + int sequence) +{ + int i; + + /* + * Save the hostname and port info + */ + secprintf(("%s: udp_inithandle port %hd handle %s sequence %d\n", + debug_prefix_time(NULL), ntohs(port), + handle, sequence)); + assert(he != NULL); + + rh->hostname = stralloc(he->h_name); + memcpy(&rh->peer.sin_addr, he->h_addr, SIZEOF(rh->peer.sin_addr)); + rh->peer.sin_port = port; + rh->peer.sin_family = (sa_family_t)AF_INET; + + /* + * Do a forward lookup of the hostname. This is unnecessary if we + * are initiating the connection, but is very serious if we are + * receiving. We want to make sure the hostname + * resolves back to the remote ip for security reasons. + */ + if ((he = gethostbyname(rh->hostname)) == NULL) { + secprintf(("%s: udp: bb\n", debug_prefix_time(NULL))); + security_seterror(&rh->sech, + "%s: could not resolve hostname", rh->hostname); + return (-1); + } + + /* + * Make sure the hostname matches. This should always work. + */ + if (strncasecmp(rh->hostname, he->h_name, strlen(rh->hostname)) != 0) { + secprintf(("%s: udp: cc\n", debug_prefix_time(NULL))); + security_seterror(&rh->sech, + "%s: did not resolve to itself, it resolv to", + rh->hostname, he->h_name); + return (-1); + } + + /* + * Now look for a matching ip address. + */ + for (i = 0; he->h_addr_list[i] != NULL; i++) { + if (memcmp(&rh->peer.sin_addr, he->h_addr_list[i], + SIZEOF(struct in_addr)) == 0) { + break; + } + } + + /* + * If we didn't find it, try the aliases. This is a workaround for + * Solaris if DNS goes over NIS. + */ + if (he->h_addr_list[i] == NULL) { + const char *ipstr = inet_ntoa(rh->peer.sin_addr); + for (i = 0; he->h_aliases[i] != NULL; i++) { + if (strcmp(he->h_aliases[i], ipstr) == 0) + break; + } + /* + * No aliases either. Failure. Someone is fooling with us or + * DNS is messed up. + */ + if (he->h_aliases[i] == NULL) { + security_seterror(&rh->sech, + "DNS check failed: no matching ip address for %s", + rh->hostname); + return (-1); + } + } + + rh->prev = udp->bh_last; + if (udp->bh_last) { + rh->prev->next = rh; + } + if (!udp->bh_first) { + udp->bh_first = rh; + } + rh->next = NULL; + udp->bh_last = rh; + + rh->sequence = sequence; + rh->event_id = (event_id_t)newevent++; + amfree(rh->proto_handle); + rh->proto_handle = stralloc(handle); + rh->fn.connect = NULL; + rh->arg = NULL; + rh->ev_read = NULL; + rh->ev_timeout = NULL; + + secprintf(("%s: udp: adding handle '%s'\n", + debug_prefix_time(NULL), rh->proto_handle)); + + return(0); +} + + +/* + * Callback for received packets. This is the function bsd_recvpkt + * registers with the event handler. It is called when the event handler + * realizes that data is waiting to be read on the network socket. + */ +void +udp_netfd_read_callback( + void * cookie) +{ + struct udp_handle *udp = cookie; + struct sec_handle *rh; + struct hostent *he; + int a; + + secprintf(("%s: udp_netfd_read_callback(cookie=%p)\n", + debug_prefix(NULL), cookie)); + assert(udp != NULL); + +#ifndef TEST /* { */ + /* + * Receive the packet. + */ + dgram_zero(&udp->dgram); + if (dgram_recv(&udp->dgram, 0, &udp->peer) < 0) + return; +#endif /* !TEST */ /* } */ + + /* + * Parse the packet. + */ + if (str2pkthdr(udp) < 0) + return; + + /* + * If there are events waiting on this handle, we're done + */ + rh = udp->bh_first; + while(rh != NULL && (strcmp(rh->proto_handle, udp->handle) != 0 || + rh->sequence != udp->sequence || + rh->peer.sin_addr.s_addr != udp->peer.sin_addr.s_addr || + rh->peer.sin_port != udp->peer.sin_port)) { + rh = rh->next; + } + if (rh && event_wakeup(rh->event_id) > 0) + return; + + /* + * If we didn't find a handle, then check for a new incoming packet. + * If no accept handler was setup, then just return. + */ + if (udp->accept_fn == NULL) + return; + + he = gethostbyaddr((void *)&udp->peer.sin_addr, + (socklen_t)sizeof(udp->peer.sin_addr), AF_INET); + if (he == NULL) + return; + rh = alloc(SIZEOF(*rh)); + rh->proto_handle=NULL; + rh->udp = udp; + rh->rc = NULL; + security_handleinit(&rh->sech, udp->driver); + a = udp_inithandle(udp, rh, + he, + udp->peer.sin_port, + udp->handle, + udp->sequence); + if (a < 0) { + secprintf(("%s: bsd: closeX handle '%s'\n", + debug_prefix_time(NULL), rh->proto_handle)); + + amfree(rh); + return; + } + /* + * Check the security of the packet. If it is bad, then pass NULL + * to the accept function instead of a packet. + */ + if (rh->udp->recv_security_ok(rh, &udp->pkt) < 0) + (*udp->accept_fn)(&rh->sech, NULL); + else + (*udp->accept_fn)(&rh->sech, &udp->pkt); +} + +/* + * Locate an existing connection to the given host, or create a new, + * unconnected entry if none exists. The caller is expected to check + * for the lack of a connection (rc->read == -1) and set one up. + */ +struct tcp_conn * +sec_tcp_conn_get( + const char *hostname, + int want_new) +{ + struct tcp_conn *rc; + + secprintf(("%s: sec_tcp_conn_get: %s\n", debug_prefix_time(NULL), hostname)); + + if (want_new == 0) { + for (rc = connq_first(); rc != NULL; rc = connq_next(rc)) { + if (strcasecmp(hostname, rc->hostname) == 0) + break; + } + + if (rc != NULL) { + rc->refcnt++; + secprintf(("%s: sec_tcp_conn_get: exists, refcnt to %s is now %d\n", + debug_prefix_time(NULL), + rc->hostname, rc->refcnt)); + return (rc); + } + } + + secprintf(("%s: sec_tcp_conn_get: creating new handle\n", + debug_prefix_time(NULL))); + /* + * We can't be creating a new handle if we are the client + */ + rc = alloc(SIZEOF(*rc)); + rc->read = rc->write = -1; + rc->driver = NULL; + rc->pid = -1; + rc->ev_read = NULL; + rc->toclose = 0; + rc->donotclose = 0; + strncpy(rc->hostname, hostname, SIZEOF(rc->hostname) - 1); + rc->hostname[SIZEOF(rc->hostname) - 1] = '\0'; + rc->errmsg = NULL; + rc->refcnt = 1; + rc->handle = -1; + rc->pkt = NULL; + rc->accept_fn = NULL; + rc->recv_security_ok = NULL; + rc->prefix_packet = NULL; + connq_append(rc); + return (rc); +} + +/* + * Delete a reference to a connection, and close it if it is the last + * reference. + */ +void +sec_tcp_conn_put( + struct tcp_conn * rc) +{ + amwait_t status; + + assert(rc->refcnt > 0); + --rc->refcnt; + secprintf(("%s: sec_tcp_conn_put: decrementing refcnt for %s to %d\n", + debug_prefix_time(NULL), + rc->hostname, rc->refcnt)); + if (rc->refcnt > 0) { + return; + } + secprintf(("%s: sec_tcp_conn_put: closing connection to %s\n", + debug_prefix_time(NULL), rc->hostname)); + if (rc->read != -1) + aclose(rc->read); + if (rc->write != -1) + aclose(rc->write); + if (rc->pid != -1) { + waitpid(rc->pid, &status, WNOHANG); + } + if (rc->ev_read != NULL) + event_release(rc->ev_read); + if (rc->errmsg != NULL) + amfree(rc->errmsg); + connq_remove(rc); + amfree(rc->pkt); + if(!rc->donotclose) + amfree(rc); /* someone might still use it */ + /* eg. in sec_tcp_conn_read_callback if */ + /* event_wakeup call us. */ +} + +/* + * Turn on read events for a conn. Or, increase a ev_read_refcnt if we are + * already receiving read events. + */ +void +sec_tcp_conn_read( + struct tcp_conn * rc) +{ + assert (rc != NULL); + + if (rc->ev_read != NULL) { + rc->ev_read_refcnt++; + secprintf(( + "%s: sec: conn_read: incremented ev_read_refcnt to %d for %s\n", + debug_prefix_time(NULL), rc->ev_read_refcnt, rc->hostname)); + return; + } + secprintf(("%s: sec: conn_read registering event handler for %s\n", + debug_prefix_time(NULL), rc->hostname)); + rc->ev_read = event_register((event_id_t)rc->read, EV_READFD, + sec_tcp_conn_read_callback, rc); + rc->ev_read_refcnt = 1; +} + +static void +sec_tcp_conn_read_cancel( + struct tcp_conn * rc) +{ + + --rc->ev_read_refcnt; + secprintf(( + "%s: sec: conn_read_cancel: decremented ev_read_refcnt to %d for %s\n", + debug_prefix_time(NULL), + rc->ev_read_refcnt, rc->hostname)); + if (rc->ev_read_refcnt > 0) { + return; + } + secprintf(("%s: sec: conn_read_cancel: releasing event handler for %s\n", + debug_prefix_time(NULL), rc->hostname)); + event_release(rc->ev_read); + rc->ev_read = NULL; +} + +/* + * This is called when a handle is woken up because data read off of the + * net is for it. + */ +static void +recvpkt_callback( + void * cookie, + void * buf, + ssize_t bufsize) +{ + pkt_t pkt; + struct sec_handle *rh = cookie; + + assert(rh != NULL); + + secprintf(("%s: sec: recvpkt_callback: %d\n", + debug_prefix_time(NULL), bufsize)); + /* + * We need to cancel the recvpkt request before calling + * the callback because the callback may reschedule us. + */ + stream_recvpkt_cancel(rh); + + switch (bufsize) { + case 0: + security_seterror(&rh->sech, + "EOF on read from %s", rh->hostname); + (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); + return; + case -1: + security_seterror(&rh->sech, security_stream_geterror(&rh->rs->secstr)); + (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); + return; + default: + break; + } + + parse_pkt(&pkt, buf, (size_t)bufsize); + secprintf(( + "%s: sec: received %s packet (%d) from %s, contains:\n\n\"%s\"\n\n", + debug_prefix_time(NULL), pkt_type2str(pkt.type), pkt.type, + rh->hostname, pkt.body)); + if (rh->rc->recv_security_ok && (rh->rc->recv_security_ok)(rh, &pkt) < 0) + (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); + else + (*rh->fn.recvpkt)(rh->arg, &pkt, S_OK); + amfree(pkt.body); +} + +/* + * Callback for tcpm_stream_read_sync + */ +static void +stream_read_sync_callback( + void * s) +{ + struct sec_stream *rs = s; + assert(rs != NULL); + + secprintf(("%s: sec: stream_read_callback_sync: handle %d\n", + debug_prefix_time(NULL), rs->handle)); + + /* + * Make sure this was for us. If it was, then blow away the handle + * so it doesn't get claimed twice. Otherwise, leave it alone. + * + * If the handle is EOF, pass that up to our callback. + */ + if (rs->rc->handle == rs->handle) { + secprintf(("%s: sec: stream_read_callback_sync: it was for us\n", + debug_prefix_time(NULL))); + rs->rc->handle = H_TAKEN; + } else if (rs->rc->handle != H_EOF) { + secprintf(("%s: sec: stream_read_callback_sync: not for us\n", + debug_prefix_time(NULL))); + return; + } + + /* + * Remove the event first, and then call the callback. + * We remove it first because we don't want to get in their + * way if they reschedule it. + */ + tcpm_stream_read_cancel(rs); + + if (rs->rc->pktlen <= 0) { + secprintf(("%s: sec: stream_read_sync_callback: %s\n", + debug_prefix_time(NULL), rs->rc->errmsg)); + security_stream_seterror(&rs->secstr, rs->rc->errmsg); + if(rs->closed_by_me == 0 && rs->closed_by_network == 0) + sec_tcp_conn_put(rs->rc); + rs->closed_by_network = 1; + return; + } + secprintf(( + "%s: sec: stream_read_callback_sync: read %ld bytes from %s:%d\n", + debug_prefix_time(NULL), + rs->rc->pktlen, rs->rc->hostname, rs->handle)); +} + +/* + * Callback for tcpm_stream_read + */ +static void +stream_read_callback( + void * arg) +{ + struct sec_stream *rs = arg; + assert(rs != NULL); + + secprintf(("%s: sec: stream_read_callback: handle %d\n", + debug_prefix_time(NULL), rs->handle)); + + /* + * Make sure this was for us. If it was, then blow away the handle + * so it doesn't get claimed twice. Otherwise, leave it alone. + * + * If the handle is EOF, pass that up to our callback. + */ + if (rs->rc->handle == rs->handle) { + secprintf(("%s: sec: stream_read_callback: it was for us\n", + debug_prefix_time(NULL))); + rs->rc->handle = H_TAKEN; + } else if (rs->rc->handle != H_EOF) { + secprintf(("%s: sec: stream_read_callback: not for us\n", + debug_prefix_time(NULL))); + return; + } + + /* + * Remove the event first, and then call the callback. + * We remove it first because we don't want to get in their + * way if they reschedule it. + */ + tcpm_stream_read_cancel(rs); + + if (rs->rc->pktlen <= 0) { + secprintf(("%s: sec: stream_read_callback: %s\n", + debug_prefix_time(NULL), rs->rc->errmsg)); + security_stream_seterror(&rs->secstr, rs->rc->errmsg); + if(rs->closed_by_me == 0 && rs->closed_by_network == 0) + sec_tcp_conn_put(rs->rc); + rs->closed_by_network = 1; + (*rs->fn)(rs->arg, NULL, rs->rc->pktlen); + return; + } + secprintf(("%s: sec: stream_read_callback: read %ld bytes from %s:%d\n", + debug_prefix_time(NULL), + rs->rc->pktlen, rs->rc->hostname, rs->handle)); + (*rs->fn)(rs->arg, rs->rc->pkt, rs->rc->pktlen); + secprintf(("%s: sec: after callback stream_read_callback\n", + debug_prefix_time(NULL))); +} + +/* + * The callback for the netfd for the event handler + * Determines if this packet is for this security handle, + * and does the real callback if so. + */ +static void +sec_tcp_conn_read_callback( + void * cookie) +{ + struct tcp_conn * rc = cookie; + struct sec_handle * rh; + pkt_t pkt; + ssize_t rval; + int revent; + + assert(cookie != NULL); + + secprintf(("%s: sec: conn_read_callback\n", debug_prefix_time(NULL))); + + /* Read the data off the wire. If we get errors, shut down. */ + rval = tcpm_recv_token(rc->read, &rc->handle, &rc->errmsg, &rc->pkt, + &rc->pktlen, 60); + secprintf(("%s: sec: conn_read_callback: tcpm_recv_token returned %d\n", + debug_prefix_time(NULL), rval)); + if (rval < 0 || rc->handle == H_EOF) { + rc->pktlen = rval; + rc->handle = H_EOF; + revent = event_wakeup((event_id_t)rc); + secprintf(("%s: sec: conn_read_callback: event_wakeup return %d\n", + debug_prefix_time(NULL), revent)); + /* delete our 'accept' reference */ + if (rc->accept_fn != NULL) { + if(rc->refcnt != 1) { + dbprintf(("STRANGE, rc->refcnt should be 1")); + rc->refcnt=1; + } + rc->accept_fn = NULL; + sec_tcp_conn_put(rc); + } + return; + } + + if(rval == 0) { + rc->pktlen = 0; + revent = event_wakeup((event_id_t)rc); + secprintf(("%s: 0 sec: conn_read_callback: event_wakeup return %d\n", + debug_prefix_time(NULL), revent)); + return; + } + + /* If there are events waiting on this handle, we're done */ + rc->donotclose = 1; + revent = event_wakeup((event_id_t)rc); + secprintf(("%s: sec: conn_read_callback: event_wakeup return %d\n", + debug_prefix_time(NULL), rval)); + rc->donotclose = 0; + if (rc->handle == H_TAKEN || rc->pktlen == 0) { + if(rc->refcnt == 0) amfree(rc); + return; + } + + assert(rc->refcnt > 0); + + /* If there is no accept fn registered, then drop the packet */ + if (rc->accept_fn == NULL) + return; + + rh = alloc(SIZEOF(*rh)); + security_handleinit(&rh->sech, rc->driver); + rh->hostname = stralloc(rc->hostname); + rh->ev_timeout = NULL; + rh->rc = rc; + rh->peer = rc->peer; + rh->rs = tcpma_stream_client(rh, rc->handle); + + secprintf(("%s: sec: new connection\n", debug_prefix_time(NULL))); + pkt.body = NULL; + parse_pkt(&pkt, rc->pkt, (size_t)rc->pktlen); + secprintf(("%s: sec: calling accept_fn\n", debug_prefix_time(NULL))); + if (rh->rc->recv_security_ok && (rh->rc->recv_security_ok)(rh, &pkt) < 0) + (*rc->accept_fn)(&rh->sech, NULL); + else + (*rc->accept_fn)(&rh->sech, &pkt); + amfree(pkt.body); +} + +void +parse_pkt( + pkt_t * pkt, + const void *buf, + size_t bufsize) +{ + const unsigned char *bufp = buf; + + secprintf(("%s: sec: parse_pkt: parsing buffer of %d bytes\n", + debug_prefix_time(NULL), bufsize)); + + pkt->type = (pktype_t)*bufp++; + bufsize--; + + pkt->packet_size = bufsize+1; + pkt->body = alloc(pkt->packet_size); + if (bufsize == 0) { + pkt->body[0] = '\0'; + } else { + memcpy(pkt->body, bufp, bufsize); + pkt->body[pkt->packet_size - 1] = '\0'; + } + pkt->size = strlen(pkt->body); + + secprintf(("%s: sec: parse_pkt: %s (%d): \"%s\"\n", + debug_prefix_time(NULL), pkt_type2str(pkt->type), + pkt->type, pkt->body)); +} + +/* + * Convert a packet header into a string + */ +const char * +pkthdr2str( + const struct sec_handle * rh, + const pkt_t * pkt) +{ + static char retbuf[256]; + + assert(rh != NULL); + assert(pkt != NULL); + + snprintf(retbuf, SIZEOF(retbuf), "Amanda %d.%d %s HANDLE %s SEQ %d\n", + VERSION_MAJOR, VERSION_MINOR, pkt_type2str(pkt->type), + rh->proto_handle, rh->sequence); + + secprintf(("%s: bsd: pkthdr2str handle '%s'\n", + debug_prefix_time(NULL), rh->proto_handle)); + + /* check for truncation. If only we had asprintf()... */ + assert(retbuf[strlen(retbuf) - 1] == '\n'); + + return (retbuf); +} + +/* + * Parses out the header line in 'str' into the pkt and handle + * Returns negative on parse error. + */ +int +str2pkthdr( + udp_handle_t * udp) +{ + char *str; + const char *tok; + pkt_t *pkt; + + pkt = &udp->pkt; + + assert(udp->dgram.cur != NULL); + str = stralloc(udp->dgram.cur); + + /* "Amanda %d.%d HANDLE %s SEQ %d\n" */ + + /* Read in "Amanda" */ + if ((tok = strtok(str, " ")) == NULL || strcmp(tok, "Amanda") != 0) + goto parse_error; + + /* nothing is done with the major/minor numbers currently */ + if ((tok = strtok(NULL, " ")) == NULL || strchr(tok, '.') == NULL) + goto parse_error; + + /* Read in the packet type */ + if ((tok = strtok(NULL, " ")) == NULL) + goto parse_error; + amfree(pkt->body); + pkt_init(pkt, pkt_str2type(tok), ""); + if (pkt->type == (pktype_t)-1) + goto parse_error; + + /* Read in "HANDLE" */ + if ((tok = strtok(NULL, " ")) == NULL || strcmp(tok, "HANDLE") != 0) + goto parse_error; + + /* parse the handle */ + if ((tok = strtok(NULL, " ")) == NULL) + goto parse_error; + amfree(udp->handle); + udp->handle = stralloc(tok); + + /* Read in "SEQ" */ + if ((tok = strtok(NULL, " ")) == NULL || strcmp(tok, "SEQ") != 0) + goto parse_error; + + /* parse the sequence number */ + if ((tok = strtok(NULL, "\n")) == NULL) + goto parse_error; + udp->sequence = atoi(tok); + + /* Save the body, if any */ + if ((tok = strtok(NULL, "")) != NULL) + pkt_cat(pkt, "%s", tok); + + amfree(str); + return (0); + +parse_error: +#if 0 /* XXX we have no way of passing this back up */ + security_seterror(&rh->sech, + "parse error in packet header : '%s'", origstr); +#endif + amfree(str); + return (-1); +} + +char * +check_user( + struct sec_handle * rh, + const char * remoteuser, + const char * service) +{ + struct passwd *pwd; + char *r; + char *result = NULL; + char *localuser = NULL; + + /* lookup our local user name */ + if ((pwd = getpwnam(CLIENT_LOGIN)) == NULL) { + return vstralloc("getpwnam(", CLIENT_LOGIN, ") fails", NULL); + } + + /* + * Make a copy of the user name in case getpw* is called by + * any of the lower level routines. + */ + localuser = stralloc(pwd->pw_name); + +#ifndef USE_AMANDAHOSTS + r = check_user_ruserok(rh->hostname, pwd, remoteuser); +#else + r = check_user_amandahosts(rh->hostname, rh->peer.sin_addr, pwd, remoteuser, service); +#endif + if (r != NULL) { + result = vstralloc("user ", remoteuser, " from ", rh->hostname, + " is not allowed to execute the service ", + service, ": ", r, NULL); + amfree(r); + } + amfree(localuser); + return result; +} + +/* + * See if a remote user is allowed in. This version uses ruserok() + * and friends. + * + * Returns 0 on success, or negative on error. + */ +char * +check_user_ruserok( + const char * host, + struct passwd * pwd, + const char * remoteuser) +{ + int saved_stderr; + int fd[2]; + FILE *fError; + amwait_t exitcode; + pid_t ruserok_pid; + pid_t pid; + char *es; + char *result; + int ok; + char number[NUM_STR_SIZE]; + uid_t myuid = getuid(); + + /* + * note that some versions of ruserok (eg SunOS 3.2) look in + * "./.rhosts" rather than "~CLIENT_LOGIN/.rhosts", so we have to + * chdir ourselves. Sigh. + * + * And, believe it or not, some ruserok()'s try an initgroup just + * for the hell of it. Since we probably aren't root at this point + * it'll fail, and initgroup "helpfully" will blatt "Setgroups: Not owner" + * into our stderr output even though the initgroup failure is not a + * problem and is expected. Thanks a lot. Not. + */ + if (pipe(fd) != 0) { + return stralloc2("pipe() fails: ", strerror(errno)); + } + if ((ruserok_pid = fork()) < 0) { + return stralloc2("fork() fails: ", strerror(errno)); + } else if (ruserok_pid == 0) { + int ec; + + close(fd[0]); + fError = fdopen(fd[1], "w"); + if (!fError) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } + /* pamper braindead ruserok's */ + if (chdir(pwd->pw_dir) != 0) { + fprintf(fError, "chdir(%s) failed: %s", + pwd->pw_dir, strerror(errno)); + fclose(fError); + exit(1); + } + +#if defined(SHOW_SECURITY_DETAIL) /* { */ + { + char *dir = stralloc(pwd->pw_dir); + + secprintf(("%s: bsd: calling ruserok(%s, %d, %s, %s)\n", + debug_prefix_time(NULL), + host, ((myuid == 0) ? 1 : 0), remoteuser, pwd->pw_name)); + if (myuid == 0) { + secprintf(("%s: bsd: because you are running as root, ", + debug_prefix(NULL))); + secprintf(("/etc/hosts.equiv will not be used\n")); + } else { + show_stat_info("/etc/hosts.equiv", NULL); + } + show_stat_info(dir, "/.rhosts"); + amfree(dir); + } +#endif /* } */ + + saved_stderr = dup(2); + close(2); + if (open("/dev/null", O_RDWR) == -1) { + secprintf(("%s: Could not open /dev/null: %s\n", + debug_prefix(NULL), strerror(errno))); + ec = 1; + } else { + ok = ruserok(host, myuid == 0, remoteuser, CLIENT_LOGIN); + if (ok < 0) { + ec = 1; + } else { + ec = 0; + } + } + (void)dup2(saved_stderr,2); + close(saved_stderr); + exit(ec); + } + close(fd[1]); + fError = fdopen(fd[0], "r"); + if (!fError) { + error("Can't fdopen: %s", strerror(errno)); + /*NOTREACHED*/ + } + + result = NULL; + while ((es = agets(fError)) != NULL) { + if (*es == 0) { + amfree(es); + continue; + } + if (result == NULL) { + result = stralloc(""); + } else { + strappend(result, ": "); + } + strappend(result, es); + amfree(es); + } + close(fd[0]); + + pid = wait(&exitcode); + while (pid != ruserok_pid) { + if ((pid == (pid_t) -1) && (errno != EINTR)) { + amfree(result); + return stralloc2("ruserok wait failed: %s", strerror(errno)); + } + pid = wait(&exitcode); + } + if (WIFSIGNALED(exitcode)) { + amfree(result); + snprintf(number, SIZEOF(number), "%d", WTERMSIG(exitcode)); + return stralloc2("ruserok child got signal ", number); + } + if (WEXITSTATUS(exitcode) == 0) { + amfree(result); + } else if (result == NULL) { + result = stralloc("ruserok failed"); + } + + return result; +} + +/* + * Check to see if a user is allowed in. This version uses .amandahosts + * Returns -1 on failure, or 0 on success. + */ +char * +check_user_amandahosts( + const char * host, + struct in_addr addr, + struct passwd * pwd, + const char * remoteuser, + const char * service) +{ + char *line = NULL; + char *filehost; + const char *fileuser; + char *ptmp = NULL; + char *result = NULL; + FILE *fp = NULL; + int found; + struct stat sbuf; + char n1[NUM_STR_SIZE]; + char n2[NUM_STR_SIZE]; + int hostmatch; + int usermatch; + char *aservice = NULL; + + secprintf(("check_user_amandahosts(host=%s, pwd=%p, " + "remoteuser=%s, service=%s)\n", + host, pwd, remoteuser, service)); + + ptmp = stralloc2(pwd->pw_dir, "/.amandahosts"); +#if defined(SHOW_SECURITY_DETAIL) /* { */ + show_stat_info(ptmp, "");; +#endif /* } */ + if ((fp = fopen(ptmp, "r")) == NULL) { + result = vstralloc("cannot open ", ptmp, ": ", strerror(errno), NULL); + amfree(ptmp); + return result; + } + + /* + * Make sure the file is owned by the Amanda user and does not + * have any group/other access allowed. + */ + if (fstat(fileno(fp), &sbuf) != 0) { + result = vstralloc("cannot fstat ", ptmp, ": ", strerror(errno), NULL); + goto common_exit; + } + if (sbuf.st_uid != pwd->pw_uid) { + snprintf(n1, SIZEOF(n1), "%ld", (long)sbuf.st_uid); + snprintf(n2, SIZEOF(n2), "%ld", (long)pwd->pw_uid); + result = vstralloc(ptmp, ": ", + "owned by id ", n1, + ", should be ", n2, + NULL); + goto common_exit; + } + if ((sbuf.st_mode & 077) != 0) { + result = stralloc2(ptmp, + ": incorrect permissions; file must be accessible only by its owner"); + goto common_exit; + } + + /* + * Now, scan the file for the host/user/service. + */ + found = 0; + while ((line = agets(fp)) != NULL) { + if (*line == 0) { + amfree(line); + continue; + } + +#if defined(SHOW_SECURITY_DETAIL) /* { */ + secprintf(("%s: bsd: processing line: <%s>\n", debug_prefix(NULL), line)); +#endif /* } */ + /* get the host out of the file */ + if ((filehost = strtok(line, " \t")) == NULL) { + amfree(line); + continue; + } + + /* get the username. If no user specified, then use the local user */ + if ((fileuser = strtok(NULL, " \t")) == NULL) { + fileuser = pwd->pw_name; + } + + hostmatch = (strcasecmp(filehost, host) == 0); + /* ok if addr=127.0.0.1 and + * either localhost or localhost.domain is in .amandahost */ + if ( !hostmatch ) { + if (strcmp(inet_ntoa(addr), "127.0.0.1")== 0 && + (strcasecmp(filehost, "localhost")== 0 || + strcasecmp(filehost, "localhost.localdomain")== 0)) + { + hostmatch = 1; + } + } + usermatch = (strcasecmp(fileuser, remoteuser) == 0); +#if defined(SHOW_SECURITY_DETAIL) /* { */ + secprintf(("%s: bsd: comparing \"%s\" with\n", debug_prefix(NULL), filehost)); + secprintf(("%s: bsd: \"%s\" (%s)\n", host, + debug_prefix(NULL), hostmatch ? "match" : "no match")); + secprintf(("%s: bsd: and \"%s\" with\n", fileuser, debug_prefix(NULL))); + secprintf(("%s: bsd: \"%s\" (%s)\n", remoteuser, + debug_prefix(NULL), usermatch ? "match" : "no match")); +#endif /* } */ + /* compare */ + if (!hostmatch || !usermatch) { + amfree(line); + continue; + } + + if (!service) { + /* success */ + amfree(line); + found = 1; + break; + } + + /* get the services. If no service specified, then use + * noop/selfcheck/sendsize/sendbackup + */ + aservice = strtok(NULL, " \t,"); + if (!aservice) { + if (strcmp(service,"noop") == 0 || + strcmp(service,"selfcheck") == 0 || + strcmp(service,"sendsize") == 0 || + strcmp(service,"sendbackup") == 0) { + /* success */ + found = 1; + amfree(line); + break; + } + else { + amfree(line); + break; + } + } + + do { + if (strcmp(aservice,service) == 0) { + found = 1; + break; + } + if (strcmp(aservice, "amdump") == 0 && + (strcmp(service, "noop") == 0 || + strcmp(service, "selfcheck") == 0 || + strcmp(service, "sendsize") == 0 || + strcmp(service, "sendbackup") == 0)) { + found = 1; + break; + } + } while((aservice = strtok(NULL, " \t,")) != NULL); + + if (aservice && strcmp(aservice, service) == 0) { + /* success */ + found = 1; + amfree(line); + break; + } + amfree(line); + } + if (! found) { + if (strcmp(service, "amindexd") == 0 || + strcmp(service, "amidxtaped") == 0) { + result = vstralloc("Please add \"amindexd amidxtaped\" to " + "the line in ", ptmp, NULL); + } else if (strcmp(service, "amdump") == 0 || + strcmp(service, "noop") == 0 || + strcmp(service, "selfcheck") == 0 || + strcmp(service, "sendsize") == 0 || + strcmp(service, "sendbackup") == 0) { + result = vstralloc("Please add \"amdump\" to the line in ", + ptmp, NULL); + } else { + result = vstralloc(ptmp, ": ", + "invalid service ", service, NULL); + } + } + +common_exit: + + afclose(fp); + amfree(ptmp); + + return result; +} + +/* return 1 on success, 0 on failure */ +int +check_security( + struct sockaddr_in *addr, + char * str, + unsigned long cksum, + char ** errstr) +{ + char * remotehost = NULL, *remoteuser = NULL; + char * bad_bsd = NULL; + struct hostent * hp; + struct passwd * pwptr; + uid_t myuid; + int i; + int j; + char * s; + char * fp; + int ch; + + (void)cksum; /* Quiet unused parameter warning */ + + secprintf(("%s: check_security(addr=%p, str='%s', cksum=%ul, errstr=%p\n", + debug_prefix(NULL), addr, str, cksum, errstr)); + dump_sockaddr(addr); + + *errstr = NULL; + + /* what host is making the request? */ + + hp = gethostbyaddr((char *)&addr->sin_addr, SIZEOF(addr->sin_addr), + AF_INET); + if (hp == NULL) { + /* XXX include remote address in message */ + *errstr = vstralloc("[", + "addr ", inet_ntoa(addr->sin_addr), ": ", + "hostname lookup failed", + "]", NULL); + return 0; + } + remotehost = stralloc(hp->h_name); + + /* Now let's get the hostent for that hostname */ + hp = gethostbyname( remotehost ); + if (hp == NULL) { + /* XXX include remote hostname in message */ + *errstr = vstralloc("[", + "host ", remotehost, ": ", + "hostname lookup failed", + "]", NULL); + amfree(remotehost); + return 0; + } + + /* Verify that the hostnames match -- they should theoretically */ + if (strncasecmp( remotehost, hp->h_name, strlen(remotehost)+1 ) != 0 ) { + *errstr = vstralloc("[", + "hostnames do not match: ", + remotehost, " ", hp->h_name, + "]", NULL); + amfree(remotehost); + return 0; + } + + /* Now let's verify that the ip which gave us this hostname + * is really an ip for this hostname; or is someone trying to + * break in? (THIS IS THE CRUCIAL STEP) + */ + for (i = 0; hp->h_addr_list[i]; i++) { + if (memcmp(hp->h_addr_list[i], + (char *) &addr->sin_addr, SIZEOF(addr->sin_addr)) == 0) + break; /* name is good, keep it */ + } + + /* If we did not find it, your DNS is messed up or someone is trying + * to pull a fast one on you. :( + */ + + /* Check even the aliases list. Work around for Solaris if dns goes over NIS */ + + if (!hp->h_addr_list[i] ) { + for (j = 0; hp->h_aliases[j] !=0 ; j++) { + if (strcmp(hp->h_aliases[j],inet_ntoa(addr->sin_addr)) == 0) + break; /* name is good, keep it */ + } + if (!hp->h_aliases[j] ) { + *errstr = vstralloc("[", + "ip address ", inet_ntoa(addr->sin_addr), + " is not in the ip list for ", remotehost, + "]", + NULL); + amfree(remotehost); + return 0; + } + } + + /* next, make sure the remote port is a "reserved" one */ + + if (ntohs(addr->sin_port) >= IPPORT_RESERVED) { + char number[NUM_STR_SIZE]; + + snprintf(number, SIZEOF(number), "%hd", (short)ntohs(addr->sin_port)); + *errstr = vstralloc("[", + "host ", remotehost, ": ", + "port ", number, " not secure", + "]", NULL); + amfree(remotehost); + return 0; + } + + /* extract the remote user name from the message */ + + s = str; + ch = *s++; + + bad_bsd = vstralloc("[", + "host ", remotehost, ": ", + "bad bsd security line", + "]", NULL); + +#define sc "USER " + if (strncmp(s - 1, sc, SIZEOF(sc)-1) != 0) { + *errstr = bad_bsd; + bad_bsd = NULL; + amfree(remotehost); + return 0; + } + s += SIZEOF(sc)-1; + ch = s[-1]; +#undef sc + + skip_whitespace(s, ch); + if (ch == '\0') { + *errstr = bad_bsd; + bad_bsd = NULL; + amfree(remotehost); + return 0; + } + fp = s - 1; + skip_non_whitespace(s, ch); + s[-1] = '\0'; + remoteuser = stralloc(fp); + s[-1] = (char)ch; + amfree(bad_bsd); + + /* lookup our local user name */ + + myuid = getuid(); + if ((pwptr = getpwuid(myuid)) == NULL) + error("error [getpwuid(%d) fails]", myuid); + + secprintf(("%s: bsd security: remote host %s user %s local user %s\n", + debug_prefix(NULL), remotehost, remoteuser, pwptr->pw_name)); + +#ifndef USE_AMANDAHOSTS + s = check_user_ruserok(remotehost, pwptr, remoteuser); +#else + s = check_user_amandahosts(remotehost, addr->sin_addr, pwptr, remoteuser, NULL); +#endif + + if (s != NULL) { + *errstr = vstralloc("[", + "access as ", pwptr->pw_name, " not allowed", + " from ", remoteuser, "@", remotehost, + ": ", s, "]", NULL); + } + amfree(s); + amfree(remotehost); + amfree(remoteuser); + return *errstr == NULL; +} + +/* + * Writes out the entire iovec + */ +ssize_t +net_writev( + int fd, + struct iovec * iov, + int iovcnt) +{ + ssize_t delta, n, total; + + assert(iov != NULL); + + total = 0; + while (iovcnt > 0) { + /* + * Write the iovec + */ + n = writev(fd, iov, iovcnt); + if (n < 0) { + if (errno != EINTR) + return (-1); + secprintf(("%s: net_writev got EINTR\n", + debug_prefix(NULL))); + } + else if (n == 0) { + errno = EIO; + return (-1); + } else { + total += n; + /* + * Iterate through each iov. Figure out what we still need + * to write out. + */ + for (; n > 0; iovcnt--, iov++) { + /* 'delta' is the bytes written from this iovec */ + delta = ((size_t)n < iov->iov_len) ? n : (ssize_t)iov->iov_len; + /* subtract from the total num bytes written */ + n -= delta; + assert(n >= 0); + /* subtract from this iovec */ + iov->iov_len -= delta; + iov->iov_base = (char *)iov->iov_base + delta; + /* if this iovec isn't empty, run the writev again */ + if (iov->iov_len > 0) + break; + } + } + } + return (total); +} + +/* + * Like read(), but waits until the entire buffer has been filled. + */ +ssize_t +net_read( + int fd, + void * vbuf, + size_t origsize, + int timeout) +{ + char *buf = vbuf; /* ptr arith */ + ssize_t nread; + size_t size = origsize; + + secprintf(("%s: net_read: begin %d\n", debug_prefix_time(NULL), origsize)); + + while (size > 0) { + secprintf(("%s: net_read: while %d\n", + debug_prefix_time(NULL), size)); + nread = net_read_fillbuf(fd, timeout, buf, size); + if (nread < 0) { + secprintf(("%s: db: net_read: end return(-1)\n", + debug_prefix_time(NULL))); + return (-1); + } + if (nread == 0) { + secprintf(("%s: net_read: end return(0)\n", + debug_prefix_time(NULL))); + return (0); + } + buf += nread; + size -= nread; + } + secprintf(("%s: net_read: end %d\n", + debug_prefix_time(NULL), origsize)); + return ((ssize_t)origsize); +} + +/* + * net_read likes to do a lot of little reads. Buffer it. + */ +ssize_t +net_read_fillbuf( + int fd, + int timeout, + void * buf, + size_t size) +{ + fd_set readfds; + struct timeval tv; + ssize_t nread; + + secprintf(("%s: net_read_fillbuf: begin\n", debug_prefix_time(NULL))); + FD_ZERO(&readfds); + FD_SET(fd, &readfds); + tv.tv_sec = timeout; + tv.tv_usec = 0; + switch (select(fd + 1, &readfds, NULL, NULL, &tv)) { + case 0: + errno = ETIMEDOUT; + /* FALLTHROUGH */ + case -1: + secprintf(("%s: net_read_fillbuf: case -1\n", + debug_prefix_time(NULL))); + return (-1); + case 1: + secprintf(("%s: net_read_fillbuf: case 1\n", + debug_prefix_time(NULL))); + assert(FD_ISSET(fd, &readfds)); + break; + default: + secprintf(("%s: net_read_fillbuf: case default\n", + debug_prefix_time(NULL))); + assert(0); + break; + } + nread = read(fd, buf, size); + if (nread < 0) + return (-1); + secprintf(("%s: net_read_fillbuf: end %d\n", + debug_prefix_time(NULL), nread)); + return (nread); +} + + +/* + * Display stat() information about a file. + */ + +void +show_stat_info( + char * a, + char * b) +{ + char *name = vstralloc(a, b, NULL); + struct stat sbuf; + struct passwd *pwptr; + char *owner; + struct group *grptr; + char *group; + + if (stat(name, &sbuf) != 0) { + secprintf(("%s: bsd: cannot stat %s: %s\n", + debug_prefix_time(NULL), name, strerror(errno))); + amfree(name); + return; + } + if ((pwptr = getpwuid(sbuf.st_uid)) == NULL) { + owner = alloc(NUM_STR_SIZE + 1); + snprintf(owner, NUM_STR_SIZE, "%ld", (long)sbuf.st_uid); + } else { + owner = stralloc(pwptr->pw_name); + } + if ((grptr = getgrgid(sbuf.st_gid)) == NULL) { + group = alloc(NUM_STR_SIZE + 1); + snprintf(owner, NUM_STR_SIZE, "%ld", (long)sbuf.st_gid); + } else { + group = stralloc(grptr->gr_name); + } + secprintf(("%s: bsd: processing file: %s\n", debug_prefix(NULL), name)); + secprintf(("%s: bsd: owner=%s group=%s mode=%03o\n", + debug_prefix(NULL), owner, group, (int) (sbuf.st_mode & 0777))); + amfree(name); + amfree(owner); + amfree(group); +} diff --git a/common-src/security-util.h b/common-src/security-util.h new file mode 100644 index 0000000..b1d8faa --- /dev/null +++ b/common-src/security-util.h @@ -0,0 +1,254 @@ +#ifndef _SECURITY_UTIL_H +#define _SECURITY_UTIL_H + +/* + * Amanda, The Advanced Maryland Automatic Network Disk Archiver + * Copyright (c) 1999 University of Maryland + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of U.M. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. U.M. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: the Amanda Development Team. Its members are listed in a + * file named AUTHORS, in the root directory of this distribution. + */ + +/* + * $Id: security-util.h,v 1.5 2006/07/01 00:10:38 paddy_s Exp $ + * + */ + +#include "stream.h" +#include "dgram.h" +#include "queue.h" + +struct sec_handle; + +/* + * This is a sec connection to a host. We should only have + * one connection per host. + */ +struct tcp_conn { + const struct security_driver *driver; /* MUST be first */ + int read, write; /* pipes to sec */ + pid_t pid; /* pid of sec process */ + char * pkt; /* last pkt read */ + ssize_t pktlen; /* len of above */ + event_handle_t * ev_read; /* read (EV_READFD) handle */ + int ev_read_refcnt; /* number of readers */ + char hostname[MAX_HOSTNAME_LENGTH+1]; + /* host we're talking to */ + char * errmsg; /* error passed up */ + int refcnt; /* number of handles using */ + int handle; /* last proto handle read */ + void (*accept_fn)(security_handle_t *, pkt_t *); + struct sockaddr_in peer; + TAILQ_ENTRY(tcp_conn) tq; /* queue handle */ + int (*recv_security_ok)(struct sec_handle *, pkt_t *); + char * (*prefix_packet)(void *, pkt_t *); + int toclose; + int donotclose; +}; + + +struct sec_stream; + +/* + * This is the private handle data. + */ +struct sec_handle { + security_handle_t sech; /* MUST be first */ + char * hostname; /* ptr to rc->hostname */ + struct sec_stream * rs; /* virtual stream we xmit over */ + struct tcp_conn * rc; /* */ + union { + void (*recvpkt)(void *, pkt_t *, security_status_t); + /* func to call when packet recvd */ + void (*connect)(void *, security_handle_t *, security_status_t); + /* func to call when connected */ + } fn; + void * arg; /* argument to pass function */ + event_handle_t * ev_timeout; /* timeout handle for recv */ + struct sockaddr_in peer; + int sequence; + event_id_t event_id; + char * proto_handle; + event_handle_t * ev_read; + struct sec_handle * prev; + struct sec_handle * next; + struct udp_handle * udp; + void (*accept_fn)(security_handle_t *, pkt_t *); + int (*recv_security_ok)(struct sec_handle *, pkt_t *); +}; + +/* + * This is the internal security_stream data for sec. + */ +struct sec_stream { + security_stream_t secstr; /* MUST be first */ + struct tcp_conn * rc; /* physical connection */ + int handle; /* protocol handle */ + event_handle_t * ev_read; /* read (EV_WAIT) event handle */ + void (*fn)(void *, void *, ssize_t); /* read event fn */ + void * arg; /* arg for previous */ + int fd; + char databuf[NETWORK_BLOCK_BYTES]; + ssize_t len; + int socket; + in_port_t port; + int closed_by_me; + int closed_by_network; +}; + +struct connq_s { + TAILQ_HEAD(, tcp_conn) tailq; + int qlength; +}; +extern struct connq_s connq; + +#define connq_first() TAILQ_FIRST(&connq.tailq) +#define connq_next(rc) TAILQ_NEXT(rc, tq) +#define connq_append(rc) do { \ + TAILQ_INSERT_TAIL(&connq.tailq, rc, tq); \ + connq.qlength++; \ +} while (0) +#define connq_remove(rc) do { \ + assert(connq.qlength > 0); \ + TAILQ_REMOVE(&connq.tailq, rc, tq); \ + connq.qlength--; \ +} while (0) + +/* + * This is data local to the datagram socket. We have one datagram + * per process per auth. + */ +typedef struct udp_handle { + const struct security_driver *driver; /* MUST be first */ + dgram_t dgram; /* datagram to read/write from */ + struct sockaddr_in peer; /* who sent it to us */ + pkt_t pkt; /* parsed form of dgram */ + char *handle; /* handle from recvd packet */ + int sequence; /* seq no of packet */ + event_handle_t *ev_read; /* read event handle from dgram */ + int refcnt; /* number of handles blocked for reading */ + struct sec_handle *bh_first, *bh_last; + void (*accept_fn)(security_handle_t *, pkt_t *); + int (*recv_security_ok)(struct sec_handle *, pkt_t *); + char *(*prefix_packet)(void *, pkt_t *); +} udp_handle_t; + +/* + * We register one event handler for our network fd which takes + * care of all of our async requests. When all async requests + * have either been satisfied or cancelled, we unregister our + * network event handler. + */ +#define udp_addref(udp, netfd_read_callback) do { \ + if ((udp)->refcnt++ == 0) { \ + assert((udp)->ev_read == NULL); \ + (udp)->ev_read = event_register((event_id_t)(udp)->dgram.socket,\ + EV_READFD, netfd_read_callback, (udp)); \ + } \ + assert((udp)->refcnt > 0); \ +} while (0) + +/* + * If this is the last request to be removed, then remove the + * reader event from the netfd. + */ +#define udp_delref(udp) do { \ + assert((udp)->refcnt > 0); \ + if (--(udp)->refcnt == 0) { \ + assert((udp)->ev_read != NULL); \ + event_release((udp)->ev_read); \ + (udp)->ev_read = NULL; \ + } \ +} while (0) + + +int sec_stream_auth(void *); +int sec_stream_id(void *); +void sec_accept(const security_driver_t *, int, int, + void (*)(security_handle_t *, pkt_t *)); +void sec_close(void *); +void sec_connect_callback(void *); +void sec_connect_timeout(void *); +void sec_close_connection_none(void *, char *); + +ssize_t stream_sendpkt(void *, pkt_t *); +void stream_recvpkt(void *, + void (*)(void *, pkt_t *, security_status_t), + void *, int); +void stream_recvpkt_timeout(void *); +void stream_recvpkt_cancel(void *); + +int tcpm_stream_write(void *, const void *, size_t); +void tcpm_stream_read(void *, void (*)(void *, void *, ssize_t), void *); +ssize_t tcpm_stream_read_sync(void *, void **); +void tcpm_stream_read_cancel(void *); +ssize_t tcpm_send_token(int, int, char **, const void *, size_t); +ssize_t tcpm_recv_token(int, int *, char **, char **, ssize_t *, int); +void tcpm_close_connection(void *, char *); + +int tcpma_stream_accept(void *); +void * tcpma_stream_client(void *, int); +void * tcpma_stream_server(void *); +void tcpma_stream_close(void *); + +void * tcp1_stream_server(void *); +int tcp1_stream_accept(void *); +void * tcp1_stream_client(void *, int); + +int tcp_stream_write(void *, const void *, size_t); + +char * bsd_prefix_packet(void *, pkt_t *); +int bsd_recv_security_ok(struct sec_handle *, pkt_t *); + +ssize_t udpbsd_sendpkt(void *, pkt_t *); +void udp_close(void *); +void udp_recvpkt(void *, void (*)(void *, pkt_t *, security_status_t), + void *, int); +void udp_recvpkt_cancel(void *); +void udp_recvpkt_callback(void *); +void udp_recvpkt_timeout(void *); +int udp_inithandle(udp_handle_t *, struct sec_handle *, struct hostent *, + in_port_t, char *, int); +void udp_netfd_read_callback(void *); + +struct tcp_conn *sec_tcp_conn_get(const char *, int); +void sec_tcp_conn_put(struct tcp_conn *); +void sec_tcp_conn_read(struct tcp_conn *); +void parse_pkt(pkt_t *, const void *, size_t); +const char *pkthdr2str(const struct sec_handle *, const pkt_t *); +int str2pkthdr(udp_handle_t *); +char * check_user(struct sec_handle *, const char *, const char *); + +char * check_user_ruserok (const char *host, + struct passwd *pwd, + const char *user); +char * check_user_amandahosts(const char *host, + struct in_addr addr, + struct passwd *pwd, + const char *user, + const char *service); + +ssize_t net_writev(int, struct iovec *, int); +ssize_t net_read(int, void *, size_t, int); +ssize_t net_read_fillbuf(int, int, void *, size_t); +void show_stat_info(char *a, char *b); + +#endif /* _SECURITY_INFO_H */ diff --git a/common-src/security.c b/common-src/security.c index 795d64e..76cf78d 100644 --- a/common-src/security.c +++ b/common-src/security.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: security.c,v 1.26 2004/03/16 19:09:39 martinea Exp $ + * $Id: security.c,v 1.28 2006/05/25 01:47:12 johnfranks Exp $ * * Security driver interface for the Amanda backup system. */ @@ -49,6 +49,12 @@ extern const security_driver_t rsh_security_driver; #ifdef SSH_SECURITY extern const security_driver_t ssh_security_driver; #endif +#ifdef BSDTCP_SECURITY +extern const security_driver_t bsdtcp_security_driver; +#endif +#ifdef BSDUDP_SECURITY +extern const security_driver_t bsdudp_security_driver; +#endif static const security_driver_t *drivers[] = { #ifdef BSD_SECURITY @@ -66,23 +72,34 @@ static const security_driver_t *drivers[] = { #ifdef SSH_SECURITY &ssh_security_driver, #endif +#ifdef BSDTCP_SECURITY + &bsdtcp_security_driver, +#endif +#ifdef BSDUDP_SECURITY + &bsdudp_security_driver, +#endif }; -#define NDRIVERS (sizeof(drivers) / sizeof(drivers[0])) +#define NDRIVERS (size_t)(sizeof(drivers) / sizeof(drivers[0])) /* * Given a name of a security type, returns the driver structure */ const security_driver_t * -security_getdriver(name) - const char *name; +security_getdriver( + const char * name) { - int i; + size_t i; assert(name != NULL); - for (i = 0; i < NDRIVERS; i++) - if (strcasecmp(name, drivers[i]->name) == 0) + for (i = 0; i < NDRIVERS; i++) { + if (strcasecmp(name, drivers[i]->name) == 0) { + dbprintf(("security_getdriver(name=%s) returns %p\n", + name, drivers[i])); return (drivers[i]); + } + } + dbprintf(("security_getdriver(name=%s) returns NULL\n", name)); return (NULL); } @@ -90,11 +107,12 @@ security_getdriver(name) * For the drivers: initialize the common part of a security_handle_t */ void -security_handleinit(handle, driver) - security_handle_t *handle; - const security_driver_t *driver; +security_handleinit( + security_handle_t * handle, + const security_driver_t * driver) { - + dbprintf(("security_handleinit(handle=%p, driver=%p (%s))\n", + handle, driver, driver->name)); handle->driver = driver; handle->error = stralloc("unknown protocol error"); } @@ -107,16 +125,19 @@ printf_arglist_function1(void security_seterror, security_handle_t *, handle, assert(handle->error != NULL); arglist_start(argp, fmt); - vsnprintf(buf, sizeof(buf), fmt, argp); + vsnprintf(buf, SIZEOF(buf), fmt, argp); arglist_end(argp); handle->error = newstralloc(handle->error, buf); + dbprintf(("security_seterror(handle=%p, driver=%p (%s) error=%s)\n", + handle, handle->driver, handle->driver->name, handle->error)); } void -security_close(handle) - security_handle_t *handle; +security_close( + security_handle_t * handle) { - + dbprintf(("security_close(handle=%p, driver=%p (%s))\n", + handle, handle->driver, handle->driver->name)); amfree(handle->error); (*handle->driver->close)(handle); } @@ -125,11 +146,12 @@ security_close(handle) * For the drivers: initialize the common part of a security_stream_t */ void -security_streaminit(stream, driver) - security_stream_t *stream; - const security_driver_t *driver; +security_streaminit( + security_stream_t * stream, + const security_driver_t * driver) { - + dbprintf(("security_streaminit(stream=%p, driver=%p (%s))\n", + stream, driver, driver->name)); stream->driver = driver; stream->error = stralloc("unknown stream error"); } @@ -141,18 +163,18 @@ printf_arglist_function1(void security_stream_seterror, static char buf[256]; va_list argp; - assert(stream->error != NULL); arglist_start(argp, fmt); - vsnprintf(buf, sizeof(buf), fmt, argp); + vsnprintf(buf, SIZEOF(buf), fmt, argp); arglist_end(argp); stream->error = newstralloc(stream->error, buf); + dbprintf(("security_stream_seterr(%p, %s)\n", stream, stream->error)); } void -security_stream_close(stream) - security_stream_t *stream; +security_stream_close( + security_stream_t * stream) { - + dbprintf(("security_stream_close(%p)\n", stream)); amfree(stream->error); (*stream->driver->stream_close)(stream); } diff --git a/common-src/security.h b/common-src/security.h index 9d8448e..d0971b4 100644 --- a/common-src/security.h +++ b/common-src/security.h @@ -24,13 +24,15 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: security.h,v 1.11 2003/04/26 02:02:19 kovert Exp $ + * $Id: security.h,v 1.17 2006/05/26 14:00:58 martinea Exp $ * * security api */ #ifndef SECURITY_H #define SECURITY_H +#include "packet.h" + struct security_handle; /* @@ -55,27 +57,28 @@ typedef struct security_driver { * Connects a security handle, for this driver to a remote * host. */ - void (*connect) P((const char *, + void (*connect)(const char *, char *(*)(char *, void *), void (*)(void *, struct security_handle *, security_status_t), - void *)); + void *, void *); /* * This form sets up a callback that returns new handles as * they are received. It takes an input and output file descriptor. */ - void (*accept) P((int, int, void (*)(struct security_handle *, pkt_t *))); + void (*accept)(const struct security_driver *, int, int, + void (*)(struct security_handle *, pkt_t *)); /* * Frees up handles allocated by the previous */ - void (*close) P((void *)); + void (*close)(void *); /* * This transmits a packet after adding the security information * Returns 0 on success, negative on error. */ - int (*sendpkt) P((void *, pkt_t *)); + ssize_t (*sendpkt)(void *, pkt_t *); /* * This creates an event in the event handler for receiving pkt_t's @@ -89,60 +92,67 @@ typedef struct security_driver { * * Only one recvpkt request can exist per handle. */ - void (*recvpkt) P((void *, void (*)(void *, pkt_t *, - security_status_t), void *, int)); + void (*recvpkt)(void *, void (*)(void *, pkt_t *, + security_status_t), void *, int); /* * Cancel an outstanding recvpkt request on a handle. */ - void (*recvpkt_cancel) P((void *)); + void (*recvpkt_cancel)(void *); /* * Get a stream given a security handle */ - void *(*stream_server) P((void *)); + void *(*stream_server)(void *); /* * Accept a stream created by stream_server */ - int (*stream_accept) P((void *)); + int (*stream_accept)(void *); /* * Get a stream and connect it to a remote given a security handle * and a stream id. */ - void *(*stream_client) P((void *, int)); + void *(*stream_client)(void *, int); /* * Close a stream opened with stream_server or stream_client */ - void (*stream_close) P((void *)); + void (*stream_close)(void *); /* * Authenticate a stream. */ - int (*stream_auth) P((void *)); + int (*stream_auth)(void *); /* * Return a numeric id for a stream. */ - int (*stream_id) P((void *)); + int (*stream_id)(void *); /* * Write to a stream. */ - int (*stream_write) P((void *, const void *, size_t)); + int (*stream_write)(void *, const void *, size_t); /* * Read asyncronously from a stream. Only one request can exist * per stream. */ - void (*stream_read) P((void *, void (*)(void *, void *, ssize_t), void *)); + void (*stream_read)(void *, void (*)(void *, void *, ssize_t), void *); + + /* + * Read syncronously from a stream. + */ + ssize_t (*stream_read_sync)(void *, void **); /* * Cancel a stream read request */ - void (*stream_read_cancel) P((void *)); + void (*stream_read_cancel)(void *); + + void (*close_connection)(void *, char *); } security_driver_t; @@ -169,77 +179,83 @@ typedef struct security_stream { } security_stream_t; -const security_driver_t *security_getdriver P((const char *)); -void security_handleinit P((security_handle_t *, const security_driver_t *)); -void security_streaminit P((security_stream_t *, const security_driver_t *)); +const security_driver_t *security_getdriver(const char *); +void security_handleinit(security_handle_t *, const security_driver_t *); +void security_streaminit(security_stream_t *, const security_driver_t *); -/* const char *security_geterror P((security_handle_t *)); */ +/* const char *security_geterror(security_handle_t *); */ #define security_geterror(handle) ((handle)->error) -void security_seterror P((security_handle_t *, const char *, ...)) +void security_seterror(security_handle_t *, const char *, ...) __attribute__ ((format (printf, 2, 3))); -/* void security_connect P((const security_driver_t *, const char *, - void (*)(void *, security_handle_t *, security_status_t), void *)); */ -#define security_connect(driver, hostname, conf_fn, fn, arg) \ - (*(driver)->connect)(hostname, conf_fn, fn, arg) -/* void security_accept P((const security_driver_t *, int, int, - void (*)(security_handle_t *, pkt_t *))); */ +/* void security_connect(const security_driver_t *, const char *, + void (*)(void *, security_handle_t *, security_status_t), void *, void *); */ +#define security_connect(driver, hostname, conf_fn, fn, arg, datap) \ + (*(driver)->connect)(hostname, conf_fn, fn, arg, datap) +/* void security_accept(const security_driver_t *, int, int, + void (*)(security_handle_t *, pkt_t *)); */ #define security_accept(driver, in, out, fn) \ - (*(driver)->accept)(in, out, fn) -void security_close P((security_handle_t *)); + (*(driver)->accept)(driver, in, out, fn) +void security_close(security_handle_t *); -/* int security_sendpkt P((security_handle_t *, const pkt_t *)); */ +/* int security_sendpkt(security_handle_t *, const pkt_t *); */ #define security_sendpkt(handle, pkt) \ (*(handle)->driver->sendpkt)(handle, pkt) -/* void security_recvpkt P((security_handle_t *, +/* void security_recvpkt(security_handle_t *, void (*)(void *, pkt_t *, security_status_t), void *, int); */ #define security_recvpkt(handle, fn, arg, timeout) \ (*(handle)->driver->recvpkt)(handle, fn, arg, timeout) -/* void security_recvpkt_cancel P((security_handle_t *)); */ +/* void security_recvpkt_cancel(security_handle_t *); */ #define security_recvpkt_cancel(handle) \ (*(handle)->driver->recvpkt_cancel)(handle) -/* const char *security_stream_geterror P((security_stream_t *)); */ +/* const char *security_stream_geterror(security_stream_t *); */ #define security_stream_geterror(stream) ((stream)->error) -void security_stream_seterror P((security_stream_t *, const char *, ...)) +void security_stream_seterror(security_stream_t *, const char *, ...) __attribute__ ((format (printf, 2, 3))); -/* security_stream_t *security_stream_server P((security_handle_t *)); */ +/* security_stream_t *security_stream_server(security_handle_t *); */ #define security_stream_server(handle) \ (*(handle)->driver->stream_server)(handle) -/* int security_stream_accept P((security_stream_t *)); */ +/* int security_stream_accept(security_stream_t *); */ #define security_stream_accept(stream) \ (*(stream)->driver->stream_accept)(stream) -/* security_stream_t *security_stream_client P((security_handle_t *, int)); */ +/* security_stream_t *security_stream_client(security_handle_t *, int); */ #define security_stream_client(handle, id) \ (*(handle)->driver->stream_client)(handle, id) -void security_stream_close P((security_stream_t *)); +void security_stream_close(security_stream_t *); -/* int security_stream_auth P((security_stream_t *)); */ +/* int security_stream_auth(security_stream_t *); */ #define security_stream_auth(stream) \ (*(stream)->driver->stream_auth)(stream) -/* int security_stream_id P((security_stream_t *)); */ +/* int security_stream_id(security_stream_t *); */ #define security_stream_id(stream) \ (*(stream)->driver->stream_id)(stream) -/* int security_stream_write P((security_stream_t *, const void *, size_t)); */ +/* int security_stream_write(security_stream_t *, const void *, size_t); */ #define security_stream_write(stream, buf, size) \ (*(stream)->driver->stream_write)(stream, buf, size) -/* void security_stream_read P((security_stream_t *, - void (*)(void *, void *, size_t), void *)); */ +/* void security_stream_read(security_stream_t *, + void (*)(void *, void *, size_t), void *); */ #define security_stream_read(stream, fn, arg) \ (*(stream)->driver->stream_read)(stream, fn, arg) -/* void security_stream_read_cancel P((security_stream_t *)); */ +/* void security_stream_read_sync(security_stream_t *, void *); */ +#define security_stream_read_sync(stream, buf) \ + (*(stream)->driver->stream_read_sync)(stream, buf) + +/* void security_stream_read_cancel(security_stream_t *); */ #define security_stream_read_cancel(stream) \ (*(stream)->driver->stream_read_cancel)(stream) +#define security_close_connection(handle, hostname) \ + (*(handle)->driver->close_connection)(handle, hostname) #endif /* SECURITY_H */ diff --git a/common-src/sl.c b/common-src/sl.c index 4459960..f84ebb3 100644 --- a/common-src/sl.c +++ b/common-src/sl.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: sl.c,v 1.5 2005/09/30 19:01:43 martinea Exp $ + * $Id: sl.c,v 1.6 2006/05/25 01:47:12 johnfranks Exp $ * * A doubly linked list of string (char *) */ @@ -34,8 +34,8 @@ #include "sl.h" -void init_sl(sl) -sl_t *sl; +void init_sl( + sl_t *sl) { sl->first = NULL; sl->last = NULL; @@ -43,24 +43,27 @@ sl_t *sl; } -sl_t *new_sl() { +sl_t * +new_sl(void) +{ sl_t *sl; - sl = alloc(sizeof(sl_t)); + sl = alloc(SIZEOF(sl_t)); init_sl(sl); return(sl); } -sl_t *insert_sl(sl, name) -sl_t *sl; -char *name; +sl_t * +insert_sl( + sl_t *sl, + char *name) { sle_t *a; if(!sl) { sl = new_sl(); } - a = alloc(sizeof(sle_t)); + a = alloc(SIZEOF(sle_t)); a->name = stralloc(name); a->next = sl->first; a->prev = NULL; @@ -74,16 +77,17 @@ char *name; } -sl_t *append_sl(sl, name) -sl_t *sl; -char *name; +sl_t * +append_sl( + sl_t * sl, + char * name) { sle_t *a; if(!sl) { sl = new_sl(); } - a = alloc(sizeof(sle_t)); + a = alloc(SIZEOF(sle_t)); a->name = stralloc(name); a->prev = sl->last; a->next = NULL; @@ -97,9 +101,10 @@ char *name; } -sl_t *insert_sort_sl(sl, name) -sl_t *sl; -char *name; +sl_t * +insert_sort_sl( + sl_t * sl, + char * name) { sle_t *a, *b; @@ -116,7 +121,7 @@ char *name; if(b == sl->first) return insert_sl(sl, name); if(b == NULL) return append_sl(sl, name); - a = alloc(sizeof(sle_t)); + a = alloc(SIZEOF(sle_t)); a->name = stralloc(name); /* insert before b */ @@ -129,8 +134,9 @@ char *name; } -void free_sl(sl) -sl_t *sl; +void +free_sl( + sl_t * sl) { sle_t *a, *b; @@ -147,9 +153,10 @@ sl_t *sl; } -void remove_sl(sl, elem) -sl_t *sl; -sle_t *elem; +void +remove_sl( + sl_t * sl, + sle_t * elem) { if(elem->prev) elem->prev->next = elem->next; @@ -168,8 +175,9 @@ sle_t *elem; } -sl_t *duplicate_sl(sl) -sl_t *sl; +sl_t * +duplicate_sl( + sl_t * sl) { sl_t *new_sl = NULL; sle_t *a; @@ -186,8 +194,9 @@ sl_t *sl; /* * Return "true" iff sl is empty (i.e. contains no elements). */ -int is_empty_sl(sl) -sl_t *sl; +int +is_empty_sl( + sl_t * sl) { if (sl == NULL) return 1; diff --git a/common-src/sl.h b/common-src/sl.h index a54a784..7671d79 100644 --- a/common-src/sl.h +++ b/common-src/sl.h @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: sl.h,v 1.3 2004/04/23 11:44:46 martinea Exp $ + * $Id: sl.h,v 1.4 2006/05/25 01:47:12 johnfranks Exp $ * * A doubly linked list of string (char *) */ @@ -51,14 +51,14 @@ typedef struct sl_s { int nb_element; } sl_t; -void init_sl P((sl_t *sl)); -sl_t *new_sl P(()); -sl_t *insert_sl P((sl_t *sl, char *name)); -sl_t *append_sl P((sl_t *sl, char *name)); -sl_t *insert_sort_sl P((sl_t *sl, char *name)); -void free_sl P((sl_t *sl)); -void remove_sl P((sl_t *sl,sle_t *elem)); -sl_t *duplicate_sl P((sl_t *sl)); -int is_empty_sl P((sl_t *sl)); +void init_sl(sl_t *sl); +sl_t *new_sl(void); +sl_t *insert_sl(sl_t *sl, char *name); +sl_t *append_sl(sl_t *sl, char *name); +sl_t *insert_sort_sl(sl_t *sl, char *name); +void free_sl(sl_t *sl); +void remove_sl(sl_t *sl,sle_t *elem); +sl_t *duplicate_sl(sl_t *sl); +int is_empty_sl(sl_t *sl); #endif diff --git a/common-src/ssh-security.c b/common-src/ssh-security.c index 83a7a2c..c0b023c 100644 --- a/common-src/ssh-security.c +++ b/common-src/ssh-security.c @@ -25,7 +25,7 @@ */ /* - * $Id: ssh-security.c,v 1.8.2.1 2006/04/11 11:11:16 martinea Exp $ + * $Id: ssh-security.c,v 1.23 2006/08/21 20:17:10 martinea Exp $ * * ssh-security.c - security and transport over ssh or a ssh-like command. * @@ -34,10 +34,12 @@ */ #include "amanda.h" +#include "util.h" #include "event.h" #include "packet.h" #include "queue.h" #include "security.h" +#include "security-util.h" #include "stream.h" #include "version.h" @@ -46,11 +48,18 @@ /*#define SSH_DEBUG*/ #ifdef SSH_DEBUG -#define sshprintf(x) dbprintf(x) +int ssh_debug = 1; #else -#define sshprintf(x) +int ssh_debug = 0; #endif +#define sshprintf(x) \ + do { \ + if (ssh_debug) { \ + dbprintf(x); \ + } \ + } while (0) + /* * Path to the ssh binary. This should be configurable. */ @@ -59,7 +68,7 @@ /* * Arguments to ssh. This should also be configurable */ -#define SSH_ARGS "-x", "-l", CLIENT_LOGIN +#define SSH_ARGS "-x", "-o", "BatchMode=yes", "-o", "PreferredAuthentications=publickey" /* * Number of seconds ssh has to start up @@ -72,85 +81,12 @@ #define H_TAKEN -1 /* ssh_conn->tok was already read */ #define H_EOF -2 /* this connection has been shut down */ -/* - * This is a ssh connection to a host. We should only have - * one connection per host. - */ -struct ssh_conn { - int read, write; /* pipes to ssh */ - pid_t pid; /* pid of ssh process */ - char pkt[NETWORK_BLOCK_BYTES]; /* last pkt read */ - unsigned long pktlen; /* len of above */ - struct { /* buffer read() calls */ - char buf[STREAM_BUFSIZE]; /* buffer */ - size_t left; /* unread data */ - ssize_t size; /* size of last read */ - } readbuf; - event_handle_t *ev_read; /* read (EV_READFD) handle */ - int ev_read_refcnt; /* number of readers */ - char hostname[MAX_HOSTNAME_LENGTH+1]; /* host we're talking to */ - char *errmsg; /* error passed up */ - int refcnt; /* number of handles using */ - int handle; /* last proto handle read */ - TAILQ_ENTRY(ssh_conn) tq; /* queue handle */ -}; - - -struct ssh_stream; - -/* - * This is the private handle data. - */ -struct ssh_handle { - security_handle_t sech; /* MUST be first */ - char *hostname; /* ptr to rc->hostname */ - struct ssh_stream *rs; /* virtual stream we xmit over */ - - union { - void (*recvpkt) P((void *, pkt_t *, security_status_t)); - /* func to call when packet recvd */ - void (*connect) P((void *, security_handle_t *, security_status_t)); - /* func to call when connected */ - } fn; - void *arg; /* argument to pass function */ - event_handle_t *ev_timeout; /* timeout handle for recv */ -}; - -/* - * This is the internal security_stream data for ssh. - */ -struct ssh_stream { - security_stream_t secstr; /* MUST be first */ - struct ssh_conn *rc; /* physical connection */ - int handle; /* protocol handle */ - event_handle_t *ev_read; /* read (EV_WAIT) event handle */ - void (*fn) P((void *, void *, ssize_t)); /* read event fn */ - void *arg; /* arg for previous */ -}; - /* * Interface functions */ -static int ssh_sendpkt P((void *, pkt_t *)); -static int ssh_stream_accept P((void *)); -static int ssh_stream_auth P((void *)); -static int ssh_stream_id P((void *)); -static int ssh_stream_write P((void *, const void *, size_t)); -static void *ssh_stream_client P((void *, int)); -static void *ssh_stream_server P((void *)); -static void ssh_accept P((int, int, - void (*)(security_handle_t *, pkt_t *))); -static void ssh_close P((void *)); -static void ssh_connect P((const char *, - char *(*)(char *, void *), - void (*)(void *, security_handle_t *, security_status_t), void *)); -static void ssh_recvpkt P((void *, - void (*)(void *, pkt_t *, security_status_t), void *, int)); -static void ssh_recvpkt_cancel P((void *)); -static void ssh_stream_close P((void *)); -static void ssh_stream_read P((void *, void (*)(void *, void *, ssize_t), - void *)); -static void ssh_stream_read_cancel P((void *)); +static void ssh_connect(const char *, char *(*)(char *, void *), + void (*)(void *, security_handle_t *, security_status_t), + void *, void *); /* * This is our interface to the outside world. @@ -158,126 +94,96 @@ static void ssh_stream_read_cancel P((void *)); const security_driver_t ssh_security_driver = { "SSH", ssh_connect, - ssh_accept, - ssh_close, - ssh_sendpkt, - ssh_recvpkt, - ssh_recvpkt_cancel, - ssh_stream_server, - ssh_stream_accept, - ssh_stream_client, - ssh_stream_close, - ssh_stream_auth, - ssh_stream_id, - ssh_stream_write, - ssh_stream_read, - ssh_stream_read_cancel, -}; - -/* - * This is a queue of open connections - */ -static struct { - TAILQ_HEAD(, ssh_conn) tailq; - int qlength; -} connq = { - TAILQ_HEAD_INITIALIZER(connq.tailq), 0 + sec_accept, + sec_close, + stream_sendpkt, + stream_recvpkt, + stream_recvpkt_cancel, + tcpma_stream_server, + tcpma_stream_accept, + tcpma_stream_client, + tcpma_stream_close, + sec_stream_auth, + sec_stream_id, + tcpm_stream_write, + tcpm_stream_read, + tcpm_stream_read_sync, + tcpm_stream_read_cancel, + tcpm_close_connection, }; -#define connq_first() TAILQ_FIRST(&connq.tailq) -#define connq_next(rc) TAILQ_NEXT(rc, tq) -#define connq_append(rc) do { \ - TAILQ_INSERT_TAIL(&connq.tailq, rc, tq); \ - connq.qlength++; \ -} while (0) -#define connq_remove(rc) do { \ - assert(connq.qlength > 0); \ - TAILQ_REMOVE(&connq.tailq, rc, tq); \ - connq.qlength--; \ -} while (0) static int newhandle = 1; -/* - * This is a function that should be called if a new security_handle_t is - * created. If NULL, no new handles are created. - * It is passed the new handle and the received pkt - */ -static void (*accept_fn) P((security_handle_t *, pkt_t *)); - /* * Local functions */ -static void connect_callback P((void *)); -static void connect_timeout P((void *)); -static int send_token P((struct ssh_conn *, int, const void *, size_t)); -static int recv_token P((struct ssh_conn *, int)); -static void recvpkt_callback P((void *, void *, ssize_t)); -static void recvpkt_timeout P((void *)); -static void stream_read_callback P((void *)); - -static int runssh P((struct ssh_conn *)); -static struct ssh_conn *conn_get P((const char *)); -static void conn_put P((struct ssh_conn *)); -static void conn_read P((struct ssh_conn *)); -static void conn_read_cancel P((struct ssh_conn *)); -static void conn_read_callback P((void *)); -static int net_writev P((int, struct iovec *, int)); -static ssize_t net_read P((struct ssh_conn *, void *, size_t, int)); -static int net_read_fillbuf P((struct ssh_conn *, int, int)); -static void parse_pkt P((pkt_t *, const void *, size_t)); - +static int runssh(struct tcp_conn *, const char *, const char *, const char *); /* * ssh version of a security handle allocator. Logically sets * up a network "connection". */ static void -ssh_connect(hostname, conf_fn, fn, arg) - const char *hostname; - char *(*conf_fn) P((char *, void *)); - void (*fn) P((void *, security_handle_t *, security_status_t)); - void *arg; -{ - struct ssh_handle *rh; +ssh_connect( + const char * hostname, + char * (*conf_fn)(char *, void *), + void (*fn)(void *, security_handle_t *, security_status_t), + void * arg, + void * datap) +{ + struct sec_handle *rh; struct hostent *he; + char *amandad_path=NULL, *client_username=NULL, *ssh_keys=NULL; assert(fn != NULL); assert(hostname != NULL); - sshprintf(("%s: ssh: ssh_connect: %s\n", debug_prefix_time(NULL), hostname)); + (void)conf_fn; /* Quiet unused parameter warning */ + + sshprintf(("%s: ssh: ssh_connect: %s\n", debug_prefix_time(NULL), + hostname)); - rh = alloc(sizeof(*rh)); + rh = alloc(SIZEOF(*rh)); security_handleinit(&rh->sech, &ssh_security_driver); rh->hostname = NULL; rh->rs = NULL; rh->ev_timeout = NULL; + rh->rc = NULL; if ((he = gethostbyname(hostname)) == NULL) { security_seterror(&rh->sech, - "%s: could not resolve hostname", hostname); + "%s: ssh could not resolve hostname", hostname); (*fn)(arg, &rh->sech, S_ERROR); return; } - rh->hostname = he->h_name; /* will be replaced */ - rh->rs = ssh_stream_client(rh, newhandle++); + rh->hostname = stralloc(he->h_name); /* will be replaced */ + rh->rs = tcpma_stream_client(rh, newhandle++); if (rh->rs == NULL) goto error; - rh->hostname = rh->rs->rc->hostname; + amfree(rh->hostname); + rh->hostname = stralloc(rh->rs->rc->hostname); - if (rh->rs->rc->pid < 0) { - /* - * We need to open a new connection. - * - * XXX need to eventually limit number of outgoing connections here. - */ - if (runssh(rh->rs->rc) < 0) { - security_seterror(&rh->sech, - "can't connect to %s: %s", hostname, rh->rs->rc->errmsg); + /* + * We need to open a new connection. + * + * XXX need to eventually limit number of outgoing connections here. + */ + if(conf_fn) { + amandad_path = conf_fn("amandad_path", datap); + client_username = conf_fn("client_username", datap); + ssh_keys = conf_fn("ssh_keys", datap); + } + if(rh->rc->read == -1) { + if (runssh(rh->rs->rc, amandad_path, client_username, ssh_keys) < 0) { + security_seterror(&rh->sech, "can't connect to %s: %s", + hostname, rh->rs->rc->errmsg); goto error; } + rh->rc->refcnt++; } + /* * The socket will be opened async so hosts that are down won't * block everything. We need to register a write event @@ -288,10 +194,10 @@ ssh_connect(hostname, conf_fn, fn, arg) */ rh->fn.connect = fn; rh->arg = arg; - rh->rs->ev_read = event_register(rh->rs->rc->write, EV_WRITEFD, - connect_callback, rh); - rh->ev_timeout = event_register(CONNECT_TIMEOUT, EV_TIME, - connect_timeout, rh); + rh->rs->ev_read = event_register((event_id_t)rh->rs->rc->write, EV_WRITEFD, + sec_connect_callback, rh); + rh->ev_timeout = event_register((event_id_t)CONNECT_TIMEOUT, EV_TIME, + sec_connect_timeout, rh); return; @@ -299,215 +205,32 @@ error: (*fn)(arg, &rh->sech, S_ERROR); } -/* - * Called when a ssh connection is finished connecting and is ready - * to be authenticated. - */ -static void -connect_callback(cookie) - void *cookie; -{ - struct ssh_handle *rh = cookie; - - event_release(rh->rs->ev_read); - rh->rs->ev_read = NULL; - event_release(rh->ev_timeout); - rh->ev_timeout = NULL; - - (*rh->fn.connect)(rh->arg, &rh->sech, S_OK); -} - -/* - * Called if a connection times out before completion. - */ -static void -connect_timeout(cookie) - void *cookie; -{ - struct ssh_handle *rh = cookie; - - event_release(rh->rs->ev_read); - rh->rs->ev_read = NULL; - event_release(rh->ev_timeout); - rh->ev_timeout = NULL; - - (*rh->fn.connect)(rh->arg, &rh->sech, S_TIMEOUT); -} - -/* - * Setup to handle new incoming connections - */ -static void -ssh_accept(in, out, fn) - int in, out; - void (*fn) P((security_handle_t *, pkt_t *)); -{ - struct ssh_conn *rc; - - rc = conn_get("unknown"); - rc->read = in; - rc->write = out; - accept_fn = fn; - conn_read(rc); -} - -/* - * Locate an existing connection to the given host, or create a new, - * unconnected entry if none exists. The caller is expected to check - * for the lack of a connection (rc->read == -1) and set one up. - */ -static struct ssh_conn * -conn_get(hostname) - const char *hostname; -{ - struct ssh_conn *rc; - - sshprintf(("%s: ssh: conn_get: %s\n", debug_prefix_time(NULL), hostname)); - - for (rc = connq_first(); rc != NULL; rc = connq_next(rc)) { - if (strcasecmp(hostname, rc->hostname) == 0) - break; - } - - if (rc != NULL) { - rc->refcnt++; - sshprintf(("%s: ssh: conn_get: exists, refcnt to %s is now %d\n", debug_prefix_time(NULL), - rc->hostname, rc->refcnt)); - return (rc); - } - - sshprintf(("%s: ssh: conn_get: creating new handle\n", debug_prefix_time(NULL))); - /* - * We can't be creating a new handle if we are the client - */ - assert(accept_fn == NULL); - rc = alloc(sizeof(*rc)); - rc->read = rc->write = -1; - rc->pid = -1; - rc->readbuf.left = 0; - rc->readbuf.size = 0; - rc->ev_read = NULL; - strncpy(rc->hostname, hostname, sizeof(rc->hostname) - 1); - rc->hostname[sizeof(rc->hostname) - 1] = '\0'; - rc->errmsg = NULL; - rc->refcnt = 1; - rc->handle = -1; - connq_append(rc); - return (rc); -} - -/* - * Delete a reference to a connection, and close it if it is the last - * reference. - */ -static void -conn_put(rc) - struct ssh_conn *rc; -{ - amwait_t status; - - assert(rc->refcnt > 0); - --rc->refcnt; - sshprintf(("%s: ssh: conn_put: decrementing refcnt for %s to %d\n", debug_prefix_time(NULL), - rc->hostname, rc->refcnt)); - if (rc->refcnt > 0) { - return; - } - sshprintf(("%s: ssh: conn_put: closing connection to %s\n", debug_prefix_time(NULL), rc->hostname)); - if (rc->read != -1) - aclose(rc->read); - if (rc->write != -1) - aclose(rc->write); - if (rc->pid != -1) { - waitpid(rc->pid, &status, WNOHANG); - } - if (rc->ev_read != NULL) - event_release(rc->ev_read); - if (rc->errmsg != NULL) - amfree(rc->errmsg); - connq_remove(rc); - amfree(rc); -} - -/* - * Turn on read events for a conn. Or, increase a ev_read_refcnt if we are - * already receiving read events. - */ -static void -conn_read(rc) - struct ssh_conn *rc; -{ - - if (rc->ev_read != NULL) { - rc->ev_read_refcnt++; - sshprintf(("%s: ssh: conn_read: incremented ev_read_refcnt to %d for %s\n", debug_prefix_time(NULL), - rc->ev_read_refcnt, rc->hostname)); - return; - } - sshprintf(("%s: ssh: conn_read registering event handler for %s\n", debug_prefix_time(NULL), - rc->hostname)); - rc->ev_read = event_register(rc->read, EV_READFD, conn_read_callback, rc); - rc->ev_read_refcnt = 1; -} - -static void -conn_read_cancel(rc) - struct ssh_conn *rc; -{ - - --rc->ev_read_refcnt; - sshprintf(("%s: ssh: conn_read_cancel: decremented ev_read_refcnt to %d for %s\n", debug_prefix_time(NULL), - rc->ev_read_refcnt, rc->hostname)); - if(rc->ev_read_refcnt > 0) { - return; - } - sshprintf(("%s: ssh: conn_read_cancel: releasing event handler for %s\n", debug_prefix_time(NULL), - rc->hostname)); - event_release(rc->ev_read); - rc->ev_read = NULL; -} - -/* - * frees a handle allocated by the above - */ -static void -ssh_close(inst) - void *inst; -{ - struct ssh_handle *rh = inst; - - assert(rh != NULL); - - sshprintf(("%s: ssh: closing handle to %s\n", debug_prefix_time(NULL), rh->hostname)); - - if (rh->rs != NULL) { - /* This may be null if we get here on an error */ - ssh_recvpkt_cancel(rh); - security_stream_close(&rh->rs->secstr); - } - /* keep us from getting here again */ - rh->sech.driver = NULL; - amfree(rh); -} - /* * Forks a ssh to the host listed in rc->hostname * Returns negative on error, with an errmsg in rc->errmsg. */ static int -runssh(rc) - struct ssh_conn *rc; +runssh( + struct tcp_conn * rc, + const char * amandad_path, + const char * client_username, + const char * ssh_keys) { int rpipe[2], wpipe[2]; - char *amandad_path; + char *xamandad_path = (char *)amandad_path; + char *xclient_username = (char *)client_username; + char *xssh_keys = (char *)ssh_keys; + memset(rpipe, -1, SIZEOF(rpipe)); + memset(wpipe, -1, SIZEOF(wpipe)); if (pipe(rpipe) < 0 || pipe(wpipe) < 0) { - rc->errmsg = newvstralloc("pipe: ", strerror(errno), NULL); + rc->errmsg = newvstralloc(rc->errmsg, "pipe: ", strerror(errno), NULL); return (-1); } + switch (rc->pid = fork()) { case -1: - rc->errmsg = newvstralloc("fork: ", strerror(errno), NULL); + rc->errmsg = newvstralloc(rc->errmsg, "fork: ", strerror(errno), NULL); aclose(rpipe[0]); aclose(rpipe[1]); aclose(wpipe[0]); @@ -516,7 +239,6 @@ runssh(rc) case 0: dup2(wpipe[0], 0); dup2(rpipe[1], 1); - dup2(rpipe[1], 2); break; default: rc->read = rpipe[0]; @@ -528,712 +250,25 @@ runssh(rc) safe_fd(-1, 0); - amandad_path = vstralloc(libexecdir, "/", "amandad", versionsuffix(), - NULL); - execlp(SSH_PATH, SSH_PATH, SSH_ARGS, rc->hostname, amandad_path, - "-auth=ssh", NULL); - error("error: couldn't exec %s: %s", SSH_PATH, strerror(errno)); - - /* should nerver go here, shut up compiler warning */ - return(-1); -} - -/* - * Transmit a packet. - */ -static int -ssh_sendpkt(cookie, pkt) - void *cookie; - pkt_t *pkt; -{ - char buf[sizeof(pkt_t)]; - struct ssh_handle *rh = cookie; - size_t len; - - assert(rh != NULL); - assert(pkt != NULL); - - sshprintf(("%s: ssh: sendpkt: enter\n", debug_prefix_time(NULL))); - - len = strlen(pkt->body) + 2; - buf[0] = (char)pkt->type; - strcpy(&buf[1], pkt->body); - - sshprintf(("%s: ssh: sendpkt: %s (%d) pkt_t (len %d) contains:\n\n\"%s\"\n\n", debug_prefix_time(NULL), - pkt_type2str(pkt->type), pkt->type, strlen(pkt->body), pkt->body)); - - if (ssh_stream_write(rh->rs, buf, len) < 0) { - security_seterror(&rh->sech, security_stream_geterror(&rh->rs->secstr)); - return (-1); - } - return (0); -} - -/* - * Set up to receive a packet asyncronously, and call back when - * it has been read. - */ -static void -ssh_recvpkt(cookie, fn, arg, timeout) - void *cookie, *arg; - void (*fn) P((void *, pkt_t *, security_status_t)); - int timeout; -{ - struct ssh_handle *rh = cookie; - - assert(rh != NULL); - - sshprintf(("%s: ssh: recvpkt registered for %s\n", debug_prefix_time(NULL), rh->hostname)); - - /* - * Reset any pending timeout on this handle - */ - if (rh->ev_timeout != NULL) - event_release(rh->ev_timeout); - - /* - * Negative timeouts mean no timeout - */ - if (timeout < 0) - rh->ev_timeout = NULL; - else - rh->ev_timeout = event_register(timeout, EV_TIME, recvpkt_timeout, rh); - - rh->fn.recvpkt = fn; - rh->arg = arg; - ssh_stream_read(rh->rs, recvpkt_callback, rh); -} - -/* - * Remove a async receive request from the queue - */ -static void -ssh_recvpkt_cancel(cookie) - void *cookie; -{ - struct ssh_handle *rh = cookie; - - sshprintf(("%s: ssh: cancelling recvpkt for %s\n", debug_prefix_time(NULL), rh->hostname)); - - assert(rh != NULL); - - ssh_stream_read_cancel(rh->rs); - if (rh->ev_timeout != NULL) { - event_release(rh->ev_timeout); - rh->ev_timeout = NULL; - } -} - -/* - * This is called when a handle is woken up because data read off of the - * net is for it. - */ -static void -recvpkt_callback(cookie, buf, bufsize) - void *cookie, *buf; - ssize_t bufsize; -{ - pkt_t pkt; - struct ssh_handle *rh = cookie; - - assert(rh != NULL); - - /* - * We need to cancel the recvpkt request before calling - * the callback because the callback may reschedule us. - */ - ssh_recvpkt_cancel(rh); - - switch (bufsize) { - case 0: - security_seterror(&rh->sech, - "EOF on read from %s", rh->hostname); - (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); - return; - case -1: - security_seterror(&rh->sech, security_stream_geterror(&rh->rs->secstr)); - (*rh->fn.recvpkt)(rh->arg, NULL, S_ERROR); - return; - default: - break; - } - - parse_pkt(&pkt, buf, bufsize); - sshprintf(("%s: ssh: received %s packet (%d) from %s, contains:\n\n\"%s\"\n\n", debug_prefix_time(NULL), - pkt_type2str(pkt.type), pkt.type, rh->hostname, pkt.body)); - (*rh->fn.recvpkt)(rh->arg, &pkt, S_OK); -} - -/* - * This is called when a handle times out before receiving a packet. - */ -static void -recvpkt_timeout(cookie) - void *cookie; -{ - struct ssh_handle *rh = cookie; - - assert(rh != NULL); - - sshprintf(("%s: ssh: recvpkt timeout for %s\n", debug_prefix_time(NULL), rh->hostname)); - - ssh_recvpkt_cancel(rh); - (*rh->fn.recvpkt)(rh->arg, NULL, S_TIMEOUT); -} - -/* - * Create the server end of a stream. For ssh, this means setup a stream - * object and allocate a new handle for it. - */ -static void * -ssh_stream_server(h) - void *h; -{ - struct ssh_handle *rh = h; - struct ssh_stream *rs; - - assert(rh != NULL); - - rs = alloc(sizeof(*rs)); - security_streaminit(&rs->secstr, &ssh_security_driver); - rs->rc = conn_get(rh->hostname); - /* - * Stream should already be setup! - */ - if (rs->rc->read < 0) { - conn_put(rs->rc); - amfree(rs); - security_seterror(&rh->sech, "lost connection to %s", rh->hostname); - return (NULL); - } - rh->hostname = rs->rc->hostname; - /* - * so as not to conflict with the amanda server's handle numbers, - * we start at 5000 and work down - */ - rs->handle = 5000 - newhandle++; - rs->ev_read = NULL; - sshprintf(("%s: ssh: stream_server: created stream %d\n", debug_prefix_time(NULL), rs->handle)); - return (rs); -} - -/* - * Accept an incoming connection on a stream_server socket - * Nothing needed for ssh. - */ -static int -ssh_stream_accept(s) - void *s; -{ - - return (0); -} - -/* - * Return a connected stream. For ssh, this means setup a stream - * with the supplied handle. - */ -static void * -ssh_stream_client(h, id) - void *h; - int id; -{ - struct ssh_handle *rh = h; - struct ssh_stream *rs; - - assert(rh != NULL); - - if (id <= 0) { - security_seterror(&rh->sech, - "%d: invalid security stream id", id); - return (NULL); - } - - rs = alloc(sizeof(*rs)); - security_streaminit(&rs->secstr, &ssh_security_driver); - rs->handle = id; - rs->ev_read = NULL; - rs->rc = conn_get(rh->hostname); - - sshprintf(("%s: ssh: stream_client: connected to stream %d\n", debug_prefix_time(NULL), id)); - - return (rs); -} - -/* - * Close and unallocate resources for a stream. - */ -static void -ssh_stream_close(s) - void *s; -{ - struct ssh_stream *rs = s; - - assert(rs != NULL); - - sshprintf(("%s: ssh: stream_close: closing stream %d\n", debug_prefix_time(NULL), rs->handle)); - - ssh_stream_read_cancel(rs); - conn_put(rs->rc); - amfree(rs); -} - -/* - * Authenticate a stream - * Nothing needed for ssh. The connection is authenticated by sshd - * on startup. - */ -static int -ssh_stream_auth(s) - void *s; -{ - - return (0); -} - -/* - * Returns the stream id for this stream. This is just the local - * port. - */ -static int -ssh_stream_id(s) - void *s; -{ - struct ssh_stream *rs = s; - - assert(rs != NULL); - - return (rs->handle); -} - -/* - * Write a chunk of data to a stream. Blocks until completion. - */ -static int -ssh_stream_write(s, buf, size) - void *s; - const void *buf; - size_t size; -{ - struct ssh_stream *rs = s; - - assert(rs != NULL); - - sshprintf(("%s: ssh: stream_write: writing %d bytes to %s:%d\n", debug_prefix_time(NULL), size, - rs->rc->hostname, rs->handle)); - - if (send_token(rs->rc, rs->handle, buf, size) < 0) { - security_stream_seterror(&rs->secstr, rs->rc->errmsg); - return (-1); - } - return (0); -} - -/* - * Submit a request to read some data. Calls back with the given - * function and arg when completed. - */ -static void -ssh_stream_read(s, fn, arg) - void *s, *arg; - void (*fn) P((void *, void *, ssize_t)); -{ - struct ssh_stream *rs = s; - - assert(rs != NULL); - - /* - * Only one read request can be active per stream. - */ - if (rs->ev_read == NULL) { - rs->ev_read = event_register((event_id_t)rs->rc, EV_WAIT, - stream_read_callback, rs); - conn_read(rs->rc); - } - rs->fn = fn; - rs->arg = arg; -} - -/* - * Cancel a previous stream read request. It's ok if we didn't have a read - * scheduled. - */ -static void -ssh_stream_read_cancel(s) - void *s; -{ - struct ssh_stream *rs = s; - - assert(rs != NULL); - - if (rs->ev_read != NULL) { - event_release(rs->ev_read); - rs->ev_read = NULL; - conn_read_cancel(rs->rc); - } -} - -/* - * Callback for ssh_stream_read - */ -static void -stream_read_callback(arg) - void *arg; -{ - struct ssh_stream *rs = arg; - assert(rs != NULL); - - sshprintf(("%s: ssh: stream_read_callback: handle %d\n", debug_prefix_time(NULL), rs->handle)); - - /* - * Make sure this was for us. If it was, then blow away the handle - * so it doesn't get claimed twice. Otherwise, leave it alone. - * - * If the handle is EOF, pass that up to our callback. - */ - if (rs->rc->handle == rs->handle) { - sshprintf(("%s: ssh: stream_read_callback: it was for us\n", debug_prefix_time(NULL))); - rs->rc->handle = H_TAKEN; - } else if (rs->rc->handle != H_EOF) { - sshprintf(("%s: ssh: stream_read_callback: not for us\n", debug_prefix_time(NULL))); - return; - } - - /* - * Remove the event first, and then call the callback. - * We remove it first because we don't want to get in their - * way if they reschedule it. - */ - ssh_stream_read_cancel(rs); - - if (rs->rc->pktlen == 0) { - sshprintf(("%s: ssh: stream_read_callback: EOF\n", debug_prefix_time(NULL))); - (*rs->fn)(rs->arg, NULL, 0); - return; - } - sshprintf(("%s: ssh: stream_read_callback: read %ld bytes from %s:%d\n", debug_prefix_time(NULL), - rs->rc->pktlen, rs->rc->hostname, rs->handle)); - (*rs->fn)(rs->arg, rs->rc->pkt, rs->rc->pktlen); -} - -/* - * The callback for the netfd for the event handler - * Determines if this packet is for this security handle, - * and does the real callback if so. - */ -static void -conn_read_callback(cookie) - void *cookie; -{ - struct ssh_conn *rc = cookie; - struct ssh_handle *rh; - pkt_t pkt; - int rval; - - assert(cookie != NULL); - - sshprintf(("%s: ssh: conn_read_callback\n",debug_prefix_time(NULL))); - - /* Read the data off the wire. If we get errors, shut down. */ - rval = recv_token(rc, 60); - sshprintf(("%s: ssh: conn_read_callback: recv_token returned %d\n", debug_prefix_time(NULL), rval)); - if (rval <= 0) { - rc->pktlen = 0; - rc->handle = H_EOF; - rval = event_wakeup((event_id_t)rc); - sshprintf(("%s: ssh: conn_read_callback: event_wakeup return %d\n", debug_prefix_time(NULL), rval)); - /* delete our 'accept' reference */ - if (accept_fn != NULL) - conn_put(rc); - accept_fn = NULL; - return; - } - - /* If there are events waiting on this handle, we're done */ - rval = event_wakeup((event_id_t)rc); - sshprintf(("%s: ssh: conn_read_callback: event_wakeup return %d\n", debug_prefix_time(NULL), rval)); - if (rval > 0) - return; - - /* If there is no accept fn registered, then drop the packet */ - if (accept_fn == NULL) - return; - - rh = alloc(sizeof(*rh)); - security_handleinit(&rh->sech, &ssh_security_driver); - rh->hostname = rc->hostname; - rh->rs = ssh_stream_client(rh, rc->handle); - rh->ev_timeout = NULL; - - sshprintf(("%s: ssh: new connection\n", debug_prefix_time(NULL))); - parse_pkt(&pkt, rc->pkt, rc->pktlen); - sshprintf(("%s: ssh: calling accept_fn\n", debug_prefix_time(NULL))); - (*accept_fn)(&rh->sech, &pkt); -} - -static void -parse_pkt(pkt, buf, bufsize) - pkt_t *pkt; - const void *buf; - size_t bufsize; -{ - const unsigned char *bufp = buf; - - sshprintf(("%s: ssh: parse_pkt: parsing buffer of %d bytes\n", debug_prefix_time(NULL), bufsize)); - - pkt->type = (pktype_t)*bufp++; - bufsize--; - - if (bufsize == 0) { - pkt->body[0] = '\0'; - } else { - if (bufsize > sizeof(pkt->body) - 1) - bufsize = sizeof(pkt->body) - 1; - memcpy(pkt->body, bufp, bufsize); - pkt->body[sizeof(pkt->body) - 1] = '\0'; - } - - sshprintf(("%s: ssh: parse_pkt: %s (%d): \"%s\"\n", debug_prefix_time(NULL), pkt_type2str(pkt->type), - pkt->type, pkt->body)); -} - - -/* - * Transmits a chunk of data over a ssh_handle, adding - * the necessary headers to allow the remote end to decode it. - */ -static int -send_token(rc, handle, buf, len) - struct ssh_conn *rc; - int handle; - const void *buf; - size_t len; -{ - unsigned int netlength, nethandle; - struct iovec iov[3]; - - sshprintf(("%s: ssh: send_token: handle %d writing %d bytes to %s\n", debug_prefix_time(NULL), handle, len, - rc->hostname)); - - assert(sizeof(netlength) == 4); - - /* - * Format is: - * 32 bit length (network byte order) - * 32 bit handle (network byte order) - * data - */ - netlength = htonl(len); - iov[0].iov_base = (void *)&netlength; - iov[0].iov_len = sizeof(netlength); - - nethandle = htonl(handle); - iov[1].iov_base = (void *)&nethandle; - iov[1].iov_len = sizeof(nethandle); - - iov[2].iov_base = (void *)buf; - iov[2].iov_len = len; - - if (net_writev(rc->write, iov, 3) < 0) { - rc->errmsg = newvstralloc(rc->errmsg, "ssh write error to ", - rc->hostname, ": ", strerror(errno), NULL); - return (-1); + if(!xamandad_path || strlen(xamandad_path) <= 1) + xamandad_path = vstralloc(libexecdir, "/", "amandad", + versionsuffix(), NULL); + if(!xclient_username || strlen(xclient_username) <= 1) + xclient_username = CLIENT_LOGIN; + if(!ssh_keys || strlen(ssh_keys) <= 1) { + execlp(SSH_PATH, SSH_PATH, SSH_ARGS, "-l", xclient_username, + rc->hostname, xamandad_path, "-auth=ssh", "amdump", "amindexd", + "amidxtaped", (char *)NULL); } - return (0); -} - -static int -recv_token(rc, timeout) - struct ssh_conn *rc; - int timeout; -{ - unsigned int netint; - - assert(sizeof(netint) == 4); - - assert(rc->read >= 0); - - sshprintf(("%s: ssh: recv_token: reading from %s\n", debug_prefix_time(NULL), rc->hostname)); - - switch (net_read(rc, &netint, sizeof(netint), timeout)) { - case -1: - rc->errmsg = newvstralloc(rc->errmsg, "recv error: ", strerror(errno), - NULL); - sshprintf(("%s: ssh: recv_token: A return(-1)\n", debug_prefix_time(NULL))); - return (-1); - case 0: - rc->pktlen = 0; - sshprintf(("%s: ssh: recv_token: A return(0)\n", debug_prefix_time(NULL))); - return (0); - default: - break; + else { + execlp(SSH_PATH, SSH_PATH, SSH_ARGS, "-l", xclient_username, + "-i", xssh_keys, rc->hostname, xamandad_path, "-auth=ssh", + "amdump", "amindexd", "amidxtaped", (char *)NULL); } - rc->pktlen = ntohl(netint); - if (rc->pktlen > sizeof(rc->pkt)) { - rc->errmsg = newstralloc(rc->errmsg, "recv error: huge packet"); - sshprintf(("%s: ssh: recv_token: B return(-1)\n", debug_prefix_time(NULL))); - return (-1); - } - - switch (net_read(rc, &netint, sizeof(netint), timeout)) { - case -1: - rc->errmsg = newvstralloc(rc->errmsg, "recv error: ", strerror(errno), - NULL); - sshprintf(("%s: ssh: recv_token: C return(-1)\n", debug_prefix_time(NULL))); - return (-1); - case 0: - rc->pktlen = 0; - sshprintf(("%s: ssh: recv_token: D return(0)\n", debug_prefix_time(NULL))); - return (0); - default: - break; - } - rc->handle = ntohl(netint); - - switch (net_read(rc, rc->pkt, rc->pktlen, timeout)) { - case -1: - rc->errmsg = newvstralloc(rc->errmsg, "recv error: ", strerror(errno), - NULL); - sshprintf(("%s: ssh: recv_token: E return(-1)\n", debug_prefix_time(NULL))); - return (-1); - case 0: - rc->pktlen = 0; - break; - default: - break; - } - - sshprintf(("%s: ssh: recv_token: read %ld bytes from %s\n", debug_prefix_time(NULL), rc->pktlen, - rc->hostname)); - sshprintf(("%s: ssh: recv_token: end %d\n", debug_prefix_time(NULL),rc->pktlen)); - return (rc->pktlen); -} - -/* - * Writes out the entire iovec - */ -static int -net_writev(fd, iov, iovcnt) - int fd, iovcnt; - struct iovec *iov; -{ - int delta, n, total; - - assert(iov != NULL); - - total = 0; - while (iovcnt > 0) { - /* - * Write the iovec - */ - total += n = writev(fd, iov, iovcnt); - if (n < 0) - return (-1); - if (n == 0) { - errno = EIO; - return (-1); - } - /* - * Iterate through each iov. Figure out what we still need - * to write out. - */ - for (; n > 0; iovcnt--, iov++) { - /* 'delta' is the bytes written from this iovec */ - delta = n < iov->iov_len ? n : iov->iov_len; - /* subtract from the total num bytes written */ - n -= delta; - assert(n >= 0); - /* subtract from this iovec */ - iov->iov_len -= delta; - iov->iov_base = (char *)iov->iov_base + delta; - /* if this iovec isn't empty, run the writev again */ - if (iov->iov_len > 0) - break; - } - } - return (total); -} - -/* - * Like read(), but waits until the entire buffer has been filled. - */ -static ssize_t -net_read(rc, vbuf, origsize, timeout) - struct ssh_conn *rc; - void *vbuf; - size_t origsize; - int timeout; -{ - char *buf = vbuf, *off; /* ptr arith */ - int nread; - size_t size = origsize; - - sshprintf(("%s: ssh: net_read: begin %d\n", debug_prefix_time(NULL), origsize)); - while (size > 0) { - sshprintf(("%s: ssh: net_read: while %d\n", debug_prefix_time(NULL), size)); - if (rc->readbuf.left == 0) { - if (net_read_fillbuf(rc, timeout, size) < 0) { - sshprintf(("%s: ssh: net_read: end retrun(-1)\n", debug_prefix_time(NULL))); - return (-1); - } - if (rc->readbuf.size == 0) { - sshprintf(("%s: ssh: net_read: end retrun(0)\n", debug_prefix_time(NULL))); - return (0); - } - } - nread = min(rc->readbuf.left, size); - off = rc->readbuf.buf + rc->readbuf.size - rc->readbuf.left; - memcpy(buf, off, nread); - - buf += nread; - size -= nread; - rc->readbuf.left -= nread; - } - sshprintf(("%s: ssh: net_read: end %d\n", debug_prefix_time(NULL), origsize)); - return ((ssize_t)origsize); -} - -/* - * net_read likes to do a lot of little reads. Buffer it. - */ -static int -net_read_fillbuf(rc, timeout, size) - struct ssh_conn *rc; - int timeout; - int size; -{ - fd_set readfds; - struct timeval tv; - if(size > sizeof(rc->readbuf.buf)) size = sizeof(rc->readbuf.buf); + error("error: couldn't exec %s: %s", SSH_PATH, strerror(errno)); - sshprintf(("%s: ssh: net_read_fillbuf: begin\n", debug_prefix_time(NULL))); - FD_ZERO(&readfds); - FD_SET(rc->read, &readfds); - tv.tv_sec = timeout; - tv.tv_usec = 0; - switch (select(rc->read + 1, &readfds, NULL, NULL, &tv)) { - case 0: - errno = ETIMEDOUT; - /* FALLTHROUGH */ - case -1: - sshprintf(("%s: ssh: net_read_fillbuf: case -1\n", debug_prefix_time(NULL))); - return (-1); - case 1: - sshprintf(("%s: ssh: net_read_fillbuf: case 1\n", debug_prefix_time(NULL))); - assert(FD_ISSET(rc->read, &readfds)); - break; - default: - sshprintf(("%s: ssh: net_read_fillbuf: case default\n", debug_prefix_time(NULL))); - assert(0); - break; - } - rc->readbuf.left = 0; - rc->readbuf.size = read(rc->read, rc->readbuf.buf, size); - if (rc->readbuf.size < 0) - return (-1); - rc->readbuf.left = rc->readbuf.size; - sshprintf(("%s: ssh: net_read_fillbuf: end %d\n", debug_prefix_time(NULL),rc->readbuf.size)); - return (0); + /* should never go here, shut up compiler warning */ + return(-1); } #endif /* SSH_SECURITY */ diff --git a/common-src/statfs.c b/common-src/statfs.c index 5f5270f..9e1d3cd 100644 --- a/common-src/statfs.c +++ b/common-src/statfs.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: statfs.c,v 1.13 2005/09/30 19:13:27 martinea Exp $ + * $Id: statfs.c,v 1.16 2006/08/24 17:05:35 martinea Exp $ * * a generic statfs-like routine */ @@ -98,7 +98,7 @@ # define STATFS_FAVAIL(buf) (buf).f_ffree # define STATFS_FFREE(buf) (buf).f_ffree # define STATFS_SCALE(buf) (buf).f_bsize -# define STATFS(path, buffer) statfs(path, &buffer, sizeof(STATFS_STRUCT), 0) +# define STATFS(path, buffer) statfs(path, &buffer, SIZEOF(STATFS_STRUCT), 0) # else # if HAVE_SYS_MOUNT_H /* @@ -119,7 +119,7 @@ # define STATFS_SCALE(buf) (buf).f_bsize # define STATFS(path, buffer) statfs(path, &buffer) # ifdef STATFS_OSF1 -# define STATFS(path, buffer) statfs(path, &buffer, sizeof(STATFS_STRUCT)) +# define STATFS(path, buffer) statfs(path, &buffer, SIZEOF(STATFS_STRUCT)) # endif # endif # endif @@ -127,11 +127,23 @@ # endif #endif -#define scale(r,s) ( (r) == -1? -1 : (int)((r)*(double)(s)/1024.0) ) -int get_fs_stats(dir, sp) -char *dir; -generic_fs_stats_t *sp; +off_t scale(off_t r, off_t s); + +off_t +scale( + off_t r, + off_t s) +{ + if (r == (off_t)-1) + return (off_t)-1; + return r*(s/(off_t)1024); +} + +int +get_fs_stats( + char * dir, + generic_fs_stats_t *sp) { STATFS_STRUCT statbuf; @@ -140,15 +152,18 @@ generic_fs_stats_t *sp; /* total, avail, free: converted to kbytes, rounded down */ - sp->total = scale(STATFS_TOTAL(statbuf), STATFS_SCALE(statbuf)); - sp->avail = scale(STATFS_AVAIL(statbuf), STATFS_SCALE(statbuf)); - sp->free = scale(STATFS_FREE(statbuf), STATFS_SCALE(statbuf)); + sp->total = scale((off_t)STATFS_TOTAL(statbuf), + (off_t)STATFS_SCALE(statbuf)); + sp->avail = scale((off_t)STATFS_AVAIL(statbuf), + (off_t)STATFS_SCALE(statbuf)); + sp->free = scale((off_t)STATFS_FREE(statbuf), + (off_t)STATFS_SCALE(statbuf)); /* inode stats */ - sp->files = STATFS_FILES(statbuf); - sp->favail = STATFS_FAVAIL(statbuf); - sp->ffree = STATFS_FFREE(statbuf); + sp->files = (off_t)STATFS_FILES(statbuf); + sp->favail = (off_t)STATFS_FAVAIL(statbuf); + sp->ffree = (off_t)STATFS_FFREE(statbuf); return 0; } @@ -156,9 +171,10 @@ generic_fs_stats_t *sp; #ifdef TEST /* ----- test scaffolding ----- */ -int main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char ** argv) { generic_fs_stats_t statbuf; @@ -166,6 +182,8 @@ char **argv; set_pname(argv[0]); + dbopen(NULL); + if(argc < 2) { fprintf(stderr, "Usage: %s files ...\n", get_pname()); return 1; diff --git a/common-src/statfs.h b/common-src/statfs.h index 8260d6c..7252e8f 100644 --- a/common-src/statfs.h +++ b/common-src/statfs.h @@ -24,20 +24,25 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: statfs.h,v 1.3 1998/07/04 00:18:58 oliva Exp $ + * $Id: statfs.h,v 1.4 2006/05/25 01:47:12 johnfranks Exp $ * * interface to statfs module */ +#ifndef STATFS_H +#define STATFS_H + #include "amanda.h" typedef struct generic_fs_stats { - long total; /* total KB in filesystem */ - long avail; /* KB available to non-superuser */ - long free; /* KB free for superuser */ + off_t total; /* total KB in filesystem */ + off_t avail; /* KB available to non-superuser */ + off_t free; /* KB free for superuser */ - long files; /* total # of files in filesystem */ - long favail; /* # files avail for non-superuser */ - long ffree; /* # files free for superuser */ + off_t files; /* total # of files in filesystem */ + off_t favail; /* # files avail for non-superuser */ + off_t ffree; /* # files free for superuser */ } generic_fs_stats_t; -int get_fs_stats P((char *dir, generic_fs_stats_t *sp)); +int get_fs_stats(char *dir, generic_fs_stats_t *sp); + +#endif /* !STATFS_H */ diff --git a/common-src/strcasecmp.c b/common-src/strcasecmp.c index b3dd1fa..ac5f79f 100644 --- a/common-src/strcasecmp.c +++ b/common-src/strcasecmp.c @@ -1,21 +1,13 @@ /* Provided by Michael Schmitz ; public domain? */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -#include -#else -#include -#endif +#include "amanda.h" /* Compare S1 and S2 ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ int -strcasecmp(s1, s2) - const char *s1; - const char *s2; +strcasecmp( + const char *s1, + const char *s2) { register const unsigned char *p1 = (const unsigned char *) s1; register const unsigned char *p2 = (const unsigned char *) s2; @@ -24,11 +16,10 @@ strcasecmp(s1, s2) if (p1 == p2) return 0; - do - { + do { c1 = tolower (*p1++); c2 = tolower (*p2++); if (c1 == '\0' || c2 == '\0' || c1 != c2) return c1 - c2; - } while ( 1 == 1 ); + } while ( 1 == 1 ); } diff --git a/common-src/stream.c b/common-src/stream.c index b5e2445..5d29b19 100644 --- a/common-src/stream.c +++ b/common-src/stream.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: stream.c,v 1.31 2006/01/14 04:37:19 paddy_s Exp $ + * $Id: stream.c,v 1.39 2006/08/24 01:57:15 paddy_s Exp $ * * functions for managing stream sockets */ @@ -35,22 +35,28 @@ #include "util.h" /* local functions */ -static void try_socksize P((int sock, int which, int size)); +static void try_socksize(int sock, int which, size_t size); +static int stream_client_internal(const char *hostname, in_port_t port, + size_t sendsize, size_t recvsize, in_port_t *localport, + int nonblock, int priv); -int stream_server(portp, sendsize, recvsize) -int *portp; -int sendsize, recvsize; +int +stream_server( + in_port_t *portp, + size_t sendsize, + size_t recvsize, + int priv) { - int server_socket; + int server_socket, retries; socklen_t len; -#ifdef SO_KEEPALIVE - int on = 1; +#if defined(SO_KEEPALIVE) || defined(USE_REUSEADDR) + const int on = 1; int r; #endif struct sockaddr_in server; int save_errno; - *portp = -1; /* in case we error exit */ + *portp = USHRT_MAX; /* in case we error exit */ if((server_socket = socket(AF_INET, SOCK_STREAM, 0)) == -1) { save_errno = errno; dbprintf(("%s: stream_server: socket() failed: %s\n", @@ -59,7 +65,7 @@ int sendsize, recvsize; errno = save_errno; return -1; } - if(server_socket < 0 || server_socket >= FD_SETSIZE) { + if(server_socket < 0 || server_socket >= (int)FD_SETSIZE) { aclose(server_socket); errno = EMFILE; /* out of range */ save_errno = errno; @@ -69,14 +75,22 @@ int sendsize, recvsize; errno = save_errno; return -1; } - memset(&server, 0, sizeof(server)); - server.sin_family = AF_INET; + memset(&server, 0, SIZEOF(server)); + server.sin_family = (sa_family_t)AF_INET; server.sin_addr.s_addr = INADDR_ANY; - if(sendsize >= 0) - try_socksize(server_socket, SO_SNDBUF, sendsize); - if(recvsize >= 0) - try_socksize(server_socket, SO_RCVBUF, recvsize); +#ifdef USE_REUSEADDR + r = setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, + (void *)&on, (socklen_t)sizeof(on)); + if (r < 0) { + dbprintf(("%s: stream_server: setsockopt(SO_REUSEADDR) failed: %s\n", + debug_prefix(NULL), + strerror(errno))); + } +#endif + + try_socksize(server_socket, SO_SNDBUF, sendsize); + try_socksize(server_socket, SO_RCVBUF, recvsize); /* * If a port range was specified, we try to get a port in that @@ -89,31 +103,51 @@ int sendsize, recvsize; * to get the desired port, and to make sure we return a port that * is within the range it requires. */ + for (retries = 0; ; retries++) { #ifdef TCPPORTRANGE - if (bind_portrange(server_socket, &server, TCPPORTRANGE, "tcp") == 0) - goto out; + if (bind_portrange(server_socket, &server, TCPPORTRANGE, "tcp") == 0) + goto out; + dbprintf(("%s: stream_server: Could not bind to port in range: %d - %d.\n", + debug_prefix(NULL), TCPPORTRANGE)); #endif - if (bind_portrange(server_socket, &server, 512, IPPORT_RESERVED - 1, "tcp") == 0) - goto out; + if(priv) { + if (bind_portrange(server_socket, &server, + (in_port_t)512, (in_port_t)(IPPORT_RESERVED - 1), "tcp") == 0) + goto out; + dbprintf(("%s: stream_server: Could not bind to port in range 512 - %d.\n", + debug_prefix(NULL), IPPORT_RESERVED - 1)); + } - server.sin_port = INADDR_ANY; - if (bind(server_socket, (struct sockaddr *)&server, (socklen_t) sizeof(server)) == -1) { - save_errno = errno; - dbprintf(("%s: stream_server: bind(INADDR_ANY) failed: %s\n", + server.sin_port = INADDR_ANY; + if (bind(server_socket, (struct sockaddr *)&server, (socklen_t)sizeof(server)) == 0) + goto out; + dbprintf(("%s: stream_server: Could not bind to any port: %s\n", + debug_prefix(NULL), strerror(errno))); + + if (retries >= BIND_CYCLE_RETRIES) + break; + + dbprintf(("%s: stream_server: Retrying entire range after 10 second delay.\n", + debug_prefix(NULL))); + + sleep(15); + } + + save_errno = errno; + dbprintf(("%s: stream_server: bind(INADDR_ANY) failed: %s\n", debug_prefix(NULL), strerror(save_errno))); - aclose(server_socket); - errno = save_errno; - return -1; - } + aclose(server_socket); + errno = save_errno; + return -1; out: listen(server_socket, 1); /* find out what port was actually used */ - len = sizeof(server); + len = SIZEOF(server); if(getsockname(server_socket, (struct sockaddr *)&server, &len) == -1) { save_errno = errno; dbprintf(("%s: stream_server: getsockname() failed: %s\n", @@ -138,7 +172,7 @@ out: } #endif - *portp = (int) ntohs(server.sin_port); + *portp = (in_port_t)ntohs(server.sin_port); dbprintf(("%s: stream_server: waiting for connection: %s.%d\n", debug_prefix_time(NULL), inet_ntoa(server.sin_addr), @@ -147,31 +181,25 @@ out: } static int -stream_client_internal(hostname, - port, - sendsize, - recvsize, - localport, - nonblock, - priv) - const char *hostname; - int port, sendsize, recvsize, *localport, nonblock, priv; +stream_client_internal( + const char *hostname, + in_port_t port, + size_t sendsize, + size_t recvsize, + in_port_t *localport, + int nonblock, + int priv) { - int client_socket; - socklen_t len; -#ifdef SO_KEEPALIVE - int on = 1; - int r; -#endif struct sockaddr_in svaddr, claddr; struct hostent *hostp; int save_errno; char *f; + int client_socket; f = priv ? "stream_client_privileged" : "stream_client"; if((hostp = gethostbyname(hostname)) == NULL) { - save_errno = errno; + save_errno = EHOSTUNREACH; dbprintf(("%s: %s: gethostbyname(%s) failed\n", debug_prefix(NULL), f, @@ -180,43 +208,14 @@ stream_client_internal(hostname, return -1; } - memset(&svaddr, 0, sizeof(svaddr)); - svaddr.sin_family = AF_INET; - svaddr.sin_port = htons(port); - memcpy(&svaddr.sin_addr, hostp->h_addr, hostp->h_length); + memset(&svaddr, 0, SIZEOF(svaddr)); + svaddr.sin_family = (sa_family_t)AF_INET; + svaddr.sin_port = (in_port_t)htons(port); + memcpy(&svaddr.sin_addr, hostp->h_addr, (size_t)hostp->h_length); - if((client_socket = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - save_errno = errno; - dbprintf(("%s: %s: socket() failed: %s\n", - debug_prefix(NULL), - f, - strerror(save_errno))); - errno = save_errno; - return -1; - } - if(client_socket < 0 || client_socket >= FD_SETSIZE) { - aclose(client_socket); - errno = EMFILE; /* out of range */ - return -1; - } -#ifdef SO_KEEPALIVE - r = setsockopt(client_socket, SOL_SOCKET, SO_KEEPALIVE, - (void *)&on, sizeof(on)); - if(r == -1) { - save_errno = errno; - dbprintf(("%s: %s: setsockopt() failed: %s\n", - debug_prefix(NULL), - f, - strerror(save_errno))); - aclose(client_socket); - errno = save_errno; - return -1; - } -#endif - - memset(&claddr, 0, sizeof(claddr)); - claddr.sin_family = AF_INET; + memset(&claddr, 0, SIZEOF(claddr)); + claddr.sin_family = (sa_family_t)AF_INET; claddr.sin_addr.s_addr = INADDR_ANY; /* @@ -230,104 +229,68 @@ stream_client_internal(hostname, * is within the range it requires. */ if (priv) { - int b; - - b = bind_portrange(client_socket, &claddr, 512, IPPORT_RESERVED - 1, "tcp"); - if (b == 0) { - goto out; /* got what we wanted */ - } - save_errno = errno; - dbprintf(("%s: %s: bind(IPPORT_RESERVED) failed: %s\n", - debug_prefix(NULL), - f, - strerror(save_errno))); - aclose(client_socket); - errno = save_errno; - return -1; +#ifdef LOW_TCPPORTRANGE + client_socket = connect_portrange(&claddr, LOW_TCPPORTRANGE, + "tcp", &svaddr, nonblock); +#else + client_socket = connect_portrange(&claddr, (socklen_t)512, + (socklen_t)(IPPORT_RESERVED - 1), + "tcp", &svaddr, nonblock); +#endif + + if (client_socket > 0) + goto out; + +#ifdef LOW_TCPPORTRANGE + dbprintf(( + "%s: stream_client: Could not bind to port in range %d-%d.\n", + debug_prefix(NULL), LOW_TCPPORTRANGE)); +#else + dbprintf(( + "%s: stream_client: Could not bind to port in range 512-%d.\n", + debug_prefix(NULL), IPPORT_RESERVED - 1)); +#endif } #ifdef TCPPORTRANGE - if (bind_portrange(client_socket, &claddr, TCPPORTRANGE, "tcp") == 0) + client_socket = connect_portrange(&claddr, TCPPORTRANGE, + "tcp", &svaddr, nonblock); + if(client_socket > 0) goto out; -#endif - - claddr.sin_port = INADDR_ANY; - if (bind(client_socket, (struct sockaddr *)&claddr, sizeof(claddr)) == -1) { - save_errno = errno; - dbprintf(("%s: %s: bind(INADDR_ANY) failed: %s\n", - debug_prefix(NULL), - f, - strerror(save_errno))); - aclose(client_socket); - errno = save_errno; - return -1; - } -out: - - /* find out what port was actually used */ - - len = sizeof(claddr); - if(getsockname(client_socket, (struct sockaddr *)&claddr, &len) == -1) { - save_errno = errno; - dbprintf(("%s: %s: getsockname() failed: %s\n", - debug_prefix(NULL), - f, - strerror(save_errno))); - aclose(client_socket); - errno = save_errno; - return -1; - } + dbprintf(("%s: stream_client: Could not bind to port in range %d - %d.\n", + debug_prefix(NULL), TCPPORTRANGE)); +#endif - if (nonblock) - fcntl(client_socket, F_SETFL, - fcntl(client_socket, F_GETFL, 0)|O_NONBLOCK); + client_socket = connect_portrange(&claddr, (socklen_t)(IPPORT_RESERVED+1), + (socklen_t)(65535), + "tcp", &svaddr, nonblock); - if(connect(client_socket, (struct sockaddr *)&svaddr, sizeof(svaddr)) - == -1 && !nonblock) { - save_errno = errno; - dbprintf(("%s: %s: connect to %s.%d failed: %s\n", - debug_prefix_time(NULL), - f, - inet_ntoa(svaddr.sin_addr), - ntohs(svaddr.sin_port), - strerror(save_errno))); - aclose(client_socket); - errno = save_errno; - return -1; - } + if(client_socket > 0) + goto out; - dbprintf(("%s: %s: connected to %s.%d\n", - debug_prefix_time(NULL), - f, - inet_ntoa(svaddr.sin_addr), - ntohs(svaddr.sin_port))); - dbprintf(("%s: %s: our side is %s.%d\n", - debug_prefix(NULL), - f, - inet_ntoa(claddr.sin_addr), - ntohs(claddr.sin_port))); - - if(sendsize >= 0) - try_socksize(client_socket, SO_SNDBUF, sendsize); - if(recvsize >= 0) - try_socksize(client_socket, SO_RCVBUF, recvsize); + save_errno = errno; + dbprintf(("%s: stream_client: Could not bind to any port: %s\n", + debug_prefix(NULL), strerror(save_errno))); + errno = save_errno; + return -1; +out: + try_socksize(client_socket, SO_SNDBUF, sendsize); + try_socksize(client_socket, SO_RCVBUF, recvsize); if (localport != NULL) - *localport = ntohs(claddr.sin_port); - + *localport = (in_port_t)ntohs(claddr.sin_port); return client_socket; } int -stream_client_privileged(hostname, - port, - sendsize, - recvsize, - localport, - nonblock) - const char *hostname; - int port, sendsize, recvsize, *localport, nonblock; +stream_client_privileged( + const char *hostname, + in_port_t port, + size_t sendsize, + size_t recvsize, + in_port_t *localport, + int nonblock) { return stream_client_internal(hostname, port, @@ -339,9 +302,13 @@ stream_client_privileged(hostname, } int -stream_client(hostname, port, sendsize, recvsize, localport, nonblock) - const char *hostname; - int port, sendsize, recvsize, *localport, nonblock; +stream_client( + const char *hostname, + in_port_t port, + size_t sendsize, + size_t recvsize, + in_port_t *localport, + int nonblock) { return stream_client_internal(hostname, port, @@ -356,62 +323,69 @@ stream_client(hostname, port, sendsize, recvsize, localport, nonblock) static struct sockaddr_in addr; static socklen_t addrlen; -int stream_accept(server_socket, timeout, sendsize, recvsize) -int server_socket, timeout, sendsize, recvsize; +int +stream_accept( + int server_socket, + int timeout, + size_t sendsize, + size_t recvsize) { - fd_set readset; + SELECT_ARG_TYPE readset; struct timeval tv; int nfound, connected_socket; int save_errno; + int ntries = 0; assert(server_socket >= 0); - tv.tv_sec = timeout; - tv.tv_usec = 0; - FD_ZERO(&readset); - FD_SET(server_socket, &readset); - nfound = select(server_socket+1, (SELECT_ARG_TYPE *)&readset, NULL, NULL, &tv); - if(nfound <= 0 || !FD_ISSET(server_socket, &readset)) { - save_errno = errno; - if(nfound < 0) { - dbprintf(("%s: stream_accept: select() failed: %s\n", + do { + ntries++; + memset(&tv, 0, SIZEOF(tv)); + tv.tv_sec = timeout; + memset(&readset, 0, SIZEOF(readset)); + FD_ZERO(&readset); + FD_SET(server_socket, &readset); + nfound = select(server_socket+1, &readset, NULL, NULL, &tv); + if(nfound <= 0 || !FD_ISSET(server_socket, &readset)) { + save_errno = errno; + if(nfound < 0) { + dbprintf(("%s: stream_accept: select() failed: %s\n", debug_prefix_time(NULL), strerror(save_errno))); - } else if(nfound == 0) { - dbprintf(("%s: stream_accept: timeout after %d second%s\n", + } else if(nfound == 0) { + dbprintf(("%s: stream_accept: timeout after %d second%s\n", debug_prefix_time(NULL), timeout, (timeout == 1) ? "" : "s")); - save_errno = ENOENT; /* ??? */ - } else if (!FD_ISSET(server_socket, &readset)) { - int i; - - for(i = 0; i < server_socket + 1; i++) { - if(FD_ISSET(i, &readset)) { - dbprintf(("%s: stream_accept: got fd %d instead of %d\n", + errno = ENOENT; /* ??? */ + return -1; + } else if (!FD_ISSET(server_socket, &readset)) { + int i; + + for(i = 0; i < server_socket + 1; i++) { + if(FD_ISSET(i, &readset)) { + dbprintf(("%s: stream_accept: got fd %d instead of %d\n", debug_prefix_time(NULL), i, server_socket)); + } } + save_errno = EBADF; } - save_errno = EBADF; - } - errno = save_errno; - return -1; - } + if (ntries > 5) { + errno = save_errno; + return -1; + } + } + } while (nfound <= 0); while(1) { - addrlen = sizeof(struct sockaddr); + addrlen = (socklen_t)sizeof(struct sockaddr); connected_socket = accept(server_socket, (struct sockaddr *)&addr, &addrlen); if(connected_socket < 0) { - save_errno = errno; - dbprintf(("%s: stream_accept: accept() failed: %s\n", - debug_prefix_time(NULL), - strerror(save_errno))); - errno = save_errno; - return -1; + break; } dbprintf(("%s: stream_accept: connection from %s.%d\n", debug_prefix_time(NULL), @@ -421,10 +395,13 @@ int server_socket, timeout, sendsize, recvsize; * Make certain we got an inet connection and that it is not * from port 20 (a favorite unauthorized entry tool). */ - if(addr.sin_family == AF_INET && ntohs(addr.sin_port) != 20) { - break; + if((addr.sin_family == (sa_family_t)AF_INET) + && (ntohs(addr.sin_port) != (in_port_t)20)) { + try_socksize(connected_socket, SO_SNDBUF, sendsize); + try_socksize(connected_socket, SO_RCVBUF, recvsize); + return connected_socket; } - if(addr.sin_family != AF_INET) { + if(addr.sin_family != (sa_family_t)AF_INET) { dbprintf(("%s: family is %d instead of %d(AF_INET): ignored\n", debug_prefix_time(NULL), addr.sin_family, @@ -438,24 +415,32 @@ int server_socket, timeout, sendsize, recvsize; aclose(connected_socket); } - if(sendsize >= 0) - try_socksize(connected_socket, SO_SNDBUF, sendsize); - if(recvsize >= 0) - try_socksize(connected_socket, SO_RCVBUF, recvsize); - - return connected_socket; + save_errno = errno; + dbprintf(("%s: stream_accept: accept() failed: %s\n", + debug_prefix_time(NULL), + strerror(save_errno))); + errno = save_errno; + return -1; } -static void try_socksize(sock, which, size) -int sock, which, size; +static void +try_socksize( + int sock, + int which, + size_t size) { - int origsize; + size_t origsize; + + if (size == 0) + return; origsize = size; /* keep trying, get as big a buffer as possible */ - while(size > 1024 && - setsockopt(sock, SOL_SOCKET, which, (void *) &size, sizeof(int)) < 0) + while((size > 1024) && + (setsockopt(sock, SOL_SOCKET, + which, (void *) &size, (socklen_t)sizeof(int)) < 0)) { size -= 1024; + } if(size > 1024) { dbprintf(("%s: try_socksize: %s buffer size is %d\n", debug_prefix(NULL), diff --git a/common-src/stream.h b/common-src/stream.h index 6835cf4..eb73dd4 100644 --- a/common-src/stream.h +++ b/common-src/stream.h @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: stream.h,v 1.10 2001/08/14 22:38:26 jrjackson Exp $ + * $Id: stream.h,v 1.12 2006/06/01 14:44:05 martinea Exp $ * * interface to stream module */ @@ -37,19 +37,19 @@ #define NETWORK_BLOCK_BYTES DISK_BLOCK_BYTES #define STREAM_BUFSIZE (NETWORK_BLOCK_BYTES * 2) -int stream_server P((int *port, int sendsize, int recvsize)); -int stream_accept P((int sock, int timeout, int sendsize, int recvsize)); -int stream_client_privileged P((const char *hostname, - int port, - int sendsize, - int recvsize, - int *localport, - int nonblock)); -int stream_client P((const char *hostname, - int port, - int sendsize, - int recvsize, - int *localport, - int nonblock)); +int stream_server(in_port_t *port, size_t sendsize, size_t recvsize, int priv); +int stream_accept(int sock, int timeout, size_t sendsize, size_t recvsize); +int stream_client_privileged(const char *hostname, + in_port_t port, + size_t sendsize, + size_t recvsize, + in_port_t *localport, + int nonblock); +int stream_client(const char *hostname, + in_port_t port, + size_t sendsize, + size_t recvsize, + in_port_t *localport, + int nonblock); #endif diff --git a/common-src/strerror.c b/common-src/strerror.c index b33db7a..2ec138c 100644 --- a/common-src/strerror.c +++ b/common-src/strerror.c @@ -15,7 +15,7 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* $Id: strerror.c,v 1.6 1999/05/18 20:38:53 kashmir Exp $ */ +/* $Id: strerror.c,v 1.7 2006/05/25 01:47:12 johnfranks Exp $ */ #include "amanda.h" @@ -31,12 +31,12 @@ strerror(e) extern int sys_nerr; extern char *sys_errlist[]; unsigned int errnum; - static char buf[NUM_STR_SIZE + sizeof(UPREFIX) + 1]; + static char buf[NUM_STR_SIZE + SIZEOF(UPREFIX) + 1]; errnum = e; /* convert to unsigned */ if (errnum < sys_nerr) return (sys_errlist[errnum]); - snprintf(buf, sizeof(buf), UPREFIX, errnum); + snprintf(buf, SIZEOF(buf), UPREFIX, errnum); return (buf); } diff --git a/common-src/strftime.c b/common-src/strftime.c index e3b0ea7..c180985 100644 --- a/common-src/strftime.c +++ b/common-src/strftime.c @@ -21,10 +21,8 @@ static char sccsid[] = "@(#)strftime.c 5.8 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ -#include -#include +#include "amanda.h" #include -#include static char *afmt[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", @@ -235,7 +233,7 @@ _conv(n, digits, pad) static char buf[10]; register char *p; - for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) + for (p = buf + SIZEOF(buf) - 2; n > 0 && p > buf; n /= 10, --digits) *p-- = n % 10 + '0'; while (p > buf && digits-- > 0) *p-- = pad; diff --git a/common-src/strncasecmp.c b/common-src/strncasecmp.c index 3bcbb94..655746b 100644 --- a/common-src/strncasecmp.c +++ b/common-src/strncasecmp.c @@ -1,13 +1,4 @@ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -#include -#else -#include -#endif +#include "amanda.h" /* * The following function compares the first 'n' characters in 's1' diff --git a/common-src/tapelist.c b/common-src/tapelist.c index 8d39cab..194db84 100644 --- a/common-src/tapelist.c +++ b/common-src/tapelist.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: tapelist.c,v 1.3 2006/01/15 21:00:59 martinea Exp $ + * $Id: tapelist.c,v 1.8 2006/06/12 15:34:48 martinea Exp $ * * Support code for amidxtaped and amindexd. */ @@ -35,58 +35,94 @@ /* * Count the number of entries in this tapelist */ -int num_entries (tapelist) -tapelist_t *tapelist; +int +num_entries( + tapelist_t * tapelist) { tapelist_t *cur_tape; int count = 0; - for(cur_tape = tapelist ; cur_tape ; cur_tape = cur_tape->next) count++; + for(cur_tape = tapelist ; cur_tape ; cur_tape = cur_tape->next) + count++; + dbprintf(("num_entries(tapelist=%p)=%d\n", tapelist, count)); return(count); } +void +dump_tapelist( + tapelist_t *tapelist) +{ + tapelist_t *cur_tape; + int count = 0; + int file; + + dbprintf(("dump_tapelist(%p):\n", tapelist)); + for(cur_tape = tapelist ; cur_tape != NULL ; cur_tape = cur_tape->next) { + dbprintf((" %p->next = %p\n", cur_tape, cur_tape->next)); + dbprintf((" %p->label = %s\n", cur_tape, cur_tape->label)); + dbprintf((" %p->isafile = %d\n", cur_tape, cur_tape->isafile)); + dbprintf((" %p->numfiles = %d\n", cur_tape, cur_tape->numfiles)); + for (file=0; file < cur_tape->numfiles; file++) { + dbprintf((" %p->files[%d] = " OFF_T_FMT "\n", + cur_tape, file, (OFF_T_FMT_TYPE)cur_tape->files[file])); + } + count++; + } + dbprintf((" %p count = %d\n", tapelist, count)); +} + /* * Add a tape entry with the given label to the given tapelist, creating a new * tapelist if handed a NULL one. Squashes duplicates. */ -tapelist_t *append_to_tapelist (tapelist, label, file, isafile) -tapelist_t *tapelist; -char *label; -int file, isafile; +tapelist_t * +append_to_tapelist( + tapelist_t *tapelist, + char * label, + off_t file, + int isafile) { tapelist_t *new_tape, *cur_tape; int c; + dbprintf(("append_to_tapelist(tapelist=%p, label='%s', , file=" + OFF_T_FMT ", isafile=%d)\n", + tapelist, label, (OFF_T_FMT_TYPE)file, isafile)); + /* see if we have this tape already, and if so just add to its file list */ - for(cur_tape = tapelist; cur_tape; cur_tape = cur_tape->next){ - if(!strcmp(label, cur_tape->label)){ + for(cur_tape = tapelist; cur_tape; cur_tape = cur_tape->next) { + if(strcmp(label, cur_tape->label) == 0) { int d_idx = 0; - int *newfiles; - if(file >= 0){ - newfiles = alloc(sizeof(int) * (cur_tape->numfiles + 1)); - for(c = 0; c < cur_tape->numfiles ; c++){ - if(cur_tape->files[c] > file && c == d_idx){ + off_t *newfiles; + + if(file >= (off_t)0) { + newfiles = alloc(SIZEOF(*newfiles) * + (cur_tape->numfiles + 1)); + for(c = 0; c < cur_tape->numfiles ; c++) { + if(cur_tape->files[c] > file && c == d_idx) { newfiles[d_idx] = file; d_idx++; } newfiles[d_idx] = cur_tape->files[c]; d_idx++; } - if(c == d_idx) newfiles[d_idx] = file; + if(c == d_idx) + newfiles[d_idx] = file; cur_tape->numfiles++; amfree(cur_tape->files); cur_tape->files = newfiles; } + dump_tapelist(tapelist); return(tapelist); } } - new_tape = alloc(sizeof(tapelist_t)); - memset(new_tape, 0, sizeof(tapelist_t)); + new_tape = alloc(SIZEOF(tapelist_t)); + memset(new_tape, 0, SIZEOF(tapelist_t)); new_tape->label = stralloc(label); - if(file >= 0){ - new_tape->files = alloc(sizeof(int)); + if(file >= (off_t)0){ + new_tape->files = alloc(SIZEOF(*(new_tape->files))); new_tape->files[0] = file; new_tape->numfiles = 1; new_tape->isafile = isafile; @@ -95,21 +131,24 @@ int file, isafile; /* first instance of anything, start our tapelist with it */ if(!tapelist){ tapelist = new_tape; - return(tapelist); + } else { + /* new tape, tack it onto the end of the list */ + cur_tape = tapelist; + while (cur_tape->next != NULL) + cur_tape = cur_tape->next; + cur_tape->next = new_tape; } - /* new tape, tack it onto the end of the list */ - for(cur_tape = tapelist; cur_tape->next; cur_tape = cur_tape->next); - cur_tape->next = new_tape; - + dump_tapelist(tapelist); return(tapelist); } /* * Backslash-escape all of the commas (and backslashes) in a label string. */ -char *escape_label (label) -char *label; +char * +escape_label( + char * label) { char *cooked_str, *temp_str; int s_idx = 0, d_idx = 0; @@ -139,8 +178,9 @@ char *label; /* * Strip out any escape characters (backslashes) */ -char *unescape_label(label) -char *label; +char * +unescape_label( + char * label) { char *cooked_str, *temp_str; int s_idx = 0, d_idx = 0, prev_esc = 0; @@ -171,9 +211,10 @@ char *label; /* * Convert a tapelist into a parseable string of tape labels and file numbers. */ -char *marshal_tapelist (tapelist, do_escape) -tapelist_t *tapelist; -int do_escape; +char * +marshal_tapelist( + tapelist_t *tapelist, + int do_escape) { tapelist_t *cur_tape; char *str = NULL; @@ -188,13 +229,18 @@ int do_escape; for(c = 0; c < cur_tape->numfiles ; c++){ char num_str[NUM_STR_SIZE]; - snprintf(num_str, sizeof(num_str), "%d", cur_tape->files[c]); - if(!files_str) files_str = stralloc(num_str); - else files_str = vstralloc(files_str, ",", num_str, NULL); + snprintf(num_str, SIZEOF(num_str), OFF_T_FMT, + (OFF_T_FMT_TYPE)cur_tape->files[c]); + if (!files_str) + files_str = stralloc(num_str); + else + vstrextend(&files_str, ",", num_str, NULL); } - if(!str) str = vstralloc(esc_label, ":", files_str, NULL); - else str = vstralloc(str, ";", esc_label, ":", files_str, NULL); + if (!str) + str = vstralloc(esc_label, ":", files_str, NULL); + else + vstrextend(&str, ";", esc_label, ":", files_str, NULL); amfree(esc_label); amfree(files_str); @@ -207,11 +253,13 @@ int do_escape; * Convert a previously str-ified and escaped list of tapes back into a * tapelist structure. */ -tapelist_t *unmarshal_tapelist_str (tapelist_str) -char *tapelist_str; +tapelist_t * +unmarshal_tapelist_str( + char * tapelist_str) { char *temp_label, *temp_filenum; - int l_idx, n_idx, input_length; + int l_idx, n_idx; + size_t input_length; tapelist_t *tapelist = NULL; if(!tapelist_str) return(NULL); @@ -226,32 +274,38 @@ char *tapelist_str; memset(temp_label, '\0', input_length+1); l_idx = 0; while(*tapelist_str != ':' && *tapelist_str != '\0'){ - if(*tapelist_str == '\\') *tapelist_str++; /* skip escapes */ + if(*tapelist_str == '\\') + tapelist_str++; /* skip escapes */ temp_label[l_idx] = *tapelist_str; - if(*tapelist_str == '\0') break; /* bad format, should kvetch */ - *tapelist_str++; + if(*tapelist_str == '\0') + break; /* bad format, should kvetch */ + tapelist_str++; l_idx++; } - if(*tapelist_str != '\0') *tapelist_str++; - tapelist = append_to_tapelist(tapelist, temp_label, -1, 0); + if(*tapelist_str != '\0') + tapelist_str++; + tapelist = append_to_tapelist(tapelist, temp_label, (off_t)-1, 0); /* now read the list of file numbers */ while(*tapelist_str != ';' && *tapelist_str != '\0'){ - int filenum = -1; + off_t filenum; + memset(temp_filenum, '\0', input_length+1); n_idx = 0; while(*tapelist_str != ';' && *tapelist_str != ',' && *tapelist_str != '\0'){ temp_filenum[n_idx] = *tapelist_str; - *tapelist_str++; + tapelist_str++; n_idx++; } - filenum = atoi(temp_filenum); + filenum = OFF_T_ATOI(temp_filenum); tapelist = append_to_tapelist(tapelist, temp_label, filenum, 0); - if(*tapelist_str != '\0' && *tapelist_str != ';') *tapelist_str++; + if(*tapelist_str != '\0' && *tapelist_str != ';') + tapelist_str++; } - if(*tapelist_str != '\0') *tapelist_str++; + if(*tapelist_str != '\0') + tapelist_str++; } while(*tapelist_str != '\0'); @@ -264,18 +318,18 @@ char *tapelist_str; /* * Free up a list of tapes */ -void free_tapelist (tapelist) -tapelist_t *tapelist; +void +free_tapelist( + tapelist_t * tapelist) { tapelist_t *cur_tape; tapelist_t *prev = NULL; for(cur_tape = tapelist ; cur_tape ; cur_tape = cur_tape->next){ - if(cur_tape->label) amfree(cur_tape->label); - if(cur_tape->files) amfree(cur_tape->files); - if(prev) amfree(prev); + amfree(cur_tape->label); + amfree(cur_tape->files); + amfree(prev); prev = cur_tape; } - if(prev) amfree(prev); - + amfree(prev); } diff --git a/common-src/tapelist.h b/common-src/tapelist.h index 7d3e99b..e6b58e2 100644 --- a/common-src/tapelist.h +++ b/common-src/tapelist.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: tapelist.h,v 1.1 2005/10/11 01:17:00 vectro Exp $ + * $Id: tapelist.h,v 1.2 2006/05/25 01:47:12 johnfranks Exp $ * */ @@ -44,17 +44,18 @@ typedef struct tapelist_s { struct tapelist_s *next; char *label; int isafile; /* set to 1 and make *label the path to the file */ - int *files; + off_t *files; int numfiles; } tapelist_t; -extern int num_entries P((tapelist_t *tapelist)); -extern tapelist_t *append_to_tapelist P((tapelist_t *tapelist, char *label, - int file, int isafile)); -extern char *marshal_tapelist P((tapelist_t *tapelist, int escape)); -extern tapelist_t *unmarshal_tapelist_str P((char *tapelist_str)); -extern char *escape_label P((char *label)); -extern char *unescape_label P((char *label)); -extern void free_tapelist P((tapelist_t *tapelist)); - +int num_entries(tapelist_t *tapelist); +tapelist_t *append_to_tapelist(tapelist_t *tapelist, char *label, + off_t file, int isafile); +char *marshal_tapelist(tapelist_t *tapelist, int escape); +tapelist_t *unmarshal_tapelist_str(char *tapelist_str); +char *escape_label(char *label); +char *unescape_label(char *label); +void free_tapelist(tapelist_t *tapelist); +void dump_tapelist(tapelist_t *); + #endif /* !TAPELIST_H */ diff --git a/common-src/token.c b/common-src/token.c index d894f40..5dd8569 100644 --- a/common-src/token.c +++ b/common-src/token.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: token.c,v 1.29 2006/01/14 04:37:19 paddy_s Exp $ + * $Id: token.c,v 1.32 2006/07/19 17:41:15 martinea Exp $ * * token bashing routines */ @@ -47,11 +47,12 @@ ** Inspired by awk and a routine called splitter() that I snarfed from ** the net ages ago (original author long forgotten). */ -int split(str, token, toklen, sep) -char *str; /* String to split */ -char **token; /* Array of token pointers */ -int toklen; /* Size of token[] */ -char *sep; /* Token separators - usually " " */ +int +split( + char * str, /* String to split */ + char ** token, /* Array of token pointers */ + int toklen, /* Size of token[] */ + char * sep) /* Token separators - usually " " */ { register char *pi, *po; register int fld; @@ -70,21 +71,7 @@ char *sep; /* Token separators - usually " " */ if (*sep == '\0' || *str == '\0' || toklen == 1) return fld; /* Calculate the length of the unquoted string. */ - - len = 0; - for (pi = str; *pi && *pi != '\n'; pi++) { - switch(*pi) { - case '\\': /* had better not be trailing... */ - pi++; - if (*pi >= '0' && *pi <= '3') pi = pi + 2; - len++; - break; - case '"': /* just ignore "'s */ - break; - default: - len++; - } - } + len = strlen(str);; /* Allocate some space */ @@ -95,29 +82,36 @@ char *sep; /* Token separators - usually " " */ in_quotes = 0; po = buf; token[++fld] = po; - for (pi = str; *pi && *pi != '\n'; pi++) { - if (*pi == '\\') { /* escape */ - pi++; - if (*pi >= '0' && *pi <= '3') { - *po = ((*pi++ - '0') << 6); - *po = *po + ((*pi++ - '0') << 3); - *po = *po + ((*pi - '0') ); - } - else *po = *pi; - po++; - } - else if (*pi == '"') { /* quotes */ - in_quotes = !in_quotes; - } - else if (!in_quotes && strchr(sep, *pi)) { /* separator */ + for (pi = str; *pi && *pi != '\0'; pi++) { + if (*pi == '\n' && !in_quotes) + break; + + if (!in_quotes && strchr(sep, *pi)) { + /* + * separator + * Advance to next field. + */ *po = '\0'; /* end of token */ if (fld+1 >= toklen) return fld; /* too many tokens */ token[++fld] = po + 1; po++; + continue; } - else { - *po++ = *pi; /* normal */ + + if (*pi == '"') { + /* + * Start or end of quote + * Emit quote in either case + */ + in_quotes = !in_quotes; + } else if (in_quotes && *pi == '\\' && (*(pi + 1) == '"')) { + /* + * Quoted quote. + * emit '/' - default will pick up '"' + */ + *po++ = *pi++; } + *po++ = *pi; /* Emit character */ } *po = '\0'; @@ -141,7 +135,7 @@ printf_arglist_function(char *squotef, char *, format) /* Format the token */ arglist_start(argp, format); - vsnprintf(linebuf, sizeof(linebuf), format, argp); + vsnprintf(linebuf, SIZEOF(linebuf), format, argp); arglist_end(argp); return quote(" ", linebuf); @@ -155,21 +149,22 @@ printf_arglist_function1(char *quotef, char *, sep, char *, format) /* Format the token */ arglist_start(argp, format); - vsnprintf(linebuf, sizeof(linebuf), format, argp); + vsnprintf(linebuf, SIZEOF(linebuf), format, argp); arglist_end(argp); return quote(sep, linebuf); } -char *squote(str) -char *str; /* the string to quote */ +char *squote( + char * str) /* the string to quote */ { return quote(" ", str); } -char *quote(sepchr, str) -char *sepchr; /* separators that also need quoting */ -char *str; /* the string to quote */ +char * +quote( + char * sepchr, /* separators that also need quoting */ + char * str) /* the string to quote */ { register char *pi, *po; register size_t len; @@ -178,7 +173,8 @@ char *str; /* the string to quote */ /* Calculate the length of the quoted token. */ - len = sep = 0; + sep = 0; + len = 0; for (pi = str; *pi; pi++) { if (*pi < ' ' || *pi > '~') len = len + 4; @@ -209,9 +205,9 @@ char *str; /* the string to quote */ for (pi = str; *pi; pi++) { if (*pi < ' ' || *pi > '~') { *po++ = '\\'; - *po++ = ((*pi >> 6) & 07) + '0'; - *po++ = ((*pi >> 3) & 07) + '0'; - *po++ = ((*pi ) & 07) + '0'; + *po++ = (char)(((*pi >> 6) & 07) + '0'); + *po++ = (char)(((*pi >> 3) & 07) + '0'); + *po++ = (char)(((*pi ) & 07) + '0'); } else if (*pi == '\\' || *pi == '"') { *po++ = '\\'; @@ -224,14 +220,15 @@ char *str; /* the string to quote */ *po = '\0'; - assert(po - buf == len); /* Just checking! */ + assert(po == (buf + len)); /* Just checking! */ return buf; } /* Quote a string so that it can be used as a regular expression */ -char *rxquote(str) -char *str; /* the string to quote */ +char * +rxquote( + char * str) /* the string to quote */ { char *pi, *po; size_t len; @@ -289,15 +286,16 @@ char *str; /* the string to quote */ *po = '\0'; - assert(po - buf == len); /* Just checking! */ + assert(po == (buf + len)); /* Just checking! */ return buf; } #ifndef HAVE_SHQUOTE /* Quote a string so that it can be safely passed to a shell */ -char *shquote(str) -char *str; /* the string to quote */ +char * +shquote( + char * str) /* the string to quote */ { char *pi, *po; size_t len; @@ -364,7 +362,7 @@ char *str; /* the string to quote */ *po = '\0'; - assert(po - buf == len); /* Just checking! */ + assert(po == (buf + len)); /* Just checking! */ return buf; } @@ -372,13 +370,15 @@ char *str; /* the string to quote */ /* Table lookup. */ -int table_lookup(table, str) -table_t *table; -char *str; +int +table_lookup( + table_t * table, + char * str) { while(table->word != (char *)0) { - if (*table->word == *str && - strcmp(table->word, str) == 0) return table->value; + if (*table->word == *str && strcmp(table->word, str) == 0) { + return table->value; + } table++; } @@ -387,12 +387,15 @@ char *str; /* Reverse table lookup. */ -char *table_lookup_r(table, val) -table_t *table; -int val; +char * +table_lookup_r( + /*@keep@*/ table_t * table, + int val) { while(table->word != (char *)0) { - if (table->value == val) return table->word; + if (table->value == val) { + return table->word; + } table++; } @@ -401,7 +404,10 @@ int val; #ifdef TEST -int main() +int +main( + int argc, + char ** argv) { char *str = NULL; char *t[20]; @@ -411,8 +417,14 @@ int main() safe_fd(-1, 0); + /* shut up compiler */ + argc = argc; + argv = argv; + set_pname("token test"); + dbopen(NULL); + /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); @@ -443,8 +455,8 @@ int main() } sr = squote(str); printf("Quoted = \"%s\"\n", sr); - strncpy(str,sr,sizeof(str)-1); - str[sizeof(str)-1] = '\0'; + strncpy(str,sr,SIZEOF(str)-1); + str[SIZEOF(str)-1] = '\0'; r = split(str, t, 20, " "); if (r != 1) printf("split()=%d!\n", r); printf("Unquoted = \"%s\"\n", t[1]); diff --git a/common-src/token.h b/common-src/token.h index 6e33b7b..1856cbf 100644 --- a/common-src/token.h +++ b/common-src/token.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: token.h,v 1.12 2003/03/26 20:17:13 kovert Exp $ + * $Id: token.h,v 1.13 2006/05/25 01:47:12 johnfranks Exp $ * * interface to token module */ @@ -35,18 +35,18 @@ typedef struct {char *word; int value;} table_t; -extern int split P((char *str, char **token, int toklen, char *sep)); -extern char *squotef P((char *format, ...)) +extern int split(char *str, char **token, int toklen, char *sep); +extern char *squotef(char *format, ...) __attribute__ ((format (printf, 1, 2))); -extern char *squote P((char *str)); -extern char *quotef P((char *sep, char *format, ...)) +extern char *squote(char *str); +extern char *quotef(char *sep, char *format, ...) __attribute__ ((format (printf, 2, 3))); -extern char *quote P((char *sep, char *str)); -extern char *rxquote P((char *str)); +extern char *quote(char *sep, char *str); +extern char *rxquote(char *str); #ifndef HAVE_SHQUOTE -extern char *shquote P((char *str)); +extern char *shquote(char *str); #endif -extern int table_lookup P((table_t *table, char *str)); -extern char *table_lookup_r P((table_t *table, int val)); +extern int table_lookup(table_t *table, char *str); +extern char *table_lookup_r(table_t *table, int val); #endif diff --git a/common-src/util.c b/common-src/util.c index 0eafec0..a5f88f8 100644 --- a/common-src/util.c +++ b/common-src/util.c @@ -24,11 +24,40 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: util.c,v 1.17 2006/01/14 04:37:19 paddy_s Exp $ + * $Id: util.c,v 1.42 2006/08/24 01:57:15 paddy_s Exp $ */ #include "amanda.h" #include "util.h" +#include "arglist.h" +#include "clock.h" + +int allow_overwrites; +int token_pushed; + +tok_t tok, pushed_tok; +val_t tokenval; + +int conf_line_num, got_parserror; +FILE *conf_conf = (FILE *)NULL; +char *conf_confname = NULL; +char *conf_line = NULL; +char *conf_char = NULL; + +/*#define NET_READ_DEBUG*/ + +#ifdef NET_READ_DEBUG +#define netprintf(x) dbprintf(x) +#else +#define netprintf(x) +#endif + +static int make_socket(void); +static int connect_port(struct sockaddr_in *addrp, in_port_t port, char *proto, + struct sockaddr_in *svaddr, int nonblock); + +char conftoken_getc(void); +int conftoken_ungetc(int c); /* * Keep calling read() until we've read buflen's worth of data, or EOF, @@ -37,10 +66,10 @@ * Returns the number of bytes read, 0 on EOF, or negative on error. */ ssize_t -fullread(fd, vbuf, buflen) - int fd; - void *vbuf; - size_t buflen; +fullread( + int fd, + void * vbuf, + size_t buflen) { ssize_t nread, tot = 0; char *buf = vbuf; /* cast to char so we can ++ it */ @@ -70,10 +99,10 @@ fullread(fd, vbuf, buflen) * Returns the number of bytes written, or negative on error. */ ssize_t -fullwrite(fd, vbuf, buflen) - int fd; - const void *vbuf; - size_t buflen; +fullwrite( + int fd, + const void *vbuf, + size_t buflen) { ssize_t nwritten, tot = 0; const char *buf = vbuf; /* cast to char so we can ++ it */ @@ -92,6 +121,208 @@ fullwrite(fd, vbuf, buflen) return (tot); } +static int +make_socket(void) +{ + int s; + int save_errno; +#if defined(SO_KEEPALIVE) || defined(USE_REUSEADDR) + int on=1; + int r; +#endif + + if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + save_errno = errno; + dbprintf(("%s: make_socket: socket() failed: %s\n", + debug_prefix(NULL), + strerror(save_errno))); + errno = save_errno; + return -1; + } + if (s < 0 || s >= (int)FD_SETSIZE) { + aclose(s); + errno = EMFILE; /* out of range */ + return -1; + } + +#ifdef USE_REUSEADDR + r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + if (r < 0) { + save_errno = errno; + dbprintf(("%s: stream_server: setsockopt(SO_REUSEADDR) failed: %s\n", + debug_prefix(NULL), + strerror(errno))); + errno = save_errno; + } +#endif + +#ifdef SO_KEEPALIVE + r = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, + (void *)&on, SIZEOF(on)); + if (r == -1) { + save_errno = errno; + dbprintf(("%s: make_socket: setsockopt() failed: %s\n", + debug_prefix(NULL), + strerror(save_errno))); + aclose(s); + errno = save_errno; + return -1; + } +#endif + + return s; +} + +/* addrp is my address */ +/* svaddr is the address of the remote machine */ +/* return socket on success */ +/* return -1 on failure */ +int +connect_portrange( + struct sockaddr_in *addrp, + in_port_t first_port, + in_port_t last_port, + char * proto, + struct sockaddr_in *svaddr, + int nonblock) +{ + int s; + in_port_t port; + static in_port_t port_in_use[1024]; + static int nb_port_in_use = 0; + int i; + + assert(first_port <= last_port); + + /* Try a port already used */ + for(i=0; i < nb_port_in_use; i++) { + port = port_in_use[i]; + if(port >= first_port && port <= last_port) { + s = connect_port(addrp, port, proto, svaddr, nonblock); + if(s == -2) return -1; + if(s > 0) { + return s; + } + } + } + + /* Try a port in the range */ + for (port = first_port; port <= last_port; port++) { + s = connect_port(addrp, port, proto, svaddr, nonblock); + if(s == -2) return -1; + if(s > 0) { + port_in_use[nb_port_in_use++] = port; + return s; + } + } + + dbprintf(("%s: connect_portrange: all ports between %d and %d busy\n", + debug_prefix_time(NULL), + first_port, + last_port)); + errno = EAGAIN; + return -1; +} + +/* addrp is my address */ +/* svaddr is the address of the remote machine */ +/* return -2: Don't try again */ +/* return -1: Try with another port */ +/* return >0: this is the connected socket */ +int +connect_port( + struct sockaddr_in *addrp, + in_port_t port, + char * proto, + struct sockaddr_in *svaddr, + int nonblock) +{ + int save_errno; + struct servent * servPort; + socklen_t len; + int s; + + servPort = getservbyport((int)htons(port), proto); + if (servPort != NULL && !strstr(servPort->s_name, "amanda")) { + dbprintf(("%s: connect_port: Skip port %d: Owned by %s.\n", + debug_prefix_time(NULL), port, servPort->s_name)); + return -1; + } + + if(servPort == NULL) + dbprintf(("%s: connect_port: Try port %d: Available - ", + debug_prefix_time(NULL), port)); + else { + dbprintf(("%s: connect_port: Try port %d: Owned by %s - ", + debug_prefix_time(NULL), port, servPort->s_name)); + } + + if ((s = make_socket()) == -1) return -2; + + addrp->sin_port = (in_port_t)htons(port); + + if (bind(s, (struct sockaddr *)addrp, sizeof(*addrp)) != 0) { + save_errno = errno; + aclose(s); + if (save_errno != EADDRINUSE) { + dbprintf(("errno %d strerror %s\n", + errno, strerror(errno))); + errno = save_errno; + return -2; + } + errno = save_errno; + return -1; + } + + /* find out what port was actually used */ + + len = sizeof(*addrp); + if (getsockname(s, (struct sockaddr *)addrp, &len) == -1) { + save_errno = errno; + dbprintf(("%s: connect_port: getsockname() failed: %s\n", + debug_prefix(NULL), + strerror(save_errno))); + aclose(s); + errno = save_errno; + return -1; + } + + if (nonblock) + fcntl(s, F_SETFL, fcntl(s, F_GETFL, 0)|O_NONBLOCK); + if (connect(s, (struct sockaddr *)svaddr, + (socklen_t)sizeof(*svaddr)) == -1 && !nonblock) { + save_errno = errno; + dbprintf(("%s: connect_portrange: connect from %s.%d failed\n", + debug_prefix_time(NULL), + inet_ntoa(addrp->sin_addr), + ntohs(addrp->sin_port), + strerror(save_errno))); + dbprintf(("%s: connect_portrange: connect to %s.%d failed: %s\n", + debug_prefix_time(NULL), + inet_ntoa(svaddr->sin_addr), + ntohs(svaddr->sin_port), + strerror(save_errno))); + aclose(s); + errno = save_errno; + if (save_errno == ECONNREFUSED || + save_errno == ETIMEDOUT) { + return -2 ; + } + return -1; + } + + dbprintf(("%s: connected to %s.%d\n", + debug_prefix_time(NULL), + inet_ntoa(svaddr->sin_addr), + ntohs(svaddr->sin_port))); + dbprintf(("%s: our side is %s.%d\n", + debug_prefix(NULL), + inet_ntoa(addrp->sin_addr), + ntohs(addrp->sin_port))); + return s; +} + + /* * Bind to a port in the given range. Takes a begin,end pair of port numbers. * @@ -99,67 +330,59 @@ fullwrite(fd, vbuf, buflen) * on success. */ int -bind_portrange(s, addrp, first_port, last_port, proto) - int s; - struct sockaddr_in *addrp; - int first_port, last_port; - char *proto; +bind_portrange( + int s, + struct sockaddr_in *addrp, + in_port_t first_port, + in_port_t last_port, + char * proto) { - int port, cnt; - const int num_ports = last_port - first_port + 1; - int save_errno; + in_port_t port; + in_port_t cnt; struct servent *servPort; + const in_port_t num_ports = (in_port_t)(last_port - first_port + 1); - assert(first_port > 0 && first_port <= last_port && last_port < 65536); + assert(first_port <= last_port); /* * We pick a different starting port based on our pid and the current * time to avoid always picking the same reserved port twice. */ - port = ((getpid() + time(0)) % num_ports) + first_port; + port = (in_port_t)(((getpid() + time(0)) % num_ports) + first_port); + /* * Scan through the range, trying all available ports that are either * not taken in /etc/services or registered for *amanda*. Wrap around * if we don't happen to start at the beginning. */ for (cnt = 0; cnt < num_ports; cnt++) { - servPort = getservbyport(htons(port), proto); - if((servPort == NULL) || strstr(servPort->s_name, "amanda")){ - dbprintf(("%s: bind_portrange2: trying port=%d\n", + servPort = getservbyport((int)htons(port), proto); + if ((servPort == NULL) || strstr(servPort->s_name, "amanda")) { + if (servPort == NULL) { + dbprintf(("%s: bind_portrange2: Try port %d: Available - ", debug_prefix_time(NULL), port)); - addrp->sin_port = htons(port); - if (bind(s, (struct sockaddr *)addrp, sizeof(*addrp)) >= 0) + } else { + dbprintf(("%s: bind_portrange2: Try port %d: Owned by %s - ", + debug_prefix_time(NULL), port, servPort->s_name)); + } + addrp->sin_port = (in_port_t)htons(port); + if (bind(s, (struct sockaddr *)addrp, (socklen_t)sizeof(*addrp)) >= 0) { + dbprintf(("Success\n")); return 0; - /* - * If the error was something other then port in use, stop. - */ - if (errno != EADDRINUSE) - break; + } + dbprintf(("%s\n", strerror(errno))); + } else { + dbprintf(("%s: bind_portrange2: Skip port %d: Owned by %s.\n", + debug_prefix_time(NULL), port, servPort->s_name)); } if (++port > last_port) port = first_port; } - if (cnt == num_ports) { - dbprintf(("%s: bind_portrange: all ports between %d and %d busy\n", + dbprintf(("%s: bind_portrange: all ports between %d and %d busy\n", debug_prefix_time(NULL), first_port, last_port)); - errno = EAGAIN; - } else if (last_port < IPPORT_RESERVED - && getuid() != 0 - && errno == EACCES) { - /* - * Do not bother with an error message in this case because it - * is expected. - */ - } else { - save_errno = errno; - dbprintf(("%s: bind_portrange: port %d: %s\n", - debug_prefix_time(NULL), - port, - strerror(errno))); - errno = save_errno; - } + errno = EAGAIN; return -1; } @@ -167,20 +390,23 @@ bind_portrange(s, addrp, first_port, last_port, proto) * Construct a datestamp (YYYYMMDD) from a time_t. */ char * -construct_datestamp(t) - time_t *t; +construct_datestamp( + time_t *t) { struct tm *tm; - char datestamp[3*NUM_STR_SIZE]; + char datestamp[3 * NUM_STR_SIZE]; time_t when; - if(t == NULL) { + if (t == NULL) { when = time((time_t *)NULL); } else { when = *t; } tm = localtime(&when); - snprintf(datestamp, sizeof(datestamp), + if (!tm) + return stralloc("19000101"); + + snprintf(datestamp, SIZEOF(datestamp), "%04d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday); return stralloc(datestamp); } @@ -189,22 +415,2249 @@ construct_datestamp(t) * Construct a timestamp (YYYYMMDDHHMMSS) from a time_t. */ char * -construct_timestamp(t) - time_t *t; +construct_timestamp( + time_t *t) { struct tm *tm; - char timestamp[6*NUM_STR_SIZE]; + char timestamp[6 * NUM_STR_SIZE]; time_t when; - if(t == NULL) { + if (t == NULL) { when = time((time_t *)NULL); } else { when = *t; } tm = localtime(&when); - snprintf(timestamp, sizeof(timestamp), + if (!tm) + return stralloc("19000101000000"); + + snprintf(timestamp, SIZEOF(timestamp), "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); return stralloc(timestamp); } + + +int +needs_quotes( + const char * str) +{ + return (match("[ \t\f\r\n\"]", str) != 0); +} + + +/* + * For backward compatibility we are trying for minimal quoting. + * We only quote a string if it contains whitespace or is misquoted... + */ + +char * +quote_string( + const char *str) +{ + char * s; + char * ret; + + if ((str == NULL) || (*str == '\0')) { + ret = stralloc("\"\""); + } else if ((match("[\\\"[:space:][:cntrl:]]", str)) == 0) { + /* + * String does not need to be quoted since it contains + * neither whitespace, control or quote characters. + */ + ret = stralloc(str); + } else { + /* + * Allocate maximum possible string length. + * (a string of all quotes plus room for leading ", trailing " and NULL) + */ + ret = s = alloc((strlen(str) * 2) + 2 + 1); + *(s++) = '"'; + while (*str != '\0') { + if (*str == '\t') { + *(s++) = '\\'; + *(s++) = 't'; + str++; + continue; + } else if (*str == '\n') { + *(s++) = '\\'; + *(s++) = 'n'; + str++; + continue; + } else if (*str == '\r') { + *(s++) = '\\'; + *(s++) = 'r'; + str++; + continue; + } else if (*str == '\f') { + *(s++) = '\\'; + *(s++) = 'f'; + str++; + continue; + } + if (*str == '"') + *(s++) = '\\'; + *(s++) = *(str++); + } + *(s++) = '"'; + *s = '\0'; + } + return (ret); +} + + +char * +unquote_string( + const char *str) +{ + char * ret; + + if ((str == NULL) || (*str == '\0')) { + ret = stralloc(""); + } else { + char * in; + char * out; + + ret = in = out = stralloc(str); + while (*in != '\0') { + if (*in == '"') { + in++; + continue; + } + + if (*in == '\\') { + in++; + if (*in == 'n') { + in++; + *(out++) = '\n'; + continue; + } else if (*in == 't') { + in++; + *(out++) = '\t'; + continue; + } else if (*in == 'r') { + in++; + *(out++) = '\r'; + continue; + } else if (*in == 'f') { + in++; + *(out++) = '\f'; + continue; + } + } + *(out++) = *(in++); + } + *out = '\0'; + } + return (ret); +} + +char * +sanitize_string( + const char *str) +{ + char * s; + char * ret; + + if ((str == NULL) || (*str == '\0')) { + ret = stralloc(""); + } else { + ret = stralloc(str); + for (s = ret; *s != '\0'; s++) { + if (iscntrl(*s)) + *s = '?'; + } + } + return (ret); +} + +char * +strquotedstr(void) +{ + char * tok = strtok(NULL, " "); + + if ((tok != NULL) && (tok[0] == '"')) { + char * t; + size_t len; + + len = strlen(tok); + do { + t = strtok(NULL, " "); + tok[len] = ' '; + len = strlen(tok); + } while ((t != NULL) && + (tok[len - 1] != '"') && (tok[len - 2] != '\\')); + } + return tok; +} + +ssize_t +hexdump( + const char *buffer, + size_t len) +{ + ssize_t rc = -1; + + FILE *stream = popen("od -w10 -c -x -", "w"); + + if (stream != NULL) { + fflush(stdout); + rc = (ssize_t)fwrite(buffer, len, 1, stream); + if (ferror(stream)) + rc = -1; + fclose(stream); + } + return rc; +} + +/* + Return 0 if the following characters are present + * ( ) < > [ ] , ; : ! $ \ / " + else returns 1 +*/ + +int +validate_mailto( + const char *mailto) +{ + return !match("\\*|<|>|\\(|\\)|\\[|\\]|,|;|:|\\\\|/|\"|\\!|\\$|\\|", mailto); +} + + +t_conf_var * +get_np( + t_conf_var *get_var, + int parm) +{ + t_conf_var *np; + + for(np = get_var; np->token != CONF_UNKNOWN; np++) { + if(np->parm == parm) + break; + } + + if(np->token == CONF_UNKNOWN) { + error("error [unknown getconf_np parm: %d]", parm); + /* NOTREACHED */ + } + return np; +} + +void +get_simple( + val_t *var, + tok_t type) +{ + ckseen(&var->seen); + + switch(type) { + case CONF_STRING: + case CONF_IDENT: + get_conftoken(type); + var->v.s = newstralloc(var->v.s, tokenval.v.s); + malloc_mark(var->v.s); + break; + + case CONF_INT: + var->v.i = get_int(); + break; + + case CONF_LONG: + var->v.l = get_long(); + break; + + case CONF_SIZE: + var->v.size = get_size(); + break; + + case CONF_AM64: + var->v.am64 = get_am64_t(); + break; + + case CONF_BOOL: + var->v.i = get_bool(); + break; + + case CONF_REAL: + get_conftoken(CONF_REAL); + var->v.r = tokenval.v.r; + break; + + case CONF_TIME: + var->v.t = get_time(); + break; + + default: + error("error [unknown get_simple type: %d]", type); + /* NOTREACHED */ + } + return; +} + +time_t +get_time(void) +{ + time_t hhmm; + + get_conftoken(CONF_ANY); + switch(tok) { + case CONF_INT: +#if SIZEOF_TIME_T < SIZEOF_INT + if ((off_t)tokenval.v.i >= (off_t)TIME_MAX) + conf_parserror("value too large"); +#endif + hhmm = (time_t)tokenval.v.i; + break; + + case CONF_LONG: +#if SIZEOF_TIME_T < SIZEOF_LONG + if ((off_t)tokenval.v.l >= (off_t)TIME_MAX) + conf_parserror("value too large"); +#endif + hhmm = (time_t)tokenval.v.l; + break; + + case CONF_SIZE: +#if SIZEOF_TIME_T < SIZEOF_SSIZE_T + if ((off_t)tokenval.v.size >= (off_t)TIME_MAX) + conf_parserror("value too large"); +#endif + hhmm = (time_t)tokenval.v.size; + break; + + case CONF_AM64: +#if SIZEOF_TIME_T < SIZEOF_LONG_LONG + if ((off_t)tokenval.v.am64 >= (off_t)TIME_MAX) + conf_parserror("value too large"); +#endif + hhmm = (time_t)tokenval.v.am64; + break; + + case CONF_AMINFINITY: + hhmm = TIME_MAX; + break; + + default: + conf_parserror("a time is expected"); + hhmm = 0; + break; + } + return hhmm; +} + +keytab_t numb_keytable[] = { + { "B", CONF_MULT1 }, + { "BPS", CONF_MULT1 }, + { "BYTE", CONF_MULT1 }, + { "BYTES", CONF_MULT1 }, + { "DAY", CONF_MULT1 }, + { "DAYS", CONF_MULT1 }, + { "INF", CONF_AMINFINITY }, + { "K", CONF_MULT1K }, + { "KB", CONF_MULT1K }, + { "KBPS", CONF_MULT1K }, + { "KBYTE", CONF_MULT1K }, + { "KBYTES", CONF_MULT1K }, + { "KILOBYTE", CONF_MULT1K }, + { "KILOBYTES", CONF_MULT1K }, + { "KPS", CONF_MULT1K }, + { "M", CONF_MULT1M }, + { "MB", CONF_MULT1M }, + { "MBPS", CONF_MULT1M }, + { "MBYTE", CONF_MULT1M }, + { "MBYTES", CONF_MULT1M }, + { "MEG", CONF_MULT1M }, + { "MEGABYTE", CONF_MULT1M }, + { "MEGABYTES", CONF_MULT1M }, + { "G", CONF_MULT1G }, + { "GB", CONF_MULT1G }, + { "GBPS", CONF_MULT1G }, + { "GBYTE", CONF_MULT1G }, + { "GBYTES", CONF_MULT1G }, + { "GIG", CONF_MULT1G }, + { "GIGABYTE", CONF_MULT1G }, + { "GIGABYTES", CONF_MULT1G }, + { "MPS", CONF_MULT1M }, + { "TAPE", CONF_MULT1 }, + { "TAPES", CONF_MULT1 }, + { "WEEK", CONF_MULT7 }, + { "WEEKS", CONF_MULT7 }, + { NULL, CONF_IDENT } +}; + +int +get_int(void) +{ + int val; + keytab_t *save_kt; + + save_kt = keytable; + keytable = numb_keytable; + + get_conftoken(CONF_ANY); + switch(tok) { + case CONF_INT: + val = tokenval.v.i; + break; + + case CONF_LONG: +#if SIZEOF_INT < SIZEOF_LONG + if ((off_t)tokenval.v.l > (off_t)INT_MAX) + conf_parserror("value too large"); + if ((off_t)tokenval.v.l < (off_t)INT_MIN) + conf_parserror("value too small"); +#endif + val = (int)tokenval.v.l; + break; + + case CONF_SIZE: +#if SIZEOF_INT < SIZEOF_SSIZE_T + if ((off_t)tokenval.v.size > (off_t)INT_MAX) + conf_parserror("value too large"); + if ((off_t)tokenval.v.size < (off_t)INT_MIN) + conf_parserror("value too small"); +#endif + val = (int)tokenval.v.size; + break; + + case CONF_AM64: +#if SIZEOF_INT < SIZEOF_LONG_LONG + if (tokenval.v.am64 > (off_t)INT_MAX) + conf_parserror("value too large"); + if (tokenval.v.am64 < (off_t)INT_MIN) + conf_parserror("value too small"); +#endif + val = (int)tokenval.v.am64; + break; + + case CONF_AMINFINITY: + val = INT_MAX; + break; + + default: + conf_parserror("an int is expected"); + val = 0; + break; + } + + /* get multiplier, if any */ + get_conftoken(CONF_ANY); + switch(tok) { + case CONF_NL: /* multiply by one */ + case CONF_END: + case CONF_MULT1: + case CONF_MULT1K: + break; + + case CONF_MULT7: + if (val > (INT_MAX / 7)) + conf_parserror("value too large"); + if (val < (INT_MIN / 7)) + conf_parserror("value too small"); + val *= 7; + break; + + case CONF_MULT1M: + if (val > (INT_MAX / 1024)) + conf_parserror("value too large"); + if (val < (INT_MIN / 1024)) + conf_parserror("value too small"); + val *= 1024; + break; + + case CONF_MULT1G: + if (val > (INT_MAX / (1024 * 1024))) + conf_parserror("value too large"); + if (val < (INT_MIN / (1024 * 1024))) + conf_parserror("value too small"); + val *= 1024 * 1024; + break; + + default: /* it was not a multiplier */ + unget_conftoken(); + break; + } + + keytable = save_kt; + return val; +} + +long +get_long(void) +{ + long val; + keytab_t *save_kt; + + save_kt = keytable; + keytable = numb_keytable; + + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_LONG: + val = tokenval.v.l; + break; + + case CONF_INT: +#if SIZEOF_LONG < SIZEOF_INT + if ((off_t)tokenval.v.i > (off_t)LONG_MAX) + conf_parserror("value too large"); + if ((off_t)tokenval.v.i < (off_t)LONG_MIN) + conf_parserror("value too small"); +#endif + val = (long)tokenval.v.i; + break; + + case CONF_SIZE: +#if SIZEOF_LONG < SIZEOF_SSIZE_T + if ((off_t)tokenval.v.size > (off_t)LONG_MAX) + conf_parserror("value too large"); + if ((off_t)tokenval.v.size < (off_t)LONG_MIN) + conf_parserror("value too small"); +#endif + val = (long)tokenval.v.size; + break; + + case CONF_AM64: +#if SIZEOF_LONG < SIZEOF_LONG_LONG + if (tokenval.v.am64 > (off_t)LONG_MAX) + conf_parserror("value too large"); + if (tokenval.v.am64 < (off_t)LONG_MIN) + conf_parserror("value too small"); +#endif + val = (long)tokenval.v.am64; + break; + + case CONF_AMINFINITY: + val = (long)LONG_MAX; + break; + + default: + conf_parserror("a long is expected"); + val = 0; + break; + } + + /* get multiplier, if any */ + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_NL: /* multiply by one */ + case CONF_MULT1: + case CONF_MULT1K: + break; + + case CONF_MULT7: + if (val > (LONG_MAX / 7L)) + conf_parserror("value too large"); + if (val < (LONG_MIN / 7L)) + conf_parserror("value too small"); + val *= 7L; + break; + + case CONF_MULT1M: + if (val > (LONG_MAX / 1024L)) + conf_parserror("value too large"); + if (val < (LONG_MIN / 1024L)) + conf_parserror("value too small"); + val *= 1024L; + break; + + case CONF_MULT1G: + if (val > (LONG_MAX / (1024L * 1024L))) + conf_parserror("value too large"); + if (val < (LONG_MIN / (1024L * 1024L))) + conf_parserror("value too small"); + val *= 1024L * 1024L; + break; + + default: /* it was not a multiplier */ + unget_conftoken(); + break; + } + + keytable = save_kt; + return val; +} + +ssize_t +get_size(void) +{ + ssize_t val; + keytab_t *save_kt; + + save_kt = keytable; + keytable = numb_keytable; + + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_SIZE: + val = tokenval.v.size; + break; + + case CONF_INT: +#if SIZEOF_SIZE_T < SIZEOF_INT + if ((off_t)tokenval.v.i > (off_t)SSIZE_MAX) + conf_parserror("value too large"); + if ((off_t)tokenval.v.i < (off_t)SSIZE_MIN) + conf_parserror("value too small"); +#endif + val = (ssize_t)tokenval.v.i; + break; + + case CONF_LONG: +#if SIZEOF_SIZE_T < SIZEOF_LONG + if ((off_t)tokenval.v.l > (off_t)SSIZE_MAX) + conf_parserror("value too large"); + if ((off_t)tokenval.v.l < (off_t)SSIZE_MIN) + conf_parserror("value too small"); +#endif + val = (ssize_t)tokenval.v.l; + break; + + case CONF_AM64: +#if SIZEOF_SIZE_T < SIZEOF_LONG_LONG + if (tokenval.v.am64 > (off_t)SSIZE_MAX) + conf_parserror("value too large"); + if (tokenval.v.am64 < (off_t)SSIZE_MIN) + conf_parserror("value too small"); +#endif + val = (ssize_t)tokenval.v.am64; + break; + + case CONF_AMINFINITY: + val = (ssize_t)SSIZE_MAX; + break; + + default: + conf_parserror("an integer is expected"); + val = 0; + break; + } + + /* get multiplier, if any */ + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_NL: /* multiply by one */ + case CONF_MULT1: + case CONF_MULT1K: + break; + + case CONF_MULT7: + if (val > (ssize_t)(SSIZE_MAX / 7)) + conf_parserror("value too large"); + if (val < (ssize_t)(SSIZE_MIN / 7)) + conf_parserror("value too small"); + val *= (ssize_t)7; + break; + + case CONF_MULT1M: + if (val > (ssize_t)(SSIZE_MAX / (ssize_t)1024)) + conf_parserror("value too large"); + if (val < (ssize_t)(SSIZE_MIN / (ssize_t)1024)) + conf_parserror("value too small"); + val *= (ssize_t)1024; + break; + + case CONF_MULT1G: + if (val > (ssize_t)(SSIZE_MAX / (1024 * 1024))) + conf_parserror("value too large"); + if (val < (ssize_t)(SSIZE_MIN / (1024 * 1024))) + conf_parserror("value too small"); + val *= (ssize_t)(1024 * 1024); + break; + + default: /* it was not a multiplier */ + unget_conftoken(); + break; + } + + keytable = save_kt; + return val; +} + +off_t +get_am64_t(void) +{ + off_t val; + keytab_t *save_kt; + + save_kt = keytable; + keytable = numb_keytable; + + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_INT: + val = (off_t)tokenval.v.i; + break; + + case CONF_LONG: + val = (off_t)tokenval.v.l; + break; + + case CONF_SIZE: + val = (off_t)tokenval.v.size; + break; + + case CONF_AM64: + val = tokenval.v.am64; + break; + + case CONF_AMINFINITY: + val = AM64_MAX; + break; + + default: + conf_parserror("an am64 is expected %d", tok); + val = 0; + break; + } + + /* get multiplier, if any */ + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_NL: /* multiply by one */ + case CONF_MULT1: + case CONF_MULT1K: + break; + + case CONF_MULT7: + if (val > AM64_MAX/7 || val < AM64_MIN/7) + conf_parserror("value too large"); + val *= 7; + break; + + case CONF_MULT1M: + if (val > AM64_MAX/1024 || val < AM64_MIN/1024) + conf_parserror("value too large"); + val *= 1024; + break; + + case CONF_MULT1G: + if (val > AM64_MAX/(1024*1024) || val < AM64_MIN/(1024*1024)) + conf_parserror("value too large"); + val *= 1024*1024; + break; + + default: /* it was not a multiplier */ + unget_conftoken(); + break; + } + + keytable = save_kt; + + return val; +} + +keytab_t bool_keytable[] = { + { "Y", CONF_ATRUE }, + { "YES", CONF_ATRUE }, + { "T", CONF_ATRUE }, + { "TRUE", CONF_ATRUE }, + { "ON", CONF_ATRUE }, + { "N", CONF_AFALSE }, + { "NO", CONF_AFALSE }, + { "F", CONF_AFALSE }, + { "FALSE", CONF_AFALSE }, + { "OFF", CONF_AFALSE }, + { NULL, CONF_IDENT } +}; + +int +get_bool(void) +{ + int val; + keytab_t *save_kt; + + save_kt = keytable; + keytable = bool_keytable; + + get_conftoken(CONF_ANY); + + switch(tok) { + case CONF_INT: + if (tokenval.v.i != 0) + val = 1; + else + val = 0; + break; + + case CONF_LONG: + if (tokenval.v.l != 0L) + val = 1; + else + val = 0; + break; + + case CONF_SIZE: + if (tokenval.v.size != (size_t)0) + val = 1; + else + val = 0; + break; + + case CONF_AM64: + if (tokenval.v.am64 != (off_t)0) + val = 1; + else + val = 0; + break; + + case CONF_ATRUE: + val = 1; + break; + + case CONF_AFALSE: + val = 0; + break; + + case CONF_NL: + unget_conftoken(); + val = 2; /* no argument - most likely TRUE */ + break; + default: + unget_conftoken(); + val = 3; /* a bad argument - most likely TRUE */ + conf_parserror("YES, NO, TRUE, FALSE, ON, OFF expected"); + break; + } + + keytable = save_kt; + return val; +} + +void +ckseen( + int *seen) +{ + if (*seen && !allow_overwrites && conf_line_num != -2) { + conf_parserror("duplicate parameter, prev def on line %d", *seen); + } + *seen = conf_line_num; +} + +printf_arglist_function(void conf_parserror, const char *, format) +{ + va_list argp; + + /* print error message */ + + if(conf_line) + fprintf(stderr, "argument \"%s\": ", conf_line); + else + fprintf(stderr, "\"%s\", line %d: ", conf_confname, conf_line_num); + arglist_start(argp, format); + vfprintf(stderr, format, argp); + arglist_end(argp); + fputc('\n', stderr); + + got_parserror = 1; +} + +tok_t +lookup_keyword( + char * str) +{ + keytab_t *kwp; + + /* switch to binary search if performance warrants */ + + for(kwp = keytable; kwp->keyword != NULL; kwp++) { + if (strcmp(kwp->keyword, str) == 0) break; + } + return kwp->token; +} + +char tkbuf[4096]; + +/* push the last token back (can only unget ANY tokens) */ +void +unget_conftoken(void) +{ + token_pushed = 1; + pushed_tok = tok; + tok = CONF_UNKNOWN; + return; +} + +char +conftoken_getc(void) +{ + if(conf_line == NULL) + return getc(conf_conf); + if(*conf_char == '\0') + return -1; + return(*conf_char++); +} + +int +conftoken_ungetc( + int c) +{ + if(conf_line == NULL) + return ungetc(c, conf_conf); + else if(conf_char > conf_line) { + if(c == -1) + return c; + conf_char--; + if(*conf_char != c) { + error("*conf_char != c : %c %c", *conf_char, c); + /* NOTREACHED */ + } + } else { + error("conf_char == conf_line"); + /* NOTREACHED */ + } + return c; +} + +void +get_conftoken( + tok_t exp) +{ + int ch, d; + off_t am64; + char *buf; + char *tmps; + int token_overflow; + int inquote = 0; + int escape = 0; + int sign; + + if (token_pushed) { + token_pushed = 0; + tok = pushed_tok; + + /* + ** If it looked like a key word before then look it + ** up again in the current keyword table. + */ + switch(tok) { + case CONF_LONG: case CONF_AM64: case CONF_SIZE: + case CONF_INT: case CONF_REAL: case CONF_STRING: + case CONF_LBRACE: case CONF_RBRACE: case CONF_COMMA: + case CONF_NL: case CONF_END: case CONF_UNKNOWN: + case CONF_TIME: + break; + + default: + if (exp == CONF_IDENT) + tok = CONF_IDENT; + else + tok = lookup_keyword(tokenval.v.s); + break; + } + } + else { + ch = conftoken_getc(); + + while(ch != EOF && ch != '\n' && isspace(ch)) + ch = conftoken_getc(); + if (ch == '#') { /* comment - eat everything but eol/eof */ + while((ch = conftoken_getc()) != EOF && ch != '\n') { + (void)ch; /* Quiet empty loop complaints */ + } + } + + if (isalpha(ch)) { /* identifier */ + buf = tkbuf; + token_overflow = 0; + do { + if (islower(ch)) ch = toupper(ch); + if (buf < tkbuf+sizeof(tkbuf)-1) { + *buf++ = (char)ch; + } else { + *buf = '\0'; + if (!token_overflow) { + conf_parserror("token too long: %.20s...", tkbuf); + } + token_overflow = 1; + } + ch = conftoken_getc(); + } while(isalnum(ch) || ch == '_' || ch == '-'); + + if (ch != EOF && conftoken_ungetc(ch) == EOF) { + if (ferror(conf_conf)) { + conf_parserror("Pushback of '%c' failed: %s", + ch, strerror(ferror(conf_conf))); + } else { + conf_parserror("Pushback of '%c' failed: EOF", ch); + } + } + *buf = '\0'; + + tokenval.v.s = tkbuf; + + if (token_overflow) tok = CONF_UNKNOWN; + else if (exp == CONF_IDENT) tok = CONF_IDENT; + else tok = lookup_keyword(tokenval.v.s); + } + else if (isdigit(ch)) { /* integer */ + sign = 1; + +negative_number: /* look for goto negative_number below sign is set there */ + am64 = 0; + do { + am64 = am64 * 10 + (ch - '0'); + ch = conftoken_getc(); + } while (isdigit(ch)); + + if (ch != '.') { + if (exp == CONF_INT) { + tok = CONF_INT; + tokenval.v.i = sign * (int)am64; + } else if (exp == CONF_LONG) { + tok = CONF_LONG; + tokenval.v.l = (long)sign * (long)am64; + } else if (exp != CONF_REAL) { + tok = CONF_AM64; + tokenval.v.am64 = (off_t)sign * am64; + } else { + /* automatically convert to real when expected */ + tokenval.v.r = (double)sign * (double)am64; + tok = CONF_REAL; + } + } else { + /* got a real number, not an int */ + tokenval.v.r = sign * (double) am64; + am64 = 0; + d = 1; + ch = conftoken_getc(); + while (isdigit(ch)) { + am64 = am64 * 10 + (ch - '0'); + d = d * 10; + ch = conftoken_getc(); + } + tokenval.v.r += sign * ((double)am64) / d; + tok = CONF_REAL; + } + + if (ch != EOF && conftoken_ungetc(ch) == EOF) { + if (ferror(conf_conf)) { + conf_parserror("Pushback of '%c' failed: %s", + ch, strerror(ferror(conf_conf))); + } else { + conf_parserror("Pushback of '%c' failed: EOF", ch); + } + } + } else switch(ch) { + case '"': /* string */ + buf = tkbuf; + token_overflow = 0; + inquote = 1; + *buf++ = (char)ch; + while (inquote && ((ch = conftoken_getc()) != EOF)) { + if (ch == '\n') { + if (!escape) + break; + escape = 0; + buf--; /* Consume escape in buffer */ + } else if (ch == '\\') { + escape = 1; + } else { + if (ch == '"') { + if (!escape) + inquote = 0; + } + escape = 0; + } + + if(buf >= &tkbuf[sizeof(tkbuf) - 1]) { + if (!token_overflow) { + conf_parserror("string too long: %.20s...", tkbuf); + } + token_overflow = 1; + break; + } + *buf++ = (char)ch; + } + *buf = '\0'; + + /* + * A little manuver to leave a fully unquoted, unallocated string + * in tokenval.v.s + */ + tmps = unquote_string(tkbuf); + strncpy(tkbuf, tmps, sizeof(tkbuf)); + amfree(tmps); + tokenval.v.s = tkbuf; + + tok = (token_overflow) ? CONF_UNKNOWN : + (exp == CONF_IDENT) ? CONF_IDENT : CONF_STRING; + break; + + case '-': + ch = conftoken_getc(); + if (isdigit(ch)) { + sign = -1; + goto negative_number; + } + else { + if (ch != EOF && conftoken_ungetc(ch) == EOF) { + if (ferror(conf_conf)) { + conf_parserror("Pushback of '%c' failed: %s", + ch, strerror(ferror(conf_conf))); + } else { + conf_parserror("Pushback of '%c' failed: EOF", ch); + } + } + tok = CONF_UNKNOWN; + } + break; + + case ',': + tok = CONF_COMMA; + break; + + case '{': + tok = CONF_LBRACE; + break; + + case '}': + tok = CONF_RBRACE; + break; + + case '\n': + tok = CONF_NL; + break; + + case EOF: + tok = CONF_END; + break; + + default: + tok = CONF_UNKNOWN; + break; + } + } + + if (exp != CONF_ANY && tok != exp) { + char *str; + keytab_t *kwp; + + switch(exp) { + case CONF_LBRACE: + str = "\"{\""; + break; + + case CONF_RBRACE: + str = "\"}\""; + break; + + case CONF_COMMA: + str = "\",\""; + break; + + case CONF_NL: + str = "end of line"; + break; + + case CONF_END: + str = "end of file"; + break; + + case CONF_INT: + str = "an integer"; + break; + + case CONF_REAL: + str = "a real number"; + break; + + case CONF_STRING: + str = "a quoted string"; + break; + + case CONF_IDENT: + str = "an identifier"; + break; + + default: + for(kwp = keytable; kwp->keyword != NULL; kwp++) { + if (exp == kwp->token) + break; + } + if (kwp->keyword == NULL) + str = "token not"; + else + str = kwp->keyword; + break; + } + conf_parserror("%s is expected", str); + tok = exp; + if (tok == CONF_INT) + tokenval.v.i = 0; + else + tokenval.v.s = ""; + } +} + + +void +read_string( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + get_conftoken(CONF_STRING); + val->v.s = newstralloc(val->v.s, tokenval.v.s); +} + +void +read_ident( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + get_conftoken(CONF_IDENT); + val->v.s = newstralloc(val->v.s, tokenval.v.s); +} + +void +read_int( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + val->v.i = get_int(); +} + +void +read_long( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + val->v.l = get_long(); +} + +void +read_size( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + val->v.size = get_size(); +} + +void +read_am64( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + val->v.am64 = get_am64_t(); +} + +void +read_bool( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + val->v.i = get_bool(); +} + +void +read_real( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + get_conftoken(CONF_REAL); + val->v.r = tokenval.v.r; +} + +void +read_time( + t_conf_var *np, + val_t *val) +{ + np = np; + ckseen(&val->seen); + val->v.t = get_time(); +} + +void +copy_val_t( + val_t *valdst, + val_t *valsrc) +{ + if(valsrc->seen) { + valdst->type = valsrc->type; + valdst->seen = valsrc->seen; + switch(valsrc->type) { + case CONFTYPE_INT: + case CONFTYPE_BOOL: + case CONFTYPE_COMPRESS: + case CONFTYPE_ENCRYPT: + case CONFTYPE_HOLDING: + case CONFTYPE_ESTIMATE: + case CONFTYPE_STRATEGY: + case CONFTYPE_TAPERALGO: + case CONFTYPE_PRIORITY: + valdst->v.i = valsrc->v.i; + break; + + case CONFTYPE_LONG: + valdst->v.l = valsrc->v.l; + break; + + case CONFTYPE_SIZE: + valdst->v.size = valsrc->v.size; + break; + + case CONFTYPE_AM64: + valdst->v.am64 = valsrc->v.am64; + break; + + case CONFTYPE_REAL: + valdst->v.r = valsrc->v.r; + break; + + case CONFTYPE_RATE: + valdst->v.rate[0] = valsrc->v.rate[0]; + valdst->v.rate[1] = valsrc->v.rate[1]; + break; + + case CONFTYPE_IDENT: + case CONFTYPE_STRING: + valdst->v.s = stralloc(valsrc->v.s); + break; + + case CONFTYPE_TIME: + valdst->v.t = valsrc->v.t; + break; + + case CONFTYPE_SL: + valdst->v.sl = duplicate_sl(valsrc->v.sl); + break; + + case CONFTYPE_EXINCLUDE: + valdst->v.exinclude.type = valsrc->v.exinclude.type; + valdst->v.exinclude.optional = valsrc->v.exinclude.optional; + valdst->v.exinclude.sl = duplicate_sl(valsrc->v.exinclude.sl); + break; + } + } +} + +void +free_val_t( + val_t *val) +{ + switch(val->type) { + case CONFTYPE_INT: + case CONFTYPE_BOOL: + case CONFTYPE_COMPRESS: + case CONFTYPE_ENCRYPT: + case CONFTYPE_HOLDING: + case CONFTYPE_ESTIMATE: + case CONFTYPE_STRATEGY: + case CONFTYPE_SIZE: + case CONFTYPE_TAPERALGO: + case CONFTYPE_PRIORITY: + case CONFTYPE_LONG: + case CONFTYPE_AM64: + case CONFTYPE_REAL: + case CONFTYPE_RATE: + break; + + case CONFTYPE_IDENT: + case CONFTYPE_STRING: + amfree(val->v.s); + break; + + case CONFTYPE_TIME: + break; + + case CONFTYPE_SL: + free_sl(val->v.sl); + break; + + case CONFTYPE_EXINCLUDE: + free_sl(val->v.exinclude.sl); + break; + } + val->seen = 0; +} + +char * +taperalgo2str( + int taperalgo) +{ + if(taperalgo == ALGO_FIRST) return "FIRST"; + if(taperalgo == ALGO_FIRSTFIT) return "FIRSTFIT"; + if(taperalgo == ALGO_LARGEST) return "LARGEST"; + if(taperalgo == ALGO_LARGESTFIT) return "LARGESTFIT"; + if(taperalgo == ALGO_SMALLEST) return "SMALLEST"; + if(taperalgo == ALGO_LAST) return "LAST"; + return "UNKNOWN"; +} + +static char buffer_conf_print[1025]; + +char * +conf_print( + val_t *val) +{ + struct tm *stm; + int pos; + + buffer_conf_print[0] = '\0'; + switch(val->type) { + case CONFTYPE_INT: + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), "%d", val->v.i); + break; + + case CONFTYPE_LONG: + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), "%ld", val->v.l); + break; + + case CONFTYPE_SIZE: + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), SSIZE_T_FMT, + (SSIZE_T_FMT_TYPE)val->v.size); + break; + + case CONFTYPE_AM64: + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), OFF_T_FMT , + (OFF_T_FMT_TYPE)val->v.am64); + break; + + case CONFTYPE_REAL: + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), "%0.5f" , val->v.r); + break; + + case CONFTYPE_RATE: + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), "%0.5f %0.5f" , val->v.rate[0], val->v.rate[1]); + break; + + case CONFTYPE_IDENT: + if(val->v.s) { + strncpy(buffer_conf_print, val->v.s, SIZEOF(buffer_conf_print)); + buffer_conf_print[SIZEOF(buffer_conf_print) - 1] = '\0'; + } else + buffer_conf_print[0] = '\0'; + break; + + case CONFTYPE_STRING: + buffer_conf_print[0] = '"'; + if(val->v.s) { + strncpy(&buffer_conf_print[1], val->v.s, + SIZEOF(buffer_conf_print) - 1); + buffer_conf_print[SIZEOF(buffer_conf_print) - 2] = '\0'; + buffer_conf_print[strlen(buffer_conf_print)] = '"'; + } else { + buffer_conf_print[1] = '"'; + buffer_conf_print[2] = '\0'; + } + break; + + case CONFTYPE_TIME: + stm = localtime(&val->v.t); + if (stm) { + snprintf(buffer_conf_print, SIZEOF(buffer_conf_print), + "%d%02d%02d", stm->tm_hour, stm->tm_min, stm->tm_sec); + } else { + strcpy(buffer_conf_print, "00000"); + } + break; + + case CONFTYPE_SL: + buffer_conf_print[0] = '\0'; + break; + + case CONFTYPE_EXINCLUDE: + buffer_conf_print[0] = '\0'; + if(val->v.exinclude.type == 0) + strncpy(buffer_conf_print, "LIST ", SIZEOF(buffer_conf_print)); + else + strncpy(buffer_conf_print, "FILE ", SIZEOF(buffer_conf_print)); + pos = 5; + if(val->v.exinclude.optional == 1) + strncpy(&buffer_conf_print[pos], "OPTIONAL ", SIZEOF(buffer_conf_print)); + pos += 9; + break; + + case CONFTYPE_BOOL: + if(val->v.i) + strncpy(buffer_conf_print, "yes", SIZEOF(buffer_conf_print)); + else + strncpy(buffer_conf_print, "no", SIZEOF(buffer_conf_print)); + break; + + case CONFTYPE_STRATEGY: + switch(val->v.i) { + case DS_SKIP: + strncpy(buffer_conf_print, "SKIP", SIZEOF(buffer_conf_print)); + break; + + case DS_STANDARD: + strncpy(buffer_conf_print, "STANDARD", SIZEOF(buffer_conf_print)); + break; + + case DS_NOFULL: + strncpy(buffer_conf_print, "NOFULL", SIZEOF(buffer_conf_print)); + break; + + case DS_NOINC: + strncpy(buffer_conf_print, "NOINC", SIZEOF(buffer_conf_print)); + break; + + case DS_HANOI: + strncpy(buffer_conf_print, "HANOI", SIZEOF(buffer_conf_print)); + break; + + case DS_INCRONLY: + strncpy(buffer_conf_print, "INCRONLY", SIZEOF(buffer_conf_print)); + break; + } + break; + + case CONFTYPE_COMPRESS: + switch(val->v.i) { + case COMP_NONE: + strncpy(buffer_conf_print, "NONE", SIZEOF(buffer_conf_print)); + break; + + case COMP_FAST: + strncpy(buffer_conf_print, "CLIENT FAST", SIZEOF(buffer_conf_print)); + break; + + case COMP_BEST: + strncpy(buffer_conf_print, "CLIENT BEST", SIZEOF(buffer_conf_print)); + break; + + case COMP_CUST: + strncpy(buffer_conf_print, "CLIENT CUSTOM", SIZEOF(buffer_conf_print)); + break; + + case COMP_SERV_FAST: + strncpy(buffer_conf_print, "SERVER FAST", SIZEOF(buffer_conf_print)); + break; + + case COMP_SERV_BEST: + strncpy(buffer_conf_print, "SERVER FAST", SIZEOF(buffer_conf_print)); + break; + + case COMP_SERV_CUST: + strncpy(buffer_conf_print, "SERVER CUSTOM", SIZEOF(buffer_conf_print)); + break; + } + break; + + case CONFTYPE_ESTIMATE: + switch(val->v.i) { + case ES_CLIENT: + strncpy(buffer_conf_print, "CLIENT", SIZEOF(buffer_conf_print)); + break; + + case ES_SERVER: + strncpy(buffer_conf_print, "SERVER", SIZEOF(buffer_conf_print)); + break; + + case ES_CALCSIZE: + strncpy(buffer_conf_print, "CALCSIZE", SIZEOF(buffer_conf_print)); + break; + } + break; + + case CONFTYPE_ENCRYPT: + switch(val->v.i) { + case ENCRYPT_NONE: + strncpy(buffer_conf_print, "NONE", SIZEOF(buffer_conf_print)); + break; + + case ENCRYPT_CUST: + strncpy(buffer_conf_print, "CLIENT", SIZEOF(buffer_conf_print)); + break; + + case ENCRYPT_SERV_CUST: + strncpy(buffer_conf_print, "SERVER", SIZEOF(buffer_conf_print)); + break; + } + break; + + case CONFTYPE_HOLDING: + switch(val->v.i) { + case HOLD_NEVER: + strncpy(buffer_conf_print, "NEVER", SIZEOF(buffer_conf_print)); + break; + + case HOLD_AUTO: + strncpy(buffer_conf_print, "AUTO", SIZEOF(buffer_conf_print)); + break; + + case HOLD_REQUIRED: + strncpy(buffer_conf_print, "REQUIRED", SIZEOF(buffer_conf_print)); + break; + } + break; + + case CONFTYPE_TAPERALGO: + strncpy(buffer_conf_print, taperalgo2str(val->v.i), SIZEOF(buffer_conf_print)); + break; + + case CONFTYPE_PRIORITY: + switch(val->v.i) { + case 0: + strncpy(buffer_conf_print, "LOW", SIZEOF(buffer_conf_print)); + break; + + case 1: + strncpy(buffer_conf_print, "MEDIUM", SIZEOF(buffer_conf_print)); + break; + + case 2: + strncpy(buffer_conf_print, "HIGH", SIZEOF(buffer_conf_print)); + break; + } + break; + } + buffer_conf_print[SIZEOF(buffer_conf_print) - 1] = '\0'; + return buffer_conf_print; +} + +void +conf_init_string( + val_t *val, + char *s) +{ + val->seen = 0; + val->type = CONFTYPE_STRING; + if(s) + val->v.s = stralloc(s); + else + val->v.s = NULL; +} + +void +conf_init_ident( + val_t *val, + char *s) +{ + val->seen = 0; + val->type = CONFTYPE_IDENT; + if(s) + val->v.s = stralloc(s); + else + val->v.s = NULL; +} + +void +conf_init_int( + val_t *val, + int i) +{ + val->seen = 0; + val->type = CONFTYPE_INT; + val->v.i = i; +} + +void +conf_init_bool( + val_t *val, + int i) +{ + val->seen = 0; + val->type = CONFTYPE_BOOL; + val->v.i = i; +} + +void +conf_init_strategy( + val_t *val, + int i) +{ + val->seen = 0; + val->type = CONFTYPE_STRATEGY; + val->v.i = i; +} + +void +conf_init_estimate( + val_t *val, + int i) +{ + val->seen = 0; + val->type = CONFTYPE_ESTIMATE; + val->v.i = i; +} + +void +conf_init_taperalgo( + val_t *val, + int i) +{ + val->seen = 0; + val->type = CONFTYPE_TAPERALGO; + val->v.i = i; +} + +void +conf_init_priority( + val_t *val, + int i) +{ + val->seen = 0; + val->type = CONFTYPE_PRIORITY; + val->v.i = i; +} + +void +conf_init_compress( + val_t *val, + comp_t i) +{ + val->seen = 0; + val->type = CONFTYPE_COMPRESS; + val->v.i = (int)i; +} + +void +conf_init_encrypt( + val_t *val, + encrypt_t i) +{ + val->seen = 0; + val->type = CONFTYPE_ENCRYPT; + val->v.i = (int)i; +} + +void +conf_init_holding( + val_t *val, + dump_holdingdisk_t i) +{ + val->seen = 0; + val->type = CONFTYPE_HOLDING; + val->v.i = (int)i; +} + +void +conf_init_long( + val_t *val, + long l) +{ + val->seen = 0; + val->type = CONFTYPE_LONG; + val->v.l = l; +} + +void +conf_init_size( + val_t *val, + ssize_t sz) +{ + val->seen = 0; + val->type = CONFTYPE_SIZE; + val->v.size = sz; +} + +void +conf_init_am64( + val_t *val, + off_t l) +{ + val->seen = 0; + val->type = CONFTYPE_AM64; + val->v.am64 = l; +} + +void +conf_init_real( + val_t *val, + double r) +{ + val->seen = 0; + val->type = CONFTYPE_REAL; + val->v.r = r; +} + +void +conf_init_rate( + val_t *val, + double r1, + double r2) +{ + val->seen = 0; + val->type = CONFTYPE_RATE; + val->v.rate[0] = r1; + val->v.rate[1] = r2; +} + +void +conf_init_time( + val_t *val, + time_t t) +{ + val->seen = 0; + val->type = CONFTYPE_TIME; + val->v.t = t; +} + +void +conf_init_sl( + val_t *val, + sl_t *sl) +{ + val->seen = 0; + val->type = CONFTYPE_AM64; + val->v.sl = sl; +} + +void +conf_init_exinclude( + val_t *val) +{ + val->seen = 0; + val->type = CONFTYPE_EXINCLUDE; + val->v.exinclude.type = 0; + val->v.exinclude.optional = 0; + val->v.exinclude.sl = NULL; +} + +void +conf_set_string( + val_t *val, + char *s) +{ + val->seen = -1; + val->type = CONFTYPE_STRING; + amfree(val->v.s); + val->v.s = stralloc(s); +} + +void +conf_set_int( + val_t *val, + int i) +{ + val->seen = -1; + val->type = CONFTYPE_INT; + val->v.i = i; +} + +void +conf_set_bool( + val_t *val, + int i) +{ + val->seen = -1; + val->type = CONFTYPE_BOOL; + val->v.i = i; +} + +void +conf_set_compress( + val_t *val, + comp_t i) +{ + val->seen = -1; + val->type = CONFTYPE_COMPRESS; + val->v.i = (int)i; +} + +void +conf_set_encrypt( + val_t *val, + encrypt_t i) +{ + val->seen = -1; + val->type = CONFTYPE_COMPRESS; + val->v.i = (int)i; +} + +void +conf_set_holding( + val_t *val, + dump_holdingdisk_t i) +{ + val->seen = -1; + val->type = CONFTYPE_HOLDING; + val->v.i = (int)i; +} + +void +conf_set_strategy( + val_t *val, + int i) +{ + val->seen = -1; + val->type = CONFTYPE_STRATEGY; + val->v.i = i; +} + + +int +get_conftype_int( + val_t *val) +{ + if (val->type != CONFTYPE_INT) { + error("get_conftype_int: val.type is not CONFTYPE_INT"); + /*NOTREACHED*/ + } + return val->v.i; +} + +long +get_conftype_long( + val_t *val) +{ + if (val->type != CONFTYPE_LONG) { + error("get_conftype_long: val.type is not CONFTYPE_LONG"); + /*NOTREACHED*/ + } + return val->v.l; +} + +off_t +get_conftype_am64( + val_t *val) +{ + if (val->type != CONFTYPE_AM64) { + error("get_conftype_am64: val.type is not CONFTYPE_AM64"); + /*NOTREACHED*/ + } + return val->v.am64; +} + +double +get_conftype_real( + val_t *val) +{ + if (val->type != CONFTYPE_REAL) { + error("get_conftype_real: val.type is not CONFTYPE_REAL"); + /*NOTREACHED*/ + } + return val->v.r; +} + +char * +get_conftype_string( + val_t *val) +{ + if (val->type != CONFTYPE_STRING) { + error("get_conftype_string: val.type is not CONFTYPE_STRING"); + /*NOTREACHED*/ + } + return val->v.s; +} + +char * +get_conftype_ident( + val_t *val) +{ + if (val->type != CONFTYPE_IDENT) { + error("get_conftype_ident: val.type is not CONFTYPE_IDENT"); + /*NOTREACHED*/ + } + return val->v.s; +} + +time_t +get_conftype_time( + val_t *val) +{ + if (val->type != CONFTYPE_TIME) { + error("get_conftype_time: val.type is not CONFTYPE_TIME"); + /*NOTREACHED*/ + } + return val->v.t; +} + +ssize_t +get_conftype_size( + val_t *val) +{ + if (val->type != CONFTYPE_SIZE) { + error("get_conftype_size: val.type is not CONFTYPE_SIZE"); + /*NOTREACHED*/ + } + return val->v.size; +} + +sl_t * +get_conftype_sl( + val_t *val) +{ + if (val->type != CONFTYPE_SL) { + error("get_conftype_size: val.type is not CONFTYPE_SL"); + /*NOTREACHED*/ + } + return val->v.sl; +} + +int +get_conftype_bool( + val_t *val) +{ + if (val->type != CONFTYPE_BOOL) { + error("get_conftype_bool: val.type is not CONFTYPE_BOOL"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_hold( + val_t *val) +{ + if (val->type != CONFTYPE_HOLDING) { + error("get_conftype_hold: val.type is not CONFTYPE_HOLDING"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_compress( + val_t *val) +{ + if (val->type != CONFTYPE_COMPRESS) { + error("get_conftype_compress: val.type is not CONFTYPE_COMPRESS"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_encrypt( + val_t *val) +{ + if (val->type != CONFTYPE_ENCRYPT) { + error("get_conftype_encrypt: val.type is not CONFTYPE_ENCRYPT"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_estimate( + val_t *val) +{ + if (val->type != CONFTYPE_ESTIMATE) { + error("get_conftype_extimate: val.type is not CONFTYPE_ESTIMATE"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_strategy( + val_t *val) +{ + if (val->type != CONFTYPE_STRATEGY) { + error("get_conftype_strategy: val.type is not CONFTYPE_STRATEGY"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_taperalgo( + val_t *val) +{ + if (val->type != CONFTYPE_TAPERALGO) { + error("get_conftype_taperalgo: val.type is not CONFTYPE_TAPERALGO"); + /*NOTREACHED*/ + } + return val->v.i; +} + +int +get_conftype_priority( + val_t *val) +{ + if (val->type != CONFTYPE_PRIORITY) { + error("get_conftype_priority: val.type is not CONFTYPE_PRIORITY"); + /*NOTREACHED*/ + } + return val->v.i; +} + +exinclude_t +get_conftype_exinclude( + val_t *val) +{ + if (val->type != CONFTYPE_EXINCLUDE) { + error("get_conftype_exinclude: val.type is not CONFTYPE_EXINCLUDE"); + /*NOTREACHED*/ + } + return val->v.exinclude; +} + + +void +dump_sockaddr( + struct sockaddr_in * sa) +{ + dbprintf(("%s: (sockaddr_in *)%p = { %d, %hd, %s }\n", + debug_prefix(NULL), sa, sa->sin_family, sa->sin_port, + inet_ntoa(sa->sin_addr))); +} + +void +read_block( + command_option_t *command_options, + t_conf_var *read_var, + keytab_t *keytab, + val_t *valarray, + char *prefix, + char *errormsg, + int read_brace, + void (*copy_function)(void)) +{ + t_conf_var *np; + int saved_conf_line_num; + int done; + + if(read_brace) { + get_conftoken(CONF_LBRACE); + get_conftoken(CONF_NL); + } + + done = 0; + do { + conf_line_num += 1; + get_conftoken(CONF_ANY); + switch(tok) { + case CONF_RBRACE: + done = 1; + break; + case CONF_NL: /* empty line */ + break; + case CONF_END: /* end of file */ + done = 1; + break; + case CONF_IDENT: + case CONF_STRING: + if(copy_function) + copy_function(); + else + conf_parserror("ident not expected"); + break; + default: + { + for(np = read_var; np->token != CONF_UNKNOWN; np++) + if(np->token == tok) break; + + if(np->token == CONF_UNKNOWN) + conf_parserror(errormsg); + else { + np->read_function(np, &valarray[np->parm]); + if(np->validate) + np->validate(np, &valarray[np->parm]); + } + } + } + if(tok != CONF_NL && tok != CONF_END && tok != CONF_RBRACE) + get_conftoken(CONF_NL); + } while(!done); + + /* overwrite with command line option */ + saved_conf_line_num = conf_line_num; + command_overwrite(command_options, read_var, keytab, valarray, prefix); + conf_line_num = saved_conf_line_num; +} + +void +command_overwrite( + command_option_t *command_options, + t_conf_var *overwrite_var, + keytab_t *keytab, + val_t *valarray, + char *prefix) +{ + t_conf_var *np; + keytab_t *kt; + char *myprefix; + command_option_t *command_option; + + if(!command_options) return; + + for(np = overwrite_var; np->token != CONF_UNKNOWN; np++) { + for(kt = keytab; kt->token != CONF_UNKNOWN; kt++) + if(kt->token == np->token) break; + + if(kt->token == CONF_UNKNOWN) { + error("read_conf: invalid token"); + /* NOTREACHED */ + } + + for(command_option = command_options; command_option->name != NULL; + command_option++) { + myprefix = stralloc2(prefix, kt->keyword); + if(strcasecmp(myprefix, command_option->name) == 0) { + command_option->used = 1; + valarray[np->parm].seen = -2; + if(np->type == CONFTYPE_STRING && + command_option->value[0] != '"') { + conf_line = vstralloc("\"", command_option->value, "\"", + NULL); + } + else { + conf_line = stralloc(command_option->value); + } + conf_char = conf_line; + token_pushed = 0; + conf_line_num = -2; + np->read_function(np, &valarray[np->parm]); + amfree(conf_line); + conf_line = conf_char = NULL; + + if(np->validate) + np->validate(np, &valarray[np->parm]); + } + amfree(myprefix); + } + } +} + +void +free_new_argv( + int new_argc, + char **new_argv) +{ + int i; + for(i=0; i [ ] , ; : ! $ \ / " + * else returns 1 + */ +int validate_mailto(const char *mailto); -char *construct_datestamp P((time_t *t)); -char *construct_timestamp P((time_t *t)); +char *taperalgo2str(int taperalgo); +void free_new_argv(int new_argc, char **new_argv); #endif /* UTIL_H */ diff --git a/common-src/version.c b/common-src/version.c index efb8414..525284a 100644 --- a/common-src/version.c +++ b/common-src/version.c @@ -1,8 +1,8 @@ /* version.c - generated by genversion.c - DO NOT EDIT! */ const char * const version_info[] = { - "build: VERSION=\"Amanda-2.5.0p2\"\n", - " BUILT_DATE=\"Mon May 8 07:54:11 EDT 2006\"\n", - " BUILT_MACH=\"Linux modemcable099.122-200-24.mc.videotron.ca 2.6.16-1.2111_FC5 #1 SMP Thu May 4 21:16:04 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux\"\n", + "build: VERSION=\"Amanda-2.5.1\"\n", + " BUILT_DATE=\"Tue Sep 5 10:09:05 EDT 2006\"\n", + " BUILT_MACH=\"Linux modemcable197.174-201-24.mc.videotron.ca 2.6.17-1.2174_FC5 #1 SMP Tue Aug 8 15:30:44 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux\"\n", " CC=\"gcc\"\n", " CONFIGURE_COMMAND=\"'./configure' '--prefix=/home/martinea/linux' '--with-configdir=/home/martinea/etc/amanda' '--with-gnutar-listdir=/var/gnutar-lists' '--with-bsd-security' '--with-ssh-security' '--with-rsh-security' '--with-krb4-security' '--without-krb5-security' '--with-user=martinea' '--with-group=martinea' '--mandir=/home/martinea/man'\"\n", "paths: bindir=\"/home/martinea/linux/bin\"\n", @@ -18,14 +18,13 @@ const char * const version_info[] = { " COMPRESS_PATH=\"/usr/bin/gzip\"\n", " UNCOMPRESS_PATH=\"/usr/bin/gzip\" LPRCMD=\"/usr/bin/lpr\"\n", " MAILER=\"/usr/bin/Mail\" listed_incr_dir=\"/var/gnutar-lists\"\n", - "defs: DEFAULT_SERVER=\"modemcable099.122-200-24.mc.videotron.ca\"\n", + "defs: DEFAULT_SERVER=\"modemcable197.174-201-24.mc.videotron.ca\"\n", " DEFAULT_CONFIG=\"DailySet1\"\n", - " DEFAULT_TAPE_SERVER=\"modemcable099.122-200-24.mc.videotron.ca\"\n", - " DEFAULT_TAPE_DEVICE=\"null:\" HAVE_MMAP HAVE_SYSVSHM\n", - " LOCKING=POSIX_FCNTL SETPGRP_VOID DEBUG_CODE\n", - " AMANDA_DEBUG_DAYS=4 BSD_SECURITY RSH_SECURITY USE_AMANDAHOSTS\n", - " CLIENT_LOGIN=\"martinea\" FORCE_USERID HAVE_GZIP\n", - " COMPRESS_SUFFIX=\".gz\" COMPRESS_FAST_OPT=\"--fast\"\n", + " DEFAULT_TAPE_SERVER=\"modemcable197.174-201-24.mc.videotron.ca\"\n", + " HAVE_MMAP HAVE_SYSVSHM LOCKING=POSIX_FCNTL SETPGRP_VOID\n", + " DEBUG_CODE AMANDA_DEBUG_DAYS=4 BSD_SECURITY RSH_SECURITY\n", + " USE_AMANDAHOSTS CLIENT_LOGIN=\"martinea\" FORCE_USERID\n", + " HAVE_GZIP COMPRESS_SUFFIX=\".gz\" COMPRESS_FAST_OPT=\"--fast\"\n", " COMPRESS_BEST_OPT=\"--best\" UNCOMPRESS_OPT=\"-dc\"\n", 0 }; diff --git a/common-src/version.h b/common-src/version.h index f287767..1ee7cf9 100644 --- a/common-src/version.h +++ b/common-src/version.h @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: version.h,v 1.5 1999/04/16 04:58:58 kashmir Exp $ + * $Id: version.h,v 1.6 2006/05/25 01:47:12 johnfranks Exp $ * * interface to obtain the current amanda version */ @@ -51,9 +51,9 @@ extern const char * const VERSION_COMMENT; extern const char * const version_info[]; /* versionsuffix returns an empty string or a string like -2.3.0.4b1. */ -extern const char *versionsuffix P((void)); +extern const char *versionsuffix(void); /* version returns a string representing the version of Amanda. */ -extern const char *version P((void)); +extern const char *version(void); #endif diff --git a/common-src/versuff.c b/common-src/versuff.c index b32588a..2cafbd6 100644 --- a/common-src/versuff.c +++ b/common-src/versuff.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: versuff.c.in,v 1.11 2003/05/20 17:33:53 martinea Exp $ + * $Id: versuff.c.in,v 1.12 2006/05/25 01:47:12 johnfranks Exp $ * * provide amanda version number and suffix appended to program names */ @@ -33,21 +33,21 @@ const int VERSION_MAJOR = 2; const int VERSION_MINOR = 5; -const int VERSION_PATCH = 0; -const char *const VERSION_COMMENT = "p2"; +const int VERSION_PATCH = 1; +const char *const VERSION_COMMENT = ""; const char * -versionsuffix() +versionsuffix(void) { #ifdef USE_VERSION_SUFFIXES - return "-2.5.0p2"; + return "-2.5.1"; #else return ""; #endif } const char * -version() +version(void) { - return "2.5.0p2"; + return "2.5.1"; } diff --git a/common-src/versuff.c.in b/common-src/versuff.c.in index 572333d..7996a2f 100644 --- a/common-src/versuff.c.in +++ b/common-src/versuff.c.in @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: versuff.c.in,v 1.11 2003/05/20 17:33:53 martinea Exp $ + * $Id: versuff.c.in,v 1.12 2006/05/25 01:47:12 johnfranks Exp $ * * provide amanda version number and suffix appended to program names */ @@ -37,7 +37,7 @@ const int VERSION_PATCH = @VERSION_PATCH@; const char *const VERSION_COMMENT = @VERSION_COMMENT@; const char * -versionsuffix() +versionsuffix(void) { #ifdef USE_VERSION_SUFFIXES return "-@VERSION_SUFFIX@"; @@ -47,7 +47,7 @@ versionsuffix() } const char * -version() +version(void) { return "@VERSION_SUFFIX@"; } diff --git a/config/Makefile.in b/config/Makefile.in index 0ca145e..31f3577 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -58,11 +58,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -70,6 +73,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ diff --git a/config/config.h.in b/config/config.h.in index 490c6c9..7433932 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -24,6 +24,12 @@ /* Define as the user who owns installed binaries. */ #undef BINARY_OWNER +/* Define if BSDTCP transport should be enabled. */ +#undef BSDTCP_SECURITY + +/* Define if BSDUDP transport should be enabled. */ +#undef BSDUDP_SECURITY + /* Define to use BSD .rhosts/.amandahosts security. */ #undef BSD_SECURITY @@ -152,6 +158,24 @@ /* Define if atof is declared. */ #undef HAVE_ATOF_DECL +/* Define to 1 if you have the `atoi' function. */ +#undef HAVE_ATOI + +/* Define if atoi is declared. */ +#undef HAVE_ATOI_DECL + +/* Define to 1 if you have the `atol' function. */ +#undef HAVE_ATOL + +/* Define to 1 if you have the `atoll' function. */ +#undef HAVE_ATOLL + +/* Define if atoll is declared. */ +#undef HAVE_ATOLL_DECL + +/* Define if atol is declared. */ +#undef HAVE_ATOL_DECL + /* Define to 1 if you have the `basename' function. */ #undef HAVE_BASENAME @@ -403,6 +427,12 @@ /* Define to 1 if you have the `isascii' function. */ #undef HAVE_ISASCII +/* Define to 1 if you have the `isnormal' function. */ +#undef HAVE_ISNORMAL + +/* Define if isnormal is declared. */ +#undef HAVE_ISNORMAL_DECL + /* Define to 1 if you have the `c' library (-lc). */ #undef HAVE_LIBC @@ -424,12 +454,21 @@ /* Define to 1 if you have the `dbm' library (-ldbm). */ #undef HAVE_LIBDBM +/* Define to 1 if you have the `dbmalloc' library (-ldbmalloc). */ +#undef HAVE_LIBDBMALLOC + /* Define to 1 if you have the `gdbm' library (-lgdbm). */ #undef HAVE_LIBGDBM +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBGEN_H + /* Define to 1 if you have the `intl' library (-lintl). */ #undef HAVE_LIBINTL +/* Define to 1 if you have the `krb5support' library (-lkrb5support). */ +#undef HAVE_LIBKRB5SUPPORT + /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM @@ -442,6 +481,9 @@ /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL +/* Define to 1 if you have the `readline' library (-lreadline). */ +#undef HAVE_LIBREADLINE + /* Define to 1 if you have the `resolv' library (-lresolv). */ #undef HAVE_LIBRESOLV @@ -484,6 +526,9 @@ /* Define if malloc is declared. */ #undef HAVE_MALLOC_DECL +/* Define to 1 if you have the header file. */ +#undef HAVE_MATH_H + /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE @@ -775,6 +820,9 @@ /* Define to 1 if you have the `statvfs' function. */ #undef HAVE_STATVFS +/* Define to 1 if you have the header file. */ +#undef HAVE_STDARG_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H @@ -1002,6 +1050,9 @@ /* Define if writev is declared. */ #undef HAVE_WRITEV_DECL +/* xslt is available to generate man pages */ +#undef HAVE_XSLTPROC + /* Define if limits.h defines _POSIX2_RE_DUP_MAX. */ #undef HAVE__POSIX2_RE_DUP_MAX @@ -1026,6 +1077,11 @@ /* Format for a long long printf. */ #undef LL_FMT +/* A comma-separated list of two integers, determining the minimum and maximum + reserved TCP port numbers sockets should be bound to. (mainly for + amrecover) */ +#undef LOW_TCPPORTRANGE + /* Command for starting printing jobs. */ #undef LPRCMD @@ -1128,6 +1184,15 @@ /* The size of a `short', as computed by sizeof. */ #undef SIZEOF_SHORT +/* The size of a `size_t', as computed by sizeof. */ +#undef SIZEOF_SIZE_T + +/* The size of a `ssize_t', as computed by sizeof. */ +#undef SIZEOF_SSIZE_T + +/* The size of a `time_t', as computed by sizeof. */ +#undef SIZEOF_TIME_T + /* The size of a `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP @@ -1210,6 +1275,9 @@ /* Define to use Posix fcntl for file locking. */ #undef USE_POSIX_FCNTL +/* Define to set SO_REUSEADDR on network connections. */ +#undef USE_REUSEADDR + /* Define to invoke rundump (setuid-root) instead of DUMP program directly. */ #undef USE_RUNDUMP @@ -1287,6 +1355,9 @@ /* Define to `int' if does not define. */ #undef pid_t +/* Define if sa_family_t is not a standard system type */ +#undef sa_family_t + /* Directory in which administrator binaries should be installed. */ #undef sbindir diff --git a/configure b/configure index 4b65cf8..a2cdb31 100755 --- a/configure +++ b/configure @@ -463,7 +463,7 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CONFIGURE_COMMAND INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar SNAPSHOT_STAMP VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_COMMENT VERSION_SUFFIX DUMPER_DIR CONFIG_DIR USE_VERSION_SUFFIXES CLIENT_SCRIPTS_OPT DEFAULT_SERVER CLIENT_LOGIN SETUID_GROUP BINARY_OWNER DEFAULT_CONFIG DEFAULT_TAPE_SERVER DEFAULT_TAPE_DEVICE DEFAULT_RAW_TAPE_DEVICE DEFAULT_CHANGER_DEVICE GNUTAR_LISTED_INCREMENTAL_DIRX GNUTAR_LISTED_INCREMENTAL_DIR MAXTAPEBLOCKSIZE AMANDA_TMPDIR AMANDA_DBGDIR AMANDA_DEBUG_DAYS SERVICE_SUFFIX CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE MT_FILE_FLAG CPP EGREP AR AWK_VAR_ASSIGNMENT_OPT YACC CAT COMPRESS DD GETCONF GNUPLOT GREP GNUTAR SAMBA_CLIENT GZIP MAILER MT CHIO CHS MTX MCUTIL PRINT PCAT PERL DUMP RESTORE XFSDUMP XFSRESTORE VXDUMP VXRESTORE VDUMP VRESTORE AMPLOT_COMPRESS AMPLOT_CAT_GZIP AMPLOT_CAT_COMPRESS AMPLOT_CAT_PACK LL_FMT LN_S ECHO ac_ct_AR RANLIB ac_ct_RANLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS LEX LEXLIB LEX_OUTPUT_ROOT READLINE_LIBS DB_EXT ALLOCA LIBOBJS ac_n ac_c WANT_CLIENT_TRUE WANT_CLIENT_FALSE WANT_SAMBA_TRUE WANT_SAMBA_FALSE WANT_RESTORE_TRUE WANT_RESTORE_FALSE WANT_SERVER_TRUE WANT_SERVER_FALSE WANT_RECOVER_TRUE WANT_RECOVER_FALSE WANT_TAPE_TRUE WANT_TAPE_FALSE WANT_AMPLOT_TRUE WANT_AMPLOT_FALSE WANT_CHG_SCSI_TRUE WANT_CHG_SCSI_FALSE WANT_CHIO_SCSI_TRUE WANT_CHIO_SCSI_FALSE WANT_RUNTIME_PSEUDO_RELOC_TRUE WANT_RUNTIME_PSEUDO_RELOC_FALSE WANT_SETUID_CLIENT_TRUE WANT_SETUID_CLIENT_FALSE WANT_SSH_SECURITY_TRUE WANT_SSH_SECURITY_FALSE LTLIBOBJS LTALLOCA DOC_BUILD_DATE XSLTPROC HAVE_XSLTPROC_TRUE HAVE_XSLTPROC_FALSE' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CONFIGURE_COMMAND INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar SNAPSHOT_STAMP VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_COMMENT VERSION_SUFFIX CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE GREP EGREP AMLINT AMLINTFLAGS DUMPER_DIR CONFIG_DIR USE_VERSION_SUFFIXES CLIENT_SCRIPTS_OPT DEFAULT_SERVER CLIENT_LOGIN SETUID_GROUP BINARY_OWNER DEFAULT_CONFIG DEFAULT_TAPE_SERVER DEFAULT_TAPE_DEVICE DEFAULT_RAW_TAPE_DEVICE DEFAULT_CHANGER_DEVICE GNUTAR_LISTED_INCREMENTAL_DIRX GNUTAR_LISTED_INCREMENTAL_DIR MAXTAPEBLOCKSIZE AMANDA_TMPDIR AMANDA_DBGDIR AMANDA_DEBUG_DAYS SERVICE_SUFFIX MT_FILE_FLAG CPP AR AWK_VAR_ASSIGNMENT_OPT YACC CAT COMPRESS DD GETCONF GNUPLOT GNUTAR SAMBA_CLIENT GZIP MAILER MT CHIO CHS MTX MCUTIL PRINT PCAT PERL DUMP RESTORE XFSDUMP XFSRESTORE VXDUMP VXRESTORE VDUMP VRESTORE AMPLOT_COMPRESS AMPLOT_CAT_GZIP AMPLOT_CAT_COMPRESS AMPLOT_CAT_PACK LL_FMT LN_S ECHO ac_ct_AR RANLIB ac_ct_RANLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS LEX LEXLIB LEX_OUTPUT_ROOT READLINE_LIBS DB_EXT ALLOCA LIBOBJS ac_n ac_c WANT_CLIENT_TRUE WANT_CLIENT_FALSE WANT_SAMBA_TRUE WANT_SAMBA_FALSE WANT_RESTORE_TRUE WANT_RESTORE_FALSE WANT_SERVER_TRUE WANT_SERVER_FALSE WANT_RECOVER_TRUE WANT_RECOVER_FALSE WANT_TAPE_TRUE WANT_TAPE_FALSE WANT_AMPLOT_TRUE WANT_AMPLOT_FALSE WANT_CHG_SCSI_TRUE WANT_CHG_SCSI_FALSE WANT_CHIO_SCSI_TRUE WANT_CHIO_SCSI_FALSE WANT_RUNTIME_PSEUDO_RELOC_TRUE WANT_RUNTIME_PSEUDO_RELOC_FALSE WANT_SETUID_CLIENT_TRUE WANT_SETUID_CLIENT_FALSE WANT_SSH_SECURITY_TRUE WANT_SSH_SECURITY_FALSE LTLIBOBJS LTALLOCA DOC_BUILD_DATE BUILD_MAN_PAGES_TRUE BUILD_MAN_PAGES_FALSE XSLTPROC HAVE_XSLTPROC_TRUE HAVE_XSLTPROC_FALSE AM_CFLAGS' ac_subst_files='' # Initialize some variables set by options. @@ -1026,6 +1026,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors + --disable-largefile omit support for large files --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] @@ -1033,7 +1034,6 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) - --disable-largefile omit support for large files Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1068,6 +1068,7 @@ Optional Packages: --with-changer-device=ARG default tape changer device [/dev/ch0 if it exists] --with-fqdn use FQDN's to backup multiple networks --with-broken-fsf only enable if tape fsf calls fail mid-file + --without-reuseaddr Don't closed network connections to be reused until full timeout period. --with-gnutar[=PROG] use PROG as GNU tar executable [default: looks for one] --with-smbclient[=PROG] use PROG as Samba's smbclient executable [default: looks for one] --with-samba-user was deprecated @@ -1079,6 +1080,8 @@ Optional Packages: --with-krb4-security=DIR Location of Kerberos software [/usr/kerberos /usr/cygnus /usr /opt/kerberos] --with-rsh-security use rsh as a transport --with-ssh-security use ssh as a transport + --with-bsdtcp-security use tcp as a transport + --with-bsdudp-security use tcp as a transport --with-server-principal=ARG server host principal ["amanda"] --with-server-instance=ARG server host instance ["amanda"] --with-server-keyfile=ARG server host key file ["/.amanda"] @@ -1087,7 +1090,7 @@ Optional Packages: --with-client-keyfile=ARG client host key file [KEYFILE] --with-ticket-lifetime=ARG ticket lifetime [128] --with-krb5-security=DIR Location of Kerberos V software [/usr/kerberos /usr/cygnus /usr /opt/kerberos] - --with-portrange=low,high bind unreserved TCP server sockets to ports within this range [unlimited] + --with-low-tcpportrange=low,high bind reserved TCP server sockets to ports within this range unlimited (mainly for amrecover) --with-tcpportrange=low,high bind unreserved TCP server sockets to ports within this range [unlimited] --with-udpportrange=low,high bind reserved UDP server sockets to ports within this range [unlimited] --with-maxtapeblocksize=kb Maximum size of a tape block @@ -1962,7 +1965,7 @@ fi # Define the identity of the package. PACKAGE=amanda - VERSION=2.5.0p2 + VERSION=2.5.1 cat >>confdefs.h <<_ACEOF @@ -2127,7 +2130,7 @@ VERSION_SUFFIX="$VERSION" -SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd:/etc:/usr/etc" +SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/opt/SUNWspro/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc" LOCPATH=`( test "x$prefix" = xNONE && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix=${prefix} @@ -2137,14 +2140,15 @@ SYSLOCPATH="$SYSPATH:$LOCPATH" LOCSYSPATH="$LOCPATH:$SYSPATH" + # Check whether --with-cflags or --without-cflags was given. if test "${with_cflags+set}" = set; then withval="$with_cflags" case "$withval" in "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-includes option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-includes option." >&2;} + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-cflags option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-cflags option." >&2;} { (exit 1); exit 1; }; } ;; esac @@ -2152,2506 +2156,2695 @@ echo "$as_me: error: *** You must supply an argument to the --with-includes opti fi; +CFLAGS="-D_GNU_SOURCE $CFLAGS" -# Check whether --with-includes or --without-includes was given. -if test "${with_includes+set}" = set; then - withval="$with_includes" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-includes option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-includes option." >&2;} - { (exit 1); exit 1; }; } - ;; - esac - INCLUDE_DIRS="$withval" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -fi; +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -if test "$INCLUDE_DIRS"; then - for dir in $INCLUDE_DIRS; do - if test -d "$dir"; then - AMANDA_CPPFLAGS="$AMANDA_CPPFLAGS -I$dir" - else - { echo "$as_me:$LINENO: WARNING: *** Include directory $dir does not exist." >&5 -echo "$as_me: WARNING: *** Include directory $dir does not exist." >&2;} - fi - done fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -# Check whether --with-libraries or --without-libraries was given. -if test "${with_libraries+set}" = set; then - withval="$with_libraries" + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-libraries option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-libraries option." >&2;} - { (exit 1); exit 1; }; } - ;; - esac - LIBRARY_DIRS="$withval" +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -fi; +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -if test "$LIBRARY_DIRS"; then - for dir in $LIBRARY_DIRS; do - if test -d "$dir"; then - case "$target" in - *-solaris2*,*-netbsd*) - AMANDA_LDFLAGS="$AMANDA_LDFLAGS -R$dir" - ;; - esac - AMANDA_LDFLAGS="$AMANDA_LDFLAGS -L$dir" - else - { echo "$as_me:$LINENO: WARNING: *** Library directory $dir does not exist." >&5 -echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;} - fi - done fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -# Check whether --with-dumperdir or --without-dumperdir was given. -if test "${with_dumperdir+set}" = set; then - withval="$with_dumperdir" + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-dumperdir option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-dumperdir option." >&2;} - { (exit 1); exit 1; }; } - ;; - esac - DUMPER_DIR="$withval" +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi - test "x$prefix" = xNONE && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix=${prefix} - DUMPER_DIR=$exec_prefix/dumper +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -fi; -DUMPER_DIR=`( - test "x$prefix" = xNONE && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix=${prefix} - eval echo "$DUMPER_DIR" -)` + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -cat >>confdefs.h <<_ACEOF -#define DUMPER_DIR "$DUMPER_DIR" -_ACEOF +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + test -n "$ac_ct_CC" && break +done + CC=$ac_ct_CC +fi +fi -# Check whether --with-configdir or --without-configdir was given. -if test "${with_configdir+set}" = set; then - withval="$with_configdir" - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-configdir option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-configdir option." >&2;} +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } - ;; - *) CONFIG_DIR="$withval" - ;; - esac - -else - : ${CONFIG_DIR="$sysconfdir/amanda"} -fi; -CONFIG_DIR=`( - test "x$prefix" = xNONE && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix=${prefix} - eval echo "$CONFIG_DIR" -)` +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } -cat >>confdefs.h <<_ACEOF -#define CONFIG_DIR "$CONFIG_DIR" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -# Check whether --with-indexdir or --without-indexdir was given. -if test "${with_indexdir+set}" = set; then - withval="$with_indexdir" - { { echo "$as_me:$LINENO: error: *** --with-indexdir is deprecated, use indexdir in amanda.conf instead." >&5 -echo "$as_me: error: *** --with-indexdir is deprecated, use indexdir in amanda.conf instead." >&2;} - { (exit 1); exit 1; }; } - -fi; +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 -# Check whether --with-dbdir or --without-dbdir was given. -if test "${with_dbdir+set}" = set; then - withval="$with_dbdir" - { { echo "$as_me:$LINENO: error: *** --with-dbdir is deprecated, use infofile in amanda.conf instead." >&5 -echo "$as_me: error: *** --with-dbdir is deprecated, use infofile in amanda.conf instead." >&2;} +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 -fi; - +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 -# Check whether --with-logdir or --without-logdir was given. -if test "${with_logdir+set}" = set; then - withval="$with_logdir" - { { echo "$as_me:$LINENO: error: *** --with-logdir is deprecated, use logdir in amanda.conf instead." >&5 -echo "$as_me: error: *** --with-logdir is deprecated, use logdir in amanda.conf instead." >&2;} +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } +fi -fi; - +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 -# Check whether --with-suffixes or --without-suffixes was given. -if test "${with_suffixes+set}" = set; then - withval="$with_suffixes" - USE_VERSION_SUFFIXES=$withval +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - : ${USE_VERSION_SUFFIXES=no} - -fi; -case "$USE_VERSION_SUFFIXES" in -y | ye | yes) - -cat >>confdefs.h <<\_ACEOF -#define USE_VERSION_SUFFIXES 1 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ - program_suffix="-$VERSION" - # This is from the output of configure.in. - if test "x$program_transform_name" = xs,x,x,; then - program_transform_name= - else - # Double any \ or $. echo might interpret backslashes. - cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g -EOF_SED - program_transform_name="`echo $program_transform_name|sed -f conftestsed`" - rm -f conftestsed - fi - test "x$program_prefix" != xNONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" - # Use a double $ so make ignores it. - test "x$program_suffix" != xNONE && - program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - # sed with no file args requires a program. - test "x$program_transform_name" = "" && program_transform_name="xs,x,x," - # Remove empty command - cat <<\EOF_SED > conftestsed -s,\;\;,\;,g; s,\; \$,,g; s,\;$,,g -EOF_SED - program_transform_name="`echo $program_transform_name|sed -f conftestsed`" - rm -f conftestsed - ;; -n | no) USE_VERSION_SUFFIXES=no - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-suffixes option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-suffixes option." >&2;} +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } - ;; -esac - - -case "$target" in - *-hp-*) - CLIENT_SCRIPTS_OPT=amhpfixdevs - ;; - *-sni-sysv4) - CLIENT_SCRIPTS_OPT=amsinixfixdevs - ;; - *) - CLIENT_SCRIPTS_OPT= - ;; -esac - +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ +#ifndef __GNUC__ + choke me +#endif -# Check whether --with-client-only or --without-client-only was given. -if test "${with_client_only+set}" = set; then - withval="$with_client_only" - { { echo "$as_me:$LINENO: error: *** --with-client-only is deprecated, use --without-server instead." >&5 -echo "$as_me: error: *** --with-client-only is deprecated, use --without-server instead." >&2;} - { (exit 1); exit 1; }; } + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -fi; +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu -# Check whether --with-server-only or --without-server-only was given. -if test "${with_server_only+set}" = set; then - withval="$with_server_only" - { { echo "$as_me:$LINENO: error: *** --with-server-only is deprecated, use --without-client instead." >&5 -echo "$as_me: error: *** --with-server-only is deprecated, use --without-client instead." >&2;} - { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -fi; +int +main () +{ + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -# Check whether --with-client or --without-client was given. -if test "${with_client+set}" = set; then - withval="$with_client" +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} - case "$withval" in - y | ye | yes) NO_CLIENT_MODE=false;; - n | no) NO_CLIENT_MODE=true;; - *) - { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-client option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-client option." >&2;} - { (exit 1); exit 1; }; } - ;; - esac +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -fi; +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC +fi -# Check whether --with-server or --without-server was given. -if test "${with_server+set}" = set; then - withval="$with_server" +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac - case "$withval" in - y | ye | yes) NO_SERVER_MODE=false ;; - n | no) NO_SERVER_MODE=true;NO_RESTORE_MODE=true;; - *) - { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-server option. Maybe you meant --with-index-server=$withval" >&5 -echo "$as_me: error: *** You must not supply an argument to --with-server option. Maybe you meant --with-index-server=$withval" >&2;} - { (exit 1); exit 1; }; } - ;; - esac +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -fi; -if test "x${NO_SERVER_MODE+set}" != xset ; then - NO_SERVER_MODE=false +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -# Check whether --with-restore or --without-restore was given. -if test "${with_restore+set}" = set; then - withval="$with_restore" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" - case "$withval" in - y | ye | yes) NO_RESTORE_MODE=false;; - n | no) NO_RESTORE_MODE=true;; - *) - { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-restore option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-restore option." >&2;} - { (exit 1); exit 1; }; } - ;; - esac + ac_config_commands="$ac_config_commands depfiles" -fi; -if test "x${NO_RESTORE_MODE+set}" != xset ; then - NO_RESTORE_MODE=${NO_SERVER_MODE-false} +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU fi - -if ${NO_SERVER_MODE-false}; then - if ${NO_RESTORE_MODE-false}; then - true - else - { { echo "$as_me:$LINENO: error: *** --without-server requires --without-restore" >&5 -echo "$as_me: error: *** --without-server requires --without-restore" >&2;} - { (exit 1); exit 1; }; } +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD fi fi -# Check whether --with-amrecover or --without-amrecover was given. -if test "${with_amrecover+set}" = set; then - withval="$with_amrecover" - - case "$withval" in - y | ye | yes) - if ${NO_CLIENT_MODE-false}; then - { { echo "$as_me:$LINENO: error: *** --without-client and --with-amrecover are incompatible" >&5 -echo "$as_me: error: *** --without-client and --with-amrecover are incompatible" >&2;} - { (exit 1); exit 1; }; } - fi - NO_RECOVER_MODE=false;; - n | no) NO_RECOVER_MODE=true;; - *) - { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-amrecover option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-amrecover option." >&2;} - { (exit 1); exit 1; }; } - ;; - esac +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi -# Check whether --with-index-server or --without-index-server was given. -if test "${with_index_server+set}" = set; then - withval="$with_index_server" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-index-server option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-index-server option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) DEFAULT_SERVER="$withval" - ;; - esac - +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' else - : ${DEFAULT_SERVER=`uname -n`} + AMDEP_TRUE='#' + AMDEP_FALSE= +fi -fi; - -cat >>confdefs.h <<_ACEOF -#define DEFAULT_SERVER "$DEFAULT_SERVER" -_ACEOF +depcc="$CC" am_compiler_list= -# Check whether --with-force-uid or --without-force-uid was given. -if test "${with_force_uid+set}" = set; then - withval="$with_force_uid" - FORCE_USERID="$withval" +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - : ${FORCE_USERID=yes} - -fi; -case "$FORCE_USERID" in -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define FORCE_USERID 1 -_ACEOF - - ;; -n | no) : - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-force-uid option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-force-uid option." >&2;} - { (exit 1); exit 1; }; } -esac - - -# Check whether --with-user or --without-user was given. -if test "${with_user+set}" = set; then - withval="$with_user" + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-user option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-user option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) CLIENT_LOGIN="$withval" - ;; - esac + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done -fi; -if test "x${CLIENT_LOGIN+set}" != xset; then - { { echo "$as_me:$LINENO: error: *** --with-user=USER is missing" >&5 -echo "$as_me: error: *** --with-user=USER is missing" >&2;} - { (exit 1); exit 1; }; } + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none fi -cat >>confdefs.h <<_ACEOF -#define CLIENT_LOGIN "$CLIENT_LOGIN" -_ACEOF - - - - -# Check whether --with-group or --without-group was given. -if test "${with_group+set}" = set; then - withval="$with_group" +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-group option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-group option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) SETUID_GROUP="$withval" - ;; - esac -fi; -if test "x${SETUID_GROUP+set}" != xset; then - { { echo "$as_me:$LINENO: error: *** --with-group=GROUP is missing" >&5 -echo "$as_me: error: *** --with-group=GROUP is missing" >&2;} - { (exit 1); exit 1; }; } +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= fi -# Check whether --with-owner or --without-owner was given. -if test "${with_owner+set}" = set; then - withval="$with_owner" - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-owner option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-owner option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) BINARY_OWNER="$withval" - ;; - esac +# Check whether --enable-largefile or --disable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval="$enable_largefile" fi; -if test "x${BINARY_OWNER+set}" != xset ; then - BINARY_OWNER=$CLIENT_LOGIN -fi +if test "$enable_largefile" != no; then -cat >>confdefs.h <<_ACEOF -#define BINARY_OWNER "$BINARY_OWNER" + echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_largefile_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + ; + return 0; +} +_ACEOF + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +fi +rm -f conftest.err conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_largefile_CC=' -n32'; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +fi +rm -f conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi -# Check whether --with-rundump or --without-rundump was given. -if test "${with_rundump+set}" = set; then - withval="$with_rundump" - - case "$withval" in - n | no | y | ye | yes) FORCE_USE_RUNDUMP="$withval";; - *) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-rundump option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-rundump option." >&2;} - { (exit 1); exit 1; }; };; - esac - - -fi; - - -# Check whether --with-config or --without-config was given. -if test "${with_config+set}" = set; then - withval="$with_config" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-config option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-config option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) DEFAULT_CONFIG="$withval" - ;; - esac - + echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_file_offset_bits+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - : ${DEFAULT_CONFIG=DailySet1} - -fi; - -cat >>confdefs.h <<_ACEOF -#define DEFAULT_CONFIG "$DEFAULT_CONFIG" + while :; do + ac_cv_sys_file_offset_bits=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ - -# Check whether --with-tape-server or --without-tape-server was given. -if test "${with_tape_server+set}" = set; then - withval="$with_tape_server" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-tape-server option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-tape-server option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) DEFAULT_TAPE_SERVER="$withval" - ;; - esac - + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_file_offset_bits=64; break else - : ${DEFAULT_TAPE_SERVER=$DEFAULT_SERVER} + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -fi; +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 +if test "$ac_cv_sys_file_offset_bits" != no; then cat >>confdefs.h <<_ACEOF -#define DEFAULT_TAPE_SERVER "$DEFAULT_TAPE_SERVER" +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF - - - -# Check whether --with-tape-device or --without-tape-device was given. -if test "${with_tape_device+set}" = set; then - withval="$with_tape_device" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-tape-device option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-tape-device option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) DEFAULT_TAPE_DEVICE="$withval" - ;; - esac - +fi +rm -f conftest* + echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 +if test "${ac_cv_sys_large_files+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else + while :; do + ac_cv_sys_large_files=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ - if test -z "$DEFAULT_TAPE_DEVICE"; then - echo "$as_me:$LINENO: checking for non-rewinding tape device" >&5 -echo $ECHO_N "checking for non-rewinding tape device... $ECHO_C" >&6 - tape_dev=null: - nr_tape_dev=null: - if test -d /dev/rmt; then - - - for num in 9 8 7 6 5 4 3 2 1 0; do - td=/dev/rmt/${num}b - ntd=/dev/rmt/${num}bn - if test -r $td -a -r $ntd; then - tape_dev=$td - nr_tape_dev=$ntd - fi - done - else - for num in 9 8 7 6 5 4 3 2 1 0; do - td=/dev/rst${num} - ntd=/dev/nrst${num} - if test -r $td -a -r $ntd; then - tape_dev=$td - nr_tape_dev=$ntd - fi - done - fi - DEFAULT_TAPE_DEVICE=$nr_tape_dev - echo "$as_me:$LINENO: result: $DEFAULT_TAPE_DEVICE" >&5 -echo "${ECHO_T}$DEFAULT_TAPE_DEVICE" >&6 - fi + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ -fi; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_large_files=1; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -if test -z "$DEFAULT_TAPE_DEVICE"; then - DEFAULT_TAPE_DEVICE=/dev/null fi - +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + break +done +fi +echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +echo "${ECHO_T}$ac_cv_sys_large_files" >&6 +if test "$ac_cv_sys_large_files" != no; then cat >>confdefs.h <<_ACEOF -#define DEFAULT_TAPE_DEVICE "$DEFAULT_TAPE_DEVICE" +#define _LARGE_FILES $ac_cv_sys_large_files _ACEOF +fi +rm -f conftest* +fi - -# Check whether --with-ftape-raw-device or --without-ftape-raw-device was given. -if test "${with_ftape_raw_device+set}" = set; then - withval="$with_ftape_raw_device" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-ftape-rawdevice option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-ftape-rawdevice option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) DEFAULT_RAW_TAPE_DEVICE="$withval" - ;; - esac - +for ac_prog in grep +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else + case $GREP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GREP="$GREP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done - if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then - echo "$as_me:$LINENO: checking for raw ftape device" >&5 -echo $ECHO_N "checking for raw ftape device... $ECHO_C" >&6 - raw_tape_dev=/dev/null - for num in 3 2 1 0 ; do - td=/dev/rawft${num} - if test -r $td; then - raw_tape_dev=$td - fi - done - DEFAULT_RAW_TAPE_DEVICE=$raw_tape_dev - echo "$as_me:$LINENO: result: $DEFAULT_RAW_TAPE_DEVICE" >&5 -echo "${ECHO_T}$DEFAULT_RAW_TAPE_DEVICE" >&6 - fi + ;; +esac +fi +GREP=$ac_cv_path_GREP +if test -n "$GREP"; then + echo "$as_me:$LINENO: result: $GREP" >&5 +echo "${ECHO_T}$GREP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -fi; + test -n "$GREP" && break +done -if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then - DEFAULT_RAW_TAPE_DEVICE=/dev/null +if test -z "$GREP"; then + GREP=grep fi - cat >>confdefs.h <<_ACEOF -#define DEFAULT_RAW_TAPE_DEVICE "$DEFAULT_RAW_TAPE_DEVICE" +#define GREP "$GREP" _ACEOF - - - -# Check whether --with-rew-tape or --without-rew-tape was given. -if test "${with_rew_tape+set}" = set; then - withval="$with_rew_tape" - { { echo "$as_me:$LINENO: error: *** --with-rew-tape is deprecated, use --with-tape-device instead." >&5 -echo "$as_me: error: *** --with-rew-tape is deprecated, use --with-tape-device instead." >&2;} - { (exit 1); exit 1; }; } - -fi; - - -# Check whether --with-norew-tape or --without-norew-tape was given. -if test "${with_norew_tape+set}" = set; then - withval="$with_norew_tape" - { { echo "$as_me:$LINENO: error: *** --with-norew-tape is deprecated, use --with-tape-device instead." >&5 -echo "$as_me: error: *** --with-norew-tape is deprecated, use --with-tape-device instead." >&2;} - { (exit 1); exit 1; }; } - -fi; - - -# Check whether --with-changer-device or --without-changer-device was given. -if test "${with_changer_device+set}" = set; then - withval="$with_changer_device" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-changer-device option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-changer-device option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) DEFAULT_CHANGER_DEVICE="$withval" - ;; - esac - +for ac_prog in egrep +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else + case $EGREP in + [\\/]* | ?:[\\/]*) + ac_cv_path_EGREP="$EGREP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_EGREP="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done - if test -z "$DEFAULT_CHANGER_DEVICE" && - test -f /dev/ch0; then - DEFAULT_CHANGER_DEVICE=/dev/ch0 - fi - - -fi; - -if test -z "$DEFAULT_CHANGER_DEVICE"; then - DEFAULT_CHANGER_DEVICE=/dev/null + ;; +esac fi +EGREP=$ac_cv_path_EGREP +if test -n "$EGREP"; then + echo "$as_me:$LINENO: result: $EGREP" >&5 +echo "${ECHO_T}$EGREP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -cat >>confdefs.h <<_ACEOF -#define DEFAULT_CHANGER_DEVICE "$DEFAULT_CHANGER_DEVICE" -_ACEOF + test -n "$EGREP" && break +done +for ac_prog in lint +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AMLINT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AMLINT in + [\\/]* | ?:[\\/]*) + ac_cv_path_AMLINT="$AMLINT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="/opt/SUNWspro/bin:$SYSLOCPATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AMLINT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + ;; +esac +fi +AMLINT=$ac_cv_path_AMLINT -# Check whether --with-fqdn or --without-fqdn was given. -if test "${with_fqdn+set}" = set; then - withval="$with_fqdn" - USE_FQDN=$withval +if test -n "$AMLINT"; then + echo "$as_me:$LINENO: result: $AMLINT" >&5 +echo "${ECHO_T}$AMLINT" >&6 else - : ${USE_FQDN=no} - -fi; -case "$USE_FQDN" in -n | no) : ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define USE_FQDN 1 -_ACEOF + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + test -n "$AMLINT" && break +done + +if test ! -z "$AMLINT"; then + $AMLINT -flags | $GREP -- '-errfmt=' 2>&1 > /dev/null + if test $? -eq 0; then + AMLINTFLAGS="-n -s -u -m -x" + AMLINTFLAGS="$AMLINTFLAGS -errchk=%all" + AMLINTFLAGS="$AMLINTFLAGS -errfmt=macro" + AMLINTFLAGS="$AMLINTFLAGS -errhdr=no%/usr/include" + AMLINTFLAGS="$AMLINTFLAGS -errhdr=%user" + AMLINTFLAGS="$AMLINTFLAGS -errsecurity=extended" + AMLINTFLAGS="$AMLINTFLAGS -errtags=yes" + AMLINTFLAGS="$AMLINTFLAGS -Ncheck=%all" + AMLINTFLAGS="$AMLINTFLAGS -Nlevel=2" + AMLINTFLAGS="$AMLINTFLAGS -erroff=E_ASGN_NEVER_USED" + AMLINTFLAGS="$AMLINTFLAGS,E_ASGN_RESET" + AMLINTFLAGS="$AMLINTFLAGS,E_CAST_INT_CONST_TO_SMALL_INT" + AMLINTFLAGS="$AMLINTFLAGS,E_CAST_INT_TO_SMALL_INT" + AMLINTFLAGS="$AMLINTFLAGS,E_CAST_UINT_TO_SIGNED_INT" + AMLINTFLAGS="$AMLINTFLAGS,E_CONSTANT_CONDITION" + AMLINTFLAGS="$AMLINTFLAGS,E_ENUM_UNUSE" + AMLINTFLAGS="$AMLINTFLAGS,E_EXPR_NULL_EFFECT" + AMLINTFLAGS="$AMLINTFLAGS,E_FUNC_RET_ALWAYS_IGNOR" + AMLINTFLAGS="$AMLINTFLAGS,E_FUNC_RET_MAYBE_IGNORED" + AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK0" + AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK1" + AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK2" + AMLINTFLAGS="$AMLINTFLAGS,E_INCL_MNUSD" + AMLINTFLAGS="$AMLINTFLAGS,E_INCL_NUSD" + AMLINTFLAGS="$AMLINTFLAGS,E_MCR_NODIFF" + AMLINTFLAGS="$AMLINTFLAGS,E_NAME_MULTIPLY_DEF" + AMLINTFLAGS="$AMLINTFLAGS,E_P_REF_NULL_PSBL" + AMLINTFLAGS="$AMLINTFLAGS,E_P_REF_SUSP" + AMLINTFLAGS="$AMLINTFLAGS,E_PTRDIFF_OVERFLOW" + AMLINTFLAGS="$AMLINTFLAGS,E_P_USE_NULL_PSBL" + AMLINTFLAGS="$AMLINTFLAGS,E_P_USE_SUSP" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_ACCESS_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CHDIR_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CHMOD_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CREAT_WITHOUT_EXCL" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_EXEC_PATH" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_EXEC_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_FOPEN_MODE" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_GETENV_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_MKDIR_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_PRINTF_VAR_FMT" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_RAND_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SCANF_VAR_FMT" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SELECT_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SHELL_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_STRNCPY_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_UMASK_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_USE_AFTER_STAT" + AMLINTFLAGS="$AMLINTFLAGS,E_SIGN_EXTENSION_PSBL" + AMLINTFLAGS="$AMLINTFLAGS,E_TYPEDEF_UNUSE" + AMLINTFLAGS="$AMLINTFLAGS,E_UNCAL_F" + else + AMLINTFLAGS="" + fi +else + for ac_prog in splint +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AMLINT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AMLINT in + [\\/]* | ?:[\\/]*) + ac_cv_path_AMLINT="$AMLINT" # Let the user override the test with a path. ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-fqdn option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-fqdn option." >&2;} - { (exit 1); exit 1; }; } + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $SYSLOCPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AMLINT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + ;; esac +fi +AMLINT=$ac_cv_path_AMLINT - -# Check whether --with-broken-fsf or --without-broken-fsf was given. -if test "${with_broken_fsf+set}" = set; then - withval="$with_broken_fsf" - HAVE_BROKEN_FSF=$withval +if test -n "$AMLINT"; then + echo "$as_me:$LINENO: result: $AMLINT" >&5 +echo "${ECHO_T}$AMLINT" >&6 else - : ${HAVE_BROKEN_FSF=no} + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -fi; -case "$HAVE_BROKEN_FSF" in -n | no) : ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define HAVE_BROKEN_FSF 1 -_ACEOF + test -n "$AMLINT" && break +done - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-broken-fsf option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-broken-fsf option." >&2;} - { (exit 1); exit 1; }; } - ;; -esac + if test ! -z "$AMLINT"; then + AMLINT="splint" + fi + AMLINTFLAGS='+show-scan +unixlib -weak -globs +usedef +usereleased +impouts -paramimptemp -varuse -warnposix -redef -preproc -fixedformalarray -retval -unrecog -usevarargs -formatcode' +fi -# Check whether --with-gnutar or --without-gnutar was given. -if test "${with_gnutar+set}" = set; then - withval="$with_gnutar" + +# Check whether --with-includes or --without-includes was given. +if test "${with_includes+set}" = set; then + withval="$with_includes" case "$withval" in - /*) GNUTAR="$withval";; - y|ye|yes) :;; - n|no) GNUTAR=;; - *) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-gnutar" >&5 -echo "$as_me: error: *** You must supply a full pathname to --with-gnutar" >&2;} - { (exit 1); exit 1; }; };; + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-includes option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-includes option." >&2;} + { (exit 1); exit 1; }; } + ;; esac - + INCLUDE_DIRS="$withval" fi; +if test "$INCLUDE_DIRS"; then + for dir in $INCLUDE_DIRS; do + if test -d "$dir"; then + AMANDA_CPPFLAGS="$AMANDA_CPPFLAGS -I$dir" + else + { echo "$as_me:$LINENO: WARNING: *** Include directory $dir does not exist." >&5 +echo "$as_me: WARNING: *** Include directory $dir does not exist." >&2;} + fi + done +fi + -# Check whether --with-smbclient or --without-smbclient was given. -if test "${with_smbclient+set}" = set; then - withval="$with_smbclient" +# Check whether --with-libraries or --without-libraries was given. +if test "${with_libraries+set}" = set; then + withval="$with_libraries" case "$withval" in - /*) SAMBA_CLIENT="$withval";; - y|ye|yes) :;; - n|no) SAMBA_CLIENT=;; - *) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-smbclient" >&5 -echo "$as_me: error: *** You must supply a full pathname to --with-smbclient" >&2;} - { (exit 1); exit 1; }; };; + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-libraries option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-libraries option." >&2;} + { (exit 1); exit 1; }; } + ;; esac - + LIBRARY_DIRS="$withval" fi; +if test "$LIBRARY_DIRS"; then + for dir in $LIBRARY_DIRS; do + if test -d "$dir"; then + case "$target" in + *-solaris2*,*-netbsd*) + AMANDA_LDFLAGS="$AMANDA_LDFLAGS -R$dir" + ;; + esac + AMANDA_LDFLAGS="$AMANDA_LDFLAGS -L$dir" + else + { echo "$as_me:$LINENO: WARNING: *** Library directory $dir does not exist." >&5 +echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;} + fi + done +fi -# Check whether --with-samba-user or --without-samba-user was given. -if test "${with_samba_user+set}" = set; then - withval="$with_samba_user" - { { echo "$as_me:$LINENO: error: *** The samba-user option was deprecated, the username go in the amandapass" >&5 -echo "$as_me: error: *** The samba-user option was deprecated, the username go in the amandapass" >&2;} - { (exit 1); exit 1; }; } - - -fi; -# Check whether --with-gnutar-listdir or --without-gnutar-listdir was given. -if test "${with_gnutar_listdir+set}" = set; then - withval="$with_gnutar_listdir" +# Check whether --with-dumperdir or --without-dumperdir was given. +if test "${with_dumperdir+set}" = set; then + withval="$with_dumperdir" case "$withval" in - n | no) unset GNUTAR_LISTDIR ;; - y | ye | yes) : ${GNUTAR_LISTDIR=$localstatedir/amanda/gnutar-lists} ;; - /*) GNUTAR_LISTDIR="$withval" ;; - *) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-gnutar-listdir" >&5 -echo "$as_me: error: *** You must supply a full pathname to --with-gnutar-listdir" >&2;} + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-dumperdir option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-dumperdir option." >&2;} { (exit 1); exit 1; }; } + ;; esac + DUMPER_DIR="$withval" else - : ${GNUTAR_LISTDIR="$localstatedir/amanda/gnutar-lists"} -fi; -if test "$GNUTAR_LISTDIR"; then - GNUTAR_LISTDIR=`( test "x$prefix" = xNONE && prefix=$ac_default_prefix - eval echo "$GNUTAR_LISTDIR" - )` - -cat >>confdefs.h <<_ACEOF -#define GNUTAR_LISTED_INCREMENTAL_DIR "$GNUTAR_LISTDIR" -_ACEOF + test "x$exec_prefix" = xNONE && exec_prefix=${prefix} + DUMPER_DIR=$exec_prefix/dumper - GNUTAR_LISTED_INCREMENTAL_DIRX=$GNUTAR_LISTDIR -else - GNUTAR_LISTED_INCREMENTAL_DIRX= -fi +fi; +DUMPER_DIR=`( + test "x$prefix" = xNONE && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix=${prefix} + eval echo "$DUMPER_DIR" +)` +cat >>confdefs.h <<_ACEOF +#define DUMPER_DIR "$DUMPER_DIR" +_ACEOF -# Check whether --with-gnutar-listed-incremental or --without-gnutar-listed-incremental was given. -if test "${with_gnutar_listed_incremental+set}" = set; then - withval="$with_gnutar_listed_incremental" - { { echo "$as_me:$LINENO: error: *** The gnutar-listed-incremental option was deprecated, use gnutar-listdir instead" >&5 -echo "$as_me: error: *** The gnutar-listed-incremental option was deprecated, use gnutar-listdir instead" >&2;} - { (exit 1); exit 1; }; } -fi; -GNUTAR_LISTED_INCREMENTAL_DIR=$GNUTAR_LISTDIR +# Check whether --with-configdir or --without-configdir was given. +if test "${with_configdir+set}" = set; then + withval="$with_configdir" + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-configdir option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-configdir option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) CONFIG_DIR="$withval" + ;; + esac -# Check whether --with-bsd-security or --without-bsd-security was given. -if test "${with_bsd_security+set}" = set; then - withval="$with_bsd_security" - BSD_SECURITY=$withval else - : ${BSD_SECURITY=yes} + : ${CONFIG_DIR="$sysconfdir/amanda"} fi; -case "$BSD_SECURITY" in -n | no) : ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define BSD_SECURITY 1 -_ACEOF +CONFIG_DIR=`( + test "x$prefix" = xNONE && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix=${prefix} + eval echo "$CONFIG_DIR" +)` - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-bsd-security option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-bsd-security option." >&2;} - { (exit 1); exit 1; }; } - ;; -esac +cat >>confdefs.h <<_ACEOF +#define CONFIG_DIR "$CONFIG_DIR" +_ACEOF -# Check whether --with-amandahosts or --without-amandahosts was given. -if test "${with_amandahosts+set}" = set; then - withval="$with_amandahosts" - USE_AMANDAHOSTS=$withval -else - : ${USE_AMANDAHOSTS=yes} -fi; -case "$USE_AMANDAHOSTS" in -n | no) : ;; -y | ye | yes) : - case "$BSD_SECURITY" in - y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define USE_AMANDAHOSTS 1 -_ACEOF - ;; - esac - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-amandahosts option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-amandahosts option." >&2;} +# Check whether --with-indexdir or --without-indexdir was given. +if test "${with_indexdir+set}" = set; then + withval="$with_indexdir" + { { echo "$as_me:$LINENO: error: *** --with-indexdir is deprecated, use indexdir in amanda.conf instead." >&5 +echo "$as_me: error: *** --with-indexdir is deprecated, use indexdir in amanda.conf instead." >&2;} { (exit 1); exit 1; }; } - ;; -esac +fi; -# Check whether --with-dbmalloc or --without-dbmalloc was given. -if test "${with_dbmalloc+set}" = set; then - withval="$with_dbmalloc" - DBMALLOC="$withval" -else - : ${DBMALLOC=no} +# Check whether --with-dbdir or --without-dbdir was given. +if test "${with_dbdir+set}" = set; then + withval="$with_dbdir" + { { echo "$as_me:$LINENO: error: *** --with-dbdir is deprecated, use infofile in amanda.conf instead." >&5 +echo "$as_me: error: *** --with-dbdir is deprecated, use infofile in amanda.conf instead." >&2;} + { (exit 1); exit 1; }; } fi; -case "$DBMALLOC" in -n | no) - DBMALLOCCFLAGS="" - DBMALLOCLIBS="" - ;; -*) - DBMALLOCCFLAGS="-I$DBMALLOC -DUSE_DBMALLOC" - DBMALLOCLIBS="-L$DBMALLOC -ldbmalloc" - ;; -esac +# Check whether --with-logdir or --without-logdir was given. +if test "${with_logdir+set}" = set; then + withval="$with_logdir" + { { echo "$as_me:$LINENO: error: *** --with-logdir is deprecated, use logdir in amanda.conf instead." >&5 +echo "$as_me: error: *** --with-logdir is deprecated, use logdir in amanda.conf instead." >&2;} + { (exit 1); exit 1; }; } -: ${KRB4_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"} +fi; -# Check whether --with-krb4-security or --without-krb4-security was given. -if test "${with_krb4_security+set}" = set; then - withval="$with_krb4_security" - KRB4_SECURITY="$withval" +# Check whether --with-suffixes or --without-suffixes was given. +if test "${with_suffixes+set}" = set; then + withval="$with_suffixes" + USE_VERSION_SUFFIXES=$withval else - : ${KRB4_SECURITY=no} + : ${USE_VERSION_SUFFIXES=no} fi; - -case "$KRB4_SECURITY" in -n | no) KRB4_SECURITY=no ;; -y | ye | yes) : ;; -*) KRB4_SPOTS="$KRB4_SECURITY" - KRB4_SECURITY=yes - ;; -esac - -echo "$as_me:$LINENO: checking for Kerberos and Amanda kerberos4 bits" >&5 -echo $ECHO_N "checking for Kerberos and Amanda kerberos4 bits... $ECHO_C" >&6 -if test "x${KRB4_SECURITY}" = xyes -a -f ${srcdir-.}/common-src/krb4-security.c ; then - for dir in $KRB4_SPOTS; do - if test -f ${dir}/lib/libkrb.a -a -f ${dir}/lib/libdes.a ; then - # - # This is the original Kerberos 4. - # - echo "$as_me:$LINENO: result: found in $dir" >&5 -echo "${ECHO_T}found in $dir" >&6 - KRB4_SECURITY=yes - -cat >>confdefs.h <<\_ACEOF -#define KRB4_SECURITY 1 -_ACEOF - - if test -d $dir/include/kerberosIV ; then - # - # This handles BSD/OS. - # - KRB4INCLUDES=-I$dir/include/kerberosIV - else - KRB4INCLUDES=-I$dir/include - fi - KRB4LDFLAGS=-L$dir/lib - KRB4LIBS="-lkrb -ldes" - if test -f ${dir}/lib/libcom_err.a; then - KRB4LIBS="$KRB4LIBS -lcom_err" - fi - break - elif test -f ${dir}/lib/libkrb4.a && - test -f ${dir}/lib/libcrypto.a && - test -f ${dir}/lib/libdes425.a ; then - # - # This is Kerberos 5 with Kerberos 4 back-support. - # - echo "$as_me:$LINENO: result: found in $dir" >&5 -echo "${ECHO_T}found in $dir" >&6 - KRB4_SECURITY=yes +case "$USE_VERSION_SUFFIXES" in +y | ye | yes) cat >>confdefs.h <<\_ACEOF -#define KRB4_SECURITY 1 +#define USE_VERSION_SUFFIXES 1 _ACEOF - KRB4INCLUDES="-I$dir/include -I$dir/include/kerberosIV" - KRB4LDFLAGS=-L$dir/lib - if test -f ${dir}/lib/libkrb5.a && - test -f ${dir}/lib/libcom_err.a; then - KRB4LIBS="-lkrb4 -lkrb5 -lcrypto -ldes425 -lcom_err" - else - KRB4LIBS="-lkrb4 -lcrypto -ldes425" - fi - break - fi - done - if test "x$KRB4LDFLAGS" = "x" ; then - echo "$as_me:$LINENO: result: no libraries found" >&5 -echo "${ECHO_T}no libraries found" >&6 + program_suffix="-$VERSION" + # This is from the output of configure.in. + if test "x$program_transform_name" = xs,x,x,; then + program_transform_name= + else + # Double any \ or $. echo might interpret backslashes. + cat <<\EOF_SED > conftestsed +s,\\,\\\\,g; s,\$,$$,g +EOF_SED + program_transform_name="`echo $program_transform_name|sed -f conftestsed`" + rm -f conftestsed fi -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - -# Check whether --with-rsh-security or --without-rsh-security was given. -if test "${with_rsh_security+set}" = set; then - withval="$with_rsh_security" - RSH_SECURITY=$withval -else - : ${RSH_SECURITY=yes} - -fi; -case "$RSH_SECURITY" in -n | no) : ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define RSH_SECURITY 1 -_ACEOF + test "x$program_prefix" != xNONE && + program_transform_name="s,^,${program_prefix},; $program_transform_name" + # Use a double $ so make ignores it. + test "x$program_suffix" != xNONE && + program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" + # sed with no file args requires a program. + test "x$program_transform_name" = "" && program_transform_name="xs,x,x," + # Remove empty command + cat <<\EOF_SED > conftestsed +s,\;\;,\;,g; s,\; \$,,g; s,\;$,,g +EOF_SED + program_transform_name="`echo $program_transform_name|sed -f conftestsed`" + rm -f conftestsed ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument the to --with-rsh-security option." >&5 -echo "$as_me: error: *** You must not supply an argument the to --with-rsh-security option." >&2;} - { (exit 1); exit 1; }; } - ;; -esac - - -# Check whether --with-ssh-security or --without-ssh-security was given. -if test "${with_ssh_security+set}" = set; then - withval="$with_ssh_security" - SSH_SECURITY=$withval -else - : ${SSH_SECURITY=no} - -fi; -case "$SSH_SECURITY" in -n | no) : ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define SSH_SECURITY 1 -_ACEOF - - SSH_SECURITY_SET=true +n | no) USE_VERSION_SUFFIXES=no ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument the to --with-ssh-security option." >&5 -echo "$as_me: error: *** You must not supply an argument the to --with-ssh-security option." >&2;} +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-suffixes option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-suffixes option." >&2;} { (exit 1); exit 1; }; } ;; esac -# Check whether --with-server-principal or --without-server-principal was given. -if test "${with_server_principal+set}" = set; then - withval="$with_server_principal" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-server-principal option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-server-principal option." >&2;} - { (exit 1); exit 1; }; } - ;; - *) - SERVER_HOST_PRINCIPLE="$withval" - ;; - esac - -else - : ${SERVER_HOST_PRINCIPLE="amanda"} - -fi; - -cat >>confdefs.h <<_ACEOF -#define SERVER_HOST_PRINCIPLE "$SERVER_HOST_PRINCIPLE" -_ACEOF +case "$target" in + *-hp-*) + CLIENT_SCRIPTS_OPT=amhpfixdevs + ;; + *-sni-sysv4) + CLIENT_SCRIPTS_OPT=amsinixfixdevs + ;; + *) + CLIENT_SCRIPTS_OPT= + ;; +esac -# Check whether --with-server-instance or --without-server-instance was given. -if test "${with_server_instance+set}" = set; then - withval="$with_server_instance" - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-server-instance option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-server-instance option." >&2;} +# Check whether --with-client-only or --without-client-only was given. +if test "${with_client_only+set}" = set; then + withval="$with_client_only" + { { echo "$as_me:$LINENO: error: *** --with-client-only is deprecated, use --without-server instead." >&5 +echo "$as_me: error: *** --with-client-only is deprecated, use --without-server instead." >&2;} { (exit 1); exit 1; }; } - ;; - *) SERVER_HOST_INSTANCE="$withval" - ;; - esac - -else - : ${SERVER_HOST_INSTANCE="amanda"} fi; -cat >>confdefs.h <<_ACEOF -#define SERVER_HOST_INSTANCE "$SERVER_HOST_INSTANCE" -_ACEOF - - - -# Check whether --with-server-keyfile or --without-server-keyfile was given. -if test "${with_server_keyfile+set}" = set; then - withval="$with_server_keyfile" - - case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-server-keyfile option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-server-keyfile option." >&2;} +# Check whether --with-server-only or --without-server-only was given. +if test "${with_server_only+set}" = set; then + withval="$with_server_only" + { { echo "$as_me:$LINENO: error: *** --with-server-only is deprecated, use --without-client instead." >&5 +echo "$as_me: error: *** --with-server-only is deprecated, use --without-client instead." >&2;} { (exit 1); exit 1; }; } - ;; - *) SERVER_HOST_KEY_FILE="$withval" - ;; - esac - -else - : ${SERVER_HOST_KEY_FILE="/.amanda"} fi; -cat >>confdefs.h <<_ACEOF -#define SERVER_HOST_KEY_FILE "$SERVER_HOST_KEY_FILE" -_ACEOF - - -# Check whether --with-client-principal or --without-client-principal was given. -if test "${with_client_principal+set}" = set; then - withval="$with_client_principal" +# Check whether --with-client or --without-client was given. +if test "${with_client+set}" = set; then + withval="$with_client" case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-client-principal option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-client-principal option." >&2;} + y | ye | yes) NO_CLIENT_MODE=false;; + n | no) NO_CLIENT_MODE=true;; + *) + { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-client option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-client option." >&2;} { (exit 1); exit 1; }; } ;; - *) CLIENT_HOST_PRINCIPLE="$withval" - ;; esac -else - : ${CLIENT_HOST_PRINCIPLE="rcmd"} fi; -cat >>confdefs.h <<_ACEOF -#define CLIENT_HOST_PRINCIPLE "$CLIENT_HOST_PRINCIPLE" -_ACEOF - - -# Check whether --with-client-instance or --without-client-instance was given. -if test "${with_client_instance+set}" = set; then - withval="$with_client_instance" +# Check whether --with-server or --without-server was given. +if test "${with_server+set}" = set; then + withval="$with_server" case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-client-instance option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-client-instance option." >&2;} + y | ye | yes) NO_SERVER_MODE=false ;; + n | no) NO_SERVER_MODE=true;NO_RESTORE_MODE=true;; + *) + { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-server option. Maybe you meant --with-index-server=$withval" >&5 +echo "$as_me: error: *** You must not supply an argument to --with-server option. Maybe you meant --with-index-server=$withval" >&2;} { (exit 1); exit 1; }; } ;; - *) CLIENT_HOST_INSTANCE="$withval" - ;; esac -else - : ${CLIENT_HOST_INSTANCE=HOSTNAME_INSTANCE} fi; - -cat >>confdefs.h <<_ACEOF -#define CLIENT_HOST_INSTANCE $CLIENT_HOST_INSTANCE -_ACEOF - +if test "x${NO_SERVER_MODE+set}" != xset ; then + NO_SERVER_MODE=false +fi -# Check whether --with-client-keyfile or --without-client-keyfile was given. -if test "${with_client_keyfile+set}" = set; then - withval="$with_client_keyfile" +# Check whether --with-restore or --without-restore was given. +if test "${with_restore+set}" = set; then + withval="$with_restore" case "$withval" in - "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-client-keyfile option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-client-keyfile option." >&2;} + y | ye | yes) NO_RESTORE_MODE=false;; + n | no) NO_RESTORE_MODE=true;; + *) + { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-restore option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-restore option." >&2;} { (exit 1); exit 1; }; } ;; - *) CLIENT_HOST_KEY_FILE="$withval" - ;; esac -else - : ${CLIENT_HOST_KEY_FILE=KEYFILE} fi; +if test "x${NO_RESTORE_MODE+set}" != xset ; then + NO_RESTORE_MODE=${NO_SERVER_MODE-false} +fi -# Assume it's either KEYFILE (defined in krb.h), or a string filename... -if test "x$CLIENT_HOST_KEY_FILE" != "xKEYFILE"; then - CLIENT_HOST_KEY_FILE="\"$CLIENT_HOST_KEY_FILE\"" +if ${NO_SERVER_MODE-false}; then + if ${NO_RESTORE_MODE-false}; then + true + else + { { echo "$as_me:$LINENO: error: *** --without-server requires --without-restore" >&5 +echo "$as_me: error: *** --without-server requires --without-restore" >&2;} + { (exit 1); exit 1; }; } + fi fi -cat >>confdefs.h <<_ACEOF -#define CLIENT_HOST_KEY_FILE $CLIENT_HOST_KEY_FILE -_ACEOF +# Check whether --with-amrecover or --without-amrecover was given. +if test "${with_amrecover+set}" = set; then + withval="$with_amrecover" + case "$withval" in + y | ye | yes) + if ${NO_CLIENT_MODE-false}; then + { { echo "$as_me:$LINENO: error: *** --without-client and --with-amrecover are incompatible" >&5 +echo "$as_me: error: *** --without-client and --with-amrecover are incompatible" >&2;} + { (exit 1); exit 1; }; } + fi + NO_RECOVER_MODE=false;; + n | no) NO_RECOVER_MODE=true;; + *) + { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-amrecover option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-amrecover option." >&2;} + { (exit 1); exit 1; }; } + ;; + esac -# Check whether --with-ticket-lifetime or --without-ticket-lifetime was given. -if test "${with_ticket_lifetime+set}" = set; then - withval="$with_ticket_lifetime" +fi; + + +# Check whether --with-index-server or --without-index-server was given. +if test "${with_index_server+set}" = set; then + withval="$with_index_server" case "$withval" in "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-ticket-lifetime option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-ticket-lifetime option." >&2;} + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-index-server option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-index-server option." >&2;} { (exit 1); exit 1; }; } ;; - *) TICKET_LIFETIME="$withval" + *) DEFAULT_SERVER="$withval" ;; esac else - : ${TICKET_LIFETIME=128} + : ${DEFAULT_SERVER=`uname -n`} fi; cat >>confdefs.h <<_ACEOF -#define TICKET_LIFETIME $TICKET_LIFETIME +#define DEFAULT_SERVER "$DEFAULT_SERVER" _ACEOF -: ${KRB5_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"} - -# Check whether --with-krb5-security or --without-krb5-security was given. -if test "${with_krb5_security+set}" = set; then - withval="$with_krb5_security" - KRB5_SECURITY="$withval" +# Check whether --with-force-uid or --without-force-uid was given. +if test "${with_force_uid+set}" = set; then + withval="$with_force_uid" + FORCE_USERID="$withval" else - : ${KRB5_SECURITY=no} + : ${FORCE_USERID=yes} fi; +case "$FORCE_USERID" in +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define FORCE_USERID 1 +_ACEOF -case "$KRB5_SECURITY" in -n | no) KRB5_SECURITY=no - KRB5_SPOTS="" - ;; -y | ye | yes) : ;; -*) KRB5_SPOTS="$KRB5_SECURITY" - KRB5_SECURITY=yes - ;; + ;; +n | no) : + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-force-uid option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-force-uid option." >&2;} + { (exit 1); exit 1; }; } esac -# if found, force the static versions of these libs (.a) by linking directly -# with the .a files. I don't know how to get -R dependancies checked -# in autoconf at this time. -kashmir -echo "$as_me:$LINENO: checking for Kerberos V" >&5 -echo $ECHO_N "checking for Kerberos V... $ECHO_C" >&6 -KRB5_DIR_FOUND="" -KRB5_CFLAGS="" -for dir in $KRB5_SPOTS; do - k5libdir=${dir}/lib - if test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libgssapi_krb5.a -a -f ${k5libdir}/libcom_err.a; then - if test -f ${k5libdir}/libcrypto.a; then - K5CRYPTO=${k5libdir}/libcrypto.a - elif test -f ${k5libdir}/libk5crypto.a; then - K5CRYPTO=${k5libdir}/libk5crypto.a - else - K5CRYPTO="" - fi - KRB5_DIR_FOUND=$dir - KRB5LIBS="${k5libdir}/libgssapi_krb5.a ${k5libdir}/libkrb5.a $K5CRYPTO ${k5libdir}/libcom_err.a" - KRB5CFLAGS="" - break - elif test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libasn1.a -a -f ${k5libdir}/libgssapi.a; then - KRB5_DIR_FOUND=$dir - KRB5LIBS="${k5libdir}/libgssapi.a ${k5libdir}/libkrb5.a ${k5libdir}/libasn1.a" - KRB5_CFLAGS="-DKRB5_HEIMDAL_INCLUDES" - break - fi -done -if test "$KRB5_DIR_FOUND"; then - echo "$as_me:$LINENO: result: found in $KRB5_DIR_FOUND" >&5 -echo "${ECHO_T}found in $KRB5_DIR_FOUND" >&6 - KRB5_SECURITY=yes +# Check whether --with-user or --without-user was given. +if test "${with_user+set}" = set; then + withval="$with_user" -cat >>confdefs.h <<\_ACEOF -#define KRB5_SECURITY 1 -_ACEOF + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-user option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-user option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) CLIENT_LOGIN="$withval" + ;; + esac - # - # some OS's, such as NetBSD, stick krb5 includes out of the way... - # should probably just use autoconf to look for various include - # options and set them, but don't quite want to do that until I've - # dug into it a bit more. - # - if test -d "$KRB5_DIR_FOUND/krb5" ; then - KRB5INCLUDES="-I$KRB5_DIR_FOUND/include/krb5" - else - KRB5INCLUDES="-I$KRB5_DIR_FOUND/include" - fi - if test "$KRB5_CFLAGS" ; then - KRB5INCLUDES="$KRB5INCLUDES $KRB5_CFLAGS" - fi - KRB5LDFLAGS=-L$k5libdir - break -fi -if test "x$KRB5LDFLAGS" = "x" ; then - echo "$as_me:$LINENO: result: no krb5 system libraries found" >&5 -echo "${ECHO_T}no krb5 system libraries found" >&6 +fi; +if test "x${CLIENT_LOGIN+set}" != xset; then + { { echo "$as_me:$LINENO: error: *** --with-user=USER is missing" >&5 +echo "$as_me: error: *** --with-user=USER is missing" >&2;} + { (exit 1); exit 1; }; } fi +cat >>confdefs.h <<_ACEOF +#define CLIENT_LOGIN "$CLIENT_LOGIN" +_ACEOF -# Check whether --with-portrange or --without-portrange was given. -if test "${with_portrange+set}" = set; then - withval="$with_portrange" - - TCPPORTRANGE="$withval" - -fi; -# Check whether --with-tcpportrange or --without-tcpportrange was given. -if test "${with_tcpportrange+set}" = set; then - withval="$with_tcpportrange" +# Check whether --with-group or --without-group was given. +if test "${with_group+set}" = set; then + withval="$with_group" - TCPPORTRANGE="$withval" + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-group option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-group option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) SETUID_GROUP="$withval" + ;; + esac fi; -if test x"${TCPPORTRANGE+set}" = x"set"; then - if test x`echo "$TCPPORTRANGE" | sed 's/[0-9][0-9]*,[0-9][0-9]*//'` != x""; then - { { echo "$as_me:$LINENO: error: *** --with-tcpportrange requires two comma-separated positive numbers" >&5 -echo "$as_me: error: *** --with-tcpportrange requires two comma-separated positive numbers" >&2;} - { (exit 1); exit 1; }; } - fi - min_tcp_port=`echo "$TCPPORTRANGE" | sed 's/,.*//'` - max_tcp_port=`echo "$TCPPORTRANGE" | sed 's/.*,//'` - if test $min_tcp_port -gt $max_tcp_port; then - { { echo "$as_me:$LINENO: error: *** the second TCP port number must be greater than the first in --with-tcpportrange" >&5 -echo "$as_me: error: *** the second TCP port number must be greater than the first in --with-tcpportrange" >&2;} +if test "x${SETUID_GROUP+set}" != xset; then + { { echo "$as_me:$LINENO: error: *** --with-group=GROUP is missing" >&5 +echo "$as_me: error: *** --with-group=GROUP is missing" >&2;} { (exit 1); exit 1; }; } - fi - if test $min_tcp_port -lt 1024; then - { echo "$as_me:$LINENO: WARNING: *** the TCP port range should be 1024 or greater in --with-tcpportrange" >&5 -echo "$as_me: WARNING: *** the TCP port range should be 1024 or greater in --with-tcpportrange" >&2;} - fi - if test $max_tcp_port -ge 65536; then - { echo "$as_me:$LINENO: WARNING: *** the TCP port range should be less than 65536 in --with-tcpportrange" >&5 -echo "$as_me: WARNING: *** the TCP port range should be less than 65536 in --with-tcpportrange" >&2;} - fi - -cat >>confdefs.h <<_ACEOF -#define TCPPORTRANGE $TCPPORTRANGE -_ACEOF - fi -# Check whether --with-udpportrange or --without-udpportrange was given. -if test "${with_udpportrange+set}" = set; then - withval="$with_udpportrange" - - UDPPORTRANGE="$withval" +# Check whether --with-owner or --without-owner was given. +if test "${with_owner+set}" = set; then + withval="$with_owner" -fi; -if test x"${UDPPORTRANGE+set}" = x"set"; then - if test x`echo "$UDPPORTRANGE" | sed 's/[0-9][0-9]*,[0-9][0-9]*//'` != x""; then - { { echo "$as_me:$LINENO: error: *** --with-udpportrange requires two comma-separated positive numbers" >&5 -echo "$as_me: error: *** --with-udpportrange requires two comma-separated positive numbers" >&2;} - { (exit 1); exit 1; }; } - fi - min_udp_port=`echo "$UDPPORTRANGE" | sed 's/,.*//'` - max_udp_port=`echo "$UDPPORTRANGE" | sed 's/.*,//'` - if test $min_udp_port -gt $max_udp_port; then - { { echo "$as_me:$LINENO: error: *** the second UDP port number must be greater than the first in --with-udpportrange" >&5 -echo "$as_me: error: *** the second UDP port number must be greater than the first in --with-udpportrange" >&2;} + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-owner option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-owner option." >&2;} { (exit 1); exit 1; }; } - fi - if test $max_udp_port -ge 1024; then - { echo "$as_me:$LINENO: WARNING: *** the UDP port range should be less than 1024 in --with-udpportrange" >&5 -echo "$as_me: WARNING: *** the UDP port range should be less than 1024 in --with-udpportrange" >&2;} - fi - if test $min_udp_port -le 0; then - { echo "$as_me:$LINENO: WARNING: *** the UDP port range should be greater than 0 in --with-udpportrange" >&5 -echo "$as_me: WARNING: *** the UDP port range should be greater than 0 in --with-udpportrange" >&2;} - fi + ;; + *) BINARY_OWNER="$withval" + ;; + esac -cat >>confdefs.h <<_ACEOF -#define UDPPORTRANGE $UDPPORTRANGE -_ACEOF +fi; +if test "x${BINARY_OWNER+set}" != xset ; then + BINARY_OWNER=$CLIENT_LOGIN fi +cat >>confdefs.h <<_ACEOF +#define BINARY_OWNER "$BINARY_OWNER" +_ACEOF -# Check whether --with-maxtapeblocksize or --without-maxtapeblocksize was given. -if test "${with_maxtapeblocksize+set}" = set; then - withval="$with_maxtapeblocksize" - - MAXTAPEBLOCKSIZE="$withval" -else - : ${MAXTAPEBLOCKSIZE=32} -fi; +# Check whether --with-rundump or --without-rundump was given. +if test "${with_rundump+set}" = set; then + withval="$with_rundump" -cat >>confdefs.h <<_ACEOF -#define MAX_TAPE_BLOCK_KB ($MAXTAPEBLOCKSIZE) -_ACEOF + case "$withval" in + n | no | y | ye | yes) FORCE_USE_RUNDUMP="$withval";; + *) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-rundump option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-rundump option." >&2;} + { (exit 1); exit 1; }; };; + esac +fi; -# Check whether --with-db or --without-db was given. -if test "${with_db+set}" = set; then - withval="$with_db" +# Check whether --with-config or --without-config was given. +if test "${with_config+set}" = set; then + withval="$with_config" case "$withval" in "" | y | ye | yes | n | no) - { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-db option." >&5 -echo "$as_me: error: *** You must supply an argument to the --with-db option." >&2;} + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-config option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-config option." >&2;} { (exit 1); exit 1; }; } ;; - *) DB_STYLE="$withval" + *) DEFAULT_CONFIG="$withval" ;; esac - -fi; -if test "$DB_STYLE"; then - case "$DB_STYLE" in - db | dbm | gdbm | ndbm | text) ;; - *) - { { echo "$as_me:$LINENO: error: *** Unknown argument $DB_STYLE given to --with-db. Choose from db, dbm, gdbm, ndbm, text." >&5 -echo "$as_me: error: *** Unknown argument $DB_STYLE given to --with-db. Choose from db, dbm, gdbm, ndbm, text." >&2;} - { (exit 1); exit 1; }; } - DB_STYLE= - ;; - esac -fi - - -# Check whether --with-mmap or --without-mmap was given. -if test "${with_mmap+set}" = set; then - withval="$with_mmap" - FORCE_MMAP=$withval else - : ${FORCE_MMAP=no} + : ${DEFAULT_CONFIG=DailySet1} fi; -case "$FORCE_MMAP" in -y | ye | yes | n | no) : ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-mmap." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-mmap." >&2;} - { (exit 1); exit 1; }; } - ;; -esac - -# Check whether --with-buffered-dump or --without-buffered-dump was given. -if test "${with_buffered_dump+set}" = set; then - withval="$with_buffered_dump" - DUMPER_SOCKET_BUFFERING=$withval -else - : ${DUMPER_SOCKET_BUFFERING=no} - -fi; -case "$DUMPER_SOCKET_BUFFERING" in -n | no) : - ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define DUMPER_SOCKET_BUFFERING 1 +cat >>confdefs.h <<_ACEOF +#define DEFAULT_CONFIG "$DEFAULT_CONFIG" _ACEOF - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-buffered-dump." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-buffered-dump." >&2;} - { (exit 1); exit 1; }; } - ;; -esac -# Check whether --with-assertions or --without-assertions was given. -if test "${with_assertions+set}" = set; then - withval="$with_assertions" - ASSERTIONS="$withval" -else - : ${ASSERTIONS=no} -fi; -case "$ASSERTIONS" in -n | no) : ;; -y | ye | yes) -cat >>confdefs.h <<\_ACEOF -#define ASSERTIONS 1 -_ACEOF +# Check whether --with-tape-server or --without-tape-server was given. +if test "${with_tape_server+set}" = set; then + withval="$with_tape_server" - ;; -*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-assertions option." >&5 -echo "$as_me: error: *** You must not supply an argument to --with-assertions option." >&2;} + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-tape-server option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-tape-server option." >&2;} { (exit 1); exit 1; }; } - ;; -esac - + ;; + *) DEFAULT_TAPE_SERVER="$withval" + ;; + esac -# Check whether --with-tmpdir or --without-tmpdir was given. -if test "${with_tmpdir+set}" = set; then - withval="$with_tmpdir" - tmpdir="$withval" else - : ${tmpdir=yes} + : ${DEFAULT_TAPE_SERVER=$DEFAULT_SERVER} fi; -tmpdir=`( - test "x$prefix" = xNONE && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix=${prefix} - eval echo "$tmpdir" -)` -case "$tmpdir" in -n | no) { { echo "$as_me:$LINENO: error: *** --without-tmpdir is not allowed." >&5 -echo "$as_me: error: *** --without-tmpdir is not allowed." >&2;} - { (exit 1); exit 1; }; };; -y | ye | yes) - AMANDA_TMPDIR="/tmp/amanda";; -/*) - AMANDA_TMPDIR="$tmpdir";; -*) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-tmpdir option." >&5 -echo "$as_me: error: *** You must supply a full pathname to --with-tmpdir option." >&2;} - { (exit 1); exit 1; }; };; -esac cat >>confdefs.h <<_ACEOF -#define AMANDA_TMPDIR "$AMANDA_TMPDIR" +#define DEFAULT_TAPE_SERVER "$DEFAULT_TAPE_SERVER" _ACEOF -# Check whether --with-debugging or --without-debugging was given. -if test "${with_debugging+set}" = set; then - withval="$with_debugging" - debugging="$withval" -else - : ${debugging=yes} +# Check whether --with-tape-device or --without-tape-device was given. +if test "${with_tape_device+set}" = set; then + withval="$with_tape_device" -fi; -debugging=`( - test "x$prefix" = xNONE && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix=${prefix} - eval echo "$debugging" -)` -case "$debugging" in -n | no) AMANDA_DBGDIR="";; -y | ye | yes) AMANDA_DBGDIR="$AMANDA_TMPDIR";; -/*) AMANDA_DBGDIR="$debugging";; -*) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-debugging option." >&5 -echo "$as_me: error: *** You must supply a full pathname to --with-debugging option." >&2;} + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-tape-device option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-tape-device option." >&2;} { (exit 1); exit 1; }; } - ;; -esac -case "$AMANDA_DBGDIR" in -"") :;; -*) -cat >>confdefs.h <<\_ACEOF -#define DEBUG_CODE 1 -_ACEOF + ;; + *) DEFAULT_TAPE_DEVICE="$withval" + ;; + esac +else -cat >>confdefs.h <<_ACEOF -#define AMANDA_DBGDIR "$AMANDA_DBGDIR" -_ACEOF + if test -z "$DEFAULT_TAPE_DEVICE"; then + echo "$as_me:$LINENO: checking for non-rewinding tape device" >&5 +echo $ECHO_N "checking for non-rewinding tape device... $ECHO_C" >&6 + tape_dev= + nr_tape_dev= + if test -d /dev/rmt; then - ;; -esac + for num in 9 8 7 6 5 4 3 2 1 0; do + td=/dev/rmt/${num}b + ntd=/dev/rmt/${num}bn + if test -r $td -a -r $ntd; then + tape_dev=$td + nr_tape_dev=$ntd + fi + done + else + for num in 9 8 7 6 5 4 3 2 1 0; do + td=/dev/rst${num} + ntd=/dev/nrst${num} + if test -r $td -a -r $ntd; then + tape_dev=$td + nr_tape_dev=$ntd + fi + done + fi + DEFAULT_TAPE_DEVICE=$nr_tape_dev + echo "$as_me:$LINENO: result: $DEFAULT_TAPE_DEVICE" >&5 +echo "${ECHO_T}$DEFAULT_TAPE_DEVICE" >&6 + fi -# Check whether --with-debug_days or --without-debug_days was given. -if test "${with_debug_days+set}" = set; then - withval="$with_debug_days" - debug_days="$withval" -else - : ${debug_days=4} fi; -case "$debug_days" in -n | no) AMANDA_DEBUG_DAYS=0 ;; -y | ye | yes) AMANDA_DEBUG_DAYS=4 ;; -[0-9] | [0-9][0-9] | [0-9][0-9][0-9]) AMANDA_DEBUG_DAYS="$debug_days" ;; -*) { { echo "$as_me:$LINENO: error: *** --with-debug-days value not numeric or out of range." >&5 -echo "$as_me: error: *** --with-debug-days value not numeric or out of range." >&2;} - { (exit 1); exit 1; }; } - ;; -esac + +if test ! -z "$DEFAULT_TAPE_DEVICE"; then cat >>confdefs.h <<_ACEOF -#define AMANDA_DEBUG_DAYS $AMANDA_DEBUG_DAYS +#define DEFAULT_TAPE_DEVICE "$DEFAULT_TAPE_DEVICE" _ACEOF +fi -# Check whether --with-testing or --without-testing was given. -if test "${with_testing+set}" = set; then - withval="$with_testing" - TESTING="$withval" -else - : ${TESTING=no} +# Check whether --with-ftape-raw-device or --without-ftape-raw-device was given. +if test "${with_ftape_raw_device+set}" = set; then + withval="$with_ftape_raw_device" -fi; -case "$TESTING" in -n | no) SERVICE_SUFFIX="";; -y | ye | yes) SERVICE_SUFFIX="-test";; -*) SERVICE_SUFFIX="-$TESTING";; -esac -AMANDA_SERVICE_NAME="amanda$SERVICE_SUFFIX" -KAMANDA_SERVICE_NAME="kamanda$SERVICE_SUFFIX" + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-ftape-rawdevice option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-ftape-rawdevice option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) DEFAULT_RAW_TAPE_DEVICE="$withval" + ;; + esac +else -cat >>confdefs.h <<_ACEOF -#define SERVICE_SUFFIX "$SERVICE_SUFFIX" -_ACEOF + if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then + echo "$as_me:$LINENO: checking for raw ftape device" >&5 +echo $ECHO_N "checking for raw ftape device... $ECHO_C" >&6 + raw_tape_dev=/dev/null + for num in 3 2 1 0 ; do + td=/dev/rawft${num} + if test -r $td; then + raw_tape_dev=$td + fi + done + DEFAULT_RAW_TAPE_DEVICE=$raw_tape_dev + echo "$as_me:$LINENO: result: $DEFAULT_RAW_TAPE_DEVICE" >&5 +echo "${ECHO_T}$DEFAULT_RAW_TAPE_DEVICE" >&6 + fi -cat >>confdefs.h <<_ACEOF -#define AMANDA_SERVICE_NAME "$AMANDA_SERVICE_NAME" -_ACEOF +fi; + +if test -z "$DEFAULT_RAW_TAPE_DEVICE"; then + DEFAULT_RAW_TAPE_DEVICE=/dev/null +fi cat >>confdefs.h <<_ACEOF -#define KAMANDA_SERVICE_NAME "$KAMANDA_SERVICE_NAME" +#define DEFAULT_RAW_TAPE_DEVICE "$DEFAULT_RAW_TAPE_DEVICE" _ACEOF -( - test "x$prefix" = xNONE && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix=${prefix} - tmp=`eval echo "$bindir"` -cat >>confdefs.h <<_ACEOF -#define bindir "$tmp" -_ACEOF +# Check whether --with-rew-tape or --without-rew-tape was given. +if test "${with_rew_tape+set}" = set; then + withval="$with_rew_tape" + { { echo "$as_me:$LINENO: error: *** --with-rew-tape is deprecated, use --with-tape-device instead." >&5 +echo "$as_me: error: *** --with-rew-tape is deprecated, use --with-tape-device instead." >&2;} + { (exit 1); exit 1; }; } +fi; - tmp=`eval echo "$sbindir"` -cat >>confdefs.h <<_ACEOF -#define sbindir "$tmp" -_ACEOF +# Check whether --with-norew-tape or --without-norew-tape was given. +if test "${with_norew_tape+set}" = set; then + withval="$with_norew_tape" + { { echo "$as_me:$LINENO: error: *** --with-norew-tape is deprecated, use --with-tape-device instead." >&5 +echo "$as_me: error: *** --with-norew-tape is deprecated, use --with-tape-device instead." >&2;} + { (exit 1); exit 1; }; } +fi; - tmp=`eval echo "$libexecdir"` -cat >>confdefs.h <<_ACEOF -#define libexecdir "$tmp" -_ACEOF +# Check whether --with-changer-device or --without-changer-device was given. +if test "${with_changer_device+set}" = set; then + withval="$with_changer_device" + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-changer-device option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-changer-device option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) DEFAULT_CHANGER_DEVICE="$withval" + ;; + esac - tmp=`eval echo $mandir` +else -cat >>confdefs.h <<_ACEOF -#define mandir "$tmp" -_ACEOF + if test -z "$DEFAULT_CHANGER_DEVICE" && + test -f /dev/ch0; then + DEFAULT_CHANGER_DEVICE=/dev/ch0 + fi -) -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done +fi; -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +if test -z "$DEFAULT_CHANGER_DEVICE"; then + DEFAULT_CHANGER_DEVICE=/dev/null fi -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi +cat >>confdefs.h <<_ACEOF +#define DEFAULT_CHANGER_DEVICE "$DEFAULT_CHANGER_DEVICE" +_ACEOF - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +# Check whether --with-fqdn or --without-fqdn was given. +if test "${with_fqdn+set}" = set; then + withval="$with_fqdn" + USE_FQDN=$withval else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + : ${USE_FQDN=no} -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi +fi; +case "$USE_FQDN" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define USE_FQDN 1 +_ACEOF - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-fqdn option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-fqdn option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 +# Check whether --with-broken-fsf or --without-broken-fsf was given. +if test "${with_broken_fsf+set}" = set; then + withval="$with_broken_fsf" + HAVE_BROKEN_FSF=$withval else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi + : ${HAVE_BROKEN_FSF=no} -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done +fi; +case "$HAVE_BROKEN_FSF" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define HAVE_BROKEN_FSF 1 +_ACEOF -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-broken-fsf option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-broken-fsf option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 +# Check whether --with-reuseports or --without-reuseports was given. +if test "${with_reuseports+set}" = set; then + withval="$with_reuseports" + case "$withval" in + y | ye | yes) + REUSEADDR=no;; + n | no) + REUSEADDR=yes;; + *) + REUSEADDR=no;; + esac + else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi + REUSEADDR=yes; +fi; +case "$REUSEADDR" in +n | no) : + ;; +y | ye | yes) - test -n "$ac_ct_CC" && break -done +cat >>confdefs.h <<\_ACEOF +#define USE_REUSEADDR 1 +_ACEOF - CC=$ac_ct_CC -fi + ;; +*) + { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-reuseports option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-reuseports option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac -fi +# Check whether --with-gnutar or --without-gnutar was given. +if test "${with_gnutar+set}" = set; then + withval="$with_gnutar" -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } + case "$withval" in + /*) GNUTAR="$withval";; + y|ye|yes) :;; + n|no) GNUTAR=;; + *) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-gnutar" >&5 +echo "$as_me: error: *** You must supply a full pathname to --with-gnutar" >&2;} + { (exit 1); exit 1; }; };; + esac -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ +fi; -int -main () -{ - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. +# Check whether --with-smbclient or --without-smbclient was given. +if test "${with_smbclient+set}" = set; then + withval="$with_smbclient" -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; - * ) - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + case "$withval" in + /*) SAMBA_CLIENT="$withval";; + y|ye|yes) :;; + n|no) SAMBA_CLIENT=;; + *) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-smbclient" >&5 +echo "$as_me: error: *** You must supply a full pathname to --with-smbclient" >&2;} + { (exit 1); exit 1; }; };; + esac -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi -ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 +fi; -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} + +# Check whether --with-samba-user or --without-samba-user was given. +if test "${with_samba_user+set}" = set; then + withval="$with_samba_user" + { { echo "$as_me:$LINENO: error: *** The samba-user option was deprecated, the username go in the amandapass" >&5 +echo "$as_me: error: *** The samba-user option was deprecated, the username go in the amandapass" >&2;} { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi +fi; -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +# Check whether --with-gnutar-listdir or --without-gnutar-listdir was given. +if test "${with_gnutar_listdir+set}" = set; then + withval="$with_gnutar_listdir" + + case "$withval" in + n | no) unset GNUTAR_LISTDIR ;; + y | ye | yes) : ${GNUTAR_LISTDIR=$localstatedir/amanda/gnutar-lists} ;; + /*) GNUTAR_LISTDIR="$withval" ;; + *) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-gnutar-listdir" >&5 +echo "$as_me: error: *** You must supply a full pathname to --with-gnutar-listdir" >&2;} + { (exit 1); exit 1; }; } + esac + else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ + : ${GNUTAR_LISTDIR="$localstatedir/amanda/gnutar-lists"} -int -main () -{ +fi; +if test "$GNUTAR_LISTDIR"; then + GNUTAR_LISTDIR=`( + test "x$prefix" = xNONE && prefix=$ac_default_prefix + eval echo "$GNUTAR_LISTDIR" + )` - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define GNUTAR_LISTED_INCREMENTAL_DIR "$GNUTAR_LISTDIR" _ACEOF -rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done + + GNUTAR_LISTED_INCREMENTAL_DIRX=$GNUTAR_LISTDIR else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + GNUTAR_LISTED_INCREMENTAL_DIRX= +fi -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} + + +# Check whether --with-gnutar-listed-incremental or --without-gnutar-listed-incremental was given. +if test "${with_gnutar_listed_incremental+set}" = set; then + withval="$with_gnutar_listed_incremental" + { { echo "$as_me:$LINENO: error: *** The gnutar-listed-incremental option was deprecated, use gnutar-listdir instead" >&5 +echo "$as_me: error: *** The gnutar-listed-incremental option was deprecated, use gnutar-listdir instead" >&2;} { (exit 1); exit 1; }; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 -if test "${ac_cv_c_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -int -main () -{ -#ifndef __GNUC__ - choke me -#endif +fi; +GNUTAR_LISTED_INCREMENTAL_DIR=$GNUTAR_LISTDIR - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -ac_compiler_gnu=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu -fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 -GCC=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +# Check whether --with-bsd-security or --without-bsd-security was given. +if test "${with_bsd_security+set}" = set; then + withval="$with_bsd_security" + BSD_SECURITY=$withval else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ + : ${BSD_SECURITY=yes} + +fi; +case "$BSD_SECURITY" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define BSD_SECURITY 1 _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -int -main () -{ + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-bsd-security option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-bsd-security option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_prog_cc_g=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +# Check whether --with-amandahosts or --without-amandahosts was given. +if test "${with_amandahosts+set}" = set; then + withval="$with_amandahosts" + USE_AMANDAHOSTS=$withval else - ac_cv_prog_cc_stdc=no -ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ + : ${USE_AMANDAHOSTS=yes} + +fi; +case "$USE_AMANDAHOSTS" in +n | no) : ;; +y | ye | yes) : + case "$BSD_SECURITY" in + y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define USE_AMANDAHOSTS 1 _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + ;; + esac + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-amandahosts option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-amandahosts option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -fi -rm -f conftest.err conftest.$ac_objext -done -rm -f conftest.$ac_ext conftest.$ac_objext -CC=$ac_save_CC -fi +# Check whether --with-dbmalloc or --without-dbmalloc was given. +if test "${with_dbmalloc+set}" = set; then + withval="$with_dbmalloc" + DBMALLOC="$withval" +else + : ${DBMALLOC=no} -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; - *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; -esac +fi; + +case "$DBMALLOC" in +n | no) + DBMALLOCCFLAGS="" + DBMALLOCLIBS="" + ;; +*) -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. +echo "$as_me:$LINENO: checking for malloc in -ldbmalloc" >&5 +echo $ECHO_N "checking for malloc in -ldbmalloc... $ECHO_C" >&6 +if test "${ac_cv_lib_dbmalloc_malloc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldbmalloc $LIBS" cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_declaration -#include + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char malloc (); int main () { -exit (42); +malloc (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -4665,38 +4858,518 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - : + ac_cv_lib_dbmalloc_malloc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -continue +ac_cv_lib_dbmalloc_malloc=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dbmalloc_malloc" >&5 +echo "${ECHO_T}$ac_cv_lib_dbmalloc_malloc" >&6 +if test $ac_cv_lib_dbmalloc_malloc = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBDBMALLOC 1 +_ACEOF + + LIBS="-ldbmalloc $LIBS" + +fi + + if test "x$ac_cv_lib_dbmalloc_malloc" != "xyes"; then + { echo "$as_me:$LINENO: WARNING: *** dbmalloc library not found - no malloc debugging support!" >&5 +echo "$as_me: WARNING: *** dbmalloc library not found - no malloc debugging support!" >&2;} + DBMALLOCCFLAGS="" + DBMALLOCLIBS="" + else + DBMALLOCCFLAGS="-I$DBMALLOC -DUSE_DBMALLOC" + DBMALLOCLIBS="-L$DBMALLOC -ldbmalloc" + fi + ;; +esac + + +: ${KRB4_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"} + + +# Check whether --with-krb4-security or --without-krb4-security was given. +if test "${with_krb4_security+set}" = set; then + withval="$with_krb4_security" + KRB4_SECURITY="$withval" +else + : ${KRB4_SECURITY=no} + +fi; + +case "$KRB4_SECURITY" in +n | no) KRB4_SECURITY=no ;; +y | ye | yes) : ;; +*) KRB4_SPOTS="$KRB4_SECURITY" + KRB4_SECURITY=yes + ;; +esac + +echo "$as_me:$LINENO: checking for Kerberos and Amanda kerberos4 bits" >&5 +echo $ECHO_N "checking for Kerberos and Amanda kerberos4 bits... $ECHO_C" >&6 +if test "x${KRB4_SECURITY}" = xyes -a -f ${srcdir-.}/common-src/krb4-security.c ; then + for dir in $KRB4_SPOTS; do + if test -f ${dir}/lib/libkrb.a -a -f ${dir}/lib/libdes.a ; then + # + # This is the original Kerberos 4. + # + echo "$as_me:$LINENO: result: found in $dir" >&5 +echo "${ECHO_T}found in $dir" >&6 + KRB4_SECURITY=yes + +cat >>confdefs.h <<\_ACEOF +#define KRB4_SECURITY 1 +_ACEOF + + if test -d $dir/include/kerberosIV ; then + # + # This handles BSD/OS. + # + KRB4INCLUDES=-I$dir/include/kerberosIV + else + KRB4INCLUDES=-I$dir/include + fi + KRB4LDFLAGS=-L$dir/lib + KRB4LIBS="-lkrb -ldes" + if test -f ${dir}/lib/libcom_err.a; then + KRB4LIBS="$KRB4LIBS -lcom_err" + fi + break + elif test -f ${dir}/lib/libkrb4.a && + test -f ${dir}/lib/libcrypto.a && + test -f ${dir}/lib/libdes425.a ; then + # + # This is Kerberos 5 with Kerberos 4 back-support. + # + echo "$as_me:$LINENO: result: found in $dir" >&5 +echo "${ECHO_T}found in $dir" >&6 + KRB4_SECURITY=yes + +cat >>confdefs.h <<\_ACEOF +#define KRB4_SECURITY 1 +_ACEOF + + KRB4INCLUDES="-I$dir/include -I$dir/include/kerberosIV" + KRB4LDFLAGS=-L$dir/lib + if test -f ${dir}/lib/libkrb5.a && + test -f ${dir}/lib/libcom_err.a; then + KRB4LIBS="-lkrb4 -lkrb5 -lcrypto -ldes425 -lcom_err" + else + KRB4LIBS="-lkrb4 -lcrypto -ldes425" + fi + break + fi + done + + if test "x$KRB4LDFLAGS" = "x" ; then + echo "$as_me:$LINENO: result: no libraries found" >&5 +echo "${ECHO_T}no libraries found" >&6 + fi +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + +# Check whether --with-rsh-security or --without-rsh-security was given. +if test "${with_rsh_security+set}" = set; then + withval="$with_rsh_security" + RSH_SECURITY=$withval +else + : ${RSH_SECURITY=yes} + +fi; +case "$RSH_SECURITY" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define RSH_SECURITY 1 +_ACEOF + + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument the to --with-rsh-security option." >&5 +echo "$as_me: error: *** You must not supply an argument the to --with-rsh-security option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac + + +# Check whether --with-ssh-security or --without-ssh-security was given. +if test "${with_ssh_security+set}" = set; then + withval="$with_ssh_security" + SSH_SECURITY=$withval +else + : ${SSH_SECURITY=no} + +fi; +case "$SSH_SECURITY" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define SSH_SECURITY 1 +_ACEOF + + SSH_SECURITY_SET=true + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument the to --with-ssh-security option." >&5 +echo "$as_me: error: *** You must not supply an argument the to --with-ssh-security option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac + + +# Check whether --with-bsdtcp-security or --without-bsdtcp-security was given. +if test "${with_bsdtcp_security+set}" = set; then + withval="$with_bsdtcp_security" + BSDTCP_SECURITY=$withval +else + : ${BSDTCP_SECURITY=yes} + +fi; +case "$BSDTCP_SECURITY" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define BSDTCP_SECURITY 1 +_ACEOF + + BSDTCP_SECURITY_SET=true + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument the to --with-bsdtcp-security option." >&5 +echo "$as_me: error: *** You must not supply an argument the to --with-bsdtcp-security option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac + + +# Check whether --with-bsdudp-security or --without-bsdudp-security was given. +if test "${with_bsdudp_security+set}" = set; then + withval="$with_bsdudp_security" + BSDUDP_SECURITY=$withval +else + : ${BSDUDP_SECURITY=yes} + +fi; +case "$BSDUDP_SECURITY" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define BSDUDP_SECURITY 1 +_ACEOF + + BSDUDP_SECURITY_SET=true + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument the to --with-bsdudp-security option." >&5 +echo "$as_me: error: *** You must not supply an argument the to --with-bsdudp-security option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac + + +# Check whether --with-server-principal or --without-server-principal was given. +if test "${with_server_principal+set}" = set; then + withval="$with_server_principal" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-server-principal option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-server-principal option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) + SERVER_HOST_PRINCIPLE="$withval" + ;; + esac + +else + : ${SERVER_HOST_PRINCIPLE="amanda"} + +fi; + +cat >>confdefs.h <<_ACEOF +#define SERVER_HOST_PRINCIPLE "$SERVER_HOST_PRINCIPLE" +_ACEOF + + + +# Check whether --with-server-instance or --without-server-instance was given. +if test "${with_server_instance+set}" = set; then + withval="$with_server_instance" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-server-instance option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-server-instance option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) SERVER_HOST_INSTANCE="$withval" + ;; + esac + +else + : ${SERVER_HOST_INSTANCE="amanda"} + +fi; + +cat >>confdefs.h <<_ACEOF +#define SERVER_HOST_INSTANCE "$SERVER_HOST_INSTANCE" +_ACEOF + + + +# Check whether --with-server-keyfile or --without-server-keyfile was given. +if test "${with_server_keyfile+set}" = set; then + withval="$with_server_keyfile" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-server-keyfile option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-server-keyfile option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) SERVER_HOST_KEY_FILE="$withval" + ;; + esac + +else + : ${SERVER_HOST_KEY_FILE="/.amanda"} + +fi; + +cat >>confdefs.h <<_ACEOF +#define SERVER_HOST_KEY_FILE "$SERVER_HOST_KEY_FILE" +_ACEOF + + + +# Check whether --with-client-principal or --without-client-principal was given. +if test "${with_client_principal+set}" = set; then + withval="$with_client_principal" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-client-principal option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-client-principal option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) CLIENT_HOST_PRINCIPLE="$withval" + ;; + esac + +else + : ${CLIENT_HOST_PRINCIPLE="rcmd"} + +fi; + +cat >>confdefs.h <<_ACEOF +#define CLIENT_HOST_PRINCIPLE "$CLIENT_HOST_PRINCIPLE" +_ACEOF + + + +# Check whether --with-client-instance or --without-client-instance was given. +if test "${with_client_instance+set}" = set; then + withval="$with_client_instance" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-client-instance option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-client-instance option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) CLIENT_HOST_INSTANCE="$withval" + ;; + esac + +else + : ${CLIENT_HOST_INSTANCE=HOSTNAME_INSTANCE} + +fi; + +cat >>confdefs.h <<_ACEOF +#define CLIENT_HOST_INSTANCE $CLIENT_HOST_INSTANCE +_ACEOF + + + +# Check whether --with-client-keyfile or --without-client-keyfile was given. +if test "${with_client_keyfile+set}" = set; then + withval="$with_client_keyfile" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-client-keyfile option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-client-keyfile option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) CLIENT_HOST_KEY_FILE="$withval" + ;; + esac + +else + : ${CLIENT_HOST_KEY_FILE=KEYFILE} + +fi; + +# Assume it's either KEYFILE (defined in krb.h), or a string filename... +if test "x$CLIENT_HOST_KEY_FILE" != "xKEYFILE"; then + CLIENT_HOST_KEY_FILE="\"$CLIENT_HOST_KEY_FILE\"" +fi + + +cat >>confdefs.h <<_ACEOF +#define CLIENT_HOST_KEY_FILE $CLIENT_HOST_KEY_FILE +_ACEOF + + + +# Check whether --with-ticket-lifetime or --without-ticket-lifetime was given. +if test "${with_ticket_lifetime+set}" = set; then + withval="$with_ticket_lifetime" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-ticket-lifetime option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-ticket-lifetime option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) TICKET_LIFETIME="$withval" + ;; + esac + +else + : ${TICKET_LIFETIME=128} + +fi; + +cat >>confdefs.h <<_ACEOF +#define TICKET_LIFETIME $TICKET_LIFETIME +_ACEOF + + + +: ${KRB5_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"} + + +# Check whether --with-krb5-security or --without-krb5-security was given. +if test "${with_krb5_security+set}" = set; then + withval="$with_krb5_security" + KRB5_SECURITY="$withval" +else + : ${KRB5_SECURITY=no} + +fi; + +case "$KRB5_SECURITY" in +n | no) KRB5_SECURITY=no + KRB5_SPOTS="" + ;; +y | ye | yes) : ;; +*) KRB5_SPOTS="$KRB5_SECURITY" + KRB5_SECURITY=yes + ;; +esac + +# if found, force the static versions of these libs (.a) by linking directly +# with the .a files. I don't know how to get -R dependancies checked +# in autoconf at this time. -kashmir +echo "$as_me:$LINENO: checking for Kerberos V" >&5 +echo $ECHO_N "checking for Kerberos V... $ECHO_C" >&6 +KRB5_DIR_FOUND="" +KRB5_CFLAGS="" +for dir in $KRB5_SPOTS; do + for lib in lib lib64; do + k5libdir=${dir}/${lib} + if test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libgssapi_krb5.a -a -f ${k5libdir}/libcom_err.a; then + if test -f ${k5libdir}/libk5crypto.a; then + K5CRYPTO=${k5libdir}/libk5crypto.a + elif test -f ${k5libdir}/libcrypto.a; then + K5CRYPTO=${k5libdir}/libcrypto.a + else + K5CRYPTO="" + fi + if test -f ${k5libdir}/libkrb5support.a; then + K5SUPPORT=${k5libdir}/libkrb5support.a + else + K5SUPPORT="" + fi + KRB5_DIR_FOUND=$dir + KRB5LIBS="${k5libdir}/libgssapi_krb5.a ${k5libdir}/libkrb5.a $K5CRYPTO $K5SUPPORT ${k5libdir}/libcom_err.a" + KRB5CFLAGS="" + break + elif test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libasn1.a -a -f ${k5libdir}/libgssapi.a; then + KRB5_DIR_FOUND=$dir + KRB5LIBS="${k5libdir}/libgssapi.a ${k5libdir}/libkrb5.a ${k5libdir}/libasn1.a" + KRB5_CFLAGS="-DKRB5_HEIMDAL_INCLUDES" + break + fi + done +done + +if test "$KRB5_DIR_FOUND"; then + echo "$as_me:$LINENO: result: found in $KRB5_DIR_FOUND" >&5 +echo "${ECHO_T}found in $KRB5_DIR_FOUND" >&6 + KRB5_SECURITY=yes + +cat >>confdefs.h <<\_ACEOF +#define KRB5_SECURITY 1 +_ACEOF + + # + # some OS's, such as NetBSD, stick krb5 includes out of the way... + # should probably just use autoconf to look for various include + # options and set them, but don't quite want to do that until I've + # dug into it a bit more. + # + if test -d "$KRB5_DIR_FOUND/krb5" ; then + KRB5INCLUDES="-I$KRB5_DIR_FOUND/include/krb5" + else + KRB5INCLUDES="-I$KRB5_DIR_FOUND/include" + fi + if test "$KRB5_CFLAGS" ; then + KRB5INCLUDES="$KRB5INCLUDES $KRB5_CFLAGS" + fi + +echo "$as_me:$LINENO: checking for main in -lkrb5support" >&5 +echo $ECHO_N "checking for main in -lkrb5support... $ECHO_C" >&6 +if test "${ac_cv_lib_krb5support_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lkrb5support $LIBS" +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_declaration + + int main () { -exit (42); +main (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -4710,215 +5383,429 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - break + ac_cv_lib_krb5support_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_lib_krb5support_main=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi +echo "$as_me:$LINENO: result: $ac_cv_lib_krb5support_main" >&5 +echo "${ECHO_T}$ac_cv_lib_krb5support_main" >&6 +if test $ac_cv_lib_krb5support_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBKRB5SUPPORT 1 +_ACEOF -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + LIBS="-lkrb5support $LIBS" fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - ac_config_commands="$ac_config_commands depfiles" + KRB5LDFLAGS=-L$k5libdir + break +fi + +if test "x$KRB5LDFLAGS" = "x" ; then + echo "$as_me:$LINENO: result: no krb5 system libraries found" >&5 +echo "${ECHO_T}no krb5 system libraries found" >&6 +fi -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 -echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU + +# Check whether --with-low-tcpportrange or --without-low-tcpportrange was given. +if test "${with_low_tcpportrange+set}" = set; then + withval="$with_low_tcpportrange" + + LOW_TCPPORTRANGE="$withval" + + +fi; + +if test x"${LOW_TCPPORTRANGE+set}" = x"set"; then + if test x`echo "$LOW_TCPPORTRANGE" | sed 's/[0-9][0-9]*,[0-9][0-9]*//'` != x""; then + { { echo "$as_me:$LINENO: error: *** --with-low-tcpportrange requires two comma-separated positive numbers" >&5 +echo "$as_me: error: *** --with-low-tcpportrange requires two comma-separated positive numbers" >&2;} + { (exit 1); exit 1; }; } + fi + min_low_tcp_port=`echo "$LOW_TCPPORTRANGE" | sed 's/,.*//'` + max_low_tcp_port=`echo "$LOW_TCPPORTRANGE" | sed 's/.*,//'` + if test $min_low_tcp_port -gt $max_low_tcp_port; then + { { echo "$as_me:$LINENO: error: *** the second TCP port number must be greater than the first in --with-low-tcpportrange" >&5 +echo "$as_me: error: *** the second TCP port number must be greater than the first in --with-low-tcpportrange" >&2;} + { (exit 1); exit 1; }; } + fi + if test $min_low_tcp_port -lt 512; then + { echo "$as_me:$LINENO: WARNING: *** the low TCP port range should be 512 or greater in --with-low-tcpportrange" >&5 +echo "$as_me: WARNING: *** the low TCP port range should be 512 or greater in --with-low-tcpportrange" >&2;} + fi + if test $max_low_tcp_port -ge 1024; then + { echo "$as_me:$LINENO: WARNING: *** the low TCP port range should be less than 1024 in --with-low-tcpportrange" >&5 +echo "$as_me: WARNING: *** the low TCP port range should be less than 1024 in --with-low-tcpportrange" >&2;} + fi + +cat >>confdefs.h <<_ACEOF +#define LOW_TCPPORTRANGE $LOW_TCPPORTRANGE +_ACEOF + fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi + + +# Check whether --with-tcpportrange or --without-tcpportrange was given. +if test "${with_tcpportrange+set}" = set; then + withval="$with_tcpportrange" + + TCPPORTRANGE="$withval" + + +fi; +if test x"${TCPPORTRANGE+set}" = x"set"; then + if test x`echo "$TCPPORTRANGE" | sed 's/[0-9][0-9]*,[0-9][0-9]*//'` != x""; then + { { echo "$as_me:$LINENO: error: *** --with-tcpportrange requires two comma-separated positive numbers" >&5 +echo "$as_me: error: *** --with-tcpportrange requires two comma-separated positive numbers" >&2;} + { (exit 1); exit 1; }; } + fi + min_tcp_port=`echo "$TCPPORTRANGE" | sed 's/,.*//'` + max_tcp_port=`echo "$TCPPORTRANGE" | sed 's/.*,//'` + if test $min_tcp_port -gt $max_tcp_port; then + { { echo "$as_me:$LINENO: error: *** the second TCP port number must be greater than the first in --with-tcpportrange" >&5 +echo "$as_me: error: *** the second TCP port number must be greater than the first in --with-tcpportrange" >&2;} + { (exit 1); exit 1; }; } + fi + if test $min_tcp_port -lt 1024; then + { echo "$as_me:$LINENO: WARNING: *** the TCP port range should be 1024 or greater in --with-tcpportrange" >&5 +echo "$as_me: WARNING: *** the TCP port range should be 1024 or greater in --with-tcpportrange" >&2;} + fi + if test $max_tcp_port -ge 65536; then + { echo "$as_me:$LINENO: WARNING: *** the TCP port range should be less than 65536 in --with-tcpportrange" >&5 +echo "$as_me: WARNING: *** the TCP port range should be less than 65536 in --with-tcpportrange" >&2;} + fi + +cat >>confdefs.h <<_ACEOF +#define TCPPORTRANGE $TCPPORTRANGE +_ACEOF + fi -echo "$as_me:$LINENO: result: $_am_result" >&5 -echo "${ECHO_T}$_am_result" >&6 -rm -f confinc confmf +# Check whether --with-udpportrange or --without-udpportrange was given. +if test "${with_udpportrange+set}" = set; then + withval="$with_udpportrange" + + UDPPORTRANGE="$withval" -# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then - enableval="$enable_dependency_tracking" fi; -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' +if test x"${UDPPORTRANGE+set}" = x"set"; then + if test x`echo "$UDPPORTRANGE" | sed 's/[0-9][0-9]*,[0-9][0-9]*//'` != x""; then + { { echo "$as_me:$LINENO: error: *** --with-udpportrange requires two comma-separated positive numbers" >&5 +echo "$as_me: error: *** --with-udpportrange requires two comma-separated positive numbers" >&2;} + { (exit 1); exit 1; }; } + fi + min_udp_port=`echo "$UDPPORTRANGE" | sed 's/,.*//'` + max_udp_port=`echo "$UDPPORTRANGE" | sed 's/.*,//'` + if test $min_udp_port -gt $max_udp_port; then + { { echo "$as_me:$LINENO: error: *** the second UDP port number must be greater than the first in --with-udpportrange" >&5 +echo "$as_me: error: *** the second UDP port number must be greater than the first in --with-udpportrange" >&2;} + { (exit 1); exit 1; }; } + fi + if test $max_udp_port -ge 1024; then + { echo "$as_me:$LINENO: WARNING: *** the UDP port range should be less than 1024 in --with-udpportrange" >&5 +echo "$as_me: WARNING: *** the UDP port range should be less than 1024 in --with-udpportrange" >&2;} + fi + if test $min_udp_port -le 0; then + { echo "$as_me:$LINENO: WARNING: *** the UDP port range should be greater than 0 in --with-udpportrange" >&5 +echo "$as_me: WARNING: *** the UDP port range should be greater than 0 in --with-udpportrange" >&2;} + fi + +cat >>confdefs.h <<_ACEOF +#define UDPPORTRANGE $UDPPORTRANGE +_ACEOF + fi -if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' +# Check whether --with-maxtapeblocksize or --without-maxtapeblocksize was given. +if test "${with_maxtapeblocksize+set}" = set; then + withval="$with_maxtapeblocksize" + + MAXTAPEBLOCKSIZE="$withval" + else - AMDEP_TRUE='#' - AMDEP_FALSE= + : ${MAXTAPEBLOCKSIZE=32} + +fi; + + +cat >>confdefs.h <<_ACEOF +#define MAX_TAPE_BLOCK_KB ($MAXTAPEBLOCKSIZE) +_ACEOF + + + + +# Check whether --with-db or --without-db was given. +if test "${with_db+set}" = set; then + withval="$with_db" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-db option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-db option." >&2;} + { (exit 1); exit 1; }; } + ;; + *) DB_STYLE="$withval" + ;; + esac + + +fi; +if test "$DB_STYLE"; then + case "$DB_STYLE" in + db | dbm | gdbm | ndbm | text) ;; + *) + { { echo "$as_me:$LINENO: error: *** Unknown argument $DB_STYLE given to --with-db. Choose from db, dbm, gdbm, ndbm, text." >&5 +echo "$as_me: error: *** Unknown argument $DB_STYLE given to --with-db. Choose from db, dbm, gdbm, ndbm, text." >&2;} + { (exit 1); exit 1; }; } + DB_STYLE= + ;; + esac fi +# Check whether --with-mmap or --without-mmap was given. +if test "${with_mmap+set}" = set; then + withval="$with_mmap" + FORCE_MMAP=$withval +else + : ${FORCE_MMAP=no} +fi; +case "$FORCE_MMAP" in +y | ye | yes | n | no) : ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-mmap." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-mmap." >&2;} + { (exit 1); exit 1; }; } + ;; +esac -depcc="$CC" am_compiler_list= -echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 -echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +# Check whether --with-buffered-dump or --without-buffered-dump was given. +if test "${with_buffered_dump+set}" = set; then + withval="$with_buffered_dump" + DUMPER_SOCKET_BUFFERING=$withval else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub + : ${DUMPER_SOCKET_BUFFERING=no} - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf +fi; +case "$DUMPER_SOCKET_BUFFERING" in +n | no) : + ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define DUMPER_SOCKET_BUFFERING 1 +_ACEOF - case $depmode in - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - none) break ;; - esac - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. - if depmode=$depmode \ - source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-buffered-dump." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-buffered-dump." >&2;} + { (exit 1); exit 1; }; } + ;; +esac - cd .. - rm -rf conftest.dir + +# Check whether --with-assertions or --without-assertions was given. +if test "${with_assertions+set}" = set; then + withval="$with_assertions" + ASSERTIONS="$withval" else - am_cv_CC_dependencies_compiler_type=none -fi + : ${ASSERTIONS=no} -fi -echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 -echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type +fi; +case "$ASSERTIONS" in +n | no) : ;; +y | ye | yes) +cat >>confdefs.h <<\_ACEOF +#define ASSERTIONS 1 +_ACEOF + ;; +*) { { echo "$as_me:$LINENO: error: *** You must not supply an argument to --with-assertions option." >&5 +echo "$as_me: error: *** You must not supply an argument to --with-assertions option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac -if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' +# Check whether --with-tmpdir or --without-tmpdir was given. +if test "${with_tmpdir+set}" = set; then + withval="$with_tmpdir" + tmpdir="$withval" else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi + : ${tmpdir=yes} + +fi; +tmpdir=`( + test "x$prefix" = xNONE && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix=${prefix} + eval echo "$tmpdir" +)` +case "$tmpdir" in +n | no) { { echo "$as_me:$LINENO: error: *** --without-tmpdir is not allowed." >&5 +echo "$as_me: error: *** --without-tmpdir is not allowed." >&2;} + { (exit 1); exit 1; }; };; +y | ye | yes) + AMANDA_TMPDIR="/tmp/amanda";; +/*) + AMANDA_TMPDIR="$tmpdir";; +*) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-tmpdir option." >&5 +echo "$as_me: error: *** You must supply a full pathname to --with-tmpdir option." >&2;} + { (exit 1); exit 1; }; };; +esac + +cat >>confdefs.h <<_ACEOF +#define AMANDA_TMPDIR "$AMANDA_TMPDIR" +_ACEOF + +# Check whether --with-debugging or --without-debugging was given. +if test "${with_debugging+set}" = set; then + withval="$with_debugging" + debugging="$withval" +else + : ${debugging=yes} + +fi; +debugging=`( + test "x$prefix" = xNONE && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix=${prefix} + eval echo "$debugging" +)` +case "$debugging" in +n | no) AMANDA_DBGDIR="";; +y | ye | yes) AMANDA_DBGDIR="$AMANDA_TMPDIR";; +/*) AMANDA_DBGDIR="$debugging";; +*) { { echo "$as_me:$LINENO: error: *** You must supply a full pathname to --with-debugging option." >&5 +echo "$as_me: error: *** You must supply a full pathname to --with-debugging option." >&2;} + { (exit 1); exit 1; }; } + ;; +esac +case "$AMANDA_DBGDIR" in +"") :;; +*) +cat >>confdefs.h <<\_ACEOF +#define DEBUG_CODE 1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define AMANDA_DBGDIR "$AMANDA_DBGDIR" +_ACEOF + + ;; +esac + + +# Check whether --with-debug_days or --without-debug_days was given. +if test "${with_debug_days+set}" = set; then + withval="$with_debug_days" + debug_days="$withval" +else + : ${debug_days=4} + +fi; +case "$debug_days" in +n | no) AMANDA_DEBUG_DAYS=0 ;; +y | ye | yes) AMANDA_DEBUG_DAYS=4 ;; +[0-9] | [0-9][0-9] | [0-9][0-9][0-9]) AMANDA_DEBUG_DAYS="$debug_days" ;; +*) { { echo "$as_me:$LINENO: error: *** --with-debug-days value not numeric or out of range." >&5 +echo "$as_me: error: *** --with-debug-days value not numeric or out of range." >&2;} + { (exit 1); exit 1; }; } + ;; +esac + +cat >>confdefs.h <<_ACEOF +#define AMANDA_DEBUG_DAYS $AMANDA_DEBUG_DAYS +_ACEOF + + + + +# Check whether --with-testing or --without-testing was given. +if test "${with_testing+set}" = set; then + withval="$with_testing" + TESTING="$withval" +else + : ${TESTING=no} + +fi; +case "$TESTING" in +n | no) SERVICE_SUFFIX="";; +y | ye | yes) SERVICE_SUFFIX="-test";; +*) SERVICE_SUFFIX="-$TESTING";; +esac +AMANDA_SERVICE_NAME="amanda$SERVICE_SUFFIX" +KAMANDA_SERVICE_NAME="kamanda$SERVICE_SUFFIX" + + +cat >>confdefs.h <<_ACEOF +#define SERVICE_SUFFIX "$SERVICE_SUFFIX" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define AMANDA_SERVICE_NAME "$AMANDA_SERVICE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define KAMANDA_SERVICE_NAME "$KAMANDA_SERVICE_NAME" +_ACEOF + + +( + test "x$prefix" = xNONE && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix=${prefix} + + tmp=`eval echo "$bindir"` + +cat >>confdefs.h <<_ACEOF +#define bindir "$tmp" +_ACEOF + + + tmp=`eval echo "$sbindir"` + +cat >>confdefs.h <<_ACEOF +#define sbindir "$tmp" +_ACEOF + + tmp=`eval echo "$libexecdir"` + +cat >>confdefs.h <<_ACEOF +#define libexecdir "$tmp" +_ACEOF + + + tmp=`eval echo $mandir` + +cat >>confdefs.h <<_ACEOF +#define mandir "$tmp" +_ACEOF + +) DUMP_PROGRAMS="ufsdump dump backup" GETCONF_LFS="LFS" @@ -4978,6 +5865,8 @@ _ACEOF ;; *-pc-linux-*) ;; + *-redhat-linux-*) + ;; x86_64-*-linux-*) ;; alpha*-*-linux-*) @@ -5112,7 +6001,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7974,19 +8862,323 @@ else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -cat >conftest.$ac_ext <<_ACEOF +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void*))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void*))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void*))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_voidp=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void*), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (void*), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (void*)); } +unsigned long ulongval () { return (long) (sizeof (void*)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (void*))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (void*)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (void*)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_voidp=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void*), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (void*), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_voidp=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_voidp" >&5 +echo "${ECHO_T}$ac_cv_sizeof_voidp" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOIDP $ac_cv_sizeof_voidp +_ACEOF + + + ac_cv_char_data_model="" + ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char" + ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short" + ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int" + ac_cv_long_data_model="" + ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int" + ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long" + ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp" + echo "$as_me:$LINENO: checking data model" >&5 +echo $ECHO_N "checking data model... $ECHO_C" >&6 + case "$ac_cv_char_data_model/$ac_cv_long_data_model" in + 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;; + 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;; + 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;; + 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;; + 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;; + 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;; + 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;; + 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;; + 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;; + 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;; + 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;; + 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;; + 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;; + 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;; + 222/*|333/*|444/*|666/*|888/*) : + ac_cv_data_model="iDSP" ; n="unusual dsptype" ;; + *) ac_cv_data_model="none" ; n="very unusual model" ;; + esac + echo "$as_me:$LINENO: result: $ac_cv_data_model ($ac_cv_long_data_model, $n)" >&5 +echo "${ECHO_T}$ac_cv_data_model ($ac_cv_long_data_model, $n)" >&6 + +fi + +if test "_$ac_cv_header_stdint_x" != "_" ; then + ac_cv_header_stdint="$ac_cv_header_stdint_x" +elif test "_$ac_cv_header_stdint_o" != "_" ; then + ac_cv_header_stdint="$ac_cv_header_stdint_o" +elif test "_$ac_cv_header_stdint_u" != "_" ; then + ac_cv_header_stdint="$ac_cv_header_stdint_u" +else + ac_cv_header_stdint="stddef.h" +fi + +echo "$as_me:$LINENO: checking for extra inttypes in chosen header" >&5 +echo $ECHO_N "checking for extra inttypes in chosen header... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: ($ac_cv_header_stdint)" >&5 +echo "${ECHO_T}($ac_cv_header_stdint)" >&6 +unset ac_cv_type_int_least32_t +unset ac_cv_type_int_fast32_t +echo "$as_me:$LINENO: checking for int_least32_t" >&5 +echo $ECHO_N "checking for int_least32_t... $ECHO_C" >&6 +if test "${ac_cv_type_int_least32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +#include <$ac_cv_header_stdint> + int main () { -static int test_array [1 - 2 * !(((long) (sizeof (void*))) < 0)]; -test_array [0] = 0 - +if ((int_least32_t *) 0) + return 0; +if (sizeof (int_least32_t)) + return 0; ; return 0; } @@ -8013,21 +9205,38 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF + ac_cv_type_int_least32_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_int_least32_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_int_least32_t" >&5 +echo "${ECHO_T}$ac_cv_type_int_least32_t" >&6 + +echo "$as_me:$LINENO: checking for int_fast32_t" >&5 +echo $ECHO_N "checking for int_fast32_t... $ECHO_C" >&6 +if test "${ac_cv_type_int_fast32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +#include<$ac_cv_header_stdint> + int main () { -static int test_array [1 - 2 * !(((long) (sizeof (void*))) >= $ac_mid)]; -test_array [0] = 0 - +if ((int_fast32_t *) 0) + return 0; +if (sizeof (int_fast32_t)) + return 0; ; return 0; } @@ -8054,45 +9263,38 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_lo=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - done + ac_cv_type_int_fast32_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_lo= ac_hi= +ac_cv_type_int_fast32_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` +echo "$as_me:$LINENO: result: $ac_cv_type_int_fast32_t" >&5 +echo "${ECHO_T}$ac_cv_type_int_fast32_t" >&6 + +echo "$as_me:$LINENO: checking for intmax_t" >&5 +echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 +if test "${ac_cv_type_intmax_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +#include <$ac_cv_header_stdint> + int main () { -static int test_array [1 - 2 * !(((long) (sizeof (void*))) <= $ac_mid)]; -test_array [0] = 0 - +if ((intmax_t *) 0) + return 0; +if (sizeof (intmax_t)) + return 0; ; return 0; } @@ -8119,361 +9321,751 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=$ac_mid + ac_cv_type_intmax_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_intmax_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 +echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 + + +fi # shortcircut to system "stdint.h" +# ------------------ PREPARE VARIABLES ------------------------------ +if test "$GCC" = "yes" ; then +ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` +else +ac_cv_stdint_message="using $CC" +fi + +echo "$as_me:$LINENO: result: make use of $ac_cv_header_stdint in $ac_stdint_h $ac_cv_stdint_result" >&5 +echo "${ECHO_T}make use of $ac_cv_header_stdint in $ac_stdint_h $ac_cv_stdint_result" >&6 + +# ----------------- DONE inttypes.h checks START header ------------- + ac_config_commands="$ac_config_commands $ac_stdint_h" + + + +for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AR in + [\\/]* | ?:[\\/]*) + ac_cv_path_AR="$AR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +AR=$ac_cv_path_AR + +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AR" && break +done + + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + + + + echo "$as_me:$LINENO: checking for $AWK command line variable assignment" >&5 +echo $ECHO_N "checking for $AWK command line variable assignment... $ECHO_C" >&6 +if test "${amanda_cv_awk_var_assignment+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + echo 'BEGIN{print i; exit}' > conftest.awk + result=`$AWK -f conftest.awk i=xx | wc -c` + if test "$result" -le 1; then + result=`$AWK -f conftest.awk -v i=xx | wc -c` + if test "$result" -le 1; then + amanda_cv_awk_var_assignment=no + else + amanda_cv_awk_var_assignment="yes with -v" + fi + else + amanda_cv_awk_var_assignment="yes" + fi + rm -fr conftest.awk + + +fi +echo "$as_me:$LINENO: result: $amanda_cv_awk_var_assignment" >&5 +echo "${ECHO_T}$amanda_cv_awk_var_assignment" >&6 + AWK_VAR_ASSIGNMENT_OPT= + case "$amanda_cv_awk_var_assignment" in + no) + HAVE_AWK_WITH_VAR=no + ;; + yes) + HAVE_AWK_WITH_VAR=yes + ;; + "yes with -v") + HAVE_AWK_WITH_VAR=yes + AWK_VAR_ASSIGNMENT_OPT=-v + ;; + esac + + + +if test "x$amanda_cv_awk_var_assignment" = xno; then + NO_AMPLOT_MODE=true + { echo "$as_me:$LINENO: WARNING: *** Your $awk cannot do command line variable assignment. Amplot will not be installed." >&5 +echo "$as_me: WARNING: *** Your $awk cannot do command line variable assignment. Amplot will not be installed." >&2;} +fi + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_YACC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + echo "$as_me:$LINENO: result: $YACC" >&5 +echo "${ECHO_T}$YACC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +for ac_prog in cat +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_CAT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $CAT in + [\\/]* | ?:[\\/]*) + ac_cv_path_CAT="$CAT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CAT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +CAT=$ac_cv_path_CAT + +if test -n "$CAT"; then + echo "$as_me:$LINENO: result: $CAT" >&5 +echo "${ECHO_T}$CAT" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CAT" && break +done + +if test -z "$CAT"; then + CAT=cat +fi +for ac_prog in compress +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_COMPRESS+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $COMPRESS in + [\\/]* | ?:[\\/]*) + ac_cv_path_COMPRESS="$COMPRESS" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_COMPRESS="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +COMPRESS=$ac_cv_path_COMPRESS + +if test -n "$COMPRESS"; then + echo "$as_me:$LINENO: result: $COMPRESS" >&5 +echo "${ECHO_T}$COMPRESS" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$COMPRESS" && break +done + +for ac_prog in dd +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_DD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $DD in + [\\/]* | ?:[\\/]*) + ac_cv_path_DD="$DD" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_DD="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +DD=$ac_cv_path_DD + +if test -n "$DD"; then + echo "$as_me:$LINENO: result: $DD" >&5 +echo "${ECHO_T}$DD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$DD" && break +done + +for ac_prog in getconf +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GETCONF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GETCONF in + [\\/]* | ?:[\\/]*) + ac_cv_path_GETCONF="$GETCONF" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $SYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GETCONF="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +GETCONF=$ac_cv_path_GETCONF + +if test -n "$GETCONF"; then + echo "$as_me:$LINENO: result: $GETCONF" >&5 +echo "${ECHO_T}$GETCONF" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$GETCONF" && break +done + + +for ac_prog in gnuplot +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GNUPLOT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GNUPLOT in + [\\/]* | ?:[\\/]*) + ac_cv_path_GNUPLOT="$GNUPLOT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GNUPLOT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac +fi +GNUPLOT=$ac_cv_path_GNUPLOT + +if test -n "$GNUPLOT"; then + echo "$as_me:$LINENO: result: $GNUPLOT" >&5 +echo "${ECHO_T}$GNUPLOT" >&6 else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -ac_lo=`expr '(' $ac_mid ')' + 1` + test -n "$GNUPLOT" && break +done + +if test -z "$GNUPLOT"; then + NO_AMPLOT_MODE=true + { echo "$as_me:$LINENO: WARNING: *** You do not have gnuplot. Amplot will not be installed." >&5 +echo "$as_me: WARNING: *** You do not have gnuplot. Amplot will not be installed." >&2;} fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +for ac_prog in gtar gnutar tar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GNUTAR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GNUTAR in + [\\/]* | ?:[\\/]*) + ac_cv_path_GNUTAR="$GNUTAR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GNUTAR="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi done -case $ac_lo in -?*) ac_cv_sizeof_voidp=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void*), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (void*), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } ;; +done + + ;; esac +fi +GNUTAR=$ac_cv_path_GNUTAR + +if test -n "$GNUTAR"; then + echo "$as_me:$LINENO: result: $GNUTAR" >&5 +echo "${ECHO_T}$GNUTAR" >&6 else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -long longval () { return (long) (sizeof (void*)); } -unsigned long ulongval () { return (long) (sizeof (void*)); } -#include -#include -int -main () -{ + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (void*))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (void*)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (void*)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); + test -n "$GNUTAR" && break +done - ; - return 0; -} +if test ! -z "$GNUTAR"; then + case "`\"$GNUTAR\" --version 2>&1`" in + *GNU*tar* | *Free*paxutils* ) + +cat >>confdefs.h <<_ACEOF +#define GNUTAR "$GNUTAR" _ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_voidp=`cat conftest.val` -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void*), 77 -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (void*), 77 -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi + ;; + *) + { echo "$as_me:$LINENO: WARNING: *** $GNUTAR is not GNU tar, so it will not be used." >&5 +echo "$as_me: WARNING: *** $GNUTAR is not GNU tar, so it will not be used." >&2;} + GNUTAR= + ;; + esac fi -rm -f conftest.val + +for ac_prog in smbclient +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_SAMBA_CLIENT+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_sizeof_voidp=0 + case $SAMBA_CLIENT in + [\\/]* | ?:[\\/]*) + ac_cv_path_SAMBA_CLIENT="$SAMBA_CLIENT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_SAMBA_CLIENT="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac fi +SAMBA_CLIENT=$ac_cv_path_SAMBA_CLIENT + +if test -n "$SAMBA_CLIENT"; then + echo "$as_me:$LINENO: result: $SAMBA_CLIENT" >&5 +echo "${ECHO_T}$SAMBA_CLIENT" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_voidp" >&5 -echo "${ECHO_T}$ac_cv_sizeof_voidp" >&6 + + test -n "$SAMBA_CLIENT" && break +done + +if test ! -z "$SAMBA_CLIENT"; then + case "`\"$SAMBA_CLIENT\" '\\\\not.a.host.name\\notashare' -U nosuchuser -N -Tx /dev/null 2>&1`" in + *"Unknown host"*) + smbversion=1 + ;; + *"Connection to not.a.host.name failed"*) + smbversion=2 + ;; + *) + { echo "$as_me:$LINENO: WARNING: *** $SAMBA_CLIENT does not seem to be smbclient, so it will not be used." >&5 +echo "$as_me: WARNING: *** $SAMBA_CLIENT does not seem to be smbclient, so it will not be used." >&2;} + SAMBA_CLIENT= + ;; + esac + if test -n "$SAMBA_CLIENT"; then + cat >>confdefs.h <<_ACEOF -#define SIZEOF_VOIDP $ac_cv_sizeof_voidp +#define SAMBA_CLIENT "$SAMBA_CLIENT" _ACEOF - ac_cv_char_data_model="" - ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char" - ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short" - ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int" - ac_cv_long_data_model="" - ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int" - ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long" - ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp" - echo "$as_me:$LINENO: checking data model" >&5 -echo $ECHO_N "checking data model... $ECHO_C" >&6 - case "$ac_cv_char_data_model/$ac_cv_long_data_model" in - 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;; - 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;; - 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;; - 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;; - 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;; - 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;; - 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;; - 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;; - 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;; - 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;; - 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;; - 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;; - 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;; - 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;; - 222/*|333/*|444/*|666/*|888/*) : - ac_cv_data_model="iDSP" ; n="unusual dsptype" ;; - *) ac_cv_data_model="none" ; n="very unusual model" ;; - esac - echo "$as_me:$LINENO: result: $ac_cv_data_model ($ac_cv_long_data_model, $n)" >&5 -echo "${ECHO_T}$ac_cv_data_model ($ac_cv_long_data_model, $n)" >&6 +cat >>confdefs.h <<_ACEOF +#define SAMBA_VERSION $smbversion +_ACEOF + fi fi -if test "_$ac_cv_header_stdint_x" != "_" ; then - ac_cv_header_stdint="$ac_cv_header_stdint_x" -elif test "_$ac_cv_header_stdint_o" != "_" ; then - ac_cv_header_stdint="$ac_cv_header_stdint_o" -elif test "_$ac_cv_header_stdint_u" != "_" ; then - ac_cv_header_stdint="$ac_cv_header_stdint_u" +for ac_prog in gzip +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GZIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_header_stdint="stddef.h" + case $GZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac fi +GZIP=$ac_cv_path_GZIP -echo "$as_me:$LINENO: checking for extra inttypes in chosen header" >&5 -echo $ECHO_N "checking for extra inttypes in chosen header... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: ($ac_cv_header_stdint)" >&5 -echo "${ECHO_T}($ac_cv_header_stdint)" >&6 -unset ac_cv_type_int_least32_t -unset ac_cv_type_int_fast32_t -echo "$as_me:$LINENO: checking for int_least32_t" >&5 -echo $ECHO_N "checking for int_least32_t... $ECHO_C" >&6 -if test "${ac_cv_type_int_least32_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +if test -n "$GZIP"; then + echo "$as_me:$LINENO: result: $GZIP" >&5 +echo "${ECHO_T}$GZIP" >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_cv_header_stdint> + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -int -main () -{ -if ((int_least32_t *) 0) - return 0; -if (sizeof (int_least32_t)) - return 0; - ; - return 0; -} + test -n "$GZIP" && break +done + +if test "$GZIP"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_GZIP 1 _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_int_least32_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_int_least32_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + COMPRESS_PATH="$GZIP" + COMPRESS_SUFFIX=".gz" + COMPRESS_FAST_OPT="--fast" + COMPRESS_BEST_OPT="--best" + UNCOMPRESS_PATH="$GZIP" + UNCOMPRESS_OPT="-dc" +else + if test "$COMPRESS"; then + COMPRESS_PATH="$COMPRESS" + COMPRESS_SUFFIX=".Z" + COMPRESS_FAST_OPT="-f" + COMPRESS_BEST_OPT="-f" + UNCOMPRESS_PATH="$COMPRESS" + UNCOMPRESS_OPT="-dc" + else + { echo "$as_me:$LINENO: WARNING: *** Cannot find either gzip or compress. Using cat. ***" >&5 +echo "$as_me: WARNING: *** Cannot find either gzip or compress. Using cat. ***" >&2;} + COMPRESS_PATH="$CAT" + COMPRESS_SUFFIX="" + COMPRESS_FAST_OPT="" + COMPRESS_BEST_OPT="" + UNCOMPRESS_PATH="$CAT" + UNCOMPRESS_OPT="" + fi fi -echo "$as_me:$LINENO: result: $ac_cv_type_int_least32_t" >&5 -echo "${ECHO_T}$ac_cv_type_int_least32_t" >&6 -echo "$as_me:$LINENO: checking for int_fast32_t" >&5 -echo $ECHO_N "checking for int_fast32_t... $ECHO_C" >&6 -if test "${ac_cv_type_int_fast32_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ +cat >>confdefs.h <<_ACEOF +#define COMPRESS_PATH "$COMPRESS_PATH" _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include<$ac_cv_header_stdint> -int -main () -{ -if ((int_fast32_t *) 0) - return 0; -if (sizeof (int_fast32_t)) - return 0; - ; - return 0; -} + +cat >>confdefs.h <<_ACEOF +#define COMPRESS_SUFFIX "$COMPRESS_SUFFIX" _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_int_fast32_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_int_fast32_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_int_fast32_t" >&5 -echo "${ECHO_T}$ac_cv_type_int_fast32_t" >&6 -echo "$as_me:$LINENO: checking for intmax_t" >&5 -echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 -if test "${ac_cv_type_intmax_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ +cat >>confdefs.h <<_ACEOF +#define COMPRESS_FAST_OPT "$COMPRESS_FAST_OPT" _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_cv_header_stdint> -int -main () -{ -if ((intmax_t *) 0) - return 0; -if (sizeof (intmax_t)) - return 0; - ; - return 0; -} + +cat >>confdefs.h <<_ACEOF +#define COMPRESS_BEST_OPT "$COMPRESS_BEST_OPT" _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_intmax_t=yes + + +cat >>confdefs.h <<_ACEOF +#define UNCOMPRESS_PATH "$UNCOMPRESS_PATH" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define UNCOMPRESS_OPT "$UNCOMPRESS_OPT" +_ACEOF + + +for ac_prog in Mail mailx mail +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_MAILER+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + case $MAILER in + [\\/]* | ?:[\\/]*) + ac_cv_path_MAILER="$MAILER" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_MAILER="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -ac_cv_type_intmax_t=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + ;; +esac fi -echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 -echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 - +MAILER=$ac_cv_path_MAILER -fi # shortcircut to system "stdint.h" -# ------------------ PREPARE VARIABLES ------------------------------ -if test "$GCC" = "yes" ; then -ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` +if test -n "$MAILER"; then + echo "$as_me:$LINENO: result: $MAILER" >&5 +echo "${ECHO_T}$MAILER" >&6 else -ac_cv_stdint_message="using $CC" + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo "$as_me:$LINENO: result: make use of $ac_cv_header_stdint in $ac_stdint_h $ac_cv_stdint_result" >&5 -echo "${ECHO_T}make use of $ac_cv_header_stdint in $ac_stdint_h $ac_cv_stdint_result" >&6 + test -n "$MAILER" && break +done -# ----------------- DONE inttypes.h checks START header ------------- - ac_config_commands="$ac_config_commands $ac_stdint_h" +if test -z "$MAILER"; then + if $NO_SERVER_MODE; then + MAILER="NONE" + { echo "$as_me:$LINENO: WARNING: *** WARNING: Amanda cannot send mail reports without these programs." >&5 +echo "$as_me: WARNING: *** WARNING: Amanda cannot send mail reports without these programs." >&2;} + else + { { echo "$as_me:$LINENO: error: Set MAILER to some program that accepts -s subject user < message_file." >&5 +echo "$as_me: error: Set MAILER to some program that accepts -s subject user < message_file." >&2;} + { (exit 1); exit 1; }; } + fi +fi +cat >>confdefs.h <<_ACEOF +#define MAILER "$MAILER" +_ACEOF -for ac_prog in ar +for ac_prog in mt do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_AR+set}" = set; then +if test "${ac_cv_path_MT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $AR in + case $MT in [\\/]* | ?:[\\/]*) - ac_cv_path_AR="$AR" # Let the user override the test with a path. + ac_cv_path_MT="$MT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -8483,7 +10075,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_MT="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8493,171 +10085,227 @@ done ;; esac fi -AR=$ac_cv_path_AR +MT=$ac_cv_path_MT -if test -n "$AR"; then - echo "$as_me:$LINENO: result: $AR" >&5 -echo "${ECHO_T}$AR" >&6 +if test -n "$MT"; then + echo "$as_me:$LINENO: result: $MT" >&5 +echo "${ECHO_T}$MT" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$AR" && break + test -n "$MT" && break done +test -n "$MT" || MT="mt" -for ac_prog in gawk mawk nawk awk +for ac_prog in chio do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_AWK+set}" = set; then +if test "${ac_cv_path_CHIO+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH + case $CHIO in + [\\/]* | ?:[\\/]*) + ac_cv_path_CHIO="$CHIO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" + ac_cv_path_CHIO="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done + ;; +esac fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - echo "$as_me:$LINENO: result: $AWK" >&5 -echo "${ECHO_T}$AWK" >&6 +CHIO=$ac_cv_path_CHIO + +if test -n "$CHIO"; then + echo "$as_me:$LINENO: result: $CHIO" >&5 +echo "${ECHO_T}$CHIO" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$AWK" && break + test -n "$CHIO" && break done +test -n "$CHIO" || CHIO="chio" - - echo "$as_me:$LINENO: checking for $AWK command line variable assignment" >&5 -echo $ECHO_N "checking for $AWK command line variable assignment... $ECHO_C" >&6 -if test "${amanda_cv_awk_var_assignment+set}" = set; then +for ac_prog in chs +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_CHS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else + case $CHS in + [\\/]* | ?:[\\/]*) + ac_cv_path_CHS="$CHS" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CHS="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done - echo 'BEGIN{print i; exit}' > conftest.awk - result=`$AWK -f conftest.awk i=xx | wc -c` - if test "$result" -le 1; then - result=`$AWK -f conftest.awk -v i=xx | wc -c` - if test "$result" -le 1; then - amanda_cv_awk_var_assignment=no - else - amanda_cv_awk_var_assignment="yes with -v" - fi - else - amanda_cv_awk_var_assignment="yes" - fi - rm -fr conftest.awk - + ;; +esac +fi +CHS=$ac_cv_path_CHS +if test -n "$CHS"; then + echo "$as_me:$LINENO: result: $CHS" >&5 +echo "${ECHO_T}$CHS" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo "$as_me:$LINENO: result: $amanda_cv_awk_var_assignment" >&5 -echo "${ECHO_T}$amanda_cv_awk_var_assignment" >&6 - AWK_VAR_ASSIGNMENT_OPT= - case "$amanda_cv_awk_var_assignment" in - no) - HAVE_AWK_WITH_VAR=no - ;; - yes) - HAVE_AWK_WITH_VAR=yes - ;; - "yes with -v") - HAVE_AWK_WITH_VAR=yes - AWK_VAR_ASSIGNMENT_OPT=-v - ;; - esac + test -n "$CHS" && break +done +test -n "$CHS" || CHS="chs" -if test "x$amanda_cv_awk_var_assignment" = xno; then - NO_AMPLOT_MODE=true - { echo "$as_me:$LINENO: WARNING: *** Your $awk cannot do command line variable assignment. Amplot will not be installed." >&5 -echo "$as_me: WARNING: *** Your $awk cannot do command line variable assignment. Amplot will not be installed." >&2;} +for ac_prog in mtx +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_MTX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MTX in + [\\/]* | ?:[\\/]*) + ac_cv_path_MTX="$MTX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_MTX="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + ;; +esac fi +MTX=$ac_cv_path_MTX -for ac_prog in 'bison -y' byacc +if test -n "$MTX"; then + echo "$as_me:$LINENO: result: $MTX" >&5 +echo "${ECHO_T}$MTX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$MTX" && break +done +test -n "$MTX" || MTX="mtx" + + +for ac_prog in mcutil do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_YACC+set}" = set; then +if test "${ac_cv_path_MCUTIL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$YACC"; then - ac_cv_prog_YACC="$YACC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH + case $MCUTIL in + [\\/]* | ?:[\\/]*) + ac_cv_path_MCUTIL="$MCUTIL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $LOCSYSPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_YACC="$ac_prog" + ac_cv_path_MCUTIL="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done + ;; +esac fi -fi -YACC=$ac_cv_prog_YACC -if test -n "$YACC"; then - echo "$as_me:$LINENO: result: $YACC" >&5 -echo "${ECHO_T}$YACC" >&6 +MCUTIL=$ac_cv_path_MCUTIL + +if test -n "$MCUTIL"; then + echo "$as_me:$LINENO: result: $MCUTIL" >&5 +echo "${ECHO_T}$MCUTIL" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$YACC" && break + test -n "$MCUTIL" && break done -test -n "$YACC" || YACC="yacc" +test -n "$MCUTIL" || MCUTIL="mcutil" -for ac_prog in cat + +for ac_prog in lpr lp do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_CAT+set}" = set; then +if test "${ac_cv_path_PRINT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $CAT in + case $PRINT in [\\/]* | ?:[\\/]*) - ac_cv_path_CAT="$CAT" # Let the user override the test with a path. + ac_cv_path_PRINT="$PRINT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_CAT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_PRINT="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8667,34 +10315,64 @@ done ;; esac fi -CAT=$ac_cv_path_CAT +PRINT=$ac_cv_path_PRINT -if test -n "$CAT"; then - echo "$as_me:$LINENO: result: $CAT" >&5 -echo "${ECHO_T}$CAT" >&6 +if test -n "$PRINT"; then + echo "$as_me:$LINENO: result: $PRINT" >&5 +echo "${ECHO_T}$PRINT" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$CAT" && break + test -n "$PRINT" && break done -if test -z "$CAT"; then - CAT=cat +if test ! -z "$PRINT"; then + +cat >>confdefs.h <<_ACEOF +#define LPRCMD "$PRINT" +_ACEOF + + echo "$as_me:$LINENO: checking which flag to use to select a printer" >&5 +echo $ECHO_N "checking which flag to use to select a printer... $ECHO_C" >&6 +if test "${amanda_cv_printer_flag+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + amanda_cv_printer_flag=$PRINTER_FLAG + case "$PRINT" in + lpr|*/lpr) amanda_cv_printer_flag="-P";; + lp|*/lp) amanda_cv_printer_flag="-d";; + esac + fi -for ac_prog in compress +echo "$as_me:$LINENO: result: $amanda_cv_printer_flag" >&5 +echo "${ECHO_T}$amanda_cv_printer_flag" >&6 + if test ! -z "$amanda_cv_printer_flag"; then + +cat >>confdefs.h <<_ACEOF +#define LPRFLAG "$amanda_cv_printer_flag" +_ACEOF + + else + { echo "$as_me:$LINENO: WARNING: *** WARNING: amanda will always print to the default printer" >&5 +echo "$as_me: WARNING: *** WARNING: amanda will always print to the default printer" >&2;} + fi +fi + +for ac_prog in pcat do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_COMPRESS+set}" = set; then +if test "${ac_cv_path_PCAT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $COMPRESS in + case $PCAT in [\\/]* | ?:[\\/]*) - ac_cv_path_COMPRESS="$COMPRESS" # Let the user override the test with a path. + ac_cv_path_PCAT="$PCAT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -8704,7 +10382,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_COMPRESS="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_PCAT="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8714,31 +10392,31 @@ done ;; esac fi -COMPRESS=$ac_cv_path_COMPRESS +PCAT=$ac_cv_path_PCAT -if test -n "$COMPRESS"; then - echo "$as_me:$LINENO: result: $COMPRESS" >&5 -echo "${ECHO_T}$COMPRESS" >&6 +if test -n "$PCAT"; then + echo "$as_me:$LINENO: result: $PCAT" >&5 +echo "${ECHO_T}$PCAT" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$COMPRESS" && break + test -n "$PCAT" && break done -for ac_prog in dd +for ac_prog in perl5 perl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_DD+set}" = set; then +if test "${ac_cv_path_PERL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $DD in + case $PERL in [\\/]* | ?:[\\/]*) - ac_cv_path_DD="$DD" # Let the user override the test with a path. + ac_cv_path_PERL="$PERL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -8748,7 +10426,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_DD="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8758,41 +10436,43 @@ done ;; esac fi -DD=$ac_cv_path_DD +PERL=$ac_cv_path_PERL -if test -n "$DD"; then - echo "$as_me:$LINENO: result: $DD" >&5 -echo "${ECHO_T}$DD" >&6 +if test -n "$PERL"; then + echo "$as_me:$LINENO: result: $PERL" >&5 +echo "${ECHO_T}$PERL" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$DD" && break + test -n "$PERL" && break done -for ac_prog in egrep + + +for ac_prog in $DUMP_PROGRAMS do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_EGREP+set}" = set; then +if test "${ac_cv_path_DUMP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $EGREP in + case $DUMP in [\\/]* | ?:[\\/]*) - ac_cv_path_EGREP="$EGREP" # Let the user override the test with a path. + ac_cv_path_DUMP="$DUMP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $SYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_EGREP="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_DUMP="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8802,86 +10482,242 @@ done ;; esac fi -EGREP=$ac_cv_path_EGREP +DUMP=$ac_cv_path_DUMP -if test -n "$EGREP"; then - echo "$as_me:$LINENO: result: $EGREP" >&5 -echo "${ECHO_T}$EGREP" >&6 +if test -n "$DUMP"; then + echo "$as_me:$LINENO: result: $DUMP" >&5 +echo "${ECHO_T}$DUMP" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$EGREP" && break + test -n "$DUMP" && break done -for ac_prog in getconf +for ac_prog in ufsrestore restore do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_GETCONF+set}" = set; then +if test "${ac_cv_path_RESTORE+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $GETCONF in + case $RESTORE in [\\/]* | ?:[\\/]*) - ac_cv_path_GETCONF="$GETCONF" # Let the user override the test with a path. + ac_cv_path_RESTORE="$RESTORE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSPATH +for as_dir in $SYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GETCONF="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_RESTORE="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done - ;; -esac + ;; +esac +fi +RESTORE=$ac_cv_path_RESTORE + +if test -n "$RESTORE"; then + echo "$as_me:$LINENO: result: $RESTORE" >&5 +echo "${ECHO_T}$RESTORE" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$RESTORE" && break +done + +if test "$DUMP" -a "$RESTORE"; then + +cat >>confdefs.h <<_ACEOF +#define DUMP "$DUMP" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define RESTORE "$RESTORE" +_ACEOF + + if test -x $DUMP; then + echo "$as_me:$LINENO: checking whether $DUMP supports -E or -S for estimates" >&5 +echo $ECHO_N "checking whether $DUMP supports -E or -S for estimates... $ECHO_C" >&6 +if test "${amanda_cv_dump_estimate+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + case "$DUMP" in + *dump) + { ac_try='$DUMP 9Ef /dev/null /dev/null/invalid/fs 2>&1 + | $GREP -v Dumping + | $GREP -v Date + | $GREP -v Label >conftest.d-E 2>&1' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + cat conftest.d-E >&5 + { ac_try='$DUMP 9Sf /dev/null /dev/null/invalid/fs 2>&1 + | $GREP -v Dumping + | $GREP -v Date + | $GREP -v Label >conftest.d-S 2>&1' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + cat conftest.d-S >&5 + { ac_try='$DUMP 9f /dev/null /dev/null/invalid/fs 2>&1 + | $GREP -v Dumping + | $GREP -v Date + | $GREP -v Label >conftest.d 2>&1' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + cat conftest.d >&5 + if { ac_try='cmp conftest.d-E conftest.d 1>&2' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + amanda_cv_dump_estimate=E + elif { ac_try='cmp conftest.d-S conftest.d 1>&2' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + amanda_cv_dump_estimate=S + else + amanda_cv_dump_estimate=no + fi + rm -f conftest.d conftest.d-E conftest.d-S + ;; + *) amanda_cv_dump_estimate=no + ;; + esac + +fi +echo "$as_me:$LINENO: result: $amanda_cv_dump_estimate" >&5 +echo "${ECHO_T}$amanda_cv_dump_estimate" >&6 + else + { echo "$as_me:$LINENO: WARNING: *** $DUMP is not executable, cannot run -E/-S test" >&5 +echo "$as_me: WARNING: *** $DUMP is not executable, cannot run -E/-S test" >&2;} + amanda_cv_dump_estimate=no + fi + if test "x$amanda_cv_dump_estimate" != xno; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DUMP_ESTIMATE "$amanda_cv_dump_estimate" +_ACEOF + + fi + + +# Check whether --with-dump-honor-nodump or --without-dump-honor-nodump was given. +if test "${with_dump_honor_nodump+set}" = set; then + withval="$with_dump_honor_nodump" + if test -x $DUMP; then + echo "$as_me:$LINENO: checking whether $DUMP supports -h (honor nodump flag)" >&5 +echo $ECHO_N "checking whether $DUMP supports -h (honor nodump flag)... $ECHO_C" >&6 +if test "${amanda_cv_honor_nodump+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + case "$DUMP" in + *dump) + { ac_try='$DUMP 9hf 0 /dev/null /dev/null/invalid/fs 2>&1 + | $GREP -v Dumping + | $GREP -v Date + | $GREP -v Label >conftest.d-h 2>&1' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + cat conftest.d-h >&5 + { ac_try='$DUMP 9f /dev/null /dev/null/invalid/fs 2>&1 + | $GREP -v Dumping + | $GREP -v Date + | $GREP -v Label >conftest.d 2>&1' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + cat conftest.d >&5 + if { ac_try='diff conftest.d-h conftest.d 1>&2' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + amanda_cv_honor_nodump=yes + else + amanda_cv_honor_nodump=no + fi + rm -f conftest.d conftest.d-h + ;; + *) amanda_cv_honor_nodump=no + ;; + esac + fi -GETCONF=$ac_cv_path_GETCONF +echo "$as_me:$LINENO: result: $amanda_cv_honor_nodump" >&5 +echo "${ECHO_T}$amanda_cv_honor_nodump" >&6 + else + { echo "$as_me:$LINENO: WARNING: *** $DUMP is not executable, cannot run -h test" >&5 +echo "$as_me: WARNING: *** $DUMP is not executable, cannot run -h test" >&2;} + amanda_cv_honor_nodump=no + fi + if test "x$amanda_cv_honor_nodump" = xyes; then -if test -n "$GETCONF"; then - echo "$as_me:$LINENO: result: $GETCONF" >&5 -echo "${ECHO_T}$GETCONF" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi +cat >>confdefs.h <<\_ACEOF +#define HAVE_HONOR_NODUMP 1 +_ACEOF - test -n "$GETCONF" && break -done + fi +fi; +fi -for ac_prog in gnuplot +for ac_prog in xfsdump do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_GNUPLOT+set}" = set; then +if test "${ac_cv_path_XFSDUMP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $GNUPLOT in + case $XFSDUMP in [\\/]* | ?:[\\/]*) - ac_cv_path_GNUPLOT="$GNUPLOT" # Let the user override the test with a path. + ac_cv_path_XFSDUMP="$XFSDUMP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $SYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GNUPLOT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_XFSDUMP="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8891,47 +10727,41 @@ done ;; esac fi -GNUPLOT=$ac_cv_path_GNUPLOT +XFSDUMP=$ac_cv_path_XFSDUMP -if test -n "$GNUPLOT"; then - echo "$as_me:$LINENO: result: $GNUPLOT" >&5 -echo "${ECHO_T}$GNUPLOT" >&6 +if test -n "$XFSDUMP"; then + echo "$as_me:$LINENO: result: $XFSDUMP" >&5 +echo "${ECHO_T}$XFSDUMP" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$GNUPLOT" && break + test -n "$XFSDUMP" && break done -if test -z "$GNUPLOT"; then - NO_AMPLOT_MODE=true - { echo "$as_me:$LINENO: WARNING: *** You do not have gnuplot. Amplot will not be installed." >&5 -echo "$as_me: WARNING: *** You do not have gnuplot. Amplot will not be installed." >&2;} -fi - -for ac_prog in grep +for ac_prog in xfsrestore do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_GREP+set}" = set; then +if test "${ac_cv_path_XFSRESTORE+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $GREP in + case $XFSRESTORE in [\\/]* | ?:[\\/]*) - ac_cv_path_GREP="$GREP" # Let the user override the test with a path. + ac_cv_path_XFSRESTORE="$XFSRESTORE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $SYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_XFSRESTORE="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8941,50 +10771,59 @@ done ;; esac fi -GREP=$ac_cv_path_GREP +XFSRESTORE=$ac_cv_path_XFSRESTORE -if test -n "$GREP"; then - echo "$as_me:$LINENO: result: $GREP" >&5 -echo "${ECHO_T}$GREP" >&6 +if test -n "$XFSRESTORE"; then + echo "$as_me:$LINENO: result: $XFSRESTORE" >&5 +echo "${ECHO_T}$XFSRESTORE" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$GREP" && break + test -n "$XFSRESTORE" && break done -if test -z "$GREP"; then - GREP=grep -fi +if test "$XFSDUMP" -a "$XFSRESTORE"; then cat >>confdefs.h <<_ACEOF -#define GREP "$GREP" +#define XFSDUMP "$XFSDUMP" _ACEOF -for ac_prog in gtar gnutar tar +cat >>confdefs.h <<_ACEOF +#define XFSRESTORE "$XFSRESTORE" +_ACEOF + + { echo "$as_me:$LINENO: WARNING: *** xfsdump causes the setuid-root rundump program to be enabled" >&5 +echo "$as_me: WARNING: *** xfsdump causes the setuid-root rundump program to be enabled" >&2;} + { echo "$as_me:$LINENO: WARNING: *** to disable it, just #undef XFSDUMP in config/config.h" >&5 +echo "$as_me: WARNING: *** to disable it, just #undef XFSDUMP in config/config.h" >&2;} +fi + +VXSYSLOCPATH="$SYSLOCPATH:/usr/lib/fs/vxfs" +for ac_prog in vxdump do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_GNUTAR+set}" = set; then +if test "${ac_cv_path_VXDUMP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $GNUTAR in + case $VXDUMP in [\\/]* | ?:[\\/]*) - ac_cv_path_GNUTAR="$GNUTAR" # Let the user override the test with a path. + ac_cv_path_VXDUMP="$VXDUMP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $VXSYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GNUTAR="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_VXDUMP="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8994,58 +10833,41 @@ done ;; esac fi -GNUTAR=$ac_cv_path_GNUTAR +VXDUMP=$ac_cv_path_VXDUMP -if test -n "$GNUTAR"; then - echo "$as_me:$LINENO: result: $GNUTAR" >&5 -echo "${ECHO_T}$GNUTAR" >&6 +if test -n "$VXDUMP"; then + echo "$as_me:$LINENO: result: $VXDUMP" >&5 +echo "${ECHO_T}$VXDUMP" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$GNUTAR" && break + test -n "$VXDUMP" && break done -if test ! -z "$GNUTAR"; then - case "`\"$GNUTAR\" --version 2>&1`" in - *GNU*tar* | *Free*paxutils* ) - -cat >>confdefs.h <<_ACEOF -#define GNUTAR "$GNUTAR" -_ACEOF - - ;; - *) - { echo "$as_me:$LINENO: WARNING: *** $GNUTAR is not GNU tar, so it will not be used." >&5 -echo "$as_me: WARNING: *** $GNUTAR is not GNU tar, so it will not be used." >&2;} - GNUTAR= - ;; - esac -fi - -for ac_prog in smbclient +for ac_prog in vxrestore do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_SAMBA_CLIENT+set}" = set; then +if test "${ac_cv_path_VXRESTORE+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $SAMBA_CLIENT in + case $VXRESTORE in [\\/]* | ?:[\\/]*) - ac_cv_path_SAMBA_CLIENT="$SAMBA_CLIENT" # Let the user override the test with a path. + ac_cv_path_VXRESTORE="$VXRESTORE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $VXSYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_SAMBA_CLIENT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_VXRESTORE="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -9055,69 +10877,54 @@ done ;; esac fi -SAMBA_CLIENT=$ac_cv_path_SAMBA_CLIENT +VXRESTORE=$ac_cv_path_VXRESTORE -if test -n "$SAMBA_CLIENT"; then - echo "$as_me:$LINENO: result: $SAMBA_CLIENT" >&5 -echo "${ECHO_T}$SAMBA_CLIENT" >&6 +if test -n "$VXRESTORE"; then + echo "$as_me:$LINENO: result: $VXRESTORE" >&5 +echo "${ECHO_T}$VXRESTORE" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$SAMBA_CLIENT" && break + test -n "$VXRESTORE" && break done -if test ! -z "$SAMBA_CLIENT"; then - case "`\"$SAMBA_CLIENT\" '\\\\not.a.host.name\\notashare' -U nosuchuser -N -Tx /dev/null 2>&1`" in - *"Unknown host"*) - smbversion=1 - ;; - *"Connection to not.a.host.name failed"*) - smbversion=2 - ;; - *) - { echo "$as_me:$LINENO: WARNING: *** $SAMBA_CLIENT does not seem to be smbclient, so it will not be used." >&5 -echo "$as_me: WARNING: *** $SAMBA_CLIENT does not seem to be smbclient, so it will not be used." >&2;} - SAMBA_CLIENT= - ;; - esac - if test -n "$SAMBA_CLIENT"; then +if test "$VXDUMP" -a "$VXRESTORE"; then cat >>confdefs.h <<_ACEOF -#define SAMBA_CLIENT "$SAMBA_CLIENT" +#define VXDUMP "$VXDUMP" _ACEOF cat >>confdefs.h <<_ACEOF -#define SAMBA_VERSION $smbversion +#define VXRESTORE "$VXRESTORE" _ACEOF - fi fi -for ac_prog in gzip +for ac_prog in vdump do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_GZIP+set}" = set; then +if test "${ac_cv_path_VDUMP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $GZIP in + case $VDUMP in [\\/]* | ?:[\\/]*) - ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path. + ac_cv_path_VDUMP="$VDUMP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH +for as_dir in $SYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_VDUMP="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -9127,103 +10934,41 @@ done ;; esac fi -GZIP=$ac_cv_path_GZIP +VDUMP=$ac_cv_path_VDUMP -if test -n "$GZIP"; then - echo "$as_me:$LINENO: result: $GZIP" >&5 -echo "${ECHO_T}$GZIP" >&6 +if test -n "$VDUMP"; then + echo "$as_me:$LINENO: result: $VDUMP" >&5 +echo "${ECHO_T}$VDUMP" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$GZIP" && break + test -n "$VDUMP" && break done -if test "$GZIP"; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_GZIP 1 -_ACEOF - - COMPRESS_PATH="$GZIP" - COMPRESS_SUFFIX=".gz" - COMPRESS_FAST_OPT="--fast" - COMPRESS_BEST_OPT="--best" - UNCOMPRESS_PATH="$GZIP" - UNCOMPRESS_OPT="-dc" -else - if test "$COMPRESS"; then - COMPRESS_PATH="$COMPRESS" - COMPRESS_SUFFIX=".Z" - COMPRESS_FAST_OPT="-f" - COMPRESS_BEST_OPT="-f" - UNCOMPRESS_PATH="$COMPRESS" - UNCOMPRESS_OPT="-dc" - else - { echo "$as_me:$LINENO: WARNING: *** Cannot find either gzip or compress. Using cat. ***" >&5 -echo "$as_me: WARNING: *** Cannot find either gzip or compress. Using cat. ***" >&2;} - COMPRESS_PATH="$CAT" - COMPRESS_SUFFIX="" - COMPRESS_FAST_OPT="" - COMPRESS_BEST_OPT="" - UNCOMPRESS_PATH="$CAT" - UNCOMPRESS_OPT="" - fi -fi - -cat >>confdefs.h <<_ACEOF -#define COMPRESS_PATH "$COMPRESS_PATH" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define COMPRESS_SUFFIX "$COMPRESS_SUFFIX" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define COMPRESS_FAST_OPT "$COMPRESS_FAST_OPT" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define COMPRESS_BEST_OPT "$COMPRESS_BEST_OPT" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define UNCOMPRESS_PATH "$UNCOMPRESS_PATH" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define UNCOMPRESS_OPT "$UNCOMPRESS_OPT" -_ACEOF - - -for ac_prog in Mail mailx mail +for ac_prog in vrestore do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_MAILER+set}" = set; then +if test "${ac_cv_path_VRESTORE+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $MAILER in + case $VRESTORE in [\\/]* | ?:[\\/]*) - ac_cv_path_MAILER="$MAILER" # Let the user override the test with a path. + ac_cv_path_VRESTORE="$VRESTORE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +for as_dir in $SYSLOCPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_MAILER="$as_dir/$ac_word$ac_exec_ext" + ac_cv_path_VRESTORE="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -9233,1024 +10978,1357 @@ done ;; esac fi -MAILER=$ac_cv_path_MAILER +VRESTORE=$ac_cv_path_VRESTORE -if test -n "$MAILER"; then - echo "$as_me:$LINENO: result: $MAILER" >&5 -echo "${ECHO_T}$MAILER" >&6 +if test -n "$VRESTORE"; then + echo "$as_me:$LINENO: result: $VRESTORE" >&5 +echo "${ECHO_T}$VRESTORE" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi - test -n "$MAILER" && break + test -n "$VRESTORE" && break done -if test -z "$MAILER"; then - if $NO_SERVER_MODE; then - MAILER="NONE" - { echo "$as_me:$LINENO: WARNING: *** WARNING: Amanda cannot send mail reports without these programs." >&5 -echo "$as_me: WARNING: *** WARNING: Amanda cannot send mail reports without these programs." >&2;} - else - { { echo "$as_me:$LINENO: error: Set MAILER to some program that accepts -s subject user < message_file." >&5 -echo "$as_me: error: Set MAILER to some program that accepts -s subject user < message_file." >&2;} - { (exit 1); exit 1; }; } - fi -fi +if test "$VDUMP" -a "$VRESTORE"; then cat >>confdefs.h <<_ACEOF -#define MAILER "$MAILER" +#define VDUMP "$VDUMP" _ACEOF -for ac_prog in mt -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_MT+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $MT in - [\\/]* | ?:[\\/]*) - ac_cv_path_MT="$MT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_MT="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done +cat >>confdefs.h <<_ACEOF +#define VRESTORE "$VRESTORE" +_ACEOF - ;; -esac fi -MT=$ac_cv_path_MT -if test -n "$MT"; then - echo "$as_me:$LINENO: result: $MT" >&5 -echo "${ECHO_T}$MT" >&6 +if test "$PCAT"; then + AMPLOT_CAT_PACK="if(o==\"z\")print \"$PCAT\"; else" else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + AMPLOT_CAT_PACK= +fi +if test "$COMPRESS"; then + AMPLOT_COMPRESS=$COMPRESS + AMPLOT_CAT_COMPRESS="if(o==\"Z\")print \"$COMPRESS -dc\"; else" +else + AMPLOT_CAT_COMPRESS= +fi +if test "$GZIP"; then + AMPLOT_COMPRESS=$GZIP + AMPLOT_CAT_GZIP="if(o==\"gz\")print \"$GZIP -dc\"; else" +else + AMPLOT_CAT_GZIP= fi - test -n "$MT" && break -done -test -n "$MT" || MT="mt" -for ac_prog in chio -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_CHIO+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + + +# Determine the printf format characters to use when printing +# values of type long long. This will normally be "ll", but where +# the compiler treats "long long" as a alias for "long" and printf +# doesn't know about "long long" use "l". Hopefully the sprintf +# will produce a inconsistant result in the later case. If the compiler +# fails due to seeing "%lld" we fall back to "l". +# +# Win32 uses "%I64d", but that's defined elsewhere since we don't use +# configure on Win32. +# +echo "$as_me:$LINENO: checking printf format modifier for 64-bit integers" >&5 +echo $ECHO_N "checking printf format modifier for 64-bit integers... $ECHO_C" >&6 +if test "$cross_compiling" = yes; then + echo "$as_me:$LINENO: result: assuming target platform uses ll" >&5 +echo "${ECHO_T}assuming target platform uses ll" >&6 + LL_FMT="%lld" else - case $CHIO in - [\\/]* | ?:[\\/]*) - ac_cv_path_CHIO="$CHIO" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_CHIO="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ - ;; -esac -fi -CHIO=$ac_cv_path_CHIO +#include +main() { + long long int j = 0; + char buf[100]; + buf[0] = 0; + sprintf(buf, "%lld", j); + exit((sizeof(long long int) != sizeof(long int))? 0 : + (strcmp(buf, "0") != 0)); +} -if test -n "$CHIO"; then - echo "$as_me:$LINENO: result: $CHIO" >&5 -echo "${ECHO_T}$CHIO" >&6 +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: ll" >&5 +echo "${ECHO_T}ll" >&6 + LL_FMT="%lld" else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +echo "$as_me:$LINENO: result: l" >&5 +echo "${ECHO_T}l" >&6 + LL_FMT="%ld" +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - test -n "$CHIO" && break -done -test -n "$CHIO" || CHIO="chio" +cat >>confdefs.h <<_ACEOF +#define LL_FMT "$LL_FMT" +_ACEOF -for ac_prog in chs -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_CHS+set}" = set; then + +GZIP= + +need_resetofs=yes +echo "$as_me:$LINENO: checking for large file compilation CFLAGS" >&5 +echo $ECHO_N "checking for large file compilation CFLAGS... $ECHO_C" >&6 +if test "${amanda_cv_LFS_CFLAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $CHS in - [\\/]* | ?:[\\/]*) - ac_cv_path_CHS="$CHS" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_CHS="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - ;; -esac -fi -CHS=$ac_cv_path_CHS + amanda_cv_LFS_CFLAGS= + if test "$GETCONF"; then + if $GETCONF ${GETCONF_LFS}_CFLAGS >/dev/null 2>&1; then + amanda_cv_LFS_CFLAGS=`$GETCONF ${GETCONF_LFS}_CFLAGS 2>/dev/null` + need_resetofs=no + fi + fi + -if test -n "$CHS"; then - echo "$as_me:$LINENO: result: $CHS" >&5 -echo "${ECHO_T}$CHS" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 fi +echo "$as_me:$LINENO: result: $amanda_cv_LFS_CFLAGS" >&5 +echo "${ECHO_T}$amanda_cv_LFS_CFLAGS" >&6 +echo "$as_me:$LINENO: checking for large file compilation LDFLAGS" >&5 +echo $ECHO_N "checking for large file compilation LDFLAGS... $ECHO_C" >&6 +if test "${amanda_cv_LFS_LDFLAGS+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else - test -n "$CHS" && break -done -test -n "$CHS" || CHS="chs" + amanda_cv_LFS_LDFLAGS= + if test "$GETCONF"; then + if $GETCONF ${GETCONF_LFS}_LDFLAGS >/dev/null 2>&1; then + amanda_cv_LFS_LDFLAGS=`$GETCONF ${GETCONF_LFS}_LDFLAGS 2>/dev/null` + need_resetofs=no + fi + fi -for ac_prog in mtx -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_MTX+set}" = set; then +fi +echo "$as_me:$LINENO: result: $amanda_cv_LFS_LDFLAGS" >&5 +echo "${ECHO_T}$amanda_cv_LFS_LDFLAGS" >&6 +echo "$as_me:$LINENO: checking for large file compilation LIBS" >&5 +echo $ECHO_N "checking for large file compilation LIBS... $ECHO_C" >&6 +if test "${amanda_cv_LFS_LIBS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $MTX in - [\\/]* | ?:[\\/]*) - ac_cv_path_MTX="$MTX" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_MTX="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - ;; -esac + amanda_cv_LFS_LIBS= + if test "$GETCONF"; then + if $GETCONF ${GETCONF_LFS}_LIBS >/dev/null 2>&1; then + amanda_cv_LFS_LIBS=`$GETCONF ${GETCONF_LFS}_LIBS 2>/dev/null` + need_resetofs=no + fi + fi + + fi -MTX=$ac_cv_path_MTX +echo "$as_me:$LINENO: result: $amanda_cv_LFS_LIBS" >&5 +echo "${ECHO_T}$amanda_cv_LFS_LIBS" >&6 +if test "x$need_resetofs" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define NEED_RESETOFS 1 +_ACEOF -if test -n "$MTX"; then - echo "$as_me:$LINENO: result: $MTX" >&5 -echo "${ECHO_T}$MTX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 fi - test -n "$MTX" && break -done -test -n "$MTX" || MTX="mtx" +CFLAGS="$amanda_cv_LFS_CFLAGS $CFLAGS" +CPPFLAGS="$amanda_cv_LFS_CPPFLAGS $CPPFLAGS" +LDFLAGS="$amanda_cv_LFS_LDFLAGS $LDFLAGS" +LIBS="$amanda_cv_LFS_LIBS $LIBS" -for ac_prog in mcutil -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_MCUTIL+set}" = set; then +echo "$as_me:$LINENO: checking for int" >&5 +echo $ECHO_N "checking for int... $ECHO_C" >&6 +if test "${ac_cv_type_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $MCUTIL in - [\\/]* | ?:[\\/]*) - ac_cv_path_MCUTIL="$MCUTIL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_MCUTIL="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((int *) 0) + return 0; +if (sizeof (int)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_int=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ;; -esac +ac_cv_type_int=no fi -MCUTIL=$ac_cv_path_MCUTIL +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 +echo "${ECHO_T}$ac_cv_type_int" >&6 -if test -n "$MCUTIL"; then - echo "$as_me:$LINENO: result: $MCUTIL" >&5 -echo "${ECHO_T}$MCUTIL" >&6 +echo "$as_me:$LINENO: checking size of int" >&5 +echo $ECHO_N "checking size of int... $ECHO_C" >&6 +if test "${ac_cv_sizeof_int+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + if test "$ac_cv_type_int" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - test -n "$MCUTIL" && break -done -test -n "$MCUTIL" || MCUTIL="mcutil" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; +test_array [0] = 0 -for ac_prog in lpr lp -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_PRINT+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break else - case $PRINT in - [\\/]* | ?:[\\/]*) - ac_cv_path_PRINT="$PRINT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PRINT="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ;; -esac +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` fi -PRINT=$ac_cv_path_PRINT - -if test -n "$PRINT"; then - echo "$as_me:$LINENO: result: $PRINT" >&5 -echo "${ECHO_T}$PRINT" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 - test -n "$PRINT" && break + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done +case $ac_lo in +?*) ac_cv_sizeof_int=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (int)); } +unsigned long ulongval () { return (long) (sizeof (int)); } +#include +#include +int +main () +{ -if test ! -z "$PRINT"; then + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (int))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (int)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (int)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); -cat >>confdefs.h <<_ACEOF -#define LPRCMD "$PRINT" + ; + return 0; +} _ACEOF - - echo "$as_me:$LINENO: checking which flag to use to select a printer" >&5 -echo $ECHO_N "checking which flag to use to select a printer... $ECHO_C" >&6 -if test "${amanda_cv_printer_flag+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_int=`cat conftest.val` else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - amanda_cv_printer_flag=$PRINTER_FLAG - case "$PRINT" in - lpr|*/lpr) amanda_cv_printer_flag="-P";; - lp|*/lp) amanda_cv_printer_flag="-d";; - esac - +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -echo "$as_me:$LINENO: result: $amanda_cv_printer_flag" >&5 -echo "${ECHO_T}$amanda_cv_printer_flag" >&6 - if test ! -z "$amanda_cv_printer_flag"; then - -cat >>confdefs.h <<_ACEOF -#define LPRFLAG "$amanda_cv_printer_flag" -_ACEOF - - else - { echo "$as_me:$LINENO: WARNING: *** WARNING: amanda will always print to the default printer" >&5 -echo "$as_me: WARNING: *** WARNING: amanda will always print to the default printer" >&2;} - fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - -for ac_prog in pcat -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_PCAT+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $PCAT in - [\\/]* | ?:[\\/]*) - ac_cv_path_PCAT="$PCAT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PCAT="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - ;; -esac fi -PCAT=$ac_cv_path_PCAT - -if test -n "$PCAT"; then - echo "$as_me:$LINENO: result: $PCAT" >&5 -echo "${ECHO_T}$PCAT" >&6 +rm -f conftest.val else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + ac_cv_sizeof_int=0 +fi fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 +echo "${ECHO_T}$ac_cv_sizeof_int" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT $ac_cv_sizeof_int +_ACEOF - test -n "$PCAT" && break -done -for ac_prog in perl5 perl -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_PERL+set}" = set; then +echo "$as_me:$LINENO: checking for long" >&5 +echo $ECHO_N "checking for long... $ECHO_C" >&6 +if test "${ac_cv_type_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $PERL in - [\\/]* | ?:[\\/]*) - ac_cv_path_PERL="$PERL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $LOCSYSPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long *) 0) + return 0; +if (sizeof (long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ;; -esac +ac_cv_type_long=no fi -PERL=$ac_cv_path_PERL - -if test -n "$PERL"; then - echo "$as_me:$LINENO: result: $PERL" >&5 -echo "${ECHO_T}$PERL" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 +echo "${ECHO_T}$ac_cv_type_long" >&6 - test -n "$PERL" && break -done - - - -for ac_prog in $DUMP_PROGRAMS -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_DUMP+set}" = set; then +echo "$as_me:$LINENO: checking size of long" >&5 +echo $ECHO_N "checking size of long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $DUMP in - [\\/]* | ?:[\\/]*) - ac_cv_path_DUMP="$DUMP" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_DUMP="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - ;; -esac -fi -DUMP=$ac_cv_path_DUMP - -if test -n "$DUMP"; then - echo "$as_me:$LINENO: result: $DUMP" >&5 -echo "${ECHO_T}$DUMP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi + if test "$ac_cv_type_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +test_array [0] = 0 - test -n "$DUMP" && break -done + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 -for ac_prog in ufsrestore restore -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_RESTORE+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break else - case $RESTORE in - [\\/]* | ?:[\\/]*) - ac_cv_path_RESTORE="$RESTORE" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_RESTORE="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ;; -esac +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi -RESTORE=$ac_cv_path_RESTORE - -if test -n "$RESTORE"; then - echo "$as_me:$LINENO: result: $RESTORE" >&5 -echo "${ECHO_T}$RESTORE" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$RESTORE" && break -done - -if test "$DUMP" -a "$RESTORE"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -cat >>confdefs.h <<_ACEOF -#define DUMP "$DUMP" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +test_array [0] = 0 -cat >>confdefs.h <<_ACEOF -#define RESTORE "$RESTORE" + ; + return 0; +} _ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - if test -x $DUMP; then - echo "$as_me:$LINENO: checking whether $DUMP supports -E or -S for estimates" >&5 -echo $ECHO_N "checking whether $DUMP supports -E or -S for estimates... $ECHO_C" >&6 -if test "${amanda_cv_dump_estimate+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - case "$DUMP" in - *dump) - { ac_try='$DUMP 9Ef /dev/null /dev/null/invalid/fs 2>&1 - | $GREP -v Dumping - | $GREP -v Date - | $GREP -v Label >conftest.d-E 2>&1' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } - cat conftest.d-E >&5 - { ac_try='$DUMP 9Sf /dev/null /dev/null/invalid/fs 2>&1 - | $GREP -v Dumping - | $GREP -v Date - | $GREP -v Label >conftest.d-S 2>&1' + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } - cat conftest.d-S >&5 - { ac_try='$DUMP 9f /dev/null /dev/null/invalid/fs 2>&1 - | $GREP -v Dumping - | $GREP -v Date - | $GREP -v Label >conftest.d 2>&1' + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } - cat conftest.d >&5 - if { ac_try='cmp conftest.d-E conftest.d 1>&2' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long)); } +unsigned long ulongval () { return (long) (sizeof (long)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - amanda_cv_dump_estimate=E - elif { ac_try='cmp conftest.d-S conftest.d 1>&2' + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - amanda_cv_dump_estimate=S - else - amanda_cv_dump_estimate=no - fi - rm -f conftest.d conftest.d-E conftest.d-S - ;; - *) amanda_cv_dump_estimate=no - ;; - esac + ac_cv_sizeof_long=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -echo "$as_me:$LINENO: result: $amanda_cv_dump_estimate" >&5 -echo "${ECHO_T}$amanda_cv_dump_estimate" >&6 - else - { echo "$as_me:$LINENO: WARNING: *** $DUMP is not executable, cannot run -E/-S test" >&5 -echo "$as_me: WARNING: *** $DUMP is not executable, cannot run -E/-S test" >&2;} - amanda_cv_dump_estimate=no - fi - if test "x$amanda_cv_dump_estimate" != xno; then - +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_long=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long" >&6 cat >>confdefs.h <<_ACEOF -#define HAVE_DUMP_ESTIMATE "$amanda_cv_dump_estimate" +#define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF - fi - -# Check whether --with-dump-honor-nodump or --without-dump-honor-nodump was given. -if test "${with_dump_honor_nodump+set}" = set; then - withval="$with_dump_honor_nodump" - if test -x $DUMP; then - echo "$as_me:$LINENO: checking whether $DUMP supports -h (honor nodump flag)" >&5 -echo $ECHO_N "checking whether $DUMP supports -h (honor nodump flag)... $ECHO_C" >&6 -if test "${amanda_cv_honor_nodump+set}" = set; then +echo "$as_me:$LINENO: checking for long long" >&5 +echo $ECHO_N "checking for long long... $ECHO_C" >&6 +if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - - case "$DUMP" in - *dump) - { ac_try='$DUMP 9hf 0 /dev/null /dev/null/invalid/fs 2>&1 - | $GREP -v Dumping - | $GREP -v Date - | $GREP -v Label >conftest.d-h 2>&1' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long long *) 0) + return 0; +if (sizeof (long long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } - cat conftest.d-h >&5 - { ac_try='$DUMP 9f /dev/null /dev/null/invalid/fs 2>&1 - | $GREP -v Dumping - | $GREP -v Date - | $GREP -v Label >conftest.d 2>&1' + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } - cat conftest.d >&5 - if { ac_try='diff conftest.d-h conftest.d 1>&2' + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - amanda_cv_honor_nodump=yes - else - amanda_cv_honor_nodump=no - fi - rm -f conftest.d conftest.d-h - ;; - *) amanda_cv_honor_nodump=no - ;; - esac - -fi -echo "$as_me:$LINENO: result: $amanda_cv_honor_nodump" >&5 -echo "${ECHO_T}$amanda_cv_honor_nodump" >&6 - else - { echo "$as_me:$LINENO: WARNING: *** $DUMP is not executable, cannot run -h test" >&5 -echo "$as_me: WARNING: *** $DUMP is not executable, cannot run -h test" >&2;} - amanda_cv_honor_nodump=no - fi - if test "x$amanda_cv_honor_nodump" = xyes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_HONOR_NODUMP 1 -_ACEOF - - fi - -fi; -fi - -for ac_prog in xfsdump -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_XFSDUMP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + ac_cv_type_long_long=yes else - case $XFSDUMP in - [\\/]* | ?:[\\/]*) - ac_cv_path_XFSDUMP="$XFSDUMP" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_XFSDUMP="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ;; -esac +ac_cv_type_long_long=no fi -XFSDUMP=$ac_cv_path_XFSDUMP - -if test -n "$XFSDUMP"; then - echo "$as_me:$LINENO: result: $XFSDUMP" >&5 -echo "${ECHO_T}$XFSDUMP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 +echo "${ECHO_T}$ac_cv_type_long_long" >&6 - test -n "$XFSDUMP" && break -done - -for ac_prog in xfsrestore -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_XFSRESTORE+set}" = set; then +echo "$as_me:$LINENO: checking size of long long" >&5 +echo $ECHO_N "checking size of long long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - case $XFSRESTORE in - [\\/]* | ?:[\\/]*) - ac_cv_path_XFSRESTORE="$XFSRESTORE" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_XFSRESTORE="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - ;; -esac -fi -XFSRESTORE=$ac_cv_path_XFSRESTORE - -if test -n "$XFSRESTORE"; then - echo "$as_me:$LINENO: result: $XFSRESTORE" >&5 -echo "${ECHO_T}$XFSRESTORE" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$XFSRESTORE" && break -done - -if test "$XFSDUMP" -a "$XFSRESTORE"; then - -cat >>confdefs.h <<_ACEOF -#define XFSDUMP "$XFSDUMP" + if test "$ac_cv_type_long_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; +test_array [0] = 0 - -cat >>confdefs.h <<_ACEOF -#define XFSRESTORE "$XFSRESTORE" + ; + return 0; +} _ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +test_array [0] = 0 - { echo "$as_me:$LINENO: WARNING: *** xfsdump causes the setuid-root rundump program to be enabled" >&5 -echo "$as_me: WARNING: *** xfsdump causes the setuid-root rundump program to be enabled" >&2;} - { echo "$as_me:$LINENO: WARNING: *** to disable it, just #undef XFSDUMP in config/config.h" >&5 -echo "$as_me: WARNING: *** to disable it, just #undef XFSDUMP in config/config.h" >&2;} -fi - -VXSYSLOCPATH="$SYSLOCPATH:/usr/lib/fs/vxfs" -for ac_prog in vxdump -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_VXDUMP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $VXDUMP in - [\\/]* | ?:[\\/]*) - ac_cv_path_VXDUMP="$VXDUMP" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $VXSYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_VXDUMP="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - ;; -esac -fi -VXDUMP=$ac_cv_path_VXDUMP - -if test -n "$VXDUMP"; then - echo "$as_me:$LINENO: result: $VXDUMP" >&5 -echo "${ECHO_T}$VXDUMP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$VXDUMP" && break -done - -for ac_prog in vxrestore -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_VXRESTORE+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break else - case $VXRESTORE in - [\\/]* | ?:[\\/]*) - ac_cv_path_VXRESTORE="$VXRESTORE" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $VXSYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_VXRESTORE="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - ;; -esac -fi -VXRESTORE=$ac_cv_path_VXRESTORE + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -if test -n "$VXRESTORE"; then - echo "$as_me:$LINENO: result: $VXRESTORE" >&5 -echo "${ECHO_T}$VXRESTORE" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - test -n "$VXRESTORE" && break -done - -if test "$VXDUMP" -a "$VXRESTORE"; then - -cat >>confdefs.h <<_ACEOF -#define VXDUMP "$VXDUMP" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; +test_array [0] = 0 - -cat >>confdefs.h <<_ACEOF -#define VXRESTORE "$VXRESTORE" + ; + return 0; +} _ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; +test_array [0] = 0 -fi - -for ac_prog in vdump -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_VDUMP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break else - case $VDUMP in - [\\/]* | ?:[\\/]*) - ac_cv_path_VDUMP="$VDUMP" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_VDUMP="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - ;; -esac -fi -VDUMP=$ac_cv_path_VDUMP + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -if test -n "$VDUMP"; then - echo "$as_me:$LINENO: result: $VDUMP" >&5 -echo "${ECHO_T}$VDUMP" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` fi - - test -n "$VDUMP" && break -done - -for ac_prog in vrestore -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_VRESTORE+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done else - case $VRESTORE in - [\\/]* | ?:[\\/]*) - ac_cv_path_VRESTORE="$VRESTORE" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $SYSLOCPATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_VRESTORE="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - ;; -esac +ac_lo= ac_hi= fi -VRESTORE=$ac_cv_path_VRESTORE - -if test -n "$VRESTORE"; then - echo "$as_me:$LINENO: result: $VRESTORE" >&5 -echo "${ECHO_T}$VRESTORE" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi - - test -n "$VRESTORE" && break -done - -if test "$VDUMP" -a "$VRESTORE"; then - -cat >>confdefs.h <<_ACEOF -#define VDUMP "$VDUMP" +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +test_array [0] = 0 - -cat >>confdefs.h <<_ACEOF -#define VRESTORE "$VRESTORE" + ; + return 0; +} _ACEOF - -fi - -if test "$PCAT"; then - AMPLOT_CAT_PACK="if(o==\"z\")print \"$PCAT\"; else" -else - AMPLOT_CAT_PACK= -fi -if test "$COMPRESS"; then - AMPLOT_COMPRESS=$COMPRESS - AMPLOT_CAT_COMPRESS="if(o==\"Z\")print \"$COMPRESS -dc\"; else" +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid else - AMPLOT_CAT_COMPRESS= + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` fi -if test "$GZIP"; then - AMPLOT_COMPRESS=$GZIP - AMPLOT_CAT_GZIP="if(o==\"gz\")print \"$GZIP -dc\"; else" +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac else - AMPLOT_CAT_GZIP= -fi - - - - - -# Determine the printf format characters to use when printing -# values of type long long. This will normally be "ll", but where -# the compiler treats "long long" as a alias for "long" and printf -# doesn't know about "long long" use "l". Hopefully the sprintf -# will produce a inconsistant result in the later case. If the compiler -# fails due to seeing "%lld" we fall back to "l". -# -# Win32 uses "%I64d", but that's defined elsewhere since we don't use -# configure on Win32. -# -echo "$as_me:$LINENO: checking printf format modifier for 64-bit integers" >&5 -echo $ECHO_N "checking printf format modifier for 64-bit integers... $ECHO_C" >&6 -if test "$cross_compiling" = yes; then - echo "$as_me:$LINENO: result: assuming target platform uses ll" >&5 -echo "${ECHO_T}assuming target platform uses ll" >&6 - LL_FMT="%lld" + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -10258,17 +12336,37 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - +$ac_includes_default +long longval () { return (long) (sizeof (long long)); } +unsigned long ulongval () { return (long) (sizeof (long long)); } #include -main() { - long long int j = 0; - char buf[100]; - buf[0] = 0; - sprintf(buf, "%lld", j); - exit((sizeof(long long int) != sizeof(long int))? 0 : - (strcmp(buf, "0") != 0)); -} +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + ; + return 0; +} _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 @@ -10281,100 +12379,37 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - echo "$as_me:$LINENO: result: ll" >&5 -echo "${ECHO_T}ll" >&6 - LL_FMT="%lld" + ac_cv_sizeof_long_long=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -echo "$as_me:$LINENO: result: l" >&5 -echo "${ECHO_T}l" >&6 - LL_FMT="%ld" +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - -cat >>confdefs.h <<_ACEOF -#define LL_FMT "$LL_FMT" -_ACEOF - - - -GZIP= - -need_resetofs=yes -echo "$as_me:$LINENO: checking for large file compilation CFLAGS" >&5 -echo $ECHO_N "checking for large file compilation CFLAGS... $ECHO_C" >&6 -if test "${amanda_cv_LFS_CFLAGS+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - amanda_cv_LFS_CFLAGS= - if test "$GETCONF"; then - if $GETCONF ${GETCONF_LFS}_CFLAGS >/dev/null 2>&1; then - amanda_cv_LFS_CFLAGS=`$GETCONF ${GETCONF_LFS}_CFLAGS 2>/dev/null` - need_resetofs=no - fi - fi - - fi -echo "$as_me:$LINENO: result: $amanda_cv_LFS_CFLAGS" >&5 -echo "${ECHO_T}$amanda_cv_LFS_CFLAGS" >&6 -echo "$as_me:$LINENO: checking for large file compilation LDFLAGS" >&5 -echo $ECHO_N "checking for large file compilation LDFLAGS... $ECHO_C" >&6 -if test "${amanda_cv_LFS_LDFLAGS+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +rm -f conftest.val else - - amanda_cv_LFS_LDFLAGS= - if test "$GETCONF"; then - if $GETCONF ${GETCONF_LFS}_LDFLAGS >/dev/null 2>&1; then - amanda_cv_LFS_LDFLAGS=`$GETCONF ${GETCONF_LFS}_LDFLAGS 2>/dev/null` - need_resetofs=no - fi - fi - - + ac_cv_sizeof_long_long=0 fi -echo "$as_me:$LINENO: result: $amanda_cv_LFS_LDFLAGS" >&5 -echo "${ECHO_T}$amanda_cv_LFS_LDFLAGS" >&6 -echo "$as_me:$LINENO: checking for large file compilation LIBS" >&5 -echo $ECHO_N "checking for large file compilation LIBS... $ECHO_C" >&6 -if test "${amanda_cv_LFS_LIBS+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - amanda_cv_LFS_LIBS= - if test "$GETCONF"; then - if $GETCONF ${GETCONF_LFS}_LIBS >/dev/null 2>&1; then - amanda_cv_LFS_LIBS=`$GETCONF ${GETCONF_LFS}_LIBS 2>/dev/null` - need_resetofs=no - fi - fi - - fi -echo "$as_me:$LINENO: result: $amanda_cv_LFS_LIBS" >&5 -echo "${ECHO_T}$amanda_cv_LFS_LIBS" >&6 -if test "x$need_resetofs" = xyes; then - -cat >>confdefs.h <<\_ACEOF -#define NEED_RESETOFS 1 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF -fi -CFLAGS="$amanda_cv_LFS_CFLAGS $CFLAGS" -CPPFLAGS="$amanda_cv_LFS_CFLAGS $CPPFLAGS" -LDFLAGS="$amanda_cv_LFS_LDFLAGS $LDFLAGS" -LIBS="$amanda_cv_LFS_LIBS $LIBS" -echo "$as_me:$LINENO: checking for int" >&5 -echo $ECHO_N "checking for int... $ECHO_C" >&6 -if test "${ac_cv_type_int+set}" = set; then +echo "$as_me:$LINENO: checking for intmax_t" >&5 +echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 +if test "${ac_cv_type_intmax_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10387,9 +12422,9 @@ $ac_includes_default int main () { -if ((int *) 0) +if ((intmax_t *) 0) return 0; -if (sizeof (int)) +if (sizeof (intmax_t)) return 0; ; return 0; @@ -10417,24 +12452,24 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_int=yes + ac_cv_type_intmax_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_int=no +ac_cv_type_intmax_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 -echo "${ECHO_T}$ac_cv_type_int" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 +echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 -echo "$as_me:$LINENO: checking size of int" >&5 -echo $ECHO_N "checking size of int... $ECHO_C" >&6 -if test "${ac_cv_sizeof_int+set}" = set; then +echo "$as_me:$LINENO: checking size of intmax_t" >&5 +echo $ECHO_N "checking size of intmax_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_intmax_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_int" = yes; then + if test "$ac_cv_type_intmax_t" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -10451,7 +12486,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) >= 0)]; test_array [0] = 0 ; @@ -10492,7 +12527,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -10549,7 +12584,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) < 0)]; test_array [0] = 0 ; @@ -10590,7 +12625,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) >= $ac_mid)]; test_array [0] = 0 ; @@ -10655,7 +12690,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -10694,10 +12729,10 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_int=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +?*) ac_cv_sizeof_intmax_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (intmax_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (int), 77 +echo "$as_me: error: cannot compute sizeof (intmax_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac @@ -10716,8 +12751,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (int)); } -unsigned long ulongval () { return (long) (sizeof (int)); } +long longval () { return (long) (sizeof (intmax_t)); } +unsigned long ulongval () { return (long) (sizeof (intmax_t)); } #include #include int @@ -10727,17 +12762,17 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (int))) < 0) + if (((long) (sizeof (intmax_t))) < 0) { long i = longval (); - if (i != ((long) (sizeof (int)))) + if (i != ((long) (sizeof (intmax_t)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (int)))) + if (i != ((long) (sizeof (intmax_t)))) exit (1); fprintf (f, "%lu\n", i); } @@ -10758,16 +12793,16 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_int=`cat conftest.val` + ac_cv_sizeof_intmax_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (intmax_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (int), 77 +echo "$as_me: error: cannot compute sizeof (intmax_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -10776,19 +12811,19 @@ fi fi rm -f conftest.val else - ac_cv_sizeof_int=0 + ac_cv_sizeof_intmax_t=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 -echo "${ECHO_T}$ac_cv_sizeof_int" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_intmax_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_intmax_t" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT $ac_cv_sizeof_int +#define SIZEOF_INTMAX_T $ac_cv_sizeof_intmax_t _ACEOF -echo "$as_me:$LINENO: checking for long" >&5 -echo $ECHO_N "checking for long... $ECHO_C" >&6 -if test "${ac_cv_type_long+set}" = set; then +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10801,9 +12836,9 @@ $ac_includes_default int main () { -if ((long *) 0) +if ((off_t *) 0) return 0; -if (sizeof (long)) +if (sizeof (off_t)) return 0; ; return 0; @@ -10831,24 +12866,24 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_long=yes + ac_cv_type_off_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_long=no +ac_cv_type_off_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 -echo "${ECHO_T}$ac_cv_type_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 -echo "$as_me:$LINENO: checking size of long" >&5 -echo $ECHO_N "checking size of long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long+set}" = set; then +echo "$as_me:$LINENO: checking size of off_t" >&5 +echo $ECHO_N "checking size of off_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long" = yes; then + if test "$ac_cv_type_off_t" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -10865,7 +12900,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= 0)]; test_array [0] = 0 ; @@ -10906,7 +12941,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -10963,7 +12998,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) < 0)]; test_array [0] = 0 ; @@ -11004,7 +13039,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= $ac_mid)]; test_array [0] = 0 ; @@ -11069,7 +13104,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -11108,10 +13143,10 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +?*) ac_cv_sizeof_off_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long), 77 +echo "$as_me: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac @@ -11130,8 +13165,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (long)); } -unsigned long ulongval () { return (long) (sizeof (long)); } +long longval () { return (long) (sizeof (off_t)); } +unsigned long ulongval () { return (long) (sizeof (off_t)); } #include #include int @@ -11141,17 +13176,17 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (long))) < 0) + if (((long) (sizeof (off_t))) < 0) { long i = longval (); - if (i != ((long) (sizeof (long)))) + if (i != ((long) (sizeof (off_t)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (long)))) + if (i != ((long) (sizeof (off_t)))) exit (1); fprintf (f, "%lu\n", i); } @@ -11172,16 +13207,16 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_long=`cat conftest.val` + ac_cv_sizeof_off_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long), 77 +echo "$as_me: error: cannot compute sizeof (off_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -11190,19 +13225,19 @@ fi fi rm -f conftest.val else - ac_cv_sizeof_long=0 + ac_cv_sizeof_off_t=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long +#define SIZEOF_OFF_T $ac_cv_sizeof_off_t _ACEOF -echo "$as_me:$LINENO: checking for long long" >&5 -echo $ECHO_N "checking for long long... $ECHO_C" >&6 -if test "${ac_cv_type_long_long+set}" = set; then +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -11215,9 +13250,9 @@ $ac_includes_default int main () { -if ((long long *) 0) +if ((size_t *) 0) return 0; -if (sizeof (long long)) +if (sizeof (size_t)) return 0; ; return 0; @@ -11245,24 +13280,24 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_long_long=yes + ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_long_long=no +ac_cv_type_size_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 -echo "${ECHO_T}$ac_cv_type_long_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 -echo "$as_me:$LINENO: checking size of long long" >&5 -echo $ECHO_N "checking size of long long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long_long+set}" = set; then +echo "$as_me:$LINENO: checking size of size_t" >&5 +echo $ECHO_N "checking size of size_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long_long" = yes; then + if test "$ac_cv_type_size_t" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -11279,7 +13314,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (size_t))) >= 0)]; test_array [0] = 0 ; @@ -11320,7 +13355,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (size_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -11377,7 +13412,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (size_t))) < 0)]; test_array [0] = 0 ; @@ -11418,7 +13453,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (size_t))) >= $ac_mid)]; test_array [0] = 0 ; @@ -11483,7 +13518,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (size_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -11522,10 +13557,10 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_long_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +?*) ac_cv_sizeof_size_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77 +echo "$as_me: error: cannot compute sizeof (size_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac @@ -11544,8 +13579,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (long long)); } -unsigned long ulongval () { return (long) (sizeof (long long)); } +long longval () { return (long) (sizeof (size_t)); } +unsigned long ulongval () { return (long) (sizeof (size_t)); } #include #include int @@ -11555,17 +13590,17 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (long long))) < 0) + if (((long) (sizeof (size_t))) < 0) { long i = longval (); - if (i != ((long) (sizeof (long long)))) + if (i != ((long) (sizeof (size_t)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (long long)))) + if (i != ((long) (sizeof (size_t)))) exit (1); fprintf (f, "%lu\n", i); } @@ -11586,16 +13621,16 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_long_long=`cat conftest.val` + ac_cv_sizeof_size_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77 +echo "$as_me: error: cannot compute sizeof (size_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -11604,19 +13639,19 @@ fi fi rm -f conftest.val else - ac_cv_sizeof_long_long=0 + ac_cv_sizeof_size_t=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_size_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_size_t" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long +#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF -echo "$as_me:$LINENO: checking for intmax_t" >&5 -echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 -if test "${ac_cv_type_intmax_t+set}" = set; then +echo "$as_me:$LINENO: checking for ssize_t" >&5 +echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6 +if test "${ac_cv_type_ssize_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -11629,9 +13664,9 @@ $ac_includes_default int main () { -if ((intmax_t *) 0) +if ((ssize_t *) 0) return 0; -if (sizeof (intmax_t)) +if (sizeof (ssize_t)) return 0; ; return 0; @@ -11659,24 +13694,24 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_intmax_t=yes + ac_cv_type_ssize_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_intmax_t=no +ac_cv_type_ssize_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 -echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5 +echo "${ECHO_T}$ac_cv_type_ssize_t" >&6 -echo "$as_me:$LINENO: checking size of intmax_t" >&5 -echo $ECHO_N "checking size of intmax_t... $ECHO_C" >&6 -if test "${ac_cv_sizeof_intmax_t+set}" = set; then +echo "$as_me:$LINENO: checking size of ssize_t" >&5 +echo $ECHO_N "checking size of ssize_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_ssize_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_intmax_t" = yes; then + if test "$ac_cv_type_ssize_t" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -11693,7 +13728,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (ssize_t))) >= 0)]; test_array [0] = 0 ; @@ -11734,7 +13769,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (ssize_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -11791,7 +13826,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (ssize_t))) < 0)]; test_array [0] = 0 ; @@ -11832,7 +13867,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (ssize_t))) >= $ac_mid)]; test_array [0] = 0 ; @@ -11897,7 +13932,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (intmax_t))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (ssize_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -11936,10 +13971,10 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_intmax_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (intmax_t), 77 +?*) ac_cv_sizeof_ssize_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (ssize_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (intmax_t), 77 +echo "$as_me: error: cannot compute sizeof (ssize_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac @@ -11958,8 +13993,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (intmax_t)); } -unsigned long ulongval () { return (long) (sizeof (intmax_t)); } +long longval () { return (long) (sizeof (ssize_t)); } +unsigned long ulongval () { return (long) (sizeof (ssize_t)); } #include #include int @@ -11969,17 +14004,17 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (intmax_t))) < 0) + if (((long) (sizeof (ssize_t))) < 0) { long i = longval (); - if (i != ((long) (sizeof (intmax_t)))) + if (i != ((long) (sizeof (ssize_t)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (intmax_t)))) + if (i != ((long) (sizeof (ssize_t)))) exit (1); fprintf (f, "%lu\n", i); } @@ -12000,16 +14035,16 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_intmax_t=`cat conftest.val` + ac_cv_sizeof_ssize_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (intmax_t), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (ssize_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (intmax_t), 77 +echo "$as_me: error: cannot compute sizeof (ssize_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -12018,19 +14053,19 @@ fi fi rm -f conftest.val else - ac_cv_sizeof_intmax_t=0 + ac_cv_sizeof_ssize_t=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_intmax_t" >&5 -echo "${ECHO_T}$ac_cv_sizeof_intmax_t" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_ssize_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_ssize_t" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_INTMAX_T $ac_cv_sizeof_intmax_t +#define SIZEOF_SSIZE_T $ac_cv_sizeof_ssize_t _ACEOF -echo "$as_me:$LINENO: checking for off_t" >&5 -echo $ECHO_N "checking for off_t... $ECHO_C" >&6 -if test "${ac_cv_type_off_t+set}" = set; then +echo "$as_me:$LINENO: checking for time_t" >&5 +echo $ECHO_N "checking for time_t... $ECHO_C" >&6 +if test "${ac_cv_type_time_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -12043,9 +14078,9 @@ $ac_includes_default int main () { -if ((off_t *) 0) +if ((time_t *) 0) return 0; -if (sizeof (off_t)) +if (sizeof (time_t)) return 0; ; return 0; @@ -12073,24 +14108,24 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_type_off_t=yes + ac_cv_type_time_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_type_off_t=no +ac_cv_type_time_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 -echo "${ECHO_T}$ac_cv_type_off_t" >&6 +echo "$as_me:$LINENO: result: $ac_cv_type_time_t" >&5 +echo "${ECHO_T}$ac_cv_type_time_t" >&6 -echo "$as_me:$LINENO: checking size of off_t" >&5 -echo $ECHO_N "checking size of off_t... $ECHO_C" >&6 -if test "${ac_cv_sizeof_off_t+set}" = set; then +echo "$as_me:$LINENO: checking size of time_t" >&5 +echo $ECHO_N "checking size of time_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_time_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_off_t" = yes; then + if test "$ac_cv_type_time_t" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -12107,7 +14142,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (time_t))) >= 0)]; test_array [0] = 0 ; @@ -12148,7 +14183,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (time_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -12205,7 +14240,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) < 0)]; +static int test_array [1 - 2 * !(((long) (sizeof (time_t))) < 0)]; test_array [0] = 0 ; @@ -12246,7 +14281,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (time_t))) >= $ac_mid)]; test_array [0] = 0 ; @@ -12311,7 +14346,7 @@ $ac_includes_default int main () { -static int test_array [1 - 2 * !(((long) (sizeof (off_t))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long) (sizeof (time_t))) <= $ac_mid)]; test_array [0] = 0 ; @@ -12350,10 +14385,10 @@ fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in -?*) ac_cv_sizeof_off_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 +?*) ac_cv_sizeof_time_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (time_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (off_t), 77 +echo "$as_me: error: cannot compute sizeof (time_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac @@ -12372,8 +14407,8 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -long longval () { return (long) (sizeof (off_t)); } -unsigned long ulongval () { return (long) (sizeof (off_t)); } +long longval () { return (long) (sizeof (time_t)); } +unsigned long ulongval () { return (long) (sizeof (time_t)); } #include #include int @@ -12383,17 +14418,17 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); - if (((long) (sizeof (off_t))) < 0) + if (((long) (sizeof (time_t))) < 0) { long i = longval (); - if (i != ((long) (sizeof (off_t)))) + if (i != ((long) (sizeof (time_t)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); - if (i != ((long) (sizeof (off_t)))) + if (i != ((long) (sizeof (time_t)))) exit (1); fprintf (f, "%lu\n", i); } @@ -12414,16 +14449,16 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_off_t=`cat conftest.val` + ac_cv_sizeof_time_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t), 77 +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (time_t), 77 See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute sizeof (off_t), 77 +echo "$as_me: error: cannot compute sizeof (time_t), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -12432,13 +14467,13 @@ fi fi rm -f conftest.val else - ac_cv_sizeof_off_t=0 + ac_cv_sizeof_time_t=0 fi fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 -echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6 +echo "$as_me:$LINENO: result: $ac_cv_sizeof_time_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_time_t" >&6 cat >>confdefs.h <<_ACEOF -#define SIZEOF_OFF_T $ac_cv_sizeof_off_t +#define SIZEOF_TIME_T $ac_cv_sizeof_time_t _ACEOF @@ -12977,7 +15012,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 12980 "configure"' > conftest.$ac_ext + echo '#line 15015 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14083,7 +16118,7 @@ fi # Provide some information about the compiler. -echo "$as_me:14086:" \ +echo "$as_me:16121:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -15185,11 +17220,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15188: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17223: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15192: \$? = $ac_status" >&5 + echo "$as_me:17227: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15447,11 +17482,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15450: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17485: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15454: \$? = $ac_status" >&5 + echo "$as_me:17489: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15509,11 +17544,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15512: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17547: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15516: \$? = $ac_status" >&5 + echo "$as_me:17551: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17757,7 +19792,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:22152: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:20121: \$? = $ac_status" >&5 + echo "$as_me:22156: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -20176,11 +22211,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:20179: $lt_compile\"" >&5) + (eval echo "\"\$as_me:22214: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:20183: \$? = $ac_status" >&5 + echo "$as_me:22218: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21553,7 +23588,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:24574: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:22543: \$? = $ac_status" >&5 + echo "$as_me:24578: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -22598,11 +24633,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:22601: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24636: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:22605: \$? = $ac_status" >&5 + echo "$as_me:24640: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24732,11 +26767,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24735: $lt_compile\"" >&5) + (eval echo "\"\$as_me:26770: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24739: \$? = $ac_status" >&5 + echo "$as_me:26774: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24994,11 +27029,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24997: $lt_compile\"" >&5) + (eval echo "\"\$as_me:27032: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:25001: \$? = $ac_status" >&5 + echo "$as_me:27036: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -25056,11 +27091,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:25059: $lt_compile\"" >&5) + (eval echo "\"\$as_me:27094: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:25063: \$? = $ac_status" >&5 + echo "$as_me:27098: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -27304,7 +29339,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5 -echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 -if test "${ac_cv_type_socklen_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if STDC_HEADERS -#include -#include -#endif -#include -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "(^|[^a-zA-Z_0-9])socklen_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then - ac_cv_type_socklen_t=yes -else - ac_cv_type_socklen_t=no -fi -rm -f conftest* - -fi -echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 -echo "${ECHO_T}$ac_cv_type_socklen_t" >&6 -if test "x$ac_cv_type_socklen_t" = xno; then - -cat >>confdefs.h <<\_ACEOF -#define socklen_t int -_ACEOF - -fi - - echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then @@ -29604,6 +31600,83 @@ fi +echo "$as_me:$LINENO: checking for socklen_t" >&5 +echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 +if test "${ac_cv_type_socklen_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "(^|[^a-zA-Z_0-9])socklen_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + ac_cv_type_socklen_t=yes +else + ac_cv_type_socklen_t=no +fi +rm -f conftest* + +fi +echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 +echo "${ECHO_T}$ac_cv_type_socklen_t" >&6 +if test "x$ac_cv_type_socklen_t" = xno; then + +cat >>confdefs.h <<\_ACEOF +#define socklen_t int +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for sa_family_t" >&5 +echo $ECHO_N "checking for sa_family_t... $ECHO_C" >&6 +if test "${ac_cv_type_sa_family_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "(^|[^a-zA-Z_0-9])sa_family_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + ac_cv_type_sa_family_t=yes +else + ac_cv_type_sa_family_t=no +fi +rm -f conftest* + +fi +echo "$as_me:$LINENO: result: $ac_cv_type_sa_family_t" >&5 +echo "${ECHO_T}$ac_cv_type_sa_family_t" >&6 +if test "x$ac_cv_type_sa_family_t" = xno; then + +cat >>confdefs.h <<\_ACEOF +#define sa_family_t unsigned short +_ACEOF + +fi + + + + @@ -30513,6 +32586,9 @@ fi + + + @@ -30531,8 +32607,10 @@ for ac_header in \ grp.h \ history.h \ libc.h \ + libgen.h \ limits.h \ linux/zftape.h \ + math.h \ mntent.h \ mnttab.h \ ndbm.h \ @@ -30543,6 +32621,7 @@ for ac_header in \ readline/readline.h \ scsi/sg.h \ scsi/scsi_ioctl.h \ + stdarg.h \ stdlib.h \ string.h \ strings.h \ @@ -32543,7 +34622,8 @@ fi if test "x$ac_cv_lib_termcap_tgetent" = xyes || test "x$ac_cv_lib_curses_tgetent" = xyes || test "x$ac_cv_lib_ncurses_tgetent" = xyes; then - echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 + +echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6 if test "${ac_cv_lib_readline_readline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -32608,11 +34688,18 @@ fi echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5 echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6 if test $ac_cv_lib_readline_readline = yes; then - READLINE_LIBS="-lreadline"; + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBREADLINE 1 +_ACEOF + + LIBS="-lreadline $LIBS" fi - if test "x$ac_cv_lib_readline_readline" != xyes; then + if test "x$ac_cv_lib_readline_readline" = xyes; then + READLINE_LIBS="-lreadline" + + else { echo "$as_me:$LINENO: WARNING: *** No readline library, no history and command line editing in amrecover!" >&5 echo "$as_me: WARNING: *** No readline library, no history and command line editing in amrecover!" >&2;} fi @@ -34871,18 +36958,522 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF - ice_have_atof=yes + ice_have_atof=yes +fi +done + +if test "${ice_have_atof}" = yes; then +echo "$as_me:$LINENO: checking for atof declaration in stdlib.h" >&5 +echo $ECHO_N "checking for atof declaration in stdlib.h... $ECHO_C" >&6 +if test "${ice_cv_have_atof_decl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +ice_cv_have_atof_decl=no +ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' +ice_re_word='(^|[^a-zA-Z0-9_])' +for header in stdlib.h; do +# Check for ordinary declaration +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}atof[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_atof_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_atof_decl" = yes; then + break +fi +# Check for "fixed" declaration like "getpid _PARAMS((int))" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}atof[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_atof_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_atof_decl" = yes; then + break +fi +done + +fi + +echo "$as_me:$LINENO: result: $ice_cv_have_atof_decl" >&5 +echo "${ECHO_T}$ice_cv_have_atof_decl" >&6 +if test "$ice_cv_have_atof_decl" = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_ATOF_DECL 1 +_ACEOF + +fi +fi + + +ice_have_atoi=no + +for ac_func in atoi +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* 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 (); +/* 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 +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + ice_have_atoi=yes +fi +done + +if test "${ice_have_atoi}" = yes; then +echo "$as_me:$LINENO: checking for atoi declaration in stdlib.h" >&5 +echo $ECHO_N "checking for atoi declaration in stdlib.h... $ECHO_C" >&6 +if test "${ice_cv_have_atoi_decl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +ice_cv_have_atoi_decl=no +ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' +ice_re_word='(^|[^a-zA-Z0-9_])' +for header in stdlib.h; do +# Check for ordinary declaration +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}atoi[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_atoi_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_atoi_decl" = yes; then + break +fi +# Check for "fixed" declaration like "getpid _PARAMS((int))" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}atoi[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_atoi_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_atoi_decl" = yes; then + break +fi +done + +fi + +echo "$as_me:$LINENO: result: $ice_cv_have_atoi_decl" >&5 +echo "${ECHO_T}$ice_cv_have_atoi_decl" >&6 +if test "$ice_cv_have_atoi_decl" = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_ATOI_DECL 1 +_ACEOF + +fi +fi + + +ice_have_atol=no + +for ac_func in atol +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* 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 (); +/* 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 +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + ice_have_atol=yes +fi +done + +if test "${ice_have_atol}" = yes; then +echo "$as_me:$LINENO: checking for atol declaration in stdlib.h" >&5 +echo $ECHO_N "checking for atol declaration in stdlib.h... $ECHO_C" >&6 +if test "${ice_cv_have_atol_decl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +ice_cv_have_atol_decl=no +ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' +ice_re_word='(^|[^a-zA-Z0-9_])' +for header in stdlib.h; do +# Check for ordinary declaration +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}atol[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_atol_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_atol_decl" = yes; then + break +fi +# Check for "fixed" declaration like "getpid _PARAMS((int))" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}atol[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_atol_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_atol_decl" = yes; then + break +fi +done + +fi + +echo "$as_me:$LINENO: result: $ice_cv_have_atol_decl" >&5 +echo "${ECHO_T}$ice_cv_have_atol_decl" >&6 +if test "$ice_cv_have_atol_decl" = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_ATOL_DECL 1 +_ACEOF + +fi +fi + + +ice_have_atoll=no + +for ac_func in atoll +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* 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 (); +/* 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 +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + ice_have_atoll=yes fi done -if test "${ice_have_atof}" = yes; then -echo "$as_me:$LINENO: checking for atof declaration in stdlib.h" >&5 -echo $ECHO_N "checking for atof declaration in stdlib.h... $ECHO_C" >&6 -if test "${ice_cv_have_atof_decl+set}" = set; then +if test "${ice_have_atoll}" = yes; then +echo "$as_me:$LINENO: checking for atoll declaration in stdlib.h" >&5 +echo $ECHO_N "checking for atoll declaration in stdlib.h... $ECHO_C" >&6 +if test "${ice_cv_have_atoll_decl+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -ice_cv_have_atof_decl=no +ice_cv_have_atoll_decl=no ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' ice_re_word='(^|[^a-zA-Z0-9_])' for header in stdlib.h; do @@ -34897,12 +37488,12 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}atof[ ]*\(" >/dev/null 2>&1; then - ice_cv_have_atof_decl=yes + $EGREP "${ice_re_word}atoll[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_atoll_decl=yes fi rm -f conftest* -if test "$ice_cv_have_atof_decl" = yes; then +if test "$ice_cv_have_atoll_decl" = yes; then break fi # Check for "fixed" declaration like "getpid _PARAMS((int))" @@ -34916,24 +37507,24 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}atof[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then - ice_cv_have_atof_decl=yes + $EGREP "${ice_re_word}atoll[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_atoll_decl=yes fi rm -f conftest* -if test "$ice_cv_have_atof_decl" = yes; then +if test "$ice_cv_have_atoll_decl" = yes; then break fi done fi -echo "$as_me:$LINENO: result: $ice_cv_have_atof_decl" >&5 -echo "${ECHO_T}$ice_cv_have_atof_decl" >&6 -if test "$ice_cv_have_atof_decl" = yes; then +echo "$as_me:$LINENO: result: $ice_cv_have_atoll_decl" >&5 +echo "${ECHO_T}$ice_cv_have_atoll_decl" >&6 +if test "$ice_cv_have_atoll_decl" = yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_ATOF_DECL 1 +#define HAVE_ATOLL_DECL 1 _ACEOF fi @@ -39353,161 +41944,265 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF - ice_have_gettimeofday=yes -fi -done - -if test "${ice_have_gettimeofday}" = yes; then -echo "$as_me:$LINENO: checking for gettimeofday declaration in time.h sys/time.h" >&5 -echo $ECHO_N "checking for gettimeofday declaration in time.h sys/time.h... $ECHO_C" >&6 -if test "${ice_cv_have_gettimeofday_decl+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - -ice_cv_have_gettimeofday_decl=no -ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' -ice_re_word='(^|[^a-zA-Z0-9_])' -for header in time.h sys/time.h; do -# Check for ordinary declaration -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$header> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}gettimeofday[ ]*\(" >/dev/null 2>&1; then - ice_cv_have_gettimeofday_decl=yes -fi -rm -f conftest* - -if test "$ice_cv_have_gettimeofday_decl" = yes; then - break -fi -# Check for "fixed" declaration like "getpid _PARAMS((int))" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$header> + ice_have_gettimeofday=yes +fi +done + +if test "${ice_have_gettimeofday}" = yes; then +echo "$as_me:$LINENO: checking for gettimeofday declaration in time.h sys/time.h" >&5 +echo $ECHO_N "checking for gettimeofday declaration in time.h sys/time.h... $ECHO_C" >&6 +if test "${ice_cv_have_gettimeofday_decl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +ice_cv_have_gettimeofday_decl=no +ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' +ice_re_word='(^|[^a-zA-Z0-9_])' +for header in time.h sys/time.h; do +# Check for ordinary declaration +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}gettimeofday[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_gettimeofday_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_gettimeofday_decl" = yes; then + break +fi +# Check for "fixed" declaration like "getpid _PARAMS((int))" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}gettimeofday[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_gettimeofday_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_gettimeofday_decl" = yes; then + break +fi +done + +fi + +echo "$as_me:$LINENO: result: $ice_cv_have_gettimeofday_decl" >&5 +echo "${ECHO_T}$ice_cv_have_gettimeofday_decl" >&6 +if test "$ice_cv_have_gettimeofday_decl" = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_GETTIMEOFDAY_DECL 1 +_ACEOF + +fi +fi + + + + echo "$as_me:$LINENO: checking for gettimeofday number of arguments" >&5 +echo $ECHO_N "checking for gettimeofday number of arguments... $ECHO_C" >&6 +if test "${amanda_cv_gettimeofday_args+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +int +main () +{ + + struct timeval val; + struct timezone zone; + gettimeofday(&val, &zone); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + amanda_cv_gettimeofday_args=2 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +amanda_cv_gettimeofday_args=1 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +echo "$as_me:$LINENO: result: $amanda_cv_gettimeofday_args" >&5 +echo "${ECHO_T}$amanda_cv_gettimeofday_args" >&6 + if test "$amanda_cv_gettimeofday_args" = 2; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_TWO_ARG_GETTIMEOFDAY 1 +_ACEOF + + fi + + + + + +for ac_func in getvfsent initgroups isascii +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* 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 (); +/* 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 +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}gettimeofday[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then - ice_cv_have_gettimeofday_decl=yes -fi -rm -f conftest* - -if test "$ice_cv_have_gettimeofday_decl" = yes; then - break fi done -fi - -echo "$as_me:$LINENO: result: $ice_cv_have_gettimeofday_decl" >&5 -echo "${ECHO_T}$ice_cv_have_gettimeofday_decl" >&6 -if test "$ice_cv_have_gettimeofday_decl" = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_GETTIMEOFDAY_DECL 1 -_ACEOF - -fi -fi - - - - echo "$as_me:$LINENO: checking for gettimeofday number of arguments" >&5 -echo $ECHO_N "checking for gettimeofday number of arguments... $ECHO_C" >&6 -if test "${amanda_cv_gettimeofday_args+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -int -main () -{ - - struct timeval val; - struct timezone zone; - gettimeofday(&val, &zone); - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - amanda_cv_gettimeofday_args=2 -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -amanda_cv_gettimeofday_args=1 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - - -fi -echo "$as_me:$LINENO: result: $amanda_cv_gettimeofday_args" >&5 -echo "${ECHO_T}$amanda_cv_gettimeofday_args" >&6 - if test "$amanda_cv_gettimeofday_args" = 2; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_TWO_ARG_GETTIMEOFDAY 1 -_ACEOF - - fi - - - +ice_have_initgroups=no -for ac_func in getvfsent initgroups isascii +for ac_func in initgroups do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -39604,14 +42299,78 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF + ice_have_initgroups=yes +fi +done + +if test "${ice_have_initgroups}" = yes; then +echo "$as_me:$LINENO: checking for initgroups declaration in grp.h sys/types.h unistd.h libc.h" >&5 +echo $ECHO_N "checking for initgroups declaration in grp.h sys/types.h unistd.h libc.h... $ECHO_C" >&6 +if test "${ice_cv_have_initgroups_decl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +ice_cv_have_initgroups_decl=no +ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' +ice_re_word='(^|[^a-zA-Z0-9_])' +for header in grp.h sys/types.h unistd.h libc.h; do +# Check for ordinary declaration +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}initgroups[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_initgroups_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_initgroups_decl" = yes; then + break +fi +# Check for "fixed" declaration like "getpid _PARAMS((int))" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$header> +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "${ice_re_word}initgroups[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_initgroups_decl=yes +fi +rm -f conftest* + +if test "$ice_cv_have_initgroups_decl" = yes; then + break fi done +fi -ice_have_initgroups=no +echo "$as_me:$LINENO: result: $ice_cv_have_initgroups_decl" >&5 +echo "${ECHO_T}$ice_cv_have_initgroups_decl" >&6 +if test "$ice_cv_have_initgroups_decl" = yes; then -for ac_func in initgroups +cat >>confdefs.h <<_ACEOF +#define HAVE_INITGROUPS_DECL 1 +_ACEOF + +fi +fi + + +ice_have_ioctl=no + +for ac_func in ioctl do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -39708,21 +42467,21 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF - ice_have_initgroups=yes + ice_have_ioctl=yes fi done -if test "${ice_have_initgroups}" = yes; then -echo "$as_me:$LINENO: checking for initgroups declaration in grp.h sys/types.h unistd.h libc.h" >&5 -echo $ECHO_N "checking for initgroups declaration in grp.h sys/types.h unistd.h libc.h... $ECHO_C" >&6 -if test "${ice_cv_have_initgroups_decl+set}" = set; then +if test "${ice_have_ioctl}" = yes; then +echo "$as_me:$LINENO: checking for ioctl declaration in sys/ioctl.h unistd.h libc.h" >&5 +echo $ECHO_N "checking for ioctl declaration in sys/ioctl.h unistd.h libc.h... $ECHO_C" >&6 +if test "${ice_cv_have_ioctl_decl+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -ice_cv_have_initgroups_decl=no +ice_cv_have_ioctl_decl=no ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' ice_re_word='(^|[^a-zA-Z0-9_])' -for header in grp.h sys/types.h unistd.h libc.h; do +for header in sys/ioctl.h unistd.h libc.h; do # Check for ordinary declaration cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -39734,12 +42493,12 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}initgroups[ ]*\(" >/dev/null 2>&1; then - ice_cv_have_initgroups_decl=yes + $EGREP "${ice_re_word}ioctl[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_ioctl_decl=yes fi rm -f conftest* -if test "$ice_cv_have_initgroups_decl" = yes; then +if test "$ice_cv_have_ioctl_decl" = yes; then break fi # Check for "fixed" declaration like "getpid _PARAMS((int))" @@ -39753,33 +42512,33 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}initgroups[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then - ice_cv_have_initgroups_decl=yes + $EGREP "${ice_re_word}ioctl[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_ioctl_decl=yes fi rm -f conftest* -if test "$ice_cv_have_initgroups_decl" = yes; then +if test "$ice_cv_have_ioctl_decl" = yes; then break fi done fi -echo "$as_me:$LINENO: result: $ice_cv_have_initgroups_decl" >&5 -echo "${ECHO_T}$ice_cv_have_initgroups_decl" >&6 -if test "$ice_cv_have_initgroups_decl" = yes; then +echo "$as_me:$LINENO: result: $ice_cv_have_ioctl_decl" >&5 +echo "${ECHO_T}$ice_cv_have_ioctl_decl" >&6 +if test "$ice_cv_have_ioctl_decl" = yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_INITGROUPS_DECL 1 +#define HAVE_IOCTL_DECL 1 _ACEOF fi fi -ice_have_ioctl=no +ice_have_isnormal=no -for ac_func in ioctl +for ac_func in isnormal do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -39876,21 +42635,21 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF - ice_have_ioctl=yes + ice_have_isnormal=yes fi done -if test "${ice_have_ioctl}" = yes; then -echo "$as_me:$LINENO: checking for ioctl declaration in sys/ioctl.h unistd.h libc.h" >&5 -echo $ECHO_N "checking for ioctl declaration in sys/ioctl.h unistd.h libc.h... $ECHO_C" >&6 -if test "${ice_cv_have_ioctl_decl+set}" = set; then +if test "${ice_have_isnormal}" = yes; then +echo "$as_me:$LINENO: checking for isnormal declaration in math.h" >&5 +echo $ECHO_N "checking for isnormal declaration in math.h... $ECHO_C" >&6 +if test "${ice_cv_have_isnormal_decl+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else -ice_cv_have_ioctl_decl=no +ice_cv_have_isnormal_decl=no ice_re_params='[a-zA-Z_][a-zA-Z0-9_]*' ice_re_word='(^|[^a-zA-Z0-9_])' -for header in sys/ioctl.h unistd.h libc.h; do +for header in math.h; do # Check for ordinary declaration cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -39902,12 +42661,12 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}ioctl[ ]*\(" >/dev/null 2>&1; then - ice_cv_have_ioctl_decl=yes + $EGREP "${ice_re_word}isnormal[ ]*\(" >/dev/null 2>&1; then + ice_cv_have_isnormal_decl=yes fi rm -f conftest* -if test "$ice_cv_have_ioctl_decl" = yes; then +if test "$ice_cv_have_isnormal_decl" = yes; then break fi # Check for "fixed" declaration like "getpid _PARAMS((int))" @@ -39921,24 +42680,24 @@ cat >>conftest.$ac_ext <<_ACEOF _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "${ice_re_word}ioctl[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then - ice_cv_have_ioctl_decl=yes + $EGREP "${ice_re_word}isnormal[ ]*$ice_re_params\(\(" >/dev/null 2>&1; then + ice_cv_have_isnormal_decl=yes fi rm -f conftest* -if test "$ice_cv_have_ioctl_decl" = yes; then +if test "$ice_cv_have_isnormal_decl" = yes; then break fi done fi -echo "$as_me:$LINENO: result: $ice_cv_have_ioctl_decl" >&5 -echo "${ECHO_T}$ice_cv_have_ioctl_decl" >&6 -if test "$ice_cv_have_ioctl_decl" = yes; then +echo "$as_me:$LINENO: result: $ice_cv_have_isnormal_decl" >&5 +echo "${ECHO_T}$ice_cv_have_isnormal_decl" >&6 +if test "$ice_cv_have_isnormal_decl" = yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_IOCTL_DECL 1 +#define HAVE_ISNORMAL_DECL 1 _ACEOF fi @@ -51986,370 +54745,6 @@ fi done -# Check whether --enable-largefile or --disable-largefile was given. -if test "${enable_largefile+set}" = set; then - enableval="$enable_largefile" - -fi; -if test "$enable_largefile" != no; then - - echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 -echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_largefile_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - ac_save_CC=$CC - while :; do - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext - CC="$CC -n32" - rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sys_largefile_CC=' -n32'; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext - break - done - CC=$ac_save_CC - rm -f conftest.$ac_ext - fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 -echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 - if test "$ac_cv_sys_largefile_CC" != no; then - CC=$CC$ac_cv_sys_largefile_CC - fi - - echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_file_offset_bits+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - while :; do - ac_cv_sys_file_offset_bits=no - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#define _FILE_OFFSET_BITS 64 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sys_file_offset_bits=64; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - break -done -fi -echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 -echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 -if test "$ac_cv_sys_file_offset_bits" != no; then - -cat >>confdefs.h <<_ACEOF -#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits -_ACEOF - -fi -rm -f conftest* - echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 -echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 -if test "${ac_cv_sys_large_files+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - while :; do - ac_cv_sys_large_files=no - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#define _LARGE_FILES 1 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sys_large_files=1; break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - break -done -fi -echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 -echo "${ECHO_T}$ac_cv_sys_large_files" >&6 -if test "$ac_cv_sys_large_files" != no; then - -cat >>confdefs.h <<_ACEOF -#define _LARGE_FILES $ac_cv_sys_large_files -_ACEOF - -fi -rm -f conftest* -fi - echo "$as_me:$LINENO: checking disk device prefixes" >&5 echo $ECHO_N "checking disk device prefixes... $ECHO_C" >&6 @@ -52864,31 +55259,28 @@ DOC_BUILD_DATE=`date '+%d-%m-%Y'` -# Check whether --with-xsltproc or --without-xsltproc was given. -if test "${with_xsltproc+set}" = set; then - withval="$with_xsltproc" - case "$withval" in - y | ye | yes) - USE_XSLTPROC=yes;; - n | no) - USE_XSLTPROC=no;; - *) - USE_XSLTPROC=yes; - XSLTPROC="$withval";; - esac - +# Check whether --with-built-manpages or --without-built-manpages was given. +if test "${with_built_manpages+set}" = set; then + withval="$with_built_manpages" + BUILDMANPAGES=$withval; else - USE_XSLTPROC=maybe; + BUILDMANPAGES=yes; fi; +if test "x$BUILDMANPAGES" = "xyes"; then + BUILD_MAN_PAGES_TRUE= + BUILD_MAN_PAGES_FALSE='#' +else + BUILD_MAN_PAGES_TRUE='#' + BUILD_MAN_PAGES_FALSE= +fi -# This looks bad, but && and || have equal precedence in shells, so -# actually it's all OK. -if test "$USE_XSLTPROC" = "yes" || test "$USE_XSLTPROC" = "maybe" && \ - test -z "$XSLTPROC"; then - # Extract the first word of "xsltproc", so it can be a program name with args. -set dummy xsltproc; ac_word=$2 + +for ac_prog in xsltproc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_XSLTPROC+set}" = set; then @@ -52900,7 +55292,7 @@ else ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +for as_dir in $LOCSYSPATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. @@ -52926,22 +55318,24 @@ else echo "${ECHO_T}no" >&6 fi - if test -n "$XSLTPROC"; then - USE_XSLTPROC=yes; - else - if test "$USE_XSLTPROC" = yes; then - { { echo "$as_me:$LINENO: error: can't find xsltproc, but running with --with-xsltproc." >&5 -echo "$as_me: error: can't find xsltproc, but running with --with-xsltproc." >&2;} - { (exit 1); exit 1; }; } - else - USE_XSLTPROC=no; - fi - fi -fi + test -n "$XSLTPROC" && break +done + +if test -z "$XSLTPROC"; then + USE_XSLTPROC=no + { echo "$as_me:$LINENO: WARNING: can't find xsltproc, xsltproc support is unavailable" >&5 +echo "$as_me: WARNING: can't find xsltproc, xsltproc support is unavailable" >&2;} +else + USE_XSLTPROC=yes +cat >>confdefs.h <<\_ACEOF +#define HAVE_XSLTPROC 1 +_ACEOF +fi -if test "$USE_XSLTPROC" = yes; then + +if test "x$USE_XSLTPROC" = "xyes"; then HAVE_XSLTPROC_TRUE= HAVE_XSLTPROC_FALSE='#' else @@ -52950,7 +55344,71 @@ else fi - ac_config_files="$ac_config_files amplot/amcat.awk amplot/amplot.sh amplot/Makefile changer-src/chg-manual.sh changer-src/chg-multi.sh changer-src/chg-mtx.sh changer-src/chg-chs.sh changer-src/chg-rth.pl changer-src/chg-chio.pl changer-src/chg-zd-mtx.sh changer-src/Makefile changer-src/chg-juke.sh changer-src/chg-rait.sh changer-src/chg-null.sh changer-src/chg-mcutil.sh changer-src/chg-disk.sh changer-src/chg-iomega.pl client-src/patch-system.sh client-src/Makefile dumper-src/gnutar.pl dumper-src/generic-dumper.pl dumper-src/Makefile common-src/versuff.c common-src/Makefile example/amanda.conf example/Makefile example/chg-mcutil.conf man/Makefile docs/Makefile recover-src/Makefile restore-src/Makefile server-src/amcheckdb.sh server-src/amcleanup.sh server-src/amdump.sh server-src/amfreetapes.sh server-src/amoverview.pl server-src/amrmtape.sh server-src/amtoc.pl server-src/amverify.sh server-src/Makefile server-src/amstatus.pl server-src/amverifyrun.sh server-src/amcrypt.sh server-src/amaespipe.sh tape-src/Makefile config/Makefile Makefile" +#### Enforce amanda code cleanliness rules. +#### Done here to allow configuration code to remain intact. +if test "x$CC" = "xgcc"; then + AM_CFLAGS="$AM_CFLAGS -Wall" + $CC -v --help 2>&1 | $GREP -- '-Wextra ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wextra" + else + AM_CFLAGS="$AM_CFLAGS -W" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wparentheses' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wparentheses" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wdeclaration-after-statement' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wdeclaration-after-statement" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wmissing-prototypes ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wmissing-prototypes" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wstrict-prototypes ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wmissing-declarations ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wmissing-declarations" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wformat' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wformat" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wsign-compare' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wsign-compare" + fi + + $CC -v --help 2>&1 | $GREP -- '-fno-strict-aliasing' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -fno-strict-aliasing" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wfloat-equal' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wfloat-equal" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wold-style-definition' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wold-style-definition" + fi +fi + + + ac_config_files="$ac_config_files amplot/amcat.awk amplot/amplot.sh amplot/Makefile amandad-src/Makefile changer-src/chg-manual.sh changer-src/chg-multi.sh changer-src/chg-mtx.sh changer-src/chg-chs.sh changer-src/chg-rth.pl changer-src/chg-chio.pl changer-src/chg-zd-mtx.sh changer-src/Makefile changer-src/chg-juke.sh changer-src/chg-rait.sh changer-src/chg-null.sh changer-src/chg-mcutil.sh changer-src/chg-disk.sh changer-src/chg-iomega.pl client-src/patch-system.sh client-src/Makefile dumper-src/gnutar.pl dumper-src/generic-dumper.pl dumper-src/Makefile common-src/versuff.c common-src/Makefile example/amanda.conf example/Makefile example/chg-mcutil.conf example/amanda-client.conf man/Makefile docs/Makefile recover-src/Makefile oldrecover-src/Makefile restore-src/Makefile server-src/amcheckdb.sh server-src/amcleanup.sh server-src/amdump.sh server-src/amfreetapes.sh server-src/amoverview.pl server-src/amrmtape.sh server-src/amtoc.pl server-src/amverify.sh server-src/Makefile server-src/amstatus.pl server-src/amverifyrun.sh server-src/amcrypt.sh server-src/amaespipe.sh server-src/amcrypt-ossl.sh server-src/amcrypt-ossl-asym.sh tape-src/Makefile config/Makefile Makefile" + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -53148,6 +55606,13 @@ echo "$as_me: error: conditional \"WANT_SSH_SECURITY\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${BUILD_MAN_PAGES_TRUE}" && test -z "${BUILD_MAN_PAGES_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"BUILD_MAN_PAGES\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"BUILD_MAN_PAGES\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${HAVE_XSLTPROC_TRUE}" && test -z "${HAVE_XSLTPROC_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"HAVE_XSLTPROC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -53620,6 +56085,7 @@ do "amplot/amcat.awk" ) CONFIG_FILES="$CONFIG_FILES amplot/amcat.awk" ;; "amplot/amplot.sh" ) CONFIG_FILES="$CONFIG_FILES amplot/amplot.sh" ;; "amplot/Makefile" ) CONFIG_FILES="$CONFIG_FILES amplot/Makefile" ;; + "amandad-src/Makefile" ) CONFIG_FILES="$CONFIG_FILES amandad-src/Makefile" ;; "changer-src/chg-manual.sh" ) CONFIG_FILES="$CONFIG_FILES changer-src/chg-manual.sh" ;; "changer-src/chg-multi.sh" ) CONFIG_FILES="$CONFIG_FILES changer-src/chg-multi.sh" ;; "changer-src/chg-mtx.sh" ) CONFIG_FILES="$CONFIG_FILES changer-src/chg-mtx.sh" ;; @@ -53644,9 +56110,11 @@ do "example/amanda.conf" ) CONFIG_FILES="$CONFIG_FILES example/amanda.conf" ;; "example/Makefile" ) CONFIG_FILES="$CONFIG_FILES example/Makefile" ;; "example/chg-mcutil.conf" ) CONFIG_FILES="$CONFIG_FILES example/chg-mcutil.conf" ;; + "example/amanda-client.conf" ) CONFIG_FILES="$CONFIG_FILES example/amanda-client.conf" ;; "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "docs/Makefile" ) CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;; "recover-src/Makefile" ) CONFIG_FILES="$CONFIG_FILES recover-src/Makefile" ;; + "oldrecover-src/Makefile" ) CONFIG_FILES="$CONFIG_FILES oldrecover-src/Makefile" ;; "restore-src/Makefile" ) CONFIG_FILES="$CONFIG_FILES restore-src/Makefile" ;; "server-src/amcheckdb.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amcheckdb.sh" ;; "server-src/amcleanup.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amcleanup.sh" ;; @@ -53661,6 +56129,8 @@ do "server-src/amverifyrun.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amverifyrun.sh" ;; "server-src/amcrypt.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amcrypt.sh" ;; "server-src/amaespipe.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amaespipe.sh" ;; + "server-src/amcrypt-ossl.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amcrypt-ossl.sh" ;; + "server-src/amcrypt-ossl-asym.sh" ) CONFIG_FILES="$CONFIG_FILES server-src/amcrypt-ossl-asym.sh" ;; "tape-src/Makefile" ) CONFIG_FILES="$CONFIG_FILES tape-src/Makefile" ;; "config/Makefile" ) CONFIG_FILES="$CONFIG_FILES config/Makefile" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; @@ -53793,6 +56263,26 @@ s,@VERSION_MINOR@,$VERSION_MINOR,;t t s,@VERSION_PATCH@,$VERSION_PATCH,;t t s,@VERSION_COMMENT@,$VERSION_COMMENT,;t t s,@VERSION_SUFFIX@,$VERSION_SUFFIX,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@GREP@,$GREP,;t t +s,@EGREP@,$EGREP,;t t +s,@AMLINT@,$AMLINT,;t t +s,@AMLINTFLAGS@,$AMLINTFLAGS,;t t s,@DUMPER_DIR@,$DUMPER_DIR,;t t s,@CONFIG_DIR@,$CONFIG_DIR,;t t s,@USE_VERSION_SUFFIXES@,$USE_VERSION_SUFFIXES,;t t @@ -53813,25 +56303,8 @@ s,@AMANDA_TMPDIR@,$AMANDA_TMPDIR,;t t s,@AMANDA_DBGDIR@,$AMANDA_DBGDIR,;t t s,@AMANDA_DEBUG_DAYS@,$AMANDA_DEBUG_DAYS,;t t s,@SERVICE_SUFFIX@,$SERVICE_SUFFIX,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@DEPDIR@,$DEPDIR,;t t -s,@am__include@,$am__include,;t t -s,@am__quote@,$am__quote,;t t -s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t -s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t -s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t -s,@CCDEPMODE@,$CCDEPMODE,;t t -s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t -s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t s,@MT_FILE_FLAG@,$MT_FILE_FLAG,;t t s,@CPP@,$CPP,;t t -s,@EGREP@,$EGREP,;t t s,@AR@,$AR,;t t s,@AWK_VAR_ASSIGNMENT_OPT@,$AWK_VAR_ASSIGNMENT_OPT,;t t s,@YACC@,$YACC,;t t @@ -53840,7 +56313,6 @@ s,@COMPRESS@,$COMPRESS,;t t s,@DD@,$DD,;t t s,@GETCONF@,$GETCONF,;t t s,@GNUPLOT@,$GNUPLOT,;t t -s,@GREP@,$GREP,;t t s,@GNUTAR@,$GNUTAR,;t t s,@SAMBA_CLIENT@,$SAMBA_CLIENT,;t t s,@GZIP@,$GZIP,;t t @@ -53919,9 +56391,12 @@ s,@WANT_SSH_SECURITY_FALSE@,$WANT_SSH_SECURITY_FALSE,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t s,@LTALLOCA@,$LTALLOCA,;t t s,@DOC_BUILD_DATE@,$DOC_BUILD_DATE,;t t +s,@BUILD_MAN_PAGES_TRUE@,$BUILD_MAN_PAGES_TRUE,;t t +s,@BUILD_MAN_PAGES_FALSE@,$BUILD_MAN_PAGES_FALSE,;t t s,@XSLTPROC@,$XSLTPROC,;t t s,@HAVE_XSLTPROC_TRUE@,$HAVE_XSLTPROC_TRUE,;t t s,@HAVE_XSLTPROC_FALSE@,$HAVE_XSLTPROC_FALSE,;t t +s,@AM_CFLAGS@,$AM_CFLAGS,;t t CEOF _ACEOF diff --git a/configure.in b/configure.in index 2128f16..3330438 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,3 @@ -dnl Process this file with autoconf to produce a configure script. AC_INIT AC_CONFIG_SRCDIR([common-src/amanda.h]) @@ -14,7 +13,7 @@ AC_DEFINE_UNQUOTED(CONFIGURE_COMMAND,"$CONFIGURE_COMMAND", [Saves the original ./configure command line arguments]) AC_SUBST(CONFIGURE_COMMAND) -AM_INIT_AUTOMAKE(amanda, 2.5.0p2) +AM_INIT_AUTOMAKE(amanda, 2.5.1) AM_CONFIG_HEADER(config/config.h) AC_PREREQ(2.57) dnl Minimum Autoconf version required. @@ -55,9 +54,9 @@ AC_SUBST(VERSION_COMMENT) AC_SUBST(VERSION_SUFFIX) dnl -dnl runtime and compile time +dnl runtime and compile time paths dnl -SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bsd:/etc:/usr/etc" +SYSPATH="/bin:/usr/bin:/sbin:/usr/sbin:/opt/SUNWspro/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc" LOCPATH=`( test "x$prefix" = xNONE && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix=${prefix} @@ -66,17 +65,107 @@ LOCPATH=`( SYSLOCPATH="$SYSPATH:$LOCPATH" LOCSYSPATH="$LOCPATH:$SYSPATH" +dnl +dnl Set up compiler location, basic CFLAGS, and include locations +dnl and library locations before we start checking the system +dnl configuration in more detail... +dnl + AC_ARG_WITH(cflags, [ --with-cflags=CFLAGS arguments to the c compiler (-Wall, -g, etc)], [ case "$withval" in "" | y | ye | yes | n | no) - AC_MSG_ERROR([*** You must supply an argument to the --with-includes option.]) + AC_MSG_ERROR([*** You must supply an argument to the --with-cflags option.]) ;; esac CFLAGS="$withval" ]) +CFLAGS="-D_GNU_SOURCE $CFLAGS" + +AC_PROG_CC +AC_OBJEXT +AC_EXEEXT +AC_SYS_LARGEFILE + +dnl +dnl Process tool locations for tools we need right away to configure. +dnl +AC_PATH_PROGS(GREP,grep,,$LOCSYSPATH) +if test -z "$GREP"; then + GREP=grep +fi +AC_DEFINE_UNQUOTED(GREP,"$GREP",[Define the location of the grep program. ]) +AC_PATH_PROGS(EGREP,egrep,,$LOCSYSPATH) + +AC_PATH_PROGS(AMLINT,lint,,/opt/SUNWspro/bin:$SYSLOCPATH) +if test ! -z "$AMLINT"; then + $AMLINT -flags | $GREP -- '-errfmt=' 2>&1 > /dev/null + if test $? -eq 0; then + AMLINTFLAGS="-n -s -u -m -x" + AMLINTFLAGS="$AMLINTFLAGS -errchk=%all" + AMLINTFLAGS="$AMLINTFLAGS -errfmt=macro" + AMLINTFLAGS="$AMLINTFLAGS -errhdr=no%/usr/include" + AMLINTFLAGS="$AMLINTFLAGS -errhdr=%user" + AMLINTFLAGS="$AMLINTFLAGS -errsecurity=extended" + AMLINTFLAGS="$AMLINTFLAGS -errtags=yes" + AMLINTFLAGS="$AMLINTFLAGS -Ncheck=%all" + AMLINTFLAGS="$AMLINTFLAGS -Nlevel=2" + AMLINTFLAGS="$AMLINTFLAGS -erroff=E_ASGN_NEVER_USED" + AMLINTFLAGS="$AMLINTFLAGS,E_ASGN_RESET" + AMLINTFLAGS="$AMLINTFLAGS,E_CAST_INT_CONST_TO_SMALL_INT" + AMLINTFLAGS="$AMLINTFLAGS,E_CAST_INT_TO_SMALL_INT" + AMLINTFLAGS="$AMLINTFLAGS,E_CAST_UINT_TO_SIGNED_INT" + AMLINTFLAGS="$AMLINTFLAGS,E_CONSTANT_CONDITION" + AMLINTFLAGS="$AMLINTFLAGS,E_ENUM_UNUSE" + AMLINTFLAGS="$AMLINTFLAGS,E_EXPR_NULL_EFFECT" + AMLINTFLAGS="$AMLINTFLAGS,E_FUNC_RET_ALWAYS_IGNOR" + AMLINTFLAGS="$AMLINTFLAGS,E_FUNC_RET_MAYBE_IGNORED" + AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK0" + AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK1" + AMLINTFLAGS="$AMLINTFLAGS,E_H_C_CHECK2" + AMLINTFLAGS="$AMLINTFLAGS,E_INCL_MNUSD" + AMLINTFLAGS="$AMLINTFLAGS,E_INCL_NUSD" + AMLINTFLAGS="$AMLINTFLAGS,E_MCR_NODIFF" + AMLINTFLAGS="$AMLINTFLAGS,E_NAME_MULTIPLY_DEF" + AMLINTFLAGS="$AMLINTFLAGS,E_P_REF_NULL_PSBL" + AMLINTFLAGS="$AMLINTFLAGS,E_P_REF_SUSP" + AMLINTFLAGS="$AMLINTFLAGS,E_PTRDIFF_OVERFLOW" + AMLINTFLAGS="$AMLINTFLAGS,E_P_USE_NULL_PSBL" + AMLINTFLAGS="$AMLINTFLAGS,E_P_USE_SUSP" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_ACCESS_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CHDIR_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CHMOD_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_CREAT_WITHOUT_EXCL" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_EXEC_PATH" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_EXEC_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_FOPEN_MODE" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_GETENV_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_MKDIR_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_PRINTF_VAR_FMT" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_RAND_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SCANF_VAR_FMT" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SELECT_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_SHELL_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_STRNCPY_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_UMASK_WARN" + AMLINTFLAGS="$AMLINTFLAGS,E_SEC_USE_AFTER_STAT" + AMLINTFLAGS="$AMLINTFLAGS,E_SIGN_EXTENSION_PSBL" + AMLINTFLAGS="$AMLINTFLAGS,E_TYPEDEF_UNUSE" + AMLINTFLAGS="$AMLINTFLAGS,E_UNCAL_F" + else + AMLINTFLAGS="" + fi +else + AC_PATH_PROGS(AMLINT,splint,,$SYSLOCPATH) + if test ! -z "$AMLINT"; then + AMLINT="splint" + fi + AMLINTFLAGS='+show-scan +unixlib -weak -globs +usedef +usereleased +impouts -paramimptemp -varuse -warnposix -redef -preproc -fixedformalarray -retval -unrecog -usevarargs -formatcode' +fi +AC_SUBST(AMLINTFLAGS) + AC_ARG_WITH(includes, [ --with-includes=DIR site header files for readline, etc in DIR], [ @@ -124,6 +213,10 @@ if test "$LIBRARY_DIRS"; then done fi +dnl +dnl Process configuration flags +dnl + AC_ARG_WITH(dumperdir, [ --with-dumperdir=DIR where we install the dumpers [[EPREFIX/dumper]]], [ @@ -474,8 +567,8 @@ AC_ARG_WITH(tape-device, dnl bytes are returned upon reading to the next tape mark, dnl instead of returning an error. Look for devices that have dnl a 'b' in their name. - tape_dev=null: - nr_tape_dev=null: + tape_dev= + nr_tape_dev= if test -d /dev/rmt; then dnl See if we can find two devices, one being the norewind @@ -509,13 +602,11 @@ AC_ARG_WITH(tape-device, ] ) -if test -z "$DEFAULT_TAPE_DEVICE"; then - DEFAULT_TAPE_DEVICE=/dev/null +if test ! -z "$DEFAULT_TAPE_DEVICE"; then + AC_DEFINE_UNQUOTED(DEFAULT_TAPE_DEVICE,"$DEFAULT_TAPE_DEVICE",[This is the default no-rewinding tape device. ]) + AC_SUBST(DEFAULT_TAPE_DEVICE) fi -AC_DEFINE_UNQUOTED(DEFAULT_TAPE_DEVICE,"$DEFAULT_TAPE_DEVICE",[This is the default no-rewinding tape device. ]) -AC_SUBST(DEFAULT_TAPE_DEVICE) - AC_ARG_WITH(ftape-raw-device, [ --with-ftape-rawdevice=ARG raw device on tape server HOST's if using Linux ftape >=3.04d], [ @@ -617,6 +708,29 @@ y | ye | yes) AC_DEFINE(HAVE_BROKEN_FSF,1,[Define this if issuing a fsf on a ta ;; esac +AC_ARG_WITH(reuseports, + [ --without-reuseaddr Don't closed network connections to be reused until full timeout period.], + [ case "$withval" in + y | ye | yes) + REUSEADDR=no;; + n | no) + REUSEADDR=yes;; + *) + REUSEADDR=no;; + esac + ], + [ REUSEADDR=yes; ]) +case "$REUSEADDR" in +n | no) : + ;; +y | ye | yes) + AC_DEFINE(USE_REUSEADDR,1,[Define to set SO_REUSEADDR on network connections.]) + ;; +*) + AC_MSG_ERROR([*** You must not supply an argument to --with-reuseports option.]) + ;; +esac + AC_ARG_WITH(gnutar, [ --with-gnutar[[=PROG]] use PROG as GNU tar executable [[default: looks for one]]], [ @@ -723,8 +837,15 @@ n | no) DBMALLOCLIBS="" ;; *) - DBMALLOCCFLAGS="-I$DBMALLOC -DUSE_DBMALLOC" - DBMALLOCLIBS="-L$DBMALLOC -ldbmalloc" + AC_CHECK_LIB(dbmalloc,malloc) + if test "x$ac_cv_lib_dbmalloc_malloc" != "xyes"; then + AC_MSG_WARN([*** dbmalloc library not found - no malloc debugging support!]) + DBMALLOCCFLAGS="" + DBMALLOCLIBS="" + else + DBMALLOCCFLAGS="-I$DBMALLOC -DUSE_DBMALLOC" + DBMALLOCLIBS="-L$DBMALLOC -ldbmalloc" + fi ;; esac @@ -827,6 +948,34 @@ y | ye | yes) AC_DEFINE(SSH_SECURITY,1,[Define if SSH transport should be enabl ;; esac +AC_ARG_WITH(bsdtcp-security, + [ --with-bsdtcp-security use tcp as a transport], + BSDTCP_SECURITY=$withval, + : ${BSDTCP_SECURITY=yes} +) +case "$BSDTCP_SECURITY" in +n | no) : ;; +y | ye | yes) AC_DEFINE(BSDTCP_SECURITY,1,[Define if BSDTCP transport should be enabled. ]) + BSDTCP_SECURITY_SET=true + ;; +*) AC_MSG_ERROR([*** You must not supply an argument the to --with-bsdtcp-security option.]) + ;; +esac + +AC_ARG_WITH(bsdudp-security, + [ --with-bsdudp-security use tcp as a transport], + BSDUDP_SECURITY=$withval, + : ${BSDUDP_SECURITY=yes} +) +case "$BSDUDP_SECURITY" in +n | no) : ;; +y | ye | yes) AC_DEFINE(BSDUDP_SECURITY,1,[Define if BSDUDP transport should be enabled. ]) + BSDUDP_SECURITY_SET=true + ;; +*) AC_MSG_ERROR([*** You must not supply an argument the to --with-bsdudp-security option.]) + ;; +esac + AC_ARG_WITH(server-principal, [ --with-server-principal=ARG server host principal [["amanda"]]], [ @@ -968,17 +1117,23 @@ AC_MSG_CHECKING(for Kerberos V) KRB5_DIR_FOUND="" KRB5_CFLAGS="" for dir in $KRB5_SPOTS; do - k5libdir=${dir}/lib + for lib in lib lib64; do + k5libdir=${dir}/${lib} if test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libgssapi_krb5.a -a -f ${k5libdir}/libcom_err.a; then - if test -f ${k5libdir}/libcrypto.a; then - K5CRYPTO=${k5libdir}/libcrypto.a - elif test -f ${k5libdir}/libk5crypto.a; then + if test -f ${k5libdir}/libk5crypto.a; then K5CRYPTO=${k5libdir}/libk5crypto.a + elif test -f ${k5libdir}/libcrypto.a; then + K5CRYPTO=${k5libdir}/libcrypto.a else K5CRYPTO="" fi + if test -f ${k5libdir}/libkrb5support.a; then + K5SUPPORT=${k5libdir}/libkrb5support.a + else + K5SUPPORT="" + fi KRB5_DIR_FOUND=$dir - KRB5LIBS="${k5libdir}/libgssapi_krb5.a ${k5libdir}/libkrb5.a $K5CRYPTO ${k5libdir}/libcom_err.a" + KRB5LIBS="${k5libdir}/libgssapi_krb5.a ${k5libdir}/libkrb5.a $K5CRYPTO $K5SUPPORT ${k5libdir}/libcom_err.a" KRB5CFLAGS="" break elif test -f ${k5libdir}/libkrb5.a -a -f ${k5libdir}/libasn1.a -a -f ${k5libdir}/libgssapi.a; then @@ -987,6 +1142,7 @@ for dir in $KRB5_SPOTS; do KRB5_CFLAGS="-DKRB5_HEIMDAL_INCLUDES" break fi + done done if test "$KRB5_DIR_FOUND"; then @@ -1007,6 +1163,7 @@ if test "$KRB5_DIR_FOUND"; then if test "$KRB5_CFLAGS" ; then KRB5INCLUDES="$KRB5INCLUDES $KRB5_CFLAGS" fi + AC_CHECK_LIB(krb5support,main) KRB5LDFLAGS=-L$k5libdir break fi @@ -1016,12 +1173,32 @@ if test "x$KRB5LDFLAGS" = "x" ; then fi -AC_ARG_WITH(portrange, - [ --with-portrange=low,high bind unreserved TCP server sockets to ports within this range [[unlimited]]], +AC_ARG_WITH(low-tcpportrange, + [ --with-low-tcpportrange=low,high bind reserved TCP server sockets to ports within this range [unlimited] (mainly for amrecover)], [ - TCPPORTRANGE="$withval" + LOW_TCPPORTRANGE="$withval" ] ) + +if test x"${LOW_TCPPORTRANGE+set}" = x"set"; then + if test x`echo "$LOW_TCPPORTRANGE" | sed 's/[[0-9]][[0-9]]*,[[0-9]][[0-9]]*//'` != x""; then + AC_MSG_ERROR([*** --with-low-tcpportrange requires two comma-separated positive numbers]) + fi + min_low_tcp_port=`echo "$LOW_TCPPORTRANGE" | sed 's/,.*//'` + max_low_tcp_port=`echo "$LOW_TCPPORTRANGE" | sed 's/.*,//'` + if test $min_low_tcp_port -gt $max_low_tcp_port; then + AC_MSG_ERROR([*** the second TCP port number must be greater than the first in --with-low-tcpportrange]) + fi + if test $min_low_tcp_port -lt 512; then + AC_MSG_WARN([*** the low TCP port range should be 512 or greater in --with-low-tcpportrange]) + fi + if test $max_low_tcp_port -ge 1024; then + AC_MSG_WARN([*** the low TCP port range should be less than 1024 in --with-low-tcpportrange]) + fi + AC_DEFINE_UNQUOTED(LOW_TCPPORTRANGE,$LOW_TCPPORTRANGE,[A comma-separated list of two integers, determining the minimum and + maximum reserved TCP port numbers sockets should be bound to. (mainly for amrecover) ]) +fi + AC_ARG_WITH(tcpportrange, [ --with-tcpportrange=low,high bind unreserved TCP server sockets to ports within this range [[unlimited]]], [ @@ -1238,10 +1415,6 @@ AC_DEFINE_UNQUOTED(KAMANDA_SERVICE_NAME, "$KAMANDA_SERVICE_NAME", [The name for AC_DEFINE_UNQUOTED(mandir,"$tmp",[Directory in which man-pages should be installed]) ) -AC_PROG_CC -AC_OBJEXT -AC_EXEEXT - dnl Set the order of dump programs to look for. Finding the proper file dnl system dumping program is problematic. Some systems, notably HP-UX dnl and AIX, have both the backup and dump programs. HP-UX can't use the @@ -1294,6 +1467,8 @@ case "$target" in ;; *-pc-linux-*) ;; + *-redhat-linux-*) + ;; x86_64-*-linux-*) ;; alpha*-*-linux-*) @@ -1407,7 +1582,6 @@ if test -z "$CAT"; then fi AC_PATH_PROGS(COMPRESS,compress,,$LOCSYSPATH) AC_PATH_PROGS(DD,dd,,$LOCSYSPATH) -AC_PATH_PROGS(EGREP,egrep,,$LOCSYSPATH) AC_PATH_PROGS(GETCONF,getconf,,$SYSPATH) AC_PATH_PROGS(GNUPLOT,gnuplot,,$LOCSYSPATH) @@ -1416,12 +1590,6 @@ if test -z "$GNUPLOT"; then AC_MSG_WARN([*** You do not have gnuplot. Amplot will not be installed.]) fi -AC_PATH_PROGS(GREP,grep,,$LOCSYSPATH) -if test -z "$GREP"; then - GREP=grep -fi -AC_DEFINE_UNQUOTED(GREP,"$GREP",[Define the location of the grep program. ]) - AC_PATH_PROGS(GNUTAR,gtar gnutar tar,,$LOCSYSPATH) if test ! -z "$GNUTAR"; then case "`\"$GNUTAR\" --version 2>&1`" in @@ -1755,8 +1923,10 @@ AC_CACHE_CHECK( if test "x$need_resetofs" = xyes; then AC_DEFINE(NEED_RESETOFS,1,[Define if we have to reset tape offsets when reacing 2GB. ]) fi + + CFLAGS="$amanda_cv_LFS_CFLAGS $CFLAGS" -CPPFLAGS="$amanda_cv_LFS_CFLAGS $CPPFLAGS" +CPPFLAGS="$amanda_cv_LFS_CPPFLAGS $CPPFLAGS" LDFLAGS="$amanda_cv_LFS_LDFLAGS $LDFLAGS" LIBS="$amanda_cv_LFS_LIBS $LIBS" @@ -1765,6 +1935,9 @@ AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(intmax_t) AC_CHECK_SIZEOF(off_t) +AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(ssize_t) +AC_CHECK_SIZEOF(time_t) AM_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) @@ -1782,6 +1955,9 @@ AC_TYPE_SIGNAL AC_STRUCT_TM AM_PROG_LEX +dnl From here on we need to know about STDC_HEADERS +AC_HEADER_STDC + dnl AC_CHECK_TYPE does not work for socklen_t because it does not look dnl in , so this is a variant that adds another header. AC_DEFUN([AMANDA_CHECK_TYPE], @@ -1803,9 +1979,9 @@ if test "x$ac_cv_type_$1" = xno; then fi ]) AMANDA_CHECK_TYPE(socklen_t, int, sys/socket.h) +AMANDA_CHECK_TYPE(sa_family_t, unsigned short, sys/socket.h) dnl Checks for header files. -AC_HEADER_STDC AC_HEADER_DIRENT CF_WAIT CF_WAIT_INT @@ -1824,8 +2000,10 @@ AC_CHECK_HEADERS(\ grp.h \ history.h \ libc.h \ + libgen.h \ limits.h \ linux/zftape.h \ + math.h \ mntent.h \ mnttab.h \ ndbm.h \ @@ -1836,6 +2014,7 @@ AC_CHECK_HEADERS(\ readline/readline.h \ scsi/sg.h \ scsi/scsi_ioctl.h \ + stdarg.h \ stdlib.h \ string.h \ strings.h \ @@ -2138,10 +2317,11 @@ fi if test "x$ac_cv_lib_termcap_tgetent" = xyes || test "x$ac_cv_lib_curses_tgetent" = xyes || test "x$ac_cv_lib_ncurses_tgetent" = xyes; then - AC_CHECK_LIB(readline,readline, - READLINE_LIBS="-lreadline"; AC_SUBST(READLINE_LIBS) - ) - if test "x$ac_cv_lib_readline_readline" != xyes; then + AC_CHECK_LIB(readline,readline) + if test "x$ac_cv_lib_readline_readline" = xyes; then + READLINE_LIBS="-lreadline" + AC_SUBST(READLINE_LIBS) + else AC_MSG_WARN([*** No readline library, no history and command line editing in amrecover!]) fi else @@ -2545,6 +2725,9 @@ ICE_CHECK_DECL(accept,sys/types.h sys/socket.h) AC_FUNC_ALLOCA AC_CHECK_FUNCS(atexit) ICE_CHECK_DECL(atof,stdlib.h) +ICE_CHECK_DECL(atoi,stdlib.h) +ICE_CHECK_DECL(atol,stdlib.h) +ICE_CHECK_DECL(atoll,stdlib.h) AC_CHECK_FUNCS(basename) ICE_CHECK_DECL(bind,sys/types.h sys/socket.h) ICE_CHECK_DECL(bcopy,string.h strings.h stdlib.h) @@ -2578,6 +2761,7 @@ AMANDA_FUNC_GETTIMEOFDAY_ARGS AC_CHECK_FUNCS(getvfsent initgroups isascii) ICE_CHECK_DECL(initgroups,grp.h sys/types.h unistd.h libc.h) ICE_CHECK_DECL(ioctl,sys/ioctl.h unistd.h libc.h) +ICE_CHECK_DECL(isnormal,math.h) ICE_CHECK_DECL(listen,sys/types.h sys/socket.h) ICE_CHECK_DECL(lstat,sys/types.h sys/stat.h) ICE_CHECK_DECL(malloc,stdlib.h) @@ -2703,7 +2887,6 @@ ICE_CHECK_DECL(strcasecmp,string.h strings.h) AC_CHECK_FUNCS(fnmatch) -AC_SYS_LARGEFILE dnl disk device prefixes AC_MSG_CHECKING(disk device prefixes) @@ -2935,44 +3118,91 @@ AC_SUBST(LTALLOCA) DOC_BUILD_DATE=`date '+%d-%m-%Y'` AC_SUBST(DOC_BUILD_DATE) -AC_ARG_WITH(xsltproc, +AC_ARG_WITH(built-manpages, [ --without-built-manpages Do not build manpages from XML source.], - [ case "$withval" in - y | ye | yes) - USE_XSLTPROC=yes;; - n | no) - USE_XSLTPROC=no;; - *) - USE_XSLTPROC=yes; - XSLTPROC="$withval";; - esac - ], - [ USE_XSLTPROC=maybe; ]) + [ BUILDMANPAGES=$withval; ], + [ BUILDMANPAGES=yes; ]) +AM_CONDITIONAL(BUILD_MAN_PAGES, test "x$BUILDMANPAGES" = "xyes") + +AC_PATH_PROGS(XSLTPROC,xsltproc,,$LOCSYSPATH) +if test -z "$XSLTPROC"; then + USE_XSLTPROC=no + AC_MSG_WARN([can't find xsltproc, xsltproc support is unavailable]) +else + USE_XSLTPROC=yes + AC_DEFINE(HAVE_XSLTPROC,1,[xslt is available to generate man pages]) +fi +AM_CONDITIONAL(HAVE_XSLTPROC, test "x$USE_XSLTPROC" = "xyes") + +#### Enforce amanda code cleanliness rules. +#### Done here to allow configuration code to remain intact. +if test "x$CC" = "xgcc"; then + AM_CFLAGS="$AM_CFLAGS -Wall" + $CC -v --help 2>&1 | $GREP -- '-Wextra ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wextra" + else + AM_CFLAGS="$AM_CFLAGS -W" + fi -AC_DEFUN([AC_PATH_XSLTPROC], [AC_PATH_PROG(XSLTPROC, xsltproc)]) + $CC -v --help 2>&1 | $GREP -- '-Wparentheses' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wparentheses" + fi -# This looks bad, but && and || have equal precedence in shells, so -# actually it's all OK. -if test "$USE_XSLTPROC" = "yes" || test "$USE_XSLTPROC" = "maybe" && \ - test -z "$XSLTPROC"; then - AC_PATH_XSLTPROC - if test -n "$XSLTPROC"; then - USE_XSLTPROC=yes; - else - if test "$USE_XSLTPROC" = yes; then - AC_MSG_ERROR([can't find xsltproc, but running with --with-xsltproc.]) - else - USE_XSLTPROC=no; - fi - fi -fi + $CC -v --help 2>&1 | $GREP -- '-Wdeclaration-after-statement' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wdeclaration-after-statement" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wmissing-prototypes ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wmissing-prototypes" + fi -AM_CONDITIONAL(HAVE_XSLTPROC, test "$USE_XSLTPROC" = yes) + $CC -v --help 2>&1 | $GREP -- '-Wstrict-prototypes ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wmissing-declarations ' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wmissing-declarations" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wformat' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wformat" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wsign-compare' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wsign-compare" + fi + + $CC -v --help 2>&1 | $GREP -- '-fno-strict-aliasing' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -fno-strict-aliasing" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wfloat-equal' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wfloat-equal" + fi + + $CC -v --help 2>&1 | $GREP -- '-Wold-style-definition' 2>&1 > /dev/null + if test $? -eq 0; then + AM_CFLAGS="$AM_CFLAGS -Wold-style-definition" + fi +fi +AC_SUBST(AM_CFLAGS) AC_CONFIG_FILES([\ amplot/amcat.awk amplot/amplot.sh \ amplot/Makefile \ \ + amandad-src/Makefile \ + \ changer-src/chg-manual.sh changer-src/chg-multi.sh \ changer-src/chg-mtx.sh changer-src/chg-chs.sh \ changer-src/chg-rth.pl changer-src/chg-chio.pl \ @@ -2989,13 +3219,15 @@ AC_CONFIG_FILES([\ common-src/versuff.c common-src/Makefile \ \ example/amanda.conf example/Makefile \ - example/chg-mcutil.conf \ + example/chg-mcutil.conf example/amanda-client.conf \ \ man/Makefile \ \ docs/Makefile \ \ recover-src/Makefile \ + + oldrecover-src/Makefile \ \ restore-src/Makefile \ \ @@ -3005,9 +3237,10 @@ AC_CONFIG_FILES([\ server-src/amtoc.pl server-src/amverify.sh \ server-src/Makefile server-src/amstatus.pl \ server-src/amverifyrun.sh server-src/amcrypt.sh \ - server-src/amaespipe.sh \ - \ + server-src/amaespipe.sh server-src/amcrypt-ossl.sh \ + server-src/amcrypt-ossl-asym.sh \ tape-src/Makefile \ \ config/Makefile Makefile]) + AC_OUTPUT diff --git a/contrib/set_prod_link.pl b/contrib/set_prod_link.pl index 9efbd57..3143212 100644 --- a/contrib/set_prod_link.pl +++ b/contrib/set_prod_link.pl @@ -1,6 +1,6 @@ #!/usr/local/bin/perl # ======================================================================== -# @(#) $Id: set_prod_link.pl,v 1.2 1999/11/02 21:30:10 oliva Exp $ +# @(#) $Id: set_prod_link.pl,v 1.3 2006/05/25 01:47:13 johnfranks Exp $ # ------------------------------------------------------------------------ # $Source: /cvsroot/amanda/amanda/contrib/set_prod_link.pl,v $ # ------------------------------------------------------------------------ @@ -23,6 +23,21 @@ # History: # # $Log: set_prod_link.pl,v $ +# Revision 1.3 2006/05/25 01:47:13 johnfranks +# Allow spaces and arbitrary binary characters in file names +# and configuration files. +# +# 64-bit / type portability clean code. +# +# Add 'make lint' options to appropriate Makefiles. +# +# Fully lint clean code using Sun's lint, and splint code checkers. +# +# Various bug fixes that have not been pushed. +# +# Modified Files: +# Modified most of the files... +# # Revision 1.2 1999/11/02 21:30:10 oliva # * contrib/set_prod_link.pl: Create the links for a configuration # with --with-suffix. diff --git a/docs/Appendix.txt b/docs/Appendix.txt index 099ae71..1d32508 100644 --- a/docs/Appendix.txt +++ b/docs/Appendix.txt @@ -5,18 +5,84 @@ Prev Next ------------------------------------------------------------------------------- -Appendixes +Part VII. Appendixes Table of Contents - 35._The_AMANDA_Manual_Pages. + 36._The_Amanda_Manual_Pages. + + + amadmin - administrative interface to control Amanda backups + + amaespipe - wrapper program for aespipe + + amanda - Advanced Maryland Automatic Network Disk Archiver + + amanda.conf - Main configuration file for Amanda, the Advanced Maryland + Automatic Network Disk Archiver + + amanda-client.conf - Client configuration file for Amanda, the Advanced + Maryland Automatic Network Disk Archiver + + amcheck - run Amanda self-checks + + amcheckdb - check Amanda database for tape consistency + + amcleanup - run the Amanda cleanup process after a failure + + amcrypt - reference crypt program for Amanda symmetric data encryption + + amcrypt-ossl - crypt program for Amanda symmetric data encryption using + OpenSSL + + amcrypt-ossl-asym - crypt program for Amanda asymmetric data encryption + using OpenSSL + + amdd - Amanda version of dd + + amdump - back up all disks in an Amanda configuration + + amfetchdump - extract backup images from multiple Amanda tapes. + + amflush - flush Amanda backup files from holding disk to tape + + amgetconf - look up amanda.conf variables + + amlabel - label an Amanda tape + + ammt - Amanda version of mt + + amoverview - display file systems processed by Amanda over time + + amplot - visualize the behavior of Amanda + + amrecover - Amanda index database browser + + amreport - generate a formatted output of statistics for an Amanda run + + amrestore - extract backup images from an Amanda tape + + amrmtape - remove a tape from the Amanda database + + amstatus - display the state of an Amanda run + + amtape - user interface to Amanda tape changer controls + + amtapetype - generate a tapetype definition. + + amtoc - generate TOC (Table Of Contents) for an Amanda run + + amverify - check an Amanda tape for errors + + amverifyrun - check the tapes written by the last Amanda run + - 36._Web_Ressources + 37._Web_Ressources ------------------------------------------------------------------------------- -Prev Up Next -Chapter 34. Usage of floppy tape Home Chapter 35. The AMANDA Manual Pages. +Prev Next +Chapter 35. Usage of floppy tape Home Chapter 36. The Amanda Manual Pages. drives on Linux diff --git a/docs/Makefile.am b/docs/Makefile.am index 4945798..d4bbf41 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -2,13 +2,19 @@ pkgdata_DATA = \ Appendix.txt \ amadmin.8.txt \ + amaespipe.8.txt \ amanda.8.txt \ amanda.conf.5.txt \ + amanda-client.conf.5.txt \ amcheck.8.txt \ amcheckdb.8.txt \ amcleanup.8.txt \ + amcrypt.8.txt \ + amcrypt-asym-ossl.8.txt \ + amcrypt-ossl.8.txt \ amdd.8.txt \ amdump.8.txt \ + amfetchdump.8.txt \ amflush.8.txt \ amgetconf.8.txt \ amlabel.8.txt \ @@ -32,6 +38,7 @@ pkgdata_DATA = \ faq.txt \ historical.txt \ howto-afs.txt \ + howto-auth.txt \ howto-cygwin.txt \ howto-filedriver.txt \ howto-wrapper.txt \ diff --git a/docs/Makefile.in b/docs/Makefile.in index b1d3d87..5944713 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -66,11 +66,14 @@ AMANDA_DEBUG_DAYS = @AMANDA_DEBUG_DAYS@ AMANDA_TMPDIR = @AMANDA_TMPDIR@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ +AMLINT = @AMLINT@ +AMLINTFLAGS = @AMLINTFLAGS@ AMPLOT_CAT_COMPRESS = @AMPLOT_CAT_COMPRESS@ AMPLOT_CAT_GZIP = @AMPLOT_CAT_GZIP@ AMPLOT_CAT_PACK = @AMPLOT_CAT_PACK@ AMPLOT_COMPRESS = @AMPLOT_COMPRESS@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -78,6 +81,8 @@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AWK_VAR_ASSIGNMENT_OPT = @AWK_VAR_ASSIGNMENT_OPT@ BINARY_OWNER = @BINARY_OWNER@ +BUILD_MAN_PAGES_FALSE = @BUILD_MAN_PAGES_FALSE@ +BUILD_MAN_PAGES_TRUE = @BUILD_MAN_PAGES_TRUE@ CAT = @CAT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -261,13 +266,19 @@ target_vendor = @target_vendor@ pkgdata_DATA = \ Appendix.txt \ amadmin.8.txt \ + amaespipe.8.txt \ amanda.8.txt \ amanda.conf.5.txt \ + amanda-client.conf.5.txt \ amcheck.8.txt \ amcheckdb.8.txt \ amcleanup.8.txt \ + amcrypt.8.txt \ + amcrypt-asym-ossl.8.txt \ + amcrypt-ossl.8.txt \ amdd.8.txt \ amdump.8.txt \ + amfetchdump.8.txt \ amflush.8.txt \ amgetconf.8.txt \ amlabel.8.txt \ @@ -291,6 +302,7 @@ pkgdata_DATA = \ faq.txt \ historical.txt \ howto-afs.txt \ + howto-auth.txt \ howto-cygwin.txt \ howto-filedriver.txt \ howto-wrapper.txt \ diff --git a/docs/amadmin.8.txt b/docs/amadmin.8.txt index 209c3af..d99a9ec 100644 --- a/docs/amadmin.8.txt +++ b/docs/amadmin.8.txt @@ -1,22 +1,22 @@ amadmin -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amadmin  administrative interface to control AMANDA backups +amadmin  administrative interface to control Amanda backups Synopsis -amadmin config command [ command options ] +amadmin config command [command options] [ -o | configoption ]* DESCRIPTION -Amadmin performs various administrative tasks on the config AMANDA +Amadmin performs various administrative tasks on the config Amanda configuration. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. COMMANDS @@ -33,18 +33,18 @@ DISK EXPRESSION" section of amanda(8) for a description. force-bump [ hostname [ disks ]* ]+ Force the disks on hostname to bump to a new incremental level during the - next AMANDA run. + next Amanda run. force-no-bump [ hostname [ disks ]* ]+ Force the disks on hostname to not bump to a new incremental level during - the next AMANDA run. + the next Amanda run. unforce-bump [ hostname [ disks ]* ]+ Undo a previous force-bump or force-no-bump command. force [ hostname [ disks ]* ]+ Force the disks on hostname to do a full (level 0) backup during the next - AMANDA run. + Amanda run. unforce [ hostname [ disks ]* ]+ Undo a previous force command. @@ -56,30 +56,30 @@ DISK EXPRESSION" section of amanda(8) for a description. no-reuse tapelabel [ ... ] The tapes listed will not be reused when their turn comes up again in the tape cycle. Note that if this causes the number of reusable tapes to drop - below the amanda.conf tapecycle value, AMANDA will request new tapes + below the amanda.conf tapecycle value, Amanda will request new tapes until the count is satisfied again. due [ hostname [ disks ]* ]* Show when the next full dump is due. - find [ --sort hkdlb ] [ hostname [ disks ]* ]* + find [ --sort hkdlpb ] [ hostname [ disks ]* ]* Display all backups currently on tape or in the holding disk. The tape label or holding disk filename, file number, and status are displayed. The --sort option changes the sort order using the following flags: - hhost name kdisk name ddump date lbackup level btape label + hhost name kdisk name ddump date lbackup level p dump part btape label An uppercase letter reverses the sort order for that key. The default - sort order is hkdlb. + sort order is hkdlpb. delete [ hostname [ disks ]* ]+ - Delete the specified disks on hostname from the AMANDA database. + Delete the specified disks on hostname from the Amanda database. Note - If you do not also remove the disk from the disklist file, AMANDA will + If you do not also remove the disk from the disklist file, Amanda will treat it as a new disk during the next run. tape - Display the tape(s) AMANDA expects to write to during the next run. See + Display the tape(s) Amanda expects to write to during the next run. See also amcheck(8). bumpsize @@ -90,11 +90,11 @@ DISK EXPRESSION" section of amanda(8) for a description. Display the distribution of full backups throughout the dump schedule. export [ hostname [ disks ]* ]* - Convert records from the AMANDA database to a text format that may be - transmitted to another AMANDA machine and imported. + Convert records from the Amanda database to a text format that may be + transmitted to another Amanda machine and imported. import - Convert exported records read from standard input to a form AMANDA uses + Convert exported records read from standard input to a form Amanda uses and insert them into the database on this machine. disklist [ hostname [ disks ]* ]* @@ -105,11 +105,14 @@ DISK EXPRESSION" section of amanda(8) for a description. Display the database record for each of the disks on hostname (or all hosts). Mostly used for debugging. + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + EXAMPLES Request three specific file systems on machine-a get a full level 0 backup -during the next AMANDA run. +during the next Amanda run. $ amadmin daily force machine-a / /var /usr amadmin: machine-a:/ is set to a forced level 0 tonight. @@ -117,7 +120,7 @@ during the next AMANDA run. amadmin: machine-a:/usr is set to a forced level 0 tonight. Request all file systems on machine-b get a full level 0 backup during the next -AMANDA run. +Amanda run. $ amadmin daily force machine-b amadmin: machine-b:/ is set to a forced level 0 tonight. @@ -140,30 +143,30 @@ holding disk. The status column tells you whether the backup was successful or had some type of error. $ amadmin daily find machine-c /var - date host disk lv tape or file file status - 2000-11-09 machine-c /var 0 000110 9 OK - 2000-11-08 machine-c /var 2 000109 2 OK - 2000-11-07 machine-c /var 2 /amanda/20001107/machine-c._var.2 0 OK - 2000-11-06 machine-c /var 2 000107 2 OK - 2000-11-05 machine-c /var 2 000106 3 OK - 2000-11-04 machine-c /var 2 000105 2 OK - 2000-11-03 machine-c /var 2 000104 2 OK - 2000-11-02 machine-c /var 2 000103 2 OK - 2000-11-01 machine-c /var 1 000102 5 OK - 2000-10-31 machine-c /var 1 000101 3 OK + date host disk lv tape or file file part status + 2000\-11\-09 machine\-c /var 0 000110 9 -- OK + 2000\-11\-08 machine\-c /var 2 000109 2 -- OK + 2000\-11\-07 machine\-c /var 2 /amanda/20001107/machine-c._var.2 0 OK + 2000\-11\-06 machine\-c /var 2 000107 2 -- OK + 2000\-11\-05 machine\-c /var 2 000106 3 -- OK + 2000\-11\-04 machine\-c /var 2 000105 2 -- OK + 2000\-11\-03 machine\-c /var 2 000104 2 -- OK + 2000\-11\-02 machine\-c /var 2 000103 2 -- OK + 2000\-11\-01 machine\-c /var 1 000102 5 -- OK + 2000\-10\-31 machine\-c /var 1 000101 3 -- OK Forget about the /workspace disk on machine-d. If you do not also remove the -disk from the disklist file, AMANDA will treat it as a new disk during the next +disk from the disklist file, Amanda will treat it as a new disk during the next run. $ amadmin daily delete machine-d /workspace amadmin: machine-d:/workspace deleted from database. amadmin: NOTE: you'll have to remove these from the disklist yourself. -Find the next tape AMANDA will use (in this case, 123456). +Find the next tape Amanda will use (in this case, 123456). $ amadmin daily tape - The next AMANDA run should go onto tape 123456 or a new tape. + The next Amanda run should go onto tape 123456 or a new tape. Show how well full backups are balanced across the dump cycle. The due-date column is the day the backups are due for a full backup. #fs shows the number @@ -171,16 +174,16 @@ of filesystems doing full backups that night, and orig KB and out KB show the estimated total size of the backups before and after any compression, respectively. The balance column shows how far off that night's backups are from the average -size (shown at the bottom of the balance column). AMANDA tries to keep the +size (shown at the bottom of the balance column). Amanda tries to keep the backups within +/- 5%, but since the amount of data on each filesystem is -always changing, and AMANDA will never delay backups just to rebalance the +always changing, and Amanda will never delay backups just to rebalance the schedule, it is common for the schedule to fluctuate by larger percentages. In particular, in the case of a tape or backup failure, a bump will occur the following night, which will not be smoothed out until the next pass through the schedule. -The last line also shows an estimate of how many AMANDA runs will be made +The last line also shows an estimate of how many Amanda runs will be made between full backups for a file system. In the example, a file system will -probably have a full backup done every eight times AMANDA is run (e.g. every +probably have a full backup done every eight times Amanda is run (e.g. every eight days). $ amadmin daily balance @@ -207,14 +210,14 @@ FILES AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO -amanda(8), amcheck(8), amdump(8), amrestore(8) +amanda(8), amcheck(8), amdump(8), amrestore(8), amfetchdump(8) ------------------------------------------------------------------------------- -Prev Up Next -Chapter 35. The AMANDA Manual Pages. Home amanda +Prev Up Next +Chapter 36. The Amanda Manual Pages. Home amaespipe diff --git a/docs/amaespipe.8.txt b/docs/amaespipe.8.txt new file mode 100644 index 0000000..b222701 --- /dev/null +++ b/docs/amaespipe.8.txt @@ -0,0 +1,35 @@ + + amaespipe +Prev Chapter 36. The Amanda Manual Pages. Next + +------------------------------------------------------------------------------- + +Name + +amaespipe  wrapper program for aespipe + +Synopsis + +amaespipe + +DESCRIPTION + +amaespipe requires aespipe, uuencode and gpg to work. Aespipe is available from +http://loop-aes.sourceforge.net +amaespipe will search for the aespipe program in the following directories: / +usr/bin:/usr/local/bin:/sbin:/usr/sbin. +amaespipe is called by amcrypt for Amanda data encryption. +amaespipe is based on aespipe's bzaespipe program. It calls aespipe to encrypt +data using AES256 as the encryption and SHA256 as the hash function. GPG key +should be stored in $AMANDA_HOME/.gnupg/am_key.gpg. amaespipe reads passphrase +from file descriptor 3. During decryption, amaespipe autodects encryption type +and hash function from the encrypted image. + +SEE ALSO + +amanda(8), amanda.conf(5), aespipe(1), amcrypt(8), gpg(1) +------------------------------------------------------------------------------- + +Prev Up Next +amadmin Home amanda + diff --git a/docs/amanda-client.conf.5.txt b/docs/amanda-client.conf.5.txt new file mode 100644 index 0000000..2444dc8 --- /dev/null +++ b/docs/amanda-client.conf.5.txt @@ -0,0 +1,121 @@ + + amanda-client.conf +Prev Chapter 36. The Amanda Manual Pages. Next + +------------------------------------------------------------------------------- + +Name + +amanda-client.conf  Client configuration file for Amanda, the Advanced +Maryland Automatic Network Disk Archiver + +DESCRIPTION + +amanda-client.conf is the client configuration file for Amanda. This manpage +lists the relevant sections and parameters of this file for quick reference. + +PARAMETERS + +There are a number of configuration parameters that control the behavior of the +Amanda programs. All have default values, so you need not specify the parameter +in amanda-client.conf if the default is suitable. +Lines starting with # are ignored, as are blank lines. Comments may be placed +on a line with a directive by starting the comment with a #. The remainder of +the line is ignored. +Keywords are case insensitive, i.e. auth and Auth are treated the same. +Integer arguments may have one of the following (case insensitive) suffixes, +some of which have a multiplier effect: + +POSSIBLE SUFFIXES + + + + b byte bytes + Some number of bytes. + + bps + Some number of bytes per second. + + k kb kbyte kbytes kilobyte kilobytes + Some number of kilobytes (bytes*1024). + + kps kbps + Some number of kilobytes per second (bytes*1024). + + m mb meg mbyte mbytes megabyte megabytes + Some number of megabytes (bytes*1024*1024). + + mps mbps + Some number of megabytes per second (bytes*1024*1024). + + g gb gbyte gbytes gigabyte gigabytes + Some number of gigabytes (bytes*1024*1024*1024). + + tape tapes + Some number of tapes. + + day days + Some number of days. + + week weeks + Some number of weeks (days*7). + + Note + + The value inf may be used in most places where an integer is expected to + mean an infinite amount. + Boolean arguments may have any of the values y, yes, t, true or on to + indicate a true state, or n, no, f, false or off to indicate a false + state. If no argument is given, true is assumed. + + +PARAMETERS + + + + conf string + Default: Set by configure. The conf use by amrecover. + + index_server string + Default: Set by configure. The amindexd server amrecover will connect to. + + tape_server string + Default: Set by configure. The amidxtaped server amrecover will connect + to. + + tapedev string + Default: Set by configure. The tapedev amrecover will use. + + auth string + Default: bsd. Type of authorization to perform between tape server and + backup client hosts. + bsd, bsd authorization with udp initial connection and one tcp connection + by data stream. + bsdtcp, bsd authorization but use only one tcp connection. + bsdudp, like bsd, but will use only one tcp connection for all data + stream. + krb4 to use Kerberos-IV authorization. + krb5 to use Kerberos-V authorization. + rsh to use rsh authorization. + ssh to use OpenSSH authorization. + + ssh_keys string + Default: No default. The key file the ssh auth will use, it must be the + private key. If this parameter is not specified, then the deafult ssh key + will be used. + + +AUTHOR + +James da Silva, : Original text +Stefan G. Weichinger, , maintainer of the Amanda-documentation: +XML-conversion, major update, splitting + +SEE ALSO + +amanda(8), amanda.conf(5), amcrypt(8), aespipe(1), +------------------------------------------------------------------------------- + +Prev Up Next +amanda.conf Home amcheck + diff --git a/docs/amanda.8.txt b/docs/amanda.8.txt index 1deec26..6572c62 100644 --- a/docs/amanda.8.txt +++ b/docs/amanda.8.txt @@ -1,6 +1,6 @@ amanda -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- @@ -14,8 +14,10 @@ amadmin config command [options] amcheck [options] config amcheckdb config amcleanup config +amcrypt amdd [options] amdump config +amaespipe amflush [-f ] config amgetconf [config] parameter amlabel config label [ slot slot ] @@ -25,6 +27,7 @@ amplot [options] amdump-files amrecover [config] [options] amreport [config] [options] amrestore [options] tapedevice [ hostname [diskname]] +amfetchdump [options] config [ hostname [ diskname [ date [level]]]] amrmtape [options] config label amstatus config [options] amtape config command [options] @@ -35,15 +38,15 @@ amverifyrun config DESCRIPTION -AMANDA is the "Advanced Maryland Automatic Network Disk Archiver". This manual -page gives an overview of the AMANDA commands and configuration files for quick +Amanda is the "Advanced Maryland Automatic Network Disk Archiver". This manual +page gives an overview of the Amanda commands and configuration files for quick reference. -Here are all the AMANDA commands. Each one has its own manual page. See them +Here are all the Amanda commands. Each one has its own manual page. See them for all the gory details. amdump - Take care of automatic AMANDA backups. This is normally executed by cron + Take care of automatic Amanda backups. This is normally executed by cron on a computer called the tape server host and requests backups of file systems located on backup clients. Amdump backs up all disks in the disklist file (discussed below) to tape or, if there is a problem, to a @@ -62,18 +65,24 @@ for all the gory details. server host crashed while amdump was running. amrecover - Provides an interactive interface to browse the AMANDA index files + Provides an interactive interface to browse the Amanda index files (backup image catalogues) and select which tapes to recover files from. It can also run amrestore and a restore program (e.g. tar) to actually recover the files. amrestore - Read an AMANDA tape, searching for requested backups. Amrestore is + Read an Amanda tape, searching for requested backups. Amrestore is suitable for everything from interactive restores of single files to a full restore of all partitions on a failed disk. + amfetchdump + Performs Amanda tape restoration, similar to amrestore. Additional + capabilities include "hands-off" searching of multiple tapes, automatic + retrieval of specific dump files based on dump logs, and assembly of + tape-spanning split dump files. + amlabel - Write an AMANDA format label onto a tape. All AMANDA tapes must be + Write an Amanda format label onto a tape. All Amanda tapes must be labeled with amlabel. Amdump and amflush will not write to an unlabeled tape (see TAPE MANAGEMENT below). @@ -93,10 +102,10 @@ for all the gory details. tapes, ejecting tapes and scanning the tape storage slots. amverify - Check AMANDA backup tapes for errors. + Check Amanda backup tapes for errors. amrmtape - Delete a tape from the AMANDA databases. + Delete a tape from the Amanda databases. amstatus Report the status of a running or completed amdump. @@ -105,30 +114,36 @@ for all the gory details. Display a chart of hosts and file systems backed up every run. amplot - Generate utilization plots of AMANDA runs for performance tuning. + Generate utilization plots of Amanda runs for performance tuning. amreport - Generate an AMANDA summary E-mail report. + Generate an Amanda summary E-mail report. amtoc - Generate table of content files for AMANDA tapes. + Generate table of content files for Amanda tapes. amcheckdb - Verify every tape AMANDA knows about is consistent in the database. + Verify every tape Amanda knows about is consistent in the database. amgetconf - Look up parameters in the AMANDA configuration file. + Look up parameters in the Amanda configuration file. amtapetype Generate a tapetype definition. + amaespipe + Wrapper program from aespipe (data encryption utility) + + amcrypt + Reference encryption program for Amanda symmetric data encryption + CONFIGURATION -There are three user-editable files that control the behavior of AMANDA. +There are three user-editable files that control the behavior of Amanda. The first is amanda.conf, the main configuration file. It contains parameters -to customize AMANDA for the site. Refer to the amanda.conf(5), manpage for -details on AMANDA configuration parameters. +to customize Amanda for the site. Refer to the amanda.conf(5), manpage for +details on Amanda configuration parameters. Second is the disklist file, which lists hosts and disk partitions to back up. Third is the tapelist file, which lists tapes that are currently active. These files are described in more detail in the following sections. @@ -137,14 +152,14 @@ etc/amanda/. A site will often have more than one configuration. For example, it might have a normal configuration for everyday backups and an archive configuration for infrequent full archival backups. The configuration files would be stored under directories /usr/local/etc/amanda/normal/ and /usr/local/ -etc/amanda/archive/, respectively. Part of the job of an AMANDA administrator +etc/amanda/archive/, respectively. Part of the job of an Amanda administrator is to create, populate and maintain these directories. -All log and database files generated by AMANDA go in corresponding directories +All log and database files generated by Amanda go in corresponding directories somewhere. The exact location is controlled by entries in amanda.conf. A typical location would be under /var/adm/amanda. For the above example, the files might go in /var/adm/amanda/normal/ and /var/adm/amanda/archive/. As log files are no longer needed (no longer contain relevant information), -AMANDA cycles them out in various ways, depending on the type of file. +Amanda cycles them out in various ways, depending on the type of file. Detailed information about amdump runs are stored in files named amdump.NN where NN is a sequence number, with 1 being the most recent file. Amdump rotates these files each run, keeping roughly the last tapecycle (see below) @@ -153,7 +168,7 @@ The file used by amreport to generate the mail summary is named log.YYYYMMDD.NN where YYYYMMDD is the datestamp of the start of the amdump run and NN is a sequence number started at 0. At the end of each amdump run, log files for runs whose tapes have been reused are renamed into a subdirectory of the main log -directory (see the logdir parameter below) named oldlog. It is up to the AMANDA +directory (see the logdir parameter below) named oldlog. It is up to the Amanda administrator to remove them from this directory when desired. Index (backup image catalogue) files older than the full dump matching the oldest backup image for a given client and disk are removed by amdump at the @@ -161,7 +176,7 @@ end of each run. DISKLIST FILE -The disklist file determines which disks will be backed up by AMANDA. The file +The disklist file determines which disks will be backed up by Amanda. The file usually contains one line per disk: hostname diskname [diskdevice] dumptype [spindle [interface] ] @@ -173,7 +188,7 @@ following meanings: hostname The name of the host to be backed up. If diskdevice refers to a PC share, - this is the host AMANDA will run the Samba smbclient program on to back + this is the host Amanda will run the Samba smbclient program on to back up the share. diskname @@ -181,7 +196,7 @@ following meanings: the diskdevice and you don't set the diskdevice. If you want multiple entries with the same diskdevice, you must set a different diskname for each entry. It's the diskname that you use on the commandline for any - AMANDA command. Look at the example/disklist file for example. + Amanda command. Look at the example/disklist file for example. diskdevice Default: same as diskname. The name of the disk device to be backed up. @@ -200,7 +215,7 @@ following meanings: priority, etc. spindle - Default: -1. A number used to balance backup load on a host. AMANDA will + Default: -1. A number used to balance backup load on a host. Amanda will not run multiple backups at the same time on the same spindle, unless the spindle number is -1, which means there is no spindle restriction. @@ -226,13 +241,13 @@ work instead of defining a new dumptype: TAPE MANAGEMENT The tapelist file contains the list of tapes in active use. This file is -maintained entirely by AMANDA and should not be created or edited during normal +maintained entirely by Amanda and should not be created or edited during normal operation. It contains lines of the form: YYYYMMDD label flags Where YYYYMMDD is the date the tape was written, label is a label for the tape -as written by amlabel and flags tell AMANDA whether the tape may be reused, etc +as written by amlabel and flags tell Amanda whether the tape may be reused, etc (see the reuse options of amadmin). Amdump and amflush will refuse to write to an unlabeled tape, or to a labeled tape that is considered active. There must be more tapes in active rotation @@ -245,7 +260,7 @@ OUTPUT DRIVERS The normal value for the tapedev parameter, or for what a tape changer returns, is a full path name to a non-rewinding tape device, such as /dev/nst0 or /dev/ rmt/0mn or /dev/nst0.1 or whatever conventions the operating system uses. -AMANDA provides additional application level drivers that support non- +Amanda provides additional application level drivers that support non- traditional tape-simulations or features. To access a specific output driver, set tapedev (or configure your changer to return) a string of the form driver: driver-info where driver is one of the supported drivers and driver-info is @@ -268,7 +283,7 @@ The supported drivers are: null This driver throws away anything written to it and returns EOF for any reads except a special case is made for reading a label, in which case a - "fake" value is returned that AMANDA checks for and allows through + "fake" value is returned that Amanda checks for and allows through regardless of what you have set in labelstr. The driver-info field is not used and may be left blank: @@ -315,7 +330,7 @@ The supported drivers are: for the actual data. Create a symlink named data in the file directory to one of the data directories. Set the tapetype length to whatever the medium will hold. - When AMANDA fills the file device, remove the symlink and (optionally) + When Amanda fills the file device, remove the symlink and (optionally) create a new symlink to another data area. Use a CD writer software package to burn the image from the first data area. To read the CD, mount it and create the data symlink in the file device @@ -324,34 +339,37 @@ The supported drivers are: AUTHORIZATION -AMANDA processes on the tape server host run as the dumpuser user listed in -amanda.conf. When they connect to a backup client, they do so with an AMANDA- +Amanda processes on the tape server host run as the dumpuser user listed in +amanda.conf. When they connect to a backup client, they do so with an Amanda- specific protocol. They do not, for instance, use rsh or ssh directly. On the client side, the amandad daemon validates the connection using one of several methods, depending on how it was compiled and on options it is passed: .rhosts - Even though AMANDA does not use rsh, it can use .rhosts-style + Even though Amanda does not use rsh, it can use .rhosts-style authentication and a .rhosts file. .amandahosts This is essentially the same as .rhosts authentication except a different file, with almost the same format, is used. This is the default mechanism - built into AMANDA. + built into Amanda. The format of the .amandahosts file is: - hostname [ username ] + hostname [ username [ service ]*] If username is ommitted, it defaults to the user running amandad, i.e. the user listed in the inetd or xinetd configuration file. + The service is a list of the service the client is authorized to execute: + amdump, noop, selfcheck, sendsize, sendbackup, amindexd, amidxtaped. + amdump is a shortcut for "noop selfcheck sendsize sendbackup" Kerberos - AMANDA may use the Kerberos authentication system. Further information is - in the docs/KERBEROS file that comes with an AMANDA distribution. - For Samba access, AMANDA needs a file on the Samba server (which may or + Amanda may use the Kerberos authentication system. Further information is + in the docs/KERBEROS file that comes with an Amanda distribution. + For Samba access, Amanda needs a file on the Samba server (which may or may not also be the tape server) named /etc/amandapass with share names, (clear text) passwords and (optional) domain names, in that order, one per line, whitespace separated. By default, the user used to connect to - the PC is the same for all PC's and is compiled into AMANDA. It may be + the PC is the same for all PC's and is compiled into Amanda. It may be changed on a host by host basis by listing it first in the password field followed by a percent sign and then the password. For instance: @@ -359,10 +377,10 @@ several methods, depending on how it was compiled and on options it is passed: //another-pc/disk otheruser%otherpw With clear text passwords, this file should obviously be tightly - protected. It only needs to be readable by the AMANDA-user on the Samba + protected. It only needs to be readable by the Amanda-user on the Samba server. You can find further information in the docs/SAMBA file that comes with - an AMANDA distribution. + an Amanda distribution. HOST & DISK EXPRESSION @@ -376,37 +394,35 @@ expression at left with a '^'. You can anchor the expression at right with a '$'. The matcher is case insensitive for host but is case sensitive for disk. A match succeeds if all words in your expression match contiguous words in the host or disk. - ________________________________________________________ -|._|word_separator_for_a_host____________________________| -|/_|word_separator_for_a_disk____________________________| -|^_|anchor_at_left_______________________________________| -|$_|anchor_at_right______________________________________| -|?_|match_exactly_one_character_except_the_separator_____| -|*_|match_zero_or_more_characters_except_the_separator___| -|**|match_zero_or_more_characters_including_the_separator| +. word separator for a host +/ word separator for a disk +^ anchor at left +$ anchor at right +? match exactly one character except the separator +* match zero or more characters except the separator +** match zero or more characters including the separator Some examples: - ___________________________________________ -|EXPRESSION|WILL_MATCH_______|WILL_NOT_MATCH| -|hosta_____|hosta____________|hostb_________| -|__________|hoSTA.dOMAIna.ORG|______________| -|__________|foo.hosta.org____|______________| -|host______|host_____________|hosta_________| -|host?_____|hosta____________|host__________| -|__________|hostb____________|______________| -|ho*na_____|hoina____________|ho.aina.org___| -|ho**na____|hoina____________|______________| -|__________|ho.aina.org______|______________| -|^hosta____|hosta____________|foo.hosta.org_| -|sda*______|/dev/sda1________|______________| -|__________|/dev/sda12_______|______________| -|/opt/_____|opt_(disk)_______|opt_(host)____| -|.opt._____|opt_(host)_______|opt_(disk)____| -|/_________|/________________|any_other_disk| -|/usr______|/usr_____________|______________| -|__________|/usr/opt_________|______________| -|/usr$_____|/usr_____________|/usr/opt______| +EXPRESSION WILL MATCH WILL NOT MATCH +hosta hosta hostb + hoSTA.dOMAIna.ORG + foo.hosta.org +host host hosta +host? hosta host + hostb +ho*na hoina ho.aina.org +ho**na hoina + ho.aina.org +^hosta hosta foo.hosta.org +sda* /dev/sda1 + /dev/sda12 +/opt/ opt (disk) opt (host) +.opt. opt (host) opt (disk) +/ / any other disk +/usr /usr + /usr/opt +/usr$ /usr /usr/opt DATESTAMP EXPRESSION @@ -422,20 +438,31 @@ Leading ^ is removed. Trailing $ forces an exact match. |200010$____|match_only_200010____________________________________________| +CONFIGURATION OVERWRITE + +Most command allow to overwrite any configuration parameter on the command line +with the -o option. +-o NAME=value +eg. -o runtapes=2 +eg. -o DUMPTYPE:no-compress:compress="server fast" +eg. -o TAPETYPE:HP-DAT:length=2000m +eg. -o INTERFACE:local:use="2000 kbps" + AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion, major update SEE ALSO -amadmin(8), amanda.conf(5), amcheck(8), amcheckdb(8), amcleanup(8), amdd(8), -amdump(8), amflush(8), amgetconf(8), amlabel(8), ammt(8), amoverview(8), amplot -(8), amrecover(8), amreport(8), amrestore(8), amrmtape(8), amstatus(8), amtape -(8), amtapetype(8), amtoc(8), amverify(8), amverifyrun(8) +amadmin(8), amanda.conf(5), amanda-client.conf(5), amcheck(8), amcheckdb(8), +amcleanup(8), amdd(8), amdump(8), amfetchdump(8) amflush(8), amgetconf(8), +amlabel(8), ammt(8), amoverview(8), amplot(8), amrecover(8), amreport(8), +amrestore(8), amrmtape(8), amstatus(8), amtape(8), amtapetype(8), amtoc(8), +amverify(8), amverifyrun(8) ------------------------------------------------------------------------------- -Prev Up Next -amadmin Home amanda.conf +Prev Up Next +amaespipe Home amanda.conf diff --git a/docs/amanda.conf.5.txt b/docs/amanda.conf.5.txt index ecaf1ca..bf94e87 100644 --- a/docs/amanda.conf.5.txt +++ b/docs/amanda.conf.5.txt @@ -1,23 +1,23 @@ amanda.conf -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amanda.conf  Main configuration file for AMANDA, the Advanced Maryland +amanda.conf  Main configuration file for Amanda, the Advanced Maryland Automatic Network Disk Archiver DESCRIPTION -amanda.conf is the main configuration file for AMANDA. This manpage lists the +amanda.conf is the main configuration file for Amanda. This manpage lists the relevant sections and parameters of this file for quick reference. PARAMETERS There are a number of configuration parameters that control the behavior of the -AMANDA programs. All have default values, so you need not specify the parameter +Amanda programs. All have default values, so you need not specify the parameter in amanda.conf if the default is suitable. Lines starting with # are ignored, as are blank lines. Comments may be placed on a line with a directive by starting the comment with a #. The remainder of @@ -73,325 +73,8 @@ PARAMETERS - org string - Default: daily. A descriptive name for the configuration. This string - appears in the Subject line of mail reports. Each AMANDA configuration - should have a different string to keep mail reports distinct. - - mailto string - Default: operators. A space separated list of recipients for mail - reports. - - dumpcycle int - Default: 10 days. The number of days in the backup cycle. Each disk will - get a full backup at least this often. Setting this to zero tries to do a - full backup each run. - - Note - - This parameter may also be set in a specific dumptype (see below). This - value sets the default for all dumptypes so must appear in amanda.conf - before any dumptypes are defined. - - runspercycle int - Default: same as dumpcycle. The number of amdump runs in dumpcycle days. - A value of 0 means the same value as dumpcycle. A value of -1 means guess - the number of runs from the tapelist file, which is the number of tapes - used in the last dumpcycle days / runtapes. - - tapecycle int - Default: 15 tapes. Typically tapes are used by AMANDA in an ordered - rotation. The tapecycle parameter defines the size of that rotation. The - number of tapes in rotation must be larger than the number of tapes - required for a complete dump cycle (see the dumpcycle parameter). - This is calculated by multiplying the number of amdump runs per dump - cycle (runspercycle parameter) times the number of tapes used per run - (runtapes parameter). Typically two to four times this calculated number - of tapes are in rotation. While AMANDA is always willing to use a new - tape in its rotation, it refuses to reuse a tape until at least - 'tapecycle -1' number of other tapes have been used. - It is considered good administrative practice to set the tapecycle - parameter slightly lower than the actual number of tapes in rotation. - This allows the administrator to more easily cope with damaged or - misplaced tapes or schedule adjustments that call for slight adjustments - in the rotation order. - - dumpuser string - Default: amanda. The login name AMANDA uses to run the backups. The - backup client hosts must allow access from the tape server host as this - user via .rhosts or .amandahosts, depending on how the AMANDA software - was built. - - printer string - Printer to use when doing tape labels. See the lbl-templ tapetype option. - - tapedev string - Default: /dev/nst0. The path name of the non-rewinding tape device. Non- - rewinding tape device names often have an 'n' in the name, e.g. /dev/rmt/ - 0mn, however this is operating system specific and you should consult - that documentation for detailed naming information. - If a tape changer is configured (see the tpchanger option), this option - might not be used. - If the null output driver is selected (see the section OUTPUT DRIVERS in - the amanda(8) manpage for more information), programs such as amdump will - run normally but all images will be thrown away. This should only be used - for debugging and testing, and probably only with the record option set - to no. - - rawtapedev string - Default: /dev/null. The path name of the raw tape device. This is only - used if AMANDA is compiled for Linux machines with floppy tapes and is - needed for QIC volume table operations. - - tpchanger string - Default: none. The name of the tape changer. If a tape changer is not - configured, this option is not used and should be commented out of the - configuration file. - If a tape changer is configured, choose one of the changer scripts (e.g. - chg-scsi) and enter that here. - - changerdev string - Default: /dev/null. A tape changer configuration parameter. Usage depends - on the particular changer defined with the tpchanger option. - - changerfile string - Default: /usr/adm/amanda/log/changer-status. A tape changer configuration - parameter. Usage depends on the particular changer defined with the - tpchanger option. - - runtapes int - Default: 1. The maximum number of tapes used in a single run. If a tape - changer is not configured, this option is not used and should be - commented out of the configuration file. - If a tape changer is configured, this may be set larger than one to let - AMANDA write to more than one tape. - Note that this is an upper bound on the number of tapes, and AMANDA may - use less. - Also note that as of this release, AMANDA does not support true tape - overflow. When it reaches the end of one tape, the backup image AMANDA - was processing starts over again on the next tape. - - maxdumpsize int - Default: runtapes*tape_length. Maximum number of bytes the planner will - schedule for a run. - - taperalgo [first|firstfit|largest|largestfit|smallest|last] - Default: first. The algorithm used to choose which dump image to send to - the taper. - - - first - First in, first out. - - firstfit - The first dump image that will fit on the current tape. - - largest - The largest dump image. - - largestfit - The largest dump image that will fit on the current tape. - - smallest - The smallest dump image. - - last - Last in, first out. - - - labelstr string - Default: .*. The tape label constraint regular expression. All tape - labels generated (see amlabel(8)) and used by this configuration must - match the regular expression. If multiple configurations are run from the - same tape server host, it is helpful to set their labels to different - strings (for example, "DAILY[0-9][0-9]*" vs. "ARCHIVE[0-9][0-9]*") to - avoid overwriting each other's tapes. - - tapetype string - Default: EXABYTE. The type of tape drive associated with tapedev or - tpchanger. This refers to one of the defined tapetypes in the config file - (see below), which specify various tape parameters, like the length, - filemark size, and speed of the tape media and device. - - ctimeout int - Default: 30 seconds. Maximum amount of time that amcheck will wait for - each client host. - - dtimeout int - Default: 1800 seconds. Amount of idle time per disk on a given client - that a dumper running from within amdump will wait before it fails with a - data timeout error. - - etimeout int - Default: 300 seconds. Amount of time per disk on a given client that the - planner step of amdump will wait to get the dump size estimates. For - instance, with the default of 300 seconds and four disks on client A, - planner will wait up to 20 minutes for that machine. A negative value - will be interpreted as a total amount of time to wait per client instead - of per disk. - - netusage int - Default: 300 Kbps. The maximum network bandwidth allocated to AMANDA, in - Kbytes per second. See also the interface section. - - inparallel int - Default: 10. The maximum number of backups that AMANDA will attempt to - run in parallel. AMANDA will stay within the constraints of network - bandwidth and holding disk space available, so it doesn't hurt to set - this number a bit high. Some contention can occur with larger numbers of - backups, but this effect is relatively small on most systems. - - displayunit "k|m|g|t" - Default: "k". The unit used to print many numbers, k=kilo, m=mega, - g=giga, t=tera. - - dumporder string - Default: tttTTTTTTT. The priority order of each dumper: - - * s: smallest size - * S: largest size - * t: smallest time - * T: largest time - * b: smallest bandwidth - * B: largest bandwidth - - - maxdumps int - Default: 1. The maximum number of backups from a single host that AMANDA - will attempt to run in parallel. See also the inparallel option. - Note that this parameter may also be set in a specific dumptype (see - below). This value sets the default for all dumptypes so must appear in - amanda.conf before any dumptypes are defined. - - bumpsize int - Default: 10 Mbytes. The minimum savings required to trigger an automatic - bump from one incremental level to the next, expressed as size. If AMANDA - determines that the next higher backup level will be this much smaller - than the current level, it will do the next level. The value of this - parameter is used only if the parameter bumppercent is set to 0. - The global setting of this parameter can be overwritten inside of a - dumptype-definition. - See also the options bumppercent, bumpmult and bumpdays. - - bumppercent int - Default: 0 percent. The minimum savings required to trigger an automatic - bump from one incremental level to the next, expressed as percentage of - the current size of the DLE (size of current level 0). If AMANDA - determines that the next higher backup level will be this much smaller - than the current level, it will do the next level. - If this parameter is set to 0, the value of the parameter bumpsize is - used to trigger bumping. - The global setting of this parameter can be overwritten inside of a - dumptype-definition. - See also the options bumpsize, bumpmult and bumpdays. - - bumpmult float - Default: 1.5. The bump size multiplier. AMANDA multiplies bumpsize by - this factor for each level. This prevents active filesystems from bumping - too much by making it harder to bump to the next level. For example, with - the default bumpsize and bumpmult set to 2.0, the bump threshold will be - 10 Mbytes for level one, 20 Mbytes for level two, 40 Mbytes for level - three, and so on. - The global setting of this parameter can be overwritten inside of a - dumptype-definition. - - bumpdays int - Default: 2 days. To insure redundancy in the dumps, AMANDA keeps - filesystems at the same incremental level for at least bumpdays days, - even if the other bump threshold criteria are met. - The global setting of this parameter can be overwritten inside of a - dumptype-definition. - - diskfile string - Default: disklist. The file name for the disklist file holding client - hosts, disks and other client dumping information. - - infofile string - Default: /usr/adm/amanda/curinfo. The file or directory name for the - historical information database. If AMANDA was configured to use DBM - databases, this is the base file name for them. If it was configured to - use text formated databases (the default), this is the base directory and - within here will be a directory per client, then a directory per disk, - then a text file of data. - - logdir string - Default: /usr/adm/amanda. The directory for the amdump and log files. - - indexdir string - Default /usr/adm/amanda/index. The directory where index files (backup - image catalogues) are stored. Index files are only generated for - filesystems whose dumptype has the index option enabled. - - tapelist string - Default: tapelist. The file name for the active tapelist file. AMANDA - maintains this file with information about the active set of tapes. - - tapebufs int - Default: 20. The number of buffers used by the taper process run by - amdump and amflush to hold data as it is read from the network or disk - before it is written to tape. Each buffer is a little larger than 32 - KBytes and is held in a shared memory region. - - reserve number - Default: 100. The part of holding-disk space that should be reserved for - incremental backups if no tape is available, expressed as a percentage of - the available holding-disk space (0-100). By default, when there is no - tape to write to, degraded mode (incremental) backups will be performed - to the holding disk. If full backups should also be allowed in this case, - the amount of holding disk space reserved for incrementals should be - lowered. - - autoflush bool - Default: off. Whether an amdump run will flush the dump already on - holding disk to tape. - - amrecover_do_fsf bool - Default: off. Amrecover will call amrestore with the -f flag for faster - positioning of the tape. - - amrecover_check_label bool - Default: off. Amrecover will call amrestore with the -l flag to check the - label. - - amrecover_changer string - Default: ''. Amrecover will use the changer if you use 'settape ' - and that string is the same as the amrecover_changer setting. - - columnspec string - Defines the width of columns amreport should use. String is a comma (',') - separated list of triples. Each triple consists of three parts which are - separated by a equal sign ('=') and a colon (':') (see the example). - These three parts specify: - - * the name of the column, which may be: - - o Compress (compression ratio) - o Disk (client disk name) - o DumpRate (dump rate in KBytes/sec) - o DumpTime (total dump time in hours:minutes) - o HostName (client host name) - o Level (dump level) - o OrigKB (original image size in KBytes) - o OutKB (output image size in KBytes) - o TapeRate (tape writing rate in KBytes/sec) - o TapeTime (total tape time in hours:minutes) - - * the amount of space to display before the column (used to get - whitespace between columns). - * the width of the column itself. If set to a negative value, the width - will be calculated on demand to fit the largest entry in this column. - - Here is an example: - - columnspec "Disk=1:18,HostName=0:10,OutKB=1:7" - - The above will display the disk information in 18 characters and put one - space before it. The hostname column will be 10 characters wide with no - space to the left. The output KBytes column is seven characters wide with - one space before it. - includefile string - Default: none. The name of an AMANDA configuration file to include within + Default: none. The name of an Amanda configuration file to include within the current file. Useful for sharing dumptypes, tapetypes and interface definitions among several configurations. @@ -419,7 +102,7 @@ The options and values are: use int Default: 0 Gb. Amount of space that can be used in this holding disk area. If the value is zero, all available space on the file system is - used. If the value is negative, AMANDA will use all available space minus + used. If the value is negative, Amanda will use all available space minus that value. chunksize int @@ -428,17 +111,15 @@ The options and values are: chunk will not exceed the specified value. However, even though dump images are split in the holding disk, they are concatenated as they are written to tape, so each dump image still corresponds to a single - continuous tape section. - If 0 is specified, AMANDA will create holding disk chunks as large as ( - (INT_MAX/1024)-64) Kbytes. - Each holding disk chunk includes a 32 Kbyte header, so the minimum chunk - size is 64 Kbytes (but that would be really silly). - Operating systems that are limited to a maximum file size of 2 Gbytes - actually cannot handle files that large. They must be at least one byte - less than 2 Gbytes. Since AMANDA works with 32 Kbyte blocks, and to - handle the final read at the end of the chunk, the chunk size should be - at least 64 Kbytes (2 * 32 Kbytes) smaller than the maximum file size, - e.g. 2047 Mbytes. + continuous tape section. If 0 is specified, Amanda will create holding + disk chunks as large as ((INT_MAX/1024)-64) Kbytes. Each holding disk + chunk includes a 32 Kbyte header, so the minimum chunk size is 64 Kbytes + (but that would be really silly). Operating systems that are limited to a + maximum file size of 2 Gbytes actually cannot handle files that large. + They must be at least one byte less than 2 Gbytes. Since Amanda works + with 32 Kbyte blocks, and to handle the final read at the end of the + chunk, the chunk size should be at least 64 Kbytes (2 * 32 Kbytes) + smaller than the maximum file size, e.g. 2047 Mbytes. DUMPTYPE SECTION @@ -470,11 +151,28 @@ The dumptype options and values are: auth string Default: bsd. Type of authorization to perform between tape server and - backup client hosts. May be krb4 to use Kerberos-IV authorization. + backup client hosts. + bsd, bsd authorization with udp initial connection and one tcp connection + by data stream. + bsdtcp, bsd authorization but use only one tcp connection. + bsdudp, like bsd, but will use only one tcp connection for all data + stream. + krb4 to use Kerberos-IV authorization. + krb5 to use Kerberos-V authorization. + rsh to use rsh authorization. + ssh to use OpenSSH authorization. + + amandad_path string + Default: $libexec/amandad. Specify the amandad path of the client, only + use with rsh/ssh authentification. + + client_username string + Default: CLIENT_LOGIN. Specify the username to connect on the client, + only use with rsh/ssh authentification. bumpsize int Default: 10 Mbytes. The minimum savings required to trigger an automatic - bump from one incremental level to the next, expressed as size. If AMANDA + bump from one incremental level to the next, expressed as size. If Amanda determines that the next higher backup level will be this much smaller than the current level, it will do the next level. The value of this parameter is used only if the parameter bumppercent is set to 0. @@ -483,7 +181,7 @@ The dumptype options and values are: bumppercent int Default: 0 percent. The minimum savings required to trigger an automatic bump from one incremental level to the next, expressed as percentage of - the current size of the DLE (size of current level 0). If AMANDA + the current size of the DLE (size of current level 0). If Amanda determines that the next higher backup level will be this much smaller than the current level, it will do the next level. If this parameter is set to 0, the value of the parameter bumpsize is @@ -491,7 +189,7 @@ The dumptype options and values are: See also the options bumpsize, bumpmult and bumpdays. bumpmult float - Default: 1.5. The bump size multiplier. AMANDA multiplies bumpsize by + Default: 1.5. The bump size multiplier. Amanda multiplies bumpsize by this factor for each level. This prevents active filesystems from bumping too much by making it harder to bump to the next level. For example, with the default bumpsize and bumpmult set to 2.0, the bump threshold will be @@ -499,7 +197,7 @@ The dumptype options and values are: three, and so on. bumpdays int - Default: 2 days. To insure redundancy in the dumps, AMANDA keeps + Default: 2 days. To insure redundancy in the dumps, Amanda keeps filesystems at the same incremental level for at least bumpdays days, even if the other bump threshold criteria are met. @@ -508,43 +206,73 @@ The dumptype options and values are: comprate float [, float ] Default: 0.50, 0.50. The expected full and incremental compression factor - for dumps. It is only used if AMANDA does not have any history + for dumps. It is only used if Amanda does not have any history information on compression rates for a filesystem, so should not usually need to be set. However, it may be useful for the first time a very large filesystem that compresses very little is backed up. compress [client|server] string - Default: client fast. If AMANDA does compression of the backup images, it + Default: client fast. If Amanda does compression of the backup images, it can do so either on the backup client host before it crosses the network or on the tape server host as it goes from the network into the holding disk or to tape. Which place to do compression (if at all) depends on how well the dump image usually compresses, the speed and load on the client or server, network capacity, holding disk capacity, availability of tape hardware compression, etc. - For either type of compression, AMANDA also allows the selection of two + For either type of compression, Amanda also allows the selection of three styles of compression. Best is the best compression available, often at the expense of CPU overhead. Fast is often not as good a compression as - best, but usually less CPU overhead. + best, but usually less CPU overhead. Or to specify Custom to use your own + compression method. (See dumptype custom-compress in example/amanda.conf + for reference) So the compress options line may be one of: * compress none * compress [client] fast * compress [client] best + * compress client custom + Specify client_custom_compress "PROG" + PROG must not contain white space and it must accept -d for uncompress. * compress server fast * compress server best + * compress server custom + Specify server_custom_compress "PROG" + PROG must not contain white space and it must accept -d for uncompress. Note that some tape devices do compression and this option has nothing to do with whether that is used. If hardware compression is used (usually - via a particular tape device name or mt option), AMANDA (software) + via a particular tape device name or mt option), Amanda (software) compression should be disabled. dumpcycle int Default: 10 days. The number of days in the backup cycle. Each disk using - this set of options will get a full backup at least this often. Setting + this set of options will get a full backup at least this of ten. Setting this to zero tries to do a full backup each run. + encrypt [none|client|server] + Default: none. To encrypt backup images, it can do so either on the + backup client host before it crosses the network or on the tape server + host as it goes from the network into the holding disk or to tape. + So the encrypt options line may be one of: + + * encrypt none + * encrypt client + Specify client_encrypt "PROG" + PROG must not contain white space. + Specify client_decrypt_option "decryption-parameter" Default: "-d" + decryption-parameter must not contain white space. + (See dumptype server-encrypt-fast in example/amanda.conf for reference) + * encrypt server + Specify server_encrypt "PROG" + PROG must not contain white space. + Specify server_decrypt_option "decryption-parameter" Default: "-d" + decryption-parameter must not contain white space. + (See dumptype client-encrypt-nocomp in example/amanda.conf for + reference) + + estimate client|calcsize|server - Default: client. Determine the way AMANDA does it's estimate. + Default: client. Determine the way Amanda does it's estimate. * client: Use the same program as the dumping program, this is the most accurate @@ -561,9 +289,13 @@ The dumptype options and values are: Default: file. There are two exclude lists, exclude file and exclude list. With exclude file , the string is a GNU-tar exclude expression. With exclude list , the string is a file name on the client containing - GNU-tar exclude expressions. + GNU-tar exclude expressions. The path to the specified exclude list file, + if present (see description of 'optional' below), must be readable by the + Amanda user. All exclude expressions are concatenated in one file and passed to GNU- tar as an --exclude-from argument. + Exclude expressions must always be specified as relative to the head + directory of the DLE. With the append keyword, the string is appended to the current list, without it, the string overwrites the list. If optional is specified for exclude list, then amcheck will not complain @@ -579,7 +311,7 @@ The dumptype options and values are: holdingdisk boolean Default: yes. Whether a holding disk should be used for these backups or whether they should go directly to tape. If the holding disk is a portion - of another file system that AMANDA is backing up, that file system should + of another file system that Amanda is backing up, that file system should refer to a dumptype with holdingdisk set to no to avoid backing up the holding disk into itself. @@ -594,9 +326,16 @@ The dumptype options and values are: list. With include file , the string is a glob expression. With include list , the string is a file name on the client containing glob expressions. - All include expressions are expanded by AMANDA, concatenated in one file + All include expressions are expanded by Amanda, concatenated in one file and passed to GNU-tar as a --files-from argument. They must start with "./" and contain no other "/". + Include expressions must always be specified as relative to the head + directory of the DLE. + + Note + + For globbing to work at all, even the limited single level, the top level + directory of the DLE must be readable by the Amanda user. With the append keyword, the string is appended to the current list, without it, the string overwrites the list. If optional is specified for include list, then amcheck will not complain @@ -615,7 +354,7 @@ The dumptype options and values are: server host. maxdumps int - Default: 1. The maximum number of backups from a single host that AMANDA + Default: 1. The maximum number of backups from a single host that Amanda will attempt to run in parallel. See also the main section parameter inparallel. @@ -625,7 +364,7 @@ The dumptype options and values are: overpromoted. priority string - Default: medium. When there is no tape to write to, AMANDA will do + Default: medium. When there is no tape to write to, Amanda will do incremental backups in priority order to the holding disk. The priority may be high (2), medium (1), low (0) or a number of your choice. @@ -643,7 +382,7 @@ The dumptype options and values are: skip-full boolean Default: no. If true and planner has scheduled a full backup, these disks will be skipped, and full backups should be run off-line on these days. - It was reported that AMANDA only schedules level 1 incrementals in this + It was reported that Amanda only schedules level 1 incrementals in this configuration; this is probably a bug. skip-incr boolean @@ -660,7 +399,7 @@ The dumptype options and values are: standard - The standard AMANDA schedule. + The standard Amanda schedule. nofull Never do full backups, only level 1 incrementals. @@ -673,14 +412,38 @@ The dumptype options and values are: incronly Only do incremental dumps. amadmin force should be used to tell - AMANDA that a full dump has been performed off-line, so that it + Amanda that a full dump has been performed off-line, so that it resets to level 1. It is similar to skip-full, but with incronly full dumps may be scheduled manually. Unfortunately, it appears - that AMANDA will perform full backups with this configuration, + that Amanda will perform full backups with this configuration, which is probably a bug. -The following dumptype entries are predefined by AMANDA: + tape_splitsize int + Default: none. Split dump file on tape into pieces of a specified size. + This allows dumps to be spread across multiple tapes, and can potentially + make more efficient use of tape space. Note that if this value is too + large (more than half the size of the average dump being split), + substantial tape space can be wasted. If too small, large dumps will be + split into innumerable tiny dumpfiles, adding to restoration complexity. + A good rule of thumb, usually, is 1/10 of the size of your tape. + + split_diskbuffer string + Default: none. When dumping a split dump in PORT-WRITE mode (usually + meaning "no holding disk"), buffer the split chunks to a file in the + directory specified by this option. + + fallback_splitsize int + Default: 10M. When dumping a split dump in PORT-WRITE mode, if no + split_diskbuffer is specified (or if we somehow fail to use our + split_diskbuffer), we must buffer split chunks in memory. This specifies + the maximum size split chunks can be in this scenario, and thus the + maximum amount of memory consumed for in-memory splitting. The size of + this buffer can be changed from its (very conservative) default to a + value reflecting the amount of memory that each taper process on the dump + server may reasonably consume. + +The following dumptype entries are predefined by Amanda: define dumptype no-compress { compress none @@ -727,7 +490,7 @@ record option: record no } -AMANDA provides a dumptype named global in the sample amanda.conf file that all +Amanda provides a dumptype named global in the sample amanda.conf file that all dumptypes should reference. This provides an easy place to make changes that will affect every dumptype. @@ -757,8 +520,8 @@ The tapetype options and values are: length int Default: 2000 kbytes. How much data will fit on a tape. - Note that this value is only used by AMANDA to schedule which backups - will be run. Once the backups start, AMANDA will continue to write to a + Note that this value is only used by Amanda to schedule which backups + will be run. Once the backups start, Amanda will continue to write to a tape until it gets an error, regardless of what value is entered for length (but see the section OUTPUT DRIVERS in the amanda(8) manpage for exceptions). @@ -767,12 +530,12 @@ The tapetype options and values are: Default: 32. How much data will be written in each tape record expressed in KiloBytes. The tape record size (= blocksize) can not be reduced below the default 32 KBytes. The parameter blocksize can only be raised if - AMANDA was compiled with the configure option --with-maxtapeblocksize=N + Amanda was compiled with the configure option --with-maxtapeblocksize=N set with "N" greater than 32 during configure. file-pad boolean Default: true. If true, every record, including the last one in the file, - will have the same length. This matches the way AMANDA wrote tapes prior + will have the same length. This matches the way Amanda wrote tapes prior to the availability of this parameter. It may also be useful on devices that only support a fixed blocksize. Note that the last record on the tape probably includes trailing null @@ -786,11 +549,11 @@ The tapetype options and values are: speed int Default: 200 bps. How fast the drive will accept data, in bytes per - second. This parameter is NOT currently used by AMANDA. + second. This parameter is NOT currently used by Amanda. lbl-templ string A PostScript template file used by amreport to generate labels. Several - sample files are provided with the AMANDA sources in the example + sample files are provided with the Amanda sources in the example directory. See the amreport(8) man page for more information. In addition to options, another tapetype name may be entered, which makes this @@ -825,11 +588,11 @@ name is the name of this type of network interface. It is referenced from the disklist file. Note that these sections define network interface characteristics, not the actual interface that will be used. Nor do they impose limits on the bandwidth -that will actually be taken up by AMANDA. AMANDA computes the estimated +that will actually be taken up by Amanda. Amanda computes the estimated bandwidth each file system backup will take based on the estimated size and time, then compares that plus any other running backups with the limit as another of the criteria when deciding whether to start the backup. Once a -backup starts, AMANDA will use as much of the network as it can leaving +backup starts, Amanda will use as much of the network as it can leaving throttling up to the operating system and network hardware. The interface options and values are: @@ -848,14 +611,14 @@ little use. AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion, major update, splitting SEE ALSO -amanda(8), +amanda(8), amanda-client.conf(5), amcrypt(8), aespipe(1), ------------------------------------------------------------------------------- -Prev Up Next -amanda Home amcheck +Prev Up Next +amanda Home amanda-client.conf diff --git a/docs/amcheck.8.txt b/docs/amcheck.8.txt index c3c0616..91bcb32 100644 --- a/docs/amcheck.8.txt +++ b/docs/amcheck.8.txt @@ -1,21 +1,22 @@ amcheck -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amcheck  run AMANDA self-checks +amcheck  run Amanda self-checks Synopsis -amcheck [-mwsclt ] [-Maddress ] config [ host [disk...]...] +amcheck [-am] [-w] [-sclt] [ -M | address ]* config [ host | [disk]*]* [ -o | +configoption ]* DESCRIPTION -Amcheck runs a number of self-checks on both the AMANDA tape server host and -the AMANDA client hosts. +Amcheck runs a number of self-checks on both the Amanda tape server host and +the Amanda client hosts. On the tape server host, amcheck can go through the same tape checking used at the start of the nightly amdump run to verify the correct tape for the next run is mounted. @@ -23,7 +24,7 @@ Amcheck can also do a self-check on all client hosts to make sure each host is running and that permissions on filesystems to be backed up are correct. You can specify many host/disk expressions, only disks that match an expression will be checked. All disks are checked if no expressions are given. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. OPTIONS @@ -42,12 +43,12 @@ OPTIONS Run the tape tests on the server host. -w - Enables a destructive check for write-protection on the tape (which would + Enables a DESTRUCTIVE check for write-protection on the tape (which would otherwise cause the subsequent amdump to fail). If the tape is writable, - this check causes all data after the tape label to be erased (actually - depends on the device driver: there is no portable non-destructive way to - check for write-protection). The check implies -t and is only made if the - tape is otherwise correct. + this check causes all data after the tape label to be erased. If the + label_new_tapes option is enabled, this check may ERASE any non-Amanda + tape in the drive or changer. The check enable the tape tests on the + server host and is only made if the tape is otherwise correct. -m Nothing is printed, but mail is sent if any errors are detected. The mail @@ -57,10 +58,16 @@ OPTIONS -a Like -m but the mail is always sent. - -Maddress + -M address Mail the report to address instead of the mailto value from amanda.conf. Implies -m. + host [disk]* + Specify the host and disk on which the command will work. + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + The default is -cs. EXAMPLES @@ -69,21 +76,21 @@ In this example, both the tape server and client tests are run. The results are displayed on standard output. % amcheck daily - AMANDA Tape Server Host Check + Amanda Tape Server Host Check ----------------------------- /amanda2/amanda/work: 911475 KB disk space available, that's plenty. NOTE: skipping tape-writable test. Tape VOL10 label ok. Server check took 34.966 seconds. - AMANDA Backup Client Hosts Check + Amanda Backup Client Hosts Check -------------------------------- WARNING: northstar: selfcheck request timed out. Host down? WARNING: drinkme: selfcheck request timed out. Host down? WARNING: scruffy: selfcheck request timed out. Host down? Client check: 136 hosts checked in 51.945 seconds, 3 problems found. - (brought to you by AMANDA 2.4.5) + (brought to you by Amanda 2.5.0) In this example, if the line mailto csd-amanda is in amanda.conf, mail will be sent to csd-amanda if the server check returns an error. @@ -143,7 +150,7 @@ MESSAGES instead of runuser. ERROR: program dir directory: not accessible - (error) The directory AMANDA expects to find its auxiliary programs in, + (error) The directory Amanda expects to find its auxiliary programs in, directory, is not accessible. ERROR: program program: does not exist @@ -169,21 +176,21 @@ MESSAGES log - for the AMANDA log directory (see logdir in amanda.conf) + for the Amanda log directory (see logdir in amanda.conf) oldlog for the directory that holds the old log files (see logdir in amanda.conf) info - for an AMANDA database information directory (see curinfo in + for an Amanda database information directory (see curinfo in amanda.conf) or index - for an AMANDA index directory (see indexdir in amanda.conf) + for an Amanda index directory (see indexdir in amanda.conf) tapelist - for the AMANDA tapelist directory (see tapelist in amanda.conf) + for the Amanda tapelist directory (see tapelist in amanda.conf) NOTE: XXX dir directory: does not exist @@ -216,16 +223,16 @@ MESSAGES not allow search permission. ERROR: tape list tapelist: not writable - (error) AMANDA tape list file tapelist (see tapelist in amanda.conf) is + (error) Amanda tape list file tapelist (see tapelist in amanda.conf) is not writable or was not found. ERROR: tape list tapelist: parse error - (error) AMANDA tape list file tapelist (see tapelist in amanda.conf) + (error) Amanda tape list file tapelist (see tapelist in amanda.conf) could not be read or parsed. WARNING: tapedev is /dev/null, dumps will be thrown away (warning) The tapedev parameter in amanda.conf is set to /dev/null and - AMANDA uses that when debugging to throw all the dump images away. + Amanda uses that when debugging to throw all the dump images away. WARNING: hold file file exists (info) Hold file file exists and will cause amdump to pause at the @@ -265,7 +272,7 @@ MESSAGES enough for what is requested in amanda.conf. Holding disk disk: F KB disk space available, using U KB - (info) Holding disk disk has F KBytes of free space and AMANDA will be + (info) Holding disk disk has F KBytes of free space and Amanda will be using up to U Kbytes. WARNING: if a tape changer is not available, runtapes must be set to 1. @@ -302,7 +309,7 @@ MESSAGES (info) The tape write test (see the -w option) was not enabled. WARNING: skipping tape test because amdump or amflush seem to be running, - WARNING: if they are not, you must run amcleanup, + WARNING: if they are not, you must run amcleanup (warning) It looked to amcheck like either amdump or amflush were running because a log file or amdump file exists. If they are not running, you probably need to run amcleanup to clear up a previous failure. Otherwise, @@ -341,7 +348,7 @@ MESSAGES ERROR: host NAK: [NAK parse failed] (error) Amcheck could not parse the negative acknowledgment error from - host. There might be an AMANDA version mismatch between the host running + host. There might be an Amanda version mismatch between the host running amcheck and host. ERROR: host [mutual-authentication failed] @@ -354,7 +361,7 @@ MESSAGES AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO @@ -362,6 +369,6 @@ SEE ALSO amanda(8), amdump(8) ------------------------------------------------------------------------------- -Prev Up Next -amanda.conf Home amcheckdb +Prev Up Next +amanda-client.conf Home amcheckdb diff --git a/docs/amcheckdb.8.txt b/docs/amcheckdb.8.txt index c5b7ef3..8821ca6 100644 --- a/docs/amcheckdb.8.txt +++ b/docs/amcheckdb.8.txt @@ -1,12 +1,12 @@ amcheckdb -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amcheckdb  check AMANDA database for tape consistency +amcheckdb  check Amanda database for tape consistency Synopsis @@ -14,9 +14,9 @@ amcheckdb config DESCRIPTION -Amcheckdb verifies that every tape mentioned in the AMANDA database is still +Amcheckdb verifies that every tape mentioned in the Amanda database is still valid in the tapelist file. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. EXAMPLE @@ -36,7 +36,7 @@ in the tapelist file: AUTHOR Adrian T. Filipi-Martin : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/amcleanup.8.txt b/docs/amcleanup.8.txt index 6ad14ed..8bb79bc 100644 --- a/docs/amcleanup.8.txt +++ b/docs/amcleanup.8.txt @@ -1,12 +1,12 @@ amcleanup -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amcleanup  run the AMANDA cleanup process after a failure +amcleanup  run the Amanda cleanup process after a failure Synopsis @@ -14,21 +14,21 @@ amcleanup config DESCRIPTION -Amcleanup generates the AMANDA Mail Report and updates the AMANDA databases +Amcleanup generates the Amanda Mail Report and updates the Amanda databases after a system failure on a tape server host. This cleanup process is normally done automatically as part of the amdump program, but if amdump cannot complete for some reason (usually because of a tape server host crash), amcleanup must be run some time later (usually during system boot). -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. EXAMPLES -This example runs the AMANDA cleanup process by hand after a failure. +This example runs the Amanda cleanup process by hand after a failure. % amcleanup daily Putting the following line in a system boot script (e.g. /etc/rc.local) runs -the AMANDA cleanup process as part of the reboot, eliminating the need to run +the Amanda cleanup process as part of the reboot, eliminating the need to run it by hand. /usr/local/sbin/amcleanup daily @@ -41,7 +41,7 @@ If nothing needs to be done, amcleanup exits normally with the message: AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO @@ -49,6 +49,6 @@ SEE ALSO amanda(8), amdump(8) ------------------------------------------------------------------------------- -Prev Up Next -amcheckdb Home amdd +Prev Up Next +amcheckdb Home amcrypt diff --git a/docs/amcrypt-asym-ossl.8.txt b/docs/amcrypt-asym-ossl.8.txt new file mode 100644 index 0000000..5d287b4 --- /dev/null +++ b/docs/amcrypt-asym-ossl.8.txt @@ -0,0 +1,86 @@ + + amcrypt-ossl-asym +Prev Chapter 36. The Amanda Manual Pages. Next + +------------------------------------------------------------------------------- + +Name + +amcrypt-ossl-asym  crypt program for Amanda asymmetric data encryption using +OpenSSL + +Synopsis + +amcrypt-ossl-asym [-d] + +DESCRIPTION + +amcrypt-ossl-asym uses OpenSSL to encrypt and decrypt data. OpenSSL is +available from www.openssl.org. OpenSSL offers a wide variety of cipher choices +( amcrypt-ossl-asym defaults to 256-bit AES) and can use hardware cryptographic +accelerators on several platforms. +amcrypt-ossl-asym will search for the OpenSSL program in the following +directories: /bin:/usr/bin:/usr/local/bin:/usr/ssl/bin:/usr/local/ssl/bin. + +GENERATING PUBLIC AND PRIVATE KEYS + +RSA keys can be generated with the standard OpenSSL commands, e.g.: + + $ cd /var/lib/amanda + $ openssl genrsa -aes128 -out backup-key.pem 1024 + Generating RSA private key, 1024 bit long modulus + [...] + Enter pass phrase for backup-key.pem: ENTER YOUR PASS PHRASE + Verifying - Enter pass phrase for backup-key.pem: ENTER YOUR PASS PHRASE + + $ openssl rsa -in backup-key.pem -pubout -out backup-pubkey.pem + Enter pass phrase for backup-key.pem: ENTER YOUR PASS PHRASE + Writing RSA key + +To generate a private key without a passphrase, omit the -aes128 option. See +openssl_genrsa(1) for more key generation options. +Note that it is always possible to generate the public key from the private +key. + +KEY AND PASSPHRASE MANAGEMENT + +amcrypt-ossl-asym uses the public key to encrypt data. The security of the data +does not depend on the confidentiality of the public key. The private key is +used to decrypt data, and must be protected. Encrypted backup data cannot be +recovered without the private key. The private key may optionally be encrypted +with a passphrase. +While the public key must be online at all times to perorm backups, the private +key and optional passphrase are only needed to restore data. It is recommended +that the latter be stored offline all other times. For example, you could keep +the private key on removable media, and copy it into place for a restore; or +you could keep the private key online, encrypted with a passphrase that is +present only for a restore. +OpenSSL's key derivation routines use a salt to guard against dictionary +attacks on the pass phrase; still it is important to pick a pass phrase that is +hard to guess. The Diceware method (see www.diceware.com) can be used to create +passphrases that are difficult to guess and easy to remember. + +FILES + + + + /var/lib/amanda/backup-privkey.pem + File containing the RSA private key. It should not be readable by any + user other than the Amanda user. + + /var/lib/amanda/backup-pubkey.pem + File containing the RSA public key. + + /var/lib/amanda/.pass + File containing the pass phrase. It should not be readable by any user + other than the Amanda user. + + +SEE ALSO + +amanda(8), amanda.conf(5), openssl(1), amcrypt-ossl(8) +------------------------------------------------------------------------------- + +Prev Up Next +amcrypt-ossl Home amdd + diff --git a/docs/amcrypt-ossl.8.txt b/docs/amcrypt-ossl.8.txt new file mode 100644 index 0000000..c3eb0b6 --- /dev/null +++ b/docs/amcrypt-ossl.8.txt @@ -0,0 +1,50 @@ + + amcrypt-ossl +Prev Chapter 36. The Amanda Manual Pages. Next + +------------------------------------------------------------------------------- + +Name + +amcrypt-ossl  crypt program for Amanda symmetric data encryption using OpenSSL + +Synopsis + +amcrypt-ossl [-d] + +DESCRIPTION + +amcrypt-ossl uses OpenSSL to encrypt and decrypt data. OpenSSL is available +from www.openssl.org. OpenSSL offers a wide variety of cipher choices +( amcrypt-ossl defaults to 256-bit AES) and can use hardware cryptographic +accelerators on several platforms. +amcrypt-ossl will search for the OpenSSL program in the following directories: +/bin:/usr/bin:/usr/local/bin:/usr/ssl/bin:/usr/local/ssl/bin. + +PASSPHRASE MANAGEMENT + +amcrypt-ossl uses the same pass phrase to encrypt and decrypt data. It is very +important to store and protect the pass phrase properly. Encrypted backup data +can only be recovered with the correct passphrase. +OpenSSL's key derivation routines use a salt to guard against dictionary +attacks on the pass phrase; still it is important to pick a pass phrase that is +hard to guess. The Diceware method (see www.diceware.com) can be used to create +passphrases that are difficult to guess and easy to remember. + +FILES + + + + /var/lib/amanda/.am_passphrase + File containing the pass phrase. It should not be readable by any user + other than the Amanda user. + + +SEE ALSO + +amanda(8), amanda.conf(5), openssl(1), amcrypt-ossl-asym(8) +------------------------------------------------------------------------------- + +Prev Up Next +amcrypt Home amcrypt-ossl-asym + diff --git a/docs/amcrypt.8.txt b/docs/amcrypt.8.txt new file mode 100644 index 0000000..1282fd3 --- /dev/null +++ b/docs/amcrypt.8.txt @@ -0,0 +1,56 @@ + + amcrypt +Prev Chapter 36. The Amanda Manual Pages. Next + +------------------------------------------------------------------------------- + +Name + +amcrypt  reference crypt program for Amanda symmetric data encryption + +Synopsis + +amcrypt + +DESCRIPTION + +amcrypt requires aespipe, uuencode and gpg to work. Aespipe is available from +http://loop-aes.sourceforge.net +amcrypt will search for the aespipe program in the following directories: /usr/ +bin:/usr/local/bin:/sbin:/usr/sbin. +amcrypt calls amaespipe and pass the passphrase through file descriptor 3. The +passphrase should be stored in ~amanda/.am_passphrase. + +How to create encryption keys for amcrypt + +1. Create 65 random encryption keys and encrypt those keys using gpg. Reading +from /dev/random may take indefinitely long if kernel's random entropy pool is +empty. If that happens, do some other work on some other console (use keyboard, +mouse and disks). +head -c 2925 /dev/random | uuencode -m - | head -n 66 | tail -n 65 \ | gpg -- +symmetric -a > ~amanda/.gnupg/am_key.gpg +This will ask for a passphrase. Remember this passphrase as you will need it in +the next step. +2. Store the passphrase inside the home-directory of the AMANDA-user and +protect it with proper permissions: + + echo my_secret_passphrase > ~amanda/.am_passphrase + chown amanda:disk ~amanda/.am_passphrase + chmod 700 ~amanda/.am_passphrase + + +Key and Passphrase + +amcrypt uses the same key to encrypt and decrypt data. +It is very important to store and protect the key and the passphrase properly. +Encrypted backup data can only be recovered with the correct key and +passphrase. + +SEE ALSO + +amanda(8), amanda.conf(5), aespipe(1), amaespipe(8), gpg(1) +------------------------------------------------------------------------------- + +Prev Up Next +amcleanup Home amcrypt-ossl + diff --git a/docs/amdd.8.txt b/docs/amdd.8.txt index 149d464..13ea42b 100644 --- a/docs/amdd.8.txt +++ b/docs/amdd.8.txt @@ -1,12 +1,12 @@ amdd -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amdd  AMANDA version of dd +amdd  Amanda version of dd Synopsis @@ -15,13 +15,13 @@ amdd [-d ] [if=input] [of=output] [bs=blocksize] [skip=count] [count=count] DESCRIPTION Amdd provides just enough of the standard UNIX dd command for the needs of -AMANDA. This is handy when doing a full restore and the standard dd program has +Amanda. This is handy when doing a full restore and the standard dd program has not yet been found. -Amdd also provides access to the AMANDA output drivers that support various +Amdd also provides access to the Amanda output drivers that support various tape simulations. This may be used for debugging or to convert from one format to another. -See the amanda(8) man page for more details about AMANDA. See the OUTPUT -DRIVERS section of amanda(8) for more information on the AMANDA output drivers. +See the amanda(8) man page for more details about Amanda. See the OUTPUT +DRIVERS section of amanda(8) for more information on the Amanda output drivers. OPTIONS @@ -72,7 +72,7 @@ OPTIONS AUTHOR Marc Mengel , John R. Jackson : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO @@ -80,6 +80,6 @@ SEE ALSO amanda(8) ------------------------------------------------------------------------------- -Prev Up Next -amcleanup Home amdump +Prev Up Next +amcrypt-ossl-asym Home amdump diff --git a/docs/amdump.8.txt b/docs/amdump.8.txt index 9b03ee8..6a0b299 100644 --- a/docs/amdump.8.txt +++ b/docs/amdump.8.txt @@ -1,20 +1,20 @@ amdump -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amdump  back up all disks in an AMANDA configuration +amdump  back up all disks in an Amanda configuration Synopsis -amdump config [ host [disk...]...] +amdump config [ host | [disk]*]* [ -o | configoption ]* DESCRIPTION -Amdump switches to the appropriate AMANDA configuration directory, e.g. /usr/ +Amdump switches to the appropriate Amanda configuration directory, e.g. /usr/ local/etc/amanda/config, then attempts to back up every disk specified by the amanda.conf file. Amdump is normally run by cron. You can specify many host/disk expressions, only disks that match an expression @@ -24,7 +24,18 @@ is removed before starting the backups. This allows scheduled backups to be delayed when circumstances warrant, for example, if the tape device is being used for some other purpose. While waiting, amdump checks for the hold file every minute. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. + +OPTIONS + + + + host [disk]* + Specify the host and disk on which the command will work. + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + EXAMPLE @@ -54,7 +65,7 @@ MESSAGES AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO @@ -62,6 +73,6 @@ SEE ALSO amanda(8), amcheck(8), amcleanup(8), amrestore(8), amflush(8), cron(8) ------------------------------------------------------------------------------- -Prev Up Next -amdd Home amflush +Prev Up Next +amdd Home amfetchdump diff --git a/docs/amfetchdump.8.txt b/docs/amfetchdump.8.txt new file mode 100644 index 0000000..639c09d --- /dev/null +++ b/docs/amfetchdump.8.txt @@ -0,0 +1,147 @@ + + amfetchdump +Prev Chapter 36. The Amanda Manual Pages. Next + +------------------------------------------------------------------------------- + +Name + +amfetchdump  extract backup images from multiple Amanda tapes. + +Synopsis + +amfetchdump [-pcClawns] [-d device] [-O directory] [-i logfile] [-b blocksize] +config hostname [ disk [ date [ level [ hostname [...] ] ] ] ] [ -o | +configoption ]* + +DESCRIPTION + +Amfetchdump pulls one or more matching dumps from tape or from the holding +disk, handling the reassembly of multi-tape split dump files as well as any +tape autochanger operations. +It will automatically use the logs created by amdump(8) to locate available +dumps on tape, in the same way that the find feature of amadmin(8) lists +available dumps. If these logs are unavailable, it can search tape-by-tape to +find what it needs, and can generate new logs to serve as an emergency tape +inventory. +The hostname, diskname, datestamp, and level dump pattern-matching works as in +amrestore(8), with the added requirement that at minimum a hostname must be +specified when not in inventory mode. +Unless -p is used, backup images are extracted to files in the current +directory named: +hostname.diskname.datestamp.dumplevel + +OPTIONS + + + + -p + Pipe exactly one complete dump file to stdout, instead of writing the + file to disk. This will restore only the first matching dumpfile (where + "first" is determined by the dump log search facility). + + -d device + Restore from this tape device instead of the default. + + -O directory + Output restored files to this directory, instead of to the current + working directory. + + -c + Compress output, fastest method available. + + -C + Compress output, smallest file size method available. + + -l + Leave dumps in the compressed/uncompressed state in which they were found + on tape. By default, amfetchdump will automatically uncompress when + restoring. + + -a + Assume that all tapes are already available, via tape changer or + otherwise, instead of prompting the operator to ensure that all tapes are + loaded. + + -i filename + Generate an inventory of all dumps "seen" on the tapes we search, for + later use as a log. + + -w + Wait to put split dumps together until all chunks have been restored. + Normally, amfetchdump will attempt to read pieces of a split file from + tape in order, so that it can assemble them simply by appending each file + to the first. This option disables the appending behavior, and instead + restores each piece as an individual file and reassembles them only after + all have been restored. + + Note + + This requires at least double the size of your dump in free disk space, + in order to build the final assembled dumpfile. + This behavior is implicitly invoked in circumstances where knowing the + location of all dumps on tape in advance is not possible, such as when + you are restoring without log files. + + -n + Do not reassemble split dump files at all, just restore each piece as an + individual file. + + -s + Do not fast-forward straight to needed files on tape. This will slow down + most restores substantially. Only use this option if your tape drive does + not properly support the fast-forward operation. + + -b blocksize + Force a particular block size when reading from tapes. This value will + usually be autodetected, and should not normally need to be set. + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + + +EXAMPLES + +All the examples here assume your configuration is called SetA. +Here's a simple case, restoring all known dumps of the host vanya to the +current working directory. + +$ amfetchdump SetA vanya +A more likely scenario involves restoring a particular dump from a particular +date. We'll pipe this one to GNU-tar as well, to automatically extract the +dump. + +$ amfetchdump -p SetA vanya /home 20051020 | gtar -xvpf - +In a situation where all of our dump logs have been wiped out, we could also +use amfetchdump to inventory our tapes and recreate an imitation of those logs, +which we'll send to stdout for casual perusal. + +$ amfetchdump -i - SetA +Note that you can specify a restore while in inventory mode, and amfetchdump +will continue searching for more dumps from this host even after successfully +restoring a dump, inventorying all the while. If your backup searcher has been +trashed, this is a handy way to recover what you have. + +$ amfetchdump -i /var/amanda/log SetA backupserver + +CAVEATS + +Amfetchdump is dependent on accessing your server's config, tape changer, and +(normally) dump logs. As such, it's not necessarily the most useful tool when +those have all been wiped out and you desperately need to pull things from your +tape. Pains have been taken to make it as capable as possible, but for +seriously minimialist restores, look to amrestore(8) or dd(8) instead. + +AUTHOR + +John Stange, , National Academies Press +Ian Turner, : XML-conversion + +SEE ALSO + +amanda(8), amadmin(8), amrestore(8), tar(1) restore(8) +------------------------------------------------------------------------------- + +Prev Up Next +amdump Home amflush + diff --git a/docs/amflush.8.txt b/docs/amflush.8.txt index 399bf06..8135968 100644 --- a/docs/amflush.8.txt +++ b/docs/amflush.8.txt @@ -1,21 +1,22 @@ amflush -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amflush  flush AMANDA backup files from holding disk to tape +amflush  flush Amanda backup files from holding disk to tape Synopsis -amflush [-b ] [-f ] [-s ] [ -D datestamp ...] config [ host [disk...]...] +amflush [-b] [-f] [-s] [ -D | datestamp ]* config [ host | [disk]*]* [ -o | +configoption ]* DESCRIPTION -Amflush writes AMANDA backups from the holding disks to tape, and updates the -AMANDA info database and tapelist accordingly. Backups may stay in a holding +Amflush writes Amanda backups from the holding disks to tape, and updates the +Amanda info database and tapelist accordingly. Backups may stay in a holding disk when something is wrong with the tape at the time amdump is run. When this happens, the problem must be corrected and amflush run by hand. @@ -42,15 +43,21 @@ OPTIONS EXPRESSION" section of amanda(8) for a description. -D 20001225-7 will flush all dumps from 25 december 2000 to 27 december 2000. + host [disk]* + Specify the host and disk on which the command will work. + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + You can specify many host/disk expressions, only disks that match an expression will be flushed. All disks are flushed if no expressions are given. see the "HOST & DISK EXPRESSION" section of amanda(8) for a description. Amflush will look in the holding disks specified by the amanda.conf file in / -usr/local/etc/amanda/config for any non-empty AMANDA work directories. It then +usr/local/etc/amanda/config for any non-empty Amanda work directories. It then prompts you to select a directory or to process all of the directories. The work directories in the holding disks are named by the date at the time amdump was run, e.g. 19910215. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. EXAMPLE @@ -60,10 +67,10 @@ updates the databases and sends a mail report similar to amdump(8). % amflush daily Scanning /amanda-hold... - 20001113: found AMANDA directory. - 20001114: found AMANDA directory. + 20001113: found Amanda directory. + 20001114: found Amanda directory. - Multiple AMANDA directories, please pick one by letter: + Multiple Amanda directories, please pick one by letter: A. 20001113 B. 20001114 Select directories to flush [A..B]: [ALL] all @@ -80,7 +87,7 @@ updates the databases and sends a mail report similar to amdump(8). AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO @@ -88,6 +95,6 @@ SEE ALSO amanda(8), amdump(8) ------------------------------------------------------------------------------- -Prev Up Next -amdump Home amgetconf +Prev Up Next +amfetchdump Home amgetconf diff --git a/docs/amgetconf.8.txt b/docs/amgetconf.8.txt index 46a3805..2282127 100644 --- a/docs/amgetconf.8.txt +++ b/docs/amgetconf.8.txt @@ -1,6 +1,6 @@ amgetconf -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- @@ -10,11 +10,11 @@ amgetconf  look up amanda.conf variables Synopsis -amgetconf [config] parameter +amgetconf [config] parameter [ -o | configoption ]* DESCRIPTION -Amgetconf looks up parameters in amanda.conf, the AMANDA configuration file, or +Amgetconf looks up parameters in amanda.conf, the Amanda configuration file, or from the build and runtime environment, and returns their corresponding value. If config is not specified, amgetconf assumes it is being run from the configuration directory and that amanda.conf is present. @@ -25,12 +25,20 @@ error and will return an empty string as the value. Flag variables (e.g. USE_AMANDAHOSTS) will return 1 if the flag is set or an empty string if it is not. If parameter begins with dbopen., the string following the period is a program -name and an AMANDA debug file will be created for the caller. The name of the +name and an Amanda debug file will be created for the caller. The name of the file is returned. If parameter begins with dbclose., the string following the period is a program name previously used with dbopen., followed by a colon (:) and the previously opened file name. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. + +OPTIONS + + + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + EXAMPLE diff --git a/docs/amlabel.8.txt b/docs/amlabel.8.txt index 6fb8d17..51709a0 100644 --- a/docs/amlabel.8.txt +++ b/docs/amlabel.8.txt @@ -1,41 +1,49 @@ amlabel -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amlabel  label an AMANDA tape +amlabel  label an Amanda tape Synopsis -amlabel [-f ] config label [ slot slot ] +amlabel [-f ] config label [ slot | slot ] [ -o | configoption ]* DESCRIPTION -All AMANDA tapes must be pre-labeled before they are used. AMANDA verifies the +All Amanda tapes must be pre-labeled before they are used. Amanda verifies the label in amdump and amflush before writing to make sure the proper tape is loaded. -Amlabel writes an AMANDA label on the tape in the device specified by the +Amlabel writes an Amanda label on the tape in the device specified by the amanda.conf file in /usr/local/etc/amanda/config. Label may be any string that does not contain whitespace and that matches the amanda.conf labelstr regular expression option. It is up to the system administrator to define a naming convention. -Amlabel appends the new tape to the tapelist file so it will be used by AMANDA +Amlabel appends the new tape to the tapelist file so it will be used by Amanda before it reuses any other tapes. When you amlabel multiple tapes, they will be used in the order you amlabel them. -Amlabel will not write the label if the tape contains an active AMANDA tape or +Amlabel will not write the label if the tape contains an active Amanda tape or if the label specified is on an active tape. The -f (force) flag bypasses these verifications. An optional slot may be specified after the tape label. If a tape changer is in use, amlabel will label the tape in the specified slot instead of the currently loaded tape. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. + +OPTIONS + + + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + EXAMPLE -Write an AMANDA label with the string "DMP000" on the tape loaded in the device +Write an Amanda label with the string "DMP000" on the tape loaded in the device named in the tapedev option in /usr/local/etc/amanda/daily/amanda.conf: % amlabel daily DMP000 @@ -55,31 +63,31 @@ MESSAGES expression str from amanda.conf. label label already on a tape - Label label is already listed as an active AMANDA tape. + Label label is already listed as an active Amanda tape. no tpchanger specified in path , so slot command invalid The command line has the slot parameter but the amanda.conf file in path does not have a tape changer configured. reading label label, tape is in another amanda configuration - This tape appears to be a valid AMANDA tape, but label does not match + This tape appears to be a valid Amanda tape, but label does not match labelstr for this configuration so it is probably part of a different - AMANDA configuration. + Amanda configuration. reading label label, tape is active - Tape label appears to already be part of this AMANDA configuration and + Tape label appears to already be part of this Amanda configuration and active, i.e. has valid data on it. no label found, are you sure tape is non-rewinding? While checking that the label was written correctly, amlabel got an error - that might be caused by mis-configuring AMANDA with a rewinding tape + that might be caused by mis-configuring Amanda with a rewinding tape device name instead of a non-rewinding device name for tape. AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/ammt.8.txt b/docs/ammt.8.txt index 5b437ed..353ef27 100644 --- a/docs/ammt.8.txt +++ b/docs/ammt.8.txt @@ -1,12 +1,12 @@ ammt -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -ammt  AMANDA version of mt +ammt  Amanda version of mt Synopsis @@ -15,12 +15,12 @@ ammt [-d ] [ -f | -t | device ] command [count] DESCRIPTION Ammt provides just enough of the standard UNIX mt command for the needs of -AMANDA. This is handy when doing a full restore and the standard mt program has +Amanda. This is handy when doing a full restore and the standard mt program has not yet been found. -Ammt also provides access to the AMANDA output drivers that support various +Ammt also provides access to the Amanda output drivers that support various tape simulations. -See the amanda(8) man page for more details about AMANDA. See the OUTPUT -DRIVERS section of amanda(8) for more information on the AMANDA output drivers. +See the amanda(8) man page for more details about Amanda. See the OUTPUT +DRIVERS section of amanda(8) for more information on the Amanda output drivers. OPTIONS @@ -105,7 +105,7 @@ Many systems only report good data when a tape is in the drive and ready. AUTHOR Marc Mengel , John R. Jackson : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/amoverview.8.txt b/docs/amoverview.8.txt index ccd7964..a5f93e6 100644 --- a/docs/amoverview.8.txt +++ b/docs/amoverview.8.txt @@ -1,23 +1,23 @@ amoverview -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amoverview  display file systems processed by AMANDA over time +amoverview  display file systems processed by Amanda over time Synopsis amoverview [[-config ] config ] [-hostwidth width] [-diskwidth width] [- -skipmissed] [-verbose] +skipmissed] [-last] [-num0] [-togo0] [-verbose] DESCRIPTION -Amoverview displays a chart showing hosts and file systems processed by AMANDA +Amoverview displays a chart showing hosts and file systems processed by Amanda along with the backup level performed each day. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. OPTIONS @@ -33,9 +33,19 @@ OPTIONS Set disk field column width to width characters instead of 20. -skipmissed - Compacts the output by only printing stats for the days AMANDA actually + Compacts the output by only printing stats for the days Amanda actually ran. + -last + Outputs the last status of each disk at the start. Useful for long + tapecycles and/or sparse reports. + + -num0 + Outputs the number of level 0 dumps for each disk. + + -togo0 + Outputs the number of runs until the last level 0 dump is overwritten. + -verbose Amoverview can take a long while on large systems. This option reports intermediate steps while it is working. @@ -53,7 +63,7 @@ You can have an "E" followed by a number if a filesystem ran into end-of-tape once (gives an "E", and later that day, you flush it to a second tape (a number: the level, indicating success). If the flush failed too, you get a double "EE" for that day. -You can also have a double code if you have two tapes in the changer and AMANDA +You can also have a double code if you have two tapes in the changer and Amanda failed to write to tape the first time because it hit end of tape (resulting in "E0", for a full, "E1" for an incremental etc.) or twice with error ("EE"), and may a successful flush afterwards giving maybe "EE0". (Only the latest 2 diff --git a/docs/amplot.8.txt b/docs/amplot.8.txt index 1f71f57..bba73ea 100644 --- a/docs/amplot.8.txt +++ b/docs/amplot.8.txt @@ -1,12 +1,12 @@ amplot -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amplot  visualize the behavior of AMANDA +amplot  visualize the behavior of Amanda Synopsis @@ -14,7 +14,7 @@ amplot [-b ] [-c ] [-e ] [-g ] [-l ] [-p ] [ -t T ] amdump_files DESCRIPTION -Amplot reads an amdump output file that AMANDA generates each run (e.g. +Amplot reads an amdump output file that Amanda generates each run (e.g. amdump.1) and translates the information into a picture format that may be used to determine how your installation is doing and if any parameters need to be changed. Amplot also prints out amdump lines that it either does not understand @@ -26,7 +26,7 @@ the graph. The awk program is written in an enhanced version of awk, such as GNU awk (gawk version 2.15 or later) or nawk. During execution, amplot generates a few temporary files that gnuplot uses. These files are deleted at the end of execution. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. OPTIONS @@ -80,7 +80,7 @@ AUTHOR Olafur Gudmundsson , Trusted Information Systems, formerly at University of Maryland, College Park: Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion BUGS diff --git a/docs/amrecover.8.txt b/docs/amrecover.8.txt index f957e7d..0833bc8 100644 --- a/docs/amrecover.8.txt +++ b/docs/amrecover.8.txt @@ -1,47 +1,53 @@ amrecover -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amrecover  AMANDA index database browser +amrecover  Amanda index database browser Synopsis -amrecover [[-C ] config ] [ -s index-server ] [ -t tape-server ] [ -d tape- -device ] +amrecover [[-C ] | config ] [ -s | index-server ] [ -t | tape-server ] [ -d | +tape-device ] [ -o | clientconfigoption ]* DESCRIPTION -Amrecover browses the database of AMANDA index files to determine which tapes +Amrecover browses the database of Amanda index files to determine which tapes contain files to recover. Furthermore, it is able to recover files. In order to restore files in place, you must invoke amrecover from the root of the backed up filesystem, or use lcd to move into that directory, otherwise a directory tree that resembles the backed up filesystem will be created in the current directory. See the examples below for details. -See the amanda(8) man page for more details about AMANDA. +Amrecover will read the amanda-client.conf file and the config/amanda- +client.conf file. +See the amanda(8) man page for more details about Amanda. OPTIONS Note -The listed defaults map to the values you ran the configure-script with. +The Default values are those set at compile-time. Use amrestore to recover +client-encrypted or client-custom-compressed tapes. [ -C ] config - AMANDA configuration (default: daily). + Amanda configuration. -s index-server - Host that runs the index daemon (default: oops). + Host that runs the index daemon. -t tape-server - Host that runs the tape server daemon (default: 192.168.0.10). + Host that runs the tape server daemon. -d tape-device - Tape device to use on the tape server host (default: /dev/nst0). + Tape device to use on the tape server host. + + -o clientconfigoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). COMMANDS @@ -57,8 +63,8 @@ be extracted from the backup system. The following commands are available: Specifies which host to look at backup files for (default: the local host). - setdate YYYY-MM-DD - Set the date (default: today). File listing commands only return + setdate YYYY-MM-DD-HH-MM[-SS] | YYYY-MM-DD + Set the restore time (default: now). File listing commands only return information on backup images for this day, for the day before with the next lower dump level, and so on, until the most recent level 0 backup on or before the specified date is encountered. @@ -67,8 +73,8 @@ be extracted from the backup system. The following commands are available: 1996-07-01 was a level 0 backup 1996-07-02 through 1996-07-05 were level 1 backups 1996-07-06 through 1997-07-08 were level 2 backups - then if 1997-07-08 is the requested date, files from the following days - would be used: + then the command setdate 1997-07-08-00 would yield files from the + following days: 1997-07-08 (the latest level 2 backup) 1997-07-05 (the latest level 1 backup) @@ -86,7 +92,7 @@ be extracted from the backup system. The following commands are available: - setdisk diskname mountpoint + setdisk diskname [mountpoint] Specifies which disk to consider (default: the disk holding the working directory where amrecover is started). It can only be set after the host is set with sethost. Diskname is the device name specified in the @@ -94,17 +100,20 @@ be extracted from the backup system. The following commands are available: host. If mountpoint is not specified, all pathnames will be relative to the (unknown) mount point instead of full pathnames. + listhost [diskdevice] + List all host + listdisk [diskdevice] List all diskname settape [[server]:][tapedev|default] Specifies the host to use as the tape server, and which of its tape devices to use. If the server is omitted, but the colon is not, the - server name reverts to 192.168.0.10, the configure-time default. If the - tape device is omitted, it remains unchanged. To use the default tape - device selected by the tape server, the word default must be specified. - If no argument is specified, or the argument is an empty string, no - changes occur, and the current settings are displayed. + server name reverts to the configure-time default. If the tape device is + omitted, it remains unchanged. To use the default tape device selected by + the tape server, the word default must be specified. If no argument is + specified, or the argument is an empty string, no changes occur, and the + current settings are displayed. If you want amrecover to use your changer, the tapedev must be equal to the amrecover_changer setting on the server. If you need to change the protocol (tape:, rait:, file:, null:) then you @@ -181,7 +190,7 @@ be extracted from the backup system. The following commands are available: list file Display the contents of the restore list. If a file name is specified, the restore list is written to that file. This can be used to manually - extract the files from the AMANDA tapes with amrestore. + extract the files from the Amanda tapes with amrestore. clear Clear the restore list. @@ -211,7 +220,7 @@ The following shows the recovery of an old syslog file. syslog.7: No such file or directory # amrecover AMRECOVER Version 2.4.2. Contacting server on oops ... - 220 oops AMANDA index server (2.4.2) ready. + 220 oops Amanda index server (2.4.2) ready. Setting restore date to today (1997-12-09) 200 Working date set to 1997-12-09. 200 Config set to daily. @@ -336,16 +345,22 @@ ENVIRONMENT PAGER The ls and list commands will use $PAGER to display the file lists. Defaults to more if PAGER is not set. +AMANDA_SERVER If set, $AMANDA_SERVER will be used as index-server. The value +will take precedence over the compiled default, but will be overridden by the - +s switch. +AMANDA_TAPE_SERVER If set, $AMANDA_TAPE_SERVER will be used as tape-server. The +value will take precedence over the compiled default, but will be overridden by +the -t switch. AUTHOR Alan M. McIvor : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO -amanda(8), amrestore(8), readline(3) +amanda(8), amanda-client.conf(5), amrestore(8), amfetchdump(8), readline(3) ------------------------------------------------------------------------------- Prev Up Next diff --git a/docs/amreport.8.txt b/docs/amreport.8.txt index 3f27de1..cb176ca 100644 --- a/docs/amreport.8.txt +++ b/docs/amreport.8.txt @@ -1,23 +1,24 @@ amreport -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amreport  generate a formatted output of statistics for an AMANDA run +amreport  generate a formatted output of statistics for an Amanda run Synopsis -amreport [config] [ -l logfile ] [ -f outputfile ] [ -p postscriptfile ] +amreport [config] [-i] [ -M | address ] [ -l | logfile ] [ -f | outputfile ] +[ -p | postscriptfile ] [ -o | configoption ]* DESCRIPTION Amreport generates a summary report of an amanda(8) backup run. If no configuration name is specified, amanda.conf is read from the current directory. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. OPTIONS @@ -26,6 +27,12 @@ OPTIONS config Name of the configuration to process. + -i + Don't email the report. + + -M address + Mail the report to address instead of the mailto value from amanda.conf. + -l logfile Name of the log file to parse to generate the report. If a log file is not specified, it defaults to the file: @@ -44,10 +51,13 @@ where logdir is the log directory defined in amanda.conf. lpr(1) command. This option has an effect only if the lbl-templ directive is specified in amanda.conf. + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + LABEL PRINTING -AMANDA can print postscript labels describing the contents of tape(s) written +Amanda can print postscript labels describing the contents of tape(s) written in a run. The labels are designed to be folded and inserted into the tape case along with the tape or hole punched and put in a 3-ring binder. Various label templates are provided to format data for different tape sizes. @@ -63,7 +73,7 @@ the system default printer. TEMPLATES -AMANDA provides label templates for the following tape types. These are pretty +Amanda provides label templates for the following tape types. These are pretty generic labels and should be easy to customize for other tape types or particular site needs. diff --git a/docs/amrestore.8.txt b/docs/amrestore.8.txt index 61603ea..2b5f66d 100644 --- a/docs/amrestore.8.txt +++ b/docs/amrestore.8.txt @@ -1,18 +1,18 @@ amrestore -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amrestore  extract backup images from an AMANDA tape +amrestore  extract backup images from an Amanda tape Synopsis -amrestore [ -r | -c | -C ] [ -b blocksize ] [ -f fileno ] [ -l label ] [-p ] [- -h ] tapedevice | holdingfile | [ hostname [ diskname [ datestamp [ hostname -[ diskname [datestamp...]]]]]] +amrestore [ -r | -c | -C ] [ -b | blocksize ] [ -f | fileno ] [ -l | label ] [- +p] [-h] tapedevice | holdingfile [ hostname [ diskname [ datestamp [ hostname +[ diskname [ datestamp | ... ]]]]]] DESCRIPTION @@ -94,6 +94,11 @@ block size, and you should set it to 2. See the example below. If a header is written (-r or -h), only 32 KBytes are output regardless of the tape blocksize. This makes the resulting image usable as a holding file. + + -o configoption + See the "CONFIGURATION OVERWRITE" section in amanda(8). + + EXAMPLES The following does an interactive restore of disk rz3g from host seine, to @@ -132,7 +137,7 @@ AUTHOR James da Silva, , University of Maryland, College Park: Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/amrmtape.8.txt b/docs/amrmtape.8.txt index fd37e97..ffe340a 100644 --- a/docs/amrmtape.8.txt +++ b/docs/amrmtape.8.txt @@ -1,12 +1,12 @@ amrmtape -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amrmtape  remove a tape from the AMANDA database +amrmtape  remove a tape from the Amanda database Synopsis @@ -18,7 +18,7 @@ Amrmtape invalidates the contents of an existing backup tape in the configuration database. This is meant as a recovery mechanism when a good backup is damaged either by faulty hardware or user error, e.g. the tape is eaten by the drive or is overwritten. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. OPTIONS @@ -49,7 +49,7 @@ Remove tape labeled DAILY034 from the DailySet1 configuration. AUTHOR Adrian T. Filipi-Martin : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/amstatus.8.txt b/docs/amstatus.8.txt index fdb9d9a..2f0e1c3 100644 --- a/docs/amstatus.8.txt +++ b/docs/amstatus.8.txt @@ -1,12 +1,12 @@ amstatus -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amstatus  display the state of an AMANDA run +amstatus  display the state of an Amanda run Synopsis @@ -16,11 +16,11 @@ waitdumping ] [--waittaper ] [--dumpingtape ] [--writingtape ] [--finished ] [- DESCRIPTION -Amstatus gives the current state of the AMANDA run specified by the config -configuration. If there is no active AMANDA running, it summarizes the result +Amstatus gives the current state of the Amanda run specified by the config +configuration. If there is no active Amanda running, it summarizes the result of the last run. It may also be used to summarize the results of a previous run. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. OPTIONS @@ -29,7 +29,7 @@ options are given, everything is displayed. [--config] config - Specify the AMANDA configuration you want to display the state for. + Specify the Amanda configuration you want to display the state for. --file amdumpfile Specify an alternate file instead of the amdump or amflush file. diff --git a/docs/amtape.8.txt b/docs/amtape.8.txt index 232cc33..b8f930e 100644 --- a/docs/amtape.8.txt +++ b/docs/amtape.8.txt @@ -1,12 +1,12 @@ amtape -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amtape  user interface to AMANDA tape changer controls +amtape  user interface to Amanda tape changer controls Synopsis @@ -15,14 +15,14 @@ amtape config command [ command options ] DESCRIPTION Amtape performs tape changer control operations. It uses the underlying tape -changer script defined by the tpchanger option for a particular AMANDA +changer script defined by the tpchanger option for a particular Amanda configuration as specified by the config argument. Tape changers maintain a notion of the current and next slot for each configuration. These may or may not correspond to an actual physical state of the device, but do tend to minimize searching through the tape storage slots. If the desired tape is in the current slot, it is likely the next tape needed is in the next slot rather than at some random position in the storage slots. -See the amanda(8) man page for more details about AMANDA. +See the amanda(8) man page for more details about Amanda. COMMANDS @@ -32,7 +32,7 @@ COMMANDS Reset the tape changer to a known state. The current slot is set to the first slot. Other device-specific side effects may occur. Some gravity stackers need to be reset to the top position by hand. This command - notifies AMANDA the stacker is back in that position. + notifies Amanda the stacker is back in that position. eject If a tape is loaded in the drive, it is ejected and returned to the slot @@ -46,7 +46,7 @@ COMMANDS Show the contents of all slots. This can be slow. label label - Search for and load the AMANDA tape with label label. + Search for and load the Amanda tape with label label. taper Perform the taper scan algorithm. Load the next tape in the @@ -91,7 +91,7 @@ COMMANDS tape, but do not load it. This is useful with non-gravity stackers to unload the last tape used and set -up AMANDA for the next run. If you just use eject, the current tape will be +up Amanda for the next run. If you just use eject, the current tape will be mounted again in the next run, where it will be rejected as being still in use, ejected and the next tape requested. Using slot next followed by eject does an unnecessary mount. @@ -101,7 +101,7 @@ it is the one being requested. AUTHOR James da Silva, : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/amtapetype.8.txt b/docs/amtapetype.8.txt index 0e482db..4e726a4 100644 --- a/docs/amtapetype.8.txt +++ b/docs/amtapetype.8.txt @@ -1,6 +1,6 @@ amtapetype -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- @@ -15,7 +15,7 @@ t typename] DESCRIPTION -amtapetype generates a tapetype entry for AMANDA. +amtapetype generates a tapetype entry for Amanda. OPTIONS @@ -29,7 +29,7 @@ OPTIONS takes a few minutes only. -o - Overwrite the tape, even if it's an AMANDA tape. + Overwrite the tape, even if it's an Amanda tape. -bblocksize record block size (default: 32k) diff --git a/docs/amtoc.8.txt b/docs/amtoc.8.txt index 5d475b6..4260b7f 100644 --- a/docs/amtoc.8.txt +++ b/docs/amtoc.8.txt @@ -1,12 +1,12 @@ amtoc -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amtoc  generate TOC (Table Of Contents) for an AMANDA run +amtoc  generate TOC (Table Of Contents) for an Amanda run Synopsis @@ -14,7 +14,7 @@ amtoc [-a ] [-i ] [-t ] [ -f file ] [ -s subs ] [-w ] [-- ] logfile DESCRIPTION -Amtoc generates a table of contents for an AMANDA run. It's a perl script (if +Amtoc generates a table of contents for an Amanda run. It's a perl script (if you don't have perl, install it first!). OPTIONS @@ -89,7 +89,7 @@ AUTHOR Nicolas Mayencourt , University of Geneva/ Switzerland : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion ------------------------------------------------------------------------------- diff --git a/docs/amverify.8.txt b/docs/amverify.8.txt index fcee013..c4e11f5 100644 --- a/docs/amverify.8.txt +++ b/docs/amverify.8.txt @@ -1,6 +1,6 @@ amverify -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- @@ -34,7 +34,7 @@ See the amanda(8) man page for more details about Amanda. AUTHOR Axel Zinser : Original text -Stefan G. Weichinger, , maintainer of the AMANDA-documentation: +Stefan G. Weichinger, , maintainer of the Amanda-documentation: XML-conversion SEE ALSO diff --git a/docs/amverifyrun.8.txt b/docs/amverifyrun.8.txt index 0f54241..59a3bfe 100644 --- a/docs/amverifyrun.8.txt +++ b/docs/amverifyrun.8.txt @@ -1,12 +1,12 @@ amverifyrun -Prev Chapter 35. The AMANDA Manual Pages. Next +Prev Chapter 36. The Amanda Manual Pages. Next ------------------------------------------------------------------------------- Name -amverifyrun  check the tapes written by the last AMANDA run +amverifyrun  check the tapes written by the last Amanda run Synopsis @@ -14,7 +14,7 @@ amverifyrun config DESCRIPTION -Amverifyrun read the log from the last AMANDA run to find the slot of the first +Amverifyrun read the log from the last Amanda run to find the slot of the first tape used and the number of tapes used. It call amverify with these argument. SEE ALSO @@ -23,5 +23,5 @@ amanda(8), amverify(8) ------------------------------------------------------------------------------- Prev Up Next -amverify Home Chapter 36. Web Ressources +amverify Home Chapter 37. Web Ressources diff --git a/docs/chgscsi.txt b/docs/chgscsi.txt index eb50c21..f0d523b 100644 --- a/docs/chgscsi.txt +++ b/docs/chgscsi.txt @@ -23,7 +23,7 @@ Table of Contents Notes_about_changer.conf - AMANDA's_actual_usage_of_chg-scsi + Amanda's_actual_usage_of_chg-scsi Configuration_notes @@ -37,7 +37,7 @@ this document. Jason's new and improved chg-scsi documentation. This documentation will also include an occasional reference to the mtx suite as I have attempted to use chg-zd-mtx. I use mtx often as a fast query tool. -Please also refer to AMANDA_Tape_Changer_Support for additional details. +Please also refer to Amanda_Tape_Changer_Support for additional details. My equipment list is as follows: * Redhat 7.0 machine @@ -53,7 +53,7 @@ My equipment list is as follows: I base this documentation on the following: * mtx version 1.2.16rel -* AMANDA version 2.4.3b3 +* Amanda version 2.4.3b3 * SCSI2 specification: X3T9.2/375R revision 10L * Quantum/ATL Field Service Manual 6321101-03 Ver.3, rel.0 * Quantum DLT800 Tape system product manual 02 April, 2001 81-60118-04 @@ -62,8 +62,8 @@ I base this documentation on the following: Note that Quantum/ATL's L-series changers follow the SCSI command set, and do not use any proprietary commands. Thus, it was fairly simple to make this work. -I had to install AMANDA --with-suffixes and setup my server's client side of -things using AMANDA-2.4.2p2 --with-suffixes. +I had to install Amanda --with-suffixes and setup my server's client side of +things using Amanda-2.4.2p2 --with-suffixes. Please note that my usage of "barcode" and "barcode reader" throughout this document really refers to "physical tape identification system". for example: the EEPROM in the AIT cartridge. @@ -86,9 +86,9 @@ chg-scsi's command line options: -scan -genconf -Note that chg-scsi is called by AMANDA in the context of whatever AMANDA -configuration AMANDA is currently using. In short, to call chg-scsi by hand, -change to your AMANDA configuration directory, then run chg-scsi. +Note that chg-scsi is called by Amanda in the context of whatever Amanda +configuration Amanda is currently using. In short, to call chg-scsi by hand, +change to your Amanda configuration directory, then run chg-scsi. -slot command: this command takes either a slot number, or any one of the following: current, next, prev, first, last, advance @@ -114,7 +114,7 @@ labelfile with the given parameter as it's tape header. I have not tested this. -search command: this only should be used if a barcode reader is present, or emulate barcode is turned on. -the required parameter is an AMANDA tape label. The label searched in the +the required parameter is an Amanda tape label. The label searched in the labelfile. If a barcode is found, then that tape is loaded directly. I believe the fallback is to search the entire magazine. -status command: @@ -128,7 +128,7 @@ present only for a particular type of changer. -inventory: (this takes a LONG time to do) unloads tape back to its slot issues command to changer to do an inventory of itself (read all barcodes...) -loads each tape, retrieves the barcode, and reads the AMANDA +loads each tape, retrieves the barcode, and reads the Amanda label off of the tape itself stores/updates the label database file -dumpdb: prints out in human readable form the label database contents from the @@ -139,7 +139,7 @@ name and the device types. I found that linux didn't classify either of my tape devices as generic, but this facility did. USE THIS FOR FINDING VALUE OF SCSItapedev. Be certain though you have the correct tape drive: I came close to wreaking havoc with my DDS3 drive while it -was flushing AMANDA data...and my changer has a DLT drive! Please refer to my +was flushing Amanda data...and my changer has a DLT drive! Please refer to my configuration notes below. -genconf: prints out a SAMPLE changer.conf file. Note that I said sample. except for that @@ -206,12 +206,12 @@ other values are (taken from the code) cleanmax cleancart cleanfile I have my changer set to autoclean, and the slot the cleaning cartridge is in is not available for any other use. - AMANDA's actual usage of chg-scsi + Amanda's actual usage of chg-scsi -this should be brief: AMANDA really only issues "slot next" type commands. -Currently AMANDA doesn't ask chg-scsi to load "tape x with label Daily_set023". +this should be brief: Amanda really only issues "slot next" type commands. +Currently Amanda doesn't ask chg-scsi to load "tape x with label Daily_set023". the chg-scsi mechanism is there for use, and functions quite well for the user -to load a particular tape. I understand they (the AMANDA team) are working on +to load a particular tape. I understand they (the Amanda team) are working on this. Configuration notes @@ -227,7 +227,7 @@ tapedev to 0 set changerdev to /dev/ in changer.conf: set number_configs to 1 set dev to set debug to 9:0 -run "chg-scsi -scan" from your AMANDA configuration directory I get: name /dev/ +run "chg-scsi -scan" from your Amanda configuration directory I get: name /dev/ sg0 Tape Count 1 name /dev/sg1 Changer Count 2 name /dev/sg2 Tape Count 3 I set SCSItapedev to /dev/sg0 to test with, then ran chg-scsi -info. Check the chg-scsi debug file for tapeidentification details. This is where I discoverd @@ -261,6 +261,6 @@ My desires are: ------------------------------------------------------------------------------- Prev Up Next -Chapter 8. AMANDA Tape Changer Home Chapter 10. RAIT (Redundant Array of +Chapter 8. Amanda Tape Changer Home Chapter 10. RAIT (Redundant Array of Support Inexpensive Tape) Support diff --git a/docs/dumperapi.txt b/docs/dumperapi.txt index 72c68ef..770e1d5 100644 --- a/docs/dumperapi.txt +++ b/docs/dumperapi.txt @@ -1,10 +1,10 @@ - Chapter 22. AMANDA dumper API + Chapter 23. Amanda dumper API Prev Part V. Technical Background Next ------------------------------------------------------------------------------- -Chapter 22. AMANDA dumper API +Chapter 23. Amanda dumper API Alexandre Oliva @@ -53,23 +53,23 @@ this document. Introduction -This is a proposal of a mechanism for AMANDA to support arbitrary backup +This is a proposal of a mechanism for Amanda to support arbitrary backup programs, that relies on a generic backup driver and scripts or programs that interface with backup programs such as dump, tar, smbclient, and others. It can also be used to introduce pre- and post-backup commands. The interface is simple, but supports everything that is currently supported by -AMANDA, and it can be consistently extended to support new abstractions that +Amanda, and it can be consistently extended to support new abstractions that may be introduced in the backup driver in the future. -This proposal does not imply any modification in the AMANDA protocol or in -AMANDA servers; only AMANDA clients have to be modified. By AMANDA clients, we -refer to hosts whose disks are to be backed up; an AMANDA server is a host +This proposal does not imply any modification in the Amanda protocol or in +Amanda servers; only Amanda clients have to be modified. By Amanda clients, we +refer to hosts whose disks are to be backed up; an Amanda server is a host connected to a tape unit. -Currently (as of release 2.4.1 of AMANDA), AMANDA clients support three +Currently (as of release 2.4.1 of Amanda), Amanda clients support three operations: selfcheck, estimate and backup. Selfcheck is used by the server program amcheck, to check whether a client is responding or if there are configuration or permission problems in the client that might prevent the backup from taking place. -Estimates are requested by the AMANDA planner, that runs on the server and +Estimates are requested by the Amanda planner, that runs on the server and collects information about the expected sizes of backups of each disk at several levels. Given this information and the amount of available tape space, the planner can select which disks and which levels it should tell dumper to @@ -78,7 +78,7 @@ dumper is yet another server-side program; it requests clients to perform dumps, as determined by planner, and stores these dumps in holding disks or sends them directly to the taper program. The interaction between dumper and taper is beyond the scope of this text. -We are going to focus on the interaction between the AMANDA client program and +We are going to focus on the interaction between the Amanda client program and wrappers of dump programs. These wrappers must implement the DUMPER API. The dumptype option `program' should name the wrapper that will be used to back up filesystems of that dumptype. One wrapper may call another, so as to extend its @@ -106,13 +106,13 @@ on the last backup, be it a full or an incremental backup (0-inf++). Some support incrementals based on a timestamp (incr/date); whereas others are based on a limited number of incremental levels, but incrementals of the same level can be repeated, such as dump (0-9). -AMANDA was originally built upon DUMP incremental levels, so this is the only +Amanda was originally built upon DUMP incremental levels, so this is the only model it currently supports. Backup programs that use other incremental management mechanisms had to be adapted to this policy. Wrapper scripts are responsible for this adaptation. Another important issue has to do with index generation. Some backup programs can generate indexes, but each one lists files in its own particular format, -but they must be stored in a common format, so that the AMANDA server can +but they must be stored in a common format, so that the Amanda server can manipulate them. The DUMPER API must accomodate for all these variations. @@ -128,16 +128,16 @@ should be printed to stderr, and the program should terminate with exit status The `support' command -As a general mechanism for AMANDA to probe for features provided by a backup +As a general mechanism for Amanda to probe for features provided by a backup program, a wrapper script must support at least the `support' command. Some -features must be supported, and AMANDA won't ever ask about them. Others will -be considered as extensions, and AMANDA will ask the wrapper whether they are +features must be supported, and Amanda won't ever ask about them. Others will +be considered as extensions, and Amanda will ask the wrapper whether they are supported before issuing the corresponding commands. The `level-incrementals' subcommand For example, before requesting for an incremental backup of a given level, -AMANDA should ask the wrapper whether the backup program supports level-based +Amanda should ask the wrapper whether the backup program supports level-based incrementals. We don't currently support backup programs that don't, but we may in the future, so it would be nice if wrappers already implemented the command `support level-incrementals', by returning a 0 exit status, printing, say, the @@ -217,7 +217,7 @@ implying that the inquired feature is not supported. The `selfcheck' command We should support commands to perform self-checks, run estimates, backups and -restores (for future extensions of the AMANDA protocol so as to support +restores (for future extensions of the Amanda protocol so as to support restores) A selfcheck request would go like this: DUMP selfcheck hda0 option option=value ... @@ -229,7 +229,7 @@ Errors should be printed as: ERROR [/etc/dumpdates is not writable] A wrapper script will certainly have to figure out either the disk device name or its mount point, given a filesystem name such as `hda0', as specified in the -disklist. In order to help these scripts, AMANDA provides a helper program that +disklist. In order to help these scripts, Amanda provides a helper program that can guess device names, mount points and filesystem types, when given disklist entries. The filesystem type can be useful on some operation systems, in which more than @@ -255,7 +255,7 @@ to stdout the informations needed by the `estimate-parse' command, that should extract from its input the estimated size. The syntax of `estimate-parse' is identical to that of `estimate'. Both `estimate' and `estimate-parse' can output the word `KILL', after printing -the estimate. In this case, AMANDA will send a SIGTERM signal to the process +the estimate. In this case, Amanda will send a SIGTERM signal to the process group of the `estimate' process. If it does not die within a few seconds, a SIGKILL will be issued. If `estimate' or `estimate-parse' succeed, they should exit 0, otherwise exit @@ -320,6 +320,6 @@ and/or the API. Some help on its implementation would be welcome, too. ------------------------------------------------------------------------------- Prev Up Next -Chapter 21. How AMANDA uses UDP and TCP Home Chapter 23. AMANDA Internals +Chapter 22. How Amanda uses UDP and TCP Home Chapter 24. Amanda Internals ports diff --git a/docs/eventapi.txt b/docs/eventapi.txt index f36daa3..dd8e282 100644 --- a/docs/eventapi.txt +++ b/docs/eventapi.txt @@ -1,10 +1,10 @@ - Chapter 24. AMANDA Event API + Chapter 25. Amanda Event API Prev Part V. Technical Background Next ------------------------------------------------------------------------------- -Chapter 24. AMANDA Event API +Chapter 25. Amanda Event API Mike Grupenhoff @@ -32,6 +32,8 @@ Table of Contents event_loop + event_wait + event_wakeup @@ -101,6 +103,12 @@ until all events have been released. If the argument is nonzero, this will do one pass over all pending events, and fire the ones that are immediately ready, and then return. + event_wait + +void event_wait(event_id_t id); +Like event_loop(0), except that it will stop as soon as the event id is +serviced. + event_wakeup int event_wakeup(event_id_t id); @@ -163,5 +171,5 @@ argument equal to the argument this event was registered with. ------------------------------------------------------------------------------- Prev Up Next -Chapter 23. AMANDA Internals Home Chapter 25. AMANDA Security API +Chapter 24. Amanda Internals Home Chapter 26. Amanda Security API diff --git a/docs/exclude.txt b/docs/exclude.txt index 239e5cb..16a9530 100644 --- a/docs/exclude.txt +++ b/docs/exclude.txt @@ -52,14 +52,14 @@ this document. Introduction There are times when data needs to be excluded from a backup. When these times -arise be confident that AMANDA has this capability. (Actually it's not AMANDA, -it's tar.) There are three ways of excluding data in an AMANDA backup: +arise be confident that Amanda has this capability. (Actually it's not Amanda, +it's tar.) There are three ways of excluding data in an Amanda backup: * Exclude an individual item explicitly in the dumptype * Utilize an "Exclude List" * Do not include the data in the disklist -This document is based on AMANDA 2.4.2 and some of this might not work with +This document is based on Amanda 2.4.2 and some of this might not work with older versions. This was compiled from my personal experience and with help from the members of the amanda-users mailing list (mailto://amanda- users@amanda.org) when I was originally setting this up, to whom I wish to @@ -68,7 +68,7 @@ thank for all of their support. Please Read As far as I am able to tell the only way to exclude files or directories with -AMANDA is to use GNU-tar as the dump program (others?). The file system dump +Amanda is to use GNU-tar as the dump program (others?). The file system dump programs provided with unix systems (e.g. dump, ufsdump) get data at a raw drive level and generally do not allow exclusion of specific files or directories. @@ -83,7 +83,7 @@ The only exception that I am aware of is to just not include the data in question in the disklist. This option may not be suitable for everyone's needs and can confuse the issue some, so I have elected to include this mechanism in its own section named Do_not_include_the_data_in_the_disklist. -For the purpose of this document an AMANDA backup configuration named "exclude- +For the purpose of this document an Amanda backup configuration named "exclude- test" will be used. The machine that contains the tape drive which receives data to be archived will be referred to as "SERVER". The machine that data is being archived from will be referred to as "CLIENT". These two systems are @@ -92,7 +92,7 @@ machine. Parts of this setup are on the server and some are on the client. Note -When AMANDA attempts to exclude a file or directory it does so relative to the +When Amanda attempts to exclude a file or directory it does so relative to the area being archived. For example if /var is in your disklist and you want to exclude /var/log/somefile, then your exclude file would contain ./log/somefile. You may use one exclude file in multiple dumptypes without any restriction. @@ -100,18 +100,18 @@ You may use one exclude file in multiple dumptypes without any restriction. Before We Begin The first step that should be taken is to verify that backups are currently -working. Connect to SERVER and run amcheck as your AMANDA user, to verify that +working. Connect to SERVER and run amcheck as your Amanda user, to verify that there are no errors in the current setup. $ amcheck -cl CLIENT Output should look something like below for success: - AMANDA Tape Server Host Check + Amanda Tape Server Host Check ----------------------------- /path/to/holding-disk: 4771300 KB disk space available, that's plenty. - AMANDA Backup Client Hosts Check + Amanda Backup Client Hosts Check -------------------------------- Client check: 1 host checked in 0.084 seconds, 0 problems found. @@ -148,12 +148,12 @@ the need is to exclude multiple files or directories then use an Exclude List. The easiest way to exclude a file or directory is to specify it with the "exclude" option in the dumptype. This option accepts an argument of the file -or directory to be excluded. AMANDA allows only one exclude option in any +or directory to be excluded. Amanda allows only one exclude option in any dumptype at a time. Note -UPDATE: Recent AMANDA-releases bring the option "exclude append" which enables +UPDATE: Recent Amanda-releases bring the option "exclude append" which enables the administrator to define more than one exclusion-pattern within one dumptype without using a exclude-list. Please look at the amanda.conf.5-manpage for details. @@ -169,7 +169,7 @@ above, the dumptype would now look like: } Next run amcheck again to verify that there are no problems with the revised -AMANDA configuration. If the data is not being excluded as expected please see +Amanda configuration. If the data is not being excluded as expected please see the Troubleshooting section below. This completes the setup of excluding an individual item in the dumptype. @@ -189,7 +189,7 @@ Connect to CLIENT and create the exclude directory as root. For example: $ mkdir -p /usr/local/etc/amanda/exclude $ cd /usr/local/etc/amanda/exclude -Next create the exclude list for AMANDA to use. You can name the exclude file +Next create the exclude list for Amanda to use. You can name the exclude file anything you wish it to be. Create a file, and in this file place all paths to files and directories that are to be excluded. Keeping with the /var example, assume that /var/log/XFree86.0.log, and /var/log/maillog need to be excluded. @@ -205,8 +205,8 @@ example: $ chmod 644 /usr/local/etc/amanda/exclude/exclude-filename This concludes the necessary configuration on the client. -Connect to SERVER and cd to the exclude-test AMANDA configuration directory. -Edit the AMANDA configuration file e.g. amanda.conf. Add an entry similar to +Connect to SERVER and cd to the exclude-test Amanda configuration directory. +Edit the Amanda configuration file e.g. amanda.conf. Add an entry similar to the following line, to the dumptype for the client in question, where the exclude-filename is the file that was created on CLIENT in the step above including the quotes. For example: @@ -223,14 +223,14 @@ The new dumptype should look something like: } Save the file. Run amcheck again to verify that there are no problems with the -revised AMANDA configuration. If amcheck succeeds then run amdump to verify the +revised Amanda configuration. If amcheck succeeds then run amdump to verify the data is being excluded correctly. If the data is not being excluded as expected please see the Troubleshooting section below. This completes the setup of an exclude list. Do not include the data in the disklist -AMANDA uses disklist entries to define which directories or partitions should +Amanda uses disklist entries to define which directories or partitions should be archived. This allows us to exclude data by just not placing the data in question in the disklist. Assume that there is a disk mounted on /example. The directory /example has five subdirectories "a", "b", "c", "d", and "e". The @@ -243,7 +243,7 @@ contain: CLIENT /examples/b exclude-test CLIENT /examples/c exclude-test -Run amcheck to verify that AMANDA is working correctly. If the data is not +Run amcheck to verify that Amanda is working correctly. If the data is not being excluded as expected please see the Troubleshooting section below. This completes the setup of using a disklist to exclude data. @@ -261,7 +261,7 @@ backup image but nothing below it. Wildcard Expansion -AMANDA has the ability to use wildcard expansion while excluding data as +Amanda has the ability to use wildcard expansion while excluding data as implemented by tar(1). The only places that wildcard expansion is allowed is in the "exclude" option in the dumptype, or in the exclude list. Some simple examples: @@ -297,7 +297,7 @@ the script. Broken gnutar? There are versions of GNU-tar that do not correctly exclude data. Version 1.12 -(plus the AMANDA patches from http://www.amanda.org) are known to work +(plus the Amanda patches from http://www.amanda.org) are known to work correctly, as does version 1.13.19 (and later). Anything else is questionable. Note @@ -335,5 +335,5 @@ Subscription information is available at http://www.amanda.org. ------------------------------------------------------------------------------- Prev Up Next -Chapter 2. AMANDA Installation Notes Home Chapter 4. Indexing with AMANDA +Chapter 2. Amanda Installation Notes Home Chapter 4. Indexing with Amanda diff --git a/docs/faq.txt b/docs/faq.txt index 560862a..82fb691 100644 --- a/docs/faq.txt +++ b/docs/faq.txt @@ -1,13 +1,13 @@ - Chapter 17. AMANDA FAQ + Chapter 19. Amanda FAQ Prev Part IV. Various Information Next ------------------------------------------------------------------------------- -Chapter 17. AMANDA FAQ +Chapter 19. Amanda FAQ -AMANDA Core Team +Amanda Core Team AMANDA Core Team @@ -22,22 +22,22 @@ Note Refer to http://www.amanda.org/docs/faq.html for the current version of this document. This file contains answers to some questions that are frequently asked in the -AMANDA mailing lists, specially by new users. Please take a look at this file -before posting, this can save us time that could be spent improving AMANDA and +Amanda mailing lists, specially by new users. Please take a look at this file +before posting, this can save us time that could be spent improving Amanda and its documentation. New entries and modifications are welcome; send them to mailto://amanda- users@amanda.org or mailto://amanda-hackers@amanda.org. -You may also want to take a look at the AMANDA FAQ-O-Matic http:// +You may also want to take a look at the Amanda FAQ-O-Matic http:// www.amanda.org/fom-serve/cache/1.html. - Why_does_AMANDA_fail_to_build_on_my_system? + Why_does_Amanda_fail_to_build_on_my_system? Why_does_amdump_report_that_all_disks_failed? Why_does_amcheck_say_"port_NNN_is_not_secure"? - Why_does_amcheck_claim_that_the_tape_is_"not_an_AMANDA_tape"? + Why_does_amcheck_claim_that_the_tape_is_"not_an_Amanda_tape"? Why_does_amcheck_report_"selfcheck_request_timed_out"? @@ -54,19 +54,21 @@ www.amanda.org/fom-serve/cache/1.html. Which_tape_changer_configuration_should_I_use_in_amanda.conf? + Where_do_I_get_my_tapetype-definition_from?_Do_I_have_to_run_amtapetype? + Should_I_use_software_or_hardware_compression? - How_can_I_configure_AMANDA_so_that_it_performs_full_backups_on_the_week-end + How_can_I_configure_Amanda_so_that_it_performs_full_backups_on_the_week-end and_incrementals_on_weekdays? What_if_my_tape_unit_uses_expensive_tapes,_and_I_don't_want_to_use_one_tape - per_day?_Can't_AMANDA_append_to_tapes? + per_day?_Can't_Amanda_append_to_tapes? - How_can_I_configure_AMANDA_for_long-term_archiving? + How_can_I_configure_Amanda_for_long-term_archiving? Can_I_backup_separate_disks_of_the_same_host_in_different_configurations? - Can_AMANDA_span_large_filesystems_across_multiple_tapes? + Can_Amanda_span_large_filesystems_across_multiple_tapes? What's_the_difference_between_option_"skip-full"_and_"strategy_nofull"? @@ -78,24 +80,31 @@ www.amanda.org/fom-serve/cache/1.html. amdump_reported_"infofile_update_failed"._What_should_I_do? - Why_does_AMANDA_sometimes_promote_full_dumps? + Why_does_Amanda_sometimes_promote_full_dumps? Why_does_amrecover_report_"no_index_records"_or_"disk_not_found"? - Ok,_I'm_done_with_testing_AMANDA,_now_I_want_to_put_it_in_production._How_can + Ok,_I'm_done_with_testing_Amanda,_now_I_want_to_put_it_in_production._How_can I_reset_its_databases_so_as_to_start_from_scratch? The_man-page_of_dump_says_that_active_filesystems_may_be_backed_up - inconsistently._What_does_AMANDA_do_to_prevent_inconsistent_backups? + inconsistently._What_does_Amanda_do_to_prevent_inconsistent_backups? Which_version_of_GNU-tar_should_I_use? - What_does_"bumping"bumping_mean? + What_does_"bumping"_mean? How_do_I_backup_a_Windows_server? + How_do_I_tell_my_iptables-based_firewall_to_allow_Amanda_through? + + How_do_I_get_rid_of_pressing_"q"_to_get_rid_of_a_pager_prompt_when_using + amrecover? + + Is_there_a_way_to_tell_the_pager_that_my_terminal_has_"y"_lines? + - Why does AMANDA fail to build on my system? + Why does Amanda fail to build on my system? One of the most common reasons for compile-time errors is stale information in config.cache, after a build on a different platform using the same build tree. In order to avoid this problem, make sure you don't ever reuse build trees @@ -105,34 +114,34 @@ www.amanda.org/fom-serve/cache/1.html. in libtool that causes it to search for symbols in already-installed amanda libraries, instead of in the just-built ones. This problem is known to affect SunOS 4.1.3 and FreeBSD. You can usually work around it by specifying a - different prefix when you configure the new version of AMANDA. However, it may - not work if the previous version of AMANDA was installed in /usr/local and gcc + different prefix when you configure the new version of Amanda. However, it may + not work if the previous version of Amanda was installed in /usr/local and gcc searches this directory by default; in this case, you must either remove the old libraries (which you don't want to do, right? :-) or call configure with - the flag --disable-libtool. In this case, AMANDA won't create shared + the flag --disable-libtool. In this case, Amanda won't create shared libraries, so binaries will be larger, but you may worry about that later. - You may also want to take a look at AMANDA_2.4.x_-_System-Specific - Installation_Notes, as well as to the AMANDA Patches Page (http:// + You may also want to take a look at Amanda_2.5.0_-_System-Specific + Installation_Notes, as well as to the Amanda Patches Page (http:// www.amanda.org/patches/) for other known problems. If everything fails, you should read the manual, but since we don't have one yet, just post a help request to the amanda-users mailing list (mailto://amanda-users@amanda.org), showing the last few lines of the failed build. Why does amdump report that all disks failed? - Probably because the AMANDA clients are not properly configured. Before you + Probably because the Amanda clients are not properly configured. Before you ever run amdump, make sure amcheck succeeds. When it does, so should amdump. Make sure you run amcheck as the same user that is supposed to start amdump, otherwise you may get incorrect results. Why does amcheck say "port NNN is not secure"? - Because amcheck, as some other AMANDA programs, must be installed as setuid- - root. Run make install as "root", or chown all AMANDA setuid programs to + Because amcheck, as some other Amanda programs, must be installed as setuid- + root. Run make install as "root", or chown all Amanda setuid programs to "root", then chown u+s them again, if chown drops the setuid bit. - Why does amcheck claim that the tape is "not an AMANDA tape"? - Because AMANDA requires you to label tapes before it uses them. Run amlabel in + Why does amcheck claim that the tape is "not an Amanda tape"? + Because Amanda requires you to label tapes before it uses them. Run amlabel in order to label a tape. If, even after labeling a tape, amcheck still complains about it, make sure the regular expression specified in amanda.conf matches the label you have specified, and check whether you have configured non-rewinding tape devices - for AMANDA to use. For example, use /dev/nrst0 instead of /dev/rst0, /dev/rmt/ + for Amanda to use. For example, use /dev/nrst0 instead of /dev/rst0, /dev/rmt/ 0bn instead of /dev/rmt/0b, or some other system-dependent device name that contains an "n", instead of one that does not. The "n" stands for non- rewinding. @@ -140,8 +149,8 @@ www.amanda.org/fom-serve/cache/1.html. have to label them again. Why does amcheck report "selfcheck request timed out"? This can occur under several different situations. First, make sure this - problem is repeatable; if AMANDA programs are NFS-auto-mounted, some clients - may fail to mount the AMANDA binaries in time. + problem is repeatable; if Amanda programs are NFS-auto-mounted, some clients + may fail to mount the Amanda binaries in time. If the error is repeatable, log into the client, and check whether the directory /tmp/amanda exists, and a file named amandad.debug exists in there: amandad will create this file whenever it starts. If this file does not exist, @@ -149,7 +158,7 @@ www.amanda.org/fom-serve/cache/1.html. amanda/amandad.debug. In the latter case, wipe out /tmp/amanda, and amandad should create it next time it runs. In the former case, check your inetd configuration. Make sure - you have added the AMANDA services to /etc/services (or the NIS services map), + you have added the Amanda services to /etc/services (or the NIS services map), that /etc/inetd.conf was properly configured, and that you have signalled inetd to reread this file (some systems may need rebooting). Check section 2.2 from in the Amanda_Installation_Notes for details. Check the inetd man-page @@ -161,7 +170,7 @@ www.amanda.org/fom-serve/cache/1.html. specified at configure-time (configure --with-user=) is listed in / etc/inetd.conf. Check whether this user has permission to run amandad, as well as any shared libraries amandad depends upon, by running the specified amandad - command by hand, as the AMANDA user. It should just time-out after 30 seconds + command by hand, as the Amanda user. It should just time-out after 30 seconds waiting for a UDP packet. If you type anything, it will abort immediately, because it can't read a UDP packet from the keyboard. As soon as you have properly configured /etc/inetd.conf so as to run amandad, @@ -174,8 +183,8 @@ www.amanda.org/fom-serve/cache/1.html. try to read a UDP packet from the keyboard, and this was reported not to work on most keyboards :-). However, if you have run amandad as any user other than the one listed in /etc/inetd.conf, it may have created a /tmp/amanda directory - that the AMANDA user cannot write to, so you should wipe it out. - Another possibility is that the AMANDA service was not properly configured as + that the Amanda user cannot write to, so you should wipe it out. + Another possibility is that the Amanda service was not properly configured as a UDP service; check /etc/services and /etc/inetd.conf. Why does amcheck say "access as not allowed..."? There must be something wrong with .amandahosts configuration (or .rhosts, if @@ -189,27 +198,27 @@ www.amanda.org/fom-serve/cache/1.html. names. Why does amcheck report "ip address #.#.#.#" is not in the ip list list for '? - Check your DNS configuration tables. In order to avoid DNS-spoofing, AMANDA + Check your DNS configuration tables. In order to avoid DNS-spoofing, Amanda double-checks hostname<->IP address mapping. If the IP address the request comes from maps to a hostname, but this hostname does not map back to the incoming IP address, the request is denied. Why does amcheck say "cannot overwrite active tape"? - Because, if you configure AMANDA to use N tapes, by setting tapecycle to N in - amanda.conf, before AMANDA overwrites a tape, it must write to at least other - N-1 tapes. Of course, AMANDA will always refuse to overwrite a tape marked for - `noreuse' with amadmin. Furthermore, such tapes are not counted when AMANDA + Because, if you configure Amanda to use N tapes, by setting tapecycle to N in + amanda.conf, before Amanda overwrites a tape, it must write to at least other + N-1 tapes. Of course, Amanda will always refuse to overwrite a tape marked for + `noreuse' with amadmin. Furthermore, such tapes are not counted when Amanda computes `N-1' tapes. - If, for some reason, you want to tell AMANDA to overwrite a particular tape, + If, for some reason, you want to tell Amanda to overwrite a particular tape, regardless of its position in the cycle, use amrmtape. This command will remove this tape from the tapelist file, that is used to manage the tape cycle, and will delete information about backups stored in that tape from the - AMANDA database. + Amanda database. Why does amcheck tell me "DUMP program not available"? Because configure could not find dump when it was first run. This is a common problem on Linux hosts, because most Linux distributions do not install dump by default. If you don't have a DUMP program installed, install it, remove config.cache, - run configure again and rebuild AMANDA. While configure is running, make sure + run configure again and rebuild Amanda. While configure is running, make sure it can find the installed DUMP program. If it cannot, you may have to set the environment variables DUMP and RESTORE by hand, before running configure. If you can't or don't want to install DUMP, you may use GNU tar, but make sure @@ -236,22 +245,39 @@ www.amanda.org/fom-serve/cache/1.html. mtx, for example, is available for several platforms. However, even if you find it for your platform, beware that there exist several different programs named mtx, that require different command line arguments, and print different - output, and AMANDA's chg-mtx does not support them all. You may have to edit + output, and Amanda's chg-mtx does not support them all. You may have to edit the script, which shouldn't be hard to do. - In section BUILT-IN TAPE CHANGERS of AMANDA_Tape_Changer_Support you will find - details about the tape changer interfacing programs provided with AMANDA, that + In section BUILT-IN TAPE CHANGERS of Amanda_Tape_Changer_Support you will find + details about the tape changer interfacing programs provided with Amanda, that can interact with common tape changer programs and with tape changer-related system calls provided by some operating system. If none of them matches your needs, you may have to develop your own tape changer interface script. - Before posting a question to the AMANDA mailing lists, *please* search the + Before posting a question to the Amanda mailing lists, *please* search the archives, and try to obtain as much information about driving your tape changer hardware from the vendor of the changer hardware and of the operating - system, rather than from the AMANDA mailing lists. We usually don't have much + system, rather than from the Amanda mailing lists. We usually don't have much to say about tape changer units, and several questions about them remain unanswered. :-( Anyway, if you decide to post a question, make sure you specify both the tape changer hardware *and* the OS/platform that is going to interface with it. Good luck! :-) + Where do I get my tapetype-definition from? Do I have to run amtapetype? + It is not mandatory to run amtapetype at installation-time. It is very likely + that your tapedrive or -changer is one of the devices that are already covered + by one of the existing tapetype-definitions. + You may find tapetype-definitions in the example amanda.conf, in the + mailinglist-archives of the amanda-users-mailinglist at http:// + marc.theaimsgroup.com/?l=amanda-users or in the Amanda-FAQ-O-Matic at http:// + www.amanda.org/fom-serve/cache/1.html. + Reasons to run amtapetype for your device: + + * You want to generate your own tapetype-definition because you can't find any + suitable tapetype-definition for your device. + * You want to determine the performance of your device. + * You want to determine if your device has hardware-compression enabled. + + If you decide to run amtapetype, please refer to the chapter Tapetypes and the + manpage amtapetype(8). Should I use software or hardware compression? When you enable software compression, you drastically reduce the compression that might be achieved by hardware. In fact, tape drives will usually use @@ -259,28 +285,30 @@ www.amanda.org/fom-serve/cache/1.html. data. Thus, you must choose whether you're going to use software or hardware compression; don't ever enable both unless you want to waste tape space. - Since AMANDA prefers to have complete information about tape sizes and + Since Amanda prefers to have complete information about tape sizes and compression rates, it can do a better job if you use software compression. - However, if you can't afford the extra CPU usage, AMANDA can live with the + However, if you can't afford the extra CPU usage, Amanda can live with the unpredictability of hardware compression, but you'll have to be very conservative about the specified tape size, specially if there are filesystems that contain mostly uncompressible data. - How can I configure AMANDA so that it performs full backups on the week-end + You might want to run amtapetype to determine if you have hardware-compression + enabled for your tape-drive. + How can I configure Amanda so that it performs full backups on the week-end and incrementals on weekdays? - You can't. AMANDA doesn't work this way. You just have to tell AMANDA how many + You can't. Amanda doesn't work this way. You just have to tell Amanda how many tapes you have (tapecycle), and how often you want it to perform full backups of each filesystem (dumpcycle). If you don't run it once a daily (including - Saturdays and Sundays :-), you'll also want to tell AMANDA how many times + Saturdays and Sundays :-), you'll also want to tell Amanda how many times you'll run it per dumpcycle (runspercycle). It will spread full backups along the dumpcycle, so you won't have any full-only or incremental-only runs. Please also refer to "the friday-tape-question" in Collection_of_the_top_ten - AMANDA_questions._And_answers.. + Amanda_questions._And_answers.. What if my tape unit uses expensive tapes, and I don't want to use one tape - per day? Can't AMANDA append to tapes? + per day? Can't Amanda append to tapes? It can't, and this is good. Tape drives and OS drivers are (in)famous for rewinding tapes at unexpected times, without telling the program that's writing to them. If you have a month's worth of backups in that tape, you - really don't want them to be overwritten, so AMANDA has taken the safe + really don't want them to be overwritten, so Amanda has taken the safe approach of requiring tapes to be written from the beginning on every run. This can be wasteful, specially if you have a small amount of data to back up, but expensive large-capacity tapes. One possible approach is to run amdump @@ -293,12 +321,12 @@ www.amanda.org/fom-serve/cache/1.html. backs up the holding disk only, always as a full backup. You'd run this configuration always after your regular backup, so you always have a complete image of the holding disk on tape, just in case it fails. - How can I configure AMANDA for long-term archiving? + How can I configure Amanda for long-term archiving? The best approach is to create a separate configuration for your archive backups. It should use a separate set of tapes, and have all dumptypes configured with `record no', so it doesn't interfere with regular backups. Can I backup separate disks of the same host in different configurations? - Yes, but you have to be careful. AMANDA uses UDP to issue estimate and backup + Yes, but you have to be careful. Amanda uses UDP to issue estimate and backup requests and, although replies to backup requests are immediate (so that TCP connections for the actual backup can be established), replies to estimate requests are not and, while one request is being processed, any other request @@ -312,14 +340,14 @@ www.amanda.org/fom-serve/cache/1.html. So, there are two easy ways out: i. Ensure that the configurations never run concurrently, or - ii. set up two different installations of the AMANDA server, using different + ii. set up two different installations of the Amanda server, using different services names to contact the clients, i.e., different port numbers. This - can be attained with the configure flag --with-testing=i. + can be attained with the configure flag --with-testing=. Yes, the flag name is not appropriate, but so what? - If you don't want to set up two installations of AMANDA (I agree, it's + If you don't want to set up two installations of Amanda (I agree, it's overkill), but you still want to back up disks of the same host in separate - configurations, you can set up AMANDA so that one configuration only starts + configurations, you can set up Amanda so that one configuration only starts after the first one has already finished its One possible way to work-around this limitation is to start one configuration only after you know the estimates for the first one have already finished (modifying the crontab @@ -327,10 +355,10 @@ www.amanda.org/fom-serve/cache/1.html. (a dumptype option) of the disks in the first configuration, so that they don't start backing up before the estimates of the second configuration finish. - Can AMANDA span large filesystems across multiple tapes? + Can Amanda span large filesystems across multiple tapes? Not yet :-( This is an open project, looking for developers. If you'd like to help, please - take a look at the AMANDA Ongoing Projects Page (http://www.amanda.org/ + take a look at the Amanda Ongoing Projects Page (http://www.amanda.org/ ongoing.php), where more up-to-date information is likely to be found about this project. Update September 2004: Refer to the archive of the amanda-hackers mailinglist @@ -342,14 +370,14 @@ www.amanda.org/fom-serve/cache/1.html. What's the difference between option "skip-full" and "strategy nofull"? "strategy nofull" is supposed to handle the following situation: you run a full dump off-line once a millenium :-), because that disk isn't supposed to - change at all and, if it does, changes are minimal. AMANDA will run only level + change at all and, if it does, changes are minimal. Amanda will run only level 1 backups of that filesystem, to avoid the risk of overwriting a level 1 backup needed to do a restore. Remember, you run full dumps once a millenium, and your tape cycle probably won't last that long :-) "skip-full", OTOH, is supposed to let the user run full dumps off-line - regularly (i.e., as often as specified in the dumpcycle), while AMANDA takes - care of the incrementals. Currently, AMANDA will tell you when you're supposed - to run the level 0 backups but, if you fail to do so, AMANDA will not only + regularly (i.e., as often as specified in the dumpcycle), while Amanda takes + care of the incrementals. Currently, Amanda will tell you when you're supposed + to run the level 0 backups but, if you fail to do so, Amanda will not only skip a full day's worth of valuable backups of the filesystem, on the day it told you to the full backup manually, but it will also run a level 1 backup on the next day, even if you have not performed the full backup yet. Worse yet: @@ -359,7 +387,7 @@ www.amanda.org/fom-serve/cache/1.html. Why does amdump report "results missing"? One of the possible reasons is that you have requested too many backups of the host. In this case, the estimate request or the reply may not fit in a UDP - packet. This will cause AMANDA not to perform some of the backups. Fixing this + packet. This will cause Amanda not to perform some of the backups. Fixing this problem involves modifying the way estimate requests are issued, so that no packet exceeds the maximum packet size, and issuing additional requests that did not fit in a UDP packet after a reply for the previous set is obtained. @@ -392,39 +420,39 @@ www.amanda.org/fom-serve/cache/1.html. DUMP to crash before it estimates the backup size; a fsck may help. Yet another possibility is that the filesystem is so large that the backup program is incorrectly reporting the estimated size, for example, by printing - a negative value that AMANDA will not accept as a valid estimate. If you are + a negative value that Amanda will not accept as a valid estimate. If you are using dump, contact your vendor and request a patch for dump that fixes this bug. If you are using GNU-tar, make sure it is release 1.12 or newer; 1.11.8 won't do! Even release 1.12 may require a patch to correctly report estimates and dump sizes, as well as to handle sparse files correctly and quickly instead of printing error messages like `Read error at byte 0, reading 512 bytes, in file ./var/log/lastlog: Bad file number' in sendsize.debug and being - very slow. Check the patches directory of the AMANDA distribution. + very slow. Check the patches directory of the Amanda distribution. What if amdump reports "dumps way too big, must skip incremental dumps"? - It means AMANDA couldn't back up some disk because it wouldn't fit in the tape - (s) you have configured AMANDA to use. It considered performing some + It means Amanda couldn't back up some disk because it wouldn't fit in the tape + (s) you have configured Amanda to use. It considered performing some incrementals instead of full dumps, so that all disks would fit, but this wouldn't be enough, so the disk really had to be dropped in this run. In general, you can just ignore this message if it happens only once in a while. Low-priority disks are discarded first, so you'll hardly miss really important data. - One real work-around is to configure AMANDA to use more tapes: increase + One real work-around is to configure Amanda to use more tapes: increase `runtapes' in amanda.conf. Even if you don't have a real tape changer, you can act yourself as a changer (`chg-manual'; more details in the question about tape changer configuration), or use `chg-multi' with a single tape unit, and - lie to AMANDA that it will have two tapes to use. If you have a holding disk - as large as a tape, and configure AMANDA (2.4.1b1 or newer) not to reserve any + lie to Amanda that it will have two tapes to use. If you have a holding disk + as large as a tape, and configure Amanda (2.4.1b1 or newer) not to reserve any space for degraded dumps, dumps that would be stored in the second tape of a run will be performed to the holding disk, so you can flush them to tape in the morning. amdump reported "infofile update failed". What should I do? - Make sure all directories and files are readable and writable by the AMANDA + Make sure all directories and files are readable and writable by the Amanda user, within the directory you specified as `infofile' in amanda.conf. From then on, only run amanda server commands ( amadmin, amdump, amflush, - amcleanup) as the AMANDA user, not as root. - Why does AMANDA sometimes promote full dumps? + amcleanup) as the Amanda user, not as root. + Why does Amanda sometimes promote full dumps? To spread the full dumps along the dumpcycle, so that daily runs take roughly - the same amount of tape and time. As soon as you start using AMANDA, it will + the same amount of tape and time. As soon as you start using Amanda, it will run full dumps of all filesystems. Then, on the following runs, it will promote some backups, so as to adjust the balance. After one or two dumpcycles, it should stop promoting dumps. You can see how well it is doing @@ -437,12 +465,12 @@ www.amanda.org/fom-serve/cache/1.html. Another possibility is that amrecover is not selecting the configuration name that contains the backups for the selected disk. You may specify a configuration name with the `-C' switch, when you invoke amrecover. The - default configuration name can only be specified at AMANDA configure time + default configuration name can only be specified at Amanda configure time (configure --with-config=). Indexes are currently generated at backup-time only, so, if a backup was performed without creating an index, you won't be able to use amrecover to restore it, you'll have to use amrestore. - Ok, I'm done with testing AMANDA, now I want to put it in production. How can + Ok, I'm done with testing Amanda, now I want to put it in production. How can I reset its databases so as to start from scratch? First, remove the `curinfo' database. By default, it is a directory, but, if you have selected any other database format (don't, they're deprecated), they @@ -453,16 +481,16 @@ www.amanda.org/fom-serve/cache/1.html. on the tape changer you have selected, you may also want to reset its state file. The man-page of dump says that active filesystems may be backed up - inconsistently. What does AMANDA do to prevent inconsistent backups? + inconsistently. What does Amanda do to prevent inconsistent backups? Nothing. When you back up an active filesystem, there are two possibilities: dump may print strange error messages about invalid blocks, then fail; in this - case, AMANDA will retry the backup on the next run. + case, Amanda will retry the backup on the next run. Files that are modified while dump runs may be backed up inconsistently. But then, they will be included in the next incremental backup, which should usually be enough. Large, critical files such as databases should be locked somehow, to avoid - inconsistent backups, but there's no direct support for that in AMANDA. The - best bet is to configure AMANDA to use a wrapper to dump, that locks and + inconsistent backups, but there's no direct support for that in Amanda. The + best bet is to configure Amanda to use a wrapper to dump, that locks and unlocks the database when appropriate. Which version of GNU-tar should I use? (This answer was slightly adapted from a posting by Paul Bijnens @@ -470,7 +498,7 @@ www.amanda.org/fom-serve/cache/1.html. * 1.13.19 is good. However it still sets return code 2 for some infrequent conditions even with - --ignore-failed-read option. This results in AMANDA thinking the total + --ignore-failed-read option. This results in Amanda thinking the total archive is bad, and drops the complete archive. Those conditions are very rare on a quiet filesystem. * 1.13.25 is good: no problems found (yet). @@ -488,7 +516,7 @@ www.amanda.org/fom-serve/cache/1.html. What does "bumping" mean? The term "bumping" is used to describe the change from one backup-level to the - next higher level. If AMANDA changes from Level 0 to Level 1 for a specific + next higher level. If Amanda changes from Level 0 to Level 1 for a specific DLE, it "bumps". The basic goal of "bumping" is to save precious space on the backup media as higher level incremental backups are smaller in size than lower level @@ -499,17 +527,57 @@ www.amanda.org/fom-serve/cache/1.html. of tape-errors and similar problems during the process of restore. So in general it is recommended to keep the levels as low as possible with the given hardware and data. - There are various amanda.conf parameters to control and fine-tune AMANDA's + There are various amanda.conf parameters to control and fine-tune Amanda's behavior when it comes to "bumping": Please refer to the amanda-manpage and the example amanda.conf for details on the parameters bumppercent, bumpsize, bumpdays and bumpmult. How do I backup a Windows server? - AMANDA is able to use smbclient to dump SMB/CIFS-shares. Refer to the Backup + Amanda is able to use smbclient to dump SMB/CIFS-shares. Refer to the Backup PC_hosts_using_Samba for details. + How do I tell my iptables-based firewall to allow Amanda through? + posted by Matt Hyclak : + Use something like + + iptables -A INPUT -p udp -s $AMANDA_SERVER -d $AMANDA_CLIENT --dport + 10080 -j ACCEPT + + and load the ip_conntrack_amanda kernel module. I use the following in /etc/ + modprobe.conf: + + options ip_conntrack_amanda master_timeout=2400 + install ip_tables /sbin/modprobe --ignore-install ip_tables && /sbin/ + modprobe ip_conntrack_amanda + + This sets the UDP timeout for Amanda packets to 2400 seconds, up from the + default 300 (don't hold me to that, it might be 600). I was getting estimate + timeouts since they were taking longer than 300/600 seconds and the firewall + would close the port. + Makes things a little more secure than opening up everything > 1024 ;-) + How do I get rid of pressing "q" to get rid of a pager prompt when using + amrecover? + compiled from postings by Paul Bijnens and Jon + LaBadie + Paul Bijnens wrote: + If you have to press "q" all the time in amrecover this is related to the + pager-binary you use. If you use Linux this will be most likely less. To teach + less to quit when hitting EOF, you need to set something like LESS=--QUIT-AT- + EOF; export LESS, for example in your .profile. Refer to the manpage of less + for details. + Jon LaBadie wrote: + If you don't like the quit at EOF behavior "except" when in amrecover create + an alias or a wrapper; something like: + alias amrecov='LESS="$LESS -E" _pathto_your_amrecover' + Is there a way to tell the pager that my terminal has "y" lines? + Jon LaBadie wrote: + The pager normally does it's best to find out how many lines your terminal + has, given the right TERM-variable. Even terminals with elastic boundaries + (e.g. xterms) work. But I have to admit that on Solaris the settings are not + always correct. You can fix it quickly by setting an environment variable to + e.g. LINES=24 (and export it). ------------------------------------------------------------------------------- Prev Up Next -Chapter 16. Using AMANDA Home Chapter 18. Collection of the top ten AMANDA +Chapter 18. Using Amanda Home Chapter 20. Collection of the top ten Amanda questions. And answers. diff --git a/docs/historical.txt b/docs/historical.txt index b483bdb..c97fc9e 100644 --- a/docs/historical.txt +++ b/docs/historical.txt @@ -5,24 +5,24 @@ Prev Next ------------------------------------------------------------------------------- -Historical files +Part VI. Historical files Old and outdated material, proposals and drafts. Here you find some chapters which contain outdated informations. These chapters -nonetheless can help to get a more complete picture of AMANDA. +nonetheless can help to get a more complete picture of Amanda. Note Please realize that the following does not necessarily describe current -features of AMANDA. There are also features described which were never added to -AMANDA. +features of Amanda. There are also features described which were never added to +Amanda. Table of Contents - 28._Response_to_CPIO_Security_Notice_Issue_11: + 29._Response_to_CPIO_Security_Notice_Issue_11: Affected_Versions @@ -32,12 +32,12 @@ Table of Contents Acknowledgements - 29._Upgrade_Issues + 30._Upgrade_Issues - 30._What_once_was_new + 31._What_once_was_new - What's_new_in_AMANDA_2.3 + What's_new_in_Amanda_2.3 Indexing_backups_for_easier_restore @@ -57,7 +57,7 @@ Table of Contents amadmin_import/export - What's_new_in_AMANDA_2.2 + What's_new_in_Amanda_2.2 Client_side_setup_has_changed @@ -94,7 +94,7 @@ Table of Contents - 31._Multitape_support_in_AMANDA_2.2 + 32._Multitape_support_in_Amanda_2.2 Introduction @@ -124,15 +124,15 @@ Table of Contents - 32._Thoughts_about_a_Strategy_API + 33._Thoughts_about_a_Strategy_API - 33._Y2K_Compliancy + 34._Y2K_Compliancy - 34._Usage_of_floppy_tape_drives_on_Linux + 35._Usage_of_floppy_tape_drives_on_Linux ------------------------------------------------------------------------------- -Prev Up Next -Chapter 27. Using Kerberos with Home Chapter 28. Response to CPIO Security -AMANDA Notice Issue 11: +Prev Next +Chapter 28. Using Kerberos with Home Chapter 29. Response to CPIO Security +Amanda Notice Issue 11: diff --git a/docs/howto-afs.txt b/docs/howto-afs.txt index d409c12..4554e4f 100644 --- a/docs/howto-afs.txt +++ b/docs/howto-afs.txt @@ -7,7 +7,7 @@ Prev Part III. HOWTOs Next Chapter 14. AFS HOWTO -AMANDA Core Team +Amanda Core Team AMANDA Core Team @@ -26,10 +26,10 @@ with amanda: ftp://ftp.ccmr.cornell.edu/pub/amanda-afs/amanda-afs.tar.gz or anonymous cvs from :pserver:anonymous@cvs.ccmr.cornell.edu:/usr/common/cvs and checkout project 'amanda-afs' -The patch to AMANDA is already included in this distribution. +The patch to Amanda is already included in this distribution. ------------------------------------------------------------------------------- Prev Up Next -Chapter 13. How to use the AMANDA file- Home Chapter 15. How to use a wrapper +Chapter 13. How to use the Amanda file- Home Chapter 15. How to use a wrapper driver diff --git a/docs/howto-auth.txt b/docs/howto-auth.txt new file mode 100644 index 0000000..9699de6 --- /dev/null +++ b/docs/howto-auth.txt @@ -0,0 +1,197 @@ + +Chapter 17. How to use different auth with Amanda +Prev Part III. HOWTOs Next + +------------------------------------------------------------------------------- + +Chapter 17. How to use different auth with Amanda + + +Jean-Louis Martineau + +Original text;XML-conversion;Updates +AMANDA Core Team + +Table of Contents + + + Introduction + + BSD + + BSDTCP + + BSDUDP + + KRB4 + + KRB5 + + RSH + + SSH + + + For_amdump: + + For_amrecover: + + + +Note + +Refer to http://www.amanda.org/docs/howto-auth.html for the current version of +this document. +This document covers the use of the auth in Amanda 2.5.1 and higher. + +Introduction + + + BSD + +You must configure amanda with --with-bsd-security and --with-amandahosts. +The xinetd.d/amanda file on the client: + + service amanda + { + only_from = 127.0.0.1 + socket_type = dgram + protocol = udp + wait = yes + user = amanda + group = amanda + groups = yes + server = /path/to/amandad + server_args = -auth=bsd amdump + disable = no + } + +The only_from line should list your tape server ip address. +The ~amanda/.amandahosts file on the client: + + tapeserver.fqdn amanda amdump + +If you want to also enable amindexd and amidxtaped, you must change the +server_args line in the xinetd.d/amanda file on the tape server: + + server_args = -auth=bsd amdump amindexd amidxtaped + +The only_from line should list all machine that can use amdump/amrecover. It's +the .amandahosts that will limit which client can use amdump/amindexd/ +amidxtaped. +The ~amanda/.amandahosts file on the tape server must have a line for each +machi ne: + + clientmachine1 amanda amindexd amidxtaped + clientmachine2 amanda amindexd amidxtaped + + + BSDTCP + +Like bsd but you must configure amanda with --with-bsdtcp-security and --with- +amandahosts and do 4 changes in the xinetd.d/amanda file: + + socket_type = stream + protocol = tcp + wait = no + server_args = -auth=bsdtcp amdump + + + BSDUDP + +Like bsd but you must configure amanda with --with-bsdudp-security and --with- +amandahosts and do 1 change in the xinetd.d/amanda file: + + server_args = -auth=bsdudp amdump + + + KRB4 + +You must configure amanda with --with-krb4-security. + + KRB5 + +You must configure amanda with --with-krb5-security. + + RSH + +You must configure amanda with --with-rsh-security. +It's your system that should allow your server user to rsh to your client user. +If your server username and client username are different, you must add the +client_username option in all DLE for that host. + + client_username "client_username" + +If your server amandad path and client amandad path are different, you must set +the amandad_path option in all DLE for that hosts. + + amandad_path "client/amandad/path" + + + SSH + +You must configure amanda with --with-ssh-security. + + For amdump: + +You must create an ssh key for your server. In this example, the key is put in +the id_rsa_amdump file: + + ssh-keygen -t rsa + Enter file in which to save the key (/home/amanda/.ssh/id_rsa)? /home/ + amanda/.ssh/id_rsa_amdump + +You must set the ssh_keys option in all DLE for that host: + + ssh_keys "/home/amanda/.ssh/id_rsa_amdump" + +You mush append the /home/amanda/.ssh/id_rsa_amdump.pub file to the .ssh/ +authorized_keys file of all client host. +For security reason, you must prepend the line with the following: + + from="tape_server_fqdn_name",no-port-forwarding,no-X11-forwarding,no-agent- + forwarding,command="/path/to/amandad -auth=ssh amdump" + +That will limit that key to connect only from your server and only be able to +execute amandad. +Like rsh if your server username and client username are different, you must +add the client_username option in all DLE for that +host: + + client_username "client_username" + +Like rsh, if your server amandad path and client amandad path are different, +you must set the amandad_path option in all DLE for that hosts: + + amandad_path "client/amandad/path" + + + For amrecover: + +You must create an ssh key for root on all clients that can use amrecover. In +this example, the key is put in the /root/.ssh/id_ rsa_amrecover file: +Log in as root: + + ssh-keygen -t rsa + Enter file in which to save the key (/root/.ssh/id_rsa)? /root/.ssh/ + id_rsa_amrecover + +You must set the ssh_keys option in the amanda_client.conf file + + ssh_keys "/root/.ssh/id_rsa_amrecover" + +You mush append all client /home/root/.ssh/id_rsa_amrecover.pub file to the / +home/amanda/.ssh/authorized_keys of the server. +For security reason, you must prefix all lines with the following: + + from="aclient_fqdn_name",no-port-forwarding,no-X11-forwarding,no-agent- + forwarding,command="/path/to/amandad -auth=ssh amindexd amidxtaped" + +That will limit every client key to connect from the client and only be able to +execute amandad. +------------------------------------------------------------------------------- + +Prev Up Next +Chapter 16. How to do Amanda-server-side Home Part IV. Various Information +gpg-encrypted backups. + diff --git a/docs/howto-cygwin.txt b/docs/howto-cygwin.txt index 5f762c5..5daa0d1 100644 --- a/docs/howto-cygwin.txt +++ b/docs/howto-cygwin.txt @@ -1,10 +1,10 @@ -Chapter 12. AMANDA on Cygwin HOWTO +Chapter 12. Amanda on Cygwin HOWTO Prev Part III. HOWTOs Next ------------------------------------------------------------------------------- -Chapter 12. AMANDA on Cygwin HOWTO +Chapter 12. Amanda on Cygwin HOWTO Doug Kingston @@ -23,7 +23,7 @@ Table of Contents Other_Preparation - Compile_AMANDA + Compile_Amanda Configure_Cygwin_files @@ -35,7 +35,7 @@ Table of Contents Windows_NT/2000/XP - Notes_on_AMANDA_backup_options + Notes_on_Amanda_backup_options Compression @@ -50,11 +50,11 @@ Note Refer to http://www.amanda.org/docs/howto-cygwin.html for the current version of this document. -by Doug Kingston, 30 January 2003. Based on Cygwin 1.3.18, and AMANDA 2.4.3- +by Doug Kingston, 30 January 2003. Based on Cygwin 1.3.18, and Amanda 2.4.3- 20021027 and some fixes which will be in the official release by the time you see this. With thanks to Enrico Bernardini from whom I have borrowed some material from -an earlier attempt at documenting the installation of AMANDA on Cygwin in 2001. +an earlier attempt at documenting the installation of Amanda on Cygwin in 2001. Please send annotations and corrections to mailto://amanda-hackers@amanda.org. I can be reached as dpk (at) randomnotes.org (do the obvious). @@ -79,7 +79,7 @@ a more specific list of what is required. If someone has a more definitive list, I would appreciate and email to mailto://amanda-hackers@amanda.org. One user reported some problems with access rights when running under Cygwin, which he solved by setting the CYGWIN environment variable to nontsec. I do not -believe this is necessary if you run the AMANDA daemon as System (see below). +believe this is necessary if you run the Amanda daemon as System (see below). Other Preparation @@ -87,7 +87,7 @@ When doing backups on a NT, Windows 2000 or Windows XP system, the choice of user and group will be important if you are to properly interact with the security mechanisms of these more modern Microsoft product. For Windows 95/98/ ME this is probably a non-issue. The most privileged account on the Windows -systems is 'System', and I have chosen to use this account for AMANDA backups +systems is 'System', and I have chosen to use this account for Amanda backups to ensure that I can access the widest set of files. On Unix we would run as root, with equivalent access permissions. I have also chose to run under the 'Administrators' group, another standard Windows group. Ensure these exist @@ -105,10 +105,10 @@ relevant lines from my file /etc/passwd are: root:*:18:18:,S-1-5-18:/home/root: - Compile AMANDA + Compile Amanda -After installing Cygwin, unpack the AMANDA sources, typically in /usr/src/ -AMANDA or something similar. In the AMANDA directory, you will need to execute: +After installing Cygwin, unpack the Amanda sources, typically in /usr/src/ +Amanda or something similar. In the Amanda directory, you will need to execute: automake # this may not be necessary in the official release autoconf # this may not be necessary in the official release @@ -150,7 +150,7 @@ You have to modify some config files: * create _/home/root/.amandahosts_ (or whereever System's home directory is): -Then create the following AMANDA directories and the file amandates: +Then create the following Amanda directories and the file amandates: mkdir -p /usr/local/var/amanda/gnutar-lists @@ -165,9 +165,9 @@ Update the Windows services list * WINDIR\Services: add - amanda 10080/udp # AMANDA backup services - amandaidx 10082/tcp # AMANDA backup services - amidxtape 10083/tcp # AMANDA backup services + amanda 10080/udp # Amanda backup services + amandaidx 10082/tcp # Amanda backup services + amidxtape 10083/tcp # Amanda backup services where WINDIR is C:\WINNT\system32\drivers\etc or something similar. The last @@ -220,7 +220,7 @@ Then, to start/stop the inetd service use the Services control panel or the following Windows command: net start/stop inetd - Notes on AMANDA backup options + Notes on Amanda backup options Compression @@ -229,15 +229,15 @@ Currently, client side compression does not work, probably due to problems in pipe emulation in Cygwin. I have not tried to debug this yet. This may be addressed in a subsequent release, or it could be fixed in later releases of Cygwin. Due to this issue, we recommend that if you want compressed dumps from -Windows clients, you configure AMANDA for server compression in amanda.conf on -your AMANDA server: +Windows clients, you configure Amanda for server compression in amanda.conf on +your Amanda server: define dumptype srv-comp-tar { global comment "partitions dumped via tar with server compression" program "GNUTAR" compress server fast - exclude list ".AMANDA.exclude" + exclude list ".Amanda.exclude" } @@ -252,10 +252,10 @@ something similar if you want to get the Windows files and the Cygwin files. '/ Debugging Files -AMANDA will leave debugging files in /tmp/amanda if it exists. I have +Amanda will leave debugging files in /tmp/amanda if it exists. I have recommended to create this directory above. ------------------------------------------------------------------------------- Prev Up Next -Part III. HOWTOs Home Chapter 13. How to use the AMANDA file-driver +Part III. HOWTOs Home Chapter 13. How to use the Amanda file-driver diff --git a/docs/howto-filedriver.txt b/docs/howto-filedriver.txt index 6d16a65..b6ba1df 100644 --- a/docs/howto-filedriver.txt +++ b/docs/howto-filedriver.txt @@ -1,10 +1,10 @@ -Chapter 13. How to use the AMANDA file-driver +Chapter 13. How to use the Amanda file-driver Prev Part III. HOWTOs Next ------------------------------------------------------------------------------- -Chapter 13. How to use the AMANDA file-driver +Chapter 13. How to use the Amanda file-driver Stefan G. Weichinger @@ -32,33 +32,33 @@ Note Refer to http://www.amanda.org/docs/howto-filedriver.html for the current version of this document. -This document covers the use of the file-driver in AMANDA 2.4.3 and higher. +This document covers the use of the file-driver in Amanda 2.4.3 and higher. Examples given here have been taken from a SuSE-Linux-8.2-Pro-environment, -using AMANDA 2.4.4p1 and the snapshot 2.4.4p1-20031202. Please adjust paths, +using Amanda 2.4.4p1 and the snapshot 2.4.4p1-20031202. Please adjust paths, configuration names and other parameters to your system. Stefan G. Weichinger, November - December, 2003 ; minor updates in April, 2005. Introduction -Since release 2.4.3 AMANDA supports the usage of a output driver called "file". +Since release 2.4.3 Amanda supports the usage of a output driver called "file". See man amanda, section OUTPUT DRIVERS, for more information on its implementation. As the name suggests, this driver uses files as virtual (or file) tapes. Once created and labeled, these file tapes can be selected and -changed with the standard tape-changer-interface of the AMANDA server. +changed with the standard tape-changer-interface of the Amanda server. Possible Uses * test installations - You can easily explore the rich features of AMANDA on systems without tape + You can easily explore the rich features of Amanda on systems without tape drives. * cheap installations - Without buying a tape drive you can enjoy the benefits of AMANDA and backup + Without buying a tape drive you can enjoy the benefits of Amanda and backup to a bunch of harddisks. You can create CD/DVD-sized backups which you can burn onto optical disks later. * disk-based installations You can use the file-driver to backup onto a set of file tapes hosted on a - bunch of hard-disks or a RAID-system. Combined with another AMANDA- + bunch of hard-disks or a RAID-system. Combined with another Amanda- configuration that dumps the file tapes to real tapes, you can provide reliable backup with faster tapeless recovery. This is called "disk-to-disk- to-tape"-backup by some people today. @@ -69,7 +69,7 @@ changed with the standard tape-changer-interface of the AMANDA server. Basics -This guide assumes you have setup the basic AMANDA-services as described in +This guide assumes you have setup the basic Amanda-services as described in Amanda_Installation_Notes The configuration in this HOWTO is called "daily". The file tapes are also called vtapes in this document, which stands for "virtual tapes". @@ -82,7 +82,7 @@ disk(s) for your file tape storage. While this space could be spread among several file systems and hard disks, I recommend to dedicate at least a specific partition, better a specific physical harddisk to the task of keeping your vtapes. The use of a dedicated disk will speed things up definitely. -The disk space you dedicate for your vtapes should NOT be backed up by AMANDA. +The disk space you dedicate for your vtapes should NOT be backed up by Amanda. Also, for performance reasons there should be NO holding disks on the same partition as the vtapes, preferably not even on the same physical drive. If you only have one harddisk, it will work out, too, but you will suffer low @@ -120,7 +120,7 @@ Steps (Available Space * 0.9) >= tapelength * tapecycle This is a very conservative approach to make sure you don´t suffer any performance drop due to a nearly-full-filesystem. - As it is uncommon for AMANDA to fill, or almost fill an entire tape you + As it is uncommon for Amanda to fill, or almost fill an entire tape you may also wish to use more space than that. So you could determine possible combinations of tapelength/tapecycle with the more general formula: @@ -156,15 +156,15 @@ Steps You don´t have to specify the parameter speed (as it is commonly listed in - tapetype definitions and reported by the program amtapetype). AMANDA does + tapetype definitions and reported by the program amtapetype). Amanda does not use this parameter right now. There is also an optional parameter filemark, which indicates the amount - of space "wasted" after each tape-listitem. Leave it blank and AMANDA uses + of space "wasted" after each tape-listitem. Leave it blank and Amanda uses the default of 1KB. 4. Think about tapechangers. As you will use a set of vtapes, you have to also use a kind of vtape- - changer. There are several tape-changer-scripts included in the AMANDA- - tarball. Read more about tape-changer-scripts in AMANDA_Tape_Changer + changer. There are several tape-changer-scripts included in the Amanda- + tarball. Read more about tape-changer-scripts in Amanda_Tape_Changer Support. Right now there are two scripts that can be used with vtapes. These scripts take different approaches to the handling of tapes. @@ -174,13 +174,13 @@ Steps chg-multi simulates multiple tape drives with one tape in each drive. chg- disk simulates one tape-library with multiple tapes in. As chg-multi exists for a much longer time than chg-disk, it is still used - in many AMANDA-vtape-installations. + in many Amanda-vtape-installations. chg-disk was introduced with the snapshot 20031202. Contrary to chg-multi, which is a generic changer-script that must be somewhat adjusted to the use of the file-driver, chg-disk offers exactly the behavior needed for handling vtapes IMHO the approach is much more logical, so I recommend to use chg-disk in - new AMANDA-vtape-installations. + new Amanda-vtape-installations. Note @@ -204,11 +204,11 @@ Steps This reflects the use of your defined tapetype. - The parameter tapecycle tells AMANDA how much tapes can be used, Set this + The parameter tapecycle tells Amanda how much tapes can be used, Set this value according to the number of tapes you want to use. The parameter tapetype , points to the tapetype definition you have created before. - The parameter tpchanger tells AMANDA to use the generic tape-changer- + The parameter tpchanger tells Amanda to use the generic tape-changer- script to handle the vtapes. You can think of it as a virtual tape- changer-device. The parameter changerfile is used to give chg-disk the "prefix" for the @@ -280,7 +280,7 @@ Steps $ ln -s /amandatapes/daily/slot1 /amandatapes/daily/data - Make sure the AMANDA-user has write-permissions on these directories: + Make sure the Amanda-user has write-permissions on these directories: $ chown -R amanda_user /amandatapes $ chgrp -R amanda_group /amandatapes @@ -288,7 +288,7 @@ Steps 7. Label the virtual tapes. - As the virtual tapes are handled just like physical tapes by the AMANDA- + As the virtual tapes are handled just like physical tapes by the Amanda- Server they have to be labeled before use. Usage: amlabel [-f]