// Copyright 2007 (c) by Perforce Software, Inc. All rights reserved. // // p4wClientRootPane: // Simple class to capture the Root and AltRoots fields from a client. // ------------------------------------- // Includes // #include <p4wp4.h> #include <assert.h> #include "p4wStrBuf.h" #include "p4wHtml.h" #include "p4wPane.h" #include "p4wClientRootPane.h" // ------------------------------------- // Constructors and destructor. // p4wClientRootPane::p4wClientRootPane(p4wView & ParentView, p4wRequest & Request) : p4wPane(ParentView, Request) { fIsForm = 0; fIsLockedAway = 1; fInvalidClient = 0; } p4wClientRootPane::~p4wClientRootPane() { } // ------------------------------------- // Render functions. // void p4wClientRootPane::Begin() { } void p4wClientRootPane::Render(StrDict * varList) { // // Check the client values StrPtr * client = varList->GetVar("Client"); StrPtr * owner = varList->GetVar("Owner"); StrPtr * host = varList->GetVar("Host"); StrPtr * options = varList->GetVar("Options"); StrPtr * root = varList->GetVar("Root"); StrPtr * altroots = varList->GetVar("AltRoots0"); StrPtr * accessed = varList->GetVar("Access"); if (!accessed) accessed = varList->GetVar("Accessed"); StrPtr * updated = varList->GetVar("Update"); if (!updated) updated = varList->GetVar("Updated"); if (client) fClient.Set(client); if (owner) fOwner.Set(owner); if (host) fHost.Set(host); if (owner && !strcmp(owner->Text(), fRequest.GetUser().Text())) fIsLockedAway = 0; else if (options && strstr(options->Text(), "unlocked")) fIsLockedAway = 0; if (root) { if (fRequest.GetCmd() != AC_CLIENTSPROCESSOR) { StrPtr cwd = fRequest.GetCwd(); int lgth = fRequest.GetMasterRoot()->Length(); int ckmasterroot = (lgth && !fRequest.GetCr8NewClient() && accessed && updated) ? 1 : 0; if (ckmasterroot && fRequest.GetCmd() == AC_CLIENTCMD) ckmasterroot = 0; if (!SEC_ALLOW_CREATE_CLIENTS && !strcmp(cwd.Text(), root->Text())) { fRoot.Set("Invalid Root"); fIsLockedAway = fInvalidClient = 1; fErrorText << "<p>" << "You are not allowed to create new clients and<br>you may not use a client whose root is the same as P4Web's current working directory."; } else if (!SEC_ALLOW_NULL_ROOT && !root->CCompare(StrRef("null"))) { fRoot.Set("Invalid Root"); fIsLockedAway = fInvalidClient = 1; fErrorText << "<p>" << "You are not allowed to use a client whose root is null."; } else if (!SEC_ALLOW_DOTDOT_ROOT && strstr(root->Text(), "..")) { fRoot.Set("Invalid Root"); fIsLockedAway = fInvalidClient = 1; fErrorText << "<p>" << "You are not allowed to use a client whose root contains \"..\""; } else if (ckmasterroot #ifdef OS_NT && strnicmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgth)) #else && strncmp(root->Text(), fRequest.GetMasterRoot()->Text(), lgth)) #endif { fRoot.Set("Invalid Root"); fInvalidClient = 1; fErrorText << "<p>" << "You are only allowed to use a client whose root begins with "; fErrorText << fRequest.GetMasterRoot()->Text(); } else if (lgth && fRequest.GetCr8NewClient()) fRoot.Set(fRequest.GetMasterRoot()->Text()); else fRoot.Set(root); } else fRoot.Set(root); } if (altroots) { int i = 0; StrBuf var; StrNum nbr; do { if (i) fAltRoots << "\n"; // don't add \n after last one fAltRoots << altroots; var.Set("AltRoots"); nbr.Set(++i); var << nbr; } while (altroots = varList->GetVar(var)); } if (host) { StrPtr myhost = fRequest.GetHost(); if (strcmp(myhost.Text(), host->Text())) { fIsLockedAway = fInvalidClient = 1; fErrorText << "<p>" << "Client '" << fClient; fErrorText << "' can only be used on host machine '" << host->Text() << "'"; } } } void p4wClientRootPane::RenderInfo( char *data, char level ) { if (!strstr(data, "TRIGGER START") && !fRequest.bQuiet()) printf("%s\n", data); } void p4wClientRootPane::RenderError(char *data, int escapeHTML) { fErrorText << "<p>" << data; } void p4wClientRootPane::End() { }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
//guest/perforce_software/p4web/Panes/p4wClientRootPane.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |