Date: Sun, 1 Nov 2020 13:53:14 +0100 From: Oliver Pinter <oliver.pntr@gmail.com> To: =?UTF-8?B?U3RlZmFuIEXDn2Vy?= <se@freebsd.org> Cc: "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org> Subject: Re: svn commit: r367243 - in head: lib/libc/gen sys/kern Message-ID: <CAPjTQNHn6TFb-HZ-nvzhug0Qs77wDXidDAK5wk9J=UFq5n_qMA@mail.gmail.com> In-Reply-To: <202010312348.09VNmfWN009773@repo.freebsd.org> References: <202010312348.09VNmfWN009773@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday, November 1, 2020, Stefan E=C3=9Fer <se@freebsd.org> wrote: > Author: se > Date: Sat Oct 31 23:48:41 2020 > New Revision: 367243 > URL: https://svnweb.freebsd.org/changeset/base/367243 > > Log: > Make sysctl user.local a tunable that can be written at run-time > > This sysctl value had been provided as a read-only variable that is > compiled into the C library based on the value of _PATH_LOCALBASE in > paths.h. > > After this change, the value is compiled into the kernel as an empty > string, which is translated to _PATH_LOCALBASE by the C library. > > This empty string can be overridden at boot time or by a privileged > user at run time and will then be returned by sysctl. > > When set to an empty string, the value returned by sysctl reverts to > _PATH_LOCALBASE. > > This update does not change the behavior on any system that does > not modify the default value of user.localbase. > > I consider this change as experimental and would prefer if the run-time > write permission was reconsidered and the sysctl variable defined with > CLFLAG_RDTUN instead to restrict it to be set at boot time. > > MFC after: 1 month Wouldn't be better to make this variable a per-jail variable? > > Modified: > head/lib/libc/gen/sysctl.c > head/sys/kern/kern_mib.c > > Modified: head/lib/libc/gen/sysctl.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- head/lib/libc/gen/sysctl.c Sat Oct 31 23:19:59 2020 (r367242) > +++ head/lib/libc/gen/sysctl.c Sat Oct 31 23:48:41 2020 (r367243) > @@ -68,14 +68,14 @@ sysctl(const int *name, u_int namelen, void *oldp, si= z > if (retval || name[0] !=3D CTL_USER) > return (retval); > > - if (newp !=3D NULL) { > - errno =3D EPERM; > - return (-1); > - } > if (namelen !=3D 2) { > errno =3D EINVAL; > return (-1); > } > + if (newp !=3D NULL && name[1] !=3D USER_LOCALBASE) { > + errno =3D EPERM; > + return (-1); > + } > > switch (name[1]) { > case USER_CS_PATH: > @@ -88,13 +88,21 @@ sysctl(const int *name, u_int namelen, void *oldp, si= z > memmove(oldp, _PATH_STDPATH, > sizeof(_PATH_STDPATH)); > return (0); > case USER_LOCALBASE: > - if (oldp !=3D NULL && orig_oldlen < sizeof(_PATH_LOCALBAS= E)) > { > - errno =3D ENOMEM; > - return (-1); > + if (oldlenp !=3D NULL) { > + if (oldp =3D=3D NULL) { > + if (*oldlenp =3D=3D 1) > + *oldlenp =3D sizeof(_PATH_LOCALBA= SE); > + } else { > + if (*oldlenp !=3D 1) > + return (retval); > + if (orig_oldlen < sizeof(_PATH_LOCALBASE)= ) > { > + errno =3D ENOMEM; > + return (-1); > + } > + *oldlenp =3D sizeof(_PATH_LOCALBASE); > + memmove(oldp, _PATH_LOCALBASE, > sizeof(_PATH_LOCALBASE)); > + } > } > - *oldlenp =3D sizeof(_PATH_LOCALBASE); > - if (oldp !=3D NULL) > - memmove(oldp, _PATH_LOCALBASE, > sizeof(_PATH_LOCALBASE)); > return (0); > } > > > Modified: head/sys/kern/kern_mib.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- head/sys/kern/kern_mib.c Sat Oct 31 23:19:59 2020 (r367242) > +++ head/sys/kern/kern_mib.c Sat Oct 31 23:48:41 2020 (r367243) > @@ -652,8 +652,11 @@ SYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFL= AG > SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of streams a process may > have open at one time"); > SYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD, > SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of types supported for > timezone names"); > -SYSCTL_STRING(_user, USER_LOCALBASE, localbase, CTLFLAG_RD, > - "", 0, "Prefix used to install and locate add-on packages"); > + > +static char localbase[MAXPATHLEN] =3D ""; > + > +SYSCTL_STRING(_user, USER_LOCALBASE, localbase, CTLFLAG_RWTUN, > + localbase, sizeof(localbase), "Prefix used to install and locate > add-on packages"); > > #include <sys/vnode.h> > SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD, > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPjTQNHn6TFb-HZ-nvzhug0Qs77wDXidDAK5wk9J=UFq5n_qMA>