bool server_id_same_process(const struct server_id *p1,
const struct server_id *p2);
bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
-char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id);
struct server_id server_id_from_string(uint32_t local_vnn,
const char *pid_string);
return dst->buf;
}
-char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id)
-{
- struct server_id_buf tmp;
- char *result;
-
- result = talloc_strdup(mem_ctx, server_id_str_buf(*id, &tmp));
- if (result == NULL) {
- return NULL;
- }
-
- /*
- * beautify the talloc_report output
- */
- talloc_set_name_const(result, result);
- return result;
-}
-
struct server_id server_id_from_string(uint32_t local_vnn,
const char *pid_string)
{
/*
* We accept various forms with 1, 2 or 3 component forms
- * because the server_id_str() can print different forms, and
+ * because the server_id_str_buf() can print different forms, and
* we want backwards compatibility for scripts that may call
* smbclient.
*/
static void print_lock_struct(unsigned int i, const struct lock_struct *pls)
{
+ struct server_id_buf tmp;
+
DEBUG(10,("[%u]: smblctx = %llu, tid = %u, pid = %s, ",
i,
(unsigned long long)pls->context.smblctx,
(unsigned int)pls->context.tid,
- server_id_str(talloc_tos(), &pls->context.pid) ));
+ server_id_str_buf(pls->context.pid, &tmp) ));
DEBUG(10, ("start = %ju, size = %ju, fnum = %ju, %s %s\n",
(uintmax_t)pls->start,
struct lock_context *ctx = &lock[n].context;
if (!server_id_is_disconnected(&ctx->pid)) {
+ struct server_id_buf tmp;
DEBUG(5, ("brl_cleanup_disconnected: byte range lock "
"%s used by server %s, do not cleanup\n",
file_id_string(frame, &fid),
- server_id_str(frame, &ctx->pid)));
+ server_id_str_buf(ctx->pid, &tmp)));
goto done;
}
struct share_mode_entry *entry = &data->share_modes[n];
if (!server_id_is_disconnected(&entry->pid)) {
+ struct server_id_buf tmp;
DEBUG(5, ("share_mode_cleanup_disconnected: "
"file (file-id='%s', servicepath='%s', "
"base_name='%s%s%s') "
? "" : "', stream_name='",
(data->stream_name == NULL)
? "" : data->stream_name,
- server_id_str(frame, &entry->pid)));
+ server_id_str_buf(entry->pid, &tmp)));
goto done;
}
if (open_persistent_id != entry->share_file_id) {
uint16_t break_from;
uint16_t break_to;
bool break_needed = true;
+ struct server_id_buf tmp;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
break_to = msg.op_type;
DEBUG(10, ("Got oplock break to %u message from pid %s: %s/%llu\n",
- (unsigned)break_to, server_id_str(talloc_tos(), &src),
+ (unsigned)break_to, server_id_str_buf(src, &tmp),
file_id_string_tos(&msg.id),
(unsigned long long)msg.share_file_id));
struct smbd_server_connection *sconn =
talloc_get_type_abort(private_data,
struct smbd_server_connection);
+ struct server_id_buf tmp;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
file_id = (unsigned long)IVAL(data->data, 24);
DEBUG(10, ("Got kernel oplock break message from pid %s: %s/%u\n",
- server_id_str(talloc_tos(), &src), file_id_string_tos(&id),
+ server_id_str_buf(src, &tmp), file_id_string_tos(&id),
(unsigned int)file_id));
fsp = initial_break_processing(sconn, id, file_id);
static int smbd_scavenger_main(struct smbd_scavenger_state *state)
{
+ struct server_id_buf tmp1, tmp2;
+
DEBUG(10, ("scavenger: %s started, parent: %s\n",
- server_id_str(talloc_tos(), state->scavenger_id),
- server_id_str(talloc_tos(), &state->parent_id)));
+ server_id_str_buf(*state->scavenger_id, &tmp1),
+ server_id_str_buf(state->parent_id, &tmp2)));
while (true) {
TALLOC_CTX *frame = talloc_stackframe();
}
DEBUG(10, ("scavenger: %s event loop iteration\n",
- server_id_str(talloc_tos(), state->scavenger_id)));
+ server_id_str_buf(*state->scavenger_id, &tmp1)));
TALLOC_FREE(frame);
}
{
struct smbd_scavenger_state *state = talloc_get_type_abort(
private_data, struct smbd_scavenger_state);
+ struct server_id_buf tmp;
DEBUG(2, ("scavenger: %s died\n",
- server_id_str(talloc_tos(), state->scavenger_id)));
+ server_id_str_buf(*state->scavenger_id, &tmp)));
TALLOC_FREE(state->scavenger_id);
}
{
struct smbd_scavenger_state *state = talloc_get_type_abort(
private_data, struct smbd_scavenger_state);
+ struct server_id_buf tmp1, tmp2;
DEBUG(2, ("scavenger: %s parent %s died\n",
- server_id_str(talloc_tos(), state->scavenger_id),
- server_id_str(talloc_tos(), &state->parent_id)));
+ server_id_str_buf(*state->scavenger_id, &tmp1),
+ server_id_str_buf(state->parent_id, &tmp2)));
exit_server("smbd_scavenger_parent_dead");
}
const uint8_t *msg = (const uint8_t *)&self;
size_t remaining = sizeof(self);
size_t ofs = 0;
+ struct server_id_buf tmp;
while (remaining > 0) {
ssize_t ret;
}
DEBUG(4, ("scavenger_say_hello: self[%s]\n",
- server_id_str(talloc_tos(), &self)));
+ server_id_str_buf(self, &tmp)));
return true;
}
uint8_t *msg = (uint8_t *)child;
size_t remaining = sizeof(*child);
size_t ofs = 0;
+ struct server_id_buf tmp;
while (remaining > 0) {
ssize_t ret;
}
DEBUG(4, ("scavenger_say_hello: child[%s]\n",
- server_id_str(talloc_tos(), child)));
+ server_id_str_buf(*child, &tmp)));
return true;
}
SMB_ASSERT(server_id_equal(&state->parent_id, &self));
if (smbd_scavenger_running(state)) {
+ struct server_id_buf tmp;
DEBUG(10, ("scavenger %s already running\n",
- server_id_str(talloc_tos(),
- state->scavenger_id)));
+ server_id_str_buf(*state->scavenger_id,
+ &tmp)));
return true;
}
if (state->scavenger_id != NULL) {
+ struct server_id_buf tmp;
DEBUG(10, ("scavenger zombie %s, cleaning up\n",
- server_id_str(talloc_tos(),
- state->scavenger_id)));
+ server_id_str_buf(*state->scavenger_id,
+ &tmp)));
TALLOC_FREE(state->scavenger_id);
}
TALLOC_CTX *frame = talloc_stackframe();
struct server_id self = messaging_server_id(msg_ctx);
struct scavenger_message *msg = NULL;
+ struct server_id_buf tmp1, tmp2;
DEBUG(10, ("smbd_scavenger_msg: %s got message from %s\n",
- server_id_str(talloc_tos(), &self),
- server_id_str(talloc_tos(), &src)));
+ server_id_str_buf(self, &tmp1),
+ server_id_str_buf(src, &tmp2)));
if (server_id_equal(&state->parent_id, &self)) {
NTSTATUS status;
uint64_t timeout_usec;
struct scavenger_message msg;
DATA_BLOB msg_blob;
+ struct server_id_buf tmp;
if (fsp->op == NULL) {
return;
DEBUG(10, ("smbd: %s mark file %s as disconnected at %s with timeout "
"at %s in %fs\n",
- server_id_str(talloc_tos(), &self),
+ server_id_str_buf(self, &tmp),
file_id_string_tos(&fsp->file_id),
timeval_string(talloc_tos(), &disconnect_time, true),
timeval_string(talloc_tos(), &until, true),
MSG_SMB_SCAVENGER,
&msg_blob);
if (!NT_STATUS_IS_OK(status)) {
+ struct server_id_buf tmp1, tmp2;
DEBUG(2, ("Failed to send message to parent smbd %s "
"from %s: %s\n",
- server_id_str(talloc_tos(),
- &smbd_scavenger_state->parent_id),
- server_id_str(talloc_tos(), &self),
+ server_id_str_buf(smbd_scavenger_state->parent_id,
+ &tmp1),
+ server_id_str_buf(self, &tmp2),
nt_errstr(status)));
}
}
struct server_id self_pid = messaging_server_id(state->msg_ctx);
struct server_id pid = session->channels[0].server_id;
const char *addr = session->channels[0].remote_address;
+ struct server_id_buf tmp;
DEBUG(10, ("shutdown_other_smbds: %s, %s\n",
- server_id_str(talloc_tos(), &pid), addr));
+ server_id_str_buf(pid, &tmp), addr));
if (!process_exists(pid)) {
DEBUG(10, ("process does not exist\n"));
exists = serverid_exists(&global->server_id);
}
if (!exists) {
+ struct server_id_buf idbuf;
DEBUG(2,("smbXsrv_open_global_verify_record: "
"key '%s' server_id %s does not exist.\n",
hex_encode_talloc(frame, key.dptr, key.dsize),
- server_id_str(frame, &global->server_id)));
+ server_id_str_buf(global->server_id, &idbuf)));
if (CHECK_DEBUGLVL(2)) {
NDR_PRINT_DEBUG(smbXsrv_open_globalB, &global_blob);
}
op->durable_timeout_msec / 1000,
delete_open ? "" : " not"));
} else if (!serverid_exists(&op->server_id)) {
+ struct server_id_buf idbuf;
DEBUG(10, ("smbXsrv_open_cleanup[global: 0x%08x] "
"server[%s] does not exist\n",
- global_id, server_id_str(frame, &op->server_id)));
+ global_id,
+ server_id_str_buf(op->server_id, &idbuf)));
delete_open = true;
}
exists = serverid_exists(&global->channels[0].server_id);
if (!exists) {
+ struct server_id_buf idbuf;
DEBUG(2,("smbXsrv_session_global_verify_record: "
"key '%s' server_id %s does not exist.\n",
hex_encode_talloc(frame, key.dptr, key.dsize),
- server_id_str(frame, &global->channels[0].server_id)));
+ server_id_str_buf(global->channels[0].server_id,
+ &idbuf)));
if (DEBUGLVL(2)) {
NDR_PRINT_DEBUG(smbXsrv_session_globalB, &global_blob);
}
exists = serverid_exists(&global->server_id);
if (!exists) {
+ struct server_id_buf idbuf;
DEBUG(2,("smbXsrv_tcon_global_verify_record: "
"key '%s' server_id %s does not exist.\n",
hex_encode_talloc(frame, key.dptr, key.dsize),
- server_id_str(frame, &global->server_id)));
+ server_id_str_buf(global->server_id, &idbuf)));
if (DEBUGLVL(2)) {
NDR_PRINT_DEBUG(smbXsrv_tcon_globalB, &global_blob);
}
dump_data_file(key.dptr, key.dsize, false, stdout);
for (i=0; i<num_watchers; i++) {
- char *str = server_id_str(talloc_tos(), &watchers[i]);
- printf("%s\n", str);
- TALLOC_FREE(str);
+ struct server_id_buf idbuf;
+ printf("%s\n", server_id_str_buf(watchers[i], &idbuf));
}
printf("\n");
return 0;
static int net_g_lock_dump_fn(struct server_id pid, enum g_lock_type lock_type,
void *private_data)
{
- char *pidstr;
-
- pidstr = server_id_str(talloc_tos(), &pid);
- d_printf("%s: %s\n", pidstr,
+ struct server_id_buf idbuf;
+ d_printf("%s: %s\n", server_id_str_buf(pid, &idbuf),
(lock_type & 1) ? "WRITE" : "READ");
- TALLOC_FREE(pidstr);
return 0;
}
static int net_serverid_list_fn(const struct server_id *id,
uint32_t msg_flags, void *priv)
{
- char *str = server_id_str(talloc_tos(), id);
- d_printf("%s %llu 0x%x\n", str, (unsigned long long)id->unique_id,
+ struct server_id_buf idbuf;
+ d_printf("%s %llu 0x%x\n", server_id_str_buf(*id, &idbuf),
+ (unsigned long long)id->unique_id,
(unsigned int)msg_flags);
- TALLOC_FREE(str);
return 0;
}
}
status = dbwrap_record_delete(rec);
if (!NT_STATUS_IS_OK(status)) {
- char *str = server_id_str(talloc_tos(), id);
+ struct server_id_buf idbuf;
DEBUG(1, ("Could not delete serverid.tdb record %s: %s\n",
- str, nt_errstr(status)));
- TALLOC_FREE(str);
+ server_id_str_buf(*id, &idbuf), nt_errstr(status)));
}
return 0;
}
ret = *(struct wipedbs_server_data**) val.dptr;
TALLOC_FREE(val.dptr);
} else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+ struct server_id_buf idbuf;
+
+ server_id_str_buf(*id, &idbuf);
+
ret = talloc_zero(state->id2server_data,
struct wipedbs_server_data);
if (ret == NULL) {
DEBUG(0, ("Failed to allocate server entry for %s\n",
- server_id_str(talloc_tos(), id)));
+ idbuf.buf));
goto done;
}
ret->server_id = *id;
- ret->server_id_str = server_id_str(ret, id);
+ ret->server_id_str = talloc_strdup(ret, idbuf.buf);
ret->exists = true;
val = make_tdb_data((const void*)&ret, sizeof(ret));
status = dbwrap_store(state->id2server_data,
key, val, TDB_INSERT);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to store server entry for %s: %s\n",
- server_id_str(talloc_tos(), id),
- nt_errstr(status)));
+ idbuf.buf, nt_errstr(status)));
}
goto done;
} else {
+ struct server_id_buf idbuf;
DEBUG(0, ("Failed to fetch server entry for %s: %s\n",
- server_id_str(talloc_tos(), id), nt_errstr(status)));
+ server_id_str_buf(*id, &idbuf), nt_errstr(status)));
goto done;
}
if (!server_id_equal(id, &ret->server_id)) {
+ struct server_id_buf idbuf1, idbuf2;
DEBUG(0, ("uniq id collision for %s and %s\n",
- server_id_str(talloc_tos(), id),
- server_id_str(talloc_tos(), &ret->server_id)));
+ server_id_str_buf(*id, &idbuf1),
+ server_id_str_buf(ret->server_id, &idbuf2)));
smb_panic("server_id->unique_id not unique!");
}
done:
for (i=0; i<num_entries; i++) {
struct notify_db_entry *e = &entries[i];
- char *str;
+ struct server_id_buf idbuf;
- str = server_id_str(talloc_tos(), &e->server);
- printf("%s %x %x\n", str, (unsigned)e->filter,
+ printf("%s %x %x\n", server_id_str_buf(e->server, &idbuf),
+ (unsigned)e->filter,
(unsigned)e->subdir_filter);
- TALLOC_FREE(str);
}
printf("\n");
}
/* Only error out if an error happened, not on STATUS_MORE_ENTRIES, ie a delayed message */
if (NT_STATUS_IS_ERR(status)) {
+ struct server_id_buf idbuf;
ldb_asprintf_errstring(ldb_module_get_ctx(module),
"Failed to send MSG_DREPL_ALLOCATE_RID to dreplsrv at %s: %s",
- server_id_str(tmp_ctx, servers), nt_errstr(status));
+ server_id_str_buf(*servers, &idbuf),
+ nt_errstr(status));
talloc_free(tmp_ctx);
return LDB_ERR_UNWILLING_TO_PERFORM;
}
int flags;
struct smbsrv_connection *smb_conn = req->smb_conn;
NTSTATUS status;
- char *task_id;
+ struct server_id_buf idbuf;
type &= 0xff;
req->session = smbsrv_session_find(req->smb_conn, SVAL(req->in.hdr,HDR_UID), req->request_time);
}
- task_id = server_id_str(NULL, &req->smb_conn->connection->server_id);
- DEBUG(5,("switch message %s (task_id %s)\n",
- smb_fn_name(type), task_id));
- talloc_free(task_id);
+ DEBUG(5, ("switch message %s (task_id %s)\n",
+ smb_fn_name(type),
+ server_id_str_buf(req->smb_conn->connection->server_id,
+ &idbuf)));
/* this must be called before we do any reply */
if (flags & SIGNING_NO_REPLY) {
{
TALLOC_CTX *tmp_ctx;
const char *title;
+ struct server_id_buf idbuf;
tmp_ctx = talloc_new(srv_conn);
stream_socket->ops->name,
tsocket_address_string(srv_conn->remote_address, tmp_ctx),
tsocket_address_string(srv_conn->local_address, tmp_ctx),
- server_id_str(tmp_ctx, &server_id));
+ server_id_str_buf(server_id, &idbuf));
if (title) {
stream_connection_set_title(srv_conn, title);
}