aboutsummaryrefslogtreecommitdiff
path: root/client/remctl.c
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-02-07 23:33:23 +0000
committerRuss Allbery <rra@stanford.edu>2008-02-07 23:33:23 +0000
commitf0bde61f5ecfc6a58a2c0ec0ccadbdd1332b64f8 (patch)
treed13773de8ccd3461a1fc3cedcfb06d7f61d18aff /client/remctl.c
parent71bba523b426da1a9cf39ce066b2a3ebb376860b (diff)
Add new exists and autocreate wallet server interfaces. The first
states whether a given object exists and the second attempts to create the object using the default owner rules. Remove default owner handling from the create interface, which is now for administrators only. Remove server-side auto-creation of objects on get or store and instead have the client check for object existence and call autocreate if necessary. This removes confusion between default ACLs and administrative object creation for users who are also on the ADMIN ACL.
Diffstat (limited to 'client/remctl.c')
-rw-r--r--client/remctl.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/client/remctl.c b/client/remctl.c
index 6d80bf2..aa9a9f8 100644
--- a/client/remctl.c
+++ b/client/remctl.c
@@ -72,3 +72,48 @@ run_command(struct remctl *r, const char **command, char **data,
} while (output->type != REMCTL_OUT_DONE);
return status;
}
+
+
+/*
+** Check whether an object exists using the exists wallet interface. Returns
+** true if it does, false if it doesn't, and dies on remctl errors.
+*/
+int
+object_exists(struct remctl *r, const char *prefix, const char *type,
+ const char *name)
+{
+ const char *command[5];
+ char *data = NULL;
+ size_t length;
+
+ command[0] = prefix;
+ command[1] = "exists";
+ command[2] = type;
+ command[3] = name;
+ command[4] = NULL;
+ if (run_command(r, command, &data, &length) != 0)
+ exit(1);
+ if (length == 4 && strncmp(data, "yes\n", 4) == 0)
+ return 1;
+ else
+ return 0;
+}
+
+
+/*
+** Attempt autocreation of an object. Dies if autocreation fails.
+*/
+void
+object_autocreate(struct remctl *r, const char *prefix, const char *type,
+ const char *name)
+{
+ const char *command[5];
+
+ command[0] = prefix;
+ command[1] = "autocreate";
+ command[2] = type;
+ command[3] = name;
+ command[4] = NULL;
+ if (run_command(r, command, NULL, NULL) != 0)
+ exit(1);
+}