Changeset 5146:716400712348 in roaraudio


Ignore:
Timestamp:
10/15/11 12:48:07 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Moved error frame handling into proto functions (pr0)

Files:
15 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5145 r5146  
    99          message to client converter code (pr0) 
    1010        * Updated error handling (pr0) 
     11        * Moved error frame handling into proto functions (pr0) 
    1112 
    1213v. 0.4rc0 - Mon Sep 05 2011 15:25 CEST 
  • doc/man1/roard.1

    r4860 r5146  
    140140.TP 
    141141\fB--guest-acclev\fR 
    142 Sets the access level for guest connections. 
     142Sets the access level for guest connections. Set to "none" to disable guest access. 
    143143 
    144144.TP 
    145145\fB--trust-acclev\fR 
    146146Sets the access level for clients authenticated by trust auth. 
     147Set to "none" to disable trust auth. 
    147148 
    148149.TP 
  • include/libroar/basic.h

    r5114 r5146  
    103103int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data); 
    104104int roar_req          (struct roar_connection * con, struct roar_message * mes, char ** data); 
     105int roar_recv_message2 (struct roar_connection * con, struct roar_message * mes, char ** data, 
     106                        struct roar_error_frame * errorframe); 
     107int roar_req2          (struct roar_connection * con, struct roar_message * mes, char ** data, 
     108                        struct roar_error_frame * errorframe); 
     109#define roar_req3(con,mes,data) roar_req2((con), (mes), (data), roar_err_errorframe()) 
    105110 
    106111int roar_vsend_message(struct roar_vio_calls  * vio, struct roar_message * mes, char *  data); 
    107112int roar_vrecv_message(struct roar_vio_calls  * vio, struct roar_message * mes, char ** data); 
    108113int roar_vreq         (struct roar_vio_calls  * vio, struct roar_message * mes, char ** data); 
     114int roar_vrecv_message2(struct roar_vio_calls  * vio, struct roar_message * mes, char ** data, 
     115                        struct roar_error_frame * errorframe); 
     116int roar_vreq2         (struct roar_vio_calls  * vio, struct roar_message * mes, char ** data, 
     117                        struct roar_error_frame * errorframe); 
    109118 
    110119int roar_debug_message_print    (struct roar_message * mes) _LIBROAR_ATTR_DEPRECATED; 
  • include/libroar/error.h

    r5109 r5146  
    6767}; 
    6868 
     69struct roar_error_frame * roar_err_errorframe(void); 
     70 
    6971int    roar_err_int(struct roar_error_frame * frame); 
     72int    roar_err_init(struct roar_error_frame * frame); 
     73void * roar_err_buildmsg2(struct roar_message * mes, void ** data, struct roar_error_frame * frame); 
     74int    roar_err_parsemsg2(struct roar_message * mes, void *  data, struct roar_error_frame * frame); 
    7075void * roar_err_buildmsg(struct roar_message * mes, struct roar_error_frame * frame); 
    7176int    roar_err_parsemsg(struct roar_message * mes, struct roar_error_frame * frame); 
  • libroar/asyncctl.c

    r4708 r5146  
    7676 m.datalen = len_have; 
    7777 
    78  if ( roar_req(con, &m, NULL) != 0 ) 
     78 if ( roar_req3(con, &m, NULL) != 0 ) 
    7979  return -1; 
    8080 
  • libroar/auth.c

    r5144 r5146  
    135135 char                  * data = NULL; 
    136136 
     137 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 
     138 
     139 roar_err_init(&error_frame); 
    137140 memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy! 
    138141 
     
    162165 } 
    163166 
    164  if ( (ret = roar_req(con, &mes, &data)) == -1 ) { 
     167 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 
     168 
     169 if ( (ret = roar_req2(con, &mes, &data, &error_frame)) == -1 ) { 
    165170  authmes->type = -1; 
    166   return -1; 
    167  } 
     171  ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = -1 // next: -1", con, authmes, authmes->type); 
     172  return -1; 
     173 } 
     174 
     175 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): mes->cmd=%i", con, authmes, authmes->type, mes.cmd); 
    168176 
    169177 if ( data != NULL ) { 
     
    173181 } 
    174182 
    175  if ( mes.cmd != ROAR_CMD_OK ) { 
    176   if ( data != NULL ) { 
    177    // we currently do not support long error frames. 
    178    free(data); 
    179    return -1; 
    180   } 
    181  
     183 if ( mes.cmd == ROAR_CMD_ERROR ) 
    182184  ret = -1; 
    183   if ( roar_err_parsemsg(&mes, &error_frame) == -1 ) { 
    184    authmes->type = -1; 
    185    return -1; 
    186   } 
    187  
     185 
     186 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): error_frame.data=%p", 
     187           con, authmes, authmes->type, error_frame.data); 
     188 
     189 if ( mes.cmd == ROAR_CMD_ERROR && error_frame.data != NULL ) { 
    188190  header = error_frame.data; 
    189191  mes.datalen = error_frame.datalen; 
    190192 } 
     193 
     194 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 
    191195 
    192196 if ( mes.datalen < 4 ) { 
     
    197201 } 
    198202 
     203 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = ?", con, authmes); 
     204 
    199205 authmes->stage         = header[1]; 
    200206 authmes->reserved.c[0] = header[2]; 
     
    204210  free(data); 
    205211 
     212 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = %i // next: %i", con, authmes, ret, authmes->type); 
    206213 return ret; 
    207214} 
     
    307314 for (i = 0; ltt[i] != _EOL; i++) { 
    308315  next = ltt[i]; 
     316  ROAR_DBG("roar_auth(con=%p): next from ltt: %s(%i)", con, roar_autht2str(next), next); 
     317 
    309318  while (next != -1) { 
    310319   done = 1; 
     
    312321   cur  = next; 
    313322   next = -1; 
     323 
     324   ROAR_DBG("roar_auth(con=%p): cur=%s(%i)", con, roar_autht2str(cur), cur); 
    314325 
    315326   switch (cur) { 
     
    322333    case ROAR_AUTH_T_RHOST: 
    323334    case ROAR_AUTH_T_NONE: 
    324       roar_auth_mes_init(&authmes, ltt[i]); 
     335      roar_auth_mes_init(&authmes, cur); 
    325336      if ( (ret = roar_auth_ask_server(con, &authmes)) == -1 ) 
    326337       done = 0; 
     
    341352    done = 0; 
    342353 
    343    if ( done ) 
     354   ROAR_DBG("roar_auth(con=%p): done=%i, next=%i", con, done, next); 
     355 
     356   if ( done ) { 
     357    ROAR_DBG("roar_auth(con=%p) = 0", con); 
    344358    return 0; 
     359   } 
    345360  } 
    346361 } 
    347362 
     363 ROAR_DBG("roar_auth(con=%p) = -1", con); 
    348364 return -1; 
    349365} 
     
    354370 char header[4] = {0, 0, 0, 0}; 
    355371 
    356  if ( ames == NULL || mes == NULL ) 
    357   return -1; 
     372 if ( ames == NULL || mes == NULL ) { 
     373  roar_err_set(ROAR_ERROR_FAULT); 
     374  return -1; 
     375 } 
    358376 
    359377 if ( data != NULL ) { 
     
    386404 char * obuf; 
    387405 
    388  if ( mes == NULL || ames == NULL ) 
    389   return -1; 
     406 if ( mes == NULL || ames == NULL ) { 
     407  roar_err_set(ROAR_ERROR_FAULT); 
     408  return -1; 
     409 } 
    390410 
    391411 if ( data != NULL ) 
  • libroar/basic.c

    r5144 r5146  
    389389 mes.stream = -1; 
    390390 
    391  return roar_req(con, &mes, NULL); 
     391 return roar_req3(con, &mes, NULL); 
    392392} 
    393393 
     
    432432 strncpy(mes.data+5, name, max_len); 
    433433 
    434  return roar_req(con, &mes, NULL); 
     434 return roar_req3(con, &mes, NULL); 
    435435} 
    436436 
  • libroar/beep.c

    r5145 r5146  
    6363 } 
    6464 
    65  if ( roar_req(con, &m, NULL) != 0 ) 
     65 if ( roar_req3(con, &m, NULL) != 0 ) 
    6666  return -1; 
    6767 
  • libroar/error.c

    r5097 r5146  
    4545int roar_errno = ROAR_ERROR_NONE; 
    4646 
     47struct roar_error_frame * roar_err_errorframe(void) { 
     48 static struct roar_error_frame frame = { 
     49  .version     =  0, 
     50  .cmd         = -1, 
     51  .ra_errno    = ROAR_ERROR_UNKNOWN, 
     52  .ra_suberrno = -1, 
     53  .p_errno     = -1, 
     54  .flags       =  0, 
     55  .datalen     =  0, 
     56  .data        = NULL 
     57 }; 
     58 
     59 return &frame; 
     60} 
     61 
    4762int    roar_err_int(struct roar_error_frame * frame) { 
    48  if ( frame == NULL ) 
     63 roar_debug_warn_obsolete("roar_err_int", "roar_err_init", NULL); 
     64 return roar_err_init(frame); 
     65} 
     66int    roar_err_init(struct roar_error_frame * frame) { 
     67 if ( frame == NULL ) { 
     68  roar_err_set(ROAR_ERROR_FAULT); 
    4969  return -1; 
     70 } 
    5071 
    5172 memset(frame, 0, sizeof(struct roar_error_frame)); 
    5273 
    5374 frame->cmd         = -1; 
    54  frame->ra_errno    = -1; 
     75 frame->ra_errno    = ROAR_ERROR_UNKNOWN; 
    5576 frame->ra_suberrno = -1; 
    5677 frame->p_errno     = -1; 
     78 frame->datalen     =  0; 
     79 frame->data        = NULL; 
    5780 
    5881 return 0; 
    5982} 
    6083 
     84 
    6185void * roar_err_buildmsg(struct roar_message * mes, struct roar_error_frame * frame) { 
     86 roar_debug_warn_obsolete("roar_err_buildmsg", "roar_err_buildmsg2", NULL); 
     87 return roar_err_buildmsg2(mes, NULL, frame); 
     88} 
     89void * roar_err_buildmsg2(struct roar_message * mes, void ** data, struct roar_error_frame * frame) { 
     90 char * databuf = NULL; 
    6291 int16_t * d; 
    63  
    64  if ( mes == NULL || frame == NULL ) 
     92 size_t datalen; 
     93 
     94 if ( mes == NULL || frame == NULL ) { 
     95  roar_err_set(ROAR_ERROR_FAULT); 
    6596  return NULL; 
     97 } 
     98 
     99 if ( data != NULL ) 
     100  *data = NULL; 
     101 
     102 datalen = 8 + frame->datalen; 
     103 if ( datalen > LIBROAR_BUFFER_MSGDATA ) { 
     104  if ( data == NULL ) { 
     105   roar_err_set(ROAR_ERROR_FAULT); 
     106   return NULL; 
     107  } 
     108 
     109  roar_err_clear_errno(); 
     110  *data = malloc(datalen); 
     111  roar_err_from_errno(); 
     112  if ( *data == NULL ) 
     113   return NULL; 
     114 
     115  databuf = *data; 
     116 } else { 
     117  databuf = mes->data; 
     118 } 
    66119 
    67120 memset(mes,  0, sizeof(struct roar_message)); 
    68  
    69  d = (int16_t*)mes->data; 
    70  
    71  mes->datalen = 8 + frame->datalen; 
    72  frame->data  = &(mes->data[8]); 
    73  
    74  mes->data[0]    = 0; // version. 
    75  mes->data[1]    = frame->cmd; 
    76  mes->data[2]    = frame->ra_errno; 
    77  mes->data[3]    = frame->ra_suberrno; 
     121 memset(databuf, 0, mes->datalen); 
     122 
     123 mes->datalen = datalen; 
     124 
     125 d = (int16_t*)databuf; 
     126 
     127 frame->data  = &(databuf[8]); 
     128 
     129 databuf[0]    = 0; // version. 
     130 databuf[1]    = frame->cmd; 
     131 databuf[2]    = frame->ra_errno; 
     132 databuf[3]    = frame->ra_suberrno; 
    78133 d[2]            = ROAR_HOST2NET16(frame->p_errno); 
    79134 d[3]            = ROAR_HOST2NET16(frame->flags); 
     
    83138 
    84139int    roar_err_parsemsg(struct roar_message * mes, struct roar_error_frame * frame) { 
     140 roar_debug_warn_obsolete("roar_err_parsemsg", "roar_err_parsemsg", NULL); 
     141 return roar_err_parsemsg2(mes, NULL, frame); 
     142} 
     143int    roar_err_parsemsg2(struct roar_message * mes, void *  data, struct roar_error_frame * frame) { 
     144 char * databuf = (char *)data; 
    85145 int16_t * d; 
    86146 
    87  if ( mes == NULL || frame == NULL ) 
     147 ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?", 
     148          mes, (int)mes->datalen, mes->data, data, frame); 
     149 
     150 if ( mes == NULL || frame == NULL ) { 
     151  roar_err_set(ROAR_ERROR_FAULT); 
     152  ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = -1 // error=FAULT", 
     153           mes, (int)mes->datalen, mes->data, data, frame); 
    88154  return -1; 
    89  
    90  d = (int16_t*)mes->data; 
    91  
    92  if ( mes->datalen < 8 ) 
     155 } 
     156 
     157 ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?", 
     158          mes, (int)mes->datalen, mes->data, data, frame); 
     159 
     160 if ( databuf == NULL ) 
     161  databuf = mes->data; 
     162 
     163 d = (int16_t*)databuf; 
     164 
     165 ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?", 
     166          mes, (int)mes->datalen, mes->data, data, frame); 
     167 
     168 if ( mes->datalen < 8 ) { 
     169  roar_err_set(ROAR_ERROR_MSGSIZE); 
     170  ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = -1 // error=MSGSIZE", 
     171           mes, (int)mes->datalen, mes->data, data, frame); 
    93172  return -1; 
    94  
    95  if ( mes->data[0] != 0 ) 
     173 } 
     174 
     175 ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?", 
     176          mes, (int)mes->datalen, mes->data, data, frame); 
     177 
     178 if ( databuf[0] != 0 ) { 
     179  roar_err_set(ROAR_ERROR_NSVERSION); 
     180  ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = -1 // error=NSVERSION", 
     181           mes, (int)mes->datalen, mes->data, data, frame); 
    96182  return -1; 
    97  
    98  frame->cmd         = mes->data[1]; 
    99  frame->ra_errno    = mes->data[2]; 
    100  frame->ra_suberrno = mes->data[3]; 
     183 } 
     184 
     185 ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = ?", 
     186          mes, (int)mes->datalen, mes->data, data, frame); 
     187 
     188 frame->cmd         = databuf[1]; 
     189 frame->ra_errno    = databuf[2]; 
     190 frame->ra_suberrno = databuf[3]; 
    101191 frame->p_errno     = ROAR_NET2HOST16(d[2]); 
    102192 frame->flags       = ROAR_NET2HOST16(d[3]); 
    103193 
    104194 frame->datalen     = mes->datalen - 8; 
    105  frame->data        = &(mes->data[8]); 
    106  
     195 frame->data        = &(databuf[8]); 
     196 
     197 ROAR_DBG("roar_err_parsemsg2(mes=%p{.datalen=%i, .data=%p}, data=%p, frame=%p) = 0", 
     198          mes, (int)mes->datalen, mes->data, data, frame); 
    107199 return 0; 
    108200} 
     
    128220 int * err = roar_errno2(); 
    129221 
    130  // NOTE: _NEVER_ call ROAR_{DBG,INFO,WARN,ERRO}() in here! (will result in endless loop) 
     222 // NOTE: _NEVER_ call ROAR_{DBG,INFO,WARN,ERROR}() in here! (will result in endless loop) 
    131223 //printf("*err=%i, errno=%i\n", *err, (int)errno); 
    132224 
  • libroar/proto.c

    r5030 r5146  
    134134 
    135135int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) { 
     136 return roar_recv_message2(con, mes, data, NULL); 
     137} 
     138int roar_recv_message2 (struct roar_connection * con, struct roar_message * mes, char ** data, 
     139                        struct roar_error_frame * errorframe) { 
    136140 struct roar_vio_calls * vio; 
    137141 
     
    139143  return -1; 
    140144 
    141  return roar_vrecv_message(vio, mes, data); 
     145 return roar_vrecv_message2(vio, mes, data, errorframe); 
    142146} 
    143147 
    144148int roar_vrecv_message(struct roar_vio_calls * vio, struct roar_message * mes, char ** data) { 
     149 return roar_vrecv_message2(vio, mes, data, NULL); 
     150} 
     151 
     152int roar_vrecv_message2(struct roar_vio_calls  * vio, struct roar_message * mes, char ** data, 
     153                        struct roar_error_frame * errorframe) { 
    145154 // TODO: add CRC support. 
    146155 char buf[_ROAR_MESS_BUF_LEN_MAX]; 
     
    153162 roar_err_set(ROAR_ERROR_UNKNOWN); 
    154163 
    155  ROAR_DBG("roar_recv_message(*): try to get a response form the server..."); 
    156  
    157  if ( mes == NULL ) 
    158   return -1; 
     164 ROAR_DBG("roar_vrecv_message2(vio=%p, mes=%p, data=%p, errorframe=%p) = ?", vio, mes, data, errorframe); 
     165 
     166 ROAR_DBG("roar_vrecv_message2(*): try to get a response form the server..."); 
     167 
     168 if ( vio == NULL || mes == NULL ) { 
     169  roar_err_set(ROAR_ERROR_FAULT); 
     170  return -1; 
     171 } 
    159172 
    160173 if ( data != NULL ) 
     
    168181 } 
    169182 
    170  ROAR_DBG("roar_recv_message(*): Got a header"); 
     183 ROAR_DBG("roar_vrecv_message2(*): Got a header"); 
    171184 
    172185 mes->version = buf[0]; 
     
    224237  mes->stream = -1; 
    225238 
    226  ROAR_DBG("roar_recv_message(*): command=%i(%s)", mes->cmd, 
     239 ROAR_DBG("roar_vrecv_message2(*): command=%i(%s)", mes->cmd, 
    227240           mes->cmd == ROAR_CMD_OK ? "OK" : (mes->cmd == ROAR_CMD_ERROR ? "ERROR" : "UNKNOWN")); 
    228241 
     
    230243 
    231244 if ( mes->datalen == 0 ) { 
    232   ROAR_DBG("roar_recv_message(*): no data in this pkg"); 
    233   ROAR_DBG("roar_recv_message(*) = 0"); 
     245  ROAR_DBG("roar_vrecv_message2(*): no data in this pkg"); 
     246  if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 
     247   roar_err_init(errorframe); 
     248  } 
    234249  roar_err_clear(); 
     250  ROAR_DBG("roar_vrecv_message2(*) = 0"); 
    235251  return 0; 
    236252 } 
     
    238254 if ( mes->datalen <= LIBROAR_BUFFER_MSGDATA ) { 
    239255  if ( roar_vio_read(vio, mes->data, mes->datalen) == mes->datalen ) { 
    240    ROAR_DBG("roar_recv_message(*): Got data!"); 
    241    ROAR_DBG("roar_recv_message(*) = 0"); 
     256   ROAR_DBG("roar_vrecv_message2(*): Got data!"); 
    242257   roar_err_clear(); 
     258   if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 
     259    if ( roar_err_parsemsg2(mes, *data, errorframe) != 0 ) { 
     260     roar_err_init(errorframe); 
     261    } 
     262   } 
     263   ROAR_DBG("roar_vrecv_message2(*) = 0"); 
    243264   return 0; 
    244265  } 
     
    258279  if ( mes->datalen == 0 ) { 
    259280   roar_err_clear(); 
     281   if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 
     282    roar_err_init(errorframe); 
     283   } 
    260284   return 0; 
    261285  } 
    262286 
    263287  if ( roar_vio_read(vio, *data, mes->datalen) == mes->datalen ) { 
    264    ROAR_DBG("roar_recv_message(*): Got data!"); 
    265    ROAR_DBG("roar_recv_message(*) = 0"); 
     288   ROAR_DBG("roar_vrecv_message2(*): Got data!"); 
     289 
    266290   roar_err_clear(); 
     291   if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 
     292    if ( roar_err_parsemsg2(mes, *data, errorframe) != 0 ) { 
     293     roar_err_init(errorframe); 
     294    } 
     295   } 
     296   ROAR_DBG("roar_vrecv_message2(*) = 0"); 
    267297   return 0; 
    268298  } 
     
    277307 
    278308int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) { 
     309 return roar_req2(con, mes, data, NULL); 
     310} 
     311 
     312int roar_req2          (struct roar_connection * con, struct roar_message * mes, char ** data, 
     313                        struct roar_error_frame * errorframe) { 
    279314 struct roar_vio_calls * vio; 
    280315 
     
    282317  return -1; 
    283318 
    284  return roar_vreq(vio, mes, data); 
     319 return roar_vreq2(vio, mes, data, errorframe); 
    285320} 
    286321 
    287322int roar_vreq         (struct roar_vio_calls * vio, struct roar_message * mes, char ** data) { 
     323 return roar_vreq2(vio, mes, data, NULL); 
     324} 
     325 
     326int roar_vreq2         (struct roar_vio_calls  * vio, struct roar_message * mes, char ** data, 
     327                        struct roar_error_frame * errorframe) { 
    288328 if ( roar_vsend_message(vio, mes, data != NULL ? *data : NULL) != 0 ) 
    289329  return -1; 
     
    294334 roar_vio_sync(vio); // we need to do this becasue of ssl/compressed links 
    295335 
    296  return roar_vrecv_message(vio, mes, data); 
     336 return roar_vrecv_message2(vio, mes, data, errorframe); 
    297337} 
    298338 
  • roard/auth.c

    r4745 r5146  
    127127 for (i = 0; i < AUTH_KEYRING_LEN; i++) { 
    128128  if ( (key = &(g_auth_keyring[i]))->type == authmes->type ) { 
    129     ret = -1; 
     129   ROAR_DBG("auth_client_ckeck(cs=%p, authmes=%p, next=%p{%i}): key=%p{.type=%i, ...}", cs, authmes, next, *next, key, key->type); 
     130   ret = -1; 
    130131   switch (key->type) { 
    131132    case ROAR_AUTH_T_NONE: 
  • roard/clients.c

    r4947 r5146  
    10281028   return _g_acclevs[i].acclev; 
    10291029 
    1030  return -1; 
     1030 return ACCLEV_ERROR; 
    10311031} 
    10321032 
  • roard/include/client.h

    r4708 r5146  
    4949// access level: 
    5050enum roard_client_acclev { 
    51  ACCLEV_NONE     = 0, // only very basic commands like NOOP and IDENTIFY 
    52  ACCLEV_IDENTED,      // same as NONE but INDENTIFY worked. 
    53  ACCLEV_CONCTL,       // only allowed to do basic connection things. 
    54  ACCLEV_GUEST,        // guest connection (read only) 
    55  ACCLEV_USER,         // normal user connect (read write) 
    56  ACCLEV_PWRUSER,      // power user, may access other user's clients 
    57  ACCLEV_ALL           // full (admin) access (read write ctl) 
     51 ACCLEV_ERROR    = -1, // used as erorr return value. 
     52 ACCLEV_NONE     =  0, // only very basic commands like NOOP and IDENTIFY 
     53 ACCLEV_IDENTED,       // same as NONE but INDENTIFY worked. 
     54 ACCLEV_CONCTL,        // only allowed to do basic connection things. 
     55 ACCLEV_GUEST,         // guest connection (read only) 
     56 ACCLEV_USER,          // normal user connect (read write) 
     57 ACCLEV_PWRUSER,       // power user, may access other user's clients 
     58 ACCLEV_ALL            // full (admin) access (read write ctl) 
    5859}; 
    5960 
  • roard/req.c

    r5065 r5146  
    141141                           client, roar_autht2str(authmes.type), authmes.type, (long long unsigned int)authmes.len); 
    142142 
     143 ROAR_DBG("req_on_auth(client=%i,...): CALL auth_client_ckeck(cs=%p, &authmes=%p, &next=%p)", client, cs, &authmes, &next); 
    143144 ret = auth_client_ckeck(cs, &authmes, &next); 
     145 ROAR_DBG("req_on_auth(client=%i,...): RET %i // next=%s(%i)", client, ret, roar_autht2str(next), next); 
    144146 
    145147 if ( ret != 1 ) { 
     148  ROAR_DBG("req_on_auth(client=%i,...) = ?", client); 
     149 
    146150  if ( next != -1 ) { 
     151   ROAR_DBG("req_on_auth(client=%i,...) = ?", client); 
    147152   memset(&authmes, 0, sizeof(authmes)); 
    148153 
     
    152157    return -1; 
    153158 
    154    if ( roar_err_int(&error_frame) == -1 ) 
    155     return -1; 
     159   ROAR_DBG("req_on_auth(client=%i,...) = ?", client); 
     160 
     161   if ( roar_err_init(&error_frame) == -1 ) 
     162    return -1; 
     163 
     164   ROAR_DBG("req_on_auth(client=%i,...) = ?", client); 
    156165 
    157166   error_frame.ra_errno = ROAR_ERROR_PERM; 
     
    159168 
    160169   error_data   = roar_err_buildmsg(mes, &error_frame); 
     170   ROAR_DBG("req_on_auth(client=%i,...): error_data=%p", client, error_data); 
    161171 
    162172   memcpy(error_data, error_mes.data, error_mes.datalen); 
     
    164174   mes->cmd     = ROAR_CMD_ERROR; 
    165175   mes->pos     = g_pos; 
     176 
     177   ROAR_DBG("req_on_auth(client=%i,...): mes=%p{.datalen=%i}", client, mes, (int)mes->datalen); 
     178   ROAR_DBG("req_on_auth(client=%i,...) = 0 // cmd=ERROR", client); 
    166179   return 0; 
    167180  } 
    168181 
     182  ROAR_DBG("req_on_auth(client=%i,...) = 0", client); 
    169183  return -1; 
    170184 } 
     
    173187 mes->pos     = g_pos; 
    174188 mes->datalen = 0; 
     189 
     190 ROAR_DBG("req_on_auth(client=%i,...) = 0", client); 
    175191 return 0; 
    176192} 
  • roard/roard.c

    r5103 r5146  
    217217 printf("\nAuth Options:\n\n"); 
    218218 printf( 
    219         " --guest-acclev ACCLEV - Sets the access level for guest access to ACCLEV\n" 
     219        " --guest-acclev ACCLEV - Sets the access level for guest access to ACCLEV,\n" 
     220        "                         Use \"none\" to disable guest access.\n" 
    220221        " --trust-acclev ACCLEV - Sets the access level for trust-authed\n" 
    221         "                         connections to ACCLEV\n" 
     222        "                         connections to ACCLEV. Use \"none\" to disable trust auth.\n" 
    222223        " --trust-root          - Trust root user\n" 
    223224        " --no-trust-root       - Don't trust root user\n" 
     
    16791680   _CKHAVEARGS(1); 
    16801681   none_acclev = clients_str2acclev(argv[++i]); 
     1682   if ( none_acclev == -1 ) { 
     1683    ROAR_ERR("Invalid access level: %s", argv[i]); 
     1684    return 1; 
     1685   } 
    16811686  } else if ( strcmp(k, "--trust-acclev") == 0 ) { 
    16821687   _CKHAVEARGS(1); 
    16831688   trust_acclev = clients_str2acclev(argv[++i]); 
     1689   if ( trust_acclev == -1 ) { 
     1690    ROAR_ERR("Invalid access level: %s", argv[i]); 
     1691    return 1; 
     1692   } 
    16841693  } else if ( strcmp(k, "--trust-root") == 0 ) { 
    16851694   trust_root = 1; 
Note: See TracChangeset for help on using the changeset viewer.