From 8b77810a9c727bb6026e575f38a176a39e7675b4 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sat, 8 Nov 2003 21:08:13 +0000 Subject: [PATCH] 0.8.5.27: SB-{POSIX/BSD-SOCKETS} cleanups ... make sb-bsd-sockets-tests depend on sb-posix so we can check to see if /dev/log is actually a socket; ... test that /, not /root, is not writeable by others; ... (taking advantage of our 0.x version number) alter SB-POSIX:S-ISFOO to use the BOOLEAN alien type, rather than MODE-T -- the point being that the macros have no function other than returning a boolean. Adjust the sb-posix manifesto too, to document this. --- contrib/sb-bsd-sockets/sb-bsd-sockets.asd | 2 +- contrib/sb-bsd-sockets/tests.lisp | 12 ++++++++---- contrib/sb-posix/README | 7 ++++++- contrib/sb-posix/interface.lisp | 16 +++++++--------- contrib/sb-posix/macros.lisp | 5 +++-- contrib/sb-posix/posix-tests.lisp | 27 +++++++++++++++------------ version.lisp-expr | 2 +- 7 files changed, 41 insertions(+), 30 deletions(-) diff --git a/contrib/sb-bsd-sockets/sb-bsd-sockets.asd b/contrib/sb-bsd-sockets/sb-bsd-sockets.asd index 3c68951..6056a5a 100644 --- a/contrib/sb-bsd-sockets/sb-bsd-sockets.asd +++ b/contrib/sb-bsd-sockets/sb-bsd-sockets.asd @@ -110,7 +110,7 @@ (operate 'test-op 'sb-bsd-sockets-tests)) (defsystem sb-bsd-sockets-tests - :depends-on (sb-rt sb-bsd-sockets) + :depends-on (sb-rt sb-bsd-sockets sb-posix) :components ((:file "tests"))) (defmethod perform ((o test-op) (c (eql (find-system :sb-bsd-sockets-tests)))) diff --git a/contrib/sb-bsd-sockets/tests.lisp b/contrib/sb-bsd-sockets/tests.lisp index dc59b94..5d15ab0 100644 --- a/contrib/sb-bsd-sockets/tests.lisp +++ b/contrib/sb-bsd-sockets/tests.lisp @@ -135,10 +135,14 @@ Tests are in the file tests.lisp and also make good examples. (deftest simple-local-client (progn - ;; SunOS (Solaris) and Darwin systems don't have a socket at - ;; /dev/log. We might also be building in a chroot or something, - ;; so don't fail this test just because the file is unavailable - (when (probe-file "/dev/log") + ;; SunOS (Solaris) and Darwin systems don't have a socket at + ;; /dev/log. We might also be building in a chroot or + ;; something, so don't fail this test just because the file is + ;; unavailable, or if it's a symlink to some weird character + ;; device. + (when (and (probe-file "/dev/log") + (sb-posix:s-issock + (sb-posix::stat-mode (sb-posix:stat "/dev/log")))) (let ((s (make-instance 'local-socket :type :datagram))) (format t "Connecting ~A... " s) (finish-output) diff --git a/contrib/sb-posix/README b/contrib/sb-posix/README index 5448ffe..e62ea00 100644 --- a/contrib/sb-posix/README +++ b/contrib/sb-posix/README @@ -191,7 +191,12 @@ of the error number] We do not automatically translate the returned value into "Lispy" objects - for example, SB-POSIX:OPEN returns a small integer, not a -stream. +stream. Exception: boolean-returning functions (or, more commonly, +macros) do not return a C integer, but instead a lisp boolean [ or +maybe "true"/"false" in CLtS parlance ]; the rationale behind this +exception is that there is nothing that can be meaningfully done with +the boolean except test for truth or falsity -- it cannot be passed +meaningfully to other POSIX functions. [ Rationale: This is an interface to POSIX, not a high-level interface that uses POSIX, and many people using it will actually want to mess diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp index bd7ed8d..3631996 100644 --- a/contrib/sb-posix/interface.lisp +++ b/contrib/sb-posix/interface.lisp @@ -152,13 +152,13 @@ ;;; mode flags -(define-call "s_isreg" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) -(define-call "s_isdir" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) -(define-call "s_ischr" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) -(define-call "s_isblk" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) -(define-call "s_isfifo" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) -(define-call "s_islnk" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) -(define-call "s_issock" sb-posix::mode-t never-fails (mode sb-posix::mode-t)) +(define-call "s_isreg" boolean never-fails (mode sb-posix::mode-t)) +(define-call "s_isdir" boolean never-fails (mode sb-posix::mode-t)) +(define-call "s_ischr" boolean never-fails (mode sb-posix::mode-t)) +(define-call "s_isblk" boolean never-fails (mode sb-posix::mode-t)) +(define-call "s_isfifo" boolean never-fails (mode sb-posix::mode-t)) +(define-call "s_islnk" boolean never-fails (mode sb-posix::mode-t)) +(define-call "s_issock" boolean never-fails (mode sb-posix::mode-t)) (export 'sb-posix::pipe :sb-posix) (declaim (inline sb-posix::pipe)) @@ -173,5 +173,3 @@ (when (minusp r) (syscall-error))) (values (aref filedes2 0) (aref filedes2 1))) - -(define-call "frobozz" int minusp) diff --git a/contrib/sb-posix/macros.lisp b/contrib/sb-posix/macros.lisp index 882ac62..b35a31f 100644 --- a/contrib/sb-posix/macros.lisp +++ b/contrib/sb-posix/macros.lisp @@ -31,7 +31,7 @@ (string filename)) (define-designator file-descriptor (integer 32) - (sb-impl::file-stream (sb-impl::fd-stream-fd file-descriptor)) + (file-stream (sb-sys:fd-stream-fd file-descriptor)) (fixnum file-descriptor)) (define-designator sap-or-nil sb-sys:system-area-pointer @@ -43,7 +43,8 @@ (defmacro define-call (name return-type error-predicate &rest arguments) (let ((lisp-name (lisp-for-c-symbol name))) - (if (sb-fasl::foreign-symbol-address-as-integer-or-nil name) + (if (sb-fasl::foreign-symbol-address-as-integer-or-nil + (sb-vm:extern-alien-name name)) `(progn (export ',lisp-name :sb-posix) (declaim (inline ,lisp-name)) diff --git a/contrib/sb-posix/posix-tests.lisp b/contrib/sb-posix/posix-tests.lisp index 14f04b0..dd5784c 100644 --- a/contrib/sb-posix/posix-tests.lisp +++ b/contrib/sb-posix/posix-tests.lisp @@ -165,8 +165,11 @@ #.(logior sb-posix::s-iread sb-posix::s-iwrite sb-posix::s-iexec)) (deftest stat.2 - (let* ((stat (sb-posix:stat "/root")) + (let* ((stat (sb-posix:stat "/")) (mode (sb-posix::stat-mode stat))) + ;; it's logically possible for / to be writeable by others... but + ;; if it is, either someone is playing with strange security + ;; modules or they want to know about it anyway. (logand mode sb-posix::s-iwoth)) 0) @@ -225,32 +228,32 @@ (deftest stat-mode.1 (with-stat-mode (mode *test-directory*) (sb-posix:s-isreg mode)) - 0) + nil) (deftest stat-mode.2 (with-stat-mode (mode *test-directory*) - (zerop (sb-posix:s-isdir mode))) - nil) + (sb-posix:s-isdir mode)) + t) (deftest stat-mode.3 (with-stat-mode (mode *test-directory*) (sb-posix:s-ischr mode)) - 0) + nil) (deftest stat-mode.4 (with-stat-mode (mode *test-directory*) (sb-posix:s-isblk mode)) - 0) + nil) (deftest stat-mode.5 (with-stat-mode (mode *test-directory*) (sb-posix:s-isfifo mode)) - 0) + nil) (deftest stat-mode.6 (with-stat-mode (mode *test-directory*) (sb-posix:s-issock mode)) - 0) + nil) (deftest stat-mode.7 (let ((link-pathname (make-pathname :name "stat-mode.7" @@ -259,9 +262,9 @@ (progn (sb-posix:symlink *test-directory* link-pathname) (with-lstat-mode (mode link-pathname) - (zerop (sb-posix:s-islnk mode)))) + (sb-posix:s-islnk mode))) (ignore-errors (sb-posix:unlink link-pathname)))) - nil) + t) (deftest stat-mode.8 (let ((pathname (make-pathname :name "stat-mode.8" @@ -271,9 +274,9 @@ (with-open-file (out pathname :direction :output) (write-line "test" out)) (with-stat-mode (mode pathname) - (zerop (sb-posix:s-isreg mode)))) + (sb-posix:s-isreg mode))) (ignore-errors (delete-file pathname)))) - nil) + t) ;;; see comment in filename's designator definition, in macros.lisp (deftest filename-designator.1 diff --git a/version.lisp-expr b/version.lisp-expr index 82bfa93..c306c27 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.5.26" +"0.8.5.27" -- 1.7.10.4