Deleted Added
full compact
automountd.c (270276) automountd.c (270406)
1/*-
2 * Copyright (c) 2014 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2014 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/usr.sbin/autofs/automountd.c 270276 2014-08-21 15:07:25Z trasz $");
32__FBSDID("$FreeBSD: head/usr.sbin/autofs/automountd.c 270406 2014-08-23 12:00:45Z trasz $");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/ioctl.h>
37#include <sys/param.h>
38#include <sys/linker.h>
39#include <sys/mount.h>
40#include <sys/socket.h>

--- 136 unchanged lines hidden (view full) ---

177
178static void
179handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
180 bool incomplete_hierarchy)
181{
182 const char *map;
183 struct node *root, *parent, *node;
184 FILE *f;
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/ioctl.h>
37#include <sys/param.h>
38#include <sys/linker.h>
39#include <sys/mount.h>
40#include <sys/socket.h>

--- 136 unchanged lines hidden (view full) ---

177
178static void
179handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
180 bool incomplete_hierarchy)
181{
182 const char *map;
183 struct node *root, *parent, *node;
184 FILE *f;
185 char *options, *fstype, *retrycnt, *tmp;
185 char *options, *fstype, *nobrowse, *retrycnt, *tmp;
186 int error;
187
188 log_debugx("got request %d: from %s, path %s, prefix \"%s\", "
189 "key \"%s\", options \"%s\"", adr->adr_id, adr->adr_from,
190 adr->adr_path, adr->adr_prefix, adr->adr_key, adr->adr_options);
191
192 /*
193 * Try to notify the kernel about any problems.

--- 23 unchanged lines hidden (view full) ---

217 log_errx(1, "map %s does not contain key for \"%s\"; "
218 "failing mount", map, adr->adr_path);
219 }
220
221 if (node->n_location == NULL) {
222 log_debugx("found node defined at %s:%d; not a mountpoint",
223 node->n_config_file, node->n_config_line);
224
186 int error;
187
188 log_debugx("got request %d: from %s, path %s, prefix \"%s\", "
189 "key \"%s\", options \"%s\"", adr->adr_id, adr->adr_from,
190 adr->adr_path, adr->adr_prefix, adr->adr_key, adr->adr_options);
191
192 /*
193 * Try to notify the kernel about any problems.

--- 23 unchanged lines hidden (view full) ---

217 log_errx(1, "map %s does not contain key for \"%s\"; "
218 "failing mount", map, adr->adr_path);
219 }
220
221 if (node->n_location == NULL) {
222 log_debugx("found node defined at %s:%d; not a mountpoint",
223 node->n_config_file, node->n_config_line);
224
225 options = node_options(node);
226
225 /*
227 /*
228 * Prepend options passed via automountd(8) command line.
229 */
230 if (cmdline_options != NULL) {
231 options =
232 separated_concat(cmdline_options, options, ',');
233 }
234
235 nobrowse = pick_option("nobrowse", &options);
236 if (nobrowse != NULL && adr->adr_key[0] == '\0') {
237 log_debugx("skipping map %s due to \"nobrowse\" "
238 "option; exiting", map);
239 done(0);
240
241 /*
242 * Exit without calling exit_callback().
243 */
244 quick_exit(0);
245 }
246
247 /*
226 * Not a mountpoint; create directories in the autofs mount
227 * and complete the request.
228 */
229 create_subtree(node, incomplete_hierarchy);
230
231 if (incomplete_hierarchy && adr->adr_key[0] != '\0') {
232 /*
233 * We still need to create the single subdirectory
234 * user is trying to access.
235 */
236 tmp = separated_concat(adr->adr_path,
237 adr->adr_key, '/');
238 node = node_find(root, tmp);
239 if (node != NULL)
240 create_subtree(node, false);
241 }
248 * Not a mountpoint; create directories in the autofs mount
249 * and complete the request.
250 */
251 create_subtree(node, incomplete_hierarchy);
252
253 if (incomplete_hierarchy && adr->adr_key[0] != '\0') {
254 /*
255 * We still need to create the single subdirectory
256 * user is trying to access.
257 */
258 tmp = separated_concat(adr->adr_path,
259 adr->adr_key, '/');
260 node = node_find(root, tmp);
261 if (node != NULL)
262 create_subtree(node, false);
263 }
242 done(0);
243
244 log_debugx("nothing to mount; exiting");
264
265 log_debugx("nothing to mount; exiting");
266 done(0);
245
246 /*
247 * Exit without calling exit_callback().
248 */
249 quick_exit(0);
250 }
251
252 log_debugx("found node defined at %s:%d; it is a mountpoint",

--- 16 unchanged lines hidden (view full) ---

269 options = separated_concat(cmdline_options, options, ',');
270
271 /*
272 * Append "automounted".
273 */
274 options = separated_concat(options, "automounted", ',');
275
276 /*
267
268 /*
269 * Exit without calling exit_callback().
270 */
271 quick_exit(0);
272 }
273
274 log_debugx("found node defined at %s:%d; it is a mountpoint",

--- 16 unchanged lines hidden (view full) ---

291 options = separated_concat(cmdline_options, options, ',');
292
293 /*
294 * Append "automounted".
295 */
296 options = separated_concat(options, "automounted", ',');
297
298 /*
299 * Remove "nobrowse", mount(8) doesn't understand it.
300 */
301 pick_option("nobrowse", &options);
302
303 /*
277 * Figure out fstype.
278 */
279 fstype = pick_option("fstype=", &options);
280 if (fstype == NULL) {
281 log_debugx("fstype not specified in options; "
282 "defaulting to \"nfs\"");
283 fstype = checked_strdup("nfs");
284 }

--- 19 unchanged lines hidden (view full) ---

304
305 f = auto_popen("mount", "-t", fstype, "-o", options,
306 node->n_location, adr->adr_path, NULL);
307 assert(f != NULL);
308 error = auto_pclose(f);
309 if (error != 0)
310 log_errx(1, "mount failed");
311
304 * Figure out fstype.
305 */
306 fstype = pick_option("fstype=", &options);
307 if (fstype == NULL) {
308 log_debugx("fstype not specified in options; "
309 "defaulting to \"nfs\"");
310 fstype = checked_strdup("nfs");
311 }

--- 19 unchanged lines hidden (view full) ---

331
332 f = auto_popen("mount", "-t", fstype, "-o", options,
333 node->n_location, adr->adr_path, NULL);
334 assert(f != NULL);
335 error = auto_pclose(f);
336 if (error != 0)
337 log_errx(1, "mount failed");
338
312 done(0);
313 log_debugx("mount done; exiting");
339 log_debugx("mount done; exiting");
340 done(0);
314
315 /*
316 * Exit without calling exit_callback().
317 */
318 quick_exit(0);
319}
320
321static int

--- 179 unchanged lines hidden ---
341
342 /*
343 * Exit without calling exit_callback().
344 */
345 quick_exit(0);
346}
347
348static int

--- 179 unchanged lines hidden ---