[racket] Too Many Redirects (Apache)

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Sep 16 15:38:00 EDT 2011

An hour ago, John Clements wrote:
> 
> On Sep 16, 2011, at 11:03 AM, Jay McCarthy wrote:
> 
> > I think you can use ffi-lib with #f because it is already attached.
> 
> Yeah, okay, looks like this works:
> 
> #lang racket
> 
> (require ffi/unsafe)
> 
> ;; return type is "gid_t". Safe to use int?
> (define setuid
>   (get-ffi-obj "setuid" (ffi-lib #f)
>                (_fun _int -> _int)))
> 
> (setuid 0)

But since you want to demote to a known username rather than a uid,
this is useful too:

  (define-cstruct _passwd
    ([name   _string]
     [passwd _string]
     [uid    _int]
     [gid    _int]
     [gecos  _string]
     [dir    _string]
     [shell  _string]))
  
  (define getpwnam
    (get-ffi-obj 'getpwnam (ffi-lib #f) (_fun _string -> _passwd-pointer)))
  
  (passwd-uid (getpwnam "eli"))


-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.