root/trunk/bknr/datastore/src/utils/smbpasswd.lisp

Revision 2521, 1.6 kB (checked in by ksprotte, 11 months ago)

#+cmu removed :use :ext from defpackages bknr.utils and bknr.indices
as this does not seem to be needed and causes a symbol conflict

  • Property svn:eol-style set to native
  • Property svn:keywords set to author date id revision
Line 
1 (in-package :bknr.utils)
2
3 (defvar +smb-wrapper-program+ "/usr/local/bin/smbpasswd-wrapper")
4
5 (define-condition smb-password-error ()
6   ((message :initarg :message :accessor smb-password-error-message)))
7
8 (defmethod print-object ((error smb-password-error) stream)
9   (format stream "#<~a ~a>"
10           (class-name (class-of error))
11           (smb-password-error-message error))
12   error)
13
14 (defun set-smb-password (username password &key (create t))
15   (unless (and username password)
16     (error (make-condition 'smb-password-error :message "please specify both username and password")))
17   (let ((args (list username password)))
18     (when create
19       (push "-a" args))
20     (push "smbpasswd" args)
21     (with-output-to-string (stream)
22       #+allegro
23       (excl:run-shell-command (apply #'concatenate
24                                 'string
25                                 +smb-wrapper-program+
26                                 args)
27                          :output stream :error-output stream)
28       #+cmu
29       (let ((process
30              (ext:run-program +smb-wrapper-program+ args :output stream :error :output)))
31         (unwind-protect
32              (unless (zerop (ext:process-exit-code process))
33                (error (make-condition 'smb-password-error :message (get-output-stream-string stream))))
34           (ext:process-close process)))
35       #+openmcl
36       (ccl::run-program +smb-wrapper-program+
37                         args
38                         :output stream)
39       #+sbcl
40       (let ((process
41              (sb-ext:run-program +smb-wrapper-program+ args :output stream :error :output)))
42         (unwind-protect
43              (unless (zerop (process-exit-code process))
44                (error (make-condition 'smb-password-error :message (get-output-stream-string stream))))
45           (process-close process))))))
Note: See TracBrowser for help on using the browser.