Changeset 34493 in project


Ignore:
Timestamp:
09/02/17 19:35:41 (3 weeks ago)
Author:
zbigniew
Message:

phricken 1.2: Add Kooda's patches for user/group switch and avoiding logfile seek

Location:
release/4/phricken/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/phricken/trunk/phricken.scm

    r22873 r34493  
    2424   logger logger-port client-ip extension-type-map
    2525   path->entry
     26   phricken-user phricken-group
    2627   ;; reexports from gopher
    2728   send-lastline send-line
     
    5455(define port (make-parameter 70))
    5556(define client-ip (make-parameter #f))   ; Read-only for users.
     57(define phricken-user (make-parameter #f))
     58(define phricken-group (make-parameter #f))
    5659
    5760;;; Records
     
    7881;; Default logger implementation logs a formatted message to (logger-port),
    7982;; or skips logging if the port is #f.  No locking is performed.
    80 ;; Seeking to end is performed prior to writing, but it is recommended
    81 ;; the port be opened in #:append mode.
     83;; Does not seek to end before writing; always open the port in
     84;; #:append mode to do this.
    8285;; It is legal for REQ to be #f if a request has not yet been created.
    8386;; TYPE can be any symbol; current types are 'connect, 'access,
     
    9194             (ip (or (client-ip) '-))
    9295             (p (logger-port)))
    93          (set! (file-position p 0) seek/end)
    9496         (fprintf p         ; thread ID might be nice.
    9597                  "~A ~A:~A ~A ~A ~S ~A\n"
     
    371373                   ((logger) 'error req "Invalid selector"))))))
    372374
     375(define (switch-user/group user group)
     376  (when group    ; group first, since only superuser can switch groups
     377    (let ((ginfo (group-information group)))
     378      (unless ginfo
     379        (error "Group does not exist" group))
     380      (set! (current-group-id) (list-ref ginfo 2))))
     381  (when user
     382    (let ((uinfo (user-information user)))
     383      (unless uinfo
     384        (error "User does not exist" user))
     385      (setenv "HOME" (list-ref uinfo 5))
     386      (initialize-groups user (list-ref uinfo 3))
     387      (unless group                 ; Already changed to target group?
     388        (set! (current-group-id) (list-ref uinfo 3)))
     389      (set! (current-user-id) (list-ref uinfo 2)))))
     390
    373391;;; Start/stop server
    374392
     
    386404                  ((logger) 'connect #f)
    387405                  (gopher:accept handle-request)))))))
     406      (switch-user/group (phricken-user) (phricken-group))
    388407      (parameterize ((tcp-buffer-size 16384))
    389408        (if bg
  • release/4/phricken/trunk/phricken.setup

    r22873 r34493  
    55  'phricken
    66  '("phricken.so" "phricken.import.so")
    7   `((version "1.1")
     7  `((version "1.2")
    88    (documentation "phricken.html")))
Note: See TracChangeset for help on using the changeset viewer.