summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-01-31 11:49:29 +0000
committerAndrew Tridgell <tridge@samba.org>2002-01-31 11:49:29 +0000
commitbcd234a3dad2cd3d1c57780f4a7a3833ea611764 (patch)
treeaf343fb6da2e18a9aa46afc5e4f8d9512a357414 /source
parent3cd97d65dea428382104ebde63eaf660aa3942fb (diff)
downloadsamba-bcd234a3dad2cd3d1c57780f4a7a3833ea611764.tar.gz
samba-bcd234a3dad2cd3d1c57780f4a7a3833ea611764.tar.xz
samba-bcd234a3dad2cd3d1c57780f4a7a3833ea611764.zip
added 'wbinfo --sequence' to show sequence numbers of all domains
Diffstat (limited to 'source')
-rw-r--r--source/nsswitch/wbinfo.c34
-rw-r--r--source/nsswitch/winbindd.c1
-rw-r--r--source/nsswitch/winbindd_misc.c29
-rw-r--r--source/nsswitch/winbindd_nss.h2
-rw-r--r--source/nsswitch/winbindd_proto.h1
5 files changed, 67 insertions, 0 deletions
diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index 5a46f7d56e3..32a3c95113a 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/nsswitch/wbinfo.c
@@ -157,6 +157,31 @@ static BOOL wbinfo_list_domains(void)
return True;
}
+
+/* show sequence numbers */
+static BOOL wbinfo_show_sequence(void)
+{
+ struct winbindd_response response;
+ fstring name;
+
+ ZERO_STRUCT(response);
+
+ /* Send request */
+ if (winbindd_request(WINBINDD_SHOW_SEQUENCE, NULL, &response) !=
+ NSS_STATUS_SUCCESS) {
+ return False;
+ }
+
+ /* Display response */
+ if (response.extra_data) {
+ char *extra_data = (char *)response.extra_data;
+ printf("%s", extra_data);
+ SAFE_FREE(response.extra_data);
+ }
+
+ return True;
+}
+
/* Check trust account password */
static BOOL wbinfo_check_secret(void)
@@ -539,6 +564,7 @@ static void usage(void)
printf("\t-r user\t\t\tget user groups\n");
printf("\t-a user%%password\tauthenticate user\n");
printf("\t-p 'ping' winbindd to see if it is alive\n");
+ printf("\t--sequence\t\tshow sequence numbers of all domains\n");
}
/* Main program */
@@ -556,6 +582,7 @@ int main(int argc, char **argv)
static char *string_arg;
static int int_arg;
BOOL got_command = False;
+ enum {OPT_SEQUENCE=1};
struct poptOption long_options[] = {
@@ -571,6 +598,7 @@ int main(int argc, char **argv)
{ "sid-to-gid", 'Y', POPT_ARG_STRING, &string_arg, 'Y' },
{ "check-secret", 't', POPT_ARG_NONE, 0, 't' },
{ "trusted-domains", 'm', POPT_ARG_NONE, 0, 'm' },
+ { "sequence", OPT_SEQUENCE, POPT_ARG_NONE, 0, OPT_SEQUENCE },
{ "user-groups", 'r', POPT_ARG_STRING, &string_arg, 'r' },
{ "authenticate", 'a', POPT_ARG_STRING, &string_arg, 'a' },
{ "set-auth-user", 0, POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER },
@@ -689,6 +717,12 @@ int main(int argc, char **argv)
return 1;
}
break;
+ case OPT_SEQUENCE:
+ if (!wbinfo_show_sequence()) {
+ printf("Could not show sequence numbers\n");
+ return 1;
+ }
+ break;
case 'r':
if (!wbinfo_get_usergroups(string_arg)) {
printf("Could not get groups for user %s\n",
diff --git a/source/nsswitch/winbindd.c b/source/nsswitch/winbindd.c
index fe6c3311877..debe7f716fe 100644
--- a/source/nsswitch/winbindd.c
+++ b/source/nsswitch/winbindd.c
@@ -230,6 +230,7 @@ static struct dispatch_table dispatch_table[] = {
{ WINBINDD_LIST_USERS, winbindd_list_users, "LIST_USERS" },
{ WINBINDD_LIST_GROUPS, winbindd_list_groups, "LIST_GROUPS" },
{ WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains, "LIST_TRUSTDOM" },
+ { WINBINDD_SHOW_SEQUENCE, winbindd_show_sequence, "SHOW_SEQUENCE" },
/* SID related functions */
diff --git a/source/nsswitch/winbindd_misc.c b/source/nsswitch/winbindd_misc.c
index 448af3ac957..8b22b87c3d0 100644
--- a/source/nsswitch/winbindd_misc.c
+++ b/source/nsswitch/winbindd_misc.c
@@ -145,6 +145,35 @@ enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state
return WINBINDD_OK;
}
+
+enum winbindd_result winbindd_show_sequence(struct winbindd_cli_state *state)
+{
+ struct winbindd_domain *domain;
+ char *extra_data = NULL;
+
+ DEBUG(3, ("[%5d]: show sequence\n", state->pid));
+
+ extra_data = strdup("");
+
+ /* this makes for a very simple data format, and is easily parsable as well
+ if that is ever needed */
+ for (domain = domain_list(); domain; domain = domain->next) {
+ char *s;
+
+ domain->methods->sequence_number(domain, &domain->sequence_number);
+
+ asprintf(&s,"%s%s : %u\n", extra_data,
+ domain->name, (unsigned)domain->sequence_number);
+ free(extra_data);
+ extra_data = s;
+ }
+
+ state->response.extra_data = extra_data;
+ state->response.length += strlen(extra_data);
+
+ return WINBINDD_OK;
+}
+
enum winbindd_result winbindd_ping(struct winbindd_cli_state
*state)
{
diff --git a/source/nsswitch/winbindd_nss.h b/source/nsswitch/winbindd_nss.h
index 76a2406ae99..7a0926a0356 100644
--- a/source/nsswitch/winbindd_nss.h
+++ b/source/nsswitch/winbindd_nss.h
@@ -92,6 +92,8 @@ enum winbindd_cmd {
WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
WINBINDD_DOMAIN_NAME, /* The domain this winbind server is a member of (lp_workgroup()) */
+ WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
+
/* Placeholder for end of cmd list */
WINBINDD_NUM_CMDS
diff --git a/source/nsswitch/winbindd_proto.h b/source/nsswitch/winbindd_proto.h
index 4c355d11b0e..58e42eeab81 100644
--- a/source/nsswitch/winbindd_proto.h
+++ b/source/nsswitch/winbindd_proto.h
@@ -69,6 +69,7 @@ void winbindd_idmap_status(void);
enum winbindd_result winbindd_check_machine_acct(struct winbindd_cli_state *state);
enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state
*state);
+enum winbindd_result winbindd_show_sequence(struct winbindd_cli_state *state);
enum winbindd_result winbindd_ping(struct winbindd_cli_state
*state);
enum winbindd_result winbindd_info(struct winbindd_cli_state *state);