void TraceSvcUtil::setAttachInfo(const string& service_name, const string& user, const string& role, const string& pwd, const AuthReader::AuthBlock& /*authBlock*/, bool isAdmin) { ISC_STATUS_ARRAY status = {0}; ClumpletWriter spb(ClumpletWriter::spbList, MAXBUF); if (user.hasData()) { spb.insertString(isc_spb_user_name, user); } if (pwd.hasData()) { spb.insertString(isc_spb_password, pwd); } if (role.hasData()) { spb.insertString(isc_spb_sql_role_name, role); } if (isAdmin) { spb.insertTag(isc_spb_trusted_auth); } if (isc_service_attach(status, 0, service_name.c_str(), &m_svcHandle, static_cast<USHORT>(spb.getBufferLength()), reinterpret_cast<const char*>(spb.getBuffer()))) { status_exception::raise(status); } }
void TraceSvcUtil::setAttachInfo(const string& service_name, const string& /*user*/, const string& /*pwd*/, bool isAdmin) { ISC_STATUS_ARRAY status = {0}; ClumpletWriter spb(ClumpletWriter::spbList, MAXBUF); if (isAdmin) { spb.insertTag(isc_spb_trusted_auth); } if (isc_service_attach(status, 0, service_name.c_str(), &m_svcHandle, static_cast<USHORT>(spb.getBufferLength()), reinterpret_cast<const char*>(spb.getBuffer()))) { status_exception::raise(status); } }
/** * This function provides the connect method for the ServiceManager class. * * @param self A reference to the ServiceManager object to be connected. * @param user A string containing the user that will be used for service * execution. * @param password A string containing the user password that will be used * for service execution. * * @return A reference to the newly connected ServiceManager object. * */ VALUE connectServiceManager(VALUE self, VALUE user, VALUE password) { ManagerHandle *manager = NULL; char *buffer = NULL, *position = NULL, *text = NULL, *service = NULL; short length = 2, size = 0; VALUE host = rb_iv_get(self, "@host"); ISC_STATUS status[ISC_STATUS_LENGTH]; Data_Get_Struct(self, ManagerHandle, manager); if(manager->handle != 0) { rb_fireruby_raise(NULL, "Service manager already connected."); } /* Calculate the size of the service parameter buffer. */ length += strlen(StringValuePtr(user)) + 2; length += strlen(StringValuePtr(password)) + 2; /* Create the service parameter buffer. */ position = buffer = ALLOC_N(char, length); if(position == NULL) { rb_raise(rb_eNoMemError, "Memory allocation failure creating service parameter buffer."); } memset(buffer, 0, length); /* Populate the service parameter buffer. */ *position++ = isc_spb_version; *position++ = isc_spb_current_version; text = StringValuePtr(user); size = strlen(text); *position++ = isc_spb_user_name; *position++ = size; strncpy(position, text, size); position += size; text = StringValuePtr(password); size = strlen(text); *position++ = isc_spb_password; *position++ = size; strncpy(position, text, size); /* Create the service name. */ size = strlen(StringValuePtr(host)) + 13; service = ALLOC_N(char, size); if(service == NULL) { free(buffer); rb_raise(rb_eNoMemError, "Memory allocation failure service manager service name."); } memset(service, 0, size); sprintf(service, "%s:service_mgr", StringValuePtr(host)); /* Make the attachment call. */ if(isc_service_attach(status, 0, service, &manager->handle, length, buffer)) { free(buffer); free(service); rb_fireruby_raise(status, "Error connecting service manager."); } /* Clean up. */ free(buffer); free(service); return(self); }
int CLIB_ROUTINE main( int argc, char **argv) { /************************************** * * m a i n * ************************************** * *Functional Description * This utility uses the Firebird service api to inform the server * to print out the memory pool information into a specified file. * This utilitiy is for WIN_NT only, In case of UNIX ibmgr utility will * should be used. * *************************************************************************/ char fname[512]; if (argc != 2 && argc != 1) { printf("Usage %s \n %s filename\n"); exit(1); } if (argc == 1) { printf(" Filename : "); if (!fgets(fname, sizeof(fname), stdin)) return 1; const size_t len = strlen(fname); if (!len) return 1; if (fname[len - 1] == '\n') { fname[len - 1] = 0; if (len == 1) return 1; } } else { fb_utils::copy_terminate(fname, argv[1], sizeof(fname)); if (!fname[0]) return 1; } printf("Filename to dump pool info = %s \n", fname); ISC_STATUS_ARRAY status; const char svc_name[] = "localhost:anonymous"; isc_svc_handle svc_handle = NULL; if (isc_service_attach(status, 0, svc_name, &svc_handle, 0, NULL)) { printf("Failed to attach service\n"); return 1; } const unsigned short path_length = strlen(fname); char sendbuf[520]; // 512 + tag + length_word char* sptr = sendbuf; *sptr = isc_info_svc_dump_pool_info; ++sptr; add_word(sptr, path_length); strcpy(sptr, fname); sptr += path_length; char respbuf[256]; if (isc_service_query(status, &svc_handle, NULL, 0, NULL, sptr - sendbuf, sendbuf, sizeof(respbuf), respbuf)) { printf("Failed to query service\n"); isc_service_detach(status, &svc_handle); return 1; } isc_service_detach(status, &svc_handle); return 0; }