[cl-debian] Bug#477169: post-sysdef-install.lisp: GET-UID broken on ECL and otherwise inconsistent

Mark Wooding mdw at distorted.org.uk
Mon Apr 21 14:47:52 UTC 2008


Package: common-lisp-controller
Version: 6.12
Severity: important
Tags: patch

I recently found that my ECL fails to ASDF-whatever systems.  It fails
like this:

[metalzone ~]ecl
;;; Loading #P"/usr/lib/ecl/cmp.fas"
;;; Loading #P"/usr/lib/ecl/sysfun.lsp"
ECL (Embeddable Common-Lisp) 0.9i
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Top level.
> (asdf:oos 'asdf:load-op :cl-ppcre)
; loading system definition from
/usr/share/common-lisp/systems/cl-ppcre.asd
; into #<ASDF0 package>
; registering #<SYSTEM :CL-PPCRE 135932064> as CL-PPCRE
1000
Unable to find out user ID
Broken at EVAL.No restarts available.
Broken at ASDF:OPERATE.
>>

Tracking down the problem shows that CLC's fallback implementation of
GET-UID, in terms of `id', isn't working for whatever reason (presumably
ECL doesn't do the right output-redirection stuff).

Since ECL has a convenient FFI, it's trivial to implement a working
GET-UID which doesn't need to mess with running shell commands and doing
redirection.

While staring at this code, I've noticed inconsistencies in the
behaviour of GET-UID:

  * SBCL, CMU and Allegro (and now ECL) use the real uid of the process.

  * CLisp uses the uid of the user named by the USER environment
    variable.

  * Other Lisps call `id -u', which returns the effective uid.

This is clearly an undesirable state of affairs, so the patch below
makes everyone use the ruid.  (Using the euid would be better, but I'm
not sure that running Lisp systems in a setuid state is clever in the
first place; besides, SBCL and CMU don't provide convenient ways of
getting hold of the effective uid.)

--- /usr/share/common-lisp/source/common-lisp-controller/post-sysdef-install.lisp.aside	2008-04-21 14:53:46.000000000 +0100
+++ /usr/share/common-lisp/source/common-lisp-controller/post-sysdef-install.lisp	2008-04-21 15:28:39.000000000 +0100
@@ -30,20 +30,21 @@
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (require :osi))
 
-#+clisp (defun get-uid () (posix:user-info-uid (posix:user-info (ext:getenv "USER"))))
+#+clisp (defun get-uid () (posix:getuid))
 #+sbcl (defun get-uid () (sb-unix:unix-getuid))
 #+cmu (defun get-uid () (unix:unix-getuid))
 #+allegro (defun get-uid () (excl.osi:getuid))
+#+ecl (defun get-uid () (ffi:c-inline () () :int "getuid()" :one-liner t))
 #+clisp (defun world-writable? (mode) (or (member :RWXO mode) (member :WOTH mode)))
 #+clisp (defun group-writable? (mode) (or (member :RWXG mode) (member :WGRP mode)))
 #-clisp (defun world-writable? (mode) (/= 0 (logand mode #o002)))
 #-clisp (defun group-writable? (mode) (/= 0 (logand mode #o020)))
 
-#-(or cmu sbcl clisp allegro)
+#-(or cmu sbcl clisp allegro ecl)
 (defun get-uid ()
   (let ((uid-string 
 	 (with-output-to-string (asdf::*VERBOSE-OUT*)
-	   (asdf:run-shell-command "id -u"))))
+	   (asdf:run-shell-command "id -ur"))))
     (with-input-from-string (stream uid-string)
       (read-line stream)
       (handler-case (parse-integer (read-line stream))

(I've set the severity to important, not because it breaks CLC, but
because it has a major adverse effect on ECL.)

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.24.4 (PREEMPT)
Locale: LANG=C, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages common-lisp-controller depends on:
ii  bash                          3.1dfsg-9  The GNU Bourne Again SHell
ii  cl-asdf                       1.109-2    Another System Definition Facility
ii  debconf [debconf-2.0]         1.5.20     Debian configuration management sy
ii  debianutils                   2.28.4     Miscellaneous utilities specific t
ii  perl                          5.8.8-12   Larry Wall's Practical Extraction 
ii  realpath                      1.11       Return the canonicalized absolute 

common-lisp-controller recommends no packages.

-- debconf information excluded






More information about the Cl-debian mailing list