/* verifier return value: -438: You should send a 438-reply. -437: You should send a 437-reply. -436: You should send a 436-reply. -428: You should send a 428-reply. -3: Error verifying Date header field. -2: Authentication service is not authoritative. -1: An error occured. 1: verification OK */ static int verifier_(struct sip_msg* msg, char* str1, char* str2) { char identityHF[MAX_IDENTITY] = "\0"; X509 * cert = NULL; int retval = -1; STACK_OF(X509) * certchain = NULL; /* parse all headers */ if (parse_headers(msg, HDR_EOH_F, 0)!=0) { LM_ERR("failed to parse headers\n"); return -1; } retval = getIdentityHF(identityHF, msg); switch(retval) { case 0: /* Identity header field does not exist */ return -428; case -1: LM_ERR("getIdentityHF failed\n"); return -1; } if(!getCert(&cert, &certchain, msg)) { return -436; } if(!validateCert(cert, certchain)) { X509_free(cert); sk_X509_pop_free(certchain, X509_free); return -437; } sk_X509_pop_free(certchain, X509_free); if(!checkAuthority(cert, msg)) { X509_free(cert); return -2; } if(!checkSign(cert, identityHF, msg)) { X509_free(cert); return -438; } if(!checkDate(cert, msg)) { X509_free(cert); return -3; } X509_free(cert); return 1; }
void removeFile(int index, char next[BUFFER_SIZE], int num, Client clients[CLIENT_SIZE], char* line) { index = nextToken(line, next, index); if (checkAuthority(next, num) == 1) { char fileName[BUFFER_SIZE] = ""; //;"__shared__"; strcpy(fileName, MY_PATH); strcat(fileName, next); unlink(fileName); removeFileFromClient(next, num); do_send("Deletion was successful!", clients[num].fd); } else { println("Unauthorized access or file not found"); do_send("Unauthorized access or file not found", clients[num].fd); } }
void renameFile(int index, char next[BUFFER_SIZE], int num, char recv_buf[BUFFER_SIZE], Client clients[CLIENT_SIZE], char* line) { index = nextToken(line, next, index); if (checkAuthority(next, num) == 1) { char fileName[BUFFER_SIZE] = ""; //"__shared__"; strcpy(fileName, MY_PATH); char newFileName[BUFFER_SIZE] = ""; //"__shared__"; strcpy(newFileName, MY_PATH); index = nextToken(line, recv_buf, index); strcat(fileName, next); strcat(newFileName, recv_buf); rename(fileName, newFileName); renameFileFromClient(next, recv_buf, num); do_send("Rename was successful!", clients[num].fd); } else { println("Unauthorized access or file not found"); do_send("Unauthorized access or file not found", clients[num].fd); } }