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-2911 NDMP logging should use syslog and is too chatty
NEX-1123 NDMP commands can not uniquely identify Nexenta and the file server version (currently 4.0.1) and Sun Microsystems.
NEX-894 Default location of NDMP log file should be under /var/log
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c
+++ new/usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c
1 1 /*
2 2 * Copyright (c) 2008, 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:
14 14 * - Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions and the following disclaimer.
16 16 *
17 17 * - Redistributions in binary form must reproduce the above copyright
18 18 * notice, this list of conditions and the following disclaimer in
19 19 * the documentation and/or other materials provided with the
20 20 * distribution.
21 21 *
22 22 * - Neither the name of The Storage Networking Industry Association (SNIA)
23 23 * nor the names of its contributors may be used to endorse or promote
24 24 * products derived from this software without specific prior written
25 25 * permission.
26 26 *
27 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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
40 40 /*
41 41 * NDMP configuration management
42 42 */
43 43 #include <stdio.h>
44 44 #include <stdlib.h>
45 45 #include <synch.h>
46 46 #include <syslog.h>
47 47 #include <strings.h>
48 48 #include <ndmpd_prop.h>
49 49 #include <libndmp.h>
50 50 #include "ndmpd.h"
51 51
52 52 typedef struct ndmpd_cfg_param {
53 53 char *sc_name;
54 54 char *sc_defval;
55 55 char *sc_value;
56 56 uint32_t sc_flags;
57 57 } ndmpd_cfg_param_t;
58 58
59 59
60 60 static int ndmpd_config_update(ndmpd_cfg_param_t *cfg, char *value);
61 61
62 62 /*
63 63 * IMPORTANT: any changes to the order of this table's entries
64 64 * need to be reflected in the enum ndmpd_cfg_id_t.
65 65 */
66 66 ndmpd_cfg_param_t ndmpd_cfg_table[] =
67 67 {
68 68 {"dar-support", "", 0, NDMP_CF_NOTINIT},
69 69 {"mover-nic", "", 0, NDMP_CF_NOTINIT},
70 70 {"dump-pathnode", "", 0, NDMP_CF_NOTINIT},
71 71 {"tar-pathnode", "", 0, NDMP_CF_NOTINIT},
72 72 {"fh-inode", "", 0, NDMP_CF_NOTINIT},
73 73 {"ignore-ctime", "", 0, NDMP_CF_NOTINIT},
74 74 {"include-lmtime", "", 0, NDMP_CF_NOTINIT},
75 75 {"token-maxseq", "", 0, NDMP_CF_NOTINIT},
76 76 {"version", "", 0, NDMP_CF_NOTINIT},
77 77 {"restore-fullpath", "", 0, NDMP_CF_NOTINIT},
78 78 {"debug-path", "", 0, NDMP_CF_NOTINIT},
79 79 {"plugin-path", "", 0, NDMP_CF_NOTINIT},
80 80 {"socket-css", "", 0, NDMP_CF_NOTINIT},
81 81 {"socket-crs", "", 0, NDMP_CF_NOTINIT},
82 82 {"mover-recordsize", "", 0, NDMP_CF_NOTINIT},
83 83 {"restore-wildcard-enable", "", 0, NDMP_CF_NOTINIT},
84 84 {"cram-md5-username", "", 0, NDMP_CF_NOTINIT},
|
↓ open down ↓ |
71 lines elided |
↑ open up ↑ |
85 85 {"cram-md5-password", "", 0, NDMP_CF_NOTINIT},
86 86 {"cleartext-username", "", 0, NDMP_CF_NOTINIT},
87 87 {"cleartext-password", "", 0, NDMP_CF_NOTINIT},
88 88 {"tcp-port", "", 0, NDMP_CF_NOTINIT},
89 89 {"backup-quarantine", "", 0, NDMP_CF_NOTINIT},
90 90 {"restore-quarantine", "", 0, NDMP_CF_NOTINIT},
91 91 {"overwrite-quarantine", "", 0, NDMP_CF_NOTINIT},
92 92 {"zfs-force-override", "", 0, NDMP_CF_NOTINIT},
93 93 {"drive-type", "", 0, NDMP_CF_NOTINIT},
94 94 {"debug-mode", "", 0, NDMP_CF_NOTINIT},
95 + {"vendor-name", "", 0, NDMP_CF_NOTINIT},
96 + {"product-name", "", 0, NDMP_CF_NOTINIT},
97 + {"autosync-support", "", 0, NDMP_CF_NOTINIT},
98 + {"hpr-support", "", 0, NDMP_CF_NOTINIT},
95 99 };
96 100
97 101 /*
98 102 * Loads all the NDMP configuration parameters and sets up the
99 103 * config table.
100 104 */
101 105 int
102 106 ndmpd_load_prop(void)
103 107 {
104 108 ndmpd_cfg_id_t id;
105 109 ndmpd_cfg_param_t *cfg;
106 110 char *value;
107 111
108 112 for (id = 0; id < NDMP_MAXALL; id++) {
109 113 cfg = &ndmpd_cfg_table[id];
110 114 if ((ndmp_get_prop(cfg->sc_name, &value)) == -1) {
111 - syslog(LOG_DEBUG, "%s %s",
115 + syslog(LOG_ERR, "%s %s",
112 116 cfg->sc_name, ndmp_strerror(ndmp_errno));
113 117 continue;
114 118 }
115 119 /*
116 120 * enval == 0 could mean two things, either the
117 121 * config param is not defined, or it has been
118 122 * removed. If the variable has already been defined
119 123 * and now enval is 0, it should be removed, otherwise
120 124 * we don't need to do anything in this case.
121 125 */
122 126 if ((cfg->sc_flags & NDMP_CF_DEFINED) || value) {
123 127 if (ndmpd_config_update(cfg, value)) {
124 128 free(value);
125 129 return (-1);
126 130 }
127 131 }
128 132 free(value);
129 133 }
130 134 return (0);
131 135 }
132 136
133 137 /*
134 138 * ndmpd_config_update
135 139 *
136 140 * Updates the specified config param with the given value.
137 141 * This function is called both on (re)load and set.
138 142 */
139 143 static int
140 144 ndmpd_config_update(ndmpd_cfg_param_t *cfg, char *value)
141 145 {
142 146 char *curval;
143 147 int rc = 0;
144 148 int len;
145 149
146 150 if (value) {
147 151 len = strlen(value);
148 152 if (cfg->sc_value) {
149 153 curval = realloc(cfg->sc_value, (len + 1));
150 154 } else {
151 155 curval = ndmp_malloc(len + 1);
152 156 }
153 157
154 158 if (curval) {
155 159 cfg->sc_value = curval;
156 160 (void) strcpy(cfg->sc_value, value);
157 161 cfg->sc_flags |= NDMP_CF_DEFINED;
158 162 } else {
159 163 syslog(LOG_ERR, "Out of memory.");
160 164 rc = -1;
161 165 }
162 166 } else if (cfg->sc_value) {
163 167 free(cfg->sc_value);
164 168 cfg->sc_value = 0;
165 169 cfg->sc_flags &= ~NDMP_CF_DEFINED;
166 170 }
167 171
168 172 return (rc);
169 173 }
170 174
171 175 /*
172 176 * Returns value of the specified config param.
173 177 * The return value is a string pointer to the locally
174 178 * allocated memory if the config param is defined
175 179 * otherwise it would be NULL.
176 180 */
177 181 char *
178 182 ndmpd_get_prop(ndmpd_cfg_id_t id)
179 183 {
180 184 char *env_val;
181 185
182 186 if (id < NDMP_MAXALL) {
183 187 env_val = ndmpd_cfg_table[id].sc_value;
184 188 return (env_val);
185 189 }
186 190
187 191 return (0);
188 192 }
189 193
190 194 /*
191 195 * Similar to ndmpd_get_prop except it will return dflt value
192 196 * if env is not set.
193 197 */
194 198 char *
195 199 ndmpd_get_prop_default(ndmpd_cfg_id_t id, char *dflt)
196 200 {
197 201 char *env;
198 202
199 203 env = ndmpd_get_prop(id);
200 204
201 205 if (env && *env != 0) {
202 206 return (env);
203 207 } else {
204 208 return (dflt);
205 209 }
206 210 }
207 211
208 212 /*
209 213 * Returns the value of a yes/no config param.
210 214 * Returns 1 is config is set to "yes", otherwise 0.
211 215 */
212 216 int
213 217 ndmpd_get_prop_yorn(ndmpd_cfg_id_t id)
214 218 {
215 219 char *val;
216 220
217 221 val = ndmpd_get_prop(id);
218 222 if (val) {
219 223 if (strcasecmp(val, "yes") == 0)
220 224 return (1);
221 225 }
222 226
223 227 return (0);
224 228 }
|
↓ open down ↓ |
103 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX