Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Aug 2009 16:02:59 -0800
From:      Mel Flynn <mel.flynn+fbsd.current@mailing.thruhere.net>
To:        freebsd-current@freebsd.org
Cc:        Chris Ruiz <yr.retarded@gmail.com>, Ed Schouten <ed@80386.nl>
Subject:   Fixing install (Was: Re: [Fwd: How To Recover From Missing /lib/libc.so.7?])
Message-ID:  <200908071602.59676.mel.flynn%2Bfbsd.current@mailing.thruhere.net>
In-Reply-To: <20090807191454.GP1292@hoeg.nl>
References:  <4A7C7220.2090309@mykitchentable.net> <20090807190350.GO1292@hoeg.nl> <20090807191454.GP1292@hoeg.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_zCMfKTGzASiM7qP
Content-Type: text/plain;
  charset="iso-8859-6"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Friday 07 August 2009 11:14:54 Ed Schouten wrote:
> * Ed Schouten <ed@80386.nl> wrote:
> > * Chris Ruiz <yr.retarded@gmail.com> wrote:
> > > You must specify NO_FSCHG= when you installworld on an unupgraded ZFS
> > > filesystem, otherwise you will lose libc.so.7!  I'll spare you the
> > > details on why this happens.
> >
> > Which is because our install(1) is stupid enough to delete the resulting
> > binary if it can't add the schg flag. We should really change this
> > behaviour.
>
> It looks like there are actually two bugs:
>
> - install(1) does check for EOPNOTSUPP, while ZFS seems to return
>   EINVAL. This is probably a ZFS bug.
> - Inside jails, (un)setting schg is not permitted and returns EPERM. We
>   should change the VFS to return EOPNOTSUPP or install(1) to allow
>   EPERM as well.
>
> It's a bit late, but I think it would be nice to have this fixed before
> 8.0.

Perhaps the second case only if jailed? EPERM is also given when the running 
user doesn't have permission and I'd rather have things bail out sooner then 
later. Patch attached for this.
-- 
Mel

--Boundary-00=_zCMfKTGzASiM7qP
Content-Type: text/plain;
  charset="ISO-8859-1";
  name="xinstall.patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="xinstall.patch.txt"

Index: usr.bin/xinstall/xinstall.c
===================================================================
--- usr.bin/xinstall/xinstall.c	(revision 196085)
+++ usr.bin/xinstall/xinstall.c	(working copy)
@@ -47,6 +47,8 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
 #include <sys/mman.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
@@ -83,6 +85,7 @@
 gid_t gid;
 uid_t uid;
 int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose;
+int is_jailed;
 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 const char *suffix = BACKUP_SUFFIX;
 
@@ -106,9 +109,11 @@
 	int ch, no_target;
 	u_int iflags;
 	char *flags;
+	size_t len = sizeof(int);
 	const char *group, *owner, *to_name;
 
 	iflags = 0;
+	is_jailed = 0;
 	group = owner = NULL;
 	while ((ch = getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) != -1)
 		switch((char)ch) {
@@ -242,6 +247,11 @@
 			errx(EX_USAGE, 
 			    "%s and %s are the same file", *argv, to_name);
 	}
+	if( sysctlbyname("security.jail.jailed", (void *)&is_jailed,
+				&len, NULL, 0) == -1 ) {
+		warn("Unable to get security.jail.jailed, assuming unjailed");
+		is_jailed = 0;
+	}
 	install(*argv, to_name, fset, iflags);
 	exit(EX_OK);
 	/* NOTREACHED */
@@ -506,6 +516,8 @@
 		if (flags & SETFLAGS) {
 			if (errno == EOPNOTSUPP)
 				warn("%s: chflags", to_name);
+			else if( errno == EPERM && is_jailed )
+				warn("%s: chflags", to_name);
 			else {
 				serrno = errno;
 				(void)unlink(to_name);

--Boundary-00=_zCMfKTGzASiM7qP--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908071602.59676.mel.flynn%2Bfbsd.current>