Add rxgk client options to vl and pt utilities
[openafs.git] / src / ptserver / pts.c
index 6504de3..aa1f415 100644 (file)
 #include <afs/cmd.h>
 #include <rx/rx.h>
 #include <rx/xdr.h>
+#include <rx/rxgk_int.h>
 
 #include "ptclient.h"
 #include "ptuser.h"
 #include "pterror.h"
 #include "ptprototypes.h"
 
-#undef FOREIGN
-
 char *whoami;
 int force = 0;
 
@@ -169,6 +168,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
     afs_int32 sec;
     int changed = 0;
     const char* confdir;
+    RXGK_Level rxgk_level = RXGK_LEVEL_BOGUS;
 
     whoami = as->a0name;
 
@@ -223,9 +223,26 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
        confdir = as->parms[23].items->data;
     }
 
+    if (as->parms[24].items) { /* -rxgk */
+       char *rxgk_seclevel_str = as->parms[24].items->data;
+       changed = 1;
+
+       if (strcmp(rxgk_seclevel_str, "clear") == 0)
+           rxgk_level = RXGK_LEVEL_CLEAR;
+       else if (strcmp(rxgk_seclevel_str, "auth") == 0)
+           rxgk_level = RXGK_LEVEL_AUTH;
+       else if (strcmp(rxgk_seclevel_str, "crypt") == 0)
+           rxgk_level = RXGK_LEVEL_CRYPT;
+       else {
+           fprintf(stderr, "Invalid argument to -rxgk: %s\n", rxgk_seclevel_str);
+           return 1;
+       }
+
+    }
+
     if (changed) {
        CleanUp(as, arock);
-       code = pr_Initialize(sec, confdir, cell);
+       code = pr_Initialize2(sec, confdir, cell, rxgk_level);
     } else {
        code = 0;
     }
@@ -283,7 +300,7 @@ CreateGroup(struct cmd_syndesc *as, void *arock)
                return code;
            }
            if (id == 0) {
-               printf("0 isn't a valid group id; aborting\n");
+               fprintf(stderr, "0 isn't a valid group id; aborting\n");
                return EINVAL;
            }
            if (id > 0) {
@@ -336,7 +353,7 @@ CreateUser(struct cmd_syndesc *as, void *arock)
                return code;
            }
            if (id == 0) {
-               printf("0 isn't a valid user id; aborting\n");
+               fprintf(stderr, "0 isn't a valid user id; aborting\n");
                return EINVAL;
            }
            if (id < 0) {
@@ -793,9 +810,6 @@ CheckEntry(struct cmd_syndesc *as, void *arock)
            printf(", group quota: unlimited");
        else
            printf(", group quota: %d", aentry.ngroups);
-#if FOREIGN
-       printf(", foreign user quota=%d", aentry.nusers);
-#endif
        printf(".\n");
     }
 
@@ -934,7 +948,7 @@ SetMaxCommand(struct cmd_syndesc *as, void *arock)
     }
     if (!as->parms[0].items && !as->parms[1].items) {
        code = PRBADARG;
-       printf("Must specify at least one of group or user.\n");
+       fprintf(stderr, "Must specify at least one of group or user.\n");
     }
     return code;
 }
@@ -964,7 +978,7 @@ SetFields(struct cmd_syndesc *as, void *arock)
        } else {                /* interpret flag bit names */
            if (strlen(access) != 5) {
              form_error:
-               printf("Access bits must be of the form 'somar', not %s\n",
+               fprintf(stderr, "Access bits must be of the form 'somar', not %s\n",
                       access);
                return PRBADARG;
            }
@@ -979,8 +993,8 @@ SetFields(struct cmd_syndesc *as, void *arock)
                else if (access[i] == '-')
                    new = 0;
                else {
-                   printf
-                       ("Access bits out of order or illegal:\n  must be a combination of letters from '%s' or '%s' or hyphen, not %s\n",
+                   fprintf(stderr,
+                       "Access bits out of order or illegal:\n  must be a combination of letters from '%s' or '%s' or hyphen, not %s\n",
                         flags_upcase, flags_dncase, access);
                    return PRBADARG;
                }
@@ -1003,17 +1017,6 @@ SetFields(struct cmd_syndesc *as, void *arock)
        }
        mask |= PR_SF_NGROUPS;
     }
-#if FOREIGN
-    if (as->parms[3].items) {  /* limitgroups */
-       code = util_GetInt32(as->parms[3].items->data, &nusers);
-       if (code) {
-           afs_com_err(whoami, code, "because nusers was: '%s'",
-                   as->parms[3].items->data);
-           return code;
-       }
-       mask |= PR_SF_NUSERS;
-    }
-#endif
 
     for (i = 0; i < ids.idlist_len; i++) {
        afs_int32 id = ids.idlist_val[i];
@@ -1087,9 +1090,12 @@ ListOwned(struct cmd_syndesc *as, void *arock)
 static void
 add_std_args(struct cmd_syndesc *ts)
 {
-    char test_help[AFSDIR_PATH_MAX];
+    char *test_help;
 
-    sprintf(test_help, "use config file in %s", AFSDIR_SERVER_ETC_DIRPATH);
+    if (asprintf(&test_help, "use config file in %s",
+                AFSDIR_SERVER_ETC_DIRPATH) < 0) {
+       test_help = strdup("use server config file");
+    }
 
     cmd_Seek(ts, 16);
     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
@@ -1104,6 +1110,8 @@ add_std_args(struct cmd_syndesc *ts)
     cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL,
                "encrypt commands");
     cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL, "config location");
+    cmd_AddParm(ts, "-rxgk", CMD_SINGLE, CMD_OPTIONAL, "rxgk security level to use");
+    free(test_help);
 }
 
 /*
@@ -1226,10 +1234,6 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-access", CMD_SINGLE, CMD_OPTIONAL, "set privacy flags");
     cmd_AddParm(ts, "-groupquota", CMD_SINGLE, CMD_OPTIONAL,
                "set limit on group creation");
-#if FOREIGN
-    cmd_AddParm(ts, "-userquota", CMD_SINGLE, CMD_OPTIONAL,
-               "set limit on foreign user creation");
-#endif
     add_std_args(ts);
 
     ts = cmd_CreateSyntax("listowned", ListOwned, NULL, 0,