mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
libadmin: add rxstat_* -localauth option
Add the -localauth option to the libadmin rxstat sample programs which require a token. This allows the use of these rxstat commands on the server when the cache manager is not available. Change-Id: If0d4d12abc80df73da5898ebb0052fb61d23cb48 Reviewed-on: https://gerrit.openafs.org/12376 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
13748871a0
commit
59b7132256
@ -24,6 +24,7 @@
|
||||
|
||||
#include <rx/rx.h>
|
||||
#include <rx/rxstat.h>
|
||||
#include <afs/dirpath.h>
|
||||
#include <afs/cmd.h>
|
||||
|
||||
#include <afs/afs_Admin.h>
|
||||
@ -34,6 +35,7 @@ enum optionsList {
|
||||
OPT_cell,
|
||||
OPT_server,
|
||||
OPT_port,
|
||||
OPT_localauth,
|
||||
};
|
||||
|
||||
static int
|
||||
@ -45,12 +47,15 @@ rxstat_clear_peer(struct cmd_syndesc *as, void *arock)
|
||||
char *srvrName = NULL;
|
||||
int srvrPort = 0;
|
||||
char *cellName = NULL;
|
||||
int localauth = 0;
|
||||
const char *confdir = AFSDIR_SERVER_ETC_DIR;
|
||||
void *tokenHandle;
|
||||
void *cellHandle;
|
||||
|
||||
cmd_OptionAsString(as, OPT_cell, &cellName);
|
||||
cmd_OptionAsString(as, OPT_server, &srvrName);
|
||||
cmd_OptionAsInt(as, OPT_port, &srvrPort);
|
||||
cmd_OptionAsFlag(as, OPT_localauth, &localauth);
|
||||
|
||||
if (srvrPort <= 0 || srvrPort > USHRT_MAX) {
|
||||
fprintf(stderr, "Out of range -port value.\n");
|
||||
@ -63,10 +68,18 @@ rxstat_clear_peer(struct cmd_syndesc *as, void *arock)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
if (localauth) {
|
||||
rc = afsclient_TokenPrint(confdir, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenPrint, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
|
||||
@ -119,6 +132,7 @@ main(int argc, char *argv[])
|
||||
cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_REQUIRED, "cell name");
|
||||
cmd_AddParmAtOffset(ts, OPT_server, "-server", CMD_SINGLE, CMD_REQUIRED, "server");
|
||||
cmd_AddParmAtOffset(ts, OPT_port, "-port", CMD_SINGLE, CMD_REQUIRED, "port");
|
||||
cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG, CMD_OPTIONAL, "use server tickets");
|
||||
|
||||
return cmd_Dispatch(argc, argv);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <rx/rx.h>
|
||||
#include <rx/rxstat.h>
|
||||
#include <afs/dirpath.h>
|
||||
#include <afs/cmd.h>
|
||||
|
||||
#include <afs/afs_Admin.h>
|
||||
@ -34,6 +35,7 @@ enum optionsList {
|
||||
OPT_cell,
|
||||
OPT_server,
|
||||
OPT_port,
|
||||
OPT_localauth,
|
||||
};
|
||||
|
||||
static int
|
||||
@ -45,12 +47,15 @@ rxstat_clear_process(struct cmd_syndesc *as, void *arock)
|
||||
char *srvrName = NULL;
|
||||
int srvrPort = 0;
|
||||
char *cellName = NULL;
|
||||
int localauth = 0;
|
||||
const char *confdir = AFSDIR_SERVER_ETC_DIR;
|
||||
void *tokenHandle;
|
||||
void *cellHandle;
|
||||
|
||||
cmd_OptionAsString(as, OPT_cell, &cellName);
|
||||
cmd_OptionAsString(as, OPT_server, &srvrName);
|
||||
cmd_OptionAsInt(as, OPT_port, &srvrPort);
|
||||
cmd_OptionAsFlag(as, OPT_localauth, &localauth);
|
||||
|
||||
if (srvrPort <= 0 || srvrPort > USHRT_MAX) {
|
||||
fprintf(stderr, "Out of range -port value.\n");
|
||||
@ -63,10 +68,18 @@ rxstat_clear_process(struct cmd_syndesc *as, void *arock)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
if (localauth) {
|
||||
rc = afsclient_TokenPrint(confdir, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenPrint, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
|
||||
@ -119,6 +132,7 @@ main(int argc, char *argv[])
|
||||
cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_REQUIRED, "cell name");
|
||||
cmd_AddParmAtOffset(ts, OPT_server, "-server", CMD_SINGLE, CMD_REQUIRED, "server");
|
||||
cmd_AddParmAtOffset(ts, OPT_port, "-port", CMD_SINGLE, CMD_REQUIRED, "port");
|
||||
cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG, CMD_OPTIONAL, "use server tickets");
|
||||
|
||||
return cmd_Dispatch(argc, argv);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <rx/rx.h>
|
||||
#include <rx/rxstat.h>
|
||||
#include <afs/dirpath.h>
|
||||
#include <afs/cmd.h>
|
||||
|
||||
#include <afs/afs_Admin.h>
|
||||
@ -34,6 +35,7 @@ enum optionsList {
|
||||
OPT_cell,
|
||||
OPT_server,
|
||||
OPT_port,
|
||||
OPT_localauth,
|
||||
};
|
||||
|
||||
static int
|
||||
@ -45,12 +47,15 @@ rxstat_disable_peer(struct cmd_syndesc *as, void *arock)
|
||||
char *srvrName = NULL;
|
||||
int srvrPort = 0;
|
||||
char *cellName = NULL;
|
||||
int localauth = 0;
|
||||
const char *confdir = AFSDIR_SERVER_ETC_DIR;
|
||||
void *tokenHandle;
|
||||
void *cellHandle;
|
||||
|
||||
cmd_OptionAsString(as, OPT_cell, &cellName);
|
||||
cmd_OptionAsString(as, OPT_server, &srvrName);
|
||||
cmd_OptionAsInt(as, OPT_port, &srvrPort);
|
||||
cmd_OptionAsFlag(as, OPT_localauth, &localauth);
|
||||
|
||||
if (srvrPort <= 0 || srvrPort > USHRT_MAX) {
|
||||
fprintf(stderr, "Out of range -port value.\n");
|
||||
@ -63,10 +68,18 @@ rxstat_disable_peer(struct cmd_syndesc *as, void *arock)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
if (localauth) {
|
||||
rc = afsclient_TokenPrint(confdir, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenPrint, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
|
||||
@ -118,6 +131,7 @@ main(int argc, char *argv[])
|
||||
cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_REQUIRED, "cell name");
|
||||
cmd_AddParmAtOffset(ts, OPT_server, "-server", CMD_SINGLE, CMD_REQUIRED, "server");
|
||||
cmd_AddParmAtOffset(ts, OPT_port, "-port", CMD_SINGLE, CMD_REQUIRED, "port");
|
||||
cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG, CMD_OPTIONAL, "use server tickets");
|
||||
|
||||
return cmd_Dispatch(argc, argv);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <rx/rx.h>
|
||||
#include <rx/rxstat.h>
|
||||
#include <afs/dirpath.h>
|
||||
#include <afs/cmd.h>
|
||||
|
||||
#include <afs/afs_Admin.h>
|
||||
@ -34,6 +35,7 @@ enum optionsList {
|
||||
OPT_cell,
|
||||
OPT_server,
|
||||
OPT_port,
|
||||
OPT_localauth,
|
||||
};
|
||||
|
||||
static int
|
||||
@ -45,12 +47,15 @@ rxstat_disable_process(struct cmd_syndesc *as, void *arock)
|
||||
char *srvrName = NULL;
|
||||
int srvrPort = 0;
|
||||
char *cellName = NULL;
|
||||
int localauth = 0;
|
||||
const char *confdir = AFSDIR_SERVER_ETC_DIR;
|
||||
void *tokenHandle;
|
||||
void *cellHandle;
|
||||
|
||||
cmd_OptionAsString(as, OPT_cell, &cellName);
|
||||
cmd_OptionAsString(as, OPT_server, &srvrName);
|
||||
cmd_OptionAsInt(as, OPT_port, &srvrPort);
|
||||
cmd_OptionAsFlag(as, OPT_localauth, &localauth);
|
||||
|
||||
if (srvrPort <= 0 || srvrPort > USHRT_MAX) {
|
||||
fprintf(stderr, "Out of range -port value.\n");
|
||||
@ -63,10 +68,18 @@ rxstat_disable_process(struct cmd_syndesc *as, void *arock)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
if (localauth) {
|
||||
rc = afsclient_TokenPrint(confdir, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenPrint, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
|
||||
@ -118,6 +131,7 @@ main(int argc, char *argv[])
|
||||
cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_REQUIRED, "cell name");
|
||||
cmd_AddParmAtOffset(ts, OPT_server, "-server", CMD_SINGLE, CMD_REQUIRED, "server");
|
||||
cmd_AddParmAtOffset(ts, OPT_port, "-port", CMD_SINGLE, CMD_REQUIRED, "port");
|
||||
cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG, CMD_OPTIONAL, "use server tickets");
|
||||
|
||||
return cmd_Dispatch(argc, argv);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <rx/rx.h>
|
||||
#include <rx/rxstat.h>
|
||||
#include <afs/dirpath.h>
|
||||
#include <afs/cmd.h>
|
||||
|
||||
#include <afs/afs_Admin.h>
|
||||
@ -34,6 +35,7 @@ enum optionsList {
|
||||
OPT_cell,
|
||||
OPT_server,
|
||||
OPT_port,
|
||||
OPT_localauth,
|
||||
};
|
||||
|
||||
static int
|
||||
@ -45,12 +47,15 @@ rxstat_enable_peer(struct cmd_syndesc *as, void *arock)
|
||||
char *srvrName = NULL;
|
||||
int srvrPort = 0;
|
||||
char *cellName = NULL;
|
||||
int localauth = 0;
|
||||
const char *confdir = AFSDIR_SERVER_ETC_DIR;
|
||||
void *tokenHandle;
|
||||
void *cellHandle;
|
||||
|
||||
cmd_OptionAsString(as, OPT_cell, &cellName);
|
||||
cmd_OptionAsString(as, OPT_server, &srvrName);
|
||||
cmd_OptionAsInt(as, OPT_port, &srvrPort);
|
||||
cmd_OptionAsFlag(as, OPT_localauth, &localauth);
|
||||
|
||||
if (srvrPort <= 0 || srvrPort > USHRT_MAX) {
|
||||
fprintf(stderr, "Out of range -port value.\n");
|
||||
@ -63,10 +68,18 @@ rxstat_enable_peer(struct cmd_syndesc *as, void *arock)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
if (localauth) {
|
||||
rc = afsclient_TokenPrint(confdir, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenPrint, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
|
||||
@ -118,6 +131,7 @@ main(int argc, char *argv[])
|
||||
cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_REQUIRED, "cell name");
|
||||
cmd_AddParmAtOffset(ts, OPT_server, "-server", CMD_SINGLE, CMD_REQUIRED, "server");
|
||||
cmd_AddParmAtOffset(ts, OPT_port, "-port", CMD_SINGLE, CMD_REQUIRED, "port");
|
||||
cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG, CMD_OPTIONAL, "use server tickets");
|
||||
|
||||
return cmd_Dispatch(argc, argv);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <rx/rx.h>
|
||||
#include <rx/rxstat.h>
|
||||
#include <afs/dirpath.h>
|
||||
#include <afs/cmd.h>
|
||||
#include <afs/afs_Admin.h>
|
||||
#include <afs/afs_clientAdmin.h>
|
||||
@ -33,6 +34,7 @@ enum optionsList {
|
||||
OPT_cell,
|
||||
OPT_server,
|
||||
OPT_port,
|
||||
OPT_localauth,
|
||||
};
|
||||
|
||||
static int
|
||||
@ -44,12 +46,15 @@ rxstat_enable_process(struct cmd_syndesc *as, void *arock)
|
||||
char *srvrName = NULL;
|
||||
int srvrPort = 0;
|
||||
char *cellName = NULL;
|
||||
int localauth = 0;
|
||||
const char *confdir = AFSDIR_SERVER_ETC_DIR;
|
||||
void *tokenHandle;
|
||||
void *cellHandle;
|
||||
|
||||
cmd_OptionAsString(as, OPT_cell, &cellName);
|
||||
cmd_OptionAsString(as, OPT_server, &srvrName);
|
||||
cmd_OptionAsInt(as, OPT_port, &srvrPort);
|
||||
cmd_OptionAsFlag(as, OPT_localauth, &localauth);
|
||||
|
||||
if (srvrPort <= 0 || srvrPort > USHRT_MAX) {
|
||||
fprintf(stderr, "Out of range -port value.\n");
|
||||
@ -62,10 +67,18 @@ rxstat_enable_process(struct cmd_syndesc *as, void *arock)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
if (localauth) {
|
||||
rc = afsclient_TokenPrint(confdir, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenPrint, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
rc = afsclient_TokenGetExisting(cellName, &tokenHandle, &st);
|
||||
if (!rc) {
|
||||
fprintf(stderr, "afsclient_TokenGetExisting, status %d\n", st);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = afsclient_CellOpen(cellName, tokenHandle, &cellHandle, &st);
|
||||
@ -117,6 +130,7 @@ main(int argc, char *argv[])
|
||||
cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_REQUIRED, "cell name");
|
||||
cmd_AddParmAtOffset(ts, OPT_server, "-server", CMD_SINGLE, CMD_REQUIRED, "server");
|
||||
cmd_AddParmAtOffset(ts, OPT_port, "-port", CMD_SINGLE, CMD_REQUIRED, "port");
|
||||
cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG, CMD_OPTIONAL, "use server tickets");
|
||||
|
||||
return cmd_Dispatch(argc, argv);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user