From: Jun Kuriyama <[EMAIL PROTECTED]>
        To: Kirk McKusick <[EMAIL PROTECTED]>
        Cc: [EMAIL PROTECTED]
        Subject: Re: dump -L and privilege
        In-Reply-To: <[EMAIL PROTECTED]>
        X-ASK-Info: Whitelist match

        Is this enough?

        -r-sr-x---  1 root  operator  5750 Jan 31 22:13 mksnap_ffs

        o Should use filesystem device name rather than mountpoint?
        o Should use the group of device rather than "operator"?


        -- 
        Jun Kuriyama <[EMAIL PROTECTED]> // IMG SRC, Inc.
                     <[EMAIL PROTECTED]> // FreeBSD Project

The mount command needs the mountpoint, not the device name, so
the device name would only be needed if we want to use the group
of the device rather than operator. I argue that we should use
operator rather than the group of the device because the purpose
of this command is to allow the dump program, run by people in 
the operator group, to take snapshots.

At any rate, I have cleaned up the program and provided a Makefile 
and manual page (see below). The only semantic change that I made
to your program was to do the `chown' before doing the `chmod' so
as not to open a brief hole that would allow members of the default
(wheel) group to get read access to the snapshot.

        Kirk McKusick

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       mksnap_ffs/Makefile
#       mksnap_ffs/mksnap_ffs.8
#       mksnap_ffs/mksnap_ffs.c
#
mkdir mksnap_ffs
echo x - mksnap_ffs/Makefile
sed 's/^X//' >mksnap_ffs/Makefile << 'END-of-mksnap_ffs/Makefile'
X# $FreeBSD$
X
XPROG=  mksnap_ffs
XMAN=   mksnap_ffs.8
X
X.if defined(NOSUID)
XBINMODE=550
X.else
XBINMODE=4550
XBINOWN=        root
X.endif
XBINGRP=        operator
X
X.include <bsd.prog.mk>
END-of-mksnap_ffs/Makefile
echo x - mksnap_ffs/mksnap_ffs.8
sed 's/^X//' >mksnap_ffs/mksnap_ffs.8 << 'END-of-mksnap_ffs/mksnap_ffs.8'
X.\"
X.\" Copyright (c) 2003 Networks Associates Technology, Inc.
X.\" All rights reserved.
X.\"
X.\" This software was developed for the FreeBSD Project by Marshall
X.\" Kirk McKusick and Network Associates Laboratories, the Security
X.\" Research Division of Network Associates, Inc. under DARPA/SPAWAR
X.\" contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
X.\" research program.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. The names of the authors may not be used to endorse or promote
X.\"    products derived from this software without specific prior written
X.\"    permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\" $FreeBSD$
X.\"
X.Dd January 19, 2003
X.Dt MKSNAP_FFS 8
X.Os
X.Sh NAME
X.Nm mksnap_ffs
X.Nd take a filesystem snapshot
X.Sh SYNOPSIS
X.Nm
X.Ar mountpoint
X.Ar snapshot_name
X.Sh DESCRIPTION
XThe
X.Nm
Xcommand creates a snapshot named
X.Ar snapshot_name
Xon the filesystem mounted at
X.Ar mountpoint .
XThe
X.Ar snapshot_name
Xargument must be contained within the filesystem mounted at
X.Ar mountpoint .
X.Pp
XThe group ownership of the file is set to
X.Dq operator ;
Xthe owner of the file remains
X.Dq root .
XThe mode of the snapshot is set to be readable by the owner
Xor members of the
X.Dq operator
Xgroup.
X.Sh SEE ALSO
X.Xr chmod 2 ,
X.Xr chown 8 ,
X.Xr mount_ffs 8
X.Sh HISTORY
XA
X.Nm
Xcommand first appeared in
X.Fx 5.0 .
END-of-mksnap_ffs/mksnap_ffs.8
echo x - mksnap_ffs/mksnap_ffs.c
sed 's/^X//' >mksnap_ffs/mksnap_ffs.c << 'END-of-mksnap_ffs/mksnap_ffs.c'
X/*
X * Copyright (c) 2003 Networks Associates Technology, Inc.
X * All rights reserved.
X *
X * This software was developed for the FreeBSD Project by Marshall
X * Kirk McKusick and Network Associates Laboratories, the Security
X * Research Division of Network Associates, Inc. under DARPA/SPAWAR
X * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
X * research program.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. The names of the authors may not be used to endorse or promote
X *    products derived from this software without specific prior written
X *    permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X * $FreeBSD$
X */
X
X#include <sys/param.h>
X#include <sys/mount.h>
X#include <sys/stat.h>
X#include <ufs/ufs/ufsmount.h>
X#include <err.h>
X#include <errno.h>
X#include <grp.h>
X#include <stdio.h>
X#include <stdlib.h>
X#include <string.h>
X#include <sysexits.h>
X#include <unistd.h>
X
Xvoid
Xusage()
X{
X
X       fprintf(stderr, "usage: mksnap_ffs mountpoint file\n");
X       exit(EX_USAGE);
X}
X
Xint
Xmain(int argc, char **argv)
X{
X       const char *dir;
X       struct ufs_args args;
X       struct group *grp;
X
X       if (argc != 3)
X               usage();
X
X       dir = argv[1];
X       args.fspec = argv[2];
X
X       if ((grp = getgrnam("operator")) == NULL)
X               errx(1, "Cannot retrieve operator gid");
X       if (mount("ffs", dir, MNT_UPDATE | MNT_SNAPSHOT, &args) < 0)
X               err(1, "Cannot create %s", args.fspec);
X       if (chown(args.fspec, -1, grp->gr_gid) != 0)
X               err(1, "Cannot chown %s", args.fspec);
X       if (chmod(args.fspec, S_IRUSR | S_IRGRP) != 0)
X               err(1, "Cannot chmod %s", args.fspec);
X
X       exit(EXIT_SUCCESS);
X}
END-of-mksnap_ffs/mksnap_ffs.c
exit


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to