pacify gcc -Wall.
fix rcsid strings and copyrights
awk -f db2rest.awk < ../db/schema.sql > rest.pc
rest1.pc: rest.pc
clean::
- $(RM) bkup.pc bkup1.pc rest.pc rest1.pc
+ $(RM) bkup.pc bkup1.pc bkup.h rest.pc rest1.pc rest.h
sqlfile(dump_db)
sqlfile(rest_db)
sqlfile(dumprest)
-# $Source$
-# $Header$
+# $Id $
#
# This converts the file used to originally create the database
# into a program to back it up.
BEGIN {
print "/* This file automatically generated */";
print "/* Do not edit */\n";
- print "#include <stdio.h>";
print "EXEC SQL INCLUDE sqlca;";
print "EXEC SQL WHENEVER SQLERROR DO dbmserr();";
print "#include \"dump_db.h\"";
+ print "#include \"bkup.h\"";
print "#define dump_bin dump_str\n";
print "/* This file automatically generated */" > "bkup1.pc";
print "/* Do not edit */\n" >> "bkup1.pc";
- print "#include <stdio.h>" >> "bkup1.pc";
- print "FILE *open_file(char *prefix, char *suffix);\n" >> "bkup1.pc";
- print "int do_backups(char *prefix)\n{" >> "bkup1.pc";
+ print "#include \"dump_db.h\"" >> "bkup1.pc";
+ print "#include \"bkup.h\"" >> "bkup1.pc";
+ print "void do_backups(char *prefix)\n{" >> "bkup1.pc";
+
+ print "/* This file automatically generated */" > "bkup.h";
+ print "/* Do not edit */\n" >> "bkup.h";
}
$1=="#" { next; }
/^create/ {
- printf "int dump_%s(FILE *f)\n{\n EXEC SQL BEGIN DECLARE SECTION;\n", $3;
+ printf "void dump_%s(FILE *f)\n{\n EXEC SQL BEGIN DECLARE SECTION;\n", $3;
printf " dump_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "bkup1.pc";
+ printf "void dump_%s(FILE *f);\n", $3 >> "bkup.h";
tablename = $3;
rangename = substr(tablename, 1, 1);
-# $Source$
-# $Header$
+# $Id $
#
# This converts the file used to originally create the database
# into a program to restore it from a backup.
BEGIN {
print "/* This file automatically generated */";
print "/* Do not edit */\n";
- print "#include <stdio.h>";
print "EXEC SQL INCLUDE sqlca;";
print "EXEC SQL WHENEVER SQLERROR DO dbmserr();";
- print "void parse_nl(FILE *), parse_str(FILE *, char *, int), parse_sep(FILE *);\n";
+ print "#include <com_err.h>";
+ print "#include \"dump_db.h\"";
+ print "#include \"rest.h\"";
print "/* This file automatically generated */" > "rest1.pc";
print "/* Do not edit */\n" >> "rest1.pc";
- print "#include <stdio.h>" >> "rest1.pc";
- print "FILE *open_file(char *prefix, char *suffix);\n" >> "rest1.pc";
- print "int do_restores(char *prefix)\n{" >> "rest1.pc";
+ print "#include \"dump_db.h\"" >> "rest1.pc";
+ print "#include \"rest.h\"" >> "rest1.pc";
+ print "void do_restores(char *prefix)\n{" >> "rest1.pc";
+
+ print "/* This file automatically generated */" > "bkup.h";
+ print "/* Do not edit */\n" >> "bkup.h";
}
$1=="#" { next; }
/^create/ {
- printf "int restore_%s(FILE *f)\n", $3;
+ printf "void restore_%s(FILE *f)\n", $3;
print "{\n EXEC SQL BEGIN DECLARE SECTION;";
printf " restore_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "rest1.pc";
+ printf "void restore_%s(FILE *f);\n", $3 >> "rest.h";
tablename = $3;
rangename = substr(tablename, 1, 1);
-/* $Header$ */
+/* $Id $ */
+
+#include <stdio.h>
+#include <moira.h>
#define SEP_CHAR ('|')
+void do_backups(char *prefix);
+void do_restores(char *prefix);
+
+void dump_int(FILE *f, int n);
+void dump_str(FILE *f, char *str);
#define dump_nl(f) { if (putc('\n', f) < 0) wpunt(); }
#define dump_sep(f) { if (putc(SEP_CHAR, f) < 0) wpunt(); }
+
+int parse_int(FILE *f);
+void parse_str(FILE *f, char *buf, int maxlen);
+void parse_sep(FILE *f);
+void parse_nl(FILE *f);
+
+void wpunt(void);
+void punt(char *msg);
+void dbmserr(void);
+void safe_close(FILE *stream);
+FILE *open_file(char *prefix, char *suffix);
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+/* $Id $
*
* This program dumps the Moira database to a series of output files
* which can be later read back into Moira in the event of a crash.
*
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_dump_db_c = "$Header$";
-#endif lint
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <ctype.h>
#include <mit-copyright.h>
-EXEC SQL INCLUDE sqlca;
+#include <moira.h>
#include "dump_db.h"
-/* putc without the line buffer hair */
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
-#define putc1(x, p) (--(p)->_cnt >= 0 ?\
- (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\
- _flsbuf((unsigned char)(x), p))
+EXEC SQL INCLUDE sqlca;
-FILE *open_file();
+RCSID("$Header$");
EXEC SQL BEGIN DECLARE SECTION;
char *db = "moira";
int main(int argc, char **argv)
{
char *prefix;
- int i;
if (argc != 2)
{
exit(0);
}
-int dump_int(FILE *f, int n)
+void dump_int(FILE *f, int n)
{
char buf[1024];
sprintf(buf, "%d", n);
dump_str(f, buf);
}
-int wpunt(void)
+void wpunt(void)
{
punt("can't write backup file");
}
-int dump_str(FILE *f, char *str)
+void dump_str(FILE *f, char *str)
{
char *ibp, c;
int t;
- for (ibp = str; c = (unsigned char) *ibp; ibp++)
+ for (ibp = str; (c = *ibp); ibp++)
{
if (c < 32 || c > 126 || c == SEP_CHAR || c == '\\')
{
- if (putc1('\\', f) < 0)
+ if (putc('\\', f) < 0)
wpunt();
t = ((c >> 6) & 7) + '0';
- if (putc1(t, f) < 0)
+ if (putc(t, f) < 0)
wpunt();
t = ((c >> 3) & 7) + '0';
- if (putc1(t, f) < 0)
+ if (putc(t, f) < 0)
wpunt();
t = (c & 7) + '0';
- if (putc1(t, f) < 0)
+ if (putc(t, f) < 0)
wpunt();
}
else
{
- if (putc1(c, f) < 0)
+ if (putc(c, f) < 0)
wpunt();
}
}
}
-int safe_close(FILE *stream)
+void safe_close(FILE *stream)
{
if (fflush(stream) == EOF)
punt("Unable to fflush");
fprintf(stderr, "Working on %s\n", name);
return f;
}
-
-
-/*
- * Trim whitespace off both ends of a string.
- */
-char *strtrim(char *save)
-{
- char *t, *s;
-
- s = save;
- while (isspace(*s))
- s++;
- /* skip to end of string */
- if (*s == '\0')
- {
- *save = '\0';
- return save;
- }
-
- for (t = s; *t; t++)
- continue;
- while (t > s)
- {
- --t;
- if (!isspace(*t))
- {
- t++;
- break;
- }
- }
- *t = '\0';
- return s;
-}
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+/* $Id$
*
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_dumprest_qc = "$Header$";
-#endif lint
+#include <mit-copyright.h>
+#include <moira.h>
+#include "dump_db.h"
#include <stdio.h>
-#include <mit-copyright.h>
-int punt(char *msg)
+RCSID("$Header$");
+
+extern void sqlglm(char *, unsigned int *, unsigned int *);
+
+void punt(char *msg)
{
perror(msg);
exit(1);
}
-int dbmserr(void)
+void dbmserr(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char err_msg[256];
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * This program restores the Moira database from an mrbackup.
*
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_rest_db_qc = "$Header$";
-#endif lint
+#include <mit-copyright.h>
+#include <moira.h>
+#include "dump_db.h"
-#include <sys/file.h>
-#include <stdio.h>
-#include <fcntl.h>
#include <ctype.h>
-#include <mit-copyright.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
EXEC SQL INCLUDE sqlca;
-#include "dump_db.h"
+RCSID("$Header$");
+
+int yes_or_no(char *prompt);
int main(int argc, char **argv)
{
if (getc(f) != SEP_CHAR)
punt("Expected Separator");
}
+
void parse_nl(FILE *f)
{
if (getc(f) != '\n')
punt("Expected newline");
}
-
FILE *open_file(char *prefix, char *suffix)
{
char name[BUFSIZ];
-/* $Header$
+/* $Id $
*
- * Program to add users en batch to the moira database
+ * Program to add users en masse to the moira database
*
* by Mark Rosenstein, July 1992.
*
- * Copyright 1992 by the Massachusetts Institute of Technology.
- *
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
* <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <des.h>
-#include <krb.h>
#include <moira.h>
#include <moira_site.h>
-#ifndef LINT
-static char adduser_rcsid[] = "$Header$";
-#endif
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+RCSID("$Header$");
#ifdef ATHENA
#define DEFAULT_SHELL "/bin/athena/tcsh"
char *whoami;
int duplicate, errors;
-extern char *FixCase(), *RemoveHyphens(), *strtrim();
-extern int errno;
-int usercheck(), scream();
+extern int ureg_init(void);
+extern int grab_login(char *first, char *last, char *idnumber,
+ char *hashidnumber, char *login);
+extern int set_password(char *first, char *last, char *idnumber,
+ char *hashidnumber, char *password);
+
+void usage(char **argv);
+int usercheck(int argc, char **argv, void *qargv);
int main(int argc, char **argv)
{
dargv[1] = qargv[U_LAST];
duplicate = 0;
status = mr_query("get_user_account_by_name", 2, dargv,
- usercheck, (char *) qargv);
+ usercheck, qargv);
if (status && status != MR_NO_MATCH)
{
com_err(whoami, status,
}
}
status = mr_query("add_user_account", U_SECURE + 1, qargv,
- scream, NULL);
+ NULL, NULL);
if (status)
{
com_err(whoami, status, "adding user %s %s", first, last);
}
-usage(char **argv)
+void usage(char **argv)
{
fprintf(stderr, "Usage: %s [options]\n", argv[0]);
fprintf(stderr, "Options are\n");
}
-/* Called only if a query returns a value that we weren't expecting */
-
-scream(void)
-{
- fprintf(stderr, "Programmer botch\n");
- exit(3);
-}
-
-
/* query callback routine to check for duplicate users */
-usercheck(int argc, char **argv, char **qargv)
+int usercheck(int argc, char **argv, void *qargv)
{
- if (!strcmp(argv[U_MITID], qargv[U_MITID]))
+ if (!strcmp(argv[U_MITID], ((char **)qargv)[U_MITID]))
duplicate++;
else
duplicate--;
+
+ return MR_CONT;
}
-/* $Header$
+/* $Id $
*
* Command line oriented Moira List tool.
*
* by Mark Rosenstein, September 1988.
*
- * Copyright 1989 by the Massachusetts Institute of Technology.
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
* <mit-copyright.h>.
*/
-/* ### Aren't there a lot of sq abstraction barrier violations here?
- Do we need to improve the support for queue operations? */
-
#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <string.h>
-#include <moira.h>
-#include <moira_site.h>
-
-#ifndef LINT
-static char blanche_rcsid[] = "$Header$";
-#endif
+RCSID("$Header$");
struct member {
int type;
char *listname, *whoami;
-int show_list_info(), show_list_count(), get_list_members(), scream();
-int show_list_members(), membercmp(), save_list_info();
-struct member *parse_member();
+void usage(char **argv);
+void show_list_member(struct member *memberstruct);
+int show_list_info(int argc, char **argv, void *hint);
+int save_list_info(int argc, char **argv, void *hint);
+int show_list_count(int argc, char **argv, void *hint);
+void recursive_display_list_members(void);
+void unique_add_member(struct save_queue *q, struct member *m);
+int get_list_members(int argc, char **argv, void *sq);
+void get_members_from_file(char *filename, struct save_queue *queue);
+int collect(int argc, char **argv, void *l);
+struct member *parse_member(char *s);
+int membercmp(const void *mem1, const void *mem2);
+int sq_count_elts(struct save_queue *q);
int main(int argc, char **argv)
{
case M_ANY:
case M_USER:
argv[7] = "USER";
- status = mr_query("add_list", 10, argv, scream, NULL);
+ status = mr_query("add_list", 10, argv, NULL, NULL);
if (owner->type != M_ANY || status != MR_USER)
break;
case M_LIST:
argv[7] = "LIST";
- status = mr_query("add_list", 10, argv, scream, NULL);
+ status = mr_query("add_list", 10, argv, NULL, NULL);
break;
case M_KERBEROS:
argv[7] = "KERBEROS";
- status = mr_query("add_list", 10, argv, scream, NULL);
+ status = mr_query("add_list", 10, argv, NULL, NULL);
break;
}
}
argv[7] = "USER";
argv[8] = getenv("USER");
- status = mr_query("add_list", 10, argv, scream, NULL);
+ status = mr_query("add_list", 10, argv, NULL, NULL);
}
if (status)
char *argv[11];
status = mr_query("get_list_info", 1, &listname,
- save_list_info, (char *)argv);
+ save_list_info, argv);
if (status)
{
com_err(whoami, status, "while getting list information");
case M_ANY:
case M_USER:
argv[8] = "USER";
- status = mr_query("update_list", 11, argv, scream, NULL);
+ status = mr_query("update_list", 11, argv, NULL, NULL);
if (owner->type != M_ANY || status != MR_USER)
break;
case M_LIST:
argv[8] = "LIST";
- status = mr_query("update_list", 11, argv, scream, NULL);
+ status = mr_query("update_list", 11, argv, NULL, NULL);
break;
case M_KERBEROS:
argv[8] = "KERBEROS";
- status = mr_query("update_list", 11, argv, scream, NULL);
+ status = mr_query("update_list", 11, argv, NULL, NULL);
break;
}
}
else
- status = mr_query("update_list", 11, argv, scream, NULL);
+ status = mr_query("update_list", 11, argv, NULL, NULL);
if (status)
com_err(whoami, status, "while updating list.");
if (syncflg)
{
status = mr_query("get_members_of_list", 1, &listname,
- get_list_members, (char *)memberlist);
+ get_list_members, memberlist);
if (status)
{
com_err(whoami, status, "getting members of list %s", listname);
if (memberstruct->type == M_STRING &&
(p = strchr(memberstruct->name, '@')))
{
- char *host = canonicalize_hostname(strsave(++p));
+ char *host = canonicalize_hostname(strdup(++p));
static char **mailhubs = NULL;
char *argv[4];
- int i, collect();
+ int i;
if (!mailhubs)
{
mailhubs = malloc(sizeof(char *));
mailhubs[0] = NULL;
status = mr_query("get_alias", 3, argv, collect,
- (char *)&mailhubs);
+ &mailhubs);
if (status != MR_SUCCESS && status != MR_NO_MATCH)
{
com_err(whoami, status,
{
if (!strcasecmp(p, host))
{
- host = strsave(memberstruct->name);
+ host = strdup(memberstruct->name);
*(strchr(memberstruct->name, '@')) = 0;
memberstruct->type = M_ANY;
fprintf(stderr, "Warning: \"STRING:%s\" converted to "
case M_ANY:
case M_USER:
membervec[1] = "USER";
- status = mr_query("add_member_to_list", 3, membervec, scream, NULL);
+ status = mr_query("add_member_to_list", 3, membervec, NULL, NULL);
if (status == MR_SUCCESS)
break;
else if (status != MR_USER || memberstruct->type != M_ANY)
case M_LIST:
membervec[1] = "LIST";
status = mr_query("add_member_to_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status == MR_SUCCESS)
{
if (!strcmp(membervec[0], getenv("USER")))
membervec[1] = "STRING";
status = mr_query("add_member_to_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status != MR_SUCCESS)
{
com_err(whoami, status, "while adding member %s to %s",
case M_KERBEROS:
membervec[1] = "KERBEROS";
status = mr_query("add_member_to_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status != MR_SUCCESS)
{
com_err(whoami, status, "while adding member %s to %s",
case M_USER:
membervec[1] = "USER";
status = mr_query("delete_member_from_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status == MR_SUCCESS)
break;
else if ((status != MR_USER && status != MR_NO_MATCH) ||
case M_LIST:
membervec[1] = "LIST";
status = mr_query("delete_member_from_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status == MR_SUCCESS)
break;
else if ((status != MR_LIST && status != MR_NO_MATCH) ||
case M_STRING:
membervec[1] = "STRING";
status = mr_query("delete_member_from_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status == MR_STRING && memberstruct->type == M_ANY)
{
com_err(whoami, 0, " Unable to find member %s to delete from %s",
case M_KERBEROS:
membervec[1] = "KERBEROS";
status = mr_query("delete_member_from_list", 3, membervec,
- scream, NULL);
+ NULL, NULL);
if (status != MR_SUCCESS)
{
com_err(whoami, status, "while deleting member %s from %s",
else
{
status = mr_query("get_members_of_list", 1, &listname,
- get_list_members, (char *)memberlist);
+ get_list_members, memberlist);
if (status)
com_err(whoami, status, "while getting members of list %s",
listname);
exit(success ? 0 : 1);
}
-usage(char **argv)
+void usage(char **argv)
{
fprintf(stderr, "Usage: %s listname [options]\n", argv[0]);
fprintf(stderr, "Options are\n");
/* Display the members stored in the queue */
-show_list_member(struct member *memberstruct)
+void show_list_member(struct member *memberstruct)
{
char *s = "";
/* Show the retrieved information about a list */
-int show_list_info(int argc, char **argv, int hint)
+int show_list_info(int argc, char **argv, void *hint)
{
printf("List: %s\n", argv[0]);
printf("Description: %s\n", argv[9]);
/* Copy retrieved information about a list into a new argv */
-int save_list_info(int argc, char **argv, int hint)
+int save_list_info(int argc, char **argv, void *hint)
{
- char **nargv = (char **)hint;
+ char **nargv = hint;
for (argc = 0; argc < 10; argc++)
nargv[argc + 1] = strdup(argv[argc]);
/* Show the retrieve list member count */
-show_list_count(int argc, char **argv, int hint)
+int show_list_count(int argc, char **argv, void *hint)
{
printf("Members: %s\n", argv[0]);
+ return MR_CONT;
}
/* Recursively find all of the members of listname, and then display them */
-recursive_display_list_members(void)
+void recursive_display_list_members(void)
{
int status, count, savecount;
struct save_queue *lists, *members;
sq_destroy(memberlist);
memberlist = sq_create();
status = mr_query("get_members_of_list", 1, &(m->name),
- get_list_members, (char *)memberlist);
+ get_list_members, memberlist);
if (status)
com_err(whoami, status, "while getting members of list %s", m->name);
while (sq_get_data(memberlist, &m1))
/* add a struct member to a queue if that member isn't already there. */
-unique_add_member(struct save_queue *q, struct member *m)
+void unique_add_member(struct save_queue *q, struct member *m)
{
struct save_queue *qp;
/* Collect the retrieved members of the list */
-int get_list_members(int argc, char **argv, struct save_queue *q)
+int get_list_members(int argc, char **argv, void *sq)
{
+ struct save_queue *q = sq;
struct member *m;
m = malloc(sizeof(struct member));
m->type = M_KERBEROS;
break;
}
- m->name = strsave(argv[1]);
+ m->name = strdup(argv[1]);
sq_save_data(q, m);
return MR_CONT;
}
-/* Called only if a query returns a value that we weren't expecting */
-
-scream(void)
-{
- fprintf(stderr, "Programmer botch\n");
- exit(3);
-}
-
-
/* Open file, parse members from file, and put them on the specified queue */
-get_members_from_file(char *filename, struct save_queue *queue)
+void get_members_from_file(char *filename, struct save_queue *queue)
{
FILE *in;
char buf[BUFSIZ];
/* Collect the possible expansions of the alias MAILHUB */
-int collect(int argc, char **argv, char ***list)
+int collect(int argc, char **argv, void *l)
{
+ char ***list = l;
int i;
for (i = 0; (*list)[i]; i++)
;
*list = realloc(*list, (i + 2) * sizeof(char *));
- (*list)[i] = strsave(argv[2]);
+ (*list)[i] = strdup(argv[2]);
(*list)[i + 1] = NULL;
return MR_CONT;
}
*(--p) = ':';
m->name = s;
}
- m->name = strsave(m->name);
+ m->name = strdup(m->name);
}
else
{
- m->name = strsave(s);
+ m->name = strdup(s);
m->type = M_ANY;
}
return m;
* > 0 if the second member is less (the first member is greater).
*/
-int membercmp(struct member *m1, struct member *m2)
+int membercmp(const void *mem1, const void *mem2)
{
+ const struct member *m1 = mem1, *m2 = mem2;
+
if (m1->type == M_ANY || m2->type == M_ANY || (m1->type == m2->type))
return strcmp(m1->name, m2->name);
else
-/*
- * $Source$
- * $Header$
+/* $Id $
+ *
+ * Simple add-me-to/remove-me-from list client
+ *
+ * mailmaint.c - pjlevine - 20 August 1987
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char rcsid_mailmaint_c[] = "$Header$";
-#endif
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
-/***********************************************************************/
-/* mailmaint.c - pjlevine - 20 August 1987 */
-/***********************************************************************/
-#include <stdio.h>
-#include <pwd.h>
-#include <signal.h>
-#include <string.h>
+#include <ctype.h>
#include <curses.h>
-#include <sys/types.h>
-#include <stdarg.h>
+#include <pwd.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <com_err.h>
-#include <ctype.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <mit-copyright.h>
+#include <string.h>
+#include <unistd.h>
+RCSID("$Header$");
#define STARTCOL 0
#define STARTROW 3
char *whoami; /* should not be static, for logging package */
static int status;
-static int scream();
-void menu_err_hook(const char *who, long code, const char *fmt, va_list args);
typedef struct list_info {
int active;
} List_info;
static char *ascbuff = {"0123456789"};
-static int print_2(), print_1();
static List_info *current_li = (List_info *) NULL;
-static int get_list_info();
-static int fetch_list_info();
typedef struct _menu {
int num_items;
int moreflg, toggle, first_time;
char *username;
+void get_main_input(void);
+void show_list_info(void);
+void display_buff(char *buf);
+void start_display_buff(char *buff);
+void add_member(void);
+void delete_member(void);
+void list_by_member(void);
+void show_all(void);
+static int print_1(int argc, char *argv[], void *callback);
+static int print_all(int argc, char *argv[], void *callback);
+void list_all_groups(void);
+void list_members(void);
+static int print_2(int argc, char *argv[], void *callback);
+void start_display(char *buff);
+void end_display(void);
+void display_menu(MENU *menu);
+void pack_main_menu(void);
+void pack_help_menu(void);
+void highlight(MENU *menu);
+void title(char *buff);
+void center_text(int row, char *buff);
+void show_text(int row, int col, char *buff);
+void erase_line(int row, int col);
+void cls(void);
+void clrwin(int erase_row);
+static int fetch_list_info(char *list, List_info *li);
+static int get_list_info(int argc, char **argv, void *hint);
+int Prompt(char *prompt, char *buf, int buflen, int crok);
+void menu_err_hook(const char *who, long code, const char *fmt, va_list args);
+
/* This crock is because the original code was very broken and this makes
* it work. Someday, we should abandon the code or fix it right.
*/
current_li->modwith = NULL;
}
if (!(username = getlogin()))
- {
- struct passwd *getpwuid();
-
- username = getpwuid(getuid())->pw_name;
- }
- username = (username && strlen(username)) ? strsave(username) : "";
+ username = getpwuid(getuid())->pw_name;
+ username = username ? strdup(username) : "";
printf("Connecting to database for %s...please hold on.\n", username);
}
/****************************************************/
-int get_main_input(void)
+void get_main_input(void)
{
int c;
int retflg;
}
/****************************************************/
-int show_list_info(void)
+void show_list_info(void)
{
char *buf;
}
/****************************************************/
-int display_buff(char *buf)
+void display_buff(char *buf)
{
int i, cnt;
char *printbuf;
start_display_buff(printbuf);
free(printbuf);
}
- return 0;
+ return;
}
/****************************************************/
-int start_display_buff(char *buff)
+void start_display_buff(char *buff)
{
char buffer[5];
num_members++;
if (moreflg)
- return 0;
+ return;
if (currow >= LINES - 2)
{
page++;
erase_line(currow, STARTCOL);
show_text(currow, STARTCOL, "Flushing query...");
moreflg = 1;
- return 0;
+ return;
}
clrwin(DISPROW + 2);
currow = DISPROW + 2;
}
show_text(currow, STARTCOL, buff);
currow++;
- return 0;
+ return;
}
/****************************************************/
-int add_member(void)
+void add_member(void)
{
char *argv[3];
char *buf;
if (Prompt("Enter List Name: ", buf, LISTSIZE, 1) == 1)
{
display_buff("\n");
- argv[0] = strsave(buf);
- argv[1] = strsave("user");
- argv[2] = strsave(username);
- if ((status = mr_query("add_member_to_list", 3, argv, scream, NULL)))
+ argv[0] = strdup(buf);
+ argv[1] = strdup("user");
+ argv[2] = strdup(username);
+ if ((status = mr_query("add_member_to_list", 3, argv, NULL, NULL)))
{
display_buff("\n");
com_err(whoami, status, " found.\n");
}
/****************************************************/
-int delete_member(void)
+void delete_member(void)
{
char *argv[3];
char *buf;
if (Prompt("Enter List Name: ", buf, LISTSIZE, 1) == 1)
{
display_buff("\n");
- argv[0] = strsave(buf);
- argv[1] = strsave("user");
- argv[2] = strsave(username);
- if ((status = mr_query("delete_member_from_list", 3, argv, scream, NULL)))
+ argv[0] = strdup(buf);
+ argv[1] = strdup("user");
+ argv[2] = strdup(username);
+ if ((status = mr_query("delete_member_from_list", 3, argv, NULL, NULL)))
{
display_buff("\n");
com_err(whoami, status, " found.\n");
}
/****************************************************/
-int list_by_member(void)
+void list_by_member(void)
{
char *nargv[3];
char *buf;
- nargv[1] = strsave("ruser");
- nargv[2] = strsave(username);
+ nargv[1] = strdup("ruser");
+ nargv[2] = strdup(username);
buf = calloc(BUFSIZ, 1);
sprintf(buf, "%s is on the following lists:\n", username);
show_text(DISPROW, STARTCOL, buf);
show_text(currow, STARTCOL, "Press any Key to continue...");
getchar();
clrwin(DISPROW);
- return;
}
/****************************************************/
-int show_all(void)
+void show_all(void)
{
char c;
}
else
erase_line(DISPROW, STARTCOL);
- return;
}
/****************************************************/
-static int print_1(int argc, char *argv[], char *callback)
+static int print_1(int argc, char *argv[], void *callback)
{
char buf[BUFSIZ];
sprintf(buf, "%s\n", argv[0]);
start_display(buf);
- return 0;
+ return MR_CONT;
}
/****************************************************/
-static int print_all(int argc, char *argv[], char *callback)
+static int print_all(int argc, char *argv[], void *callback)
{
char buf[BUFSIZ];
sprintf(buf, "%s\n", argv[0]);
start_display(buf);
- return 0;
+ return MR_CONT;
}
/****************************************************/
-int list_all_groups(void)
+void list_all_groups(void)
{
char *argv[5];
argv[0] = argv[1] = argv[3] = "true";
com_err(whoami, status, " in list_all_groups\n");
}
end_display();
-
- return 0;
}
/****************************************************/
-int list_members(void)
+void list_members(void)
{
char *argv[1];
char *buf;
return;
}
end_display();
- return 0;
+ return;
}
clrwin(DISPROW);
- return 0;
}
/****************************************************/
-static int print_2(int argc, char *argv[], char *callback)
+static int print_2(int argc, char *argv[], void *callback)
{
char buf[BUFSIZ];
sprintf(buf, "%s %s", argv[0], argv[1]);
start_display(buf);
- return 0;
+ return MR_CONT;
}
/****************************************************/
-int start_display(char *buff)
+void start_display(char *buff)
{
char *buffer;
int secondcol; /* where to start the second column of text */
secondcol = (COLS / 2); /* 1/2 was accross the screen */
num_members++;
if (moreflg)
- return 0;
+ return;
buffer = calloc(50, 1);
if (currow >= LINES - 2)
{
erase_line(currow, STARTCOL);
show_text(currow, STARTCOL, "Flushing query...");
moreflg = 1;
- return 0;
+ return;
}
clrwin(DISPROW + 2);
currow = DISPROW + 2;
currow++;
}
toggle = !toggle;
- return 0;
}
/****************************************************/
-int end_display(void)
+void end_display(void)
{
char *buffer;
}
/****************************************************/
-int display_menu(MENU *menu)
+void display_menu(MENU *menu)
{
int i;
}
/****************************************************/
-int pack_main_menu(void)
+void pack_main_menu(void)
{
char *buf;
buf = calloc(50, 1);
sprintf(buf, "Mail List Program for %s", username);
- main_menu->title = strsave(buf);
- main_menu->items[0] = strsave("1. Show all public mailing lists.");
- main_menu->items[1] = strsave("2. Get all members of a mailing list.");
- main_menu->items[2] = strsave("3. Display lists of which you are a member.");
- main_menu->items[3] = strsave("4. Show description of list.");
- main_menu->items[4] = strsave("5. Add yourself to a mailing list.");
- main_menu->items[5] = strsave("6. Delete yourself from a mailing list.");
- main_menu->items[6] = strsave("q. Quit.");
+ main_menu->title = strdup(buf);
+ main_menu->items[0] = strdup("1. Show all public mailing lists.");
+ main_menu->items[1] = strdup("2. Get all members of a mailing list.");
+ main_menu->items[2] = strdup("3. Display lists of which you are a member.");
+ main_menu->items[3] = strdup("4. Show description of list.");
+ main_menu->items[4] = strdup("5. Add yourself to a mailing list.");
+ main_menu->items[5] = strdup("6. Delete yourself from a mailing list.");
+ main_menu->items[6] = strdup("q. Quit.");
}
/****************************************************/
-int pack_help_menu(void)
+void pack_help_menu(void)
{
help_menu = malloc(sizeof(MENU));
help_menu->num_items = 5;
help_menu->items = malloc(sizeof(char *) * help_menu->num_items);
- help_menu->title = strsave("mailmaint is designed as a basic mail list administration program.");
- help_menu->items[0] = strsave("if you need to perform more advanced list manipulation like");
- help_menu->items[1] = strsave("adding lists, or changing list characteristics, refer to the");
- help_menu->items[2] = strsave("program listmaint.");
- help_menu->items[3] = strsave(" ");
- help_menu->items[4] = strsave("Press any key to continue.");
+ help_menu->title = strdup("mailmaint is designed as a basic mail list administration program.");
+ help_menu->items[0] = strdup("if you need to perform more advanced list manipulation like");
+ help_menu->items[1] = strdup("adding lists, or changing list characteristics, refer to the");
+ help_menu->items[2] = strdup("program listmaint.");
+ help_menu->items[3] = strdup(" ");
+ help_menu->items[4] = strdup("Press any key to continue.");
}
/****************************************************/
-int highlight(MENU *menu)
+void highlight(MENU *menu)
{
if (oldpos[level] != position[level])
{
}
/****************************************************/
-int title(char *buff)
+void title(char *buff)
{
move(0, MAX(0, (COLS - strlen(buff)) >> 1));
standout();
}
/****************************************************/
-int center_text(int row, char *buff)
+void center_text(int row, char *buff)
{
move(row, MAX(0, (COLS - strlen(buff)) >> 1));
addstr(buff);
}
/****************************************************/
-int show_text(int row, int col, char *buff)
+void show_text(int row, int col, char *buff)
{
mvcur(0, 0, row, col);
addstr(buff);
}
/****************************************************/
-int erase_line(int row, int col)
+void erase_line(int row, int col)
{
char *buff;
int i;
}
/****************************************************/
-int cls(void)
+void cls(void)
{
clear();
refresh();
}
/****************************************************/
-int clrwin(int erase_row)
+void clrwin(int erase_row)
{
int i;
char *buff;
free(buff);
}
-/****************************************************/
-static int scream(void)
-{
- com_err(whoami, status,
- "\nA Moira update returned a value -- programmer botch\n");
- mr_disconnect();
- exit(1);
- return 0; /* to keep compiler happy */
-}
-
/****************************************************/
static int fetch_list_info(char *list, List_info *li)
{
return mr_query("get_list_info", 1, argv, get_list_info, NULL);
}
-static int get_list_info(int argc, char **argv)
+static int get_list_info(int argc, char **argv, void *hint)
{
if (current_li->acl_type)
free(current_li->acl_type);
- current_li->acl_type = strsave(argv[7]);
+ current_li->acl_type = strdup(argv[7]);
if (current_li->acl_name)
free(current_li->acl_name);
- current_li->acl_name = strsave(argv[8]);
+ current_li->acl_name = strdup(argv[8]);
if (current_li->desc)
free(current_li->desc);
- current_li->desc = strsave(argv[9]);
+ current_li->desc = strdup(argv[9]);
if (current_li->modtime)
free(current_li->modtime);
- current_li->modtime = strsave(argv[10]);
+ current_li->modtime = strdup(argv[10]);
if (current_li->modby)
free(current_li->modby);
- current_li->modby = strsave(argv[11]);
+ current_li->modby = strdup(argv[11]);
if (current_li->modwith)
free(current_li->modwith);
- current_li->modwith = strsave(argv[12]);
- return 0;
+ current_li->modwith = strdup(argv[12]);
+ return MR_CONT;
}
NOBJS= namespace.o globals.o lists.o menu.o \
pobox.o user.o utils.o misc.o
OBJS= ${MOBJS} ${NOBJS}
-INCLUDE= -I$(BUILDTOP)/include -I$(BUILDTOP)/lib ${GDSSINC} -I/usr/athena/include -I.
+INCLUDE= -I$(BUILDTOP)/include -I$(BUILDTOP)/lib ${GDSSINC} ${COM_ERR_INC} -I/usr/athena/include -I.
program(moira, ${MOBJS},${MR_LIBDEP} ${GDB_LIBDEP}, ${LIBGDSS} ${CLIBS} ${CRYPT} ${CURSES},${PROGDIR})
program(namespace, ${NOBJS},${MR_LIBDEP} ${GDB_LIBDEP}, ${LIBGDSS} ${CLIBS} ${CRYPT} ${CURSES},${PROGDIR})
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file attach.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file attach.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: Functions for maintaining data used by Hesiod
* to map courses/projects/users to their file systems,
* Created: 5/4/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+RCSID("$Header$");
+
+char *canonicalize_cell(char *c);
+int GetAliasValue(int argc, char **argv, void *retval);
+void RealDeleteFS(char **info, Bool one_item);
+char *SortAfter(struct qelem *elem, int count);
+void RealDeleteFSAlias(char **info, Bool one_item);
+
#define FS_ALIAS_TYPE "FILESYS"
#define LABEL 0
{
char buf[BUFSIZ];
- info[FS_NAME] = Strsave(name);
- info[FS_TYPE] = Strsave(DEFAULT_TYPE);
- info[FS_MACHINE] = Strsave(DEFAULT_MACHINE);
- info[FS_PACK] = Strsave(DEFAULT_PACK);
+ info[FS_NAME] = strdup(name);
+ info[FS_TYPE] = strdup(DEFAULT_TYPE);
+ info[FS_MACHINE] = strdup(DEFAULT_MACHINE);
+ info[FS_PACK] = strdup(DEFAULT_PACK);
sprintf(buf, "/mit/%s", name);
- info[FS_M_POINT] = Strsave(buf);
- info[FS_ACCESS] = Strsave(DEFAULT_ACCESS);
- info[FS_COMMENTS] = Strsave(DEFAULT_COMMENTS);
- info[FS_OWNER] = Strsave(DEFAULT_OWNER);
- info[FS_OWNERS] = Strsave(DEFAULT_OWNERS);
- info[FS_CREATE] = Strsave(DEFAULT_CREATE);
- info[FS_L_TYPE] = Strsave(DEFAULT_L_TYPE);
+ info[FS_M_POINT] = strdup(buf);
+ info[FS_ACCESS] = strdup(DEFAULT_ACCESS);
+ info[FS_COMMENTS] = strdup(DEFAULT_COMMENTS);
+ info[FS_OWNER] = strdup(DEFAULT_OWNER);
+ info[FS_OWNERS] = strdup(DEFAULT_OWNERS);
+ info[FS_CREATE] = strdup(DEFAULT_CREATE);
+ info[FS_L_TYPE] = strdup(DEFAULT_L_TYPE);
info[FS_MODTIME] = info[FS_MODBY] = info[FS_MODWITH] = info[FS_END] = NULL;
return info;
}
{
case LABEL:
if ((stat = do_mr_query("get_filesys_by_label", 1, &name,
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetFSInfo");
return NULL;
break;
case MACHINE:
if ((stat = do_mr_query("get_filesys_by_machine", 1, &name,
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetFSInfo");
return NULL;
break;
case GROUP:
if ((stat = do_mr_query("get_filesys_by_group", 1, &name,
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetFSInfo");
return NULL;
args[ALIAS_NAME] = name;
args[ALIAS_TYPE] = FS_ALIAS_TYPE;
args[ALIAS_TRANS] = "*";
- if ((stat = do_mr_query("get_alias", 3, args, StoreInfo,
- (char *) &elem)))
+ if ((stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
{
com_err(program_name, stat, " in get_alias.");
return NULL;
static int fsgCount = 1;
-static char *PrintFSGMembers(char **info)
+static void PrintFSGMembers(char **info)
{
char print_buf[BUFSIZ];
sprintf(print_buf, " %d. Filesystem: %-32s (sort key: %s)",
fsgCount++, info[0], info[1]);
Put_message(print_buf);
- return info[0];
}
Put_message(print_buf);
Put_message("Containing the filesystems (in order):");
if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME],
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
if (stat == MR_NO_MATCH)
Put_message(" [no members]");
return c;
path[count] = 0;
free(c);
- return strsave(path);
+ return strdup(path);
}
-int GetAliasValue(int argc, char **argv, char **retval)
+int GetAliasValue(int argc, char **argv, void *retval)
{
- *retval = strsave(argv[2]);
+ *(char **)retval = strdup(argv[2]);
return MR_CONT;
}
if (name)
{
- newname = Strsave(info[FS_NAME]);
+ newname = strdup(info[FS_NAME]);
if (GetValueFromUser("The new name for this filesystem",
&newname) == SUB_ERROR)
return NULL;
if (fsgroup)
{
free(info[FS_MACHINE]);
- info[FS_MACHINE] = Strsave(NO_MACHINE);
+ info[FS_MACHINE] = strdup(NO_MACHINE);
}
else
{
if (!name || newdefaults)
{
free(info[FS_MACHINE]);
- info[FS_MACHINE] = strsave(DEFAULT_CELL);
+ info[FS_MACHINE] = strdup(DEFAULT_CELL);
}
if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) ==
SUB_ERROR)
sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
lowercase(info[FS_L_TYPE]), info[FS_NAME]);
}
- info[FS_PACK] = strsave(temp_buf);
+ info[FS_PACK] = strdup(temp_buf);
}
}
if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
struct qelem *top;
top = GetFSInfo(LABEL, argv[1]); /* get info. */
- Loop(top, PrintFSInfo);
+ Loop(top, (void (*)(char **))PrintFSInfo);
FreeQueue(top); /* clean the queue. */
return DM_NORMAL;
}
{
struct qelem *top;
- argv[1] = canonicalize_hostname(strsave(argv[1]));
+ argv[1] = canonicalize_hostname(strdup(argv[1]));
top = GetFSInfo(MACHINE, argv[1]); /* get info. */
- Loop(top, PrintFSInfo);
+ Loop(top, (void (*)(char **))PrintFSInfo);
FreeQueue(top); /* clean the queue. */
return DM_NORMAL;
}
if (!one_item || Confirm(temp_buf))
{
if ((stat = do_mr_query("delete_filesys", 1,
- &info[FS_NAME], Scream, NULL)))
+ &info[FS_NAME], NULL, NULL)))
com_err(program_name, stat, " filesystem not deleted.");
else
Put_message("Filesystem deleted.");
Put_message("Aborted.");
return;
}
- stat = do_mr_query("update_filesys", CountArgs(args), args, NullFunc, NULL);
+ stat = do_mr_query("update_filesys", CountArgs(args), args, NULL, NULL);
switch (stat)
{
case MR_NFS:
if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE) == TRUE)
{
if ((stat = do_mr_query("update_filesys", CountArgs(args), args,
- NullFunc, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " filesystem not updated");
else
Put_message("filesystem sucessfully updated.");
return DM_NORMAL;
if (!(stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
- NullFunc, NULL)))
+ NULL, NULL)))
{
Put_message ("A Filesystem by that name already exists.");
return DM_NORMAL;
return DM_NORMAL;
}
- stat = do_mr_query("add_filesys", CountArgs(args), args, NullFunc, NULL);
+ stat = do_mr_query("add_filesys", CountArgs(args), args, NULL, NULL);
switch (stat)
{
case MR_NFS:
if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
== TRUE) {
if ((stat = do_mr_query("add_filesys", CountArgs(args), args,
- NullFunc, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in AddFS");
else
Put_message("Created.");
if (!def_quota)
{
stat = do_mr_query("get_value", CountArgs(val), val,
- StoreInfo, (char *) &top);
+ StoreInfo, &top);
if (stat != MR_SUCCESS)
com_err(program_name, stat, " getting default quota");
else
{
top = QueueTop(top);
- def_quota = Strsave(((char **)top->q_data)[0]);
+ def_quota = strdup(((char **)top->q_data)[0]);
FreeQueue(top);
}
}
else
argv[Q_TYPE] = "ANY";
argv[Q_QUOTA] = def_quota;
- if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, Scream,
+ if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, NULL,
NULL)))
com_err(program_name, stat, " while adding quota");
}
{
parsed_argc = 1;
parsed_argv[0] = info[FS_NAME];
- AddQuota();
+ AddQuota(parsed_argc, parsed_argv);
}
}
*key++ = (prevnext + 'Z') / 2;
}
*key = 0;
- return Strsave(keybuf);
+ return strdup(keybuf);
}
/* Function Name: AddFSToGroup
char buf[BUFSIZ], *args[5], *bufp;
if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
- (char *)&elem)))
+ &elem)))
{
if (stat != MR_NO_MATCH)
com_err(program_name, stat, " in AddFSToGroup");
args[0] = argv[1];
args[1] = argv[2];
args[2] = "M";
- stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
+ stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
if (stat)
com_err(program_name, stat, " in AddFSToGroup");
return DM_NORMAL;
fsgCount = 1;
Loop(elem, PrintFSGMembers);
sprintf(buf, "%d", QueueCount(elem));
- bufp = Strsave(buf);
+ bufp = strdup(buf);
if (GetValueFromUser("Enter number of filesystem it should follow "
"(0 to make it first):", &bufp) == SUB_ERROR)
return DM_NORMAL;
FreeQueue(QueueTop(elem));
args[0] = argv[1];
args[1] = argv[2];
- stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
+ stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
if (stat == MR_EXISTS)
{
Put_message("That filesystem is already a member of the group.");
if (!Confirm(buf))
return DM_NORMAL;
if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv + 1,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, ", not removed.");
return DM_NORMAL;
}
char buf[BUFSIZ], *bufp, *args[3];
if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
- (char *)&elem)))
+ &elem)))
{
if (stat == MR_NO_MATCH)
{
Loop(top, PrintFSGMembers);
while (1)
{
- bufp = Strsave("1");
+ bufp = strdup("1");
if (GetValueFromUser("Enter number of the filesystem to move:",
&bufp) == SUB_ERROR)
return DM_NORMAL;
}
while (1)
{
- bufp = Strsave("0");
+ bufp = strdup("0");
if (GetValueFromUser("Enter number of filesystem it should follow "
"(0 to make it first):", &bufp) == SUB_ERROR)
return DM_NORMAL;
args[0] = argv[1];
args[1] = ((char **)elem->q_data)[0];
if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, stat, " in ChangeFSGroupOrder");
return DM_NORMAL;
}
if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in ChangeFSGroupOrder");
return DM_NORMAL;
}
if (!ValidName(argv[1]))
return DM_NORMAL;
- args[ALIAS_NAME] = Strsave(argv[1]);
- args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
- args[ALIAS_TRANS] = Strsave("*");
+ args[ALIAS_NAME] = strdup(argv[1]);
+ args[ALIAS_TYPE] = strdup(FS_ALIAS_TYPE);
+ args[ALIAS_TRANS] = strdup("*");
/*
* Check to see if this alias already exists in the database, if so then
* print out values, free memory used and then exit.
*/
- if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo,
- (char *)&elem)))
+ if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
{
top = elem = QueueTop(elem);
while (elem)
{
- info = (char **) elem->q_data;
+ info = elem->q_data;
sprintf(buf, "The alias: %s currently describes the filesystem %s",
info[ALIAS_NAME], info[ALIAS_TRANS]);
Put_message(buf);
return DM_NORMAL;
}
- args[ALIAS_TRANS] = Strsave("");
+ args[ALIAS_TRANS] = strdup("");
args[ALIAS_END] = NULL;
if (GetValueFromUser("Which filesystem will this alias point to?",
&args[ALIAS_TRANS]) == SUB_ERROR)
return DM_NORMAL;
- if ((stat = do_mr_query("add_alias", 3, args, NullFunc, NULL)))
+ if ((stat = do_mr_query("add_alias", 3, args, NULL, NULL)))
com_err(program_name, stat, " in CreateFSAlias.");
FreeInfo(args);
if (!one_item || Confirm(temp_buf))
{
if ((stat = do_mr_query("delete_alias", CountArgs(info),
- info, Scream, NULL)))
+ info, NULL, NULL)))
com_err(program_name, stat, " filesystem alias not deleted.");
else
Put_message("Filesystem alias deleted.");
* Returns: DM_NORMAL.
*/
-int FSGroupHelp(void)
+int FSGroupHelp(int argc, char **argv)
{
static char *message[] = {
"A filesystem group is a named sorted list of filesystems.",
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file cluster.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file cluster.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains:
*
* Created: 4/22/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
/* BTW: for anyone who cares MCD is short for Machine, Cluster, Data. */
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
+#include <sys/utsname.h>
+
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <sys/utsname.h>
#include <netdb.h>
+
#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+void PrintAliases(char **info);
+struct qelem *GetMCInfo(int type, char *name1, char *name2);
+char **AskMCDInfo(char **info, int type, Bool name);
+int CheckAndRemoveFromCluster(char *name, Bool ask_user);
+int CheckAndRemoveMachines(char *name, Bool ask_first);
+char *partial_canonicalize_hostname(char *s);
#define MACHINE 0
#define CLUSTER 1
static char **SetMachineDefaults(char **info, char *name)
{
- info[M_NAME] = Strsave(name);
- info[M_VENDOR] = Strsave(M_DEFAULT_TYPE);
- info[M_MODEL] = Strsave(M_DEFAULT_TYPE);
- info[M_OS] = Strsave(M_DEFAULT_TYPE);
- info[M_LOC] = Strsave(M_DEFAULT_TYPE);
- info[M_CONTACT] = Strsave(M_DEFAULT_TYPE);
- info[M_USE] = Strsave("0");
- info[M_STAT] = Strsave("1");
- info[M_SUBNET] = Strsave("NONE");
- info[M_ADDR] = Strsave("unique");
- info[M_OWNER_TYPE] = Strsave("NONE");
- info[M_OWNER_NAME] = Strsave("NONE");
- info[M_ACOMMENT] = Strsave("");
- info[M_OCOMMENT] = Strsave("");
+ info[M_NAME] = strdup(name);
+ info[M_VENDOR] = strdup(M_DEFAULT_TYPE);
+ info[M_MODEL] = strdup(M_DEFAULT_TYPE);
+ info[M_OS] = strdup(M_DEFAULT_TYPE);
+ info[M_LOC] = strdup(M_DEFAULT_TYPE);
+ info[M_CONTACT] = strdup(M_DEFAULT_TYPE);
+ info[M_USE] = strdup("0");
+ info[M_STAT] = strdup("1");
+ info[M_SUBNET] = strdup("NONE");
+ info[M_ADDR] = strdup("unique");
+ info[M_OWNER_TYPE] = strdup("NONE");
+ info[M_OWNER_NAME] = strdup("NONE");
+ info[M_ACOMMENT] = strdup("");
+ info[M_OCOMMENT] = strdup("");
info[15] = info[16] = NULL;
return info;
}
static char **SetClusterDefaults(char **info, char *name)
{
- info[C_NAME] = Strsave(name);
- info[C_DESCRIPT] = Strsave(C_DEFAULT_DESCRIPT);
- info[C_LOCATION] = Strsave(C_DEFAULT_LOCATION);
+ info[C_NAME] = strdup(name);
+ info[C_DESCRIPT] = strdup(C_DEFAULT_DESCRIPT);
+ info[C_LOCATION] = strdup(C_DEFAULT_LOCATION);
info[C_MODBY] = info[C_MODTIME] = info[C_MODWITH] = info[C_END] = NULL;
return info;
}
{
char buf[256];
- info[C_NAME] = Strsave(name);
- info[SN_DESC] = Strsave("");
+ info[C_NAME] = strdup(name);
+ info[SN_DESC] = strdup("");
sprintf(buf, "%ld", ntohl(inet_addr("18.255.0.0")));
- info[SN_ADDRESS] = Strsave(buf);
+ info[SN_ADDRESS] = strdup(buf);
sprintf(buf, "%ld", ntohl(inet_addr("255.255.0.0")));
- info[SN_MASK] = Strsave(buf);
+ info[SN_MASK] = strdup(buf);
sprintf(buf, "%ld", ntohl(inet_addr(S_DEFAULT_LOW)));
- info[SN_LOW] = Strsave(buf);
+ info[SN_LOW] = strdup(buf);
sprintf(buf, "%ld", ntohl(inet_addr(S_DEFAULT_HIGH)));
- info[SN_HIGH] = Strsave(buf);
- info[SN_PREFIX] = Strsave("");
- info[SN_ACE_TYPE] = Strsave("LIST");
- info[SN_ACE_NAME] = Strsave("network");
+ info[SN_HIGH] = strdup(buf);
+ info[SN_PREFIX] = strdup("");
+ info[SN_ACE_TYPE] = strdup("LIST");
+ info[SN_ACE_NAME] = strdup("network");
info[SN_MODBY] = info[SN_MODTIME] = info[SN_MODWITH] = info[SN_END] = NULL;
return info;
}
static char aliasbuf[256];
-static char *PrintAliases(char **info)
+void PrintAliases(char **info)
{
if (strlen(aliasbuf) == 0)
sprintf(aliasbuf, "Aliases: %s", info[0]);
Put_message(buf);
args[0] = "*";
args[1] = info[M_NAME];
- if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, &elem)))
{
if (stat != MR_NO_MATCH)
com_err(program_name, stat, " looking up aliases");
case MACHINE:
args[0] = name1;
args[1] = args[2] = args[3] = "*";
- if ((stat = do_mr_query("get_host", 4, args,
- StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_host", 4, args, StoreInfo, &elem)))
{
if (stat == MR_NO_MATCH)
{
case CNAME:
args[0] = name1;
args[1] = name2;
- if ((stat = do_mr_query("get_hostalias", 2, args,
- StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, &elem)))
{
com_err(program_name, stat, " in get_hostalias.");
return NULL;
}
break;
case SUBNET:
- if ((stat = do_mr_query("get_subnet", 1, &name1,
- StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_subnet", 1, &name1, StoreInfo, &elem)))
{
if (stat == MR_NO_MATCH)
{
}
break;
case CLUSTER:
- if ((stat = do_mr_query("get_cluster", 1, &name1,
- StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_cluster", 1, &name1, StoreInfo, &elem)))
{
com_err(program_name, stat, " in get_cluster.");
return NULL;
args[MAP_MACHINE] = name1;
args[MAP_CLUSTER] = name2;
if ((stat = do_mr_query("get_machine_to_cluster_map", 2, args,
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in get_machine_to_cluster_map.");
return NULL;
case DATA:
args[CD_NAME] = name1;
args[CD_LABEL] = name2;
- if ((stat = do_mr_query("get_cluster_data", 2, args,
- StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_cluster_data", 2, args, StoreInfo, &elem)))
{
com_err(program_name, stat, " in get_cluster_data.");
return NULL;
switch (type)
{
case MACHINE:
- newname = Strsave(info[M_NAME]);
+ newname = strdup(info[M_NAME]);
if (GetValueFromUser("The new name for this machine? ", &newname) ==
SUB_ERROR)
return NULL;
- oldnewname = Strsave(newname);
+ oldnewname = strdup(newname);
newname = canonicalize_hostname(newname);
if (strcasecmp(newname, oldnewname) && *oldnewname != '"')
{
free(oldnewname);
break;
case SUBNET:
- newname = Strsave(info[SN_NAME]);
+ newname = strdup(info[SN_NAME]);
if (GetValueFromUser("The new name for this network? ", &newname) ==
SUB_ERROR)
return NULL;
break;
case CLUSTER:
- newname = Strsave(info[C_NAME]);
+ newname = strdup(info[C_NAME]);
if (GetValueFromUser("The new name for this cluster? ", &newname) ==
SUB_ERROR)
return NULL;
low.s_addr = atoi(info[SN_LOW]);
low.s_addr = (low.s_addr & ~mask) | (addr & mask);
free(info[SN_LOW]);
- sprintf(temp_buf, "%d", low.s_addr);
- info[SN_LOW] = strsave(temp_buf);
+ sprintf(temp_buf, "%ld", low.s_addr);
+ info[SN_LOW] = strdup(temp_buf);
}
if (GetAddressFromUser("Lowest assignable address", &info[SN_LOW]) ==
SUB_ERROR)
high.s_addr = atoi(info[SN_HIGH]);
high.s_addr = (high.s_addr & ~mask) | (addr & mask);
free(info[SN_HIGH]);
- sprintf(temp_buf, "%d", high.s_addr);
- info[SN_HIGH] = strsave(temp_buf);
+ sprintf(temp_buf, "%ld", high.s_addr);
+ info[SN_HIGH] = strdup(temp_buf);
}
if (GetAddressFromUser("Highest assignable address", &info[SN_HIGH]) ==
SUB_ERROR)
struct qelem *top;
char *tmpname;
- tmpname = canonicalize_hostname(strsave(argv[1]));
+ tmpname = canonicalize_hostname(strdup(argv[1]));
top = GetMCInfo(MACHINE, tmpname, NULL);
Loop(top, ((void *) PrintMachInfo));
FreeQueue(top);
}
if (*argv[1])
- args[0] = canonicalize_hostname(strsave(argv[1]));
+ args[0] = canonicalize_hostname(strdup(argv[1]));
else
args[0] = "*";
if (*argv[2])
else
args[3] = "*";
- if ((stat = do_mr_query("get_host", 4, args, StoreInfo,
- (char *)&elem)))
+ if ((stat = do_mr_query("get_host", 4, args, StoreInfo, &elem)))
{
if (stat == MR_NO_MATCH)
Put_message("No machine(s) found matching query in the database.");
*/
if (strcasecmp(argv[1], "none") &&
- (stat = do_mr_query("get_subnet", 1, &argv[1],
- StoreInfo, (char *)&elem)))
+ (stat = do_mr_query("get_subnet", 1, &argv[1], StoreInfo, &elem)))
{
if (stat == MR_NO_MATCH)
{
* Check to see if this machine already exists.
*/
- name = strsave(""); /* want to put prefix here */
+ name = strdup(""); /* want to put prefix here */
if (GetValueFromUser("Machine name", &name) == SUB_ERROR)
return 0;
- name = canonicalize_hostname(strsave(name));
+ name = canonicalize_hostname(strdup(name));
xargs[0] = name;
xargs[1] = xargs[2] = xargs[3] = "*";
- if (!(stat = do_mr_query("get_host", 4, xargs, NullFunc, NULL)))
+ if (!(stat = do_mr_query("get_host", 4, xargs, NULL, NULL)))
{
sprintf(buf, "The machine '%s' already exists.", name);
Put_message(buf);
return DM_NORMAL;
}
rinfo = SetMachineDefaults(info, name);
- rinfo[M_SUBNET] = strsave(argv[1]);
+ rinfo[M_SUBNET] = strdup(argv[1]);
if (!(args = AskMCDInfo(rinfo, MACHINE, FALSE)))
{
Put_message("Aborted.");
* Actually create the new Machine.
*/
- if ((stat = do_mr_query("add_host", CountArgs(args),
- args, Scream, NULL)))
+ if ((stat = do_mr_query("add_host", CountArgs(args), args, NULL, NULL)))
com_err(program_name, stat, " in AddMachine.");
FreeInfo(info);
Put_message("Aborted.");
return;
}
- if ((stat = do_mr_query("update_host", CountArgs(args),
- args, Scream, NULL)))
+ if ((stat = do_mr_query("update_host", CountArgs(args), args, NULL, NULL)))
com_err(program_name, stat, " in UpdateMachine.");
else
Put_message("Machine successfully updated.");
struct qelem *top;
char *tmpname;
- tmpname = canonicalize_hostname(strsave(argv[1]));
+ tmpname = canonicalize_hostname(strdup(argv[1]));
top = GetMCInfo(MACHINE, tmpname, NULL);
QueryLoop(top, NullPrint, RealUpdateMachine, "Update the machine");
ret_value = SUB_NORMAL; /* initialize ret_value. */
args[0] = name;
args[1] = "*";
- stat = do_mr_query("get_machine_to_cluster_map", 2, args,
- StoreInfo, (char *)&elem);
+ stat = do_mr_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
if (stat && stat != MR_NO_MATCH)
{
com_err(program_name, stat, " in get_machine_to_cluster_map.");
{
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
if ((stat = do_mr_query("delete_machine_from_cluster",
- 2, info, Scream, NULL)))
+ 2, info, NULL, NULL)))
{
ret_value = SUB_ERROR;
com_err(program_name, stat,
if (CheckAndRemoveFromCluster(info[M_NAME], TRUE) != SUB_ERROR)
{
if ((stat = do_mr_query("delete_host", 1,
- &info[M_NAME], Scream, NULL)))
+ &info[M_NAME], NULL, NULL)))
{
com_err(program_name, stat, " in DeleteMachine.");
sprintf(temp_buf, "%s ** NOT ** deleted.",
struct qelem *top;
char *tmpname;
- tmpname = canonicalize_hostname(strsave(argv[1]));
+ tmpname = canonicalize_hostname(strdup(argv[1]));
top = GetMCInfo(MACHINE, tmpname, (char *) NULL);
QueryLoop(top, PrintMachInfo, RealDeleteMachine, "Delete the machine");
FreeQueue(top);
hp = gethostbyname(name.nodename);
cp = strchr(hp->h_name, '.');
if (cp)
- def_domain = strsave(++cp);
+ def_domain = strdup(++cp);
else
def_domain = "";
}
return s;
sprintf(buf, "%s.%s", s, def_domain);
free(s);
- return strsave(buf);
+ return strdup(buf);
}
struct qelem *top;
char *tmpalias, *tmpname;
- tmpalias = partial_canonicalize_hostname(strsave(argv[1]));
- tmpname = canonicalize_hostname(strsave(argv[2]));
+ tmpalias = partial_canonicalize_hostname(strdup(argv[1]));
+ tmpname = canonicalize_hostname(strdup(argv[2]));
top = GetMCInfo(CNAME, tmpalias, tmpname);
Put_message(""); /* blank line on screen */
Loop(top, ((void *) PrintCname));
int stat;
char *args[10];
- args[0] = partial_canonicalize_hostname(strsave(argv[1]));
- args[1] = canonicalize_hostname(strsave(argv[2]));
- stat = do_mr_query("add_hostalias", 2, args, Scream, NULL);
+ args[0] = partial_canonicalize_hostname(strdup(argv[1]));
+ args[1] = canonicalize_hostname(strdup(argv[2]));
+ stat = do_mr_query("add_hostalias", 2, args, NULL, NULL);
switch (stat)
{
case MR_SUCCESS:
int DeleteCname(int argc, char **argv)
{
int stat;
- char *machine, *cluster, temp_buf[BUFSIZ], *args[10];
- Bool add_it, one_machine, one_cluster;
- struct qelem *melem, *mtop, *celem, *ctop;
+ char *args[10];
- args[0] = partial_canonicalize_hostname(strsave(argv[1]));
- args[1] = canonicalize_hostname(strsave(argv[2]));
- stat = do_mr_query("delete_hostalias", 2, args, Scream, NULL);
+ args[0] = partial_canonicalize_hostname(strdup(argv[1]));
+ args[1] = canonicalize_hostname(strdup(argv[2]));
+ stat = do_mr_query("delete_hostalias", 2, args, NULL, NULL);
if (stat)
com_err(program_name, stat, " in delete_hostalias");
return DM_NORMAL;
Bool add_it, one_machine, one_cluster;
struct qelem *melem, *mtop, *celem, *ctop;
- machine = canonicalize_hostname(strsave(argv[1]));
+ machine = canonicalize_hostname(strdup(argv[1]));
if (strcasecmp(machine, argv[1]) && *argv[1] != '"')
{
sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
while (melem)
{
- char **minfo = (char **) melem->q_data;
+ char **minfo = melem->q_data;
while (celem)
{
- char **cinfo = (char **) celem->q_data;
+ char **cinfo = celem->q_data;
if (one_machine && one_cluster)
add_it = TRUE;
else
args[0] = minfo[M_NAME];
args[1] = cinfo[C_NAME];
stat = do_mr_query("add_machine_to_cluster", 2, args,
- Scream, NULL);
+ NULL, NULL);
switch (stat)
{
case MR_SUCCESS:
if (!one_map || Confirm(temp_buf))
{
if ((stat = do_mr_query("delete_machine_from_cluster", 2,
- info, Scream, NULL)))
+ info, NULL, NULL)))
com_err(program_name, stat, " in delete_machine_from_cluster");
else
{
char buf[BUFSIZ], * args[10];
int stat;
- args[MAP_MACHINE] = canonicalize_hostname(strsave(argv[1]));
+ args[MAP_MACHINE] = canonicalize_hostname(strdup(argv[1]));
if (strcasecmp(args[MAP_MACHINE], argv[1]) && *argv[1] != '"')
{
sprintf(buf, "Warning: '%s' canonicalized to '%s'.",
args[MAP_END] = NULL;
stat = do_mr_query("get_machine_to_cluster_map", CountArgs(args), args,
- StoreInfo, (char *)&elem);
+ StoreInfo, &elem);
if (stat == MR_NO_MATCH)
{
sprintf(buf, "The machine %s is not is the cluster %s.",
if (!ValidName(name))
return DM_NORMAL;
- if ((stat = do_mr_query("get_subnet", 1, &name,
- NullFunc, NULL)) == MR_SUCCESS)
+ if ((stat = do_mr_query("get_subnet", 1, &name, NULL, NULL)) == MR_SUCCESS)
{
Put_message("This subnet already exists.");
return DM_NORMAL;
/*
* Actually create the new Subnet.
*/
- if ((stat = do_mr_query("add_subnet", CountArgs(args),
- args, Scream, NULL)))
+ if ((stat = do_mr_query("add_subnet", CountArgs(args), args, NULL, NULL)))
com_err(program_name, stat, " in AddSubnet.");
FreeInfo(info);
Put_message("Aborted.");
return;
}
- if ((stat = do_mr_query("update_subnet", CountArgs(args),
- args, Scream, NULL)))
+ if ((stat = do_mr_query("update_subnet", CountArgs(args), args, NULL, NULL)))
com_err(program_name, stat, " in UpdateSubnet.");
else
Put_message("Subnet successfully updated.");
info[C_NAME]);
if (!one_subnet || Confirm(temp_buf))
{
- if ((stat = do_mr_query("delete_subnet", 1,
- &info[C_NAME], Scream, NULL)))
+ if ((stat = do_mr_query("delete_subnet", 1, &info[C_NAME], NULL, NULL)))
{
com_err(program_name, stat, " in delete_subnet.");
sprintf(temp_buf, "Subnet %s ** NOT ** deleted.", info[C_NAME]);
if (!ValidName(name))
return DM_NORMAL;
- if ((stat = do_mr_query("get_cluster", 1, &name,
- NullFunc, NULL)) == MR_SUCCESS)
+ if ((stat = do_mr_query("get_cluster", 1, &name, NULL, NULL)) == MR_SUCCESS)
{
Put_message("This cluster already exists.");
return DM_NORMAL;
/*
* Actually create the new Cluster.
*/
- if ((stat = do_mr_query("add_cluster", CountArgs(args),
- args, Scream, NULL)))
+ if ((stat = do_mr_query("add_cluster", CountArgs(args), args, NULL, NULL)))
com_err(program_name, stat, " in AddCluster.");
FreeInfo(info);
return;
}
if ((stat = do_mr_query("update_cluster", CountArgs(args),
- args, Scream, NULL)))
+ args, NULL, NULL)))
com_err(program_name, stat, " in UpdateCluster.");
else
Put_message("Cluster successfully updated.");
ret_value = SUB_NORMAL;
args[MAP_MACHINE] = "*";
args[MAP_CLUSTER] = name;
- stat = do_mr_query("get_machine_to_cluster_map", 2, args,
- StoreInfo, (char *)&elem);
+ stat = do_mr_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
if (stat && stat != MR_NO_MATCH)
{
com_err(program_name, stat, " in get_machine_to_cluster_map.");
Put_message(temp_buf);
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
Print(1, &info[MAP_MACHINE], (char *) NULL);
elem = elem->q_forw;
}
elem = top;
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
if ((stat = do_mr_query("delete_machine_from_cluster",
- 2, info, Scream, NULL)))
+ 2, info, NULL, NULL)))
{
ret_value = SUB_ERROR;
com_err(program_name, stat,
if (CheckAndRemoveMachines(info[C_NAME], TRUE) != SUB_ERROR)
{
if ((stat = do_mr_query("delete_cluster", 1,
- &info[C_NAME], Scream, NULL)))
+ &info[C_NAME], NULL, NULL)))
{
com_err(program_name, stat, " in delete_cluster.");
sprintf(temp_buf, "Cluster %s ** NOT ** deleted.", info[C_NAME]);
top = elem = GetMCInfo(DATA, argv[1], argv[2]);
while (elem)
{
- info = (char **) elem->q_data;
+ info = elem->q_data;
PrintClusterData(info);
elem = elem->q_forw;
}
{
int stat;
- if ((stat = do_mr_query("add_cluster_data", 3, argv + 1,
- Scream, (char *) NULL)))
+ if ((stat = do_mr_query("add_cluster_data", 3, argv + 1, NULL, NULL)))
com_err(program_name, stat, " in AddClusterData.");
return DM_NORMAL;
}
PrintClusterData(info);
if (!one_item || Confirm(temp_ptr))
{
- if ((stat = do_mr_query("delete_cluster_data", 3, info,
- Scream, (char *) NULL)))
+ if ((stat = do_mr_query("delete_cluster_data", 3, info, NULL, NULL)))
{
com_err(program_name, stat, " in DeleteClusterData.");
Put_message("Data not removed.");
struct qelem *elem, *top;
char *tmpname, temp_buf[256];
- tmpname = canonicalize_hostname(strsave(argv[1]));
+ tmpname = canonicalize_hostname(strdup(argv[1]));
if (strcasecmp(tmpname, argv[1]) && *argv[1] != '"')
{
sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
Put_message(""); /* blank line on screen */
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
PrintMCMap(info);
elem = elem->q_forw;
}
-/* $Header$
+/* $Id $
*
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ * DCM-related functions for Moira client
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
* <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+RCSID("$Header$");
+
extern char *whoami;
static char buf[BUFSIZ];
-char *unparse_interval(), *canonicalize_hostname();
-char *atot();
+
+int genable(int argc, char **argv, void *info);
+int shserv(int argc, char **argv, void *hint);
+char *unparse_interval(int i);
+char **askserv(char **info);
+int gserv(int argc, char **argv, void *hint);
+void initserv(char *name, char **argv);
+int shhost(int argc, char **argv, void *hint);
+int ghost(int argc, char **argv, void *hint);
+void inithost(char **info);
+char **askhost(char **info);
+int pserv(int argc, char **argv, void *count);
+int phost(int argc, char **argv, void *count);
#define DCM_ENABLE_FLAG 0
-int genable(int argc, char **argv, char **info)
+int genable(int argc, char **argv, void *info)
{
- info[1] = strsave(argv[0]);
+ ((char **)info)[1] = strdup(argv[0]);
return MR_CONT;
}
com_err(whoami, status, " while getting value of dcm_enable");
if (GetValueFromUser("Enable value", &info[1]) == SUB_ERROR)
return DM_NORMAL;
- if ((status = do_mr_query("update_value", 2, info, Scream, NULL)))
+ if ((status = do_mr_query("update_value", 2, info, NULL, NULL)))
com_err(whoami, status, " while updating value of dcm_enable");
FreeAndClear(&info[0], FALSE);
FreeAndClear(&info[1], TRUE);
}
-int shserv(int argc, char **argv)
+int shserv(int argc, char **argv, void *hint)
{
char tmp[64], *dfgen;
sprintf(tmp, "Error %d: %s", atoi(argv[SVC_HARDERROR]), argv[SVC_ERRMSG]);
else
strcpy(tmp, "No error");
- dfgen = strsave(atot(argv[SVC_DFGEN]));
+ dfgen = strdup(atot(argv[SVC_DFGEN]));
sprintf(buf, " Generated %s; Last Checked %s", dfgen,
atot(argv[SVC_DFCHECK]));
free(dfgen);
int addserv(int argc, char **argv)
{
int status;
- char *info[SC_END + 1], **askserv();
+ char *info[SC_END + 1];
initserv(argv[1], info);
if (!askserv(info))
Put_message("Aborted.");
return DM_NORMAL;
}
- if ((status = do_mr_query("add_server_info", SC_END, info, Scream, NULL)))
+ if ((status = do_mr_query("add_server_info", SC_END, info, NULL, NULL)))
com_err(whoami, status, " while updating server info");
FreeInfo(info);
return DM_NORMAL;
}
-int gserv(int argc, char **argv, char **cargv)
+int gserv(int argc, char **argv, void *hint)
{
- cargv[SC_SERVICE] = strsave(argv[SVC_SERVICE]);
- cargv[SC_INTERVAL] = strsave(argv[SVC_INTERVAL]);
- cargv[SC_TARGET] = strsave(argv[SVC_TARGET]);
- cargv[SC_SCRIPT] = strsave(argv[SVC_SCRIPT]);
- cargv[SC_TYPE] = strsave(argv[SVC_TYPE]);
- cargv[SC_ENABLE] = strsave(argv[SVC_ENABLE]);
- cargv[SC_ACE_TYPE] = strsave(argv[SVC_ACE_TYPE]);
- cargv[SC_ACE_NAME] = strsave(argv[SVC_ACE_NAME]);
+ char **cargv = hint;
+
+ cargv[SC_SERVICE] = strdup(argv[SVC_SERVICE]);
+ cargv[SC_INTERVAL] = strdup(argv[SVC_INTERVAL]);
+ cargv[SC_TARGET] = strdup(argv[SVC_TARGET]);
+ cargv[SC_SCRIPT] = strdup(argv[SVC_SCRIPT]);
+ cargv[SC_TYPE] = strdup(argv[SVC_TYPE]);
+ cargv[SC_ENABLE] = strdup(argv[SVC_ENABLE]);
+ cargv[SC_ACE_TYPE] = strdup(argv[SVC_ACE_TYPE]);
+ cargv[SC_ACE_NAME] = strdup(argv[SVC_ACE_NAME]);
cargv[SC_END] = NULL;
return MR_CONT;
}
-int initserv(char *name, char **argv)
+void initserv(char *name, char **argv)
{
char tmp[BUFSIZ];
- argv[SC_SERVICE] = strsave(name);
- argv[SC_INTERVAL] = strsave("1440");
+ argv[SC_SERVICE] = strdup(name);
+ argv[SC_INTERVAL] = strdup("1440");
sprintf(tmp, "/tmp/%s.out", name);
- argv[SC_TARGET] = strsave(tmp);
+ argv[SC_TARGET] = strdup(tmp);
sprintf(tmp, "%s/%s.sh", BIN_DIR, name);
- argv[SC_SCRIPT] = strsave(tmp);
- argv[SC_TYPE] = strsave("UNIQUE");
- argv[SC_ENABLE] = strsave("1");
- argv[SC_ACE_TYPE] = strsave("LIST");
- argv[SC_ACE_NAME] = strsave("dbadmin");
+ argv[SC_SCRIPT] = strdup(tmp);
+ argv[SC_TYPE] = strdup("UNIQUE");
+ argv[SC_ENABLE] = strdup("1");
+ argv[SC_ACE_TYPE] = strdup("LIST");
+ argv[SC_ACE_NAME] = strdup("dbadmin");
argv[SC_END] = NULL;
}
int status;
qargv[0] = (char *)argv[1];
- if ((status = do_mr_query("get_server_info", 1,
- qargv, gserv, (char *)qargv)))
+ if ((status = do_mr_query("get_server_info", 1, qargv, gserv, qargv)))
{
com_err(whoami, status, " while getting server info");
return DM_NORMAL;
Put_message("Aborted.");
return DM_NORMAL;
}
- if ((status = do_mr_query("update_server_info", SC_END, qargv, Scream, NULL)))
+ if ((status = do_mr_query("update_server_info", SC_END, qargv, NULL, NULL)))
com_err(whoami, status, " while updating server info");
return DM_NORMAL;
}
-int shhost(int argc, char **argv)
+int shhost(int argc, char **argv, void *hint)
{
char tmp[64], *ltt;
atoi(argv[SH_OVERRIDE]) ? "Override" : "Normal", tmp);
Put_message(buf);
Put_message(" Last Try Last Success Value1 Value2 Value3");
- ltt = strsave(atot(argv[SH_LASTTRY]));
+ ltt = strdup(atot(argv[SH_LASTTRY]));
sprintf(buf, " %-20s %-20s %-9d %-9d %s", ltt, atot(argv[SH_LASTSUCCESS]),
atoi(argv[SH_VALUE1]), atoi(argv[SH_VALUE2]), argv[SH_VALUE3]);
free(ltt);
int status;
qargv[SHI_SERVICE] = argv[1];
- qargv[SHI_MACHINE] = canonicalize_hostname(strsave(argv[2]));
+ qargv[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2]));
if ((status = do_mr_query("get_server_host_info", 2, qargv, shhost, NULL)))
com_err(whoami, status, " getting server/host info");
return DM_NORMAL;
int resetsrverr(int argc, char **argv)
{
int status;
- if ((status = do_mr_query("reset_server_error", 1, &argv[1], Scream, NULL)))
+ if ((status = do_mr_query("reset_server_error", 1, &argv[1], NULL, NULL)))
com_err(whoami, status, " while resetting server error");
return DM_NORMAL;
}
qargv[4] = "0";
qargv[5] = "";
if ((status = do_mr_query("set_server_internal_flags", 6, qargv,
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while resetting server error");
return DM_NORMAL;
}
{
int status;
- argv[2] = canonicalize_hostname(strsave(argv[2]));
+ argv[2] = canonicalize_hostname(strdup(argv[2]));
if ((status = do_mr_query("reset_server_host_error", 2, &argv[1],
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while resetting server/host error");
return DM_NORMAL;
}
char *qargv[9], buf[BUFSIZ];
sprintf(buf, "Reset state for service %s on host %s (Y/N)", argv[1],
- canonicalize_hostname(strsave(argv[2])));
+ canonicalize_hostname(strdup(argv[2])));
if (!Confirm(buf))
return DM_NORMAL;
qargv[0] = argv[1];
- qargv[1] = canonicalize_hostname(strsave(argv[2]));
+ qargv[1] = canonicalize_hostname(strdup(argv[2]));
qargv[2] = "0";
qargv[3] = "0";
qargv[4] = "0";
qargv[7] = "0";
qargv[8] = "0";
if ((status = do_mr_query("set_server_host_internal", 9, qargv,
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while resetting server/host error");
return DM_NORMAL;
}
{
int status;
- argv[2] = canonicalize_hostname(strsave(argv[2]));
+ argv[2] = canonicalize_hostname(strdup(argv[2]));
if ((status = do_mr_query("set_server_host_override", 2, &argv[1],
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while setting server/host override");
return DM_NORMAL;
}
-int ghost(int argc, char **argv, char **cargv)
+int ghost(int argc, char **argv, void *hint)
{
- cargv[SHI_SERVICE] = strsave(argv[SH_SERVICE]);
- cargv[SHI_MACHINE] = strsave(argv[SH_MACHINE]);
- cargv[SHI_ENABLE] = strsave(argv[SH_ENABLE]);
- cargv[SHI_VALUE1] = strsave(argv[SH_VALUE1]);
- cargv[SHI_VALUE2] = strsave(argv[SH_VALUE2]);
- cargv[SHI_VALUE3] = strsave(argv[SH_VALUE3]);
+ char **cargv = hint;
+
+ cargv[SHI_SERVICE] = strdup(argv[SH_SERVICE]);
+ cargv[SHI_MACHINE] = strdup(argv[SH_MACHINE]);
+ cargv[SHI_ENABLE] = strdup(argv[SH_ENABLE]);
+ cargv[SHI_VALUE1] = strdup(argv[SH_VALUE1]);
+ cargv[SHI_VALUE2] = strdup(argv[SH_VALUE2]);
+ cargv[SHI_VALUE3] = strdup(argv[SH_VALUE3]);
cargv[SHI_END] = NULL;
return MR_CONT;
}
-int inithost(char **info)
+void inithost(char **info)
{
- info[SHI_MACHINE] = canonicalize_hostname(strsave(info[SH_MACHINE]));
- info[SHI_ENABLE] = strsave("1");
- info[SHI_VALUE1] = strsave("0");
- info[SHI_VALUE2] = strsave("0");
- info[SHI_VALUE3] = strsave("");
+ info[SHI_MACHINE] = canonicalize_hostname(strdup(info[SH_MACHINE]));
+ info[SHI_ENABLE] = strdup("1");
+ info[SHI_VALUE1] = strdup("0");
+ info[SHI_VALUE2] = strdup("0");
+ info[SHI_VALUE3] = strdup("");
info[SHI_END] = NULL;
}
char *info[SHI_END + 1];
int status;
- info[SHI_SERVICE] = strsave(argv[1]);
- info[SHI_MACHINE] = canonicalize_hostname(strsave(argv[2]));
- if ((status = do_mr_query("get_server_host_info", 2, info, ghost,
- (char *)info)))
+ info[SHI_SERVICE] = strdup(argv[1]);
+ info[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2]));
+ if ((status = do_mr_query("get_server_host_info", 2, info, ghost, info)))
{
com_err(whoami, status, " while getting server/host info");
return DM_NORMAL;
return DM_NORMAL;
}
if ((status = do_mr_query("update_server_host_info", SHI_END, info,
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while updating server/host info");
FreeInfo(info);
return DM_NORMAL;
char *info[SHI_END + 1];
int status;
- info[SHI_SERVICE] = strsave(argv[1]);
- info[SHI_MACHINE] = canonicalize_hostname(strsave(argv[2]));
+ info[SHI_SERVICE] = strdup(argv[1]);
+ info[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2]));
inithost(info);
if (!askhost(info))
{
return DM_NORMAL;
}
if ((status = do_mr_query("add_server_host_info", SHI_END, info,
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while adding server/host info");
FreeInfo(info);
return DM_NORMAL;
{
int status;
- if ((status = do_mr_query("delete_server_info", 1, &argv[1], Scream, NULL)))
+ if ((status = do_mr_query("delete_server_info", 1, &argv[1], NULL, NULL)))
com_err(whoami, status, " while deleting server info");
return DM_NORMAL;
}
{
int status;
- argv[2] = canonicalize_hostname(strsave(argv[2]));
+ argv[2] = canonicalize_hostname(strdup(argv[2]));
if ((status = do_mr_query("delete_server_host_info", 2, &argv[1],
- Scream, NULL)))
+ NULL, NULL)))
com_err(whoami, status, " while deleting server/host info");
return DM_NORMAL;
}
-int pserv(int argc, char **argv, int *count)
+int pserv(int argc, char **argv, void *count)
{
sprintf(buf, "Service %s", argv[0]);
Put_message(buf);
- (*count)++;
+ (*(int *)count)++;
return MR_CONT;
}
-int phost(int argc, char **argv, int *count)
+int phost(int argc, char **argv, void *count)
{
sprintf(buf, "Host %s:%s", argv[0], argv[1]);
Put_message(buf);
- (*count)++;
+ (*(int *)count)++;
return MR_CONT;
}
-int InProgress(void)
+int InProgress(int argc, char **oargv)
{
char *argv[6];
int status, count = 0;
argv[0] = argv[2] = "DONTCARE";
argv[1] = "TRUE";
if ((status = do_mr_query("qualified_get_server", 3, argv, pserv,
- (char *)&count)) && status != MR_NO_MATCH)
+ &count)) && status != MR_NO_MATCH)
com_err(whoami, status, " while getting servers");
argv[0] = "*";
argv[1] = argv[2] = argv[3] = argv[5] = "DONTCARE";
argv[4] = "TRUE";
if ((status = do_mr_query("qualified_get_server_host", 6, argv, phost,
- (char *)&count)) && status != MR_NO_MATCH)
+ &count)) && status != MR_NO_MATCH)
com_err(whoami, status, " while getting server/hosts");
if (!count)
strcpy(buf, "Nothing is in progress at this time");
return DM_NORMAL;
}
-int DcmFailed(void)
+int DcmFailed(int argc, char **oargv)
{
char *argv[6];
int status, count = 0;
argv[0] = argv[1] = "DONTCARE";
argv[2] = "TRUE";
if ((status = do_mr_query("qualified_get_server", 3, argv, pserv,
- (char *)&count)) && status != MR_NO_MATCH)
+ &count)) && status != MR_NO_MATCH)
com_err(whoami, status, " while getting servers");
argv[0] = "*";
argv[1] = argv[2] = argv[3] = argv[4] = "DONTCARE";
argv[5] = "TRUE";
if ((status = do_mr_query("qualified_get_server_host", 6, argv, phost,
- (char *)&count)) && status != MR_NO_MATCH)
+ &count)) && status != MR_NO_MATCH)
com_err(whoami, status, " while getting server/hosts");
if (!count)
strcpy(buf, "Nothing has failed at this time");
}
-int Dcm(void)
+int Dcm(int argc, char **argv)
{
int status;
if (Confirm("Are you sure you want to start a DCM now"))
-/* This is the file defs.h for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file defs.h for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: useful definitions.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include "mit-copyright.h"
+#include <mit-copyright.h>
#ifndef _defs_header_
#define _defs_header_
#define MAX_ARGS_SIZE 100
-typedef void (*FVoid)(); /* function pointer typedef. */
-typedef char *(*FCharStar)(); /* function pointer typedef. */
-typedef int (*FInt)(); /* function pointer typedef. */
-
typedef int Bool;
#define IS_EMPTY(s) (strlen((s)) == 0)
struct qelem {
struct qelem *q_forw;
struct qelem *q_back;
- char *q_data;
+ void *q_data;
};
#endif /* _defs_header_ */ /* Do Not Add Anything After This Line */
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file delete.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file delete.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: functions for deleting users and lists.
*
* Created: 5/18/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+int CheckListForDeletion(char *name, Bool verbose);
+void CheckAce(char *type, char *name, Bool verbose);
+int CheckIfAce(char *name, char *type, Bool verbose);
+int RemoveItemFromLists(char *name, char *type, struct qelem **elem,
+ int verbose);
+int RemoveMembersOfList(char *name, Bool verbose);
+int DeleteUserGroup(char *name, Bool verbose);
+int DeleteHomeFilesys(char *name, Bool verbose);
+void AttemptToDeleteList(char **list_info, Bool ask_first);
+
/* Function Name: CheckListForDeletion
* Description: Check one of the lists in which we just removed a member.
* if the list is empty then it will delete it.
char *args[2], buf[BUFSIZ], **info;
if ((status = do_mr_query("count_members_of_list", 1, &name, StoreInfo,
- (char *) &elem)))
+ &elem)))
{
com_err(program_name, status, " in DeleteList (count_members_of_list).");
return SUB_NORMAL;
}
- info = (char **) elem->q_data;
+ info = elem->q_data;
if (!strcmp(info[NAME], "0"))
{
if (verbose)
args[0] = type;
args[1] = name;
- status = do_mr_query("get_ace_use", 2, args, NullFunc, NULL);
+ status = do_mr_query("get_ace_use", 2, args, NULL, NULL);
if (status != MR_NO_MATCH)
return; /* If this query fails the ace will
not be deleted even if it is empty. */
args[0] = type;
args[1] = name;
- switch ((status = do_mr_query("get_ace_use", 2, args,
- StoreInfo, (char *) &elem)))
+ switch ((status = do_mr_query("get_ace_use", 2, args, StoreInfo, &elem)))
{
case MR_NO_MATCH:
return DM_NORMAL;
case MR_SUCCESS:
local = elem = QueueTop(elem);
- info = (char **) local->q_data;
+ info = local->q_data;
if (QueueCount(elem) == 1 &&
!strcmp(info[0], "LIST") &&
!strcmp(info[1], name))
Put_message("");
for (; local != NULL; local = local->q_forw)
{
- info = (char **) local->q_data;
+ info = local->q_data;
if (!strcmp(info[0], "LIST") &&
!strcmp(info[1], name))
continue;
* Get all list of which this item is a member, and store them in a queue.
*/
- status = do_mr_query("get_lists_of_member", 2, args, StoreInfo,
- (char *) elem);
+ status = do_mr_query("get_lists_of_member", 2, args, StoreInfo, elem);
if (status == MR_NO_MATCH)
return SUB_NORMAL;
Put_message(temp_buf);
while (local)
{
- char **info = (char **) local->q_data;
+ char **info = local->q_data;
Print(1, &info[GLOM_NAME], (char *) NULL);
local = local->q_forw;
}
args[DM_TYPE] = type;
while (local)
{
- char **info = (char **) local->q_data;
+ char **info = local->q_data;
args[DM_LIST] = info[GLOM_NAME];
if ((status = do_mr_query("delete_member_from_list",
- 3, args, Scream, NULL)))
+ 3, args, NULL, NULL)))
{
com_err(program_name, status, " in delete_member\nAborting\n");
FreeQueue(*elem);
/*
* Get the members of this list.
*/
- status = do_mr_query("get_members_of_list", 1, &name, StoreInfo,
- (char *) &elem);
+ status = do_mr_query("get_members_of_list", 1, &name, StoreInfo, &elem);
if (status == MR_NO_MATCH)
return SUB_NORMAL;
Put_message(" "); /* Blank Line. */
while (local)
{
- char **info = (char **) local->q_data;
+ char **info = local->q_data;
Print(CountArgs(info), info, NULL);
local = local->q_forw;
}
args[0] = name;
while (local)
{
- char **info = (char **) local->q_data;
+ char **info = local->q_data;
args[1] = info[0];
args[2] = info[1];
if ((status = do_mr_query("delete_member_from_list",
- 3, args, Scream, NULL)))
+ 3, args, NULL, NULL)))
{
com_err(program_name, status, " in delete_member\nAborting\n");
FreeQueue(elem);
int status, ans;
char buf[BUFSIZ], *args[10];
- status = do_mr_query("get_list_info", 1, &name, NullFunc, (char *) NULL);
+ status = do_mr_query("get_list_info", 1, &name, NULL, NULL);
if (!status)
{
if (verbose)
int status;
char buf[BUFSIZ];
- switch ((status = do_mr_query("get_filesys_by_label", 1, &name, NullFunc,
- NULL)))
+ switch ((status = do_mr_query("get_filesys_by_label", 1, &name, NULL, NULL)))
{
case MR_NO_MATCH:
break;
return SUB_ERROR;
}
}
- if ((status = do_mr_query("delete_filesys", 1, &name, Scream,
+ if ((status = do_mr_query("delete_filesys", 1, &name, NULL,
NULL)) != MR_SUCCESS)
{
com_err(program_name, status, " in delete_filesys.");
char buf[BUFSIZ];
int status;
- if ((status = do_mr_query("delete_user", 1, &name, Scream,
+ if ((status = do_mr_query("delete_user", 1, &name, NULL,
NULL)) != MR_SUCCESS)
{
com_err(program_name, status, ": user not deleted");
char buf[BUFSIZ];
int status;
- if ((status = do_mr_query("delete_list", 1, &name, Scream,
+ if ((status = do_mr_query("delete_list", 1, &name, NULL,
NULL)) != MR_SUCCESS)
{
com_err(program_name, status, ": list not deleted");
* 3) This list is not an ace of another object.
*/
- switch ((status = do_mr_query("delete_list", 1, &name, Scream, NULL)))
+ switch ((status = do_mr_query("delete_list", 1, &name, NULL, NULL)))
{
case MR_SUCCESS:
Put_message("List Sucessfully Deleted.");
{
free(list_info[L_ACE_TYPE]);
free(list_info[L_ACE_NAME]);
- list_info[L_ACE_TYPE] = Strsave("USER");
- list_info[L_ACE_NAME] = Strsave(user);
- SlipInNewName(list_info, Strsave(list_info[L_NAME]));
+ list_info[L_ACE_TYPE] = strdup("USER");
+ list_info[L_ACE_NAME] = strdup(user);
+ SlipInNewName(list_info, strdup(list_info[L_NAME]));
if ((status = do_mr_query("update_list", CountArgs(list_info) - 3,
- list_info, Scream, NULL)) != MR_SUCCESS)
+ list_info, NULL, NULL)) != MR_SUCCESS)
{
com_err(program_name, status, " while updating list owner");
Put_message("List may be only partly deleted.");
local = QueueTop(member_of);
while (local)
{
- char **info = (char **) local->q_data;
+ char **info = local->q_data;
if (CheckListForDeletion(info[LM_LIST], ask_first) == SUB_ERROR)
break;
local = local->q_forw;
list = NULL;
switch ((status = do_mr_query("get_list_info", 1, argv + 1,
- StoreInfo, (char *) &list)))
+ StoreInfo, &list)))
{
case MR_SUCCESS:
break;
one_list = (QueueCount(list) == 1);
while (list)
{
- char **info = (char **) list->q_data;
+ char **info = list->q_data;
if (one_list)
{
sprintf(buf, "Are you sure that you want to delete the list %s",
if (!Confirm("Are you sure that you want to delete this user?"))
return DM_NORMAL;
- status = do_mr_query("delete_user", 1, &name, Scream, NULL);
+ status = do_mr_query("delete_user", 1, &name, NULL, NULL);
if (status != MR_IN_USE && status != 0)
{
com_err(program_name, status, ": user not deleted");
local = member_of;
while (local)
{
- char **info = (char **) local->q_data;
+ char **info = local->q_data;
if (CheckListForDeletion(info[0], TRUE) == SUB_ERROR)
break;
local = local->q_forw;
-/* This is the file f_defs.h for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file f_defs.h for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: useful definitions.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include "mit-copyright.h"
+#include <mit-copyright.h>
+#include "menu.h"
#ifndef _f_defs_
#define _f_defs_
/* attach.c */
-int GetFS(); /* Get information about named filsys. */
-int GetFSM(); /* Get filesys by machine */
-int AddFS(); /* Adds a new Filsys to the database. */
-int ChangeFS(); /* Changes information in a Filsys entry. */
-int DeleteFS(); /* Delete a filesystem from the database. */
+int GetFS(int argc, char **argv);
+int GetFSM(int argc, char **argv);
+int AddFS(int argc, char **argv);
+int ChangeFS(int argc, char **argv);
+int DeleteFS(int argc, char **argv);
-int AddFSToGroup(); /* Add a filesystem to an fsgroup */
-int RemoveFSFromGroup(); /* remove a filesystem from an fsgroup */
-int ChangeFSGroupOrder(); /* change the sortorder on an fsgrouop */
-int FSGroupHelp(); /* print info about fsgroups */
+int AddFSToGroup(int argc, char **argv);
+int RemoveFSFromGroup(int argc, char **argv);
+int ChangeFSGroupOrder(int argc, char **argv);
+int FSGroupHelp(int argc, char **argv);
-int GetFSAlias(); /* Gets the value for a Filsys alias. */
-int CreateFSAlias(); /* Creates a new alias in the database. */
-int DeleteFSAlias(); /* Deletes an FS alias from the database. */
+int GetFSAlias(int argc, char **argv);
+int CreateFSAlias(int argc, char **argv);
+int DeleteFSAlias(int argc, char **argv);
-int AttachHelp(); /* Help information specific to filsys. */
+int AttachHelp(void);
/* cluster.c */
-int ShowMachineInfo(); /* Show information on a(many) machine(s). */
-int ShowMachineQuery(); /* Show mach info based on complex query */
-int AddMachine(); /* add a new machine to teh database. */
-int UpdateMachine(); /* updates machine information. */
-int DeleteMachine(); /* delete a machine from the database. */
-int MachineToClusterMap(); /* show machines in clusters. */
-int AddMachineToCluster(); /* add a machine to a new cluster. */
-int RemoveMachineFromCluster(); /* remove a machine from a cluster. */
-
-int ShowClusterInfo(); /* Show information about a cluster. */
-int AddCluster(); /* adds a new cluster to the database. */
-int UpdateCluster(); /* updates information about a cluster. */
-int DeleteCluster(); /* removes a cluste from the database. */
-
-int ShowClusterInfo(); /* show information about a cluster. */
-int MachinesInCluster(); /* list all machines in a give cluster. */
-int AddCluster();
-int UpdateCluster(); /* add, update, and delete clusters. */
-int DeleteCluster();
-
-int ShowClusterData(); /* Show, add, and remove data */
-int AddClusterData(); /* associated with a cluster. */
-int RemoveClusterData();
-
-int ShowSubnetInfo();
-int AddSubnet();
-int UpdateSubnet();
-int DeleteSubnet();
-
-int ShowCname();
-int AddCname();
-int DeleteCname();
+int ShowMachineInfo(int argc, char **argv);
+int ShowMachineQuery(int argc, char **argv);
+int AddMachine(int argc, char **argv);
+int UpdateMachine(int argc, char **argv);
+int DeleteMachine(int argc, char **argv);
+int MachineToClusterMap(int argc, char **argv);
+int AddMachineToCluster(int argc, char **argv);
+int RemoveMachineFromCluster(int argc, char **argv);
+
+int ShowClusterInfo(int argc, char **argv);
+int AddCluster(int argc, char **argv);
+int UpdateCluster(int argc, char **argv);
+int DeleteCluster(int argc, char **argv);
+
+int ShowClusterInfo(int argc, char **argv);
+int AddCluster(int argc, char **argv);
+int UpdateCluster(int argc, char **argv);
+int DeleteCluster(int argc, char **argv);
+
+int ShowClusterData(int argc, char **argv);
+int AddClusterData(int argc, char **argv);
+int RemoveClusterData(int argc, char **argv);
+
+int ShowSubnetInfo(int argc, char **argv);
+int AddSubnet(int argc, char **argv);
+int UpdateSubnet(int argc, char **argv);
+int DeleteSubnet(int argc, char **argv);
+
+int ShowCname(int argc, char **argv);
+int AddCname(int argc, char **argv);
+int DeleteCname(int argc, char **argv);
/* delete.c */
-int DeleteList(), DeleteUser();
+int DeleteList(int argc, char **argv);
+int DeleteUser(int argc, char **argv);
/* lists.c */
-int ListByMember(); /* list all list to which a member belongs. */
-int ListByAdministrator(); /* list all list to which a given member can
- administer. */
-int ListAllGroups();
-int ListAllPublicMailLists(); /* List misc. types of lists. */
-int ListAllMailLists();
+int ListByMember(int argc, char **argv);
+int ListByAdministrator(int argc, char **argv);
+int ListAllPublicMailLists(int argc, char **argv);
-int AddMember(), DeleteMember(); /* add and delete mamber of current list. */
-int ListAllMembers();
-int ListUserMembers(); /* List various members of the current list. */
-int ListListMembers();
-int ListStringMembers();
+int AddMember(int argc, char **argv);
+int DeleteMember(int argc, char **argv);
+int ListAllMembers(int argc, char **argv);
+int ListUserMembers(int argc, char **argv);
+int ListListMembers(int argc, char **argv);
+int ListStringMembers(int argc, char **argv);
-int ShowListInfo(); /* show info about a list. */
-int UpdateList(); /* change info about a list. */
-int InterRemoveItemFromLists(); /* Interactivly remove item from all lists */
+int ShowListInfo(int argc, char **argv);
+int UpdateList(int argc, char **argv);
+int InterRemoveItemFromLists(int argc, char **argv);
-int ListmaintMemberMenuEntry(); /* entry and exit functions for member menu. */
-int ListmaintMemberMenuExit();
-int ListHelp(); /* help function for lists. */
+int ListmaintMemberMenuEntry(Menu *m, int argc, char **argv);
+int ListmaintMemberMenuExit(Menu *m);
+int ListHelp(int argc, char **argv);
/* nfs.c */
-int ShowNFSService(); /* functions that manipulate nfs physical */
-int AddNFSService(); /* services. */
-int UpdateNFSService();
-int DeleteNFSService();
+int ShowNFSService(int argc, char **argv);
+int AddNFSService(int argc, char **argv);
+int UpdateNFSService(int argc, char **argv);
+int DeleteNFSService(int argc, char **argv);
/* pobox.c */
-int GetUserPOBox(); /* operate on user post office boxes. */
-int SetUserPOBox();
-int RemoveUserPOBox();
+int GetUserPOBox(int argc, char **argv);
+int SetUserPOBox(int argc, char **argv);
+int RemoveUserPOBox(int argc, char **argv);
/* quota.c */
-int ShowDefaultQuota(); /* show or change system default quota. */
-int ChangeDefaultQuota();
+int ShowDefaultQuota(int argc, char **argv);
+int ChangeDefaultQuota(int argc, char **argv);
-int GetQuota(); /* modify a user's quota. */
-int GetQuotaByFilesys();
-int AddQuota();
-int UpdateQuota();
-int DeleteQuota();
+int GetQuota(int argc, char **argv);
+int GetQuotaByFilesys(int argc, char **argv);
+int AddQuota(int argc, char **argv);
+int UpdateQuota(int argc, char **argv);
+int DeleteQuota(int argc, char **argv);
/* user.c */
-int ShowUserByLogin(); /* misc. ways to show user. */
-int ShowUserByName();
-int ShowUserByClass();
-int ShowUserById();
-int AddNewUser(); /* add a new user to the database. */
-int RegisterUser(); /* register a user. */
-int UpdateUser(); /* modify info about a user. */
-int DeactivateUser(); /* change a user's status to DELETED */
-int ChangeUserPOBox(); /* change the PO box of a user. */
-int DeleteUserByUid(); /* detete a user by uid. */
-int GetKrbmap(); /* fetch a user->kerberos mapping */
-int AddKrbmap();
-int DeleteKrbmap();
-int GetDirFlags();
-int SetDirFlags();
+int ShowUserByLogin(int argc, char **argv);
+int ShowUserByName(int argc, char **argv);
+int ShowUserByClass(int argc, char **argv);
+int ShowUserById(int argc, char **argv);
+int AddNewUser(int argc, char **argv);
+int RegisterUser(int argc, char **argv);
+int UpdateUser(int argc, char **argv);
+int DeactivateUser(int argc, char **argv);
+int DeleteUserByUid(int argc, char **argv);
+int GetKrbmap(int argc, char **argv);
+int AddKrbmap(int argc, char **argv);
+int DeleteKrbmap(int argc, char **argv);
+int GetDirFlags(int argc, char **argv);
+int SetDirFlags(int argc, char **argv);
/* printer.c */
-int AddPcap();
-int GetPcap();
-int ChngPcap();
-int DeletePcap();
-int GetPalladium(), AddPalladium(), ChngPalladium(), DeletePalladium();
-int ShowPalladiumAlias(), AddPalladiumAlias(), DeletePalladiumAlias();
+int AddPcap(int argc, char **argv);
+int GetPcap(int argc, char **argv);
+int ChngPcap(int argc, char **argv);
+int DeletePcap(int argc, char **argv);
+int GetPalladium(int argc, char **argv);
+int AddPalladium(int argc, char **argv);
+int ChngPalladium(int argc, char **argv);
+int DeletePalladium(int argc, char **argv);
+int ShowPalladiumAlias(int argc, char **argv);
+int AddPalladiumAlias(int argc, char **argv);
+int DeletePalladiumAlias(int argc, char **argv);
/* zephyr.c */
-int AddZephyr();
-int GetZephyr();
-int ChngZephyr();
-int DeleteZephyr();
-
-/* dcm.c */
-int EnableDcm(), InProgress(), DcmFailed(), Dcm();
-int enabledcm(), showserv(), addserv(), updateserv(), delserv();
-int showhost(), resetsrverr(), resetsrvc(), resethosterr();
-int resethost(), sethostor(), addhost(), updatehost(), delhost();
-int inprogress(), failed(), dcm();
+int AddZephyr(int argc, char **argv);
+int GetZephyr(int argc, char **argv);
+int ChngZephyr(int argc, char **argv);
+int DeleteZephyr(int argc, char **argv);
+
+/* dcmmaint.c */
+int EnableDcm(int argc, char **argv);
+int InProgress(int argc, char **argv);
+int DcmFailed(int argc, char **argv);
+int Dcm(int argc, char **argv);
+int showserv(int argc, char **argv);
+int addserv(int argc, char **argv);
+int updateserv(int argc, char **argv);
+int delserv(int argc, char **argv);
+int showhost(int argc, char **argv);
+int resetsrverr(int argc, char **argv);
+int resetsrvc(int argc, char **argv);
+int resethosterr(int argc, char **argv);
+int resethost(int argc, char **argv);
+int sethostor(int argc, char **argv);
+int addhost(int argc, char **argv);
+int updatehost(int argc, char **argv);
+int delhost(int argc, char **argv);
/* misc.c */
-int TableStats(), ShowClients(), ShowValue(), ShowAlias();
+int TableStats(int argc, char **argv);
+int ShowClients(int argc, char **argv);
+int ShowValue(int argc, char **argv);
+int ShowAlias(int argc, char **argv);
/* utils.c */
* internals documentation.
*/
-void EncryptMITID(); /* Encrypts an mit id number. */
-char **CopyInfo(); /* Copies a NULL terminated array of strings */
-void FreeInfo(); /* Frees a NULL terminated array of strings. */
-void FreeQueue(); /* Frees an entire queue. */
-void FreeAndClear(); /* Frees a single pointer. */
-void Loop(); /* Performs an operation on every item in
- a queue. */
-void QueryLoop(); /* Queries the user before performing
- an operation on every item in
- a queue. */
-void RemoveHyphens(); /* Removes the hyphens from a string. */
-void SlipInNewName(); /* Slips a new name into an argument list in
- the correct place. */
-int CountArgs(); /* Counts the strings in a NULL terminated
- array. */
-int GetValueFromUser(); /* Updates value by asking the user. */
-int GetYesNoValueFromUser(); /* Updates yes/no value by asking the user. */
-int GetFSTypes(); /* Gets Filesystem types from a user. */
-int NullFunc(); /* NULL return function. */
-int Print(); /* Prints out array of strings. */
-int PrintByType(); /* Prints out array of strings by type. */
-int PrintHelp(); /* Prints out help information. */
-int StoreInfo(); /* Stores info returned from a Moira query
- in a queue. */
-int Scream(); /* Query Return function that yells if called*/
-int ToggleVerboseMode(); /* Turns on and off the verbose variable. */
-char *CanonicalizeHostname(); /* this is what it does. */
-char *NullPrint(); /* Prints nothing, returns argv[0]. */
-char *Strsave(); /* allocated space for a copy of the string. */
-char *atot(); /* convert unix time to date string */
-struct qelem *QueueTop(); /* Finds the top of a queue. */
-Bool Confirm(); /* Confirms a delete operation, with user. */
-Bool YesNoQuestion(); /* Asks a user a yes no type question. */
-Bool YesNoQuitQuestion(); /* Asks a user a yes - no - quit question. */
-
-#endif /* _f_defs_ */ /* Do Not Add Anything After This Line */
-
-
+char **CopyInfo(char **info);
+void FreeInfo(char **);
+void FreeQueue(struct qelem *elem);
+void FreeAndClear(char **pointer, Bool free_it);
+void Loop(struct qelem *elem, void (*func)(char **));
+void QueryLoop(struct qelem *elem, char * (*print_func)(char **),
+ void (*op_func)(char **, Bool), char *query_string);
+void SlipInNewName(char **info, char *name);
+int CountArgs(char **args);
+int GetValueFromUser(char *prompt, char **pointer);
+int GetYesNoValueFromUser(char *prompt, char **pointer);
+int GetFSTypes(char **current, int options);
+int Print(int argc, char **argv, void *callback);
+int PrintByType(int argc, char **argv, void *callback);
+int PrintHelp(char **help);
+int StoreInfo(int argc, char **argv, void *data);
+int ToggleVerboseMode(int argc, char **argv);
+char *NullPrint(char **info);
+char *atot(char *itime);
+struct qelem *QueueTop(struct qelem *elem);
+Bool Confirm(char *prompt);
+Bool YesNoQuestion(char *prompt, int bool_def);
+Bool YesNoQuitQuestion(char *prompt, int bool_def);
+int do_mr_query(char *name, int argc, char **argv,
+ int (*proc)(int, char **, void *), void *hint);
+int GetTypeFromUser(char *prompt, char *tname, char **pointer);
+int GetAddressFromUser(char *prompt, char **pointer);
+Bool ValidName(char *s);
+int QueueCount(struct qelem *elem);
+int PromptWithDefault(char *prompt, char *buf, int buflen, char *def);
+struct qelem *GetTypeValues(char *tname);
+
+#endif /* _f_defs_ */
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file globals.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file globals.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: globals variable definitions.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include "mit-copyright.h"
+#include <mit-copyright.h>
+#include <moira.h>
#include "defs.h"
+RCSID("$Header$");
+
Bool verbose; /* TRUE if verbose mode is active (default). */
Bool found_some; /* used by lists.c for determining if there
are any members of a given type. */
-/* This is the file globals.h for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file globals.h for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: globals variable definitions.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include "mit-copyright.h"
+#include <mit-copyright.h>
#include "defs.h"
#ifndef _moira_client_globals_
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file lists.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file lists.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: All list manipulation functions, except delete.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+struct qelem *GetListInfo(int type, char *name1, char *name2);
+char **AskListInfo(char **info, Bool name);
+int AddList(int argc, char **argv);
+void ListMembersByType(char *type);
+int GetMemberInfo(char *action, char **ret_argv);
+
#define LIST 0
#define MEMBERS 1
#define GLOM 2
{
case LIST:
args[0] = name1;
- if ((status = do_mr_query("get_list_info", 1, args,
- StoreInfo, (char *) &elem)))
+ if ((status = do_mr_query("get_list_info", 1, args, StoreInfo, &elem)))
{
com_err(program_name, status, " in get_list_info");
return NULL;
case MEMBERS:
args[0] = name1;
if ((status = do_mr_query("get_members_of_list", 1, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status, " in get_members_of_list");
return NULL;
args[0] = name1;
args[1] = name2;
if ((status = do_mr_query("get_lists_of_member", 2, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status, " in get_list_of_members");
return NULL;
case ACE_USE:
args[0] = name1;
args[1] = name2;
- if ((status = do_mr_query("get_ace_use", 2, args,
- StoreInfo, (char *) &elem)))
+ if ((status = do_mr_query("get_ace_use", 2, args, StoreInfo, &elem)))
{
com_err(program_name, status, " in get_ace_use");
return NULL;
{
while (1)
{
- newname = Strsave(info[L_NAME]);
+ newname = strdup(info[L_NAME]);
if (GetValueFromUser("The new name for this list", &newname) ==
SUB_ERROR)
return NULL;
top = list = GetListInfo(LIST, argv[1], NULL);
while (list)
{
- PrintListInfo((char **) list->q_data);
+ PrintListInfo(list->q_data);
list = list->q_forw;
}
*/
if ((strlen(args[2]) <= 8) &&
do_mr_query("get_user_account_by_login", 1, args + 1,
- StoreInfo, (char *) &elem) != MR_NO_MATCH)
+ StoreInfo, &elem) != MR_NO_MATCH)
{
char buf[256];
}
if ((stat = do_mr_query("update_list", CountArgs(args), args,
- Scream, (char *) NULL)) != MR_SUCCESS)
+ NULL, NULL)) != MR_SUCCESS)
{
com_err(program_name, stat, " in UpdateList.");
Put_message("List ** NOT ** Updated.");
static char **SetDefaults(char **info, char *name)
{
- info[L_NAME] = Strsave(name);
- info[L_ACTIVE] = Strsave(DEFAULT_ACTIVE);
- info[L_PUBLIC] = Strsave(DEFAULT_PUBLIC);
- info[L_HIDDEN] = Strsave(DEFAULT_HIDDEN);
- info[L_MAILLIST] = Strsave(DEFAULT_MAILLIST);
- info[L_GROUP] = Strsave(DEFAULT_GROUP);
- info[L_GID] = Strsave(DEFAULT_GID);
- info[L_ACE_TYPE] = Strsave(DEFAULT_ACE_TYPE);
- info[L_ACE_NAME] = Strsave(DEFAULT_ACE_NAME);
- info[L_DESC] = Strsave(DEFAULT_DESCRIPTION);
+ info[L_NAME] = strdup(name);
+ info[L_ACTIVE] = strdup(DEFAULT_ACTIVE);
+ info[L_PUBLIC] = strdup(DEFAULT_PUBLIC);
+ info[L_HIDDEN] = strdup(DEFAULT_HIDDEN);
+ info[L_MAILLIST] = strdup(DEFAULT_MAILLIST);
+ info[L_GROUP] = strdup(DEFAULT_GROUP);
+ info[L_GID] = strdup(DEFAULT_GID);
+ info[L_ACE_TYPE] = strdup(DEFAULT_ACE_TYPE);
+ info[L_ACE_NAME] = strdup(DEFAULT_ACE_NAME);
+ info[L_DESC] = strdup(DEFAULT_DESCRIPTION);
info[L_MODTIME] = info[L_MODBY] = info[L_MODWITH] = info[L_END] = NULL;
return info;
}
if (!ValidName(argv[1]))
return DM_NORMAL;
- status = do_mr_query("get_list_info", 1, argv + 1, NullFunc, NULL);
+ status = do_mr_query("get_list_info", 1, argv + 1, NULL, NULL);
if (status != MR_NO_MATCH)
{
if (status == MR_SUCCESS)
*/
if ((strlen(argv[1]) <= 8) &&
do_mr_query("get_user_account_by_login", 1, argv + 1,
- StoreInfo, (char *) &elem) != MR_NO_MATCH)
+ StoreInfo, &elem) != MR_NO_MATCH)
{
char buf[256];
}
if ((status = do_mr_query("add_list", CountArgs(add_args), add_args,
- Scream, (char *) NULL)) != MR_SUCCESS)
+ NULL, NULL)) != MR_SUCCESS)
{
com_err(program_name, status, " in AddList.");
Put_message("List Not Created.");
* Returns: DM Status Code.
*/
-int ListHelp(void)
+int ListHelp(int argc, char **argv)
{
static char *message[] = {
"Listmaint handles the creation, deletion, and updating of lists.",
else
/* All we want to know is if it exists. */
switch ((stat = do_mr_query("count_members_of_list", 1, argv + 1,
- NullFunc, NULL)))
+ NULL, NULL)))
{
case MR_SUCCESS:
break;
}
sprintf(temp_buf, "Change/Display membership of '%s'", list_name);
- m->m_title = Strsave(temp_buf);
+ m->m_title = strdup(temp_buf);
strcpy(current_list, list_name);
return DM_NORMAL;
}
* NOTE: if type is NULL, all lists members are listed.
*/
-int ListMembersByType(char *type)
+void ListMembersByType(char *type)
{
char temp_buf[BUFSIZ];
int status;
found_some = FALSE;
if ((status = do_mr_query("get_members_of_list", CountArgs(args), args,
PrintByType, type)))
- {
- com_err(program_name, status, " in ListMembersByType");
- return DM_NORMAL;
- }
+ com_err(program_name, status, " in ListMembersByType");
if (!found_some)
{
if (!type)
* Returns: DM_NORMAL
*/
-int ListAllMembers(void)
+int ListAllMembers(int argc, char **argv)
{
ListMembersByType(NULL);
return DM_NORMAL;
* Returns: DM_NORMAL.
*/
-int ListUserMembers(void)
+int ListUserMembers(int argc, char **argv)
{
ListMembersByType("USER");
return DM_NORMAL;
* Returns: DM_NORMAL.
*/
-int ListListMembers(void)
+int ListListMembers(int argc, char **argv)
{
ListMembersByType("LIST");
return DM_NORMAL;
* Returns: DM_NORMAL.
*/
-int ListStringMembers(void)
+int ListStringMembers(int argc, char **argv)
{
ListMembersByType("STRING");
return DM_NORMAL;
{
char temp_buf[BUFSIZ];
- ret_argv[LM_LIST] = Strsave(current_list);
+ ret_argv[LM_LIST] = strdup(current_list);
- ret_argv[LM_TYPE] = Strsave("user");
+ ret_argv[LM_TYPE] = strdup("user");
if (GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]) ==
SUB_ERROR)
return SUB_ERROR;
sprintf(temp_buf, "Name of %s to %s", ret_argv[LM_TYPE], action);
- ret_argv[LM_MEMBER] = Strsave(user);
+ ret_argv[LM_MEMBER] = strdup(user);
if (GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]) == SUB_ERROR)
return SUB_ERROR;
ret_argv[LM_END] = NULL; /* NULL terminate this list. */
* Returns: DM_NORMAL.
*/
-int AddMember(void)
+int AddMember(int argc, char **argv)
{
char *args[10], temp_buf[BUFSIZ], *p;
int status;
- struct qelem *mailhubs, *elem, *GetTypeValues();
+ struct qelem *mailhubs, *elem;
if (GetMemberInfo("add", args) == SUB_ERROR)
return DM_NORMAL;
{
if ((p = strchr(args[LM_MEMBER], '@')))
{
- char *host = canonicalize_hostname(strsave(++p));
+ char *host = canonicalize_hostname(strdup(++p));
mailhubs = GetTypeValues("mailhub");
for (elem = mailhubs; elem; elem = elem->q_forw)
{
if (!strcasecmp(host, elem->q_data))
{
free(host);
- host = strsave(args[LM_MEMBER]);
+ host = strdup(args[LM_MEMBER]);
*(--p) = 0;
sprintf(temp_buf, "String \"%s\" should be USER or LIST "
"\"%s\" because it is a local name.", host,
}
if ((status = do_mr_query("add_member_to_list", CountArgs(args), args,
- Scream, NULL)) != MR_SUCCESS)
+ NULL, NULL)) != MR_SUCCESS)
{
if (status == MR_EXISTS)
{
* Returns: DM_NORMAL
*/
-int DeleteMember(void)
+int DeleteMember(int argc, char **argv)
{
char *args[10];
int status;
if (Confirm("Are you sure you want to delete this member?"))
{
if ((status = do_mr_query("delete_member_from_list", CountArgs(args),
- args, Scream, NULL)))
+ args, NULL, NULL)))
com_err(program_name, status, " in DeleteMember");
else
Put_message("Deletion Completed.");
* enough information in it to delete the member from the list.
*/
-int InterRemoveItemFromLists(void)
+int InterRemoveItemFromLists(int argc, char **argv)
{
int status;
char *type, *name, *args[10], buf[BUFSIZ];
struct qelem *top, *elem;
- type = strsave("USER");
+ type = strdup("USER");
if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
return DM_NORMAL;
sprintf(buf, "Name of %s", type);
- name = strsave(user);
+ name = strdup(user);
if (GetValueFromUser(buf, &name) == SUB_ERROR)
return DM_NORMAL;
while (elem)
{
char line[BUFSIZ];
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
name, info[GLOM_NAME]);
switch (YesNoQuitQuestion(line, FALSE))
args[DM_TYPE] = type;
args[DM_MEMBER] = name;
if ((status = do_mr_query("delete_member_from_list", 3, args,
- Scream, (char *) NULL)))
+ NULL, NULL)))
{
/* should probabally check to delete list. */
com_err(program_name, status, " in delete_member");
* Returns: DM_NORMAL.
*/
-int ListByMember(void)
+int ListByMember(int argc, char **argv)
{
char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
Bool maillist, group;
struct qelem *top, *elem;
- type = strsave("USER");
+ type = strdup("USER");
if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
return DM_NORMAL;
sprintf(buf, "Name of %s", type);
- name = strsave(user);
+ name = strdup(user);
if (GetValueFromUser(buf, &name) == SUB_ERROR)
return DM_NORMAL;
/* What we really want is a recursive search */
sprintf(temp_buf, "R%s", type);
free(type);
- type = Strsave(temp_buf);
+ type = strdup(temp_buf);
if ((maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
TRUE)) == -1)
while (elem)
{
- info = (char **) elem->q_data;
+ info = elem->q_data;
if ((maillist == TRUE && !strcmp(info[GLOM_MAILLIST], "1")) ||
(group == TRUE && !strcmp(info[GLOM_GROUP], "1")))
Put_message(info[GLOM_NAME]);
* Returns: DM_NORMAL.
*/
-int ListByAdministrator(void)
+int ListByAdministrator(int argc, char **argv)
{
char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
struct qelem *top;
- type = strsave("USER");
+ type = strdup("USER");
if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
return DM_NORMAL;
sprintf(buf, "Name of %s", type);
- name = strsave(user);
+ name = strdup(user);
if (GetValueFromUser(buf, &name) == SUB_ERROR)
return DM_NORMAL;
case TRUE:
sprintf(temp_buf, "R%s", type); /* "USER" to "RUSER" etc. */
free(type);
- type = Strsave(temp_buf);
+ type = strdup(temp_buf);
break;
case FALSE:
break;
* Returns: DM_NORMAL.
*/
-int ListAllPublicMailLists(void)
+int ListAllPublicMailLists(int argc, char **argv)
{
int status;
static char *args[] = {
if (YesNoQuestion("This query will take a while. Do you wish to continue?",
TRUE) == TRUE)
{
- if (status = do_mr_query("qualified_get_lists", 5, args,
- Print, NULL) != MR_SUCCESS)
+ if ((status = do_mr_query("qualified_get_lists", 5, args,
+ Print, NULL)) != MR_SUCCESS)
com_err(program_name, status, " in ListAllGroups");
}
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file main.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file main.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: The main driver for the Moira Client.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
+#include <mit-copyright.h>
+#include <moira.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <moira.h>
-#include <menu.h>
-#include <krb_et.h>
+#include <unistd.h>
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+RCSID("$Header$");
+
+static void ErrorExit(char *buf, int status);
+static void Usage(void);
+static void Signal_Handler(void);
+static void CatchInterrupt(void);
char *whoami; /* used by menu.c ugh!!! */
char *moira_server;
extern Menu moira_top_menu, list_menu, user_menu, dcm_menu;
-static void Signal_Handler(), CatchInterrupt();
-
-static void ErrorExit(), Usage();
-char *getlogin();
-uid_t getuid();
-struct passwd *getpwuid();
-
Bool use_menu = TRUE; /* whether or not we are using a menu. */
/* Function Name: main
if (!(user = getlogin()))
user = getpwuid(getuid())->pw_name;
- user = (user && strlen(user)) ? Strsave(user) : "";
+ user = (user && strlen(user)) ? strdup(user) : "";
if (!(program_name = strrchr(argv[0], '/')))
program_name = argv[0];
else
program_name++;
- program_name = Strsave(program_name);
- whoami = Strsave(program_name); /* used by menu.c, ugh !!! */
+ program_name = strdup(program_name);
+ whoami = strdup(program_name); /* used by menu.c, ugh !!! */
verbose = TRUE;
arg = argv;
++arg;
moira_server = *arg;
} else
- Usage(argv);
+ Usage();
}
else
- Usage(argv);
+ Usage();
}
}
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) Signal_Handler;
+ act.sa_handler = Signal_Handler;
sigaction(SIGHUP, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
if (use_menu)
sigaction(SIGINT, &act, NULL);
else
{
- act.sa_handler = (void (*)()) CatchInterrupt;
+ act.sa_handler = CatchInterrupt;
sigaction(SIGINT, &act, NULL);
}
-/*
- * Copyright 1987 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- *
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
* Generic menu system module.
*
- * Basically, we define an enormous tree structure which represents the
- * menu. Some extra pieces (ml_command, ma_doc) get thrown in so we can
- * also use the structure for a command-based system.
- *
- * By making the menu descriptions so general, we can ease porting to just
- * about anything.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char rcsid_menu_c[] = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <sys/types.h>
+#include <moira.h>
+#include "menu.h"
+
+#include <ctype.h>
+#include <curses.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <signal.h>
-#include <curses.h>
#include <unistd.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <com_err.h>
-#include <moira.h>
-#include "menu.h"
+
+RCSID("$Header$");
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
int parsed_argc; /* used by extern routines to get additional */
char **parsed_argv; /* comand line input */
+int Parse_words(char *buf, char *argv[], int n);
+void refresh_ms(struct menu_screen *ms);
+void Put_line(char *msg);
+void menu_com_err_hook(const char *who, long code, const char *fmt, ...);
+struct menu_screen *make_ms(int length);
+void destroy_ms(struct menu_screen *ms);
+struct menu_line *find_command_from(char *c, struct menu *m, int d);
+struct menu_line *Find_command(Menu *m, char *command);
+int toggle_logging(int argc, char *argv[]);
+
/*
* Hook function to cause error messages to be printed through
* curses instead of around it. Takes at most 5 args to the
* printf string (crock...)
*/
-void menu_com_err_hook(const char *who, long code, const char *fmt,
- caddr_t arg1, caddr_t arg2, caddr_t arg3,
- caddr_t arg4, caddr_t arg5)
+void menu_com_err_hook(const char *who, long code, const char *fmt, ...)
{
char buf[BUFSIZ], *cp;
+ va_list ap;
strcpy(buf, who);
for (cp = buf; *cp; cp++)
while (*cp)
cp++;
}
- sprintf(cp, fmt, arg1, arg2, arg3, arg4, arg5);
+ va_start(ap, fmt);
+ vsprintf(cp, fmt, ap);
+ va_end(ap);
Put_message(buf);
}
* if user functions which run their own menus don't cooperate.)
* Start_menu should only be called once, at the start of the program.
*/
-int Start_menu(Menu *m)
+void Start_menu(Menu *m)
{
- struct menu_screen *make_ms();
void (*old_hook)(const char *, long, const char *, va_list) =
set_com_err_hook((void (*) (const char *, long, const char *, va_list))menu_com_err_hook);
Cleanup_menu();
}
-int Cleanup_menu(void)
+void Cleanup_menu(void)
{
if (cur_ms)
{
/* Like Start_menu, except it doesn't print menus and doesn't use curses */
-int Start_no_menu(Menu *m)
+void Start_no_menu(Menu *m)
{
cur_ms = NULLMS;
COLS = 80;
/*
* This routine destroys a menu_screen.
*/
-int destroy_ms(struct menu_screen *ms)
+void destroy_ms(struct menu_screen *ms)
{
delwin(ms->ms_title);
delwin(ms->ms_menu);
char *argv[MAX_ARGC];
int line;
int i;
- struct menu_line *command, *Find_command();
+ struct menu_line *command;
int argc;
int quitflag, is_topmenu = (margc < 0);
- int toggle_logging();
/* Entry function gets called with old menu_screen still current */
if (m->m_entry != NULLFUNC)
}
}
-int refresh_screen(void)
+void refresh_screen(void)
{
if (cur_ms != NULLMS)
{
/* Start paging */
/* This routine will cause the most recently put message to be the
one at the top of the screen when a ---More--- prompt is displayed */
-int Start_paging(void)
+void Start_paging(void)
{
if (cur_ms != NULLMS)
lines_left = LINES - cur_ms->ms_input_y - 1;
}
/* Turn off paging */
-int Stop_paging(void)
+void Stop_paging(void)
{
lines_left = -1;
}
/* Print a message in the input window of cur_ms. */
-int Put_message(char *msg)
+void Put_message(char *msg)
{
char *copy, *line, *s;
}
/* Will be truncated to COLS characters. */
-int Put_line(char *msg)
+void Put_line(char *msg)
{
int y, x, i;
char *msg1, chr;
}
/* Refresh a menu_screen onto the real screen */
-int refresh_ms(struct menu_screen *ms)
+void refresh_ms(struct menu_screen *ms)
{
wrefresh(ms->ms_title);
wrefresh(ms->ms_menu);
-/* $Header$ */
+/* $Id $ */
#define MAX_ARGC 16 /* Maximum argument count per line */
#define MAX_ARGLEN 128 /* Maximum length of an argument */
} Menu_Arg;
typedef struct menu_line {
- int (*ml_function)();
+ int (*ml_function)(int argc, char **argv);
struct menu *ml_submenu;
int ml_argc;
struct menu_arg ml_args[MAX_ARGC];
#define ml_command ml_args[0].ma_doc
typedef struct menu {
- int (*m_entry)();
- int (*m_exit)();
+ int (*m_entry)(struct menu *m, int argc, char **argv);
+ int (*m_exit)(struct menu *m);
char *m_title;
int m_length;
struct menu_line m_lines[MAX_LINES];
#define DM_QUIT 1 /* Quit; ^C or q command received */
/* Macros for initializing menu lines */
-#define NULLFUNC ((int (*)()) 0)
+#define NULLFUNC (0)
#define NULLMENU NULL
#define SUBMENU(cmd, doc, menu) { NULLFUNC, menu, 1, { { cmd, doc } } }
#define SIMPLEFUNC(cmd, doc, func) { func, NULLMENU, 1, { { cmd, doc } } }
/* Unused words found on parsed command line */
extern int parsed_argc;
extern char **parsed_argv;
+
+/* prototypes */
+void Put_message(char *msg);
+void Start_menu(Menu *m);
+void Start_no_menu(Menu *m);
+int Do_menu(Menu *m, int margc, char *margv[]);
+void Cleanup_menu(void);
+void Start_paging(void);
+void Stop_paging(void);
+int Prompt_input(char *prompt, char *buf, int buflen);
+void refresh_screen(void);
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file menus.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file menus.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: All menu definitions.
*
* Created: 4/11/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
+#include <mit-copyright.h>
+#include <moira.h>
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+
+RCSID("$Header$");
/* ------------------------- Second Tier Menus ------------------------- */
-/* This is the file misc.c for the Moira Client, which allows a naieve
+/* $Id $
+ *
+ * This is the file misc.c for the Moira Client, which allows a naieve
* to quickly and easily maintain most parts of the Moira database.
* It Contains:
* TableStats
* Created: 5 October 1988
* By: Mark A. Rosenstein
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
#include <sys/types.h>
-#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+void PrintStats(char **info);
+void PrintClients(char **info);
+void PrintValue(char **info);
+void PrintAlias(char **info);
/* Function Name: PrintStats
* Description: print statistics from argv
* Returns: DM_NORMAL
*/
-int PrintStats(char **info)
+void PrintStats(char **info)
{
char buf[BUFSIZ];
* Returns: DM_NORMAL
*/
-int TableStats(void)
+int TableStats(int argc, char **argv)
{
int status;
struct qelem *elem = NULL;
- if ((status = do_mr_query("get_all_table_stats", 0, NULL,
- StoreInfo, (char *)&elem)))
+ if ((status = do_mr_query("get_all_table_stats", 0, NULL, StoreInfo, &elem)))
{
com_err(program_name, status, " in TableStats");
return DM_NORMAL;
* Arguments: argv
*/
-int PrintClients(char **info)
+void PrintClients(char **info)
{
char buf[BUFSIZ];
unsigned long host_address;
if (host_entry)
{
free(info[1]);
- info[1] = Strsave(host_entry->h_name);
+ info[1] = strdup(host_entry->h_name);
}
}
sprintf(buf, "Principal %s on %s (%s)", info[0], info[1], info[2]);
* Returns: DM_NORMAL
*/
-int ShowClients(void)
+int ShowClients(int argc, char **argv)
{
int status;
struct qelem *elem = NULL;
- if ((status = do_mr_query("_list_users", 0, NULL,
- StoreInfo, (char *) &elem)))
+ if ((status = do_mr_query("_list_users", 0, NULL, StoreInfo, &elem)))
{
com_err(program_name, status, " in ShowClients");
return DM_NORMAL;
* Arguments: argv
*/
-int PrintValue(char **info)
+void PrintValue(char **info)
{
char buf[BUFSIZ];
int status;
struct qelem *elem = NULL;
- if ((status = do_mr_query("get_value", 1, &argv[1],
- StoreInfo, (char *) &elem)))
+ if ((status = do_mr_query("get_value", 1, &argv[1], StoreInfo, &elem)))
{
com_err(program_name, status, " in ShowValue");
return DM_NORMAL;
* Arguments: argv
*/
-int PrintAlias(char **info)
+void PrintAlias(char **info)
{
char buf[BUFSIZ];
info[0] = argv[1];
info[1] = argv[2];
info[2] = "*";
- if ((status = do_mr_query("get_alias", 3, info,
- StoreInfo, (char *) &elem)))
+ if ((status = do_mr_query("get_alias", 3, info, StoreInfo, &elem)))
{
com_err(program_name, status, " in ShowAlias");
return DM_NORMAL;
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file main.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file main.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: The main driver for the Moira Client.
*
* Created: 4/12/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <pwd.h>
+#include <mit-copyright.h>
+#include <moira.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
#include <signal.h>
#include <stdio.h>
#include <string.h>
+#if 0
+#include <pwd.h>
#include <sys/types.h>
-#include <moira.h>
-#include <menu.h>
+#endif
+
#include <krb.h>
+RCSID("$Header$");
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+static void ErrorExit(char *buf, int status);
+static void Usage(void);
+static void Signal_Handler(void);
+static void CatchInterrupt(void);
+int NewListHelp(int argc, char **argv);
char *whoami; /* used by menu.c ugh!!! */
char *moira_server;
int interrupt = 0;
-int NewListHelp();
/*
* List Information Menu
}
};
-
-static void Signal_Handler(), CatchInterrupt();
-
-static void ErrorExit(), Usage();
-char *getlogin();
-uid_t getuid();
-struct passwd *getpwuid();
-
Bool use_menu = TRUE; /* whether or not we are using a menu. */
/* Function Name: main
program_name = argv[0];
else
program_name++;
- program_name = Strsave(program_name);
- whoami = Strsave(program_name); /* used by menu.c, ugh !!! */
+ program_name = strdup(program_name);
+ whoami = strdup(program_name); /* used by menu.c, ugh !!! */
verbose = TRUE;
arg = argv;
moira_server = *arg;
}
else
- Usage(argv);
+ Usage();
else
- Usage(argv);
+ Usage();
}
}
exit(1);
}
tf_close();
- user = Strsave(pname);
+ user = strdup(pname);
if ((status = mr_motd(&motd)))
ErrorExit("\nUnable to check server status", status);
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) Signal_Handler;
+ act.sa_handler = Signal_Handler;
sigaction(SIGHUP, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
if (use_menu)
sigaction(SIGINT, &act, NULL);
else
{
- act.sa_handler = (void (*)()) CatchInterrupt;
+ act.sa_handler = CatchInterrupt;
sigaction(SIGINT, &act, NULL);
}
/* Dummy routine to be able to link against the rest of the moira client */
-int DeleteUser(void)
+int DeleteUser(int argc, char **argv)
{
return DM_QUIT;
}
-int NewListHelp(void)
+int NewListHelp(int argc, char **argv)
{
static char *message[] = {
"A list can be a mailing list, an Athena group list, or both. Each",
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file nfs.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file nfs.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: All functions for manipulating NFS Physical directories.
*
* Created: 5/6/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+char **AskNFSInfo(char **info);
#define TYPE_NFS "NFS"
{
char temp_buf[BUFSIZ];
sprintf(temp_buf, "Machine %s Directory %s", info[NFS_NAME], info[NFS_DIR]);
- return Strsave(temp_buf); /* Small memory leak here, but no good way
+ return strdup(temp_buf); /* Small memory leak here, but no good way
to avoid it that I see. */
}
if (!ValidName(argv[1]))
return DM_NORMAL;
- args[0] = canonicalize_hostname(strsave(argv[1]));
- args[1] = strsave(DEFAULT_DIR);
+ args[0] = canonicalize_hostname(strdup(argv[1]));
+ args[1] = strdup(DEFAULT_DIR);
if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
return DM_NORMAL;
- if ((stat = do_mr_query("get_nfsphys", 2, args,
- StoreInfo, &elem)))
+ if ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, &elem)))
com_err(program_name, stat, " in ShowNFSServices.");
free(args[0]);
free(args[1]); /* prevents memory leaks. */
char *info[MAX_ARGS_SIZE];
int stat;
- args[0] = canonicalize_hostname(strsave(argv[1]));
- args[1] = strsave(DEFAULT_DIR);
+ args[0] = canonicalize_hostname(strdup(argv[1]));
+ args[1] = strdup(DEFAULT_DIR);
if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
return DM_NORMAL;
if (!ValidName(args[0]) || !ValidName(args[1]))
return DM_NORMAL;
- if (!(stat = do_mr_query("get_nfsphys", 2, args, NullFunc, NULL)))
+ if (!(stat = do_mr_query("get_nfsphys", 2, args, NULL, NULL)))
stat = MR_EXISTS;
if (stat != MR_NO_MATCH)
{
return DM_NORMAL;
}
- info[NFS_NAME] = Strsave(args[0]);
+ info[NFS_NAME] = strdup(args[0]);
info[NFS_DIR] = args[1]; /* already saved. */
- info[NFS_DEVICE] = Strsave(DEFAULT_DEVICE);
- info[NFS_STATUS] = Strsave(DEFAULT_STATUS);
- info[NFS_ALLOC] = Strsave(DEFAULT_ALLOC);
- info[NFS_SIZE] = Strsave(DEFAULT_SIZE);
+ info[NFS_DEVICE] = strdup(DEFAULT_DEVICE);
+ info[NFS_STATUS] = strdup(DEFAULT_STATUS);
+ info[NFS_ALLOC] = strdup(DEFAULT_ALLOC);
+ info[NFS_SIZE] = strdup(DEFAULT_SIZE);
info[NFS_MODBY] = info[NFS_MODWITH] = info[NFS_MODTIME] = NULL;
info[NFS_END] = NULL;
}
if ((stat = do_mr_query("add_nfsphys", CountArgs(add_args), add_args,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in AdsNFSService");
FreeInfo(info);
}
if ((stat = do_mr_query("update_nfsphys", CountArgs(args), args,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in RealUpdateNFSService");
}
if (!ValidName(argv[1]))
return DM_NORMAL;
- args[0] = canonicalize_hostname(strsave(argv[1]));
- args[1] = strsave(DEFAULT_DIR);
+ args[0] = canonicalize_hostname(strdup(argv[1]));
+ args[1] = strdup(DEFAULT_DIR);
if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
return DM_NORMAL;
- if ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, (char *) &elem)))
+ if ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, &elem)))
{
com_err(program_name, stat, " in UpdateNFSService.");
return DM_NORMAL;
args[1] = info[NFS_DIR];
args[2] = NULL;
switch ((stat = do_mr_query("get_filesys_by_nfsphys", CountArgs(args),
- args, StoreInfo, (char *)&elem)))
+ args, StoreInfo, &elem)))
{
case MR_NO_MATCH: /* it is unused, delete it. */
- if ((stat = do_mr_query("delete_nfsphys", 2, info, Scream, NULL)))
+ if ((stat = do_mr_query("delete_nfsphys", 2, info, NULL, NULL)))
com_err(program_name, stat, " in DeleteNFSService");
else
Put_message("Physical Filesystem Deleted.");
if (!ValidName(argv[1]))
return DM_NORMAL;
- args[0] = canonicalize_hostname(strsave(argv[1]));
- args[1] = strsave(DEFAULT_DIR);
+ args[0] = canonicalize_hostname(strdup(argv[1]));
+ args[1] = strdup(DEFAULT_DIR);
if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
return DM_NORMAL;
- switch ((stat = do_mr_query("get_nfsphys", 2, args,
- StoreInfo, (char *) &elem)))
+ switch ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, &elem)))
{
case MR_NO_MATCH:
Put_message("This filsystem does not exist!");
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file pobox.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file pobox.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: Functions for handling the poboxes.
*
* Created: 7/10/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
#define FOREIGN_BOX ("SMTP")
#define LOCAL_BOX ("POP")
struct qelem *top = NULL;
if ((status = do_mr_query("get_server_locations", CountArgs(args), args,
- StoreInfo, (char *)&top)))
+ StoreInfo, &top)))
{
com_err(program_name, status, " in get_server_locations.");
return SUB_ERROR;
if (!ValidName(argv[1]))
return DM_NORMAL;
- switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo,
- (char *)&top)))
+ switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo, &top)))
{
case MR_NO_MATCH:
Put_message("This user has no P.O. Box.");
Put_message("");
if (!Prompt_input("Which Machine? ", temp_buf, BUFSIZ))
return (char *) SUB_ERROR;
- return canonicalize_hostname(strsave(temp_buf));
+ return canonicalize_hostname(strdup(temp_buf));
}
Put_message("Could not get machines to choose from, quitting.");
return (char *) SUB_ERROR;
return DM_NORMAL;
/* Print the current PO Box info */
- switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo,
- (char *)&top)))
+ switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo, &top)))
{
case MR_SUCCESS:
sprintf(temp_buf, "Current pobox for user %s: \n", local_user);
{
case TRUE:
switch ((status = do_mr_query("set_pobox_pop", 1,
- &local_user, Scream, NULL)))
+ &local_user, NULL, NULL)))
{
case MR_SUCCESS:
return DM_NORMAL;
args[PO_BOX] = box;
args[PO_END] = NULL;
if ((status = do_mr_query("set_pobox", CountArgs(args), args,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, status, " in ChangeUserPOBox");
else
Put_message("PO Box assigned.");
if (Confirm(temp_buf))
{
if ((status = do_mr_query("delete_pobox", 1, argv + 1,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, status, " in delete_pobox.");
else
Put_message("PO Box removed.");
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file printer.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file printer.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: Functions for handling the printers.
*
* Created: 8/16/88
* By: Theodore Y. Ts'o
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+void RealDeletePcap(char **info, Bool one_item);
+void ChangePcap(char **info, Bool one_item);
+void ChangePalladium(char **info, Bool one_item);
+void RealDeletePalladium(char **info, Bool one_item);
+
#define DEFAULT_MACHINE "E40-PRINT-SERVER-1.MIT.EDU"
/* Function Name: SetDefaults
strcpy(spool_dir, "/usr/spool/printer/");
strcat(spool_dir, name);
- info[PCAP_NAME] = Strsave(name);
- info[PCAP_SPOOL_HOST] = Strsave(DEFAULT_MACHINE);
- info[PCAP_SPOOL_DIR] = Strsave(spool_dir);
- info[PCAP_RPRINTER] = Strsave(name);
- info[PCAP_QSERVER] = Strsave("[NONE]");
- info[PCAP_AUTH] = Strsave("1");
- info[PCAP_PRICE] = Strsave("10");
- info[PCAP_COMMENTS] = Strsave("");
+ info[PCAP_NAME] = strdup(name);
+ info[PCAP_SPOOL_HOST] = strdup(DEFAULT_MACHINE);
+ info[PCAP_SPOOL_DIR] = strdup(spool_dir);
+ info[PCAP_RPRINTER] = strdup(name);
+ info[PCAP_QSERVER] = strdup("[NONE]");
+ info[PCAP_AUTH] = strdup("1");
+ info[PCAP_PRICE] = strdup("10");
+ info[PCAP_COMMENTS] = strdup("");
info[PCAP_MODTIME] = info[PCAP_MODBY] = info[PCAP_MODWITH] = NULL;
info[PCAP_END] = NULL;
int stat;
struct qelem *elem = NULL;
- if ((stat = do_mr_query("get_printcap_entry", 1, &name,
- StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_printcap_entry", 1, &name, StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetPcapInfo");
return NULL;
/* Function Name: PrintPcapInfo
* Description: Yet another specialized print function.
* Arguments: info - all info about this Printer.
- * Returns: none
+ * Returns: printer name
*/
-static void PrintPcapInfo(char **info)
+static char *PrintPcapInfo(char **info)
{
char buf[BUFSIZ];
if (!info) /* If no informaion */
{
Put_message("PrintPcapInfo called with null info!");
- return;
+ return NULL;
}
sprintf(buf, "Printer: %-35s Spool host: %s", info[PCAP_NAME],
info[PCAP_SPOOL_HOST]);
sprintf(buf, MOD_FORMAT, info[PCAP_MODBY], info[PCAP_MODTIME],
info[PCAP_MODWITH]);
Put_message(buf);
+
+ return info[PCAP_NAME];
}
/* Function Name: AskPcapInfo.
int stat;
if ((stat = do_mr_query("delete_printcap_entry", 1,
- &info[PCAP_NAME], Scream, NULL)))
+ &info[PCAP_NAME], NULL, NULL)))
com_err(program_name, stat, " printcap entry not deleted.");
else
Put_message("Printcap entry deleted.");
return DM_NORMAL;
if (!(stat = do_mr_query("get_printcap_entry", 1, argv + 1,
- NullFunc, NULL)))
+ NULL, NULL)))
{
Put_message ("A Printer by that name already exists.");
return DM_NORMAL;
}
if ((stat = do_mr_query("add_printcap_entry", CountArgs(args), args,
- NullFunc, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in AddPcap");
FreeInfo(info);
* Returns:
*/
-int ChangePcap(char **info, Bool one_item)
+void ChangePcap(char **info, Bool one_item)
{
int stat;
char **oldinfo;
oldinfo = CopyInfo(info);
if (!AskPcapInfo(info))
- return DM_QUIT;
+ return;
if ((stat = do_mr_query("delete_printcap_entry", 1, &info[PCAP_NAME],
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, stat, " printcap entry not deleted.");
- return DM_NORMAL;
+ return;
}
if ((stat = do_mr_query("add_printcap_entry", CountArgs(info), info,
- NullFunc, NULL)))
+ NULL, NULL)))
{
com_err(program_name, stat, " in ChngPcap");
if ((stat = do_mr_query("add_printcap_entry", CountArgs(oldinfo) - 3,
- oldinfo, NullFunc, NULL)))
+ oldinfo, NULL, NULL)))
com_err(program_name, stat, " while attempting to put old info back");
}
FreeInfo(oldinfo);
- return DM_NORMAL;
+ return;
}
static char **SetPdDefaults(char **info, char *name)
{
- info[PD_NAME] = Strsave(name);
- info[PD_IDENT] = Strsave("10000");
- info[PD_HOST] = Strsave(DEFAULT_MACHINE);
+ info[PD_NAME] = strdup(name);
+ info[PD_IDENT] = strdup("10000");
+ info[PD_HOST] = strdup(DEFAULT_MACHINE);
info[PD_MODTIME] = info[PD_MODBY] = info[PD_MODWITH] = NULL;
info[PD_END] = NULL;
/* Function Name: PrintPalladiumInfo
* Description: Yet another specialized print function.
* Arguments: info - all info about this Printer.
- * Returns: none
+ * Returns: printer name
*/
-static void PrintPalladiumInfo(char **info)
+static char *PrintPalladiumInfo(char **info)
{
char buf[BUFSIZ];
if (!info) /* If no informaion */
{
Put_message("PrintPalladiumInfo called with null info!");
- return;
+ return NULL;
}
sprintf(buf, "Name: %-24s Program #: %s Host: %s",
sprintf(buf, MOD_FORMAT, info[PD_MODBY], info[PD_MODTIME],
info[PD_MODWITH]);
Put_message(buf);
+ return info[PD_NAME];
}
}
-int ChangePalladium(char **info, Bool one_item)
+void ChangePalladium(char **info, Bool one_item)
{
int status;
if (!AskPalladiumInfo(info))
- return DM_QUIT;
+ return;
if ((status = do_mr_query("delete_palladium", 1, &info[PD_NAME],
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, status, " palladium entry not deleted.");
- return DM_NORMAL;
+ return;
}
if ((status = do_mr_query("add_palladium", CountArgs(info), info,
- NullFunc, NULL)))
+ NULL, NULL)))
com_err(program_name, status, " in ChngPalladium");
- return DM_NORMAL;
+ return;
}
int stat;
if ((stat = do_mr_query("delete_palladium", 1,
- &info[PD_NAME], Scream, NULL)))
+ &info[PD_NAME], NULL, NULL)))
com_err(program_name, stat, " palladium entry not deleted.");
else
Put_message("Palladium entry deleted.");
struct qelem *top;
top = GetPalladiumInfo(argv[1]);
- Loop(top, PrintPalladiumInfo);
+ Loop(top, (void (*)(char **))PrintPalladiumInfo);
FreeQueue(top);
return DM_NORMAL;
}
if (!ValidName(argv[1]))
return DM_NORMAL;
- if (!(status = do_mr_query("get_palladium", 1, &argv[1], NullFunc, NULL)))
+ if (!(status = do_mr_query("get_palladium", 1, &argv[1], NULL, NULL)))
{
Put_message("A server or supervisor by that name already exists.");
return DM_NORMAL;
}
if ((status = do_mr_query("add_palladium", CountArgs(args), args,
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, status, " in AddPalladium");
FreeInfo(info);
Put_message("");
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
sprintf(buf, "Printer: %-16s Server/Supervisor: %s", info[0], info[2]);
Put_message(buf);
elem = elem->q_forw;
qargv[0] = argv[1];
qargv[1] = "PALLADIUM";
qargv[2] = argv[2];
- if ((status = do_mr_query("add_alias", 3, qargv, Scream, NULL)))
+ if ((status = do_mr_query("add_alias", 3, qargv, NULL, NULL)))
com_err(program_name, status, " in AddPalladiumAlias");
return DM_NORMAL;
}
qargv[0] = argv[1];
qargv[1] = "PALLADIUM";
qargv[2] = argv[2];
- if ((status = do_mr_query("delete_alias", 3, qargv, Scream, NULL)))
+ if ((status = do_mr_query("delete_alias", 3, qargv, NULL, NULL)))
com_err(program_name, status, " in DeletePalladiumAlias");
return DM_NORMAL;
}
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file quota.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file quota.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: Functions for manipulating the quota information.
*
* Created: 7/10/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int afsfilsyshelper(int argc, char **argv, void *hint);
+int afsfilesys(char *name);
+
static char *def_quota = NULL;
#define DEFAULT_FILESYS DEFAULT_NONE
if (override || (def_quota == NULL))
{
if ((status = do_mr_query("get_value", CountArgs(val), val,
- StoreInfo, (char *) &top)))
+ StoreInfo, &top)))
{
com_err(program_name, status, " in ShowDefaultQuota");
if (!def_quota)
{
Put_message("No default Quota Found, setting default to 0.");
- def_quota = Strsave("0");
+ def_quota = strdup("0");
}
else
Put_message("No default Quota Found, retaining old value.");
else
{
top = QueueTop(top);
- info = (char **) top->q_data;
+ info = top->q_data;
FreeAndClear(&def_quota, TRUE);
- def_quota = Strsave(info[0]);
+ def_quota = strdup(info[0]);
FreeQueue(top);
}
}
}
-int afsfilsyshelper(int argc, char **argv, int *hint)
+int afsfilsyshelper(int argc, char **argv, void *hint)
{
- *hint = !strcmp(argv[FS_TYPE], "AFS");
- return 0;
+ *(int *)hint = !strcmp(argv[FS_TYPE], "AFS");
+ return MR_CONT;
}
return NULL;
}
- args[Q_FILESYS] = Strsave(DEFAULT_FILESYS);
- args[Q_TYPE] = Strsave(DEFAULT_QTYPE);
- args[Q_NAME] = Strsave(DEFAULT_USER);
+ args[Q_FILESYS] = strdup(DEFAULT_FILESYS);
+ args[Q_TYPE] = strdup(DEFAULT_QTYPE);
+ args[Q_NAME] = strdup(DEFAULT_USER);
if (quota)
{
- args[Q_QUOTA] = Strsave(GetDefaultUserQuota(FALSE));
+ args[Q_QUOTA] = strdup(GetDefaultUserQuota(FALSE));
args[Q_QUOTA + 1] = NULL; /* NULL terminate. */
}
else
}
if (af)
{
- args[Q_TYPE] = strsave("ANY");
- args[Q_NAME] = strsave(NOBODY);
+ args[Q_TYPE] = strdup("ANY");
+ args[Q_NAME] = strdup(NOBODY);
}
else
{
* Returns: DM_NORMAL.
*/
-int ShowDefaultQuota(void)
+int ShowDefaultQuota(int argc, char **argv)
{
PrintDefaultQuota(GetDefaultUserQuota(TRUE));
return DM_NORMAL;
{
newval[1] = argv[1];
if ((status = do_mr_query("update_value", CountArgs(newval),
- newval, Scream, NULL)) == MR_SUCCESS)
+ newval, NULL, NULL)) == MR_SUCCESS)
{
FreeAndClear(&def_quota, TRUE);
- def_quota = Strsave(argv[1]);
+ def_quota = strdup(argv[1]);
}
else
com_err(program_name, status, " in update_value");
* Returns: DM_NORMAL
*/
-int GetQuota(void)
+int GetQuota(int argc, char **argv)
{
struct qelem *top = NULL;
int status;
return DM_NORMAL;
if ((status = do_mr_query("get_quota", CountArgs(args), args,
- StoreInfo, (char *) &top)) != MR_SUCCESS)
+ StoreInfo, &top)) != MR_SUCCESS)
com_err(program_name, status, " in get_quota");
FreeInfo(args);
* Returns: DM_NORMAL
*/
-int GetQuotaByFilesys(void)
+int GetQuotaByFilesys(int argc, char **argv)
{
struct qelem *top = NULL;
int status;
return DM_NORMAL;
}
- args[0] = Strsave("");
+ args[0] = strdup("");
args[1] = NULL;
if (GetValueFromUser("Filesystem", &args[0]) == SUB_ERROR)
return DM_NORMAL;
if ((status = do_mr_query("get_quota_by_filesys", 1, args,
- StoreInfo, (char *) &top)) != MR_SUCCESS)
+ StoreInfo, &top)) != MR_SUCCESS)
com_err(program_name, status, " in get_quota_by_filesys");
FreeInfo(args);
* Arguments: None
* Returns: DM_NORMAL
*/
-int AddQuota(void)
+int AddQuota(int argc, char **argv)
{
char **args;
int status;
return DM_NORMAL;
if ((status = do_mr_query("add_quota", CountArgs(args), args,
- Scream, NULL)) != MR_SUCCESS)
+ NULL, NULL)) != MR_SUCCESS)
com_err(program_name, status, " in add_quota");
FreeInfo(args);
return;
}
- if (status = do_mr_query("update_quota", 4, info,
- Scream, NULL) != MR_SUCCESS)
- {
+ if ((status = do_mr_query("update_quota", 4, info,
+ NULL, NULL)) != MR_SUCCESS)
+ {
com_err(program_name, status, " in update_quota");
sprintf(temp_buf, "Could not perform quota change on %s",
info[Q_FILESYS]);
* Returns: DM_NORMAL
*/
-int UpdateQuota(void)
+int UpdateQuota(int argc, char **argv)
{
int status;
char **args;
return DM_NORMAL;
if ((status = do_mr_query("get_quota", CountArgs(args), args,
- StoreInfo, (char *) &top)) != MR_SUCCESS)
+ StoreInfo, &top)) != MR_SUCCESS)
com_err(program_name, status, " in get_quota");
FreeInfo(args); /* done with args, free them. */
if (!one_item || Confirm(temp_buf))
{
if ((status = do_mr_query("delete_quota", 3, info,
- Scream, NULL)) != MR_SUCCESS)
+ NULL, NULL)) != MR_SUCCESS)
com_err(program_name, status, " in delete_quota");
else
Put_message("Quota sucessfully removed.");
* Returns: DM_NORMAL
*/
-int DeleteQuota(void)
+int DeleteQuota(int argc, char **argv)
{
int status;
char **args;
if (!(args = GetQuotaArgs(FALSE)))
return DM_NORMAL;
- if ((status = do_mr_query("get_quota", 3, args,
- StoreInfo, (char *) &top)))
+ if ((status = do_mr_query("get_quota", 3, args, StoreInfo, &top)))
com_err(program_name, status, " in get_quota");
FreeInfo(args);
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file user.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file user.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: Functions for manipulating user information.
*
* Created: 5/9/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
#include <ctype.h>
-#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
#ifdef GDSS
-#include <des.h>
-#include <krb.h>
#include <gdss.h>
#endif
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+
+RCSID("$Header$");
+
+void CorrectCapitalization(char **name);
+char **AskUserInfo(char **info, Bool name);
+struct qelem *GetUserInfo(int type, char *name1, char *name2);
#define LOGIN 0
#define UID 1
static char **SetUserDefaults(char **info)
{
- info[U_NAME] = Strsave(UNIQUE_LOGIN);
- info[U_UID] = Strsave(UNIQUE_UID);
- info[U_SHELL] = Strsave(DEFAULT_SHELL);
- info[U_LAST] = Strsave(DEFAULT_NONE);
- info[U_FIRST] = Strsave(DEFAULT_NONE);
- info[U_MIDDLE] = Strsave(DEFAULT_NONE);
- info[U_STATE] = Strsave(DEFAULT_NO);
- info[U_MITID] = Strsave(DEFAULT_NONE);
- info[U_CLASS] = Strsave(DEFAULT_CLASS);
- info[U_COMMENT] = Strsave("");
- info[U_SIGNATURE] = Strsave("");
- info[U_SECURE] = Strsave("0");
+ info[U_NAME] = strdup(UNIQUE_LOGIN);
+ info[U_UID] = strdup(UNIQUE_UID);
+ info[U_SHELL] = strdup(DEFAULT_SHELL);
+ info[U_LAST] = strdup(DEFAULT_NONE);
+ info[U_FIRST] = strdup(DEFAULT_NONE);
+ info[U_MIDDLE] = strdup(DEFAULT_NONE);
+ info[U_STATE] = strdup(DEFAULT_NO);
+ info[U_MITID] = strdup(DEFAULT_NONE);
+ info[U_CLASS] = strdup(DEFAULT_CLASS);
+ info[U_COMMENT] = strdup("");
+ info[U_SIGNATURE] = strdup("");
+ info[U_SECURE] = strdup("0");
info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
return info;
}
* offer to correct it if not.
*/
-int CorrectCapitalization(char **name)
+void CorrectCapitalization(char **name)
{
char temp_buf[BUFSIZ], fixname[BUFSIZ];
if (YesNoQuestion(temp_buf, 1) == TRUE)
{
free(*name);
- *name = strsave(fixname);
+ *name = strdup(fixname);
}
}
}
argv[0] = info[U_FIRST];
argv[1] = info[U_LAST];
if (do_mr_query("get_user_account_by_name", 2, argv,
- StoreInfo, (char *) &elem) == MR_SUCCESS)
+ StoreInfo, &elem) == MR_SUCCESS)
{
Put_message("A user by that name already exists in the database.");
Loop(QueueTop(elem), PrintUserInfo);
}
if (name)
{
- newname = Strsave(info[U_NAME]);
+ newname = strdup(info[U_NAME]);
if (GetValueFromUser("The new login name for this user", &newname) ==
SUB_ERROR)
return NULL;
atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
{
free(info[U_SECURE]);
- info[U_SECURE] = strsave("0");
+ info[U_SECURE] = strdup("0");
}
else if (!strcmp(info[U_SECURE], "0"))
{
gettimeofday(&tv, NULL);
sprintf(buf, "%ld", (long) tv.tv_sec);
free(info[U_SECURE]);
- info[U_SECURE] = strsave(buf);
+ info[U_SECURE] = strdup(buf);
}
/* Sign record */
}
}
#else /* GDSS */
- info[U_SIGNATURE] = strsave("");
+ info[U_SIGNATURE] = strdup("");
#endif /* GDSS */
FreeAndClear(&info[U_MODTIME], TRUE);
case LOGIN:
args[0] = name1;
if ((status = do_mr_query("get_user_account_by_login", 1, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status,
" when attempting to get_user_account_by_login.");
case UID:
args[0] = name1;
if ((status = do_mr_query("get_user_account_by_uid", 1, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status,
" when attempting to get_user_account_by_uid.");
args[0] = name1;
args[1] = name2;
if ((status = do_mr_query("get_user_account_by_name", 2, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status,
" when attempting to get_user_account_by_name.");
case CLASS:
args[0] = name1;
if ((status = do_mr_query("get_user_account_by_class", 1, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status,
" when attempting to get_user_account_by_class.");
case ID:
args[0] = name1;
if ((status = do_mr_query("get_user_account_by_id", 1, args,
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status,
" when attempting to get_user_account_by_id.");
* Returns: DM_NORMAL.
*/
-int AddNewUser(void)
+int AddNewUser(int argc, char **argv)
{
int status;
char **args, *info[MAX_ARGS_SIZE];
return DM_NORMAL;
}
if ((status = do_mr_query("add_user_account", CountArgs(args),
- args, Scream, NULL)))
+ args, NULL, NULL)))
com_err(program_name, status, " in add_user_account");
else
Put_message("New user added to database.");
{
char *name;
- name = strsave("");
+ name = strdup("");
if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
return NULL;
Put_message("KERBEROS code not added, did not reserve name with kerberos.");
{
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
PrintUserInfo(info);
switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
{
case TRUE:
- return Strsave(info[U_UID]);
+ return strdup(info[U_UID]);
case FALSE:
break;
default: /* quit or ^C. */
args[1] = last;
switch ((status = do_mr_query("get_user_account_by_name", 2, args,
- StoreInfo, (char *) &top)))
+ StoreInfo, &top)))
{
case MR_SUCCESS:
break;
top = QueueTop(top);
if (QueueCount(top) == 1) /* This is a unique name. */
{
- char **info = (char **) top->q_data;
+ char **info = top->q_data;
Put_message("User ID Number retrieved for the user: ");
Put_message("");
PrintUserName(info);
- uid = Strsave(info[U_UID]);
+ uid = strdup(info[U_UID]);
FreeQueue(top);
- return Strsave(uid);
+ return strdup(uid);
}
Put_message("That name is not unique, choose the user that you want.");
* Returns: DM_NORMAL.
*/
-int RegisterUser(void)
+int RegisterUser(int argc, char **argv)
{
char *args[MAX_ARGS_SIZE];
char *login, *fstype = NULL;
{
case TRUE:
Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
- args[0] = Strsave(temp_buf);
+ args[0] = strdup(temp_buf);
break;
case FALSE:
if (!(args[0] = GetUidNumberFromName()))
}
sprintf(temp_buf, "u%s", args[0]);
- login = strsave(temp_buf);
+ login = strdup(temp_buf);
if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
(GetFSTypes(&fstype, FALSE) == SUB_ERROR))
{
args[3] = NULL;
switch ((status = do_mr_query("register_user", CountArgs(args),
- args, Scream, NULL)))
+ args, NULL, NULL)))
{
case MR_SUCCESS:
sprintf(temp_buf, "User %s successfully registered.", login);
return;
}
if ((status = do_mr_query("update_user_account", CountArgs(args),
- args, Scream, NULL)))
+ args, NULL, NULL)))
{
com_err(program_name, status, " in ModifyFields");
sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
qargs[0] = info[NAME];
qargs[1] = "3";
- if ((status = do_mr_query("update_user_status", 2, qargs, Scream, NULL)))
+ if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
{
com_err(program_name, status, " in update_user_status");
sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
FALSE) == TRUE)
{
status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
- (char *) &elem);
+ &elem);
if (status == MR_SUCCESS)
{
- args = (char **) (QueueTop(elem)->q_data);
+ args = QueueTop(elem)->q_data;
free(args[L_ACTIVE]);
- args[L_ACTIVE] = strsave("0");
+ args[L_ACTIVE] = strdup("0");
FreeAndClear(&args[L_MODTIME], TRUE);
FreeAndClear(&args[L_MODBY], TRUE);
FreeAndClear(&args[L_MODWITH], TRUE);
SlipInNewName(args, args[L_NAME]);
if ((status = do_mr_query("update_list", CountArgs(args), args,
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, status, " updating list, "
"not deactivating list or filesystem");
}
if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, status, " getting filsys info, "
"not deactivating filesystem");
FreeQueue(elem);
return;
}
- args = (char **) (QueueTop(elem)->q_data);
+ args = QueueTop(elem)->q_data;
free(args[FS_TYPE]);
- args[FS_TYPE] = strsave("ERR");
+ args[FS_TYPE] = strdup("ERR");
free(args[FS_COMMENTS]);
- args[FS_COMMENTS] = strsave("Locker disabled; call 3-1325 for help");
+ args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
FreeAndClear(&args[FS_MODTIME], TRUE);
FreeAndClear(&args[FS_MODBY], TRUE);
FreeAndClear(&args[FS_MODWITH], TRUE);
SlipInNewName(args, args[FS_NAME]);
if ((status = do_mr_query("update_filesys", CountArgs(args), args,
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, status, " updating filesystem, "
"not deactivating filesystem");
return DM_NORMAL;
if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
- (char *) &elem)))
+ &elem)))
com_err(program_name, status, " in get_user_account_by_uid");
- info = (char **) elem->q_data;
+ info = elem->q_data;
argv[1] = info[U_NAME];
DeleteUser(argc, argv);
char buf[BUFSIZ];
if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetKrbMap.");
return DM_NORMAL;
Put_message("");
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
sprintf(buf, "User: %-9s Principal: %s",
info[KMAP_USER], info[KMAP_PRINCIPAL]);
Put_message(buf);
return DM_NORMAL;
}
if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, stat, " in AddKrbMap.");
if (stat == MR_EXISTS)
int stat;
if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in DeleteKrbMap.");
return DM_NORMAL;
}
return DM_NORMAL;
if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
- StoreInfo, (char *)&elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetDirFlags.");
return DM_NORMAL;
}
- info = (char **) QueueTop(elem)->q_data;
+ info = QueueTop(elem)->q_data;
flags = atoi(info[0]);
FreeQueue(QueueTop(elem));
/* Fetch current prefs */
if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
- StoreInfo, (char *) &elem)))
+ StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetDirFlags.");
return DM_NORMAL;
}
- info = (char **) QueueTop(elem)->q_data;
+ info = QueueTop(elem)->q_data;
flags = atoi(info[0]);
FreeQueue(QueueTop(elem));
sprintf(buf, "%d", flags);
args[1] = buf;
if ((stat = do_mr_query("update_user_directory_flags", 2,
- args, Scream, NULL)))
+ args, NULL, NULL)))
com_err(program_name, stat, " in SetDirFlags");
else
Put_message("Directory preferences set.");
-#if (!defined(lint) && !defined(SABER))
- static char rcsid_module_c[] = "$Header$";
-#endif
-
-/* This is the file utils.c for the Moira Client, which allows users
+/* $Id $
+ *
+ * This is the file utils.c for the Moira Client, which allows users
* to quickly and easily maintain most parts of the Moira database.
* It Contains: Many useful utility functions.
*
* Created: 4/25/88
* By: Chris D. Peterson
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-#include <ctype.h>
-
-#include "mit-copyright.h"
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
-#include <netdb.h> /* for gethostbyname. */
-#include <sys/types.h>
+
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <netdb.h> /* for gethostbyname. */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+RCSID("$Header$");
/* Function Name: AddQueue
* Description: Adds an element to a queue
if (!ret)
return ret;
for (i = 0; info[i]; i++)
- ret[i] = Strsave(info[i]);
+ ret[i] = strdup(info[i]);
ret[i] = NULL;
return ret;
}
static void FreeQueueElem(struct qelem *elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
if (info)
{
* Returns: MR_CONT, or MR_ABORT if it has problems.
*/
-int StoreInfo(int argc, char **argv, char *data)
+int StoreInfo(int argc, char **argv, void *data)
{
char **info = malloc(MAX_ARGS_SIZE * sizeof(char *));
- struct qelem **old_elem = (struct qelem **) data;
+ struct qelem **old_elem = data;
struct qelem *new_elem = malloc(sizeof(struct qelem));
int count;
}
for (count = 0; count < argc; count++)
- info[count] = Strsave(argv[count]);
+ info[count] = strdup(argv[count]);
info[count] = NULL; /* NULL terminate this sucker. */
- new_elem->q_data = (char *) info;
+ new_elem->q_data = info;
AddQueue(new_elem, *old_elem);
*old_elem = new_elem;
return number;
}
-/* Function Name: Scream
- * Description: Bitch Loudly and exit, it is intended as a callback
- * function for queries that should never return a value.
- * Arguments: none
- * Returns: doesn't exit.
- */
-
-int Scream(void)
-{
- com_err(program_name, 0,
- "\nA Moira update returned a value -- programmer botch\n");
- mr_disconnect();
- exit(1);
- /*NOTREACHED*/
- return -1;
-}
-
/* Function Name: PromptWithDefault
* Description: allows a user to be prompted for input, and given a
* default choice.
* Returns: DM_NORMAL.
*/
-int ToggleVerboseMode(void)
+int ToggleVerboseMode(int argc, char **argv)
{
verbose = !verbose;
return DM_NORMAL;
}
-/* Function Name: NullFunc
- * Description: dummy callback routine
- * Arguments: none
- * Returns: MR_CONT
- */
-
-int NullFunc(void)
-{
- return MR_CONT;
-}
-
/* Function Name: SlipInNewName
* Description: Slips the new name into the number 2 slot of a list, and
* returns a pointer to the new list.
if (strcmp(buf, *pointer))
{
free(*pointer);
- *pointer = Strsave(buf);
+ *pointer = strdup(buf);
}
}
return SUB_NORMAL;
case TRUE:
if (*pointer)
free(*pointer);
- *pointer = Strsave(DEFAULT_YES);
+ *pointer = strdup(DEFAULT_YES);
break;
case FALSE:
if (*pointer)
free(*pointer);
- *pointer = Strsave(DEFAULT_NO);
+ *pointer = strdup(DEFAULT_NO);
break;
case -1:
default:
FreeAndClear(current, TRUE);
sprintf(ret_value, "%d", new_val);
- *current = Strsave(ret_value);
+ *current = strdup(ret_value);
return SUB_NORMAL;
}
-/* Function Name: Strsave
- * Description: save a string.
- * Arguments: string - the string to save.
- * Returns: The malloced string, now safely saved, or NULL.
- */
-
-char *Strsave(char *str)
-{
- char *newstr = malloc(strlen(str) + 1);
-
- if (!newstr)
- return NULL;
- else
- return strcpy(newstr, str);
-}
-
-
/* atot: convert ASCII integer unix time into human readable date string */
char *atot(char *itime)
{
time_t time;
- char *ct, *ctime();
+ char *ct;
time = (time_t) atoi(itime);
ct = ctime(&time);
* Returns: MR_CONT
*/
-int Print(int argc, char **argv, char *callback)
+int Print(int argc, char **argv, void *callback)
{
char buf[BUFSIZ];
int i;
* Returns: MR_CONT or MR_QUIT.
*/
-int PrintByType(int argc, char **argv, char *callback)
+int PrintByType(int argc, char **argv, void *callback)
{
if (!callback)
return Print(argc, argv, callback);
* Returns: none.
*/
-void Loop(struct qelem *elem, FVoid func)
+void Loop(struct qelem *elem, void (*func)(char **))
{
while (elem)
{
- char **info = (char **) elem->q_data;
- (*func) (info);
+ (*func) (elem->q_data);
elem = elem->q_forw;
}
}
* "Delete the list"
*/
-void QueryLoop(struct qelem *elem, FCharStar print_func,
- FVoid op_func, char *query_string)
+void QueryLoop(struct qelem *elem, char * (*print_func)(char **),
+ void (*op_func)(char **, Bool), char *query_string)
{
Bool one_item;
char temp_buf[BUFSIZ], *name;
one_item = (QueueCount(elem) == 1);
while (elem)
{
- char **info = (char **) elem->q_data;
+ char **info = elem->q_data;
if (one_item)
(*op_func) (info, one_item);
struct qelem *GetTypeValues(char *tname)
{
int stat;
- char *argv[3], *p, **pp, *strsave();
+ char *argv[3], *p, **pp;
struct qelem *elem, *oelem;
static struct qelem *cache = NULL;
struct cache_elem {
for (elem = cache; elem; elem = elem->q_forw)
{
- ce = (struct cache_elem *) elem->q_data;
+ ce = elem->q_data;
if (!strcmp(ce->cache_name, tname))
return ce->cache_data;
}
argv[1] = "TYPE";
argv[2] = "*";
elem = NULL;
- if ((stat = do_mr_query("get_alias", 3, argv, StoreInfo, (char *)&elem)))
+ if ((stat = do_mr_query("get_alias", 3, argv, StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetTypeValues");
return NULL;
oelem = elem;
for (elem = QueueTop(elem); elem; elem = elem->q_forw)
{
- pp = (char **) elem->q_data;
- p = strsave(pp[2]);
+ pp = elem->q_data;
+ p = strdup(pp[2]);
FreeInfo(pp);
elem->q_data = p;
}
elem = malloc(sizeof(struct qelem));
ce = malloc(sizeof(struct cache_elem));
- ce->cache_name = strsave(tname);
+ ce->cache_name = strdup(tname);
ce->cache_data = QueueTop(oelem);
- elem->q_data = (char *) ce;
+ elem->q_data = ce;
AddQueue(elem, cache);
cache = QueueTop(elem);
return ce->cache_data;
Put_message(buffer);
for (elem = GetTypeValues(tname); elem; elem = elem->q_forw)
Put_message(elem->q_data);
- *pointer = strsave(def);
+ *pointer = strdup(def);
return GetTypeFromUser(prompt, tname, pointer);
}
for (elem = GetTypeValues(tname); elem; elem = elem->q_forw)
*p = toupper(*p);
}
}
- if ((stat = do_mr_query("add_alias", 3, argv, Scream, NULL)))
+ if ((stat = do_mr_query("add_alias", 3, argv, NULL, NULL)))
com_err(program_name, stat, " in add_alias");
else
{
elem = malloc(sizeof(struct qelem));
- elem->q_data = strsave(*pointer);
+ elem->q_data = strdup(*pointer);
AddQueue(elem, GetTypeValues(tname));
Put_message("Done.");
}
}
- *pointer = strsave(def);
+ *pointer = strdup(def);
return GetTypeFromUser(prompt, tname, pointer);
}
int ret;
addr.s_addr = htonl(atoi(*pointer));
- value = strsave(inet_ntoa(addr));
+ value = strdup(inet_ntoa(addr));
ret = GetValueFromUser(prompt, &value);
if (ret == SUB_ERROR)
return SUB_ERROR;
addr.s_addr = inet_addr(value);
free(pointer);
- sprintf(buf, "%d", ntohl(addr.s_addr));
- *pointer = strsave(buf);
+ sprintf(buf, "%ld", ntohl(addr.s_addr));
+ *pointer = strdup(buf);
return SUB_NORMAL;
}
-int do_mr_query(char *name, int argc, char **argv, int (*proc)(), char *hint)
+int do_mr_query(char *name, int argc, char **argv,
+ int (*proc)(int, char **, void *), void *hint)
{
int status;
extern char *whoami, *moira_server;
-/* $Header$
+/* $Id $
*
* Zephyr ACL routines for the Moira client
*
- * Copyright 1990 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution see the
- * file mit-copyright.h
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <menu.h>
-#include <mit-copyright.h>
-
#include "defs.h"
#include "f_defs.h"
#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+void RealDeleteZephyr(char **info, Bool one_item);
/* Set the default values for zephyr additions. */
static char **SetDefaults(char **info, char *name)
{
- info[ZA_CLASS] = strsave(name);
- info[ZA_XMT_TYPE] = strsave("LIST");
- info[ZA_SUB_TYPE] = strsave("LIST");
- info[ZA_IWS_TYPE] = strsave("LIST");
- info[ZA_IUI_TYPE] = strsave("LIST");
- info[ZA_XMT_ID] = strsave("empty");
- info[ZA_SUB_ID] = strsave("empty");
- info[ZA_IWS_ID] = strsave("empty");
- info[ZA_IUI_ID] = strsave("empty");
+ info[ZA_CLASS] = strdup(name);
+ info[ZA_XMT_TYPE] = strdup("LIST");
+ info[ZA_SUB_TYPE] = strdup("LIST");
+ info[ZA_IWS_TYPE] = strdup("LIST");
+ info[ZA_IUI_TYPE] = strdup("LIST");
+ info[ZA_XMT_ID] = strdup("empty");
+ info[ZA_SUB_ID] = strdup("empty");
+ info[ZA_IWS_ID] = strdup("empty");
+ info[ZA_IUI_ID] = strdup("empty");
info[ZA_MODTIME] = info[ZA_MODBY] = info[ZA_MODWITH] = NULL;
info[ZA_END] = NULL;
return info;
int stat;
struct qelem *elem = NULL;
- if ((stat = do_mr_query("get_zephyr_class", 1, &name, StoreInfo,
- (char *)&elem)))
+ if ((stat = do_mr_query("get_zephyr_class", 1, &name, StoreInfo, &elem)))
{
com_err(program_name, stat, " in GetZephyrInfo");
return NULL;
/* Print zephyr acl info */
-static void PrintZephyrInfo(char **info)
+static char *PrintZephyrInfo(char **info)
{
char buf[BUFSIZ];
if (!info)
{
Put_message("PrintZephyrInfo called with null info!");
- return;
+ return NULL;
}
sprintf(buf, " Zephyr class: %s", info[ZA_CLASS]);
Put_message(buf);
if (!strcmp(info[ZA_XMT_ID], "WILDCARD"))
{
free(info[ZA_XMT_ID]);
- info[ZA_XMT_ID] = strsave("*.*@*");
+ info[ZA_XMT_ID] = strdup("*.*@*");
}
sprintf(buf, "Transmit ACL: %s %s", info[ZA_XMT_TYPE],
strcasecmp(info[ZA_XMT_TYPE], "NONE") ? info[ZA_XMT_ID] : "");
if (!strcmp(info[ZA_SUB_ID], "WILDCARD"))
{
free(info[ZA_SUB_ID]);
- info[ZA_SUB_ID] = strsave("*.*@*");
+ info[ZA_SUB_ID] = strdup("*.*@*");
}
sprintf(buf, "Subscription ACL: %s %s", info[ZA_SUB_TYPE],
strcasecmp(info[ZA_SUB_TYPE], "NONE") ? info[ZA_SUB_ID] : "");
if (!strcmp(info[ZA_IWS_ID], "WILDCARD"))
{
free(info[ZA_IWS_ID]);
- info[ZA_IWS_ID] = strsave("*.*@*");
+ info[ZA_IWS_ID] = strdup("*.*@*");
}
sprintf(buf, "Instance Wildcard ACL: %s %s", info[ZA_IWS_TYPE],
strcasecmp(info[ZA_IWS_TYPE], "NONE") ? info[ZA_IWS_ID] : "");
if (!strcmp(info[ZA_IUI_ID], "WILDCARD"))
{
free(info[ZA_IUI_ID]);
- info[ZA_IUI_ID] = strsave("*.*@*");
+ info[ZA_IUI_ID] = strdup("*.*@*");
}
sprintf(buf, "Instance Indentity ACL: %s %s", info[ZA_IUI_TYPE],
strcasecmp(info[ZA_IUI_TYPE], "NONE") ? info[ZA_IUI_ID] : "");
Put_message(buf);
sprintf(buf, MOD_FORMAT, info[ZA_MODBY], info[ZA_MODTIME], info[ZA_MODWITH]);
Put_message(buf);
+
+ return info[ZA_CLASS];
}
{
while (1)
{
- newname = Strsave(info[ZA_CLASS]);
+ newname = strdup(info[ZA_CLASS]);
if (GetValueFromUser("The new name for this class", &newname) ==
SUB_ERROR)
return NULL;
if (!strcmp(info[ZA_XMT_ID], "WILDCARD"))
{
free(info[ZA_XMT_ID]);
- info[ZA_XMT_ID] = strsave("*.*@*");
+ info[ZA_XMT_ID] = strdup("*.*@*");
}
sprintf(buf, "Which %s: ", info[ZA_XMT_TYPE]);
if (GetValueFromUser(buf, &info[ZA_XMT_ID]) == SUB_ERROR)
if (!strcmp(info[ZA_XMT_ID], "*.*@*"))
{
free(info[ZA_XMT_ID]);
- info[ZA_XMT_ID] = strsave("WILDCARD");
+ info[ZA_XMT_ID] = strdup("WILDCARD");
}
}
if (GetTypeFromUser("What kind of subscription restriction", "ace_type",
if (!strcmp(info[ZA_SUB_ID], "WILDCARD"))
{
free(info[ZA_SUB_ID]);
- info[ZA_SUB_ID] = strsave("*.*@*");
+ info[ZA_SUB_ID] = strdup("*.*@*");
}
sprintf(buf, "Which %s: ", info[ZA_SUB_TYPE]);
if (GetValueFromUser(buf, &info[ZA_SUB_ID]) == SUB_ERROR)
if (!strcmp(info[ZA_SUB_ID], "*.*@*"))
{
free(info[ZA_SUB_ID]);
- info[ZA_SUB_ID] = strsave("WILDCARD");
+ info[ZA_SUB_ID] = strdup("WILDCARD");
}
}
if (GetTypeFromUser("What kind of wildcard instance restriction",
if (!strcmp(info[ZA_IWS_ID], "WILDCARD"))
{
free(info[ZA_IWS_ID]);
- info[ZA_IWS_ID] = strsave("*.*@*");
+ info[ZA_IWS_ID] = strdup("*.*@*");
}
sprintf(buf, "Which %s: ", info[ZA_IWS_TYPE]);
if (GetValueFromUser(buf, &info[ZA_IWS_ID]) == SUB_ERROR)
if (!strcmp(info[ZA_IWS_ID], "*.*@*"))
{
free(info[ZA_IWS_ID]);
- info[ZA_IWS_ID] = strsave("WILDCARD");
+ info[ZA_IWS_ID] = strdup("WILDCARD");
}
}
if (GetTypeFromUser("What kind of instance identity restriction",
if (!strcmp(info[ZA_IUI_ID], "WILDCARD"))
{
free(info[ZA_IUI_ID]);
- info[ZA_IUI_ID] = strsave("*.*@*");
+ info[ZA_IUI_ID] = strdup("*.*@*");
}
sprintf(buf, "Which %s: ", info[ZA_IUI_TYPE]);
if (GetValueFromUser(buf, &info[ZA_IUI_ID]) == SUB_ERROR)
if (!strcmp(info[ZA_IUI_ID], "*.*@*"))
{
free(info[ZA_IUI_ID]);
- info[ZA_IUI_ID] = strsave("WILDCARD");
+ info[ZA_IUI_ID] = strdup("WILDCARD");
}
}
FreeAndClear(&info[ZA_MODTIME], TRUE);
int stat;
if ((stat = do_mr_query("delete_zephyr_class", 1, &info[ZA_CLASS],
- Scream, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " zephyr class restriction not deleted.");
else
Put_message("Zephyr class restriction deleted.");
if (!ValidName(argv[1]))
return DM_NORMAL;
- if (!(stat = do_mr_query("get_zephyr_class", 1, argv + 1,
- NullFunc, NULL)))
+ if (!(stat = do_mr_query("get_zephyr_class", 1, argv + 1, NULL, NULL)))
{
Put_message ("A Zephyr class by that name already exists.");
return DM_NORMAL;
}
if ((stat = do_mr_query("add_zephyr_class", CountArgs(args), args,
- NullFunc, NULL)))
+ NULL, NULL)))
com_err(program_name, stat, " in AddZephyr");
FreeInfo(info);
return;
}
if ((stat = do_mr_query("update_zephyr_class", CountArgs(args), args,
- Scream, NULL)))
+ NULL, NULL)))
{
com_err(program_name, stat, " in UpdateZephyr.");
Put_message("Zephyr class ** NOT ** Updated.");
-/*
- * Verify that all Moira updates are successful
+/* $Id $
*
- * Copyright 1988, 1991 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file "mit-copyright.h".
+ * Verify that all Moira updates are successful
*
- * $Header$
- * $Author$
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_chsh_c = "$Header$";
-#endif
-
-#include <stdio.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include "mit-copyright.h"
-#include <sys/time.h>
+
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+RCSID("$Header$");
+
+char *atot(char *itime);
+int process_server(int argc, char **argv, void *sqv);
+void disp_svc(char **argv, char *msg);
+int process_host(int argc, char **argv, void *sqv);
+void disp_sh(char **argv, char *msg);
+int usage(void);
+
static int count = 0;
static char *whoami;
static struct timeval now;
* interval for later use.
*/
-int process_server(int argc, char **argv, struct save_queue *sq)
+int process_server(int argc, char **argv, void *sqv)
{
struct service *s;
+ struct save_queue *sq = sqv;
if (atoi(argv[SVC_ENABLE]))
{
/* Format the information about a service. */
-int disp_svc(char **argv, char *msg)
+void disp_svc(char **argv, char *msg)
{
- char *tmp = strsave(atot(argv[SVC_DFGEN]));
+ char *tmp = strdup(atot(argv[SVC_DFGEN]));
printf("Service %s Interval %s %s/%s/%s %s\n",
argv[SVC_SERVICE], argv[SVC_INTERVAL],
/* Decide if the host has an error or not. */
-int process_host(int argc, char **argv, struct save_queue *sq)
+int process_host(int argc, char **argv, void *sqv)
{
struct service *s = NULL;
- struct save_queue *sq1;
+ struct save_queue *sq = sqv, *sq1;
char *update_int = NULL;
for (sq1 = sq->q_next; sq1 != sq; sq1 = sq1->q_next)
/* Format the information about a host. */
-int disp_sh(char **argv, char *msg)
+void disp_sh(char **argv, char *msg)
{
- char *tmp = strsave(atot(argv[SH_LASTTRY]));
+ char *tmp = strdup(atot(argv[SH_LASTTRY]));
printf("Host %s:%s %s/%s/%s/%s/%s %s\n",
argv[SH_SERVICE], argv[SH_MACHINE],
char *args[2], buf[BUFSIZ], *motd;
struct save_queue *sq;
int status;
- int scream();
int auth_required = 1;
if ((whoami = strrchr(argv[0], '/')) == NULL)
/* Check services first */
args[0] = "*";
- if ((status = mr_query("get_server_info", 1, args,
- process_server, (char *)sq)) &&
+ if ((status = mr_query("get_server_info", 1, args, process_server, sq)) &&
status != MR_NO_MATCH)
com_err(whoami, status, " while getting servers");
args[1] = "*";
- if ((status = mr_query("get_server_host_info", 2, args,
- process_host, (char *)sq)) &&
+ if ((status = mr_query("get_server_host_info", 2, args, process_host, sq)) &&
status != MR_NO_MATCH)
com_err(whoami, status, " while getting servers");
exit(1);
}
-
-int scream(void)
-{
- com_err(whoami, 0,
- "Update to Moira returned a value -- programmer botch.\n");
- mr_disconnect();
- exit(1);
-}
-
int usage(void)
{
fprintf(stderr, "Usage: %s [-noauth]\n", whoami);
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Bare-bones Moira client
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_test_c = "$Header$";
-#endif /* lint */
-
#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <string.h>
#include <moira.h>
-#include <com_err.h>
+
+#include <errno.h>
+#include <fcntl.h>
#include <setjmp.h>
#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#ifdef USE_READLINE
#include "readline.h"
+#include "history.h"
#endif
+RCSID("$Header$");
+
int recursion = 0, interactive;
-extern int errno;
extern int sending_version_no;
int count, quit = 0, cancel = 0;
char *whoami;
#define MAXARGS 20
-void discard_input();
-char *mr_gets();
+void discard_input(void);
+char *mr_gets(char *prompt, char *buf, size_t len);
+void execute_line(char *cmdbuf);
+int parse(char *buf, char *argv[MAXARGS]);
+int print_reply(int argc, char **argv, void *hint);
+void test_noop(void);
+void test_connect(int argc, char **argv);
+void test_disconnect(void);
+void test_host(void);
+void test_new(void);
+void test_old(void);
+void test_motd(void);
+void test_query(int argc, char **argv);
+void test_auth(void);
+void test_access(int argc, char **argv);
+void test_dcm(void);
+void test_script(int argc, char **argv);
+void test_list_requests(void);
int main(int argc, char **argv)
{
return buf;
}
-int execute_line(char *cmdbuf)
+void execute_line(char *cmdbuf)
{
int argc;
char *argv[MAXARGS];
else if (!strcmp(argv[0], "query") || !strcmp(argv[0], "qy"))
test_query(argc, argv);
else if (!strcmp(argv[0], "auth") || !strcmp(argv[0], "a"))
- test_auth(argc, argv);
+ test_auth();
else if (!strcmp(argv[0], "access"))
test_access(argc, argv);
else if (!strcmp(argv[0], "dcm"))
return argc + 1;
}
-int test_noop(void)
+void test_noop(void)
{
int status = mr_noop();
if (status)
com_err("moira (noop)", status, "");
}
-int test_new(void)
+void test_new(void)
{
sending_version_no = MR_VERSION_2;
}
-int test_old(void)
+void test_old(void)
{
sending_version_no = MR_VERSION_1;
}
-int test_connect(int argc, char *argv[])
+void test_connect(int argc, char *argv[])
{
char *server = "";
int status;
com_err("moira (connect)", status, "");
}
-int test_disconnect(void)
+void test_disconnect(void)
{
int status = mr_disconnect();
if (status)
com_err("moira (disconnect)", status, "");
}
-int test_host(void)
+void test_host(void)
{
char host[BUFSIZ];
int status;
printf("You are connected to host %s\n", host);
}
-int test_auth(int argc, char *argv[])
+void test_auth(void)
{
int status;
com_err("moira (auth)", status, "");
}
-int test_script(int argc, char *argv[])
+void test_script(int argc, char *argv[])
{
FILE *inp;
char input[BUFSIZ], *cp;
}
}
-int print_reply(int argc, char **argv)
+int print_reply(int argc, char **argv, void *hint)
{
int i;
for (i = 0; i < argc; i++)
return MR_CONT;
}
-int test_query(int argc, char **argv)
+void test_query(int argc, char **argv)
{
int status;
sigset_t sigs;
com_err("moira (query)", status, "");
}
-int test_access(int argc, char **argv)
+void test_access(int argc, char **argv)
{
int status;
if (argc < 2)
com_err("moira (access)", status, "");
}
-int test_dcm(int argc, char **argv)
+void test_dcm()
{
int status;
com_err("moira (dcm)", status, " while triggering dcm");
}
-int test_motd(int argc, char **argv)
+void test_motd()
{
int status;
char *motd;
printf("No message of the day.\n");
}
-int test_list_requests(void)
+void test_list_requests(void)
{
printf("Available moira requests:\n");
printf("\n");
-/*
- * Copyright 1988 by the Massachusetts Institute of Technology. For copying
- * and distribution information, see the file "mit-copyright.h".
+/* $Id $
*
- * $Source$
- * $Header$
- * $Author$
- *
- */
-
-#ifndef lint
-static char *rcsid_chfn_c = "$Header$";
-#endif
-
-/*
* Talk to the Moira database to change a person's GECOS information.
*
* chfn with no modifiers changes the information of the user who is
* If a commandline argument is given, it is taken to be the username
* of the user whose information is to be changed.
*
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#define FALSE 0
-#define TRUE 1
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
-#include <sys/types.h>
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
-#include <sys/file.h>
+
#include <krb.h>
-#include <ctype.h>
-#include <errno.h>
-/* Moira includes */
-#include <moira.h>
-#include <moira_site.h>
-#include "mit-copyright.h"
+RCSID("$Header$");
+
+#define FALSE 0
+#define TRUE 1
char *whoami;
char *mit_year;
};
+int usage(void);
+int leave(int status);
+int chfn(char *uname);
+int get_user_info(int argc, char *argv[], void *message);
+char *ask(char *question, char *def_val, int phone_num);
+void get_new_info(struct finger_info *old_info, struct finger_info *new_info);
+
int main(int argc, char *argv[])
{
char pname[ANAME_SZ];
exit(1);
}
- if (k_errno = tf_get_pname(pname))
+ if ((k_errno = tf_get_pname(pname)))
{
com_err(whoami, k_errno, "getting kerberos principal name");
exit(1);
exit(status);
}
-int scream(void)
-{
- com_err(whoami, 0, "Unexpected return value from Moira -- programmer botch");
- leave(1);
-}
-
int chfn(char *uname)
{
int status; /* general purpose exit status */
char *motd; /* for Moira server status */
int i;
- int get_user_info();
- void get_new_info();
-
struct finger_info old_info;
struct finger_info new_info;
q_argv[NAME] = uname;
q_argc = NAME + 1;
if ((status = mr_query("get_finger_by_login", q_argc, q_argv,
- get_user_info, (char *) &old_info)))
+ get_user_info, &old_info)))
{
com_err(whoami, status, "while getting user information.");
leave(2);
q_argc = F_MODTIME; /* First non-update query argument */
if ((status = mr_query("update_finger_by_login", q_argc, q_argv,
- scream, NULL)))
+ NULL, NULL)))
{
com_err(whoami, status, "while updating finger information.");
leave(1);
return 0;
}
-int get_user_info(int argc, char *argv[], char *message)
+int get_user_info(int argc, char *argv[], void *message)
{
- struct finger_info *old_info = (struct finger_info *) message;
+ struct finger_info *old_info = message;
if (argc != F_END)
{
printf("Info last changed on %s by user %s with %s.\n",
argv[F_MODTIME], argv[F_MODBY], argv[F_MODWITH]);
- old_info->fullname = strsave(argv[F_FULLNAME]);
- old_info->nickname = strsave(argv[F_NICKNAME]);
- old_info->home_address = strsave(argv[F_HOME_ADDR]);
- old_info->home_phone = strsave(argv[F_HOME_PHONE]);
- old_info->office_address = strsave(argv[F_OFFICE_ADDR]);
- old_info->office_phone = strsave(argv[F_OFFICE_PHONE]);
- old_info->mit_department = strsave(argv[F_MIT_DEPT]);
- old_info->mit_year = strsave(argv[F_MIT_AFFIL]);
+ old_info->fullname = strdup(argv[F_FULLNAME]);
+ old_info->nickname = strdup(argv[F_NICKNAME]);
+ old_info->home_address = strdup(argv[F_HOME_ADDR]);
+ old_info->home_phone = strdup(argv[F_HOME_PHONE]);
+ old_info->office_address = strdup(argv[F_OFFICE_ADDR]);
+ old_info->office_phone = strdup(argv[F_OFFICE_PHONE]);
+ old_info->mit_department = strdup(argv[F_MIT_DEPT]);
+ old_info->mit_year = strdup(argv[F_MIT_AFFIL]);
/* Only pay attention to the first match since login names are
unique in the database. */
printf("To accept the default, type <return>.\n");
printf("To have a blank entry, type the word '%s'.\n\n", BLANK);
-#define GETINFO(m, v, n) new_info->v = strsave(ask(m, old_info->v, n))
+#define GETINFO(m, v, n) new_info->v = strdup(ask(m, old_info->v, n))
GETINFO("Full name", fullname, FALSE);
GETINFO("Nickname", nickname, FALSE);
-/*
- * Copyright 1987 by the Massachusetts Institute of Technology. For copying
- * and distribution information, see the file "mit-copyright.h".
- *
- * $Source$
- * $Header$
- * $Author$
+/* $Id $
*
- */
-
-#ifndef lint
-static char *rcsid_chpobox_c = "$Header$";
-#endif
-
-/*
* Talk to the Moira database to change a person's home mail machine. This may
* be an Athena machine, or a completely arbitrary address.
*
* are trying to change the email address of another. You must have
* Kerberos tickets as the person whose address you are trying to
* change, or the attempt will fail.
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <sys/types.h>
-#include <stdio.h>
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
-#include <errno.h>
+#include <unistd.h>
-/* Moira includes */
-#include <moira.h>
-#include <moira_site.h>
-#include "mit-copyright.h"
+RCSID("$Header$");
-char *getlogin();
-char *malloc();
-char *whoami;
-uid_t getuid();
+int get_pobox(int argc, char **argv, void *callarg);
+char *potype(char *machine);
+int check_match(int argc, char **argv, void *callback);
+int check_match3(int argc, char **argv, void *callback);
+int usage(void);
-int getopt();
+char *whoami;
static int match;
-
int main(int argc, char *argv[])
{
struct passwd *pwd;
char *mrarg[3], buf[BUFSIZ];
- char *potype();
char *address, *uname, *machine, *motd;
uid_t u;
- char *canonicalize_hostname();
- int get_pobox(), scream();
int c, setflag, prevpop, usageflag, status;
extern int optind;
extern char *optarg;
c = setflag = prevpop = usageflag = 0;
- address = uname = (char *) NULL;
+ address = uname = NULL;
u = getuid();
if ((whoami = strrchr(argv[0], '/')) == NULL)
prevpop++;
break;
case 'u':
- uname = strsave(optarg);
+ uname = strdup(optarg);
break;
default:
usageflag++;
whoami, address);
goto show;
}
- mrarg[2] = canonicalize_hostname(strsave(machine));
+ mrarg[2] = canonicalize_hostname(strdup(machine));
mrarg[1] = potype(mrarg[2]);
if (!strcmp(mrarg[1], "POP"))
{
mrarg[2] = address;
} else
goto show;
- status = mr_query("set_pobox", 3, mrarg, scream, NULL);
+ status = mr_query("set_pobox", 3, mrarg, NULL, NULL);
if (status)
com_err(whoami, status,
" while setting pobox for %s to type %s, box %s",
}
else if (prevpop)
{
- status = mr_query("set_pobox_pop", 1, mrarg, scream, NULL);
+ status = mr_query("set_pobox_pop", 1, mrarg, NULL, NULL);
if (status == MR_MACHINE)
{
fprintf(stderr,
}
-int scream(void)
-{
- com_err(whoami, 0, "Unexpected return value from Moira -- programmer botch");
- mr_disconnect();
- exit(1);
-}
-
/*
* get_pobox gets all your poboxes and displays them.
*/
-int get_pobox(int argc, char **argv, char *callarg)
+int get_pobox(int argc, char **argv, void *callarg)
{
if (!strcmp(argv[1], "POP"))
printf("User %s, Type %s, Box: %s@%s\n",
char *potype(char *machine)
{
char *service[1], *argv[3];
- int check_match(), check_match3(), status;
+ int status;
match = 0;
service[0] = "POP";
return "SMTP";
}
-int check_match(int argc, char **argv, char *callback)
+int check_match(int argc, char **argv, void *callback)
{
if (match)
return 0;
return 0;
}
-int check_match3(int argc, char **argv, char *callback)
+int check_match3(int argc, char **argv, void *callback)
{
if (match)
return 0;
-/*
- * Copyright 1988 by the Massachusetts Institute of Technology. For copying
- * and distribution information, see the file "mit-copyright.h".
+/* $Id $
*
- * $Source$
- * $Header$
- * $Author$
- *
- */
-
-#ifndef lint
-static char *rcsid_chsh_c = "$Header$";
-#endif
-
-/*
* Talk to the Moira database to change a person's login shell. The chosen
* shell must exist. A warning will be issued if the shell is not in
* /etc/shells.
* If a commandline argument is given, it is taken to be the username
* of the user whose shell is to be changed.
*
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <unistd.h>
-#include <sys/types.h>
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
#include <stdio.h>
#include <string.h>
-#include <sys/file.h>
+#include <unistd.h>
+
#include <krb.h>
-#include <ctype.h>
-#include <errno.h>
-/* Moira includes */
-#include <moira.h>
-#include <moira_site.h>
-#include "mit-copyright.h"
+RCSID("$Header$");
+
+int usage(void);
+int leave(int status);
+int chsh(char *uname);
+int get_shell(int argc, char **argv, void *uname);
+void check_shell(char *shell);
+#if defined(NEED_GETUSERSHELL) || defined(SOLARIS)
+char *getusershell(void);
+#endif
char *whoami;
-char *getusershell();
int main(int argc, char *argv[])
{
exit(status);
}
-int scream(void)
-{
- com_err(whoami, 0, "Unexpected return value from Moira -- programmer botch");
- leave(1);
-}
-
int chsh(char *uname)
{
int status; /* general purpose exit status */
int got_one = 0; /* have we got a new shell yet? */
char shell[BUFSIZ]; /* the new shell */
- int get_shell();
- void check_shell(); /* make sure new shell is valid */
/* Try each query. If we ever fail, print error message and exit. */
q_argc = NAME + 1;
if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
- get_shell, (char *) uname)))
+ get_shell, uname)))
{
com_err(whoami, status, " while getting user information.");
leave(2);
q_argv[USH_NAME] = uname;
q_argv[USH_SHELL] = shell;
q_argc = USH_END;
- if ((status = mr_query("update_user_shell", q_argc, q_argv,
- scream, NULL)))
+ if ((status = mr_query("update_user_shell", q_argc, q_argv, NULL, NULL)))
{
com_err(whoami, status, " while changing shell.");
leave(2);
return 0;
}
-int get_shell(int argc, char **argv, char *uname)
+int get_shell(int argc, char **argv, void *uname)
{
/* We'll just take the first information we get since login names
cannot be duplicated in the database. */
printf("Account information last changed on %s\n", argv[U_MODTIME]);
printf("by user %s with %s.\n", argv[U_MODBY], argv[U_MODWITH]);
- printf("Current shell for %s is %s.\n", uname, argv[U_SHELL]);
+ printf("Current shell for %s is %s.\n", (char *)uname, argv[U_SHELL]);
return MR_ABORT; /* Don't pay attention to other matches. */
}
}
#ifdef NEED_GETUSERSHELL
-char *getusershell()
+char *getusershell(void)
{
static int count = 1;
-/* $Header$
+/* $Id $
*
* disabled: check to see if registration is enabled right now. Most of this
* code is stolen from the cron daemon.
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
+#include <moira.h>
+
#include <ctype.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#include "files.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "userreg.h"
#define LISTS (2 * BUFSIZ)
#define MAXLIN BUFSIZ
#define RANGE 103
#define EOS 104
-time_t itime, time();
+time_t itime;
struct tm *loct;
-struct tm *localtime();
-char *malloc();
-char *realloc();
int flag;
char *list;
char *listend;
unsigned listsize;
-char *cmp();
+char *cmp(char *p, int v);
+void init(void);
+void append(char *fn);
int number(char c, FILE *f);
/* This routine will determine if registration is enabled at this time. If
return cp;
}
-init(void)
+void init(void)
{
/*
* Don't free in case was longer than LISTS. Trades off
listend = list;
}
-append(char *fn)
+void append(char *fn)
{
int i, c;
char *cp;
char *ocp;
int n;
- FILE *f, *fopen();
+ FILE *f;
if (!(f = fopen(fn, "r")))
return;
-/*
- * $Source$
- * $Author$
- * $Locker$
- * $Header$
+/* $Id $
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Display function for userreg client
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_display_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <stdio.h>
+#include <moira.h>
+
#include <curses.h>
-#include <sys/time.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
#include "userreg.h"
+RCSID("$Header$");
+
+void make_border(int l);
+void query_user(char *prompt, char *buf, int maxsize, int timeout,
+ int echop, int emptyok, int valuep);
+
#define DESC_WIDTH 18
#define HEADER "*** Athena User Account Registration ***"
#define HELP " Press backspace to delete a character. Press Ctrl-C to start over."
#define MIN_COLS 80
#define MIN_LINES 24
-WINDOW * displayw, *queryw;
-WINDOW * dataw, *helpw;
-WINDOW * fnamew, *midw, *lnamew, *idw, *loginw;
+WINDOW *displayw, *queryw;
+WINDOW *dataw, *helpw;
+WINDOW *fnamew, *midw, *lnamew, *idw, *loginw;
extern char typed_mit_id[100];
/* Set up the windows and subwindows on the display */
-setup_display(void)
+void setup_display(void)
{
- FILE *freopen();
-
initscr(); /* Start up curses */
if (COLS < MIN_COLS || LINES < MIN_LINES)
}
/* Clear and restore the display */
-reset_display(void)
+void reset_display(void)
{
clear();
/* Make a one-line border on line l of stdscr */
-make_border(int l)
+void make_border(int l)
{
int i;
}
/* This replaces several "useful" display functions in the old userreg */
-redisp(void)
+void redisp(void)
{
mvwprintw(fnamew, 0, 0, "%-24s", user.u_first);
wrefresh(fnamew);
/* Input and input_no_echo exist only to save on retyping */
-input(char *prompt, char *buf, int maxsize, int timeout, int emptyok)
+void input(char *prompt, char *buf, int maxsize, int timeout, int emptyok)
{
query_user(prompt, buf, maxsize, timeout, TRUE, emptyok, TRUE);
}
-input_no_echo(char *prompt, char *buf, int maxsize, int timeout)
+void input_no_echo(char *prompt, char *buf, int maxsize, int timeout)
{
query_user(prompt, buf, maxsize, timeout, FALSE, FALSE, TRUE);
}
/* make the user press any key to continue */
-wait_for_user(void)
+void wait_for_user(void)
{
char buf[BUFSIZ];
/* Gets input through the query buffer */
/* Exit(1)'s on read errors */
/* Signals SIGALRM after 'timeout' seconds */
-query_user(char *prompt, char *buf, int maxsize, int timeout,
- int echop, int emptyok, int valuep)
+void query_user(char *prompt, char *buf, int maxsize, int timeout,
+ int echop, int emptyok, int valuep)
{
int c;
int i;
/* Display_text_line puts up a line of text in the display window */
/* Special case: if line is 0, clear the display area */
-display_text_line(char *line)
+void display_text_line(char *line)
{
if (line)
{
/* Display_text displays a canned message from a file. The string
* will get imbedded in any %s's in the text.
*/
-display_text(char *filename, char *string)
+void display_text(char *filename, char *string)
{
FILE * fp;
char buf[100], buf1[110];
}
/* Clear_display wipes the display and turns off curses */
-restore_display(void)
+void restore_display(void)
{
clear();
refresh();
endwin();
}
-timer_on(void)
+void timer_on(void)
{
struct itimerval it;
setitimer(ITIMER_REAL, &it, NULL);
}
-timer_off(void)
+void timer_off(void)
{
struct itimerval it;
}
-wfeep(void)
+void wfeep(void)
{
char buf = '\007';
write(1, &buf, 1);
-/*
- * $Source$
- * $Author$
- * $Locker$
- * $Header$
- */
+/* $Id $ */
#define WELCOME "/mit/register/welcome"
#define USERNAME_BLURB "/mit/register/username_blurb"
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_reg_stubs_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <moira.h>
+#include <moira_site.h>
+#include "ureg_proto.h"
+
#include <sys/types.h>
-#include <sys/time.h>
#include <sys/socket.h>
-#include <netinet/in.h>
+
#include <netdb.h>
-#include <des.h>
-#include <krb.h>
-#include <krb_err.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
#include <errno.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <hesiod.h>
-#include "ureg_err.h"
-#include "ureg_proto.h"
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
+#include <unistd.h>
+
+#include <des.h>
+#include <hesiod.h>
+#include <kadm_err.h>
+#include <krb.h>
+
+RCSID("$Header$");
+
+int do_operation(char *first, char *last, char *idnumber, char *hashidnumber,
+ char *data, u_long opcode);
+int do_secure_operation(char *login, char *idnumber, char *passwd,
+ char *newpasswd, u_long opcode);
+int do_call(char *buf, int len, int seq_no, char *login);
+
+char *krb_realmofhost(char *);
static int reg_sock = -1;
static int seq_no = 0;
static char *host;
-extern errno;
#define UNKNOWN_HOST -1
#define UNKNOWN_SERVICE -2
#endif
if (!host || (strlen(host) == 0))
{
- host = strsave(MOIRA_SERVER);
+ host = strdup(MOIRA_SERVER);
s = strchr(host, ':');
if (s)
*s = '\0';
}
hp = gethostbyname(host);
- host = strsave(hp->h_name);
+ host = strdup(hp->h_name);
if (hp == NULL)
return UNKNOWN_HOST;
int call = ntohl(opcode);
char inst[INST_SZ], hosti[INST_SZ];
char *bp = buf, *src, *dst, *realm;
- int len, status, i;
+ int len, status;
KTEXT_ST cred;
CREDENTIALS creds;
Key_schedule keys;
- char *krb_get_phost(), *krb_realmofhost();
memmove(bp, &version, sizeof(int));
bp += sizeof(int);
bp += strlen(bp) + 1;
/* don't overwrite existing ticket file */
- sprintf(tktstring, "/tmp/tkt_cpw_%d", getpid());
+ sprintf(tktstring, "/tmp/tkt_cpw_%ld", (long)getpid());
krb_set_tkt_string(tktstring);
/* get realm and canonizalized hostname of server */
* <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_userreg_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
+#include "userreg.h"
+
+#include <errno.h>
+#include <ctype.h>
#include <curses.h>
-#include <signal.h>
-#include <sys/time.h>
#include <setjmp.h>
-#include <ctype.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include <kadm.h>
#include <kadm_err.h>
#include <krb.h>
-#include <des.h>
-#include <errno.h>
-#include "userreg.h"
-#include "ureg_err.h"
-/* 7.2 release compatibility */
-#ifndef KADM_INSECURE_PW
-#define KADM_INSECURE_PW (-1783126240L)
-#endif
+RCSID("$Header$");
+
+void fix_display(int sig);
+void reset(void);
+int dolook(void);
+int negotiate_login(void);
+int negotiate_passwd(void);
+void gfirst(void);
+void glast(void);
+void gpass(void);
+void glogin(void);
+void gmitid(void);
+void gmi(void);
+int qexit(void);
+int do_replace(void);
+int kinit(char *user, char *passwd);
+int lenient_strcmp(char *string1, char *string2);
+int strpasscmp(char *s1, char *s2);
+void restart(void);
+void canon_name(char *cp);
#define EXIT -1
-
struct user user, db_user;
struct alias alias;
char realm[REALM_SZ];
jmp_buf redo;
-int restart();
-extern int errno;
int user_is_valid = 0;
int user_has_login = 0;
int already_registered = 0;
int enrollment = 0;
-extern char *disabled();
char typed_mit_id[100];
-fix_display(sig)
+void fix_display(int sig)
{
struct sigaction act;
exit(1);
}
- if (when = disabled(&msg))
+ if ((when = disabled(&msg)))
{
printf("We're sorry, the registration service is unavailable right now\n");
if (msg)
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGINT, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
sigaction(SIGHUP, &act, NULL);
exit(0);
}
-reset(void)
+void reset(void)
{
reset_display();
memset(&user, 0, sizeof(user));
strcpy(lpassword, "moira");
}
- sprintf(tktstring, "/tmp/tkt_cpw_%d", getpid());
+ sprintf(tktstring, "/tmp/tkt_cpw_%ld", (long)getpid());
krb_set_tkt_string(tktstring);
des_string_to_key(passwd, key);
inst[0] = 0;
}
else if (result != KSUCCESS)
{
- display_text(NETWORK_DOWN);
+ display_text(NETWORK_DOWN, "");
display_text_line(" ");
sprintf(fullname, "%s while verifying password",
error_message(result));
return 0;
}
-gfirst(void)
+void gfirst(void)
{
/* input the first name */
char buf[FIRST_NAME_SIZE + 2];
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGALRM, &act, NULL);
input("Enter first Name:", buf, FIRST_NAME_SIZE + 1,
FIRSTNAME_TIMEOUT, TRUE);
redisp();
}
-glast(void)
+void glast(void)
{
/* input the last name */
char buf[LAST_NAME_SIZE + 2];
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGALRM, &act, NULL);
input("Enter family Name:", buf, LAST_NAME_SIZE + 1,
LASTNAME_TIMEOUT, FALSE);
redisp();
}
-gpass(void)
+void gpass(void)
{
/* input password */
char new_password[PASSWORD_SIZE + 1];
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGALRM, &act, NULL);
input_no_echo("Enter password:", new_password,
PASSWORD_SIZE, NEW_PASSWORD_TIMEOUT);
/* get login name */
-glogin(void)
+void glogin(void)
{
char buf[LOGIN_SIZE + 2];
struct sigaction act;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGALRM, &act, NULL);
user.u_login[0] = '\0';
input("Enter username:", buf, LOGIN_SIZE, USERNAME_TIMEOUT, FALSE);
redisp();
}
-gmitid(void)
+void gmitid(void)
{
/* get mid id */
int i;
input_mit_id:
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGALRM, &act, NULL);
input("Enter MIT Id:", buf, 14, MITID_TIMEOUT, FALSE);
i = 0;
EncryptID(user.u_mit_id, typed_mit_id, user.u_first, user.u_last);
}
-gmi(void)
+void gmi(void)
{
/* get middle initial */
char buf[MID_INIT_SIZE + 2];
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = (void (*)()) fix_display;
+ act.sa_handler = fix_display;
sigaction(SIGALRM, &act, NULL);
input("Enter Middle Initial:", buf, MID_INIT_SIZE + 1, MI_TIMEOUT, TRUE);
strncpy(user.u_mid_init, buf, MID_INIT_SIZE);
timer_on();
if (status)
{
- display_text(NETWORK_DOWN);
+ display_text(NETWORK_DOWN, "");
display_text_line(" ");
sprintf(buf, "The specific error was: %s", error_message(status));
display_text_line(buf);
*/
/* Go to asking for first name. */
-restart(void)
+void restart(void)
{
qexit();
longjmp(redo, 1);
}
-canon_name(char *cp)
+void canon_name(char *cp)
{
char *p2 = cp;
*/
#include <stdio.h>
-#include <ctype.h>
+#include "ureg_proto.h"
#include "files.h"
/*
#define NO 0
#define YES 1
-/* Externs from display.c */
-extern setup_display ();
-extern reset_display ();
-extern restore_display ();
-extern redisp ();
-extern input ();
-extern input_no_echo ();
-extern display_text_line ();
-extern display_text ();
-
/* Global variables */
extern struct user user,
db_user;
+
+/* prototypes from disable.c */
+char *disabled(char **msg);
+
+/* prototypes from display.c */
+void setup_display(void);
+void reset_display(void);
+void redisp(void);
+void input(char *prompt, char *buf, int maxsize, int timeout, int emptyok);
+void input_no_echo(char *prompt, char *buf, int maxsize, int timeout);
+void wait_for_user(void);
+int askyn(char *prompt);
+void display_text_line(char *line);
+void display_text(char *filename, char *string);
+void restore_display(void);
+void timer_on(void);
+void timer_off(void);
+void wfeep(void);
# Imakefile for server directory.
#
-SRCS = dbck.h dbck.c fix.c phase1.c phase2.c phase3.c phase4.c nhash.c
-OBJS = dbck.o fix.o phase1.o phase2.o phase3.o phase4.o nhash.o
-CODE = dbck.h dbck.pc fix.pc phase1.pc phase2.pc phase3.pc phase4.pc nhash.c
+SRCS = dbck.h dbck.c fix.c phase1.c phase2.c phase3.c phase4.c
+OBJS = dbck.o fix.o phase1.o phase2.o phase3.o phase4.o
+CODE = dbck.h dbck.pc fix.pc phase1.pc phase2.pc phase3.pc phase4.pc
SRCDIR=$(SRCTOP)/dbck
sqlrule()
-program(dbck, ${OBJS},,../lib/libmoira.a ../server/libmrglue.a $(SQL_LIB), ${PROGDIR})
+program(dbck, ${OBJS},,../lib/libmoira.a $(SQL_LIB), ${PROGDIR})
sqlfile(dbck)
sqlfile(fix)
sqlfile(phase1)
* <mit-copyright.h>.
*/
-#include <moira_site.h>
#include <mit-copyright.h>
+#include <moira_site.h>
#define MODE_ASK 1
#define MODE_NO 2
int allocated;
int count;
};
+
+void dbmserr(void);
+void out_of_mem(char *msg);
+void cleanup(void);
+
+void modified(char *table);
+
+void phase1(void);
+void phase2(void);
+void phase3(void);
+void phase4(void);
+void count_only_setup(void);
+
+/* prototypes from fix.pc */
+void generic_delete(struct save_queue *sq, int (*pfunc)(void *), char *table,
+ char *idfield, int preen);
+void single_delete(char *table, char *idfield, int id);
+void zero_fix(char *tbl, char *zrfield, char *idfield, int id);
+int single_fix(char *msg, int preen);
+void generic_fix(struct save_queue *sq, int (*pfunc)(void *), char *msg,
+ void (*ffunc)(void *), int preen);
+int prompt(char *msg);
+int set_next_object_id(char *object, char *tablename);
+int generic_fix_id(char *tbl, char *idfield, char *txtfield,
+ int oldid, char *name);
+
+/* prototypes from phase3.pc */
+struct string *string_check(int id);
-/* $Header$
+/* $Id$
*
* Moira database consistency checker
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
+#include <moira.h>
#include "dbck.h"
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
-static char dbck_qc_rcsid[] = "$Header$";
-
+RCSID("$Header$");
int debug = 0;
int mode = MODE_ASK;
EXEC SQL BEGIN DECLARE SECTION;
int dcmenable;
EXEC SQL END DECLARE SECTION;
-struct save_queue *modtables, *sq_create();
-void interrupt();
+struct save_queue *modtables;
SQLDA *mr_sqlda;
+void interrupt(void);
extern SQLDA *sqlald(int, int, int);
+extern void sqlglm(char *, unsigned int *, unsigned int *);
int main(int argc, char **argv)
{
EXEC SQL BEGIN DECLARE SECTION;
char *database;
EXEC SQL END DECLARE SECTION;
- int ingerr();
int countonly = 0;
+ struct sigaction sa;
database = "moira";
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
if (debug)
printf("Debug level is %d\n", debug);
- signal(SIGHUP, interrupt);
- signal(SIGQUIT, interrupt);
- signal(SIGINT, interrupt);
+ sa.sa_handler = interrupt;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGQUIT, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
modtables = sq_create();
mr_sqlda = sqlald(1, 255, 0);
exit(0);
}
-int dbmserr(void)
+void dbmserr(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char buf[512];
if (sqlca.sqlcode == 1403)
return;
- printf("A DBMS error occurred, code %d\n", sqlca.sqlcode);
+ printf("A DBMS error occurred, code %ld\n", sqlca.sqlcode);
sqlglm(buf, &bufsize, &msglength);
buf[msglength] = '\0';
printf("%s\n", buf);
}
-int modified(char *table)
+void modified(char *table)
{
sq_save_unique_string(modtables, table);
}
-int cleanup(void)
+void cleanup(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char *tab;
}
-int out_of_mem(char *msg)
+void out_of_mem(char *msg)
{
fprintf(stderr, "Out of memory while %s\n", msg);
if (prompt("Save database changes"))
-/* $Header$
+/* $Id$
*
* User interface routines for dbck (Moira database consistency checker)
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
#include <moira.h>
-#include <stdio.h>
#include "dbck.h"
+#include <stdio.h>
+
EXEC SQL INCLUDE sqlca; /* SQL Communications Area */
EXEC SQL INCLUDE sqlda; /* SQL Descriptor Area */
-static char fix_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
EXEC SQL BEGIN DECLARE SECTION;
char *_table;
EXEC SQL END DECLARE SECTION;
extern SQLDA *mr_sqlda;
+void generic_ffunc(void *id);
-int generic_ffunc(int id)
+void generic_ffunc(void *id)
{
int rowcount;
sprintf(stmt_buf, "DELETE FROM %s WHERE %s.%s = %d",
- _table, _table, _idfield, id);
+ _table, _table, _idfield, (int)id);
EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
rowcount = sqlca.sqlerrd[2];
if (rowcount > 0)
}
-int generic_delete(struct save_queue *sq, void (*pfunc)(), char *table,
- char *idfield, int preen)
+void generic_delete(struct save_queue *sq, int (*pfunc)(void *), char *table,
+ char *idfield, int preen)
{
_table = table;
_idfield = idfield;
}
-int single_delete(char *table, char *idfield, int id)
+void single_delete(char *table, char *idfield, int id)
{
_table = table;
_idfield = idfield;
- generic_ffunc(id);
+ generic_ffunc((void *)id);
}
-int zero_fix(char *tbl, char *zrfield, char *idfield, int id)
+void zero_fix(char *tbl, char *zrfield, char *idfield, int id)
{
int rowcount;
}
-int generic_fix(struct save_queue *sq, int (*pfunc)(), char *msg,
- int (*ffunc)(), int preen)
+void generic_fix(struct save_queue *sq, int (*pfunc)(void *), char *msg,
+ void (*ffunc)(void *), int preen)
{
int id;
while (sq_get_data(sq, &id))
{
- if ((*pfunc)(id) == 0 && single_fix(msg, preen))
- (*ffunc)(id);
+ if ((*pfunc)((void *)id) == 0 && single_fix(msg, preen))
+ (*ffunc)((void *)id);
}
sq_destroy(sq);
}
+++ /dev/null
-/* $Header$
- *
- * Generic hash table routines. Uses integer keys to store integer values.
- *
- * (c) Copyright 1996 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <ctype.h>
-#include <stdlib.h>
-/* #include <moira.h> */
-
-struct int_bucket {
- struct int_bucket *next;
- int key;
- int data;
-};
-struct int_hash {
- int size;
- struct int_bucket **data;
-};
-
-#define int_hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
-
-/* Create an int_hash table. The size is just a hint, not a maximum. */
-
-struct int_hash *create_int_hash(int size)
-{
- struct int_hash *h;
-
- h = malloc(sizeof(struct int_hash));
- if (!h)
- return NULL;
- h->size = size;
- h->data = malloc(size * sizeof(struct int_bucket *));
- if (!h->data)
- {
- free(h);
- return NULL;
- }
- memset(h->data, 0, size * sizeof(char *));
- return h;
-}
-
-/* Look up an object in the int_hash table. Returns the value associated with
- * the key, or NULL (thus NULL is not a very good value to store...)
- */
-
-int int_hash_lookup(struct int_hash *h, int key)
-{
- struct int_bucket *b;
-
- b = h->data[int_hash_func(h, key)];
- while (b && b->key != key)
- b = b->next;
- if (b && b->key == key)
- return b->data;
- else
- return 0;
-}
-
-
-/* Update an existing object in the int_hash table. Returns 1 if the object
- * existed, or 0 if not.
- */
-
-int int_hash_update(struct int_hash *h, int key, int value)
-{
- struct int_bucket *b;
-
- b = h->data[int_hash_func(h, key)];
- while (b && b->key != key)
- b = b->next;
- if (b && b->key == key)
- {
- b->data = value;
- return 1;
- }
- else
- return 0;
-}
-
-
-/* Store an item in the int_hash table. Returns 0 if the key was not
- * previously there, 1 if it was, or -1 if we ran out of memory.
- */
-
-int int_hash_store(struct int_hash *h, int key, int value)
-{
- struct int_bucket *b, **p;
-
- p = &(h->data[int_hash_func(h, key)]);
- if (!*p)
- {
- b = *p = malloc(sizeof(struct int_bucket));
- if (!b)
- return -1;
- b->next = NULL;
- b->key = key;
- b->data = value;
- return 0;
- }
-
- for (b = *p; b && b->key != key; b = *p)
- p = (struct int_bucket **) *p;
- if (b && b->key == key)
- {
- b->data = value;
- return 1;
- }
- b = *p = malloc(sizeof(struct int_bucket));
- if (!b)
- return -1;
- b->next = NULL;
- b->key = key;
- b->data = value;
- return 0;
-}
-
-
-/* Search through the int_hash table for a given value. For each piece of
- * data with that value, call the callback proc with the corresponding key.
- */
-
-int int_hash_search(struct int_hash *h, int value, void (*callback)())
-{
- struct int_bucket *b, **p;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--)
- {
- for (b = *p; b; b = b->next)
- {
- if (b->data == value)
- (*callback)(b->key);
- }
- }
-}
-
-
-/* Step through the int_hash table, calling the callback proc with each key.
- */
-
-int int_hash_step(struct int_hash *h, void (*callback)(), char *hint)
-{
- struct int_bucket *b, **p;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--)
- {
- for (b = *p; b; b = b->next)
- (*callback)(b->key, b->data, hint);
- }
-}
-
-
-/* Deallocate all of the memory associated with a table */
-
-int int_hash_destroy(struct int_hash *h)
-{
- struct int_bucket *b, **p, *b1;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--)
- {
- for (b = *p; b; b = b1)
- {
- b1 = b->next;
- free(b);
- }
- }
-}
-/* $Header$
+/* $Id$
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
#include <moira.h>
+#include "dbck.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include "dbck.h"
+#include <string.h>
EXEC SQL INCLUDE sqlca;
-static char phase1_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
EXEC SQL WHENEVER SQLERROR DO dbmserr();
-
-int show_user_id(struct user *u)
+int show_user_id(void *user);
+void handle_duplicate_logins(struct save_queue *sq);
+void fix_user_id(void *user);
+void cant_fix(void *id);
+int show_mach_id(void *machine);
+int show_mach_name(void *machine);
+void fix_mach_id(void *machine);
+int show_snet_name(void *subnet);
+int show_clu_id(void *cluster);
+int show_clu_name(void *cluster);
+void fix_clu_id(void *cluster);
+int show_list_id(void *list);
+int show_list_name(void *list);
+void fix_list_id(void *list);
+int show_fs_id(void *filesys);
+void fix_fs_id(void *filesys);
+int show_fs_name(void *fs);
+int show_np_id(void *nfsphys);
+void fix_np_id(void *nfsphys);
+int show_str_id(void *string);
+int print_str_id(void *id);
+void print_dup_map(int key, void *data, void *hint);
+
+int show_user_id(void *user)
{
+ struct user *u = user;
printf("User %s (%s, status %d) has duplicate ID\n",
u->login, u->fullname, u->status);
return 0;
}
-handle_duplicate_logins(struct save_queue *sq)
+void handle_duplicate_logins(struct save_queue *sq)
{
struct user *u, *uu, *tmp;
printf("User %s (%s, status %d) have duplicate logins\n",
uu->login, uu->fullname, uu->status);
if (!strcmp(u->fullname, uu->fullname) &&
- single_fix("Delete the second one"))
+ single_fix("Delete the second one", 0))
single_delete("users", "users_id", uu->users_id);
- else if (single_fix("Unregister the second one"))
+ else if (single_fix("Unregister the second one", 0))
{
EXEC SQL BEGIN DECLARE SECTION;
int id = uu->users_id, rowcount;
}
}
-fix_user_id(struct user *u)
+void fix_user_id(void *user)
{
+ struct user *u = user;
u->users_id = generic_fix_id("users", "users_id", "login",
u->users_id, u->login);
}
-cant_fix(int id)
+void cant_fix(void *id)
{
printf("Sorry, don't know how to fix that\n");
}
-int show_mach_id(struct machine *m)
+int show_mach_id(void *machine)
{
+ struct machine *m = machine;
printf("Machine %s has duplicate ID %d\n", m->name, m->mach_id);
return 0;
}
-int show_mach_name(struct machine *m)
+int show_mach_name(void *machine)
{
+ struct machine *m = machine;
printf("Machine %s (%d) has duplicate name\n", m->name, m->mach_id);
return 0;
}
-fix_mach_id(struct machine *m)
+void fix_mach_id(void *machine)
{
+ struct machine *m = machine;
m->mach_id = generic_fix_id("machine", "mach_id", "name",
m->mach_id, m->name);
}
-int show_snet_name(struct subnet *s)
+int show_snet_name(void *subnet)
{
+ struct subnet *s = subnet;
printf("Subnet %s (%d) has duplicate name\n", s->name, s->snet_id);
return 0;
}
-int show_clu_id(struct cluster *c)
+int show_clu_id(void *cluster)
{
+ struct cluster *c = cluster;
printf("Cluster %s has duplicate ID %d\n", c->name, c->clu_id);
return 0;
}
-int show_clu_name(struct cluster *c)
+int show_clu_name(void *cluster)
{
+ struct cluster *c = cluster;
printf("Cluster %s (%d) has duplicate name\n", c->name, c->clu_id);
return 0;
}
-fix_clu_id(struct cluster *c)
+void fix_clu_id(void *cluster)
{
+ struct cluster *c = cluster;
c->clu_id = generic_fix_id("cluster", "clu_id", "name", c->clu_id, c->name);
}
-int show_list_id(struct list *l)
+int show_list_id(void *list)
{
+ struct list *l = list;
printf("List %s has duplicate ID %d\n", l->name, l->list_id);
return 0;
}
-int show_list_name(struct list *l)
+int show_list_name(void *list)
{
+ struct list *l = list;
printf("List %s (%d) has duplicate name\n", l->name, l->list_id);
return 0;
}
-fix_list_id(struct list *l)
+void fix_list_id(void *list)
{
+ struct list *l = list;
l->list_id = generic_fix_id("list", "list_id", "name", l->list_id, l->name);
}
-int show_fs_id(struct filesys *f)
+int show_fs_id(void *filesys)
{
+ struct filesys *f = filesys;
printf("Filesys %s has duplicate ID %d\n", f->name, f->filsys_id);
return 0;
}
-fix_fs_id(struct filesys *f)
+void fix_fs_id(void *filesys)
{
+ struct filesys *f = filesys;
f->filsys_id = generic_fix_id("filesys", "filsys_id", "label",
f->filsys_id, f->name);
}
-int show_fs_name(struct filesys *fs)
+int show_fs_name(void *filesys)
{
+ struct filesys *fs = filesys;
printf("Filesys %s (%d) has duplicate name\n", fs->name, fs->filsys_id);
return 0;
}
-int show_np_id(struct nfsphys *n)
+int show_np_id(void *nfsphys)
{
+ struct nfsphys *n = nfsphys;
printf("NfsPhys %s:%s has duplicate ID %d\n",
((struct machine *)hash_lookup(machines, n->mach_id))->name,
n->dir, n->nfsphys_id);
return 0;
}
-fix_np_id(struct nfsphys *n)
+void fix_np_id(void *nfsphys)
{
+ struct nfsphys *n = nfsphys;
n->nfsphys_id = generic_fix_id("nfsphys", "nfsphys_id", "dir",
n->nfsphys_id, n->dir);
}
-int show_str_id(struct string *s)
+int show_str_id(void *string)
{
+ struct string *s = string;
printf("String %s has duplicate ID %d\n", s->name, s->string_id);
return 0;
}
-int print_str_id(int id)
+int print_str_id(void *id)
{
- printf("String %d is a duplicate\n", id);
+ printf("String %d is a duplicate\n", (int)id);
return 0;
}
-print_dup_map(int key, int data, char *hint)
+void print_dup_map(int key, void *data, void *hint)
{
- printf("String %d is a duplicate of string %d\n", key, data);
+ printf("String %d is a duplicate of string %d\n", key, (int)data);
}
-phase1(void)
+void phase1(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char name[81], name1[81], last[17], first[17], buf[257];
break;
q++;
/* If id2 is already stored, skip this row. */
- i = int_hash_lookup(string_dups, id2);
+ i = (int)hash_lookup(string_dups, id2);
if (i > 0)
continue;
/* Follow the chain of id1 equivalent IDs back to the lowest one. */
id = id1;
- while ((tmp = int_hash_lookup(string_dups, id)) > 0)
+ while ((tmp = (int)hash_lookup(string_dups, id)) > 0)
id = tmp;
- int_hash_store(string_dups, id2, id);
+ hash_store(string_dups, id2, (void *)id);
}
EXEC SQL CLOSE csr116;
dprintf("found %d duplicates\n", q);
- int_hash_step(string_dups, print_dup_map, NULL);
+ hash_step(string_dups, print_dup_map, NULL);
/* We don't want to delete the duplicates now because if the dbck
is cancelled, a LOT of state will be lost. So, we'll just let
them not get marked as used and then phase3 will clean them up */
s = malloc(sizeof(struct string));
if (!s)
out_of_mem("storing strings");
- s->name = strsave(strtrim(buf));
+ s->name = strdup(strtrim(buf));
s->string_id = id;
s->refc = 0;
retval = hash_store(strings, id, s);
strcpy(u->login, strtrim(name));
u->potype = buf[0];
sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
- u->fullname = strsave(buf);
+ u->fullname = strdup(buf);
u->status = status;
u->users_id = id;
u->modby = sid;
-/* $Header$
+/* $Id$
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <moira.h>
#include "dbck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca;
-static char phase2_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
EXEC SQL WHENEVER SQLERROR DO dbmserr();
-int show_mcm_mach(int id)
+int show_mcm_mach(void *id);
+int show_mcm_clu(void *id);
+int show_hostalias(void *id);
+int show_pcap_mach(void *id);
+int show_pcap_quota(void *id);
+void user_check(int id, void *user, void *hint);
+int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
+ char *field, char *idfield);
+int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
+ char *field, char *idfield);
+int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid);
+int maybe_fixup_modby2(char *table, char *field, char *cursor, int id);
+void pobox_check(int id, struct user *u);
+void remove_pobox(int id);
+void fix_smtp_pobox(int id, int sid);
+void mach_check(int id, void *machine, void *hint);
+void subnet_check(int id, void *subnet, void *hint);
+void clear_subnet_owner(struct subnet *s);
+void clear_mach_owner(struct machine *m);
+void cluster_check(int id, void *cluster, void *hint);
+int show_svc(void *id);
+void list_check(int id, void *list, void *hint);
+void fix_list_acl(int id);
+int show_member_list(void *id);
+int show_mem_user(void *id);
+int show_mem_list(void *id);
+int show_mem_str(void *id);
+int show_mem_krb(void *id);
+void del_mem_user(void *id);
+void del_mem_list(void *id);
+void del_mem_str(void *id);
+void del_mem_krb(void *id);
+int show_sh(void *id);
+void del_sh_mach(void *id);
+void fsmatch(int id, void *nfsphys, void *filesys);
+void check_fs(int id, void *filesys, void *hint);
+void check_nfsphys(int id, void *nfsphys, void *hint);
+int show_fsg_missing(void *id);
+int show_fsg_type(void *filesys);
+void fix_fsg_type(void *filesys);
+int show_fsg_nomember(void *id);
+int show_quota_nouser(void *id);
+int show_quota_nolist(void *id);
+void fix_quota_nouser(void *id);
+void fix_quota_nolist(void *id);
+int show_quota_nofs(void *id);
+void fix_quota_nofs(void *id);
+int show_quota_wrongpid(void *id);
+void fix_quota_physid(void *id);
+int show_srv_user(void *id);
+int show_srv_list(void *id);
+void zero_srv_user(void *id);
+void zero_srv_list(void *id);
+int show_krb_usr(void *id);
+int show_krb_str(void *id);
+int show_pdm_mach(void *id);
+
+int show_mcm_mach(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1;
+ int iid = (int)id, found = 1;
char name[33];
EXEC SQL END DECLARE SECTION;
strtrim(name);
found = 0;
- printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
+ printf("Cluster %s, non-existant machine %d in cluster map\n",
+ name, iid);
}
EXEC SQL CLOSE csr201;
return found;
}
-int show_mcm_clu(int id)
+int show_mcm_clu(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1;
+ int iid = (int)id, found = 1;
char name[33];
EXEC SQL END DECLARE SECTION;
strtrim(name);
found = 0;
- printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
+ printf("Machine %s, non-existant cluster %d in cluster map\n",
+ name, iid);
}
EXEC SQL CLOSE csr202;
return found;
}
-int show_hostalias(int id)
+int show_hostalias(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1;
+ int iid = (int)id, found = 1;
char name[33];
EXEC SQL END DECLARE SECTION;
strtrim(name);
found = 0;
- printf("Alias %s, non-existant machine %d in hostalias map\n", name, id);
+ printf("Alias %s, non-existant machine %d in hostalias map\n",
+ name, iid);
}
EXEC SQL CLOSE csr234;
return found;
}
-int show_pcap_mach(int id)
+int show_pcap_mach(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1;
+ int iid = (int)id, found = 1;
char name[33];
EXEC SQL END DECLARE SECTION;
found = 0;
printf("Printer %s, non-existant spool machine %d in printcap table\n",
- name, id);
+ name, iid);
}
EXEC SQL CLOSE csr235;
return found;
}
-int show_pcap_quota(int id)
+int show_pcap_quota(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1;
+ int iid = (int)id, found = 1;
char name[33];
EXEC SQL END DECLARE SECTION;
found = 0;
printf("Printer %s, non-existant quota server %d in printcap table\n",
- name, id);
+ name, iid);
}
EXEC SQL CLOSE csr236;
return found;
}
-user_check(int id, struct user *u, int hint)
+void user_check(int id, void *user, void *hint)
{
+ struct user *u = user;
+
u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
"comments", "users_id");
u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
"sigwho", "users_id");
- pobox_check(id, u, hint);
+ pobox_check(id, u);
}
int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
char stmt_buf[500];
EXEC SQL END DECLARE SECTION;
- if (newid = int_hash_lookup(string_dups, ret))
+ if ((newid = (int)hash_lookup(string_dups, ret)))
{
printf("%s entry %s(%d) has a %s with duplicate string %d\n",
table, oname, oid, field, ret);
char stmt_buf[500];
EXEC SQL END DECLARE SECTION;
- if ((newid = int_hash_lookup(string_dups, ret)))
+ if ((newid = (int)hash_lookup(string_dups, ret)))
{
printf("%s entry has a %s with duplicate string %d\n",
table, field, ret);
return 1;
}
-pobox_check(int id, struct user *u, int hint)
+void pobox_check(int id, struct user *u)
{
switch (u->potype)
{
}
break;
case 'S':
- if (int_hash_lookup(string_dups, u->pobox_id))
+ if (hash_lookup(string_dups, u->pobox_id))
{
printf("User %s(%s) has P.O.Box with duplicate string %d\n",
u->login, u->fullname, u->pobox_id);
{
printf("Replacing box_id dup string ID %d with %d\n",
u->pobox_id,
- int_hash_lookup(string_dups, u->pobox_id));
- u->pobox_id = int_hash_lookup(string_dups, u->pobox_id);
+ (int)hash_lookup(string_dups, u->pobox_id));
+ u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
fix_smtp_pobox(u->users_id, u->pobox_id);
string_check(u->pobox_id);
}
}
-remove_pobox(int id)
+void remove_pobox(int id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int rowcount, iid = id;
+ int rowcount, iid = (int)id;
EXEC SQL END DECLARE SECTION;
EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
modified("users");
}
-fix_smtp_pobox(int id, int sid)
+void fix_smtp_pobox(int id, int sid)
{
EXEC SQL BEGIN DECLARE SECTION;
int rowcount, iid = id, isid = sid;
modified("users");
}
-mach_check(int id, struct machine *m, int hint)
+void mach_check(int id, void *machine, void *hint)
{
+ struct machine *m = machine;
+
if (!hash_lookup(subnets, m->snet_id))
{
printf("Machine %s is on a non-existant subnet %d\n",
"modby", "mach_id");
}
-subnet_check(int id, struct subnet *s, int hint)
+void subnet_check(int id, void *subnet, void *hint)
{
+ struct subnet *s = subnet;
+
switch (s->owner_type)
{
case 'U':
"modby", "snet_id");
}
-clear_subnet_owner(struct subnet *s)
+void clear_subnet_owner(struct subnet *s)
{
EXEC SQL BEGIN DECLARE SECTION;
int rowcount, id = s->snet_id;
modified("subnet");
}
-clear_mach_owner(struct machine *m)
+void clear_mach_owner(struct machine *m)
{
EXEC SQL BEGIN DECLARE SECTION;
int rowcount, id = m->mach_id;
modified("machine");
}
-cluster_check(int id, struct cluster *c, int hint)
+void cluster_check(int id, void *cluster, void *hint)
{
+ struct cluster *c = cluster;
+
c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
"modby", "clu_id");
}
-int show_svc(int id)
+int show_svc(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1;
+ int iid = (int)id, found = 1;
char label[17], data[33];
EXEC SQL END DECLARE SECTION;
strtrim(data);
found = 0;
printf("Cluster data [%s] %s for non-existant cluster %d\n",
- label, data, id);
+ label, data, iid);
}
EXEC SQL CLOSE csr203;
return found;
}
-list_check(int id, struct list *l, int hint)
+void list_check(int id, void *list, void *hint)
{
+ struct list *l = list;
+
switch (l->acl_type)
{
case 'L':
}
}
-fix_list_acl(int id)
+void fix_list_acl(int id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int rowcount, iid = id;
+ int rowcount, iid = (int)id;
EXEC SQL END DECLARE SECTION;
EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
modified("list");
}
-int show_member_list(int id)
+int show_member_list(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int mid, iid = id, found = 1;
+ int mid, iid = (int)id, found = 1;
char mtype[9], *name = "";
EXEC SQL END DECLARE SECTION;
return found;
}
-int show_mem_user(int id)
+int show_mem_user(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int lid, iid = id, found = 1;
- char name[33];
+ int lid, iid = (int)id, found = 1;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE csr205 CURSOR FOR
return found;
}
-int show_mem_list(int id)
+int show_mem_list(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int lid, iid = id, found = 1;
- char name[33];
+ int lid, iid = (int)id, found = 1;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE csr206 CURSOR FOR
return found;
}
-int show_mem_str(int id)
+int show_mem_str(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int lid, iid = id, found = 1;
- char name[33];
+ int lid, iid = (int)id, found = 1;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE csr207 CURSOR FOR
}
-int show_mem_krb(int id)
+int show_mem_krb(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int lid, iid = id, found = 1;
- char name[33];
+ int lid, iid = (int)id, found = 1;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE csr208 CURSOR FOR
}
-del_mem_user(int id)
+void del_mem_user(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
modified("imembers");
}
-del_mem_list(int id)
+void del_mem_list(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
modified("imembers");
}
-del_mem_str(int id)
+void del_mem_str(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
}
-del_mem_krb(int id)
+void del_mem_krb(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
}
-int show_sh(int id)
+int show_sh(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
char name[33];
- int iid = id;
+ int iid = (int)id;
EXEC SQL END DECLARE SECTION;
int found = 1;
found = 0;
printf("ServerHost entry for service %s non-existant host %d\n",
- name, id);
+ name, iid);
}
EXEC SQL CLOSE csr209;
return found;
}
-del_sh_mach(int id)
+void del_sh_mach(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
static int fnchecklen;
-fsmatch(int id, struct nfsphys *n, struct filesys *f)
+void fsmatch(int id, void *nfsphys, void *filesys)
{
+ struct nfsphys *n = nfsphys;
+ struct filesys *f = filesys;
+
if (n->mach_id == f->mach_id &&
!strncmp(f->dir, n->dir, strlen(n->dir)) &&
strlen(n->dir) > fnchecklen)
}
-check_fs(int id, struct filesys *f, int hint)
+void check_fs(int id, void *filesys, void *hint)
{
EXEC SQL BEGIN DECLARE SECTION;
int iid = id, id1, id2, id3, rowcount;
char *dir;
EXEC SQL END DECLARE SECTION;
+ struct filesys *f = filesys;
struct nfsphys *n;
struct machine *m;
{
if (!hash_lookup(nfsphys, f->phys_id))
{
- m = (struct machine *)hash_lookup(machines, f->mach_id);
+ m = hash_lookup(machines, f->mach_id);
printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
if (single_fix("Fix", 1))
{
}
}
-check_nfsphys(int id, struct nfsphys *n, int hint)
+void check_nfsphys(int id, void *nfsphys, void *hint)
{
+ struct nfsphys *n = nfsphys;
+
if (!hash_lookup(machines, n->mach_id))
{
printf("NFSphys %d(%s) on non-existant machine %d\n",
}
}
-int show_fsg_missing(int id)
+int show_fsg_missing(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, id1, found = 1;
+ int iid = (int)id, id1, found = 1;
EXEC SQL END DECLARE SECTION;
struct filesys *f;
break;
found = 0;
- if (f = (struct filesys *) hash_lookup(filesys, id1))
- printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
+ if ((f = hash_lookup(filesys, id1)))
+ printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
else
- printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
+ printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
}
EXEC SQL CLOSE csr210;
return found;
}
-int show_fsg_type(struct filesys *f)
+int show_fsg_type(void *filesys)
{
+ struct filesys *f = filesys;
char *t;
switch (f->type)
return 0;
}
-fix_fsg_type(struct filesys *f)
+void fix_fsg_type(void *filesys)
{
+ struct filesys *f = filesys;
EXEC SQL BEGIN DECLARE SECTION;
int rowcount, id = f->filsys_id;
EXEC SQL END DECLARE SECTION;
modified("filesys");
}
-int show_fsg_nomember(int id)
+int show_fsg_nomember(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, id1, found = 1;
+ int iid = (int)id, id1, found = 1;
EXEC SQL END DECLARE SECTION;
struct filesys *f;
break;
found = 0;
- if (f = (struct filesys *) hash_lookup(filesys, id1))
- printf("FSGroup %s has missing member %d\n", f->name, id);
+ if ((f = hash_lookup(filesys, id1)))
+ printf("FSGroup %s has missing member %d\n", f->name, iid);
else
- printf("FSGroup %d has missing member %d\n", id1, id);
+ printf("FSGroup %d has missing member %d\n", id1, iid);
}
EXEC SQL CLOSE csr211;
return found;
}
-int show_quota_nouser(int id)
+int show_quota_nouser(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, id1, found = 1;
+ int iid = (int)id, id1, found = 1;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE csr212 CURSOR FOR
break;
found = 0;
- printf("Quota on fs %d for non-existant user %d\n", id1, id);
+ printf("Quota on fs %d for non-existant user %d\n", id1, iid);
}
EXEC SQL CLOSE csr212;
return found;
}
-int show_quota_nolist(int id)
+int show_quota_nolist(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, id1, found = 1;
+ int iid = (int)id, id1, found = 1;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE csr213 CURSOR FOR
break;
found = 0;
- printf("Quota on fs %d for non-existant list %d\n", id1, id);
+ printf("Quota on fs %d for non-existant list %d\n", id1, iid);
}
EXEC SQL CLOSE csr213;
return found;
}
-fix_quota_nouser(int id)
+void fix_quota_nouser(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount, id1;
+ int iid = (int)id, rowcount, id1;
EXEC SQL END DECLARE SECTION;
- id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+ id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
EXEC SQL DELETE FROM quota
WHERE entity_id = :iid AND type = 'USER';
rowcount = sqlca.sqlerrd[2];
modified("quota");
}
-fix_quota_nolist(int id)
+void fix_quota_nolist(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount, id1;
+ int iid = (int)id, rowcount, id1;
EXEC SQL END DECLARE SECTION;
- id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+ id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
rowcount = sqlca.sqlerrd[2];
if (rowcount > 0)
modified("quota");
}
-int show_quota_nofs(int id)
+int show_quota_nofs(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, id1, found = 1;
+ int iid = (int)id, id1, found = 1;
char type[9];
EXEC SQL END DECLARE SECTION;
break;
found = 0;
- printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
+ printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
}
EXEC SQL CLOSE csr214;
return found;
}
-fix_quota_nofs(int id)
+void fix_quota_nofs(void *id)
{
- single_delete("quota", "filsys_id", id);
+ single_delete("quota", "filsys_id", (int)id);
}
-int show_quota_wrongpid(int id)
+int show_quota_wrongpid(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, id1, found = 1;
+ int iid = (int)id, id1, found = 1;
char type[9];
EXEC SQL END DECLARE SECTION;
- struct user *u;
struct filesys *f;
- f = (struct filesys *)hash_lookup(filesys, id);
+ f = hash_lookup(filesys, iid);
EXEC SQL DECLARE csr215 CURSOR FOR
SELECT entity_id, type FROM quota
WHERE filsys_id = :iid;
found = 0;
printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
- type, id1, f->name, id);
+ type, id1, f->name, iid);
}
EXEC SQL CLOSE csr215;
return found;
}
-fix_quota_physid(int id)
+void fix_quota_physid(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount, id1;
+ int iid = (int)id, rowcount, id1;
EXEC SQL END DECLARE SECTION;
- id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+ id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
EXEC SQL UPDATE quota SET phys_id = :id1
WHERE filsys_id = :iid AND phys_id != :id1;
rowcount = sqlca.sqlerrd[2];
modified("quota");
}
-int show_srv_user(int id)
+int show_srv_user(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
char name[33];
- int iid = id;
+ int iid = (int)id;
EXEC SQL END DECLARE SECTION;
int found = 1;
break;
strtrim(name);
- printf("Service %s has acl non-existant user %d\n", name, id);
+ printf("Service %s has acl non-existant user %d\n", name, iid);
found = 0;
}
EXEC SQL CLOSE csr216;
return found;
}
-int show_srv_list(int id)
+int show_srv_list(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
char name[33];
- int iid = id;
+ int iid = (int)id;
EXEC SQL END DECLARE SECTION;
int found = 1;
break;
strtrim(name);
- printf("Service %s has acl non-existant list %d\n", name, id);
+ printf("Service %s has acl non-existant list %d\n", name, iid);
found = 0;
}
EXEC SQL CLOSE csr217;
return found;
}
-zero_srv_user(int id)
+void zero_srv_user(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
modified("servers");
}
-zero_srv_list(int id)
+void zero_srv_list(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, rowcount;
+ int iid = (int)id, rowcount;
EXEC SQL END DECLARE SECTION;
EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
modified("servers");
}
-int show_krb_usr(int id)
+int show_krb_usr(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1, id1;
+ int iid = (int)id, found = 1, id1;
EXEC SQL END DECLARE SECTION;
struct string *s;
char *ss;
if (sqlca.sqlcode)
break;
- if ((s = ((struct string *)hash_lookup(strings, id1))))
+ if ((s = hash_lookup(strings, id1)))
ss = s->name;
else
ss = "[unknown]";
found = 0;
printf("Kerberos map for non-existant user %d to principal %s\n",
- id, s);
+ iid, ss);
}
EXEC SQL CLOSE csr218;
return found;
}
-int show_krb_str(int id)
+int show_krb_str(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
- int iid = id, found = 1, id1;
+ int iid = (int)id, found = 1, id1;
EXEC SQL END DECLARE SECTION;
struct user *u;
char *s;
if (sqlca.sqlcode)
break;
- if ((u = ((struct user *)hash_lookup(users, id1))))
+ if ((u = hash_lookup(users, id1)))
s = u->login;
else
s = "[\?\?\?]";
found = 0;
printf("Kerberos map for user %s (%d) to non-existant string %d\n",
- s, id1, id);
+ s, id1, iid);
}
EXEC SQL CLOSE csr219;
return found;
}
-int show_pdm_mach(int id)
+int show_pdm_mach(void *id)
{
EXEC SQL BEGIN DECLARE SECTION;
char name[33];
- int iid = id;
+ int iid = (int)id;
EXEC SQL END DECLARE SECTION;
int found = 1;
strtrim(name);
printf("Palladium server/supervisor %s is on non-existant machine %d\n",
- name, id);
+ name, iid);
found = 0;
}
EXEC SQL CLOSE csr220;
}
-phase2(void)
+void phase2(void)
{
EXEC SQL BEGIN DECLARE SECTION;
int id1, id2, id3, id4, id5;
if (sqlca.sqlcode)
break;
- if (!(m = (struct machine *)hash_lookup(machines, id1)))
- sq_save_unique_data(sq1, id1);
+ if (!(m = hash_lookup(machines, id1)))
+ sq_save_unique_data(sq1, (void *)id1);
else if (!hash_lookup(clusters, id2))
- sq_save_unique_data(sq2, id2);
+ sq_save_unique_data(sq2, (void *)id2);
if (m)
m->clucount++;
}
break;
if (!hash_lookup(clusters, id1))
- sq_save_unique_data(sq1, id1);
+ sq_save_unique_data(sq1, (void *)id1);
}
EXEC SQL CLOSE csr222;
generic_delete(sq1, show_svc, "svc", "clu_id", 1);
if (sqlca.sqlcode)
break;
- if (!(l = (struct list *) hash_lookup(lists, id1)))
- sq_save_unique_data(sq1, id1);
+ if (!(l = hash_lookup(lists, id1)))
+ sq_save_unique_data(sq1, (void *)id1);
else if (type[0] == 'U' && !hash_lookup(users, id2))
- sq_save_unique_data(sq2, id2);
+ sq_save_unique_data(sq2, (void *)id2);
else if (type[0] == 'L' && !hash_lookup(lists, id2))
- sq_save_unique_data(sq3, id2);
+ sq_save_unique_data(sq3, (void *)id2);
else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id2))
- sq_save_unique_data(sq4, id2);
+ sq_save_unique_data(sq4, (void *)id2);
else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id2))
- sq_save_unique_data(sq5, id2);
+ sq_save_unique_data(sq5, (void *)id2);
else
l->members++;
}
maybe_fixup_modby2("servers", "modby", "csr224", id2);
strtrim(type);
if (!strcmp(type, "USER") && !hash_lookup(users, id1))
- sq_save_data(sq1, id1);
+ sq_save_data(sq1, (void *)id1);
else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1))
- sq_save_data(sq2, id1);
+ sq_save_data(sq2, (void *)id1);
}
EXEC SQL CLOSE csr224;
generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
maybe_fixup_modby2("serverhosts", "modby", "csr225", id2);
if (!hash_lookup(machines, id1))
- sq_save_data(sq, id1);
+ sq_save_data(sq, (void *)id1);
}
EXEC SQL CLOSE csr225;
generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
if (sqlca.sqlcode)
break;
- if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
- sq_save_data(sq1, id1);
+ if (!(f = hash_lookup(filesys, id1)))
+ sq_save_data(sq1, (void *)id1);
if (!hash_lookup(filesys, id2))
- sq_save_data(sq3, id2);
+ sq_save_data(sq3, (void *)id2);
}
EXEC SQL CLOSE csr226;
generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
maybe_fixup_modby2("quota", "modby", "csr227", id5);
if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
- sq_save_data(sq1, id1);
+ sq_save_data(sq1, (void *)id1);
else if (type[0] == 'G' && !hash_lookup(lists, id1))
- sq_save_data(sq4, id1);
- else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
- sq_save_data(sq2, id2);
- else if (id3 != f->phys_id ||
- !(n = (struct nfsphys *) hash_lookup(nfsphys, id3)))
- sq_save_data(sq3, id2);
+ sq_save_data(sq4, (void *)id1);
+ else if (!(f = hash_lookup(filesys, id2)))
+ sq_save_data(sq2, (void *)id2);
+ else if (id3 != f->phys_id || !(n = hash_lookup(nfsphys, id3)))
+ sq_save_data(sq3, (void *)id2);
else
n->count += id4;
}
maybe_fixup_modby2("palladium", "modby", "csr229", id2);
if (!hash_lookup(machines, id1))
- sq_save_unique_data(sq1, id1);
+ sq_save_unique_data(sq1, (void *)id1);
}
EXEC SQL CLOSE csr229;
generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
break;
if (!hash_lookup(users, id1))
- sq_save_unique_data(sq1, id1);
+ sq_save_unique_data(sq1, (void *)id1);
else if (!maybe_fixup_unref_string2("krbmap", "string_id", "csr230", id2))
- sq_save_unique_data(sq2, id2);
+ sq_save_unique_data(sq2, (void *)id2);
}
EXEC SQL CLOSE csr230;
generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
break;
if (!hash_lookup(machines, id1))
- sq_save_unique_data(sq1, id1);
+ sq_save_unique_data(sq1, (void *)id1);
}
EXEC SQL CLOSE csr232;
generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
maybe_fixup_modby2("printcap", "modby", "csr233", id3);
if (!hash_lookup(machines, id1))
- sq_save_unique_data(sq1, id1);
+ sq_save_unique_data(sq1, (void *)id1);
else if (!hash_lookup(machines, id2))
- sq_save_unique_data(sq2, id2);
+ sq_save_unique_data(sq2, (void *)id2);
}
EXEC SQL CLOSE csr233;
generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
-/* $Header$
+/* $Id$
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
+#include <moira.h>
#include "dbck.h"
-static char phase3_qc_rcsid[] = "$Header$";
+#include <stdio.h>
+
+RCSID("$Header$");
+void empty_list_check(int id, void *list, void *hint);
+void unref_string_check(int id, void *string, void *hint);
+void noclu_mach_check(int id, void *machine, void *hint);
-empty_list_check(int id, struct list *l, int hint)
+void empty_list_check(int id, void *list, void *hint)
{
+ struct list *l = list;
if (l->members == 0 && l->list_id != 0)
printf("Warning: List %s is empty\n", l->name);
}
}
-unref_string_check(int id, struct string *s, int hint)
+void unref_string_check(int id, void *string, void *hint)
{
+ struct string *s = string;
+
if (s->refc == 0)
{
printf("Unreferenced string %s id %d\n", s->name, id);
* servers in the Athena Computing Environment, has been extended to
* manage all hosts in the MIT.EDU domain (but not subdomains).
*/
-#ifndef ATHENA
-noclu_mach_check(int id, struct machine *m, int hint)
+void noclu_mach_check(int id, void *machine, void *hint)
{
+ struct machine *m = machine;
+
if (m->clucount == 0 && m->mach_id != 0)
printf("Warning: machine %s is not in any clusters\n", m->name);
}
-#endif
-phase3(void)
+void phase3(void)
{
printf("Phase 3 - Finding unused objects\n");
-/* $Header$
+/* $Id$
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdlib.h>
#include <moira.h>
#include "dbck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca;
-static char phase4_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
EXEC SQL WHENEVER SQLERROR DO dbmserr();
-count_boxes(int id, struct user *u, struct hash *boxes)
+void count_boxes(int id, void *user, void *boxes);
+void check_box_counts(int id, void *cnt, void *counts);
+void check_nfs_counts(int id, void *nfsphys, void *hint);
+
+void count_boxes(int id, void *user, void *boxes)
{
+ struct user *u = user;
int i;
if (u->potype == 'P')
{
if ((i = (int) hash_lookup(boxes, u->pobox_id)))
{
- if (hash_store(boxes, u->pobox_id, i + 1) == -1)
+ if (hash_store(boxes, u->pobox_id, (void *)(i + 1)) == -1)
out_of_mem("storing poboxes in hash table");
}
else
}
-check_box_counts(int id, int cnt, struct hash *counts)
+void check_box_counts(int id, void *cnt, void *counts)
{
EXEC SQL BEGIN DECLARE SECTION;
- int oldval, rowcount, iid = id, icnt = cnt;
+ int oldval, rowcount, iid = id, icnt = (int)cnt;
EXEC SQL END DECLARE SECTION;
oldval = (int) hash_lookup(counts, id);
- cnt--;
- if (oldval != cnt)
+ icnt--;
+ if (oldval != icnt)
{
printf("Count wrong on POBox machine %s; is %d in db, counted %d\n",
((struct machine *) hash_lookup(machines, id))->name,
- oldval, cnt);
+ oldval, icnt);
if (single_fix("Update", 1))
{
EXEC SQL UPDATE serverhosts SET value1 = :icnt
}
-check_nfs_counts(int id, struct nfsphys *n, int hint)
+void check_nfs_counts(int id, void *nfsphys, void *hint)
{
+ struct nfsphys *n = nfsphys;
EXEC SQL BEGIN DECLARE SECTION;
int iid = id, val, rowcount;
EXEC SQL END DECLARE SECTION;
}
-phase4(void)
+void phase4(void)
{
struct hash *boxes, *counts;
int id, cnt;
if (sqlca.sqlcode)
break;
- if (hash_store(boxes, id, 1) == -1)
+ if (hash_store(boxes, id, (void *)1) == -1)
out_of_mem("storing poboxes");
- if (hash_store(counts, id, cnt) == -1)
+ if (hash_store(counts, id, (void *)cnt) == -1)
out_of_mem("storing pobox counts in hash table");
}
EXEC SQL CLOSE csr401;
}
-count_only_setup(void)
+void count_only_setup(void)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, status, id2, id3;
char name[33], last[17], first[17], buf[257];
EXEC SQL END DECLARE SECTION;
- struct save_queue *sq;
struct user *u;
struct nfsphys *n;
struct machine *m;
strcpy(u->login, strtrim(name));
u->potype = buf[0];
sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
- u->fullname = strsave(buf);
+ u->fullname = strdup(buf);
u->status = status;
u->users_id = id;
switch (u->potype)
if (sqlca.sqlcode)
break;
- if (n = (struct nfsphys *) hash_lookup(nfsphys, id))
+ if ((n = hash_lookup(nfsphys, id)))
n->count += id2;
}
EXEC SQL CLOSE csr405;
-/*
- * The Data Control Manager for MOIRA.
+/* $Id$
*
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
+ * The Data Control Manager for Moira.
*
- * $Source$
- * $Author$
- * $Header$
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char rcsid_dcm_c[] = "$Header$";
-#endif lint
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+#include "update.h"
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include <unistd.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <com_err.h>
#include <gdb.h>
-#include <moira.h>
-#include <moira_site.h>
EXEC SQL INCLUDE sqlca;
+void sqlglm(char *, unsigned int *, unsigned int *);
+
+RCSID("$Header$");
+
+int generate_service(char *name, int force);
+void do_hosts(char *service);
+int dcm_send_file(char *service, char *host, char *target);
+int dcm_execute(char *service, char *host, char *script);
+void dbmserr(void);
+
EXEC SQL WHENEVER SQLERROR DO dbmserr();
#define SQL_NO_MATCH 1403
while (waitpid(0, &status, 0) > 0)
;
com_err(whoami, 0, "exiting");
+ exit(0);
}
int generate_service(char *name, int force)
EXEC SQL BEGIN DECLARE SECTION;
int interval, dfcheck, status;
time_t now;
- char *errmsg;
+ const char *errmsg;
EXEC SQL END DECLARE SECTION;
char dfgen_prog[64], dfgen_cmd[128];
struct sigaction action, prevaction;
void do_hosts(char *service)
{
EXEC SQL BEGIN DECLARE SECTION;
- char type[16], host[73], target[64], script[128], *errmsg;
- int status = 0, mid, dfgen, replicated;
+ char type[16], host[73], target[64], script[128];
+ const char *errmsg;
+ int status = 0, dfgen, replicated;
time_t now;
EXEC SQL END DECLARE SECTION;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * This program starts the DCM in a "clean" environment.
+ * and then waits for it to exit.
*
- * This program starts the DCM in a "clean" environment.
- * and then waits for it to exit.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_starter_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/resource.h>
+#include <sys/wait.h>
+
#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <moira_site.h>
-#include <time.h>
+#include <unistd.h>
+
+RCSID("$Header$");
#define PROG "dcm"
int rdpipe[2];
-extern int errno;
+
+void cleanup(void);
void cleanup(void)
{
{
char buf[BUFSIZ];
FILE *log, *prog;
- int logf, inf, i, done, pid, tty;
+ int logf, inf, i, done, pid;
struct rlimit rl;
- extern int errno;
- extern char *sys_errlist[];
-
struct sigaction action;
int nfds;
if (errno && errno != EINTR)
{
strcpy(buf, "Unable to read from program: ");
- strcat(buf, sys_errlist[errno]);
+ strcat(buf, strerror(errno));
strcat(buf, "\n");
}
else
-/* $Header$
+/* $Id$
*
* This generates a master /etc/passwd containing all active (status != 0)
* accounts.
*
- * (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
#include <moira.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+
+#include <stdio.h>
+#include <time.h>
+
EXEC SQL INCLUDE sqlca;
-extern int errno;
+RCSID("$Header$");
+
char *whoami = "directory.gen";
char *db = "moira/moira";
-/* $Header$
+/* $Id$
*
* This generates the zone files necessary to load a hesiod server.
* The following zones are generated: passwd, uid, pobox, group,
* grplist, gid, filsys, cluster, pcap, sloc, service.
*
- * (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <moira.h>
#include <moira_site.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
-#include <ctype.h>
+
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
#ifndef HTYPE
#define HTYPE "TXT"
struct grp *lists;
};
+/*
+ * Modified from sys/types.h:
+ */
+int setsize; /* = howmany(setbits, NSETBITS) */
+
+typedef long set_mask;
+#define NSETBITS (sizeof(set_mask) * NBBY) /* bits per mask */
+#ifndef howmany
+#define howmany(x, y) (((x) + ((y) - 1)) / (y))
+#endif
+
+#define SET_SET(n, p) ((p)[(n)/NSETBITS] |= (1 << ((n) % NSETBITS)))
+#define SET_CLR(n, p) ((p)[(n)/NSETBITS] &= ~(1 << ((n) % NSETBITS)))
+#define SET_ISSET(n, p) ((p)[(n)/NSETBITS] & (1 << ((n) % NSETBITS)))
+#define SET_CREATE() (malloc(setsize * sizeof(set_mask)))
+#define SET_ZERO(p) memset(p, 0, setsize * sizeof(set_mask))
+#define SET_CMP(p1, p2) (memcmp(p1, p2, setsize * sizeof(set_mask)))
+
+
+void get_mach(void);
+int nbitsset(set_mask *set);
+
+int do_passwd(void);
+int do_groups(void);
+int do_filsys(void);
+int do_cluster(void);
+int do_printcap(void);
+int do_palladium(void);
+int do_sloc(void);
+int do_service(void);
int main(int argc, char **argv)
{
}
-get_mach(void)
+void get_mach(void)
{
EXEC SQL BEGIN DECLARE SECTION;
int id;
EXEC SQL FETCH m_cursor INTO :name, :id;
if (sqlca.sqlcode)
break;
- hash_store(machines, id, strsave(strtrim(name)));
+ hash_store(machines, id, strdup(strtrim(name)));
}
if (sqlca.sqlcode < 0)
db_error(sqlca.sqlcode);
break;
strtrim(name);
sprintf(buf, "%s:%d", name, gid);
- hash_store(groups, lid, strsave(buf));
+ hash_store(groups, lid, strdup(buf));
fprintf(iout, "%d.gid\t%s CNAME %s.group\n", gid, HCLASS, name);
fprintf(gout, "%s.group\t%s %s \"%s:*:%d:\"\n",
name, HCLASS, HTYPE, name, gid);
EXEC SQL FETCH i_cursor INTO :lid, :id;
if (sqlca.sqlcode)
break;
- if ((l = hash_lookup(groups, lid)) &&
- (u = (struct user *) hash_lookup(users, id)))
+ if ((l = hash_lookup(groups, lid)) && (u = hash_lookup(users, id)))
{
g = malloc(sizeof(struct grp));
g->next = u->lists;
{
FILE *out;
char outf[64], outft[64], *mach, *group;
- char *p;
struct stat sb;
time_t ftime;
- struct save_queue *sq, *sq2, *sq_create();
+ struct save_queue *sq, *sq2;
EXEC SQL BEGIN DECLARE SECTION;
char name[33], type[9], loc[81], access[2], mount[33], trans[257];
char comments[65];
strtrim(type);
if (!strcmp(type, "NFS") || !strcmp(type, "RVD"))
{
- if (mach = hash_lookup(machines, id))
+ if ((mach = hash_lookup(machines, id)))
{
fprintf(out, "%s.filsys\t%s %s \"%s %s %s %s %s\"\n",
strtrim(name), HCLASS, HTYPE, type, strtrim(loc),
else if (!strcmp(type, "FSGROUP"))
{
sprintf(trans, "%s:%d", strtrim(name), fid);
- sq_save_data(sq, strsave(trans));
+ sq_save_data(sq, strdup(trans));
}
else if (!strcmp(type, "MUL"))
{
sprintf(trans, "%s:%d", strtrim(name), fid);
- sq_save_data(sq2, strsave(trans));
+ sq_save_data(sq2, strdup(trans));
}
}
EXEC SQL CLOSE f_cursor;
strtrim(type);
if (!strcmp(type, "NFS") || !strcmp(type, "RVD"))
{
- if (mach = hash_lookup(machines, id))
+ if ((mach = hash_lookup(machines, id)))
{
fprintf(out, "%s.filsys\t%s %s \"%s %s %s %s %s %d\"\n",
group, HCLASS, HTYPE, type, strtrim(loc), mach,
return 0;
}
-
-/*
- * Modified from sys/types.h:
- */
-int setsize; /* = howmany(setbits, NSETBITS) */
-
-typedef long set_mask;
-#define NSETBITS (sizeof(set_mask) * NBBY) /* bits per mask */
-#ifndef howmany
-#define howmany(x, y) (((x) + ((y) - 1)) / (y))
-#endif
-
-#define SET_SET(n, p) ((p)[(n)/NSETBITS] |= (1 << ((n) % NSETBITS)))
-#define SET_CLR(n, p) ((p)[(n)/NSETBITS] &= ~(1 << ((n) % NSETBITS)))
-#define SET_ISSET(n, p) ((p)[(n)/NSETBITS] & (1 << ((n) % NSETBITS)))
-#define SET_CREATE() (malloc(setsize * sizeof(set_mask)))
-#define SET_ZERO(p) memset(p, 0, setsize * sizeof(set_mask))
-#define SET_CMP(p1, p2) (memcmp(p1, p2, setsize * sizeof(set_mask)))
-
-int nbitsset(set_mask *set)
+ int nbitsset(set_mask *set)
{
int i, ret;
ret = 0;
strtrim(rp);
strtrim(sd);
fprintf(out, "%s.pcap\t%s %s \"%s:rp=%s:rm=%s:sd=%s:ka#%d:pc#%d",
- name, HCLASS, HTYPE, name, rp, hash_lookup(machines, rm),
+ name, HCLASS, HTYPE, name, rp, (char *)hash_lookup(machines, rm),
sd, ka, pc);
if (rq && hash_lookup(machines, rq))
- fprintf(out, ":rq=%s\"\n", hash_lookup(machines, rq));
+ fprintf(out, ":rq=%s\"\n", (char *)hash_lookup(machines, rq));
else
fputs("\"\n", out);
}
break;
strtrim(name);
fprintf(out, "%s.palladium\t%s %s \"%s %d %s interface directory\"\n",
- name, HCLASS, HTYPE, hash_lookup(machines, rm), identifier,
- name);
+ name, HCLASS, HTYPE, (char *)hash_lookup(machines, rm),
+ identifier, name);
}
EXEC SQL CLOSE p_cursor3;
if (sqlca.sqlcode)
break;
strtrim(service);
- if (mach = hash_lookup(machines, id))
+ if ((mach = hash_lookup(machines, id)))
fprintf(out, "%s.sloc\t%s %s %s\n", service, HCLASS, HTYPE, mach);
}
EXEC SQL CLOSE s_cursor;
-/* $Header$
+/* $Id$
*
* This generates the hstath.txt hosttable.
*
- * (c) Copyright 1993 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1993-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
#include <moira.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
-extern int errno;
+RCSID("$Header$");
+
char *whoami = "hosts.gen";
char *db = "moira/moira";
}
else
name[i - 8] = 0;
- if (p = hash_lookup(aliases, id))
+ if ((p = hash_lookup(aliases, id)))
{
sprintf(buf, "%s,%s", p, name);
- hash_update(aliases, id, strsave(buf));
+ hash_update(aliases, id, strdup(buf));
free(p);
}
else
- hash_store(aliases, id, strsave(name));
+ hash_store(aliases, id, strdup(name));
}
EXEC SQL DECLARE x CURSOR FOR SELECT
-
-/* $Header$
+/* $Id$
*
* This generates the /usr/lib/aliases file for the mailhub.
*
- * (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
#include <moira.h>
#include <moira_site.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
char *whoami = "mailhub.gen";
char *db = "moira/moira";
-char *perm_malloc();
-char *pstrsave();
char *divide = "##############################################################";
#define ML_WID 72
FILE *out = stdout;
+struct hash *users, *machines, *strings, *lists, *names;
+struct user {
+ char *login;
+ char *first;
+ char *last;
+ char mi;
+ char *pobox;
+};
+struct member {
+ struct member *next;
+ char *name;
+ int list_id;
+};
+struct list {
+ char *name;
+ char maillist;
+ char *description;
+ char acl_t;
+ int acl_id;
+ struct member *m;
+};
+struct names {
+ char *name;
+ struct names *next;
+ int keep;
+ int id;
+};
+
+void get_info(void);
+void save_mlist(int id, void *list, void *force);
+void insert_login(int id, void *user, void *hint);
+void insert_names(int id, void *user, void *hint);
+void insert_name(char *s, int id, int nodups, int copy);
+int hashstr(char *s);
+void sort_info(void);
+void output_data(int dummy, void *names, void *out);
+void output_mlist(int id, struct list *l);
+void do_member(FILE *out, char *s);
+void put_fill(FILE *aliases, char *string);
+void do_people(void);
+
int main(int argc, char **argv)
{
long tm = time(NULL);
exit(MR_SUCCESS);
}
-
-
-struct hash *users, *machines, *strings, *lists, *names;
-struct user {
- char *login;
- char *first;
- char *last;
- char mi;
- char *pobox;
-};
-struct member {
- struct member *next;
- char *name;
- int list_id;
-};
-struct list {
- char *name;
- char maillist;
- char *description;
- char acl_t;
- int acl_id;
- struct member *m;
-};
-struct names {
- char *name;
- struct names *next;
- int keep;
- int id;
-};
-
-
-get_info(void)
+void get_info(void)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, pid, bid, cnt, maillistp, acl, mid;
EXEC SQL FETCH m_cursor INTO :id, :name;
if (sqlca.sqlcode)
break;
- if (s = strchr(name, '.'))
+ if ((s = strchr(name, '.')))
*s = '\0';
else
strtrim(name);
#ifdef ATHENA
strcat(name, ".LOCAL");
#endif
- if (hash_store(machines, id, pstrsave(name)) < 0)
+ if (hash_store(machines, id, strdup(name)) < 0)
{
fprintf(stderr, "Out of memory!\n");
exit(MR_NO_MEM);
EXEC SQL FETCH s_cursor INTO :id, :name;
if (sqlca.sqlcode)
break;
- if (hash_store(strings, id, pstrsave(strtrim(name))) < 0)
+ if (hash_store(strings, id, strdup(strtrim(name))) < 0)
{
fprintf(stderr, "Out of memory!\n");
exit(MR_NO_MEM);
:type, :pid, :bid;
if (sqlca.sqlcode)
break;
- u = (struct user *) perm_malloc(sizeof(struct user));
- u->login = pstrsave(strtrim(name));
- u->first = pstrsave(strtrim(fname));
- u->last = pstrsave(strtrim(lname));
+ u = malloc(sizeof(struct user));
+ u->login = strdup(strtrim(name));
+ u->first = strdup(strtrim(fname));
+ u->last = strdup(strtrim(lname));
if (mname[0] != ' ')
u->mi = mname[0];
else
if (type[0] == 'P' && (s = hash_lookup(machines, pid)))
{
sprintf(buf, "%s@%s", u->login, s);
- u->pobox = pstrsave(buf);
+ u->pobox = strdup(buf);
}
else if (type[0] == 'S')
u->pobox = hash_lookup(strings, bid);
EXEC SQL FETCH l_cursor INTO :id, :name, :maillistp, :buf, :type, :acl;
if (sqlca.sqlcode)
break;
- l = (struct list *) perm_malloc(sizeof(struct list));
- l->name = pstrsave(strtrim(name));
+ l = malloc(sizeof(struct list));
+ l->name = strdup(strtrim(name));
l->maillist = maillistp;
- l->description = pstrsave(strtrim(buf));
+ l->description = strdup(strtrim(buf));
l->acl_t = type[0];
l->acl_id = acl;
l->m = NULL;
if (sqlca.sqlcode)
break;
cnt++;
- if ((l = (struct list *) hash_lookup(lists, id)))
+ if ((l = hash_lookup(lists, id)))
{
- m = (struct member *) perm_malloc(sizeof(struct member));
- if (type[0] == 'U' && (u = (struct user *) hash_lookup(users, mid)))
+ m = malloc(sizeof(struct member));
+ if (type[0] == 'U' && (u = hash_lookup(users, mid)))
{
m->list_id = 0;
m->name = u->login;
m->next = l->m;
l->m = m;
}
- else if (type[0] == 'L' &&
- (memberlist = (struct list *) hash_lookup(lists, mid)))
+ else if (type[0] == 'L' && (memberlist = hash_lookup(lists, mid)))
{
m->list_id = mid;
m->name = memberlist->name;
}
-save_mlist(int id, struct list *l, int force)
+void save_mlist(int id, void *list, void *force)
{
struct member *m;
- struct list *l1;
+ struct list *l = list, *l1;
if (l->maillist > 1 || (l->maillist == 0 && !force))
return;
insert_name(l->name, -1, TRUE, FALSE);
output_mlist(id, l);
- if (l->acl_t == 'L' && (l1 = (struct list *)hash_lookup(lists, l->acl_id)))
- save_mlist(0, l1, TRUE);
+ if (l->acl_t == 'L' && (l1 = hash_lookup(lists, l->acl_id)))
+ save_mlist(0, l1, (void *)TRUE);
for (m = l->m; m; m = m->next)
{
- if (m->list_id && (l1 = (struct list *)hash_lookup(lists, m->list_id)))
- save_mlist(0, l1, TRUE);
+ if (m->list_id && (l1 = hash_lookup(lists, m->list_id)))
+ save_mlist(0, l1, (void *)TRUE);
}
}
-insert_login(int id, struct user *u, int dummy)
+void insert_login(int id, void *user, void *hint)
{
+ struct user *u = user;
if (u->pobox && u->login[0] != '#')
insert_name(u->login, id, TRUE, FALSE);
}
-void insert_names(int id, struct user *u, int dummy)
+void insert_names(int id, void *user, void *hint)
{
char buffer[256];
+ struct user *u = user;
insert_name(u->last, id, FALSE, FALSE);
sprintf(buffer, "%s_%s", u->first, u->last);
int incount = 0;
-insert_name(char *s, int id, int nodups, int copy)
+void insert_name(char *s, int id, int nodups, int copy)
{
int code;
struct names *ns;
incount++;
code = hashstr(s);
- ns = (struct names *) hash_lookup(names, code);
+ ns = hash_lookup(names, code);
if (!ns)
{
- if (!(ns = (struct names *) perm_malloc(sizeof(struct names))))
+ if (!(ns = malloc(sizeof(struct names))))
{
fprintf(stderr, "ran out of memory inserting name (sorting)\n");
exit(MR_NO_MEM);
}
if (copy)
- ns->name = pstrsave(s);
+ ns->name = strdup(s);
else
ns->name = s;
ns->keep = nodups;
if (!strcasecmp(ns->name, s))
goto foundns;
}
- if (!(ns->next = (struct names *) perm_malloc(sizeof(struct names))))
+ if (!(ns->next = malloc(sizeof(struct names))))
{
fprintf(stderr, "ran out of memory insterting name (sorting)\n");
exit(MR_NO_MEM);
}
ns = ns->next;
if (copy)
- ns->name = pstrsave(s);
+ ns->name = strdup(s);
else
ns->name = s;
ns->keep = nodups;
int result;
int c;
- for (result = 0; c = *s; s++)
+ for (result = 0; (c = *s); s++)
{
if (illegalchars[c])
{
}
-sort_info(void)
+void sort_info(void)
{
names = create_hash(20001);
hash_step(users, insert_login, NULL);
}
-output_data(int dummy, struct names *nms, FILE *out)
+void output_data(int dummy, void *names, void *out)
{
- struct names *ns;
+ struct names *ns, *nms = names;
struct user *u;
incount++;
}
if (ns->id > 0)
{
- u = (struct user *) hash_lookup(users, ns->id);
+ u = hash_lookup(users, ns->id);
if (u->pobox)
fprintf(out, "%s: %s\n", ns->name, u->pobox);
#ifdef NAME_ALIASES
int lwid, bol, awid;
-output_mlist(int id, struct list *l)
+void output_mlist(int id, struct list *l)
{
struct list *l1;
struct member *m;
struct user *u;
put_fill(out, l->description);
- if (l->acl_t == 'L' && (l1 = (struct list *) hash_lookup(lists, l->acl_id)))
+ if (l->acl_t == 'L' && (l1 = hash_lookup(lists, l->acl_id)))
fprintf(out, "owner-%s: %s\n%s: ", l->name, l1->name, l->name);
- else if (l->acl_t == 'U' &&
- (u = (struct user *) hash_lookup(users, l->acl_id)))
+ else if (l->acl_t == 'U' && (u = hash_lookup(users, l->acl_id)))
fprintf(out, "owner-%s: %s\n%s: ", l->name, u->login, l->name);
else
fprintf(out, "%s: ", l->name);
/* print out strings separated by commas, doing line breaks as appropriate */
-do_member(FILE *out, char *s)
+void do_member(FILE *out, char *s)
{
- wwid;
+ int wwid;
static int cont = 1;
char str[8];
}
-put_fill(FILE *aliases, char *string)
+void put_fill(FILE *aliases, char *string)
{
char *c;
int lwid;
}
-do_people(void)
+void do_people(void)
{
incount = 0;
fprintf(out, "\n%s\n# People\n%s\n", divide, divide);
hash_step(names, output_data, out);
fprintf(stderr, "Output %d entries\n", incount);
}
-
-
-#define chunk_size 102400
-
-char *perm_malloc(unsigned size)
-{
- static char *pool = NULL;
- static unsigned pool_size = 0;
- char *ret;
-
- if (size > pool_size)
- {
- pool = malloc(chunk_size);
- pool_size = chunk_size;
- }
- ret = pool;
- pool += size;
- pool = (char *)(((unsigned) (pool + 3)) & ~3);
- pool_size -= (pool - ret);
- return ret;
-}
-
-
-/*
- * Make a (permenant) copy of a string.
- */
-char *pstrsave(char *s)
-{
- int len;
- char *p;
- /* Kludge for sloppy string semantics */
- if (!s)
- {
- printf("NULL != \"\" !!!!\r\n");
- p = perm_malloc(1);
- *p = '\0';
- return p;
- }
- len = strlen(s) + 1;
- p = perm_malloc((u_int)len);
- if (p)
- memcpy(p, s, len);
- return p;
-}
-
-#define hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
-
-/* Create a hash table. The size is just a hint, not a maximum. */
-
-struct hash *create_hash(int size)
-{
- struct hash *h;
-
- h = (struct hash *) perm_malloc(sizeof(struct hash));
- if (!h)
- return NULL;
- h->size = size;
- h->data = (struct bucket **) perm_malloc(size * sizeof(char *));
- if (!h->data)
- return NULL;
- memset(h->data, 0, size * sizeof(char *));
- return h;
-}
-
-/* Lookup an object in the hash table. Returns the value associated with
- * the key, or NULL (thus NULL is not a very good value to store...)
- */
-
-char *hash_lookup(struct hash *h, int key)
-{
- struct bucket *b;
-
- b = h->data[hash_func(h, key)];
- while (b && b->key != key)
- b = b->next;
- if (b && b->key == key)
- return b->data;
- else
- return NULL;
-}
-
-
-/* Update an existing object in the hash table. Returns 1 if the object
- * existed, or 0 if not.
- */
-
-int hash_update(struct hash *h, int key, char *value)
-{
- struct bucket *b;
-
- b = h->data[hash_func(h, key)];
- while (b && b->key != key)
- b = b->next;
- if (b && b->key == key)
- {
- b->data = value;
- return 1;
- }
- else
- return 0;
-}
-
-
-/* Store an item in the hash table. Returns 0 if the key was not previously
- * there, 1 if it was, or -1 if we ran out of memory.
- */
-
-int hash_store(struct hash *h, int key, char *value)
-{
- struct bucket *b, **p;
-
- p = &(h->data[hash_func(h, key)]);
- if (!*p)
- {
- b = *p = (struct bucket *) perm_malloc(sizeof(struct bucket));
- if (!b)
- return -1;
- b->next = NULL;
- b->key = key;
- b->data = value;
- return 0;
- }
-
- for (b = *p; b && b->key != key; b = *p)
- p = (struct bucket **) *p;
- if (b && b->key == key)
- {
- b->data = value;
- return 1;
- }
- b = *p = (struct bucket *) perm_malloc(sizeof(struct bucket));
- if (!b)
- return -1;
- b->next = NULL;
- b->key = key;
- b->data = value;
- return 0;
-}
-
-
-/* Search through the hash table for a given value. For each piece of
- * data with that value, call the callback proc with the corresponding key.
- */
-
-hash_search(struct hash *h, char *value, void (*callback)())
-{
- struct bucket *b, **p;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--)
- {
- for (b = *p; b; b = b->next)
- {
- if (b->data == value)
- (*callback)(b->key);
- }
- }
-}
-
-
-/* Step through the hash table, calling the callback proc with each key.
- */
-
-hash_step(struct hash *h, void (*callback)(), char *hint)
-{
- struct bucket *b, **p;
-
- for (p = &(h->data[h->size - 1]); p >= h->data; p--)
- {
- for (b = *p; b; b = b->next)
- (*callback)(b->key, b->data, hint);
- }
-}
-/* $Header$
+/* $Id$
*
- * (c) Copyright 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
+#include <moira.h>
+
+#include <sys/types.h>
+
#include <stdio.h>
#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <moira.h>
-#include <moira_site.h>
-EXEC SQL INCLUDE sqlca;
-static char *MONTHNAMES[] = {"january", "february", "march", "april", "may",
- "june", "july", "august", "september",
- "october", "november", "december"};
+#include "util.h"
-static int MONTHDAYS[] = {0,0,31,59,90,120,151,181,212,243,273,304,334};
+EXEC SQL INCLUDE sqlca;
+/* Julian day of the UNIX epoch (January 1, 1970) */
+#define UNIX_EPOCH 2440588
/****************************************************************/
/** Return the difference between the modtime & table modtime **/
{
time_t filetimeno;
EXEC SQL BEGIN DECLARE SECTION;
- char filetime[48], *tbl_name;
+ char filetime[48], *ft = filetime, *tbl_name;
EXEC SQL END DECLARE SECTION;
*flag = 0;
tbl_name = tbl;
- EXEC SQL SELECT TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS')
+ /* Get modtime as seconds, minutes, hours, and Julian day */
+ EXEC SQL SELECT TO_CHAR(modtime, 'SS MI HH24 J')
INTO :filetime FROM tblstats
WHERE table_name = :tbl_name;
if (sqlca.sqlcode)
{
- fprintf(stderr, "Moddiff Query failed: %d\n", sqlca.sqlcode);
+ fprintf(stderr, "Moddiff Query failed: %ld\n", sqlca.sqlcode);
return MR_DATE;
}
- if (Date2Sec (filetime, &filetimeno))
- {
- fprintf(stderr, "Unable to parse mod. date for file %s\n", tbl);
- return MR_DATE;
- }
- *flag = (int) (filetimeno - ModTime);
- return 0;
-}
-
-
-/***************************************************/
-/** convert Unix-time (# of seconds since 1970) **/
-/** from a date-time string **/
-/** Return 1 if failure, 0 if success **/
-/***************************************************/
-
-int Date2Sec(char *DS, time_t *UTime)
-{
- static int defzone = -1;
- int Day, Month, Year, Hour, Minute, Sec, Err, TotalDays, Iter;
- struct timeval tv;
- struct timezone tz;
-
- if (defzone == -1)
- {
- if (gettimeofday(&tv, &tz))
- defzone = 0;
- else
- defzone = tz.tz_minuteswest;
- }
-
- Err = ParseDateString (DS, &Day, &Month, &Year, &Hour, &Minute, &Sec);
- if (Err)
- return Err;
-
- if (Year < 1970)
- {
- for (TotalDays = 0, Iter = 1969; Iter > Year; Iter--)
- TotalDays += NumdaysY(Iter);
- TotalDays += (NumdaysY(Year) - NumdaysM(Month, Year) - Day);
- *UTime = -((((24 * TotalDays) + 24 - Hour) * 60 - Minute) * 60 -
- Sec) + defzone;
- return 0;
- }
- else
- {
- for (TotalDays = 0, Iter = 1970; Iter < Year; Iter++)
- TotalDays += NumdaysY(Iter);
- TotalDays += NumdaysM(Month, Year);
- TotalDays += (Day - 1);
- *UTime = (((24 * TotalDays) + Hour) * 60 + Minute) * 60 +
- Sec + defzone;
- return 0;
- }
-}
-
-
-/*****************************************/
-/** Return the # of days in the Year **/
-/*****************************************/
-
-int NumdaysY(int Year)
-{
- return 365 + Leapyear(Year);
-}
-
-
-/*****************************************/
-/** Return the # of days in the Month **/
-/*****************************************/
-
-int NumdaysM(int Month, int Year)
-{
- if ((Month > 2) && (Leapyear (Year)))
- return MONTHDAYS[Month] + 1;
- else
- return MONTHDAYS[Month];
-}
-
-
-/*****************************************/
-/** Return 1 if a leapyear, else 0 **/
-/*****************************************/
-
-int Leapyear(int Year)
-{
- if ((Year % 4) && (!(Year % 100) || (Year % 1000)))
- return 0;
- else
- return 1;
-}
-
-
-/************************************************/
-/** Compute numeric breakdown of date string **/
-/** Return 0 if success, 1 if failure **/
-/************************************************/
-
-int ParseDateString(char *DS, int *Day, int *Month, int *Year, int *Hour,
- int *Minute, int *Sec)
-{
- int Gotten;
- char *M, *D, *Temp;
- int Y = 0, H = 0, Min = 0, S = 0, DayNum = 0, MonthNum = 0;
-
- M = malloc(strlen(DS) + 2);
- D = malloc(strlen(DS) + 2);
- if (!(M && D))
- return 1;
- Gotten = sscanf (DS, "%[^-]-%[^-]-%d %d:%d:%d", D, M, &Y, &H, &Min, &S);
- if (Gotten < 3)
- Gotten = sscanf (DS, "%[^/]/%[^/]/%d %d:%d:%d", D, M, &Y, &H, &Min, &S);
- if (Gotten < 3)
- Gotten = sscanf (DS, "%s %[^,], %d %d:%d:%d", M, D, &Y, &H, &Min, &S);
- if ((Gotten < 3) || !(D && M && Y))
- {
- free(M);
- free(D);
- return 1; /* Couldn't scan in a date */
- }
- if (atoi(M))
- { /* Month not text, so M/D/Y not D/M/Y */
- Temp = M;
- M = D;
- D = Temp;
- }
- DayNum = atoi(D);
- MonthNum = MonthNo(M);
- free(M);
- free(D);
- if ((DayNum < 1) || (DayNum > 31))
- return 1; /* Bad Day */
- if (!MonthNum)
- return 1; /* Bad Month */
- if ((Y < 1) || (Y > 10000))
- return 1; /* Bad Year */
- if (Gotten == 4)
- return 1; /* Bad Time (Hour only) */
- if ((Gotten > 4) && (H < 0) || (H > 24))
- return 1; /* Bad Hour */
- if ((Gotten > 4) && ((Min < 0) || (Min > 59)))
- return 1; /* Bad Minute */
- if ((Gotten > 5) && ((S < 0) || (S > 59)))
- return 1; /* Bad Second */
- *Day = DayNum;
- *Month = MonthNum;
- if (Y < 100) /* For abreviations like 90 for 1990 */
- Y += 1900; /* (Yes, it will be wrong in 2000) */
- *Year = Y;
- if (Gotten > 4)
- {
- *Hour = H;
- *Minute = Min;
- }
- else
- {
- *Hour = 0;
- *Minute = 0;
- }
- if (Gotten > 5)
- *Sec = S;
- else
- *Sec = 0;
- return 0;
-}
-
-/***********************************************************/
-/** Return the Month number of a Month number or string **/
-/***********************************************************/
+ filetimeno = strtol(ft, &ft, 10);
+ filetimeno = filetimeno * 60 + strtol(ft, &ft, 10);
+ filetimeno = filetimeno * 60 + strtol(ft, &ft, 10);
+ filetimeno = filetimeno * 24 + (strtol(ft, NULL, 10) - UNIX_EPOCH);
-int MonthNo(char *M)
-{
- int Count;
- if (atoi(M))
- {
- if ((atoi(M) > 0) && (atoi(M) < 13))
- return atoi(M);
- else
- return 0;
- }
- for (Count = 0; Count < 12; Count++)
- {
- if (!strcasecmp (M, MONTHNAMES[Count])
- || !strncasecmp(M, MONTHNAMES[Count], 3))
- return Count + 1;
- }
+ *flag = (int) (filetimeno - ModTime);
return 0;
}
-/* $Header$
+/* $Id$
*
* This generates the msql database for the network tables.
*
- * (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright 1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
#include <moira.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
-extern int errno;
+RCSID("$Header$");
+
char *whoami = "ndb.gen";
char *db = "moira/moira";
-/* $Header$
+/* $Id$
*
* This generates the network table.
*
- * (c) Copyright 1994 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1994-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
#include <moira.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+
#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include "util.h"
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
char *whoami = "network.gen";
char *db = "moira/moira";
int main(int argc, char **argv)
{
FILE *out = stdout;
- char *outf = NULL, outft[64], *p, buf[256];
+ char *outf = NULL, outft[64];
struct stat sb;
struct timeval now;
struct in_addr addr;
- int flag1, i;
+ int flag1;
EXEC SQL BEGIN DECLARE SECTION;
int id, saddr;
char name[65], description[65];
-/* $Header$
+/* $Id$
*
* This generates the files necessary to load an nfs server.
*
- * (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <moira.h>
#include <moira_site.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
#define min(x, y) ((x) < (y) ? (x) : (y))
char *whoami = "nfs.gen";
char *db = "moira/moira";
-char *strsave();
char nfs_dir[64];
struct hash *users, *groups;
+int do_nfs(void);
+int do_lists(struct save_queue *lists);
+void do_everyone(void);
+int do_machs(struct save_queue *machs);
int main(int argc, char **argv)
{
EXEC SQL FETCH s_cursor INTO :machname, :listname;
if (sqlca.sqlcode)
break;
- sq_save_unique_string(machs, strsave(strtrim(machname)));
- sq_save_unique_string(lists, strsave(strtrim(listname)));
+ sq_save_unique_string(machs, strdup(strtrim(machname)));
+ sq_save_unique_string(lists, strdup(strtrim(listname)));
}
EXEC SQL CLOSE s_cursor;
int do_lists(struct save_queue *lists)
{
char file[64], *u;
- struct stat sb;
FILE *fd;
EXEC SQL BEGIN DECLARE SECTION;
- char *listname, *lsname, lname[33], uname[9];
- int uid, id, flag1, flag2, flag3, flag4;
+ char *listname;
+ int id;
EXEC SQL END DECLARE SECTION;
sprintf(file, "%s/list-", nfs_dir);
};
-do_everyone(void)
+void do_everyone(void)
{
char buf[BUFSIZ], *l;
struct user *u;
struct bucket *b, **p;
EXEC SQL BEGIN DECLARE SECTION;
char name[33];
- int gid, id, lid, maxid, uid;
+ int gid, id, lid, uid;
EXEC SQL END DECLARE SECTION;
FILE *fd;
- int i;
- struct save_queue *sq;
fprintf(stderr, "Building the list of everybody\n");
sprintf(buf, "%s/list-", nfs_dir);
if (sqlca.sqlcode)
break;
sprintf(buf, ":%d", gid);
- hash_store(groups, lid, strsave(buf));
+ hash_store(groups, lid, strdup(buf));
}
EXEC SQL CLOSE l_cursor;
EXEC SQL FETCH m_cursor2 INTO :lid, :id;
if (sqlca.sqlcode)
break;
- if ((u = (struct user *) hash_lookup(users, id)) &&
- (l = hash_lookup(groups, lid)))
+ if ((u = hash_lookup(users, id)) && (l = hash_lookup(groups, lid)))
{
g = malloc(sizeof(struct grp));
g->next = u->lists;
sprintf(buf, "%s:%d", u->name, u->uid);
for (g = u->lists; g; g = g->next)
strcat(buf, g->lid);
- b->data = strsave(buf);
+ b->data = strdup(buf);
fprintf(fd, "%s\n", buf);
}
}
fclose(fd);
- return 1;
sqlerr:
db_error(sqlca.sqlcode);
exit(MR_DBMS_ERR);
{
EXEC SQL BEGIN DECLARE SECTION;
char *machname, listname[33], dev[33], dir[81], fstype[9];
- int uid, quota, id, gid, flag1, flag2, flag3, flag4;
+ int uid, quota, id, gid, flag1, flag2, flag3;
EXEC SQL END DECLARE SECTION;
char file[64], f1[64], f2[64], *cp;
int prevuid, quotasum, olddev, oldmach;
fclose(fd);
olddev = flag1;
oldmach = flag2;
- while (cp = strchr(dev, '/'))
+ while ((cp = strchr(dev, '/')))
*cp = '@';
sprintf(file, "%s/%s.%s.quotas", nfs_dir,
- hash_lookup(machines, flag2), strtrim(dev));
+ (char *)hash_lookup(machines, flag2), strtrim(dev));
fd = fopen(file, "w");
if (!fd)
{
fclose(fd);
olddev = flag1;
oldmach = flag2;
- while (cp = strchr(dev, '/'))
+ while ((cp = strchr(dev, '/')))
*cp = '@';
sprintf(file, "%s/%s.%s.quotas", nfs_dir,
- hash_lookup(machines, flag2), strtrim(dev));
+ (char *)hash_lookup(machines, flag2), strtrim(dev));
fd = fopen(file, "w");
if (!fd)
{
}
if (gid != prevuid)
{
- if (cp = hash_lookup(groups, prevuid))
+ if ((cp = hash_lookup(groups, prevuid)))
prevuid = atoi(cp + 1);
if (quotasum)
fprintf(fd, "%d %d\n", prevuid, quotasum);
fclose(fd);
olddev = flag1;
oldmach = flag2;
- while (cp = strchr(dev, '/'))
+ while ((cp = strchr(dev, '/')))
*cp = '@';
sprintf(file, "%s/%s.%s.dirs", nfs_dir,
- hash_lookup(machines, flag2), strtrim(dev));
+ (char *)hash_lookup(machines, flag2), strtrim(dev));
fd = fopen(file, "w");
if (!fd)
{
-/* $Header$
+/* $Id$
*
* This generates a master /etc/passwd containing all active (status != 0)
* accounts.
*
- * (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
#include <moira.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
char *whoami = "passwd.gen";
char *db = "moira/moira";
-/* $Header$
+/* $Id $
*
* This generates a list of everyone's poboxes for the mitdir.
*
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
#include <moira.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
+#include <sys/types.h>
+
#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
char *whoami = "pobox.gen";
char *db = "moira/moira";
-/* $Header$
+/* $Id$
*
* Utility routines used by the MOIRA extraction programs.
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-
#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/time.h>
#include <moira.h>
#include <moira_site.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "util.h"
+
+RCSID("$Header$");
+
extern void sqlglm(char buf[], int *, int *);
-fix_file(char *targetfile)
+void fix_file(char *targetfile)
{
char oldfile[64], filename[64];
}
-db_error(int code)
+void db_error(int code)
{
extern char *whoami;
char buf[256];
--- /dev/null
+void fix_file(char *targetfile);
+char *dequote(char *s);
+void db_error(int code);
+
+int ModDiff(int *flag, char *tbl, time_t ModTime);
-/* $Header$
+/* $Id$
*
* This generates a database extract from the users table for the MIT
* Warehouse.
*
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1996-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
#include <moira.h>
#include <moira_site.h>
-#include <des.h>
-#include <krb.h>
-#include <gdss.h>
-#include <sys/types.h>
+
#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#include <string.h>
-#include <ctype.h>
+#include <sys/types.h>
+
#include <fcntl.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
+
+#include <krb.h>
+#include <gdss.h>
+
+#include "util.h"
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
char *whoami = "warehouse.gen";
char *db = "moira/moira";
struct stat sb;
int flag1;
SigInfo si;
- struct timeval now;
int records = 0;
EXEC SQL BEGIN DECLARE SECTION;
char login[9], sig[257], id[17], kname[257];
#include <sys/types.h>
#include <sys/time.h>
+#include <stdio.h>
+
#ifndef TRUE
#define TRUE 1
#endif
-/* $Header$ */
-/*
+/* $Id$
-Copyright 1987, 1988 by the Massachusetts Institute of Technology
+Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
*
*/
/* return values from queries (and error codes) */
+#include <com_err.h>
#include "mr_et.h"
+#include "krb_et.h"
+#include "gdss_et.h"
+#include "ureg_err.h"
#define MR_SUCCESS 0 /* Query was successful */
#define MR_VERSION_1 1 /* Version in use from 7/87 to 4/88 */
/* Structure used by Save Queue routines (for temporary storage of data) */
struct save_queue
{
- struct save_queue *q_next;
- struct save_queue *q_prev;
- struct save_queue *q_lastget;
- char *q_data;
+ struct save_queue *q_next;
+ struct save_queue *q_prev;
+ struct save_queue *q_lastget;
+ void *q_data;
};
/* Hash table declarations */
struct bucket {
- struct bucket *next;
- int key;
- char *data;
+ struct bucket *next;
+ int key;
+ void *data;
};
struct hash {
- int size;
- struct bucket **data;
+ int size;
+ struct bucket **data;
};
-#ifdef __STDC__
+/* prototypes from critical.c */
+void critical_alert(char *instance, char *msg, ...);
+void send_zgram(char *inst, char *msg);
+
+/* prototypes from fixhost.c */
+char *canonicalize_hostname(char *s);
+
+/* prototypes from fixname.c */
+void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle);
+void FixCase(char *p);
+void LookForJrAndIII(char *nm, int *pends_jr, int *pends_sr,
+ int *pends_ii, int *pends_iii,
+ int *pends_iv, int *pends_v);
+void LookForSt(char *nm);
+void LookForO(char *nm);
+void TrimTrailingSpace(char *ip);
+void GetMidInit(char *nm, char *mi);
+
+/* prototypes from gdss_convert.c */
+int gdss2et(int code);
+
+/* prototypes from hash.c */
+struct hash *create_hash(int size);
+void *hash_lookup(struct hash *h, int key);
+int hash_update(struct hash *h, int key, void *value);
+int hash_store(struct hash *h, int key, void *value);
+void hash_search(struct hash *h, void *value, void (*callback)(int));
+void hash_step(struct hash *h, void (*callback)(int, void *, void *),
+ void *hint);
+void hash_destroy(struct hash *h);
+
+/* prototypes from idno.c */
+void RemoveHyphens(char *str);
+void EncryptID(char *sbuf, char *idnumber, char *first, char *last);
+
+/* prototypes from kname_unparse.c */
+char *kname_unparse(char *p, char *i, char *r);
+
+/* prototypes from nfsparttype.c */
+char *parse_filesys_type(char *fs_type_name);
+char *format_filesys_type(char *fs_status);
+
+/* prototypes from sq.c */
+struct save_queue *sq_create(void);
+int sq_save_data(struct save_queue *sq, void *data);
+int sq_save_args(int argc, char *argv[], struct save_queue *sq);
+int sq_save_unique_data(struct save_queue *sq, void *data);
+int sq_save_unique_string(struct save_queue *sq, char *data);
+/* in sq_get_data and sq_remove_data, the `data' arg should be a
+ pointer to a pointer */
+int sq_get_data(struct save_queue *sq, void *data);
+int sq_remove_data(struct save_queue *sq, void *data);
+int sq_empty(struct save_queue *sq);
+void sq_destroy(struct save_queue *sq);
+
+/* prototypes from strs.c */
+char *strtrim(char *s);
+char *uppercase(char *s);
+char *lowercase(char *s);
+
+/* mr_ functions */
+int mr_access(char *handle, int argc, char **argv);
+int mr_auth(char *prog);
int mr_connect(char *server);
-int mr_disconnect();
+int mr_disconnect(void);
+int mr_do_update(void);
int mr_host(char *host, int size);
int mr_motd(char **motd);
-int mr_auth(char *prog);
-int mr_access(char *handle, int argc, char **argv);
-int mr_access_internal(int argc, char **argv);
+int mr_noop(void);
int mr_query(char *handle, int argc, char **argv,
- int (*callback)(), char *callarg);
-int mr_query_internal(int argc, char **argv,
- int (*callback)(), char *callarg);
-int mr_noop();
-struct save_queue *sq_create();
-struct hash *create_hash(int size);
-char *hash_lookup(struct hash *h, int key);
-char *strsave(char *s);
-char *strtrim(char *s);
-char *canonicalize_hostname(char *s);
-#else /* !__STDC__ */
-int mr_connect();
-int mr_disconnect();
-int mr_host();
-int mr_motd();
-int mr_auth();
-int mr_access();
-int mr_query();
-int mr_noop();
-struct save_queue *sq_create();
-struct hash *create_hash();
-char *hash_lookup();
-char *strsave();
-char *strtrim();
-char *canonicalize_hostname();
-#endif /* __STDC__ */
+ int (*callback)(int, char **, void *), void *callarg);
/* error-name backward compatibility */
#define MR_INGRES_ERR MR_DBMS_ERR
#define MR_INGRES_SOFTFAIL MR_DBMS_SOFTFAIL
+
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+#define RCSID(id) static char *rcsid __attribute__ ((__unused__)) = id
+
#endif /* _moira_h_ */ /* Do Not Add Anything after this line. */
-/*
+/* $Id$
+ *
* This file contains all definitions that allow easy access to
* elements returned by most of the @i[Moira] queries. It also defines
* the default server location and the directories used on the server.
* Chris D. Peterson - kit@athena
* 7/27/88
*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright 1988 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution
- * see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For further information on copyright and distribution
+ * see the file <mit-copyright.h>.
*/
#ifndef _moira_site_
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
*
*/
int mr_state;
} mr_params;
-extern int mr_start_recv(), mr_start_send();
+int mr_start_send(OPERATION op, HALF_CONNECTION hcon, struct mr_params *arg);
+int mr_start_recv(OPERATION op, HALF_CONNECTION hcon, struct mr_params **argp);
+void mr_destroy_reply(mr_params *reply);
-/*
- * Update mechanism description structure.
- */
-struct update_desc {
- int last_time; /* when did we try last? */
- int success; /* did it succeed? */
- int interval; /* interval in minutes between updates */
- char *service_name;
- char *host_name;
- char *target_path; /* where to put the file */
- int override; /* override interval */
- int enable; /* can we update at all? */
- char *instructions; /* script pathname */
-};
-
#define log_DEBUG 0
#define log_INFO 1
#define log_WARNING 2
#define SERVICE_NAME "moira_update"
#define UPDATE_BUFSIZ BUFSIZ
+
+int send_file(char *pathname, char *target_path, int encrypt);
+int send_auth(char *hostname);
+int execute(char *path);
+void send_quit(void);
+
+#include <krb.h>
+int get_mr_update_ticket(char *host, KTEXT ticket);
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
*
*/
#define UREG_GET_SECURE 5
#define UREG_SET_SECURE 6
-typedef u_long U_32BIT;
+typedef unsigned long U_32BIT;
+
+#ifndef REG_SVR
+/* (client) prototypes from reg_stubs.c */
+int ureg_init(void);
+int verify_user(char *first, char *last, char *idnumber,
+ char *hashidnumber, char *login);
+int grab_login(char *first, char *last, char *idnumber, char *hashidnumber,
+ char *login);
+int enroll_login(char *first, char *last, char *idnumber, char *hashidnumber,
+ char *login);
+int set_password(char *first, char *last, char *idnumber, char *hashidnumber,
+ char *password);
+int get_krb(char *first, char *last, char *idnumber, char *hashidnumber,
+ char *password);
+#endif
#include <stdio.h>
#include <stdlib.h>
+#include <sys/resource.h>
#include <sys/types.h>
+#include <sys/utsname.h>
#include <sys/file.h>
#include <string.h>
#include <unistd.h>
+#include <com_err.h>
#include <krb.h>
#include <moira.h>
#include <moira_site.h>
char *whoami;
/* Main stub routines */
-int do_user();
-int do_list();
-int do_member();
-int do_filesys();
-int do_quota();
+void do_user(char **before, int beforec, char **after, int afterc);
+void do_list(char **before, int beforec, char **after, int afterc);
+void do_member(char **before, int beforec, char **after, int afterc);
+void do_filesys(char **before, int beforec, char **after, int afterc);
+void do_quota(char **before, int beforec, char **after, int afterc);
/* Support stub routines */
-int run_cmd();
-int add_user_lists();
-int add_list_members();
-int check_user();
-int edit_group();
+void run_cmd(char *cmd);
+int add_user_lists(int ac, char **av, void *user);
+int add_list_members(int ac, char **av, void *group);
+int check_user(int ac, char **av, void *ustate);
+void edit_group(int op, char *group, char *type, char *member);
long pr_try();
-int check_afs();
+void check_afs(void);
+int moira_connect(void);
+int moira_disconnect(void);
/* libprot.a routines */
extern long pr_Initialize();
{
int beforec, afterc, i;
char *table, **before, **after;
+ struct rlimit rl;
- for (i = getdtablesize() - 1; i > 2; i--)
+ getrlimit(RLIMIT_NOFILE, &rl);
+ for (i = rl.rlim_cur; i > 2; i--)
close(i);
whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]);
}
-do_user(char **before, int beforec, char **after, int afterc)
+void do_user(char **before, int beforec, char **after, int afterc)
{
int astate, bstate, auid, buid, code;
char *av[2];
}
-do_list(char **before, int beforec, char **after, int afterc)
+void do_list(char **before, int beforec, char **after, int afterc)
{
int agid, bgid;
int ahide, bhide;
#define LM_EXTRA_GID (LM_END+5)
#define LM_EXTRA_END (LM_END+6)
-do_member(char **before, int beforec, char **after, int afterc)
+void do_member(char **before, int beforec, char **after, int afterc)
{
- int code;
- char *p;
-
if (afterc)
{
if (afterc < LM_EXTRA_END)
}
-do_filesys(char **before, int beforec, char **after, int afterc)
+void do_filesys(char **before, int beforec, char **after, int afterc)
{
char cmd[1024];
int acreate, atype, bcreate, btype;
}
-do_quota(char **before, int beforec, char **after, int afterc)
+void do_quota(char **before, int beforec, char **after, int afterc)
{
char cmd[1024];
}
-run_cmd(char *cmd)
+void run_cmd(char *cmd)
{
int success=0, tries=0;
}
-int add_user_lists(int ac, char *av[], char *user)
+int add_user_lists(int ac, char **av, void *user)
{
if (atoi(av[L_ACTIVE]) && atoi(av[L_GROUP])) /* active group ? */
edit_group(1, av[L_NAME], "USER", user);
}
-int add_list_members(int ac, char *av[], char *group)
+int add_list_members(int ac, char **av, void *group)
{
edit_group(1, group, av[0], av[1]);
return 0;
}
-int check_user(int ac, char *av[], int *ustate)
+int check_user(int ac, char **av, void *ustate)
{
- *ustate = atoi(av[U_STATE]);
+ *(int *)ustate = atoi(av[U_STATE]);
return 0;
}
-edit_group(int op, char *group, char *type, char *member)
+void edit_group(int op, char *group, char *type, char *member)
{
char *p = 0;
char buf[PR_MAXNAMELEN];
{
critical_alert("incremental", "Couldn't initialize libprot: %s",
error_message(code));
- return;
+ return code;
}
sleep(1); /* give ptserver room */
- while (code = (*fn)(a1, a2, a3, a4, a5, a6, a7, a8))
+ while ((code = (*fn)(a1, a2, a3, a4, a5, a6, a7, a8)))
{
if (++tries > 2)
break; /* 3 tries */
}
-check_afs(void)
+void check_afs(void)
{
int i;
int moira_connect(void)
{
- static char hostname[64];
long code;
if (!mr_connections++)
{
- gethostname(hostname, sizeof(hostname));
- code = mr_connect(hostname);
+ struct utsname uts;
+ uname(&uts);
+ code = mr_connect(uts.nodename);
if (!code)
code = mr_auth("afs.incr");
return code;
if (!--mr_connections)
{
mr_disconnect();
- while (m = member_head)
+ while ((m = member_head))
{
edit_group(m->op, m->list, m->type, m->member);
member_head = m->next;
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/param.h>
#include <krb.h>
/*#include <conf.h>*/
char rcsid[] =
"$Header$";
-
-void usage(char **argv)
-{
- fprintf(stderr,
- "Usage: %s name instance [-r realm] [-s srvtab] [-l lifetime]\n",
- argv[0]);
- exit(1);
-}
-
+void usage(char **argv);
int main(int argc, char **argv)
{
exit(code);
}
+void usage(char **argv)
+{
+ fprintf(stderr,
+ "Usage: %s name instance [-r realm] [-s srvtab] [-l lifetime]\n",
+ argv[0]);
+ exit(1);
+}
-/* $Header$
+/* $Id $
*
* Log and send a zephyrgram about any critical errors.
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <moira_site.h>
+
#ifdef ZEPHYR
+/* need to include before moira.h, which includes krb_et.h, because
+ zephyr.h is broken */
#include <zephyr/zephyr.h>
+/* zephyr.h doesn't prototype this */
+extern Code_t ZSendNotice(ZNotice_t *notice, Z_AuthProc cert_routine);
#endif
+
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <string.h>
#ifdef SYSLOG
#include <syslog.h>
#endif
-#include <string.h>
-#include <time.h>
-#include <com_err.h>
+
+RCSID("$Header$");
/* mode to create the file with */
#define LOGFILEMODE 0644
extern char *whoami;
-
/* This routine sends a class MOIRA zephyrgram of specified instance
* and logs to a special logfile the message passed to it via msg
* and args in printf format. *** It expects the global variable
* whoami to be defined and contain the name of the calling program.
- * It's a kludge that it takes a max of 8 arguments in a way that
- * isn't necessarily portable, but varargs doesn't work here and we
- * don't necessarily have vsprintf().
*/
-void critical_alert(char *instance, char *msg, char *arg1, char *arg2,
- char *arg3, char *arg4, char *arg5, char *arg6,
- char *arg7, char *arg8)
+void critical_alert(char *instance, char *msg, ...)
{
FILE *crit; /* FILE for critical log file */
char buf[BUFSIZ]; /* Holds the formatted message */
+ va_list ap;
- sprintf(buf, msg, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ va_start(ap, msg);
+ vsprintf(buf, msg, ap);
+ va_end(ap);
/* Send zephyr notice */
send_zgram(instance, buf);
time_s = ctime(&t) + 4;
time_s[strlen(time_s) - 6] = '\0';
- fprintf(crit, "%s <%d> %s\n", time_s, getpid(), buf);
+ fprintf(crit, "%s <%ld> %s\n", time_s, (long)getpid(), buf);
fclose(crit);
}
* errors while sending message.
*/
-send_zgram(char *inst, char *msg)
+void send_zgram(char *inst, char *msg)
{
#ifdef ZEPHYR
ZNotice_t znotice;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
+ *
+ * Canonicalize a hostname
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_fixhost_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
+
#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>
+#include <sys/utsname.h>
+
#include <netdb.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/utsname.h>
#include <string.h>
-#include <ctype.h>
-#include <moira.h>
+
+RCSID("$Header$");
/*
* Canonicalize hostname:
strcpy(tbuf, host + 1);
free(host);
tbuf[strlen(tbuf) - 1] = '\0';
- return strsave(tbuf);
+ return strdup(tbuf);
}
if (strchr(host, '*') || strchr(host, '?') || strchr(host, '['))
hp = gethostbyname(name.nodename);
cp = strchr(hp->h_name, '.');
if (cp)
- domain = strsave(++cp);
+ domain = strdup(++cp);
else
domain = "";
}
sprintf(tbuf, "%s.%s", host, domain);
free(host);
- host = strsave(tbuf);
+ host = strdup(tbuf);
}
return host;
}
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Put a name into Moira-canonical form
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_fixname_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
+
#include <ctype.h>
+#include <string.h>
+
+RCSID("$Header$");
#define LAST_LEN 100
#define FIRST_LEN 100
void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle)
{
- int ends_jr = 0, ends_iii = 0, ends_iv = 0, ends_ii = 0, ends_v = 0;
+ int ends_jr = 0, ends_sr = 0;
+ int ends_iii = 0, ends_iv = 0, ends_ii = 0, ends_v = 0;
uppercase(ilnm);
uppercase(ifnm);
/* Last name ... */
TrimTrailingSpace(ilnm);
- LookForJrAndIII(ilnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v);
+ LookForJrAndIII(ilnm, &ends_jr, &ends_sr,
+ &ends_ii, &ends_iii, &ends_iv, &ends_v);
LookForSt(ilnm);
LookForO(ilnm);
FixCase(ilnm);
/* First name & middle initial ... */
TrimTrailingSpace(ifnm);
- LookForJrAndIII(ifnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v);
+ LookForJrAndIII(ifnm, &ends_jr, &ends_sr,
+ &ends_ii, &ends_iii, &ends_iv, &ends_v);
GetMidInit(ifnm, middle);
FixCase(ifnm);
-#ifdef notdef
- /* okay, finish up first name */
- AppendJrOrIII(ifnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v);
-#endif
strncpy(first, ifnm, FIRST_LEN);
}
-FixCase(char *p)
+void FixCase(char *p)
{
int cflag; /* convert to lcase, unless at start or following */
/* a space or punctuation mark (e.g., '-') */
}
}
-LookForJrAndIII(char *nm, int *pends_jr, int *pends_ii, int *pends_iii,
- int *pends_iv, int *pends_v)
+void LookForJrAndIII(char *nm, int *pends_jr, int *pends_sr, int *pends_ii,
+ int *pends_iii, int *pends_iv, int *pends_v)
{
int len = strlen(nm);
*pends_jr = 1;
nm[len - 3] = '\0';
}
+ else if (len >= 4 && !strcmp(nm + len - 3, " SR"))
+ {
+ *pends_sr = 1;
+ nm[len - 3] = '\0';
+ }
else if (len >= 4 && !strcmp(nm + len - 3, " IV"))
{
*pends_iv = 1;
}
}
-LookForSt(char *nm) /* ST PIERRE, etc. */
+void LookForSt(char *nm) /* ST PIERRE, etc. */
{
char temp[256];
}
}
-LookForO(char *nm) /* O BRIEN, etc. */
+void LookForO(char *nm) /* O BRIEN, etc. */
{
if (!strcmp(nm, "O ") && isalpha(nm[2]))
nm[1] = '\'';
}
-TrimTrailingSpace(char *ip)
+void TrimTrailingSpace(char *ip)
{
char *p;
for (p = ip + strlen(ip) - 1; p >= ip && isspace(*p); p--)
*p = '\0';
}
-GetMidInit(char *nm, char *mi)
+void GetMidInit(char *nm, char *mi)
{
while (*nm && !isspace(*nm))
nm++;
-/* $Header$
+/* $Id $
*
* Convert from GDSS error codes to com_err error codes
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
+#include <mit-copyright.h>
+#include <moira.h>
+
#include <gdss_et.h>
+RCSID("$Header$");
+
int gdss2et(int code)
{
if (code == 0)
-/* $Header$
+/* $Id $
*
* Generic hash table routines. Uses integer keys to store char * values.
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <ctype.h>
#include <moira.h>
-#include <string.h>
+
#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
-#ifndef NULL
-#define NULL 0
-#endif
#define hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
/* Create a hash table. The size is just a hint, not a maximum. */
if (!h)
return NULL;
h->size = size;
- h->data = malloc(size * sizeof(char *));
+ h->data = malloc(size * sizeof(void *));
if (!h->data)
{
free(h);
return NULL;
}
- memset(h->data, 0, size * sizeof(char *));
+ memset(h->data, 0, size * sizeof(void *));
return h;
}
* the key, or NULL (thus NULL is not a very good value to store...)
*/
-char *hash_lookup(struct hash *h, int key)
+void *hash_lookup(struct hash *h, int key)
{
struct bucket *b;
* existed, or 0 if not.
*/
-int hash_update(struct hash *h, int key, char *value)
+int hash_update(struct hash *h, int key, void *value)
{
struct bucket *b;
* there, 1 if it was, or -1 if we ran out of memory.
*/
-int hash_store(struct hash *h, int key, char *value)
+int hash_store(struct hash *h, int key, void *value)
{
struct bucket *b, **p;
* data with that value, call the callback proc with the corresponding key.
*/
-hash_search(struct hash *h, char *value, void (*callback)())
+void hash_search(struct hash *h, void *value, void (*callback)(int))
{
struct bucket *b, **p;
/* Step through the hash table, calling the callback proc with each key.
*/
-hash_step(struct hash *h, void (*callback)(), char *hint)
+void hash_step(struct hash *h, void (*callback)(int, void *, void *),
+ void *hint)
{
struct bucket *b, **p;
/* Deallocate all of the memory associated with a table */
-hash_destroy(struct hash *h)
+void hash_destroy(struct hash *h)
{
struct bucket *b, **p, *b1;
-/* $Header$
+/* $Id $
*
- * Routines to encrypt ID's
+ * Routines to deal with MIT IDs
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
+
#include <ctype.h>
-#include <unistd.h>
+#include <string.h>
+
#ifdef USE_CRYPT_H
#include <crypt.h>
+#else
+#include <unistd.h>
#endif
/* Function Name: RemoveHyphens
-/* $Header$
+/* $Id $
*
* Don't know why this function is not in libkrb.a. It's the inverse
* of kname_parse() which is there.
+ *
+ * Copyright (C) 1993-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
+#include <mit-copyright.h>
+#include <moira.h>
+
#include <stdio.h>
+
#include <des.h>
#include <krb.h>
+RCSID("$Header$");
+
/* Turn a principal, instance, realm triple into a single non-ambiguous
* string. This is the inverse of kname_parse(). It returns a pointer
* to a static buffer, or NULL on error.
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
+ *
+ * Check access to a Moira query
*
- * Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_access_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
#include "mr_private.h"
-#include <string.h>
+
#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+int mr_access_internal(int argc, char **argv);
/*
* Check access to a named query.
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Handles the client side of the sending of authenticators to the moira server
*
- * Handles the client side of the sending of authenticators to
- * the mr server.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_auth_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
#include "mr_private.h"
+
#include <ctype.h>
-#include <krb.h>
-#include <krb_et.h>
#include <string.h>
+#include <krb.h>
+extern char *krb_realmofhost(char *);
+extern int krb_mk_req(KTEXT, char *, char *, char *, int);
+
+RCSID("$Header$");
+
/* Authenticate this client with the Moira server. prog is the name of the
* client program, and will be recorded in the database.
*/
char *args[2];
int argl[2];
char realm[REALM_SZ], host[BUFSIZ], *p;
-
mr_params *params = ¶ms_st;
mr_params *reply = NULL;
KTEXT_ST auth;
if ((status = mr_host(host, sizeof(host) - 1)))
return status;
- strcpy(realm, (char *)krb_realmofhost(host));
+ strcpy(realm, krb_realmofhost(host));
for (p = host; *p && *p != '.'; p++)
{
if (isupper(*p))
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Pass an mr_params off to the Moira server and get a reply
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_call_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
#include "mr_private.h"
+RCSID("$Header$");
+
int mr_do_call(struct mr_params *params, struct mr_params **reply)
{
CHECK_CONNECTED;
queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
/* Block until operation done. */
- mr_complete_operation(_mr_send_op);
- mr_complete_operation(_mr_recv_op);
+ complete_operation(_mr_send_op);
+ complete_operation(_mr_recv_op);
/* Look at results */
if ((OP_STATUS(_mr_send_op) != OP_COMPLETE) ||
(OP_STATUS(_mr_recv_op) != OP_COMPLETE))
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * This routine is part of the client library. It handles
+ * creating a connection to the moira server.
*
- * This routine is part of the client library. It handles
- * creating a connection to the mr server.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_connect_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include "mr_private.h"
+#include <moira.h>
#include <moira_site.h>
-#include <string.h>
+#include "mr_private.h"
+
+#include <errno.h>
#include <stdlib.h>
+#include <string.h>
+
#include <hesiod.h>
+RCSID("$Header$");
+
static char *mr_server_host = 0;
/*
int mr_connect(char *server)
{
- extern int errno;
char *p, **pp, sbuf[256];
if (!mr_inited)
* stash hostname for later use
*/
- mr_server_host = strsave(server);
+ mr_server_host = strdup(server);
if ((p = strchr(mr_server_host, ':')))
*p = '\0';
mr_server_host = canonicalize_hostname(mr_server_host);
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * A few variables
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_data_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
#include "mr_private.h"
+RCSID("$Header$");
+
CONNECTION _mr_conn;
OPERATION _mr_send_op, _mr_recv_op;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Initialize libmoira
+ *
+ * Copyright (C) 1987-1990 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_init_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
#include "mr_private.h"
+RCSID("$Header$");
+
int mr_inited = 0;
/* the reference to link_against_the_moira_version_of_gdb is to make
* sure that this is built with the proper libraries.
*/
-mr_init(void)
+void mr_init(void)
{
extern int link_against_the_moira_version_of_gdb;
if (mr_inited)
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987, 1989, 1990 by the Massachusetts Institute of
- * Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * This routine is part of the client library. It handles
+ * the protocol operations: invoking an update and getting the
+ * Moira message of the day.
*
- * This routine is part of the client library. It handles
- * the protocol operations: invoking an update and getting the
- * Moira message of the day.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_do_update_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
#include "mr_private.h"
+#include <string.h>
+
+RCSID("$Header$");
/* Invoke a DCM update. */
initialize_operation(_mr_recv_op, mr_start_recv, &reply, NULL);
queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
- mr_complete_operation(_mr_recv_op);
+ complete_operation(_mr_recv_op);
if (OP_STATUS(_mr_recv_op) != OP_COMPLETE)
{
mr_disconnect();
else
return status;
}
-
-
-/* Tell the library to take care of another input source while it is
- * processing a query. For instance, an X toolkit application would
- * do something like
- * mr_set_alternate_input(ConnectionNumber(XtDisplay(widget)), doxinput);
- * where doxinput is defined as:
- * doxinput() {
- * extern Widget toplevel;
- * XEvent event;
- * while (XPending(XtDisplay(toplevel))) {
- * XNextEvent(XtDisplay(toplevel), &event);
- * XtDispatchEvent(&event);
- * }
- * XFlush(XtDisplay(toplevel));
- * }
- */
-
-static int mr_alternate_input = 0;
-static int (*mr_alternate_handler)();
-
-int mr_set_alternate_input(int fd, int (*proc)())
-{
- if (mr_alternate_input != 0)
- return MR_ALREADY_CONNECTED;
- mr_alternate_input = fd;
- mr_alternate_handler = proc;
- return MR_SUCCESS;
-}
-
-
-/* This is used by the parts of the library that must wait for GDB. It
- * handles alternate input streams (such as X) as well.
- */
-
-int mr_complete_operation(OPERATION op)
-{
- long infd, outfd, exfd;
- int rc;
-
- gdb_progress(); /* try for an immediate completion */
-
- if (mr_alternate_input == 0)
- return complete_operation(op);
-
- infd = 1 << mr_alternate_input;
- outfd = exfd = 0;
-
- while (op->status != OP_COMPLETE && op->status != OP_CANCELLED)
- {
- rc = con_select(mr_alternate_input, (fd_set *)&infd, (fd_set *)&outfd,
- (fd_set *)&exfd, NULL);
- if (rc > 0 && mr_alternate_handler)
- (*mr_alternate_handler)();
- }
- return op->status;
-}
-
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
+ *
+ * Deal with mrgdb (bleah!)
*
- * Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_mr_param_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
+#include "mr_private.h"
+
#include <sys/types.h>
#include <netinet/in.h>
-#include "mr_private.h"
-#include <string.h>
+
#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
/*
* GDB operations to send and recieve RPC requests and replies.
return mr_cont_recv(op, hcon, argp);
}
-mr_destroy_reply(mr_params *reply)
+void mr_destroy_reply(mr_params *reply)
{
int i;
if (reply)
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Private declarations of the Moira library.
*
- * Private declarations of the Moira library.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include "mr_proto.h"
#define EVER (;;)
#define CHECK_CONNECTED {if (!_mr_conn) return MR_NOT_CONNECTED;}
+
+/* prototypes from mr_call.h */
+int mr_do_call(struct mr_params *params, struct mr_params **reply);
+
+/* prototypes from mr_init.c */
+void mr_init(void);
+
+/* prototypes from mr_ops.c */
+int mr_complete_operation(OPERATION op);
+
+/* prototypes from mr_params.c */
+int mr_cont_send(OPERATION op, HALF_CONNECTION hcon, struct mr_params *arg);
+int mr_cont_recv(OPERATION op, HALF_CONNECTION hcon, mr_params **argp);
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
+ *
+ * Perform a Moira query
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_mr_query_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
+#include <moira.h>
#include "mr_private.h"
-#include <string.h>
+
#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+int mr_query_internal(int argc, char **argv,
+ int (*callback)(int, char **, void *), void *callarg);
/*
* This routine is the primary external interface to the mr library.
static int level = 0;
int mr_query(char *name, int argc, char **argv,
- int (*callproc)(), char *callarg)
+ int (*callproc)(int, char **, void *), void *callarg)
{
char **nargv = malloc(sizeof(char *) * (argc + 1));
int status = 0;
* way to send it a quench..)
*/
-int mr_query_internal(int argc, char **argv, int (*callproc)(), char *callarg)
+int mr_query_internal(int argc, char **argv,
+ int (*callproc)(int, char **, void *), void *callarg)
{
int status;
mr_params params_st;
while ((status = reply->mr_status) == MR_MORE_DATA)
{
- if (!stopcallbacks)
+ if (!stopcallbacks && callproc)
stopcallbacks = (*callproc)(reply->mr_argc, reply->mr_argv, callarg);
mr_destroy_reply(reply);
reply = NULL;
initialize_operation(_mr_recv_op, mr_start_recv, &reply, NULL);
queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
- mr_complete_operation(_mr_recv_op);
+ complete_operation(_mr_recv_op);
if (OP_STATUS(_mr_recv_op) != OP_COMPLETE)
{
mr_disconnect();
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
+ *
+ * Deal with NFS partition types
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_nfsparttype_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
#include <moira.h>
+
#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
-extern char *strsave();
-extern char *strtrim();
+RCSID("$Header$");
struct pair {
int type;
}
if (!n_names)
strcpy(buf, "none");
- return strsave(buf);
+ return strdup(buf);
}
/*
}
while (cp);
sprintf(temp, "%d", flags);
- return strsave(temp);
+ return strdup(temp);
}
-/* $Header$
+/* $Id $
*
* Generic Queue Routines
*
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
#include <moira.h>
-#include <string.h>
+
#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
struct save_queue *sq_create(void)
{
return sq;
}
-int sq_save_data(struct save_queue *sq, char *data)
+int sq_save_data(struct save_queue *sq, void *data)
{
struct save_queue *q;
memcpy(argv_copy[i], argv[i], n);
}
- return sq_save_data(sq, (char *)argv_copy);
+ return sq_save_data(sq, argv_copy);
}
-int sq_save_unique_data(struct save_queue *sq, char *data)
+int sq_save_unique_data(struct save_queue *sq, void *data)
{
struct save_queue *q;
return sq_save_data(sq, data);
}
-int sq_get_data(struct save_queue *sq, char **data)
+/* in sq_get_data and sq_remove_data, `data' is actually a pointer to the
+ variable to put the data in to. */
+
+int sq_get_data(struct save_queue *sq, void *data)
{
- if (sq->q_lastget == (struct save_queue *)0)
+ void **dptr = data;
+
+ if (sq->q_lastget == NULL)
sq->q_lastget = sq->q_next;
else
sq->q_lastget = sq->q_lastget->q_next;
if (sq->q_lastget == sq)
return 0;
- *data = sq->q_lastget->q_data;
+ *dptr = sq->q_lastget->q_data;
return 1;
}
-int sq_remove_data(struct save_queue *sq, char **data)
+int sq_remove_data(struct save_queue *sq, void *data)
{
+ void **dptr = data;
+
if (sq->q_next != sq)
{
- *data = sq->q_next->q_data;
+ *dptr = sq->q_next->q_data;
sq->q_next = sq->q_next->q_next;
free(sq->q_next->q_prev);
sq->q_next->q_prev = sq;
return 0;
}
-sq_destroy(struct save_queue *sq)
+void sq_destroy(struct save_queue *sq)
{
struct save_queue *q;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Miscellaneous string functions.
*
- * Miscellaneous string functions.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_strs_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+#include <moira.h>
-/*
- * Random string functions which should be in the C library..
- */
+#include <ctype.h>
-/*
- * Make a copy of a string.
- */
-char *strsave(char *s)
-{
- int len;
- char *p;
- /* Kludge for sloppy string semantics */
- if (!s)
- {
- p = malloc(1);
- *p = '\0';
- return p;
- }
- len = strlen(s) + 1;
- p = malloc(len);
- if (p)
- memcpy(p, s, len);
- return p;
-}
+RCSID("$Header$");
/*
* Trim whitespace off both ends of a string.
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Server for user registration with Moira and Kerberos.
*
- * Server for user registration with Moira and Kerberos.
+ * This program is a client of the Kerberos admin_server and a
+ * server for the userreg program. It is not a client of the
+ * Moira server as it is linked with libmoiraglue which bypasses
+ * the network protocol.
*
- * This program is a client of the Kerberos admin_server and a
- * server for the userreg program. It is not a client of the
- * Moira server as it is linked with libmoiraglue which bypasses
- * the network protocol.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_reg_svr_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/utsname.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <krb.h>
+#include <time.h>
+
#include <des.h>
#include <kadm.h>
#include <kadm_err.h>
-#include <krb_err.h>
-#include <errno.h>
-#include <com_err.h>
-#include "moira.h"
-#include "moira_site.h"
+#include <krb.h>
+
#include "reg_svr.h"
+RCSID("$Header$");
+
extern char admin_errmsg[];
-void reg_com_err_hook();
+int parse_encrypted(struct msg *message, struct db_data *data);
+int parse_encrypted(struct msg *message, struct db_data *data);
+int db_callproc(int argc, char **argv, void *queue);
+int find_user(struct msg *message);
+int verify_user(struct msg *message, char *retval);
+int ureg_kadm_init(void);
+int reserve_krb(char *login);
+int setpass_krb(char *login, char *password);
+int reserve_user(struct msg *message, char *retval);
+int set_final_status(struct msg *message);
+int set_password(struct msg *message, char *retval);
+int getuserinfo(int argc, char **argv, void *qa);
+int set_identity(struct msg *message, char *retval);
+int get_secure(struct msg *message, char *retval);
+int set_secure(struct msg *message, char *retval);
int main(int argc, char *argv[])
{
int status = SUCCESS; /* Error status */
char retval[BUFSIZ]; /* Buffer to hold return message for client */
- void req_initialize(); /* Initialize request layer */
- void get_request(); /* Get a request */
- void report(); /* Respond to a request */
-
/* Initialize */
whoami = argv[0];
/* Error messages sent one line at a time */
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
- set_com_err_hook(reg_com_err_hook);
/* Initialize com_err error tables */
init_ureg_err_tbl();
des_key_schedule sched; /* En/decryption schedule */
static char decrypt[BUFSIZ]; /* Buffer to hold decrypted information */
long decrypt_len; /* Length of decypted ID information */
- char recrypt[14]; /* Buffer to hold re-encrypted information */
static char hashid[14]; /* Buffer to hold one-way encrypted ID */
char idnumber[BUFSIZ]; /* Buffer to hold plain-text ID */
char *temp; /* A temporary string pointer */
/* This function is called by mr_query after each tuple found. It is
used by find_user to cache information about each user found. */
-int db_callproc(int argc, char **argv, struct save_queue *queue)
+int db_callproc(int argc, char **argv, void*queue)
{
struct db_data *data; /* Structure to store the information in */
int status = SUCCESS; /* Error status */
int find_user(struct msg *message)
{
#define GUBN_ARGS 2 /* Arguements needed by get_user_by_name */
- char *q_name; /* Name of query */
+ char *q_name; /* Name of Moira query */
int q_argc; /* Number of arguments for query */
char *q_argv[GUBN_ARGS]; /* Arguments to query */
int status = SUCCESS; /* Query return status */
queue = sq_create();
/* Do it */
- status = mr_query(q_name, q_argc, q_argv, db_callproc, (char *)queue);
+ status = mr_query(q_name, q_argc, q_argv, db_callproc, queue);
if (status == MR_SUCCESS)
{
{
unsigned int status = SUCCESS; /* Return status */
static char krbrealm[REALM_SZ]; /* kerberos realm name */
- static char hostbuf[BUFSIZ], *host; /* local hostname in principal fmt */
+ static char *host; /* local hostname in principal fmt */
static int inited = 0;
char *p;
+ struct utsname uts;
if (!inited)
{
inited++;
memset(krbrealm, 0, sizeof(krbrealm));
- if (status = krb_get_lrealm(krbrealm, 1))
+ if ((status = krb_get_lrealm(krbrealm, 1)))
{
status += krb_err_base;
com_err(whoami, status, " fetching kerberos realm");
exit(1);
}
- if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
+ if (uname(&uts) < 0)
com_err(whoami, errno, "getting local hostname");
- host = canonicalize_hostname(strsave(hostbuf));
+ host = canonicalize_hostname(strdup(uts.nodename));
for (p = host; *p && *p != '.'; p++)
{
if (isupper(*p))
/* Get keys for interacting with Kerberos admin server. */
/* principal, instance, realm, service, service instance, life, file */
- if (status = krb_get_svc_in_tkt(MOIRA_SNAME, host, krbrealm, PWSERV_NAME,
- KADM_SINST, 1, KEYFILE))
+ if ((status = krb_get_svc_in_tkt(MOIRA_SNAME, host, krbrealm, PWSERV_NAME,
+ KADM_SINST, 1, KEYFILE)))
status += krb_err_base;
if (status != SUCCESS)
return status;
}
-/* This routine is a null callback that should be used for queries that
- do not return tuples. If it ever gets called, something is wrong. */
-int null_callproc(int argc, char *argv[], char *message)
-{
- critical_alert(FAIL_INST, "Something returned from an update query.");
- return FAILURE;
-}
-
/*
* This routine reserves a principal in kerberos by setting up a
* principal with a random initial key.
q_argv[1] = login;
q_argv[2] = fstype_buf;
q_argc = 3;
- status = mr_query(q_name, q_argc, q_argv, null_callproc, NULL);
+ status = mr_query(q_name, q_argc, q_argv, NULL, NULL);
switch (status)
{
case MR_SUCCESS:
q_argc = 2;
q_argv[0] = login;
q_argv[1] = state;
- if ((status = mr_query(q_name, q_argc, q_argv, null_callproc, NULL))
+ if ((status = mr_query(q_name, q_argc, q_argv, NULL, NULL))
!= MR_SUCCESS)
{
if (status == MR_DEADLOCK)
}
-int getuserinfo(int argc, char **argv, char **qargv)
+int getuserinfo(int argc, char **argv, void *qa)
{
+ char **qargv = qa;
int status = SUCCESS;
int i;
}
else
{
- qargv[U_NAME] = strsave(argv[U_NAME]);
+ qargv[U_NAME] = strdup(argv[U_NAME]);
for (i = 1; i < U_MODTIME; i++)
- qargv[i + 1] = strsave(argv[i]);
+ qargv[i + 1] = strdup(argv[i]);
qargv[U_MODTIME + 1] = NULL;
}
return status;
int set_identity(struct msg *message, char *retval)
{
- int q_argc; /* Number of arguments to query */
char *q_argv[U_END]; /* Arguments to Moira query */
- char *q_name; /* Name of Moira query */
int status = SUCCESS; /* General purpose error status */
- char fstype_buf[7]; /* Buffer to hold fs_type, a 16 bit number */
char *login; /* The login name the user wants */
int i; /* A counter */
q_argv[0] = message->db.uid;
status = mr_query("get_user_account_by_uid", 1, q_argv,
- getuserinfo, (char *)q_argv);
+ getuserinfo, q_argv);
if (status != SUCCESS)
{
com_err(whoami, status, " while getting user info");
q_argv[U_STATE + 1] = "7";
q_argv[U_SIGNATURE + 1] = "";
status = mr_query("update_user_account", U_MODTIME + 1, q_argv,
- null_callproc, NULL);
+ NULL, NULL);
switch (status)
{
case MR_SUCCESS:
}
-void reg_com_err_hook(char *whoami, int code, char *fmt, caddr_t pvar)
-{
- if (whoami)
- {
- fputs(whoami, stderr);
- fputs(": ", stderr);
- }
- if (code)
- fputs(error_message(code), stderr);
- if (fmt)
- _doprnt(fmt, pvar, stderr);
- putc('\n', stderr);
- fflush(stderr);
-}
-
-
/* Find out if someone's secure instance password is set.
* Returns UREG_ALREADY_REGISTERED if set, SUCCESS (0) if not.
*/
com_err(whoami, 0, "checking status of secure password for %s",
message->first);
argv[0] = message->first;
- status = mr_query("get_user_account_by_login", 1, argv, getuserinfo,
- (char *)argv);
+ status = mr_query("get_user_account_by_login", 1, argv, getuserinfo, argv);
if (status != SUCCESS)
{
com_err(whoami, status, " while getting user info");
int set_secure(struct msg *message, char *retval)
{
- int status, i;
- char *argv[U_END], hostbuf[256], *bp, *p, buf[512], *passwd, *id;
+ int status;
+ char *argv[U_END], *bp, buf[512], *passwd, *id;
KTEXT_ST creds;
AUTH_DAT auth;
C_Block key;
struct timeval now;
static int inited = 0;
static char *host;
- extern char *krb_get_phost(char *);
+ struct utsname uts;
if (!inited)
{
inited++;
- if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
+ if (uname(&uts) < 0)
com_err(whoami, errno, "getting local hostname");
- host = strsave(krb_get_phost(hostbuf));
+ host = strdup(krb_get_phost(uts.nodename));
}
com_err(whoami, 0, "setting secure passwd for %s", message->first);
argv[0] = message->first;
- status = mr_query("get_user_account_by_login", 1, argv, getuserinfo,
- (char *)argv);
+ status = mr_query("get_user_account_by_login", 1, argv, getuserinfo, argv);
if (status != SUCCESS)
{
com_err(whoami, status, " while getting user info");
argv[0] = message->first;
argv[1] = buf;
gettimeofday(&now, NULL);
- sprintf(buf, "%d", now.tv_sec);
- status = mr_query("update_user_security_status", 2, argv, getuserinfo,
- (char *)argv);
+ sprintf(buf, "%ld", now.tv_sec);
+ status = mr_query("update_user_security_status", 2, argv, getuserinfo, argv);
if (status != SUCCESS)
{
com_err(whoami, status, " while updating user status");
#include <sys/types.h>
#include <ctype.h>
#include "ureg_err.h"
+#define REG_SVR
#include "ureg_proto.h"
#ifndef TRUE
#define UID_LEN 7 /* Allow room for a 16 bit number */
extern char *whoami; /* Name of program - used by libraries */
-extern int errno; /* Unix error number */
/* This structure holds information from the Moira database that will be
worth holding on to. An instance of it appears in the formatted
struct db_data db; /* Information from the Moira database */
};
-void failure_alert(); /* Log an unexplainable failure */
-int parse_pkt(); /* Parse a packet from the client */
-int format_pkt(); /* Prepare a packet to send to client*/
-int verify_user(); /* Make sure user is allowed to register */
-int reserve_user(); /* Reserve a login for this user */
-int set_password(); /* Set this user's password */
-
-
/* For logging successful database transactions */
extern FILE *journal;
+/* prototypes from requests.c */
+void req_initialize(void);
+void get_request(struct msg *message);
+void report(int status, char *message);
+u_long cur_req_sender(void);
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Server for user registration with Moira and Kerberos.
*
- * Server for user registration with Moira and Kerberos.
+ * This file handles the processing of requests for the register
+ * server.
*
- * This file handles the processing of requests for the register
- * server.
- */
-
-#ifndef lint
-static char *rcsid_requests_c = "$Header$";
-#endif lint
-
-/*
- * Before you add anything to the list of things that are #included and
- * #defined, make sure that it is not already done in reg_svr.h
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
+#include <moira.h>
+#include <moira_site.h>
+
#include <sys/types.h>
-#include <sys/file.h>
-#include <krb.h>
-#include <des.h>
-#include <errno.h>
#include <sys/socket.h>
+
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <netdb.h>
-#include "moira.h"
-#include "moira_site.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
#include "reg_svr.h"
+RCSID("$Header$");
+
#define NUM_REQUESTS_SAVED 100 /* Number of transactions to save */
#define CUR_REQ (requests[cur_request_index]) /* The current request */
#define NEXT_INDEX(x) (x == NUM_REQUESTS_SAVED - 1) ? 0 : (x + 1)
static struct request_save requests[NUM_REQUESTS_SAVED]; /* Saved packets */
static int cur_request_index = 0; /* Index to the current request */
+void clear_req(struct request_save *req);
+void req_initialize(void);
+int handle_retransmitted(void);
+void respond(int status, char *text);
+void get_request(struct msg *message);
+void report(int status, char *message);
+int format_pkt(char *packet, int *pktlenp, U_32BIT seqno,
+ int cl_status, char *message);
+int ureg_validate_char(char *s);
+int parse_pkt(char *packet, int pktlen, struct msg *message);
+u_long cur_req_sender(void);
+
void clear_req(struct request_save *req)
{
req->seqno = 0;
{
while (*s)
{
- if (illegalchars[*s++])
+ if (illegalchars[(int)*s++])
return FAILURE;
}
return SUCCESS;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * This program starts the user registration server
+ * in a "clean" environment, and then waits for it to exit.
*
- * This program starts the user registration server
- * in a "clean" environment, and then waits for it to exit.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_starter_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/resource.h>
+#include <sys/wait.h>
+
#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <moira_site.h>
+#include <unistd.h>
+
+RCSID("$Header$");
#define PROG "reg_svr"
int rdpipe[2];
-extern int errno;
+
+void cleanup(void);
void cleanup(void)
{
{
char buf[BUFSIZ];
FILE *log, *prog;
- int logf, inf, i, done, pid, tty;
+ int logf, inf, i, done, pid;
struct rlimit rl;
- extern int errno;
- extern char *sys_errlist[];
-
struct sigaction action;
int nfds;
if (errno && errno != EINTR)
{
strcpy(buf, "Unable to read from program: ");
- strcat(buf, sys_errlist[errno]);
+ strcat(buf, strerror(errno));
strcat(buf, "\n");
}
else
#
# Imakefile for moira regtape programs.
-SRCS= students.c employee.c sign.c verify.c vote.c rafnu.c
-CODE= students.pc employee.pc sign.pc verify.pc vote.pc rafnu.c
+SRCS= students.c employee.c sign.c verify.c vote.c
+CODE= students.pc employee.pc sign.pc verify.pc vote.pc
SRCDIR = $(SRCTOP)/regtape
#ifdef USE_CRYPT_H
-DEFINES = $(GDSSINC) -DUSE_CRYPT_H
-#else
-DEFINES = $(GDSSINC)
+DEFINES = -DUSE_CRYPT_H
#endif
+GDSS_INC = $(GDSSINC)
sqlrule()
-program(students, students.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
-program(employee, employee.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
-program(verify, verify.o rafnu.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
-program(sign, sign.o rafnu.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
-program(vote, vote.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(students, students.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(employee, employee.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(verify, verify.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(sign, sign.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(vote, vote.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
sqlfile(students)
sqlfile(employee)
-/* $Header$
+/* $Id$
+ *
+ * Load data into Moira from Personnel Office data file
+ *
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca;
+extern void sqlglm(char *, unsigned int *, unsigned int *);
+RCSID("$Header$");
#define WHO 11859 /* root */
#define PROG "emp-tape"
int highid;
};
+struct entry *get_next_entry(FILE *in);
+void process_entry(struct entry *e);
+void newuser(struct entry *e);
+int set_next_users_id(int limit);
+int set_next_uid(int high);
+void sqlexit(void);
+void dbmserr(char *where, int what);
char *whoami;
int newfinger = 0;
int main(int argc, char **argv)
{
FILE *in;
- struct entry *e, *get_next_entry();
+ struct entry *e;
int i, wait = 0;
char buf[BUFSIZ], *file = NULL;
EXEC SQL BEGIN DECLARE SECTION;
{
if (!strcmp(argv[i], "-w"))
wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
else if (!strcmp(argv[i], "-n"))
newfinger++;
else if (file)
while ((e = get_next_entry(in)))
{
- again:
process_entry(e);
EXEC SQL COMMIT WORK;
if (sqlca.sqlcode)
exit(0);
}
-
-char *substr(char *buf, char *key)
-{
- int l;
-
- for (l = strlen(key); *buf; buf++)
- {
- if (!strncmp(buf, key, l))
- return buf;
- }
- return NULL;
-}
-
-
struct entry *get_next_entry(FILE *in)
{
static struct entry e;
- static char buf[BUFSIZ], mid[16], eid[16];
+ static char buf[BUFSIZ], eid[16];
static char name[LEN_NAME + 1], sname[LEN_NAME + 1], id[LEN_ID + 1];
static char office[LEN_OFFICE + 1], phone[LEN_PHONE + 1];
static char phone2[LEN_PHONE2 + 1], dept[LEN_DEPT + 1], title[LEN_TITLE + 1];
while (isspace(*p))
p++;
e.first = p;
- if (p = strchr(e.first, ' '))
+ if ((p = strchr(e.first, ' ')))
{
*p = '\0';
e.first = strtrim(e.first);
ends_sr = ends_jr = ends_iii = ends_iv = ends_ii = ends_v = 0;
LookForSt(e.last);
LookForO(e.last);
- LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv,
- &ends_ii, &ends_v);
- LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv,
- &ends_ii, &ends_v);
+ LookForJrAndIII(e.last, &ends_jr, &ends_sr, &ends_ii, &ends_iii,
+ &ends_iv, &ends_v);
+ LookForJrAndIII(e.first, &ends_jr, &ends_sr, &ends_ii, &ends_iii,
+ &ends_iv, &ends_v);
FixCase(e.last);
FixCase(e.first);
FixCase(e.middle);
e.class = "MITS";
e.highid = 0;
- if (substr(e.title, "PROF") || substr(e.title, "LECTURE"))
+ if (strstr(e.title, "PROF") || strstr(e.title, "LECTURE"))
e.class = "FACULTY";
if (!strcmp(e.dept, "LINCOLN LAB"))
{
return &e;
}
-
-process_entry(struct entry *e)
+void process_entry(struct entry *e)
{
int changed, nochange, encrypted;
char buf[BUFSIZ], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
- char *first, *last, *middle, *eid, *sid, *name, *title, *phone2, *rdept;
+ char *first, *last, *middle, *eid, *sid, *name, *rdept;
char *rtitle, *raddr, *rhphone, *rophone, *prog;
char class[9], oaddr[25], ophone[17], dept[128];
char dfirst[17], dlast[17], dmiddle[17];
}
-newuser(struct entry *e)
+void newuser(struct entry *e)
{
char *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
int id, uid, st, who;
char *last, *first, *class, *middle, login[9], *sid, fullname[65], *prog;
- char oaddr[81], ophone[17], dept[128], *name, *title, phone2[17];
+ char oaddr[81], ophone[17], dept[128], *name, *title;
char *rdept, *rhphone, *rophone;
EXEC SQL END DECLARE SECTION;
}
-set_next_users_id(int limit)
+int set_next_users_id(int limit)
{
EXEC SQL BEGIN DECLARE SECTION;
- int rowcount, flag, value, retval;
+ int flag, value, retval;
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT value INTO :value FROM numvalues
return retval;
}
-set_next_uid(int high)
+int set_next_uid(int high)
{
EXEC SQL BEGIN DECLARE SECTION;
- int rowcount, flag, value, retval;
+ int flag, value, retval;
char *name;
EXEC SQL END DECLARE SECTION;
}
-sqlexit(void)
+void sqlexit(void)
{
dbmserr(NULL, sqlca.sqlcode);
EXEC SQL ROLLBACK WORK;
exit(1);
}
-dbmserr(char *where, int what)
+void dbmserr(char *where, int what)
{
char err_msg[256];
int bufsize = 256, msglength = 0;
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- */
-
-#ifndef lint
-static char *rcsid_rafnu_c = "$Header$";
-
-#endif lint
-
-
-#include <stdio.h>
-#include <ctype.h>
-
-FixCase(char *p)
-{
- int cflag;
-
- for (cflag = 0; *p; p++)
- {
- if (cflag && isupper(*p))
- *p = tolower(*p);
- else if (isspace(*p) || ispunct(*p))
- cflag = 0;
- else
- cflag = 1;
- }
-}
-
-LookForJrAndIII(char *nm, int *pends_sr, int *pends_jr, int *pends_iii,
- int *pends_iv)
-{
- int len = strlen(nm);
-
- if (len >= 4 && !strcmp(nm + len - 3, " SR"))
- {
- *pends_sr = 1;
- nm[len - 3] = '\0';
- }
- else if (len >= 4 && !strcmp(nm + len - 3, " JR"))
- {
- *pends_jr = 1;
- nm[len - 3] = '\0';
- }
- else if (len >= 4 && !strcmp(nm + len - 3, " IV"))
- {
- *pends_iv = 1;
- nm[len - 3] = '\0';
- }
- else if (len >= 5 && !strcmp(nm + len - 4, " SR."))
- {
- *pends_sr = 1;
- nm[len - 4] = '\0';
- }
- else if (len >= 5 && !strcmp(nm + len - 4, " JR."))
- {
- *pends_jr = 1;
- nm[len - 4] = '\0';
- }
- else if (len >= 5 && !strcmp(nm + len - 4, " III"))
- {
- *pends_iii = 1;
- nm[len - 4] = '\0';
- }
-}
-
-LookForSt(char *nm) /* ST PIERRE, etc. */
-{
- char temp[256];
-
- if (!strcmp(nm, "ST "))
- {
- strcpy(temp, nm + 3);
- strcpy(nm, "ST. ");
- strcat(nm, temp);
- }
-}
-
-LookForO(char *nm) /* O BRIEN, etc. */
-{
- if (!strcmp(nm, "O ") && isalpha(nm[2]))
- nm[1] = '\'';
-}
-/* $Header$
+/* $Id$
*
* This program will bulk sign user records in the database.
+ *
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <des.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include <krb.h>
-#include <krb_err.h>
#include <gdss.h>
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
char *program;
{
if (!strcmp(argv[i], "-w"))
wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
else
fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]);
}
if (login[0] == '#' || !isdigit(mid[0]))
continue;
sprintf(buf, "%d:%s:%s", id, strtrim(login), strtrim(mid));
- sq_save_data(sq, strsave(buf));
+ sq_save_data(sq, strdup(buf));
found++;
}
EXEC SQL CLOSE c;
-/* $Header$
+/* $Id$
+ *
+ * Load data into Moira from Registrar's Office data file
+ *
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
EXEC SQL INCLUDE sqlca;
+extern void sqlglm(char *, unsigned int *, unsigned int *);
+RCSID("$Header$");
#define WHO 11859 /* root */
#define PROG "stu-tape"
char *class;
};
-
char *whoami;
int newfinger = 0;
+struct entry *get_next_entry(FILE *in);
+void process_entry(struct entry *e);
+void newuser(struct entry *e);
+int set_next_users_id(int limit);
+int set_next_uid(int limit);
+void sqlexit(void);
+void dbmserr(char *where, int what);
+
#define SQL_DUPLICATE -2112
#define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 1403)
int main(int argc, char **argv)
{
FILE *in;
- struct entry *e, *get_next_entry();
+ struct entry *e;
int i, wait = 0;
char buf[BUFSIZ], *file = NULL;
EXEC SQL BEGIN DECLARE SECTION;
{
if (!strcmp(argv[i], "-w"))
wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
else if (!strcmp(argv[i], "-n"))
newfinger++;
else if (file)
while ((e = get_next_entry(in)))
{
- again:
process_entry(e);
EXEC SQL COMMIT WORK;
if (sqlca.sqlcode)
struct entry *get_next_entry(FILE *in)
{
static struct entry e;
- static char buf[BUFSIZ], eid[16], classbuf[10], titlebuf[12];
+ static char buf[BUFSIZ], eid[16], classbuf[10];
static char name[LEN_NAME + 1], id[LEN_ID + 1], course[LEN_COURSE + 1];
static char year[LEN_YEAR + 1], address[LEN_ADDRESS + 1];
static char dorm_room[LEN_DORM_ROOM + 1], city[LEN_CITY + 1];
while (isspace(*p))
p++;
e.first = p;
- if (p = strchr(e.first, ' '))
+ if ((p = strchr(e.first, ' ')))
{
*p = '\0';
e.first = strtrim(e.first);
}
-process_entry(struct entry *e)
+void process_entry(struct entry *e)
{
int changed, nochange, encrypted;
char buf[BUFSIZ], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
- char *first, *last, *middle, *eid, *title, *sid, *name, *rname, *rdept;
+ char *first, *last, *middle, *eid, *sid, *name, *rdept;
char *rtitle, *rophone, *rhphone, *prog;
char class[9], haddr[128], hphone[33], ophone[33], dept[33], raddr[128];
char dfirst[17], dlast[17], dmiddle[17];
}
}
-
-newuser(struct entry *e)
+void newuser(struct entry *e)
{
char buf[512], *from, *to;
EXEC SQL BEGIN DECLARE SECTION;
int set_next_users_id(int limit)
{
EXEC SQL BEGIN DECLARE SECTION;
- int rowcount, flag, value, retval;
+ int flag, value, retval;
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT value INTO :value FROM numvalues
int set_next_uid(int limit)
{
EXEC SQL BEGIN DECLARE SECTION;
- int rowcount, flag, value, retval;
+ int flag, value, retval;
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT value INTO :value FROM numvalues
}
-sqlexit(void)
+void sqlexit(void)
{
dbmserr(NULL, sqlca.sqlcode);
EXEC SQL ROLLBACK WORK;
exit(1);
}
-dbmserr(char *where, int what)
+void dbmserr(char *where, int what)
{
char err_msg[256];
int bufsize = 256, msglength = 0;
-/* $Header$
+/* $Id$
*
* This program will verify signatures on user records in the database.
+ *
+ * Copyright (C) 1993-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
-#include <des.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
#include <krb.h>
-#include <krb_err.h>
#include <gdss.h>
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
+void hex_dump(unsigned char *p);
char *program;
EXEC SQL BEGIN DECLARE SECTION;
char login[10], mid[32], rawsig[256], who[257];
EXEC SQL VAR rawsig IS STRING(256);
- int id, timestamp, sms;
+ int timestamp, sms;
EXEC SQL END DECLARE SECTION;
initialize_sms_error_table();
wait++;
else if (!strcmp(argv[i], "-d"))
debug++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
else if (!strcmp(argv[i], "-fix"))
fix++;
else if (argv[i][0] == '-')
if (status)
com_err(program, gdss2et(status), "verifying user %s", login);
if (fix && status == GDSS_E_BADSIG)
- sq_save_data(sq, strsave(buf));
+ sq_save_data(sq, strdup(buf));
if (wait)
{
printf("Next");
*strchr(login, ':') = '\0';
again:
com_err(program, 0, "fixing sig for %s", login);
- status = GDSS_Sign(data, strlen(data), sigbuf, &si);
+ status = GDSS_Sign(data, strlen(data), sigbuf);
if (status)
{
com_err(program, gdss2et(status), "signing data");
}
-hex_dump(unsigned char *p)
+void hex_dump(unsigned char *p)
{
printf("Size: %d\n", strlen(p));
while (strlen(p) >= 8)
-/* $Header$
+/* $Id$
+ *
+ * Copyright (C) 1993-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
#include <moira.h>
#include <moira_site.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
struct entry {
char *line;
char *whoami;
int debug;
+struct entry *get_next_entry(FILE *in);
+int process_entry(struct entry *e);
int main(int argc, char **argv)
{
FILE *in;
- struct entry *e, *get_next_entry();
+ struct entry *e;
int i, wait = 0;
char buf[BUFSIZ], *file = NULL, *p, *p1, *db = "moira";
{
if (!strcmp(argv[i], "-w"))
wait++;
- else if (!strcmp(argv[i], "-D"))
- setenv("ING_SET", "set printqry");
else if (!strcmp(argv[i], "-d"))
debug = 1;
else if (file)
exit(0);
}
-
-
struct entry *get_next_entry(FILE *in)
{
static struct entry e;
return &e;
}
-
int process_entry(struct entry *e)
{
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL SELECT login INTO :login FROM users WHERE clearid = :id;
if (sqlca.sqlcode)
{
- fprintf(stderr, "Error %d on %s\n", sqlca.sqlcode, e->line);
+ fprintf(stderr, "Error %ld on %s\n", sqlca.sqlcode, e->line);
return -1;
}
strncpy(e->login, login, 8);
# Imakefile for server directory.
#
-DEFINES= -I. $(GDSSINC)
+GDSS_INC=$(GDSSINC)
SRCS = startmoira.c mr_main.c mr_sauth.c mr_scall.c \
mr_srvdata.c mr_shutdown.c mr_util.c \
-/*
- * $Header$
+/* $Id$
*
- * Copyright (C) 1989, 1990 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Keep a cache of name/id mappings
+ *
+ * Copyright (C) 1989-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_cache_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <string.h>
#include "mr_server.h"
#include "query.h"
+
+#include <stdlib.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
EXEC SQL WHENEVER SQLERROR DO dbmserr();
extern char *whoami;
/* statistics counters */
int cachehits = 0, cachemisses = 0;
+int hashname(char *name, enum tables type);
/* Name hash function. */
if (i->id != id || type != i->type)
continue;
free(*name);
- *name = strsave(i->name);
+ *name = strdup(i->name);
cachehits++;
i->next->prev = i->prev;
i->prev->next = i->next;
{
free(*name);
sprintf(iname, "#%d", j);
- *name = strsave(iname);
+ *name = strdup(iname);
return MR_NO_MATCH;
}
if (sqlca.sqlerrd[2] > 1)
if (sqlca.sqlcode)
return MR_DBMS_ERR;
free(*name);
- *name = strsave(strtrim(iname));
+ *name = strdup(strtrim(iname));
if (**name == '#' && type != USERS_TABLE)
return MR_SUCCESS;
if (cachesize < CACHESIZE)
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1989 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Deal with incremental updates
*
+ * Copyright (C) 1989-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_increment_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <moira.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
#include "mr_server.h"
#include "query.h"
#include "qrtn.h"
+
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
EXEC SQL INCLUDE sqlca;
+RCSID("$Header$");
+
extern char *whoami;
extern char *table_name[];
extern int num_tables;
break;
c = malloc(sizeof(struct inc_cache));
c->next = cache;
- c->table = strsave(strtrim(tab));
- c->service = strsave(strtrim(serv));
+ c->table = strdup(strtrim(tab));
+ c->service = strdup(strtrim(serv));
cache = c;
}
EXEC SQL CLOSE inc;
{
char **ret = malloc(sizeof(char *) * argc);
while (--argc >= 0)
- ret[argc] = strsave(strtrim(argv[argc]));
+ ret[argc] = strdup(strtrim(argv[argc]));
return ret;
}
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Glue routines to allow the database stuff to be linked in to
+ * a program expecting a library level interface.
*
- * Glue routines to allow the database stuff to be linked in to
- * a program expecting a library level interface.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_glue_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/wait.h>
-#include <krb_et.h>
-#include <pwd.h>
#include "mr_server.h"
#include "query.h"
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+extern char *krb_get_lrealm(char *, int);
+
+RCSID("$Header$");
+
static int already_connected = 0;
#define CHECK_CONNECTED { if (!already_connected) return MR_NOT_CONNECTED; }
static client pseudo_client;
-extern int errno;
extern char *whoami;
extern time_t now;
-void reapchild();
+
+void reapchild(void);
+int callback(int argc, char **argv, void *arg);
int mr_connect(char *server)
{
{
struct passwd *pw;
extern char *krb_realm;
- char buf[1024], *strsave();
+ char buf[1024];
CHECK_CONNECTED;
pw = getpwuid(getuid());
}
struct hint {
- int (*proc)();
+ int (*proc)(int, char **, void *);
char *hint;
};
-callback(int argc, char **argv, struct hint *arg)
+int callback(int argc, char **argv, void *arg)
{
+ struct hint *hint = arg;
if (mr_trim_args(argc, argv) == MR_NO_MEM)
com_err(whoami, MR_NO_MEM, "while trimmming args");
- (*arg->proc)(argc, argv, arg->hint);
+ return (*hint->proc)(argc, argv, hint->hint);
}
-int mr_query(char *name, int argc, char **argv, int (*callproc)(), char *callarg)
+int mr_query(char *name, int argc, char **argv,
+ int (*callproc)(int, char **, void *), void *callarg)
{
struct hint hints;
mr_copy_args(argv, argc));
}
-int mr_query_internal(int argc, char **argv, int (*callproc)(), char *callarg)
-{
- struct hint hints;
-
- time(&now);
- hints.proc = callproc;
- hints.hint = callarg;
- next_incremental();
- return mr_process_query(&pseudo_client, argv[0], argc - 1,
- mr_copy_args(argv + 1, argc - 1), callback,
- (char *)&hints);
-}
-
-int mr_access_internal(int argc, char **argv)
-{
- time(&now);
- return mr_check_access(&pseudo_client, argv[0], argc - 1,
- mr_copy_args(argv + 1, argc - 1));
-}
-
-mr_shutdown(char *why)
-{
- fprintf(stderr, "Sorry, not implemented\n");
-}
-
-
/* trigger_dcm is also used as a followup routine to the
* set_server_host_override query, hence the two dummy arguments.
*/
"tdcm",
};
-int trigger_dcm(int dummy0, int dummy1, client *cl)
+int trigger_dcm(struct query *q, char *argv[], client *cl)
{
int pid, status;
char prog[128];
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- * Moira server process.
+/* $Id$
*
- * Most of this is stolen from ../gdb/tsr.c
+ * Moira server process.
*
- * You are in a maze of twisty little finite automata, all different.
- * Let the reader beware.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-static char *rcsid_mr_main_c = "$Header$";
-
#include <mit-copyright.h>
-#include <string.h>
-#include <stdio.h>
+#include "mr_server.h"
+
+#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/signal.h>
+#include <sys/utsname.h>
#include <sys/wait.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <signal.h>
-#include "mr_server.h"
-#include <krb_et.h>
-#include <gdss_et.h>
+
+#include <netinet/in.h>
#include <arpa/inet.h>
+#include <ctype.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+RCSID("$Header$");
+
+extern char *krb_get_lrealm(char *, int);
+
extern CONNECTION newconn, listencon;
extern int nclients;
extern char *whoami;
extern char buf1[BUFSIZ];
extern char *takedown;
-extern int errno;
extern FILE *journal;
extern time_t now;
-char hostbuf[BUFSIZ], *host;
+char *host;
+void reapchild(int x);
+void godormant(int x);
+void gowakeup(int x);
int do_listen(char *port);
void do_reset_listen(void);
void clist_append(client *cp);
char *port, *p;
extern char *database;
struct stat stbuf;
+ struct utsname uts;
whoami = argv[0];
/*
/*
* Get moira server hostname for authentication
*/
- if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
+ if (uname(&uts) < 0)
{
com_err(whoami, errno, "Unable to get local hostname");
exit(1);
}
- host = canonicalize_hostname(strsave(hostbuf));
+ host = canonicalize_hostname(strdup(uts.nodename));
for (p = host; *p && *p != '.'; p++)
{
if (isupper(*p))
op_list = create_list_of_operations(1, listenop);
com_err(whoami, 0, "started (pid %d)", getpid());
- com_err(whoami, 0, rcsid_mr_main_c);
+ com_err(whoami, 0, rcsid);
if (dormant != ASLEEP)
send_zgram("MOIRA", "server started");
else
cp->con = newconn;
cp->id = counter++;
cp->args = NULL;
- cp->clname[0] = NULL;
+ cp->clname[0] = '\0';
cp->reply.mr_argv = NULL;
cp->first = NULL;
cp->last = NULL;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
+ *
+ * Handle server side of authentication
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_mr_sauth_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <string.h>
#include "mr_server.h"
-#include <ctype.h>
-#include <krb_et.h>
-#include <moira.h>
-#include <time.h>
-extern char *whoami, *host;
+#include <sys/types.h>
-/* from libmoira */
-char *kname_unparse(char *, char *, char *);
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+extern char *whoami, *host;
typedef struct _replay_cache {
KTEXT_ST auth;
KTEXT_ST auth;
AUTH_DAT ad;
int status, ok;
- extern int errno;
replay_cache *rc, *rcnew;
time_t now;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
+ *
+ * Do RPC
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_mr_scall_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <sys/types.h>
+#include "mr_server.h"
+#include "query.h"
+
#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <string.h>
-#include <netinet/in.h>
+#include <sys/types.h>
+
#include <arpa/inet.h>
-#include <krb.h>
+#include <netinet/in.h>
+
#include <errno.h>
-#include "mr_server.h"
-#include "query.h"
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+RCSID("$Header$");
+
extern char buf1[];
extern int nclients;
extern char *whoami;
-extern int errno;
-extern void clist_delete(), do_auth(), do_shutdown();
-void do_call();
extern int dbms_errno, mr_errcode;
static int row_count;
+void do_call(client *cl);
+void free_rtn_tuples(client *cp);
+int retr_callback(int argc, char **argv, void *p_cp);
+int list_users(int (*callbk)(int, char **, void *), char *callarg);
+void do_retr(client *cl);
+void do_access(client *cl);
+void get_motd(client *cl);
+
/* Put this in a variable so that we can patch it if necessary */
int max_row_count = 4096;
return;
case MR_DO_UPDATE:
- trigger_dcm(0, 0, cl);
+ trigger_dcm(NULL, NULL, cl);
return;
case MR_MOTD:
}
}
-free_rtn_tuples(client *cp)
+void free_rtn_tuples(client *cp)
{
returned_tuples *temp;
for (temp = cp->first; temp && OP_DONE(temp->op); )
cp->first = temp;
}
-retr_callback(int argc, char **argv, char *p_cp)
+int retr_callback(int argc, char **argv, void *p_cp)
{
- client *cp = (client *)p_cp;
+ client *cp = p_cp;
mr_params *arg_tmp;
returned_tuples *tp;
OPERATION op_tmp;
if (row_count++ >= max_row_count)
{
dbms_errno = mr_errcode = MR_NO_MEM;
- return;
+ return MR_ABORT;
}
/*
* This takes too much advantage of the fact that
* serialization of the data happens during the queue operation.
*/
- arg_tmp = db_alloc(sizeof(mr_params));
- tp = db_alloc(sizeof(returned_tuples));
+ arg_tmp = malloc(sizeof(mr_params));
+ tp = malloc(sizeof(returned_tuples));
nargv = malloc(argc * sizeof(char *));
op_tmp = create_operation();
reset_operation(op_tmp);
initialize_operation(op_tmp, mr_start_send, (char *)arg_tmp, NULL);
queue_operation(cp->con, CON_OUTPUT, op_tmp);
+ return MR_CONT;
}
-int list_users(int (*callbk)(), char *callarg)
+int list_users(int (*callbk)(int, char **, void *), char *callarg)
{
char *argv[6];
char buf[30];
int i;
extern client **clients;
char *cp;
- char *ctime();
for (i = 0; i < nclients; i++)
{
return 0;
}
-do_retr(client *cl)
+void do_retr(client *cl)
{
char *queryname;
cl->reply.mr_status = mr_process_query(cl, queryname,
cl->args->mr_argc - 1,
cl->args->mr_argv + 1,
- retr_callback, (char *)cl);
+ retr_callback, cl);
}
if (row_count >= max_row_count)
{
com_err(whoami, 0, "Query complete.");
}
-do_access(client *cl)
+void do_access(client *cl)
{
if (cl->args->mr_argc < 1)
{
"tdcm",
};
-int trigger_dcm(int dummy0, int dummy1, client *cl)
+int trigger_dcm(struct query *q, char *argv[], client *cl)
{
int pid;
char prog[128];
}
-get_motd(client *cl)
+void get_motd(client *cl)
{
int motd, len;
char buffer[1024];
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
+/* $Id$
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "mr_proto.h"
+#include <moira.h>
+#include <mr_proto.h>
#include <moira_site.h>
-#include <krb.h>
-#include <com_err.h>
-#include <stdlib.h>
+
+#include <netinet/in.h>
+
#include <stdarg.h>
+#include <krb.h>
+
typedef struct returned_tuples {
struct returned_tuples *next;
OPERATION op;
#define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
+/* types needed for prototypes */
+struct query;
+struct validate;
+struct valobj;
+
/* prototypes from gdb */
int gdb_init(void);
int gdb_debug(int flag);
void start_accepting_client(CONNECTION, OPERATION, CONNECTION *,
char *, int *, TUPLE *);
-int initialize_operation(OPERATION, int (*init_function)(), char *,
- int (*cancel_function)());
+int initialize_operation(OPERATION, int (*init_function)(OPERATION, HALF_CONNECTION, void *),
+ char *, int (*cancel_function)(HALF_CONNECTION, void *));
int reset_operation(OPERATION);
int delete_operation(OPERATION);
int start_replying_to_client(OPERATION, CONNECTION, int, char *, char *);
int op_select(LIST_OF_OPERATIONS, int, fd_set *, fd_set *, fd_set *,
struct timeval *);
-/* prototypes from libmoira */
-struct save_queue *sq_create(void);
-int sq_save_data(struct save_queue *sq, void *data);
-int sq_save_unique_data(struct save_queue *sq, void *data);
-int sq_save_args(int argc, void *argv[], struct save_queue *sq);
-int sq_get_data(struct save_queue *sq, void *data);
-int sq_remove_data(struct save_queue *sq, void *data);
-int sq_empty(struct save_queue *sq);
-void sq_destroy(struct save_queue *sq);
-
-void send_zgram(char *instance, char *buf);
-void critical_alert(char *, char *, ...);
-void mr_destroy_reply(mr_params *reply);
-int gdss2et(int);
-
/* prototypes from increment.dc */
void incremental_init(void);
void next_incremental(void);
int mr_open_database(void);
void mr_close_database(void);
int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
- int (*action)(), char *actarg);
+ int (*action)(int, char *[], void *), void *actarg);
int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]);
void sanity_check_queries(void);
int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid);
int find_member(char *list_type, int list_id, client *cl);
-int do_for_all_rows(char *query, int count, int (*action)(), int actarg);
-int build_qual(char *fmt, int argc, char *argv[], char *qual);
+int do_for_all_rows(char *query, int count,
+ int (*action)(int, char *[], void *), void *actarg);
+void build_qual(char *fmt, int argc, char *argv[], char *qual);
/* prototyoes from qsupport.dc */
/* prototypes from mr_scall.c */
void do_client(client *cp);
-int trigger_dcm(int dummy0, int dummy1, client *cl);
+int trigger_dcm(struct query *q, char *argv[], client *cl);
/* prototypes from mr_shutdown.c */
void sigshut(int);
void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar);
int mr_trim_args(int argc, char **argv);
char **mr_copy_args(char **argv, int argc);
+
+/* prototypes from qaccess.pc */
+int access_user(struct query *q, char *argv[], client *cl);
+int access_login(struct query *q, char *argv[], client *cl);
+int access_list(struct query *q, char *argv[], client *cl);
+int access_visible_list(struct query *q, char *argv[], client *cl);
+int access_vis_list_by_name(struct query *q, char *argv[], client *cl);
+int access_member(struct query *q, char *argv[], client *cl);
+int access_qgli(struct query *q, char *argv[], client *cl);
+int access_service(struct query *q, char *argv[], client *cl);
+int access_filesys(struct query *q, char *argv[], client *cl);
+int access_host(struct query *q, char *argv[], client *cl);
+int access_ahal(struct query *q, char *argv[], client *cl);
+int access_snt(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qfollow.pc */
+int followup_fix_modby(struct query *q, struct save_queue *sq,
+ struct validate *v, int (*action)(int, char **, void *),
+ void *actarg, client *cl);
+int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
+ int (*action)(int, char **, void *), void *actarg,
+ client *cl);
+
+int followup_ausr(struct query *q, char *argv[], client *cl);
+int followup_aqot(struct query *q, char *argv[], client *cl);
+int followup_dqot(struct query *q, char *argv[], client *cl);
+int followup_uuac(struct query *q, char *argv[], client *cl);
+
+int set_modtime(struct query *q, char *argv[], client *cl);
+int set_modtime_by_id(struct query *q, char *argv[], client *cl);
+int set_finger_modtime(struct query *q, char *argv[], client *cl);
+int set_pobox_modtime(struct query *q, char *argv[], client *cl);
+int set_uppercase_modtime(struct query *q, char *argv[], client *cl);
+int set_mach_modtime_by_id(struct query *q, char *argv[], client *cl);
+int set_cluster_modtime_by_id(struct query *q, char *argv[], client *cl);
+int set_serverhost_modtime(struct query *q, char *argv[], client *cl);
+int set_nfsphys_modtime(struct query *q, char *argv[], client *cl);
+int set_filesys_modtime(struct query *q, char *argv[], client *cl);
+int set_zephyr_modtime(struct query *q, char *argv[], client *cl);
+int _sdl_followup(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qsetup.pc */
+int prefetch_value(struct query *q, char *argv[], client *cl);
+int prefetch_filesys(struct query *q, char *argv[], client *cl);
+int setup_ausr(struct query *q, char *argv[], client *cl);
+int setup_dusr(struct query *q, char *argv[], client *cl);
+int setup_spop(struct query *q, char *argv[], client *cl);
+int setup_dpob(struct query *q, char *argv[], client *cl);
+int setup_dmac(struct query *q, char *argv[], client *cl);
+int setup_dclu(struct query *q, char *argv[], client *cl);
+int setup_alis(struct query *q, char *argv[], client *cl);
+int setup_dlis(struct query *q, char *argv[], client *cl);
+int setup_dsin(struct query *q, char *argv[], client *cl);
+int setup_dshi(struct query *q, char *argv[], client *cl);
+int setup_afil(struct query *q, char *argv[], client *cl);
+int setup_ufil(struct query *q, char *argv[], client *cl);
+int setup_dfil(struct query *q, char *argv[], client *cl);
+int setup_aftg(struct query *q, char *argv[], client *cl);
+int setup_dnfp(struct query *q, char *argv[], client *cl);
+int setup_dqot(struct query *q, char *argv[], client *cl);
+int setup_akum(struct query *q, char *argv[], client *cl);
+int setup_dsnt(struct query *q, char *argv[], client *cl);
+int setup_ahst(struct query *q, char *argv[], client *cl);
+int setup_ahal(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qsupport.pc */
+int set_pobox(struct query *q, char *argv[], client *cl);
+int add_member_to_list(struct query *q, char *argv[], client *cl);
+int delete_member_from_list(struct query *q, char *argv[], client *cl);
+int register_user(struct query *q, char *argv[], client *cl);
+
+int get_list_info(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+int get_ace_use(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+int qualified_get_lists(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+int get_members_of_list(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+int get_end_members_of_list(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *),
+ void *actarg);
+int qualified_get_server(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+int qualified_get_serverhost(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *),
+ void *actarg);
+int count_members_of_list(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+int get_lists_of_member(struct query *q, char **argv, client *cl,
+ int (*action)(int, char *[], void *), void *actarg);
+
+/* prototypes from qvalidate.pc */
+/* from qvalidate.dc */
+int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);
+int validate_row(struct query *q, char *argv[], struct validate *v);
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+/* $Id$
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_shutdown_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <sys/errno.h>
#include "mr_server.h"
+#include <errno.h>
+
+RCSID("$Header$");
+
extern char *takedown;
extern char *whoami;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Global variables inside the Moira server.
*
- * Global variables inside the Moira server.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_srvdata_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include "mr_server.h"
+RCSID("$Header$");
+
/*
* Connections & clients:
*
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_util_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include "mr_server.h"
-#include <com_err.h>
+
#include <ctype.h>
-#include <sys/types.h>
+#include <stdlib.h>
#include <string.h>
+RCSID("$Header$");
+
extern char *whoami;
char *requote(char *buf, char *cp, int len)
if (code)
fputs(error_message(code), stderr);
if (fmt)
- _doprnt(fmt, pvar, stderr);
+ vfprintf(stderr, fmt, pvar);
putc('\n', stderr);
}
if (!a)
return a;
for (i = 0; i < argc; i++)
- a[i] = strsave(argv[i]);
+ a[i] = strdup(argv[i]);
return a;
}
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Check access to queries
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include "mr_server.h"
+#include "qrtn.h"
#include "query.h"
+
#include <ctype.h>
+#include <stdlib.h>
+
EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
+
+RCSID("$Header$");
extern char *whoami;
extern int dbms_errno, mr_errcode;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Query followup routines
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include "mr_server.h"
#include "query.h"
+#include "qrtn.h"
+
#include <ctype.h>
+#include <stdlib.h>
#include <string.h>
#ifdef GDSS
#include "gdss.h"
#endif /* GDSS */
+
EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
+
+RCSID("$Header$");
extern char *whoami, *table_name[];
extern int dbms_errno, mr_errcode;
* username, or # + the users_id.
*/
int followup_fix_modby(struct query *q, struct save_queue *sq,
- struct validate *v, int (*action)(), int actarg,
- client *cl)
+ struct validate *v, int (*action)(int, char *[], void *),
+ void *actarg, client *cl)
{
int i, j;
char **argv;
* routine but don't have a signature.
*/
int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
int i, j;
char **argv;
char *kname;
SigInfo si;
EXEC SQL BEGIN DECLARE SECTION;
- int timestamp, who, siglen;
+ int timestamp, who;
char *login;
char rsig[256];
EXEC SQL VAR rsig IS STRING(256);
si.SigInfoVersion = 0; /* XXXXX this isn't used */
kname_parse(si.pname, si.pinst, si.prealm, kname);
free(kname);
- si.rawsig = (unsigned char *)strsave(rsig);
+ si.rawsig = (unsigned char *)strdup(rsig);
if (log_flags & LOG_GDSS)
com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"",
strlen(si.rawsig), si.rawsig);
GDSS_Recompose(&si, sigbuf);
free(si.rawsig);
free(argv[U_SIGNATURE]);
- argv[U_SIGNATURE] = strsave(sigbuf);
+ argv[U_SIGNATURE] = strdup(sigbuf);
if (log_flags & LOG_GDSS)
com_err(whoami, 0, "generated signature length %d",
strlen(sigbuf));
char fullname[129];
EXEC SQL END DECLARE SECTION;
#ifdef GDSS
- char databuf[32], *kname_unparse();
+ char databuf[32];
EXEC SQL BEGIN DECLARE SECTION;
char rawsig[128];
int sigwho, timestamp;
char *entity, *name;
EXEC SQL END DECLARE SECTION;
#ifdef GDSS
- char databuf[32], *kname_unparse();
+ char databuf[32];
EXEC SQL BEGIN DECLARE SECTION;
char rawsig[128];
char *login;
*/
int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
char **argv;
char *ptype, *p;
*/
int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
char **argv, *type;
int id, i, idx, status;
{
status = 0;
free(argv[idx]);
- argv[idx] = strsave("NONE");
+ argv[idx] = strdup("NONE");
}
else
{
status = 0;
free(argv[idx]);
- argv[idx] = strsave("???");
+ argv[idx] = strdup("???");
}
if (status && status != MR_NO_MATCH)
return status;
*/
int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
char **argv, *type;
int id, i, idx, status;
{
status = 0;
free(argv[idx]);
- argv[idx] = strsave("NONE");
+ argv[idx] = strdup("NONE");
}
else
{
status = 0;
free(argv[idx]);
- argv[idx] = strsave("???");
+ argv[idx] = strdup("???");
}
if (status && status != MR_NO_MATCH)
return status;
*/
int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
char **argv, *type;
int id, i, idx, status;
{
status = 0;
free(argv[idx]);
- argv[idx] = strsave("NONE");
+ argv[idx] = strdup("NONE");
}
else
{
status = 0;
free(argv[idx]);
- argv[idx] = strsave("???");
+ argv[idx] = strdup("???");
}
if (status && status != MR_NO_MATCH)
return status;
*/
int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
int j;
char **argv;
break;
case 'A':
free(argv[2]);
- argv[2] = strsave("system:anyuser");
+ argv[2] = strdup("system:anyuser");
break;
default:
id = atoi(argv[2]);
int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
int i, j;
char **argv;
*/
int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
int id, i, status;
char **argv;
{
status = 0;
free(argv[i + 1]);
- argv[i + 1] = strsave("NONE");
+ argv[i + 1] = strdup("NONE");
}
else
{
status = 0;
free(argv[i + 1]);
- argv[i + 1] = strsave("???");
+ argv[i + 1] = strdup("???");
}
if (status && status != MR_NO_MATCH)
return status;
*/
int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
- int (*action)(), int actarg, client *cl)
+ int (*action)(int, char *[], void *), void *actarg,
+ client *cl)
{
char **argv;
int i, id, status;
{
status = 0;
free(argv[2]);
- argv[2] = strsave("NONE");
+ argv[2] = strdup("NONE");
}
else
{
status = 0;
free(argv[2]);
- argv[2] = strsave("???");
+ argv[2] = strdup("???");
}
if (status && status != MR_NO_MATCH)
return status;
extern int mr_sig_length;
extern char stmt_buf[MR_STMTBUF_LEN];
-extern void dbmserr();
+void dbmserr(void);
/* eof:qtrn.h */
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
+ *
+ * Query-processing routines
*
- * Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_qrtn_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <string.h>
#include "mr_server.h"
+#include "qrtn.h"
#include "query.h"
+
+#include <stdlib.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca; /* SQL Communications Area */
EXEC SQL INCLUDE sqlda; /* SQL Descriptor Area */
-#include "qrtn.h"
+
+RCSID("$Header$");
SQLDA *mr_sqlda;
EXEC SQL BEGIN DECLARE SECTION;
int mr_verify_query(client *cl, struct query *q, int argc, char *argv_ro[]);
int do_retrieve(struct query *q, char *pqual, char *psort,
- int (*action)(), char *actarg);
+ int (*action)(int, char *[], void *), void *actarg);
int do_update(struct query *q, char *argv[], char *qual,
- int (*action)(), char *actarg);
+ int (*action)(int, char *[], void *), void *actarg);
int do_append(struct query *q, char *argv[], char *pqual,
- int (*action)(), char *actarg);
+ int (*action)(int, char *[], void *), void *actarg);
int do_delete(struct query *q, char *qual,
- int (*action)(), char *actarg);
+ int (*action)(int, char *[], void *), void *actarg);
void build_sql_stmt(char *result_buf, char *cmd, char *targetlist,
char *argv[], char *qual);
char *build_sort(struct validate *v, char *sort);
+char *sqlstrstr(char *str, char *pat);
+void optimize_sql_stmt(char *buf);
-/* from qvalidate.dc */
-int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);
-int validate_row(struct query *q, char *argv[], struct validate *v);
-
+SQLDA *mr_alloc_sqlda(void);
+void sqlglm(char *, int *, int *);
/*
* dbmserr: Called when the DBMS indicates an error.
int mr_open_database(void)
{
int i;
- SQLDA *mr_alloc_sqlda();
static first_open = 1;
if (first_open)
}
int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
- int (*action)(), char *actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
struct query *q;
int status;
/* perform any special query pre-processing */
if (v && v->pre_rtn)
{
- status = (*v->pre_rtn)(q, Argv, cl, 0);
+ status = (*v->pre_rtn)(q, Argv, cl);
if (status != MR_SUCCESS)
goto out;
}
if (v && v->post_rtn)
{
sq = sq_create();
- status = do_retrieve(q, pqual, psort, sq_save_args, (char *)sq);
+ status = do_retrieve(q, pqual, psort, sq_save_args, sq);
if (status != MR_SUCCESS)
{
sq_destroy(sq);
if (v->post_rtn)
status = (*v->post_rtn)(q, Argv, cl);
break;
+
+ case SPECIAL:
+ break;
}
out:
fprintf(journal, "%% %s %s %s",
cl->clname, cl->entity, ctime(&now));
- fprintf(journal, "%s[%d] ", q->name, cl->args->mr_version_no);
+ fprintf(journal, "%s[%ld] ", q->name, cl->args->mr_version_no);
for (i = 0; i < argc; i++)
{
if (i != 0)
return status;
}
-int build_qual(char *fmt_buf, int argc, char *argv[], char *qual)
+void build_qual(char *fmt_buf, int argc, char *argv[], char *qual)
{
char *res, *fmt;
int do_retrieve(struct query *q, char *pqual, char *psort,
- int (*action)(), char *actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
build_sql_stmt(stmt_buf, "SELECT", q->tlist, NULL, pqual);
if (psort)
strcat(stmt_buf, psort);
}
- return do_for_all_rows(stmt_buf, q->vcnt, action, (int)actarg);
+ return do_for_all_rows(stmt_buf, q->vcnt, action, actarg);
}
char *sqlstrstr(char *str, char *pat)
{
char *point = buf, *pat, *eopat, *esc1, *esc2, *csr;
- for (point = buf; point = sqlstrstr(point, "LIKE"); point++)
+ for (point = buf; (point = sqlstrstr(point, "LIKE")); point++)
{
/* Now pointing to string "LIKE" */
}
int do_update(struct query *q, char *argv[], char *qual,
- int (*action)(), char *actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
build_sql_stmt(stmt_buf, "UPDATE", q->tlist, argv, qual);
EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
}
int do_append(struct query *q, char *argv[], char *pqual,
- int (*action)(), char *actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
build_sql_stmt(stmt_buf, "INSERT", q->tlist, argv, pqual);
EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
return MR_SUCCESS;
}
-int do_delete(struct query *q, char *qual, int (*action)(), char *actarg)
+int do_delete(struct query *q, char *qual,
+ int (*action)(int, char *[], void *), void *actarg)
{
sprintf(stmt_buf, "DELETE FROM %s WHERE %s", table_name[q->rtable], qual);
EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
}
}
-int do_for_all_rows(char *query, int count, int (*action)(), int actarg)
+int do_for_all_rows(char *query, int count,
+ int (*action)(int, char *[], void *), void *actarg)
{
int i, rowcount = 0;
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL PREPARE stmt FROM :q;
if (sqlca.sqlcode)
- return;
+ return MR_INTERNAL;
EXEC SQL DECLARE curs CURSOR FOR stmt;
EXEC SQL OPEN curs;
mr_sqlda->N = count;
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Query setup routines
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include "mr_server.h"
#include "query.h"
-#include <ctype.h>
+#include "qrtn.h"
+
#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
-extern char *whoami, *strsave();
+RCSID("$Header$");
+
+extern char *whoami;
extern int dbms_errno, mr_errcode;
EXEC SQL BEGIN DECLARE SECTION;
* and may safely be deleted.
*/
-int setup_dusr(struct query *q, char **argv)
+int setup_dusr(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int flag, id, cnt;
/* setup_spop: verify that there is already a valid POP machine_id in the
* pop_id field. Also take care of keeping track of the post office usage.
*/
-int setup_spop(struct query *q, char **argv)
+int setup_spop(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, mid;
id = *(int *)argv[0];
EXEC SQL SELECT potype, pop_id INTO :type, :mid FROM users
WHERE users_id = :id;
- if (sqlca.sqlerrd[2] = 0)
+ if (sqlca.sqlerrd[2] == 0)
return MR_MACHINE;
EXEC SQL SELECT mach_id INTO :mid FROM machine
WHERE mach_id = :mid;
- if (sqlca.sqlerrd[2] = 0)
+ if (sqlca.sqlerrd[2] == 0)
return MR_MACHINE;
if (strcmp(strtrim(type), "POP"))
set_pop_usage(mid, 1);
/* setup_dpob: Take care of keeping track of the post office usage.
*/
-int setup_dpob(struct query *q, char **argv)
+int setup_dpob(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, user;
* and may safely be deleted.
*/
-int setup_dmac(struct query *q, char **argv)
+int setup_dmac(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int flag, id, cnt;
* and may safely be deleted.
*/
-int setup_dsnt(struct query *q, char **argv)
+int setup_dsnt(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, cnt = 0;
* and may safely be deleted.
*/
-int setup_dclu(struct query *q, char **argv)
+int setup_dclu(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, cnt;
* and may safely be deleted.
*/
-int setup_dlis(struct query *q, char **argv)
+int setup_dlis(struct query *q, char *argv[], client *cl)
{
int id;
EXEC SQL BEGIN DECLARE SECTION;
* and may safely be deleted.
*/
-int setup_dsin(struct query *q, char **argv)
+int setup_dsin(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int ec, cnt;
* and may safely be deleted.
*/
-int setup_dshi(struct query *q, char **argv)
+int setup_dshi(struct query *q, char *argv[], client *cl)
{
EXEC SQL BEGIN DECLARE SECTION;
int id, ec;
* make IP address is unique. If this a modify request
* (row == 1), then we expect one record to exist.
*/
- if (row == 0 || row == 1 && cnt > 1)
+ if (row == 0 || (row == 1 && cnt > 1))
return MR_ADDRESS;
if (row == 1 && cnt == 1)
{
if (((id & 0xff) == 0) || ((id & 0xff) == 255))
continue;
addr.s_addr = htonl(id);
- name = (char *)inet_ntoa(addr);
+ name = inet_ntoa(addr);
EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine
WHERE address = :name;
if (dbms_errno)
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+/* $Id$
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_qsubs_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <moira.h>
#include "mr_server.h"
#include "query.h"
+#include <stdlib.h>
+
+RCSID("$Header$");
+
extern struct query Queries2[];
extern int QueryCount2;
+int qcmp(const void *q1, const void *q2);
+
struct query *get_query_by_name(char *name, int version)
{
struct query *q;
return NULL;
}
-void list_queries(int version, int (*action)(), char *actarg)
+void list_queries(int version, int (*action)(int, char *[], void *),
+ void *actarg)
{
struct query *q;
int i;
char qnames[80];
char *qnp;
int count;
- int qcmp();
count = QueryCount2;
if (!squeries2)
(*action)(1, &qnp, actarg);
}
-void help_query(struct query *q, int (*action)(), char *actarg)
+void help_query(struct query *q, int (*action)(int, char *[], void *),
+ void *actarg)
{
int argcount;
int i;
(*action)(argcount, argv, actarg);
}
-int qcmp(struct query **q1, struct query **q2)
+int qcmp(const void *q1, const void *q2)
{
- return strcmp((*q1)->name, (*q2)->name);
+ return strcmp((*(struct query **)q1)->name, (*(struct query **)q2)->name);
}
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Special query routines
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include "mr_server.h"
#include "query.h"
+#include "qrtn.h"
+
#include <ctype.h>
+#include <stdlib.h>
#include <string.h>
+
EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
+
+RCSID("$Header$");
extern char *whoami, *table_name[];
extern int dbms_errno, mr_errcode;
EXEC SQL WHENEVER SQLERROR DO dbmserr();
-int get_ace_internal(char *atypex, int aid, int (*action)(), int actarg);
+int get_ace_internal(char *atypex, int aid,
+ int (*action)(int, char *[], void *), void *actarg);
int gmol_internal(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg, int flag);
-int qualified_get(struct query *q, char *argv[], int (*action)(), int actarg,
+ int (*action)(int, char *[], void *), void *actarg,
+ int flag);
+int qualified_get(struct query *q, char *argv[],
+ int (*action)(int, char *[], void *), void *actarg,
char *start, char *range, char *field, char *flags[]);
-/* Special query routines */
-
/* set_pobox - this does all of the real work.
* argv = user_id, type, box
* if type is POP, then box should be a machine, and its ID should be put in
*/
int get_list_info(struct query *q, char **aargv, client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
char *argv[13];
EXEC SQL BEGIN DECLARE SECTION;
int id, rowcount, acl_id, hid, modby_id;
EXEC SQL END DECLARE SECTION;
int returned, status;
- struct save_queue *sq, *sq_create();
+ struct save_queue *sq;
returned = rowcount = 0;
name = aargv[0];
EXEC SQL FETCH csr102 INTO :id;
if (sqlca.sqlcode)
break;
- sq_save_data(sq, (char *)id);
+ sq_save_data(sq, (void *)id);
rowcount++;
}
EXEC SQL CLOSE csr102;
{
status = 0;
free(argv[8]);
- argv[8] = strsave("NONE");
+ argv[8] = strdup("NONE");
}
else
{
status = 0;
free(argv[8]);
- argv[8] = strsave("???");
+ argv[8] = strdup("???");
}
if (status && status != MR_NO_MATCH)
return status;
*/
int get_ace_use(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
int found = 0;
EXEC SQL BEGIN DECLARE SECTION;
char *atype;
int aid, listid, id;
EXEC SQL END DECLARE SECTION;
- struct save_queue *sq, *sq_create();
+ struct save_queue *sq;
atype = argv[0];
aid = *(int *)argv[1];
sq = sq_create();
if (!strcmp(atype, "RLIST"))
{
- sq_save_data(sq, (char *)aid);
+ sq_save_data(sq, (void *)aid);
/* get all the list_id's of containing lists */
EXEC SQL DECLARE csr107 CURSOR FOR
SELECT list_id FROM imembers
EXEC SQL FETCH csr107 INTO :listid;
if (sqlca.sqlcode)
break;
- sq_save_unique_data(sq, (char *)listid);
+ sq_save_unique_data(sq, (void *)listid);
}
EXEC SQL CLOSE csr107;
/* now process each one */
EXEC SQL FETCH csr108 INTO :listid;
if (sqlca.sqlcode)
break;
- sq_save_data(sq, (char *)listid);
+ sq_save_data(sq, (void *)listid);
}
EXEC SQL CLOSE csr108;
/* now process each one */
EXEC SQL FETCH csr109 INTO :listid;
if (sqlca.sqlcode)
break;
- sq_save_data(sq, (char *)listid);
+ sq_save_data(sq, (void *)listid);
}
EXEC SQL CLOSE csr109;
/* now process each one */
* by get_ace_use above.
*/
-int get_ace_internal(char *atype, int aid, int (*action)(), int actarg)
+int get_ace_internal(char *atype, int aid,
+ int (*action)(int, char *[], void *), void *actarg)
{
char *rargv[2];
int found = 0;
*/
int get_lists_of_member(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
int found = 0, direct = 1;
char *rargv[6];
static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "grouplist" };
int qualified_get_lists(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
return qualified_get(q, argv, action, actarg, "l.list_id != 0",
"l", "name", lflags);
/* get_members_of_list - this gets only direct members */
int get_members_of_list(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
return gmol_internal(q, argv, cl, action, actarg, 1);
}
/* get_end_members_of_list - this gets direct or indirect members */
int get_end_members_of_list(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
return gmol_internal(q, argv, cl, action, actarg, 0);
}
**/
int gmol_internal(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg, int flag)
+ int (*action)(int, char *[], void *), void *actarg, int flag)
{
EXEC SQL BEGIN DECLARE SECTION;
- int list_id, member_id, direct;
- char member_name[129], member_type[9];
+ int list_id, direct;
+ char member_name[129];
EXEC SQL END DECLARE SECTION;
char *targv[2];
- int members;
/* true/false flag indicates whether to display only direct members. */
if (flag)
*/
int count_members_of_list(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
EXEC SQL BEGIN DECLARE SECTION;
int list, ct = 0;
static char *sflags[3] = { "enable", "inprogress", "harderror" };
int qualified_get_server(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *), void *actarg)
{
return qualified_get(q, argv, action, actarg, "s.name is not null",
"s", "name", sflags);
* flags - an array of strings, names of the flag variables
*/
-int qualified_get(struct query *q, char *argv[], int (*action)(), int actarg,
+int qualified_get(struct query *q, char *argv[],
+ int (*action)(int, char *[], void *), void *actarg,
char *start, char *range, char *field, char *flags[])
{
char qual[256];
"inprogress", "hosterror" };
int qualified_get_serverhost(struct query *q, char *argv[], client *cl,
- int (*action)(), int actarg)
+ int (*action)(int, char *[], void *),
+ void *actarg)
{
char qual[256], buf[32];
int i;
EXEC SQL BEGIN DECLARE SECTION;
char *login, *entity, directory[129], machname[33];
int who, rowcount, mid, uid, users_id, utype, list_id;
- int ostatus, nstatus, gidval, fsidval;
+ int ostatus, nstatus, fsidval;
static int m_id = 0, def_quota = 0;
EXEC SQL END DECLARE SECTION;
char buffer[256], *aargv[3];
-/* This file defines the query dispatch table for version 2 of the protocol
+/* $Id$
*
- * $Header$
+ * This file defines the query dispatch table for version 2 of the protocol
*
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
* <mit-copyright.h>.
*/
#undef ACE_NAME
#undef NAME
#include "query.h"
-#include "mr_et.h"
-
-/* Specialized Support Query Routines */
-
-/* Special Access Check Routines */
-int access_user();
-int access_login();
-int access_list();
-int access_visible_list();
-int access_vis_list_by_name();
-int access_member();
-int access_qgli();
-int access_service();
-int access_filesys();
-int access_host();
-int access_ahal();
-int access_snt();
-
-/* Query Setup Routines */
-int prefetch_value();
-int prefetch_filesys();
-int setup_ausr();
-int setup_dusr();
-int setup_spop();
-int setup_dpob();
-int setup_dmac();
-int setup_dsnet();
-int setup_dclu();
-int setup_alis();
-int setup_dlis();
-int setup_dsin();
-int setup_dshi();
-int setup_afil();
-int setup_ufil();
-int setup_dfil();
-int setup_aftg();
-int setup_dnfp();
-int setup_dqot();
-int setup_akum();
-int setup_dsnt();
-int setup_ahst();
-int setup_ahal();
-
-/* Query Followup Routines */
-int followup_fix_modby();
-int followup_ausr();
-int followup_gpob();
-int followup_glin();
-int followup_aqot();
-int followup_dqot();
-int followup_gzcl();
-int followup_gsha();
-int followup_gqot();
-int followup_gpce();
-int followup_guax();
-int followup_uuac();
-int followup_gsnt();
-int followup_ghst();
-
-int set_modtime();
-int set_modtime_by_id();
-int set_finger_modtime();
-int set_pobox_modtime();
-int set_uppercase_modtime();
-int set_mach_modtime_by_id();
-int set_cluster_modtime_by_id();
-int set_serverhost_modtime();
-int set_nfsphys_modtime();
-int set_filesys_modtime();
-int set_zephyr_modtime();
-
-/* Special Queries */
-int set_pobox();
-int get_list_info();
-int add_member_to_list();
-int delete_member_from_list();
-int get_ace_use();
-int qualified_get_lists();
-int get_members_of_list();
-int get_end_members_of_list();
-int qualified_get_server();
-int qualified_get_serverhost();
-int trigger_dcm();
-int count_members_of_list();
-int get_lists_of_member();
-int register_user();
-int _sdl_followup();
+#include "mr_et.h"
-\f
/* String compression
* These are commonly used strings in the table, defined here so that
* they can be shared.
{
0,
0,
- (char *)0,
- (char *)0,
+ NULL,
+ NULL,
0,
0,
0,
"INTO users (login, unix_uid, shell, last, first, middle, status, clearid, type, comments, signature, secure, users_id) VALUES ('%s', %s, '%s', NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), '%s', %d, LENGTH(NVL('%s', CHR(0))), %s, %s)", /* followup_ausr fixes signature field */
auac_fields,
12,
- (char *)0,
+ NULL,
0,
&auac_validate,
},
DELETE,
"u",
USERS_TABLE,
- (char *)0,
+ NULL,
dusr_fields,
0,
"users_id = %d",
DELETE,
"u",
USERS_TABLE,
- (char *)0,
+ NULL,
dubu_fields,
0,
"users_id = %d",
0,
spob_fields,
3,
- (char *)0,
+ NULL,
0,
&spob_validate,
},
DELETE,
"m",
MACHINE_TABLE,
- (char *)0,
+ NULL,
dhst_fields,
0,
"mach_id = %d",
DELETE,
"a",
HOSTALIAS_TABLE,
- (char *)0,
+ NULL,
ghal_fields,
0,
"name = UPPER('%s') AND mach_id = %d",
DELETE,
"s",
SUBNET_TABLE,
- (char *)0,
+ NULL,
dsnt_fields,
0,
"snet_id = %d",
DELETE,
"c",
CLUSTER_TABLE,
- (char *)0,
+ NULL,
dclu_fields,
0,
"clu_id = %d",
"INTO svc (clu_id, serv_label, serv_cluster) VALUES (%d, '%s', '%s')",
acld_fields,
3,
- (char *)0,
+ NULL,
0,
&acld_validate,
},
DELETE,
"svc",
SVC_TABLE,
- (char *)0,
+ NULL,
acld_fields,
0,
"clu_id = %d AND serv_label = '%s' AND serv_cluster = '%s'",
DELETE,
"l",
LIST_TABLE,
- (char *)0,
+ NULL,
dlis_fields,
0,
"list_id = %d",
0,
amtl_fields,
3,
- (char *)0,
+ NULL,
0,
&amtl_validate,
},
DELETE,
0,
IMEMBERS_TABLE,
- (char *)0,
+ NULL,
amtl_fields,
0,
0,
"get_members_of_list",
"gmol",
RETRIEVE,
- (char *)0,
+ NULL,
IMEMBERS_TABLE,
- (char *)0,
+ NULL,
gmol_fields,
2,
- (char *)0,
+ NULL,
1,
&gmol_validate,
},
"get_end_members_of_list",
"geml",
RETRIEVE,
- (char *)0,
+ NULL,
IMEMBERS_TABLE,
- (char *)0,
+ NULL,
gmol_fields,
2,
- (char *)0,
+ NULL,
1,
&geml_validate,
},
"INTO servers (name, update_int, target_file, script, type, enable, acl_type, acl_id) VALUES (UPPER('%s'), %s, '%s', '%s', '%s', %s, '%s', %d)",
asin_fields,
8,
- (char *)0,
+ NULL,
0,
&asin_validate,
},
DELETE,
"s",
SERVERS_TABLE,
- (char *)0,
+ NULL,
dsin_fields,
0,
"name = UPPER('%s')",
"INTO serverhosts (service, mach_id, enable, value1, value2, value3) VALUES (UPPER('%s'), %d, %s, %s, %s, NVL('%s', CHR(0)))",
ashi_fields,
6,
- (char *)0,
+ NULL,
0,
&ashi_validate,
},
DELETE,
"sh",
SERVERHOSTS_TABLE,
- (char *)0,
+ NULL,
dshi_fields,
0,
"service = UPPER('%s') AND mach_id = %d",
DELETE,
"fs",
FILESYS_TABLE,
- (char *)0,
+ NULL,
dfil_fields,
0,
"filsys_id = %d",
"INTO fsgroup (group_id, filsys_id, key) VALUES (%d, %d, '%s')",
gfgm_fields,
3,
- (char *)0,
+ NULL,
0,
&aftg_validate,
},
DELETE,
"fg",
FSGROUP_TABLE,
- (char *)0,
+ NULL,
gfgm_fields,
0,
"group_id = %d AND filsys_id = %d",
DELETE,
"np",
NFSPHYS_TABLE,
- (char *)0,
+ NULL,
dnfp_fields,
0,
"mach_id = %d AND dir = '%s'",
"INTO quota (filsys_id, type, entity_id, quota, phys_id) VALUES ('%s', %d, %d, %s, %s)",
aqot_fields,
4,
- (char *)0,
+ NULL,
0,
&aqot_validate,
},
DELETE,
0,
QUOTA_TABLE,
- (char *)0,
+ NULL,
aqot_fields,
0,
0,
"INTO quota (type, filsys_id, entity_id, quota, phys_id ) VALUES ('USER', %d, %d, %s, %s)",
anfq_fields,
3,
- (char *)0,
+ NULL,
0,
&anfq_validate,
},
DELETE,
0,
QUOTA_TABLE,
- (char *)0,
+ NULL,
anfq_fields,
0,
0,
"INTO services (name, protocol, port, description) VALUES ('%s', '%s', %s, NVL('%s', CHR(0)))",
asvc_fields,
4,
- (char *)0,
+ NULL,
0,
&asvc_validate,
},
"INTO alias (name, type, trans) VALUES ('%s', '%s', '%s')",
aali_fields,
3,
- (char *)0,
+ NULL,
0,
&aali_validate,
},
DELETE,
"a",
ALIAS_TABLE,
- (char *)0,
+ NULL,
aali_fields,
0,
"name = '%s' AND type = '%s' AND trans = '%s'",
"INTO numvalues (name, value) VALUES ('%s', %s)",
aval_fields,
2,
- (char *)0,
+ NULL,
0,
&aval_validate,
},
DELETE,
"val",
NUMVALUES_TABLE,
- (char *)0,
+ NULL,
dval_fields,
0,
"name = '%s'",
"table_name, appends, updates, deletes, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS') FROM tblstats",
gats_fields,
5,
- (char *)0,
+ NULL,
0,
0,
},
"_set_debug_level",
"_sdl",
UPDATE,
- (char *)0,
+ NULL,
0,
- (char *)0,
+ NULL,
_sdl_fields,
1,
- (char *)0,
+ NULL,
0,
&_sdl_validate,
},
-/* $Header$
+/* $Id$
*
* Structures and constants used in the query dispatch table
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
/* Query Types */
/* values field containing current max object id */
char *object_id;
/* routine to verify access permission on objects */
- int (*acs_rtn)();
+ int (*acs_rtn)(struct query *q, char *Argv[], client *cl);
/* pre-processing routine (var setup only) */
- int (*pre_rtn)();
+ int (*pre_rtn)(struct query *q, char *Argv[], client *cl);
/* post-processing routine */
int (*post_rtn)();
};
/* Validated Object Types */
-enum vo_type {V_NAME, V_ID, V_TYPE, V_TYPEDATA, V_DATE,
+enum vo_type {V_NAME, V_ID, V_TYPE, V_TYPEDATA,
V_SORT, V_RENAME, V_CHAR, V_LOCK, V_WILD, V_UPWILD,
V_RLOCK, V_LEN};
int set_next_object_id(char *objectx, enum tables table, int limit);
/* prototypes from qsubs.c */
-void list_queries(int version, int (*action)(), char *actarg);
-void help_query(struct query *q, int (*action)(), char *actarg);
+void list_queries(int version, int (*action)(int, char *[], void *),
+ void *actarg);
+void help_query(struct query *q, int (*action)(int, char *[], void *),
+ void *actarg);
struct query *get_query_by_name(char *name, int version);
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Argument validation routines
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
-#include <unistd.h>
#include "mr_server.h"
#include "query.h"
+#include "qrtn.h"
+
#include <ctype.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE sqlda;
-#include "qrtn.h"
+
+RCSID("$Header$");
extern char *whoami, *table_name[], *sqlbuffer[QMAXARGS];
extern int dbms_errno, mr_errcode;
int convert_wildcards_uppercase(char *arg);
extern SQLDA *sqlald(int, int, int);
+SQLDA *mr_alloc_sqlda(void);
EXEC SQL WHENEVER SQLERROR DO dbmserr();
int validate_chars(char *argv[], struct valobj *vo)
{
char *s = argv[vo->index];
- int arg;
EXEC SQL BEGIN DECLARE SECTION;
int len;
char *tname, *cname;
/* check for bad characters */
while (*s)
{
- if (illegalchars[*s++])
+ if (illegalchars[(int)*s++])
return MR_BAD_CHAR;
}
c = val = argv[vo->index];
while (*c)
{
- if (illegalchars[*c++])
+ if (illegalchars[(int)*c++])
return MR_BAD_CHAR;
}
char *sqlbuffer[QMAXARGS];
/* Dynamic SQL support routines */
-SQLDA *mr_alloc_sqlda()
+SQLDA *mr_alloc_sqlda(void)
{
SQLDA *it;
int j;
int add_string(char *nm)
{
EXEC SQL BEGIN DECLARE SECTION;
- char buf[256], *name = nm;
+ char *name = nm;
int id;
EXEC SQL END DECLARE SECTION;
id++;
EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :nm);
+ EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
return id;
}
-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- * This program starts the moira server in a "clean" environment.
- * and then waits for it to exit.
+ * This program starts the moira server in a "clean" environment.
+ * and then waits for it to exit.
*
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_mr_starter_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/resource.h>
+#include <sys/wait.h>
+
#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <moira_site.h>
+#include <unistd.h>
+RCSID("$Header$");
#define PROG "moirad"
int rdpipe[2];
-extern int errno;
char *whoami;
+void cleanup(void);
void cleanup(void)
{
{
char buf[BUFSIZ];
FILE *log, *prog;
- int logf, inf, i, done, pid, tty;
+ int logf, inf, i, done, pid;
struct rlimit rl;
- extern int errno;
- extern char *sys_errlist[];
-
struct sigaction action;
int nfds;
if (errno && errno != EINTR)
{
strcpy(buf, "Unable to read from program: ");
- strcat(buf, sys_errlist[errno]);
+ strcat(buf, strerror(errno));
strcat(buf, "\n");
}
else
#
SRCS= auth_002.c checksum.c client.c config.c exec_002.c \
- get_file.c hostname.c log.c send_file.c ticket.c \
+ get_file.c log.c send_file.c ticket.c \
update_server.c update_test.c xfer_002.c xfer_003.c
SRCDIR=${SRCTOP}/update
CODE=${SRCS} Imakefile
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_auth_002_c = "$Header$";
-#endif
#include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/utsname.h>
+
+#include <errno.h>
#include <stdio.h>
-#include <string.h>
+
#include <gdb.h>
#include <krb.h>
-#include <krb_et.h>
-#include <netinet/in.h>
-#include <errno.h>
-#ifdef POSIX
-#include <sys/utsname.h>
-#endif
+
+RCSID("$Header$");
extern char buf[BUFSIZ];
extern int have_authorization;
-extern struct sockaddr_in *client_address();
extern CONNECTION conn;
extern int code;
-extern char *PrincipalHostname();
static char service[] = "rcmd";
static char master[] = "sms";
static char qmark[] = "???";
int auth_002(char *str)
{
STRING data;
- char realm[REALM_SZ];
char aname[ANAME_SZ], ainst[INST_SZ], arealm[REALM_SZ];
AUTH_DAT ad;
- char *p, *first, *config_lookup();
+ char *p, *first;
KTEXT_ST ticket_st;
struct utsname name;
des_key_schedule sched;
* authenticator we received, then accept it. If there's no
* auth record, assume [master]@[local realm].
*/
- if (first = p = config_lookup("auth"))
+ if ((first = p = config_lookup("auth")))
{
do
{
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_checksum_c = "$Header$";
-#endif
#include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
+
+RCSID("$Header$");
/*
* checksum_fd(fd)
-/*
- * $Source$
- * $Header$
- */
-
-#ifndef lint
-static char *rcsid_client2_c = "$Header$";
-#endif lint
-
-/*
- * MODULE IDENTIFICATION:
- * $Header$
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- * DESCRIPTION:
- * This code handles the actual distribution of data files
- * to servers in the Moira server-update program.
- * AUTHOR:
- * Ken Raeburn (spook@athena.MIT.EDU),
- * MIT Project Athena/MIT Information Systems.
- * DEFINED VALUES:
- * conn
- * mr_update_server
+/* $Id$
+ *
+ * This code handles the actual distribution of data files
+ * to servers in the Moira server-update program.
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
+#include <moira.h>
+#include "update.h"
+
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+
+#include <des.h>
#include <gdb.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <update.h>
-#include <errno.h>
-#include <moira.h>
-#include <moira_site.h>
#include <krb.h>
-extern int errno, dbg;
-extern C_Block session;
+RCSID("$Header$");
-static char buf[BUFSIZ];
-static int code;
+extern int dbg;
+extern C_Block session;
CONNECTION conn;
-
-/*
- * FUNCTION:
- * initialize()
- * DESCRIPTION:
- * Insures that various libraries have a chance to get
- * initialized.
- * INPUT:
- * OUTPUT:
- * RETURN VALUE:
- * void
- * SIDE EFFECTS:
- * Initializes GDB library.
- * PROBLEMS:
- *
- */
-static void initialize()
-{
- static int initialized = 0;
-
- if (!initialized)
- {
- gdb_init();
- initialized++;
- }
-}
-
int send_auth(char *host_name)
{
KTEXT_ST ticket_st;
return MR_SUCCESS;
}
-send_quit(void)
+void send_quit(void)
{
STRING str;
if (!conn)
-/* $Header$
+/* $Id$
*
* Routines to handle configuration file for Moira's update_server.
* These routines must load the file into memory rather than parse
* it each time as one of the things the server may do is chroot()
* itself.
*
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
* For copying and distribution information, please see the file
* <mit-copyright.h>.
*/
#include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <moira.h>
+#include <unistd.h>
+RCSID("$Header$");
#define CONFIG_FILE "/etc/athena/moira.conf"
static char **config_keys, **config_values;
-static init()
+static int init(void)
{
int fd, count = 0;
struct stat st;
- char *p, *start;
+ char *p;
/* Only execute once */
if (config_buf)
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_exec_002_c = "$Header$";
-#endif
#include <mit-copyright.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
+#include <moira.h>
+#include "update_server.h"
+#include "update.h"
+
#include <sys/wait.h>
+
+#include <errno.h>
#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
#include <gdb.h>
-#include <moira.h>
-#include "update.h"
+
+RCSID("$Header$");
extern CONNECTION conn;
-extern int code, errno, uid, log_priority, have_authorization;
+extern int code, uid, log_priority, have_authorization;
extern char *whoami;
int exec_002(char *str)
exit(1);
}
}
+ return 0;
}
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_get_file_c = "$Header$";
-#endif
#include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <des.h>
-#include <krb.h>
#include <moira.h>
+#include "update_server.h"
#include "update.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <des.h>
+#include <gdb.h>
+
+RCSID("$Header$");
+
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif /* MIN */
extern CONNECTION conn;
extern char buf[BUFSIZ];
-extern int code, errno, uid;
+extern int code, uid;
extern char *whoami;
extern int have_authorization, have_file, done;
static des_key_schedule sched;
static des_cblock ivec;
-static int get_block();
+static int get_block(int fd, int max_size, int encrypt);
/*
* get_file()
}
n_written += n_wrote;
}
- lseek(fd, 0, L_SET);
+ lseek(fd, 0, SEEK_SET);
if (send_ok())
lose("sending okay for file transfer (get_file)");
if (encrypt)
+++ /dev/null
-/*
- * $Source$
- * $Header$
- */
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_hostname_c = "$Header$";
-#endif lint
-
-/* PrincipalHostname, borrowed from rcmd.c in Kerberos code */
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <string.h>
-
-char *PrincipalHostname(char *alias)
-{
- struct hostent *h;
- char *phost = alias;
- if ((h = gethostbyname(alias)))
- {
- char *p = strchr(h->h_name, '.');
- if (p)
- *p = NULL;
- p = phost = h->h_name;
- do
- {
- if (isupper(*p))
- *p = tolower(*p);
- }
- while (*p++);
- }
- return phost;
-}
-/*
- * $Source$
- * $Header$
- */
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_log_c = "$Header$";
-#endif
-
-/*
+/* $Id$
+ *
* handle logging for dcm and update server
*
- * this should eventually use zephyr
- */
-
-/*
- * define syslog for using syslog,
- * default to tty
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
#include <stdio.h>
-#include "com_err.h"
#include <stdarg.h>
+
#include "update.h"
-#include <krb.h>
#ifdef use_syslog
#include <syslog.h>
#define use_tty
#endif
+RCSID("$Header$");
+
+void mr_update_com_err_hook(const char *whoami, long code,
+ const char *fmt, va_list args);
+
#ifdef use_syslog
int syslog_prio[] = {
LOG_DEBUG,
const char *fmt, va_list args)
{
char buf[BUFSIZ], *cp;
- FILE _strbuf;
#ifndef use_syslog
strcpy(buf, whoami);
#endif
}
-mr_update_initialize(void)
+void mr_update_initialize(void)
{
static int initialized = 0;
if (initialized)
static char fmt[] = "[%s] %s";
#define def(name, level, prio) \
-name(char *msg)\
+void name(char *msg)\
{\
int old_prio; \
old_prio = log_priority; \
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_send_file_c = "$Header$";
-#endif
#include <mit-copyright.h>
-#include <stdio.h>
-#include <com_err.h>
-#include <gdb.h>
#include <moira.h>
-#include <sys/file.h>
+#include "update_server.h"
+
#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
#include <des.h>
-#include <krb.h>
+#include <gdb.h>
#include <update.h>
-#include <fcntl.h>
+
+RCSID("$Header$");
extern CONNECTION conn;
-extern int errno;
char buf[BUFSIZ];
extern C_Block session;
extern char *whoami;
-/* $Header$ */
-
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ */
#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/file.h>
+#include <moira.h>
+
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
#include <des.h>
+
+RCSID("$Header$");
+
int debug = 0; /* goddamn des library breakage */
char string[] = "sms\0\0Athena\0\1";
char srvtab[] = "/etc/srvtab";
{
int fd;
C_Block key;
- char *tty, *ttyname();
+ char *tty;
tty = ttyname(0);
if (!tty || strcmp(tty, "/dev/console"))
{
perror(srvtab);
close(fd);
printf("\nKey written.\n");
+ exit(0);
}
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_ticket_c = "$Header$";
-#endif
#include <mit-copyright.h>
-#include <stdio.h>
-#include <krb.h>
-#include <sys/types.h>
+#include <moira.h>
+
#include <sys/stat.h>
+
+#include <stdio.h>
#include <string.h>
+
+#include <krb.h>
#include <update.h>
-#include <com_err.h>
-#include <krb_et.h>
+
+RCSID("$Header$");
extern char *whoami;
static char service[ANAME_SZ] = "rcmd";
C_Block session;
+int get_mr_tgt(void);
-static init(void)
+static void init(void)
{
static int initialized = 0;
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_dispatch_c = "$Header$";
-#endif
#include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/stat.h>
+
+#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <gdb.h>
-#include <errno.h>
#include <string.h>
-#include <pwd.h>
-#include <moira.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#ifdef POSIX
-#include <termios.h>
-#endif
-#include "update.h"
-#include "des.h"
+#include <unistd.h>
-extern int auth_002(), xfer_002(), xfer_003(), exec_002();
+#include <des.h>
+#include <gdb.h>
+#include "update.h"
-extern int sync_proc(), quit();
-extern char *config_lookup();
+RCSID("$Header$");
-extern void gdb_debug();
extern int errno;
CONNECTION conn;
struct _dt {
char *str;
- int (*proc)();
+ int (*proc)(char *);
} dispatch_table[] = {
{ "AUTH_002", auth_002 },
{ "XFER_002", xfer_002 },
{ "XFER_003", xfer_003 },
{ "EXEC_002", exec_002 },
{ "quit", quit },
- { NULL, (int (*)())abort }
+ { NULL, (int (*)(char *))abort }
};
/* general scratch space -- useful for building error messages et al... */
STRING str;
struct _dt *d;
char *p;
- int n;
whoami = strrchr(argv[0], '/');
if (whoami)
}
-initialize(void)
+void initialize(void)
{
/* keep have_authorization around */
have_file = 0;
* put <msg> to log as error, break connection, and exit
*/
-lose(char *msg)
+void lose(char *msg)
{
com_err(whoami, code, msg);
if (conn)
* send back (external) <code>; if error, punt big with <lose(msg)>
*/
-report_error(char *msg)
+void report_error(char *msg)
{
code = send_object(conn, (char *)&code, INTEGER_T);
if (code)
* set (external) <code> to <c> and call <report_error>
*/
-reject_call(int c)
+void reject_call(int c)
{
code = c;
report_error("call rejected");
--- /dev/null
+/* prototypes for the update_server */
+
+int auth_002(char *str);
+int exec_002(char *str);
+int xfer_002(char *str);
+int xfer_003(char *str);
+
+/* from checksum.c */
+int checksum_file(char *path);
+
+/* from config.c */
+char *config_lookup(char *key);
+
+/* from get_file.c */
+int get_file(char *pathname, int file_size, int checksum,
+ int mode, int encrypt);
+
+/* from log.c */
+void mr_update_initialize(void);
+void mr_log_error(char *msg);
+void mr_log_warning(char *msg);
+void mr_log_info(char *msg);
+void mr_debug(char *msg);
+
+/* from update_server.c */
+void initialize(void);
+int send_ok(void);
+int quit(char *str);
+void lose(char *msg);
+void report_error(char *msg);
+void reject_call(int c);
-/* $Header$
+/* $Id$
*
* Test client for update_server protocol.
*
- * Reads commands from the command line:
- * test host [commands...]
- * -s file file sends file to host
- * -S file file sends encrypted file to host
- * -i file sends instruction file to host
- * -x file executes instructions
- * -n nop
+ * Copyright 1992-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
#include <mit-copyright.h>
+#include <moira.h>
+#include <update.h>
+
#include <stdio.h>
-#include <string.h>
+#include <stdlib.h>
+
#include <gdb.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <update.h>
-#include <errno.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <krb.h>
+
+void usage(void);
CONNECTION conn;
char *whoami;
int main(int argc, char **argv)
{
char *host, service_address[256], *file, *rfile, buf[256];
- int code, i, count = 0;
+ int code, i;
whoami = argv[0];
initialize_sms_error_table();
exit(code);
}
-usage(void)
+void usage(void)
{
fprintf(stderr, "Usage: test host [commands...]\n");
fprintf(stderr, " Commands are:\n");
-/*
- * $Source$
- * $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/* For copying and distribution information, please see the file */
-/* <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_xfer_002_c = "$Header$";
-#endif
#include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
+#include <moira.h>
+#include "update_server.h"
+
#include <ctype.h>
-#include <sys/param.h>
-#include <sys/file.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <moira.h>
+
+#include <gdb.h>
+
+RCSID("$Header$");
extern CONNECTION conn;
extern char buf[BUFSIZ];
-extern int code, errno;
+extern int code;
extern int have_authorization, have_file, done;
-/*
- * $Source$
- * $Header$
- */
-/* (c) Copyright 1988, 1992 by the Massachusetts Institute of Technology.
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char *rcsid_xfer_002_c = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
+#include <moira.h>
+#include "update_server.h"
+
#include <ctype.h>
-#include <sys/param.h>
-#include <sys/file.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <moira.h>
+
+#include <gdb.h>
+
+RCSID("$Header$");
extern CONNECTION conn;
extern char buf[BUFSIZ];
-extern int code, errno;
+extern int code;
extern int have_authorization, have_file, done;