]> andersk Git - moira.git/blobdiff - server/qaccess.dc
DBMS=ORACLE
[moira.git] / server / qaccess.dc
index e795064cb58e0166ad3d5aab4c398371478edbe1..8a7a0d97509175b5616c64b71078540f7769fb75 100644 (file)
@@ -14,21 +14,20 @@ static char *rcsid_qsupport_dc = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 #include <ctype.h>
 EXEC SQL INCLUDE sqlca;
-EXEC SQL INCLUDE sqlda;
 #include "qrtn.h"
 
 extern char *whoami;
-extern int ingres_errno, mr_errcode;
+extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
 extern char stmt_buf[];
 EXEC SQL END DECLARE SECTION;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 
 /* Specialized Access Routines */
@@ -39,10 +38,10 @@ EXEC SQL WHENEVER SQLERROR CALL ingerr;
  *    now in argv[0] instead of the login name.
  */
 
-access_user(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_user(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if (cl->users_id != *(int *)argv[0])
        return(MR_PERM);
@@ -57,21 +56,31 @@ access_user(q, argv, cl)
  *   argv[0...n] contain search info.  q->
  */
 
-access_login(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_login(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id;
-    char qual[256];
     EXEC SQL END DECLARE SECTION;
 
-    build_qual(q->qual, q->argc, argv, qual);
-    if (!strncmp(q->name,"get_user_account",strlen("get_user_account"))) {
-       EXEC SQL SELECT users_id INTO :id FROM users u, strings str WHERE :qual;
-    } else {
-       EXEC SQL SELECT users_id INTO :id FROM users u WHERE :qual;
+    if(q->argc != 1) return MR_ARGS;
+
+    if(!strcmp(q->shortname, "gual")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u, strings str
+       WHERE u.login LIKE :argv[0] AND u.users_id != 0
+       AND u.comments = str.string_id;
+    } else if (!strcmp(q->shortname, "gubl")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u
+       WHERE u.login LIKE :argv[0] AND u.users_id != 0;
+    } else if (!strcmp(q->shortname, "guau")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u, strings str
+       WHERE u.unix_uid = :argv[0] AND u.users_id != 0
+       AND u.comments = str.string_id;
+    } else if(!strcmp(q->shortname, "gubu")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u
+       WHERE u.unix_uid = :argv[0] AND u.users_id != 0;
     }
 
     if (sqlca.sqlerrd[2] != 1 || id != cl->users_id)
@@ -95,10 +104,10 @@ access_login(q, argv, cl)
  *     and the list is public, allow access if client = member
  */
 
-access_list(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_list(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int list_id, acl_id, flags, gid;
@@ -127,13 +136,15 @@ access_list(q, argv, cl)
        if (*(int *)argv[2] == client_id) return(MR_SUCCESS);
     /* if update_list, don't allow them to change the GID */
     } else if (!strcmp("ulis", q->shortname)) {
-       if ((!strcmp(argv[7], UNIQUE_GID) && (gid != -1)) ||
-           (strcmp(argv[7], UNIQUE_GID) && (gid != atoi(argv[7]))))
-         return(MR_PERM);
+      if (!strcmp(argv[7], UNIQUE_GID)) {
+       if(gid != -1) return MR_PERM;
+      } else {
+       if(gid != atoi(argv[7])) return MR_PERM;
+      }
     }
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status) return(MR_PERM);
 
     return(MR_SUCCESS);
@@ -147,10 +158,10 @@ access_list(q, argv, cl)
  *         cl - client identifier
  */
 
-access_visible_list(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_visible_list(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int list_id, acl_id, flags ;
@@ -174,7 +185,7 @@ access_visible_list(q, argv, cl)
        return(status);
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status)
        return(MR_PERM);
 
@@ -189,10 +200,10 @@ access_visible_list(q, argv, cl)
  *         cl - client identifier
  */
 
-access_vis_list_by_name(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_vis_list_by_name(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int acl_id, flags, rowcount;
@@ -218,7 +229,7 @@ access_vis_list_by_name(q, argv, cl)
        return(status);
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status)
        return(MR_PERM);
 
@@ -231,10 +242,10 @@ access_vis_list_by_name(q, argv, cl)
  * on the acl of, or the list is visible.
  */
 
-access_member(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_member(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if (!strcmp(argv[0], "LIST") || !strcmp(argv[0], "RLIST"))
       return(access_visible_list(q, &argv[1], cl));
@@ -257,10 +268,10 @@ access_member(q, argv, cl)
  * access iff argv[0] == "TRUE" and argv[2] == "FALSE".
  */
 
-access_qgli(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_qgli(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if (!strcmp(argv[0], "TRUE") && !strcmp(argv[2], "FALSE"))
       return(MR_SUCCESS);
@@ -272,10 +283,10 @@ access_qgli(q, argv, cl)
  * allow access if a wildcard is used.
  */
 
-access_service(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_service(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int acl_id;
@@ -296,7 +307,7 @@ access_service(q, argv, cl)
        return(status);
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status) return(MR_PERM);
 
     return(MR_SUCCESS);
@@ -307,10 +318,10 @@ access_service(q, argv, cl)
  *     named by argv[0]
  */
 
-access_filesys(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_filesys(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int users_id, list_id;
@@ -329,7 +340,7 @@ access_filesys(q, argv, cl)
       return(MR_SUCCESS);
     if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
-    status = find_member("LIST", list_id, client_type, client_id, 0);
+    status = find_member("LIST", list_id, client_type, client_id);
     if (status)
       return(MR_SUCCESS);
     else
@@ -342,14 +353,14 @@ access_filesys(q, argv, cl)
 
 int host_access_level = 0;              /* 1 for network, 2 for host */
 
-access_host(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_host(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int mid, sid, users_id, id;
-    char mtype[9], stype[9], *name;
+    int mid, sid, id;
+    char mtype[9], stype[9];
     EXEC SQL END DECLARE SECTION;
     int status, client_id;
     char *client_type;
@@ -361,11 +372,6 @@ access_host(q, argv, cl)
          WHERE s.snet_id=:id;
        mid =0;
     } else if (q->type == RETRIEVE) {
-/*     name = argv[0];
-       EXEC SQL SELECT m.owner_type, m.owner_id, s.owner_type, s.owner_id
-         INTO :mtype, :mid, :stype, :sid FROM machine m, subnet s
-         WHERE m.name=:name and s.snet_id=m.snet_id;
-*/
        return(MR_SUCCESS);
     } else {
        id = *(int *)argv[0];
@@ -378,12 +384,12 @@ access_host(q, argv, cl)
 
     if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
-    status = find_member(stype, sid, client_type, client_id, 0);
+    status = find_member(stype, sid, client_type, client_id);
     if (status) {
        host_access_level = 1;
        return(MR_SUCCESS);
     }
-    status = find_member(mtype, mid, client_type, client_id, 0);
+    status = find_member(mtype, mid, client_type, client_id);
     if (status) {
        host_access_level = 2;
        return(MR_SUCCESS);
@@ -398,10 +404,10 @@ access_host(q, argv, cl)
  * If deleting an alias, any owner will do.
  */
 
-access_ahal(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_ahal(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int cnt, id, mid, sid;
@@ -410,28 +416,46 @@ access_ahal(q, argv, cl)
     char *client_type;
     int status, client_id;
 
+    if (q->type == RETRIEVE)
+      return(MR_SUCCESS);
+
     id = *(int *)argv[1];
 
     EXEC SQL SELECT count(name) INTO :cnt from hostalias WHERE mach_id = :id;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     /* if the type is APPEND, this is ahal and we need to make sure there
      * will be no more than 2 aliases.  If it's not, it must be dhal and
      * any owner will do.
      */
     if (q->type == APPEND && cnt >= 2)
       return(MR_PERM);
-
     EXEC SQL SELECT m.owner_type, m.owner_id, s.owner_type, s.owner_id
       INTO :mtype, :mid, :stype, :sid FROM machine m, subnet s
       WHERE m.mach_id=:id and s.snet_id=m.snet_id;
     if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
-    status = find_member(mtype, mid, client_type, client_id, 0);
+    status = find_member(mtype, mid, client_type, client_id);
     if (status)
       return(MR_SUCCESS);
-    status = find_member(stype, sid, client_type, client_id, 0);
+    status = find_member(stype, sid, client_type, client_id);
     if (status)
       return(MR_SUCCESS);
     else
       return(MR_PERM);
 }
+
+
+
+/* access_snt - check for retrieving network structure
+ */
+
+int access_snt(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
+{
+    if(q->type == RETRIEVE)
+       return(MR_SUCCESS);
+
+    return(MR_PERM);
+}
This page took 0.1501 seconds and 4 git commands to generate.