umount.c revision 42d159821800ff240cc201c8fe07f575b9e8a62b
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * CDDL HEADER START
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * The contents of this file are subject to the terms of the
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Common Development and Distribution License (the "License").
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * You may not use this file except in compliance with the License.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * See the License for the specific language governing permissions
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * and limitations under the License.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * When distributing Covered Code, include this CDDL HEADER in each
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * If applicable, add the following below this CDDL HEADER, with the
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * fields enclosed by brackets "[]" replaced with your own identifying
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * information: Portions Copyright [yyyy] [name of copyright owner]
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * CDDL HEADER END
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Use is subject to license terms.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * smbfs umount
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void usage();
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int smbfs_unmount(char *, int);
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic char *myname;
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross * Normal users are allowed to umount smbfs mounts they own.
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross * To allow that, this program is installed setuid root, and
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross * it adds SYS_MOUNT privilege here (if needed), and then
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross * restores the user's normal privileges.
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross if (__init_suid_priv(0, PRIV_SYS_MOUNT, (char *)NULL) < 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Set options
4bff34e37def8a90f9194d81bc345c52ba20086athurlow switch (c) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow umnt_flag |= MS_FORCE; /* forced unmount is desired */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow gettext("Usage: smbfs umount [-o opts] {//server/share | dir}\n"));
42d159821800ff240cc201c8fe07f575b9e8a62bGordon Ross /* Need sys_mount privilege for the umount call. */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow pr_err(gettext("%s: %s\n"), pathname, strerror(errno));
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Find the mnttab entry that corresponds to "name".
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * We're not sure what the name represents: either
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * a mountpoint name, or a special name (server:/path).
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Return the last entry in the file that matches.
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic struct extmnttab *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow while (getextmntent(fp, &mnt, sizeof (struct extmnttab)) == 0) {