emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should Emacs provide a uuid function?


From: Leo
Subject: Re: Should Emacs provide a uuid function?
Date: Mon, 09 May 2011 14:29:20 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7)

On 2011-04-26 03:52 +0800, Chong Yidong wrote:
> Ken Raeburn <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]