From owner-svn-src-head@freebsd.org  Sat Dec 14 18:20:14 2019
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85F051D3B38;
 Sat, 14 Dec 2019 18:20:14 +0000 (UTC)
 (envelope-from rlibby@gmail.com)
Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com
 [IPv6:2607:f8b0:4864:20::830])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (2048 bits) client-digest SHA256)
 (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 47ZwnB32L9z4bpJ;
 Sat, 14 Dec 2019 18:20:14 +0000 (UTC)
 (envelope-from rlibby@gmail.com)
Received: by mail-qt1-x830.google.com with SMTP id g17so834675qtp.11;
 Sat, 14 Dec 2019 10:20:14 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=pVhUfiqXM1pdl8Z46ChT9mF7qYS+xu4mpuE5lry/u+A=;
 b=m6PiTlsaPKclGJhRa7puQE/VoWtfHT/z9kMl7Ws7TOs84LpARHZjHLeemlFGihE78D
 i8c3uThMJFdTpG2CfdSCFK5bsodD2lnK9d7Z7F1nzWZEeAYlYLgQzPTyPNHCACGydjaj
 3Z5Nmat+IFAUF5d+aQFu31yyXeftJs7NrMXqPwQihj8ifzzJZec02V5GKQzdXymDh3tl
 nFhc74z7UqF16ScyOsIGqUgvCOctgD2osp6rBQccOmV89CZHcxZzHraF+/3C8dFEnVj7
 plqyY69lRBJN6PtbGSw0AX6BtKN4HyRKvnvlRrEjHgyiM6ESF4b9uKl3w4Hbzja89Jw2
 8kag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=pVhUfiqXM1pdl8Z46ChT9mF7qYS+xu4mpuE5lry/u+A=;
 b=svRq5GpdfEUJjyTsKJpbmRfROOTtvZnxlVy+zWIy4ulk9ooSNNnF0LTrlm19r/Jpef
 haMNPhLOTPTk0VpQ1/KwQDxJGlr85qkrgjguAPtMRlWRdxTny7Zo5Dpn1yHyEzCbc/L9
 hiV62CDxCAH1PiomOeUTt9RKMJiou2ofjsXoVUlkTZObwD1NbEuHw3CbCUmtCc5eFV1k
 cELBoCYqCeFseDUEoypPvL1hbYbNwZyocUwhvOASfH7GlR0Wg1RhJVbnnc7sBZ/Ibs8d
 4mxhi58Zu3rTpHyax70Q/JTkfIyg0WTcblu8Ysy01qwysNADMXaxRRrCB6JPzkjtdtHc
 HXMA==
X-Gm-Message-State: APjAAAVBhXllRE98qPtoQOObciI/3eClT0lOQAm/ltzjbh79TUcFB8tp
 KAj51+xfNYjby9bNuVjaaaHW9cidX24s8gAT2DqejQ==
X-Google-Smtp-Source: APXvYqxPjINd1Q269MhWua6v009RAo3rRbrp5Qszzv+MxhtMi4s7zlf/UsicqaxpoOjlFM+SA6Nl4nGWbgssbR0TAH8=
X-Received: by 2002:aed:3641:: with SMTP id e59mr224139qtb.174.1576347611838; 
 Sat, 14 Dec 2019 10:20:11 -0800 (PST)
MIME-Version: 1.0
References: <201912140828.xBE8SAXq027656@repo.freebsd.org>
In-Reply-To: <201912140828.xBE8SAXq027656@repo.freebsd.org>
From: Ryan Libby <rlibby@gmail.com>
Date: Sat, 14 Dec 2019 10:20:00 -0800
Message-ID: <CAHgpiFyQ6+-cbjtwi6NsPkohbQd+6ies0+55g5KtYH9Pog_sTw@mail.gmail.com>
Subject: Re: svn commit: r355747 - in head: . include lib/libc/stdlib lib/libxo
To: Conrad Meyer <cem@freebsd.org>
Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, 
 svn-src-head@freebsd.org
Content-Type: text/plain; charset="UTF-8"
X-Rspamd-Queue-Id: 47ZwnB32L9z4bpJ
X-Spamd-Bar: -----
Authentication-Results: mx1.freebsd.org;
	none
X-Spamd-Result: default: False [-6.00 / 15.00];
 NEURAL_HAM_MEDIUM(-1.00)[-0.997,0];
 NEURAL_HAM_LONG(-1.00)[-0.999,0]; REPLY(-4.00)[]
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 14 Dec 2019 18:20:14 -0000

On Sat, Dec 14, 2019 at 12:28 AM Conrad Meyer <cem@freebsd.org> wrote:
>
> Author: cem
> Date: Sat Dec 14 08:28:10 2019
> New Revision: 355747
> URL: https://svnweb.freebsd.org/changeset/base/355747
>
> Log:
>   Deprecate sranddev(3) API
>
>   It serves no useful purpose and wasn't as popular as its equally meritless
>   cousin, srandomdev(3).
>
>   Setting aside the problems with rand(3) in general, the problem with this
>   interface is that the seed isn't shared with the caller (other than by
>   attacking the output of the generator, which is trivial, but not a hallmark of
>   pleasant API design).  The (arguable) utility of rand(3) or random(3) is as a
>   semi-fast simulation generator which produces consistent results from a given
>   seed.  These are mutually at odd.  Furthermore, sometimes people got the
>   mistaken impression that a high quality random seed meant a weak generator like
>   rand(3) or random(3) could be used for things like cryptographic key
>   generation.  This is absolutely not so.
>
>   The API was never part of a standard and was not widely used in tree.  Existing
>   in-tree uses have all been removed.
>
>   Possible replacement in out of tree codebases:
>
>         char buf[3];
>         time_t t;
>
>         time(t);
>         strftime(buf, sizeof(buf), "%S", gmtime(&t));
>         srand(atoi(buf));
>
>   Relnotes:     yes
>
> Modified:
>   head/ObsoleteFiles.inc
>   head/include/stdlib.h
>   head/lib/libc/stdlib/Makefile.inc
>   head/lib/libc/stdlib/Symbol.map
>   head/lib/libc/stdlib/rand.3
>   head/lib/libc/stdlib/rand.c
>   head/lib/libxo/xo_config.h
>
> Modified: head/ObsoleteFiles.inc
> ==============================================================================
> --- head/ObsoleteFiles.inc      Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/ObsoleteFiles.inc      Sat Dec 14 08:28:10 2019        (r355747)
> @@ -36,6 +36,8 @@
>  #   xargs -n1 | sort | uniq -d;
>  # done
>
> +# 20191214: Removal of sranddev(3)
> +OLD_FILES+=usr/share/man/man3/sranddev.3.gz
>  # 20191213: remove timeout(9)
>  OLD_FILES+=usr/share/man/man9/timeout.9.gz
>  OLD_FILES+=usr/share/man/man9/untimeout.9.gz
>
> Modified: head/include/stdlib.h
> ==============================================================================
> --- head/include/stdlib.h       Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/include/stdlib.h       Sat Dec 14 08:28:10 2019        (r355747)
> @@ -309,12 +309,17 @@ int        rpmatch(const char *);
>  void    setprogname(const char *);
>  int     sradixsort(const unsigned char **, int, const unsigned char *,
>             unsigned);
> -void    sranddev(void);
>  void    srandomdev(void);
>  long long
>         strtonum(const char *, long long, long long, const char **);
>
>  /* Deprecated interfaces, to be removed. */
> +static inline void
> +__attribute__((__deprecated__("sranddev to be removed in FreeBSD 13")))
> +sranddev(void)
> +{
> +}
> +

This broke some gcc builds in ci.  It looks like older versions of gcc
don't like having an argument to deprecated.

>  __int64_t
>          strtoq(const char *, char **, int);
>  __uint64_t
>
> Modified: head/lib/libc/stdlib/Makefile.inc
> ==============================================================================
> --- head/lib/libc/stdlib/Makefile.inc   Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/lib/libc/stdlib/Makefile.inc   Sat Dec 14 08:28:10 2019        (r355747)
> @@ -52,7 +52,7 @@ MLINKS+=insque.3 remque.3
>  MLINKS+=lsearch.3 lfind.3
>  MLINKS+=ptsname.3 grantpt.3 ptsname.3 unlockpt.3
>  MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 qsort.3 qsort_r.3
> -MLINKS+=rand.3 rand_r.3 rand.3 srand.3 rand.3 sranddev.3
> +MLINKS+=rand.3 rand_r.3 rand.3 srand.3
>  MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3 \
>         random.3 srandomdev.3
>  MLINKS+=radixsort.3 sradixsort.3
>
> Modified: head/lib/libc/stdlib/Symbol.map
> ==============================================================================
> --- head/lib/libc/stdlib/Symbol.map     Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/lib/libc/stdlib/Symbol.map     Sat Dec 14 08:28:10 2019        (r355747)
> @@ -56,7 +56,6 @@ FBSD_1.0 {
>         rand_r;
>         rand;
>         srand;
> -       sranddev;
>         srandom;
>         srandomdev;
>         initstate;
>
> Modified: head/lib/libc/stdlib/rand.3
> ==============================================================================
> --- head/lib/libc/stdlib/rand.3 Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/lib/libc/stdlib/rand.3 Sat Dec 14 08:28:10 2019        (r355747)
> @@ -32,13 +32,12 @@
>  .\"     @(#)rand.3     8.1 (Berkeley) 6/4/93
>  .\" $FreeBSD$
>  .\"
> -.Dd April 22, 2019
> +.Dd December 14, 2019
>  .Dt RAND 3
>  .Os
>  .Sh NAME
>  .Nm rand ,
>  .Nm srand ,
> -.Nm sranddev ,
>  .Nm rand_r
>  .Nd bad random number generator
>  .Sh LIBRARY
> @@ -47,8 +46,6 @@
>  .In stdlib.h
>  .Ft void
>  .Fn srand "unsigned seed"
> -.Ft void
> -.Fn sranddev void
>  .Ft int
>  .Fn rand void
>  .Ft int
> @@ -90,10 +87,6 @@ value is provided, the functions are automatically
>  seeded with a value of 1.
>  .Pp
>  The
> -.Fn sranddev
> -function initializes a seed using pseudo-random numbers obtained from the kernel.
> -.Pp
> -The
>  .Fn rand_r
>  function
>  provides the same functionality as
> @@ -122,4 +115,5 @@ conform to
>  .Pp
>  The
>  .Fn rand_r
> -function is as proposed in the POSIX.4a Draft #6 document.
> +function is marked as obsolescent in POSIX and may be removed in a future
> +revision of the standard.
>
> Modified: head/lib/libc/stdlib/rand.c
> ==============================================================================
> --- head/lib/libc/stdlib/rand.c Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/lib/libc/stdlib/rand.c Sat Dec 14 08:28:10 2019        (r355747)
> @@ -40,7 +40,9 @@ __FBSDID("$FreeBSD$");
>  #include "namespace.h"
>  #include <sys/param.h>
>  #include <sys/sysctl.h>
> +#include <stdbool.h>
>  #include <stdlib.h>
> +#include <syslog.h>
>  #include "un-namespace.h"
>
>  #ifdef TEST
> @@ -102,25 +104,18 @@ srand(unsigned seed)
>  }
>
>
> -/*
> - * sranddev:
> - *
> - * Many programs choose the seed value in a totally predictable manner.
> - * This often causes problems.  We seed the generator using pseudo-random
> - * data from the kernel.
> - */
> +void __sranddev_fbsd12(void);
>  void
> -sranddev(void)
> +__sranddev_fbsd12(void)
>  {
> -       int mib[2];
> -       size_t len;
> +       static bool warned = false;
>
> -       len = sizeof(next);
> -
> -       mib[0] = CTL_KERN;
> -       mib[1] = KERN_ARND;
> -       sysctl(mib, 2, (void *)&next, &len, NULL, 0);
> +       if (!warned) {
> +               syslog(LOG_DEBUG, "Deprecated function sranddev() called");
> +               warned = true;
> +       }
>  }
> +__sym_compat(sranddev, __sranddev_fbsd12, FBSD_1.0);
>
>
>  #ifdef TEST
>
> Modified: head/lib/libxo/xo_config.h
> ==============================================================================
> --- head/lib/libxo/xo_config.h  Sat Dec 14 05:21:56 2019        (r355746)
> +++ head/lib/libxo/xo_config.h  Sat Dec 14 08:28:10 2019        (r355747)
> @@ -102,7 +102,7 @@
>  #define HAVE_SRAND 1
>
>  /* Define to 1 if you have the `sranddev' function. */
> -#define HAVE_SRANDDEV 1
> +/* #undef HAVE_SRANDDEV */
>
>  /* Define to 1 if you have the <stdint.h> header file. */
>  #define HAVE_STDINT_H 1
> _______________________________________________
> svn-src-all@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"