Loading...
Searching...
No Matches
XrdSecProtocolpwd.cc File Reference
`#include <unistd.h>`
`#include <cctype>`
`#include <cerrno>`
`#include <cstdlib>`
`#include <strings.h>`
`#include <cstdio>`
`#include <sys/param.h>`
`#include <pwd.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <fcntl.h>`
`#include <sys/times.h>`
`#include "XrdVersion.hh"`
`#include "XrdSys/XrdSysHeaders.hh"`
`#include "XrdSys/XrdSysLogger.hh"`
`#include "XrdSys/XrdSysError.hh"`
`#include "XrdSys/XrdSysPwd.hh"`
`#include "XrdOuc/XrdOucStream.hh"`
`#include "XrdSys/XrdSysPriv.hh"`
`#include "XrdSut/XrdSutPFCache.hh"`
`#include "XrdSecpwd/XrdSecProtocolpwd.hh"`
`#include "XrdSecpwd/XrdSecpwdPlatform.hh"`
Include dependency graph for XrdSecProtocolpwd.cc:

Go to the source code of this file.

## Macros

#define | POPTS(t, y)

## Functions

static const char * | ClientStepStr (int kclt)
static const char * | ServerStepStr (int ksrv)
char * | XrdSecProtocolpwdInit (const char mode, const char *parms, XrdOucErrInfo *erp)
XrdSecProtocol * | XrdSecProtocolpwdObject (const char mode, const char *hostname, XrdNetAddrInfo &endPoint, const char *parms, XrdOucErrInfo *erp)
| XrdVERSIONINFO (XrdSecProtocolpwdInit, secpwd)
| XrdVERSIONINFO (XrdSecProtocolpwdObject, secpwd)

## Variables

static String | AdminRef = ProtoID + "admin"
static const char * | gPWErrStr []
static const int | kOneDay = 86400
static const short | kOptsAFSPwd = 0x0800
static const short | kOptsAregAll = 0x0008
static const short | kOptsAutoReg = 0x0004
static const short | kOptsChngPwd = 0x0400
static const short | kOptsClntTty = 0x0080
static const short | kOptsCrypPwd = 0x0200
static const short | kOptsExpCred = 0x0100
static const short | kOptsServer = 0x0001
static const short | kOptsUserPwd = 0x0002
static const short | kOptsVeriClt = 0x0040
static const short | kOptsVeriSrv = 0x0020
static String | NetRcRef = ProtoID + "netrc"
static String | Prefix = "xrd"
static String | ProtoID = XrdSecPROTOIDENT
static const char * | pwdClientSteps []
static const char * | pwdServerSteps []
XrdOucTrace * | pwdTrace = 0
static String | SrvPukRef = ProtoID + "srvpuk"
static String | UserRef = ProtoID + "user"
static const kXR_int32 | Version = XrdSecpwdVERSION

## Macro Definition Documentation

## POPTS

#define POPTS | ( |  | t,
|  |  | y )

Value:
{if (t) {t->Beg(epname); std::cerr <<y; t->End();}}

Definition at line 61 of file XrdSecProtocolpwd.cc.

## Function Documentation

## ClientStepStr()

const char * ClientStepStr | ( | int | kclt | ) |

static

Definition at line 215 of file XrdSecProtocolpwd.cc.

{
// Return string with client step
static const char *ukn = "Unknown";
kclt = (kclt < 0) ? 0 : kclt;
kclt = (kclt > kXPC_reserved) ? 0 : kclt;
kclt = (kclt >= kXPC_normal) ? (kclt - kXPC_normal + 1) : kclt;
if (kclt < 0 || kclt > (kXPC_reserved - kXPC_normal + 1))
return ukn;
else
return pwdClientSteps[kclt];
}
pwdClientSteps
static const char * pwdClientSteps[]
Definition XrdSecProtocolpwd.cc:78
kXPC_reserved
@ kXPC_reserved
Definition XrdSecProtocolpwd.hh:133
kXPC_normal
@ kXPC_normal
Definition XrdSecProtocolpwd.hh:127

References kXPC_normal, kXPC_reserved, and pwdClientSteps.

## ServerStepStr()

const char * ServerStepStr | ( | int | ksrv | ) |

static

Definition at line 231 of file XrdSecProtocolpwd.cc.

{
// Return string with server step
static const char *ukn = "Unknown";
ksrv = (ksrv < 0) ? 0 : ksrv;
ksrv = (ksrv > kXPS_reserved) ? 0 : ksrv;
ksrv = (ksrv >= kXPS_init) ? (ksrv - kXPS_init + 1) : ksrv;
if (ksrv < 0 || ksrv > (kXPS_reserved - kXPS_init + 1))
return ukn;
else
return pwdServerSteps[ksrv];
}
pwdServerSteps
static const char * pwdServerSteps[]
Definition XrdSecProtocolpwd.cc:89
kXPS_reserved
@ kXPS_reserved
Definition XrdSecProtocolpwd.hh:146
kXPS_init
@ kXPS_init
Definition XrdSecProtocolpwd.hh:139

References kXPS_init, kXPS_reserved, and pwdServerSteps.

## XrdSecProtocolpwdInit()

char * XrdSecProtocolpwdInit | ( | const char | mode,
|  | const char * | parms,
|  | XrdOucErrInfo * | erp )

Definition at line 1677 of file XrdSecProtocolpwd.cc.

{
// One-time protocol initialization, filling the static flags and options
// of the protocol.
// For clients (mode == 'c') we use values in envs.
// For servers (mode == 's') the command line options are passed through
// parms.
EPNAME("ProtocolpwdInit");
pwdOptions opts;
char *rc = (char *)"";
char *cenv = 0;
// Initiate error logging and tracing
pwdTrace = XrdSecProtocolpwd::EnableTracing();
//
// Clients first
if (mode == 'c') {
//
// Decode envs:
// "XrdSecDEBUG" debug flag ("0","1","2","3")
// "XrdSecPWDVERIFYSRV" "1" server verification ON [default]
// "0" server verification OFF
// "XrdSecPWDSRVPUK" full path to file with server puks
// [default: $HOME/.xrd/pwdsrvpuk]
// "XrdSecPWDAUTOLOG" "1" autologin ON [default]
// "0" autologin OFF
// "XrdSecPWDALOGFILE" full path to file with autologin
// info [default: $HOME/.xrd/pwdnetrc]
// "XrdSecPWDALOGUPDT" update autologin file option:
// "0" never [default]
// "1" remove_obsolete_info
// "2" "1" + register_new_valid_info
// "XrdSecPWDMAXPROMPT" max number of attemts to get valid
// input info by prompting the client
//
opts.mode = mode;
// debug
cenv = getenv("XrdSecDEBUG");
if (cenv)
{if (cenv[0] >= 49 && cenv[0] <= 51) opts.debug = atoi(cenv);
else {PRINT("unsupported debug value from env XrdSecDEBUG: "<<cenv<<" - setting to 1");
opts.debug = 1;
}
}
// server verification
cenv = getenv("XrdSecPWDVERIFYSRV");
if (cenv)
if (cenv[0] >= 48 && cenv[0] <= 49) opts.verisrv = atoi(cenv);
// file with server public keys
cenv = getenv("XrdSecPWDSRVPUK");
if (cenv)
opts.srvpuk = strdup(cenv);
// autologin
cenv = getenv("XrdSecPWDAUTOLOG");
if (cenv)
if (cenv[0] >= 48 && cenv[0] <= 50) opts.alog = atoi(cenv);
// autologin file
cenv = getenv("XrdSecPWDALOGFILE");
if (cenv)
opts.alogfile = strdup(cenv);
// max re-prompts
cenv = getenv("XrdSecPWDMAXPROMPT");
if (cenv) {
opts.maxprompts = strtol(cenv, (char **)0, 10);
if (errno == ERANGE) opts.maxprompts = -1;
}
//
// Setup the object with the chosen options
rc = XrdSecProtocolpwd::Init(opts,erp);
// Notify init options, if required or in case of init errors
if (!rc) opts.debug = 1;
opts.Print(pwdTrace);
// Some cleanup
if (opts.srvpuk) free(opts.srvpuk);
if (opts.alogfile) free(opts.alogfile);
// We are done
return rc;
}
// Take into account xrootd debug flag
cenv = getenv("XRDDEBUG");
if (cenv && !strcmp(cenv,"1")) opts.debug = 1;
//
// Server initialization
if (parms) {
//
// Duplicate the parms
char parmbuff[1024];
strlcpy(parmbuff, parms, sizeof(parmbuff));
//
// The tokenizer
XrdOucTokenizer inParms(parmbuff);
//
// Decode parms:
// for servers: [-upwd:<user_pwd_option>]
// [-a:<autoreg_level>]
// [-vc:<client_verification_level>]
// [-dir:<dir_with_pwd_info>]
// [-udir:<sub_dir_with_user_pwd_info>]
// [-c:[-]ssl[:[-]<CryptoModuleName]]
// [-d:<debug_level>]
// [-syspwd]
// [-lf:<credential_lifetime>]
// [-maxfail:<max_number_of_failures>]
// [-keepcreds]
// [-expcreds:<creds_file_name>]
// [-expfmt:<creds_exp_format>]
//
// <user_pwd_opt> = 0 (do-not-use), 1 (use), 2 (also-crypt-hash)
// <debug_level> = 0 (none), 1 (low), 2 (medium), 3 (high) [0]
// <autoreg_level> = 0 (none), 1 (local users + allowed tags), 2 (all) [0]
// <credential_lifetime> = 1d, 5h:10m, ... (see XrdSutAux::ParseTime)
// <client_verification_level> = 0 (none), 1 (timestamp), 2 (random tag) [2]
// <creds_file_name> = can be a fully specified path or in the templated form
// /path/<user>/file, with <user> expanded at the moment
// of use with the login name.
// <creds_exp_format> = 0 (XrdSutPFEntry in dedicated file),
// 1 (hex form), 2 (plain), 3 (plain, no keywords) [0]
//
int debug = -1;
int areg = -1;
int vc = -1;
int upw = -1;
int syspwd = -1;
int lifetime = -1;
int maxfail = -1;
String dir = "";
String udir = "";
String clist = "";
String cpass = "";
int keepcreds = -1;
String expcreds = "";
int expfmt = 0;
char *op = 0;
while (inParms.GetLine()) {
while ((op = inParms.GetToken())) {
if (!strncmp(op, "-upwd:",6)) {
upw = atoi(op+6);
} else if (!strncmp(op, "-dir:",5)) {
dir = (const char *)(op+5);
} else if (!strncmp(op, "-udir:",6)) {
udir = (const char *)(op+6);
} else if (!strncmp(op, "-c:",3)) {
clist = (const char *)(op+3);
} else if (!strncmp(op, "-d:",3)) {
debug = atoi(op+3);
} else if (!strncmp(op, "-a:",3)) {
areg = atoi(op+3);
} else if (!strncmp(op, "-vc:",4)) {
vc = atoi(op+4);
} else if (!strncmp(op, "-syspwd",7)) {
syspwd = 1;
} else if (!strncmp(op, "-lf:",4)) {
lifetime = XrdSutParseTime(op+4);
} else if (!strncmp(op, "-maxfail:",9)) {
maxfail = atoi(op+9);
} else if (!strncmp(op, "-cryptfile:",11)) {
cpass = (const char *)(op+11);
} else if (!strncmp(op, "-keepcreds",10)) {
keepcreds = 1;
} else if (!strncmp(op, "-expcreds:",10)) {
expcreds = (const char *)(op+10);
} else if (!strncmp(op, "-expfmt:",8)) {
expfmt = atoi(op+8);
}
}
// Check inputs
areg = (areg >= 0 && areg <= 2) ? areg : 0;
vc = (vc >= 0 && vc <= 2) ? vc : 2;
}
//
// Build the option object
opts.debug = (debug > -1) ? debug : opts.debug;
opts.mode = 's';
opts.areg = areg;
opts.vericlnt = vc;
opts.upwd = upw;
opts.syspwd = syspwd;
opts.lifecreds = lifetime;
opts.maxfailures = maxfail;
opts.expfmt = expfmt;
if (dir.length() > 0)
opts.dir = (char *)dir.c_str();
if (udir.length() > 0)
opts.udir = (char *)udir.c_str();
if (clist.length() > 0)
opts.clist = (char *)clist.c_str();
if (cpass.length() > 0)
opts.cpass = (char *)cpass.c_str();
opts.keepcreds = keepcreds;
if (expcreds.length() > 0)
opts.expcreds = (char *)expcreds.c_str();
// Notify init options, if required
opts.Print(pwdTrace);
//
// Setup the plug-in with the chosen options
return XrdSecProtocolpwd::Init(opts,erp);
}
// Notify init options, if required
opts.Print(pwdTrace);
//
// Setup the plug-in with the defaults
return XrdSecProtocolpwd::Init(opts,erp);
}}
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
PRINT
#define PRINT(y)
Definition XrdCryptosslTrace.hh:39
String
XrdOucString String
Definition XrdSecProtocolgsi.hh:62
pwdTrace
XrdOucTrace * pwdTrace
Definition XrdSecProtocolpwd.cc:209
opts
struct myOpts opts
XrdSutParseTime
int XrdSutParseTime(const char *tstr, int opt)
Definition XrdSutAux.cc:534
strlcpy
size_t strlcpy(char *dst, const char *src, size_t sz)
Definition XrdSysPlatform.cc:60
XrdOucString::length
int length() const
Definition XrdOucString.hh:279
XrdOucString::c_str
const char * c_str() const
Definition XrdOucString.hh:278
XrdOucTokenizer
Definition XrdOucTokenizer.hh:33
XrdSecProtocolpwd::Init
static char * Init(pwdOptions o, XrdOucErrInfo *erp)
Definition XrdSecProtocolpwd.cc:341
XrdSecProtocolpwd::EnableTracing
static XrdOucTrace * EnableTracing()
Definition XrdSecProtocolpwd.cc:1609
pwdOptions
Definition XrdSecProtocolpwd.hh:214

References XrdOucString::c_str(), XrdSecProtocolpwd::EnableTracing(), EPNAME, XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), XrdSecProtocolpwd::Init(), XrdOucString::length(), opts, PRINT, pwdTrace, strlcpy(), and XrdSutParseTime().

Referenced by XrdVERSIONINFO().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdSecProtocolpwdObject()

XrdSecProtocol * XrdSecProtocolpwdObject | ( | const char | mode,
|  | const char * | hostname,
|  | XrdNetAddrInfo & | endPoint,
|  | const char * | parms,
|  | XrdOucErrInfo * | erp )

Definition at line 1903 of file XrdSecProtocolpwd.cc.

{
XrdSecProtocolpwd *prot;
int options = XrdSecNOIPCHK;
//
// Get a new protocol object
if (!(prot = new XrdSecProtocolpwd(options, hostname, endPoint, parms))) {
const char *msg = "Secpwd: Insufficient memory for protocol.";
if (erp)
erp->setErrInfo(ENOMEM, msg);
else
std::cerr <<msg <<std::endl;
return (XrdSecProtocol *)0;
}
//
// We are done
if (!erp)
std::cerr << "protocol object instantiated" << std::endl;
return prot;
}}
XrdSecNOIPCHK
#define XrdSecNOIPCHK
Definition XrdSecProtocolgsi.hh:68
XrdOucErrInfo::setErrInfo
int setErrInfo(int code, const char *emsg)
Definition XrdOucErrInfo.hh:147
XrdSecProtocol
Definition XrdSecInterface.hh:131
XrdSecProtocolpwd
Definition XrdSecProtocolpwd.hh:286

References XrdOucErrInfo::setErrInfo(), and XrdSecNOIPCHK.

Referenced by XrdVERSIONINFO().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdVERSIONINFO() [1/2]

XrdVERSIONINFO | ( | XrdSecProtocolpwdInit | ,
|  | secpwd | )

References XrdSecProtocolpwdInit().

Here is the call graph for this function:

## XrdVERSIONINFO() [2/2]

XrdVERSIONINFO | ( | XrdSecProtocolpwdObject | ,
|  | secpwd | )

References XrdSecProtocolpwdObject().

Here is the call graph for this function:

## Variable Documentation

## AdminRef

String AdminRef = ProtoID + "admin"

static

Definition at line 73 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Init(), and ParseArguments().

## gPWErrStr

const char* gPWErrStr[]

static

Definition at line 101 of file XrdSecProtocolpwd.cc.

{
"parsing buffer", // 10000
"decoding buffer", // 10001
"loading crypto factory", // 10002
"protocol mismatch", // 10003
"resolving user / host", // 10004
"user missing", // 10005
"host missing", // 10006
"unknown user", // 10007
"creating bucket", // 10008
"duplicating bucket", // 10009
"creating buffer", // 10010
"serializing buffer", // 10011
"generating cipher", // 10012
"exporting public key", // 10013
"encrypting random tag", // 10014
"random tag mismatch", // 10015
"random tag missing", // 10016
"cipher missing", // 10017
"getting credentials", // 10018
"credentials missing", // 10019
"wrong password for user", // 10020
"checking cache", // 10021
"cache entry for link missing", // 10022
"session handshaking ID missing", // 10023
"session handshaking ID mismatch", // 10024
"unknown step option", // 10025
"marshaling integer", // 10026
"unmarshaling integer", // 10027
"saving new credentials", // 10028
"salt missing", // 10029
"buffer empty", // 10030
"obtaining reference cipher", // 10031
"obtaining cipher public info", // 10032
"adding bucket to list", // 10033
"finalizing cipher from public info", // 10034
"error during initialization", // 10035
"wrong credentials", // 10035
"error" // 10036
};

## kOneDay

const int kOneDay = 86400

static

Definition at line 155 of file XrdSecProtocolpwd.cc.

## kOptsAFSPwd

const short kOptsAFSPwd = 0x0800

static

Definition at line 153 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Authenticate().

## kOptsAregAll

const short kOptsAregAll = 0x0008

static

Definition at line 146 of file XrdSecProtocolpwd.cc.

## kOptsAutoReg

const short kOptsAutoReg = 0x0004

static

Definition at line 145 of file XrdSecProtocolpwd.cc.

## kOptsChngPwd

const short kOptsChngPwd = 0x0400

static

Definition at line 152 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Authenticate(), and XrdSecProtocolpwd::getCredentials().

## kOptsClntTty

const short kOptsClntTty = 0x0080

static

Definition at line 149 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Authenticate(), and XrdSecProtocolpwd::getCredentials().

## kOptsCrypPwd

const short kOptsCrypPwd = 0x0200

static

Definition at line 151 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Authenticate().

## kOptsExpCred

const short kOptsExpCred = 0x0100

static

Definition at line 150 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Authenticate().

## kOptsServer

const short kOptsServer = 0x0001

static

Definition at line 143 of file XrdSecProtocolpwd.cc.

## kOptsUserPwd

const short kOptsUserPwd = 0x0002

static

Definition at line 144 of file XrdSecProtocolpwd.cc.

## kOptsVeriClt

const short kOptsVeriClt = 0x0040

static

Definition at line 148 of file XrdSecProtocolpwd.cc.

## kOptsVeriSrv

const short kOptsVeriSrv = 0x0020

static

Definition at line 147 of file XrdSecProtocolpwd.cc.

## NetRcRef

String NetRcRef = ProtoID + "netrc"

static

Definition at line 76 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Init(), and ParseArguments().

## Prefix

String Prefix = "xrd"

static

Definition at line 70 of file XrdSecProtocolpwd.cc.

## ProtoID

String ProtoID = XrdSecPROTOIDENT

static

Definition at line 71 of file XrdSecProtocolpwd.cc.

## pwdClientSteps

const char* pwdClientSteps[]

static

Initial value:
= {
"kXPC_none",
"kXPC_normal",
"kXPC_verifysrv",
"kXPC_signedrtag",
"kXPC_creds",
"kXPC_autoreg",
"kXPC_failureack",
"kXPC_reserved"
}

Definition at line 78 of file XrdSecProtocolpwd.cc.

{
"kXPC_none",
"kXPC_normal",
"kXPC_verifysrv",
"kXPC_signedrtag",
"kXPC_creds",
"kXPC_autoreg",
"kXPC_failureack",
"kXPC_reserved"
};

Referenced by ClientStepStr().

## pwdServerSteps

const char* pwdServerSteps[]

static

Initial value:
= {
"kXPS_none",
"kXPS_init",
"kXPS_credsreq",
"kXPS_rtag",
"kXPS_signedrtag",
"kXPS_newpuk",
"kXPS_puk",
"kXPS_failure",
"kXPS_reserved"
}

Definition at line 89 of file XrdSecProtocolpwd.cc.

{
"kXPS_none",
"kXPS_init",
"kXPS_credsreq",
"kXPS_rtag",
"kXPS_signedrtag",
"kXPS_newpuk",
"kXPS_puk",
"kXPS_failure",
"kXPS_reserved"
};

Referenced by ServerStepStr().

## pwdTrace

XrdOucTrace* pwdTrace = 0

Definition at line 209 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Init(), and XrdSecProtocolpwdInit().

## SrvPukRef

String SrvPukRef = ProtoID + "srvpuk"

static

Definition at line 74 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Init(), and ParseArguments().

## UserRef

String UserRef = ProtoID + "user"

static

Definition at line 75 of file XrdSecProtocolpwd.cc.

Referenced by XrdSecProtocolpwd::Init(), and ParseArguments().

## Version

const kXR_int32 Version = XrdSecpwdVERSION

static

Definition at line 72 of file XrdSecProtocolpwd.cc.