* Jörgen Persson <[EMAIL PROTECTED]> [010320 09:27]:
> On Tue, Mar 20, 2001 at 06:26:35AM -0500, Peter Green wrote:
> [snip]
> > Sure, but the mycheckpasswd part is hanging me up. Specifically, writing to
> > the numbered FDs is hanging me up, and I didn't have a lot of time to figure
> > this out, so I was hoping something already existed.
> > 
> > If anyone could whip up the important bits (the IO redirection and the
> > execution string), I could easily figure out the rest. And I'd be extremely
> > grateful. :-)
> > 
> > Thanks,
> 
> Sorry for the delay but I'm at work... Well, here's some help with the 
> file descriptors, I tested the following successfully under bash-2.03.
> 
> # checkpassword echo $? 3< /tmp/dummypwd
> 0
> # od -c /tmp/dummypwd
> 0000000   d   u   m   m   y  \0   d   u   m   m   y   d   u   m   m   y
> 0000020  \0   9   8   5   0   9   3   2   3   9 004
> 
> Check out http://cr.yp.to/checkpwd/interface.html

Thanks for the help, Jörgen! However, it wasn't the format of the string
checkpassword (and friends) expects; it's the IO. For example, let's say I
wanted to do this in bash2. I might do, simply:

  #!/bin/bash2

  # check vmailmgr first; save the environment
  # /tmp/scr just executes /usr/bin/id
  ENVIRON = $(/usr/bin/checkvpw /tmp/scr Maildir/)
  rc=$?
  if [ $rc -ne 0 ]; then
          # failed; try vpopmail
          ENVIRON = $(/usr/local/vpopmail/bin/vchkpw /tmp/scr Maildir/)
          rc=$?
          if [ $rc -ne 0 ]; then
                  # failed all
                  echo "-ERR Authorization failed"
                  exit $rc
          else
                  export $ENVIRON
                  exec qmail-pop3d "$@"
          fi
  else
          export $ENVIRON
          exec qmail-pop3d "$MAILDIR"
  fi

It mostly works, since all child processes inherit FD 3 properly. However,
if the first method fails, it cannot try the second method, since FD 3 has
already hit EOF; how can I rewind this from bash? Also, if it succeeds, the
exec line simply does not work; the error is always ``-ERR this user has no
$HOME/Maildir''. I have double-checked the environment with
``env>>/tmp/debug'' after the export call, and home get set properly.

This is simply out of my league, I think. Any additional thoughts before I
throw in the towel? Would this be useful for other situations?

Thanks for the continued help!

/pg
-- 
Peter Green : Gospel Communications Network, SysAdmin : [EMAIL PROTECTED]
---
If Bill Gates is the Devil then Linus Torvalds must be the Messiah.
(Unknown source)

Reply via email to