nicer looking drivers
[hunchentoot.git] / unix-cmu.lisp
blob25d0f1e0a01c063a2b9b6f882eb76d8ad7f43ef6
1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: HUNCHENTOOT; Base: 10 -*-
2 ;;; $Header: /usr/local/cvsrep/hunchentoot/unix-cmu.lisp,v 1.6 2008/02/13 16:02:19 edi Exp $
4 ;;; Copyright (c) 2004-2008, Dr. Edmund Weitz. All rights reserved.
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
10 ;;; * Redistributions of source code must retain the above copyright
11 ;;; notice, this list of conditions and the following disclaimer.
13 ;;; * Redistributions in binary form must reproduce the above
14 ;;; copyright notice, this list of conditions and the following
15 ;;; disclaimer in the documentation and/or other materials
16 ;;; provided with the distribution.
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 (in-package :hunchentoot)
32 (defun setuid (uid)
33 "Sets the effective user ID of the current process to UID - see
34 setuid\(2)."
35 (multiple-value-bind (return-value errno)
36 (unix:unix-setuid uid)
37 (unless (and return-value (zerop return-value))
38 (parameter-error "setuid failed: ~A" (unix:get-unix-error-msg errno)))))
40 (defun setgid (gid)
41 "Sets the effective group ID of the current process to GID -
42 see setgid\(2)."
43 (multiple-value-bind (return-value errno)
44 (unix:unix-setgid gid)
45 (unless (and return-value (zerop return-value))
46 (parameter-error "setgid failed: ~A" (unix:get-unix-error-msg errno)))))
48 (defun get-uid-from-name (name)
49 "Returns the UID for the user named NAME."
50 (unix:user-info-uid (unix:unix-getpwnam name)))
52 (defun get-gid-from-name (name)
53 "Returns the GID for the group named NAME."
54 (unix:group-info-gid (unix:unix-getgrnam name)))