Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Dec 2018 08:33:40 +0100
From:      Andre Albsmeier <Andre.Albsmeier@siemens.com>
To:        Eugene Grosbein <eugen@freebsd.org>
Cc:        Ian Lepore <ian@freebsd.org>, Andre Albsmeier <Andre.Albsmeier@siemens.com>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   Re: svn commit: r341794 - stable/11/etc/periodic/weekly
Message-ID:  <20181222073340.GA27107@bali>
In-Reply-To: <3a15a5aa-913a-88eb-a072-86526ef4899e@freebsd.org>
References:  <201812101424.wBAEOgbC053582@repo.freebsd.org> <20181215090926.GA33682@bali> <c00a7e0c-5258-26b2-efea-72af490d71a1@freebsd.org> <1544893102.76088.70.camel@freebsd.org> <3a15a5aa-913a-88eb-a072-86526ef4899e@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16-Dec-2018 at 06:47:04 +0700, Eugene Grosbein wrote:
> 15.12.2018 23:58, Ian Lepore wrote:
> 
> > It uses sysrc, which sources in /usr/share/bsdconfig/common.subr; this
> > is the first reference to sysrc in any periodic script, so it does
> > establish a new dependency, requiring sysrc to be installed on any
> > system that runs periodic scripts.
> 
> Thanks, I've re-implemented this without sysrc.
> 
> > A safer way to extract the root path of all running jails might be
> > something like:
> > 
> >   if which -s jls; then
> >       allpaths="$(jls -d path)"
> >       for onepath in ${allpaths}; do 
> >           # do whatever with ${onepath} here
> >       done
> >   fi
> 
> This needs to check for all configured full-blown jails including maybe not running at the moment.
> sysrc is handy but is not really necessary.
> 
> Andre, this should fix it for your case, please test:
> 
> fetch -o /tmp/noid.diff 'https://svnweb.freebsd.org/base/head/usr.sbin/periodic/etc/weekly/340.noid?view=patch&r1=342141&r2=342140&pathrev=342141'
> cd /etc/periodic/weekly && patch -p5 < /tmp/noid.diff

Yes, that fixes it, thanks. But please note that I don't use jails and don't
have jail(8) installed at all (WITHOUT_JAIL).

Also, maybe we should check if jail(8) exists before running $(jail ...) or
even the whole "if" expression. The result will probably be the same but one
can clearly see that it depends on jail(8) and maybe one can then even leave
out the 2>/dev/null so errors can come through (no idea if this is something
that can happen). Something like (bad indenting to be ignored):

--- 340.noid.ORI	2018-12-22 08:26:24.515158000 +0100
+++ 340.noid	2018-12-22 08:27:51.985887000 +0100
@@ -21,6 +21,7 @@
 	# of this script.
 
 	exclude=''
+if [ -x /usr/sbin/jail ]; then
 	if [ $(sysctl -n security.jail.jailed) = 0 ]; then
 	    # For jail_conf
 	    . /etc/rc.subr
@@ -29,7 +30,7 @@
 	    sep=:
 	    OIFS="$IFS"
 	    IFS="$sep"
-	    for param in $(jail -f "$jail_conf" -e "$sep" 2>/dev/null)
+	    for param in $(jail -f "$jail_conf" -e "$sep")
 	    do
 		case "$param" in
 		    path=*)
@@ -44,6 +45,7 @@
 	    done
 	    IFS="$OIFS"
 	fi
+fi
 
 	rc=$(find -H ${weekly_noid_dirs:-/} \
 	    \( $exclude ! -fstype local -prune -or -name \* \) -and \


(Or replace the -x by some which(1) construct...)

Sorry for the late reply but I was on holidays (and had to wait for the weekly
run anyway).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20181222073340.GA27107>