src/dird/ua_cmds.c
bool do_a_command(UAContext *ua)
{
   int i;
   int len;
   bool ok = false;
   bool found = false;

   Dmsg1(900, "Command: %s\n", ua->argk[0]);
   if (ua->argc == 0) {
      return false;
   }

   if (ua->jcr->wstorage) {
      while (ua->jcr->wstorage->size()) {
         ua->jcr->wstorage->remove(0);
      }
   }

   len = strlen(ua->argk[0]);
   for (i=0; i<comsize; i++) {     /* search for command */
      if (strncasecmp(ua->argk[0],  commands[i].key, len) == 0) {
         ua->cmd_index = i;
         /* Check if command permitted, but "quit" is always OK */
         if (strcmp(ua->argk[0], NT_("quit")) != 0 &&
             !acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
            break;
         }
         /* Check if this command is authorized in RunScript */
         if (ua->runscript && !commands[i].use_in_rs) {
            ua->error_msg(_("Can't use %s command in a runscript"), ua->argk[0]);
            break;
         }
         if (ua->api) ua->signal(BNET_CMD_BEGIN);
         ok = (*commands[i].func)(ua, ua->cmd);   /* go execute command */
         if (ua->api) ua->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED);
         found = ua->UA_sock && ua->UA_sock->is_stop() ? false : true;
         break;
      }
   }
   if (!found) {
      ua->error_msg(_("%s: is an invalid command.\n"), ua->argk[0]);
      ok = false;
   }
   return ok;
}
/*
 * Execute a command from the UA
 */
Execute a command from the UA
Execute a command from the UA
bool do_a_command(UAContext *ua)
{
   int i;
   int len;
   bool ok = false;
   bool found = false;
   Dmsg1(900, "Command: %s\n", ua->argk[0]);
   if (ua->argc == 0) {
      return false;
   }
   if (ua->jcr->wstorage) {
      while (ua->jcr->wstorage->size()) {
         ua->jcr->wstorage->remove(0);
      }
   }
   len = strlen(ua->argk[0]);
   for (i=0; i<comsize; i++) {     
      if (strncasecmp(ua->argk[0],  commands[i].key, len) == 0) {
         ua->cmd_index = i;
         if (strcmp(ua->argk[0], NT_("quit")) != 0 &&
             !acl_access_ok(ua, Command_ACL, ua->argk[0], len)) {
            break;
         }
         if (ua->runscript && !commands[i].use_in_rs) {
            ua->error_msg(_("Can't use %s command in a runscript"), ua->argk[0]);
            break;
         }
         if (ua->api) ua->signal(BNET_CMD_BEGIN);
         ok = (*commands[i].func)(ua, ua->cmd);   
         if (ua->api) ua->signal(ok?BNET_CMD_OK:BNET_CMD_FAILED);
         found = ua->UA_sock && ua->UA_sock->is_stop() ? false : true;
         break;
      }
   }
   if (!found) {
      ua->error_msg(_("%s: is an invalid command.\n"), ua->argk[0]);
      ok = false;
   }
   return ok;
}
bool do_a_command ( UAContext * ua ) { int i ; int len ; bool ok = false ; bool found = false ; Dmsg1 ( 900 , " \n " , ua -> argk [ 0 ] ) ; if ( ua -> argc == 0 ) { return false ; } if ( ua -> jcr -> wstorage ) { while ( ua -> jcr -> wstorage -> size ( ) ) { ua -> jcr -> wstorage -> remove ( 0 ) ; } } len = strlen ( ua -> argk [ 0 ] ) ; for ( i = 0 ; i < comsize ; i ++ ) { if ( strncasecmp ( ua -> argk [ 0 ] , commands [ i ] . key , len ) == 0 ) { ua -> cmd_index = i ; if ( strcmp ( ua -> argk [ 0 ] , NT_ ( " " ) ) != 0 && ! acl_access_ok ( ua , Command_ACL , ua -> argk [ 0 ] , len ) ) { break ; } if ( ua -> runscript && ! commands [ i ] . use_in_rs ) { ua -> error_msg ( _ ( " " ) , ua -> argk [ 0 ] ) ; break ; } if ( ua -> api ) ua -> signal ( BNET_CMD_BEGIN ) ; ok = ( * commands [ i ] . func ) ( ua , ua -> cmd ) ; if ( ua -> api ) ua -> signal ( ok ? BNET_CMD_OK : BNET_CMD_FAILED ) ; found = ua -> UA_sock && ua -> UA_sock -> is_stop ( ) ? false : true ; break ; } } if ( ! found ) { ua -> error_msg ( _ ( " \n " ) , ua -> argk [ 0 ] ) ; ok = false ; } return ok ; }
Execute a command from the UA
Execute a command from the UA
/* search for command */ /* Check if command permitted, but "quit" is always OK */ /* Check if this command is authorized in RunScript */ /* go execute command */