mount.c (92882) | mount.c (95289) |
---|---|
1/*- 2 * Copyright (c) 1980, 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; 43#endif 44static const char rcsid[] = | 1/*- 2 * Copyright (c) 1980, 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/sbin/mount/mount.c 92882 2002-03-21 13:14:21Z imp $"; | 45 "$FreeBSD: head/sbin/mount/mount.c 95289 2002-04-22 23:03:03Z mux $"; |
46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/mount.h> 50#include <sys/stat.h> 51#include <sys/wait.h> 52 | 46#endif /* not lint */ 47 48#include <sys/param.h> 49#include <sys/mount.h> 50#include <sys/stat.h> 51#include <sys/wait.h> 52 |
53#include <ctype.h> |
|
53#include <err.h> 54#include <errno.h> 55#include <fstab.h> 56#include <pwd.h> 57#include <signal.h> 58#include <stdio.h> 59#include <stdlib.h> 60#include <string.h> --- 65 unchanged lines hidden (view full) --- 126 char * const argv[]; 127{ 128 const char *mntfromname, **vfslist, *vfstype; 129 struct fstab *fs; 130 struct statfs *mntbuf; 131 FILE *mountdfp; 132 pid_t pid; 133 int all, ch, i, init_flags, mntsize, rval, have_fstab; | 54#include <err.h> 55#include <errno.h> 56#include <fstab.h> 57#include <pwd.h> 58#include <signal.h> 59#include <stdio.h> 60#include <stdlib.h> 61#include <string.h> --- 65 unchanged lines hidden (view full) --- 127 char * const argv[]; 128{ 129 const char *mntfromname, **vfslist, *vfstype; 130 struct fstab *fs; 131 struct statfs *mntbuf; 132 FILE *mountdfp; 133 pid_t pid; 134 int all, ch, i, init_flags, mntsize, rval, have_fstab; |
134 char *options; | 135 char *cp, *ep, *options; |
135 136 all = init_flags = 0; 137 options = NULL; 138 vfslist = NULL; 139 vfstype = "ufs"; 140 while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1) 141 switch (ch) { 142 case 'a': --- 130 unchanged lines hidden (view full) --- 273 errx(1, "%s has unknown file system type", 274 *argv); 275 rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, 276 init_flags, options, fs->fs_mntops); 277 break; 278 case 2: 279 /* 280 * If -t flag has not been specified, the path cannot be | 136 137 all = init_flags = 0; 138 options = NULL; 139 vfslist = NULL; 140 vfstype = "ufs"; 141 while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1) 142 switch (ch) { 143 case 'a': --- 130 unchanged lines hidden (view full) --- 274 errx(1, "%s has unknown file system type", 275 *argv); 276 rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, 277 init_flags, options, fs->fs_mntops); 278 break; 279 case 2: 280 /* 281 * If -t flag has not been specified, the path cannot be |
281 * found, spec contains either a ':' or a '@', and the 282 * spec is not a file with those characters, then assume | 282 * found, spec contains either a ':' or a '@', then assume |
283 * that an NFS filesystem is being specified ala Sun. | 283 * that an NFS filesystem is being specified ala Sun. |
284 * Check if the hostname contains only allowed characters 285 * to reduce false positives. IPv6 addresses containing 286 * ':' will be correctly parsed only if the separator is '@'. 287 * The definition of a valid hostname is taken from RFC 1034. |
|
284 */ | 288 */ |
285 if (vfslist == NULL && strpbrk(argv[0], ":@") != NULL && 286 access(argv[0], 0) == -1) 287 vfstype = "nfs"; | 289 if (vfslist == NULL && ((ep = strchr(argv[0], '@')) != NULL) || 290 ((ep = strchr(argv[0], ':')) != NULL)) { 291 cp = argv[0]; 292 while (cp != ep) { 293 if (!isdigit(*cp) && !isalpha(*cp) && 294 *cp != '.' && *cp != '-' && *cp != ':') 295 break; 296 cp++; 297 } 298 if (cp == ep) 299 vfstype = "nfs"; 300 } |
288 rval = mountfs(vfstype, 289 argv[0], argv[1], init_flags, options, NULL); 290 break; 291 default: 292 usage(); 293 /* NOTREACHED */ 294 } 295 --- 455 unchanged lines hidden --- | 301 rval = mountfs(vfstype, 302 argv[0], argv[1], init_flags, options, NULL); 303 break; 304 default: 305 usage(); 306 /* NOTREACHED */ 307 } 308 --- 455 unchanged lines hidden --- |