#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <stdio.h>
#include <string.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
#include <WINNT/afsevent.h>
+#include <WINNT/afsreg.h>
#else
#include <netinet/in.h>
#endif
#include <rx/rx.h>
#include <rx/xdr.h>
#include "ptclient.h"
+#include "ptuser.h"
#include "pterror.h"
+#include "ptprototypes.h"
#include <afs/afsutil.h>
#include <afs/com_err.h>
FILE *s_file;
} *shead;
-int
+struct authstate {
+ int sec;
+ const char *confdir;
+ char cell[MAXCELLCHARS];
+};
+
+static int CleanUp(struct cmd_syndesc *as, void *arock);
+
+static int
pts_Interactive(struct cmd_syndesc *as, void *arock)
{
+ source = stdin;
finished = 0;
return 0;
}
-int
+static int
pts_Quit(struct cmd_syndesc *as, void *arock)
{
finished = 1;
return 0;
}
-int
+static int
pts_Source(struct cmd_syndesc *as, void *arock)
{
FILE *fd;
return 0;
}
-int
+static int
pts_Sleep(struct cmd_syndesc *as, void *arock)
{
int delay;
return 1;
}
delay = atoi(as->parms[0].items->data);
+#ifdef AFS_PTHREAD_ENV
+ sleep(delay);
+#else
IOMGR_Sleep(delay);
+#endif
return 0;
}
-int
-popsource()
+static int
+popsource(void)
{
register struct sourcestack *sp;
if (!(sp = shead))
}
int
-osi_audit()
+osi_audit(void)
{
/* OK, this REALLY sucks bigtime, but I can't tell who is calling
* afsconf_CheckAuth easily, and only *SERVERS* should be calling osi_audit
return 0;
}
-int
+#ifdef AFS_NT40_ENV
+static DWORD
+win32_enableCrypt(void)
+{
+ HKEY parmKey;
+ DWORD dummyLen;
+ DWORD cryptall = 0;
+ DWORD code;
+
+ /* Look up configuration parameters in Registry */
+ code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
+ 0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey);
+ if (code != ERROR_SUCCESS) {
+ dummyLen = sizeof(cryptall);
+ RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
+ (BYTE *) &cryptall, &dummyLen);
+ }
+ RegCloseKey (parmKey);
+
+ return cryptall;
+}
+#endif /* AFS_NT40_ENV */
+
+static int
GetGlobals(struct cmd_syndesc *as, void *arock)
{
- register afs_int32 code;
- char *cell;
- afs_int32 sec = 1;
+ struct authstate *state = (struct authstate *) arock;
+ afs_int32 code;
+ char *cell = NULL;
+ afs_int32 sec;
+ int changed = 0;
+ const char* confdir;
whoami = as->a0name;
if (!strcmp(as->name, "help"))
return 0;
- if (as->parms[16].items)
+
+ if (*state->cell) {
+ cell = state->cell;
+ }
+ sec = state->sec;
+
+ if (state->confdir == NULL) {
+ changed = 1;
+ }
+
+ if (as->parms[16].items) {
+ changed = 1;
cell = as->parms[16].items->data;
- else
- cell = 0;
- if (as->parms[17].items)
+ }
+ if (as->parms[17].items) { /* -noauth */
+ changed = 1;
sec = 0;
-
- if (as->parms[18].items) { /* testing? */
- code = pr_Initialize(sec, AFSDIR_SERVER_ETC_DIRPATH, cell);
+ }
+ if (as->parms[20].items) { /* -localauth */
+ changed = 1;
+ sec = 2;
+ }
+ if (as->parms[21].items) { /* -auth */
+ changed = 1;
+ sec = 1;
+ }
+ if (as->parms[22].items /* -encrypt */
+#ifdef AFS_NT40_ENV
+ || win32_enableCrypt()
+#endif /* AFS_NT40_ENV */
+ ) {
+ changed = 1;
+ sec = 3;
+ }
+ if (as->parms[18].items || as->parms[20].items) { /* -test, -localauth */
+ changed = 1;
+ confdir = AFSDIR_SERVER_ETC_DIRPATH;
} else {
- code = pr_Initialize(sec, AFSDIR_CLIENT_ETC_DIRPATH, cell);
+ if (sec == 2)
+ confdir = AFSDIR_SERVER_ETC_DIRPATH;
+ else
+ confdir = AFSDIR_CLIENT_ETC_DIRPATH;
+ }
+ if (changed) {
+ CleanUp(as, arock);
+ code = pr_Initialize(sec, confdir, cell);
+ } else {
+ code = 0;
}
if (code) {
afs_com_err(whoami, code, "while initializing");
return code;
}
+ state->sec = sec;
+ state->confdir = confdir;
+ if (cell && cell != state->cell)
+ strncpy(state->cell, cell, MAXCELLCHARS-1);
+
+ force = 0;
if (as->parms[19].items)
force = 1;
+
return code;
}
-int
+static int
CleanUp(struct cmd_syndesc *as, void *arock)
{
if (as && !strcmp(as->name, "help"))
return 0;
}
-int
+static int
CreateGroup(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return 0;
}
-int
+static int
CreateUser(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
#ifdef notdef
-int
-GetNameOrId(register struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
+static int
+GetNameOrId(struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
{
register afs_int32 code = 0;
int n = 0;
#endif
-int
-GetNameOrId(register struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
+static int
+GetNameOrId(struct cmd_syndesc *as, struct idlist *lids,
+ struct namelist *lnames)
{
register afs_int32 code = 0;
int n = 0, nd = 0, nm = 0, id, x;
}
-int
+static int
AddToGroup(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return 0;
}
-int
+static int
RemoveFromGroup(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return 0;
}
-int
+static int
ListMembership(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return 0;
}
-int
+static int
Delete(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
char *flags_dncase = "s mar"; /* legal member acces values */
int flags_shift[5] = { 2, 1, 2, 2, 1 }; /* bits for each */
-int
+static int
CheckEntry(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return (rcode);
}
-int
+static int
ListEntries(struct cmd_syndesc *as, void *arock)
{
afs_int32 code = 0;
pr_ListEntries(flag, startindex, &nentries, &entriesp,
&nextstartindex);
if (code) {
- afs_com_err(whoami, code, "; unable to list entries\n");
+ afs_com_err(whoami, code, "; unable to list entries");
if (entriesp)
free(entriesp);
break;
return code;
}
-int
+static int
ChownGroup(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return code;
}
-int
+static int
ChangeName(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return code;
}
-int
+static int
ListMax(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
return code;
}
-int
-SetMax(struct cmd_syndesc *as, void *arock)
+static int
+SetMaxCommand(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
afs_int32 maxid;
return code;
}
-int
+static int
SetFields(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
int new;
if (strpbrk(access, "76543210") != 0) { /* all octal digits */
- sscanf(access, "%lo", &flags);
+ sscanf(access, "%lo", (long unsigned int *) &flags);
} else { /* interpret flag bit names */
if (strlen(access) != 5) {
form_error:
return 0;
}
-int
+static int
ListOwned(struct cmd_syndesc *as, void *arock)
{
register afs_int32 code;
}
static void
-add_std_args(register struct cmd_syndesc *ts)
+add_std_args(struct cmd_syndesc *ts)
{
char test_help[AFSDIR_PATH_MAX];
cmd_AddParm(ts, "-test", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, test_help);
cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
"Continue oper despite reasonable errors");
+ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
+ "use local authentication");
+ cmd_AddParm(ts, "-auth", CMD_FLAG, CMD_OPTIONAL,
+ "use user's authentication (default)");
+ cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL,
+ "encrypt commands");
}
/*
int parsec;
char *parsev[CMD_MAXPARMS];
char *savec;
+ struct authstate state;
#ifdef WIN32
WSADATA WSAjunk;
sigaction(SIGSEGV, &nsa, NULL);
#endif
+ memset(&state, 0, sizeof(state));
+ state.sec = 1; /* default is auth */
+
ts = cmd_CreateSyntax("creategroup", CreateGroup, NULL,
"create a new group");
cmd_AddParm(ts, "-name", CMD_LIST, 0, "group name");
ts = cmd_CreateSyntax("listmax", ListMax, NULL, "list max id");
add_std_args(ts);
- ts = cmd_CreateSyntax("setmax", SetMax, NULL, "set max id");
+ ts = cmd_CreateSyntax("setmax", SetMaxCommand, NULL, "set max id");
cmd_AddParm(ts, "-group", CMD_SINGLE, CMD_OPTIONAL, "group max");
cmd_AddParm(ts, "-user", CMD_SINGLE, CMD_OPTIONAL, "user max");
add_std_args(ts);
cmd_AddParm(ts, "-delay", CMD_SINGLE, 0, "seconds");
add_std_args(ts);
- cmd_SetBeforeProc(GetGlobals, 0);
+ cmd_SetBeforeProc(GetGlobals, &state);
finished = 1;
- source = stdin;
- if (code = cmd_Dispatch(argc, argv)) {
+ source = NULL;
+ if ((code = cmd_Dispatch(argc, argv))) {
CleanUp(NULL, NULL);
exit(1);
}
- while (!finished) {
+ while (source && !finished) {
if (isatty(fileno(source)))
fprintf(stderr, "pts> ");
if (!fgets(line, sizeof line, source)) {