From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.devel Subject: Re: Should Emacs provide a uuid function? Date: Mon, 09 May 2011 14:29:20 +0800 Message-ID: References: <87ipu3v0ru.fsf@stupidchicken.com> <871v0raqub.fsf@uwakimon.sk.tsukuba.ac.jp> <42A7030B-DE0C-4CCA-A768-B82BE70C42F9@raeburn.org> <87liyynm6a.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1304922583 13335 80.91.229.12 (9 May 2011 06:29:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 9 May 2011 06:29:43 +0000 (UTC) Cc: Ken Raeburn , Emacs Dev To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 09 08:29:39 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QJJyN-0003S8-0c for ged-emacs-devel@m.gmane.org; Mon, 09 May 2011 08:29:39 +0200 Original-Received: from localhost ([::1]:37706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJJyL-0006HR-UB for ged-emacs-devel@m.gmane.org; Mon, 09 May 2011 02:29:37 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJJyI-0006HB-T3 for emacs-devel@gnu.org; Mon, 09 May 2011 02:29:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QJJyH-00075k-OJ for emacs-devel@gnu.org; Mon, 09 May 2011 02:29:34 -0400 Original-Received: from mail-pv0-f169.google.com ([74.125.83.169]:46820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QJJyH-00075a-Cr for emacs-devel@gnu.org; Mon, 09 May 2011 02:29:33 -0400 Original-Received: by pvc12 with SMTP id 12so3323267pvc.0 for ; Sun, 08 May 2011 23:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:message-id :user-agent:mime-version:content-type; bh=QRsMZ9hSEeoLz/D9QORlxMb3PdtsldvJc5NKZfSTHQ4=; b=ikbzglqv+9fUx4skGT6BV6EhYGBmv0FVlswybva2QL7V0u79FPnntT+0y15LuP/JcO fkhc0FbPoKrtDaLbkwRLqVRwLesiQkTz+DfgxMVTqFhMjGFcOug57G8Poxyfc7yvuUhH QJFVkcGMsOU0QWgu6IAk/NeFrSAUNti9LcLP0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-type; b=CcYawTswVOVxuhgJB0RQmHge0eYyyGz1eGgqTzhcUmN30w4/m8J6gEc/LtSbAroqnW sklNn2KFcXpcGv17Mrte3433rgBIN8+To+IzKuYL76EHneq0EYbeaeRYOZu9ts5RiBwq JVEcRmjbY2Ph5s5eJPCSjm4BJ/uFFdQXIb9CQ= Original-Received: by 10.68.44.200 with SMTP id g8mr9669652pbm.362.1304922571999; Sun, 08 May 2011 23:29:31 -0700 (PDT) Original-Received: from th041156.ip.tsinghua.edu.cn ([123.114.50.27]) by mx.google.com with ESMTPS id j2sm3903751pbo.79.2011.05.08.23.29.26 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 May 2011 23:29:30 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:139240 Archived-At: On 2011-04-26 03:52 +0800, Chong Yidong wrote: > Ken Raeburn writes: > >> I wouldn't consider the elisp 'random' function to be remotely good >> enough though. > > You mean, because of the way it's seeded? I guess we can (should?) > improve it to use /dev/random where that's available. I think this is a good proposal. It seems everything can be built on top of the ability to get some bytes from /dev/random or /dev/urandom. For example: (defun secure-random-bytes (n) (let ((file (cond ((file-exists-p "/dev/random") "/dev/random") ((file-exists-p "/dev/urandom") "/dev/urandom") (t (error "Secure random device not available"))))) (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents file nil 0 n) (buffer-string)))) After patching insert-file-contents to support CHAR DEV. diff --git a/src/fileio.c b/src/fileio.c index c6e93ceb..c8ab7ef6 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3275,7 +3275,7 @@ variable `last-coding-system-used' to the coding system actually used. */) /* This code will need to be changed in order to work on named pipes, and it's probably just not worth it. So we should at least signal an error. */ - if (!S_ISREG (st.st_mode)) + if (!S_ISREG (st.st_mode) && !S_ISCHR (st.st_mode)) { not_regular = 1; Leo