## char qual[256];
build_qual(q->qual, q->argc, argv, qual);
+## range of u is users
## retrieve (id = u.users_id) where qual
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1 || id != cl->users_id)
return(SMS_PERM);
}
+ if (!strcmp(strtrim(acl_type), "LIST")) {
+ if (!client_is_member(cl, acl_id))
+ return(SMS_PERM);
+ else
+ return(SMS_SUCCESS);
+ }
+
/* check for client in access control list */
status = find_member(acl_type, acl_id, client_type, client_id, 0);
if (!status) return(SMS_PERM);
if (!flags)
return(SMS_SUCCESS);
+
+ if (!strcmp(strtrim(acl_type), "LIST")) {
+ if (!client_is_member(cl, acl_id))
+ return(SMS_PERM);
+ else
+ return(SMS_SUCCESS);
+ }
+
/* parse client structure */
if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
return(status);
if (!flags)
return(SMS_SUCCESS);
+ if (!strcmp(strtrim(acl_type), "LIST")) {
+ if (!client_is_member(cl, acl_id))
+ return(SMS_PERM);
+ else
+ return(SMS_SUCCESS);
+ }
+
/* parse client structure */
if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
return(status);
if (rowcount > 1)
return(SMS_PERM);
+ if (!strcmp(strtrim(acl_type), "LIST")) {
+ if (!client_is_member(cl, acl_id))
+ return(SMS_PERM);
+ else
+ return(SMS_SUCCESS);
+ }
+
/* parse client structure */
if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
return(status);
return(SMS_PERM);
if (users_id == cl->users_id)
return(SMS_SUCCESS);
- if ((status = get_client(cl, &client_type, &client_id)) != SMS_SUCCESS)
- return(status);
- status = find_member("LIST", list_id, client_type, client_id, 0);
- if (status)
+ if (!client_is_member(cl, list_id))
+ return(SMS_PERM);
+ else
return(SMS_SUCCESS);
- return(SMS_PERM);
##}
/* For now, only allow users to be deleted if their status is 0 */
## repeat retrieve (flag = u.status) where u.users_id = @id
- if (flag != 0)
+ if (flag != 0 && flag != 4)
return(SMS_IN_USE);
## repeat delete nfsquota where nfsquota.users_id = @id
+## repeat delete krbmap where krbmap.users_id = @id
## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
## and imembers.member_type = "USER"))
if (flag)
## repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
if (flag)
return(SMS_IN_USE);
+## repeat retrieve (flag = any(palladium.mach_id where palladium.mach_id=@id))
+ if (flag)
+ return(SMS_IN_USE);
## repeat delete mcmap where mcmap.mach_id = @id
return(SMS_SUCCESS);
##}
+/* setup add_kerberos_user_mapping: add the string to the string
+ * table if necessary.
+ */
+
+setup_akum(q, argv, cl)
+struct query *q;
+char **argv;
+client *cl;
+##{
+## int id, rowcount;
+## char *name;
+
+ name = argv[1];
+## range of s is strings
+## repeat retrieve (id = s.string_id) where s.string = @name
+## inquire_equel (rowcount = "rowcount")
+ if (rowcount == 0) {
+ if (q->type != APPEND) return(SMS_STRING);
+## range of v is values
+## retrieve (id = v.value) where v.#name = "strings_id"
+ id++;
+## replace v (value = id) where v.#name = "strings_id"
+## append to strings (string_id = id, string = name)
+ }
+ *(int *)argv[1] = id;
+ return(0);
+##}
+
+
\f
/* FOLLOWUP ROUTINES */
## int who;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
table = q->rtable;
name = argv[0];
## int who, id;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
table = q->rtable;
id_name = q->validate->object_id;
## char *entity;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
users_id = *(int *)argv[0];
## repeat replace u (fmodtime = "now", fmodby = @who, fmodwith = @entity)
## char *entity;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
users_id = *(int *)argv[0];
## repeat replace users (pmodtime = "now", pmodby = @who, pmodwith = @entity)
## int who;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
table = q->rtable;
name = argv[0];
## int who, id;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
id = *(int *)argv[0];
## range of m is machine
## int who, id;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
id = *(int *)argv[0];
## range of c is cluster
## int who, id;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
serv = argv[0];
id = *(int *)argv[1];
## int who, id;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
id = *(int *)argv[0];
dir = argv[1];
## int who;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
label = argv[0];
if (!strcmp(q->shortname, "ufil"))
## int who;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
class = argv[0];
while (sq_get_data(sq, &argv)) {
id = atoi(argv[i]);
free(argv[i]);
- argv[i] = malloc(9);
+ argv[i] = malloc(256);
name = argv[i];
-## repeat retrieve (name = users.login) where users.users_id = @id
+ if (id > 0)
+## repeat retrieve (name = users.login) where users.users_id = @id
+ else {
+ id = -id;
+## repeat retrieve (name = strings.string) where strings.string_id = @id
+ id = -id;
+ }
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1) {
sprintf(argv[i], "#%d", id);
## char fullname[129];
login = argv[0];
- who = cl->users_id;
+ who = cl->client_id;
entity = cl->entity;
/* build fullname */
if (!strcmp(q->shortname, "gpob")) {
sid = atoi(argv[4]);
free(argv[4]);
- argv[4] = malloc(9);
+ argv[4] = malloc(256);
name = argv[4];
-## repeat retrieve (name = users.login) where users.users_id = @sid
+ if (sid > 0)
+## repeat retrieve (name = users.login) where users.users_id = @sid
+ else {
+ sid = -sid;
+## repeat retrieve (name = strings.string)
+## where strings.string_id = @sid
+ sid = -sid;
+ }
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
sprintf(name, "#%d", sid);
/* free saved data */
free(argv[0]);
free(argv[1]);
+ free(argv[4]);
free(argv);
}
id = atoi(argv[i = q->vcnt - 2]);
free(argv[i]);
- name = argv[i] = malloc(9);
-## repeat retrieve (name = users.login) where users.users_id = @id
+ name = argv[i] = malloc(256);
+ if (id > 0)
+## repeat retrieve (name = users.login) where users.users_id = @id
+ else {
+ id = -id;
+## repeat retrieve (name = strings.string) where strings.string_id = @id
+ id = -id;
+ }
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
sprintf(argv[i], "#%d", id);
list_id = *(int *)argv[0];
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
## range of l is list
## repeat replace l (modtime = "now", modby = @who, modwith = @entity)
##}
+/* followup_gnfq: Fix the directory name & modby fields
+ * argv[0] = filsys_id
+ * argv[2] = ascii(quota)
+ */
+
+followup_gnfq(q, sq, v, action, actarg, cl)
+ struct query *q;
+ register struct save_queue *sq;
+ struct validate *v;
+ register int (*action)();
+ register int actarg;
+ client *cl;
+##{
+ register int j;
+ char **argv, *malloc();
+## int id, rowcount;
+## char *name, *label;
+
+ while (sq_get_data(sq, &argv)) {
+ id = atoi(argv[3]);
+ free(argv[3]);
+ argv[3] = malloc(256);
+ name = argv[3];
+ if (id == 0) {
+ label = argv[0];
+## repeat retrieve (name = filesys.#name) where filesys.#label = @label
+ } else {
+## repeat retrieve (name = nfsphys.dir) where nfsphys.nfsphys_id = @id
+ }
+## inquire_equel(rowcount = "rowcount")
+ if (rowcount != 1) {
+ sprintf(argv[3], "#%d", id);
+ }
+
+ id = atoi(argv[6]);
+ free(argv[6]);
+ argv[6] = malloc(256);
+ name = argv[6];
+ if (id > 0)
+## repeat retrieve (name = users.login) where users.users_id = @id
+ else {
+ id = -id;
+## repeat retrieve (name = strings.string) where strings.string_id = @id
+ id = -id;
+ }
+## inquire_equel(rowcount = "rowcount")
+ if (rowcount != 1) {
+ sprintf(argv[6], "#%d", id);
+ }
+ (*action)(q->vcnt, argv, actarg);
+ for (j = 0; j < q->vcnt; j++)
+ free(argv[j]);
+ free(argv);
+ }
+ sq_destroy(sq);
+ return(SMS_SUCCESS);
+##}
+
+
/* followup_anfq: Add allocation to nfsphys after creating quota.
* argv[0] = filsys_id
* argv[2] = ascii(quota)
fs = *(int *)argv[0];
user = *(int *)argv[1];
quota = atoi(argv[2]);
- who = cl->users_id;
+ who = cl->client_id;
entity = cl->entity;
## repeat replace nq (modtime = "now", modby = @who, modwith = @entity)
id = atoi(argv[i = q->vcnt - 2]);
free(argv[i]);
- name = argv[i] = malloc(9);
-## repeat retrieve (name = users.login) where users.users_id = @id
+ name = argv[i] = malloc(256);
+ if (id > 0)
+## repeat retrieve (name = users.login) where users.users_id = @id
+ else {
+ id = -id;
+## repeat retrieve (name = strings.string) where strings.string_id = @id
+ id = -id;
+ }
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
sprintf(argv[i], "#%d", id);
id = atoi(argv[4]);
free(argv[4]);
- name = argv[4] = malloc(9);
-## repeat retrieve (name = users.login) where users.users_id = @id
+ name = argv[4] = malloc(256);
+ if (id > 0)
+## repeat retrieve (name = users.login) where users.users_id = @id
+ else {
+ id = -id;
+## repeat retrieve (name = strings.string) where strings.string_id = @id
+ id = -id;
+ }
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
sprintf(argv[4], "#%d", id);
char *argv[13], *malloc(), *realloc();
## char *name, acl_type[9], listname[33], active[5], public[5], hidden[5];
## char maillist[5], group[5], gid[6], acl_name[33], desc[256], modtime[27];
-## char modby[9], modwith[9];
+## char modby[256], modwith[9];
## int id, rowcount, acl_id, hid, modby_id;
int returned;
struct save_queue *sq, *sq_create();
sq_save_data(sq, id);
rowcount++;
## }
+ if (ingres_errno) return(sms_errcode);
if (rowcount == 0)
return(SMS_NO_MATCH);
## desc = l.#desc, modtime = l.#modtime, modby_id = l.#modby,
## modwith =l.#modwith)
## where l.list_id = @id
+ if (ingres_errno) return(sms_errcode);
if (atoi(gid) == -1)
argv[6] = UNIQUE_GID;
} else
strcpy(acl_name, "???");
-## repeat retrieve (modby = users.login) where users.users_id = @modby_id
+ if (modby_id > 0)
+## repeat retrieve (modby = users.login) where users.users_id = @modby_id
+ else {
+ modby_id = -modby_id;
+## repeat retrieve (modby = strings.string)
+## where strings.string_id = @modby_id
+ modby_id = -modby_id;
+ }
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1)
- sprintf(modby, "#%d", id);
+ sprintf(modby, "#%d", modby_id);
+ if (ingres_errno) return(sms_errcode);
sms_trim_args(q->vcnt, argv);
returned++;
int ancestors[MAXLISTDEPTH], acount, a;
int descendants[MAXLISTDEPTH], dcount, d;
char *dtypes[MAXLISTDEPTH];
+ char *iargv[3];
## range of m is imembers
lid = *(int *)argv[0];
## endretrieve
}
## }
+ if (ingres_errno) return(sms_errcode);
if (acount >= MAXLISTDEPTH) {
return(SMS_INTERNAL);
}
## endretrieve
}
## }
+ if (ingres_errno) return(sms_errcode);
if (error)
return(SMS_INTERNAL);
}
## where m.list_id = lid and m.member_id = mid and
## m.member_type = mtype
} else {
+ incremental_clear_before();
if (a == 0 && d == 0)
## append imembers (list_id=lid, member_id = mid, direct = 1,
## member_type=mtype, ref_count = 1)
else
## append imembers (list_id=lid, member_id = mid,
## member_type=mtype, ref_count = 1)
+ iargv[0] = (char *)lid;
+ iargv[1] = mtype;
+ iargv[2] = (char *)mid;
+ incremental_after("members", 0, iargv);
}
}
}
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
int ancestors[MAXLISTDEPTH], acount, a;
int descendants[MAXLISTDEPTH], dcount, d;
char *dtypes[MAXLISTDEPTH];
+ char *iargv[3];
## range of m is imembers
lid = *(int *)argv[0];
## repeat retrieve (exists = any(m.list_id where m.list_id=@lid and
## m.member_id = @mid and m.member_type = @mtype
## and m.direct = 1))
+ if (ingres_errno) return(sms_errcode);
if (!exists)
return(SMS_NO_MATCH);
ancestors[0] = lid;
if (acount >= MAXLISTDEPTH)
## endretrieve
## }
+ if (ingres_errno) return(sms_errcode);
if (acount >= MAXLISTDEPTH)
return(SMS_INTERNAL);
descendants[0] = mid;
if (dcount >= MAXLISTDEPTH)
## endretrieve
## }
+ if (ingres_errno) return(sms_errcode);
if (error)
return(SMS_INTERNAL);
}
## where m.list_id = @lid and m.member_id = @mid
## and m.member_type = @mtype
if (cnt <= 1) {
+ iargv[0] = (char *)lid;
+ iargv[1] = mtype;
+ iargv[2] = (char *)mid;
+ incremental_before("members", 0, iargv);
## delete m where m.list_id = lid and m.member_id = mid and
## m.member_type = mtype
+ incremental_clear_after();
} else if (a == 0 && d == 0) {
## replace m (ref_count = m.ref_count-1, direct = 0)
## where m.list_id = lid and m.member_id = mid and
}
}
}
+ if (ingres_errno) return(sms_errcode);
return(SMS_SUCCESS);
##}
## char *login, dir[65], *entity, *directory, machname[33];
## int who, rowcount, mid, uid, users_id, flag, utype, nid, list_id, quota;
## int size, alloc, pid, m_id;
+ char buffer[256], *aargv[3];
int maxsize;
entity = cl->entity;
- who = cl->users_id;
+ who = cl->client_id;
uid = atoi(argv[0]);
login = argv[1];
/* find user */
## repeat retrieve (users_id = u.#users_id)
-## where u.#uid = @uid and u.status = 0
+## where u.#uid = @uid and (u.status = 0 or u.status = 5)
## inquire_equel(rowcount = "rowcount");
if (rowcount == 0)
return(SMS_NO_MATCH);
return(SMS_NOT_UNIQUE);
/* check new login name */
-## repeat retrieve (flag = any(u.#login where u.#login = @login))
+## repeat retrieve (flag = any(u.#login where u.#login = @login and
+## u.#users_id != users_id))
if (ingres_errno) return(sms_errcode);
if (flag) return(SMS_IN_USE);
## repeat retrieve (flag = any(l.#name where l.#name = @login))
return(SMS_NO_POBOX);
/* change login name, set pobox */
+ sprintf(buffer, "u.users_id = %d", users_id);
+ incremental_before("users", buffer, 0);
## repeat replace u (#login = @login, status = 2, modtime = "now",
## modby = @who, modwith = @entity, potype="POP",
## pop_id = @mid, pmodtime="now", pmodby=@who,
return(SMS_INTERNAL);
set_pop_usage(mid, 1);
com_err(whoami, 0, "set login name to %s and pobox to %s", login,
- trim(machname));
+ strtrim(machname));
+ incremental_after("users", buffer, 0);
/* create group list */
if (set_next_object_id("gid", "list"))
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
+ incremental_clear_before();
## repeat append list (name = @login, #list_id = @list_id, active = 1,
## public = 0, hidden = 0, maillist = 0, group = 1,
## #gid = values.value, desc = "User Group",
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
+ sprintf(buffer, "l.list_id = %d", list_id);
+ incremental_after("list", buffer, 0);
+ aargv[0] = (char *) list_id;
+ aargv[1] = "USER";
+ aargv[2] = (char *) users_id;
+ incremental_clear_before();
## repeat append imembers (#list_id = @list_id, member_type = "USER",
## member_id = @users_id, ref_count = 1, direct = 1)
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
+ incremental_after("members", 0, argv);
com_err(whoami, 0, "group list created");
/* decide where to put filesystem */
/* create filesystem */
if (set_next_object_id("filsys_id", "filesys"))
return(SMS_NO_ID);
+ incremental_clear_before();
## repeat append filesys (filsys_id = values.value, phys_id = @pid,
## label = @login, type = "NFS", mach_id = @m_id,
## name = @directory + "/" + @login,
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
+ incremental_after("filesys",
+ "fs.filsys_id = values.value and values.name = \"filsys_id\"",
+ 0);
com_err(whoami, 0, "filesys created on mach %d in %s/%s", m_id,
directory, login);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_NO_QUOTA);
+ incremental_clear_before();
## repeat append nfsquota (#users_id = @users_id, filsys_id = values.value,
## #quota = @quota, phys_id = @pid, modtime = "now",
## modby = @who, modwith = @entity)
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(SMS_INTERNAL);
+ aargv[0] = login;
+ aargv[1] = login;
+ sprintf(buffer, "nq.users_id = %d and nq.filsys_id = values.value and values.name = \"filsys_id\"", users_id);
+ incremental_after("nfsquota", buffer, argv);
com_err(whoami, 0, "quota of %d assigned", quota);
## repeat replace tblstats (updates = tblstats.updates + 1, modtime = "now")
##}
-/* This looks up a login name and returns the SMS internal ID. It is used
- * by authenticate to put the users_id in the client structure.
- */
-
-int get_users_id(name)
-char *name;
-##{
-## int id, rowcount;
-## char *login;
-
- login = name;
-
-## range of u is users
-## repeat retrieve (id = u.#users_id) where u.#login = @login
-## inquire_equel (rowcount = "rowcount")
-
- if (rowcount == 1)
- return(id);
- else
- return(0);
-##}
-
-
/* Check the database at startup time. For now this just resets the
* inprogress flags that the DCM uses.
*/