]> andersk Git - moira.git/commitdiff
Initial revision
authorwesommer <wesommer>
Sat, 22 Aug 1987 18:03:20 +0000 (18:03 +0000)
committerwesommer <wesommer>
Sat, 22 Aug 1987 18:03:20 +0000 (18:03 +0000)
clients/mrtest/Makefile [new file with mode: 0644]
clients/mrtest/mrtest.c [new file with mode: 0644]
clients/mrtest/test_cmds.ct [new file with mode: 0644]
clients/userreg/reg_stubs.c [new file with mode: 0644]
include/com_err.h [new file with mode: 0644]
include/ureg_proto.h [new file with mode: 0644]
lib/ureg_err.et [new file with mode: 0644]
reg_svr/unreg_user.qc [new file with mode: 0644]

diff --git a/clients/mrtest/Makefile b/clients/mrtest/Makefile
new file mode 100644 (file)
index 0000000..11bbeb6
--- /dev/null
@@ -0,0 +1,34 @@
+#
+#      $Source$
+#      $Header$
+#
+
+
+LIBS = ../rpc/libsms.a ../gdb/libgdb.a 
+LLIBS= -L../lib -lkrb -ldes -lss -lcom_err -lm -lc 
+
+COPTS= -O
+
+INCDIRS=-I../include
+
+CFLAGS= ${INCDIRS} ${COPTS}
+
+.SUFFIXES: .ct
+
+.ct.o: ; make_commands $*.ct
+
+all: smstest smsfinger
+
+smstest: test_cmds.o test.o ${LIBS} 
+       cc ${COPTS} -o $@ test_cmds.o test.o ${LIBS} ${LLIBS}
+
+smsfinger: smsfinger.o ${LIBS} 
+       cc ${COPTS} -o $@ smsfinger.o ${LIBS} ${LLIBS}
+
+clean:
+       rm -f *.o core \#* *~ gmon.out
+       rm -f smstest smsfinger
+
+       
+
+
diff --git a/clients/mrtest/mrtest.c b/clients/mrtest/mrtest.c
new file mode 100644 (file)
index 0000000..62944bf
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ *     $Source$
+ *     $Header$
+ */
+
+#ifndef lint
+static char *rcsid_test_c = "$Header$";
+#endif lint
+
+/*
+ *     $Source$
+ *     $Author$
+ *     $Header$
+ *
+ *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *
+ *     $Log$
+ *     Revision 1.1  1987-08-22 18:31:59  wesommer
+ *     Initial revision
+ *
+ */
+
+#ifndef lint
+static char *rcsid_test_c = "$Header$";
+#endif lint
+
+#include <stdio.h>
+#include <sms.h>
+#include <ss.h>
+
+int ss;
+extern ss_request_table sms_test;
+
+#ifndef __SABER__
+main(argc, argv)
+       int argc;
+       char **argv;
+#else __SABER__
+sms()
+#endif __SABER__
+{      
+       int status;
+       char *whoami;
+       
+#ifndef __SABER__
+       whoami = argv[0];
+#else
+       whoami = "sms";
+#endif __SABER__
+       
+       init_ss_err_tbl();
+       init_sms_err_tbl();
+       init_krb_err_tbl();
+
+       ss = ss_create_invocation("sms", "0.1", (char *)NULL,
+                                 &sms_test, &status);
+       if (status != 0) {
+               com_err(whoami, status, "Unable to create invocation");
+               exit(1);
+       }
+       ss_listen(ss, &status);
+       if (status != 0) {
+               com_err(whoami, status, 0);
+               exit(1);
+       }
+}
+
+test_noop()
+{
+       int status = sms_noop();
+       if (status) ss_perror(ss, status, 0);
+}
+
+test_connect()
+{
+       int status = sms_connect();
+       if (status) ss_perror(ss, status, 0);
+}
+
+test_disconnect()
+{
+       int status = sms_disconnect();
+       if (status) ss_perror(ss, status, 0);
+}
+
+test_auth()
+{
+       int status = sms_auth();
+       if (status) ss_perror(ss, status, 0);
+}
+
+char *concat(str1, str2)
+       char *str1, *str2;
+{
+       char *rtn;
+       extern char *malloc();
+       
+       if (!str1) {
+               int len = strlen(str2) + 1 ;
+               rtn = malloc(len);
+               bcopy(str2, rtn, len);
+       } else {
+               int len1 = strlen(str1);
+               int len2 = strlen(str2) + 1;
+               rtn = malloc(len1+len2);
+               bcopy(str1, rtn, len1);
+               bcopy(str2, rtn+len1, len2);
+       }
+       return rtn;
+}
+
+test_shutdown(argc, argv)
+       int argc;
+       char **argv;
+{
+       char *reason = NULL;
+       int status, i;
+       
+       if (argc < 2) {
+               ss_perror(ss, 0, "Usage: shutdown reason ...");
+               return;
+       }
+       
+       for (i = 1 ; i < argc; i++) {
+               if (i != 1) reason = concat(reason, " ");
+               reason = concat(reason, argv[i]);
+       }
+       status = sms_shutdown(reason);
+       if (status) ss_perror(ss, status, 0);
+}
+static int count;
+
+
+print_reply(argc, argv)
+       int argc;
+       char **argv;
+{
+       int i;
+       for (i = 0; i < argc; i++) {
+               if (i != 0) printf(", ");
+               printf("%s", argv[i]);
+       }
+       printf("\n");
+       count++;
+}
+
+test_query(argc, argv)
+       int argc;
+       char **argv;
+{
+       int status;
+       if (argc < 2) {
+               ss_perror(ss, 0, "Usage: query handle [ args ... ]");
+               return;
+       }
+       count = 0;
+       status = sms_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
+       printf("%d tuples\n", count);
+       if (status) ss_perror(ss, status, 0);
+}
+
+test_access(argc, argv)
+       int argc;
+       char **argv;
+{
+       int status;
+       if (argc < 2) {
+               ss_perror(ss, 0, "Usage: access handle [ args ... ]");
+               return;
+       }
+       status = sms_access(argv[1], argc-2, argv+2);
+       if (status) ss_perror(ss, status, 0);
+}
+
diff --git a/clients/mrtest/test_cmds.ct b/clients/mrtest/test_cmds.ct
new file mode 100644 (file)
index 0000000..862c69a
--- /dev/null
@@ -0,0 +1,38 @@
+       command_table sms_test;
+
+       request ss_quit, "Exit the program",
+               quit, q;
+
+       request test_noop, "Ask SMS to do nothing",
+               noop;
+
+       request test_connect, "Connect to SMS",
+               connect, c;
+
+       request test_disconnect, "Disconnect from SMS",
+               disconnect;
+
+       request test_query, "Make a query.",
+               query;
+
+       request test_shutdown, "Shut down SMS.",
+               shutdown;
+
+       request test_auth, "Authenticate to SMS.",
+               auth;
+
+       request test_access, "Check access to an SMS query.",
+               access;
+
+       request ss_self_identify, "Identify the subsystem.",
+               ".",
+               (dont_list, dont_summarize);
+
+       request ss_list_requests, "List available commands.",
+               list_requests, lr, "?";
+
+       request ss_quit, "Leave the subsystem.",
+               quit, q;
+
+       end;
+
diff --git a/clients/userreg/reg_stubs.c b/clients/userreg/reg_stubs.c
new file mode 100644 (file)
index 0000000..e51775d
--- /dev/null
@@ -0,0 +1,298 @@
+/*
+ *     $Source$
+ *     $Author$
+ *     $Header$
+ *
+ *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *
+ *     $Log$
+ *     Revision 1.1  1987-08-22 18:39:29  wesommer
+ *     Initial revision
+ *
+ */
+
+#ifndef lint
+static char *rcsid_reg_stubs_c = "$Header$";
+#endif lint
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <des.h>
+#include <errno.h>
+#include "ureg_err.h"
+#include "ureg_proto.h"
+#include <strings.h>
+
+static int reg_sock = -1;
+extern errno;
+#define UNKNOWN_HOST -1
+#define UNKNOWN_SERVICE -2
+
+ureg_init()
+{
+    struct servent *sp;
+    struct hostent *hp;
+    struct sockaddr_in sin;
+    
+    init_ureg_err_tbl();
+    init_sms_err_tbl();
+    
+    hp = gethostbyname("sms.mit.edu");
+    if (hp == NULL) return UNKNOWN_HOST;
+
+    sp = getservbyname("sms_ureg", "udp");
+
+    if (sp == NULL) return UNKNOWN_SERVICE;
+    
+    (void) close(reg_sock);
+    reg_sock = socket(AF_INET, SOCK_DGRAM, 0);
+    if (reg_sock < 0) return errno;
+
+    bzero((char *)&sin, sizeof(sin));
+    sin.sin_port = sp->s_port;
+    bcopy(hp->h_addr, (char *)&sin.sin_addr, sizeof(struct in_addr));
+    sin.sin_family = AF_INET;
+
+    if (connect(reg_sock, &sin, sizeof(sin)) < 0)
+       return errno;
+    return 0;
+}
+
+static int seq_no = 0;
+int
+verify_user(first, last, idnumber, hashidnumber, login)
+    char *first, *last, *idnumber, *hashidnumber, *login;
+{
+    char buf[1024];
+    int version = ntohl((u_long)1);
+    int call = ntohl((u_long)UREG_VERIFY_USER);
+    C_Block key;
+    Key_schedule ks;
+    register char *bp = buf;
+    register int len;
+    char crypt_src[1024];
+    
+    bcopy((char *)&version, bp, sizeof(int));
+    bp += sizeof(int);
+    seq_no++;
+    bcopy((char *)&seq_no, bp, sizeof(int));
+
+    bp += sizeof(int);
+
+    bcopy((char *)&call, bp, sizeof(int));
+
+    bp += sizeof(int);
+
+    (void) strcpy(bp, first);
+    bp += strlen(bp)+1;
+
+    (void) strcpy(bp, last);
+    bp += strlen(bp)+1;
+
+    len = strlen(idnumber) + 1;
+    bcopy(idnumber, crypt_src, len);
+
+    bcopy(hashidnumber, crypt_src+len, 13);
+
+    string_to_key(hashidnumber, key);
+    key_sched(key, ks);
+    pcbc_encrypt(crypt_src, bp, len+14, ks, key, 1);
+    bp += len+14+8;
+    len = bp - buf;
+    return do_call(buf, len, seq_no, login);
+}
+
+grab_login(first, last, idnumber, hashidnumber, login)
+    char *first, *last, *idnumber, *hashidnumber, *login;
+{
+    char buf[1024];
+    int version = ntohl((u_long)1);
+    int call = ntohl((u_long)UREG_RESERVE_LOGIN);
+    C_Block key;
+    Key_schedule ks;
+    register char *bp = buf;
+    register int len;
+    int i;
+    
+    char crypt_src[1024];
+    char *cbp;
+    
+    bcopy((char *)&version, bp, sizeof(int));
+    bp += sizeof(int);
+    seq_no++;
+    bcopy((char *)&seq_no, bp, sizeof(int));
+
+    bp += sizeof(int);
+
+    bcopy((char *)&call, bp, sizeof(int));
+
+    bp += sizeof(int);
+
+    (void) strcpy(bp, first);
+    bp += strlen(bp)+1;
+
+    (void) strcpy(bp, last);
+    bp += strlen(bp)+1;
+
+    len = strlen(idnumber) + 1;
+    cbp = crypt_src;
+    
+    bcopy(idnumber, crypt_src, len);
+    cbp += len;
+    
+    bcopy(hashidnumber, cbp, 14);
+    cbp += 14;
+    
+    len = strlen(login) + 1;
+    bcopy(login, cbp, len);
+    cbp += len;
+
+    len = cbp - crypt_src;
+    string_to_key(hashidnumber, key);
+    key_sched(key, ks);
+    pcbc_encrypt(crypt_src, bp, len, ks, key, 1);
+#ifdef notdef    
+    for (i = 0; i < len; i++) {
+       printf("%02.2x ", (unsigned char)bp[i]);
+    }
+    printf("\n");
+#endif notdef
+    len = ((len + 7) >> 3) << 3;
+    bp += len;
+    
+    len = bp - buf;
+    return do_call(buf, len, seq_no, 0);
+
+}
+
+set_password(first, last, idnumber, hashidnumber, password)
+    char *first, *last, *idnumber, *hashidnumber, *password;
+{
+    char buf[1024];
+    int version = ntohl((u_long)1);
+    int call = ntohl((u_long)UREG_SET_PASSWORD);
+    C_Block key;
+    Key_schedule ks;
+    register char *bp = buf;
+    register int len;
+    int i;
+    
+    char crypt_src[1024];
+    char *cbp;
+    
+    bcopy((char *)&version, bp, sizeof(int));
+    bp += sizeof(int);
+    seq_no++;
+    bcopy((char *)&seq_no, bp, sizeof(int));
+
+    bp += sizeof(int);
+
+    bcopy((char *)&call, bp, sizeof(int));
+
+    bp += sizeof(int);
+
+    (void) strcpy(bp, first);
+    bp += strlen(bp)+1;
+
+    (void) strcpy(bp, last);
+    bp += strlen(bp)+1;
+
+    len = strlen(idnumber) + 1;
+    cbp = crypt_src;
+    
+    bcopy(idnumber, crypt_src, len);
+    cbp += len;
+    
+    bcopy(hashidnumber, cbp, 14);
+    cbp += 14;
+    
+    len = strlen(password) + 1;
+    bcopy(password, cbp, len);
+    cbp += len;
+
+    len = cbp - crypt_src;
+    string_to_key(hashidnumber, key);
+    key_sched(key, ks);
+    pcbc_encrypt(crypt_src, bp, len, ks, key, 1);
+#ifdef notdef    
+    for (i = 0; i < len; i++) {
+       printf("%02.2x ", (unsigned char)bp[i]);
+    }
+    printf("\n");
+#endif notdef
+    len = ((len + 7) >> 3) << 3;
+    bp += len;
+    
+    len = bp - buf;
+    return do_call(buf, len, seq_no, 0);
+
+}
+
+static do_call(buf, len, seq_no, login)
+    char *buf;
+    char *login;
+    int seq_no;
+    int len;
+{
+    struct timeval timeout;
+    char ibuf[1024];
+    fd_set set;
+    
+    int retry = 0;
+
+    do {
+       if (write(reg_sock, buf, len) != len) return errno;
+
+       FD_ZERO(&set);
+       FD_SET(reg_sock, &set);
+       timeout.tv_sec = 10;
+       timeout.tv_usec = 0;
+       do {
+           int rtn;
+           struct sockaddr_in sin;
+           int addrlen = sizeof(sin);
+           int vno;
+           int sno;
+           int stat;
+           
+           rtn = select(reg_sock+1, &set, (fd_set *)0, (fd_set *)0, &timeout);
+           if (rtn == 0)
+               break;
+           else if (rtn < 0) return errno;
+       
+           len = recvfrom(reg_sock, ibuf, BUFSIZ, 0, &sin, &addrlen);
+           if (len < 0) return errno;
+           if (len < 12) return UREG_BROKEN_PACKET;
+           bcopy(ibuf, (char *)&vno, sizeof(long));
+           vno = ntohl((u_long)vno);
+           if (vno != 1) continue;
+           bcopy(ibuf + 4, (char *)&sno, sizeof(long));
+
+           if (sno != seq_no) continue;
+
+           bcopy(ibuf + 8, (char *)&stat, sizeof(long));
+           stat = ntohl((u_long)stat);
+           if (login) {
+               bcopy(ibuf+12, login, len-12);
+               login[len-12] = '\0';
+           }
+           return stat;
+       } while (1);
+    } while (++retry < 6);
+    return ETIMEDOUT;
+}    
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-continued-statement-offset: 4
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * End:
+ */
diff --git a/include/com_err.h b/include/com_err.h
new file mode 100644 (file)
index 0000000..31241ac
--- /dev/null
@@ -0,0 +1,18 @@
+#include "mit-sipb-copyright.h"
+
+#ifdef __SABER__
+void com_err(char *, int, char *, ...);
+char *error_message(int);
+void perror(char *);
+/* too painful to do right.  someday... */
+int (*com_err_hook)();
+int (*set_com_err_hook())();
+int (*reset_com_err_hook())();
+#else
+void com_err();
+char *error_message();
+void perror();
+int (*com_err_hook)();
+int (*set_com_err_hook())();
+int (*reset_com_err_hook())();
+#endif /* __SABER__ */
diff --git a/include/ureg_proto.h b/include/ureg_proto.h
new file mode 100644 (file)
index 0000000..8cc223d
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ *     $Source$
+ *     $Author$
+ *     $Header$
+ *
+ *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ *
+ *     $Log$
+ *     Revision 1.1  1987-08-22 18:40:35  wesommer
+ *     Initial revision
+ *
+ */
+
+#define UREG_VERIFY_USER 0
+#define UREG_RESERVE_LOGIN 1
+#define UREG_SET_PASSWORD 2
+/*
+ * Local Variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-continued-statement-offset: 4
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * End:
+ */
diff --git a/lib/ureg_err.et b/lib/ureg_err.et
new file mode 100644 (file)
index 0000000..8a2dfff
--- /dev/null
@@ -0,0 +1,16 @@
+       error_table     ureg
+
+       ec      UREG_ALREADY_REGISTERED, "User already registered"
+       ec      UREG_USER_NOT_FOUND, "Unable to locate user in database"
+       ec      UREG_UNKNOWN_HOST, "Unknown host SMS"
+       ec      UREG_UNKNOWN_SERVICE, "Unknown service sms_ureg/udp"
+       ec      UREG_UNKNOWN_REQUEST, "Unknown request to userreg server"
+       ec      UREG_BROKEN_PACKET, "Unable to parse request packet"
+       ec      UREG_WRONG_VERSION, "Wrong version of protocol"
+       ec      UREG_LOGIN_USED, "That login name is already in use"
+       ec      UREG_INVALID_UNAME, "Not valid as a login name"
+       ec      UREG_NO_PASSWD_YET, "Password not yet set."
+       ec      UREG_NO_LOGIN_YET, "Cannot set password when no login name set."
+       end
+
+       
diff --git a/reg_svr/unreg_user.qc b/reg_svr/unreg_user.qc
new file mode 100644 (file)
index 0000000..f488992
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Run the salvager after doing this!! 
+ */
+
+main()
+{
+
+##     ingres sms
+##     range of u is users
+##     range of f is filesys
+##     range of p is pobox
+##     range of l is list
+##     range of nq is nfsquota
+
+##     replace u (status = 0, login="#1003") where u.login = "tau"
+       
+##     delete f where f.label = "tau"
+##     delete p where p.box = "tau"
+##     delete l where l.name = "tau"
+##     delete nq where nq.users_id = 14651
+
+}
This page took 0.057952 seconds and 5 git commands to generate.