Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Mar 2023 10:30:59 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Warner Losh <imp@freebsd.org>, src-committers@freebsd.org,  dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: adeca21464d2 - main - Add GNU glibc compatible secure_getenv
Message-ID:  <CANCZdfpkEq5%2BPRaieR4wz4AK_NBtzw5deMZB7c%2B1TcG=0zjqgA@mail.gmail.com>
In-Reply-To: <ZBA6JXzO3dq0egDi@kib.kiev.ua>
References:  <202303140419.32E4Jtsd058392@gitrepo.freebsd.org> <ZBA6JXzO3dq0egDi@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
--00000000000056f71d05f6dec12e
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, Mar 14, 2023 at 3:11=E2=80=AFAM Konstantin Belousov <kostikbel@gmai=
l.com>
wrote:

> On Tue, Mar 14, 2023 at 04:19:55AM +0000, Warner Losh wrote:
> > The branch main has been updated by imp:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=3Dadeca21464d25bc61f98968a5c1e76a=
b3c808ae4
> >
> > commit adeca21464d25bc61f98968a5c1e76ab3c808ae4
> > Author:     lucy <seafork@disroot.org>
> > AuthorDate: 2023-03-13 22:01:12 +0000
> > Commit:     Warner Losh <imp@FreeBSD.org>
> > CommitDate: 2023-03-14 04:19:24 +0000
> >
> >     Add GNU glibc compatible secure_getenv
> >
> >     Add mostly glibc and msl compatible secure_getenv. Return NULL if
> >     issetugid() indicates the process is tainted, otherwise getenv(x).
> The
> >     rational behind this is the fact that many Linux applications use
> this
> >     function instead of getenv() as it's widely consider a, "best
> >     practice".
> >
> >     Reviewed by: imp, mjg (feedback)
> >     Pull Request: https://github.com/freebsd/freebsd-src/pull/686
> >     Signed-off-by: Lucy Marsh <seafork@disroot.org>
> > ---
> >  include/stdlib.h             |  1 +
> >  lib/libc/stdlib/Makefile.inc |  4 ++--
> >  lib/libc/stdlib/Symbol.map   |  1 +
> >  lib/libc/stdlib/getenv.3     | 26 +++++++++++++++++++++++++-
> >  lib/libc/stdlib/getenv.c     | 12 ++++++++++++
> >  5 files changed, 41 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/stdlib.h b/include/stdlib.h
> > index 01629ed84a11..c41e8704e810 100644
> > --- a/include/stdlib.h
> > +++ b/include/stdlib.h
> > @@ -111,6 +111,7 @@ void       qsort(void *, size_t, size_t,
> >           int (* _Nonnull)(const void *, const void *));
> >  int   rand(void);
> >  void *realloc(void *, size_t) __result_use_check __alloc_size(2);
> > +char *secure_getenv(const char *);
> The declaration must be put under BSD_VISIBLE.
>

Thanks. https://reviews.freebsd.org/D39076


> >  void  srand(unsigned);
> >  double        strtod(const char * __restrict, char ** __restrict);
> >  float         strtof(const char * __restrict, char ** __restrict);
>

--00000000000056f71d05f6dec12e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Tue, Mar 14, 2023 at 3:11=E2=80=AF=
AM Konstantin Belousov &lt;<a href=3D"mailto:kostikbel@gmail.com">kostikbel=
@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex">On Tue, Mar 14, 2023 at 04:19:55AM +0000, Warner Losh wrote:<br>
&gt; The branch main has been updated by imp:<br>
&gt; <br>
&gt; URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3Dadeca21464d2=
5bc61f98968a5c1e76ab3c808ae4" rel=3D"noreferrer" target=3D"_blank">https://=
cgit.FreeBSD.org/src/commit/?id=3Dadeca21464d25bc61f98968a5c1e76ab3c808ae4<=
/a><br>
&gt; <br>
&gt; commit adeca21464d25bc61f98968a5c1e76ab3c808ae4<br>
&gt; Author:=C2=A0 =C2=A0 =C2=A0lucy &lt;<a href=3D"mailto:seafork@disroot.=
org" target=3D"_blank">seafork@disroot.org</a>&gt;<br>
&gt; AuthorDate: 2023-03-13 22:01:12 +0000<br>
&gt; Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh &lt;imp@FreeBSD.org&gt;<br>
&gt; CommitDate: 2023-03-14 04:19:24 +0000<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0Add GNU glibc compatible secure_getenv<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0Add mostly glibc and msl compatible secure_getenv. =
Return NULL if<br>
&gt;=C2=A0 =C2=A0 =C2=A0issetugid() indicates the process is tainted, other=
wise getenv(x).=C2=A0 The<br>
&gt;=C2=A0 =C2=A0 =C2=A0rational behind this is the fact that many Linux ap=
plications use this<br>
&gt;=C2=A0 =C2=A0 =C2=A0function instead of getenv() as it&#39;s widely con=
sider a, &quot;best<br>
&gt;=C2=A0 =C2=A0 =C2=A0practice&quot;.<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0Reviewed by: imp, mjg (feedback)<br>
&gt;=C2=A0 =C2=A0 =C2=A0Pull Request: <a href=3D"https://github.com/freebsd=
/freebsd-src/pull/686" rel=3D"noreferrer" target=3D"_blank">https://github.=
com/freebsd/freebsd-src/pull/686</a><br>
&gt;=C2=A0 =C2=A0 =C2=A0Signed-off-by: Lucy Marsh &lt;<a href=3D"mailto:sea=
fork@disroot.org" target=3D"_blank">seafork@disroot.org</a>&gt;<br>
&gt; ---<br>
&gt;=C2=A0 include/stdlib.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
|=C2=A0 1 +<br>
&gt;=C2=A0 lib/libc/stdlib/Makefile.inc |=C2=A0 4 ++--<br>
&gt;=C2=A0 lib/libc/stdlib/Symbol.map=C2=A0 =C2=A0|=C2=A0 1 +<br>
&gt;=C2=A0 lib/libc/stdlib/getenv.3=C2=A0 =C2=A0 =C2=A0| 26 +++++++++++++++=
++++++++++-<br>
&gt;=C2=A0 lib/libc/stdlib/getenv.c=C2=A0 =C2=A0 =C2=A0| 12 ++++++++++++<br=
>
&gt;=C2=A0 5 files changed, 41 insertions(+), 3 deletions(-)<br>
&gt; <br>
&gt; diff --git a/include/stdlib.h b/include/stdlib.h<br>
&gt; index 01629ed84a11..c41e8704e810 100644<br>
&gt; --- a/include/stdlib.h<br>
&gt; +++ b/include/stdlib.h<br>
&gt; @@ -111,6 +111,7 @@ void=C2=A0 =C2=A0 =C2=A0 =C2=A0qsort(void *, size_=
t, size_t,<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int (* _Nonnull)(const void *,=
 const void *));<br>
&gt;=C2=A0 int=C2=A0 =C2=A0rand(void);<br>
&gt;=C2=A0 void *realloc(void *, size_t) __result_use_check __alloc_size(2)=
;<br>
&gt; +char *secure_getenv(const char *);<br>
The declaration must be put under BSD_VISIBLE.<br></blockquote><div><br></d=
iv><div>Thanks. <a href=3D"https://reviews.freebsd.org/D39076">https://revi=
ews.freebsd.org/D39076</a></div><div>=C2=A0</div><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204=
,204);padding-left:1ex">
&gt;=C2=A0 void=C2=A0 srand(unsigned);<br>
&gt;=C2=A0 double=C2=A0 =C2=A0 =C2=A0 =C2=A0 strtod(const char * __restrict=
, char ** __restrict);<br>
&gt;=C2=A0 float=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0strtof(const char * __res=
trict, char ** __restrict);<br>
</blockquote></div></div>

--00000000000056f71d05f6dec12e--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpkEq5%2BPRaieR4wz4AK_NBtzw5deMZB7c%2B1TcG=0zjqgA>