Example #1
0
 // TODO: remove this default implementation so that all Command subclasses have to explicitly
 // declare their own.
 void Command::addRequiredPrivileges(const std::string& dbname,
                                     const BSONObj& cmdObj,
                                     std::vector<Privilege>* out) {
     if (!requiresAuth()) {
         return;
     }
     ActionSet actions;
     actions.addAction(locktype() == WRITE ? ActionType::oldWrite : ActionType::oldRead);
     Privilege privilege(adminOnly() ? "admin" : dbname, actions);
     out->push_back(privilege);
 }
Example #2
0
bool CBUShm::Unlock(int offset, int len)
{
    unsigned int loff;
    unsigned int llen;
    if (offset<=0)
        loff = LOCK_POSITION;
    else
        loff = LOCK_POSITION+offset;
    if (len<=0)
    {
        loff = LOCK_POSITION;
        llen = MAX_FILELEN;
    }
    else
        llen = len;
    return(locktype(LT_UNLOCK,loff,llen));
}
Example #3
0
 void Command::htmlHelp(stringstream& ss) const {
     string helpStr;
     {
         stringstream h;
         help(h);
         helpStr = h.str();
     }
     ss << "\n<tr><td>";
     bool web = _webCommands->count(name) != 0;
     if( web ) ss << "<a href=\"/" << name << "?text=1\">";
     ss << name;
     if( web ) ss << "</a>";
     ss << "</td>\n";
     ss << "<td>";
     int l = locktype();
     //if( l == NONE ) ss << "N ";
     if( l == READ ) ss << "R ";
     else if( l == WRITE ) ss << "W ";
     if( slaveOk() )
         ss << "S ";
     if( adminOnly() )
         ss << "A";
     if( lockGlobally() ) 
         ss << " lockGlobally ";
     ss << "</td>";
     ss << "<td>";
     if( helpStr != "no help defined" ) {
         const char *p = helpStr.c_str();
         while( *p ) {
             if( *p == '<' ) {
                 ss << "&lt;";
                 p++; continue;
             }
             else if( *p == '{' )
                 ss << "<code>";
             else if( *p == '}' ) {
                 ss << "}</code>";
                 p++;
                 continue;
             }
             if( strncmp(p, "http:", 5) == 0 ) {
                 ss << "<a href=\"";
                 const char *q = p;
                 while( *q && *q != ' ' && *q != '\n' )
                     ss << *q++;
                 ss << "\">";
                 q = p;
                 if( startsWith(q, "http://www.mongodb.org/display/") )
                     q += 31;
                 while( *q && *q != ' ' && *q != '\n' ) {
                     ss << (*q == '+' ? ' ' : *q);
                     q++;
                     if( *q == '#' )
                         while( *q && *q != ' ' && *q != '\n' ) q++;
                 }
                 ss << "</a>";
                 p = q;
                 continue;
             }
             if( *p == '\n' ) ss << "<br>";
             else ss << *p;
             p++;
         }
     }
     ss << "</td>";
     ss << "</tr>\n";
 }