View | Details | Raw Unified | Return to bug 116980
Collapse All | Expand All

(-)sbin/mount_msdosfs/mount_msdosfs.c (-17 / +30 lines)
Lines 69-75 Link Here
69
	struct iovec *iov = NULL;
69
	struct iovec *iov = NULL;
70
	int iovlen = 0;
70
	int iovlen = 0;
71
	struct stat sb;
71
	struct stat sb;
72
	int c, mntflags, set_gid, set_uid, set_mask, set_dirmask;
72
	int c, mntflags, set_gid, set_uid, set_mask, set_dirmask, update = 0;
73
	char *dev, *dir, mntpath[MAXPATHLEN], *csp;
73
	char *dev, *dir, mntpath[MAXPATHLEN], *csp;
74
	char fstype[] = "msdosfs";
74
	char fstype[] = "msdosfs";
75
	char *cs_dos = NULL;
75
	char *cs_dos = NULL;
Lines 133-138 Link Here
133
				*p = '\0';
133
				*p = '\0';
134
				val = p + 1;
134
				val = p + 1;
135
			}
135
			}
136
			update = update || !strcmp(optarg, "update");
136
			build_iovec(&iov, &iovlen, optarg, val, -1);
137
			build_iovec(&iov, &iovlen, optarg, val, -1);
137
			}
138
			}
138
			break;
139
			break;
Lines 165-177 Link Here
165
	if (optind + 2 != argc)
166
	if (optind + 2 != argc)
166
		usage();
167
		usage();
167
168
168
	if (set_mask && !set_dirmask) {
169
	if (!update) {
169
		dirmask = mask;
170
		if (set_mask && !set_dirmask) {
170
		set_dirmask = 1;
171
			dirmask = mask;
171
	}
172
			set_dirmask = 1;
172
	else if (set_dirmask && !set_mask) {
173
		}
173
		mask = dirmask;
174
		else if (set_dirmask && !set_mask) {
174
		set_mask = 1;
175
			mask = dirmask;
176
			set_mask = 1;
177
		}
175
	}
178
	}
176
179
177
	dev = argv[optind];
180
	dev = argv[optind];
Lines 195-220 Link Here
195
	(void)checkpath(dir, mntpath);
198
	(void)checkpath(dir, mntpath);
196
	(void)rmslashes(dev, dev);
199
	(void)rmslashes(dev, dev);
197
200
198
	if (!set_gid || !set_uid || !set_mask) {
201
	if (!update && (!set_gid || !set_uid || !set_mask)) {
199
		if (stat(mntpath, &sb) == -1)
202
		if (stat(mntpath, &sb) == -1)
200
			err(EX_OSERR, "stat %s", mntpath);
203
			err(EX_OSERR, "stat %s", mntpath);
201
204
		if (!set_uid) {
202
		if (!set_uid)
203
			uid = sb.st_uid;
205
			uid = sb.st_uid;
204
		if (!set_gid)
206
			set_uid = 1;
207
		}
208
		if (!set_gid) {
205
			gid = sb.st_gid;
209
			gid = sb.st_gid;
206
		if (!set_mask)
210
			set_gid = 1;
211
		}
212
		if (!set_mask) {
207
			mask = dirmask =
213
			mask = dirmask =
208
				sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
214
				sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
215
			set_mask = set_dirmask = 1;
216
		}
209
	}
217
	}
210
218
211
	build_iovec(&iov, &iovlen, "fstype", fstype, -1);
219
	build_iovec(&iov, &iovlen, "fstype", fstype, -1);
212
	build_iovec(&iov, &iovlen, "fspath", mntpath, -1);
220
	build_iovec(&iov, &iovlen, "fspath", mntpath, -1);
213
	build_iovec(&iov, &iovlen, "from", dev, -1);
221
	build_iovec(&iov, &iovlen, "from", dev, -1);
214
	build_iovec_argf(&iov, &iovlen, "uid", "%d", uid);
222
	
215
	build_iovec_argf(&iov, &iovlen, "gid", "%u", gid);
223
	if (set_uid)
216
	build_iovec_argf(&iov, &iovlen, "mask", "%u", mask);
224
		build_iovec_argf(&iov, &iovlen, "uid", "%d", uid);
217
	build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask);
225
	if (set_gid)
226
		build_iovec_argf(&iov, &iovlen, "gid", "%u", gid);
227
	if (set_mask)
228
		build_iovec_argf(&iov, &iovlen, "mask", "%u", mask);
229
	if (set_dirmask)
230
		build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask);
218
231
219
	if (nmount(iov, iovlen, mntflags) < 0)
232
	if (nmount(iov, iovlen, mntflags) < 0)
220
		err(1, "%s", dev);
233
		err(1, "%s", dev);

Return to bug 116980