mount_smbfs.c (87866) | mount_smbfs.c (88282) |
---|---|
1/* 2 * Copyright (c) 2000-2001, Boris Popov 3 * 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 2000-2001, Boris Popov 3 * 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $Id: mount_smbfs.c,v 1.13 2001/04/16 12:46:46 bp Exp $ | 32 * $Id: mount_smbfs.c,v 1.15 2001/12/20 15:03:41 bp Exp $ |
33 */ 34#include <sys/param.h> 35#include <sys/stat.h> 36#include <sys/errno.h> 37#include <sys/mount.h> 38 39#include <stdio.h> 40#include <string.h> --- 25 unchanged lines hidden (view full) --- 66 67 68int 69main(int argc, char *argv[]) 70{ 71 struct smb_ctx sctx, *ctx = &sctx; 72 struct smbfs_args mdata; 73 struct stat st; | 33 */ 34#include <sys/param.h> 35#include <sys/stat.h> 36#include <sys/errno.h> 37#include <sys/mount.h> 38 39#include <stdio.h> 40#include <string.h> --- 25 unchanged lines hidden (view full) --- 66 67 68int 69main(int argc, char *argv[]) 70{ 71 struct smb_ctx sctx, *ctx = &sctx; 72 struct smbfs_args mdata; 73 struct stat st; |
74#ifdef APPLE 75 extern void dropsuid(); 76 extern int loadsmbvfs(); 77#else |
|
74 struct vfsconf vfc; | 78 struct vfsconf vfc; |
79#endif /* APPLE */ |
|
75 char *next; 76 int opt, error, mntflags, caseopt; 77 | 80 char *next; 81 int opt, error, mntflags, caseopt; 82 |
83 84#ifdef APPLE 85 dropsuid(); 86#endif /* APPLE */ |
|
78 if (argc == 2) { 79 if (strcmp(argv[1], "-h") == 0) { 80 usage(); 81 } else if (strcmp(argv[1], "-v") == 0) { 82 errx(EX_OK, "version %d.%d.%d", SMBFS_VERSION / 100000, 83 (SMBFS_VERSION % 10000) / 1000, 84 (SMBFS_VERSION % 1000) / 100); 85 } 86 } 87 if (argc < 3) 88 usage(); 89 | 87 if (argc == 2) { 88 if (strcmp(argv[1], "-h") == 0) { 89 usage(); 90 } else if (strcmp(argv[1], "-v") == 0) { 91 errx(EX_OK, "version %d.%d.%d", SMBFS_VERSION / 100000, 92 (SMBFS_VERSION % 10000) / 1000, 93 (SMBFS_VERSION % 1000) / 100); 94 } 95 } 96 if (argc < 3) 97 usage(); 98 |
99#ifdef APPLE 100 error = loadsmbvfs(); 101#else |
|
90 error = getvfsbyname(SMBFS_VFSNAME, &vfc); 91 if (error && vfsisloadable(SMBFS_VFSNAME)) { 92 if(vfsload(SMBFS_VFSNAME)) 93 err(EX_OSERR, "vfsload("SMBFS_VFSNAME")"); 94 endvfsent(); 95 error = getvfsbyname(SMBFS_VFSNAME, &vfc); 96 } | 102 error = getvfsbyname(SMBFS_VFSNAME, &vfc); 103 if (error && vfsisloadable(SMBFS_VFSNAME)) { 104 if(vfsload(SMBFS_VFSNAME)) 105 err(EX_OSERR, "vfsload("SMBFS_VFSNAME")"); 106 endvfsent(); 107 error = getvfsbyname(SMBFS_VFSNAME, &vfc); 108 } |
109#endif /* APPLE */ |
|
97 if (error) 98 errx(EX_OSERR, "SMB filesystem is not available"); 99 100 if (smb_lib_init() != 0) 101 exit(1); 102 103 mntflags = error = 0; 104 bzero(&mdata, sizeof(mdata)); --- 94 unchanged lines hidden (view full) --- 199 if (!S_ISDIR(st.st_mode)) { 200 errno = ENOTDIR; 201 err(EX_OSERR, "can't mount on %s", mount_point); 202 } 203/* 204 if (smb_getextattr(mount_point, &einfo) == 0) 205 errx(EX_OSERR, "can't mount on %s twice", mount_point); 206*/ | 110 if (error) 111 errx(EX_OSERR, "SMB filesystem is not available"); 112 113 if (smb_lib_init() != 0) 114 exit(1); 115 116 mntflags = error = 0; 117 bzero(&mdata, sizeof(mdata)); --- 94 unchanged lines hidden (view full) --- 212 if (!S_ISDIR(st.st_mode)) { 213 errno = ENOTDIR; 214 err(EX_OSERR, "can't mount on %s", mount_point); 215 } 216/* 217 if (smb_getextattr(mount_point, &einfo) == 0) 218 errx(EX_OSERR, "can't mount on %s twice", mount_point); 219*/ |
207 if (mdata.uid == -1) | 220 if (mdata.uid == (uid_t)-1) |
208 mdata.uid = st.st_uid; | 221 mdata.uid = st.st_uid; |
209 if (mdata.gid == -1) | 222 if (mdata.gid == (gid_t)-1) |
210 mdata.gid = st.st_gid; 211 if (mdata.file_mode == 0 ) 212 mdata.file_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); 213 if (mdata.dir_mode == 0) { 214 mdata.dir_mode = mdata.file_mode; 215 if (mdata.dir_mode & S_IRUSR) 216 mdata.dir_mode |= S_IXUSR; 217 if (mdata.dir_mode & S_IRGRP) --- 48 unchanged lines hidden --- | 223 mdata.gid = st.st_gid; 224 if (mdata.file_mode == 0 ) 225 mdata.file_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); 226 if (mdata.dir_mode == 0) { 227 mdata.dir_mode = mdata.file_mode; 228 if (mdata.dir_mode & S_IRUSR) 229 mdata.dir_mode |= S_IXUSR; 230 if (mdata.dir_mode & S_IRGRP) --- 48 unchanged lines hidden --- |