Print this page
NEX-13374 NDMP should be able to backup unmounted ZFS filesystems
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Revert "NEX-5801 Snapshots left over after failed backups"
This reverts commit f182fb95f09036db71fbfc6f0a6b90469b761f21.
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2911 NDMP logging should use syslog and is too chatty
NEX-894 Default location of NDMP log file should be under /var/log
NEX-727 Netbackup Catalog verification hangs waiting for NDMP server

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c
          +++ new/usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c
   1    1  /*
   2    2   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
   3      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
        3 + * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
   4    4   */
   5    5  
   6    6  /*
   7    7   * BSD 3 Clause License
   8    8   *
   9    9   * Copyright (c) 2007, The Storage Networking Industry Association.
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
↓ open down ↓ 22 lines elided ↑ open up ↑
  36   36   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37   37   * POSSIBILITY OF SUCH DAMAGE.
  38   38   */
  39   39  /* Copyright (c) 2007, The Storage Networking Industry Association. */
  40   40  /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
  41   41  
  42   42  #include <sys/types.h>
  43   43  #include <sys/socket.h>
  44   44  #include <sys/time.h>
  45   45  #include <sys/uio.h>
       46 +#include <syslog.h>
  46   47  #include <unistd.h>
  47   48  #include <string.h>
  48   49  #include <stdlib.h>
  49   50  #include <errno.h>
  50   51  #include <netdb.h>
  51   52  #include <netinet/in.h>
  52   53  #include <arpa/inet.h>
  53   54  #include <libinetutil.h>
  54   55  #include "ndmpd.h"
  55   56  #include "ndmpd_common.h"
↓ open down ↓ 21 lines elided ↑ open up ↑
  77   78   * Refer to NDMP_FULL_RESTORE_PATH for partial path and full path definition.
  78   79   */
  79   80  int ndmp_full_restore_path = 1;
  80   81  
  81   82  /*
  82   83   * Do we support Direct Access Restore?
  83   84   */
  84   85  int ndmp_dar_support = 0;
  85   86  
  86   87  /*
       88 + * Is autosync enabled?
       89 + */
       90 +int ndmp_autosync_support = 0;
       91 +
       92 +/*
       93 + * Is HPR snapshot enabled?
       94 + */
       95 +int ndmp_hpr_support = 0;
       96 +
       97 +/*
  87   98   * ndmp_connection_t handler function
  88   99   */
  89  100  static ndmpd_file_handler_func_t connection_file_handler;
  90  101  
  91  102  extern ndmp_handler_t ndmp_msghdl_tab[];
  92  103  
  93  104  static int ndmp_readit(void *connection_handle,
  94  105      caddr_t buf,
  95  106      int len);
  96  107  static int ndmp_writeit(void *connection_handle,
↓ open down ↓ 50 lines elided ↑ open up ↑
 147  158          connection->conn_msginfo.mi_body = 0;
 148  159          connection->conn_version = ndmp_ver;
 149  160          connection->conn_client_data = 0;
 150  161          (void) mutex_init(&connection->conn_lock, 0, NULL);
 151  162          connection->conn_xdrs.x_ops = 0;
 152  163  
 153  164          xdrrec_create(&connection->conn_xdrs, 0, 0, (caddr_t)connection,
 154  165              ndmp_readit, ndmp_writeit);
 155  166  
 156  167          if (connection->conn_xdrs.x_ops == 0) {
 157      -                NDMP_LOG(LOG_DEBUG, "xdrrec_create failed");
      168 +                syslog(LOG_ERR, "xdrrec_create failed");
 158  169                  (void) mutex_destroy(&connection->conn_lock);
 159  170                  (void) close(connection->conn_sock);
 160  171                  free(connection);
 161  172                  return (0);
 162  173          }
 163  174          return ((ndmp_connection_t *)connection);
 164  175  }
 165  176  
 166  177  /*
 167  178   * ndmp_destroy_connection
↓ open down ↓ 103 lines elided ↑ open up ↑
 271  282          int server_socket;
 272  283          unsigned int ipaddr;
 273  284          struct sockaddr_in sin;
 274  285          ndmpd_worker_arg_t *argp;
 275  286  
 276  287          sin.sin_family = AF_INET;
 277  288          sin.sin_addr.s_addr = INADDR_ANY;
 278  289          sin.sin_port = htons(port);
 279  290  
 280  291          if ((server_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 281      -                NDMP_LOG(LOG_DEBUG, "Socket error: %m");
      292 +                syslog(LOG_ERR, "Socket error: %m");
 282  293                  return (-1);
 283  294          }
 284  295  
 285  296          on = 1;
 286  297          (void) setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR,
 287  298              (char *)&on, sizeof (on));
 288  299  
 289  300  
 290  301          if (bind(server_socket, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
 291      -                NDMP_LOG(LOG_DEBUG, "bind error: %m");
      302 +                syslog(LOG_ERR, "bind error: %m");
 292  303                  (void) close(server_socket);
 293  304                  return (-1);
 294  305          }
 295  306          if (listen(server_socket, 5) < 0) {
 296      -                NDMP_LOG(LOG_DEBUG, "listen error: %m");
      307 +                syslog(LOG_ERR, "listen error: %m");
 297  308                  (void) close(server_socket);
 298  309                  return (-1);
 299  310          }
 300  311  
 301  312          for (; ; ) {
 302  313                  if ((ns = tcp_accept(server_socket, &ipaddr)) < 0) {
 303      -                        NDMP_LOG(LOG_DEBUG, "tcp_accept error: %m");
      314 +                        syslog(LOG_ERR, "tcp_accept error: %m");
 304  315                          continue;
 305  316                  }
 306      -                NDMP_LOG(LOG_DEBUG, "connection fd: %d", ns);
 307  317                  set_socket_options(ns);
 308  318  
 309  319                  if ((argp = ndmp_malloc(sizeof (ndmpd_worker_arg_t))) != NULL) {
 310  320                          argp->nw_sock = ns;
 311  321                          argp->nw_ipaddr = ipaddr;
 312  322                          argp->nw_con_handler_func = con_handler_func;
 313  323                          (void) ndmp_start_worker(argp);
 314  324                  }
 315  325          }
 316  326  }
↓ open down ↓ 98 lines elided ↑ open up ↑
 415  425      ndmp_error err, void *request_data, void **reply)
 416  426  {
 417  427          ndmp_connection_t *connection = (ndmp_connection_t *)connection_handle;
 418  428          ndmp_header header;
 419  429          ndmp_msg_handler_t *handler;
 420  430          int r;
 421  431          struct timeval time;
 422  432  
 423  433          /* Lookup info necessary for processing this request. */
 424  434          if (!(handler = ndmp_get_handler(connection, message))) {
 425      -                NDMP_LOG(LOG_DEBUG, "Sending message 0x%x: not supported",
      435 +                syslog(LOG_ERR, "Sending message 0x%x: not supported",
 426  436                      message);
 427  437                  return (-1);
 428  438          }
 429  439          (void) gettimeofday(&time, 0);
 430  440  
 431  441          header.sequence = ++(connection->conn_my_sequence);
 432  442          header.time_stamp = time.tv_sec;
 433  443          header.message_type = NDMP_MESSAGE_REQUEST;
 434  444          header.message = message;
 435  445          header.reply_sequence = 0;
 436  446          header.error = err;
 437  447  
 438  448          connection->conn_xdrs.x_op = XDR_ENCODE;
 439  449          if (!xdr_ndmp_header(&connection->conn_xdrs, &header)) {
 440      -                NDMP_LOG(LOG_DEBUG,
      450 +                syslog(LOG_ERR,
 441  451                      "Sending message 0x%x: encoding request header", message);
 442  452                  (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
 443  453                  return (-1);
 444  454          }
 445  455          if (err == NDMP_NO_ERR && handler->mh_xdr_request && request_data) {
 446  456                  if (!(*handler->mh_xdr_request)(&connection->conn_xdrs,
 447  457                      request_data)) {
 448      -                        NDMP_LOG(LOG_DEBUG,
      458 +                        syslog(LOG_ERR,
 449  459                              "Sending message 0x%x: encoding request body",
 450  460                              message);
 451  461                          (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
 452  462                          return (-1);
 453  463                  }
 454  464          }
 455  465          (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
 456  466  
 457  467          if (handler->mh_xdr_reply == 0) {
 458      -                NDMP_LOG(LOG_DEBUG, "handler->mh_xdr_reply == 0");
 459  468                  return (0);
 460  469          }
 461  470  
 462  471          /*
 463  472           * Process messages until the reply to this request has been
 464  473           * processed.
 465  474           */
 466  475          for (; ; ) {
 467  476                  r = ndmp_process_messages(connection, TRUE);
 468  477  
↓ open down ↓ 2 lines elided ↑ open up ↑
 471  480                          return (-1);
 472  481  
 473  482                  /* no reply received? */
 474  483                  if (r == 0)
 475  484                          continue;
 476  485  
 477  486                  /* reply received? */
 478  487                  if (r == 1) {
 479  488                          if (message !=
 480  489                              connection->conn_msginfo.mi_hdr.message) {
 481      -                                NDMP_LOG(LOG_DEBUG,
      490 +                                syslog(LOG_ERR,
 482  491                                      "Received unexpected reply 0x%x",
 483  492                                      connection->conn_msginfo.mi_hdr.message);
 484  493                                  ndmp_free_message(connection_handle);
 485  494                                  return (-1);
 486  495                          }
 487  496                          if (reply != NULL)
 488  497                                  *reply = connection->conn_msginfo.mi_body;
 489  498                          else
 490  499                                  ndmp_free_message(connection_handle);
 491  500  
↓ open down ↓ 72 lines elided ↑ open up ↑
 564  573  
 565  574          header.sequence = ++(connection->conn_my_sequence);
 566  575          header.time_stamp = time.tv_sec;
 567  576          header.message_type = NDMP_MESSAGE_REPLY;
 568  577          header.message = connection->conn_msginfo.mi_hdr.message;
 569  578          header.reply_sequence = connection->conn_msginfo.mi_hdr.sequence;
 570  579          header.error = err;
 571  580  
 572  581          connection->conn_xdrs.x_op = XDR_ENCODE;
 573  582          if (!xdr_ndmp_header(&connection->conn_xdrs, &header)) {
 574      -                NDMP_LOG(LOG_DEBUG, "Sending message 0x%x: "
      583 +                syslog(LOG_ERR, "Sending message 0x%x: "
 575  584                      "encoding reply header",
 576  585                      header.message);
 577  586                  (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
 578  587                  return (-1);
 579  588          }
 580  589          if (err == NDMP_NO_ERR &&
 581  590              connection->conn_msginfo.mi_handler->mh_xdr_reply &&
 582  591              reply) {
 583  592                  if (!(*connection->conn_msginfo.mi_handler->mh_xdr_reply)(
 584  593                      &connection->conn_xdrs, reply)) {
 585      -                        NDMP_LOG(LOG_DEBUG,
      594 +                        syslog(LOG_ERR,
 586  595                              "Sending message 0x%x: encoding reply body",
 587  596                              header.message);
 588  597                          (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
 589  598                          return (-1);
 590  599          }
 591  600          }
 592  601          (void) xdrrec_endofrecord(&connection->conn_xdrs, 1);
 593  602          return (0);
 594  603  }
 595  604  
↓ open down ↓ 255 lines elided ↑ open up ↑
 851  860          session.ns_mover.md_record_size = MAX_RECORD_SIZE;
 852  861  
 853  862          ndmp_set_client_data(connection, (void *)&session);
 854  863  
 855  864          req.reason = NDMP_CONNECTED;
 856  865          req.protocol_version = ndmp_ver;
 857  866          req.text_reason = "";
 858  867  
 859  868          if (ndmp_send_request_lock(connection, NDMP_NOTIFY_CONNECTION_STATUS,
 860  869              NDMP_NO_ERR, (void *)&req, 0) < 0) {
 861      -                NDMP_LOG(LOG_DEBUG, "Connection terminated");
      870 +                syslog(LOG_DEBUG, "Send CONNECTION STATUS failed");
 862  871                  return;
 863  872          }
 864  873          connection_fd = ndmp_get_fd(connection);
 865  874  
 866      -        NDMP_LOG(LOG_DEBUG, "connection_fd: %d", connection_fd);
 867      -
 868  875          /*
 869  876           * Add the handler function for the connection to the DMA.
 870  877           */
 871  878          if (ndmpd_add_file_handler(&session, (void *)&session, connection_fd,
 872  879              NDMPD_SELECT_MODE_READ, HC_CLIENT, connection_file_handler) != 0) {
 873      -                NDMP_LOG(LOG_DEBUG, "Could not register session handler.");
      880 +                syslog(LOG_ERR, "Could not register session handler.");
 874  881                  return;
 875  882          }
 876  883  
 877  884          /*
 878  885           * Register the connection in the list of active connections.
 879  886           */
 880  887          if (ndmp_connect_list_add(connection, &conn_id) != 0) {
 881      -                NDMP_LOG(LOG_ERR,
      888 +                syslog(LOG_ERR,
 882  889                      "Could not register the session to the server.");
 883  890                  (void) ndmpd_remove_file_handler(&session, connection_fd);
 884  891                  return;
 885  892          }
 886  893  
 887  894          session.hardlink_q = hardlink_q_init();
 888  895  
 889  896          while (session.ns_eof == FALSE)
 890  897                  (void) ndmpd_select(&session, TRUE, HC_ALL);
 891  898  
 892  899          hardlink_q_cleanup(session.hardlink_q);
 893  900  
 894      -        NDMP_LOG(LOG_DEBUG, "Connection terminated");
 895      -
 896  901          (void) ndmpd_remove_file_handler(&session, connection_fd);
 897  902  
 898  903          if (session.ns_scsi.sd_is_open != -1) {
 899      -                NDMP_LOG(LOG_DEBUG, "scsi.is_open: %d",
      904 +                syslog(LOG_ERR, "scsi.is_open: %d",
 900  905                      session.ns_scsi.sd_is_open);
 901  906                  (void) ndmp_open_list_del(session.ns_scsi.sd_adapter_name,
 902  907                      session.ns_scsi.sd_sid, session.ns_scsi.sd_lun);
 903  908          }
 904  909          if (session.ns_tape.td_fd != -1) {
 905      -                NDMP_LOG(LOG_DEBUG, "tape.fd: %d", session.ns_tape.td_fd);
      910 +                syslog(LOG_ERR, "tape.fd: %d", session.ns_tape.td_fd);
 906  911                  (void) close(session.ns_tape.td_fd);
 907  912                  (void) ndmp_open_list_del(session.ns_tape.td_adapter_name,
 908  913                      session.ns_tape.td_sid, session.ns_tape.td_lun);
 909  914          }
 910  915          ndmpd_mover_shut_down(&session);
 911  916          ndmp_lbr_cleanup(&session);
 912  917          ndmpd_data_cleanup(&session);
 913  918          ndmpd_file_history_cleanup(&session, FALSE);
 914  919          ndmpd_mover_cleanup(&session);
 915  920  
↓ open down ↓ 111 lines elided ↑ open up ↑
1027 1032          /* Decode the header. */
1028 1033          connection->conn_xdrs.x_op = XDR_DECODE;
1029 1034          (void) xdrrec_skiprecord(&connection->conn_xdrs);
1030 1035          if (!xdr_ndmp_header(&connection->conn_xdrs,
1031 1036              &connection->conn_msginfo.mi_hdr))
1032 1037                  return (-1);
1033 1038  
1034 1039          /* Lookup info necessary for processing this message. */
1035 1040          if ((connection->conn_msginfo.mi_handler = ndmp_get_handler(connection,
1036 1041              connection->conn_msginfo.mi_hdr.message)) == 0) {
1037      -                NDMP_LOG(LOG_DEBUG, "Message 0x%x not supported",
     1042 +                syslog(LOG_DEBUG, "Message 0x%x not supported",
1038 1043                      connection->conn_msginfo.mi_hdr.message);
1039 1044                  return (NDMP_NOT_SUPPORTED_ERR);
1040 1045          }
1041 1046          connection->conn_msginfo.mi_body = 0;
1042 1047  
1043 1048          if (connection->conn_msginfo.mi_hdr.error != NDMP_NO_ERR)
1044 1049                  return (0);
1045 1050  
1046 1051          /* Determine body type */
1047 1052          if (connection->conn_msginfo.mi_hdr.message_type ==
1048 1053              NDMP_MESSAGE_REQUEST) {
1049 1054                  if (ndmp_check_auth_required(
1050 1055                      connection->conn_msginfo.mi_hdr.message) &&
1051 1056                      !connection->conn_authorized) {
1052      -                        NDMP_LOG(LOG_DEBUG,
     1057 +                        syslog(LOG_ERR,
1053 1058                              "Processing request 0x%x:connection not authorized",
1054 1059                              connection->conn_msginfo.mi_hdr.message);
1055 1060                          return (NDMP_NOT_AUTHORIZED_ERR);
1056 1061                  }
1057 1062                  if (connection->conn_msginfo.mi_handler->mh_sizeof_request >
1058 1063                      0) {
1059 1064                          xdr_func =
1060 1065                              connection->conn_msginfo.mi_handler->mh_xdr_request;
1061 1066                          if (xdr_func == NULL) {
1062      -                                NDMP_LOG(LOG_DEBUG,
     1067 +                                syslog(LOG_ERR,
1063 1068                                      "Processing request 0x%x: no xdr function "
1064 1069                                      "in handler table",
1065 1070                                      connection->conn_msginfo.mi_hdr.message);
1066 1071                                  return (NDMP_NOT_SUPPORTED_ERR);
1067 1072                          }
1068 1073                          connection->conn_msginfo.mi_body = ndmp_malloc(
1069 1074                              connection->conn_msginfo.mi_handler->
1070 1075                              mh_sizeof_request);
1071 1076                          if (connection->conn_msginfo.mi_body == NULL)
1072 1077                                  return (NDMP_NO_MEM_ERR);
1073 1078  
1074 1079                          (void) memset(connection->conn_msginfo.mi_body, 0,
1075 1080                              connection->conn_msginfo.mi_handler->
1076 1081                              mh_sizeof_request);
1077 1082                  }
1078 1083          } else {
1079 1084                  if (connection->conn_msginfo.mi_handler->mh_sizeof_reply > 0) {
1080 1085                          xdr_func =
1081 1086                              connection->conn_msginfo.mi_handler->mh_xdr_reply;
1082 1087                          if (xdr_func == NULL) {
1083      -                                NDMP_LOG(LOG_DEBUG,
     1088 +                                syslog(LOG_ERR,
1084 1089                                      "Processing reply 0x%x: no xdr function "
1085 1090                                      "in handler table",
1086 1091                                      connection->conn_msginfo.mi_hdr.message);
1087 1092                                  return (NDMP_NOT_SUPPORTED_ERR);
1088 1093                          }
1089 1094                          connection->conn_msginfo.mi_body = ndmp_malloc(
1090 1095                              connection->conn_msginfo.mi_handler->
1091 1096                              mh_sizeof_reply);
1092 1097                          if (connection->conn_msginfo.mi_body == NULL)
1093 1098                                  return (NDMP_NO_MEM_ERR);
↓ open down ↓ 1 lines elided ↑ open up ↑
1095 1100                          (void) memset(connection->conn_msginfo.mi_body, 0,
1096 1101                              connection->conn_msginfo.mi_handler->
1097 1102                              mh_sizeof_reply);
1098 1103                  }
1099 1104          }
1100 1105  
1101 1106          /* Decode message arguments if needed */
1102 1107          if (xdr_func) {
1103 1108                  if (!(*xdr_func)(&connection->conn_xdrs,
1104 1109                      connection->conn_msginfo.mi_body)) {
1105      -                        NDMP_LOG(LOG_DEBUG,
1106      -                            "Processing message 0x%x: error decoding arguments",
     1110 +                        syslog(LOG_ERR,
     1111 +                            "Processing %s message 0x%x: "
     1112 +                            "error decoding arguments",
     1113 +                            connection->conn_msginfo.mi_hdr.message_type ==
     1114 +                            NDMP_MESSAGE_REQUEST ?
     1115 +                            "Request" : "Reply",
1107 1116                              connection->conn_msginfo.mi_hdr.message);
1108 1117                          free(connection->conn_msginfo.mi_body);
1109 1118                          connection->conn_msginfo.mi_body = 0;
1110 1119                          return (NDMP_XDR_DECODE_ERR);
1111 1120                  }
1112 1121          }
1113 1122          return (0);
1114 1123  }
1115 1124  
1116 1125  /*
↓ open down ↓ 44 lines elided ↑ open up ↑
1161 1170   *   from getting blocked by a bunch of requests.
1162 1171   */
1163 1172  static int
1164 1173  ndmp_process_messages(ndmp_connection_t *connection, boolean_t reply_expected)
1165 1174  {
1166 1175          msg_info_t reply_msginfo;
1167 1176          boolean_t reply_read = FALSE;
1168 1177          boolean_t reply_error = FALSE;
1169 1178          int err;
1170 1179  
1171      -        NDMP_LOG(LOG_DEBUG, "reply_expected: %s",
1172      -            reply_expected == TRUE ? "TRUE" : "FALSE");
1173      -
1174 1180          (void) memset((void *)&reply_msginfo, 0, sizeof (msg_info_t));
1175 1181  
1176 1182          do {
1177 1183                  (void) memset((void *)&connection->conn_msginfo, 0,
1178 1184                      sizeof (msg_info_t));
1179 1185  
1180 1186                  if ((err = ndmp_recv_msg(connection)) != NDMP_NO_ERR) {
1181 1187                          if (connection->conn_eof) {
1182      -                                NDMP_LOG(LOG_DEBUG, "detected eof");
1183 1188                                  return (NDMP_PROC_ERR);
1184 1189                          }
1185 1190                          if (err < 1) {
1186      -                                NDMP_LOG(LOG_DEBUG, "error decoding header");
     1191 +                                syslog(LOG_ERR, "error decoding header");
1187 1192  
1188 1193                                  /*
1189 1194                                   * Error occurred decoding the header.
1190 1195                                   * Don't send a reply since we don't know
1191 1196                                   * the message or if the message was even
1192 1197                                   * a request message.  To be safe, assume
1193 1198                                   * that the message was a reply if a reply
1194 1199                                   * was expected. Need to do this to prevent
1195 1200                                   * hanging ndmp_send_request() waiting for a
1196 1201                                   * reply.  Don't set reply_read so that the
1197 1202                                   * reply will be processed if it is received
1198 1203                                   * later.
1199 1204                                   */
1200 1205                                  if (reply_read == FALSE)
1201 1206                                          reply_error = TRUE;
1202 1207  
1203 1208                                  continue;
1204 1209                          }
1205 1210                          if (connection->conn_msginfo.mi_hdr.message_type
1206 1211                              != NDMP_MESSAGE_REQUEST) {
1207      -                                NDMP_LOG(LOG_DEBUG, "received reply: 0x%x",
     1212 +                                syslog(LOG_DEBUG, "received reply: 0x%x",
1208 1213                                      connection->conn_msginfo.mi_hdr.message);
1209 1214  
1210 1215                                  if (reply_expected == FALSE ||
1211 1216                                      reply_read == TRUE)
1212      -                                        NDMP_LOG(LOG_DEBUG,
     1217 +                                        syslog(LOG_DEBUG,
1213 1218                                              "Unexpected reply message: 0x%x",
1214 1219                                              connection->conn_msginfo.mi_hdr.
1215 1220                                              message);
1216 1221  
1217 1222                                  ndmp_free_message((ndmp_connection_t *)
1218 1223                                      connection);
1219 1224  
1220 1225                                  if (reply_read == FALSE) {
1221 1226                                          reply_read = TRUE;
1222 1227                                          reply_error = TRUE;
1223 1228                                  }
1224 1229                                  continue;
1225 1230                          }
1226      -                        NDMP_LOG(LOG_DEBUG, "received request: 0x%x",
1227      -                            connection->conn_msginfo.mi_hdr.message);
1228 1231  
1229 1232                          (void) ndmp_send_response((ndmp_connection_t *)
1230 1233                              connection, err, NULL);
1231 1234                          ndmp_free_message((ndmp_connection_t *)connection);
1232 1235                          continue;
1233 1236                  }
1234 1237                  if (connection->conn_msginfo.mi_hdr.message_type
1235 1238                      != NDMP_MESSAGE_REQUEST) {
1236      -                        NDMP_LOG(LOG_DEBUG, "received reply: 0x%x",
     1239 +                        syslog(LOG_DEBUG, "received reply: 0x%x",
1237 1240                              connection->conn_msginfo.mi_hdr.message);
1238 1241  
1239 1242                          if (reply_expected == FALSE || reply_read == TRUE) {
1240      -                                NDMP_LOG(LOG_DEBUG,
     1243 +                                syslog(LOG_DEBUG,
1241 1244                                      "Unexpected reply message: 0x%x",
1242 1245                                      connection->conn_msginfo.mi_hdr.message);
1243 1246                                  ndmp_free_message((ndmp_connection_t *)
1244 1247                                      connection);
1245 1248                                  continue;
1246 1249                          }
1247 1250                          reply_read = TRUE;
1248 1251                          reply_msginfo = connection->conn_msginfo;
1249 1252                          continue;
1250 1253                  }
1251      -                NDMP_LOG(LOG_DEBUG, "received request: 0x%x",
1252      -                    connection->conn_msginfo.mi_hdr.message);
1253      -
1254 1254                  /*
1255 1255                   * The following is needed to catch an improperly constructed
1256 1256                   * handler table or to deal with an NDMP client that is not
1257 1257                   * conforming to the negotiated protocol version.
1258 1258                   */
1259 1259                  if (connection->conn_msginfo.mi_handler->mh_func == NULL) {
1260      -                        NDMP_LOG(LOG_DEBUG, "No handler for message 0x%x",
     1260 +                        syslog(LOG_DEBUG, "No handler for message 0x%x",
1261 1261                              connection->conn_msginfo.mi_hdr.message);
1262 1262  
1263 1263                          (void) ndmp_send_response((ndmp_connection_t *)
1264 1264                              connection, NDMP_NOT_SUPPORTED_ERR, NULL);
1265 1265                          ndmp_free_message((ndmp_connection_t *)connection);
1266 1266                          continue;
1267 1267                  }
1268 1268                  /*
1269 1269                   * Call the handler function.
1270 1270                   * The handler will send any necessary reply.
1271 1271                   */
1272 1272                  (*connection->conn_msginfo.mi_handler->mh_func) (connection,
1273 1273                      connection->conn_msginfo.mi_body);
1274 1274  
1275 1275                  ndmp_free_message((ndmp_connection_t *)connection);
1276 1276  
1277 1277          } while (xdrrec_eof(&connection->conn_xdrs) == FALSE &&
1278 1278              connection->conn_eof == FALSE);
1279 1279  
1280      -        NDMP_LOG(LOG_DEBUG, "no more messages in stream buffer");
1281      -
1282 1280          if (connection->conn_eof == TRUE) {
1283 1281                  if (reply_msginfo.mi_body)
1284 1282                          free(reply_msginfo.mi_body);
1285 1283                  return (NDMP_PROC_ERR);
1286 1284          }
1287 1285          if (reply_error) {
1288 1286                  if (reply_msginfo.mi_body)
1289 1287                          free(reply_msginfo.mi_body);
1290 1288                  return (NDMP_PROC_REP_ERR);
1291 1289          }
↓ open down ↓ 216 lines elided ↑ open up ↑
1508 1506   * Generate AUE_ndmp_backup audit record
1509 1507   */
1510 1508  /*ARGSUSED*/
1511 1509  void
1512 1510  ndmpd_audit_backup(ndmp_connection_t *conn,
1513 1511      char *path, int dest, char *local_path, int result)
1514 1512  {
1515 1513          adt_event_data_t *event;
1516 1514  
1517 1515          if ((event = adt_alloc_event(conn->conn_ah, ADT_ndmp_backup)) == NULL) {
1518      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1516 +                syslog(LOG_ERR, "Audit failure: %m.");
1519 1517                  return;
1520 1518          }
1521 1519          event->adt_ndmp_backup.source = path;
1522 1520  
1523 1521          if (dest == NDMP_ADDR_LOCAL) {
1524 1522                  event->adt_ndmp_backup.local_dest = local_path;
1525 1523          } else {
1526 1524                  event->adt_ndmp_backup.remote_dest = conn->conn_sock;
1527 1525          }
1528 1526  
1529 1527          if (result == 0) {
1530 1528                  if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0)
1531      -                        NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1529 +                        syslog(LOG_ERR, "Audit failure: %m.");
1532 1530          } else {
1533 1531                  if (adt_put_event(event, ADT_FAILURE, result) != 0)
1534      -                        NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1532 +                        syslog(LOG_ERR, "Audit failure: %m.");
1535 1533          }
1536 1534  
1537 1535          adt_free_event(event);
1538 1536  }
1539 1537  
1540 1538  
1541 1539  /*
1542 1540   * ndmpd_audit_restore
1543 1541   *
1544 1542   * Generate AUE_ndmp_restore audit record
1545 1543   */
1546 1544  /*ARGSUSED*/
1547 1545  void
1548 1546  ndmpd_audit_restore(ndmp_connection_t *conn,
1549 1547      char *path, int dest, char *local_path, int result)
1550 1548  {
1551 1549          adt_event_data_t *event;
1552 1550  
1553 1551          if ((event = adt_alloc_event(conn->conn_ah,
1554 1552              ADT_ndmp_restore)) == NULL) {
1555      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1553 +                syslog(LOG_ERR, "Audit failure: %m.");
1556 1554                  return;
1557 1555          }
1558 1556          event->adt_ndmp_restore.destination = path;
1559 1557  
1560 1558          if (dest == NDMP_ADDR_LOCAL) {
1561 1559                  event->adt_ndmp_restore.local_source = local_path;
1562 1560          } else {
1563 1561                  event->adt_ndmp_restore.remote_source = conn->conn_sock;
1564 1562          }
1565 1563  
1566 1564          if (result == 0) {
1567 1565                  if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0)
1568      -                        NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1566 +                        syslog(LOG_ERR, "Audit failure: %m.");
1569 1567          } else {
1570 1568                  if (adt_put_event(event, ADT_FAILURE, result) != 0)
1571      -                        NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1569 +                        syslog(LOG_ERR, "Audit failure: %m.");
1572 1570          }
1573 1571  
1574 1572          adt_free_event(event);
1575 1573  }
1576 1574  
1577 1575  
1578 1576  /*
1579 1577   * ndmpd_audit_connect
1580 1578   *
1581 1579   * Generate AUE_ndmp_connect audit record
1582 1580   */
1583 1581  /*ARGSUSED*/
1584 1582  void
1585 1583  ndmpd_audit_connect(ndmp_connection_t *conn, int result)
1586 1584  {
1587 1585          adt_event_data_t *event;
1588 1586          adt_termid_t *termid;
1589 1587  
1590 1588          if (adt_load_termid(conn->conn_sock, &termid) != 0) {
1591      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1589 +                syslog(LOG_ERR, "Audit failure: %m.");
1592 1590                  return;
1593 1591          }
1594 1592  
1595 1593          if (adt_set_user(conn->conn_ah, ADT_NO_ATTRIB, ADT_NO_ATTRIB,
1596 1594              ADT_NO_ATTRIB, ADT_NO_ATTRIB, termid, ADT_NEW) != 0) {
1597      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1595 +                syslog(LOG_ERR, "Audit failure: %m.");
1598 1596                  free(termid);
1599 1597                  return;
1600 1598          }
1601 1599          free(termid);
1602 1600  
1603 1601          if ((event = adt_alloc_event(conn->conn_ah,
1604 1602              ADT_ndmp_connect)) == NULL) {
1605      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1603 +                syslog(LOG_ERR, "Audit failure: %m.");
1606 1604                  return;
1607 1605          }
1608 1606  
1609 1607          if (result == 0) {
1610 1608                  if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0)
1611      -                        NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1609 +                        syslog(LOG_ERR, "Audit failure: %m.");
1612 1610          } else {
1613 1611                  if (adt_put_event(event, ADT_FAILURE, result) != 0)
1614      -                        NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1612 +                        syslog(LOG_ERR, "Audit failure: %m.");
1615 1613          }
1616 1614  
1617 1615          adt_free_event(event);
1618 1616  }
1619 1617  
1620 1618  
1621 1619  /*
1622 1620   * ndmpd_audit_disconnect
1623 1621   *
1624 1622   * Generate AUE_ndmp_disconnect audit record
1625 1623   */
1626 1624  /*ARGSUSED*/
1627 1625  void
1628 1626  ndmpd_audit_disconnect(ndmp_connection_t *conn)
1629 1627  {
1630 1628          adt_event_data_t *event;
1631 1629  
1632 1630          if ((event = adt_alloc_event(conn->conn_ah,
1633 1631              ADT_ndmp_disconnect)) == NULL) {
1634      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1632 +                syslog(LOG_ERR, "Audit failure: %m.");
1635 1633                  return;
1636 1634          }
1637 1635          if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0)
1638      -                NDMP_LOG(LOG_ERR, "Audit failure: %m.");
     1636 +                syslog(LOG_ERR, "Audit failure: %m.");
1639 1637  
1640 1638          adt_free_event(event);
1641 1639  }
1642 1640  
1643 1641  void *
1644 1642  ndmp_malloc(size_t size)
1645 1643  {
1646 1644          void *data;
1647 1645  
1648 1646          if ((data = calloc(1, size)) == NULL) {
1649      -                NDMP_LOG(LOG_ERR, "Out of memory.");
     1647 +                syslog(LOG_ERR, "Out of memory.");
1650 1648          }
1651 1649  
1652 1650          return (data);
1653 1651  }
1654 1652  
1655 1653  /*
1656 1654   * get_backup_path_v3
1657 1655   *
1658 1656   * Get the backup path from the NDMP environment variables.
1659 1657   *
↓ open down ↓ 11 lines elided ↑ open up ↑
1671 1669  
1672 1670          bkpath = MOD_GETENV(params, "PREFIX");
1673 1671          if (!bkpath)
1674 1672                  bkpath = MOD_GETENV(params, "FILESYSTEM");
1675 1673  
1676 1674  
1677 1675          if (!bkpath) {
1678 1676                  MOD_LOGV3(params, NDMP_LOG_ERROR,
1679 1677                      "Backup path not defined.\n");
1680 1678          } else {
1681      -                NDMP_LOG(LOG_DEBUG, "bkpath: \"%s\"", bkpath);
     1679 +                syslog(LOG_DEBUG, "bkpath: \"%s\"", bkpath);
1682 1680          }
1683 1681  
1684 1682          return (bkpath);
1685 1683  }
1686 1684  
1687 1685  /*
1688 1686   * get_backup_path
1689 1687   *
1690 1688   * Find the backup path from the environment variables (v2)
1691 1689   */
↓ open down ↓ 21 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX