WvStreams
uniconfpamconn.cc
1 /*
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * Manages a UniConf daemon session which is authenticated through PAM.
6  */
7 #include "uniconfpamconn.h"
8 #include "unisecuregen.h"
9 #include "unipermgen.h"
10 #include "uniunwrapgen.h"
11 #include "uniconfdaemonconn.h"
12 #include "uninullgen.h"
13 #include "wvpam.h"
14 #include "wvaddr.h"
15 
16 UniConfPamConn::UniConfPamConn(WvStream *_s, const UniConf &_root,
17  UniPermGen *perms)
18  : WvStreamClone(NULL)
19 {
20  WvPam pam("uniconfd");
21  WvString rhost(*(WvIPAddr *)_s->src());
22  if (pam.authenticate(rhost, "", WvString::null))
23  {
24  UniSecureGen *sec = new UniSecureGen(new UniUnwrapGen(_root), perms);
25 
26  // get the user and groups from PAM
27  WvString user = pam.getuser();
28  WvStringList groups;
29  pam.getgroups(groups);
30 
31  sec->setcredentials(user, groups);
32  newroot.mountgen(sec, false);
33  setclone(new UniConfDaemonConn(_s, newroot));
34  }
35  else
36  {
37  _s->print("FAIL {Not Authorized}\n");
38  _s->flush_then_close(1000);
39  }
40 }
WvStream::flush_then_close
void flush_then_close(int msec_timeout)
flush the output buffer automatically as select() is called.
Definition: wvstream.cc:827
UniConfDaemonConn
Retains all state and behavior related to a single UniConf daemon connection.
Definition: uniconfdaemonconn.h:25
UniConf
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
Definition: uniconf.h:50
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
UniPermGen
UniPermGen wraps a tree encoding Unix-style permissions, and provides an API for setting and checking...
Definition: unipermgen.h:26
WvStreamClone
WvStreamClone simply forwards all requests to the "cloned" stream.
Definition: wvstreamclone.h:23
UniSecureGen
UniSecureGen wraps a given generator and checks permissions (using a Unix-style scheme) before respon...
Definition: unisecuregen.h:32
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
UniUnwrapGen
Deprecated: a UniConfGen that delegates all requests to an inner UniConf.
Definition: uniunwrapgen.h:33
WvIPAddr
An IP address is made up of a "dotted quad" – four decimal numbers in the form www....
Definition: wvaddr.h:249
WvPam
Definition: wvpam.h:21
WvStream::src
virtual const WvAddr * src() const
get the remote address from which the last data block was received.
Definition: wvstream.cc:1124
WvStringList
This is a WvList of WvStrings, and is a really handy way to parse strings.
Definition: wvstringlist.h:27