WvStreams
|
00001 /* 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Manages a UniConf daemon session which is authenticated through PAM. 00006 */ 00007 #include "uniconfpamconn.h" 00008 #include "unisecuregen.h" 00009 #include "unipermgen.h" 00010 #include "uniunwrapgen.h" 00011 #include "uniconfdaemonconn.h" 00012 #include "uninullgen.h" 00013 #include "wvpam.h" 00014 #include "wvaddr.h" 00015 00016 UniConfPamConn::UniConfPamConn(WvStream *_s, const UniConf &_root, 00017 UniPermGen *perms) 00018 : WvStreamClone(NULL) 00019 { 00020 WvPam pam("uniconfd"); 00021 WvString rhost(*(WvIPAddr *)_s->src()); 00022 if (pam.authenticate(rhost, "", WvString::null)) 00023 { 00024 UniSecureGen *sec = new UniSecureGen(new UniUnwrapGen(_root), perms); 00025 00026 // get the user and groups from PAM 00027 WvString user = pam.getuser(); 00028 WvStringList groups; 00029 pam.getgroups(groups); 00030 00031 sec->setcredentials(user, groups); 00032 newroot.mountgen(sec, false); 00033 setclone(new UniConfDaemonConn(_s, newroot)); 00034 } 00035 else 00036 { 00037 _s->print("FAIL {Not Authorized}\n"); 00038 _s->flush_then_close(1000); 00039 } 00040 }