diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-09 11:18:15 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-09 12:40:09 +0200 |
commit | daf79e33c7e8873345fb4a251f1e880fd767df19 (patch) | |
tree | ad97087a857d7db7f7478d6057faabd830136152 /source3/lib | |
parent | f348d148b463ca61cbc48d2aadeaa099f7150425 (diff) | |
download | samba-daf79e33c7e8873345fb4a251f1e880fd767df19.tar.gz samba-daf79e33c7e8873345fb4a251f1e880fd767df19.tar.bz2 samba-daf79e33c7e8873345fb4a251f1e880fd767df19.zip |
server_id: Change format to vnn:pid.task_id, pid.task_id or pid
This helps ensure the string cannot be ambiguous, while also ensuring
that it remains simple in the non-cluster case.
The asymmetry of reading get_my_vnn() but writing based on
NONCLUSTER_VNN is acceptable because in the non-clustered case, they
are equal, and in the clustered case we will print the full string.
Andrew Bartlett
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 5fb8a41dae..499f5f7f6b 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1971,16 +1971,26 @@ struct server_id interpret_pid(const char *pid_string) ZERO_STRUCT(result); - /* We accept either the 2 or 3 componet form for backwards compatability in the smbstatus command line tool */ - if (sscanf(pid_string, "%u:%llu:%u", &vnn, &pid, &task_id) >= 2) { + /* We accept various forms with 1, 2 or 3 component forms + * because the server_id_str() can print different forms, and + * we want backwards compatibility for scripts that may call + * smbclient. */ + if (sscanf(pid_string, "%u:%llu.%u", &vnn, &pid, &task_id) == 3) { result.vnn = vnn; result.pid = pid; result.task_id = task_id; + } else if (sscanf(pid_string, "%u:%llu", &vnn, &pid) == 2) { + result.vnn = vnn; + result.pid = pid; + result.task_id = 0; + } else if (sscanf(pid_string, "%llu.%u", &pid, &task_id) == 2) { + result.vnn = get_my_vnn(); + result.pid = pid; + result.task_id = task_id; } else if (sscanf(pid_string, "%d", &pid) == 1) { result.vnn = get_my_vnn(); result.pid = pid; - } - else { + } else { result.vnn = NONCLUSTER_VNN; result.pid = (uint64_t)-1; } |