/* Define to compile with Kerberos support. */
#undef HAVE_KRB4
-/* Define to compile with Kerberos v5 support. */
-#undef HAVE_KRB5
-
-/* Define to 1 if `enc_part2' is member of `krb5_ticket'. */
-#undef HAVE_KRB5_TICKET_ENC_PART2
-
-/* Define to 1 if `keyblock.enctype' is member of `krb5_creds'. */
-#undef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
-
-/* Define to 1 if you have the `krb5_c_make_checksum' function. */
-#undef HAVE_KRB5_C_MAKE_CHECKSUM
-
-/* Define to 1 if you have the `krb5_cc_set_default_name' function. */
-#undef HAVE_KRB5_CC_SET_DEFAULT_NAME
-
-/* Define to 1 if `krb5_auth_con_getauthenticator' takes a double pointer third arg. */
-#undef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
-
-/* Define to 1 if you have the <krb5_err.h> header file. */
-#undef HAVE_KRB5_ERR_H
-
-/* Define to 1 if you have the `krb5_free_data' function. */
-#undef HAVE_KRB5_FREE_DATA
-
-/* Define to 1 if you have the <krb5/ss.h> header file. */
-#undef HAVE_KRB5_SS_H
-
-/* Define to 1 if you have the `krb_get_err_text' function. */
-#undef HAVE_KRB_GET_ERR_TEXT
-
-/* Define to 1 if you have the `krb_log' function. */
-#undef HAVE_KRB_LOG
-
/* Define to compile with ares support. */
#undef HAVE_ARES
SHELL = /bin/sh
-SUBDIRS=zaway zctl zleave zlocate znol \
- zshutdown_notify zstat zwrite
+SUBDIRS=@XCLIENTS@ zaway zctl zleave zlocate zmailnotify znol \
+ zpopnotify zshutdown_notify zstat zwrite
all:
for i in ${SUBDIRS}; do (cd $$i; ${MAKE} $@) || exit 1; done
--- /dev/null
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Command.h>
+
+#include "GetString.h"
+
+#define XVCMW XtVaCreateManagedWidget
+
+static int accepted, cancelled;
+static void Accept(), Cancel(), Focus();
+
+extern void Popup();
+
+static XtActionsRec actionTable[] = {
+ {"Accept", (XtActionProc) Accept},
+ {"Cancel", (XtActionProc) Cancel},
+ {"Focus", (XtActionProc) Focus},
+};
+
+Widget InitGetString(parent, name)
+ Widget parent;
+ char *name;
+{
+ static int first_time = 1;
+ Widget getStringWindow, form, title, edit, accept, cancel;
+
+ if (first_time) {
+ XtAppAddActions(XtWidgetToApplicationContext(parent), actionTable,
+ XtNumber(actionTable));
+ first_time = 0;
+ };
+
+ getStringWindow = XtVaCreatePopupShell(name, transientShellWidgetClass,
+ parent,
+ XtNinput, True,
+ NULL);
+ form = XVCMW("getStringForm", formWidgetClass, getStringWindow, NULL);
+ title = XVCMW("getStringTitle", labelWidgetClass, form, NULL);
+ edit = XVCMW("getStringEdit", asciiTextWidgetClass, form, NULL);
+ accept = XVCMW("getStringAccept", commandWidgetClass, form, NULL);
+ cancel = XVCMW("getStringCancel", commandWidgetClass, form, NULL);
+ XtSetKeyboardFocus(form, edit);
+
+ return getStringWindow;
+}
+
+int GetString(getStringWindow, label, value, pop_type, buf, len)
+ Widget getStringWindow;
+ String label, value;
+ int pop_type;
+ char *buf;
+ int len;
+{
+ XtAppContext app_con;
+ Widget title, edit;
+ XEvent event;
+
+ app_con = XtWidgetToApplicationContext(getStringWindow);
+ title = XtNameToWidget(getStringWindow, "getStringForm.getStringTitle");
+ edit = XtNameToWidget(getStringWindow, "getStringForm.getStringEdit");
+
+ XtVaSetValues(title, XtNlabel, label, NULL);
+ XtVaSetValues(edit, XtNstring, value, NULL);
+
+ XtRealizeWidget(getStringWindow);
+ Popup(getStringWindow, XtGrabExclusive, pop_type);
+
+ accepted = cancelled = 0;
+ while (! accepted && ! cancelled) {
+ XtAppNextEvent(app_con, &event);
+ XtDispatchEvent(&event);
+ }
+
+ XtPopdown(getStringWindow);
+
+ if (accepted) {
+ char *s;
+ Widget text_source;
+
+ XtVaGetValues(edit, XtNstring, (XtArgVal) &s, XtNtextSource,
+ (XtArgVal) &text_source, NULL);
+ strncpy(buf, s, len-2);
+ buf[len-1] = '\0';
+ XawAsciiSourceFreeString(text_source);
+
+ return GETSTRING_ACCEPT;
+ }
+ else
+ return GETSTRING_CANCEL;
+}
+
+/* ARGSUSED */
+static void Accept(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ accepted = 1;
+}
+
+/* ARGSUSED */
+static void Cancel(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ cancelled = 1;
+}
+
+/* ARGSUSED */
+static void Focus(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ XSetInputFocus(XtDisplay(w), XtWindow(w), RevertToPointerRoot,
+ CurrentTime);
+}
--- /dev/null
+#include <X11/Intrinsic.h>
+
+#define GETSTRING_ACCEPT -1000
+#define GETSTRING_CANCEL -1001
+
+Widget InitGetString();
+int GetString();
+
+
--- /dev/null
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+top_builddir=../..
+
+includedir=${prefix}/include
+mandir=@mandir@
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
+CC=@CC@
+INSTALL=@INSTALL@
+at=@
+
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
+LIBDYN=${BUILDTOP}/libdyn/libdyn.a
+CPPFLAGS=@CPPFLAGS@
+CFLAGS=@CFLAGS@
+ALL_CFLAGS=${CFLAGS} -DDATADIR=\"${datadir}\" -I${top_srcdir}/h \
+ -I${BUILDTOP}/h @X_CFLAGS@ ${CPPFLAGS}
+LDFLAGS=@X_LIBS@ @LDFLAGS@
+LIBS=${LIBZEPHYR} ${LIBDYN} -lXaw -lXmu -lXt @X_PRE_LIBS@ -lX11 -lXext \
+ @X_EXTRA_LIBS@ @LIBS@ -lcom_err
+
+OBJS= interface.o resource.o destlist.o util.o bfgets.o gethomedir.o \
+ dest_window.o xzwrite.o edit_window.o zephyr.o GetString.o Popup.o \
+ yank.o menu_window.o logins.o
+
+all: xzwrite XZwrite
+
+xzwrite: ${OBJS} ${LIBZEPHYR} ${LIBDYN}
+ ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+.c.o:
+ ${CC} -c ${ALL_CFLAGS} $<
+
+XZwrite: XZwrite.in
+ rm -f XZwrite
+ sed -e 's,$(at)datadir$(at),$(datadir),' < ${srcdir}/XZwrite.in \
+ > XZwrite
+
+check:
+
+install: xzwrite XZwrite
+ ${LIBTOOL} --mode=install ${INSTALL} -m 755 xzwrite ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/xzwrite.1 ${DESTDIR}${mandir}/man1
+ ${INSTALL} -m 644 XZwrite ${DESTDIR}${datadir}/zephyr
+ ${INSTALL} -m 644 ${srcdir}/xzwrite.bitmap ${DESTDIR}${datadir}/zephyr
+
+clean:
+ ${LIBTOOL} --mode=clean rm -f xzwrite
+ rm -f ${OBJS}
+
+${OBJS}: xzwrite.h xzwrite-proto.h ${top_srcdir}/h/sysdep.h
+${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h
+destlist.o logins.o xzwrite.o zephyr.o: ${top_srcdir}/h/dyn.h
+
+.PHONY: all check install clean
+
--- /dev/null
+/*
+ * This code has gone back and forth between myself and Jon Kamens
+ * so many times that neither really knows who wrote it..
+ */
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+static void _initPopup();
+void Popup(), PopupSafe(), PopupAtPointer();
+
+static int display_height, display_width;
+
+static void _initPopup(w)
+ Widget w;
+{
+ Display *dpy;
+ int screen;
+
+ dpy = XtDisplay(w);
+ screen = DefaultScreen(dpy);
+ display_height = DisplayHeight(dpy, screen);
+ display_width = DisplayWidth(dpy, screen);
+}
+
+/* ARGSUSED */
+void Popup(shell, GrabType, pop_type)
+ Widget shell;
+ XtGrabKind GrabType;
+ int pop_type;
+{
+ PopupAtPointer(shell, GrabType);
+}
+
+void PopupSafe(w, x, y, GrabType)
+ Widget w;
+ Dimension x, y;
+ XtGrabKind GrabType;
+{
+ static int first_time = 1;
+ Dimension width, height, border;
+
+ if (first_time) {
+ _initPopup(w);
+ first_time = 0;
+ }
+
+ XtVaGetValues(w,
+ XtNwidth, &width,
+ XtNheight, &height,
+ XtNborderWidth, &border,
+ NULL);
+
+ if (x + width + 2 * border > display_width)
+ x = display_width - width - 2 * border;
+ if (y + height + 2 * border > display_height)
+ y = display_height - height - 2 * border;
+
+ XtVaSetValues(w,
+ XtNx, x,
+ XtNy, y,
+ NULL);
+
+ XtPopup(w, GrabType);
+}
+
+void PopupAtPointer(w, GrabType)
+ Widget w;
+ XtGrabKind GrabType;
+{
+ Window garbage1, garbage2, window;
+ int root_x, root_y, x2, y2;
+ unsigned int mask;
+ Dimension width, height, border;
+ Display *dpy;
+
+ dpy = XtDisplay(w);
+ window = XtWindow(XtParent(w));
+
+ if (XQueryPointer(dpy, window, &garbage1, &garbage2,
+ &root_x, &root_y, &x2, &y2, &mask)) {
+
+ XtVaGetValues(w,
+ XtNwidth, &width,
+ XtNheight, &height,
+ XtNborderWidth, &border,
+ NULL);
+
+ if (root_x >= width / 2 + border)
+ root_x -= width / 2 + border;
+ else
+ root_x = 0;
+ if (root_y >= height / 2 + border)
+ root_y -= height / 2 + border;
+ else
+ root_y = 0;
+
+ PopupSafe(w, (Dimension) root_x, (Dimension) root_y, GrabType);
+ }
+}
--- /dev/null
+! @configure_input@
+
+*resize: on
+*allowShellResize: on
+
+*reverseVideo: on
+*maxYanks: 25
+*ping: on
+*verbose: on
+*auth: on
+*yankDest: off
+*addGlobals: on
+*classInst: on
+*closeOnSend: off
+*trackLogins: on
+*pongScan: off
+*readAnyone: on
+*readXzwrite: on
+
+*icon.bitmap: @datadir@/zephyr/xzwrite.bitmap
+*icon.translations: #override\
+ <BtnDown>: set() \n\
+ <Btn1Up>: OpenSend() unset() \n\
+ Ctrl<Btn2Up>: Quit() \n\
+ <Btn3Up>: OpenMenu() unset()
+
+*sendForm.defaultDistance: -1
+*sendForm.borderWidth: 0
+
+*sendClose.label: Close Window
+*sendClose.top: ChainTop
+*sendClose.bottom: ChainTop
+*sendClose.left: ChainLeft
+*sendClose.right: ChainRight
+*sendClose.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: CloseSend() unset() \n\
+
+*editPane.fromVert: sendClose
+*editPane.top: ChainTop
+*editPane.bottom: ChainBottom
+*editPane.left: ChainLeft
+
+*editTitle.showGrip: false
+*editTitle.borderWidth: 0
+
+*editForm.showGrip: false
+*editForm.borderWidth: 2
+*editForm.borderColor: black
+
+*editSend.label: Send Message
+*editSend.left: ChainLeft
+*editSend.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: YankStore() SendMessage() unset() \n\
+
+*editClear.label: Clear Editor
+*editClear.fromHoriz: editSend
+*editClear.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: ClearEditor() unset() \n\
+
+*editPrev.label: Yank-Prev
+*editPrev.fromHoriz: editClear
+*editPrev.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: YankPrev() unset() \n\
+
+*editNext.label: Yank-Next
+*editNext.fromHoriz: editPrev
+*editNext.right: ChainRight
+*editNext.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: YankNext() unset() \n\
+
+*editor.height: 130
+*editor*editType: edit
+*editor*wrap: never
+*editor*autoFill: true
+*editor*useStringInPlace: false
+*editor.translations: #override\
+ Ctrl<Key>Return: YankStore() SendMessage() ClearEditor() \n\
+ Ctrl<Key>Y: YankStore() YankPrev() \n\
+ Meta<Key>O: YankStore() YankPrev() \n\
+ Meta<Key>P: YankPrev() \n\
+ Meta<Key>N: YankNext()
+
+*destForm.borderWidth: 0
+*destForm.defaultDistance: 0
+*destForm.fromVert: sendClose
+*destForm.top: ChainTop
+*destForm.bottom: ChainBottom
+*destForm.right: ChainRight
+*destForm.fromHoriz: editPane
+
+*destScroll.top: ChainTop
+*destScroll.bottom: ChainBottom
+*destScroll.left: ChainLeft
+*destScroll.right: ChainRight
+*destScroll.height: 178
+*destScroll.resizable: false
+*destScroll.allowVert: true
+*destScroll.allowHoriz: false
+*destScroll.forceBars: true
+
+*destList.forceColumns: on
+*destList.defaultColumns: 1
+*destList.translations: #override\
+ <Motion>: Set() \n\
+ <Btn1Up>: Set() SelectDest() Unset() \n\
+ <Btn2Up>: CreateDest() \n\
+ <Btn3Up>: Set() DeleteDest() Unset() \n\
+ <LeaveWindow>: Unset()
+
+*menuClose.label: Close Window
+*menuClose.top: ChainTop
+*menuClose.left: ChainLeft
+*menuClose.right: ChainRight
+*menuClose.width: 200
+*menuClose.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: CloseMenu() unset() \n\
+
+*signature.label: Change Signature
+*signature.fromVert: menuClose
+*signature.left: ChainLeft
+*signature.right: ChainRight
+*signature.width: 200
+*signature.translations: #override\
+ <BtnDown>: set() \n\
+ <BtnUp>: Signature()
+
+*clearOnSend.label: Clear On Send
+*clearOnSend.fromVert: signature
+*clearOnSend.left: ChainLeft
+*clearOnSend.right: ChainRight
+*clearOnSend.width: 200
+*clearOnSend.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*closeOnSend.label: Close On Send
+*closeOnSend.fromVert: clearOnSend
+*closeOnSend.left: ChainLeft
+*closeOnSend.right: ChainRight
+*closeOnSend.width: 200
+*closeOnSend.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*pings.label: Pings
+*pings.fromVert: closeOnSend
+*pings.left: ChainLeft
+*pings.right: ChainRight
+*pings.width: 200
+*pings.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*verbose.label: Verbose
+*verbose.fromVert: pings
+*verbose.left: ChainLeft
+*verbose.right: ChainRight
+*verbose.width: 200
+*verbose.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*authentic.label: Authenticate
+*authentic.fromVert: verbose
+*authentic.left: ChainLeft
+*authentic.right: ChainRight
+
+*authentic.width: 200
+*authentic.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*yankDest.label: Yank Destinations
+*yankDest.fromVert: authentic
+*yankDest.left: ChainLeft
+*yankDest.right: ChainRight
+*yankDest.width: 200
+*yankDest.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*addGlobals.label: Add Globals
+*addGlobals.fromVert: yankDest
+*addGlobals.left: ChainLeft
+*addGlobals.right: ChainRight
+*addGlobals.width: 200
+*addGlobals.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*classInst.label: Class/Inst
+*classInst.fromVert: addGlobals
+*classInst.left: ChainLeft
+*classInst.right: ChainRight
+*classInst.width: 200
+*classInst.translations: #override\
+ <BtnDown>,<BtnUp>: toggle() ToggleOption()
+
+*exitProgram.label: Quit XZWRITE
+*exitProgram.fromVert: classInst
+*exitProgram.left: ChainLeft
+*exitProgram.right: ChainRight
+*exitProgram.width: 200
+*exitProgram.translations:#override\
+ <BtnDown>: set() \n\
+ <BtnUp>: Quit()
+
+*getStringWindow.resize: true
+
+*getStringTitle.borderWidth: 0
+*getStringTitle.top: ChainTop
+*getStringTitle.bottom: ChainTop
+*getStringTitle.left: ChainLeft
+*getStringTitle.right: ChainRight
+
+*getStringForm.width: 210
+
+*getStringEdit*editType: edit
+*getStringEdit.resize: width
+*getStringEdit.resizable: true
+*getStringEdit.top: ChainTop
+*getStringEdit.bottom: ChainTop
+*getStringEdit.left: ChainLeft
+*getStringEdit.right: ChainRight
+*getStringEdit.fromVert: getStringTitle
+*getStringEdit.translations: #override\
+ <Key>Return: Accept() \n\
+
+*getStringAccept.width: 105
+*getStringAccept.label: Accept
+*getStringAccept.fromVert: getStringEdit
+*getStringAccept.top: ChainTop
+*getStringAccept.bottom: ChainTop
+*getStringAccept.left: ChainRight
+*getStringAccept.right: ChainRight
+*getStringAccept.translations: #override\
+ <BtnDown>: set() \n\
+ <BtnUp>: Accept() unset()
+
+*getStringCancel.width: 105
+*getStringCancel.label: Cancel
+*getStringCancel.fromVert: getStringEdit
+*getStringCancel.fromHoriz: getStringAccept
+*getStringCancel.top: ChainTop
+*getStringCancel.bottom: ChainTop
+*getStringCancel.left: ChainRight
+*getStringCancel.right: ChainRight
+*getStringCancel.translations: #override\
+ <BtnDown>: set() \n\
+ <BtnUp>: Cancel() unset()
--- /dev/null
+/*
+ * This is a string-associative array abstraction with really lousy
+ * semantics. But it does what I need at the moment.
+ */
+
+#include "associate.h"
+
+AArray AACreate()
+{
+ return (DynCreate(sizeof(AElementRec), 0));
+}
+
+void AADestroy(array)
+ AArray array;
+{
+ DynDestroy(array);
+}
+
+int AAInsert(array, index, value)
+ AArray array;
+ char *index, *value;
+{
+ AElementRec temp;
+ int ret;
+
+ temp.index = index;
+ temp.value = value;
+
+ ret = DynAdd(array, &temp);
+ if (ret != DYN_OK)
+ return AA_FAILED;
+ else
+ return AA_OK;
+}
+
+char *AALookup(array, index)
+ AArray array;
+ char *index;
+{
+ AElementRec *a;
+ int i;
+
+ a = (AElementRec *) DynGet((char *) array, 0);
+ for (i=0; i < DynSize(array); i++)
+ if (strcmp(a[i].index, index) == 0)
+ return (a[i].value);
+
+ return NULL;
+}
+
+
--- /dev/null
+#ifndef _Associate_h
+#define _Associate_h
+
+#include <stdio.h>
+#include <dyn.h>
+
+#define AA_OK -1000
+#define AA_FAILED -1001
+#define AA_NOTFOUND -1002
+
+typedef struct _array_elements {
+ char *index;
+ char *value;
+} AElementRec, *AElement;
+
+typedef DynObject AArray;
+
+#endif /* _Associate_h */
--- /dev/null
+/* bfgets.c
+ *
+ * declaration:
+ * char *bfgets(s, n, iop)
+ * char *s;
+ * int n;
+ * FILE *iop;
+ *
+ * Reads n-1 characters or until a newline from iop. The terminating newline
+ * is NOT RETURNED.
+ *
+ * Written by Barr3y Jaspan (bjaspan@athena.mit.edu)
+ */
+
+#include <stdio.h>
+
+char *bfgets();
+
+char *bfgets(s, n, iop)
+ char *s;
+ int n;
+ FILE *iop;
+{
+ register int c = 0;
+ register char *cs;
+
+ cs = s;
+ while ((--n > 0) && ((c = getc(iop)) !=EOF) && (c != '\n'))
+ *cs++ = c;
+
+ *cs = '\0';
+ return (c == EOF && cs == s) ? NULL : s;
+}
--- /dev/null
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/List.h>
+
+#include "xzwrite.h"
+#include "GetString.h"
+
+extern Widget toplevel, getString, destList;
+extern DestRec current_dest;
+extern Defaults defs;
+
+void display_dest()
+{
+ XawListChange(destList, (String *) dest_text(), dest_num(), 0, True);
+}
+
+void delete_dest()
+{
+ XawListReturnStruct *item;
+
+ item = XawListShowCurrent(destList);
+ if (item->list_index == XAW_LIST_NONE)
+ return;
+
+ dest_delete_string(item->string);
+ display_dest();
+}
+
+void create_dest()
+{
+ char buf[ZLEN*3+2], *s;
+ int ret;
+
+ ret = GetString(getString, "Enter new <class,instance,recipient> triple:",
+ "", 0, buf, ZLEN*3+2);
+ if (ret == GETSTRING_ACCEPT) {
+ s = (char *) malloc(strlen(buf)+1);
+ strcpy(s, buf);
+ if (dest_add_string(s) == NULL) {
+ XBell(XtDisplay(toplevel), 0);
+ free(s);
+ }
+ else
+ display_dest();
+ }
+}
+
+void select_dest()
+{
+ DestRec dest;
+ XawListReturnStruct *item;
+ int ret, used_global = 0;
+
+ item = XawListShowCurrent(destList);
+ if (item->list_index == XAW_LIST_NONE)
+ return;
+
+ parse_into_dest(&dest, item->string);
+
+ if (! strcmp(dest.zclass, "...")) {
+ ret = GetString(getString, "Enter CLASS to send to:", "", 0,
+ dest.zclass, ZLEN);
+ if (ret != GETSTRING_ACCEPT) return;
+ used_global = 1;
+ }
+
+ if (! strcmp(dest.zinst, "...")) {
+ ret = GetString(getString, "Enter INSTANCE to send to:", "", 0,
+ dest.zinst, ZLEN);
+ if (ret != GETSTRING_ACCEPT) return;
+ used_global = 1;
+ }
+
+ if (! strcmp(dest.zrecip, "...")) {
+ ret = GetString(getString, "Enter RECIPIENT to send to:", "", 0,
+ dest.zrecip, ZLEN);
+ if (ret != GETSTRING_ACCEPT) return;
+ used_global = 1;
+ }
+
+ if (defs.add_globals && used_global) {
+ /* A hack so using "..." looks pretty */
+ if (! strcmp(dest.zclass, DEFAULT_CLASS) &&
+ ! strcmp(dest.zinst, DEFAULT_INST)) {
+ char *temp;
+
+ temp = (char *) malloc(strlen(dest.zrecip) + 1);
+ strcpy(temp, dest.zrecip);
+ dest_add_string(temp);
+ }
+ else
+ dest_add(&dest);
+ display_dest();
+ }
+
+ if (defs.ping && *dest.zrecip) {
+ ret = zeph_ping(&dest);
+ switch (ret) {
+ case SEND_OK:
+ edit_set_title(&dest);
+ (void) memcpy((char *) ¤t_dest, (char *) &dest,
+ sizeof(DestRec));
+ break;
+ case SENDFAIL_SEND:
+ case SENDFAIL_RECV:
+ case SENDFAIL_ACK:
+ XBell(XtDisplay(toplevel), 0);
+ return;
+ }
+ }
+ else {
+ edit_set_title(&dest);
+ (void) memcpy((char *) ¤t_dest, (char *) &dest,
+ sizeof(DestRec));
+ }
+}
--- /dev/null
+#include <sysdep.h>
+#include <dyn.h>
+
+#include "xzwrite.h"
+
+/*
+ * The following code extracts keypressed from an X event:
+ *
+ * keyevent = event->xkey;
+ * XLookupString(&keyevent, buffer, 1, NULL, NULL);
+ */
+
+/*
+ * This entire file could easily be changes so that multiple destination
+ * lists could be used. But I don't know that that's necessary for this
+ * program.
+ */
+
+/* Globals */
+DestRec current_dest;
+
+static DynObject dests;
+extern Defaults defs;
+
+static void get_dest_from_file(), _get_default_dest();
+static int sort_dest_func(const void *, const void *);
+
+/* A function for debugging */
+void dest_print()
+{
+ char **d;
+ int i;
+
+ d = (char **) DynGet(dests, 0);
+ for (i=0; i<DynSize(dests); i++)
+ printf("%d %s\n", i, d[i]);
+}
+
+char **dest_text()
+{
+ return ((char **) DynGet(dests, 0));
+}
+
+int dest_num()
+{
+ return (DynSize(dests));
+}
+
+void dest_set_current_dest(dest)
+ Dest dest;
+{
+ (void) memcpy((char *) ¤t_dest, (char *) dest, sizeof(DestRec));
+}
+
+void dest_init()
+{
+ dests = DynCreate(sizeof(char *), 0);
+ if (! dests)
+ Error("Out of memory reading destinations", NULL);
+
+ strcpy(current_dest.zclass, DEFAULT_CLASS);
+ strcpy(current_dest.zinst, DEFAULT_INST);
+ strcpy(current_dest.zrecip, get_username());
+}
+
+char **load_default_dest()
+{
+ char *get_home_dir();
+
+ if (! *get_home_dir())
+ Error("Cannot find your home directory.", NULL);
+
+ if (defs.read_xzwrite)
+ _get_default_dest(XZWRITE_DEST_FILE);
+ if (defs.read_zephyr)
+ _get_default_dest(ZEPHYR_FILE);
+ if (defs.read_anyone)
+ _get_default_dest(ANYONE_FILE);
+
+ if (DynSize(dests) == 0) {
+ char *def;
+
+ Warning("XZwrite: No destinations specified, using default.",
+ NULL);
+
+ def = (char *) Malloc(strlen("...") + 1, "adding default dests",
+ NULL);
+ strcpy(def, "...");
+ if (DynAdd(dests, (char *) &def) == DYN_NOMEM)
+ Error("Out of memory adding default destinations.", NULL);
+ }
+
+ sort_destinations();
+ return ((char **) DynGet(dests, 0));
+}
+
+static void _get_default_dest(s)
+ char *s;
+{
+ char *filename;
+
+ filename = (char *) Malloc(strlen(get_home_dir()) + strlen(s) + 1,
+ "While reading file ", s, NULL);
+ sprintf(filename, "%s%s", get_home_dir(), s);
+ get_dest_from_file(dests, filename);
+ free(filename);
+}
+
+static void get_dest_from_file(dests, f)
+ DynObject dests;
+ char *f;
+{
+ FILE *file;
+ char *line, buf[BUFSIZ];
+ DestRec dest;
+
+ if ((file = fopen(f, "r")) == NULL) {
+ Warning("Cannot find destinations file ", f, NULL);
+ return;
+ }
+
+ while (bfgets(buf, 80, file)) {
+ if (buf[0] == '#' || buf[0] == '\0') {
+ if (defs.debug)
+ printf("xzwrite: skipping comment or blank line\n");
+ continue;
+ }
+
+ if (! parse_into_dest(&dest, buf)) {
+ Warning("Ignoring incorrect destination: ", buf, NULL);
+ continue;
+ }
+
+ line = (char *) Malloc(strlen(buf) + 1, "parsing file ", f, NULL);
+ strcpy(line, buf);
+ if (DynAdd(dests, (char *) &line) == DYN_NOMEM)
+ Error("Out of memory parsing file ", f, NULL);
+ }
+
+ fclose(file);
+}
+
+char **dest_add(dest)
+ Dest dest;
+{
+ char *buf;
+
+ /* Two extra bytes if instance or recipient are "" */
+ buf = (char *) Malloc(strlen(dest->zclass) + strlen(dest->zinst) +
+ strlen(dest->zrecip) + 5,
+ "while adding destination ", NULL);
+ sprintf(buf, "%s,%s,%s", dest->zclass,
+ *dest->zinst ? dest->zinst : "*",
+ *dest->zrecip ? dest->zrecip : "*");
+
+ if (DynAdd(dests, (DynPtr) &buf) == DYN_NOMEM) {
+ Warning("Out of memory adding destination ", buf, ". Skipping.",
+ NULL);
+ free(buf);
+ }
+
+ sort_destinations();
+ return ((char **) DynGet(dests, 0));
+}
+
+/* XXX The return/output semantics of this function are not good */
+char **dest_add_string(s)
+ char *s;
+{
+ DestRec dest;
+
+ if (! parse_into_dest(&dest, s))
+ return NULL;
+
+ if (DynAdd(dests, (DynPtr) &s) == DYN_NOMEM)
+ Warning("Out of memory adding destination ", s, ". Skipping.",
+ NULL);
+
+ sort_destinations();
+ return ((char **) DynGet(dests, 0));
+}
+
+char **dest_delete_string(s)
+ char *s;
+{
+ int i;
+ char **d;
+
+ d = (char **) DynGet(dests, 0);
+ for (i=0; i<DynSize(dests); i++) {
+ if (! strcmp(s, d[i])) {
+ DynDelete(dests, i);
+ break;
+ }
+ }
+
+ return ((char **) DynGet(dests, 0));
+}
+
+char **delete_dest_index(i)
+ int i;
+{
+ int ret;
+
+ ret = DynDelete(dests, i);
+ if (ret != DYN_OK)
+ return NULL;
+
+ return ((char **) DynGet(dests, 0));
+}
+
+
+static int sort_dest_func(a1, a2)
+ const void *a1, *a2;
+{
+ char **c1 = (char **) a1, **c2 = (char **) a2;
+ char *s1, *s2, *i1, *i2;
+
+ /* A string with a , in it is always less than one without */
+ s1 = *c1; s2 = *c2;
+ i1 = strchr(s1, ',');
+ i2 = strchr(s2, ',');
+ if (i1 == NULL && i2 != NULL)
+ return 1;
+ else if (i1 != NULL && i2 == NULL)
+ return -1;
+ else
+ return strcmp(s1, s2);
+}
+
+static int
+binary_find_dest(key)
+char *key;
+{
+ register int low = 0, high = DynHigh(dests), mid;
+ register int val;
+ register char **d;
+
+ d = (char **) DynGet(dests, 0);
+
+ /* do binary search */
+ while (low <= high) {
+ mid = (low + high) / 2;
+ val = sort_dest_func(&key, &d[mid]);
+ if (val < 0) {
+ high = mid - 1;
+ } else if (val > 0) {
+ low = mid + 1;
+ } else {
+ return (mid);
+ }
+ }
+
+ return -1;
+}
+
+char **sort_destinations()
+{
+ register char **d;
+ register int idx, idx2;
+ int dsiz = DynSize(dests);
+
+ d = (char **) DynGet(dests, 0);
+ qsort(d, dsiz, sizeof(char *), sort_dest_func);
+
+ for (idx = 0; idx < DynSize(dests);) {
+ if (d[idx][0] == '!') {
+ /* unsubscription */
+ char *next = d[idx];
+ next++;
+ while ((idx2 = binary_find_dest(next)) >= 0) {
+ /* found one to nuke */
+ DynDelete(dests, idx2);
+ if (idx2 <= idx) {
+ /* indexes shifted, so restart this pass. */
+ idx--;
+ if (idx <= 0)
+ idx = 0;
+ continue;
+ }
+ }
+ /* ok, no more to nuke from this one, so delete it and
+ move on. */
+ DynDelete(dests, idx);
+ continue;
+ }
+ /* nope, continue on to next unsub */
+ idx++;
+ }
+ return d;
+}
+
+/* Fills in dest from s */
+int parse_into_dest(dest, s)
+ Dest dest;
+ char *s;
+{
+ char *a, *b;
+ int x, y;
+
+ /* Check for just recipient */
+ if ((a=strchr(s, ','))==0) {
+ if (strlen(s) > ZLEN)
+ return 0;
+ strcpy(dest->zclass, DEFAULT_CLASS);
+ strcpy(dest->zinst, DEFAULT_INST);
+ strcpy(dest->zrecip, s);
+ }
+
+ /* Check for just class,instance or instace,recipient */
+ else if ((b=strchr((++a), ','))==0) {
+ if (defs.class_inst) {
+ x = a - 1 - s;
+ if (x >= ZLEN)
+ return 0;
+
+ strncpy(dest->zclass, s, x);
+ dest->zclass[x] = '\0';
+ strcpy(dest->zinst, a);
+ strcpy(dest->zrecip, "*"); }
+ else {
+ x = a - 1 - s;
+ if (x >= ZLEN)
+ return 0;
+
+ strcpy(dest->zclass, DEFAULT_CLASS);
+ strncpy(dest->zinst, s, x);
+ dest->zinst[x] = '\0';
+ strcpy(dest->zrecip, a); }
+ }
+
+ /* Otherwise, deal with class,instance,recipent */
+ else {
+ ++b;
+ x = a - 1 - s;
+ y = b - 1 - a;
+ if (x >= ZLEN || y >= ZLEN)
+ return 0;
+
+ strncpy(dest->zclass, s, x);
+ dest->zclass[x] = '\0';
+ strncpy(dest->zinst, a, y);
+ dest->zinst[y] = '\0';
+ strcpy(dest->zrecip, b);
+ }
+ if (!strcmp(dest->zrecip,"*")) *(dest->zrecip) = '\0';
+ if (!strcmp(dest->zinst,"*")) *(dest->zinst) = '\0';
+
+ return 1;
+}
+
+/*
+ * notice is from <MESSAGE,inst,sender>. If inst is "PERSONAL", add
+ * destination string "<sender>" if
+ * 1) MESSAGE,PERSONAL,<sender> is not in list, and
+ * 2) <sender> is not in list.
+ * If inst is not "PERSONAL", add destination string
+ * "<MESSAGE,<inst>,<sender>>" if it is not in the list.
+ */
+void dest_add_reply(notice)
+ ZNotice_t *notice;
+{
+ char **list, *newdest, buf[ZLEN*3+2];
+ int i, num;
+
+ list = dest_text();
+ num = dest_num();
+
+
+ /* A hack so local-realm is less annoying */
+ {
+ char *r;
+
+ r = strchr(notice->z_sender, '@');
+ if (r && ! strcmp(r+1, ZGetRealm()))
+ *r = '\0';
+ }
+
+ if (! strcasecmp(notice->z_class_inst, DEFAULT_INST)) {
+ sprintf(buf, "message,personal,%s", notice->z_sender);
+ for (i=0; i < num; i++) {
+ if (! strcasecmp(list[i], buf) ||
+ ! strcasecmp(list[i], notice->z_sender))
+ return;
+ }
+
+ newdest = (char *) Malloc(strlen(notice->z_sender) + 1,
+ "while adding reply destination", NULL);
+ sprintf(newdest, "%s", notice->z_sender);
+ }
+ else {
+ sprintf(buf, "message,%s,%s", notice->z_class_inst,
+ notice->z_sender);
+ for (i=0; i < num; i++) {
+ if (! strcasecmp(list[i], buf))
+ return;
+ }
+
+ newdest = (char *) Malloc(strlen(notice->z_class) +
+ strlen(notice->z_class_inst) +
+ strlen(notice->z_sender) + 3,
+ "while adding reply destintion",
+ NULL);
+ sprintf(newdest, "%s,%s,%s", notice->z_class,
+ notice->z_class_inst, notice->z_sender);
+ }
+
+ dest_add_string(newdest);
+ display_dest();
+
+ if (defs.track_logins)
+ zeph_subto_logins(¬ice->z_sender, 1);
+}
+
--- /dev/null
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/AsciiText.h>
+
+#include "xzwrite.h"
+
+extern Widget toplevel, editor, editTitle;
+extern Defaults defs;
+extern DestRec current_dest;
+
+void edit_win_init()
+{
+ edit_set_title(¤t_dest);
+}
+
+void send_message()
+{
+ char *buf;
+ int ret;
+ Widget text_source;
+
+ /* I should do more interesting things with these error conditions */
+
+ XtVaGetValues(editor, XtNstring, (XtArgVal) &buf,
+ XtNtextSource, (XtArgVal) &text_source, NULL);
+
+ ret = zeph_send_message(¤t_dest, buf);
+ XawAsciiSourceFreeString(text_source);
+
+ switch (ret) {
+ case SEND_OK:
+ break;
+ case SENDFAIL_SEND:
+ case SENDFAIL_RECV:
+ case SENDFAIL_ACK:
+ if (defs.verbose)
+ XBell(XtDisplay(toplevel), 0);
+ break;
+ }
+
+ /* Only the second argument matters */
+ if (defs.close_on_send)
+ XtCallActionProc(toplevel, "CloseSend", NULL, NULL, 0);
+
+ if (defs.clear_on_send)
+ XtCallActionProc(toplevel, "ClearEditor", NULL, NULL, 0);
+}
+
+void edit_set_title(dest)
+ Dest dest;
+{
+ char *title;
+
+ /* alloc two extra bytes for * in case zinst or zrecip are "" */
+ title = (char *) Malloc( strlen(dest->zclass) + strlen(dest->zinst) +
+ strlen(dest->zrecip) + 20, "while setting title",
+ NULL);
+ sprintf(title, "Sending to <%s, %s, %s>", dest->zclass,
+ *dest->zinst ? dest->zinst : "*",
+ *dest->zrecip ? dest->zrecip : "*");
+
+ XtVaSetValues(editTitle,
+ XtNlabel, title,
+ NULL);
+
+ free(title);
+}
+
+void edit_clear()
+{
+ XtVaSetValues(editor,
+ XtNstring, "",
+ NULL);
+}
+
+void edit_yank_prev()
+{
+ Yank yank;
+
+ yank = yank_prev();
+ if (! yank)
+ return;
+
+ XtVaSetValues(editor,
+ XtNstring, (XtArgVal) yank->msg,
+ NULL);
+ if (defs.yank_dest) {
+ dest_set_current_dest(&yank->dest);
+ edit_set_title(&yank->dest);
+ }
+}
+
+void edit_yank_next()
+{
+ Yank yank;
+
+ yank = yank_next();
+ if (! yank)
+ return;
+
+ XtVaSetValues(editor,
+ XtNstring, (XtArgVal) yank->msg,
+ NULL);
+ if (defs.yank_dest) {
+ dest_set_current_dest(&yank->dest);
+ edit_set_title(&yank->dest);
+ }
+}
+
+void edit_yank_store()
+{
+ char *buf;
+ Widget text_source;
+
+ XtVaGetValues(editor, XtNstring, (XtArgVal) &buf,
+ XtNtextSource, (XtArgVal) &text_source, NULL);
+
+ if (buf != NULL && *buf != '\0')
+ yank_store(¤t_dest, buf);
+
+ XawAsciiSourceFreeString(text_source);
+}
--- /dev/null
+#include <stdio.h>
+#include <pwd.h>
+#include "xzwrite.h"
+
+char *get_home_dir()
+{
+ struct passwd *pwuid;
+ static char *h = NULL;
+
+ if (h) return h;
+
+ if ((h = getenv("HOME")) != NULL) return h;
+
+ pwuid = getpwuid(getuid());
+ return (pwuid->pw_dir);
+}
--- /dev/null
+/*
+ * The xzwrite interface structure. All top level widgets except toplevel
+ * are popup shells.
+ *
+ * toplevel - the top level shell
+ * icon - the top level "Z" icon
+ *
+ * sendWindow - the popup shell for the editor/destlist
+ * sendForm - the form holding the edit tree and dest tree
+ * sendClose - button to close sendWindow
+ *
+ * editPane - the pane holding editor widgets
+ * editTitle - the label holding the zephyr triple
+ * editForm - the box holding editor command buttons
+ * editSend - button to send message
+ * editClear - button to clear editor
+ * editPrev - button to yank previous
+ * editNext - button to yank next
+ * editor - the text editor
+ *
+ * destForm - the form holding the destinations list/button
+ * destScroll - the scrollbar holding the list
+ * destList - the destination list
+ *
+ * menuWindow - the popup shell for the menu
+ * menuForm - the form holding the menu list/button
+ * menuClose - the Close Window button for the dest list
+ * signature - button to change signature
+ * clearOnSend
+ * closeOnSend
+ * pings
+ * verbose
+ * authentic
+ * yankDest
+ * addGlobals
+ * classInst
+ * exitProgram
+ *
+ * getStringWindow - the popup shell for dialog boxes (GetString.c)
+ * getStringForm - the form containing the dialog widgets
+ * getStringTitle - the title label width
+ * getStringEdit - the text editor
+ * getStringAccept - the accept button
+ * getStringCancel - the cancel button
+ */
+
+#include "xzwrite.h"
+#include "GetString.h"
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/List.h>
+#include <X11/Xaw/Box.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Toggle.h>
+#include <X11/Xaw/Viewport.h>
+
+#include <zephyr/zephyr.h> /* for ZGetFD() */
+
+#define XVCMW XtVaCreateManagedWidget
+
+/* Action Procedure declarations */
+static void Quit(), SendMessage(), OpenSend(), CloseSend(),
+ ClearEditor(), YankPrev(), YankNext(), YankStore(), AlignParagraph(),
+ DeleteDest(), HighlightDest(), SelectDest(), OpenMenu(),
+ ToggleOption(), Signature(), CloseMenu(), CreateDest();
+
+static void set_editor_width(), set_sendclose_width();
+
+static XtActionsRec actionTable[] = {
+ /* sendWindow actions */
+ {"OpenSend", (XtActionProc) OpenSend},
+ {"CloseSend", (XtActionProc) CloseSend},
+
+ /* Editor actions */
+ {"Quit", (XtActionProc) Quit},
+ {"SendMessage", (XtActionProc) SendMessage},
+ {"ClearEditor", (XtActionProc) ClearEditor},
+ {"YankStore", (XtActionProc) YankStore},
+ {"YankPrev", (XtActionProc) YankPrev},
+ {"YankNext", (XtActionProc) YankNext},
+ {"AlignParagraph", (XtActionProc) AlignParagraph},
+
+ /* Destination list actions */
+ {"SelectDest", (XtActionProc) SelectDest},
+ {"DeleteDest", (XtActionProc) DeleteDest},
+ {"CreateDest", (XtActionProc) CreateDest},
+ {"HighlightDest", (XtActionProc) HighlightDest},
+
+ /* Menu actions */
+ {"OpenMenu", (XtActionProc) OpenMenu},
+ {"ToggleOption", (XtActionProc) ToggleOption},
+ {"Signature", (XtActionProc) Signature},
+ {"CloseMenu", (XtActionProc) CloseMenu},
+};
+
+extern unsigned int num_options, num_resources;
+extern String fallback_resources[];
+extern XrmOptionDescRec app_options[];
+extern XtResource app_resources[];
+
+XtAppContext app_con;
+Defaults defs;
+
+/* Widgets */
+Widget toplevel, icon, getString;
+Widget sendWindow, sendForm, sendClose;
+Widget destForm, destScroll, destList;
+Widget editPane, editTitle, editForm, editSend, editClear,
+ editPrev, editNext, editor;
+Widget menuWindow, menuForm, menuClose, signature,
+ clearOnSend, closeOnSend, pings, verbose, authentic,
+ yankDest, addGlobals, classInst, commandMask, exitProgram;
+
+void go()
+{
+ XtAppMainLoop(app_con);
+}
+
+void build_interface(argc, argv)
+ int *argc;
+ char **argv;
+{
+ /* Set XFILESEARCHPATH to find xzwrite's resource file */
+ /* XXX This is gross XXX */
+ {
+ char *path1, *path2;
+
+ path1 = (char *) getenv("XFILESEARCHPATH");
+ if (! path1) path1 = "";
+ path2 = (char *) malloc(strlen(path1) +
+#ifdef HAVE_PUTENV
+ strlen("XFILESEARCHPATH=") +
+#endif
+ strlen(DATADIR) + 12);
+ if (path2 != NULL) {
+#ifdef HAVE_PUTENV
+ sprintf(path2, "XFILESEARCHPATH=%s:%s/zephyr/%%N", path1,
+ DATADIR);
+ putenv(path2);
+#else
+ sprintf(path2, "%s:%s/zephyr/%%N", path1, DATADIR);
+ setenv("XFILESEARCHPATH", path2, 1);
+ free(path2);
+#endif
+ }
+ }
+
+ toplevel = XtVaAppInitialize(&app_con, "XZwrite", app_options,
+#if XtSpecificationRelease > 4
+ num_options, argc, argv,
+#else
+ num_options, (Cardinal *) argc, argv,
+#endif
+ fallback_resources, NULL);
+
+ XtVaGetApplicationResources(toplevel, (XtPointer) &defs, app_resources,
+ num_resources, NULL);
+
+ XtAppAddActions(app_con, actionTable, XtNumber(actionTable));
+
+ /* Create the icon */
+ icon = XVCMW("icon", commandWidgetClass, toplevel, NULL);
+
+ /* Create the menu */
+ menuWindow = XtVaCreatePopupShell("menuWindow", transientShellWidgetClass,
+ toplevel, NULL);
+ menuForm = XVCMW("menuForm", formWidgetClass, menuWindow, NULL);
+ menuClose = XVCMW("menuClose", commandWidgetClass, menuForm, NULL);
+ signature = XVCMW("signature", commandWidgetClass, menuForm, NULL);
+ clearOnSend = XVCMW("clearOnSend", toggleWidgetClass, menuForm, NULL);
+ closeOnSend = XVCMW("closeOnSend", toggleWidgetClass, menuForm, NULL);
+ pings = XVCMW("pings", toggleWidgetClass, menuForm, NULL);
+ verbose = XVCMW("verbose", toggleWidgetClass, menuForm, NULL);
+ authentic = XVCMW("authentic", toggleWidgetClass, menuForm, NULL);
+ yankDest = XVCMW("yankDest", toggleWidgetClass, menuForm, NULL);
+ addGlobals = XVCMW("addGlobals", toggleWidgetClass, menuForm, NULL);
+ classInst = XVCMW("classInst", toggleWidgetClass, menuForm, NULL);
+ exitProgram = XVCMW("exitProgram", commandWidgetClass, menuForm, NULL);
+
+ /* Create the editor/destination list */
+ sendWindow = XtVaCreatePopupShell("sendWindow", transientShellWidgetClass,
+ toplevel, NULL);
+ sendForm = XVCMW("sendForm", formWidgetClass, sendWindow, NULL);
+ sendClose = XVCMW("sendClose", commandWidgetClass, sendForm, NULL);
+
+ editPane = XVCMW("editPane", panedWidgetClass, sendForm, NULL);
+ editTitle = XVCMW("editTitle", labelWidgetClass, editPane, NULL);
+ editForm = XVCMW("editForm", formWidgetClass, editPane, NULL);
+ editSend = XVCMW("editSend", commandWidgetClass, editForm, NULL);
+ editClear = XVCMW("editClear", commandWidgetClass, editForm, NULL);
+ editPrev = XVCMW("editPrev", commandWidgetClass, editForm, NULL);
+ editNext = XVCMW("editNext", commandWidgetClass, editForm, NULL);
+ editor = XVCMW("editor", asciiTextWidgetClass, editPane, NULL);
+
+ destForm = XVCMW("destForm", formWidgetClass, sendForm, NULL);
+ destScroll = XVCMW("destScroll", viewportWidgetClass, destForm, NULL);
+ destList = XVCMW("destList", listWidgetClass, destScroll, NULL);
+
+ XtSetKeyboardFocus(sendForm, editor);
+ getString = InitGetString(toplevel, "getStringWindow");
+
+ XtAppAddInput(app_con, ZGetFD(), (XtPointer)XtInputReadMask, zeph_dispatch, NULL);
+
+ if (defs.track_logins) {
+ XtAppAddWorkProc(app_con, (XtWorkProc)login_scan_work, NULL);
+ }
+
+ set_editor_width();
+ set_sendclose_width();
+ XtRealizeWidget(toplevel);
+}
+
+/* Action Procedures */
+
+/* ARGSUSED */
+static void Quit(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ XtDestroyApplicationContext(app_con);
+ ZCancelSubscriptions(0);
+ exit(0);
+}
+
+/* ARGSUSED */
+static void OpenSend(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ XtPopup(sendWindow, XtGrabNone);
+}
+
+/* ARGSUSED */
+static void CloseSend(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ XtPopdown(sendWindow);
+}
+
+/* ARGSUSED */
+static void SendMessage(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ send_message();
+}
+
+/* ARGSUSED */
+static void ClearEditor(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ edit_clear();
+}
+
+/* ARGSUSED */
+static void YankStore(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ edit_yank_store();
+}
+
+/* ARGSUSED */
+static void YankPrev(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ edit_yank_prev();
+}
+
+/* ARGSUSED */
+static void YankNext(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ edit_yank_next();
+}
+
+/* ARGSUSED */
+static void AlignParagraph(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+}
+
+/* ARGSUSED */
+static void SelectDest(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ select_dest();
+}
+
+/* ARGSUSED */
+static void DeleteDest(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ delete_dest();
+}
+
+/* ARGSUSED */
+static void HighlightDest(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+}
+
+/* ARGSUSED */
+static void CreateDest(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ create_dest();
+}
+
+/* ARGSUSED */
+static void OpenMenu(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ XtPopup(menuWindow, XtGrabNone);
+}
+
+/* ARGSUSED */
+static void ToggleOption(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ menu_toggle(w);
+}
+
+/* ARGSUSED */
+static void Signature(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ menu_signature();
+}
+
+/* ARGSUSED */
+static void CloseMenu(w, e, p, n)
+ Widget w;
+ XEvent *e;
+ String *p;
+ Cardinal *n;
+{
+ XtPopdown(menuWindow);
+}
+
+static void set_editor_width ()
+{
+ int w, c; char m = 'm';
+ XFontStruct *fs = (XFontStruct *) NULL;
+
+ c = defs.columns;
+ /* get the font structure. */
+ XtVaGetValues(editor, XtNfont, &fs, NULL);
+ if (c < 1 || fs == (XFontStruct *) NULL) return;
+
+ /* set the editor width */
+ w = c * XTextWidth(fs, &m, 1);
+ XtVaSetValues(editor, XtNwidth, (Dimension)w, NULL);
+
+ /* set the destList to have 3/8ths the width of the editor */
+ /* an other idea would be to make it have 3/8ths as many characters,
+ which makes a difference when the editor and destList are in
+ different fonts.
+ however, I prefer this way. */
+ XtVaSetValues(destForm, XtNwidth, (Dimension)(w*3/8), NULL);
+}
+
+static void set_sendclose_width ()
+{
+ /* make the Close Window button the width of the form */
+ Dimension wi = 0;
+ XtRealizeWidget (sendWindow);
+ XtVaGetValues(sendForm, XtNwidth, &wi, NULL);
+ XtUnrealizeWidget (sendWindow);
+ XtVaSetValues(sendClose, XtNwidth, wi, NULL);
+}
--- /dev/null
+#include "xzwrite.h"
+
+#include <X11/Intrinsic.h> /* for Boolean */
+#include <dyn.h>
+#include <zephyr/zephyr.h>
+
+extern Defaults defs;
+
+void logins_deal(notice)
+ ZNotice_t *notice;
+{
+ char *newdest, *p;
+ int d;
+
+ p = strchr(notice->z_class_inst, '@');
+ d = (p) ? p - notice->z_class_inst : strlen(notice->z_class_inst);
+ newdest = (char *) Malloc(d+1, "while dealing with login/logout notice",
+ NULL);
+ strncpy(newdest, notice->z_class_inst, d);
+ newdest[d] = '\0';
+
+ if (! strcmp(notice->z_opcode, "USER_LOGIN")) {
+ dest_add_string(newdest);
+ display_dest();
+ }
+ else if (! strcmp(notice->z_opcode, "USER_LOGOUT")) {
+ dest_delete_string(newdest);
+ display_dest();
+ }
+ else {
+ Warning("Invalid login/logout notice. Opcode: ",
+ notice->z_opcode, "\n", NULL);
+ free(newdest);
+ }
+}
+
+/* Considers a destination with a , and without a . in to be a username */
+void logins_subscribe()
+{
+ DestRec dest;
+ DynObject users;
+ char **list;
+ int num;
+
+ users = DynCreate(sizeof(char *), 0);
+ if (! users)
+ Error("Out of memory subscribing to logins", NULL);
+
+ list = dest_text();
+ num = dest_num();
+ while (--num) {
+ parse_into_dest(&dest, list[num]);
+ if (*dest.zrecip)
+ if (DynAdd(users, (DynPtr)(list + num)) != DYN_OK)
+ Error("Out of memory subscribing to logins", NULL);
+ }
+
+ zeph_subto_logins((char **) DynGet(users, 0), DynSize(users));
+
+ DynDestroy(users);
+}
+
+/* ARGSUSED */
+Boolean login_scan_work(client_data)
+ caddr_t client_data;
+{
+ static int i, num, first = 1;
+ static DestRec dest = {"MESSAGE", "PERSONAL", ""};
+ static char **text;
+
+ if (first) {
+ text = dest_text();
+ num = dest_num();
+ i = first = 0;
+ }
+
+ if (i >= num)
+ return True;
+
+ if (strchr(text[i], ',') || strchr(text[i], '.')) {
+ i += 1;
+ return False; }
+
+ strcpy(dest.zrecip, text[i]);
+ if ((defs.pong_scan && zeph_pong(&dest) != SEND_OK) ||
+ (! defs.pong_scan && ! zeph_locateable(text[i]))) {
+ dest_delete_string(text[i]);
+ i -= 1;
+ num -= 1;
+ display_dest();
+ }
+
+ i += 1;
+
+ return False;
+}
+
--- /dev/null
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <X11/Xaw/Toggle.h>
+
+#include "xzwrite.h"
+#include "GetString.h"
+
+extern Widget getString, clearOnSend, closeOnSend, pings, verbose,
+ authentic, yankDest, addGlobals, classInst;
+extern Defaults defs;
+
+#define toggle(v) (v = !v)
+void menu_toggle(w)
+ Widget w;
+{
+ if (w == clearOnSend)
+ toggle(defs.clear_on_send);
+ else if (w == closeOnSend)
+ toggle(defs.close_on_send);
+ else if (w == pings)
+ toggle(defs.ping);
+ else if (w == verbose)
+ toggle(defs.verbose);
+ else if (w == authentic)
+ toggle(defs.auth);
+ else if (w == yankDest)
+ toggle(defs.yank_dest);
+ else if (w == addGlobals)
+ toggle(defs.add_globals);
+ else if (w == classInst)
+ toggle(defs.class_inst);
+ else
+ Warning("Unknown toggle widget, ignoring.", NULL);
+}
+#undef toggle
+
+#define set(w, i) XtVaSetValues(w, XtNstate, i ? True : False, NULL)
+void menu_match_defs()
+{
+ set(clearOnSend, defs.clear_on_send);
+ set(closeOnSend, defs.close_on_send);
+ set(pings, defs.ping);
+ set(verbose, defs.verbose);
+ set(authentic, defs.auth);
+ set(yankDest, defs.yank_dest);
+ set(addGlobals, defs.add_globals);
+ set(classInst, defs.class_inst);
+}
+#undef set
+
+void menu_signature()
+{
+ char buf[BUFSIZ];
+ int ret;
+
+ ret = GetString(getString, "Enter new signature:", defs.signature,
+ 0, buf, BUFSIZ);
+
+ if (ret != GETSTRING_ACCEPT)
+ return;
+
+ /* XXX Is this safe? */
+ free(defs.signature);
+ defs.signature = (char *) Malloc(strlen(buf) + 1,
+ "while setting signature", NULL);
+ strcpy(defs.signature, buf);
+
+ /* Set the zephyr variable. */
+ ZSetVariable("zwrite-signature", buf);
+}
--- /dev/null
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include "xzwrite.h"
+
+String fallback_resources[] = {
+ "*icon.label: Cannot find xzwrite resource file. Click to exit.",
+ "*icon.translations: #override \n <BtnDown>: Set() \n <BtnUp>: Quit()",
+ NULL,
+};
+
+XrmOptionDescRec app_options[] = {
+ {"+d","*auth", XrmoptionNoArg, (caddr_t) "true"},
+ {"-d","*auth", XrmoptionNoArg, (caddr_t) "false"},
+ {"-s","*signature", XrmoptionSepArg, (caddr_t) NULL},
+ {"+v","*verbose", XrmoptionNoArg, (caddr_t) "true"},
+ {"-v","*verbose", XrmoptionNoArg, (caddr_t) "false"},
+ {"-close","*closeOnSend", XrmoptionNoArg, (caddr_t) "false"},
+ {"+close","*closeOnSend", XrmoptionNoArg, (caddr_t) "true"},
+ {"-clear","*clearOnSend", XrmoptionNoArg, (caddr_t) "false"},
+ {"+clear","*clearOnSend", XrmoptionNoArg, (caddr_t) "true"},
+ {"+n","*ping", XrmoptionNoArg, (caddr_t) "true"},
+ {"-n","*ping", XrmoptionNoArg, (caddr_t) "false"},
+ {"+yd","*yankDest", XrmoptionNoArg, (caddr_t) "true"},
+ {"-yd","*yankDest", XrmoptionNoArg, (caddr_t) "false"},
+ {"+av","*addVars", XrmoptionNoArg, (caddr_t) "true"},
+ {"-av","*addVars", XrmoptionNoArg, (caddr_t) "false"},
+ {"+ci","*classInst", XrmoptionNoArg, (caddr_t) "true"},
+ {"-ci","*classInst", XrmoptionNoArg, (caddr_t) "false"},
+ {"-my","*maxYanks", XrmoptionSepArg, 0},
+ {"+l","*trackLogins", XrmoptionNoArg, (caddr_t) "true"},
+ {"-l","*trackLogins", XrmoptionNoArg, (caddr_t) "false"},
+ {"+x","*readXzwrite", XrmoptionNoArg, (caddr_t) "true"},
+ {"+z","*readZephyr", XrmoptionNoArg, (caddr_t) "true"},
+ {"+a","*readAnyone", XrmoptionNoArg, (caddr_t) "true"},
+ {"-x","*readXzwrite", XrmoptionNoArg, (caddr_t) "false"},
+ {"-z","*readZephyr", XrmoptionNoArg, (caddr_t) "false"},
+ {"-a","*readAnyone", XrmoptionNoArg, (caddr_t) "false"},
+ {"+pac", "*popupAtCursor", XrmoptionNoArg, (caddr_t) "true"},
+ {"-pac", "*popupAtCursor", XrmoptionNoArg, (caddr_t) "false"},
+ {"-mask", "*commandMask", XrmoptionSepArg, (caddr_t) 0},
+ {"-debug", "*debug", XrmoptionNoArg, (caddr_t) "true"},
+ {"-opcode", "*opcode", XrmoptionSepArg, (caddr_t) ""},
+ {"+pong", "*pongScan", XrmoptionNoArg, (caddr_t) "true"},
+ {"-pong", "*pongScan", XrmoptionNoArg, (caddr_t) "false"},
+ {"+reply", "*autoReply", XrmoptionNoArg, (caddr_t) "true"},
+ {"-reply", "*autoReply", XrmoptionNoArg, (caddr_t) "false"},
+ {"-columns", "*columns", XrmoptionSepArg, (caddr_t) 80},
+ {"-zsigs", "*randomZsigFile", XrmoptionSepArg, (caddr_t) "*"},
+ {"-logfile", "*logFile", XrmoptionSepArg, (caddr_t) "*"},
+};
+
+#define offset(field) XtOffset(Defaults *, field)
+XtResource app_resources[] = {
+ {"auth", "Auth", XtRBoolean, sizeof(Boolean),
+ offset(auth), XtRString, "true"},
+
+ {"yankDest", "YankDest", XtRBoolean, sizeof(Boolean),
+ offset(yank_dest), XtRString, "false"},
+
+ {"addGlobals", "AddGlobals", XtRBoolean, sizeof(Boolean),
+ offset(add_globals), XtRString, "false"},
+
+ {"signature", "Signature", XtRString, sizeof(String),
+ offset(signature), XtRString, ""},
+
+ {"verbose", "Verbose", XtRBoolean, sizeof(Boolean),
+ offset(verbose), XtRString, "false"},
+
+ {"closeOnSend", "Close", XtRBoolean, sizeof(Boolean),
+ offset(close_on_send), XtRString, "false"},
+
+ {"clearOnSend", "Close", XtRBoolean, sizeof(Boolean),
+ offset(clear_on_send), XtRString, "false"},
+
+ {"ping", "Ping", XtRBoolean, sizeof(Boolean),
+ offset(ping), XtRString, "true"},
+
+ {"classInst", "ClassInst", XtRBoolean, sizeof(Boolean),
+ offset(class_inst), XtRString, "true"},
+
+ {"maxYanks", "MaxYanks", XtRInt, sizeof(int),
+ offset(max_yanks), XtRString, "25"},
+
+ {"trackLogins", "TrackLogins", XtRBoolean, sizeof(Boolean),
+ offset(track_logins), XtRString, "false"},
+
+ {"readZephyr", "ReadFile", XtRBoolean, sizeof(Boolean),
+ offset(read_zephyr), XtRString, "false"},
+
+ {"readAnyone", "ReadFile", XtRBoolean, sizeof(Boolean),
+ offset(read_anyone), XtRString, "false"},
+
+ {"readXzwrite", "ReadFile", XtRBoolean, sizeof(Boolean),
+ offset(read_xzwrite), XtRString, "false"},
+
+ {"popupAtCursor", "PopupAtCursor", XtRBoolean, sizeof(Boolean),
+ offset(popup_cursor), XtRString, "false"},
+
+ {"commandMask", "CommandMask", XtRInt, sizeof(int),
+ offset(command_mask), XtRString, "0"},
+
+ {"debug", "Debug", XtRBoolean, sizeof(Boolean),
+ offset(debug), XtRString, "false"},
+
+ {"opcode", "Opcode", XtRString, sizeof(String),
+ offset(opcode), XtRString, ""},
+
+ {"pongScan", "PongScan", XtRBoolean, sizeof(Boolean),
+ offset(pong_scan), XtRString, "true"},
+
+ {"autoReply", "AutoReply", XtRBoolean, sizeof(Boolean),
+ offset(auto_reply), XtRString, "false"},
+
+ {"columns", "Columns", XtRInt, sizeof(int),
+ offset(columns), XtRString, "80"},
+
+ {"randomZsigFile", "RandomZsigFile", XtRString, sizeof(String),
+ offset(zsigfile), XtRString, "*"},
+
+ {"logFile", "LogFile", XtRString, sizeof(String),
+ offset(logfile), XtRString, "*"},
+};
+#undef offset
+
+/* These are necessary because XtNumber uses sizeof, and these arrays
+ * are declared as extern in interface.c */
+unsigned int num_options = XtNumber(app_options);
+unsigned int num_resources = XtNumber(app_resources);
--- /dev/null
+#include <stdio.h>
+#include <pwd.h>
+
+#include "xzwrite.h"
+
+#ifdef __STDC__
+void Warning(const char *first, ...)
+#else
+/*VARARGS*/
+void Warning(first, va_alist)
+ const char *first;
+ va_dcl
+#endif
+{
+ va_list vp;
+ char *s;
+
+ fputs(first, stderr);
+
+ VA_START(vp, first);
+ while ((s = va_arg(vp, char *)) != NULL)
+ fputs(s, stderr);
+ va_end(vp);
+ putc('\n', stderr);
+}
+
+#ifdef __STDC__
+void Error(const char *first, ...)
+#else
+/*VARARGS*/
+void Error(first, va_alist)
+ const char *first;
+ va_dcl
+#endif
+{
+ va_list vp;
+ char *s;
+
+ fputs(first, stderr);
+
+ VA_START(vp, first);
+ while ((s = va_arg(vp, char *)) != NULL)
+ fputs(s, stderr);
+ va_end(vp);
+ putc('\n', stderr);
+
+ exit(1);
+}
+
+#ifdef __STDC__
+char *Malloc(int n, ...)
+#else
+/*VARARGS*/
+char *Malloc(n, va_alist)
+ int n;
+ va_dcl
+#endif
+{
+ va_list vp;
+ char *ptr, *s;
+
+ ptr = (char *) malloc((unsigned) n);
+ if (ptr)
+ return ptr;
+
+ fputs("Out of memory: ", stderr);
+
+ VA_START(vp, n);
+ while ((s = va_arg(vp, char *)) != NULL)
+ fputs(s, stderr);
+ va_end(vp);
+ putc('\n', stderr);
+
+ exit(1);
+}
+
+char *get_username()
+{
+ struct passwd *pwuid;
+ static char *u = NULL;
+
+ if (u) return u;
+
+ if ((u = getenv("USER")) != NULL) return u;
+
+ pwuid = getpwuid(getuid());
+ if (pwuid)
+ return u = pwuid->pw_name;
+ else
+ return NULL;
+}
--- /dev/null
+#ifndef __P
+#ifdef __STDC__
+# define __P(s) s
+#else
+# define __P(s) ()
+#endif
+#endif
+
+
+/* interface.c */
+void go __P((void ));
+void build_interface __P((int *argc , char **argv ));
+
+/* resource.c */
+
+/* destlist.c */
+void dest_print __P((void ));
+char **dest_text __P((void ));
+int dest_num __P((void ));
+void dest_set_current_dest __P((Dest dest ));
+void dest_init __P((void ));
+char **load_default_dest __P((void ));
+char **dest_add __P((Dest dest ));
+char **dest_add_string __P((char *s ));
+char **dest_delete_string __P((char *s ));
+char **delete_dest_index __P((int i ));
+char **sort_destinations __P((void ));
+int parse_into_dest __P((Dest dest , char *s ));
+void dest_add_reply __P((ZNotice_t *notice ));
+
+/* util.c */
+void Warning __P((const char *first, ...));
+void Error __P((const char *first, ...));
+char *Malloc __P((int n, ...));
+char *get_username __P((void ));
+
+/* bfgets.c */
+char *bfgets __P((char *s , int n , FILE *iop ));
+
+/* gethomedir.c */
+char *get_home_dir __P((void ));
+
+/* dest_window.c */
+void dest_add_reply __P((ZNotice_t *notice ));
+void display_dest __P((void ));
+void delete_dest __P((void ));
+void create_dest __P((void ));
+void select_dest __P((void ));
+
+/* xzwrite.c */
+int main __P((int argc , char **argv ));
+void usage __P((void ));
+
+/* edit_window.c */
+void edit_win_init __P((void ));
+void send_message __P((void ));
+void edit_set_title __P((Dest dest ));
+void edit_clear __P((void ));
+void edit_yank_prev __P((void ));
+void edit_yank_next __P((void ));
+void edit_yank_store __P((void ));
+
+/* zephyr.c */
+void zeph_dispatch __P((XtPointer client_data , int *source , XtInputId *input_id ));
+void zeph_init __P((void ));
+int zeph_locateable __P((char *user ));
+void zeph_subto_logins __P((char **users , int num ));
+void zeph_subto_replies __P((void ));
+int zeph_send_message __P((Dest dest , char *msg ));
+int zeph_ping __P((Dest dest ));
+int zeph_pong __P((Dest dest ));
+char *zeph_get_signature __P((void ));
+void log_message __P((Dest dest , char *msg ));
+
+/* GetString.c */
+Widget InitGetString __P((Widget parent , char *name ));
+int GetString __P((Widget getStringWindow , String label , String value , int pop_type , char *buf , int len ));
+
+/* Popup.c */
+void Popup __P((Widget shell , XtGrabKind GrabType , int pop_type ));
+void PopupSafe __P((Widget w , Dimension x , Dimension y , XtGrabKind GrabType ));
+void PopupAtPointer __P((Widget w , XtGrabKind GrabType ));
+
+/* yank.c */
+void yank_init __P((void ));
+Yank yank_prev __P((void ));
+Yank yank_next __P((void ));
+void yank_store __P((Dest dest , char *msg ));
+
+/* menu_window.c */
+void menu_toggle __P((Widget w ));
+void menu_match_defs __P((void ));
+void menu_signature __P((void ));
+
+/* logins.c */
+void logins_deal __P((ZNotice_t *notice ));
+void logins_subscribe __P((void ));
+Boolean login_scan_work __P((caddr_t client_data ));
+
+/* xzwrite.h */
+
+/* GetString.h */
+
+#undef P
--- /dev/null
+.TH XZWRITE 1 "7 February 1989"
+.SH NAME
+xzwrite \- X application to write to another user via Zephyr
+.SH SYNOPSIS
+.B xzwrite
+[ -toolkitoption ... ] [-s signature] [+d | -d] [+n | -n] [+v | -v]
+[+yd | -yd] [+av | -av] [+ci | -ci] [-my yanks] [+l | -l] [+a | -a]
+[+x | -x] [+z | -z] [+pong | -pong] [+reply | -reply]
+
+.SH DESCRIPTION
+.I Xzwrite
+is an X application that sends messages to other users
+through the
+.IR Zephyr (1)
+notification service. It puts an icon on the
+screen that allows the user to send a message, select the destination
+of a message, or exit. The program remains active until explicity
+told to exit, thus eliminating the need to run a program every time
+the user wants to send a zephyr message.
+.SH USING THE DESTINATION LIST
+.PP
+.I Xzwrite
+maintains a list of 'destinations'; that is, a list of
+<class, instance, recipient> triples that a user can send messages to.
+When a user selects a destination, all subsequent messages will be
+sent to that triple, until a new destination is selected.
+.I Xzwrite
+can get its list of destinations from the files .xzwrite.dest,
+.anyone, or .zephyr.vars in the
+user's home directory. These files must consist of a list of lines, and
+each is interpreted in the following way: a line containing no commas
+is taken to mean <MESSAGE,PERSONAL,string>; a line with one comma is
+taken to be either <class,instance,*> or <MESSAGE,instance,recipient>
+depending on the value of the classInst resource (see below); a line
+with two commas is taken to be <class,instance,recipient>. A line
+that begins with an exclamation point (!) is treated as an
+"unsubscription" and has the effect of removing destinations read
+from any other file that match the destination on that line. The lines
+must appear
+.B WITHOUT WHITESPACE
+between the fields and with a linefeed between each line. Blank lines
+and lines beginning with an octothorpe (#) are ignored.
+.PP
+
+Clicking the left button in the
+.I xzwrite
+icon pops up the editor and
+destination list. Clicking with the left button in the destination
+list selects the highlighted destination; clicking with the right
+button deletes the highlighed destination. Clicking the middle button
+invokes the action CreateDest (see ACTIONS below) that prompts the
+user for a new <class,instance,recipient> triple to be added to the list.
+
+.PP
+
+If the user specifies a destination in the .xzwrite.dest file
+with an instance or recipient of "...",
+.I xzwrite
+will prompt the user to enter an instance or recipient when the
+message editor is popped up. Setting both instance and recipient to
+"..." (ie: <MESSAGE,...,...>) works. The new
+<class,instance,recipient> triple formed each time a destination with
+"..." is used may or may not be added to the destination list, depending
+on the addVars resource (see below.)
+
+.PP
+
+While the mouse pointer is inside the
+.I xzwrite
+icon, the mouse buttons have the following effect:
+.TP
+.B Left button:
+Pops up the editor and destination list so the user can create and
+send messages.
+.TP
+.B Right button:
+Pops up a list of things that can be changed while xzwrite is running.
+Clicking the "Change Signature" box causes
+.I xzwrite
+to prompt for a new signature, to be used in future messages. All the
+others toggle options which are initially set by resources or
+command-line arguments. The "Quit XZWRITE" causes
+.I xzwrite
+to exit.
+.TP
+.B Ctrl-Right button:
+Exits
+.IR xzwrite .
+
+.SH USING THE MESSAGE EDITOR
+There are four buttons in the message editor. The Send button
+sends the text currently in the message editor to the current
+destination, optionally clearing the message editor at the same time.
+The Clear Editor button clears the message editor. The Yank-Prev button yanks
+the previous message, along with its destination, into the message
+editor. The Yank-Next button yanks the next message (or the first
+message in the yank buffer, if Yank-Prev has not been called) into the
+message editor. The yank buffer is circular, so old messages are
+periodically overwritten by new ones, and stores the previous (by
+default) 25 messages.
+.PP
+The following key sequences have been defined for convenience:
+.PP
+.nf
+ Ctrl-Return Send message
+ Meta-O Store current message, yank previous
+ Meta-P Yank Previous
+ Meta-N Yank Next
+
+.SH OPTIONS
+
+.I Xzwrite
+will accept all X Toolkit command-line options and
+resource database specifications, under the name 'XZwrite'; for more
+information, see
+.IR X (1).
+The instance names of the different parts of
+.I xzwrite
+are as follows (each should be preceded by XZwrite* in the
+user's .Xresources file. For examples of how to use these resource
+names, look in /usr/athena/lib/zephyr/XZwrite.)
+
+.nf
+ toplevel - the top level shell
+ icon - the top level "Z" icon
+
+ sendWindow - the popup shell for the editor/destlist
+ sendForm - the form holding the edit tree and dest tree
+ sendClose - button to close sendWindow
+
+ editPane - the pane holding editor widgets
+ editTitle - the label holding the zephyr triple
+ editForm - the box holding editor command buttons
+ editSend - button to send message
+ editClear - button to clear editor
+ editPrev - button to yank previous
+ editNext - button to yank next
+ editor - the text editor
+
+ destForm - the form holding the destinations list/button
+ destScroll - the scrollbar holding the list
+ destList - the destination list
+
+ menuWindow - the popup shell for the menu
+ menuForm - the form holding the menu list/button
+ menuClose - the Close Window button for the dest list
+ signature - button to change signature
+ closeOnSend
+ pings
+ verbose
+ authentic
+ yankDest
+ addGlobals
+ classInst
+ exitProgram
+
+ getStringWindow - the popup shell for dialog boxes (GetString.c)
+ getStringForm - the form containing the dialog widgets
+ getStringTitle - the title label width
+ getStringEdit - the text editor
+ getStringAccept - the accept button
+ getStringCancel - the cancel button
+
+.fi
+
+.PP
+In addition,
+.I xzwrite
+will accept the following command-line options
+(or resource database specifications). Each should be preceded by
+XZwrite* in the user's .Xresources file. When a command-lie
+.TP
+.B +d (auth = true)
+.br
+.ns
+.HP 5
+.B -d (auth = false)
+.br
+When true, Zephyr messages to be sent authentic. When false, Zephyr
+messages are sent unauthentic.
+.TP
+.B +v (verbose = true)
+.br
+.ns
+.HP 5
+.B -v (verbose = false)
+.br
+When true, causes
+.I xzwrite
+to inform the user no one received a sent message by beeping. This
+is useful if the user wants to know if someone logged out between
+the time when the editor is popped up (when a PING is sent) and when
+the message is actually sent.
+.TP
+.B +z (readZephyr = true)
+.br
+.ns
+.HP 5
+.B -z (readZephyr = false)
+.br
+When true, causes
+.I xzwrite
+to include the .zephyr.subs file for its initial list of destinations.
+.TP
+.B +a (readAnyone = true)
+.br
+.ns
+.HP 5
+.B -a (readAnyone = false)
+.br
+When true, causes
+.I xzwrite
+to include the user's .anyone file for its initial list of destinations.
+.TP
+.B +x (readXzwrite = true)
+.br
+.ns
+.HP 5
+.B -x (readXzwrite = false)
+.br
+When true, causes
+.I xzwrite
+to include the user's .xzwrite.dest file for its initial list of destinations.
+.TP
+.B +l (trackLogins = true)
+.br
+.ns
+.HP 5
+.B -l (trackLogins = false)
+.br
+When true,
+.I xzwrite
+determines (at startup) if each username on the destination
+list is logged on and removes those usernames that are not. It then
+subscribes to login and logout messages for each
+username on the list, and keeps the destination list up to date with
+respect to which users are zwrite-able.
+.TP
+.B +pong (pongScan = true)
+.br
+.ns
+.HP 5
+.B -pong (pongScan = false)
+.br
+Controls the method
+.I xzwrite
+uses determine whether a certain user is logged in. If true,
+.I xzwrite
+sends a notice with an opcode of PING (and a message body of PONG) and
+awaits a response; if false,
+.I xzwrite
+performs a "zlocate". Note that this resource is only used when
+trackLogins is true.
+.TP
+.B -s (signature)
+Specifies the 'signature' for all messages sent. The signature will
+appear as the first field in every message sent.
+.I Xzwrite
+will also look in the user's .zephyr.vars file to a signature, first
+for the variable xzwrite-signature and then for the variable
+zwrite-signature. If neither is found,
+.I Xzwrite
+will look in the /etc/passwd file for the user's name.
+.TP
+.B +n (ping = true)
+.br
+.ns
+.HP 5
+.B -n (ping = false)
+.br
+When ping is set to true,
+.I xzwrite
+sends a PING to the destination when it is initially selected.
+.I Xzwrite
+uses the PING to determine if anyone will actually receive a message
+sent to that destination, and will not allow it to be selected if not.
+.TP
+.B +ci (classInst = true)
+.br
+.ns
+.HP 5
+.B -ci (classInst = false)
+.br
+When ci is set to true, a destination that contains two strings
+separated by a comma is interpreted as a class and instance, with
+a recipient of "*". When it is false, the same string is interpreted
+as an instance and recipient, with a class of MESSAGE.
+.TP
+.B +yd (yankDest = true)
+.br
+.ns
+.HP 5
+.B -yd (yankDest = false)
+.br
+When yd is set to true, yanking a previous message in the message editor
+also restores the original destination of the message. When set to false,
+only the message text is yanked, and the current destination remains
+unchanged.
+.TP
+.B +av (addVars = true)
+.br
+.ns
+.HP 5
+.B -av (addVars = false)
+.br
+When av is set to true, destinations that are specified as the result
+of a recipient or instance of "..." are added to the destinations list
+so they can be selected again.
+.TP
+.B +reply (autoReply = true)
+.br
+.ns
+.HP 5
+.B -reply (autoReply = false)
+.br
+When autoReply is set to true, xzwrite subscribes to <MESSAGE,*,%me%>
+(in other words, all messages sent directly to the user). Each time
+such a message is received, a destination that will reply to the
+sender on the same instance is added to the destination list, if it is
+not already there.
+
+.SH ACTIONS
+
+Every useful action that
+.I xzwrite
+can perform can be bound to any sequence of X events through the
+mechanism of translation tables. The following action procedures
+available to the user.
+.PP
+.nf
+ OpenSend
+ CloseSend
+ Pops up/Pops down the message editor/destination list.
+
+ SendMessage
+ Sends the message in the editor to the current destination.
+
+ ClearEditor
+ Clears the editor.
+
+ YankStore
+ Stores the contents in the message editor in the Yank buffer.
+
+ YankPrev
+ YankNext
+ Puts the previous/next item in the yank buffer into the editor,
+ optionally restoring the destination as well.
+
+ SelectDest
+ DeleteDest
+ Selects/deletes the hightlighed destination.
+
+ CreateDest
+ Prompts the user for a <class,instance,recipient> triple to
+ be added to the destinations list.
+
+ OpenMenu
+ CloseMenu
+ Pops up/Pops down the options menu.
+
+ ToggleOption
+ Toggles the option corresponding to the hightlighed item on the
+ options menu.
+
+ Signature
+ Pops up a dialog box and changes the Zephyr signature to whatever
+ is typed into it.
+
+For examples on how to use these action procedures, look in
+/usr/athena/lib/zephyr/XZwrite.
+
+.SH FILES
+.TP
+/usr/athena/lib/zephyr/xzwrite.bitmap
+Default icon bitmap
+.TP
+/usr/athena/lib/zephyr/XZwrite
+Xzwrite program defaults
+.TP
+/etc/passwd
+Signature field (from gecos information)
+.TP
+~/.Xresources
+user X resources database file
+.TP
+~/.xzwrite.dest
+The user's xzwrite destinations list.
+~/.anyone
+The user's .anyone file.
+~/.zephyr.subs
+The user's zephyr subscription file.
+.SH SEE ALSO
+X(1), zephyr(1)
+
+.SH BUGS
+
+.I xzwrite
+occasionally decided to ignore the state of the "Pings" and
+"Authentic" menu options, unless you happen to be running the program
+under a debugger.
+
+This man page contains many errors and omissions.
+
+.SH AUTHOR
+
+Written by Barry Jaspan (bjaspan@mit.edu), MIT Project Athena
+and MIT Student Information Processing Board.
--- /dev/null
+#define z_width 16
+#define z_height 16
+static char z_bits[] = {
+ 0xff, 0xff, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c, 0x00, 0x0e, 0x00, 0x07,
+ 0x80, 0x03, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1c, 0x00,
+ 0x0e, 0x00, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff};
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <pwd.h>
+#include <dyn.h>
+
+#include "xzwrite.h"
+
+extern Defaults defs;
+DynObject zsigs = NULL;
+
+static void set_signature __P((void));
+static Boolean set_random_zsigs __P((void));
+
+int main(argc, argv)
+ int argc;
+ char **argv;
+{
+ zeph_init();
+
+ build_interface(&argc, argv);
+
+ if (argc > 1) usage();
+
+ set_signature();
+ dest_init();
+ yank_init();
+ edit_win_init();
+ menu_match_defs();
+ (void) load_default_dest();
+ display_dest();
+
+ if (defs.track_logins)
+ logins_subscribe();
+ if (defs.auto_reply)
+ zeph_subto_replies();
+
+ go();
+ return 0;
+}
+
+static void set_signature()
+{
+ char *sig, sigbfr[BUFSIZ];
+
+ /* Do magic with signature */
+ if (defs.zsigfile)
+ if (strcmp(defs.zsigfile, "*"))
+ if (set_random_zsigs()) return;
+
+ if (*defs.signature)
+ return;
+
+ sig = (char *) zeph_get_signature();
+ if (!sig) {
+ /* try to find name in the password file */
+ register struct passwd *pwd;
+ register char *cp = sigbfr;
+ register char *cp2, *pp;
+
+ pwd = getpwuid(getuid());
+ if (pwd) {
+ cp2 = pwd->pw_gecos;
+ for (; *cp2 && *cp2 != ',' ; cp2++) {
+ if (*cp2 == '&') {
+ pp = pwd->pw_name;
+ *cp++ = islower(*pp) ? toupper(*pp) : *pp;
+ pp++;
+ while (*pp)
+ *cp++ = *pp++;
+ } else
+ *cp++ = *cp2;
+ }
+ *cp = '\0';
+ sig = sigbfr;
+ }
+ }
+
+ if (sig) {
+ defs.signature = (char *) Malloc(strlen(sig) + 1,
+ "getting signature",
+ NULL);
+ strcpy(defs.signature, sig);
+ }
+}
+
+
+
+void usage()
+{
+ fprintf(stderr, "Usage: xzwrite [ -toolkitoption ... ] [-s signature] [+d | -d] [+n | -n]\n\t[+v | -v] [+yd | -yd] [+av | -av] [+ci | -ci] [-my yanks]\n\t[+l | -l] [+a | -a] [+x | -x] [+z | -z] [+pong | -pong] [+reply | -reply]\n");
+ exit(1);
+}
+
+#define BUF_SIZE 1024
+
+static Boolean set_random_zsigs()
+{ int x, n;
+ char z[BUF_SIZE], *z2;
+ FILE *fp;
+
+ fp = fopen(defs.zsigfile, "r");
+ if (!fp) {
+ fprintf(stderr, "xzwrite: cant open file \"%s\".\n", defs.zsigfile);
+ return False; }
+
+ zsigs = DynCreate(sizeof(char*), 5);
+
+ while ( fgets(z, BUF_SIZE, fp) != NULL) {
+ if (z[0] == '#' || z[0] == 0) continue;
+ n = strlen(z);
+ z2 = (char *) calloc (sizeof(char), n);
+ if (!z2) {
+ fprintf(stderr, "xzwrite: out of memory.\n"); exit(1); }
+ if (z[n-1] == '\n') { n--; z[n] = 0; }
+ for (x = 0; x <= n; x++) {
+ if (z[x] != '\\') z2[x] = z[x];
+ else z2[x] = '\n'; }
+ DynAdd(zsigs, (DynPtr) &z2); }
+
+ fclose(fp);
+ return True;
+}
--- /dev/null
+#include <sysdep.h>
+#include <X11/Intrinsic.h> /* for String and Boolean */
+
+#define ZLEN 60
+#define DEFAULT_CLASS "MESSAGE"
+#define DEFAULT_INST "PERSONAL"
+#define XZWRITE_DEST_FILE "/.xzwrite.dest"
+#define ZEPHYR_FILE "/.zephyr.subs"
+#define ANYONE_FILE "/.anyone"
+
+#define SEND_OK -1000
+#define SENDFAIL_RECV -1001
+#define SENDFAIL_SEND -1002
+#define SENDFAIL_ACK -1003
+
+/* Structure to contains values from the resource database */
+typedef struct _defaults {
+ String signature, opcode;
+ Boolean auth;
+ Boolean close_on_send;
+ Boolean clear_on_send;
+ Boolean ping;
+ Boolean verbose;
+ Boolean yank_dest;
+ Boolean add_globals;
+ Boolean read_xzwrite;
+ Boolean read_zephyr;
+ Boolean read_anyone;
+ Boolean class_inst;
+ Boolean track_logins;
+ Boolean popup_cursor;
+ Boolean debug;
+ Boolean pong_scan;
+ Boolean auto_reply;
+ int max_yanks, command_mask, columns;
+ String zsigfile;
+ String logfile;
+} Defaults;
+
+/* Structure to contain a legal zephyr triple */
+typedef struct _destination {
+ char zclass[ZLEN], zinst[ZLEN], zrecip[ZLEN];
+} DestRec, *Dest;
+
+/* Structure to contain a yank */
+typedef struct _yank {
+ DestRec dest;
+ char *msg;
+} YankRec, *Yank;
+
+#include <zephyr/zephyr.h>
+#include "xzwrite-proto.h"
--- /dev/null
+#include "xzwrite.h"
+
+static Yank yank_buffer;
+extern Defaults defs;
+
+static int read_index, write_index, highest;
+
+void yank_init()
+{
+ yank_buffer = (Yank) Malloc(defs.max_yanks*sizeof(YankRec),
+ "while allocating yank buffer", NULL);
+ (void) memset((char *) yank_buffer, 0, defs.max_yanks*sizeof(YankRec));
+
+ read_index = write_index = 0;
+ highest = -1;
+}
+
+Yank yank_prev()
+{
+ if (highest == -1)
+ return NULL;
+
+ if (--read_index < 0) read_index = highest;
+ return &yank_buffer[read_index];
+}
+
+Yank yank_next()
+{
+ if (highest == -1)
+ return NULL;
+
+ if (++read_index > highest) read_index = 0;
+ return &yank_buffer[read_index];
+}
+
+void yank_store(dest, msg)
+ Dest dest;
+ char *msg;
+{
+ yank_buffer[write_index].dest = *dest;
+ if (yank_buffer[write_index].msg)
+ free(yank_buffer[write_index].msg);
+ yank_buffer[write_index].msg = (char *) Malloc(strlen(msg) + 1,
+ "while yanking message",
+ NULL);
+ strcpy(yank_buffer[write_index].msg, msg);
+
+ /*
+ * read_index = write_index + 1 so that if I follow the store by
+ * a yank_prev I will get the message just stored (since
+ * read_index is decremented before being used). If I do a
+ * yank_next, then read_index will be > highest and reset to zero.
+ */
+ read_index = write_index + 1;
+ if (write_index > highest)
+ highest = write_index;
+ write_index = (write_index + 1) % defs.max_yanks;
+}
--- /dev/null
+#include "xzwrite.h"
+#include <string.h>
+#include <dyn.h>
+#include <com_err.h>
+
+#include <zephyr/zephyr.h>
+
+static int zeph_send_notice();
+extern Defaults defs;
+extern DynObject zsigs;
+
+/* ARGSUSED */
+void zeph_dispatch(client_data, source, input_id)
+ XtPointer client_data;
+ int *source;
+ XtInputId *input_id;
+{
+ ZNotice_t notice;
+ struct sockaddr_in from;
+ int ret;
+
+ while (ZPending() > 0) {
+ ret = ZReceiveNotice(¬ice, &from);
+ if (ret != ZERR_NONE) {
+ Warning(error_message(ret), " while receiving Zephyr notice.",
+ NULL);
+ continue;
+ }
+
+ if (defs.track_logins &&
+ (! strcmp(notice.z_opcode, "USER_LOGIN") ||
+ ! strcmp(notice.z_opcode, "USER_LOGOUT")))
+ logins_deal(¬ice);
+
+ else if (defs.auto_reply &&
+ ! strcasecmp(notice.z_class, DEFAULT_CLASS) &&
+ ! strcasecmp(notice.z_recipient, ZGetSender()))
+ dest_add_reply(¬ice);
+
+ /* Handle the zlocating bug the Zephyr library explicitly. */
+ /* Only display bogon zlocate packets in debug mode */
+ else if (strcmp(notice.z_class, LOCATE_CLASS) || defs.debug) {
+ Warning("XZwrite: Unexpected notice received. ",
+ "You can probably ignore this.\n",
+ "To: <", notice.z_class, ", ",
+ notice.z_class_inst, ", ", (*notice.z_recipient) ?
+ notice.z_recipient : "*", ">\n",
+ "From: ", notice.z_sender, "\nOpcode: ",
+ notice.z_opcode, "\nMessage: ", notice.z_message,
+ "\n", NULL);
+ }
+
+ ZFreeNotice(¬ice);
+ }
+}
+
+void zeph_init()
+{
+ int retval;
+
+ retval = ZInitialize();
+ if (retval != ZERR_NONE)
+ Error("Cannot initialize the Zephyr library.", NULL);
+
+ retval = ZOpenPort(NULL);
+ if (retval != ZERR_NONE)
+ Error("Cannot open Zephyr port.", NULL);
+}
+
+int zeph_locateable(user)
+ char *user;
+{
+ char buf[BUFSIZ];
+ int n;
+
+ if (strchr(user, '@') == NULL)
+ sprintf(buf, "%s@%s", user, ZGetRealm());
+ ZLocateUser(buf, &n, ZAUTH);
+ return (!! n);
+}
+
+/* XXX This will break on interrealm zephyr */
+void zeph_subto_logins(users, num)
+ char **users;
+ int num;
+{
+ ZSubscription_t *sublist;
+ char *name, *realm;
+ int rlen, c = 0;
+
+ realm = ZGetRealm();
+ rlen = strlen(realm);
+ sublist = (ZSubscription_t *) Malloc(num*sizeof(ZSubscription_t),
+ "while subscribing to logins", NULL);
+
+ while (c < num) {
+ sublist[c].zsub_class = "login";
+ sublist[c].zsub_recipient = "";
+ name = (char *) Malloc(strlen(users[c])+rlen+2,
+ "while subscribing to login, ", users[c],
+ NULL);
+ if (strchr(users[c], '@'))
+ sprintf(name, "%s", users[c]);
+ else
+ sprintf(name, "%s@%s", users[c], realm);
+ sublist[c].zsub_classinst = name;
+ c += 1;
+ }
+
+ ZSubscribeToSansDefaults(sublist, c, (unsigned short) 0);
+ for(; c; --c)
+ free(sublist[c-1].zsub_classinst);
+ free(sublist);
+}
+
+void zeph_subto_replies()
+{
+ ZSubscription_t sub;
+
+ sub.zsub_class = "message";
+ sub.zsub_classinst = "*";
+ sub.zsub_recipient = ZGetSender();
+
+ ZSubscribeToSansDefaults(&sub, 1, (unsigned short) 0);
+}
+
+int zeph_send_message(dest, msg)
+ Dest dest;
+ char *msg;
+{
+ ZNotice_t notice;
+ int msglen, siglen, ret;
+ char *sig_msg, *sig;
+
+ if (!zsigs) sig = defs.signature;
+ else {
+ char **tmp;
+ tmp = (char **) DynGet (zsigs, rand() % DynSize(zsigs));
+ sig = *tmp; }
+
+ msglen = strlen(msg);
+ siglen = strlen(sig);
+ sig_msg = (char *) Malloc(msglen + siglen + 2, "while sending message",
+ NULL);
+ sprintf(sig_msg, "%s%c%s", sig, '\0', msg);
+
+ memset((char *) ¬ice, 0, sizeof(ZNotice_t));
+ notice.z_kind = ACKED;
+ notice.z_class = dest->zclass;
+ notice.z_class_inst = dest->zinst;
+ notice.z_recipient = dest->zrecip;
+ notice.z_sender = 0;
+ notice.z_opcode = defs.opcode;
+ notice.z_port = 0;
+ notice.z_message = sig_msg;
+ notice.z_message_len = msglen + siglen + 1;
+
+ /* This really gross looking mess is brought to you by zwrite.c */
+ if (defs.auth) {
+ if (*sig)
+ notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient)\n@bold($1) <$sender>\n\n$2";
+ else
+ notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient)\n$message";
+ }
+ else {
+ if (*sig)
+ notice.z_default_format = "@bold(UNAUTHENTIC) Class $class, Instance $instance:\n@bold($1) <$sender>\n\n$2";
+ else
+ notice.z_default_format = "@bold(UNAUTHENTIC) Class $class, Instance $instance:\n$message";
+ }
+
+ ret = zeph_send_notice(¬ice, (defs.auth) ? ZAUTH : ZNOAUTH);
+ free(sig_msg);
+
+ /* log to file */
+ if (defs.logfile)
+ if (strcmp(defs.logfile, "*"))
+ log_message (dest, msg);
+
+ return ret;
+}
+
+int zeph_ping(dest)
+ Dest dest;
+{
+ ZNotice_t notice;
+
+ (void) memset((char *) ¬ice, 0, sizeof(ZNotice_t));
+ notice.z_kind = ACKED;
+ notice.z_class = dest->zclass;
+ notice.z_class_inst = dest->zinst;
+ notice.z_recipient = dest->zrecip;
+ notice.z_opcode = "PING";
+
+ /* Should a PING ever be authenticated? */
+ return (zeph_send_notice(¬ice, ZNOAUTH));
+}
+
+int zeph_pong(dest)
+ Dest dest;
+{
+ ZNotice_t notice;
+
+ (void) memset((char *) ¬ice, 0, sizeof(ZNotice_t));
+ notice.z_kind = ACKED;
+ notice.z_class = dest->zclass;
+ notice.z_class_inst = dest->zinst;
+ notice.z_recipient = dest->zrecip;
+ notice.z_opcode = "PING";
+ notice.z_message = "PONG";
+ notice.z_message_len = 4;
+
+ /* Should a PING ever be authenticated? */
+ return (zeph_send_notice(¬ice, ZNOAUTH));
+}
+
+char *zeph_get_signature()
+{
+ char *sig;
+
+ sig = ZGetVariable("xzwrite-signature");
+ if (! sig) sig = ZGetVariable("zwrite-signature");
+ return sig;
+}
+
+static int zeph_send_notice(notice, auth)
+ ZNotice_t *notice;
+ int (*auth)();
+{
+ int retval;
+ ZNotice_t retnotice;
+
+ /* Send message with appropriate authentication */
+ retval = ZSendNotice(notice, auth);
+ if (retval != ZERR_NONE) {
+ if (defs.debug)
+ Warning(error_message(retval), " while sending message.", NULL);
+ return SENDFAIL_SEND;
+ }
+
+ /* Wait for server acknowledgement */
+ retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
+ ZCompareUIDPred, (char *) ¬ice->z_uid);
+
+ if (retval != ZERR_NONE) {
+ if (defs.debug)
+ Warning(error_message(retval),
+ " while waiting for acknowledgement.", NULL);
+ return SENDFAIL_ACK;
+ }
+
+ /* Make sure someone receives it */
+ if (strcmp(retnotice.z_message, ZSRVACK_NOTSENT)==0)
+ return SENDFAIL_RECV;
+
+ return SEND_OK;
+}
+
+void log_message(dest, msg)
+ Dest dest;
+ char *msg;
+{
+ FILE *fp;
+ int i;
+ time_t now;
+
+ fp = fopen(defs.logfile, "a");
+ if (!fp) {
+ fp = fopen(defs.logfile, "w");
+ if (!fp) {
+ fprintf(stderr, "xzwrite: could not open log file \"%s\".\n",
+ defs.logfile);
+ return; }
+ }
+
+ now = time (NULL);
+ fprintf(fp, "To: %s, %s, %s\n", dest->zclass, dest->zinst, dest->zrecip);
+ fprintf(fp, "Date: %s\n", ctime (&now));
+
+ i = strlen(msg)-1;
+ while (msg[i] == '\n' && i > 0) i--;
+ if (msg[i] != '\n') i++; msg[i] = 0;
+ fputs(msg, fp); fprintf(fp, "\n\n");
+ fclose(fp);
+}
#define DEFAULT_MSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
#define RESPONSE_OPCODE ""
-RETSIGTYPE cleanup(int);
+RETSIGTYPE cleanup();
u_short port;
-void
-usage(char *name)
+void usage(name)
+ char *name;
{
printf("Usage: %s [OPTIONS] [FILE]\n"
"\n"
name);
}
-int
-main(int argc,
- char *argv[])
+int main(argc,argv)
+ int argc;
+ char *argv[];
{
FILE *fp;
ZNotice_t notice;
int optchar, watch_location;
char *cmdline_msg;
int nlocs;
- char *find_message(ZNotice_t *, FILE *);
+ char *find_message();
#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
}
}
-char *
-find_message(ZNotice_t *notice,
- FILE *fp)
+char *find_message(notice,fp)
+ ZNotice_t *notice;
+ register FILE *fp;
{
- char *ptr,*ptr2;
+ register char *ptr,*ptr2;
char bfr[BUFSIZ],sender[BUFSIZ];
int gotone,lastwasnt;
return (ptr);
}
-RETSIGTYPE
-cleanup(int ignored)
+RETSIGTYPE cleanup()
{
ZCancelSubscriptions(port);
exit(1);
#include <pwd.h>
#include <netdb.h>
#ifndef lint
-static const char rcsid_zctl_c[] = "$Id$";
+static const char *rcsid_zctl_c = "$Id$";
#endif
#define SUBSATONCE 7
#define ERR (-1)
#define NOT_REMOVED 0
#define REMOVED 1
+int purge_subs();
int sci_idx;
char subsname[BUFSIZ];
extern ss_request_table zctl_cmds;
-int purge_subs(register ZSubscription_t *, int);
-void add_file(short, ZSubscription_t *, int);
-void del_file(short, ZSubscription_t *, int);
-void fix_macros(ZSubscription_t *, ZSubscription_t *, int);
-void fix_macros2(char *, char **);
-int make_exist(char *);
+void add_file(), del_file(), fix_macros(), fix_macros2();
-int
-main(int argc,
- char *argv[])
+main(argc,argv)
+ int argc;
+ char *argv[];
{
struct passwd *pwd;
struct hostent *hent;
}
void
-set_file(int argc,
- char *argv[])
+set_file(argc,argv)
+ int argc;
+ char *argv[];
{
if (argc > 2) {
fprintf(stderr,"Usage: %s filename\n",argv[0]);
}
void
-flush_locations(int argc,
- char *argv[])
+flush_locations(argc,argv)
+ int argc;
+ char *argv[];
{
int retval;
}
void
-wgc_control(int argc,
- char *argv[])
+wgc_control(argc,argv)
+ int argc;
+ register char **argv;
{
int retval;
short newport;
}
void
-hm_control(int argc,
- char *argv[])
+hm_control(argc,argv)
+ int argc;
+ char *argv[];
{
int retval;
ZNotice_t notice;
}
void
-show_var(int argc,
- char *argv[])
+show_var(argc,argv)
+ int argc;
+ char *argv[];
{
int i;
char *value;
}
void
-set_var(int argc, char *argv[])
+set_var(argc,argv)
+ int argc;
+ register char **argv;
{
int retval,setting_exp,i;
char *exp_level,*newargv[1];
}
void
-do_hide(int argc,
- char *argv[])
+do_hide(argc,argv)
+ int argc;
+ char *argv[];
{
char *exp_level = NULL;
Code_t retval;
}
void
-unset_var(int argc,
- char *argv[])
+unset_var(argc,argv)
+ int argc;
+ char *argv[];
{
int retval,i;
}
void
-cancel_subs(int argc,
- char *argv[])
+cancel_subs(argc,argv)
+ int argc;
+ char *argv[];
{
int retval;
short wgport;
}
void
-subscribe(int argc,
- char *argv[])
+subscribe(argc,argv)
+ int argc;
+ char *argv[];
{
int retval;
short wgport;
}
void
-sub_file(int argc,
- char *argv[])
+sub_file(argc,argv)
+ int argc;
+ char *argv[];
{
ZSubscription_t sub;
short wgport;
}
void
-add_file(short wgport,
- ZSubscription_t *subs,
- int unsub)
+add_file(wgport,subs,unsub)
+short wgport;
+ZSubscription_t *subs;
+int unsub;
{
FILE *fp;
char errbuf[BUFSIZ];
return;
}
fix_macros(subs,&sub2,1);
- retval = (unsub
- ? ZUnsubscribeTo(&sub2,1,(u_short)wgport)
- : ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport));
- if (retval)
+ if (retval = (unsub ? ZUnsubscribeTo(&sub2,1,(u_short)wgport) :
+ ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport)))
ss_perror(sci_idx,retval,
unsub ? "while unsubscribing" :
"while subscribing");
}
void
-del_file(short wgport,
- register ZSubscription_t *subs,
- int unsub)
+del_file(wgport,subs,unsub)
+short wgport;
+register ZSubscription_t *subs;
+int unsub;
{
ZSubscription_t sub2;
int retval;
}
int
-purge_subs(register ZSubscription_t *subs,
- int which)
+purge_subs(subs,which)
+register ZSubscription_t *subs;
+int which;
{
FILE *fp,*fpout;
char errbuf[BUFSIZ],subline[BUFSIZ];
}
void
-load_subs(int argc,
- char *argv[])
+load_subs(argc,argv)
+ int argc;
+ char *argv[];
{
ZSubscription_t subs[SUBSATONCE],subs2[SUBSATONCE],unsubs[SUBSATONCE];
FILE *fp;
}
void
-current(int argc,
- char *argv[])
+current(argc,argv)
+ int argc;
+ char *argv[];
{
FILE *fp;
char errbuf[BUFSIZ];
}
int
-make_exist(char *filename)
+make_exist(filename)
+ char *filename;
{
char errbuf[BUFSIZ];
FILE *fpout;
}
void
-fix_macros(ZSubscription_t *subs,
- ZSubscription_t *subs2,
- int num)
+fix_macros(subs,subs2,num)
+ ZSubscription_t *subs,*subs2;
+ int num;
{
int i;
}
void
-fix_macros2(char *src, char **dest)
+fix_macros2(src,dest)
+ register char *src;
+ char **dest;
{
if (!strcmp(src,TOKEN_HOSTNAME)) {
*dest = ourhost;
#include <com_err.h>
#ifndef lint
-static const char rcsid_zlocate_c[] = "$Id$";
+static char rcsid_zlocate_c[] = "$Id$";
#endif /* lint */
/*
*/
char origlogin[20];
char tempfile[40];
+char *getlogin();
char *whenleave;
char *reminder_message = NULL;
char buff[100];
int use_zephyr=1, oldpid;
-void usage(void);
-void doalarm(long);
-void bother(long, char *);
-void delay(long);
-int gethm(char *, int *, int*);
+void usage(), doalarm(), bother(), delay();
-int
-main(int argc,
- char **argv)
+main(argc, argv)
+char **argv;
{
time_t now;
- long when, diff;
- int hours, minutes;
+ long when, diff, hours, minutes;
char *cp;
FILE *fp;
struct tm *nv;
+ int gethm();
int port, c;
ZSubscription_t sub;
}
void
-usage(void)
+usage()
{
fprintf(stderr, "usage: zleave [[+]hhmm [-m \"Reminder Message\"]]\n\
\tor: zleave can[cel]\n");
}
int
-gethm(char *cp,
- int *hp,
- int *mp)
+gethm(cp, hp, mp)
+register char *cp;
+int *hp, *mp;
{
- char c;
- int tod;
+ register char c;
+ register int tod;
tod = 0;
while ((c = *cp++) != '\0') {
}
void
-doalarm(long nmins)
+doalarm(nmins)
+long nmins;
{
time_t daytime;
char *msg1, *msg2, *msg3, *msg4;
daytime += gseconds;
whenleave = ctime(&daytime);
- fp = fopen(tempfile,"r");
- if (fp) {
+ if (fp = fopen(tempfile,"r")) {
if (fscanf(fp, "%d", &oldpid) == 1)
if (!kill(oldpid,9))
printf("Old zleave process killed.\n");
}
void
-bother(long slp,
- char *msg)
+bother(slp, msg)
+long slp;
+char *msg;
{
ZNotice_t notice;
ZNotice_t retnotice;
* knows what zero means.
*/
void
-delay(long secs)
+delay(secs)
+long secs;
{
long n;
register char *l;
int numusers=0, numleft=0, parallel=0, oneline=0;
char *whoami;
-RETSIGTYPE
-timeout(int sig)
+RETSIGTYPE timeout(sig)
{
fprintf (stderr, "%s: no response from server\n", whoami);
exit(1);
}
-void
-usage(void)
+void usage()
{
printf("Usage: %s [ -a | -d ] [ -p ] [ -1 ] user ... \n",whoami);
exit(1);
}
-void
-print_locs(char *user,
- int nlocs)
+void print_locs(user,nlocs)
+ char *user;
+ int nlocs;
{
int one = 1, retval;
ZLocations_t locations;
}
/*ARGSUSED*/
-int
-main(int argc,
- char *argv[])
+main(argc,argv)
+ int argc;
+ char *argv[];
{
char user[BUFSIZ],*whichuser;
ZAsyncLocateData_t ald;
--- /dev/null
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=@mandir@
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+top_builddir=../..
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
+CC=@CC@
+INSTALL=@INSTALL@
+
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
+CPPFLAGS=@CPPFLAGS@
+CFLAGS=@CFLAGS@
+ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h -DKPOP ${CPPFLAGS}
+LDFLAGS=@LDFLAGS@
+LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
+
+OBJS= zmailnotify.o
+
+all: zmailnotify
+
+zmailnotify: ${OBJS} ${LIBZEPHYR}
+ ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+.c.o:
+ ${CC} -c ${ALL_CFLAGS} $<
+
+check:
+
+install: zmailnotify
+ ${LIBTOOL} --mode=install ${INSTALL} -m 755 zmailnotify \
+ ${DESTDIR}${bindir}
+ ${INSTALL} -m 644 ${srcdir}/zmailnotify.1 ${DESTDIR}${mandir}/man1
+
+clean:
+ ${LIBTOOL} --mode=clean rm -f zmailnotify
+ rm -f ${OBJS}
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
--- /dev/null
+.\" $Id$
+.\"
+.\" Copyright 1988 by the Massachusetts Institute of Technology
+.\" All rights reserved. The file /usr/include/zephyr/mit-copyright.h
+.\" specifies the terms and conditions for redistribution.
+.\"
+.TH ZMAILNOTIFY 1 "July 8, 1988" "MIT Project Athena"
+.ds ]W MIT Project Athena
+.SH NAME
+zmailnotify \- retrieve mail headers from post office and transmit via Zephyr
+.SH SYNOPSIS
+.B zmailnotify
+.SH DESCRIPTION
+.I zmailnotify
+connects to the invoking user's POP post office and retrieves the From,
+To, and Subject fields of waiting messages, and then sends one Zephyr
+notice per message to class MAIL, instance POPRET, recipient
+.I <user@realm>,
+where <user@realm> is the invoking user's username concatenated with the
+local Zephyr realm (e.g. jruser@ATHENA.MIT.EDU).
+.PP
+.I zmailnotify
+is intended to be executed by
+.I zwgc(1)
+when notifications of spooled mail (such
+as those generated by \fIzpopnotify(8)\fR) are delivered.
+By default, these notifications are not delivered, nor are they acted
+upon. To receive the notices, you must subscribe to class MAIL,
+instance POP, recipient username@realm (see \fIzctl\fR(1)).
+Once you subscribe to these notices, by default they will be simply
+displayed on your display or terminal by
+.I zwgc(1).
+To have
+.I zmailnotify
+executed when they are delivered, you must copy the system default
+windowgram description file (\fI/usr/athena/lib/zephyr/zwgc.desc\fR) to your home
+directory as filename
+.I ~/.zwgc.desc
+and follow the directions contained in that file pertaining to
+.B MAIL NOTIFICATION.
+.PP
+.I zmailnotify
+only retrieves four headers at one time in order to reduce the
+competition for the mailbox lock on the post office. If more than four mail
+messages are waiting,
+.I zmailnotify
+will only retrieve the four most recent mail headers.
+.PP
+To check for mail already waiting when you log in, use the standard MH
+program
+.I msgchk(1).
+.SH BUGS
+.I zmailnotify
+only sends notification of mail which appears to be unique.
+Uniqueness is determined by comparing the To:, From:, and Subject:
+fields of the message with the last checked mail message; if the
+three fields match exactly, the new message is
+not considered unique. The To:, From:, and Subject: fields of the last
+message are stored in the file
+.IR $HOME/.maillock .
+.SH FILES
+$HOME/.maillock
+.SH SEE ALSO
+msgchk(1), zctl(1), zephyr(1), zwgc(1), zhm(8), zephyrd(8),
+zpopnotify(8), popd(8)
+.br
+Project Athena Technical Plan Section E.4.1, `Zephyr Notification
+Service'
+.SH AUTHOR
+.PP
+Robert S. French (MIT-Project Athena)
+.SH RESTRICTIONS
+Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
+All Rights Reserved.
+.br
+.I zephyr(1)
+specifies the terms and conditions for redistribution.
--- /dev/null
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains code for the "zmailnotify" command.
+ *
+ * Created by: Robert French
+ *
+ * $Id$
+ *
+ * Copyright (c) 1987,1993 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * "mit-copyright.h".
+ */
+
+#include <sysdep.h>
+#include <zephyr/mit-copyright.h>
+#include <zephyr/zephyr.h>
+
+#ifndef lint
+static const char rcsid_zmailnotify_c[] =
+ "$Id$";
+#endif
+
+#include <sys/socket.h>
+#include <pwd.h>
+#include <netdb.h>
+#ifdef HAVE_HESIOD
+#include <hesiod.h>
+#endif
+
+#ifndef HAVE_KRB4
+#undef KPOP
+#endif
+
+#ifdef KPOP
+#include <krb.h>
+#endif
+
+#define NOTOK (-1)
+#define OK 0
+#define DONE 1
+
+FILE *sfi;
+FILE *sfo;
+char Errmsg[80];
+
+#ifdef KPOP
+char *PrincipalHostname();
+#endif
+
+void get_message(), pop_close(), mail_notify(), fatal_pop_err ();
+int pop_command __P((char *, ...));
+#define MAXMAIL 4
+
+struct _mail {
+ char *from;
+ char *to;
+ char *subj;
+} maillist[MAXMAIL];
+
+char *mailptr = NULL;
+char *prog = "zmailnotify";
+
+/* This entire program is a kludge - beware! */
+
+main(argc, argv)
+ char *argv[];
+{
+ FILE *lock;
+ int nmsgs;
+ char *user,response[512],lockfile[100];
+ char *host,*dir;
+ char *auth_cmd;
+ int i,nbytes,retval,uselock;
+ struct passwd *pwd;
+ struct _mail mymail;
+#ifdef HAVE_HESIOD
+ struct hes_postoffice *p;
+#endif
+
+ if (argv[0] && *argv[0])
+ prog = argv[0];
+
+ if ((retval = ZInitialize()) != ZERR_NONE) {
+ com_err(prog,retval,"while initializing");
+ exit(1);
+ }
+
+ dir = (char *)getenv("HOME");
+ user = (char *)getenv("USER");
+ if (!user || !dir) {
+ pwd = (struct passwd *)getpwuid((int) getuid());
+ if (!pwd) {
+ fprintf(stderr,"%s: Can't figure out who you are!\n",
+ prog);
+ exit(1);
+ }
+ if (!user)
+ user = pwd->pw_name;
+ if (!dir)
+ dir = pwd->pw_dir;
+ }
+ if (argc > 1)
+ user = argv[1];
+
+ (void) sprintf(lockfile,"%s/.maillock",dir);
+
+ host = (char *)getenv("MAILHOST");
+#ifdef HAVE_HESIOD
+ if (host == NULL) {
+ p = hes_getmailhost(user);
+ if (p != NULL && strcmp(p->po_type, "POP") == 0)
+ host = p->po_host;
+ else {
+ fprintf(stderr,
+ "%s: no POP server listed in Hesiod for %s\n",
+ prog, user);
+ exit(1);
+ }
+ }
+#endif
+ if (host == NULL) {
+ fprintf(stderr,"%s: no MAILHOST defined\n", prog);
+ exit(1);
+ }
+
+ lock = fopen(lockfile,"r+");
+#ifdef _POSIX_VERSION
+ if (lock) {
+ struct flock fl;
+
+ /* lock the whole file exclusively */
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ (void) fcntl(fileno(lock),F_SETLKW,&fl);
+ }
+#else
+ if (lock)
+ (void) flock(fileno(lock),LOCK_EX);
+#endif
+
+ if (pop_init(host) == NOTOK) {
+ fprintf(stderr,"%s: %s\n",prog, Errmsg);
+ exit(1);
+ }
+
+ if ((getline(response, sizeof response, sfi) != OK) ||
+ (*response != '+')) {
+ fprintf(stderr,"%s: %s\n",prog,response);
+ exit(1);
+ }
+
+#ifdef KPOP
+ auth_cmd = "PASS %s";
+#else
+ auth_cmd = "RPOP %s";
+#endif
+ if (pop_command("USER %s", user) == NOTOK
+ || pop_command(auth_cmd, user) == NOTOK)
+ fatal_pop_err ();
+
+ if (pop_stat(&nmsgs, &nbytes) == NOTOK)
+ fatal_pop_err ();
+
+ if (!nmsgs) {
+ if (lock) {
+#ifdef _POSIX_VERSION
+ struct flock fl;
+
+ /* unlock the whole file */
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ (void) fcntl(fileno(lock),F_SETLKW,&fl);
+#else
+ (void) flock(fileno(lock),LOCK_UN);
+#endif
+ (void) fclose(lock);
+ }
+ (void) unlink(lockfile);
+ (void) pop_command("QUIT");
+ pop_close();
+ exit (0);
+ }
+
+ uselock = 0;
+ if (lock) {
+ uselock = 1;
+ mymail.to = (char *)malloc(BUFSIZ);
+ mymail.from = (char *)malloc(BUFSIZ);
+ mymail.subj = (char *)malloc(BUFSIZ);
+ if (fgets(mymail.from,BUFSIZ,lock) != NULL)
+ mymail.from[strlen(mymail.from)-1] = 0;
+ else
+ mymail.from[0]=0;
+ if (fgets(mymail.to,BUFSIZ,lock) != NULL)
+ mymail.to[strlen(mymail.to)-1] = 0;
+ else
+ mymail.to[0] = 0;
+ if (fgets(mymail.subj,BUFSIZ,lock) != NULL)
+ mymail.subj[strlen(mymail.subj)-1] = 0;
+ else
+ mymail.subj[0] = 0;
+ }
+ else {
+ lock = fopen(lockfile,"w");
+#ifdef _POSIX_VERSION
+ if (lock) {
+ struct flock fl;
+
+ /* lock the whole file exclusively */
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ (void) fcntl(fileno(lock),F_SETLKW,&fl);
+ }
+#else
+ if (lock)
+ (void) flock(fileno(lock),LOCK_EX);
+#endif
+ uselock = 0;
+ }
+
+ for (i=nmsgs;i>0;i--) {
+ if (nmsgs-i == MAXMAIL)
+ break;
+ if (get_mail(i,&maillist[nmsgs-i]))
+ exit (1);
+ if (uselock && (!strcmp(maillist[nmsgs-i].to,mymail.to) &&
+ !strcmp(maillist[nmsgs-i].from,mymail.from) &&
+ !strcmp(maillist[nmsgs-i].subj,mymail.subj)))
+ break;
+ }
+
+ (void) pop_command("QUIT");
+ pop_close();
+
+ i++;
+ for (;i<=nmsgs;i++)
+ mail_notify(&maillist[nmsgs-i]);
+ i--;
+ if (lock) {
+#ifdef _POSIX_VERSION
+ struct flock fl;
+
+ /* unlock the whole file */
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ (void) fcntl(fileno(lock),F_SETLKW,&fl);
+#else
+ (void) flock(fileno(lock),LOCK_UN);
+#endif
+ (void) fclose(lock);
+ }
+ lock = fopen(lockfile,"w");
+ if (!lock)
+ exit (1);
+ fprintf(lock,"%s\n%s\n%s\n",
+ maillist[nmsgs-i].from,
+ maillist[nmsgs-i].to,
+ maillist[nmsgs-i].subj);
+ (void) fclose(lock);
+
+ exit(0);
+}
+
+void fatal_pop_err ()
+{
+ fprintf (stderr, "%s: %s\n", prog, Errmsg);
+ (void) pop_command ("QUIT");
+ pop_close ();
+ exit (1);
+}
+
+void get_message(i)
+ int i;
+{
+ int mbx_write();
+ if (pop_scan(i, mbx_write, 0) != OK)
+ fatal_pop_err ();
+}
+
+/* Pop stuff */
+
+void pop_close()
+{
+ if (sfi)
+ (void) fclose(sfi);
+ if (sfo)
+ (void) fclose(sfo);
+}
+
+get_mail(i,mail)
+ int i;
+ struct _mail *mail;
+{
+ char from[512],to[512],subj[512];
+ char *c,*ptr,*ptr2;
+
+ *from = 0;
+ *to = 0;
+ *subj = 0;
+
+ if (mailptr)
+ free(mailptr);
+
+ mailptr = 0;
+
+ get_message(i);
+
+ ptr = mailptr;
+ while (ptr) {
+ ptr2 = strchr(ptr,'\n');
+ if (ptr2)
+ *ptr2++ = 0;
+ if (*ptr == '\0')
+ break;
+ if (!strncmp(ptr, "From: ", 6))
+ (void) strcpy(from, ptr+6);
+ else if (!strncmp(ptr, "To: ", 4))
+ (void) strcpy(to, ptr+4);
+ else if (!strncmp(ptr, "Subject: ", 9))
+ (void) strcpy(subj, ptr+9);
+ ptr = ptr2;
+ }
+
+ /* add elipsis at end of "To:" field if it continues onto */
+ /* more than one line */
+ i = strlen(to) - 2;
+ c = to+i;
+ if (*c++ == ',') {
+ *c++ = ' ';
+ *c++ = '.';
+ *c++ = '.';
+ *c++ = '.';
+ *c++ = '\n';
+ *c = 0;
+ }
+
+ mail->from = (char *)malloc((unsigned)(strlen(from)+1));
+ (void) strcpy(mail->from,from);
+ mail->to = (char *)malloc((unsigned)(strlen(to)+1));
+ (void) strcpy(mail->to,to);
+ mail->subj = (char *)malloc((unsigned)(strlen(subj)+1));
+ (void) strcpy(mail->subj,subj);
+
+ return (0);
+}
+
+void
+mail_notify(mail)
+ struct _mail *mail;
+{
+ int retval;
+ char *fields[3];
+ ZNotice_t notice;
+
+ (void) memset((char *)¬ice, 0, sizeof(notice));
+ notice.z_kind = UNACKED;
+ notice.z_port = 0;
+ notice.z_class = "MAIL";
+ notice.z_class_inst = "POPRET";
+ notice.z_opcode = "NEW_MAIL";
+ notice.z_sender = 0;
+ notice.z_recipient = ZGetSender();
+ notice.z_default_format = "You have new mail:\n\nFrom: $1\nTo: $2\nSubject: $3";
+
+ fields[0] = mail->from;
+ fields[1] = mail->to;
+ fields[2] = mail->subj;
+
+ if ((retval = ZSendList(¬ice,fields,3,ZNOAUTH)) != ZERR_NONE)
+ com_err(prog,retval,"while sending notice");
+}
+
+/*
+ * These are the necessary KPOP routines snarfed from
+ * the GNU movemail program.
+ */
+
+pop_init(host)
+char *host;
+{
+ register struct hostent *hp;
+ register struct servent *sp;
+ int lport = IPPORT_RESERVED - 1;
+ struct sockaddr_in sin;
+ register int s;
+#ifdef KPOP
+ KTEXT ticket = (KTEXT)NULL;
+ int rem;
+ long authopts;
+ char *host_save;
+#endif
+ char *svc_name;
+
+ hp = gethostbyname(host);
+ if (hp == NULL) {
+ (void) sprintf(Errmsg, "MAILHOST unknown: %s", host);
+ return(NOTOK);
+ }
+
+
+#ifdef KPOP
+#ifdef ATHENA_COMPAT
+ svc_name = "knetd";
+#else
+ svc_name = "kpop";
+#endif
+#else
+ svc_name = "pop";
+#endif
+
+ sp = getservbyname (svc_name, "tcp");
+ if (sp == 0) {
+ (void) sprintf (Errmsg, "%s/tcp: unknown service", svc_name);
+ return NOTOK;
+ }
+ sin.sin_family = hp->h_addrtype;
+ (void) memcpy((char *)&sin.sin_addr, hp->h_addr, hp->h_length);
+ sin.sin_port = sp->s_port;
+#ifdef KPOP
+ s = socket(AF_INET, SOCK_STREAM, 0);
+#else
+ s = rresvport(&lport);
+#endif
+ if (s < 0) {
+ (void) sprintf(Errmsg, "error creating socket: %s", strerror(errno));
+ return(NOTOK);
+ }
+
+ if (connect(s, (struct sockaddr *)&sin, sizeof sin) < 0) {
+ (void) sprintf(Errmsg, "error during connect: %s", strerror(errno));
+ (void) close(s);
+ return(NOTOK);
+ }
+#ifdef KPOP
+ ticket = (KTEXT)malloc( sizeof(KTEXT_ST) );
+ rem=KSUCCESS;
+#ifdef ATHENA_COMPAT
+ authopts = KOPT_DO_OLDSTYLE;
+ rem = krb_sendsvc(s,"pop");
+ if (rem != KSUCCESS) {
+ (void) sprintf(Errmsg, "kerberos error: %s", krb_get_err_text(rem));
+ (void) close(s);
+ return(NOTOK);
+ }
+#else
+ authopts = 0L;
+#endif
+ host_save = malloc(strlen(hp->h_name) + 1);
+ if (!host_save) {
+ sprintf(Errmsg, "Out of memory.");
+ return(NOTOK);
+ }
+ strcpy(host_save, hp->h_name);
+ rem = krb_sendauth(authopts, s, ticket, "pop", host_save, (char *)0,
+ 0, (MSG_DAT *) 0, (CREDENTIALS *) 0,
+ (bit_64 *) 0, (struct sockaddr_in *)0,
+ (struct sockaddr_in *)0,"ZMAIL0.0");
+ free(host_save);
+ free(ticket);
+ if (rem != KSUCCESS) {
+ (void) sprintf(Errmsg, "kerberos error: %s",krb_get_err_text(rem));
+ (void) close(s);
+ return(NOTOK);
+ }
+#endif
+
+ sfi = fdopen(s, "r");
+ sfo = fdopen(s, "w");
+ if (sfi == NULL || sfo == NULL) {
+ (void) sprintf(Errmsg, "error in fdopen: %s", strerror(errno));
+ (void) close(s);
+ return(NOTOK);
+ }
+
+ return(OK);
+}
+
+#ifdef __STDC__
+pop_command(char *fmt, ...)
+#else
+pop_command(fmt, va_alist)
+ va_dcl
+#endif
+{
+ va_list args;
+ char buf[4096];
+
+ VA_START(args, fmt);
+ (void) vsprintf(buf, fmt, args);
+ va_end(args);
+
+ if (putline(buf, Errmsg, sfo) == NOTOK) return(NOTOK);
+
+ if (getline(buf, sizeof buf, sfi) != OK) {
+ (void) strcpy(Errmsg, buf);
+ return(NOTOK);
+ }
+
+ if (*buf != '+') {
+ (void) strcpy(Errmsg, buf);
+ return(NOTOK);
+ } else {
+ return(OK);
+ }
+}
+
+
+pop_stat(nmsgs, nbytes)
+int *nmsgs, *nbytes;
+{
+ char buf[4096];
+
+ if (putline("STAT", Errmsg, sfo) == NOTOK) return(NOTOK);
+
+ if (getline(buf, sizeof buf, sfi) != OK) {
+ (void) strcpy(Errmsg, buf);
+ return(NOTOK);
+ }
+
+ if (*buf != '+') {
+ (void) strcpy(Errmsg, buf);
+ return(NOTOK);
+ } else {
+ if (sscanf(buf, "+OK %d %d", nmsgs, nbytes) != 2)
+ return(NOTOK);
+ return(OK);
+ }
+}
+
+pop_scan(msgno, action, arg)
+int (*action)();
+{
+ char buf[4096];
+
+#ifdef HAVE_POP3_TOP
+ (void) sprintf(buf, "TOP %d 0", msgno);
+#else
+ (void) sprintf(buf, "RETR %d", msgno);
+#endif
+ if (putline(buf, Errmsg, sfo) == NOTOK) return(NOTOK);
+
+ if (getline(buf, sizeof buf, sfi) != OK) {
+ (void) strcpy(Errmsg, buf);
+ return(NOTOK);
+ }
+
+ while (1) {
+ switch (multiline(buf, sizeof buf, sfi)) {
+ case OK:
+ (*action)(buf, arg);
+ break;
+ case DONE:
+ return (OK);
+ case NOTOK:
+ (void) strcpy(Errmsg, buf);
+ return (NOTOK);
+ }
+ }
+}
+
+getline(buf, n, f)
+char *buf;
+register int n;
+FILE *f;
+{
+ register char *p;
+
+ p = fgets(buf, n, f);
+
+ if (ferror(f)) {
+ (void) strcpy(buf, "error on connection");
+ return (NOTOK);
+ }
+
+ if (p == NULL) {
+ (void) strcpy(buf, "connection closed by foreign host\n");
+ return (DONE);
+ }
+
+ p = buf + strlen(buf);
+ if (*--p == '\n') *p = '\0';
+ if (*--p == '\r') *p = '\0';
+ return(OK);
+}
+
+multiline(buf, n, f)
+char *buf;
+register int n;
+FILE *f;
+{
+ if (getline(buf, n, f) != OK) return (NOTOK);
+ if (*buf == '.') {
+ if (*(buf+1) == '\0') {
+ return (DONE);
+ } else {
+ (void) strcpy(buf, buf+1);
+ }
+ } else if (*buf == '\0') {
+ /* suck up all future lines, since this is after all only for headers */
+ while(! ((buf[0]=='.') && (buf[1] == '\0')) ) {
+ if (getline(buf, n, f) != OK) return (NOTOK);
+ }
+ return DONE;
+ }
+ return(OK);
+}
+
+putline(buf, err, f)
+char *buf;
+char *err;
+FILE *f;
+{
+ fprintf(f, "%s\r\n", buf);
+ (void) fflush(f);
+ if (ferror(f)) {
+ (void) strcpy(err, "lost connection");
+ return(NOTOK);
+ }
+ return(OK);
+}
+
+/*ARGSUSED*/
+mbx_write(line, dummy)
+char *line;
+int dummy; /* for consistency with pop_scan */
+{
+ if (mailptr) {
+ mailptr = (char *)realloc(mailptr,(unsigned)(strlen(mailptr)+strlen(line)+2));
+ (void) strcat(mailptr,line);
+ }
+ else {
+ mailptr = (char *)malloc((unsigned)(strlen(line)+2));
+ (void) strcpy(mailptr,line);
+ }
+ (void) strcat(mailptr,"\n");
+ return(0);
+}
#define ON 1
#define OFF 0
-int
-main(int argc,
- char *argv[])
+main(argc,argv)
+ int argc;
+ register char *argv[];
{
register char *cp;
ZSubscription_t subs[SUBSATONCE];
if (cleanname[0] == '#' || cleanname[0] == '\0' ||
cleanname[0] == '\n')
continue; /* ignore comment and empty lines */
- comment_ptr = strchr(cleanname, '#');
- if (comment_ptr)
+ if (comment_ptr = strchr(cleanname, '#'))
*comment_ptr = '\0'; /* Ignore from # onwards */
/* Get rid of old-style nol entries, just in case */
cp = cleanname + strlen(cleanname) - 1;
--- /dev/null
+SHELL = /bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sbindir=@sbindir@
+lsbindir=@lsbindir@
+
+includedir=${prefix}/include
+mandir=@mandir@
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+top_builddir=../..
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+BUILDTOP=../..
+VPATH=@srcdir@
+LIBTOOL=@LIBTOOL@
+CC=@CC@
+INSTALL=@INSTALL@
+
+LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
+CPPFLAGS=@CPPFLAGS@
+CFLAGS=@CFLAGS@
+ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS}
+LDFLAGS=@LDFLAGS@
+LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
+
+OBJS= zpopnotify.o
+
+all: zpopnotify
+
+zpopnotify: ${OBJS} ${LIBZEPHYR}
+ ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
+
+.c.o:
+ ${CC} -c ${ALL_CFLAGS} $<
+
+check:
+
+install: zpopnotify
+ ${LIBTOOL} --mode=install ${INSTALL} -m 755 zpopnotify \
+ ${DESTDIR}${sbindir}
+ ${INSTALL} -m 644 ${srcdir}/zpopnotify.8 ${DESTDIR}${mandir}/man8
+
+clean:
+ ${LIBTOOL} --mode=clean rm -f zpopnotify
+ rm -f ${OBJS}
+
+${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
+${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
+
+.PHONY: all check install clean
+
--- /dev/null
+.\" $Id$
+.\"
+.\" Copyright 1988 by the Massachusetts Institute of Technology
+.\" All rights reserved. The file /usr/include/zephyr/mit-copyright.h
+.\" specifies the terms and conditions for redistribution.
+.\"
+.TH ZPOPNOTIFY 8 "July 8, 1988" "MIT Project Athena"
+.ds ]W MIT Project Athena
+.SH NAME
+zpopnotify \- notify users of newly spooled mail via Zephyr
+.SH SYNOPSIS
+.B zpopnotify
+.BI username
+.SH DESCRIPTION
+.I zpopnotify
+sends a Zephyr notice announcing the delivery of new mail to class MAIL,
+instance POP, recipient
+.I <user@realm>,
+where <user@realm> is the command-line specified
+.BI username
+concatenated with the local Zephyr realm (e.g. "zpopnotify jruser" would
+send to recipient jruser@ATHENA.MIT.EDU at Project Athena).
+The body of the message contains the official hostname of the sending
+host.
+.SH SEE ALSO
+zephyr(1), zwgc(1), zmailnotify(1), zhm(8), zephyrd(8), popd(8), spop(8)
+.br
+Project Athena Technical Plan Section E.4.1, `Zephyr Notification
+Service'
+.SH AUTHOR
+.PP
+Robert S. French (MIT-Project Athena)
+.SH RESTRICTIONS
+Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
+All Rights Reserved.
+.br
+.I zephyr(1)
+specifies the terms and conditions for redistribution.
--- /dev/null
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains code for the "zpopnotify" command.
+ *
+ * Created by: Robert French
+ *
+ * $Id$
+ *
+ * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * "mit-copyright.h".
+ */
+
+
+#include <sysdep.h>
+#include <zephyr/mit-copyright.h>
+#include <zephyr/zephyr.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/param.h> /* for MAXHOSTNAMELEN */
+#include <com_err.h>
+#include <errno.h>
+
+#ifndef lint
+static char rcsid_zpopnotify_c[] = "$Id$";
+#endif /* lint */
+
+#define MAIL_CLASS "MAIL"
+#define MAIL_INSTANCE "POP"
+
+void usage();
+
+main(argc,argv)
+ int argc;
+ char *argv[];
+{
+ ZNotice_t notice;
+ struct hostent *hent;
+ int retval;
+ register int i;
+ char *whoami,myhost[MAXHOSTNAMELEN],mysender[BUFSIZ];
+ char *lines[2];
+
+ whoami = argv[0];
+
+ if ((retval = ZInitialize()) != ZERR_NONE) {
+ com_err(whoami,retval,"while initializing");
+ exit(1);
+ }
+
+ if (argc < 2) {
+ usage(whoami);
+ exit(1);
+ }
+
+ if (gethostname(myhost,MAXHOSTNAMELEN) == -1) {
+ com_err(whoami,errno,"Can't get hostname");
+ exit(1);
+ }
+ myhost[MAXHOSTNAMELEN-1] = '\0';
+
+ if (!(hent = gethostbyname(myhost))) {
+ com_err(whoami,errno,"Can't get canonical hostname");
+ exit(1);
+ }
+
+ (void) strncpy(myhost,hent->h_name,MAXHOSTNAMELEN);
+ myhost[MAXHOSTNAMELEN-1] = '\0';
+
+ lines[0] = myhost;
+ lines[1] = "You have new mail.";
+
+ (void) strcpy(mysender,"pop@");
+ (void) strcat(mysender,ZGetRealm());
+
+ for (i = 1; i < argc; i++) {
+ (void) memset((char *)¬ice, 0, sizeof(notice));
+ notice.z_kind = UNSAFE;
+ notice.z_class = MAIL_CLASS;
+ notice.z_class_inst = MAIL_INSTANCE;
+ notice.z_opcode = "";
+ notice.z_sender = mysender;
+ notice.z_default_format = "From Post Office $1:\n$2";
+
+ /* in case it's a mailbox name (pathname), strip to username */
+ notice.z_recipient = (char *)strrchr(argv[i],'/');
+ if (notice.z_recipient)
+ notice.z_recipient++;
+ else
+ notice.z_recipient = argv[i];
+
+ if ((retval = ZSendList(¬ice,lines,2,ZNOAUTH)) != ZERR_NONE) {
+ com_err(whoami,retval,"while sending notice");
+ exit(1);
+ }
+ }
+}
+
+void
+usage(whoami)
+ char *whoami;
+{
+ printf("Usage: %s username [ username ... ]\n",whoami);
+}
#include <netdb.h>
#ifndef lint
-static const char rcsid_zshutdown_notify_c[] =
+static const char *rcsid_zshutdown_notify_c =
"$Id$";
#endif
static char warning[] = "Please detach any filesystems you may have\nattached from this host by typing detach -host %s";
/*ARGSUSED*/
-int
-main(int argc,
- char *argv[])
+main(argc,argv)
+ int argc;
+ char *argv[];
{
ZNotice_t notice;
struct hostent *hp;
char rlm[REALM_SZ];
char hn2[MAXHOSTNAMELEN];
char *cp;
+ extern char *krb_get_phost();
#endif
if (gethostname(hostname, MAXHOSTNAMELEN) < 0) {
fprintf(stderr, "%s: can't figure out canonical hostname\n",argv[0]);
exit(1);
}
- retval = krb_get_lrealm(rlm, 1);
- if (retval) {
+ if (retval = krb_get_lrealm(rlm, 1)) {
fprintf(stderr, "%s: can't get local realm: %s\n",
argv[0], krb_get_err_text(retval));
exit(1);
}
- retval = krb_get_svc_in_tkt(SVC_NAME, hn2, rlm,
- SERVER_SERVICE, SERVER_INSTANCE, 1,
- KEYFILE);
- if (retval) {
+ if (retval = krb_get_svc_in_tkt(SVC_NAME, hn2, rlm,
+ SERVER_SERVICE, SERVER_INSTANCE, 1,
+ KEYFILE)) {
fprintf(stderr, "%s: can't get tickets: %s\n",
argv[0], krb_get_err_text(retval));
exit(1);
#include <internal.h>
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include "zserver.h"
#if !defined(lint) && !defined(SABER)
int serveronly = 0,hmonly = 0;
u_short srv_port;
-void usage(char *);
-void do_stat(char *);
-int srv_stat(char *);
-int hm_stat(char *, char *);
+void usage(), do_stat();
-RETSIGTYPE
-timeout(int ignored)
+RETSIGTYPE timeout()
{
outoftime = 1;
}
-int
-main(int argc,
- char *argv[])
+main(argc, argv)
+ int argc;
+ char *argv[];
{
Code_t ret;
char hostname[MAXHOSTNAMELEN];
}
void
-do_stat(char *host)
+do_stat(host)
+ char *host;
{
char srv_host[MAXHOSTNAMELEN];
}
int
-hm_stat(char *host,
- char *server)
+hm_stat(host,server)
+ char *host,*server;
{
struct in_addr inaddr;
Code_t code;
time_t runtime;
struct tm *tim;
ZNotice_t notice;
+#ifdef _POSIX_VERSION
+ struct sigaction sa;
+#endif
if ((inaddr.s_addr = inet_addr(host)) == (unsigned)(-1)) {
if ((hp = gethostbyname(host)) == NULL) {
}
int
-srv_stat(char *host)
+srv_stat(host)
+ char *host;
{
char *line[20],*mp;
int sock,i,nf,ret;
}
void
-usage(char *s)
+usage(s)
+ char *s;
{
fprintf(stderr,"usage: %s [-s] [-h] [host ...]\n",s);
exit(1);
int nrecips, msgarg, verbose, quiet, nodot, cc;
char *whoami, *inst, *class, *opcode, *realm, *recips[MAXRECIPS];
Z_AuthProc auth;
-void un_tabify(char **, int *);
+void un_tabify();
-char *fix_filsrv_inst(char *);
-void usage(char *);
-void send_off(ZNotice_t *, int);
+char *fix_filsrv_inst();
+void usage(), send_off();
-int
-main(int argc,
- char *argv[])
+main(argc, argv)
+ int argc;
+ char *argv[];
{
int retval, arg, nocheck, nchars, msgsize, filsys, tabexpand;
char *message, *signature = NULL, *format = NULL;
verbose = quiet = msgarg = nrecips = nocheck = filsys = nodot = 0;
tabexpand = 1;
- class = ZGetVariable("zwrite-class");
- if (class) {
+ if (class = ZGetVariable("zwrite-class")) {
(void) strcpy(classbfr, class);
class = classbfr;
}
else
class = DEFAULT_CLASS;
- inst = ZGetVariable("zwrite-inst");
- if (inst) {
+ if (inst = ZGetVariable("zwrite-inst")) {
(void) strcpy(instbfr, inst);
inst = instbfr;
}
else
inst = DEFAULT_INSTANCE;
- opcode = ZGetVariable("zwrite-opcode");
- if (opcode)
+ if (opcode = ZGetVariable("zwrite-opcode"))
opcode = strcpy(opbfr, opcode);
else
opcode = DEFAULT_OPCODE;
if (!nocheck && nrecips)
send_off(¬ice, 0);
- if (!msgarg && isatty(0)) {
+ if (!msgarg && isatty(0))
if (nodot)
printf("Type your message now. End with the end-of-file character.\n");
else
printf("Type your message now. End with control-D or a dot on a line by itself.\n");
- }
message = NULL;
msgsize = 0;
message = realloc(message, (unsigned)(msgsize+1));
}
else { /* Use read so you can send binary messages... */
- while ((nchars = read(fileno(stdin), bfr, sizeof bfr))) {
+ while (nchars = read(fileno(stdin), bfr, sizeof bfr)) {
if (nchars == -1) {
fprintf(stderr, "Read error from stdin! Can't continue!\n");
exit(1);
}
void
-send_off(ZNotice_t *notice,
- int real)
+send_off(notice, real)
+ ZNotice_t *notice;
+ int real;
{
int i, success, retval;
- char bfr[BUFSIZ], realm_recip[BUFSIZ], dest[3 * BUFSIZ];
+ char bfr[BUFSIZ], realm_recip[BUFSIZ], dest[3 * BUFSIZ], *cp;
ZNotice_t retnotice;
success = 0;
}
void
-usage(char *s)
+usage(s)
+ char *s;
{
fprintf(stderr,
"Usage: %s [-a] [-o] [-d] [-v] [-q] [-n] [-t] [-u] [-l]\n\
name returned by gethostbyname(hostname)
*/
-char *
-fix_filsrv_inst(char *str)
+char *fix_filsrv_inst(str)
+char *str;
{
static char fsinst[BUFSIZ];
char *ptr;
#endif /* ! TABSTOP */
void
-un_tabify(char **bufp,
- int *sizep)
+un_tabify(bufp, sizep)
+char **bufp;
+register int *sizep;
{
register char *cp, *cp2;
char *cp3;
RLIB
SLIB
KRB4_LIBS
-KRB5_LIBS
HESIOD_LIBS
REGEX_LIBS
ARES_LIBS
--with-tags[=TAGS] include additional configurations [automatic]
--with-x use the X Window System
--with-krb4=PREFIX Use Kerberos 4
- --with-krb5=PREFIX Use Kerberos 5
--with-hesiod=PREFIX Use Hesiod
--with-regex=PREFIX Use installed regex library
--with-ares=PREFIX Use libares
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4144 "configure"' > conftest.$ac_ext
+ echo '#line 4142 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6710: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6708: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6714: \$? = $ac_status" >&5
+ echo "$as_me:6712: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6943: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6941: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6947: \$? = $ac_status" >&5
+ echo "$as_me:6945: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7003: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7001: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7007: \$? = $ac_status" >&5
+ echo "$as_me:7005: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 8333 "configure"' > conftest.$ac_ext
+ echo '#line 8331 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9171 "configure"
+#line 9169 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9269 "configure"
+#line 9267 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11448: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11446: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:11452: \$? = $ac_status" >&5
+ echo "$as_me:11450: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11508: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11506: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:11512: \$? = $ac_status" >&5
+ echo "$as_me:11510: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 12019 "configure"' > conftest.$ac_ext
+ echo '#line 12017 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 12857 "configure"
+#line 12855 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 12955 "configure"
+#line 12953 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13782: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13780: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:13786: \$? = $ac_status" >&5
+ echo "$as_me:13784: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13842: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13840: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:13846: \$? = $ac_status" >&5
+ echo "$as_me:13844: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 15152 "configure"' > conftest.$ac_ext
+ echo '#line 15150 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15896: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15894: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15900: \$? = $ac_status" >&5
+ echo "$as_me:15898: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16129: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16127: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16133: \$? = $ac_status" >&5
+ echo "$as_me:16131: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16189: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16187: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16193: \$? = $ac_status" >&5
+ echo "$as_me:16191: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
- echo '#line 17519 "configure"' > conftest.$ac_ext
+ echo '#line 17517 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 18357 "configure"
+#line 18355 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 18455 "configure"
+#line 18453 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-
-for ac_header in fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h term.h
+for ac_header in fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-
-
-for ac_header in sys/select.h sys/msgbuf.h sys/cdefs.h krb5_err.h termcap.h
+for ac_header in sys/select.h sys/msgbuf.h sys/cdefs.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
if test "$no_x" != "yes"; then
+ XCLIENTS=xzwrite
ZWGC_LIBX11=-lX11
fi
fi
-# Check whether --with-krb5 was given.
-if test "${with_krb5+set}" = set; then
- withval=$with_krb5; krb5="$withval"
+# Check whether --with-hesiod was given.
+if test "${with_hesiod+set}" = set; then
+ withval=$with_hesiod; hesiod="$withval"
else
- krb5=no
+ hesiod=no
fi
-if test "$krb5" != no; then
- { echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5
-echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6; }
-if test "${ac_cv_search_gethostbyname+set}" = set; then
+if test "$hesiod" != no; then
+ { echo "$as_me:$LINENO: checking for res_send" >&5
+echo $ECHO_N "checking for res_send... $ECHO_C" >&6; }
+if test "${ac_cv_func_res_send+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_func_search_save_LIBS=$LIBS
-cat >conftest.$ac_ext <<_ACEOF
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+/* Define res_send to an innocuous variant, in case <limits.h> declares res_send.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define res_send innocuous_res_send
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char res_send (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef res_send
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
#ifdef __cplusplus
extern "C"
#endif
-char gethostbyname ();
+char res_send ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_res_send || defined __stub___res_send
+choke me
+#endif
+
int
main ()
{
-return gethostbyname ();
+return res_send ();
;
return 0;
}
_ACEOF
-for ac_lib in '' nsl; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_search_gethostbyname=$ac_res
+ ac_cv_func_res_send=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-
+ ac_cv_func_res_send=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext
- if test "${ac_cv_search_gethostbyname+set}" = set; then
- break
+ conftest$ac_exeext conftest.$ac_ext
fi
-done
-if test "${ac_cv_search_gethostbyname+set}" = set; then
+{ echo "$as_me:$LINENO: result: $ac_cv_func_res_send" >&5
+echo "${ECHO_T}$ac_cv_func_res_send" >&6; }
+if test $ac_cv_func_res_send = yes; then
:
else
- ac_cv_search_gethostbyname=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6; }
-ac_res=$ac_cv_search_gethostbyname
-if test "$ac_res" != no; then
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-{ echo "$as_me:$LINENO: checking for library containing socket" >&5
-echo $ECHO_N "checking for library containing socket... $ECHO_C" >&6; }
-if test "${ac_cv_search_socket+set}" = set; then
+{ echo "$as_me:$LINENO: checking for res_send in -lresolv" >&5
+echo $ECHO_N "checking for res_send in -lresolv... $ECHO_C" >&6; }
+if test "${ac_cv_lib_resolv_res_send+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_func_search_save_LIBS=$LIBS
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lresolv $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
#ifdef __cplusplus
extern "C"
#endif
-char socket ();
+char res_send ();
int
main ()
{
-return socket ();
+return res_send ();
;
return 0;
}
_ACEOF
-for ac_lib in '' socket; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_search_socket=$ac_res
+ ac_cv_lib_resolv_res_send=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-
+ ac_cv_lib_resolv_res_send=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext
- if test "${ac_cv_search_socket+set}" = set; then
- break
-fi
-done
-if test "${ac_cv_search_socket+set}" = set; then
- :
-else
- ac_cv_search_socket=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_search_socket" >&5
-echo "${ECHO_T}$ac_cv_search_socket" >&6; }
-ac_res=$ac_cv_search_socket
-if test "$ac_res" != no; then
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_send" >&5
+echo "${ECHO_T}$ac_cv_lib_resolv_res_send" >&6; }
+if test $ac_cv_lib_resolv_res_send = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRESOLV 1
+_ACEOF
+
+ LIBS="-lresolv $LIBS"
fi
+fi
-{ echo "$as_me:$LINENO: checking for compile in -lgen" >&5
-echo $ECHO_N "checking for compile in -lgen... $ECHO_C" >&6; }
-if test "${ac_cv_lib_gen_compile+set}" = set; then
+if test "$hesiod" != yes; then
+ CPPFLAGS="$CPPFLAGS -I$hesiod/include"
+ LDFLAGS="$LDFLAGS -L$hesiod/lib"
+fi
+{ echo "$as_me:$LINENO: checking for hes_resolve in -lhesiod" >&5
+echo $ECHO_N "checking for hes_resolve in -lhesiod... $ECHO_C" >&6; }
+if test "${ac_cv_lib_hesiod_hes_resolve+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgen $LIBS"
+LIBS="-lhesiod $LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
#ifdef __cplusplus
extern "C"
#endif
-char compile ();
+char hes_resolve ();
int
main ()
{
-return compile ();
+return hes_resolve ();
;
return 0;
}
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_gen_compile=yes
+ ac_cv_lib_hesiod_hes_resolve=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_gen_compile=no
+ ac_cv_lib_hesiod_hes_resolve=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_gen_compile" >&5
-echo "${ECHO_T}$ac_cv_lib_gen_compile" >&6; }
-if test $ac_cv_lib_gen_compile = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGEN 1
-_ACEOF
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_hesiod_hes_resolve" >&5
+echo "${ECHO_T}$ac_cv_lib_hesiod_hes_resolve" >&6; }
+if test $ac_cv_lib_hesiod_hes_resolve = yes; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: Hesiod library not found" >&5
+echo "$as_me: error: Hesiod library not found" >&2;}
+ { (exit 1); exit 1; }; }
+fi
- LIBS="-lgen $LIBS"
+ HESIOD_LIBS="-lhesiod"
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_HESIOD 1
+_ACEOF
fi
-if test "$krb5" != yes; then
- CPPFLAGS="$CPPFLAGS -I$krb5/include"
- LDFLAGS="$LDFLAGS -L$krb5/lib"
+
+# Check whether --with-regex was given.
+if test "${with_regex+set}" = set; then
+ withval=$with_regex; regex="$withval"
+else
+ regex=no
fi
-{ echo "$as_me:$LINENO: checking for krb5_init_context in -lkrb5" >&5
-echo $ECHO_N "checking for krb5_init_context in -lkrb5... $ECHO_C" >&6; }
-if test "${ac_cv_lib_krb5_krb5_init_context+set}" = set; then
+
+if test "$regex" != no; then
+ if test "$regex" != yes; then
+ CPPFLAGS="$CPPFLAGS -I$regex/include"
+ LDFLAGS="$LDFLAGS -L$regex/lib"
+ fi
+ { echo "$as_me:$LINENO: checking for regcomp in -lregex" >&5
+echo $ECHO_N "checking for regcomp in -lregex... $ECHO_C" >&6; }
+if test "${ac_cv_lib_regex_regcomp+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkrb5 -lk5crypto -lcom_err $LIBS"
+LIBS="-lregex $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
#ifdef __cplusplus
extern "C"
#endif
-char krb5_init_context ();
+char regcomp ();
int
main ()
{
-return krb5_init_context ();
+return regcomp ();
;
return 0;
}
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_krb5_krb5_init_context=yes
+ ac_cv_lib_regex_regcomp=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_krb5_krb5_init_context=no
+ ac_cv_lib_regex_regcomp=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_krb5_krb5_init_context" >&5
-echo "${ECHO_T}$ac_cv_lib_krb5_krb5_init_context" >&6; }
-if test $ac_cv_lib_krb5_krb5_init_context = yes; then
- :
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_regex_regcomp" >&5
+echo "${ECHO_T}$ac_cv_lib_regex_regcomp" >&6; }
+if test $ac_cv_lib_regex_regcomp = yes; then
+ REGEX_LIBS=-lregex
else
- { { echo "$as_me:$LINENO: error: Kerberos 5 libraries not found" >&5
-echo "$as_me: error: Kerberos 5 libraries not found" >&2;}
+ { { echo "$as_me:$LINENO: error: regex library not found" >&5
+echo "$as_me: error: regex library not found" >&2;}
{ (exit 1); exit 1; }; }
fi
- KRB5_LIBS="-lkrb5 -lk5crypto -lcom_err"
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_KRB5 1
-_ACEOF
-
-fi
-
-
-# Check whether --with-hesiod was given.
-if test "${with_hesiod+set}" = set; then
- withval=$with_hesiod; hesiod="$withval"
else
- hesiod=no
-fi
-
-if test "$hesiod" != no; then
- { echo "$as_me:$LINENO: checking for res_send" >&5
-echo $ECHO_N "checking for res_send... $ECHO_C" >&6; }
-if test "${ac_cv_func_res_send+set}" = set; then
+ { echo "$as_me:$LINENO: checking for regcomp" >&5
+echo $ECHO_N "checking for regcomp... $ECHO_C" >&6; }
+if test "${ac_cv_func_regcomp+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-/* Define res_send to an innocuous variant, in case <limits.h> declares res_send.
+/* Define regcomp to an innocuous variant, in case <limits.h> declares regcomp.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define res_send innocuous_res_send
+#define regcomp innocuous_regcomp
/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char res_send (); below.
+ which can conflict with char regcomp (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
# include <assert.h>
#endif
-#undef res_send
+#undef regcomp
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
#ifdef __cplusplus
extern "C"
#endif
-char res_send ();
+char regcomp ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
-#if defined __stub_res_send || defined __stub___res_send
+#if defined __stub_regcomp || defined __stub___regcomp
choke me
#endif
int
main ()
{
-return res_send ();
+return regcomp ();
;
return 0;
}
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_func_res_send=yes
+ ac_cv_func_regcomp=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_func_res_send=no
+ ac_cv_func_regcomp=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_res_send" >&5
-echo "${ECHO_T}$ac_cv_func_res_send" >&6; }
-if test $ac_cv_func_res_send = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_func_regcomp" >&5
+echo "${ECHO_T}$ac_cv_func_regcomp" >&6; }
+if test $ac_cv_func_regcomp = yes; then
:
else
+ { { echo "$as_me:$LINENO: error: can't find POSIX regexp support" >&5
+echo "$as_me: error: can't find POSIX regexp support" >&2;}
+ { (exit 1); exit 1; }; }
+fi
-{ echo "$as_me:$LINENO: checking for res_send in -lresolv" >&5
-echo $ECHO_N "checking for res_send in -lresolv... $ECHO_C" >&6; }
-if test "${ac_cv_lib_resolv_res_send+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char res_send ();
-int
-main ()
-{
-return res_send ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_lib_resolv_res_send=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_resolv_res_send=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_send" >&5
-echo "${ECHO_T}$ac_cv_lib_resolv_res_send" >&6; }
-if test $ac_cv_lib_resolv_res_send = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBRESOLV 1
-_ACEOF
-
- LIBS="-lresolv $LIBS"
-
-fi
-
-fi
-
-if test "$hesiod" != yes; then
- CPPFLAGS="$CPPFLAGS -I$hesiod/include"
- LDFLAGS="$LDFLAGS -L$hesiod/lib"
-fi
-{ echo "$as_me:$LINENO: checking for hes_resolve in -lhesiod" >&5
-echo $ECHO_N "checking for hes_resolve in -lhesiod... $ECHO_C" >&6; }
-if test "${ac_cv_lib_hesiod_hes_resolve+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lhesiod $LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char hes_resolve ();
-int
-main ()
-{
-return hes_resolve ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_lib_hesiod_hes_resolve=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_hesiod_hes_resolve=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_hesiod_hes_resolve" >&5
-echo "${ECHO_T}$ac_cv_lib_hesiod_hes_resolve" >&6; }
-if test $ac_cv_lib_hesiod_hes_resolve = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: Hesiod library not found" >&5
-echo "$as_me: error: Hesiod library not found" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
- HESIOD_LIBS="-lhesiod"
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_HESIOD 1
-_ACEOF
-
-fi
-
-
-# Check whether --with-regex was given.
-if test "${with_regex+set}" = set; then
- withval=$with_regex; regex="$withval"
-else
- regex=no
-fi
-
-if test "$regex" != no; then
- if test "$regex" != yes; then
- CPPFLAGS="$CPPFLAGS -I$regex/include"
- LDFLAGS="$LDFLAGS -L$regex/lib"
- fi
- { echo "$as_me:$LINENO: checking for regcomp in -lregex" >&5
-echo $ECHO_N "checking for regcomp in -lregex... $ECHO_C" >&6; }
-if test "${ac_cv_lib_regex_regcomp+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lregex $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char regcomp ();
-int
-main ()
-{
-return regcomp ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_lib_regex_regcomp=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_regex_regcomp=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_regex_regcomp" >&5
-echo "${ECHO_T}$ac_cv_lib_regex_regcomp" >&6; }
-if test $ac_cv_lib_regex_regcomp = yes; then
- REGEX_LIBS=-lregex
-else
- { { echo "$as_me:$LINENO: error: regex library not found" >&5
-echo "$as_me: error: regex library not found" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-else
- { echo "$as_me:$LINENO: checking for regcomp" >&5
-echo $ECHO_N "checking for regcomp... $ECHO_C" >&6; }
-if test "${ac_cv_func_regcomp+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define regcomp to an innocuous variant, in case <limits.h> declares regcomp.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define regcomp innocuous_regcomp
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char regcomp (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef regcomp
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char regcomp ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined __stub_regcomp || defined __stub___regcomp
-choke me
-#endif
-
-int
-main ()
-{
-return regcomp ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_func_regcomp=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_func_regcomp=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_func_regcomp" >&5
-echo "${ECHO_T}$ac_cv_func_regcomp" >&6; }
-if test $ac_cv_func_regcomp = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: can't find POSIX regexp support" >&5
-echo "$as_me: error: can't find POSIX regexp support" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-fi
-
-
-# Check whether --with-ares was given.
-if test "${with_ares+set}" = set; then
- withval=$with_ares; ares="$withval"
+fi
+
+
+# Check whether --with-ares was given.
+if test "${with_ares+set}" = set; then
+ withval=$with_ares; ares="$withval"
else
ares=no
fi
echo "$as_me: error: This package requires ss." >&2;}
{ (exit 1); exit 1; }; }
fi
-LIBS="$KRB5_LIBS $KRB4_LIBS $HESIOD_LIBS $LIBS"
+LIBS="$KRB4_LIBS $HESIOD_LIBS $LIBS"
if test $ac_cv_c_compiler_gnu = yes; then
{ echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5
done
-
-
-for ac_func in krb5_free_data krb5_c_make_checksum krb5_cc_set_default_name
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined __stub_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
-int
-main ()
-{
-return $ac_func ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- eval "$as_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- eval "$as_ac_var=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_var'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-{ echo "$as_me:$LINENO: checking for krb5_auth_con_getauthenticator taking double pointer" >&5
-echo $ECHO_N "checking for krb5_auth_con_getauthenticator taking double pointer... $ECHO_C" >&6; }
-if test "${ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#define socklen_t int
-#define ssize_t int
-#include <krb5.h>
-krb5_error_code
-krb5_auth_con_getauthenticator(krb5_context context,
- krb5_auth_context auth_context,
- krb5_authenticator *authenticator);
-int
-main ()
-{
-krb5_error_code foo = krb5_auth_con_getauthenticator(0, 0, 0);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest.$ac_objext; then
- ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=no
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=yes
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER 1
-_ACEOF
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" >&5
-echo "${ECHO_T}$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" >&6; }
-
-{ echo "$as_me:$LINENO: checking for enc_part2 in struct krb5_ticket" >&5
-echo $ECHO_N "checking for enc_part2 in struct krb5_ticket... $ECHO_C" >&6; }
-if test "${ac_cv_have_krb5_ticket_enc_part2+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <krb5.h>
-int
-main ()
-{
-krb5_ticket _tkt; _tkt.enc_part2;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest.$ac_objext; then
- ac_cv_have_krb5_ticket_enc_part2=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_have_krb5_ticket_enc_part2=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_ticket_enc_part2" = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_KRB5_TICKET_ENC_PART2 1
-_ACEOF
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_krb5_ticket_enc_part2" >&5
-echo "${ECHO_T}$ac_cv_have_krb5_ticket_enc_part2" >&6; }
-
-{ echo "$as_me:$LINENO: checking for enctype in struct krb5_keyblock" >&5
-echo $ECHO_N "checking for enctype in struct krb5_keyblock... $ECHO_C" >&6; }
-if test "${ac_cv_have_krb5_creds_keyblock_enctype+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <krb5.h>
-int
-main ()
-{
-krb5_creds _creds; _creds.keyblock.enctype;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest.$ac_objext; then
- ac_cv_have_krb5_creds_keyblock_enctype=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_have_krb5_creds_keyblock_enctype=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_creds_keyblock_enctype" = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE 1
-_ACEOF
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_have_krb5_creds_keyblock_enctype" >&5
-echo "${ECHO_T}$ac_cv_have_krb5_creds_keyblock_enctype" >&6; }
-
ac_config_headers="$ac_config_headers h/config.h"
-ac_config_files="$ac_config_files Makefile clients/Makefile clients/zaway/Makefile clients/zctl/Makefile clients/zleave/Makefile clients/zlocate/Makefile clients/znol/Makefile clients/zshutdown_notify/Makefile clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile"
+ac_config_files="$ac_config_files Makefile clients/Makefile clients/xzwrite/Makefile clients/zaway/Makefile clients/zctl/Makefile clients/zleave/Makefile clients/zlocate/Makefile clients/zmailnotify/Makefile clients/znol/Makefile clients/zpopnotify/Makefile clients/zshutdown_notify/Makefile clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
"h/config.h") CONFIG_HEADERS="$CONFIG_HEADERS h/config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"clients/Makefile") CONFIG_FILES="$CONFIG_FILES clients/Makefile" ;;
+ "clients/xzwrite/Makefile") CONFIG_FILES="$CONFIG_FILES clients/xzwrite/Makefile" ;;
"clients/zaway/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zaway/Makefile" ;;
"clients/zctl/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zctl/Makefile" ;;
"clients/zleave/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zleave/Makefile" ;;
"clients/zlocate/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zlocate/Makefile" ;;
+ "clients/zmailnotify/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zmailnotify/Makefile" ;;
"clients/znol/Makefile") CONFIG_FILES="$CONFIG_FILES clients/znol/Makefile" ;;
+ "clients/zpopnotify/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zpopnotify/Makefile" ;;
"clients/zshutdown_notify/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zshutdown_notify/Makefile" ;;
"clients/zstat/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zstat/Makefile" ;;
"clients/zwrite/Makefile") CONFIG_FILES="$CONFIG_FILES clients/zwrite/Makefile" ;;
RLIB!$RLIB$ac_delim
SLIB!$SLIB$ac_delim
KRB4_LIBS!$KRB4_LIBS$ac_delim
-KRB5_LIBS!$KRB5_LIBS$ac_delim
HESIOD_LIBS!$HESIOD_LIBS$ac_delim
REGEX_LIBS!$REGEX_LIBS$ac_delim
ARES_LIBS!$ARES_LIBS$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
-LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 2; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 1; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
AC_PATH_XTRA
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h term.h)
+AC_CHECK_HEADERS(fcntl.h paths.h termios.h sgtty.h unistd.h malloc.h)
AC_CHECK_HEADERS(sys/filio.h sys/ioctl.h sys/time.h sys/file.h sys/utsname.h)
-AC_CHECK_HEADERS(sys/select.h sys/msgbuf.h sys/cdefs.h krb5_err.h termcap.h)
+AC_CHECK_HEADERS(sys/select.h sys/msgbuf.h sys/cdefs.h)
if test "$no_x" != "yes"; then
+ XCLIENTS=xzwrite
ZWGC_LIBX11=-lX11
fi
AC_SUBST(XCLIENTS)
AC_SUBST(SLIB)
ATHENA_KRB4
-ATHENA_KRB5
ATHENA_HESIOD
ATHENA_REGEXP
ATHENA_ARES
ATHENA_UTIL_COM_ERR
ATHENA_UTIL_SS
-LIBS="$KRB5_LIBS $KRB4_LIBS $HESIOD_LIBS $LIBS"
+LIBS="$KRB4_LIBS $HESIOD_LIBS $LIBS"
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_SETPGRP
AC_CHECK_FUNCS(putenv strchr memcpy memmove waitpid getlogin strerror random)
AC_CHECK_FUNCS(lrand48 gethostid getsid getpgid krb_get_err_text krb_log)
-AC_CHECK_FUNCS(krb5_free_data krb5_c_make_checksum krb5_cc_set_default_name)
-
-AC_MSG_CHECKING(for krb5_auth_con_getauthenticator taking double pointer)
-AC_CACHE_VAL(ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer, [
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-AC_TRY_COMPILE(
-[#define socklen_t int
-#define ssize_t int
-#include <krb5.h>
-krb5_error_code
-krb5_auth_con_getauthenticator(krb5_context context,
- krb5_auth_context auth_context,
- krb5_authenticator *authenticator);],
-[krb5_error_code foo = krb5_auth_con_getauthenticator(0, 0, 0);],
-ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=no,
-ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer=yes)
-])
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" = yes; then
- AC_DEFINE(KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER)dnl
-fi
-AC_MSG_RESULT($ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer)
-
-AC_MSG_CHECKING(for enc_part2 in struct krb5_ticket)
-AC_CACHE_VAL(ac_cv_have_krb5_ticket_enc_part2, [
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-AC_TRY_COMPILE(
-[#include <krb5.h>], [krb5_ticket _tkt; _tkt.enc_part2;],
-ac_cv_have_krb5_ticket_enc_part2=yes,
-ac_cv_have_krb5_ticket_enc_part2=no)
-])
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_ticket_enc_part2" = yes; then
- AC_DEFINE(HAVE_KRB5_TICKET_ENC_PART2)dnl
-fi
-AC_MSG_RESULT($ac_cv_have_krb5_ticket_enc_part2)
-
-AC_MSG_CHECKING(for enctype in struct krb5_keyblock)
-AC_CACHE_VAL(ac_cv_have_krb5_creds_keyblock_enctype, [
-local_save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
-AC_TRY_COMPILE(
-[#include <krb5.h>], [krb5_creds _creds; _creds.keyblock.enctype;],
-ac_cv_have_krb5_creds_keyblock_enctype=yes,
-ac_cv_have_krb5_creds_keyblock_enctype=no)
-])
-CPPFLAGS="${local_save_CPPFLAGS}"
-if test "$ac_cv_have_krb5_creds_keyblock_enctype" = yes; then
- AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE)dnl
-fi
-AC_MSG_RESULT($ac_cv_have_krb5_creds_keyblock_enctype)
AC_CONFIG_HEADER(h/config.h)
-AC_OUTPUT(Makefile clients/Makefile clients/zaway/Makefile
- clients/zctl/Makefile clients/zleave/Makefile
- clients/zlocate/Makefile clients/znol/Makefile
- clients/zshutdown_notify/Makefile clients/zstat/Makefile
- clients/zwrite/Makefile lib/Makefile libdyn/Makefile
- server/Makefile zhm/Makefile zwgc/Makefile)
+AC_OUTPUT(Makefile clients/Makefile clients/xzwrite/Makefile
+ clients/zaway/Makefile clients/zctl/Makefile
+ clients/zleave/Makefile clients/zlocate/Makefile
+ clients/zmailnotify/Makefile clients/znol/Makefile
+ clients/zpopnotify/Makefile clients/zshutdown_notify/Makefile
+ clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile
+ libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile)
-zephyr (3.0~a1) unstable; urgency=low
-
- * Kerberos 5 client support; new upstream?
-
- -- Karl Ramm <kcr@1ts.org> Tue, 25 Dec 2007 00:01:24 -0500
-
zephyr (2.1.20070719.SNAPSHOT-2) unstable; urgency=low
* Z_SendLocation could be fooled by the USER_LOGIN message (which has
Package: libzephyr3-krb
Section: libs
Architecture: any
-Depends: ${shlibs:Depends}, krb5-config
+Depends: ${shlibs:Depends}, krb4-config
Conflicts: libzephyr3
Provides: libzephyr3
Description: The original "Instant Message" system libraries with Kerberos
dh_testdir
# Add here commands to configure the package.
-mkdir krb
- cd krb&& CFLAGS="-g -Wall" ../configure --with-krb4=/usr --with-krb5=/usr $(CONFIGURE_ROOT)
+ cd krb&&../configure --with-krb4=/usr $(CONFIGURE_ROOT)
-mkdir no-krb
- cd no-krb&& CFLAGS=-g ../configure $(CONFIGURE_ROOT)
+ cd no-krb&&../configure $(CONFIGURE_ROOT)
touch configure-stamp
build: configure-stamp build-stamp
dh_movefiles --sourcedir=debian/tmp-krb -plibzephyr3-krb -pzephyr-server-krb
dh_installdebconf
dh_installdocs
+# dh_installexamples
+# dh_installmenu
+# dh_installemacsen
+# dh_installpam
dh_installinit -pzephyr-clients --init-script=zhm --no-start
dh_installinit -pzephyr-server-krb --init-script=zephyrd
dh_installinit -pzephyr-server --init-script=zephyrd
+# dh_installcron
+# dh_installmanpages
+# dh_installinfo
+# dh_undocumented
dh_installchangelogs
dh_strip
+# dh_link
dh_compress
dh_fixperms
# You may want to make some executables suid here.
cp debian/libzephyr3/DEBIAN/shlibs debian/libzephyr3-krb/DEBIAN/shlibs
dh_shlibdeps
dh_installdeb
+# dh_perl
dh_gencontrol
dh_md5sums
dh_builddeb
db_input high zephyr-clients/servers || true
-db_go || true
+db_go
# if /etc/default/zephyr-clients already exists and has a zhm_args
# line, the config script should have sucked it into debconf
- db_get zephyr-clients/servers || true
+ db_get zephyr-clients/servers
tmpfile=/etc/default/zephyr-client.dpkg-new
if test -f /etc/default/zephyr-clients
. /usr/share/debconf/confmodule
db_version 2.0
-db_get zephyr-server/read_conf
-if test -f /etc/zephyr/server.list -a \( "$RET" = true \)
-then
- z="`cat /etc/zephyr/server.list`"
-
- if test -n "$z"
- then
- db_set zephyr-server/read_conf false
- db_set zephyr-server/servers "$z"
- fi
-fi
-
db_get zephyr-server/servers || true
if test -z "$RET"
then
db_set zephyr-server/servers "$z"
fi
+db_get zephyr-server/read_conf
+if test -f /etc/zephyr/server.list -a \( "$RET" = true \)
+then
+ z="`cat /etc/zephyr/server.list`"
+
+ if test -n "$z"
+ then
+ db_set zephyr-server/read_conf false
+ db_set zephyr-server/servers "$z"
+ fi
+fi
+
db_input high zephyr-server/servers || true
-db_go || true
+db_go
case "$1" in
configure)
- if test ! -f /etc/zephyr/server.list; then
- # if there's a server.list file, don't mess with it
- . /usr/share/debconf/confmodule
-
- db_version 2.0
-
- db_set zephyr-server/read_conf true
-
- db_get zephyr-server/servers || true
- : > /etc/zephyr/server.list
- for i in $RET
- do
+
+ . /usr/share/debconf/confmodule
+ db_version 2.0
+
+ db_set zephyr-server/read_conf true
+
+ db_get zephyr-server/servers
+ : > /etc/zephyr/server.list
+ for i in $RET
+ do
echo $i >> /etc/zephyr/server.list
- done
- fi
+ done
+
;;
abort-upgrade|abort-remove|abort-deconfigure)
-/* h/config.h.in. Generated from configure.in by autoheader. */
-/* Define to compile with Hesiod support. */
-#undef HAVE_HESIOD
+/* h/config.h.in. Generated automatically from configure.in by autoheader. */
-/* Define to compile with Kerberos support. */
-#undef HAVE_KRB4
+/* Define if the `getpgrp' function takes no argument. */
+#undef GETPGRP_VOID
-/* Define to compile with Kerberos v5 support. */
-#undef HAVE_KRB5
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef gid_t
-/* Define to 1 if `enc_part2' is member of `krb5_ticket'. */
-#undef HAVE_KRB5_TICKET_ENC_PART2
+/* Define if you don't have vprintf but do have _doprnt. */
+#undef HAVE_DOPRNT
-/* Define to 1 if `keyblock.enctype' is member of `krb5_creds'. */
-#undef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
-/* Define to 1 if you have the `krb5_c_make_checksum' function. */
-#undef HAVE_KRB5_C_MAKE_CHECKSUM
+/* Define if you have the vprintf function. */
+#undef HAVE_VPRINTF
-/* Define to 1 if you have the `krb5_cc_set_default_name' function. */
-#undef HAVE_KRB5_CC_SET_DEFAULT_NAME
+/* Define as the return type of signal handlers (int or void). */
+#undef RETSIGTYPE
-/* Define to 1 if `krb5_auth_con_getauthenticator' takes a double pointer third arg. */
-#undef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
+/* Define if the `setpgrp' function takes no argument. */
+#undef SETPGRP_VOID
-/* Define to 1 if you have the <krb5_err.h> header file. */
-#undef HAVE_KRB5_ERR_H
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
-/* Define to 1 if you have the `krb5_free_data' function. */
-#undef HAVE_KRB5_FREE_DATA
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef uid_t
-/* Define to 1 if you have the <krb5/ss.h> header file. */
-#undef HAVE_KRB5_SS_H
+/* Define if the X Window System is missing or not being used. */
+#undef X_DISPLAY_MISSING
-/* Define to 1 if you have the `krb_get_err_text' function. */
-#undef HAVE_KRB_GET_ERR_TEXT
+/* Define to compile with Hesiod support. */
+#undef HAVE_HESIOD
-/* Define to 1 if you have the `krb_log' function. */
-#undef HAVE_KRB_LOG
+/* Define to compile with Kerberos support. */
+#undef HAVE_KRB4
/* Define to compile with ares support. */
#undef HAVE_ARES
/* Define if you have the System Resource Controller library. */
#undef HAVE_SRC
-/* Define to "unsigned long" if your system headers don't. */
-#undef ulong
-
/* Define to a temporary directory on your system. */
#define FOUND_TMP "/var/tmp"
/* Define to the type of the host system. */
#define MACHINE_TYPE "unknown"
-/* Define if `regcomp' exists and works. */
-#undef HAVE_REGCOMP
-
-
-/* Define to 1 if the `getpgrp' function requires zero arguments. */
-#undef GETPGRP_VOID
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
+/* The number of bytes in a int. */
+#undef SIZEOF_INT
-/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
-#undef HAVE_DOPRNT
+/* The number of bytes in a long. */
+#undef SIZEOF_LONG
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
+/* The number of bytes in a short. */
+#undef SIZEOF_SHORT
-/* Define to 1 if you have the `gethostid' function. */
+/* Define if you have the gethostid function. */
#undef HAVE_GETHOSTID
-/* Define to 1 if you have the `getlogin' function. */
+/* Define if you have the getlogin function. */
#undef HAVE_GETLOGIN
-/* Define to 1 if you have the `getpgid' function. */
+/* Define if you have the getpgid function. */
#undef HAVE_GETPGID
-/* Define to 1 if you have the `getsid' function. */
+/* Define if you have the getsid function. */
#undef HAVE_GETSID
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `krb5_cc_set_default_name' function. */
-#undef HAVE_KRB5_CC_SET_DEFAULT_NAME
-
-/* Define to 1 if you have the `krb5_c_make_checksum' function. */
-#undef HAVE_KRB5_C_MAKE_CHECKSUM
-
-/* Define to 1 if you have the <krb5_err.h> header file. */
-#undef HAVE_KRB5_ERR_H
-
-/* Define to 1 if you have the `krb5_free_data' function. */
-#undef HAVE_KRB5_FREE_DATA
-
-/* Define to 1 if you have the `krb_get_err_text' function. */
+/* Define if you have the krb_get_err_text function. */
#undef HAVE_KRB_GET_ERR_TEXT
-/* Define to 1 if you have the `krb_log' function. */
+/* Define if you have the krb_log function. */
#undef HAVE_KRB_LOG
-/* Define to 1 if you have the `44bsd' library (-l44bsd). */
-#undef HAVE_LIB44BSD
-
-/* Define to 1 if you have the `curses' library (-lcurses). */
-#undef HAVE_LIBCURSES
-
-/* Define to 1 if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
-/* Define to 1 if you have the `gen' library (-lgen). */
-#undef HAVE_LIBGEN
-
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-#undef HAVE_LIBNSL
-
-/* Define to 1 if you have the `readline' library (-lreadline). */
-#undef HAVE_LIBREADLINE
-
-/* Define to 1 if you have the `resolv' library (-lresolv). */
-#undef HAVE_LIBRESOLV
-
-/* Define to 1 if you have the `socket' library (-lsocket). */
-#undef HAVE_LIBSOCKET
-
-/* Define to 1 if you have the `w' library (-lw). */
-#undef HAVE_LIBW
-
-/* Define to 1 if you have the `lrand48' function. */
+/* Define if you have the lrand48 function. */
#undef HAVE_LRAND48
-/* Define to 1 if you have the <malloc.h> header file. */
-#undef HAVE_MALLOC_H
-
-/* Define to 1 if you have the `memcpy' function. */
+/* Define if you have the memcpy function. */
#undef HAVE_MEMCPY
-/* Define to 1 if you have the `memmove' function. */
+/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <paths.h> header file. */
-#undef HAVE_PATHS_H
-
-/* Define to 1 if you have the `putenv' function. */
+/* Define if you have the putenv function. */
#undef HAVE_PUTENV
-/* Define to 1 if you have the `random' function. */
+/* Define if you have the random function. */
#undef HAVE_RANDOM
-/* Define to 1 if you have the <sgtty.h> header file. */
-#undef HAVE_SGTTY_H
+/* Define if you have the strchr function. */
+#undef HAVE_STRCHR
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
+/* Define if you have the strerror function. */
+#undef HAVE_STRERROR
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
+/* Define if you have the waitpid function. */
+#undef HAVE_WAITPID
-/* Define to 1 if you have the `strchr' function. */
-#undef HAVE_STRCHR
+/* Define if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
-/* Define to 1 if you have the `strerror' function. */
-#undef HAVE_STRERROR
+/* Define if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
+/* Define if you have the <paths.h> header file. */
+#undef HAVE_PATHS_H
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
+/* Define if you have the <sgtty.h> header file. */
+#undef HAVE_SGTTY_H
-/* Define to 1 if you have the <sys/cdefs.h> header file. */
+/* Define if you have the <sys/cdefs.h> header file. */
#undef HAVE_SYS_CDEFS_H
-/* Define to 1 if you have the <sys/file.h> header file. */
+/* Define if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
-/* Define to 1 if you have the <sys/filio.h> header file. */
+/* Define if you have the <sys/filio.h> header file. */
#undef HAVE_SYS_FILIO_H
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
+/* Define if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
-/* Define to 1 if you have the <sys/msgbuf.h> header file. */
+/* Define if you have the <sys/msgbuf.h> header file. */
#undef HAVE_SYS_MSGBUF_H
-/* Define to 1 if you have the <sys/select.h> header file. */
+/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/time.h> header file. */
+/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <sys/utsname.h> header file. */
+/* Define if you have the <sys/utsname.h> header file. */
#undef HAVE_SYS_UTSNAME_H
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#undef HAVE_SYS_WAIT_H
-
-/* Define to 1 if you have the <termcap.h> header file. */
-#undef HAVE_TERMCAP_H
-
-/* Define to 1 if you have the <termios.h> header file. */
+/* Define if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
-/* Define to 1 if you have the <term.h> header file. */
-#undef HAVE_TERM_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
+/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
-/* Define to 1 if you have the `vprintf' function. */
-#undef HAVE_VPRINTF
-
-/* Define to 1 if you have the `waitpid' function. */
-#undef HAVE_WAITPID
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
-/* Define to 1 if the `setpgrp' function takes no argument. */
-#undef SETPGRP_VOID
-
-/* The size of `int', as computed by sizeof. */
-#undef SIZEOF_INT
-
-/* The size of `long', as computed by sizeof. */
-#undef SIZEOF_LONG
+/* Define if you have the 44bsd library (-l44bsd). */
+#undef HAVE_LIB44BSD
-/* The size of `short', as computed by sizeof. */
-#undef SIZEOF_SHORT
+/* Define if you have the dl library (-ldl). */
+#undef HAVE_LIBDL
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
+/* Define if you have the gen library (-lgen). */
+#undef HAVE_LIBGEN
-/* Define to 1 if the X Window System is missing or not being used. */
-#undef X_DISPLAY_MISSING
+/* Define if you have the nsl library (-lnsl). */
+#undef HAVE_LIBNSL
-/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
- `char[]'. */
-#undef YYTEXT_POINTER
+/* Define if you have the resolv library (-lresolv). */
+#undef HAVE_LIBRESOLV
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef gid_t
+/* Define if you have the socket library (-lsocket). */
+#undef HAVE_LIBSOCKET
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef uid_t
+/* Define if you have the w library (-lw). */
+#undef HAVE_LIBW
#include <krb_err.h>
#endif
-#ifdef HAVE_KRB5
-#include <krb5.h>
-#endif
-
#ifdef HAVE_HESIOD
#include <hesiod.h>
#endif
#define Z_NOTICETIMELIMIT 30 /* Time to wait for fragments */
#define Z_INITFILTERSIZE 30 /* Starting size of uid filter */
-#define Z_AUTHMODE_NONE 0 /* no authentication */
-#define Z_AUTHMODE_KRB4 1 /* authenticate using Kerberos V4 */
-#define Z_AUTHMODE_KRB5 2 /* authenticate using Kerberos V5 */
-
-#define Z_KEYUSAGE_CLT_CKSUM 1027 /* client->server notice checksum */
-#define Z_KEYUSAGE_SRV_CKSUM 1029 /* server->client notice checksum */
-
struct _Z_Hole {
struct _Z_Hole *next;
int first;
extern int __HM_set; /* 0 if dest addr set, 1 otherwise */
extern int __Zephyr_server; /* 0 if normal client, 1 if server or zhm */
-#ifdef HAVE_KRB5
-extern krb5_context Z_krb5_ctx;
-Code_t Z_krb5_lookup_cksumtype(krb5_enctype, krb5_cksumtype *);
-#endif
-
extern ZLocations_t *__locate_list;
extern int __locate_num;
extern int __locate_next;
int (*pred) __P((ZNotice_t *, void *)), void *arg,
int timeout));
-
-Code_t Z_NewFormatHeader __P((ZNotice_t *, char *, int, int *, Z_AuthProc));
-Code_t Z_NewFormatAuthHeader __P((ZNotice_t *, char *, int, int *, Z_AuthProc));
-Code_t Z_NewFormatRawHeader __P((ZNotice_t *, char *, int, int *, char **,
- int *, char **, char **));
-Code_t Z_AsciiFormatRawHeader __P((ZNotice_t *, char *, int, int *, char **,
- int *, char **, char **));
-
void Z_gettimeofday(struct _ZTimeval *ztv, struct timezone *tz);
-
-#ifdef HAVE_KRB5
-int ZGetCreds(krb5_creds **creds_out);
-int ZGetCredsRealm(krb5_creds **creds_out, char *realm);
-Code_t Z_Checksum(krb5_data *cksumbuf, krb5_keyblock *keyblock, krb5_cksumtype cksumtype, char **asn1_data, unsigned int *asn1_len);
-Code_t Z_ExtractEncCksum(krb5_keyblock *keyblock, krb5_enctype *enctype, krb5_cksumtype *cksumtype);
-int Z_krb5_verify_cksum(krb5_keyblock *keyblock, krb5_data *cksumbuf, krb5_cksumtype cksumtype, unsigned char *asn1_data, int asn1_len);
-Code_t Z_InsertZcodeChecksum(krb5_keyblock *keyblock, ZNotice_t *notice,
- char *buffer,
- char *cksum_start, int cksum_len,
- char *cstart, char *cend, int buffer_len,
- int *length_ajdust);
-#endif
-
-#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
-#define Z_keydata(keyblock) ((keyblock)->contents)
-#define Z_keylen(keyblock) ((keyblock)->length)
-#define Z_credskey(creds) (&(creds)->keyblock)
-#define Z_enctype(keyblock) ((keyblock)->enctype)
-#else
-#define Z_keydata(keyblock) ((keyblock)->keyvalue.data)
-#define Z_keylen(keyblock) ((keyblock)->keyvalue.length)
-#define Z_credskey(creds) (&(creds)->session)
-#define Z_enctype(keyblock) ((keyblock)->keytype)
-#endif
-
-#ifdef HAVE_KRB5_TICKET_ENC_PART2
-#define Z_tktprincp(tkt) ((tkt)->enc_part2 != 0)
-#define Z_tktprinc(tkt) ((tkt)->enc_part2->client)
-#else
-#define Z_tktprincp(tkt) ((tkt)->client != 0)
-#define Z_tktprinc(tkt) ((tkt)->client)
-#endif
-
#endif /* __INTERNAL_H__ */
#include <time.h>
#include <signal.h>
#include <syslog.h>
-#ifdef HAVE_UNISTD_H
-#ifdef HAVE_GETSID
-#define __USE_XOPEN_EXTENDED
-#endif
-#include <unistd.h>
-#ifdef __USE_XOPEN_EXTENDED
-#undef __USE_XOPEN_EXTENDED
-#endif
-#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <netinet/in.h>
#endif
-#include <stdarg.h>
+/* Use __STDC__ to guess whether we can use stdarg, prototypes, and const.
+ * This is a public header file, so autoconf can't help us here. */
+#ifdef __STDC__
+# include <stdarg.h>
+# define ZP(x) x
+# define ZCONST const
+#else
+# define ZP(x) ()
+# define ZCONST
+#endif
/* Service names */
#define HM_SVCNAME "zephyr-hm"
#define SERVER_SVCNAME "zephyr-clt"
#define SERVER_SERVICE "zephyr"
#define SERVER_INSTANCE "zephyr"
-#define SERVER_KRB5_SERVICE "zephyr"
#define ZVERSIONHDR "ZEPH"
#define ZVERSIONMAJOR 0
typedef enum {
UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT
} ZNotice_Kind_t;
-extern const char *ZNoticeKinds[9];
+extern ZCONST char *ZNoticeKinds[9];
struct _ZTimeval {
int tv_sec;
char *z_multinotice;
ZUnique_Id_t z_multiuid;
ZChecksum_t z_checksum;
- char *z_ascii_checksum;
int z_num_other_fields;
char *z_other_fields[Z_MAXOTHERFIELDS];
caddr_t z_message;
/* for ZSetDebug */
#ifdef Z_DEBUG
-void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
+void (*__Z_debug_print) ZP((ZCONST char *fmt, va_list args, void *closure));
void *__Z_debug_print_closure;
#endif
-int ZCompareUIDPred(ZNotice_t *, void *);
-int ZCompareMultiUIDPred(ZNotice_t *, void *);
+int ZCompareUIDPred ZP((ZNotice_t *, void *));
+int ZCompareMultiUIDPred ZP((ZNotice_t *, void *));
/* Defines for ZFormatNotice, et al. */
-typedef Code_t (*Z_AuthProc)(ZNotice_t*, char *, int, int *);
-Code_t ZMakeAuthentication(ZNotice_t*, char *,int, int*);
-Code_t ZMakeZcodeAuthentication(ZNotice_t*, char *,int, int*);
-Code_t ZMakeZcodeRealmAuthentication(ZNotice_t*, char *,int, int*, char*);
-
-char *ZGetSender(void);
-char *ZGetVariable(char *);
-Code_t ZSetVariable(char *var, char *value);
-Code_t ZUnsetVariable(char *var);
-int ZGetWGPort(void);
-Code_t ZSetDestAddr(struct sockaddr_in *);
-Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
- char **, int*, Z_AuthProc);
-Code_t ZParseNotice(char*, int, ZNotice_t *);
-Code_t ZReadAscii(char*, int, unsigned char*, int);
-Code_t ZReadAscii32(char *, int, unsigned long *);
-Code_t ZReadAscii16(char *, int, unsigned short *);
-Code_t ZReadZcode(unsigned char*, unsigned char*, int, int *);
-Code_t ZSendPacket(char*, int, int);
-Code_t ZSendList(ZNotice_t*, char *[], int, Z_AuthProc);
-Code_t ZSrvSendList(ZNotice_t*, char*[], int, Z_AuthProc,
- Code_t (*)(ZNotice_t *, char *, int, int));
-Code_t ZSendNotice(ZNotice_t *, Z_AuthProc);
-Code_t ZSrvSendNotice(ZNotice_t*, Z_AuthProc,
- Code_t (*)(ZNotice_t *, char *, int, int));
-Code_t ZFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
-Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
-Code_t ZFormatRawNoticeList(ZNotice_t *, char *[], int, char **, int *);
-Code_t ZFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
-Code_t ZNewFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
-Code_t ZLocateUser(char *, int *, Z_AuthProc);
-Code_t ZRequestLocations(char *, ZAsyncLocateData_t *,
- ZNotice_Kind_t, Z_AuthProc);
-Code_t ZhmStat(struct in_addr *, ZNotice_t *);
-Code_t ZInitialize(void);
-Code_t ZSetServerState(int);
-Code_t ZSetFD(int);
-Code_t ZFormatSmallRawNotice(ZNotice_t*, ZPacket_t, int*);
-int ZCompareUID(ZUnique_Id_t*, ZUnique_Id_t*);
-Code_t ZSrvSendRawList(ZNotice_t*, char*[], int,
- Code_t (*)(ZNotice_t *, char *, int, int));
-Code_t ZMakeAscii(char*, int, unsigned char*, int);
-Code_t ZMakeAscii32(char *, int, unsigned long);
-Code_t ZMakeAscii16(char *, int, unsigned int);
-Code_t ZMakeZcode(char*, int, unsigned char*, int);
-Code_t ZMakeZcode32(char *, int, unsigned long);
-Code_t ZReceivePacket(ZPacket_t, int*, struct sockaddr_in*);
-Code_t ZCheckAuthentication(ZNotice_t*, struct sockaddr_in*);
-Code_t ZCheckZcodeAuthentication(ZNotice_t*, struct sockaddr_in*);
-Code_t ZCheckZcodeRealmAuthentication(ZNotice_t*, struct sockaddr_in*, char *realm);
-Code_t ZInitLocationInfo(char *hostname, char *tty);
-Code_t ZSetLocation(char *exposure);
-Code_t ZUnsetLocation(void);
-Code_t ZFlushMyLocations(void);
-char *ZParseExposureLevel(char *text);
-Code_t ZFormatRawNotice(ZNotice_t *, char**, int *);
-Code_t ZRetrieveSubscriptions(unsigned short, int*);
-Code_t ZRetrieveDefaultSubscriptions(int *);
-Code_t ZGetSubscriptions(ZSubscription_t *, int *);
-Code_t ZOpenPort(unsigned short *port);
-Code_t ZClosePort(void);
-Code_t ZFlushLocations(void);
-Code_t ZFlushSubscriptions(void);
-Code_t ZFreeNotice(ZNotice_t *notice);
-Code_t ZGetLocations(ZLocations_t *, int *);
-Code_t ZParseLocations(register ZNotice_t *notice,
- register ZAsyncLocateData_t *zald, int *nlocs,
- char **user);
-int ZCompareALDPred(ZNotice_t *notice, void *zald);
-void ZFreeALD(register ZAsyncLocateData_t *zald);
-Code_t ZCheckIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
- register int (*predicate)(ZNotice_t *,void *),
- void *args);
-Code_t ZPeekPacket(char **buffer, int *ret_len,
- struct sockaddr_in *from);
-Code_t ZPeekNotice(ZNotice_t *notice, struct sockaddr_in *from);
-Code_t ZIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
- int (*predicate)(ZNotice_t *, void *), void *args);
-Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems,
- unsigned int port);
-Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
- unsigned int port);
-Code_t ZUnsubscribeTo(ZSubscription_t *sublist, int nitems,
- unsigned int port);
-Code_t ZCancelSubscriptions(unsigned int port);
-int ZPending(void);
-Code_t ZReceiveNotice(ZNotice_t *notice, struct sockaddr_in *from);
+typedef Code_t (*Z_AuthProc) ZP((ZNotice_t*, char *, int, int *));
+Code_t ZMakeAuthentication ZP((ZNotice_t*, char *,int, int*));
+
+char *ZGetSender ZP((void));
+char *ZGetVariable ZP((char *));
+Code_t ZSetVariable ZP((char *var, char *value));
+Code_t ZUnsetVariable ZP((char *var));
+int ZGetWGPort ZP((void));
+Code_t ZSetDestAddr ZP((struct sockaddr_in *));
+Code_t ZFormatNoticeList ZP((ZNotice_t*, char**, int,
+ char **, int*, Z_AuthProc));
+Code_t ZParseNotice ZP((char*, int, ZNotice_t *));
+Code_t ZReadAscii ZP((char*, int, unsigned char*, int));
+Code_t ZReadAscii32 ZP((char *, int, unsigned long *));
+Code_t ZReadAscii16 ZP((char *, int, unsigned short *));
+Code_t ZSendPacket ZP((char*, int, int));
+Code_t ZSendList ZP((ZNotice_t*, char *[], int, Z_AuthProc));
+Code_t ZSrvSendList ZP((ZNotice_t*, char*[], int, Z_AuthProc, Code_t (*)()));
+Code_t ZSendNotice ZP((ZNotice_t *, Z_AuthProc));
+Code_t ZSrvSendNotice ZP((ZNotice_t*, Z_AuthProc, Code_t (*)()));
+Code_t ZFormatNotice ZP((ZNotice_t*, char**, int*, Z_AuthProc));
+Code_t ZFormatSmallNotice ZP((ZNotice_t*, ZPacket_t, int*, Z_AuthProc));
+Code_t ZFormatRawNoticeList ZP((ZNotice_t *notice, char *list[], int nitems,
+ char **buffer, int *ret_len));
+Code_t ZLocateUser ZP((char *, int *, Z_AuthProc));
+Code_t ZRequestLocations ZP((char *, ZAsyncLocateData_t *,
+ ZNotice_Kind_t, Z_AuthProc));
+Code_t ZhmStat ZP((struct in_addr *, ZNotice_t *));
+Code_t ZInitialize ZP((void));
+Code_t ZSetServerState ZP((int));
+Code_t ZSetFD ZP((int));
+Code_t ZFormatSmallRawNotice ZP((ZNotice_t*, ZPacket_t, int*));
+int ZCompareUID ZP((ZUnique_Id_t*, ZUnique_Id_t*));
+Code_t ZSrvSendRawList ZP((ZNotice_t*, char*[], int,
+ Code_t (*)(ZNotice_t *, char *, int, int)));
+Code_t ZMakeAscii ZP((char*, int, unsigned char*, int));
+Code_t ZMakeAscii32 ZP((char *, int, unsigned long));
+Code_t ZMakeAscii16 ZP((char *, int, unsigned int));
+Code_t ZReceivePacket ZP((ZPacket_t, int*, struct sockaddr_in*));
+Code_t ZCheckAuthentication ZP((ZNotice_t*, struct sockaddr_in*));
+Code_t ZInitLocationInfo ZP((char *hostname, char *tty));
+Code_t ZSetLocation ZP((char *exposure));
+Code_t ZUnsetLocation ZP((void));
+Code_t ZFlushMyLocations ZP((void));
+char *ZParseExposureLevel ZP((char *text));
+Code_t ZFormatRawNotice ZP((ZNotice_t *, char**, int *));
+Code_t ZRetrieveSubscriptions ZP((unsigned short, int*));
+Code_t ZOpenPort ZP((unsigned short *port));
+Code_t ZClosePort ZP((void));
+Code_t ZFlushLocations ZP((void));
+Code_t ZFlushSubscriptions ZP((void));
+Code_t ZFreeNotice ZP((ZNotice_t *notice));
+Code_t ZParseLocations ZP((register ZNotice_t *notice,
+ register ZAsyncLocateData_t *zald, int *nlocs,
+ char **user));
+int ZCompareALDPred ZP((ZNotice_t *notice, void *zald));
+void ZFreeALD ZP((register ZAsyncLocateData_t *zald));
+Code_t ZCheckIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
+ register int (*predicate) ZP((ZNotice_t *,void *)),
+ void *args));
+Code_t ZPeekPacket ZP((char **buffer, int *ret_len,
+ struct sockaddr_in *from));
+Code_t ZPeekNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
+Code_t ZIfNotice ZP((ZNotice_t *notice, struct sockaddr_in *from,
+ int (*predicate) ZP((ZNotice_t *, void *)), void *args));
+Code_t ZSubscribeTo ZP((ZSubscription_t *sublist, int nitems,
+ unsigned int port));
+Code_t ZSubscribeToSansDefaults ZP((ZSubscription_t *sublist, int nitems,
+ unsigned int port));
+Code_t ZUnsubscribeTo ZP((ZSubscription_t *sublist, int nitems,
+ unsigned int port));
+Code_t ZCancelSubscriptions ZP((unsigned int port));
+int ZPending ZP((void));
+Code_t ZReceiveNotice ZP((ZNotice_t *notice, struct sockaddr_in *from));
#ifdef Z_DEBUG
-void Z_debug(const char *, ...);
+void Z_debug ZP((ZCONST char *, ...));
#endif
+#undef ZP
+
/* Compatibility */
#define ZNewLocateUser ZLocateUser
#ifdef Z_DEBUG
-void ZSetDebug ZP((void (*)(const char *, va_list, void *), void *));
+void ZSetDebug ZP((void (*)(ZCONST char *, va_list, void *), void *));
#define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \
__Z_debug_print_closure=(closure), \
(void) 0)
#define SRV_TIMEOUT 30
#define ZAUTH (ZMakeAuthentication)
-#define ZCAUTH (ZMakeZcodeAuthentication)
#define ZNOAUTH ((Z_AuthProc)0)
/* Packet strings */
--- /dev/null
+/*
+ * zephyr_err.h:
+ * This file is automatically generated; please do not edit it.
+ */
+
+#define ZERR_PKTLEN (-772103680L)
+#define ZERR_HEADERLEN (-772103679L)
+#define ZERR_ILLVAL (-772103678L)
+#define ZERR_HMPORT (-772103677L)
+#define ZERR_PORTINUSE (-772103676L)
+#define ZERR_BADPKT (-772103675L)
+#define ZERR_VERS (-772103674L)
+#define ZERR_NOPORT (-772103673L)
+#define ZERR_NONOTICE (-772103672L)
+#define ZERR_QLEN (-772103671L)
+#define ZERR_HMDEAD (-772103670L)
+#define ZERR_INTERNAL (-772103669L)
+#define ZERR_NOLOCATIONS (-772103668L)
+#define ZERR_NOMORELOCS (-772103667L)
+#define ZERR_FIELDLEN (-772103666L)
+#define ZERR_BADFIELD (-772103665L)
+#define ZERR_SERVNAK (-772103664L)
+#define ZERR_AUTHFAIL (-772103663L)
+#define ZERR_LOGINFAIL (-772103662L)
+#define ZERR_NOSUBSCRIPTIONS (-772103661L)
+#define ZERR_NOMORESUBSCRIPTIONS (-772103660L)
+#define ZERR_TOOMANYSUBS (-772103659L)
+#define ZERR_EOF (-772103658L)
+extern void initialize_zeph_error_table(void);
+#define ERROR_TABLE_BASE_zeph (-772103680L)
+
+/* for compatibility with older versions... */
+#define init_zeph_err_tbl initialize_zeph_error_table
+#define zeph_err_base ERROR_TABLE_BASE_zeph
ZPeekIfNot.lo ZPeekNot.lo ZPeekPkt.lo ZPending.lo ZReadAscii.lo \
ZRecvNot.lo ZRecvPkt.lo ZRetSubs.lo ZSendList.lo ZSendNot.lo \
ZSendPkt.lo ZSendRaw.lo ZSendRLst.lo ZSetDest.lo ZSetFD.lo ZSetSrv.lo \
- ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo ZMakeZcode.lo \
- ZReadZcode.lo ZCkZAut.lo
+ ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo
.SUFFIXES: .lo
zephyr_err.c ${BUILDTOP}/h/zephyr/zephyr_err.h: zephyr_err.et
compile_et ${srcdir}/zephyr_err.et
- mv -f zephyr_err.h ${BUILDTOP}/h/zephyr
+ mv zephyr_err.h ${BUILDTOP}/h/zephyr
.c.lo:
${LIBTOOL} --mode=compile ${CC} -c -o $@ ${ALL_CFLAGS} $<
static const char rcsid_ZAsyncLocate_c[] = "$Id$";
#endif
-Code_t
-ZRequestLocations(char *user,
- register ZAsyncLocateData_t *zald,
- ZNotice_Kind_t kind, /* UNSAFE, UNACKED, or ACKED */
- Z_AuthProc auth)
+Code_t ZRequestLocations(user, zald, kind, auth)
+ char *user;
+ register ZAsyncLocateData_t *zald;
+ ZNotice_Kind_t kind; /* UNSAFE, UNACKED, or ACKED */
+ Z_AuthProc auth;
{
int retval;
ZNotice_t notice;
return(ZERR_NONE);
}
-Code_t
-ZParseLocations(register ZNotice_t *notice,
- register ZAsyncLocateData_t *zald,
- int *nlocs,
- char **user)
+Code_t ZParseLocations(notice,zald,nlocs,user)
+ register ZNotice_t *notice;
+ register ZAsyncLocateData_t *zald;
+ int *nlocs;
+ char **user;
{
char *ptr, *end;
int i;
return (ZERR_NONE);
}
-int
-ZCompareALDPred(ZNotice_t *notice,
- void *zald)
+int ZCompareALDPred(notice, zald)
+ ZNotice_t *notice;
+ void *zald;
{
return(ZCompareUID(&(notice->z_multiuid),
&(((ZAsyncLocateData_t *) zald)->uid)));
}
-void
-ZFreeALD(register ZAsyncLocateData_t *zald)
+void ZFreeALD(zald)
+ register ZAsyncLocateData_t *zald;
{
if (!zald) return;
*/
#ifndef lint
-static const char rcsid_ZCheckAuthentication_c[] =
+static char rcsid_ZCheckAuthentication_c[] =
"$Zephyr: /mit/zephyr/src/lib/RCS/ZCheckAuthentication.c,v 1.14 89/03/24 14:17:38 jtkohl Exp Locker: raeburn $";
#endif
#include <internal.h>
-#if defined(HAVE_KRB5) && !HAVE_KRB5_FREE_DATA
-#define krb5_free_data(ctx, dat) free((dat)->data)
-#endif
-
/* Check authentication of the notice.
If it looks authentic but fails the Kerberos check, return -1.
If it looks authentic and passes the Kerberos check, return 1.
When not using Kerberos, return true if the notice claims to be authentic.
Only used by clients; the server uses its own routine.
*/
-Code_t
-ZCheckAuthentication(ZNotice_t *notice,
- struct sockaddr_in *from)
-{
-#if defined(HAVE_KRB4) && !defined(HAVE_KRB5)
+Code_t ZCheckAuthentication(notice, from)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
+{
+#ifdef HAVE_KRB4
int result;
ZChecksum_t our_checksum;
- C_Block *session;
CREDENTIALS cred;
/* If the value is already known, return it. */
if (!notice->z_auth)
return (ZAUTH_NO);
-
+
if ((result = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE,
__Zephyr_realm, &cred)) != 0)
return (ZAUTH_NO);
- session = (C_Block *)cred.session;
-
+#ifdef NOENCRYPTION
+ our_checksum = 0;
+#else
our_checksum = des_quad_cksum(notice->z_packet, NULL,
notice->z_default_format+
strlen(notice->z_default_format)+1-
- notice->z_packet, 0, session);
-
+ notice->z_packet, 0, cred.session);
+#endif
/* if mismatched checksum, then the packet was corrupted */
return ((our_checksum == notice->z_checksum) ? ZAUTH_YES : ZAUTH_FAILED);
+
#else
- return ZCheckZcodeAuthentication(notice, from);
+ return (notice->z_auth ? ZAUTH_YES : ZAUTH_NO);
#endif
}
static const char rcsid_ZCheckIfNotice_c[] = "$Id$";
#endif
-Code_t
-ZCheckIfNotice(ZNotice_t *notice,
- struct sockaddr_in *from,
- register int (*predicate)(ZNotice_t *, void *),
- void *args)
+Code_t ZCheckIfNotice(notice, from, predicate, args)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
+ register int (*predicate) __P((ZNotice_t *, void *));
+ void *args;
{
ZNotice_t tmpnotice;
Code_t retval;
+++ /dev/null
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZCheckAuthentication function.
- *
- * Created by: Robert French
- *
- * $Source$
- * $Author$
- *
- * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- */
-/* $Header$ */
-
-#ifndef lint
-static const char rcsid_ZCheckAuthentication_c[] =
- "$Zephyr: /mit/zephyr/src/lib/RCS/ZCheckAuthentication.c,v 1.14 89/03/24 14:17:38 jtkohl Exp Locker: raeburn $";
-#endif
-
-#include <internal.h>
-
-#if defined(HAVE_KRB5) && !HAVE_KRB5_FREE_DATA
-#define krb5_free_data(ctx, dat) free((dat)->data)
-#endif
-
-/* Check authentication of the notice.
- If it looks authentic but fails the Kerberos check, return -1.
- If it looks authentic and passes the Kerberos check, return 1.
- If it doesn't look authentic, return 0
-
- When not using Kerberos, return true if the notice claims to be authentic.
- Only used by clients; the server uses its own routine.
- */
-Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
- struct sockaddr_in *from)
-{
- /* If the value is already known, return it. */
- if (notice->z_checked_auth != ZAUTH_UNSET)
- return (notice->z_checked_auth);
-
- if (!notice->z_auth)
- return (ZAUTH_NO);
-
- if (!notice->z_ascii_checksum)
- return (ZAUTH_NO);
-
-#ifdef HAVE_KRB5
- {
- krb5_error_code result;
- krb5_creds *creds;
- krb5_keyblock *keyblock;
- krb5_enctype enctype;
- krb5_cksumtype cksumtype;
- krb5_data cksumbuf;
- int valid;
- char *cksum0_base, *cksum1_base, *cksum2_base;
- char *x;
- unsigned char *asn1_data, *key_data;
- int asn1_len, key_len, cksum0_len, cksum1_len, cksum2_len;
-
- result = ZGetCreds(&creds);
-
- if (result)
- return (ZAUTH_NO);
- /* HOLDING: creds */
-
- /* Figure out what checksum type to use */
- keyblock = Z_credskey(creds);
- key_data = Z_keydata(keyblock);
- key_len = Z_keylen(keyblock);
- result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
- if (result) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return (ZAUTH_FAILED);
- }
- /* HOLDING: creds */
-
- /* Assemble the things to be checksummed */
- /* first part is from start of packet through z_default_format:
- * - z_version
- * - z_num_other_fields
- * - z_kind
- * - z_uid
- * - z_port
- * - z_auth
- * - z_authent_len
- * - z_ascii_authent
- * - z_class
- * - z_class_inst
- * - z_opcode
- * - z_sender
- * - z_recipient
- * - z_default_format
- */
- cksum0_base = notice->z_packet;
- x = notice->z_default_format;
- cksum0_len = x + strlen(x) + 1 - cksum0_base;
- /* second part is from z_multinotice through other fields:
- * - z_multinotice
- * - z_multiuid
- * - z_other_fields[]
- */
- cksum1_base = notice->z_multinotice;
- if (notice->z_num_other_fields)
- x = notice->z_other_fields[notice->z_num_other_fields];
- else
- x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */
- cksum1_len = x + strlen(x) + 1 - cksum1_base;
-
- /* last part is the message body */
- cksum2_base = notice->z_message;
- cksum2_len = notice->z_message_len;
-
- if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
- key_len == 8 &&
- (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
- /* try old-format checksum (covers cksum0 only) */
-
- ZChecksum_t our_checksum;
-
- our_checksum = des_quad_cksum((unsigned char *)cksum0_base, NULL, cksum0_len, 0,
- (C_Block *)key_data);
- if (our_checksum == notice->z_checksum) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return ZAUTH_YES;
- }
- }
- /* HOLDING: creds */
-
- cksumbuf.length = cksum0_len + cksum1_len + cksum2_len;
- cksumbuf.data = malloc(cksumbuf.length);
- if (!cksumbuf.data) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return ZAUTH_NO;
- }
- /* HOLDING: creds, cksumbuf.data */
-
- memcpy(cksumbuf.data, cksum0_base, cksum0_len);
- memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
- cksum2_base, cksum2_len);
-
- /* decode zcoded checksum */
- /* The encoded form is always longer than the original */
- asn1_len = strlen(notice->z_ascii_checksum) + 1;
- asn1_data = malloc(asn1_len);
- if (!asn1_data) {
- krb5_free_creds(Z_krb5_ctx, creds);
- free(cksumbuf.data);
- return ZAUTH_FAILED;
- }
- /* HOLDING: creds, asn1_data, cksumbuf.data */
- result = ZReadZcode((unsigned char *)notice->z_ascii_checksum,
- asn1_data, asn1_len, &asn1_len);
- if (result != ZERR_NONE) {
- krb5_free_creds(Z_krb5_ctx, creds);
- free(asn1_data);
- free(cksumbuf.data);
- return ZAUTH_FAILED;
- }
- /* HOLDING: creds, asn1_data, cksumbuf.data */
-
- valid = Z_krb5_verify_cksum(keyblock, &cksumbuf, cksumtype,
- asn1_data, asn1_len);
-
- free(asn1_data);
- krb5_free_creds(Z_krb5_ctx, creds);
- free(cksumbuf.data);
-
- if (valid)
- return ZAUTH_YES;
- else
- return ZAUTH_FAILED;
- }
-#endif /* HAVE_KRB5 */
- return (notice->z_auth ? ZAUTH_YES : ZAUTH_NO);
-}
static const char rcsid_ZClosePort_c[] = "$Id$";
#endif
-Code_t
-ZClosePort(void)
+Code_t ZClosePort()
{
if (__Zephyr_fd >= 0 && __Zephyr_open)
(void) close(__Zephyr_fd);
*/
#ifndef lint
-static const char rcsid_ZCompareUID_c[] = "$Id$";
+static char rcsid_ZCompareUID_c[] = "$Id$";
#endif
#include <internal.h>
-int
-ZCompareUID(ZUnique_Id_t *uid1,
- ZUnique_Id_t *uid2)
+int ZCompareUID(uid1, uid2)
+ ZUnique_Id_t *uid1, *uid2;
{
return (!memcmp((char *)uid1, (char *)uid2, sizeof (*uid1)));
}
*/
#ifndef lint
-static const char rcsid_ZCompareUIDPred_c[] = "$Id$";
+static char rcsid_ZCompareUIDPred_c[] = "$Id$";
#endif
#include <internal.h>
-int
-ZCompareUIDPred(ZNotice_t *notice,
- void *uid)
+int ZCompareUIDPred(notice, uid)
+ ZNotice_t *notice;
+ void *uid;
{
return (ZCompareUID(¬ice->z_uid, (ZUnique_Id_t *) uid));
}
-int
-ZCompareMultiUIDPred(ZNotice_t *notice,
- void *uid)
+int ZCompareMultiUIDPred(notice, uid)
+ ZNotice_t *notice;
+ void *uid;
{
return (ZCompareUID(¬ice->z_multiuid, (ZUnique_Id_t *) uid));
}
*/
#ifndef lint
-static const char rcsid_ZFlushLocations_c[] = "$Id$";
+static char rcsid_ZFlushLocations_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFlushLocations(void)
+Code_t ZFlushLocations()
{
int i;
static const char rcsid_ZFlushSubscriptions_c[] = "$Id$";
#endif
-Code_t
-ZFlushSubscriptions(void)
+Code_t ZFlushSubscriptions()
{
register int i;
*/
#ifndef lint
-static const char rcsid_ZFormatAuthenticNotice_c[] = "$Id$";
+static char rcsid_ZFormatAuthenticNotice_c[] = "$Id$";
#endif
#include <internal.h>
#ifdef HAVE_KRB4
-Code_t
-ZFormatAuthenticNotice(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len,
- C_Block session)
+Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session)
+ ZNotice_t *notice;
+ register char *buffer;
+ register int buffer_len;
+ int *len;
+ C_Block session;
{
ZNotice_t newnotice;
char *ptr;
&hdrlen, &ptr, NULL)) != ZERR_NONE)
return (retval);
+#ifdef NOENCRYPTION
+ newnotice.z_checksum = 0;
+#else
newnotice.z_checksum =
- (ZChecksum_t)des_quad_cksum((unsigned char *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
-
+ (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, session);
+#endif
if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
&hdrlen, NULL, NULL)) != ZERR_NONE)
return (retval);
return (ZERR_NONE);
}
#endif
-
-#ifdef HAVE_KRB5
-Code_t
-ZFormatAuthenticNoticeV5(ZNotice_t *notice,
- register char *buffer,
- register int buffer_len,
- int *len,
- krb5_keyblock *keyblock)
-{
- ZNotice_t newnotice;
- char *ptr;
- int retval, hdrlen, hdr_adj;
- krb5_enctype enctype;
- krb5_cksumtype cksumtype;
- int key_len;
- char *cksum_start, *cstart, *cend;
- int cksum_len;
-
- key_len = Z_keylen(keyblock);
- retval = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
- if (retval)
- return (ZAUTH_FAILED);
-
-#ifdef HAVE_KRB4
- if (key_len == 8 && (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
- C_Block tmp;
- memcpy(&tmp, Z_keydata(keyblock), key_len);
- return ZFormatAuthenticNotice(notice, buffer, buffer_len, len,
- tmp);
- }
-#endif
-
- newnotice = *notice;
- newnotice.z_auth = 1;
- newnotice.z_authent_len = 0;
- newnotice.z_ascii_authent = "";
-
- if ((retval = Z_NewFormatRawHeader(&newnotice, buffer, buffer_len,
- &hdrlen,
- &cksum_start, &cksum_len, &cstart,
- &cend)) != ZERR_NONE)
- return (retval);
-
- retval = Z_InsertZcodeChecksum(keyblock, &newnotice, buffer,
- cksum_start, cksum_len, cstart, cend,
- buffer_len, &hdr_adj);
- if (retval)
- return retval;
-
- hdrlen += hdr_adj;
-
- ptr = buffer+hdrlen;
-
- if (newnotice.z_message_len+hdrlen > buffer_len)
- return (ZERR_PKTLEN);
-
- (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
-
- *len = hdrlen+newnotice.z_message_len;
-
- if (*len > Z_MAXPKTLEN)
- return (ZERR_PKTLEN);
-
- return (ZERR_NONE);
-}
-#endif
"$Id$";
#endif
-Code_t
-ZFormatNoticeList(ZNotice_t *notice,
- register char **list,
- int nitems,
- char **buffer,
- int *ret_len,
- Z_AuthProc cert_routine)
+Code_t ZFormatNoticeList(notice, list, nitems, buffer, ret_len,
+ cert_routine)
+ ZNotice_t *notice;
+ register char **list;
+ int nitems;
+ char **buffer;
+ int *ret_len;
+ Z_AuthProc cert_routine;
{
char header[Z_MAXHEADERLEN];
register int i;
*/
#ifndef lint
-static const char rcsid_ZFormatNotice_c[] = "$Id$";
+static char rcsid_ZFormatNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFormatNotice(register ZNotice_t *notice,
- char **buffer,
- int *ret_len,
- Z_AuthProc cert_routine)
+Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine)
+ register ZNotice_t *notice;
+ char **buffer;
+ int *ret_len;
+ Z_AuthProc cert_routine;
{
char header[Z_MAXHEADERLEN];
int hdrlen;
return (ZERR_NONE);
}
-
-Code_t
-ZNewFormatNotice(register ZNotice_t *notice,
- char **buffer,
- int *ret_len,
- Z_AuthProc cert_routine)
-{
- char header[Z_MAXHEADERLEN];
- int hdrlen;
- Code_t retval;
-
- if ((retval = Z_NewFormatHeader(notice, header, sizeof(header), &hdrlen,
- cert_routine)) != ZERR_NONE)
- return (retval);
-
- *ret_len = hdrlen+notice->z_message_len;
-
- /* Length can never be zero, don't have to worry about malloc(0). */
- if (!(*buffer = (char *) malloc((unsigned)*ret_len)))
- return (ENOMEM);
-
- (void) memcpy(*buffer, header, hdrlen);
- (void) memcpy(*buffer+hdrlen, notice->z_message, notice->z_message_len);
-
- return (ZERR_NONE);
-}
*/
#ifndef lint
-static const char rcsid_ZFormatRawNotice_c[] = "$Id$";
+static char rcsid_ZFormatRawNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFormatRawNotice(register ZNotice_t *notice,
- char **buffer,
- int *ret_len)
+Code_t ZFormatRawNotice(notice, buffer, ret_len)
+ register ZNotice_t *notice;
+ char **buffer;
+ int *ret_len;
{
char header[Z_MAXHEADERLEN];
int hdrlen;
*/
#ifndef lint
-static const char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
+static char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFormatRawNoticeList(ZNotice_t *notice,
- char *list[],
- int nitems,
- char **buffer,
- int *ret_len)
+Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
+ char **buffer;
+ int *ret_len;
{
char header[Z_MAXHEADERLEN];
int hdrlen, i, size;
*/
#ifndef lint
-static const char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
+static char rcsid_ZFormatRawNoticeList_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFormatSmallRawNoticeList(ZNotice_t *notice,
- char *list[],
- int nitems,
- ZPacket_t buffer,
- int *ret_len)
+Code_t ZFormatSmallRawNoticeList(notice, list, nitems, buffer, ret_len)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
+ ZPacket_t buffer;
+ int *ret_len;
{
Code_t retval;
int hdrlen, i, size;
*/
#ifndef lint
-static const char rcsid_ZFormatRawNotice_c[] = "$Id$";
+static char rcsid_ZFormatRawNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFormatSmallRawNotice(ZNotice_t *notice,
- ZPacket_t buffer,
- int *ret_len)
+Code_t ZFormatSmallRawNotice(notice, buffer, ret_len)
+ ZNotice_t *notice;
+ ZPacket_t buffer;
+ int *ret_len;
{
Code_t retval;
int hdrlen;
return (ZERR_NONE);
}
-
-Code_t
-ZNewFormatSmallRawNotice(ZNotice_t *notice,
- ZPacket_t buffer,
- int *ret_len)
-{
- Code_t retval;
- int hdrlen;
-
- if ((retval = Z_AsciiFormatRawHeader(notice, buffer, Z_MAXHEADERLEN,
- &hdrlen, NULL, NULL, NULL, NULL))
- != ZERR_NONE)
- return (retval);
-
- *ret_len = hdrlen+notice->z_message_len;
-
- if (*ret_len > Z_MAXPKTLEN)
- return (ZERR_PKTLEN);
-
- (void) memcpy(buffer+hdrlen, notice->z_message, notice->z_message_len);
-
- return (ZERR_NONE);
-}
*/
#ifndef lint
-static const char rcsid_ZFreeNotice_c[] = "$Id$";
+static char rcsid_ZFreeNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZFreeNotice(ZNotice_t *notice)
+Code_t ZFreeNotice(notice)
+ ZNotice_t *notice;
{
free(notice->z_packet);
return 0;
*/
#ifndef lint
-static const char rcsid_ZGetLocations_c[] = "$Id$";
+static char rcsid_ZGetLocations_c[] = "$Id$";
#endif
#include <internal.h>
#define min(a,b) ((a)<(b)?(a):(b))
-Code_t
-ZGetLocations(ZLocations_t *location,
- int *numlocs)
+Code_t ZGetLocations(location, numlocs)
+ ZLocations_t *location;
+ int *numlocs;
{
int i;
#include <pwd.h>
-char *
-ZGetSender(void)
+char *ZGetSender()
{
struct passwd *pw;
- static char *sender = NULL;
-#ifdef HAVE_KRB5
- krb5_ccache ccache;
- krb5_principal principal;
- char *prname;
- int result;
-#else
#ifdef HAVE_KRB4
char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
-#endif
+ static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = "";
+#else
+ static char sender[128] = "";
#endif
/* Return it if already cached */
- if (sender)
+ if (*sender)
return (sender);
-#ifdef HAVE_KRB5
- result = krb5_cc_default(Z_krb5_ctx, &ccache);
- if (!result) {
- result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &principal);
- if (!result) {
- krb5_unparse_name(Z_krb5_ctx, principal, &prname);
- sender = strdup(prname);
- krb5_free_principal(Z_krb5_ctx, principal);
- return sender;
- }
- krb5_cc_close(Z_krb5_ctx, ccache);
- }
-#else
#ifdef HAVE_KRB4
if (krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm) == KSUCCESS)
{
- sender = malloc(ANAME_SZ+INST_SZ+REALM_SZ+3);
- if (sender)
- (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""),
- pinst, prealm);
+ (void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""),
+ pinst, prealm);
return (sender);
}
-#endif
#endif
/* XXX a uid_t is a u_short (now), but getpwuid
pw = getpwuid((int) getuid());
if (!pw)
return ("unknown");
- sender = malloc(strlen(pw->pw_name) + strlen(__Zephyr_realm) + 2);
- if (sender)
- (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm);
+ (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm);
return (sender);
}
*/
#ifndef lint
-static const char rcsid_ZGetSubscriptions_c[] = "$Id$";
+static char rcsid_ZGetSubscriptions_c[] = "$Id$";
#endif
#include <internal.h>
#define min(a,b) ((a)<(b)?(a):(b))
-Code_t
-ZGetSubscriptions(ZSubscription_t *subscription,
- int *numsubs)
+Code_t ZGetSubscriptions(subscription, numsubs)
+ ZSubscription_t *subscription;
+ int *numsubs;
{
int i;
*/
#ifndef lint
-static const char rcsid_ZGetWGPort_c[] = "$Id$";
+static char rcsid_ZGetWGPort_c[] = "$Id$";
#endif
#include <internal.h>
-int
-ZGetWGPort(void)
+int ZGetWGPort()
{
char *envptr, name[128];
FILE *fp;
static const char rcsid_ZIfNotice_c[] = "$Id$";
#endif
-Code_t
-ZIfNotice(ZNotice_t *notice,
- struct sockaddr_in *from,
- int (*predicate)(ZNotice_t *, void *),
- void *args)
+Code_t ZIfNotice(notice, from, predicate, args)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
+ int (*predicate) __P((ZNotice_t *, void *));
+ void *args;
{
ZNotice_t tmpnotice;
Code_t retval;
*/
#ifndef lint
-static const char rcsid_ZInitialize_c[] =
+static char rcsid_ZInitialize_c[] =
"$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZInitialize.c,v 1.17 89/05/30 18:11:25 jtkohl Exp $";
#endif
#ifdef HAVE_KRB4
#include <krb_err.h>
#endif
-#ifdef HAVE_KRB5
-#include <krb5.h>
-#endif
-#ifdef HAVE_KRB5_ERR_H
-#include <krb5_err.h>
-#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
-Code_t
-ZInitialize(void)
+Code_t ZInitialize()
{
struct servent *hmserv;
struct hostent *hostent;
char addr[4], hostname[MAXHOSTNAMELEN];
struct in_addr servaddr;
struct sockaddr_in sin;
- unsigned int s, sinsize = sizeof(sin);
+ int s, sinsize = sizeof(sin);
Code_t code;
ZNotice_t notice;
-#ifdef HAVE_KRB5
- char **krealms = NULL;
-#else
#ifdef HAVE_KRB4
char *krealm = NULL;
int krbval;
char d1[ANAME_SZ], d2[INST_SZ];
-#endif
-#endif
-#ifdef HAVE_KRB4
initialize_krb_error_table();
#endif
-#ifdef HAVE_KRB5
- initialize_krb5_error_table();
-#endif
initialize_zeph_error_table();
__Q_Tail = NULL;
__Q_Head = NULL;
-#ifdef HAVE_KRB5
- if ((code = krb5_init_context(&Z_krb5_ctx)))
- return(code);
-#endif
-
/* if the application is a server, there might not be a zhm. The
code will fall back to something which might not be "right",
but this is is ok, since none of the servers call krb_rd_req. */
If this code ever support a multiplexing zhm, this will have to
be made smarter, and probably per-message */
-#ifdef HAVE_KRB5
- code = krb5_get_host_realm(Z_krb5_ctx, notice.z_message, &krealms);
- if (code)
- return(code);
-#else
#ifdef HAVE_KRB4
krealm = krb_realmofhost(notice.z_message);
-#endif
#endif
hostent = gethostbyname(notice.z_message);
if (hostent && hostent->h_addrtype == AF_INET)
ZFreeNotice(¬ice);
}
-#ifdef HAVE_KRB5
- if (krealms) {
- strcpy(__Zephyr_realm, krealms[0]);
- krb5_free_host_realm(Z_krb5_ctx, krealms);
- } else {
- char *p; /* XXX define this somewhere portable */
- /* XXX check ticket file here */
- code = krb5_get_default_realm(Z_krb5_ctx, &p);
- strcpy(__Zephyr_realm, p);
-#ifdef HAVE_KRB5_FREE_DEFAULT_REALM
- krb5_free_default_realm(Z_krb5_ctx, p);
-#else
- free(p);
-#endif
- if (code)
- return code;
- }
-#else
#ifdef HAVE_KRB4
if (krealm) {
strcpy(__Zephyr_realm, krealm);
}
#else
strcpy(__Zephyr_realm, "local-realm");
-#endif
#endif
__My_addr.s_addr = INADDR_NONE;
*/
#ifndef lint
-static const char rcsid_ZLocations_c[] =
+static char rcsid_ZLocations_c[] =
"$Zephyr: /afs/athena.mit.edu/astaff/project/zephyr/src/lib/RCS/ZLocations.c,v 1.30 90/12/20 03:04:39 raeburn Exp $";
#endif
static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN];
static int location_info_set = 0;
-Code_t
-ZInitLocationInfo(char *hostname,
- char *tty)
+Code_t ZInitLocationInfo(hostname, tty)
+ char *hostname;
+ char *tty;
{
char *ttyp, *p;
struct hostent *hent;
return (ZERR_NONE);
}
-Code_t
-ZSetLocation(char *exposure)
+Code_t ZSetLocation(exposure)
+ char *exposure;
{
return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH,
"$sender logged in to $1 on $3 at $2"));
}
-Code_t
-ZUnsetLocation(void)
+Code_t ZUnsetLocation()
{
return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH,
"$sender logged out of $1 on $3 at $2"));
}
-Code_t
-ZFlushMyLocations(void)
+Code_t ZFlushMyLocations()
{
return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, ""));
}
-char *
-ZParseExposureLevel(char *text)
+char *ZParseExposureLevel(text)
+ char *text;
{
if (!strcasecmp(text, EXPOSE_NONE))
return (EXPOSE_NONE);
}
/* lifted from lib/ZSendPkt.c wait_for_hmack, but waits for SERVACK instead */
-static int
-wait_for_srvack(ZNotice_t *notice,
- ZUnique_id_t *uid)
+static int wait_for_srvack(notice, uid)
+ ZNotice_t *notice;
+ ZUnique_Id_t *uid;
{
return (notice->z_kind == SERVACK && ZCompareUID(¬ice->z_uid, uid));
}
-Code_t
-Z_SendLocation(char *class,
- char *opcode,
- Z_AuthProc auth,
- char *format)
+Code_t Z_SendLocation(class, opcode, auth, format)
+ char *class;
+ char *opcode;
+ Z_AuthProc auth;
+ char *format;
{
int retval;
time_t ourtime;
ZNotice_t notice, retnotice;
char *bptr[3];
+ struct hostent *hent;
short wg_port = ZGetWGPort();
if (!location_info_set)
static char *itox_chars = "0123456789ABCDEF";
-Code_t
-ZMakeAscii(register char *ptr,
- int len,
- unsigned char *field,
- int num)
+Code_t ZMakeAscii(ptr, len, field, num)
+ register char *ptr;
+ int len;
+ unsigned char *field;
+ int num;
{
int i;
return ZERR_NONE;
}
-Code_t
-ZMakeAscii32(register char *ptr,
- int len,
- unsigned long value)
+Code_t ZMakeAscii32(ptr, len, value)
+ register char *ptr;
+ int len;
+ unsigned long value;
{
if (len < 11)
return ZERR_FIELDLEN;
return ZERR_NONE;
}
-Code_t
-ZMakeAscii16(register char *ptr,
- int len,
- unsigned int value)
+Code_t ZMakeAscii16(ptr, len, value)
+ register char *ptr;
+ int len;
+ unsigned int value;
{
if (len < 7)
return ZERR_FIELDLEN;
+++ /dev/null
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZMakeZcode function.
- *
- * Created by: Jeffrey Hutzelman
- *
- * $Id$
- *
- * Copyright (c) 1987, 2002 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- */
-
-#include <internal.h>
-#include <assert.h>
-
-#ifndef lint
-static const char rcsid_ZMakeZcode_c[] = "$Id$";
-#endif
-
-Code_t
-ZMakeZcode32(char *ptr,
- int len,
- unsigned long val)
-{
- unsigned char buf[4];
- buf[0] = (val >> 24) & 0xff;
- buf[1] = (val >> 16) & 0xff;
- buf[2] = (val >> 8) & 0xff;
- buf[3] = val & 0xff;
- return ZMakeZcode(ptr, len, buf, 4);
-}
-
-Code_t
-ZMakeZcode(register char *ptr,
- int len,
- unsigned char *field,
- int num)
-{
- int i;
-
- /*
- * This optimistic check lets us discover quickly if the buffer
- * is not even large enough to hold the field without escapes.
- * It also insures we'll have space for the leading 'Z' and the
- * trailing NUL. Note that this does _not_ remove the need for
- * checking length as we encode.
- */
- if (len < num + 2)
- return ZERR_FIELDLEN;
- *ptr++ = 'Z';
- --len;
- for (i=0;i<num;i++) {
- switch (field[i]) {
- case 0x00:
- if (len < 3)
- return ZERR_FIELDLEN;
- *ptr++ = 0xff;
- *ptr++ = 0xf0;
- len -= 2;
- continue;
-
- case 0xff:
- if (len < 3)
- return ZERR_FIELDLEN;
- *ptr++ = 0xff;
- *ptr++ = 0xf1;
- len -= 2;
- continue;
-
- default:
- if (len < 2)
- return ZERR_FIELDLEN;
- *ptr++ = field[i];
- len--;
- }
- }
-
- *ptr = '\0';
- return ZERR_NONE;
-}
*
* Copyright (c) 1987 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
- * "mit-copyright.h".
+ * "mit-copyright.h".
*/
#include <internal.h>
#include <krb_err.h>
#endif
-#if defined(HAVE_KRB5) && !HAVE_KRB5_FREE_DATA
-#define krb5_free_data(ctx, dat) free((dat)->data)
-#endif
-
-Code_t
-ZResetAuthentication(void)
-{
+Code_t ZResetAuthentication () {
return ZERR_NONE;
}
-Code_t
-ZMakeAuthentication(register ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len)
+Code_t ZMakeAuthentication(notice, buffer, buffer_len, len)
+ register ZNotice_t *notice;
+ char *buffer;
+ int buffer_len;
+ int *len;
{
-#ifdef HAVE_KRB5
- return ZMakeZcodeAuthentication(notice, buffer, buffer_len, len/*?XXX*/);
-#else
#ifdef HAVE_KRB4
int result;
time_t now;
char *cstart, *cend;
ZChecksum_t checksum;
CREDENTIALS cred;
- C_Block *session;
+ extern unsigned long des_quad_cksum();
- result = krb_mk_req(&authent, SERVER_SERVICE,
+ result = krb_mk_req(&authent, SERVER_SERVICE,
SERVER_INSTANCE, __Zephyr_realm, 0);
if (result != MK_AP_OK)
return (result+krb_err_base);
if (result != KSUCCESS)
return (result+krb_err_base);
- session = (C_Block *)cred.session;
-
notice->z_auth = 1;
notice->z_authent_len = authent.length;
notice->z_ascii_authent = (char *)malloc((unsigned)authent.length*3);
/* zero length authent is an error, so malloc(0) is not a problem */
if (!notice->z_ascii_authent)
return (ENOMEM);
- if ((result = ZMakeAscii(notice->z_ascii_authent,
- authent.length*3,
- authent.dat,
+ if ((result = ZMakeAscii(notice->z_ascii_authent,
+ authent.length*3,
+ authent.dat,
authent.length)) != ZERR_NONE) {
free(notice->z_ascii_authent);
return (result);
return(result);
/* Compute a checksum over the header and message. */
- checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, session);
+ checksum = des_quad_cksum(buffer, NULL, cstart - buffer, 0, cred.session);
checksum ^= des_quad_cksum(cend, NULL, buffer + *len - cend, 0,
- session);
+ cred.session);
checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len,
- 0, session);
+ 0, cred.session);
notice->z_checksum = checksum;
ZMakeAscii32(cstart, buffer + buffer_len - cstart, checksum);
notice->z_ascii_authent = "";
return (Z_FormatRawHeader(notice, buffer, buffer_len, len, NULL, NULL));
#endif
-#endif
}
-
-Code_t
-ZMakeZcodeAuthentication(register ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *phdr_len)
-{
- return ZMakeZcodeRealmAuthentication(notice, buffer, buffer_len, phdr_len,
- __Zephyr_realm);
-}
-
-Code_t
-ZMakeZcodeRealmAuthentication(register ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *phdr_len,
- char *realm)
-{
-#ifdef HAVE_KRB5
- krb5_error_code result;
- krb5_creds *creds;
- krb5_keyblock *keyblock;
- krb5_auth_context authctx;
- krb5_data *authent;
- char *cksum_start, *cstart, *cend;
- int cksum_len, zcode_len, phdr_adj;
-
- result = ZGetCredsRealm(&creds, realm);
- if (result)
- return result;
- /* HOLDING: creds */
-
- /* Figure out what checksum type to use */
- keyblock = Z_credskey(creds);
- /* HOLDING: creds */
-
- /* Create the authenticator */
- result = krb5_auth_con_init(Z_krb5_ctx, &authctx);
- if (result) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return (result);
- }
-
- authent = (krb5_data *)malloc(sizeof(krb5_data));
-
- /* HOLDING: creds, authctx */
- result = krb5_mk_req_extended(Z_krb5_ctx, &authctx, 0 /* options */,
- 0 /* in_data */, creds, authent);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- if (result) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return (result);
- }
- /* HOLDING: creds, authent */
-
- /* Encode the authenticator */
- notice->z_auth = 1;
- notice->z_authent_len = authent->length;
- zcode_len = authent->length * 2 + 2; /* 2x growth plus Z and null */
- notice->z_ascii_authent = (char *)malloc(zcode_len);
- if (!notice->z_ascii_authent) {
- krb5_free_data(Z_krb5_ctx, authent);
- krb5_free_creds(Z_krb5_ctx, creds);
- return (ENOMEM);
- }
- /* HOLDING: creds, authent, notice->z_ascii_authent */
- result = ZMakeZcode(notice->z_ascii_authent, zcode_len,
- (unsigned char *)authent->data, authent->length);
- krb5_free_data(Z_krb5_ctx, authent);
- if (result) {
- free(notice->z_ascii_authent);
- krb5_free_creds(Z_krb5_ctx, creds);
- return (result);
- }
- /* HOLDING: creds, notice->z_ascii_authent */
-
- /* format the notice header, with a zero checksum */
- result = Z_NewFormatRawHeader(notice, buffer, buffer_len, phdr_len,
- &cksum_start, &cksum_len, &cstart, &cend);
- free(notice->z_ascii_authent);
- notice->z_authent_len = 0;
- if (result) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return (result);
- }
- result = Z_InsertZcodeChecksum(keyblock, notice, buffer, cksum_start,
- cksum_len, cstart, cend, buffer_len,
- &phdr_adj);
- krb5_free_creds(Z_krb5_ctx, creds);
- if (result) {
- return result;
- }
- *phdr_len += phdr_adj;
-
- return (result);
-#endif /* HAVE_KRB5 */
-}
-
-#ifdef HAVE_KRB5
-int
-ZGetCreds(krb5_creds **creds_out)
-{
- return ZGetCredsRealm(creds_out, __Zephyr_realm);
-}
-
-int
-ZGetCredsRealm(krb5_creds **creds_out,
- char *realm)
-{
- krb5_creds creds_in;
- krb5_ccache ccache; /* XXX make this a global or static?*/
- int result;
-
- result = krb5_cc_default(Z_krb5_ctx, &ccache);
- if (result)
- return result;
-
- memset((char *)&creds_in, 0, sizeof(creds_in));
- result = krb5_build_principal(Z_krb5_ctx, &creds_in.server,
- strlen(realm),
- realm,
- SERVER_SERVICE, SERVER_INSTANCE, 0);
- if (result) {
- krb5_cc_close(Z_krb5_ctx, ccache);
- return result;
- }
-
- result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client);
- if (result) {
- krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* I also hope this is ok */
- krb5_cc_close(Z_krb5_ctx, ccache);
- return result;
- }
-
-#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
- creds_in.keyblock.enctype = ENCTYPE_DES_CBC_CRC; /* XXX? */
-#else
- creds_in.session.keytype = KEYTYPE_DES; /* XXX? */
-#endif
-
- result = krb5_get_credentials(Z_krb5_ctx, 0, ccache, &creds_in, creds_out);
- krb5_cc_close(Z_krb5_ctx, ccache);
- krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* I also hope this is ok */
-
- return result;
-}
-#endif
"$Id$";
#endif
-Code_t
-ZLocateUser(char *user,
- int *nlocs,
- Z_AuthProc auth)
+Code_t ZLocateUser(user, nlocs, auth)
+ char *user;
+ int *nlocs;
+ Z_AuthProc auth;
{
Code_t retval;
ZNotice_t notice;
*/
#ifndef lint
-static const char rcsid_ZOpenPort_c[] = "$Id$";
+static char rcsid_ZOpenPort_c[] = "$Id$";
#endif
#include <internal.h>
#include <sys/socket.h>
-Code_t
-ZOpenPort(u_short *port)
+Code_t ZOpenPort(port)
+ u_short *port;
{
struct sockaddr_in bindin;
- unsigned int len;
+ int len;
(void) ZClosePort();
*/
#ifndef lint
-static const char rcsid_ZParseNotice_c[] =
+static char rcsid_ZParseNotice_c[] =
"$Zephyr: /mit/zephyr/src/lib/RCS/ZParseNotice.c,v 1.22 91/03/29 03:34:46 raeburn Exp $";
#endif
#include <internal.h>
/* Skip to the next NUL-terminated field in the packet. */
-static char *
-next_field(char *ptr,
- char *end)
+static char *next_field(ptr, end)
+ char *ptr, *end;
{
while (ptr < end && *ptr != '\0')
ptr++;
return (ptr);
}
-Code_t
-ZParseNotice(char *buffer,
- int len,
- ZNotice_t *notice)
+Code_t ZParseNotice(buffer, len, notice)
+ char *buffer;
+ int len;
+ ZNotice_t *notice;
{
char *ptr, *end;
unsigned long temp;
else
notice->z_default_format = "";
- if (numfields && ptr < end) {
- notice->z_ascii_checksum = ptr;
-
- if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD)
- notice->z_checksum = 0;
- else
- notice->z_checksum = temp;
-
- numfields--;
- ptr = next_field (ptr, end);
- }
- else
- {
- notice->z_ascii_checksum = "";
- notice->z_checksum = 0;
- }
+ if (ZReadAscii32(ptr, end-ptr, &temp) == ZERR_BADFIELD)
+ BAD_PACKET;
+ notice->z_checksum = temp;
+ numfields--;
+ ptr = next_field(ptr, end);
if (numfields && ptr < end) {
notice->z_multinotice = ptr;
*/
#ifndef lint
-static const char rcsid_ZPeekIfNotice_c[] = "$Id$";
+static char rcsid_ZPeekIfNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZPeekIfNotice(ZNotice_t *notice,
- struct sockaddr_in *from,
- int (*predicate)(ZNotice_t *, char *),
- char *args)
+Code_t ZPeekIfNotice(notice, from, predicate, args)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
+ int (*predicate)();
+ char *args;
{
ZNotice_t tmpnotice;
Code_t retval;
*/
#ifndef lint
-static const char rcsid_ZPeekNotice_c[] = "$Id$";
+static char rcsid_ZPeekNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZPeekNotice(ZNotice_t *notice,
- struct sockaddr_in *from)
+Code_t ZPeekNotice(notice, from)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
{
char *buffer;
int len;
*/
#ifndef lint
-static const char rcsid_ZPeekPacket_c[] = "$Id$";
+static char rcsid_ZPeekPacket_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZPeekPacket(char **buffer,
- int *ret_len,
- struct sockaddr_in *from)
+Code_t ZPeekPacket(buffer, ret_len, from)
+ char **buffer;
+ int *ret_len;
+ struct sockaddr_in *from;
{
Code_t retval;
struct _Z_InputQ *nextq;
*/
#ifndef lint
-static const char rcsid_ZPending_c[] = "$Id$";
+static char rcsid_ZPending_c[] = "$Id$";
#endif
#include <internal.h>
-int
-ZPending(void)
+int ZPending()
{
int retval;
*/
#ifndef lint
-static const char rcsid_ZReadAscii_c[] = "$Id$";
+static char rcsid_ZReadAscii_c[] = "$Id$";
#endif /* lint */
#include <internal.h>
#include <assert.h>
+#if 0
+static __inline__
+int
+Z_cnvt_xtoi (char c)
+{
+ c -= '0';
+ if (c < 10)
+ return c;
+ c -= 'A'-'9'-1;
+ if (c < 16)
+ return c;
+ return -1;
+}
+#endif
+
#define Z_cnvt_xtoi(c) ((temp=(c)-'0'),(temp<10)?temp:((temp-='A'-'9'-1),(temp<16)?temp:-1))
-Code_t
-ZReadAscii(char *ptr,
- int len,
- unsigned char *field,
- int num)
+Code_t ZReadAscii(ptr, len, field, num)
+ char *ptr;
+ int len;
+ unsigned char *field;
+ int num;
{
int i;
unsigned int hexbyte;
return *ptr ? ZERR_BADFIELD : ZERR_NONE;
}
-Code_t
-ZReadAscii32(char *ptr,
- int len,
- unsigned long *value_ptr)
+Code_t ZReadAscii32(ptr, len, value_ptr)
+ char *ptr;
+ int len;
+ unsigned long *value_ptr;
{
unsigned char buf[4];
Code_t retval;
return ZERR_NONE;
}
-Code_t
-ZReadAscii16(char *ptr,
- int len,
- unsigned short *value_ptr)
+Code_t ZReadAscii16(ptr, len, value_ptr)
+ char *ptr;
+ int len;
+ unsigned short *value_ptr;
{
unsigned char buf[2];
Code_t retval;
+++ /dev/null
-/* This file is part of the Project Athena Zephyr Notification System.
- * It contains source for the ZReadZcode function.
- *
- * Created by: Jeffrey Hutzelman
- *
- * $Id$
- *
- * Copyright (c) 1987, 1990, 2002 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- */
-
-#ifndef lint
-static const char rcsid_ZReadZcode_c[] = "$Id$";
-#endif /* lint */
-
-#include <internal.h>
-#include <assert.h>
-
-
-Code_t
-ZReadZcode(unsigned char *ptr,
- unsigned char *field,
- int max,
- int *len)
-{
- int n = 0;
-
- if (*ptr++ != 'Z')
- return ZERR_BADFIELD;
-
- while (*ptr && n < max) {
- if (*ptr == 0xff) {
- ptr++;
- switch (*ptr++) {
- case 0xf0: field[n++] = 0x00; continue;
- case 0xf1: field[n++] = 0xff; continue;
- default: return ZERR_BADFIELD;
- }
- } else {
- field[n++] = *ptr++;
- }
- }
- if (*ptr)
- return (ZERR_BADFIELD);
- *len = n;
- return (ZERR_NONE);
-}
*/
#ifndef lint
-static const char rcsid_ZReceiveNotice_c[] = "$Id$";
+static char rcsid_ZReceiveNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZReceiveNotice(ZNotice_t *notice,
- struct sockaddr_in *from)
+Code_t ZReceiveNotice(notice, from)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
{
char *buffer;
struct _Z_InputQ *nextq;
*/
#ifndef lint
-static const char rcsid_ZReceivePacket_c[] = "$Id$";
+static char rcsid_ZReceivePacket_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZReceivePacket(ZPacket_t buffer,
- int *ret_len,
- struct sockaddr_in *from)
+Code_t ZReceivePacket(buffer, ret_len, from)
+ ZPacket_t buffer;
+ int *ret_len;
+ struct sockaddr_in *from;
{
Code_t retval;
struct _Z_InputQ *nextq;
"$Id$";
#endif
-static Code_t Z_RetSubs (register ZNotice_t *, int *, Z_AuthProc);
+static Code_t Z_RetSubs ();
/* Need STDC definition when possible for unsigned short argument. */
-Code_t
-ZRetrieveSubscriptions(unsigned short port,
- int *nsubs)
+#ifdef __STDC__
+Code_t ZRetrieveSubscriptions(unsigned short port, int *nsubs)
+#else
+Code_t ZRetrieveSubscriptions(port,nsubs)
+ unsigned short port;
+ int *nsubs;
+#endif
{
int retval;
ZNotice_t notice;
return(Z_RetSubs(¬ice, nsubs, ZAUTH));
}
-Code_t
-ZRetrieveDefaultSubscriptions(int *nsubs)
+Code_t ZRetrieveDefaultSubscriptions(nsubs)
+ int *nsubs;
{
ZNotice_t notice;
}
-static Code_t
-Z_RetSubs(register ZNotice_t *notice,
- int *nsubs,
- Z_AuthProc auth_routine)
+static Code_t Z_RetSubs(notice, nsubs, auth_routine)
+ register ZNotice_t *notice;
+ int *nsubs;
+ Z_AuthProc auth_routine;
{
register int i;
int retval,nrecv,gimmeack;
*/
#ifndef lint
-static const char rcsid_ZSendList_c[] = "$Id$";
+static char rcsid_ZSendList_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t ZSendList(ZNotice_t *notice,
- char *list[],
- int nitems,
- Z_AuthProc cert_routine)
+Code_t ZSendList(notice, list, nitems, cert_routine)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
+ Z_AuthProc cert_routine;
{
return(ZSrvSendList(notice, list, nitems, cert_routine, Z_XmitFragment));
}
-Code_t
-ZSrvSendList(ZNotice_t *notice,
- char *list[],
- int nitems,
- Z_AuthProc cert_routine,
- Code_t (*send_routine)(ZNotice_t *, char *, int, int))
+Code_t ZSrvSendList(notice, list, nitems, cert_routine, send_routine)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
+ Z_AuthProc cert_routine;
+ Code_t (*send_routine)();
{
Code_t retval;
ZNotice_t newnotice;
*/
#ifndef lint
-static const char rcsid_ZSendNotice_c[] = "$Id$";
+static char rcsid_ZSendNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZSendNotice(ZNotice_t *notice,
- Z_AuthProc cert_routine)
+Code_t ZSendNotice(notice, cert_routine)
+ ZNotice_t *notice;
+ Z_AuthProc cert_routine;
{
return(ZSrvSendNotice(notice, cert_routine, Z_XmitFragment));
}
-Code_t
-ZSrvSendNotice(ZNotice_t *notice,
- Z_AuthProc cert_routine,
- Code_t (*send_routine)(ZNotice_t *, char *, int, int))
+Code_t ZSrvSendNotice(notice, cert_routine, send_routine)
+ ZNotice_t *notice;
+ Z_AuthProc cert_routine;
+ Code_t (*send_routine)();
{
Code_t retval;
ZNotice_t newnotice;
*/
#ifndef lint
-static const char rcsid_ZSendPacket_c[] =
+static char rcsid_ZSendPacket_c[] =
"$Zephyr: /mit/zephyr/src/lib/RCS/ZSendPacket.c,v 1.29 91/03/21 11:57:08 raeburn Exp $";
#endif
#include <internal.h>
#include <sys/socket.h>
-static int wait_for_hmack(ZNotice_t *, void *);
+static int wait_for_hmack();
-Code_t
-ZSendPacket(char *packet,
- int len,
- int waitforack)
+Code_t ZSendPacket(packet, len, waitforack)
+ char *packet;
+ int len;
+ int waitforack;
{
Code_t retval;
struct sockaddr_in dest;
if ((retval = ZParseNotice(packet, len, ¬ice)) != ZERR_NONE)
return (retval);
- retval = Z_WaitForNotice(&acknotice, wait_for_hmack, ¬ice.z_uid,
- HM_TIMEOUT);
+ retval = Z_WaitForNotice (&acknotice, wait_for_hmack, ¬ice.z_uid,
+ HM_TIMEOUT);
if (retval == ETIMEDOUT)
return ZERR_HMDEAD;
if (retval == ZERR_NONE)
return retval;
}
-static int
-wait_for_hmack(ZNotice_t *notice,
- void *uid)
+static int wait_for_hmack(notice, uid)
+ ZNotice_t *notice;
+ ZUnique_Id_t *uid;
{
- return (notice->z_kind == HMACK && ZCompareUID(¬ice->z_uid, (ZUnique_Id_t *)uid));
+ return (notice->z_kind == HMACK && ZCompareUID(¬ice->z_uid, uid));
}
*/
#ifndef lint
-static const char rcsid_ZSendRawList_c[] = "$Id$";
+static char rcsid_ZSendRawList_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t ZSendRawList(ZNotice_t *notice,
- char *list[],
- int nitems)
+Code_t ZSendRawList(notice, list, nitems)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
{
return(ZSrvSendRawList(notice, list, nitems, Z_XmitFragment));
}
-Code_t ZSrvSendRawList(ZNotice_t *notice,
- char *list[],
- int nitems,
- Code_t (*send_routine)(ZNotice_t *, char *, int, int))
+Code_t ZSrvSendRawList(notice, list, nitems, send_routine)
+ ZNotice_t *notice;
+ char *list[];
+ int nitems;
+ Code_t (*send_routine)();
{
Code_t retval;
ZNotice_t newnotice;
*/
#ifndef lint
-static const char rcsid_ZSendRawNotice_c[] = "$Id$";
+static char rcsid_ZSendRawNotice_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZSendRawNotice(ZNotice_t *notice)
+Code_t ZSendRawNotice(notice)
+ ZNotice_t *notice;
{
Code_t retval;
ZNotice_t newnotice;
*/
#ifndef lint
-static const char rcsid_ZSetDestAddr_c[] = "$Id$";
+static char rcsid_ZSetDestAddr_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZSetDestAddr(struct sockaddr_in *addr)
+Code_t ZSetDestAddr(addr)
+ struct sockaddr_in *addr;
{
__HM_addr = *addr;
*/
#ifndef lint
-static const char rcsid_ZSetFD_c[] = "$Id$";
+static char rcsid_ZSetFD_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZSetFD(int fd)
+Code_t ZSetFD(fd)
+ int fd;
{
(void) ZClosePort();
*/
#ifndef lint
-static const char rcsid_ZSetServerState_c[] = "$Id$";
+static char rcsid_ZSetServerState_c[] = "$Id$";
#endif
#include <internal.h>
-Code_t
-ZSetServerState(int state)
+Code_t ZSetServerState(state)
+ int state;
{
__Zephyr_server = state;
static const char rcsid_ZSubscriptions_c[] = "$Id$";
#endif
-static Code_t Z_Subscriptions(register ZSubscription_t *sublist,
- int nitems, unsigned int port,
- char *opcode, int authit);
-static Code_t subscr_sendoff(ZNotice_t *notice, char **lyst, int num,
- int authit);
-
-Code_t
-ZSubscribeTo(ZSubscription_t *sublist,
- int nitems,
- unsigned int port)
+static Code_t Z_Subscriptions __P((register ZSubscription_t *sublist,
+ int nitems, unsigned int port,
+ char *opcode, int authit));
+static Code_t subscr_sendoff __P((ZNotice_t *notice, char **lyst, int num,
+ int authit));
+
+Code_t ZSubscribeTo(sublist, nitems, port)
+ ZSubscription_t *sublist;
+ int nitems;
+ unsigned int port;
{
return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE, 1));
}
-Code_t
-ZSubscribeToSansDefaults(ZSubscription_t *sublist,
- int nitems,
- unsigned int port)
+Code_t ZSubscribeToSansDefaults(sublist, nitems, port)
+ ZSubscription_t *sublist;
+ int nitems;
+ unsigned int port;
{
return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE_NODEFS,
1));
}
-Code_t
-ZUnsubscribeTo(ZSubscription_t *sublist,
- int nitems,
- unsigned int port)
+Code_t ZUnsubscribeTo(sublist, nitems, port)
+ ZSubscription_t *sublist;
+ int nitems;
+ unsigned int port;
{
return (Z_Subscriptions(sublist, nitems, port, CLIENT_UNSUBSCRIBE, 1));
}
-Code_t
-ZCancelSubscriptions(unsigned int port)
+Code_t ZCancelSubscriptions(port)
+ unsigned int port;
{
return (Z_Subscriptions((ZSubscription_t *)0, 0, port,
CLIENT_CANCELSUB, 0));
*/
static Code_t
-Z_Subscriptions(register ZSubscription_t *sublist,
- int nitems,
- unsigned int port,
- char *opcode,
- int authit)
+Z_Subscriptions(sublist, nitems, port, opcode, authit)
+ register ZSubscription_t *sublist;
+ int nitems;
+ unsigned int port;
+ char *opcode;
+ int authit;
{
register int i, j;
int retval;
}
static Code_t
-subscr_sendoff(ZNotice_t *notice,
- char **lyst,
- int num,
- int authit)
+subscr_sendoff(notice, lyst, num, authit)
+ZNotice_t *notice;
+char **lyst;
+int num;
+int authit;
{
register Code_t retval;
ZNotice_t retnotice;
*/
#ifndef lint
-static const char rcsid_ZVariables_c[] = "$Id$";
+static char rcsid_ZVariables_c[] = "$Id$";
#endif
#include <internal.h>
#include <ctype.h>
#include <pwd.h>
-static int get_localvarfile(char *bfr);
-static char *get_varval(char *fn, char *val);
-static int varline(char *bfr, char *var);
+static int get_localvarfile __P((char *bfr));
+static char *get_varval __P((char *fn, char *val));
+static int varline __P((char *bfr, char *var));
-char *
-ZGetVariable(char *var)
+char *ZGetVariable(var)
+ char *var;
{
char varfile[128], *ret;
+ char *get_varval();
if (get_localvarfile(varfile))
return ((char *)0);
return (get_varval(varfile, var));
}
-Code_t
-ZSetVariable(char *var, char *value)
+Code_t ZSetVariable(var, value)
+ char *var;
+ char *value;
{
int written;
FILE *fpin, *fpout;
return (ZERR_NONE);
}
-Code_t
-ZUnsetVariable(char *var)
+Code_t ZUnsetVariable(var)
+ char *var;
{
FILE *fpin, *fpout;
char varfile[128], varfilebackup[128], varbfr[512];
return (ZERR_NONE);
}
-static int
-get_localvarfile(char *bfr)
+static int get_localvarfile(bfr)
+ char *bfr;
{
char *envptr;
struct passwd *pwd;
return (0);
}
-static char *
-get_varval(char *fn, char *var)
+static char *get_varval(fn, var)
+ char *fn;
+ char *var;
{
FILE *fp;
static char varbfr[512];
/* If the variable in the line bfr[] is the same as var, return index to
the variable value, else return 0. */
-static int
-varline(char *bfr, char *var)
+static int varline(bfr, var)
+ char *bfr;
+ char *var;
{
register char *cp;
#include "mit-copyright.h"
#ifndef lint
-static const char rcsid_ZWaitForNotice_c[] = "$Id$";
+static char rcsid_ZWaitForNotice_c[] = "$Id$";
#endif
#include <internal.h>
#include <sys/socket.h>
-Code_t
-Z_WaitForNotice(ZNotice_t *notice,
- int (*pred) __P((ZNotice_t *, void *)),
- void *arg,
- int timeout)
+Code_t Z_WaitForNotice (notice, pred, arg, timeout)
+ ZNotice_t *notice;
+ int (*pred) __P((ZNotice_t *, void *));
+ void *arg;
+ int timeout;
{
Code_t retval;
struct timeval tv, t0;
#define INADDR_LOOPBACK 0x7f000001
#endif
-Code_t
-ZhmStat(struct in_addr *hostaddr,
- ZNotice_t *notice)
+Code_t ZhmStat(hostaddr, notice)
+ struct in_addr *hostaddr;
+ ZNotice_t *notice;
{
struct servent *sp;
struct sockaddr_in sin;
"Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology.";
#endif
+extern char *inet_ntoa ();
+
int __Zephyr_fd = -1;
int __Zephyr_open;
int __Zephyr_port = -1;
int __subscriptions_next;
int Z_discarded_packets = 0;
-#ifdef HAVE_KRB5
-/* This context is used throughout */
-krb5_context Z_krb5_ctx;
-
-static struct cksum_map_s {
- krb5_enctype e;
- krb5_cksumtype c;
-} cksum_map[] = {
- /* per RFC1510 and draft-ietf-krb-wg-crypto-02.txt */
- { ENCTYPE_NULL, CKSUMTYPE_RSA_MD5 },
- { ENCTYPE_DES_CBC_CRC, CKSUMTYPE_RSA_MD5_DES },
- { ENCTYPE_DES_CBC_MD4, CKSUMTYPE_RSA_MD4_DES },
- { ENCTYPE_DES_CBC_MD5, CKSUMTYPE_RSA_MD5_DES },
-
- /*
- * The implementors hate us, and are inconsistent with names for
- * most things defined after RFC1510. Note that des3-cbc-sha1
- * and des3-cbc-sha1-kd are listed by number to avoid confusion
- * caused by inconsistency between the names used in the specs
- * and those used by implementations.
- * -- jhutz, 30-Nov-2002
- */
-
- /* source lost in history (an expired internet-draft) */
- { 5 /* des3-cbc-md5 */, 9 /* rsa-md5-des3 */ },
- { 7 /* des3-cbc-sha1 */, 13 /* hmac-sha1-des3 */ },
-
- /* per draft-ietf-krb-wg-crypto-02.txt */
- { 16 /* des3-cbc-sha1-kd */, 12 /* hmac-sha1-des3-kd */ },
-
- /* per draft-raeburn-krb-rijndael-krb-02.txt */
- { 17 /* aes128-cts-hmac-sha1-96 */, 15 /* hmac-sha1-96-aes128 */ },
- { 18 /* aes256-cts-hmac-sha1-96 */, 16 /* hmac-sha1-96-aes256 */ },
-
- /* per draft-brezak-win2k-krb-rc4-hmac-04.txt */
- { 23 /* rc4-hmac */, -138 /* hmac-md5 */ },
- { 24 /* rc4-hmac-exp */, -138 /* hmac-md5 */ },
-};
-#define N_CKSUM_MAP (sizeof(cksum_map) / sizeof(struct cksum_map_s))
-
-Code_t
-Z_krb5_lookup_cksumtype(krb5_enctype e,
- krb5_cksumtype *c)
-{
- int i;
-
- for (i = 0; i < N_CKSUM_MAP; i++) {
- if (cksum_map[i].e == e) {
- *c = cksum_map[i].c;
- return ZERR_NONE;
- }
- }
- return KRB5_PROG_ETYPE_NOSUPP;
-}
-#endif /* HAVE_KRB5 */
-
+#ifdef HAVE_KRB4
+C_Block __Zephyr_session;
+#endif
char __Zephyr_realm[REALM_SZ];
#ifdef Z_DEBUG
-void (*__Z_debug_print)(const char *fmt, va_list args, void *closure);
+void (*__Z_debug_print) __P((const char *fmt, va_list args, void *closure));
void *__Z_debug_print_closure;
#endif
#define min(a,b) ((a)<(b)?(a):(b))
-static int Z_AddField(char **ptr, char *field, char *end);
-static int find_or_insert_uid(ZUnique_Id_t *uid, ZNotice_Kind_t kind);
-static Code_t Z_ZcodeFormatRawHeader(ZNotice_t *, char *, int, int *, char **,
- int *, char **, char **, int cksumtype);
+static int Z_AddField __P((char **ptr, char *field, char *end));
+static int find_or_insert_uid __P((ZUnique_Id_t *uid, ZNotice_Kind_t kind));
/* Find or insert uid in the old uids buffer. The buffer is a sorted
* circular queue. We make the assumption that most packets arrive in
* order, so we can usually search for a uid or insert it into the buffer
* by looking back just a few entries from the end. Since this code is
* only executed by the client, the implementation isn't microoptimized. */
-static int
-find_or_insert_uid(ZUnique_Id_t *uid,
- ZNotice_Kind_t kind)
+static int find_or_insert_uid(uid, kind)
+ ZUnique_Id_t *uid;
+ ZNotice_Kind_t kind;
{
static struct _filter {
ZUnique_Id_t uid;
/* Return 1 if there is a packet waiting, 0 otherwise */
-int
-Z_PacketWaiting(void)
+int Z_PacketWaiting()
{
struct timeval tv;
fd_set read;
/* Wait for a complete notice to become available */
-Code_t
-Z_WaitForComplete(void)
+Code_t Z_WaitForComplete()
{
Code_t retval;
/* Read any available packets and enqueue them */
-Code_t
-Z_ReadEnqueue(void)
+Code_t Z_ReadEnqueue()
{
Code_t retval;
* notices that haven't been touched in a while
*/
-struct _Z_InputQ *
-Z_SearchQueue(ZUnique_Id_t *uid,
- ZNotice_Kind_t kind)
+struct _Z_InputQ *Z_SearchQueue(uid, kind)
+ ZUnique_Id_t *uid;
+ ZNotice_Kind_t kind;
{
register struct _Z_InputQ *qptr;
struct _Z_InputQ *next;
* returns.
*/
-Code_t
-Z_ReadWait(void)
+Code_t Z_ReadWait()
{
register struct _Z_InputQ *qptr;
ZNotice_t notice;
ZPacket_t packet;
struct sockaddr_in olddest, from;
- unsigned int from_len;
- int packet_len, zvlen, part, partof;
+ int from_len, packet_len, zvlen, part, partof;
char *slash;
Code_t retval;
fd_set fds;
/* Fragment management routines - compliments, more or less, of RFC815 */
-Code_t
-Z_AddNoticeToEntry(struct _Z_InputQ *qptr,
- ZNotice_t *notice,
- int part)
+Code_t Z_AddNoticeToEntry(qptr, notice, part)
+ struct _Z_InputQ *qptr;
+ ZNotice_t *notice;
+ int part;
{
int last, oldfirst, oldlast;
struct _Z_Hole *hole, *lasthole;
return (ZERR_NONE);
}
-void
-Z_gettimeofday(struct _ZTimeval *ztv,
- struct timezone *tz)
+void Z_gettimeofday(struct _ZTimeval *ztv, struct timezone *tz)
{
struct timeval tv;
(void) gettimeofday(&tv, tz); /* yeah, yeah, I know */
ztv->tv_usec=tv.tv_usec;
}
-Code_t
-Z_FormatHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len,
- Z_AuthProc cert_routine)
+Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine)
+ ZNotice_t *notice;
+ char *buffer;
+ int buffer_len;
+ int *len;
+ Z_AuthProc cert_routine;
{
Code_t retval;
static char version[BUFSIZ]; /* default init should be all \0 */
struct sockaddr_in name;
- unsigned int namelen = sizeof(name);
+ int namelen = sizeof(name);
if (!notice->z_sender)
notice->z_sender = ZGetSender();
return Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine);
}
-Code_t
-Z_NewFormatHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len,
- Z_AuthProc cert_routine)
-{
- Code_t retval;
- static char version[BUFSIZ]; /* default init should be all \0 */
- struct sockaddr_in name;
- struct timeval tv;
- unsigned int namelen = sizeof(name);
-
- if (!notice->z_sender)
- notice->z_sender = ZGetSender();
-
- if (notice->z_port == 0) {
- if (ZGetFD() < 0) {
- retval = ZOpenPort((u_short *)0);
- if (retval != ZERR_NONE)
- return (retval);
- }
- retval = getsockname(ZGetFD(), (struct sockaddr *) &name, &namelen);
- if (retval != 0)
- return (retval);
- notice->z_port = name.sin_port;
- }
-
- notice->z_multinotice = "";
-
- (void) gettimeofday(&tv, (struct timezone *)0);
- notice->z_uid.tv.tv_sec = htonl((u_long) tv.tv_sec);
- notice->z_uid.tv.tv_usec = htonl((u_long) tv.tv_usec);
-
- (void) memcpy(¬ice->z_uid.zuid_addr, &__My_addr, sizeof(__My_addr));
-
- notice->z_multiuid = notice->z_uid;
-
- if (!version[0])
- (void) sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR,
- ZVERSIONMINOR);
- notice->z_version = version;
-
- return Z_NewFormatAuthHeader(notice, buffer, buffer_len, len, cert_routine);
-}
-
-Code_t
-Z_FormatAuthHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len,
- Z_AuthProc cert_routine)
-{
- if (!cert_routine) {
- notice->z_auth = 0;
- notice->z_authent_len = 0;
- notice->z_ascii_authent = "";
- notice->z_checksum = 0;
- return (Z_FormatRawHeader(notice, buffer, buffer_len,
- len, NULL, NULL));
- }
-
- return ((*cert_routine)(notice, buffer, buffer_len, len));
-}
-
-Code_t
-Z_NewFormatAuthHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len,
- Z_AuthProc cert_routine)
+Code_t Z_FormatAuthHeader(notice, buffer, buffer_len, len, cert_routine)
+ ZNotice_t *notice;
+ char *buffer;
+ int buffer_len;
+ int *len;
+ Z_AuthProc cert_routine;
{
if (!cert_routine) {
notice->z_auth = 0;
return ((*cert_routine)(notice, buffer, buffer_len, len));
}
-Code_t
-Z_NewFormatRawHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *hdr_len,
- char **cksum_start,
- int *cksum_len,
- char **cstart,
- char **cend)
-{
- return(Z_ZcodeFormatRawHeader(notice, buffer, buffer_len, hdr_len,
- cksum_start, cksum_len, cstart, cend, 0));
-}
-
-Code_t
-Z_AsciiFormatRawHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *hdr_len,
- char **cksum_start,
- int *cksum_len,
- char **cstart,
- char **cend)
-{
- return(Z_ZcodeFormatRawHeader(notice, buffer, buffer_len, hdr_len,
- cksum_start, cksum_len, cstart, cend, 1));
-}
-
-static Code_t
-Z_ZcodeFormatRawHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *hdr_len,
- char **cksum_start,
- int *cksum_len,
- char **cstart,
- char **cend,
- int cksumstyle)
-{
- static char version_nogalaxy[BUFSIZ]; /* default init should be all \0 */
- char newrecip[BUFSIZ];
- char *ptr, *end;
- int i;
-
- if (!notice->z_class)
- notice->z_class = "";
-
- if (!notice->z_class_inst)
- notice->z_class_inst = "";
-
- if (!notice->z_opcode)
- notice->z_opcode = "";
-
- if (!notice->z_recipient)
- notice->z_recipient = "";
-
- if (!notice->z_default_format)
- notice->z_default_format = "";
-
- ptr = buffer;
- end = buffer+buffer_len;
-
- if (cksum_start)
- *cksum_start = ptr;
-
- (void) sprintf(version_nogalaxy, "%s%d.%d", ZVERSIONHDR,
- ZVERSIONMAJOR, ZVERSIONMINOR);
-
- notice->z_version = version_nogalaxy;
-
- if (Z_AddField(&ptr, version_nogalaxy, end))
- return (ZERR_HEADERLEN);
-
- if (ZMakeAscii32(ptr, end-ptr,
- Z_NUMFIELDS + notice->z_num_other_fields)
- == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- if (ZMakeAscii32(ptr, end-ptr, notice->z_kind) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_uid,
- sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- if (ZMakeAscii16(ptr, end-ptr, ntohs(notice->z_port)) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- if (ZMakeAscii32(ptr, end-ptr, notice->z_auth) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- if (ZMakeAscii32(ptr, end-ptr, notice->z_authent_len) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- if (Z_AddField(&ptr, notice->z_ascii_authent, end))
- return (ZERR_HEADERLEN);
- if (Z_AddField(&ptr, notice->z_class, end))
- return (ZERR_HEADERLEN);
- if (Z_AddField(&ptr, notice->z_class_inst, end))
- return (ZERR_HEADERLEN);
- if (Z_AddField(&ptr, notice->z_opcode, end))
- return (ZERR_HEADERLEN);
- if (Z_AddField(&ptr, notice->z_sender, end))
- return (ZERR_HEADERLEN);
- if (strchr(notice->z_recipient, '@') || !*notice->z_recipient) {
- if (Z_AddField(&ptr, notice->z_recipient, end))
- return (ZERR_HEADERLEN);
- }
- else {
- if (strlen(notice->z_recipient) + strlen(__Zephyr_realm) + 2 >
- sizeof(newrecip))
- return (ZERR_HEADERLEN);
- (void) sprintf(newrecip, "%s@%s", notice->z_recipient, __Zephyr_realm);
- if (Z_AddField(&ptr, newrecip, end))
- return (ZERR_HEADERLEN);
- }
- if (Z_AddField(&ptr, notice->z_default_format, end))
- return (ZERR_HEADERLEN);
-
- /* copy back the end pointer location for crypto checksum */
- if (cstart)
- *cstart = ptr;
- if (cksumstyle == 1) {
- if (Z_AddField(&ptr, notice->z_ascii_checksum, end))
- return (ZERR_HEADERLEN);
- } else {
-#ifdef xZCODE_K4SUM
- if (ZMakeZcode32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
- return ZERR_HEADERLEN;
-#else
- if (ZMakeAscii32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
-#endif
- ptr += strlen(ptr)+1;
- }
- if (cend)
- *cend = ptr;
-
- if (Z_AddField(&ptr, notice->z_multinotice, end))
- return (ZERR_HEADERLEN);
-
- if (ZMakeAscii(ptr, end-ptr, (unsigned char *)¬ice->z_multiuid,
- sizeof(ZUnique_Id_t)) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
- ptr += strlen(ptr)+1;
-
- for (i=0;i<notice->z_num_other_fields;i++)
- if (Z_AddField(&ptr, notice->z_other_fields[i], end))
- return (ZERR_HEADERLEN);
-
- if (cksum_len)
- *cksum_len = ptr-*cksum_start;
-
- *hdr_len = ptr-buffer;
-
- return (ZERR_NONE);
-}
-
-Code_t
-Z_FormatRawHeader(ZNotice_t *notice,
- char *buffer,
- int buffer_len,
- int *len,
- char **cstart,
- char **cend)
+Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, cstart, cend)
+ ZNotice_t *notice;
+ char *buffer;
+ int buffer_len;
+ int *len;
+ char **cstart, **cend;
{
char newrecip[BUFSIZ];
char *ptr, *end;
if (cstart)
*cstart = ptr;
if (ZMakeAscii32(ptr, end-ptr, notice->z_checksum) == ZERR_FIELDLEN)
- return (ZERR_HEADERLEN);
+ return (ZERR_HEADERLEN);
ptr += strlen(ptr)+1;
if (cend)
*cend = ptr;
}
static int
-Z_AddField(char **ptr,
- char *field,
- char *end)
+Z_AddField(ptr, field, end)
+ char **ptr, *field, *end;
{
register int len;
return 0;
}
-struct _Z_InputQ *
-Z_GetFirstComplete(void)
+struct _Z_InputQ *Z_GetFirstComplete()
{
struct _Z_InputQ *qptr;
return ((struct _Z_InputQ *)0);
}
-struct _Z_InputQ *
-Z_GetNextComplete(struct _Z_InputQ *qptr)
+struct _Z_InputQ *Z_GetNextComplete(qptr)
+ struct _Z_InputQ *qptr;
{
qptr = qptr->next;
while (qptr) {
return ((struct _Z_InputQ *)0);
}
-void
-Z_RemQueue(struct _Z_InputQ *qptr)
+void Z_RemQueue(qptr)
+ struct _Z_InputQ *qptr;
{
struct _Z_Hole *hole, *nexthole;
return;
}
-Code_t
-Z_SendFragmentedNotice(ZNotice_t *notice,
- int len,
- Z_AuthProc cert_func,
- Z_SendProc send_func)
+Code_t Z_SendFragmentedNotice(notice, len, cert_func, send_func)
+ ZNotice_t *notice;
+ int len;
+ Z_AuthProc cert_func;
+ Z_SendProc send_func;
{
ZNotice_t partnotice;
ZPacket_t buffer;
}
/*ARGSUSED*/
-Code_t Z_XmitFragment(ZNotice_t *notice,
- char *buf,
- int len,
- int wait)
+Code_t Z_XmitFragment(notice, buf, len, wait)
+ZNotice_t *notice;
+char *buf;
+int len;
+int wait;
{
- return(ZSendPacket(buf, len, wait));
+ return(ZSendPacket(buf, len, wait));
}
#ifdef Z_DEBUG
#ifdef Z_DEBUG
#undef Z_debug
-void
-Z_debug(const char *format, ...)
+#ifdef HAVE_STDARG_H
+void Z_debug (const char *format, ...)
{
va_list pvar;
if (!__Z_debug_print)
(*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
va_end (pvar);
}
+#else /* stdarg */
+void Z_debug (va_alist) va_dcl
+{
+ va_list pvar;
+ char *format;
+ if (!__Z_debug_print)
+ return;
+ va_start (pvar);
+ format = va_arg (pvar, char *);
+ (*__Z_debug_print) (format, pvar, __Z_debug_print_closure);
+ va_end (pvar);
+}
+#endif
-void
-Z_debug_stderr(const char *format,
- va_list args,
- void *closure)
+void Z_debug_stderr (format, args, closure)
+ const char *format;
+ va_list args;
+ void *closure;
{
#ifdef HAVE_VPRINTF
vfprintf (stderr, format, args);
}
#undef ZGetFD
-int ZGetFD (void) { return __Zephyr_fd; }
+int ZGetFD () { return __Zephyr_fd; }
#undef ZQLength
-int ZQLength (void) { return __Q_CompleteLength; }
+int ZQLength () { return __Q_CompleteLength; }
#undef ZGetDestAddr
-struct sockaddr_in ZGetDestAddr (void) { return __HM_addr; }
+struct sockaddr_in ZGetDestAddr () { return __HM_addr; }
#undef ZGetRealm
-Zconst char * ZGetRealm (void) { return __Zephyr_realm; }
+Zconst char * ZGetRealm () { return __Zephyr_realm; }
#undef ZSetDebug
-void
-ZSetDebug(void (*proc) __P((const char *, va_list, void *)),
- char *arg)
+void ZSetDebug(proc, arg)
+ void (*proc) __P((const char *, va_list, void *));
+ char *arg;
{
__Z_debug_print = proc;
__Z_debug_print_closure = arg;
}
#endif /* Z_DEBUG */
-#ifdef HAVE_KRB5
-Code_t
-Z_Checksum(krb5_data *cksumbuf,
- krb5_keyblock *keyblock,
- krb5_cksumtype cksumtype,
- char **asn1_data,
- unsigned int *asn1_len)
-{
- krb5_error_code result;
- unsigned char *data;
- int len;
-#if HAVE_KRB5_C_MAKE_CHECKSUM
- krb5_checksum checksum;
-#else
- Checksum checksum;
- krb5_crypto cryptctx;
-#endif
-
-#if HAVE_KRB5_C_MAKE_CHECKSUM
- /* Create the checksum -- MIT crypto API */
- result = krb5_c_make_checksum(Z_krb5_ctx, cksumtype,
- keyblock, Z_KEYUSAGE_CLT_CKSUM,
- cksumbuf, &checksum);
- if (result)
- return result;
- /* HOLDING: checksum */
-
- data = checksum.contents;
- len = checksum.length;
-#else
- /* Create the checksum -- heimdal crypto API */
- result = krb5_crypto_init(Z_krb5_ctx, keyblock, keyblock->keytype,
- &cryptctx);
- if (result)
- return result;
-
- /* HOLDING: cryptctx */
- result = krb5_create_checksum(Z_krb5_ctx, cryptctx,
- Z_KEYUSAGE_CLT_CKSUM, cksumtype,
- cksumbuf->data, cksumbuf->length,
- &checksum);
- krb5_crypto_destroy(Z_krb5_ctx, cryptctx);
- if (result)
- return result;
-
- len = checksum.checksum.length;
- data = checksum.checksum.data;
- /* HOLDING: checksum */
-#endif
-
- *asn1_data = malloc(len);
- if (*asn1_data == NULL)
- return errno;
- memcpy(*asn1_data, data, len);
- *asn1_len = len;
-
-#if HAVE_KRB5_C_MAKE_CHECKSUM
- krb5_free_checksum_contents(Z_krb5_ctx, &checksum);
-#else
- free_Checksum(&checksum);
-#endif
-
- return 0;
-}
-
-Code_t
-Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
- ZNotice_t *notice,
- char *buffer,
- char *cksum_start,
- int cksum_len,
- char *cstart,
- char *cend,
- int buffer_len,
- int *length_adjust)
-{
- int plain_len; /* length of part not to be checksummed */
- int cksum0_len; /* length of part before checksum */
- int cksum1_len; /* length of part after checksum */
- krb5_data cksumbuf;
- krb5_data cksum;
- unsigned char *key_data;
- int key_len;
- krb5_enctype enctype;
- krb5_cksumtype cksumtype;
- Code_t result;
-
- key_data = Z_keydata(keyblock);
- key_len = Z_keylen(keyblock);
- result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
- if (result)
- return (ZAUTH_FAILED);
-
- /* Assemble the things to be checksummed */
- plain_len = cksum_start - buffer;
- cksum0_len = cstart - cksum_start;
- cksum1_len = (cksum_start + cksum_len) - cend;
- memset(&cksumbuf, 0, sizeof(cksumbuf));
- cksumbuf.length = cksum0_len + cksum1_len + notice->z_message_len;
- cksumbuf.data = malloc(cksumbuf.length);
- if (!cksumbuf.data)
- return ENOMEM;
- memcpy(cksumbuf.data, cksum_start, cksum0_len);
- memcpy(cksumbuf.data + cksum0_len, cend, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
- notice->z_message, notice->z_message_len);
- /* compute the checksum */
- result = Z_Checksum(&cksumbuf, keyblock, cksumtype,
- (char **)&cksum.data, &cksum.length);
- if (result) {
- free(cksumbuf.data);
- return result;
- }
-
- /*
- * OK.... we can zcode to a space starting at 'cstart',
- * with a length of buffer_len - (plain_len + cksum_len).
- * Then we tack on the end part, which is located at
- * cksumbuf.data + cksum0_len and has length cksum1_len
- */
-
- result = ZMakeZcode(cstart, buffer_len - (plain_len + cksum_len),
- (unsigned char *)cksum.data, cksum.length);
- free(cksum.data);
- if (!result) {
- int zcode_len = strlen(cstart) + 1;
- memcpy(cstart + zcode_len, cksumbuf.data + cksum0_len, cksum1_len);
- *length_adjust = zcode_len - cksum_len + (cksum0_len + cksum1_len);
- }
- free(cksumbuf.data);
- return result;
-}
-
-Code_t
-Z_ExtractEncCksum(krb5_keyblock *keyblock,
- krb5_enctype *enctype,
- krb5_cksumtype *cksumtype)
-{
- *enctype = Z_enctype(keyblock);
- return Z_krb5_lookup_cksumtype(*enctype, cksumtype);
-}
-#endif
-
-#ifdef HAVE_KRB5
-/* returns 0 if invalid or losing, 1 if valid, *sigh* */
-int
-Z_krb5_verify_cksum(krb5_keyblock *keyblock,
- krb5_data *cksumbuf,
- krb5_cksumtype cksumtype,
- unsigned char *asn1_data,
- int asn1_len)
-{
- krb5_error_code result;
-#if HAVE_KRB5_C_MAKE_CHECKSUM
- krb5_checksum checksum;
- krb5_boolean valid;
-#else
- krb5_crypto cryptctx;
- Checksum checksum;
- size_t xlen;
-#endif
-
- memset(&checksum, 0, sizeof(checksum));
-#if HAVE_KRB5_C_MAKE_CHECKSUM
- /* Verify the checksum -- MIT crypto API */
- checksum.length = asn1_len;
- checksum.contents = asn1_data;
- checksum.checksum_type = cksumtype;
- result = krb5_c_verify_checksum(Z_krb5_ctx,
- keyblock, Z_KEYUSAGE_SRV_CKSUM,
- cksumbuf, &checksum, &valid);
- if (!result && valid)
- return 1;
- else
- return 0;
-#else
- checksum.checksum.length = asn1_len;
- checksum.checksum.data = asn1_data;
- checksum.cksumtype = cksumtype;
-
- result = krb5_crypto_init(Z_krb5_ctx, keyblock, keyblock->keytype, &cryptctx);
- if (result)
- return result;
-
- /* HOLDING: cryptctx */
- result = krb5_verify_checksum(Z_krb5_ctx, cryptctx,
- Z_KEYUSAGE_SRV_CKSUM,
- cksumbuf->data, cksumbuf->length,
- &checksum);
- krb5_crypto_destroy(Z_krb5_ctx, cryptctx);
- if (result)
- return 0;
- else
- return 1;
-#endif
-}
-#endif
#include "dynP.h"
-int
-DynAppend(DynObject obj,
- DynPtr els,
- int num)
+int DynAppend(obj, els, num)
+ DynObject obj;
+ DynPtr els;
+ int num;
{
if (obj->debug)
fprintf(stderr, "dyn: append: Writing %d bytes from %p to %p + %d\n",
static int default_increment = DEFAULT_INC;
-DynObject
-DynCreate(int el_size,
- int inc)
+DynObject DynCreate(el_size, inc)
+ int el_size, inc;
{
DynObject obj;
return obj;
}
-int
-DynDestroy(DynObject obj)
+int DynDestroy(obj)
+ DynObject obj;
{
free(obj->array);
free(obj);
#include "dynP.h"
-int
-DynDebug(DynObject obj,
- int state)
+int DynDebug(obj, state)
+ DynObject obj;
+ int state;
{
obj->debug = state;
* Checkers! Get away from that "hard disk erase" button!
* (Stupid dog. He almost did it to me again ...)
*/
-int
-DynDelete(DynObject obj,
- int idx)
+int DynDelete(obj, idx)
+ DynObject obj;
+ int idx;
{
if (idx < 0) {
if (obj->debug)
#include "dynP.h"
-int
-DynInsert(DynObject obj,
- int idx,
- DynPtr els,
- int num)
-
+int DynInsert(obj, idx, els, num)
+ DynObject obj;
+ DynPtr els;
+ int idx, num;
{
int ret;
#include "dynP.h"
-int
-DynParanoid(DynObject obj, int state)
+int DynParanoid(obj, state)
+ DynObject obj;
+ int state;
{
obj->paranoid = state;
static int DynPut __P((DynObject obj, DynPtr el, int index));
-DynPtr
-DynGet(DynObject obj,
- int num)
+DynPtr DynGet(obj, num)
+ DynObject obj;
+ int num;
{
if (num < 0) {
if (obj->debug)
return (DynPtr) obj->array + obj->el_size*num;
}
-int
-DynAdd(DynObject obj,
- DynPtr el)
+int DynAdd(obj, el)
+ DynObject obj;
+ DynPtr el;
{
int ret;
* obj->num_el) will not be updated properly and many other functions
* in the library will lose. Have a nice day.
*/
-static int
-DynPut(DynObject obj,
- DynPtr el,
- int index)
+static int DynPut(obj, el, index)
+ DynObject obj;
+ DynPtr el;
+ int index;
{
int ret;
* Ideally, this function should not be called from outside the
* library. However, nothing will break if it is.
*/
-int
-_DynRealloc(DynObject obj,
- int num_incs)
+int _DynRealloc(obj, num_incs)
+ DynObject obj;
+ int num_incs;
{
DynPtr temp;
int new_size_in_bytes;
#include "dynP.h"
-int
-DynSize(DynObject obj)
+int DynSize(obj)
+ DynObject obj;
{
if (obj->debug)
fprintf(stderr, "dyn: size: returning size %d.\n", obj->num_el);
static char insert2[] = "(parenthetical remark!) ";
static char insert3[] = " This follows the random string.";
-int
-main(int argc,
- char **argv)
+int main(argc, argv)
+ int argc;
+ char **argv;
{
DynObject obj;
int i, s;
*/
int
-access_check(char *sender,
- Acl *acl,
- Access accesstype)
+access_check(sender, acl, accesstype)
+ char *sender;
+ Acl *acl;
+ Access accesstype;
{
char buf[MAXPATHLEN]; /* holds the real acl name */
char *prefix;
* If we can't load it (because it probably doesn't exist),
* we deny access.
*/
+#if 0
+ zdbug ((LOG_DEBUG, "checking %s for %s", buf, sender));
+#endif
+
retval = acl_load(buf);
if (retval < 0) {
syslog(LOG_DEBUG, "Error in acl_load of %s for %s", buf, sender);
}
static void
-check_acl(Acl *acl)
+check_acl(acl)
+ Acl *acl;
{
acl->acl_types = 0;
check_acl_type(acl, TRANSMIT, ACL_XMT);
}
static void
-check_acl_type(Acl *acl,
- Access accesstype,
- int typeflag)
+check_acl_type(acl, accesstype, typeflag)
+ Acl *acl;
+ Access accesstype;
+ int typeflag;
{
char buf[MAXPATHLEN]; /* holds the real acl name */
char *prefix;
* acl files for the (non-)restricted class.
*/
static void
-access_setup(int first)
+access_setup(first)
+ int first;
{
char buf[MAXPATHLEN];
char class_name[512]; /* assume class names <= 511 bytes */
}
void
-access_init(void)
+access_init()
{
access_setup(1);
}
void
-access_reinit(void)
+access_reinit()
{
acl_cache_reset();
access_setup(0);
*/
/* Define this if you really want the ACL-writing code included. */
+/* #define WRITE_ACL */
/*
* Stolen from lib/acl_files.c because acl_load needs to be externally
#define COR(a,b) ((a!=NULL)?(a):(b))
+extern int errno;
+
+extern time_t time();
+
/* Canonicalize a principal name */
/* If instance is missing, it becomes "" */
/* If realm is missing, it becomes the local realm */
/* Canonicalized form is put in canon, which must be big enough to hold
MAX_PRINCIPAL_SIZE characters */
-void acl_canonicalize_principal(char *principal,
- char *canon)
+void acl_canonicalize_principal(principal, canon)
+ char *principal;
+ char *canon;
{
char *end;
char *dot, *atsign;
#endif
}
+#ifdef notdef
+/* Get a lock to modify acl_file */
+/* Return new FILE pointer */
+/* or NULL if file cannot be modified */
+/* REQUIRES WRITE PERMISSION TO CONTAINING DIRECTORY */
+static FILE *acl_lock_file(acl_file)
+ char *acl_file;
+{
+ struct stat s;
+ char new[LINESIZE];
+ int nfd;
+ FILE *nf;
+ int mode;
+
+ if (stat(acl_file, &s) < 0) return(NULL);
+ mode = s.st_mode;
+ sprintf(new, NEW_FILE, acl_file);
+ for (;;) {
+ /* Open the new file */
+ if ((nfd = open(new, O_WRONLY|O_CREAT|O_EXCL, mode)) < 0) {
+ if (errno == EEXIST) {
+ /* Maybe somebody got here already, maybe it's just old */
+ if (stat(new, &s) < 0) return(NULL);
+ if (time(0) - s.st_ctime > WAIT_TIME) {
+ /* File is stale, kill it */
+ unlink(new);
+ continue;
+ } else {
+ /* Wait and try again */
+ sleep(1);
+ continue;
+ }
+ } else {
+ /* Some other error, we lose */
+ return(NULL);
+ }
+ }
+
+ /* If we got to here, the lock file is ours and ok */
+ /* Reopen it under stdio */
+ if ((nf = fdopen(nfd, "w")) == NULL) {
+ /* Oops, clean up */
+ unlink(new);
+ }
+ return(nf);
+ }
+}
+
+/* Commit changes to acl_file written onto FILE *f */
+/* Returns zero if successful */
+/* Returns > 0 if lock was broken */
+/* Returns < 0 if some other error occurs */
+/* Closes f */
+static int acl_commit(acl_file, f)
+ char *acl_file;
+ FILE *f;
+{
+#ifdef WRITE_ACL
+ char new[LINESIZE];
+ int ret;
+ struct stat s;
+
+ sprintf(new, NEW_FILE, acl_file);
+ if (fflush(f) < 0
+ || fstat(fileno(f), &s) < 0
+ || s.st_nlink == 0) {
+ acl_abort(acl_file, f);
+ return(-1);
+ }
+
+ ret = rename(new, acl_file);
+ fclose(f);
+ return(ret);
+#else
+ abort ();
+#endif
+}
+
+/* Abort changes to acl_file written onto FILE *f */
+/* Returns 0 if successful, < 0 otherwise */
+/* Closes f */
+static int acl_abort(acl_file, f)
+ char *acl_file;
+ FILE *f;
+{
+#ifdef WRITE_ACL
+ char new[LINESIZE];
+ int ret;
+ struct stat s;
+
+ /* make sure we aren't nuking someone else's file */
+ if (fstat(fileno(f), &s) < 0 || s.st_nlink == 0) {
+ fclose(f);
+ return(-1);
+ } else {
+ sprintf(new, NEW_FILE, acl_file);
+ ret = unlink(new);
+ fclose(f);
+ return(ret);
+ }
+#else
+ abort ();
+#endif
+}
+
+/* Initialize an acl_file */
+/* Creates the file with permissions perm if it does not exist */
+/* Erases it if it does */
+/* Returns return value of acl_commit */
+int
+acl_initialize(acl_file, perm)
+ char *acl_file;
+ int perm;
+{
+ FILE *new;
+ int fd;
+
+ /* Check if the file exists already */
+ if ((new = acl_lock_file(acl_file)) != NULL) {
+ return(acl_commit(acl_file, new));
+ } else {
+ /* File must be readable and writable by owner */
+ if ((fd = open(acl_file, O_CREAT|O_EXCL, perm|0600)) < 0) {
+ return(-1);
+ } else {
+ close(fd);
+ return(0);
+ }
+ }
+}
+
+#endif /* notdef */
+
/* Eliminate all whitespace character in buf */
/* Modifies its argument */
-static void
-nuke_whitespace(char *buf)
+static void nuke_whitespace(buf)
+ char *buf;
{
char *pin, *pout;
};
/* Make an empty hash table of size s */
-static struct hashtbl *
-make_hash(int size)
+static struct hashtbl *make_hash(size)
+ int size;
{
struct hashtbl *h;
/* Destroy a hash table */
static void
-destroy_hash(struct hashtbl *h)
+destroy_hash(h)
+ struct hashtbl *h;
{
int i;
/* Compute hash value for a string */
static unsigned int
-hashval(char *s)
+hashval(s)
+ char *s;
{
unsigned hv;
}
/* Add an element to a hash table */
-static void
-add_hash(struct hashtbl *h,
- char *el)
+static void add_hash(h, el)
+ struct hashtbl *h;
+ char *el;
{
unsigned hv;
char *s;
char **old;
int i;
+#if 0
+ fprintf (stderr, "adding %s to acl hash %08X\n", el, h);
+#endif
/* Make space if it isn't there already */
if (h->entries + 1 > (h->size >> 1)) {
old = h->tbl;
/* Returns nonzero if el is in h */
static int
-check_hash(struct hashtbl *h,
- char *el)
+check_hash(h, el)
+ struct hashtbl *h;
+ char *el;
{
unsigned hv;
+#if 0
+ fprintf (stderr, "looking for %s in acl %08X\n", el, h);
+#endif
for (hv = hashval(el) % h->size; h->tbl[hv]; hv = (hv + 1) % h->size) {
+#if 0
+ fprintf (stderr, "\tstrcmp (%s,...)\n", h->tbl[hv]);
+#endif
if (!strcmp(h->tbl[hv], el)) {
+#if 0
+ fprintf (stderr, "success!\n");
+#endif
return 1;
}
}
+#if 0
+ fprintf (stderr, "failure\n");
+#endif
return 0;
}
/* Returns < 0 if unsuccessful in loading acl */
/* Returns index into acl_cache otherwise */
/* Note that if acl is already loaded, this is just a lookup */
-int acl_load(char *name)
+int acl_load(name)
+ char *name;
{
int i;
FILE *f;
*/
if (acl_cache[i].acl == (struct hashtbl *) 0) {
/* Gotta reload */
+#if 0
+ fprintf (stderr, "attempting to load %s\n", name);
+#endif
if ((f = fopen(name, "r")) == NULL) {
- syslog(LOG_ERR, "Error loading acl file %s: %m", name);
+#if 0
+ perror (name);
+#endif
return -1;
}
if (acl_cache[i].acl) destroy_hash(acl_cache[i].acl);
* the next time they are requested.
*/
void
-acl_cache_reset(void)
+acl_cache_reset()
{
int i;
/* Returns nonzero if it can be determined that acl contains principal */
/* Principal is not canonicalized, and no wildcarding is done */
-int
-acl_exact_match(char *acl,
- char *principal)
+acl_exact_match(acl, principal)
+ char *acl;
+ char *principal;
{
int idx;
+#if 0
+ fprintf (stderr, "checking for %s in %s\n", principal, acl);
+#endif
return((idx = acl_load(acl)) >= 0
&& check_hash(acl_cache[idx].acl, principal));
}
/* Returns nonzero if it can be determined that acl contains principal */
/* Recognizes wildcards in acl. */
int
-acl_check(char *acl,
- char *principal)
+acl_check(acl, principal)
+ char *acl;
+ char *principal;
{
char buf[MAX_PRINCIPAL_SIZE];
char canon[MAX_PRINCIPAL_SIZE];
return(0);
}
+
+#ifdef notdef
+/* Adds principal to acl */
+/* Wildcards are interpreted literally */
+int
+acl_add(acl, principal)
+ char *acl;
+ char *principal;
+{
+ int idx;
+ int i;
+ FILE *new;
+ char canon[MAX_PRINCIPAL_SIZE];
+
+ acl_canonicalize_principal(principal, canon);
+
+ if ((new = acl_lock_file(acl)) == NULL) return(-1);
+ if ((acl_exact_match(acl, canon))
+ || (idx = acl_load(acl)) < 0) {
+ acl_abort(acl, new);
+ return(-1);
+ }
+ /* It isn't there yet, copy the file and put it in */
+ for (i = 0; i < acl_cache[idx].acl->size; i++) {
+ if (acl_cache[idx].acl->tbl[i] != NULL) {
+ if (fputs(acl_cache[idx].acl->tbl[i], new) == NULL
+ || putc('\n', new) != '\n') {
+ acl_abort(acl, new);
+ return(-1);
+ }
+ }
+ }
+ fputs(canon, new);
+ putc('\n', new);
+ return(acl_commit(acl, new));
+}
+
+/* Removes principal from acl */
+/* Wildcards are interpreted literally */
+int
+acl_delete(acl, principal)
+ char *acl;
+ char *principal;
+{
+ int idx;
+ int i;
+ FILE *new;
+ char canon[MAX_PRINCIPAL_SIZE];
+
+ acl_canonicalize_principal(principal, canon);
+
+ if ((new = acl_lock_file(acl)) == NULL) return(-1);
+ if ((!acl_exact_match(acl, canon))
+ || (idx = acl_load(acl)) < 0) {
+ acl_abort(acl, new);
+ return(-1);
+ }
+ /* It isn't there yet, copy the file and put it in */
+ for (i = 0; i < acl_cache[idx].acl->size; i++) {
+ if (acl_cache[idx].acl->tbl[i] != NULL
+ && strcmp(acl_cache[idx].acl->tbl[i], canon)) {
+ fputs(acl_cache[idx].acl->tbl[i], new);
+ putc('\n', new);
+ }
+ }
+ return(acl_commit(acl, new));
+}
+#endif /* notdef */
* int num;
*/
-#if defined(HAVE_KRB5) && 0
-int krb5_init_keyblock(krb5_context context,
- krb5_enctype type,
- size_t size,
- krb5_keyblock **akey)
-{
-krb5_error_code ret;
-size_t len;
-krb5_keyblock *key;
-
-*akey=NULL;
-key=malloc(sizeof(*key));
-memset(key, 0, sizeof(*key));
-ret = krb5_enctype_keysize(context, type, &len);
-if (ret)
-return ret;
-
-if (len != size) {
-krb5_set_error_string(context, "Encryption key %d is %lu bytes "
-"long, %lu was passed in",
-type, (unsigned long)len, (unsigned long)size);
-return KRB5_PROG_ETYPE_NOSUPP;
-}
-
-ret = krb5_data_alloc(&key->keyvalue, len);
-if(ret) {
-krb5_set_error_string(context, "malloc failed: %lu",
-(unsigned long)len);
-return ret;
-}
-key->keytype = type;
-*akey=key;
-return 0;
-}
-#endif
-
-
-static void close_bdump(void* arg);
-static Code_t bdump_send_loop(Server *server);
-static Code_t bdump_recv_loop(Server *server);
-static void bdump_get_v12(ZNotice_t *, int, struct sockaddr_in *,
- Server *);
-static Code_t get_packet(void *packet, int len, int *retlen);
-static Code_t extract_sin(ZNotice_t *notice, struct sockaddr_in *target);
-static Code_t send_done(void);
-static Code_t send_list(ZNotice_Kind_t kind, int port, char *class_name,
+static void close_bdump __P((void* arg));
+static Code_t bdump_send_loop __P((Server *server)),
+bdump_ask_for __P((char *inst)),
+bdump_recv_loop __P((Server *server));
+static void bdump_get_v12 __P((ZNotice_t *, int, struct sockaddr_in *,
+ Server *));
+static Code_t get_packet __P((void *packet, int len, int *retlen));
+static Code_t extract_sin __P((ZNotice_t *notice, struct sockaddr_in *target));
+static Code_t send_done __P((void));
+static Code_t send_list __P((ZNotice_Kind_t kind, int port, char *class_name,
char *inst, char *opcode, char *sender,
- char *recip, char **lyst, int num);
-static Code_t send_normal_tcp(ZNotice_Kind_t kind, int port,
+ char *recip, char **lyst, int num));
+static Code_t send_normal_tcp __P((ZNotice_Kind_t kind, int port,
char *class_name,
char *inst, char *opcode, char *sender,
- char *recip, char *message, int len);
-static int net_read(FILE *f, char *buf, int len);
-static int net_write(FILE *f, char *buf, int len);
-static int setup_file_pointers(void);
-static void shutdown_file_pointers(void);
-static void cleanup(Server *server);
-
-#ifdef HAVE_KRB5
-static long ticket5_time;
-#define TKT5LIFETIME 8*60*60
-#define tkt5_lifetime(val) (val)
-#endif
+ char *recip, char *message, int len));
+static int net_read __P((FILE *f, char *buf, int len));
+static int net_write __P((FILE *f, char *buf, int len));
+static int setup_file_pointers __P((void));
+static void shutdown_file_pointers __P((void));
+static void cleanup __P((Server *server));
#ifdef HAVE_KRB4
static long ticket_time;
#define TKTLIFETIME 120
#define tkt_lifetime(val) ((long) val * 5L * 60L)
+#ifndef NOENCRYPTION
extern C_Block serv_key;
extern Sched serv_ksched;
+#endif
#endif /* HAVE_KRB4 */
static Timer *bdump_timer;
static int live_socket = -1;
static FILE *input, *output;
static struct sockaddr_in bdump_sin;
-#ifdef HAVE_KRB5
-static krb5_auth_context bdump_ac;
+#ifdef notdef
+static int cancel_outgoing_dump;
#endif
int bdumping;
int bdump_concurrent;
extern char *bdump_version;
-extern int bdump_auth_proto;
/*
* Functions for performing a brain dump between servers.
*/
void
-bdump_offer(struct sockaddr_in *who)
+bdump_offer(who)
+ struct sockaddr_in *who;
{
Code_t retval;
char buf[512], *addr, *lyst[2];
#ifndef HAVE_KRB4
int bdump_port = IPPORT_RESERVED - 1;
#endif /* !HAVE_KRB4 */
-
+#if 1
zdbug((LOG_DEBUG, "bdump_offer"));
-
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
+#endif
+#ifdef HAVE_KRB4
/*
- * when using kerberos server-server authentication, we can
+ * when using HAVE_KRB4 server-server authentication, we can
* use any random local address
*/
bdump_socket = socket(AF_INET, SOCK_STREAM, 0);
return;
}
if (!bdump_sin.sin_port) {
- unsigned int len = sizeof(bdump_sin);
+ int len = sizeof(bdump_sin);
if (getsockname(bdump_socket,
(struct sockaddr *) &bdump_sin, &len) < 0) {
send_list(ACKED, srv_addr.sin_port, ZEPHYR_ADMIN_CLASS, bdump_version,
ADMIN_BDUMP, myname, "", lyst, 2);
+#if 1
zdbug((LOG_DEBUG,"bdump_offer: address is %s/%d\n",
inet_ntoa(bdump_sin.sin_addr),
ntohs(bdump_sin.sin_port)));
+#endif
return;
}
*/
void
-bdump_send(void)
+bdump_send()
{
struct sockaddr_in from;
Server *server;
Code_t retval;
- unsigned int fromlen = sizeof(from);
+ int fromlen = sizeof(from);
int on = 1;
#ifdef _POSIX_VERSION
struct sigaction action;
#endif
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
- char *data = NULL;
- int len = 0;
- int proto = 0;
-#endif
+
#ifdef HAVE_KRB4
KTEXT_ST ticket;
AUTH_DAT kdata;
- /* may be moved into kstuff.c */
- char instance [INST_SZ];
-#endif
-#ifdef HAVE_KRB5
- /* may be moved into kstuff.c */
- krb5_principal principal;
- krb5_data k5data;
- krb5_keytab kt;
-#endif
-#if !defined(HAVE_KRB4) && !defined(HAVE_KRB5)
+#else
unsigned short fromport;
#endif /* HAVE_KRB4 */
+#if 1
zdbug((LOG_DEBUG, "bdump_send"));
-
+#endif
/* accept the connection, and send the brain dump */
live_socket = accept(bdump_socket, (struct sockaddr *) &from, &fromlen);
if (live_socket < 0) {
syslog(LOG_ERR, "bdump_send: unknown server?");
server = limbo_server;
}
-
+#if 1
zdbug((LOG_DEBUG, "bdump_send: connection from %s/%d",
inet_ntoa(from.sin_addr), ntohs(from.sin_port)));
+#endif
bdumping = 1;
server->dumping = 1;
bdump_socket = -1;
timer_reset(bdump_timer);
}
-
+
/* Now begin the brain dump. */
-#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
- retval = ReadKerberosData(live_socket, &len, &data, &proto);
-
- if (retval != 0) {
- syslog(LOG_ERR, "bdump_send: ReadKerberosData: %s",
+
+#ifdef HAVE_KRB4
+ /* receive the authenticator */
+ retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
+ SERVER_SERVICE, srvtab_file);
+ if (retval != KSUCCESS) {
+ syslog(LOG_ERR, "bdump_send: getkdata: %s",
krb_get_err_text(retval));
cleanup(server);
return;
}
-
- syslog(LOG_INFO, "bdump_send: got %d bytes of authenticator for protocol %d", len, proto);
-
if (get_tgt()) {
- syslog(LOG_ERR, "bdump_send: get_tgt failed");
cleanup(server);
return;
}
-
- switch(proto) {
-#ifdef HAVE_KRB5
- case 5:
- /* "server" side */
- retval = krb5_build_principal(Z_krb5_ctx, &principal,
- strlen(ZGetRealm()),
- ZGetRealm(),
- SERVER_KRB5_SERVICE, SERVER_INSTANCE,
- 0);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: krb5_build_principal: %s", error_message(retval));
- cleanup(server);
- return;
- }
-
-
- retval = krb5_auth_con_init(Z_krb5_ctx, &bdump_ac);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: krb5_auth_con_init: %s", error_message(retval));
- cleanup(server);
- return;
- }
-
- retval = krb5_auth_con_setflags(Z_krb5_ctx, bdump_ac, KRB5_AUTH_CONTEXT_DO_SEQUENCE);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: krb5_auth_con_setflags: %s", error_message(retval));
- cleanup(server);
- return;
- }
-
- retval = krb5_auth_con_genaddrs(Z_krb5_ctx, bdump_ac, live_socket,
- KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR|KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: krb5_auth_con_genaddrs: %s", error_message(retval));
- cleanup(server);
- return;
- }
-
- /* Get the "client" krb_ap_req */
-
- memset((char *)&k5data, 0, sizeof(krb5_data));
- k5data.length = len;
- k5data.data = data;
- if (retval) {
- syslog(LOG_ERR, "bdump_send: cannot get auth response: %s",
- error_message(retval));
- cleanup(server);
- return;
- }
-
- /* resolve keytab */
- retval = krb5_kt_resolve(Z_krb5_ctx, keytab_file, &kt);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: cannot resolve keytab: %s",
- error_message(retval));
- krb5_kt_close(Z_krb5_ctx, kt);
- cleanup(server);
- return;
- }
-
- retval = krb5_rd_req(Z_krb5_ctx, &bdump_ac, &k5data, principal, kt, NULL, NULL);
- krb5_free_principal(Z_krb5_ctx, principal);
- krb5_kt_close(Z_krb5_ctx, kt);
- free(k5data.data);
- memset((char *)&k5data, 0, sizeof(krb5_data));
- if (retval) {
- syslog(LOG_ERR, "bdump_send: mutual authentication failed: %s",
- error_message(retval));
- cleanup(server);
- return;
- }
-
- /* Now send back our auth packet */
-
- retval = krb5_mk_rep(Z_krb5_ctx, bdump_ac, &k5data);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: krb5_mk_rep: %s", error_message(retval));
- cleanup(server);
- return;
- }
- retval = SendKrb5Data(live_socket, &k5data);
- if (retval) {
- syslog(LOG_ERR, "bdump_send: cannot send authenticator: %s",
- error_message(retval));
- krb5_free_data_contents(Z_krb5_ctx, &k5data);
- cleanup(server);
- return;
- }
- krb5_free_data_contents(Z_krb5_ctx, &k5data);
- break;
-#endif /* HAVE_KRB5 */
-#ifdef HAVE_KRB4
- case 4:
- /* here to krb_rd_req from GetKerberosData candidate for refactoring
- back into kstuff.c */
- (void) strcpy(instance, "*"); /* let Kerberos fill it in */
-
- ticket.length = len;
- memcpy(&ticket.dat, data, MIN(len, sizeof(ticket.dat)));
- retval = krb_rd_req(&ticket, SERVER_SERVICE, instance,
- from.sin_addr.s_addr, &kdata, srvtab_file);
- /*
- retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
- SERVER_SERVICE, srvtab_file);
- */
- if (retval != KSUCCESS) {
- syslog(LOG_ERR, "bdump_send: getkdata: %s",
- krb_get_err_text(retval));
- cleanup(server);
- return;
- }
- if (strcmp(kdata.pname, SERVER_SERVICE) ||
- strcmp(kdata.pinst, SERVER_INSTANCE) ||
- strcmp(kdata.prealm, ZGetRealm())) {
- syslog(LOG_ERR, "bdump_send: peer not zephyr: %s.%s@%s",
- kdata.pname, kdata.pinst, kdata.prealm);
- cleanup(server);
- return;
- }
- /* authenticate back */
- retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
- SERVER_INSTANCE);
- if (retval != 0) {
- syslog(LOG_ERR,"bdump_send: SendKerberosData: %s",
- error_message (retval));
- cleanup(server);
- return;
- }
- break;
-#endif /* HAVE_KRB4 */
+ if (strcmp(kdata.pname, SERVER_SERVICE) ||
+ strcmp(kdata.pinst, SERVER_INSTANCE) ||
+ strcmp(kdata.prealm, ZGetRealm())) {
+ syslog(LOG_ERR, "bdump_send: peer not zephyr: %s.%s@%s",
+ kdata.pname, kdata.pinst, kdata.prealm);
+ cleanup(server);
+ return;
+ }
+ /* authenticate back */
+ retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
+ SERVER_INSTANCE);
+ if (retval != 0) {
+ syslog(LOG_ERR,"bdump_send: SendKerberosData: %s",
+ error_message (retval));
+ cleanup(server);
+ return;
}
-#else /* HAVE_KRB4 || HAVE_KRB5 */
+#else /* !HAVE_KRB4 */
if (fromport > IPPORT_RESERVED || fromport < IPPORT_RESERVED / 2) {
syslog(LOG_ERR, "bdump_send: bad port from peer: %d", fromport);
cleanup(server);
return;
}
-#endif /* HAVE_KRB4 || HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
+
retval = setup_file_pointers();
if (retval != 0) {
syslog (LOG_WARNING, "bdump_send: can't set up file pointers: %s",
cleanup(server);
return;
}
-
+#if 1
zdbug((LOG_DEBUG, "bdump_send: finished"));
-
+#endif
if (server != limbo_server) {
/* set this guy to be up, and schedule a hello */
server->state = SERV_UP;
timer_reset(server->timer);
server->timer = timer_set_rel(0L, server_timo, server);
}
-
+#if 0
+ zdbug((LOG_DEBUG,"cleanup sbd"));
+#endif
shutdown_file_pointers();
#ifdef _POSIX_VERSION
/*ARGSUSED*/
static void
-bdump_get_v12 (ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+bdump_get_v12 (notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
struct sockaddr_in from;
Code_t retval;
#ifdef _POSIX_VERSION
struct sigaction action;
#endif
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
-#ifdef HAVE_KRB5
- krb5_creds creds;
- krb5_creds *credsp;
- krb5_principal principal;
- krb5_data data;
- krb5_ap_rep_enc_part *rep;
-#endif
#ifdef HAVE_KRB4
KTEXT_ST ticket;
AUTH_DAT kdata;
-#endif
-#else /* !HAVE_KRB4 && !HAVE_KRB5 */
+#else /* !HAVE_KRB4 */
int reserved_port = IPPORT_RESERVED - 1;
-#endif /* !HAVE_KRB4 && !HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
bdumping = 1;
server->dumping = 1;
server->dumping = 0;
return;
}
-#if !defined(HAVE_KRB4) && !defined(HAVE_KRB5)
+#ifndef HAVE_KRB4
if (ntohs(from.sin_port) > IPPORT_RESERVED ||
ntohs(from.sin_port) < IPPORT_RESERVED / 2) {
syslog(LOG_ERR, "bdump_get: port not reserved: %d",
return;
}
live_socket = rresvport(&reserved_port);
-#else /* !HAVE_KRB4 && !HAVE_KRB5 */
+#else /* !HAVE_KRB4 */
live_socket = socket(AF_INET, SOCK_STREAM, 0);
-#endif /* !HAVE_KRB4 && !HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
if (live_socket < 0) {
syslog(LOG_ERR, "bdump_get: socket: %m");
cleanup(server);
if (setsockopt(live_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&on,
sizeof(on)) < 0)
syslog(LOG_WARNING, "bdump_get: setsockopt (SO_KEEPALIVE): %m");
-
+#if 1
zdbug((LOG_DEBUG, "bdump_get: connected"));
+#endif
/* Now begin the brain dump. */
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
+
+#ifdef HAVE_KRB4
+ /* send an authenticator */
if (get_tgt()) {
- syslog(LOG_ERR, "bdump_get: get_tgt failed");
cleanup(server);
return;
}
- switch(bdump_auth_proto) {
-#ifdef HAVE_KRB5
- case 5: /* "client" side */
- memset((char *)&creds, 0, sizeof(creds));
-
- retval = krb5_build_principal(Z_krb5_ctx, &principal,
- strlen(ZGetRealm()),
- ZGetRealm(),
- SERVER_KRB5_SERVICE, SERVER_INSTANCE,
- 0);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_build_principal: %s", error_message(retval));
- cleanup(server);
- return;
- }
-
- retval = krb5_copy_principal(Z_krb5_ctx, principal, &creds.server);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_copy_principal (server): %s", error_message(retval));
- krb5_free_principal(Z_krb5_ctx, principal);
- cleanup(server);
- return;
- }
-
- retval = krb5_copy_principal(Z_krb5_ctx, principal, &creds.client);
- krb5_free_principal(Z_krb5_ctx, principal);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_copy_principal (client): %s", error_message(retval));
- krb5_free_cred_contents(Z_krb5_ctx, &creds);
- cleanup(server);
- return;
- }
-
- retval = krb5_get_credentials(Z_krb5_ctx, 0, Z_krb5_ccache,
- &creds, &credsp);
- krb5_free_cred_contents(Z_krb5_ctx, &creds);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_get_credentials: %s", error_message(retval));
- cleanup(server);
- return;
- }
-
- retval = krb5_auth_con_init(Z_krb5_ctx, &bdump_ac);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_auth_con_init: %s", error_message(retval));
- krb5_free_creds(Z_krb5_ctx, credsp);
- cleanup(server);
- return;
- }
-
- retval = krb5_auth_con_setflags(Z_krb5_ctx, bdump_ac, KRB5_AUTH_CONTEXT_DO_SEQUENCE);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_auth_con_setflags: %s", error_message(retval));
- krb5_free_creds(Z_krb5_ctx, credsp);
- cleanup(server);
- return;
- }
-
- retval = krb5_auth_con_genaddrs(Z_krb5_ctx, bdump_ac, live_socket,
- KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR|KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_auth_con_genaddrs: %s", error_message(retval));
- krb5_free_creds(Z_krb5_ctx, credsp);
- cleanup(server);
- return;
- }
-
- memset((char *)&data, 0, sizeof(krb5_data));
- retval = krb5_mk_req_extended(Z_krb5_ctx, &bdump_ac, AP_OPTS_MUTUAL_REQUIRED|AP_OPTS_USE_SUBKEY,
- NULL, credsp, &data);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: krb5_mk_req_ext: %s", error_message(retval));
- krb5_free_creds(Z_krb5_ctx, credsp);
- cleanup(server);
- return;
- }
- retval = SendKrb5Data(live_socket, &data);
- krb5_free_creds(Z_krb5_ctx, credsp);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: cannot send authenticator: %s",
- error_message(retval));
- krb5_free_data_contents(Z_krb5_ctx, &data);
- cleanup(server);
- return;
- }
- krb5_free_data_contents(Z_krb5_ctx, &data);
- memset((char *)&data, 0, sizeof(krb5_data));
- retval = GetKrb5Data(live_socket, &data);
- if (retval) {
- syslog(LOG_ERR, "bdump_get: cannot get auth response: %s",
- error_message(retval));
- cleanup(server);
- return;
- }
- retval = krb5_rd_rep(Z_krb5_ctx, bdump_ac, &data, &rep);
- free(data.data);
- memset((char *)&data, 0, sizeof(krb5_data));
- if (retval) {
- syslog(LOG_ERR, "bdump_get: mutual authentication failed: %s",
- error_message(retval));
- cleanup(server);
- return;
- }
- break;
+ retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
+ SERVER_INSTANCE);
+ if (retval != 0) {
+ syslog(LOG_ERR,"bdump_get: %s", error_message(retval));
+ cleanup(server);
+ return;
+ }
+#if 1
+ zdbug((LOG_DEBUG, "bdump_get: SendKerberosData ok"));
#endif
-#ifdef HAVE_KRB4
- case 4:
- /* send an authenticator */
- retval = SendKerberosData(live_socket, &ticket, SERVER_SERVICE,
- SERVER_INSTANCE);
- if (retval != 0) {
- syslog(LOG_ERR,"bdump_get: %s", error_message(retval));
- cleanup(server);
- return;
- }
- zdbug((LOG_DEBUG, "bdump_get: SendKerberosData ok"));
-
- /* get his authenticator */
- retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
- SERVER_SERVICE, srvtab_file);
- if (retval != KSUCCESS) {
- syslog(LOG_ERR, "bdump_get getkdata: %s",krb_get_err_text(retval));
- cleanup(server);
- return;
- }
+
+ /* get his authenticator */
+ retval = GetKerberosData(live_socket, from.sin_addr, &kdata,
+ SERVER_SERVICE, srvtab_file);
+ if (retval != KSUCCESS) {
+ syslog(LOG_ERR, "bdump_get getkdata: %s",krb_get_err_text(retval));
+ cleanup(server);
+ return;
+ }
- if (strcmp(kdata.pname, SERVER_SERVICE) ||
- strcmp(kdata.pinst, SERVER_INSTANCE) ||
- strcmp(kdata.prealm, ZGetRealm())) {
- syslog(LOG_ERR, "bdump_get: peer not zephyr in lrealm: %s.%s@%s",
- kdata.pname, kdata.pinst,kdata.prealm);
- cleanup(server);
- return;
- }
- break;
-#endif /* HAVE_KRB4 */
+ if (strcmp(kdata.pname, SERVER_SERVICE) ||
+ strcmp(kdata.pinst, SERVER_INSTANCE) ||
+ strcmp(kdata.prealm, ZGetRealm())) {
+ syslog(LOG_ERR, "bdump_get: peer not zephyr in lrealm: %s.%s@%s",
+ kdata.pname, kdata.pinst,kdata.prealm);
+ cleanup(server);
+ return;
}
-#endif /* defined(HAVE_KRB4) || defined(HAVE_KRB5) */
+#endif /* HAVE_KRB4 */
retval = setup_file_pointers();
if (retval != 0) {
syslog(LOG_WARNING, "bdump_get: can't set up file pointers: %s",
cleanup(server);
return;
}
+#if 1
zdbug((LOG_DEBUG,"bdump_get: gbdl ok"));
+#endif
retval = bdump_send_loop(server);
if (retval != ZERR_NONE) {
syslog(LOG_WARNING, "bdump_send_loop failed: %s",
cleanup(server);
return;
}
-
+#if 1
zdbug((LOG_DEBUG, "bdump_get: gbd finished"));
-
+#endif
/* set this guy to be up, and schedule a hello */
server->state = SERV_UP;
timer_reset(server->timer);
server->timer = timer_set_rel(0L, server_timo, server);
-
+#if 1
zdbug((LOG_DEBUG,"cleanup gbd"));
-
+#endif
shutdown_file_pointers();
#ifdef _POSIX_VERSION
action.sa_handler = SIG_DFL;
}
void
-bdump_get(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+bdump_get(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
- void (*proc)(ZNotice_t *, int, struct sockaddr_in *, Server *);
+ void (*proc) __P((ZNotice_t *, int, struct sockaddr_in *, Server *));
proc = NULL;
+#if 1
if (zdebug) {
syslog(LOG_DEBUG, "bdump_get: bdump v%s avail %s",
notice->z_class_inst, inet_ntoa(who->sin_addr));
}
-
+#endif
if (strcmp (notice->z_class_inst, "1.2") == 0)
proc = bdump_get_v12;
*/
Code_t
-bdump_send_list_tcp(ZNotice_Kind_t kind,
- struct sockaddr_in *addr,
- char *class_name,
- char *inst,
- char *opcode,
- char *sender,
- char *recip,
- char **lyst,
- int num)
+bdump_send_list_tcp(kind, addr, class_name, inst, opcode, sender, recip, lyst,
+ num)
+ ZNotice_Kind_t kind;
+ struct sockaddr_in *addr;
+ int num;
+ char *class_name, *inst, *opcode, *sender, *recip, **lyst;
{
ZNotice_t notice;
char *pack, addrbuf[100];
retval = ZFormatNoticeList(¬ice, lyst, num, &pack, &packlen, ZNOAUTH);
if (retval != ZERR_NONE)
return retval;
-
-#ifdef HAVE_KRB5
- if (bdump_ac) {
- krb5_data indata, outmsg;
- indata.length=packlen;
- indata.data=pack;
- memset(&outmsg, 0, sizeof(krb5_data));
- retval = krb5_mk_priv(Z_krb5_ctx, bdump_ac, &indata, &outmsg, NULL);
- if (retval != ZERR_NONE)
- return retval;
- if (outmsg.length > Z_MAXPKTLEN) {
- syslog(LOG_ERR, "bsl: encrypted packet is too large");
- return ZERR_PKTLEN;
- }
- packlen = outmsg.length;
- free(pack);
- pack=malloc(packlen);
- if (!pack)
- return ENOMEM;
- memcpy(pack, outmsg.data, packlen);
- krb5_free_data_contents(Z_krb5_ctx, &outmsg);
- }
-#endif
-
+
length = htons((u_short) packlen);
count = net_write(output, (char *) &length, sizeof(length));
}
static void
-shutdown_file_pointers(void)
-{
+shutdown_file_pointers() {
if (input) {
fclose(input);
input = 0;
if (live_socket >= 0) {
close(live_socket);
live_socket = -1;
-#ifdef HAVE_KRB5
- if (bdump_ac)
- krb5_auth_con_free(Z_krb5_ctx, bdump_ac);
- bdump_ac = NULL;
-#endif
}
}
static void
-cleanup(Server *server)
+cleanup(server)
+ Server *server;
{
#ifdef _POSIX_VERSION
struct sigaction action;
#endif
+#if 1
zdbug((LOG_DEBUG, "bdump cleanup"));
-
+#endif
if (server != limbo_server) {
server->state = SERV_DEAD;
timer_reset(server->timer);
#ifdef HAVE_KRB4
int
-get_tgt(void)
+get_tgt()
{
/* MIT Kerberos 4 get_svc_in_tkt() requires instance to be writable and
* at least INST_SZ bytes long. */
static char buf[INST_SZ + 1] = SERVER_INSTANCE;
int retval = 0;
-
+ CREDENTIALS cred;
+#ifndef NOENCRYPTION
+ Sched *s;
+#endif
+
/* have they expired ? */
if (ticket_time < NOW - tkt_lifetime(TKTLIFETIME) + (15L * 60L)) {
/* +15 for leeway */
-
+#if 0
zdbug((LOG_DEBUG,"get new tickets: %d %d %d", ticket_time, NOW,
NOW - tkt_lifetime(TKTLIFETIME) + 15L));
-
+#endif
dest_tkt();
retval = krb_get_svc_in_tkt(SERVER_SERVICE, buf, ZGetRealm(),
ticket_time = NOW;
}
+#ifndef NOENCRYPTION
retval = read_service_key(SERVER_SERVICE, SERVER_INSTANCE,
ZGetRealm(), 0 /*kvno*/,
- srvtab_file, (char *)serv_key);
+ srvtab_file, serv_key);
if (retval != KSUCCESS) {
syslog(LOG_ERR, "get_tgt: read_service_key: %s",
krb_get_err_text(retval));
return 1;
}
des_key_sched(serv_key, serv_ksched.s);
+#endif /* !NOENCRYPTION */
}
-#ifdef HAVE_KRB5
- /* XXX */
- if (ticket5_time < NOW - tkt5_lifetime(TKT5LIFETIME) + (15L * 60L)) {
- krb5_keytab kt;
- krb5_get_init_creds_opt opt;
- krb5_creds cred;
- krb5_principal principal;
-
- memset(&cred, 0, sizeof(cred));
-
- retval = krb5_build_principal(Z_krb5_ctx, &principal,
- strlen(ZGetRealm()),
- ZGetRealm(),
- SERVER_KRB5_SERVICE, SERVER_INSTANCE,
- 0);
- if (retval) {
- krb5_free_principal(Z_krb5_ctx, principal);
- return(1);
- }
-
- krb5_get_init_creds_opt_init (&opt);
- krb5_get_init_creds_opt_set_tkt_life (&opt, TKT5LIFETIME);
-
- retval = krb5_kt_resolve(Z_krb5_ctx, keytab_file, &kt);
- if (retval) return(1);
-
- retval = krb5_get_init_creds_keytab (Z_krb5_ctx,
- &cred,
- principal,
- kt,
- 0,
- NULL,
- &opt);
- krb5_free_principal(Z_krb5_ctx, principal);
- krb5_kt_close(Z_krb5_ctx, kt);
- if (retval) return(1);
-
- retval = krb5_cc_initialize (Z_krb5_ctx, Z_krb5_ccache, cred.client);
- if (retval) return(1);
-
- retval = krb5_cc_store_cred (Z_krb5_ctx, Z_krb5_ccache, &cred);
- if (retval) return(1);
-
- ticket5_time = NOW;
-
- krb5_free_cred_contents (Z_krb5_ctx, &cred);
- }
-#endif
return(0);
}
#endif /* HAVE_KRB4 */
/*ARGSUSED*/
static void
-close_bdump(void *arg)
+close_bdump(arg)
+ void * arg;
{
if (bdump_socket >= 0) {
FD_CLR(bdump_socket, &interesting);
close(bdump_socket);
nfds = srv_socket + 1;
bdump_socket = -1;
-
+#if 1
zdbug((LOG_DEBUG, "bdump not used"));
+#endif
} else {
+#if 1
zdbug((LOG_DEBUG, "bdump not open"));
+#endif
}
return;
}
*/
static Code_t
-bdump_recv_loop(Server *server)
+bdump_recv_loop(server)
+ Server *server;
{
ZNotice_t notice;
ZPacket_t packet;
Code_t retval;
Client *client = NULL;
struct sockaddr_in who;
-#ifdef HAVE_KRB5
- unsigned char buf[512];
- int blen;
-#endif
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
- char *cp;
-#endif
#ifdef HAVE_KRB4
+ char *cp;
C_Block cblock;
#endif /* HAVE_KRB4 */
- ZRealm *realm = NULL;
+ Realm *realm = NULL;
+#if 1
zdbug((LOG_DEBUG, "bdump recv loop"));
+#endif
/* do the inverse of bdump_send_loop, registering stuff on the fly */
while (1) {
return retval;
}
-#if HAVE_KRB5
- if (bdump_ac) {
- krb5_data in, out;
- in.length = len;
- in.data = packet;
- memset(&out, 0, sizeof(krb5_data));
- retval = krb5_rd_priv(Z_krb5_ctx, bdump_ac, &in, &out, NULL);
- if (retval != ZERR_NONE) {
- syslog(LOG_ERR, "brl krb5 rd priv: %s", error_message(retval));
- return retval;
- }
- memcpy(packet, out.data, out.length);
- len = out.length;
- krb5_free_data_contents(Z_krb5_ctx, &out);
- }
-#endif
-
retval = ZParseNotice(packet, len, ¬ice);
if (retval != ZERR_NONE) {
syslog(LOG_ERR, "brl notice parse: %s", error_message(retval));
syslog(LOG_ERR,"brl failed: %s", error_message(retval));
return retval;
}
-#ifdef HAVE_KRB5
- client->session_keyblock = NULL;
- if (*notice.z_class_inst) {
- /* check out this session key I found */
- cp = notice.z_message + strlen(notice.z_message) + 1;
- if (*cp == '0') {
- /* ****ing netascii; this is an encrypted DES keyblock
- XXX this code should be conditionalized for server
- transitions */
- retval = Z_krb5_init_keyblock(Z_krb5_ctx, ENCTYPE_DES_CBC_CRC,
- sizeof(C_Block),
- &client->session_keyblock);
- if (retval) {
- syslog(LOG_ERR, "brl failed to allocate DES keyblock: %s",
- error_message(retval));
- return retval;
- }
- retval = ZReadAscii(cp, strlen(cp), cblock, sizeof(C_Block));
- if (retval != ZERR_NONE) {
- syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
- error_message(retval), cp);
- } else {
- des_ecb_encrypt((C_Block *)cblock, (C_Block *)Z_keydata(client->session_keyblock),
- serv_ksched.s, DES_DECRYPT);
- }
- } else if (*cp == 'Z') { /* Zcode! Long live the new flesh! */
- retval = ZReadZcode((unsigned char *)cp, buf, sizeof(buf), &blen);
- if (retval != ZERR_NONE) {
- syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
- error_message(retval), cp);
- } else {
- retval = Z_krb5_init_keyblock(Z_krb5_ctx,
- ntohl(*(krb5_enctype *)&buf[0]),
- ntohl(*(u_int32_t *)&buf[4]),
- &client->session_keyblock);
- if (retval) {
- syslog(LOG_ERR, "brl failed to allocate keyblock: %s",
- error_message(retval));
- return retval;
- }
- memcpy(Z_keydata(client->session_keyblock), &buf[8],
- Z_keylen(client->session_keyblock));
- }
- }
- }
-#else
#ifdef HAVE_KRB4
memset(client->session_key, 0, sizeof(C_Block));
if (*notice.z_class_inst) {
syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
error_message(retval), cp);
} else {
+#ifdef NOENCRYPTION
+ memcpy(cblock, client->session_key, sizeof(C_Block));
+#else
des_ecb_encrypt(cblock, client->session_key, serv_ksched.s,
DES_DECRYPT);
+#endif
}
}
#endif /* HAVE_KRB4 */
-#endif
} else if (strcmp(notice.z_opcode, CLIENT_SUBSCRIBE) == 0) {
/* a subscription packet */
if (!client) {
error_message(retval));
return retval;
}
- } /* else */
+ } /* else
/* Other side tried to send us subs for a realm we didn't
know about, and so we drop them silently */
*/
static Code_t
-bdump_send_loop(Server *server)
+bdump_send_loop(server)
+ Server *server;
{
Code_t retval;
+#if 1
zdbug((LOG_DEBUG, "bdump send loop"));
+#endif
retval = uloc_send_locations();
if (retval != ZERR_NONE)
*/
static Code_t
-send_done(void)
+send_done()
{
Code_t retval;
+#if 1
zdbug((LOG_DEBUG, "send_done"));
-
+#endif
retval = send_normal_tcp(SERVACK, bdump_sin.sin_port, ZEPHYR_ADMIN_CLASS,
"", ADMIN_DONE, myname, "", NULL, 0);
return retval;
*/
static Code_t
-send_list(ZNotice_Kind_t kind,
- int port,
- char *class_name,
- char *inst,
- char *opcode,
- char *sender,
- char *recip,
- char **lyst,
- int num)
+send_list(kind, port, class_name, inst, opcode, sender, recip, lyst, num)
+ ZNotice_Kind_t kind;
+ int port, num;
+ char *class_name, *inst, *opcode, *sender, *recip, **lyst;
{
ZNotice_t notice;
char *pack;
*/
static Code_t
-send_normal_tcp(ZNotice_Kind_t kind,
- int port,
- char *class_name,
- char *inst,
- char *opcode,
- char *sender,
- char *recip,
- char *message,
- int len)
+send_normal_tcp(kind, port, class_name, inst, opcode, sender, recip,
+ message, len)
+ ZNotice_Kind_t kind;
+ int port, len;
+ char *class_name, *inst, *opcode, *sender, *recip, *message;
{
ZNotice_t notice;
char *pack;
return retval;
}
-#ifdef HAVE_KRB5
- if (bdump_ac) {
- krb5_data indata, outmsg;
- indata.length=packlen;
- indata.data=pack;
- memset(&outmsg, 0, sizeof(krb5_data));
- retval = krb5_mk_priv(Z_krb5_ctx, bdump_ac, &indata, &outmsg, NULL);
- if (retval != ZERR_NONE)
- return retval;
- if (outmsg.length > Z_MAXPKTLEN) {
- syslog(LOG_ERR, "sn: encrypted packet is too large");
- return ZERR_PKTLEN;
- }
- packlen = outmsg.length;
- free(pack);
- pack=malloc(packlen);
- if (!pack)
- return ENOMEM;
- memcpy(pack, outmsg.data, packlen);
- krb5_free_data_contents(Z_krb5_ctx, &outmsg);
- }
-#endif
-
length = htons((u_short) packlen);
count = net_write(output, (char *) &length, sizeof(length));
*/
static Code_t
-get_packet(void *packet, int len, int *retlen)
+get_packet(packet, len, retlen)
+ void *packet;
+ int len;
+ int *retlen;
{
u_short length;
int result;
}
static Code_t
-extract_sin(ZNotice_t *notice, struct sockaddr_in *target)
+extract_sin(notice, target)
+ ZNotice_t *notice;
+ struct sockaddr_in *target;
{
char *cp = notice->z_message;
char *buf;
buf = cp;
if (!notice->z_message_len || *buf == '\0') {
+#if 0
+ zdbug((LOG_DEBUG,"no addr"));
+#endif
return ZSRV_PKSHORT;
}
target->sin_addr.s_addr = inet_addr(cp);
cp += (strlen(cp) + 1); /* past the null */
if ((cp >= notice->z_message + notice->z_message_len) || (*cp == '\0')) {
+#if 0
+ zdbug((LOG_DEBUG, "no port"));
+#endif
return(ZSRV_PKSHORT);
}
target->sin_port = htons((u_short) atoi(cp));
}
static int
-net_read(FILE *f, char *buf, int len)
+net_read(f, buf, len)
+ FILE *f;
+ char *buf;
+ int len;
{
int cc, len2 = 0;
errno = 0;
cc = fread(buf, 1, len, f);
if (cc == 0)
- {
- if (feof(f))
- return len2;
- if (errno == 0)
- errno = EIO;
return -1;
- }
buf += cc;
len2 += cc;
len -= cc;
}
static int
-net_write(FILE *f, char *buf, int len)
+net_write(f, buf, len)
+ FILE *f;
+ char *buf;
+ int len;
{
int cc;
int wrlen = len;
}
static int
-setup_file_pointers (void)
+setup_file_pointers ()
{
int fd;
static Triplet *triplet_bucket[HASHSIZE]; /* the hash table of pointers */
static Code_t remove_client __P((Triplet *triplet, Client *client,
- ZRealm *realm));
+ Realm *realm));
static Code_t insert_client __P((Triplet *triplet, Client *client,
- ZRealm *realm));
+ Realm *realm));
static Triplet *triplet_alloc __P((String *classname, String *inst,
String *recipient));
static void free_triplet __P((Triplet *));
* shouldn't affect performance.
*/
-int
-ZDest_eq(Destination *d1,
- Destination *d2)
+int ZDest_eq(d1, d2)
+ Destination *d1, *d2;
{
return((d1->classname == d2->classname) &&
(d1->inst == d2->inst) &&
/* the client as interested in a triplet */
Code_t
-triplet_register(Client *client,
- Destination *dest,
- ZRealm *realm)
+triplet_register(client, dest, realm)
+ Client *client;
+ Destination *dest;
+ Realm *realm;
{
Triplet *triplet;
unsigned long hashval;
/* Triplet not present in hash table, insert it. */
triplet = triplet_alloc(dest->classname, dest->inst, dest->recip);
- Triplet_insert(&triplet_bucket[hashval], triplet);
+ LIST_INSERT(&triplet_bucket[hashval], triplet);
return insert_client(triplet, client, realm);
}
/* dissociate client from the class, garbage collecting if appropriate */
Code_t
-triplet_deregister(Client *client,
- Destination *dest,
- ZRealm *realm)
+triplet_deregister(client, dest, realm)
+ Client *client;
+ Destination *dest;
+ Realm *realm;
{
Triplet *triplet;
int retval;
unsigned long hashval;
+#if 0
+ zdbug((LOG_DEBUG, "class_dereg: %s %s", dest->classname->string,
+ dest->inst->string));
+#endif
hashval = DEST_HASHVAL(*dest);
for (triplet = triplet_bucket[hashval]; triplet; triplet = triplet->next) {
if (ZDest_eq(&triplet->dest, dest)) {
if (retval != ZERR_NONE)
return retval;
if (*triplet->clients == NULL && !triplet->acl) {
- Triplet_delete(triplet);
+ LIST_DELETE(triplet);
free_triplet(triplet);
return ZSRV_EMPTYCLASS;
}
/* return a linked list of what clients are interested in this triplet */
Client **
-triplet_lookup(Destination *dest)
+triplet_lookup(dest)
+ Destination *dest;
{
Triplet *triplet;
unsigned long hashval;
*/
Acl *
-class_get_acl(String *class_name)
+class_get_acl(class_name)
+ String *class_name;
{
Triplet *triplet;
unsigned long hashval;
*/
Code_t
-class_restrict(char *class_name,
- Acl *acl)
+class_restrict(class_name, acl)
+ char *class_name;
+ Acl *acl;
{
Triplet *triplet;
String *d;
*/
Code_t
-class_setup_restricted(char *class_name,
- Acl *acl)
+class_setup_restricted(class_name, acl)
+ char *class_name;
+ Acl *acl;
{
Triplet *triplet;
String *d;
if (!triplet)
return ENOMEM;
triplet->acl = acl;
- Triplet_insert(&triplet_bucket[hashval], triplet);
+ LIST_INSERT(&triplet_bucket[hashval], triplet);
return ZERR_NONE;
}
/* allocate space for a class structure */
static Triplet *
-triplet_alloc(String *classname,
- String *inst,
- String *recipient)
+triplet_alloc(classname,inst,recipient)
+ String *classname, *inst, *recipient;
{
Triplet *triplet;
+ Client *clist;
triplet = (Triplet *) malloc(sizeof(Triplet));
if (!triplet)
/* insert a client into the list associated with the class *ptr */
static Code_t
-insert_client(Triplet *triplet,
- Client *client,
- ZRealm *realm)
+insert_client(triplet, client, realm)
+ Triplet *triplet;
+ Client *client;
+ Realm *realm;
{
Client **clientp, **newclients;
int new_size;
* collecting if appropriate
*/
-static Code_t
-remove_client(Triplet *triplet,
- Client *client,
- ZRealm *realm)
+static Code_t remove_client(triplet, client, realm)
+ Triplet *triplet;
+ Client *client;
+ Realm *realm;
{
Client **clientp;
return ZSRV_BADASSOC;
}
-static void
-free_triplet(Triplet *triplet)
+static void free_triplet(triplet)
+ Triplet *triplet;
{
if (triplet->clients)
free(triplet->clients);
free(triplet);
}
-void
-triplet_dump_subs(FILE *fp)
+void triplet_dump_subs(fp)
+ FILE *fp;
{
int i;
Triplet *triplet;
htons((unsigned short) (port))) % HASHSIZE)
Code_t
-client_register(ZNotice_t *notice,
- struct in_addr *host,
- Client **client_p,
- int wantdefaults)
+client_register(notice, host, client_p, wantdefaults)
+ ZNotice_t *notice;
+ struct in_addr *host;
+ Client **client_p;
+ int wantdefaults;
{
Client *client;
+ Code_t retval;
/* chain the client's host onto this server's host list */
+#if 1
zdbug((LOG_DEBUG, "client_register: adding %s at %s/%d",
notice->z_sender, inet_ntoa(*host), ntohs(notice->z_port)));
+#endif
if (!notice->z_port)
return ZSRV_BADSUBPORT;
if (!client)
return ENOMEM;
memset(&client->addr, 0, sizeof(struct sockaddr_in));
-#ifdef HAVE_KRB5
- client->session_keyblock = NULL;
-#else
-#ifdef HAVE_KRB4
+#ifdef KERBEROS
memset(&client->session_key, 0, sizeof(client->session_key));
-#endif
#endif
client->last_send = 0;
client->last_ack = NOW;
client->subs = NULL;
client->realm = NULL;
client->principal = make_string(notice->z_sender, 0);
- Client_insert(&client_bucket[INET_HASH(&client->addr.sin_addr,
- notice->z_port)], client);
+ LIST_INSERT(&client_bucket[INET_HASH(&client->addr.sin_addr,
+ notice->z_port)], client);
}
/* Add default subscriptions only if this is not resulting from a brain
*/
void
-client_deregister(Client *client,
- int flush)
+client_deregister(client, flush)
+ Client *client;
+ int flush;
{
- Client_delete(client);
+ LIST_DELETE(client);
nack_release(client);
subscr_cancel_client(client);
free_string(client->principal);
-#ifdef HAVE_KRB5
- if (client->session_keyblock)
- krb5_free_keyblock(Z_krb5_ctx, client->session_keyblock);
-#endif
if (flush)
uloc_flush_client(&client->addr);
free(client);
}
void
-client_flush_host(struct in_addr *host)
+client_flush_host(host)
+ struct in_addr *host;
{
int i;
Client *client, *next;
}
Code_t
-client_send_clients(void)
+client_send_clients()
{
int i;
Client *client;
*/
void
-client_dump_clients(FILE *fp)
+client_dump_clients(fp)
+ FILE *fp;
{
Client *client;
int i;
*/
Client *
-client_find(struct in_addr *host,
- unsigned int port)
+client_find(host, port)
+ struct in_addr *host;
+ unsigned int port;
{
Client *client;
long hashval;
/* copy a string into a newly allocated area */
char *
-strsave (const char *sp)
+strsave (sp)
+ const char *sp;
{
char *ret;
- ret = strdup(sp);
+ ret = (char *) malloc(strlen(sp) + 1);
if (!ret) {
syslog(LOG_CRIT, "no mem strdup'ing");
abort();
}
+ strcpy(ret, sp);
return ret;
}
/* The "& 0x5f" provides case-insensitivity for ASCII. */
unsigned long
-hash(const char *string)
+hash(string)
+ const char *string;
{
unsigned long hval = 0;
char cp;
}
/* Output a name, replacing newlines with \n and single quotes with \q. */
-void dump_quote(char *p, FILE *fp)
+void dump_quote(p, fp)
+ char *p;
+ FILE *fp;
{
for (; *p; p++) {
if (*p == '\'') {
#include <zephyr/mit-copyright.h>
#include "zserver.h"
#include <sys/socket.h>
-#include <com_err.h>
#ifndef lint
#ifndef SABER
#define HOSTS_SIZE_INIT 256
#ifdef DEBUG
-const char *ZNoticeKinds[9] = {"UNSAFE", "UNACKED", "ACKED", "HMACK",
+ZCONST char *ZNoticeKinds[9] = {"UNSAFE", "UNACKED", "ACKED", "HMACK",
"HMCTL", "SERVACK", "SERVNAK", "CLIENTACK",
"STAT"};
#endif
static int hosts_size = 0, num_hosts = 0;
static void
-dump_stats (void *arg)
+dump_stats (arg)
+ void *arg;
{
syslog(LOG_INFO, "stats: %s: %d", hm_packets.str, hm_packets.val);
syslog(LOG_INFO, "stats: %s: %d", control_notices.str,
*/
void
-handle_packet(void)
+handle_packet()
{
Code_t status;
ZPacket_t input_packet; /* from the network */
int authentic; /* authentic flag */
Pending *pending; /* pending packet */
int from_server; /* packet is from another server */
- ZRealm *realm; /* foreign realm ptr */
+ Realm *realm; /* foreign realm ptr */
#ifdef DEBUG
static int first_time = 1;
#endif
if (otherservers[me_server_idx].queue) {
/* something here for me; take care of it */
+#if 1
zdbug((LOG_DEBUG, "internal queue process"));
+#endif
pending = server_dequeue(me_server);
if (new_notice.z_kind == SERVACK || new_notice.z_kind == SERVNAK) {
authentic = ZAUTH_YES;
} else {
- realm = realm_which_realm(&input_sin);
- if (realm) {
+ if (realm = realm_which_realm(&input_sin)) {
authentic = ZCheckRealmAuthentication(&new_notice,
- &input_sin,
- realm->name);
+ &input_sin,
+ realm->name);
} else
authentic = ZCheckAuthentication(&new_notice, &input_sin);
}
if (new_notice.z_kind == SERVACK || new_notice.z_kind == SERVNAK) {
authentic = ZAUTH_YES;
} else {
- realm = realm_which_realm(&whoisit);
- if (realm) {
+ if (realm = realm_which_realm(&whoisit)) {
authentic = ZCheckRealmAuthentication(&new_notice,
&whoisit,
realm->name);
}
}
+ if (whoisit.sin_port != hm_port && whoisit.sin_port != hm_srv_port &&
+ strcasecmp(new_notice.z_class, ZEPHYR_ADMIN_CLASS) != 0 &&
+ whoisit.sin_port != srv_addr.sin_port &&
+ new_notice.z_kind != CLIENTACK) {
+ syslog(LOG_ERR, "bad port %s/%d", inet_ntoa(whoisit.sin_addr),
+ ntohs(whoisit.sin_port));
+ return;
+ }
+
message_notices.val++;
dispatch(&new_notice, authentic, &whoisit, from_server);
return;
*/
static void
-dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- int from_server)
+dispatch(notice, auth, who, from_server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ int from_server;
{
Code_t status;
String *notice_class;
struct sockaddr_in who2;
int authflag;
- ZRealm *realm;
+ Realm *realm;
char *cp;
#ifdef DEBUG
char dbg_buf[BUFSIZ];
inet_ntoa(who->sin_addr));
return;
}
+#if 0
+ if (zdebug) {
+ syslog(LOG_DEBUG,
+ "disp:%s '%s' '%s' '%s' notice to '%s' from '%s' %s/%d/%d",
+ ZNoticeKinds[(int) notice->z_kind], notice->z_class,
+ notice->z_class_inst, notice->z_opcode, notice->z_recipient,
+ notice->z_sender, inet_ntoa(who->sin_addr),
+ ntohs(who->sin_port), ntohs(notice->z_port));
+ }
+#endif
if (notice->z_kind == CLIENTACK) {
nack_cancel(notice, who);
}
who2 = *who;
-
+#if 0
+ if (0 && from_server) {
+ /* incorporate server_dispatch here */
+ }
+#endif
notice_class = make_string(notice->z_class,1);
if (from_server) {
*/
void
-sendit(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- int external)
+sendit(notice, auth, who, external)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ int external;
{
static int send_counter = 0;
char recipbuf[ANAME_SZ + INST_SZ + REALM_SZ + 3], *recipp;
class = make_string(notice->z_class, 1);
if (realm_bound_for_realm(ZGetRealm(), notice->z_recipient)) {
- ZRealm *rlm;
+ Realm *rlm;
acl = class_get_acl(class);
if (acl != NULL) {
}
}
}
+ if (!realm_which_realm(who)) {
+ if (memcmp(¬ice->z_sender_addr.s_addr, &who->sin_addr.s_addr,
+ sizeof(notice->z_sender_addr.s_addr))) {
+ /* someone is playing games... */
+ /* inet_ntoa returns pointer to static area */
+ /* max size is 255.255.255.255 */
+ char buffer[16];
+ strcpy(buffer, inet_ntoa(who->sin_addr));
+ if (!auth) {
+ syslog(LOG_WARNING,
+ "sendit unauthentic fake packet: claimed %s, real %s",
+ inet_ntoa(notice->z_sender_addr), buffer);
+ clt_ack(notice, who, AUTH_FAILED);
+ free_string(class);
+ return;
+ }
+ if (ntohl(notice->z_sender_addr.s_addr) != 0) {
+ syslog(LOG_WARNING,
+ "sendit invalid address: claimed %s, real %s",
+ inet_ntoa(notice->z_sender_addr), buffer);
+ clt_ack(notice, who, AUTH_FAILED);
+ free_string(class);
+ return;
+ }
+ syslog(LOG_WARNING, "sendit addr mismatch: claimed %s, real %s",
+ inet_ntoa(notice->z_sender_addr), buffer);
+ }
+ }
/* Increment the send counter, used to prevent duplicate sends to
* clients. On the off-chance that we wrap around to 0, skip over
*/
static int
-send_to_dest(ZNotice_t *notice,
- int auth,
- Destination *dest,
- int send_counter,
- int external)
+send_to_dest(notice, auth, dest, send_counter, external)
+ ZNotice_t *notice;
+ int auth;
+ Destination *dest;
+ int send_counter;
+ int external;
{
Client **clientp;
int any = 0;
*/
void
-nack_release(Client *client)
+nack_release(client)
+ Client *client;
{
int i;
Unacked *nacked, *next;
next = nacked->next;
if (nacked->client == client) {
timer_reset(nacked->timer);
- Unacked_delete(nacked);
+ LIST_DELETE(nacked);
free(nacked->packet);
free(nacked);
}
/* the arguments must be the same as the arguments to Z_XmitFragment */
/*ARGSUSED*/
Code_t
-xmit_frag(ZNotice_t *notice,
- char *buf,
- int len,
- int waitforack)
+xmit_frag(notice, buf, len, waitforack)
+ ZNotice_t *notice;
+ char *buf;
+ int len;
+ int waitforack;
{
struct sockaddr_in sin;
char *savebuf;
Unacked *nacked;
Code_t retval;
- int sendfail = 0;
+ int hashval, sendfail = 0;
retval = ZSendPacket(buf, len, 0);
if (retval != ZERR_NONE) {
nacked->packsz = len;
nacked->uid = notice->z_uid;
nacked->timer = timer_set_rel(rexmit_times[0], rexmit, nacked);
- Unacked_insert(&nacktab[NACKTAB_HASHVAL(sin, nacked->uid)], nacked);
+ LIST_INSERT(&nacktab[NACKTAB_HASHVAL(sin, nacked->uid)], nacked);
return(ZERR_NONE);
}
-
/*
* Send the notice to the client. After transmitting, put it onto the
* not ack'ed list.
*/
void
-xmit(ZNotice_t *notice,
- struct sockaddr_in *dest,
- int auth,
- Client *client)
+xmit(notice, dest, auth, client)
+ ZNotice_t *notice;
+ struct sockaddr_in *dest;
+ int auth;
+ Client *client;
{
char *noticepack;
Unacked *nacked;
int packlen, sendfail = 0;
Code_t retval;
+#if 0
+ zdbug((LOG_DEBUG,"xmit"));
+#endif
+
noticepack = (char *) malloc(sizeof(ZPacket_t));
if (!noticepack) {
syslog(LOG_ERR, "xmit malloc");
we are distributing authentic and
we have a pointer to auth info
*/
-#ifdef HAVE_KRB5
- retval = ZFormatAuthenticNoticeV5(notice, noticepack, packlen,
- &packlen, client->session_keyblock);
- if (retval != ZERR_NONE) {
- syslog(LOG_ERR, "xmit auth format: %s", error_message(retval));
- free(noticepack);
- return;
- }
-#else
-#if defined(HAVE_KRB4)
- retval = ZFormatAuthenticNotice(notice, noticepack, packlen,
- &packlen, client->session_key);
- if (retval != ZERR_NONE) {
- syslog(LOG_ERR, "xmit auth format: %s", error_message(retval));
- free(noticepack);
- return;
- }
+#ifdef HAVE_KRB4
+ retval = ZFormatAuthenticNotice(notice, noticepack, packlen, &packlen,
+ client->session_key);
+ if (retval != ZERR_NONE) {
+ syslog(LOG_ERR, "xmit auth format: %s", error_message(retval));
+ free(noticepack);
+ return;
+ }
#else /* !HAVE_KRB4 */
notice->z_auth = 1;
retval = ZFormatSmallRawNotice(notice, noticepack, &packlen);
return;
}
#endif /* HAVE_KRB4 */
-#endif /* HAVE_KRB5 */
} else {
notice->z_auth = 0;
notice->z_authent_len = 0;
* same thing with authentic Zephyrs.
*/
if (retval == ZERR_PKTLEN) {
- ZNotice_t partnotice;
+ ZNotice_t partnotice, newnotice;
char multi[64];
char *buffer, *ptr;
- int buffer_len, hdrlen, offset, fragsize, message_len;
+ int buffer_len, hdrlen, offset, fragsize, ret_len, message_len;
int origoffset, origlen;
free(noticepack);
(void) sprintf(multi, "%d/%d", offset+origoffset, origlen);
partnotice.z_multinotice = multi;
if (offset > 0) {
- (void) Z_gettimeofday(&partnotice.z_uid.tv, (struct timezone *)0);
+ (void) gettimeofday(&partnotice.z_uid.tv, (struct timezone *)0);
partnotice.z_uid.tv.tv_sec = htonl((u_long)
partnotice.z_uid.tv.tv_sec);
partnotice.z_uid.tv.tv_usec = htonl((u_long)
return; /* DON'T put on nack list */
}
}
+#if 0
+ zdbug((LOG_DEBUG," to %s/%d", inet_ntoa(dest->sin_addr),
+ ntohs(dest->sin_port)));
+#endif
retval = ZSetDestAddr(dest);
if (retval != ZERR_NONE) {
syslog(LOG_WARNING, "xmit set addr: %s", error_message(retval));
nacked->packsz = packlen;
nacked->uid = notice->z_uid;
nacked->timer = timer_set_rel(rexmit_times[0], rexmit, nacked);
- Unacked_insert(&nacktab[NACKTAB_HASHVAL(*dest, nacked->uid)], nacked);
+ LIST_INSERT(&nacktab[NACKTAB_HASHVAL(*dest, nacked->uid)], nacked);
}
/*
*/
void
-rexmit(void *arg)
+rexmit(arg)
+ void *arg;
{
Unacked *nacked = (Unacked *) arg;
int retval;
+#if 1
syslog(LOG_DEBUG, "rexmit %s/%d #%d time %d",
inet_ntoa(nacked->dest.addr.sin_addr),
- ntohs(nacked->dest.addr.sin_port), nacked->rexmits + 1, (int)NOW);
+ ntohs(nacked->dest.addr.sin_port), nacked->rexmits + 1, NOW);
+#endif
nacked->rexmits++;
if (rexmit_times[nacked->rexmits] == -1) {
* nack list before calling client_deregister(), which
* scans the nack list.)
*/
- Unacked_delete(nacked);
+ LIST_DELETE(nacked);
if (nacked->client) {
server_kill_clt(nacked->client);
client_deregister(nacked->client, 1);
}
/* retransmit the packet */
+#if 0
+ zdbug((LOG_DEBUG," to %s/%d", inet_ntoa(nacked->dest.addr.sin_addr),
+ ntohs(nacked->dest.addr.sin_port)));
+#endif
retval = ZSetDestAddr(&nacked->dest.addr);
if (retval != ZERR_NONE) {
syslog(LOG_WARNING, "rexmit set addr: %s", error_message(retval));
*/
void
-clt_ack(ZNotice_t *notice,
- struct sockaddr_in *who,
- Sent_type sent)
+clt_ack(notice, who, sent)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ Sent_type sent;
{
ZNotice_t acknotice;
ZPacket_t ackpack;
int packlen;
+ int notme = 0;
char *sent_name;
Code_t retval;
if (bdumping) { /* don't ack while dumping */
+#if 1
zdbug((LOG_DEBUG,"bdumping, no ack"));
+#endif
return;
}
abort ();
}
+#if 0
+ zdbug((LOG_DEBUG,"clt_ack type %s for %d to %s/%d", sent_name,
+ ntohs(notice->z_port), inet_ntoa(who->sin_addr),
+ ntohs(who->sin_port)));
+#endif
+
acknotice.z_multinotice = "";
/* leave room for the trailing null */
*/
static void
-nack_cancel(ZNotice_t *notice,
- struct sockaddr_in *who)
+nack_cancel(notice, who)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
{
Unacked *nacked;
int hashval;
/* search the not-yet-acked table for this packet, and flush it. */
+#if 0
+ zdbug((LOG_DEBUG, "nack_cancel: %s:%08X,%08X",
+ inet_ntoa(notice->z_uid.zuid_addr),
+ notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
+#endif
hashval = NACKTAB_HASHVAL(*who, notice->z_uid);
for (nacked = nacktab[hashval]; nacked; nacked = nacked->next) {
if (nacked->dest.addr.sin_addr.s_addr == who->sin_addr.s_addr
nacked->client->last_ack = NOW;
timer_reset(nacked->timer);
free(nacked->packet);
- Unacked_delete(nacked);
+ LIST_DELETE(nacked);
free(nacked);
return;
}
}
+#if 1
zdbug((LOG_DEBUG,"nack_cancel: nack not found %s:%08X,%08X",
inet_ntoa (notice->z_uid.zuid_addr),
notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
+#endif
}
/* for compatibility when sending subscription information to old clients */
/* Dispatch an HM_CTL notice. */
Code_t
-hostm_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+hostm_dispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
+ Server *owner;
char *opcode = notice->z_opcode;
+ Code_t retval;
int i, add = 0, remove = 0;
+#if 0
+ zdbug((LOG_DEBUG,"hm_disp"));
+#endif
+
if (notice->z_kind == HMACK) {
/* Ignore. */
;
} else if (notice->z_kind != HMCTL) {
+#if 0
+ zdbug((LOG_DEBUG, "bogus HM packet"));
+#endif
clt_ack(notice, who, AUTH_FAILED);
} else if (strcmp(opcode, HM_FLUSH) == 0) {
client_flush_host(&who->sin_addr);
*/
Code_t
-control_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+control_dispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
char *opcode = notice->z_opcode;
Client *client;
Code_t retval;
int wantdefs;
- ZRealm *realm;
+ Realm *realm;
struct sockaddr_in newwho;
/*
subscr_sendlist(notice, auth, who);
return ZERR_NONE;
} else if (!auth) {
+#if 0
+ zdbug((LOG_DEBUG,"unauth ctrl_disp"));
+#endif
if (server == me_server)
clt_ack(notice, who, AUTH_FAILED);
return ZERR_NONE;
clt_ack(notice, who, AUTH_FAILED);
return ZERR_NONE;
}
-#ifdef HAVE_KRB5
- if (client->session_keyblock) {
- krb5_free_keyblock_contents(Z_krb5_ctx, client->session_keyblock);
- retval = krb5_copy_keyblock_contents(Z_krb5_ctx, ZGetSession(),
- client->session_keyblock);
- } else {
- retval = krb5_copy_keyblock(Z_krb5_ctx, ZGetSession(),
- &client->session_keyblock);
- }
- if (retval) {
- syslog(LOG_WARNING, "keyblock copy failed in subscr: %s",
- error_message(retval));
- if (server == me_server)
- nack(notice, who);
- return ZERR_NONE;
- }
-#else
#ifdef HAVE_KRB4
/* in case it's changed */
memcpy(client->session_key, ZGetSession(), sizeof(C_Block));
-#endif
#endif
retval = subscr_subscribe(client, notice, server);
if (retval != ZERR_NONE) {
clt_ack(notice, who, AUTH_FAILED);
return ZERR_NONE;
}
+#if 0
+ if (zdebug) {
+ if (server == me_server) {
+ syslog(LOG_DEBUG, "subscription cancel for %s/%d\n",
+ inet_ntoa(who->sin_addr), ntohs(who->sin_port));
+ } else {
+ syslog(LOG_DEBUG,
+ "subscription cancel for %s/%d from %s\n",
+ inet_ntoa(who->sin_addr), ntohs(who->sin_port),
+ server->addr_str);
+ }
+ }
+#endif
subscr_cancel(who, notice);
} else {
nack(notice, who);
/* canceling subscriptions implies I can punt info about this client */
client = client_find(&who->sin_addr, notice->z_port);
if (client == NULL) {
+#if 0
+ zdbug((LOG_DEBUG,"can_sub not found client"));
+#endif
if (server == me_server)
nack(notice, who);
return ZERR_NONE;
return ZERR_NONE;
}
/* don't flush locations here, let him do it explicitly */
+#if 0
+ zdbug((LOG_DEBUG, "cancelsub clt_dereg %s/%d",
+ inet_ntoa(who->sin_addr), ntohs(who->sin_port)));
+#endif
client_deregister(client, 0);
} else {
syslog(LOG_WARNING, "unknown ctl opcode %s", opcode);
}
void
-hostm_shutdown(void)
+hostm_shutdown()
{
int i, s, newserver;
struct sockaddr_in sin;
}
void
-realm_shutdown(void)
+realm_shutdown()
{
int i, s, newserver;
+ struct sockaddr_in sin;
for (i = 0; i < nservers; i++) {
if (i != me_server_idx && otherservers[i].state == SERV_UP)
}
static void
-hostm_deathgram(struct sockaddr_in *sin,
- Server *server)
+hostm_deathgram(sin, server)
+ struct sockaddr_in *sin;
+ Server *server;
{
Code_t retval;
int shutlen;
}
static char *
-hm_recipient(void)
+hm_recipient()
{
static char *recipient;
char *realm;
#ifdef HAVE_KRB4
-static ZChecksum_t compute_checksum(ZNotice_t *, C_Block);
-static ZChecksum_t compute_rlm_checksum(ZNotice_t *, C_Block);
-static Code_t ZCheckAuthentication4(ZNotice_t *notice, struct sockaddr_in *from);
+/* Keep a hash table mapping tickets to session keys, so we can do a fast
+ * check of the cryptographic checksum without doing and DES decryptions.
+ * Also remember the expiry time of the ticket, so that we can sweep the
+ * table periodically. */
+
+#define HASHTAB_SIZE 4091
+
+typedef struct hash_entry Hash_entry;
+
+/* The ticket comes at the end, in a variable-length array. */
+struct hash_entry {
+ C_Block session_key;
+ time_t expires;
+ char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
+ Hash_entry *next;
+ int ticket_len;
+ unsigned char ticket[1];
+};
+
+Hash_entry *hashtab[HASHTAB_SIZE];
+
+static int hash_ticket __P((unsigned char *, int));
+static void add_session_key __P((KTEXT, C_Block, char *, time_t));
+static int find_session_key __P((KTEXT, C_Block, char *));
+static ZChecksum_t compute_checksum __P((ZNotice_t *, C_Block));
+static ZChecksum_t compute_rlm_checksum __P((ZNotice_t *, C_Block));
/*
* GetKerberosData
* the value of rd_ap_req() applied to the ticket.
*/
int
-GetKerberosData(int fd, /* file descr. to read from */
- struct in_addr haddr, /* address of foreign host on fd */
- AUTH_DAT *kdata, /* kerberos data (returned) */
- char *service, /* service principal desired */
- char *srvtab) /* file to get keys from */
+GetKerberosData(fd, haddr, kdata, service, srvtab)
+ int fd; /* file descr. to read from */
+ struct in_addr haddr; /* address of foreign host on fd */
+ AUTH_DAT *kdata; /* kerberos data (returned) */
+ char *service; /* service principal desired */
+ char *srvtab; /* file to get keys from */
{
char p[20];
KTEXT_ST ticket; /* will get Kerberos ticket from client */
* get the ticket and write it to the file descriptor
*/
-#if !defined(krb_err_base) && defined(ERROR_TABLE_BASE_krb)
-#define krb_err_base ERROR_TABLE_BASE_krb
-#endif
-
Code_t
-SendKerberosData(int fd, /* file descriptor to write onto */
- KTEXT ticket, /* where to put ticket (return) */
- char *service, /* service name, foreign host */
- char *host)
-
+SendKerberosData(fd, ticket, service, host)
+ int fd; /* file descriptor to write onto */
+ KTEXT ticket; /* where to put ticket (return) */
+ char *service; /* service name, foreign host */
+ char *host;
{
int rem;
char p[32];
#endif /* HAVE_KRB4 */
-#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
Code_t
-ReadKerberosData(int fd, int *size, char **data, int *proto) {
- char p[20];
- int i;
- char *dst;
- int len = 0;
-
- for (i=0; i<20; i++) {
- if (read(fd, &p[i], 1) != 1) {
- p[i] = 0;
- syslog(LOG_WARNING,"ReadKerberosData: bad read reply len @%d (got \"%s\"", i, p);
- return(KFAILURE);
- }
- if (p[i] == ' ') {
- p[i] = '\0';
- break;
- }
- }
-
- if (i == 20) {
- syslog(LOG_WARNING, "ReadKerberosData: read reply len exceeds buffer");
- return KFAILURE;
- }
-
- if (!strncmp(p, "V5-", 3) && (len = atoi(p+3)) > 0)
- *proto = 5;
- else if ((len = atoi(p)) > 0)
- *proto = 4;
-
- if ((*proto < 4) | (*proto > 5)) {
- syslog(LOG_WARNING, "ReadKerberosData: error parsing authenticator length (\"%s\")", p);
- return KFAILURE;
- }
-
- if (len <= 0) {
- syslog(LOG_WARNING, "ReadKerberosData: read reply len = %d", len);
- return KFAILURE;
- }
-
- *data = malloc(len);
- if (! *data) {
- syslog(LOG_WARNING, "ReadKerberosData: failure allocating %d bytes: %m", len);
- return errno;
- }
-
- dst=*data;
- for (i=0; i < len; i++) {
- if (read(fd, dst++, 1) != 1) {
- free(*data);
- *data = NULL;
- *size = 0;
- syslog(LOG_WARNING,"ReadKerberosData: bad read reply string");
- return ZSRV_PKSHORT;
- }
- }
- *size = len;
- return 0;
-}
-#endif
-
-#ifdef HAVE_KRB5
-Code_t
-GetKrb5Data(int fd, krb5_data *data) {
- char p[20];
- int i;
- char *dst;
-
- for (i=0; i<20; i++) {
- if (read(fd, &p[i], 1) != 1) {
- p[i] = 0;
- syslog(LOG_WARNING,"bad read reply len @%d (got \"%s\")", i, p);
- return(KFAILURE);
- }
- if (p[i] == ' ') {
- p[i] = '\0';
- break;
- }
- }
- if (i == 20 || strncmp(p, "V5-", 3) || !atoi(p+3)) {
- syslog(LOG_WARNING,"bad reply len");
- return ZSRV_PKSHORT;
- }
- data->length = atoi(p+3);
- data->data = malloc(data->length);
- if (! data->data) {
- data->length = 0;
- return errno;
- }
- dst=data->data;
- for (i=0; i < data->length; i++) {
- if (read(fd, dst++, 1) != 1) {
- free(data->data);
- memset((char *)data, 0, sizeof(krb5_data));
- syslog(LOG_WARNING,"bad read reply string");
- return ZSRV_PKSHORT;
- }
- }
- return 0;
-}
-
-Code_t
-SendKrb5Data(int fd, krb5_data *data) {
- char p[32];
- int written, size_to_write;
- sprintf(p, "V5-%d ", data->length);
- size_to_write = strlen (p);
- if (size_to_write != (written = write(fd, p, size_to_write)) ||
- data->length != (written = write(fd, data->data, data->length))) {
- return (written < 0) ? errno : ZSRV_PKSHORT;
- }
- return 0;
-}
-#endif
-
-Code_t
-ZCheckRealmAuthentication(ZNotice_t *notice,
- struct sockaddr_in *from,
- char *realm)
+ZCheckRealmAuthentication(notice, from, realm)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
+ char *realm;
{
-#ifdef HAVE_KRB5
- char *authbuf;
- char rlmprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4+1024];
- krb5_principal princ;
- krb5_data packet;
- krb5_ticket *tkt;
- char *name;
- krb5_error_code result;
- krb5_principal server;
- krb5_keytab keytabid = 0;
- krb5_auth_context authctx;
- krb5_keyblock *keyblock;
- krb5_enctype enctype;
- krb5_cksumtype cksumtype;
- krb5_data cksumbuf;
- int valid;
- char *cksum0_base, *cksum1_base, *cksum2_base;
- char *x;
- unsigned char *asn1_data;
- unsigned char *key_data;
- int asn1_len, key_len, cksum0_len, cksum1_len, cksum2_len;
-#ifdef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
- krb5_authenticator *authenticator;
-#define KRB5AUTHENT authenticator
-#else
- krb5_authenticator authenticator;
-#define KRB5AUTHENT &authenticator
-#endif
- int len;
+#ifdef HAVE_KRB4
+ int result;
+ char rlmprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
+ char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
+ KTEXT_ST authent, ticket;
+ AUTH_DAT dat;
+ ZChecksum_t checksum;
+ CREDENTIALS cred;
+ C_Block session_key;
if (!notice->z_auth)
return ZAUTH_NO;
if (notice->z_authent_len <= 0)
return ZAUTH_FAILED;
- len = strlen(notice->z_ascii_authent)+1;
- authbuf = malloc(len);
-
/* Read in the authentication data. */
- if (ZReadZcode((unsigned char *)notice->z_ascii_authent,
- (unsigned char *)authbuf,
- len, &len) == ZERR_BADFIELD) {
+ if (ZReadAscii(notice->z_ascii_authent,
+ strlen(notice->z_ascii_authent)+1,
+ (unsigned char *)authent.dat,
+ notice->z_authent_len) == ZERR_BADFIELD) {
return ZAUTH_FAILED;
}
+ authent.length = notice->z_authent_len;
- (void) sprintf(rlmprincipal, "%s/%s@%s", SERVER_SERVICE,
+ (void) sprintf(rlmprincipal, "%s.%s@%s", SERVER_SERVICE,
SERVER_INSTANCE, realm);
- packet.length = len;
- packet.data = authbuf;
-
- result = krb5_kt_resolve(Z_krb5_ctx,
- keytab_file, &keytabid);
- if (result) {
- free(authbuf);
- return (result);
- }
-
- /* HOLDING: authbuf, keytabid */
- /* Create the auth context */
- result = krb5_auth_con_init(Z_krb5_ctx, &authctx);
- if (result) {
- krb5_kt_close(Z_krb5_ctx, keytabid);
- free(authbuf);
- return (result);
- }
-
- /* HOLDING: authbuf, authctx */
- result = krb5_build_principal(Z_krb5_ctx, &server, strlen(__Zephyr_realm),
- __Zephyr_realm, SERVER_SERVICE,
- SERVER_INSTANCE, NULL);
- if (!result) {
- result = krb5_rd_req(Z_krb5_ctx, &authctx, &packet, server,
- keytabid, 0, &tkt);
- krb5_free_principal(Z_krb5_ctx, server);
- }
- krb5_kt_close(Z_krb5_ctx, keytabid);
-
- if (result) {
- if (result == KRB5KRB_AP_ERR_REPEAT)
- syslog(LOG_DEBUG, "ZCheckRealmAuthentication: k5 auth failed: %s", error_message(result));
- else
- syslog(LOG_WARNING,"ZCheckRealmAuthentication: k5 auth failed: %s", error_message(result));
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return ZAUTH_FAILED;
- }
-
- /* HOLDING: authbuf, authctx, tkt */
-
- if (tkt == 0 || !Z_tktprincp(tkt)) {
- if (tkt)
- krb5_free_ticket(Z_krb5_ctx, tkt);
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return ZAUTH_FAILED;
- }
-
- princ = Z_tktprinc(tkt);
-
- if (princ == 0) {
- krb5_free_ticket(Z_krb5_ctx, tkt);
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return ZAUTH_FAILED;
- }
-
- /* HOLDING: authbuf, authctx, tkt */
- result = krb5_unparse_name(Z_krb5_ctx, princ, &name);
- if (result) {
- syslog(LOG_WARNING, "k5 unparse_name failed: %s",
- error_message(result));
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_ticket(Z_krb5_ctx, tkt);
- return ZAUTH_FAILED;
- }
-
- krb5_free_ticket(Z_krb5_ctx, tkt);
-
- /* HOLDING: authbuf, authctx, name */
- if (strcmp(name, rlmprincipal)) {
- syslog(LOG_WARNING, "k5 name mismatch: '%s' vs '%s'",
- name, rlmprincipal);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- free(name);
- free(authbuf);
- return ZAUTH_FAILED;
- }
- free(name);
- free(authbuf);
-
- /* HOLDING: authctx */
- /* Get an authenticator so we can get the keyblock */
- result = krb5_auth_con_getauthenticator (Z_krb5_ctx, authctx,
- &authenticator);
- if(result) {
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return result;
- }
-
- /* HOLDING: authctx, authenticator */
- result = krb5_auth_con_getkey(Z_krb5_ctx, authctx, &keyblock);
- if (result) {
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- return (ZAUTH_FAILED);
- }
-
- /* HOLDING: authctx, authenticator, keyblock */
- /* Figure out what checksum type to use */
- key_data = Z_keydata(keyblock);
- key_len = Z_keylen(keyblock);
- result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
- if (result) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- return (ZAUTH_FAILED);
+ result = krb_rd_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+ from->sin_addr.s_addr, &dat, srvtab_file);
+ if (result == RD_AP_OK) {
+ sprintf(srcprincipal, "%s%s%s@%s", dat.pname, dat.pinst[0] ? "." : "",
+ dat.pinst, dat.prealm);
+ if (strcmp(rlmprincipal, srcprincipal))
+ return ZAUTH_FAILED;
+ } else {
+ return ZAUTH_FAILED; /* didn't decode correctly */
}
- /* HOLDING: authctx, authenticator, keyblock */
-
- /* Assemble the things to be checksummed */
- /* first part is from start of packet through z_default_format:
- * - z_version
- * - z_num_other_fields
- * - z_kind
- * - z_uid
- * - z_port
- * - z_auth
- * - z_authent_len
- * - z_ascii_authent
- * - z_class
- * - z_class_inst
- * - z_opcode
- * - z_sender
- * - z_recipient
- * - z_default_format
- */
- cksum0_base = notice->z_packet;
- x = notice->z_default_format;
- cksum0_len = x + strlen(x) + 1 - cksum0_base;
- /* second part is from z_multinotice through other fields:
- * - z_multinotice
- * - z_multiuid
- * - z_other_fields[]
- */
- cksum1_base = notice->z_multinotice;
- if (notice->z_num_other_fields)
- x = notice->z_other_fields[notice->z_num_other_fields];
- else
- x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */
- cksum1_len = x + strlen(x) + 1 - cksum1_base;
-
- /* last part is the message body */
- cksum2_base = notice->z_message;
- cksum2_len = notice->z_message_len;
-
- if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
- key_len == 8 &&
- (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
- /* try old-format checksum (covers cksum0 only) */
-
- ZChecksum_t our_checksum;
-
- our_checksum = compute_rlm_checksum(notice, key_data);
-
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-
- if (our_checksum == notice->z_checksum) {
- return ZAUTH_YES;
- } else
- return ZAUTH_FAILED;
- }
-
- /* HOLDING: authctx, authenticator */
-
- cksumbuf.length = cksum0_len + cksum1_len + cksum2_len;
- cksumbuf.data = malloc(cksumbuf.length);
- if (!cksumbuf.data) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- return ZAUTH_FAILED;
- }
- /* HOLDING: authctx, authenticator, cksumbuf.data */
-
- memcpy(cksumbuf.data, cksum0_base, cksum0_len);
- memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
- cksum2_base, cksum2_len);
-
- /* decode zcoded checksum */
- /* The encoded form is always longer than the original */
- asn1_len = strlen(notice->z_ascii_checksum) + 1;
- asn1_data = malloc(asn1_len);
- if (!asn1_data) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- free(cksumbuf.data);
- return ZAUTH_FAILED;
- }
- /* HOLDING: authctx, authenticator, cksumbuf.data, asn1_data */
- result = ZReadZcode((unsigned char *)notice->z_ascii_checksum,
- asn1_data, asn1_len, &asn1_len);
- if (result != ZERR_NONE) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- free(asn1_data);
- free(cksumbuf.data);
- return ZAUTH_FAILED;
- }
- /* HOLDING: asn1_data, cksumbuf.data */
-
- valid = Z_krb5_verify_cksum(keyblock, &cksumbuf, cksumtype, asn1_data, asn1_len);
-
- free(asn1_data);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- free(cksumbuf.data);
-
- if (valid)
- return (ZAUTH_YES);
- else
- return (ZAUTH_FAILED);
-#else
- return (notice->z_auth) ? ZAUTH_YES : ZAUTH_NO;
-#endif
-}
-Code_t
-ZCheckAuthentication(ZNotice_t *notice,
- struct sockaddr_in *from)
-{
-#ifdef HAVE_KRB5
- unsigned char *authbuf;
- krb5_principal princ;
- krb5_data packet;
- krb5_ticket *tkt;
- char *name;
- krb5_error_code result;
- krb5_principal server;
- krb5_keytab keytabid = 0;
- krb5_auth_context authctx;
- krb5_keyblock *keyblock;
- krb5_enctype enctype;
- krb5_cksumtype cksumtype;
- krb5_data cksumbuf;
- int valid;
- char *cksum0_base, *cksum1_base, *cksum2_base;
- char *x;
- unsigned char *asn1_data, *key_data;
- int asn1_len, key_len, cksum0_len, cksum1_len, cksum2_len;
-#ifdef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
- krb5_authenticator *authenticator;
-#define KRB5AUTHENT authenticator
+ /* Check the cryptographic checksum. */
+#ifdef NOENCRYPTION
+ checksum = 0;
#else
- krb5_authenticator authenticator;
-#define KRB5AUTHENT &authenticator
+ checksum = compute_rlm_checksum(notice, dat.session);
#endif
- int len;
-
- if (!notice->z_auth)
- return ZAUTH_NO;
-
- /* Check for bogus authentication data length. */
- if (notice->z_authent_len <= 1)
- return ZAUTH_FAILED;
-
-#ifdef HAVE_KRB4
- if (notice->z_ascii_authent[0] != 'Z')
- return ZCheckAuthentication4(notice, from);
+ if (checksum != notice->z_checksum) {
+#ifndef NOENCRYPTION
+ checksum = compute_checksum(notice, dat.session);
+ if (checksum != notice->z_checksum)
#endif
-
- len = strlen(notice->z_ascii_authent)+1;
- authbuf = malloc(len);
-
- /* Read in the authentication data. */
- if (ZReadZcode((unsigned char *)notice->z_ascii_authent,
- authbuf,
- len, &len) == ZERR_BADFIELD) {
return ZAUTH_FAILED;
}
- packet.length = len;
- packet.data = (char *)authbuf;
-
- result = krb5_kt_resolve(Z_krb5_ctx,
- keytab_file, &keytabid);
- if (result) {
- free(authbuf);
- return (result);
- }
-
- /* HOLDING: authbuf, keytabid */
- /* Create the auth context */
- result = krb5_auth_con_init(Z_krb5_ctx, &authctx);
- if (result) {
- krb5_kt_close(Z_krb5_ctx, keytabid);
- free(authbuf);
- return (result);
- }
-
- /* HOLDING: authbuf, authctx */
- result = krb5_build_principal(Z_krb5_ctx, &server, strlen(__Zephyr_realm),
- __Zephyr_realm, SERVER_SERVICE,
- SERVER_INSTANCE, NULL);
- if (!result) {
- result = krb5_rd_req(Z_krb5_ctx, &authctx, &packet, server,
- keytabid, 0, &tkt);
- krb5_free_principal(Z_krb5_ctx, server);
- }
- krb5_kt_close(Z_krb5_ctx, keytabid);
-
- if (result) {
- if (result == KRB5KRB_AP_ERR_REPEAT)
- syslog(LOG_DEBUG, "ZCheckAuthentication: k5 auth failed: %s", error_message(result));
- else
- syslog(LOG_WARNING,"ZCheckAuthentication: k5 auth failed: %s", error_message(result));
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return ZAUTH_FAILED;
- }
-
- /* HOLDING: authbuf, authctx, tkt */
-
- if (tkt == 0 || !Z_tktprincp(tkt)) {
- if (tkt)
- krb5_free_ticket(Z_krb5_ctx, tkt);
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return ZAUTH_FAILED;
- }
- princ = Z_tktprinc(tkt);
-
- if (princ == 0) {
- krb5_free_ticket(Z_krb5_ctx, tkt);
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return ZAUTH_FAILED;
- }
-
- /* HOLDING: authbuf, authctx, tkt */
- result = krb5_unparse_name(Z_krb5_ctx, princ, &name);
- if (result) {
- syslog(LOG_WARNING, "k5 unparse_name failed: %s",
- error_message(result));
- free(authbuf);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_ticket(Z_krb5_ctx, tkt);
- return ZAUTH_FAILED;
- }
-
- krb5_free_ticket(Z_krb5_ctx, tkt);
-
- /* HOLDING: authbuf, authctx, name */
- if (strcmp(name, notice->z_sender)) {
- syslog(LOG_WARNING, "k5 name mismatch: '%s' vs '%s'",
- name, notice->z_sender);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- free(name);
- free(authbuf);
- return ZAUTH_FAILED;
- }
- free(name);
- free(authbuf);
-
- /* HOLDING: authctx */
- /* Get an authenticator so we can get the keyblock */
- result = krb5_auth_con_getauthenticator (Z_krb5_ctx, authctx,
- &authenticator);
- if(result) {
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- return result;
- }
+ return ZAUTH_YES;
- /* HOLDING: authctx, authenticator */
- result = krb5_auth_con_getkey(Z_krb5_ctx, authctx, &keyblock);
- if (result) {
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- return (ZAUTH_FAILED);
- }
-
- /* HOLDING: authctx, authenticator, keyblock */
- /* Figure out what checksum type to use */
- key_data = Z_keydata(keyblock);
- key_len = Z_keylen(keyblock);
- result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
- if (result) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- return (ZAUTH_FAILED);
- }
- /* HOLDING: authctx, authenticator, keyblock */
-
- ZSetSession(keyblock);
-
- /* Assemble the things to be checksummed */
- /* first part is from start of packet through z_default_format:
- * - z_version
- * - z_num_other_fields
- * - z_kind
- * - z_uid
- * - z_port
- * - z_auth
- * - z_authent_len
- * - z_ascii_authent
- * - z_class
- * - z_class_inst
- * - z_opcode
- * - z_sender
- * - z_recipient
- * - z_default_format
- */
- cksum0_base = notice->z_packet;
- x = notice->z_default_format;
- cksum0_len = x + strlen(x) + 1 - cksum0_base;
- /* second part is from z_multinotice through other fields:
- * - z_multinotice
- * - z_multiuid
- * - z_other_fields[]
- */
- cksum1_base = notice->z_multinotice;
- if (notice->z_num_other_fields)
- x = notice->z_other_fields[notice->z_num_other_fields];
- else
- x = cksum1_base + strlen(cksum1_base) + 1; /* multiuid */
- cksum1_len = x + strlen(x) + 1 - cksum1_base;
-
- /* last part is the message body */
- cksum2_base = notice->z_message;
- cksum2_len = notice->z_message_len;
-
- if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
- key_len == 8 &&
- (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
- /* try old-format checksum (covers cksum0 only) */
-
- ZChecksum_t our_checksum;
-
- our_checksum = compute_checksum(notice, key_data);
-
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
-
- if (our_checksum == notice->z_checksum)
- return ZAUTH_YES;
- else
- return ZAUTH_FAILED;
- }
-
- /* HOLDING: authctx, authenticator */
-
- cksumbuf.length = cksum0_len + cksum1_len + cksum2_len;
- cksumbuf.data = malloc(cksumbuf.length);
- if (!cksumbuf.data) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- return ZAUTH_FAILED;
- }
- /* HOLDING: authctx, authenticator, cksumbuf.data */
-
- memcpy(cksumbuf.data, cksum0_base, cksum0_len);
- memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
- cksum2_base, cksum2_len);
-
- /* decode zcoded checksum */
- /* The encoded form is always longer than the original */
- asn1_len = strlen(notice->z_ascii_checksum) + 1;
- asn1_data = malloc(asn1_len);
- if (!asn1_data) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- free(cksumbuf.data);
- return ZAUTH_FAILED;
- }
- /* HOLDING: authctx, authenticator, cksumbuf.data, asn1_data */
- result = ZReadZcode((unsigned char *)notice->z_ascii_checksum,
- asn1_data, asn1_len, &asn1_len);
- if (result != ZERR_NONE) {
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- free(asn1_data);
- free(cksumbuf.data);
- return ZAUTH_FAILED;
- }
- /* HOLDING: asn1_data, cksumbuf.data, authctx, authenticator */
-
- valid = Z_krb5_verify_cksum(keyblock, &cksumbuf, cksumtype, asn1_data, asn1_len);
-
- free(asn1_data);
- krb5_auth_con_free(Z_krb5_ctx, authctx);
- krb5_free_authenticator(Z_krb5_ctx, KRB5AUTHENT);
- krb5_free_keyblock(Z_krb5_ctx, keyblock);
- free(cksumbuf.data);
-
- if (valid)
- return (ZAUTH_YES);
- else
- return (ZAUTH_FAILED);
-#else
+#else /* !HAVE_KRB4 */
return (notice->z_auth) ? ZAUTH_YES : ZAUTH_NO;
#endif
}
-#undef KRB5AUTHENT
-
-static Code_t
-ZCheckAuthentication4(ZNotice_t *notice,
- struct sockaddr_in *from)
+Code_t
+ZCheckAuthentication(notice, from)
+ ZNotice_t *notice;
+ struct sockaddr_in *from;
{
#ifdef HAVE_KRB4
int result;
char srcprincipal[ANAME_SZ+INST_SZ+REALM_SZ+4];
- KTEXT_ST authent;
+ KTEXT_ST authent, ticket;
AUTH_DAT dat;
ZChecksum_t checksum;
- char instance[INST_SZ+1];
+ C_Block session_key;
if (!notice->z_auth)
return ZAUTH_NO;
}
authent.length = notice->z_authent_len;
- strcpy(instance, SERVER_INSTANCE);
-
- /* We don't have the session key cached; do it the long way. */
- result = krb_rd_req(&authent, SERVER_SERVICE, instance,
+ result = krb_rd_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
from->sin_addr.s_addr, &dat, srvtab_file);
if (result == RD_AP_OK) {
- ZSetSessionDES(&dat.session);
+ memcpy(__Zephyr_session, dat.session, sizeof(C_Block));
sprintf(srcprincipal, "%s%s%s@%s", dat.pname, dat.pinst[0] ? "." : "",
dat.pinst, dat.prealm);
if (strcmp(srcprincipal, notice->z_sender))
}
/* Check the cryptographic checksum. */
+#ifdef NOENCRYPTION
+ checksum = 0;
+#else
checksum = compute_checksum(notice, dat.session);
-
+#endif
if (checksum != notice->z_checksum)
return ZAUTH_FAILED;
#endif
}
-
#ifdef HAVE_KRB4
-static ZChecksum_t
-compute_checksum(ZNotice_t *notice,
- C_Block session_key)
+
+static int hash_ticket(p, len)
+ unsigned char *p;
+ int len;
+{
+ unsigned long hashval = 0, g;
+
+ for (; len > 0; p++, len--) {
+ hashval = (hashval << 4) + *p;
+ g = hashval & 0xf0000000;
+ if (g) {
+ hashval ^= g >> 24;
+ hashval ^= g;
+ }
+ }
+ return hashval % HASHTAB_SIZE;
+}
+
+static void add_session_key(ticket, session_key, srcprincipal, expires)
+ KTEXT ticket;
+ C_Block session_key;
+ char *srcprincipal;
+ time_t expires;
+{
+ Hash_entry *entry;
+ int hashval;
+
+ /* If we can't allocate memory for the hash table entry, just forget
+ * about it. */
+ entry = (Hash_entry *) malloc(sizeof(Hash_entry) - 1 + ticket->length);
+ if (!entry)
+ return;
+
+ /* Initialize the new entry. */
+ memcpy(entry->session_key, session_key, sizeof(entry->session_key));
+ strcpy(entry->srcprincipal, srcprincipal);
+ entry->expires = expires;
+ entry->ticket_len = ticket->length;
+ memcpy(entry->ticket, ticket->dat, ticket->length * sizeof(unsigned char));
+
+ /* Insert the new entry in the hash table. */
+ hashval = hash_ticket(ticket->dat, ticket->length);
+ entry->next = hashtab[hashval];
+ hashtab[hashval] = entry;
+}
+
+static int find_session_key(ticket, key, srcprincipal)
+ KTEXT ticket;
+ C_Block key;
+ char *srcprincipal;
+{
+ unsigned char *dat;
+ int hashval, len;
+ Hash_entry *entry;
+
+ dat = ticket->dat;
+ len = ticket->length;
+ hashval = hash_ticket(dat, len);
+
+ for (entry = hashtab[hashval]; entry; entry = entry->next) {
+ if (entry->ticket_len == len && memcmp(entry->ticket, dat, len) == 0) {
+ memcpy(key, entry->session_key, sizeof(entry->session_key));
+ strcpy(srcprincipal, entry->srcprincipal);
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static ZChecksum_t compute_checksum(notice, session_key)
+ ZNotice_t *notice;
+ C_Block session_key;
{
+#ifdef NOENCRYPTION
+ return 0;
+#else
ZChecksum_t checksum;
char *cstart, *cend, *hstart = notice->z_packet, *hend = notice->z_message;
cstart = notice->z_default_format + strlen(notice->z_default_format) + 1;
cend = cstart + strlen(cstart) + 1;
- checksum = des_quad_cksum((unsigned char *)hstart, NULL, cstart - hstart, 0, (C_Block *)session_key);
- checksum ^= des_quad_cksum((unsigned char *)cend, NULL, hend - cend, 0, (C_Block *)session_key);
- checksum ^= des_quad_cksum((unsigned char *)notice->z_message, NULL, notice->z_message_len,
- 0, (C_Block *)session_key);
+ checksum = des_quad_cksum(hstart, NULL, cstart - hstart, 0, session_key);
+ checksum ^= des_quad_cksum(cend, NULL, hend - cend, 0, session_key);
+ checksum ^= des_quad_cksum(notice->z_message, NULL, notice->z_message_len,
+ 0, session_key);
return checksum;
+#endif
}
-static ZChecksum_t compute_rlm_checksum(ZNotice_t *notice,
- C_Block session_key)
+static ZChecksum_t compute_rlm_checksum(notice, session_key)
+ ZNotice_t *notice;
+ C_Block session_key;
{
+#ifdef NOENCRYPTION
+ return 0;
+#else
ZChecksum_t checksum;
- char *cstart, *cend, *hstart = notice->z_packet;
+ char *cstart, *cend, *hstart = notice->z_packet, *hend = notice->z_message;
cstart = notice->z_default_format + strlen(notice->z_default_format) + 1;
cend = cstart + strlen(cstart) + 1;
- checksum = des_quad_cksum((unsigned char *)hstart, NULL, cstart - hstart, 0, (C_Block *)session_key);
-
+ checksum = des_quad_cksum(hstart, NULL, cstart - hstart, 0, session_key);
return checksum;
-}
-
-#ifdef HAVE_KRB5
-krb5_error_code
-Z_krb5_init_keyblock(krb5_context context,
- krb5_enctype type,
- size_t size,
- krb5_keyblock **key)
-{
-#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
- return krb5_init_keyblock(context, type, size, key);
-#else
- krb5_error_code ret;
- krb5_keyblock *tmp, tmp_ss;
- tmp = &tmp_ss;
-
- *key = NULL;
- Z_enctype(tmp) = type;
- Z_keylen(tmp) = size;
- Z_keydata(tmp) = malloc(size);
- if (!Z_keydata(tmp))
- return ENOMEM;
- ret = krb5_copy_keyblock(context, tmp, key);
- free(Z_keydata(tmp));
- return ret;
#endif
}
-void
-ZSetSession(krb5_keyblock *keyblock) {
- krb5_error_code result;
-
- if (__Zephyr_keyblock) {
- krb5_free_keyblock_contents(Z_krb5_ctx, __Zephyr_keyblock);
- result = krb5_copy_keyblock_contents(Z_krb5_ctx, keyblock, __Zephyr_keyblock);
- } else {
- result = krb5_copy_keyblock(Z_krb5_ctx, keyblock, &__Zephyr_keyblock);
+void sweep_ticket_hash_table(arg)
+ void *arg;
+{
+ int i;
+ Hash_entry **ptr, *entry;
+
+ for (i = 0; i < HASHTAB_SIZE; i++) {
+ ptr = &hashtab[i];
+ while (*ptr) {
+ entry = *ptr;
+ if (entry->expires < NOW) {
+ *ptr = entry->next;
+ free(entry);
+ } else {
+ ptr = &(*ptr)->next;
+ }
+ }
}
-
- if (result) /*XXX we're out of memory? */
- ;
-}
-#endif
-#ifdef HAVE_KRB4
-void
-ZSetSessionDES(C_Block *key) {
-#ifdef HAVE_KRB5
- Code_t result;
- if (__Zephyr_keyblock) {
- krb5_free_keyblock(Z_krb5_ctx, __Zephyr_keyblock);
- __Zephyr_keyblock=NULL;
- }
- result = Z_krb5_init_keyblock(Z_krb5_ctx, ENCTYPE_DES_CBC_CRC,
- sizeof(C_Block),
- &__Zephyr_keyblock);
- if (result) /*XXX we're out of memory? */
- return;
-
- memcpy(Z_keydata(__Zephyr_keyblock), key, sizeof(C_Block));
-#else
- memcpy(__Zephyr_session, key, sizeof(C_Block));
-#endif
+ timer_set_rel(SWEEP_INTERVAL, sweep_ticket_hash_table, NULL);
}
-#endif
#endif /* HAVE_KRB4 */
#define EVER (;;) /* don't stop looping */
-static int do_net_setup(void);
-static int initialize(void);
-static void usage(void);
-static void do_reset(void);
-static RETSIGTYPE bye(int);
-static RETSIGTYPE dbug_on(int);
-static RETSIGTYPE dbug_off(int);
-static RETSIGTYPE sig_dump_db(int);
-static RETSIGTYPE reset(int);
-static RETSIGTYPE reap(int);
-static void read_from_dump(char *dumpfile);
-static void dump_db(void);
-static void dump_strings(void);
+static int do_net_setup __P((void));
+static int initialize __P((void));
+static void usage __P((void));
+static void do_reset __P((void));
+static RETSIGTYPE bye __P((int));
+static RETSIGTYPE dbug_on __P((int));
+static RETSIGTYPE dbug_off __P((int));
+static RETSIGTYPE sig_dump_db __P((int));
+static RETSIGTYPE sig_dump_strings __P((int));
+static RETSIGTYPE reset __P((int));
+static RETSIGTYPE reap __P((int));
+static void read_from_dump __P((char *dumpfile));
+static void dump_db __P((void));
+static void dump_strings __P((void));
#ifndef DEBUG
-static void detach(void);
+static void detach __P((void));
#endif
static short doreset = 0; /* if it becomes 1, perform
char myname[MAXHOSTNAMELEN]; /* my host name */
char list_file[128];
-#ifdef HAVE_KRB5
-char keytab_file[128];
-static char tkt5_file[256];
-#endif
#ifdef HAVE_KRB4
char srvtab_file[128];
char my_realm[REALM_SZ];
struct in_addr my_addr;
char *bdump_version = "1.2";
-#ifdef HAVE_KRB5
-int bdump_auth_proto = 5;
-#else /* HAVE_KRB5 */
-#ifdef HAVE_KRB4
-int bdump_auth_proto = 4;
-#else /* HAVE_KRB4 */
-int bdump_auth_proto = 0;
-#endif /* HAVE_KRB4 */
-#endif /* HAVE_KRB5 */
-
-#ifdef HAVE_KRB5
-krb5_ccache Z_krb5_ccache;
-krb5_keyblock *__Zephyr_keyblock;
-#else
-#ifdef HAVE_KRB4
-C_Block __Zephyr_session;
-#endif
-#endif
-
int
-main(int argc,
- char **argv)
+main(argc, argv)
+ int argc;
+ char **argv;
{
int nfound; /* #fildes ready on select */
fd_set readable;
#ifdef HAVE_KRB4
sprintf(srvtab_file, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_SRVTAB);
sprintf(tkt_file, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_TKFILE);
-#endif
-#ifdef HAVE_KRB5
- sprintf(keytab_file, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_KEYTAB);
- sprintf(tkt5_file, "FILE:%s/zephyr/%s", SYSCONFDIR, ZEPHYR_TK5FILE);
#endif
sprintf(acl_dir, "%s/zephyr/%s", SYSCONFDIR, ZEPHYR_ACL_DIR);
sprintf(subs_file, "%s/zephyr/%s", SYSCONFDIR, DEFAULT_SUBS_FILE);
programname = (programname) ? programname + 1 : argv[0];
/* process arguments */
- while ((optchar = getopt(argc, argv, "dsnv4f:k:")) != EOF) {
+ while ((optchar = getopt(argc, argv, "dsnv:f:k:")) != EOF) {
switch(optchar) {
case 'd':
zdebug = 1;
init_from_dump = 0;
dumpfile = optarg;
break;
- case '4':
- bdump_auth_proto = 4;
- break;
case '?':
default:
usage();
if (zalone)
syslog(LOG_DEBUG, "standalone operation");
#endif
+#if 0
if (zdebug)
syslog(LOG_DEBUG, "debugging on");
+#endif
/* set up sockets & my_addr and myname,
find other servers and set up server table, initialize queues
/* Reinitialize t_local now that initialization is done. */
gettimeofday(&t_local, NULL);
uptime = NOW;
+#ifdef HAVE_KRB4
+ timer_set_rel(SWEEP_INTERVAL, sweep_ticket_hash_table, NULL);
+#endif
realm_wakeup();
#ifdef DEBUG_MALLOC
*/
static int
-initialize(void)
+initialize()
{
if (do_net_setup())
return(1);
ZSetServerState(1);
ZInitialize(); /* set up the library */
-#ifdef HAVE_KRB5
- krb5_cc_resolve(Z_krb5_ctx, tkt5_file, &Z_krb5_ccache);
-#ifdef HAVE_KRB5_CC_SET_DEFAULT_NAME
- krb5_cc_set_default_name(Z_krb5_ctx, tkt5_file);
-#else
- {
- /* Hack to make krb5_cc_default do something reasonable */
- char *env=(char *)malloc(strlen(tkt5_file)+12);
- if (!env) return(1);
- sprintf(env, "KRB5CCNAME=%s", tkt5_file);
- putenv(env);
- }
-#endif
-#endif
#ifdef HAVE_KRB4
/* Override what Zinitialize set for ZGetRealm() */
if (*my_realm)
*/
static int
-do_net_setup(void)
+do_net_setup()
{
struct servent *sp;
struct hostent *hp;
if (srv_socket < 0) {
syslog(LOG_ERR, "client_sock failed: %m");
return 1;
- } else {
-#ifdef SO_BSDCOMPAT
- int on = 1;
-
- /* Prevent Linux from giving us socket errors we don't care about. */
- setsockopt(srv_socket, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
-#endif
}
if (bind(srv_socket, (struct sockaddr *) &srv_addr,
sizeof(srv_addr)) < 0) {
*/
static void
-usage(void)
+usage()
{
#ifdef DEBUG
fprintf(stderr, "Usage: %s [-d] [-s] [-n] [-k realm] [-f dumpfile]\n",
}
int
-packets_waiting(void)
+packets_waiting()
{
fd_set readable, initial;
struct timeval tv;
}
static RETSIGTYPE
-bye(int sig)
+bye(sig)
+ int sig;
{
server_shutdown(); /* tell other servers */
#ifdef REALM_MGMT
}
static RETSIGTYPE
-dbug_on(int sig)
+dbug_on(sig)
+ int sig;
{
syslog(LOG_DEBUG, "debugging turned on");
#ifdef DEBUG_MALLOC
}
static RETSIGTYPE
-dbug_off(int sig)
+dbug_off(sig)
+ int sig;
{
syslog(LOG_DEBUG, "debugging turned off");
#ifdef DEBUG_MALLOC
int fork_for_dump = 0;
-static void dump_strings(void)
+static RETSIGTYPE
+sig_dump_strings(sig)
+ int sig;
+{
+ dump_strings_flag = 1;
+}
+
+static void dump_strings()
{
char filename[128];
}
static RETSIGTYPE
-sig_dump_db(int sig)
+sig_dump_db(sig)
+ int sig;
{
dump_db_flag = 1;
}
-static void
-dump_db(void)
+static void dump_db()
{
/* dump the in-core database to human-readable form on disk */
FILE *fp;
}
static RETSIGTYPE
-reset(int sig)
+reset(sig)
+ int sig;
{
+#if 1
zdbug((LOG_DEBUG,"reset()"));
+#endif
doreset = 1;
}
static RETSIGTYPE
-reap(int sig)
+reap(sig)
+ int sig;
{
int pid, i = 0;
int oerrno = errno;
- ZRealm *rlm;
+ Realm *rlm;
#ifdef _POSIX_VERSION
int waitb;
#else
union wait waitb;
#endif
-
+#if 1
zdbug((LOG_DEBUG,"reap()"));
+#endif
#ifdef _POSIX_VERSION
while ((pid = waitpid(-1, &waitb, WNOHANG)) == 0)
{ i++; if (i > 10) break; }
}
static void
-do_reset(void)
+do_reset()
{
int oerrno = errno;
#ifdef _POSIX_VERSION
#else
int omask;
#endif
+#if 0
+ zdbug((LOG_DEBUG,"do_reset()"));
+#endif
#ifdef _POSIX_VERSION
sigemptyset(&mask);
sigaddset(&mask, SIGHUP);
*/
static void
-detach(void)
+detach()
{
/* detach from terminal and fork. */
int i;
#endif /* not DEBUG */
static void
-read_from_dump(char *dumpfile)
+read_from_dump(dumpfile)
+ char *dumpfile;
{
/* Not yet implemented. */
return;
Unacked *rlm_nacklist = NULL; /* not acked list for realm-realm
packets */
-ZRealm *otherrealms; /* points to an array of the known
+Realm *otherrealms; /* points to an array of the known
servers */
int nrealms = 0; /* number of other realms */
/*
* External Routines:
*
- * ZRealm *realm_which_realm(struct sockaddr_in *who)
+ * Realm *realm_which_realm(struct sockaddr_in *who)
* figures out if this packet came from another realm's server
*
- * ZRealm *realm_get_realm_by_pid(int pid)
+ * Realm *realm_get_realm_by_pid(int pid)
* figures out which realm a child handler was for
*
* void kill_realm_pids()
* int realm_sender_in_realm(char *realm, char *sender)
* figures out if sender is in realm
*
- * ZRealm *realm_get_realm_by_name(char *name)
+ * Realm *realm_get_realm_by_name(char *name)
* finds a realm struct from the realm array by name, tries expansion
*
* Code_t realm_dispatch(ZNotice_t *notice, int auth, struct sockaddr_in *who,
*
* Code_t realm_control_dispatch(ZNotice_t *notice, int auth,
* struct sockaddr_in *who, Server *server,
- * ZRealm *realm)
+ * Realm *realm)
* dispatches a foreign realm control message
*
* void realm_handoff(ZNotice_t *notice, int auth, struct sockaddr_in *who,
- * ZRealm *realm, int ack_to_sender)
+ * Realm *realm, int ack_to_sender)
* hands off a message to another realm
*
* void realm_dump_realms(File *fp)
* do a database dump of foreign realm info
*
*/
-static void realm_sendit(ZNotice_t *notice, struct sockaddr_in *who, int auth, ZRealm *realm, int ack_to_sender);
-static Code_t realm_sendit_auth(ZNotice_t *notice, struct sockaddr_in *who, int auth, ZRealm *realm, int ack_to_sender);
-static void rlm_ack(ZNotice_t *notice, Unacked *nacked);
-static void rlm_nack_cancel(ZNotice_t *notice, struct sockaddr_in *who);
-static void rlm_rexmit(void *arg);
-static Code_t realm_ulocate_dispatch(ZNotice_t *notice,int auth,struct sockaddr_in *who,Server *server,ZRealm *realm);
-static Code_t realm_new_server(struct sockaddr_in *, ZNotice_t *, ZRealm *);
-static Code_t realm_set_server(struct sockaddr_in *, ZRealm *);
+static void realm_sendit __P((ZNotice_t *notice, struct sockaddr_in *who, int auth, Realm *realm, int ack_to_sender));
+static void realm_sendit_auth __P((ZNotice_t *notice, struct sockaddr_in *who, int auth, Realm *realm, int ack_to_sender));
+static void rlm_ack __P((ZNotice_t *notice, Unacked *nacked));
+static void rlm_nack_cancel __P((ZNotice_t *notice, struct sockaddr_in *who));
+static void rlm_new_ticket __P(());
+static void rlm_rexmit __P((void *arg));
+static Code_t realm_ulocate_dispatch __P((ZNotice_t *notice,int auth,struct sockaddr_in *who,Server *server,Realm *realm));
+static Code_t realm_new_server __P((struct sockaddr_in *, ZNotice_t *, Realm *));
+static Code_t realm_set_server __P((struct sockaddr_in *, Realm *));
#ifdef HAVE_KRB4
-static Code_t ticket_retrieve(ZRealm *realm);
-static int ticket_lookup(char *realm);
+static Code_t ticket_retrieve __P((Realm *realm));
+static int ticket_lookup __P((char *realm));
+static int ticket_expired __P((CREDENTIALS *cred));
#endif
static int
-realm_get_idx_by_addr(ZRealm *realm,
- struct sockaddr_in *who)
+realm_get_idx_by_addr(realm, who)
+ Realm *realm;
+ struct sockaddr_in *who;
{
struct sockaddr_in *addr;
- int b;
+ int a, b;
/* loop through the realms */
for (addr = realm->addrs, b = 0; b < realm->count; b++, addr++)
}
char *
-realm_expand_realm(char *realmname)
+realm_expand_realm(realmname)
+char *realmname;
{
- ZRealm *realm;
+ Realm *realm;
int a;
/* First, look for an exact match (case insensitive) */
return(realmname);
}
-ZRealm *
-realm_get_realm_by_pid(int pid)
+Realm *
+realm_get_realm_by_pid(pid)
+ int pid;
{
- ZRealm *realm;
+ Realm *realm;
int a;
for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
}
void
-kill_realm_pids(void)
+kill_realm_pids()
{
- ZRealm *realm;
+ Realm *realm;
int a;
for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
return;
}
-ZRealmname *
-get_realm_lists(char *file)
+Realmname *
+get_realm_lists(file)
+ char *file;
{
- ZRealmname *rlm_list, *rlm;
+ Realmname *rlm_list, *rlm;
int ii, nused, ntotal;
FILE *fp;
char buf[REALM_SZ + MAXHOSTNAMELEN + 1]; /* one for newline */
nused = 0;
if (!(fp = fopen(file, "r")))
- return((ZRealmname *)0);
+ return((Realmname *)0);
/* start with 16, realloc if necessary */
ntotal = 16;
- rlm_list = (ZRealmname *)malloc(ntotal * sizeof(ZRealmname));
+ rlm_list = (Realmname *)malloc(ntotal * sizeof(Realmname));
if (!rlm_list) {
syslog(LOG_CRIT, "get_realm_lists malloc");
abort();
/* new realm */
if (nused + 1 >= ntotal) {
/* make more space */
- rlm_list = (ZRealmname *)realloc((char *)rlm_list,
+ rlm_list = (Realmname *)realloc((char *)rlm_list,
(unsigned)ntotal * 2 *
- sizeof(ZRealmname));
+ sizeof(Realmname));
if (!rlm_list) {
syslog(LOG_CRIT, "get_realm_lists realloc");
abort();
}
}
if (nused + 1 >= ntotal) {
- rlm_list = (ZRealmname *)realloc((char *)rlm_list,
+ rlm_list = (Realmname *)realloc((char *)rlm_list,
(unsigned)(ntotal + 1) *
- sizeof(ZRealmname));
+ sizeof(Realmname));
if (!rlm_list) {
syslog(LOG_CRIT, "get_realm_lists realloc");
abort();
}
*rlm_list[nused].name = '\0';
- fclose(fp);
return(rlm_list);
}
Code_t
-realm_send_realms(void)
+realm_send_realms()
{
int cnt, retval;
for (cnt = 0; cnt < nrealms; cnt++) {
- retval = subscr_send_realm_subs(&otherrealms[cnt]);
- if (retval != ZERR_NONE)
+ if (retval = (subscr_send_realm_subs(&otherrealms[cnt])) != ZERR_NONE)
return(retval);
}
- return ZERR_NONE;
}
int
-realm_bound_for_realm(char *realm, char *recip)
+realm_bound_for_realm(realm, recip)
+ char *realm;
+ char *recip;
{
char *rlm = NULL;
int remote = strcmp(ZGetRealm(), realm);
}
int
-realm_sender_in_realm(char *realm, char *sender)
+realm_sender_in_realm(realm, sender)
+ char *realm;
+ char *sender;
{
char *rlm = NULL;
int remote = strcmp(ZGetRealm(), realm);
return 0;
}
-int sender_in_realm(ZNotice_t *notice)
+sender_in_realm(notice)
+ ZNotice_t *notice;
{
char *realm;
return 0;
}
-ZRealm *
-realm_which_realm(struct sockaddr_in *who)
+Realm *
+realm_which_realm(who)
+ struct sockaddr_in *who;
{
- ZRealm *realm;
+ Realm *realm;
struct sockaddr_in *addr;
int a, b;
return 0;
}
-ZRealm *
-realm_get_realm_by_name(char *name)
+Realm *
+realm_get_realm_by_name(name)
+ char *name;
{
int a;
- ZRealm *realm;
+ Realm *realm;
/* First, look for an exact match (case insensitive) */
for (realm = otherrealms, a = 0; a < nrealms; a++, realm++)
}
static void
-rlm_nack_cancel(register ZNotice_t *notice,
- struct sockaddr_in *who)
+rlm_nack_cancel(notice, who)
+ register ZNotice_t *notice;
+ struct sockaddr_in *who;
{
- register ZRealm *which = realm_which_realm(who);
- register Unacked *nacked;
+ register Realm *which = realm_which_realm(who);
+ register Unacked *nacked, *next;
+ ZPacket_t retval;
+#if 1
zdbug((LOG_DEBUG, "rlm_nack_cancel: %s:%08X,%08X",
inet_ntoa(notice->z_uid.zuid_addr),
notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
-
+#endif
if (!which) {
syslog(LOG_ERR, "non-realm ack?");
return;
/* free the data */
free(nacked->packet);
- Unacked_delete(nacked);
+ LIST_DELETE(nacked);
free(nacked);
return;
}
}
}
+#if 0
+ zdbug((LOG_DEBUG,"nack_cancel: nack not found %s:%08X,%08X",
+ inet_ntoa (notice->z_uid.zuid_addr),
+ notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec));
+#endif
return;
}
static void
-rlm_ack(ZNotice_t *notice,
- Unacked *nacked)
+rlm_ack(notice, nacked)
+ ZNotice_t *notice;
+ Unacked *nacked;
{
ZNotice_t acknotice;
ZPacket_t ackpack;
}
Code_t
-realm_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+realm_dispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
- ZRealm *realm;
+ Realm *realm;
struct sockaddr_in newwho;
Code_t status = ZERR_NONE;
char rlm_recipient[REALM_SZ + 1];
}
void
-realm_init(void)
+realm_init()
{
Client *client;
- ZRealmname *rlmnames;
- ZRealm *rlm;
+ Realmname *rlmnames;
+ Realm *rlm;
int ii, jj, found;
struct in_addr *addresses;
struct hostent *hp;
for (nrealms = 0; *rlmnames[nrealms].name; nrealms++);
- otherrealms = (ZRealm *)malloc(nrealms * sizeof(ZRealm));
+ otherrealms = (Realm *)malloc(nrealms * sizeof(Realm));
if (!otherrealms) {
syslog(LOG_CRIT, "malloc failed in realm_init");
abort();
abort();
}
memset(&client->addr, 0, sizeof(struct sockaddr_in));
-#ifdef HAVE_KRB5
- client->session_keyblock = NULL;
-#else
#ifdef HAVE_KRB4
memset(&client->session_key, 0, sizeof(client->session_key));
-#endif
#endif
sprintf(rlmprinc, "%s.%s@%s", SERVER_SERVICE, SERVER_INSTANCE,
rlm->name);
}
void
-realm_deathgram(Server *server)
+realm_deathgram(server)
+ Server *server;
{
- ZRealm *realm;
+ Realm *realm;
+ char rlm_recipient[REALM_SZ + 1];
int jj = 0;
/* Get it out once, and assume foreign servers will share */
zdbug((LOG_DEBUG, "rlm_deathgram: suggesting %s to %s",
(server) ? server->addr_str : "nothing", realm->name));
-#ifdef HAVE_KRB5
+#ifdef HAVE_KRB4
if (!ticket_lookup(realm->name))
if ((retval = ticket_retrieve(realm)) != ZERR_NONE) {
syslog(LOG_WARNING, "rlm_deathgram failed: %s",
}
#endif
- if ((retval = ZFormatNotice(&snotice, &pack, &packlen, ZCAUTH))
+ if ((retval = ZFormatNotice(&snotice, &pack, &packlen, ZAUTH))
!= ZERR_NONE)
{
syslog(LOG_WARNING, "rlm_deathgram format: %s",
}
void
-realm_wakeup(void)
+realm_wakeup()
{
int jj, found = 0;
- ZRealm *realm;
+ Realm *realm;
+ char rlm_recipient[REALM_SZ + 1];
for (jj = 1; jj < nservers; jj++) { /* skip limbo server */
if (jj != me_server_idx && otherservers[jj].state == SERV_UP)
snotice.z_message = NULL;
snotice.z_message_len = 0;
-#ifdef HAVE_KRB5
+#ifdef HAVE_KRB4
if (!ticket_lookup(realm->name))
if ((retval = ticket_retrieve(realm)) != ZERR_NONE) {
syslog(LOG_WARNING, "rlm_wakeup failed: %s",
}
static Code_t
-realm_ulocate_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server,
- ZRealm *realm)
+realm_ulocate_dispatch(notice, auth, who, server, realm)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
+ Realm *realm;
{
register char *opcode = notice->z_opcode;
+ Code_t status;
if (!auth) {
syslog(LOG_WARNING, "unauth locate msg from %s (%s/%s/%s)",
inet_ntoa(who->sin_addr),
notice->z_class, notice->z_class_inst,
notice->z_opcode); /* XXX */
+#if 0
+ syslog(LOG_WARNING, "unauth locate msg from %s",
+ inet_ntoa(who->sin_addr));
+#endif
clt_ack(notice, who, AUTH_FAILED);
return(ZERR_NONE);
}
Code_t
-realm_control_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server,
- ZRealm *realm)
+realm_control_dispatch(notice, auth, who, server, realm)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
+ Realm *realm;
{
register char *opcode = notice->z_opcode;
Code_t status;
inet_ntoa(who->sin_addr),
notice->z_class, notice->z_class_inst,
notice->z_opcode); /* XXX */
+#if 0
+ syslog(LOG_WARNING, "unauth ctl msg from %s",
+ inet_ntoa(who->sin_addr));
+#endif
if (server == me_server)
clt_ack(notice, who, AUTH_FAILED);
return(ZERR_NONE);
}
static Code_t
-realm_new_server(struct sockaddr_in *sin,
- ZNotice_t *notice,
- ZRealm *realm)
+realm_new_server(sin, notice, realm)
+ struct sockaddr_in *sin;
+ ZNotice_t *notice;
+ Realm *realm;
{
+ struct hostent *hp;
+ char suggested_server[MAXHOSTNAMELEN];
unsigned long addr;
- ZRealm *rlm;
+ Realm *rlm;
struct sockaddr_in sinaddr;
int srvidx;
} else {
zdbug((LOG_DEBUG, "rlm_new_srv: not switching servers (%s)", inet_ntoa((realm->addrs[realm->idx]).sin_addr)));
}
- return 0;
}
static Code_t
-realm_set_server(struct sockaddr_in *sin,
- ZRealm *realm)
+realm_set_server(sin, realm)
+ struct sockaddr_in *sin;
+ Realm *realm;
{
- ZRealm *rlm;
+ Realm *rlm;
rlm = realm_which_realm(sin);
/* Not exactly */
return ZSRV_NORLM;
realm->idx = realm_get_idx_by_addr(realm, sin);
zdbug((LOG_DEBUG, "rlm_pick_srv: switched servers (%s)", inet_ntoa((realm->addrs[realm->idx]).sin_addr)));
-
- return 0;
}
void
-realm_handoff(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- ZRealm *realm,
- int ack_to_sender)
+realm_handoff(notice, auth, who, realm, ack_to_sender)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Realm *realm;
+ int ack_to_sender;
{
-#ifdef HAVE_KRB5
+#ifdef HAVE_KRB4
Code_t retval;
if (!auth) {
zdbug((LOG_DEBUG, "realm_sendit to realm %s auth %d", realm->name, auth));
/* valid ticket available now, send the message */
- retval = realm_sendit_auth(notice, who, auth, realm, ack_to_sender);
+ realm_sendit_auth(notice, who, auth, realm, ack_to_sender);
#else /* HAVE_KRB4 */
realm_sendit(notice, who, auth, realm, ack_to_sender);
#endif /* HAVE_KRB4 */
}
static void
-realm_sendit(ZNotice_t *notice,
- struct sockaddr_in *who,
- int auth,
- ZRealm *realm,
- int ack_to_sender)
+realm_sendit(notice, who, auth, realm, ack_to_sender)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ int auth;
+ Realm *realm;
+ int ack_to_sender;
{
caddr_t pack;
int packlen;
/* set a timer to retransmit */
nacked->timer = timer_set_rel(rexmit_times[0], rlm_rexmit, nacked);
/* chain in */
- Unacked_insert(&rlm_nacklist, nacked);
+ LIST_INSERT(&rlm_nacklist, nacked);
return;
}
static void
-packet_ctl_nack(Unacked *nackpacket)
+packet_ctl_nack(nackpacket)
+ Unacked *nackpacket;
{
ZNotice_t notice;
ZParseNotice(nackpacket->packet, nackpacket->packsz, ¬ice);
if (nackpacket->ack_addr.sin_addr.s_addr != 0)
nack(¬ice, &nackpacket->ack_addr);
+#if 1
else
syslog(LOG_WARNING, "would have acked nobody (%s/%s/%s)",
notice.z_class, notice.z_class_inst, notice.z_opcode); /* XXX */
+#endif
}
static void
-rlm_rexmit(void *arg)
+rlm_rexmit(arg)
+ void *arg;
{
Unacked *nackpacket = (Unacked *) arg;
Code_t retval;
- register ZRealm *realm;
+ register Realm *realm;
+ int new_srv_idx;
zdbug((LOG_DEBUG,"rlm_rexmit"));
if (nackpacket->rexmits >= (NUM_REXMIT_TIMES * realm->count)) {
/* give a server ack that the packet is lost/realm dead */
packet_ctl_nack(nackpacket);
- Unacked_delete(nackpacket);
+ LIST_DELETE(nackpacket);
zdbug((LOG_DEBUG, "rlm_rexmit: %s appears dead", realm->name));
realm->state = REALM_DEAD;
}
void
-realm_dump_realms(FILE *fp)
+realm_dump_realms(fp)
+ FILE *fp;
{
register int ii, jj;
}
}
-#ifdef HAVE_KRB5
-static Code_t
-realm_sendit_auth(ZNotice_t *notice,
- struct sockaddr_in *who,
- int auth,
- ZRealm *realm,
- int ack_to_sender)
+#ifdef HAVE_KRB4
+static void
+realm_sendit_auth(notice, who, auth, realm, ack_to_sender)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Realm *realm;
+ int ack_to_sender;
{
char *buffer, *ptr;
- int buffer_len, hdrlen, offset, fragsize, message_len;
+ caddr_t pack;
+ int buffer_len, hdrlen, offset, fragsize, ret_len, message_len;
int origoffset, origlen;
Code_t retval;
Unacked *nacked;
- char multi[64];
+ char buf[1024], multi[64];
+ CREDENTIALS cred;
+ KTEXT_ST authent;
ZNotice_t partnotice, newnotice;
offset = 0;
- buffer = (char *) malloc(sizeof(ZPacket_t));
- if (!buffer) {
- syslog(LOG_ERR, "realm_sendit_auth malloc");
- return ENOMEM; /* DON'T put on nack list */
+ /* build an authent. first, make sure we have the ticket available */
+ retval = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, realm->name, &cred);
+ if (retval != GC_OK) {
+ syslog(LOG_WARNING, "rlm_sendit_auth get_cred: %s",
+ error_message(retval+krb_err_base));
+ return;
}
- buffer_len = sizeof(ZPacket_t);
-
- newnotice = *notice;
+ retval = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+ realm->name, 1);
+ if (retval != MK_AP_OK) {
+ syslog(LOG_WARNING, "rlm_sendit_auth mk_req: %s",
+ error_message(retval+krb_err_base));
+ return;
+ }
- hdrlen = 0;
- retval = ZMakeZcodeRealmAuthentication(&newnotice, buffer, buffer_len,
- &hdrlen, realm->name);
+ retval = ZMakeAscii(buf, sizeof(buf), authent.dat, authent.length);
if (retval != ZERR_NONE) {
- syslog(LOG_WARNING, "rlm_sendit_auth make zcksum: %s",
+ syslog(LOG_WARNING, "rlm_sendit_auth mk_ascii: %s",
error_message(retval));
- return (retval);
+ return;
}
/* set the dest addr */
if (retval != ZERR_NONE) {
syslog(LOG_WARNING, "rlm_sendit_auth set addr: %s",
error_message(retval));
- return (retval);
+ return;
+ }
+
+ /* now format the notice, refragmenting if needed */
+ newnotice = *notice;
+ newnotice.z_auth = 1;
+ newnotice.z_ascii_authent = buf;
+ newnotice.z_authent_len = authent.length;
+
+ buffer = (char *) malloc(sizeof(ZPacket_t));
+ if (!buffer) {
+ syslog(LOG_ERR, "realm_sendit_auth malloc");
+ return; /* DON'T put on nack list */
+ }
+
+ buffer_len = sizeof(ZPacket_t);
+
+ retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen, &ptr,
+ NULL);
+ if (retval != ZERR_NONE) {
+ syslog(LOG_WARNING, "rlm_sendit_auth raw: %s", error_message(retval));
+ free(buffer);
+ return;
+ }
+
+#ifdef NOENCRYPTION
+ newnotice.z_checksum = 0;
+#else
+ newnotice.z_checksum =
+ (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0,
+ cred.session);
+#endif
+
+ retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len, &hdrlen,
+ NULL, NULL);
+ if (retval != ZERR_NONE) {
+ syslog(LOG_WARNING, "rlm_sendit_auth raw: %s", error_message(retval));
+ free(buffer);
+ return;
}
/* This is not terribly pretty, but it does do its job.
* but only the server uses it.
*/
- if ((notice->z_message_len+hdrlen > buffer_len) ||
- (notice->z_message_len+hdrlen > Z_MAXPKTLEN)) {
-
- /* Reallocate buffers inside the refragmenter */
+ if ((newnotice.z_message_len+hdrlen > buffer_len) ||
+ (newnotice.z_message_len+hdrlen > Z_MAXPKTLEN)) {
+ /* Deallocate buffer, use a local one */
free(buffer);
-
+
partnotice = *notice;
+ partnotice.z_auth = 1;
+ partnotice.z_ascii_authent = buf;
+ partnotice.z_authent_len = authent.length;
+
origoffset = 0;
origlen = notice->z_message_len;
if (sscanf(notice->z_multinotice, "%d/%d", &origoffset,
&origlen) != 2) {
syslog(LOG_WARNING, "rlm_sendit_auth frag: parse failed");
- return ZERR_BADFIELD;
+ return;
}
+#if 0
+ zdbug((LOG_DEBUG,"rlm_send_auth: orig: %d-%d/%d", origoffset,
+ notice->z_message_len, origlen));
+#endif
+
fragsize = Z_MAXPKTLEN-hdrlen-Z_FRAGFUDGE;
while (offset < notice->z_message_len || !notice->z_message_len) {
partnotice.z_message = notice->z_message+offset;
partnotice.z_message_len = message_len;
+#if 0
+ zdbug((LOG_DEBUG,"rlm_send_auth: new: %d-%d/%d",
+ origoffset+offset, message_len, origlen));
+#endif
+
buffer = (char *) malloc(sizeof(ZPacket_t));
if (!buffer) {
syslog(LOG_ERR, "realm_sendit_auth malloc");
- return ENOMEM; /* DON'T put on nack list */
+ return; /* DON'T put on nack list */
}
-
- buffer_len = sizeof(ZPacket_t);
- retval = ZMakeZcodeRealmAuthentication(&partnotice, buffer,
- buffer_len, &hdrlen,
- realm->name);
+ retval = Z_FormatRawHeader(&partnotice, buffer, buffer_len,
+ &hdrlen, &ptr, NULL);
if (retval != ZERR_NONE) {
- syslog(LOG_WARNING, "rlm_sendit_auth set addr: %s",
+ syslog(LOG_WARNING, "rlm_sendit_auth raw: %s",
error_message(retval));
free(buffer);
- return (retval);
+ return;
+ }
+
+#ifdef NOENCRYPTION
+ partnotice.z_checksum = 0;
+#else
+ partnotice.z_checksum =
+ (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0,
+ cred.session);
+#endif
+
+ retval = Z_FormatRawHeader(&partnotice, buffer, buffer_len,
+ &hdrlen, NULL, NULL);
+ if (retval != ZERR_NONE) {
+ syslog(LOG_WARNING, "rlm_sendit_auth raw: %s",
+ error_message(retval));
+ free(buffer);
+ return;
}
ptr = buffer+hdrlen;
syslog(LOG_WARNING, "rlm_sendit_auth xmit: %s",
error_message(retval));
free(buffer);
- return(retval);
+ return;
}
if (!(nacked = (Unacked *)malloc(sizeof(Unacked)))) {
/* no space: just punt */
syslog(LOG_ERR, "rlm_sendit_auth nack malloc");
free(buffer);
- return ENOMEM;
+ return;
}
nacked->rexmits = 0;
nacked->timer = timer_set_rel(rexmit_times[0], rlm_rexmit, nacked);
/* chain in */
- Unacked_insert(&rlm_nacklist, nacked);
+ LIST_INSERT(&rlm_nacklist, nacked);
offset += fragsize;
if (!notice->z_message_len)
break;
}
- }
- else {
+#if 0
+ zdbug((LOG_DEBUG, "rlm_sendit_auth frag message sent"));
+#endif
+ } else {
/* This is easy, no further fragmentation needed */
ptr = buffer+hdrlen;
(void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
- buffer_len = hdrlen+newnotice.z_message_len;
+ buffer_len = hdrlen+newnotice.z_message_len;
/* now send */
if ((retval = ZSendPacket(buffer, buffer_len, 0)) != ZERR_NONE) {
syslog(LOG_WARNING, "rlm_sendit_auth xmit: %s",
error_message(retval));
free(buffer);
- return(retval);
+ return;
}
+#if 0
+ zdbug((LOG_DEBUG, "rlm_sendit_auth message sent"));
+#endif
/* now we've sent it, mark it as not ack'ed */
if (!(nacked = (Unacked *)malloc(sizeof(Unacked)))) {
/* no space: just punt */
syslog(LOG_ERR, "rlm_sendit_auth nack malloc");
free(buffer);
- return 0;
+ return;
}
nacked->rexmits = 0;
/* set a timer to retransmit */
nacked->timer = timer_set_rel(rexmit_times[0], rlm_rexmit, nacked);
/* chain in */
- Unacked_insert(&rlm_nacklist, nacked);
+ LIST_INSERT(&rlm_nacklist, nacked);
}
- return 0;
+ return;
}
static int
-ticket_lookup(char *realm)
+ticket_expired(cred)
+CREDENTIALS *cred;
{
- krb5_error_code result;
- krb5_timestamp sec;
- krb5_ccache ccache;
- krb5_creds creds_in, *creds;
-
- result = krb5_cc_default(Z_krb5_ctx, &ccache);
- if (result)
- return 0;
-
- memset(&creds_in, 0, sizeof(creds_in));
-
- result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client);
- if (result) {
- krb5_cc_close(Z_krb5_ctx, ccache);
- return 0;
- }
-
- result = krb5_build_principal(Z_krb5_ctx, &creds_in.server,
- strlen(realm),
- realm,
- SERVER_KRB5_SERVICE, SERVER_INSTANCE, 0);
- if (result) {
- krb5_cc_close(Z_krb5_ctx, ccache);
- return 0;
- }
+#ifdef HAVE_KRB_LIFE_TO_TIME
+ return (krb_life_to_time(cred->issue_date, cred->lifetime) < NOW);
+#else /* HAVE_KRB_LIFE_TO_TIME */
+ return (cred->issue_date + cred->lifetime*5*60 < NOW);
+#endif /* HAVE_KRB_LIFE_TO_TIME */
+}
- result = krb5_get_credentials(Z_krb5_ctx, 0 /* flags */, ccache,
- &creds_in, &creds);
- krb5_cc_close(Z_krb5_ctx, ccache);
- /* good ticket? */
+static int
+ticket_lookup(realm)
+char *realm;
+{
+ CREDENTIALS cred;
+ KTEXT_ST authent;
+ int retval;
- krb5_timeofday (Z_krb5_ctx, &sec);
- krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* hope this is OK */
- if ((result == 0) && (sec < creds->times.endtime)) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return (1);
- }
- if (!result) krb5_free_creds(Z_krb5_ctx, creds);
+ retval = krb_get_cred(SERVER_SERVICE, SERVER_INSTANCE, realm, &cred);
+ if (retval == GC_OK && !ticket_expired(&cred))
+ /* good ticket */
+ return(1);
return (0);
}
static Code_t
-ticket_retrieve(ZRealm *realm)
+ticket_retrieve(realm)
+ Realm *realm;
{
- int pid;
- krb5_ccache ccache;
- krb5_error_code result;
- krb5_creds creds_in, *creds;
+ int pid, retval = 0;
+ KTEXT_ST authent;
get_tgt();
if (realm->child_pid)
/* Right idea. Basically, we haven't gotten it yet */
- return KRB5KRB_AP_ERR_TKT_EXPIRED;
+ return KRBET_KDC_AUTH_EXP;
- if (realm->have_tkt) {
- /* Get a pointer to the default ccache. We don't need to free this. */
- result = krb5_cc_default(Z_krb5_ctx, &ccache);
+ /* For Putrify */
+ memset(&authent.dat,0,MAX_KTXT_LEN);
+ authent.mbz=0;
- /* GRRR. There's no allocator or constructor for krb5_creds */
- /* GRRR. It would be nice if this API were documented at all */
- memset(&creds_in, 0, sizeof(creds_in));
-
- if (!result)
- result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client);
- /* construct the service principal */
- if (!result)
- result = krb5_build_principal(Z_krb5_ctx, &creds_in.server,
- strlen(realm->name), realm->name,
- SERVER_KRB5_SERVICE, SERVER_INSTANCE,
- 0);
-
- /* HOLDING: creds_in.server */
-
- /* look up or get the credentials we need */
- if (!result)
- result = krb5_get_credentials(Z_krb5_ctx, 0 /* flags */, ccache,
- &creds_in, &creds);
- krb5_cc_close(Z_krb5_ctx, ccache);
- krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* hope this is OK */
- if (!result) {
- krb5_free_creds(Z_krb5_ctx, creds);
- return 0;
+ if (realm->have_tkt) {
+ retval = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+ realm->name, 0);
+ if (retval == KSUCCESS) {
+ return retval;
}
} else {
syslog(LOG_ERR, "tkt_rtrv: don't have ticket, but have no child");
- result = KRB5KRB_AP_ERR_TKT_EXPIRED;
}
pid = fork();
#endif
#endif
- syslog(LOG_INFO, "tkt_rtrv running for %s", realm->name);
while (1) {
- /* Get a pointer to the default ccache. We don't need to free this. */
- result = krb5_cc_default(Z_krb5_ctx, &ccache);
-
- /* GRRR. There's no allocator or constructor for krb5_creds */
- /* GRRR. It would be nice if this API were documented at all */
- memset(&creds_in, 0, sizeof(creds_in));
-
- if (!result)
- result = krb5_cc_get_principal(Z_krb5_ctx, ccache, &creds_in.client);
- /* construct the service principal */
- if (!result)
- result = krb5_build_principal(Z_krb5_ctx, &creds_in.server,
- strlen(realm->name), realm->name,
- SERVER_KRB5_SERVICE, SERVER_INSTANCE,
- 0);
-
- /* HOLDING: creds_in.server */
-
- /* look up or get the credentials we need */
- if (!result)
- result = krb5_get_credentials(Z_krb5_ctx, 0 /* flags */, ccache,
- &creds_in, &creds);
- krb5_cc_close(Z_krb5_ctx, ccache);
- krb5_free_cred_contents(Z_krb5_ctx, &creds_in); /* hope this is OK */
- if (!result) {
- krb5_free_creds(Z_krb5_ctx, creds);
- syslog(LOG_INFO, "tkt_rtrv succeeded for %s", realm->name);
+ retval = krb_mk_req(&authent, SERVER_SERVICE, SERVER_INSTANCE,
+ realm->name, 0);
+ if (retval == KSUCCESS)
exit(0);
- }
/* Sleep a little while before retrying */
sleep(30);
} else {
realm->child_pid = pid;
realm->have_tkt = 0;
-
- syslog(LOG_WARNING, "tkt_rtrv: %s: %d", realm->name,
- result);
- return (result);
+
+ syslog(LOG_WARNING, "tkt_rtrv: %s: %s", realm->name,
+ krb_err_txt[retval]);
+ return (retval+krb_err_base);
}
}
-#endif /* HAVE_KRB5 */
+#endif /* HAVE_KRB4 */
static Code_t kill_clt __P((ZNotice_t *, Server *));
static Code_t extract_addr __P((ZNotice_t *, struct sockaddr_in *));
+#ifdef notdef
+static Code_t server_register();
+#endif
+
static struct in_addr *get_server_addrs __P((int *number));
static char **get_server_list __P((char *file));
-static char **get_single_server __P((void));
static void free_server_list __P((char **list));
static Unacked *srv_nacktab[SRV_NACKTAB_HASHSIZE];
*/
void
-server_init(void)
+server_init()
{
int i;
struct in_addr *serv_addr, *server_addrs, limbo_addr;
otherservers[i].timer = NULL;
otherservers[i].queue = NULL;
otherservers[i].dumping = 0;
+#if 0
+ zdbug((LOG_DEBUG,"found myself"));
+#endif
}
}
* handle on a particular server other than by indexing on otherservers[].
*/
void
-server_reset(void)
+server_reset()
{
int num_servers;
struct in_addr *server_addrs;
int *ok_list_new, *ok_list_old;
int num_ok, new_num;
+#if 0
+ zdbug((LOG_DEBUG, "server_reset"));
+#endif
#ifdef DEBUG
if (zalone) {
syslog(LOG_INFO, "server_reset while alone, punt");
if (i != me_server_idx && !otherservers[i].timer) {
otherservers[i].timer =
timer_set_rel(0L, server_timo, &otherservers[i]);
+#if 0
+ zdbug((LOG_DEBUG, "reset timer for %s",
+ otherservers[i].addr_str));
+#endif
}
}
free(ok_list_old);
free(ok_list_new);
+#if 0
+ zdbug((LOG_DEBUG, "server_reset: %d servers now", nservers));
+#endif
}
/* note: these must match the order given in zserver.h */
*/
void
-server_timo(void *arg)
+server_timo(arg)
+ void *arg;
{
Server *which = (Server *) arg;
int auth = 0;
+#if 0
+ zdbug((LOG_DEBUG,"srv_timo: %s", which->addr_str));
+#endif
/* change state and reset if appropriate */
switch(which->state) {
case SERV_DEAD: /* leave him dead */
auth = 0;
break;
default:
- syslog(LOG_ERR,"Bad server state, server 0x%x\n", (int)which);
+ syslog(LOG_ERR,"Bad server state, server 0x%x\n",which);
abort();
}
/* now he's either TARDY, STARTING, or DEAD
We send a "hello," which increments the counter */
+#if 0
+ zdbug((LOG_DEBUG, "srv %s is %s", which->addr_str,
+ srv_states[which->state]));
+#endif
server_hello(which, auth);
/* reschedule the timer */
which->timer = timer_set_rel(which->timeout, server_timo, which);
/*ARGSUSED*/
Code_t
-server_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who)
+server_dispatch(notice, auth, who)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
{
Server *server;
struct sockaddr_in newwho;
Code_t status;
String *notice_class;
+#if 0
+ zdbug((LOG_DEBUG, "server_dispatch"));
+#endif
if (notice->z_kind == SERVACK) {
srv_nack_cancel(notice, who);
return status;
}
+#ifdef notdef
+/*
+ * Register a new server (one not in our list). This MUST be authenticated.
+ */
+
+/*ARGSUSED*/
+static Code_t
+server_register(notice, auth, who)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+{
+ Server *temp;
+ int i;
+ long timerval;
+
+ if (who->sin_port != srv_addr.sin_port) {
+#if 0
+ zdbug((LOG_DEBUG, "srv_wrong port %d", ntohs(who->sin_port)));
+#endif
+ return 1;
+ }
+ /* Not yet... talk to ken about authenticators */
+#ifdef notdef
+ if (!auth) {
+#if 0
+ zdbug((LOG_DEBUG, "srv_unauth"));
+#endif
+ return 1;
+ }
+#endif /* notdef */
+ /* OK, go ahead and set him up. */
+ temp = (Server *) malloc((nservers + 1) * sizeof(Server));
+ if (!temp) {
+ syslog(LOG_CRIT, "srv_reg malloc");
+ return 1;
+ }
+
+ memcpy(temp, otherservers, nservers * sizeof(Server));
+ free(otherservers);
+ otherservers = temp;
+ /* don't reschedule limbo's timer, so start i=1 */
+ for (i = 1; i < nservers; i++) {
+ if (i == me_server_idx) /* don't reset myself */
+ continue;
+ /* reschedule the timers--we moved otherservers */
+ timerval = timer_when(otherservers[i].timer);
+ timer_reset(otherservers[i].timer);
+ otherservers[i].timer = timer_set_abs(timerval, server_timo,
+ &otherservers[i]);
+ }
+ setup_server(&otherservers[nservers], &who->sin_addr);
+ otherservers[nservers].state = SERV_STARTING;
+ otherservers[nservers].timeout = timo_tardy;
+ otherservers[nservers].update_queue = NULL;
+ otherservers[nservers].dumping = 0;
+
+ nservers++;
+#if 0
+ zdbug((LOG_DEBUG, "srv %s is %s", otherservers[nservers].addr_str,
+ srv_states[otherservers[nservers].state]));
+#endif
+
+ return 0;
+}
+#endif
+
/*
* Tell the other servers that this client died.
*/
void
-server_kill_clt(Client *client)
+server_kill_clt(client)
+ Client *client;
{
int i;
char buf[512], *lyst[2];
sprintf(buf, "%d", ntohs(client->addr.sin_port));
lyst[1] = buf;
+#if 0
+ zdbug((LOG_DEBUG, "server kill clt %s/%s", lyst[0], lyst[1]));
+#endif
+
pnotice = ¬ice;
memset (¬ice, 0, sizeof(notice));
*/
static Code_t
-kill_clt(ZNotice_t *notice,
- Server *server)
+kill_clt(notice, server)
+ ZNotice_t *notice;
+ Server *server;
{
struct sockaddr_in who;
Client *client;
+#if 0
+ zdbug((LOG_DEBUG, "kill_clt"));
+#endif
if (extract_addr(notice, &who) != ZERR_NONE)
return ZERR_NONE; /* XXX */
client = client_find(&who.sin_addr, notice->z_port);
server->addr_str);
return ZERR_NONE; /* XXX */
}
-
- if (zdebug) {
+#if 1
+ if (zdebug || 1) {
syslog(LOG_DEBUG, "kill_clt clt_dereg %s/%d from %s",
inet_ntoa(who.sin_addr), ntohs(who.sin_port), server->addr_str);
}
+#endif
/* remove the locations, too */
client_deregister(client, 1);
*/
static Code_t
-extract_addr(ZNotice_t *notice,
- struct sockaddr_in *who)
+extract_addr(notice, who)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
{
char *cp = notice->z_message;
}
who->sin_port = notice->z_port = htons((u_short) atoi(cp));
who->sin_family = AF_INET;
+#if 0
+ zdbug((LOG_DEBUG,"ext %s/%d", inet_ntoa(who->sin_addr),
+ ntohs(who->sin_port)));
+#endif
return ZERR_NONE;
}
*/
static void
-server_flush(Server *which)
+server_flush(which)
+ Server *which;
{
+#if 0
+ if (zdebug)
+ syslog(LOG_DEBUG, "server_flush %s", which->addr_str);
+#endif
srv_nack_release(which);
}
*/
static void
-server_hello(Server *which,
- int auth)
+server_hello(which, auth)
+ Server *which;
+ int auth;
{
send_msg(&which->addr, ADMIN_HELLO, auth);
which->num_hello_sent++;
/*ARGSUSED*/
static Code_t
-admin_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+admin_dispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
char *opcode = notice->z_opcode;
Code_t status = ZERR_NONE;
+#if 0
+ zdbug((LOG_DEBUG, "ADMIN received"));
+#endif
+
if (strcmp(opcode, ADMIN_HELLO) == 0) {
hello_respond(who, ADJUST, auth);
} else if (strcmp(opcode, ADMIN_IMHERE) == 0) {
srv_responded(who);
} else if (strcmp(opcode, ADMIN_SHUTDOWN) == 0) {
+#if 0
+ zdbug((LOG_DEBUG, "server shutdown"));
+#endif
if (server) {
srv_nack_release(server);
server->state = SERV_DEAD;
server->timeout = timo_dead;
/* don't worry about the timer, it will
be set appropriately on the next send */
- }
+#if 0
+ zdbug((LOG_DEBUG, "srv %s is %s", server->addr_str,
+ srv_states[server->state]));
+#endif
+ }
} else if (strcmp(opcode, ADMIN_BDUMP) == 0) {
/* Ignore a brain dump request if this is a brain dump packet
* or a packet being processed concurrently during a brain
/*ARGSUSED*/
Code_t
-server_adispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+server_adispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
/* this had better be a HELLO message--start of acquisition
return ZERR_NONE;
}
+#ifdef notdef
+ syslog(LOG_INFO, "disp: new server?");
+ if (server_register(notice, auth, who) != ZERR_NONE) {
+ syslog(LOG_INFO, "new server failed");
+ } else {
+ syslog(LOG_INFO, "new server %s, %d", inet_ntoa(who->sin_addr),
+ ntohs(who->sin_port));
+ hello_respond(who, DONT_ADJUST, auth);
+ }
+#else
syslog(LOG_INFO, "srv_adisp: server attempt from %s",
inet_ntoa(who->sin_addr));
+#endif /* notdef */
return ZERR_NONE;
}
static void
-send_stats(struct sockaddr_in *who)
+send_stats(who)
+ struct sockaddr_in *who;
{
int i;
char buf[BUFSIZ];
char **responses;
int num_resp;
char *vers, *pkts, *upt;
- ZRealm *realm;
+ Realm *realm;
int extrafields = 0;
#define NUM_FIXED 3 /* 3 fixed fields, plus server info */
do it this way. */
vers = get_version();
- sprintf(buf, "%lu pkts", npackets);
+ sprintf(buf, "%d pkts", npackets);
pkts = strsave(buf);
- sprintf(buf, "%ld seconds operational",NOW - uptime);
+ sprintf(buf, "%d seconds operational",NOW - uptime);
upt = strsave(buf);
#ifdef OLD_COMPAT
*/
static struct in_addr *
-get_server_addrs(int *number)
+get_server_addrs(number)
+ int *number; /* RETURN */
{
int i;
char **server_hosts = NULL;
server_hosts_free = server_hosts;
#ifdef HAVE_HESIOD
if (!server_hosts)
- server_hosts = hes_resolve("zephyr","sloc");
+ server_hosts = hes_resolve("zephyr","sloc");
#endif
- if (!server_hosts) {
- server_hosts = get_single_server();
- server_hosts_free = server_hosts;
- }
if (!server_hosts)
return NULL;
/* count up */
*/
static char **
-get_server_list(char *file)
+get_server_list(file)
+ char *file;
{
FILE *fp;
char buf[MAXHOSTNAMELEN];
int nused = 0;
char *newline;
- fp = fopen(file, "r");
- if (!fp)
- return NULL;
/* start with 16, realloc if necessary */
nhosts = 16;
ret_list = (char **) malloc(nhosts * sizeof(char *));
- if (!ret_list)
- return NULL;
-
- while (fgets(buf, MAXHOSTNAMELEN, fp)) {
- /* nuke the newline, being careful not to overrun
- the buffer searching for it with strlen() */
- buf[MAXHOSTNAMELEN - 1] = '\0';
- newline = strchr(buf, '\n');
- if (newline)
- *newline = '\0';
-
- if (nused + 1 >= nhosts) {
- /* get more pointer space if necessary */
- /* +1 to leave room for null pointer */
- ret_list = (char **) realloc(ret_list, nhosts * 2);
- nhosts = nhosts * 2;
+
+ fp = fopen(file, "r");
+ if (fp) {
+ while (fgets(buf, MAXHOSTNAMELEN, fp)) {
+ /* nuke the newline, being careful not to overrun
+ the buffer searching for it with strlen() */
+ buf[MAXHOSTNAMELEN - 1] = '\0';
+ newline = strchr(buf, '\n');
+ if (newline)
+ *newline = '\0';
+
+ if (nused + 1 >= nhosts) {
+ /* get more pointer space if necessary */
+ /* +1 to leave room for null pointer */
+ ret_list = (char **) realloc(ret_list, nhosts * 2);
+ nhosts = nhosts * 2;
+ }
+ ret_list[nused++] = strsave(buf);
+ }
+ fclose(fp);
+ } else {
+ if (gethostname(buf, sizeof(buf)) < 0) {
+ free(ret_list);
+ return NULL;
}
ret_list[nused++] = strsave(buf);
}
- fclose(fp);
- if (!nused) {
- free(ret_list);
- return NULL;
- }
- ret_list[nused] = NULL;
- return ret_list;
-}
-
-static char **
-get_single_server(void)
-{
- char buf[MAXHOSTNAMELEN];
- char **ret_list;
- int nused = 0;
- nhosts = 2;
- ret_list = (char **) malloc(nhosts * sizeof(char *));
- if (!ret_list)
- return NULL;
- if (gethostname(buf, sizeof(buf)) < 0) {
- free(ret_list);
- return NULL;
- }
- ret_list[nused++] = strsave(buf);
ret_list[nused] = NULL;
return ret_list;
}
* free storage allocated by get_server_list
*/
static void
-free_server_list(char **list)
+free_server_list(list)
+ char **list;
{
char **orig_list = list;
*/
static void
-setup_server(Server *server,
- struct in_addr *addr)
+setup_server(server, addr)
+ Server *server;
+ struct in_addr *addr;
{
server->state = SERV_DEAD;
server->timeout = timo_dead;
*/
static void
-hello_respond(struct sockaddr_in *who,
- int adj,
- int auth)
+hello_respond(who, adj, auth)
+ struct sockaddr_in *who;
+ int adj;
+ int auth;
{
Server *which;
+#if 0
+ zdbug((LOG_DEBUG, "hello from %s", inet_ntoa(who->sin_addr)));
+#endif
+
send_msg(who, ADMIN_IMHERE, auth);
if (adj != ADJUST)
return;
*/
Server *
-server_which_server(struct sockaddr_in *who)
+server_which_server(who)
+ struct sockaddr_in *who;
{
Server *server;
int i;
* appropriately.
*/
static void
-srv_responded(struct sockaddr_in *who)
+srv_responded(who)
+ struct sockaddr_in *who;
{
Server *which = server_which_server(who);
+#if 0
+ zdbug((LOG_DEBUG, "srv_responded %s", inet_ntoa(who->sin_addr)));
+#endif
+
if (!which) {
syslog(LOG_ERR, "hello input from non-server?!");
return;
which->timer = timer_set_rel(which->timeout, server_timo, which);
break;
}
+#if 0
+ zdbug((LOG_DEBUG, "srv %s is %s", which->addr_str,
+ srv_states[which->state]));
+#endif
}
/*
*/
void
-server_shutdown(void)
+server_shutdown()
{
int i;
*/
static void
-send_msg(struct sockaddr_in *who,
- char *opcode,
- int auth)
+send_msg(who, opcode, auth)
+ struct sockaddr_in *who;
+ char *opcode;
+ int auth;
{
ZNotice_t notice;
ZNotice_t *pnotice; /* speed hack */
*/
static void
-send_msg_list(struct sockaddr_in *who,
- char *opcode,
- char **lyst,
- int num,
- int auth)
+send_msg_list(who, opcode, lyst, num, auth)
+ struct sockaddr_in *who;
+ char *opcode;
+ char **lyst;
+ int num;
+ int auth;
{
ZNotice_t notice;
char *pack;
int packlen;
Code_t retval;
+ Unacked *nacked;
memset (¬ice, 0, sizeof(notice));
*/
/*ARGSUSED*/
void
-server_forward(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who)
+server_forward(notice, auth, who)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
{
int i;
caddr_t pack;
int packlen;
Code_t retval;
+#if 0
+ zdbug((LOG_DEBUG, "srv_forw"));
+#endif
/* don't send to limbo */
for (i = 1; i < nservers; i++) {
if (i == me_server_idx) /* don't xmit to myself */
syslog(LOG_CRIT, "srv_fwd malloc");
abort();
}
- retval = ZNewFormatSmallRawNotice(notice, pack, &packlen);
+ retval = ZFormatSmallRawNotice(notice, pack, &packlen);
if (retval != ZERR_NONE) {
syslog(LOG_WARNING, "srv_fwd format: %s", error_message(retval));
continue;
}
static void
-server_forw_reliable(Server *server,
- caddr_t pack,
- int packlen,
- ZNotice_t *notice)
+server_forw_reliable(server, pack, packlen, notice)
+ Server *server;
+ caddr_t pack;
+ int packlen;
+ ZNotice_t *notice;
{
Code_t retval;
Unacked *nacked;
nacked->uid = notice->z_uid;
nacked->timer = timer_set_rel(rexmit_times[0], srv_rexmit, nacked);
hashval = SRV_NACKTAB_HASHVAL(nacked->dest.srv_idx, nacked->uid);
- Unacked_insert(&srv_nacktab[hashval], nacked);
+ LIST_INSERT(&srv_nacktab[hashval], nacked);
}
/*
*/
void
-server_send_queue(Server *server)
+server_send_queue(server)
+ Server *server;
{
Pending *pending;
ZNotice_t notice;
*/
static void
-srv_nack_cancel(ZNotice_t *notice,
- struct sockaddr_in *who)
+srv_nack_cancel(notice, who)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
{
Server *server = server_which_server(who);
Unacked *nacked;
&& ZCompareUID(&nacked->uid, ¬ice->z_uid)) {
timer_reset(nacked->timer);
free(nacked->packet);
- Unacked_delete(nacked);
+ LIST_DELETE(nacked);
free(nacked);
return;
}
}
+#if 0
+ zdbug((LOG_DEBUG, "srv_nack not found"));
+#endif
}
/*
*/
static void
-srv_rexmit(void *arg)
+srv_rexmit(arg)
+ void *arg;
{
Unacked *packet = (Unacked *) arg;
Code_t retval;
/* retransmit the packet */
+#if 0
+ zdbug((LOG_DEBUG,"srv_rexmit to %s/%d",
+ otherservers[packet->dest.srv_idx].addr_str,
+ ntohs(otherservers[packet->dest.srv_idx].addr.sin_port)));
+#endif
if (otherservers[packet->dest.srv_idx].state == SERV_DEAD) {
- Unacked_delete(packet);
+#if 0
+ zdbug((LOG_DEBUG, "cancelling send to dead server"));
+#endif
+ LIST_DELETE(packet);
free(packet->packet);
srv_nack_release(&otherservers[packet->dest.srv_idx]);
free(packet);
*/
static void
-srv_nack_release(Server *server)
+srv_nack_release(server)
+ Server *server;
{
int i;
Unacked *nacked, *next;
next = nacked->next;
if (nacked->dest.srv_idx == server - otherservers) {
timer_reset(nacked->timer);
- Unacked_delete(nacked);
+ LIST_DELETE(nacked);
free(nacked->packet);
free(nacked);
}
*/
static void
-srv_nack_renumber (int *new_idx)
+srv_nack_renumber (new_idx)
+ int *new_idx;
{
/* XXX release any private queue for this server */
Unacked *nacked;
* Queue this notice to be transmitted to the server when it is ready.
*/
static void
-server_queue(Server *server,
- int len,
- void *pack,
- int auth,
- struct sockaddr_in *who)
+server_queue(server, len, pack, auth, who)
+ Server *server;
+ int len;
+ void *pack;
+ int auth;
+ struct sockaddr_in *who;
{
Pending *pending;
*/
Pending *
-server_dequeue(Server *server)
+server_dequeue(server)
+ Server *server;
{
Pending *pending;
*/
void
-server_pending_free(Pending *pending)
+server_pending_free(pending)
+ Pending *pending;
{
free(pending->packet);
free(pending);
*/
void
-server_self_queue(ZNotice_t* notice,
- int auth,
- struct sockaddr_in * who)
+server_self_queue(notice, auth, who)
+ ZNotice_t* notice;
+ int auth;
+ struct sockaddr_in * who;
{
char *pack;
int packlen;
* (true if called from signal handler)
*/
void
-server_dump_servers(FILE *fp)
+server_dump_servers(fp)
+ FILE *fp;
{
int i;
*/
#ifdef HAVE_KRB4
+#ifndef NOENCRYPTION
C_Block serv_key;
Sched serv_ksched;
#endif
+#endif
/* for compatibility when sending subscription information to old clients */
#ifdef OLD_COMPAT
#define OLD_ZEPHYR_VERSION "ZEPH0.0"
#define OLD_CLIENT_INCOMPSUBS "INCOMP"
-static void old_compat_subscr_sendlist(ZNotice_t *notice, int auth,
- struct sockaddr_in *who);
+static void old_compat_subscr_sendlist __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who));
extern int old_compat_count_subscr; /* counter of old use */
#endif /* OLD_COMPAT */
#ifdef NEW_COMPAT
#define NEW_OLD_ZEPHYR_VERSION "ZEPH0.1"
-static void new_old_compat_subscr_sendlist(ZNotice_t *notice, int auth,
- struct sockaddr_in *who);
+static void new_old_compat_subscr_sendlist __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who));
extern int new_compat_count_subscr; /* counter of old use */
#endif /* NEW_COMPAT */
-static Code_t add_subscriptions(Client *who, Destlist *subs_queue,
- ZNotice_t *notice, Server *server);
-static Destlist *extract_subscriptions(ZNotice_t *notice);
-static void free_subscriptions(Destlist *subs);
-static void free_subscription(Destlist *sub);
-static char **subscr_marshal_subs(ZNotice_t *notice, int auth,
- struct sockaddr_in *who,
- int *found);
-static Destlist *subscr_copy_def_subs(char *person);
-static Code_t subscr_realm_sendit(Client *who, Destlist *subs,
- ZNotice_t *notice, ZRealm *realm);
-static void subscr_unsub_sendit(Client *who, Destlist *subs,
- ZRealm *realm);
+extern char *re_comp(), *re_conv();
+static Code_t add_subscriptions __P((Client *who, Destlist *subs_queue,
+ ZNotice_t *notice, Server *server));
+static Destlist *extract_subscriptions __P((ZNotice_t *notice));
+static void free_subscriptions __P((Destlist *subs));
+static void free_subscription __P((Destlist *sub));
+static char **subscr_marshal_subs __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who,
+ int *found));
+static Destlist *subscr_copy_def_subs __P((char *person));
+static Code_t subscr_realm_sendit __P((Client *who, Destlist *subs,
+ ZNotice_t *notice, Realm *realm));
+static void subscr_unsub_realms __P((Destlist *newsubs));
+static void subscr_unsub_sendit __P((Client *who, Destlist *subs,
+ Realm *realm));
+static int cl_match __P((Destlist*, Client *));
static int defaults_read = 0; /* set to 1 if the default subs
are in memory */
*/
Code_t
-subscr_subscribe(Client *who,
- ZNotice_t *notice,
- Server *server)
+subscr_subscribe(who, notice, server)
+ Client *who;
+ ZNotice_t *notice;
+ Server *server;
{
Destlist *subs;
}
static Code_t
-add_subscriptions(Client *who,
- Destlist *subs,
- ZNotice_t *notice,
- Server *server)
+add_subscriptions(who, subs, notice, server)
+ Client *who;
+ Destlist *subs;
+ ZNotice_t *notice;
+ Server *server;
{
Destlist *next;
Code_t retval;
Acl *acl;
String *sender;
- ZRealm *realm = NULL;
+ Realm *realm = NULL;
if (!subs)
return ZERR_NONE; /* no subscr -> no error */
/* Loop over the new subscriptions. */
for (; subs; subs = next) {
next = subs->next;
+#if 0
+ zdbug ((LOG_DEBUG, "subscr: %s/%s/%s", subs->dest.classname->string,
+ subs->dest.inst->string, subs->dest.recip->string));
+#endif
/* check the recipient for a realm which isn't ours */
realm = NULL;
if (subs->dest.recip->string[0] == '@' &&
}
}
if (realm && !bdumping) {
+ if (server && server == me_server) {
retval = subscr_realm_sendit(who, subs, notice, realm);
if (retval != ZERR_NONE) {
+ free_subscriptions(subs);
+ free_string(sender);
+ return(retval);
+ } else {
+ /* free this one, will get from ADD */
free_subscription(subs);
- continue; /* the for loop */
+ }
} else {
/* Indicates we leaked traffic back to our realm */
- free_subscription(subs); /* free this one, wil get from
- ADD */
}
} else {
retval = triplet_register(who, &subs->dest, NULL);
}
} else {
/* If realm, let the REALM_ADD_SUBSCRIBE do insertion */
- Destlist_insert(&who->subs, subs);
+ LIST_INSERT(&who->subs, subs);
}
}
}
*/
Code_t
-subscr_def_subs(Client *who)
+subscr_def_subs(who)
+ Client *who;
{
Destlist *subs;
}
void
-subscr_reset(void)
+subscr_reset()
{
+#if 0
+ zdbug((LOG_DEBUG, "subscr_reset()"));
+#endif
free(default_notice.z_message);
default_notice.z_message = NULL;
defaults_read = 0;
}
static Destlist *
-subscr_copy_def_subs(char *person)
+subscr_copy_def_subs(person)
+ char *person;
{
int retval, fd;
struct stat statbuf;
Destlist *subs, *sub;
if (!defaults_read) {
+#if 0
+ zdbug((LOG_DEBUG, "reading default subscription file"));
+#endif
fd = open(subs_file, O_RDONLY, 0666);
if (fd < 0) {
syslog(LOG_ERR, "can't open %s:%m", subs_file);
*/
Code_t
-subscr_cancel(struct sockaddr_in *sin,
- ZNotice_t *notice)
+subscr_cancel(sin, notice)
+ struct sockaddr_in *sin;
+ ZNotice_t *notice;
{
- ZRealm *realm;
+ Realm *realm;
Client *who;
Destlist *cancel_subs, *subs, *cancel_next, *client_subs, *client_next;
Code_t retval;
int found = 0;
+ int relation;
+#if 0
+ zdbug((LOG_DEBUG,"subscr_cancel"));
+#endif
who = client_find(&sin->sin_addr, notice->z_port);
if (!who)
return ZSRV_NOCLT;
for (client_subs = who->subs; client_subs; client_subs = client_next) {
client_next = client_subs->next;
if (ZDest_eq(&client_subs->dest, &subs->dest)) {
- Destlist_delete(client_subs);
+ LIST_DELETE(client_subs);
retval = triplet_deregister(who, &client_subs->dest, NULL);
if (retval == ZSRV_EMPTYCLASS &&
client_subs->dest.recip->string[0] == '@') {
free_subscriptions(cancel_subs);
if (found) {
+#if 0
+ zdbug((LOG_DEBUG, "found & removed"));
+#endif
return ZERR_NONE;
} else {
+#if 0
+ zdbug((LOG_DEBUG, "not found"));
+#endif
return ZSRV_NOSUB;
}
}
Code_t
-subscr_realm_cancel(struct sockaddr_in *sin,
- ZNotice_t *notice,
- ZRealm *realm)
+subscr_realm_cancel(sin, notice, realm)
+ struct sockaddr_in *sin;
+ ZNotice_t *notice;
+ Realm *realm;
{
+ Client *who;
Destlist *cancel_subs, *subs, *client_subs, *next, *next2;
Code_t retval;
int found = 0;
for (client_subs = realm->subs; client_subs; client_subs = next2) {
next2 = client_subs->next;
if (ZDest_eq(&client_subs->dest, &subs->dest)) {
- Destlist_delete(client_subs);
+ LIST_DELETE(client_subs);
retval = triplet_deregister(realm->client, &client_subs->dest, realm);
free_subscription(client_subs);
found = 1;
free_subscriptions(cancel_subs);
if (found) {
+#if 0
+ zdbug((LOG_DEBUG, "found & removed"));
+#endif
return ZERR_NONE;
} else {
+#if 0
+ zdbug((LOG_DEBUG, "not found"));
+#endif
return ZSRV_NOSUB;
}
}
*/
void
-subscr_cancel_client(Client *client)
+subscr_cancel_client(client)
+ Client *client;
{
Destlist *subs, *next;
Code_t retval;
- ZRealm *realm;
+ Realm *realm;
+#if 0
+ zdbug((LOG_DEBUG,"subscr_cancel_client %s",
+ inet_ntoa(client->addr.sin_addr)));
+#endif
if (!client->subs)
return;
for (subs = client->subs; subs; subs = next) {
next = subs->next;
+#if 0
+ zdbug((LOG_DEBUG,"sub_can %s", subs->dest.classname->string));
+#endif
retval = triplet_deregister(client, &subs->dest, NULL);
if (retval == ZSRV_EMPTYCLASS &&
subs->dest.recip->string[0] == '@') {
*/
void
-subscr_sendlist(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who)
+subscr_sendlist(notice, auth, who)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
{
char **answer;
int found;
}
static char **
-subscr_marshal_subs(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- int *found)
+subscr_marshal_subs(notice, auth, who, found)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ int *found;
{
char **answer = NULL;
unsigned short temp;
int i;
int defsubs = 0;
+#if 0
+ zdbug((LOG_DEBUG, "subscr_marshal"));
+#endif
*found = 0;
-
+
/* Note that the following code is an incredible crock! */
/* We cannot send multiple packets as acknowledgements to the client,
if (client)
subs = client->subs;
} else if (strcmp(notice->z_opcode, CLIENT_GIMMEDEFS) == 0) {
+#if 0
+ zdbug((LOG_DEBUG, "gimmedefs"));
+#endif
/* subscr_copy_def_subs allocates new pointer rings, so
it must be freed when finished.
the string areas pointed to are static, however.*/
/* send 5 at a time until we are finished */
count = found?((found-1) / 5 + 1):1; /* total # to be sent */
i = 0; /* pkt # counter */
+#if 0
+ zdbug((LOG_DEBUG,"Found %d subscriptions for %d packets", found, count));
+#endif
initfound = found;
zerofound = (found == 0);
while (found > 0 || zerofound) {
found -= 5;
zerofound = 0;
}
+#if 0
+ zdbug((LOG_DEBUG,"subscr_sendlist acked"));
+#endif
if (answer)
free(answer);
}
free(answer);
return;
}
+#if 0
+ zdbug((LOG_DEBUG,"subscr_sendlist acked"));
+#endif
if (answer)
free(answer);
}
/*ARGSUSED*/
Code_t
-subscr_send_subs(Client *client)
+subscr_send_subs(client)
+ Client *client;
{
int i = 0;
Destlist *subs;
-#ifdef HAVE_KRB5
- char buf[512];
- unsigned char *bufp;
-#else
#ifdef HAVE_KRB4
char buf[512];
C_Block cblock;
#endif /* HAVE_KRB4 */
-#endif
char buf2[512];
char *list[7 * NUM_FIELDS];
int num = 0;
Code_t retval;
+#if 0
+ zdbug((LOG_DEBUG, "send_subs"));
+#endif
sprintf(buf2, "%d",ntohs(client->addr.sin_port));
list[num++] = buf2;
-#ifdef HAVE_KRB5
-#ifdef HAVE_KRB4 /* XXX make this optional for server transition time */
- if (Z_enctype(client->session_keyblock) == ENCTYPE_DES_CBC_CRC) {
- bufp = malloc(Z_keylen(client->session_keyblock));
- if (bufp == NULL) {
- syslog(LOG_WARNING, "subscr_send_subs: cannot allocate memory for DES keyblock: %m");
- return errno;
- }
- des_ecb_encrypt((C_Block *)Z_keydata(client->session_keyblock), (C_Block *)bufp, serv_ksched.s, DES_ENCRYPT);
- retval = ZMakeAscii(buf, sizeof(buf), bufp, Z_keylen(client->session_keyblock));
- } else {
-#endif
- bufp = malloc(Z_keylen(client->session_keyblock) + 8); /* + enctype
- + length */
- if (bufp == NULL) {
- syslog(LOG_WARNING, "subscr_send_subs: cannot allocate memory for keyblock: %m");
- return errno;
- }
- *(krb5_enctype *)&bufp[0] = htonl(Z_enctype(client->session_keyblock));
- *(u_int32_t *)&bufp[4] = htonl(Z_keylen(client->session_keyblock));
- memcpy(&bufp[8], Z_keydata(client->session_keyblock), Z_keylen(client->session_keyblock));
-
- retval = ZMakeZcode(buf, sizeof(buf), bufp, Z_keylen(client->session_keyblock) + 8);
-#ifdef HAVE_KRB4
- }
-#endif /* HAVE_KRB4 */
-#else /* HAVE_KRB5 */
#ifdef HAVE_KRB4
+#ifdef NOENCRYPTION
+ memcpy(cblock, client->session_key, sizeof(C_Block));
+#else
des_ecb_encrypt(client->session_key, cblock, serv_ksched.s, DES_ENCRYPT);
+#endif
retval = ZMakeAscii(buf, sizeof(buf), cblock, sizeof(C_Block));
-#endif /* HAVE_KRB4 */
-#endif /* HAVE_KRB5 */
-
-#if defined(HAVE_KRB4) || defined(HAVE_KRB5)
if (retval != ZERR_NONE) {
+#if 0
+ zdbug((LOG_DEBUG,"zmakeascii failed: %s", error_message(retval)));
+#endif
} else {
list[num++] = buf;
+#if 0
+ zdbug((LOG_DEBUG, "cblock %s", buf));
+#endif
}
-#endif /* HAVE_KRB4 || HAVE_KRB5*/
+#endif /* HAVE_KRB4 */
retval = bdump_send_list_tcp(SERVACK, &client->addr, ZEPHYR_ADMIN_CLASS,
num > 1 ? "CBLOCK" : "", ADMIN_NEWCLT,
client->principal->string, "", list, num);
}
static void
-free_subscriptions(Destlist *subs)
+free_subscriptions(subs)
+ Destlist *subs;
{
Destlist *next;
*/
static Destlist *
-extract_subscriptions(ZNotice_t *notice)
+extract_subscriptions(notice)
+ ZNotice_t *notice;
{
Destlist *subs = NULL, *sub;
char *recip, *class_name, *classinst;
classinst = cp;
ADVANCE(2);
recip = cp;
+#if 0
+ zdbug((LOG_DEBUG, "ext_sub: CLS %s INST %s RCPT %s",
+ class_name, classinst, cp));
+#endif
cp += (strlen(cp) + 1);
if (cp > notice->z_message + notice->z_message_len) {
syslog(LOG_WARNING, "malformed sub 3");
sub->dest.recip = make_string("", 0);
else
sub->dest.recip = make_string(recip, 0);
- Destlist_insert(&subs, sub);
+ LIST_INSERT(&subs, sub);
}
return subs;
}
*/
void
-subscr_dump_subs(FILE *fp,
- Destlist *subs)
+subscr_dump_subs(fp, subs)
+ FILE *fp;
+ Destlist *subs;
{
+ char *p;
+
if (!subs) /* no subscriptions to dump */
return;
/* As it exists, this function expects to take only the first sub from the
* Destlist. At some point, it and the calling code should be replaced */
static Code_t
-subscr_realm_sendit(Client *who,
- Destlist *subs,
- ZNotice_t *notice,
- ZRealm *realm)
+subscr_realm_sendit(who, subs, notice, realm)
+ Client *who;
+ Destlist *subs;
+ ZNotice_t *notice;
+ Realm *realm;
{
ZNotice_t snotice;
char *pack;
int packlen;
+ int found = 0, i;
char **text;
Code_t retval;
char addr[16]; /* xxx.xxx.xxx.xxx max */
char port[16];
+#if 0
+ zdbug((LOG_DEBUG, "subscr_rlm_sendit"));
+#endif
+
+
if ((text=(char **)malloc((NUM_FIELDS + 2)*sizeof(char *))) == (char **)0) {
syslog(LOG_ERR, "subscr_rlm_sendit malloc");
return(ENOMEM);
return(ZERR_NONE);
}
+#if 0
+ zdbug((LOG_DEBUG,"subscr_rlm_sendit len: %d", snotice.z_message_len));
+#endif
realm_handoff(&snotice, 1, &(who->addr), realm, 0);
free(pack);
/* Called from subscr_realm and subscr_foreign_user */
static Code_t
-subscr_add_raw(Client *client,
- ZRealm *realm,
- Destlist *newsubs)
+subscr_add_raw(client, realm, newsubs)
+ Client *client;
+ Realm *realm;
+ Destlist *newsubs;
{
- Destlist *subs, *subs2, **head;
+ Destlist *subs, *subs2, *subs3, **head;
Code_t retval;
+#if 0
+ zdbug((LOG_DEBUG, "subscr_add_raw"));
+#endif
head = (realm) ? &realm->subs : &client->subs;
/* Loop over the new subscriptions. */
}
} else {
if (!realm) {
- ZRealm *remrealm =
+ Realm *remrealm =
realm_get_realm_by_name(subs->dest.recip->string + 1);
if (remrealm) {
Destlist *sub = (Destlist *) malloc(sizeof(Destlist));
sub->dest.classname = make_string(subs->dest.classname->string, 0);
sub->dest.inst = make_string(subs->dest.inst->string, 0);
sub->dest.recip = make_string(subs->dest.recip->string, 0);
+#if 1
zdbug ((LOG_DEBUG, "subscr: add %s/%s/%s in %s",
sub->dest.classname->string, sub->dest.inst->string,
sub->dest.recip->string, remrealm->name));
- Destlist_insert(&remrealm->remsubs, sub);
+#endif
+ LIST_INSERT(&remrealm->remsubs, sub);
}
}
}
}
- Destlist_insert(head, subs);
+ LIST_INSERT(head, subs);
}
return ZERR_NONE;
}
/* Called from bdump_recv_loop to decapsulate realm subs */
Code_t
-subscr_realm(ZRealm *realm,
- ZNotice_t *notice)
+subscr_realm(realm, notice)
+ Realm *realm;
+ ZNotice_t *notice;
{
Destlist *newsubs;
/* Like realm_sendit, this only takes one item from subs */
static void
-subscr_unsub_sendit(Client *who,
- Destlist *subs,
- ZRealm *realm)
+subscr_unsub_sendit(who, subs, realm)
+ Client *who;
+ Destlist *subs;
+ Realm *realm;
{
ZNotice_t unotice;
Code_t retval;
char **list;
char *pack;
int packlen;
+ int found = 0;
Destlist *subsp, *subsn;
for (subsp = realm->remsubs; subsp; subsp = subsn) {
subsn = subsp->next;
if (ZDest_eq(&subs->dest, &subsp->dest)) {
+#if 1
zdbug ((LOG_DEBUG, "subscr: del %s/%s/%s in %s",
subsp->dest.classname->string, subsp->dest.inst->string,
subsp->dest.recip->string, realm->name));
- Destlist_delete(subsp);
+#endif
+ LIST_DELETE(subsp);
free_subscription(subsp);
break;
}
/* Called from bump_send_loop by way of realm_send_realms */
Code_t
-subscr_send_realm_subs(ZRealm *realm)
+subscr_send_realm_subs(realm)
+ Realm *realm;
{
int i = 0;
Destlist *subs, *next;
int num = 0;
Code_t retval;
+#if 0
+ zdbug((LOG_DEBUG, "send_realm_subs"));
+#endif
+
strcpy(buf, realm->name);
list[num++] = buf;
}
Code_t
-subscr_realm_subs(ZRealm *realm)
+subscr_realm_subs(realm)
+ Realm *realm;
{
+ int i = 0;
Destlist *subs, *next;
+ char buf[512];
char *text[2 + NUM_FIELDS];
unsigned short num = 0;
Code_t retval;
Client **clientp;
char port[16];
+#if 0
+ zdbug((LOG_DEBUG, "realm_subs"));
+#endif
+
if (!realm->remsubs)
return ZERR_NONE;
/* Called from subscr_foreign_user for REALM_REQ_SUBSCRIBE */
static Code_t
-subscr_check_foreign_subs(ZNotice_t *notice,
- struct sockaddr_in *who,
- Server *server,
- ZRealm *realm,
- Destlist *newsubs)
+subscr_check_foreign_subs(notice, who, server, realm, newsubs)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ Server *server;
+ Realm *realm;
+ Destlist *newsubs;
{
- Destlist *subs, *next;
+ Destlist *subs, *subs2, *next;
Acl *acl;
char **text;
int found = 0;
found = 0;
for (subs = newsubs; subs; subs = next) {
- ZRealm *rlm;
+ Realm *rlm;
next=subs->next;
if (subs->dest.recip->string[0] != '\0') {
rlm = realm_which_realm(who);
return retval;
}
}
- Destlist_insert(&realm->subs, subs);
+ LIST_INSERT(&realm->subs, subs);
}
/* don't send confirmation if we're not the initial server contacted */
if (!(server_which_server(who) || found == 0)) {
}
/* Called from realm_control_dispatch for REALM_REQ/ADD_SUBSCRIBE */
-Code_t subscr_foreign_user(ZNotice_t *notice,
- struct sockaddr_in *who,
- Server *server,
- ZRealm *realm)
+Code_t subscr_foreign_user(notice, who, server, realm)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ Server *server;
+ Realm *realm;
{
Destlist *newsubs, *temp;
+ Acl *acl;
Code_t status;
Client *client;
ZNotice_t snotice;
char *cp, *tp0, *tp1;
char rlm_recipient[REALM_SZ + 1];
+#if 0
+ zdbug((LOG_DEBUG, "subscr_foreign_user"));
+#endif
+
tp0 = cp = notice->z_message;
newwho.sin_addr.s_addr = inet_addr(cp);
if (newwho.sin_addr.s_addr == -1) {
- syslog(LOG_ERR, "malformed addr from %s", notice->z_sender);
+ syslog(LOG_ERR, "malformed addr from %s, notice->z_sender");
return(ZERR_NONE);
}
/* translate the recipient to represent the foreign realm */
sprintf(rlm_recipient, "@%s", realm->name);
for (temp = newsubs; temp; temp = temp->next) {
+#if 0
+ syslog(LOG_DEBUG, "in foreign_user: class is %s", temp->dest.classname->string);
+#endif
temp->dest.recip = make_string(rlm_recipient, 0);
}
- status = subscr_add_raw(client, (ZRealm *)0, newsubs);
+ status = subscr_add_raw(client, (Realm *)0, newsubs);
} else if (!strcmp(snotice.z_opcode, REALM_REQ_SUBSCRIBE)) {
zdbug((LOG_DEBUG, "subscr_foreign_user REQ %s/%s", tp0, tp1));
status = subscr_check_foreign_subs(notice, who, server, realm, newsubs);
static int num_timers = 0;
static int heap_size = 0;
-static void timer_botch (void*);
-static Timer *add_timer (Timer *);
+static void timer_botch __P((void*));
+static Timer *add_timer __P((Timer *));
-Timer *
-timer_set_rel(long time_rel,
- void (*proc)(void *),
- void *arg)
+Timer *timer_set_rel(time_rel, proc, arg)
+ long time_rel;
+ void (*proc) __P((void *));
+ void *arg;
{
Timer *new_t;
}
void
-timer_reset(Timer *tmr)
+timer_reset(tmr)
+ Timer *tmr;
{
int pos, min;
#define set_timeval(t,s) ((t).tv_sec=(s),(t).tv_usec=0,(t))
static Timer *
-add_timer(Timer *new)
+add_timer(new)
+ Timer *new;
{
int pos;
}
void
-timer_process(void)
+timer_process()
{
Timer *t;
timer_proc func;
void *arg;
+ int valid = 0;
if (num_timers == 0 || heap[0]->abstime > NOW)
return;
}
struct timeval *
-timer_timeout(struct timeval *tvbuf)
+timer_timeout(tvbuf)
+ struct timeval *tvbuf;
{
if (num_timers > 0) {
tvbuf->tv_sec = heap[0]->abstime - NOW;
}
static void
-timer_botch(void *arg)
+timer_botch(arg)
+ void *arg;
{
syslog(LOG_CRIT, "timer botch\n");
abort();
static char **ulogin_marshal_locs __P((ZNotice_t *notice, int *found,
int auth));
+static int ul_equiv __P((Location *l1, Location *l2));
+
static void free_loc __P((Location *loc));
static void ulogin_locate_forward __P((ZNotice_t *notice,
- struct sockaddr_in *who, ZRealm *realm));
+ struct sockaddr_in *who, Realm *realm));
static Location *locations = NULL; /* ptr to first in array */
static int num_locs = 0; /* number in array */
*/
Code_t
-ulogin_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+ulogin_dispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
Exposure_type retval;
int err_ret;
login_sendit(notice, auth, who, 1);
}
} else {
- if (!strcmp(notice->z_opcode, LOGIN_USER_LOGIN)) {
- zdbug((LOG_DEBUG, "ulog opcode from unknown foreign realm %s",
- notice->z_opcode));
- } else {
- syslog(LOG_ERR, "unknown ulog opcode %s", notice->z_opcode);
- }
+ syslog(LOG_ERR, "unknown ulog opcode %s", notice->z_opcode);
if (server == me_server)
nack(notice, who);
return ZERR_NONE;
}
static void
-login_sendit(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- int external)
+login_sendit(notice, auth, who, external)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ int external;
{
ZNotice_t log_notice;
* Dispatch a LOCATE notice.
*/
Code_t
-ulocate_dispatch(ZNotice_t *notice,
- int auth,
- struct sockaddr_in *who,
- Server *server)
+ulocate_dispatch(notice, auth, who, server)
+ ZNotice_t *notice;
+ int auth;
+ struct sockaddr_in *who;
+ Server *server;
{
char *cp;
- ZRealm *realm;
+ Realm *realm;
if (!strcmp(notice->z_opcode, LOCATE_LOCATE)) {
/* we are talking to a current-rev client; send an ack */
ulogin_locate(notice, who, auth);
return ZERR_NONE;
} else {
- syslog(LOG_ERR, "unknown uloc opcode %s", notice->z_opcode);
+ syslog(LOG_ERR, "unknown uloc opcode %s", notice->z_opcode);
if (server == me_server)
nack(notice, who);
return ZERR_NONE;
*/
void
-uloc_hflush(struct in_addr *addr)
+uloc_hflush(addr)
+ struct in_addr *addr;
{
Location *loc;
int i = 0, new_num = 0;
}
void
-uloc_flush_client(struct sockaddr_in *sin)
+uloc_flush_client(sin)
+ struct sockaddr_in *sin;
{
Location *loc;
int i = 0, new_num = 0;
/*ARGSUSED*/
Code_t
-uloc_send_locations(void)
+uloc_send_locations()
{
Location *loc;
int i;
default:
syslog(LOG_ERR,"broken location state %s/%d",
loc->user->string, (int) loc->exposure);
- exposure_level = EXPOSE_OPSTAFF;
break;
}
retval = bdump_send_list_tcp(ACKED, &loc->addr, LOGIN_CLASS,
*/
static int
-ulogin_add_user(ZNotice_t *notice,
- Exposure_type exposure,
- struct sockaddr_in *who)
+ulogin_add_user(notice, exposure, who)
+ ZNotice_t *notice;
+ Exposure_type exposure;
+ struct sockaddr_in *who;
{
Location *loc, *oldlocs, newloc;
int i;
*/
static int
-ulogin_setup(ZNotice_t *notice,
- Location *locs,
- Exposure_type exposure,
- struct sockaddr_in *who)
+ulogin_setup(notice, locs, exposure, who)
+ ZNotice_t *notice;
+ Location *locs;
+ Exposure_type exposure;
+ struct sockaddr_in *who;
{
if (ulogin_parse(notice, locs))
return 1;
*/
static int
-ulogin_parse(ZNotice_t *notice,
- Location *locs)
+ulogin_parse(notice, locs)
+ ZNotice_t *notice;
+ Location *locs;
{
char *cp, *base;
int nulls = 0;
static Location *
-ulogin_find(char *user,
- struct in_addr *host,
- unsigned int port)
+ulogin_find(user, host, port)
+ char *user;
+ struct in_addr *host;
+ unsigned int port;
{
Location *loc;
String *str;
*/
static Location *
-ulogin_find_user(char *user)
+ulogin_find_user(user)
+ char *user;
{
int i, rlo, rhi;
int compar;
return &locations[i];
}
+static int
+ul_equiv(l1, l2)
+ Location *l1, *l2;
+{
+ if (l1->machine != l2->machine)
+ return 0;
+ if (l1->tty != l2->tty)
+ return 0;
+ return 1;
+}
+
/*
* remove the user specified in notice from the internal table
*/
static Exposure_type
-ulogin_remove_user(ZNotice_t *notice,
- struct sockaddr_in *who,
- int *err_return)
+ulogin_remove_user(notice, who, err_return)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ int *err_return;
{
Location *new_locs, *loc;
int i = 0;
*/
static void
-ulogin_flush_user(ZNotice_t *notice)
+ulogin_flush_user(notice)
+ ZNotice_t *notice;
{
Location *loc, *loc2;
int i, j, num_match, num_left;
static void
-ulogin_locate(ZNotice_t *notice,
- struct sockaddr_in *who,
- int auth)
+ulogin_locate(notice, who, auth)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ int auth;
{
char **answer;
int found;
*/
static char **
-ulogin_marshal_locs(ZNotice_t *notice,
- int *found,
- int auth)
+ulogin_marshal_locs(notice, found, auth)
+ ZNotice_t *notice;
+ int *found;
+ int auth;
{
Location **matches = (Location **) 0;
Location *loc;
}
void
-uloc_dump_locs(FILE *fp)
+uloc_dump_locs(fp)
+ FILE *fp;
{
int i;
}
static void
-free_loc(Location *loc)
+free_loc(loc)
+ Location *loc;
{
free_string(loc->user);
free_string(loc->machine);
}
static void
-ulogin_locate_forward(ZNotice_t *notice,
- struct sockaddr_in *who,
- ZRealm *realm)
+ulogin_locate_forward(notice, who, realm)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ Realm *realm;
{
ZNotice_t lnotice;
}
void
-ulogin_realm_locate(ZNotice_t *notice,
- struct sockaddr_in *who,
- ZRealm *realm)
+ulogin_realm_locate(notice, who, realm)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
+ Realm *realm;
{
char **answer;
int found;
}
void
-ulogin_relay_locate(ZNotice_t *notice,
- struct sockaddr_in *who)
+ulogin_relay_locate(notice, who)
+ ZNotice_t *notice;
+ struct sockaddr_in *who;
{
ZNotice_t lnotice;
Code_t retval;
lnotice = *notice;
lnotice.z_opcode = LOCATE_LOCATE;
lnotice.z_kind = ACKED;
- lnotice.z_auth = 0;
- lnotice.z_authent_len = 0;
- lnotice.z_ascii_authent = "";
- lnotice.z_checksum = 0;
- lnotice.z_ascii_checksum = "";
if ((retval = ZFormatRawNotice(&lnotice, &pack, &packlen)) != ZERR_NONE) {
syslog(LOG_WARNING, "ulog_relay_loc format: %s",
#include <zephyr/mit-copyright.h>
-#include <sys/utsname.h>
-
#include "zserver.h"
#include "version.h"
#endif
char *
-get_version(void)
+get_version()
{
static char vers_buf[256];
- struct utsname un;
if (vers_buf[0] == '\0') {
#ifdef DEBUG
#ifdef NeXT
(void) strcat(vers_buf, "NeXT");
#endif /* NeXT */
-
- if (vers_buf[strlen(vers_buf) - 1] == '/') {
- uname(&un);
- (void) strcat(vers_buf, un.machine);
- (void) strcat(vers_buf, "-");
- (void) strcat(vers_buf, un.sysname);
- }
}
return(vers_buf);
}
+
+
+
+
+
#include <zephyr/mit-copyright.h>
#include <internal.h>
-
-#include <com_err.h>
-
#include <arpa/inet.h>
#include "zsrv_err.h"
#include "access.h"
#include "acl.h"
-#if defined(HAVE_KRB5) || defined(HAVE_KRB4)
+#ifdef HAVE_KRB4
/* Kerberos-specific library interfaces used only by the server. */
-#ifdef HAVE_KRB5
-extern krb5_keyblock *__Zephyr_keyblock;
-#define ZGetSession() (__Zephyr_keyblock)
-void ZSetSession(krb5_keyblock *keyblock);
-Code_t ZFormatAuthenticNoticeV5(ZNotice_t*, char*, int, int*, krb5_keyblock *);
-krb5_error_code Z_krb5_init_keyblock(krb5_context, krb5_enctype, size_t,
- krb5_keyblock **);
-#else
extern C_Block __Zephyr_session;
#define ZGetSession() (__Zephyr_session)
-#endif
-void ZSetSessionDES(C_Block *key);
-
-Code_t ZFormatAuthenticNotice(ZNotice_t*, char*, int, int*, C_Block);
+Code_t ZFormatAuthenticNotice __P((ZNotice_t*, char*, int, int*, C_Block));
#endif
/* For krb_rd_req prototype and definition. */
#define KRB_INT32 ZEPHYR_INT32
#endif
+/* These macros are for insertion into and deletion from a singly-linked list
+ * with back pointers to the previous element's next pointer. In order to
+ * make these macros act like expressions, they use the comma operator for
+ * sequenced evaluations of assignment, and "a && b" for "evaluate assignment
+ * b if expression a is true". */
+#define LIST_INSERT(head, elem) \
+ ((elem)->next = *(head), \
+ (*head) && ((*(head))->prev_p = &(elem)->next), \
+ (*head) = (elem), (elem)->prev_p = (head))
+#define LIST_DELETE(elem) \
+ (*(elem)->prev_p = (elem)->next, \
+ (elem)->next && ((elem)->next->prev_p = (elem)->prev_p))
+
/* Current time as cached by main(); use instead of time(). */
#define NOW t_local.tv_sec
#ifdef HAVE_KRB4
+#ifndef NOENCRYPTION
/* Kerberos shouldn't stick us with array types... */
typedef struct {
des_key_schedule s;
} Sched;
#endif
+#endif
typedef struct _Destination Destination;
typedef struct _Destlist Destlist;
-typedef struct _ZRealm ZRealm;
-typedef struct _ZRealmname ZRealmname;
-typedef enum _ZRealm_state ZRealm_state;
+typedef struct _Realm Realm;
+typedef struct _Realmname Realmname;
+typedef enum _Realm_state Realm_state;
typedef struct _Client Client;
typedef struct _Triplet Triplet;
typedef enum _Server_state Server_state;
struct _Destlist *next, **prev_p;
};
-enum _ZRealm_state {
- REALM_UP, /* ZRealm is up */
- REALM_TARDY, /* ZRealm due for a hello XXX */
- REALM_DEAD, /* ZRealm is considered dead */
- REALM_STARTING /* ZRealm is between dead and up */
+enum _Realm_state {
+ REALM_UP, /* Realm is up */
+ REALM_TARDY, /* Realm due for a hello XXX */
+ REALM_DEAD, /* Realm is considered dead */
+ REALM_STARTING /* Realm is between dead and up */
};
-struct _ZRealm {
+struct _Realm {
char name[REALM_SZ];
int count;
struct sockaddr_in *addrs;
Client *client;
int child_pid;
int have_tkt;
- ZRealm_state state;
+ Realm_state state;
};
-struct _ZRealmname {
+struct _Realmname {
char name[REALM_SZ];
char **servers;
int nused;
struct _Client {
struct sockaddr_in addr; /* ipaddr/port of client */
Destlist *subs ; /* subscriptions */
-#ifdef HAVE_KRB5
- krb5_keyblock *session_keyblock;
-#else
#ifdef HAVE_KRB4
C_Block session_key; /* session key for this client */
#endif /* HAVE_KRB4 */
-#endif
String *principal; /* krb principal of user */
int last_send; /* Counter for last sent packet. */
time_t last_ack; /* Time of last received ack */
- ZRealm *realm;
+ Realm *realm;
struct _Client *next, **prev_p;
};
};
/* Function declarations */
-
-/* These macros instantiate inline functions that do the work of the formder
- LIST_INSERT and LIST_DELETE functions, which unfortunately triggered gcc's
- pedanticism. The comment before the *former* macros was: */
-/* These macros are for insertion into and deletion from a singly-linked list
- * with back pointers to the previous element's next pointer. In order to
- * make these macros act like expressions, they use the comma operator for
- * sequenced evaluations of assignment, and "a && b" for "evaluate assignment
- * b if expression a is true". */
-
-#define MAKE_LIST_INSERT(type) inline static void type##_insert(type **head, type *elem) \
- {\
- (elem)->next = *(head); \
- if(*head) (*(head))->prev_p = &(elem)->next; \
- (*head) = (elem); \
- (elem)->prev_p = (head); \
- }
-#define MAKE_LIST_DELETE(type) inline static void type##_delete(type *elem) \
- {\
- *(elem)->prev_p = (elem)->next; \
- if((elem)->next) (elem)->next->prev_p = (elem)->prev_p; \
- }
-
-MAKE_LIST_INSERT(Destlist);
-MAKE_LIST_DELETE(Destlist);
-MAKE_LIST_INSERT(Client);
-MAKE_LIST_DELETE(Client);
-MAKE_LIST_INSERT(Triplet);
-MAKE_LIST_DELETE(Triplet);
-MAKE_LIST_INSERT(Unacked);
-MAKE_LIST_DELETE(Unacked);
-
/* found in bdump.c */
-void bdump_get(ZNotice_t *notice, int auth, struct sockaddr_in *who,
- Server *server);
-void bdump_send(void);
-void bdump_offer(struct sockaddr_in *who);
-Code_t bdump_send_list_tcp(ZNotice_Kind_t kind, struct sockaddr_in *addr,
+void bdump_get __P((ZNotice_t *notice, int auth, struct sockaddr_in *who,
+ Server *server));
+void bdump_send __P((void));
+void bdump_offer __P((struct sockaddr_in *who));
+Code_t bdump_send_list_tcp __P((ZNotice_Kind_t kind, struct sockaddr_in *addr,
char *class_name, char *inst, char *opcode,
char *sender, char *recip, char **lyst,
- int num);
-int get_tgt(void);
+ int num));
+int get_tgt __P((void));
/* found in class.c */
extern String *class_control, *class_admin, *class_hm;
extern String *class_ulogin, *class_ulocate;
-int ZDest_eq(Destination *d1, Destination *d2);
-Code_t triplet_register(Client *client, Destination *dest, ZRealm *realm);
-Code_t triplet_deregister(Client *client, Destination *dest,
- ZRealm *realm);
-Code_t class_restrict(char *class, Acl *acl);
-Code_t class_setup_restricted(char *class, Acl *acl);
-Client **triplet_lookup(Destination *dest);
-Acl *class_get_acl(String *class);
-int dest_eq(Destination *d1, Destination *d2);
-int order_dest_strings(Destination *d1, Destination *d2);
-void triplet_dump_subs(FILE *fp);
+int ZDest_eq __P((Destination *d1, Destination *d2));
+Code_t triplet_register __P((Client *client, Destination *dest, Realm *realm));
+Code_t triplet_deregister __P((Client *client, Destination *dest,
+ Realm *realm));
+Code_t class_restrict __P((char *class, Acl *acl));
+Code_t class_setup_restricted __P((char *class, Acl *acl));
+Client **triplet_lookup __P((Destination *dest));
+Acl *class_get_acl __P((String *class));
+int dest_eq __P((Destination *d1, Destination *d2));
+int order_dest_strings __P((Destination *d1, Destination *d2));
+void triplet_dump_subs __P((FILE *fp));
/* found in client.c */
-Code_t client_register(ZNotice_t *notice, struct in_addr *host,
- Client **client_p, int wantdefaults);
-void client_deregister(Client *client, int flush);
-void client_flush_host(struct in_addr *host);
-void client_dump_clients(FILE *fp);
-Client *client_find(struct in_addr *host, unsigned int port);
-Code_t client_send_clients(void);
+Code_t client_register __P((ZNotice_t *notice, struct in_addr *host,
+ Client **client_p, int wantdefaults));
+void client_deregister __P((Client *client, int flush));
+void client_flush_host __P((struct in_addr *host));
+void client_dump_clients __P((FILE *fp));
+Client *client_find __P((struct in_addr *host, unsigned int port));
+Code_t client_send_clients __P((void));
/* found in common.c */
-char *strsave(const char *str);
-unsigned long hash (const char *);
-void dump_quote(char *p, FILE *fp);
+char *strsave __P((const char *str));
+unsigned long hash __P((const char *));
+void dump_quote __P((char *p, FILE *fp));
/* found in dispatch.c */
-void handle_packet(void);
-void clt_ack(ZNotice_t *notice, struct sockaddr_in *who, Sent_type sent);
-void nack_release(Client *client);
-void sendit(ZNotice_t *notice, int auth, struct sockaddr_in *who,
- int external);
-void rexmit(void *);
-void xmit(ZNotice_t *notice, struct sockaddr_in *dest, int auth,
- Client *client);
-Code_t hostm_dispatch(ZNotice_t *notice, int auth,
- struct sockaddr_in *who, Server *server);
-Code_t control_dispatch(ZNotice_t *notice, int auth,
- struct sockaddr_in *who, Server *server);
-Code_t xmit_frag(ZNotice_t *notice, char *buf, int len, int waitforack);
-void hostm_shutdown(void);
+void handle_packet __P((void));
+void clt_ack __P((ZNotice_t *notice, struct sockaddr_in *who, Sent_type sent));
+void nack_release __P((Client *client));
+void sendit __P((ZNotice_t *notice, int auth, struct sockaddr_in *who,
+ int external));
+void rexmit __P((void *));
+void xmit __P((ZNotice_t *notice, struct sockaddr_in *dest, int auth,
+ Client *client));
+Code_t hostm_dispatch __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who, Server *server));
+Code_t control_dispatch __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who, Server *server));
+Code_t xmit_frag __P((ZNotice_t *notice, char *buf, int len, int waitforack));
+void hostm_shutdown __P((void));
/* found in kstuff.c */
#ifdef HAVE_KRB4
-int GetKerberosData (int, struct in_addr, AUTH_DAT *, char *, char *);
-Code_t ReadKerberosData(int, int *, char **, int *);
-Code_t SendKerberosData (int, KTEXT, char *, char *);
-Code_t SendKrb5Data(int, krb5_data *);
-Code_t GetKrb5Data(int, krb5_data *);
-void sweep_ticket_hash_table(void *);
-Code_t ZCheckRealmAuthentication(ZNotice_t *, struct sockaddr_in *, char *);
+int GetKerberosData __P((int, struct in_addr, AUTH_DAT *, char *, char *));
+Code_t SendKerberosData __P((int, KTEXT, char *, char *));
+void sweep_ticket_hash_table __P((void *));
#endif
-
+
+/* found in kopt.c */
+#ifdef HAVE_KRB4
+#ifndef NOENCRYPTION
+Sched *check_key_sched_cache __P((des_cblock key));
+void add_to_key_sched_cache __P((des_cblock key, Sched *sched));
+int krb_set_key __P((char *key, int cvt));
+/* int krb_rd_req __P((KTEXT authent, char *service, char *instance,
+ unsigned KRB_INT32 from_addr, AUTH_DAT *ad, char *fn)); */
+int krb_find_ticket __P((KTEXT authent, KTEXT ticket));
+int krb_get_lrealm __P((char *r, int n));
+#endif
+#endif
+
/* found in server.c */
-void server_timo(void *which);
-void server_dump_servers(FILE *fp);
-void server_init(void);
-void server_shutdown(void);
-void server_forward(ZNotice_t *notice, int auth,
- struct sockaddr_in *who);
-void server_kill_clt(Client *client);
-void server_pending_free(Pending *pending);
-void server_self_queue(ZNotice_t *, int, struct sockaddr_in *);
-void server_send_queue(Server *);
-void server_reset(void);
-Server *server_which_server(struct sockaddr_in *who);
-Pending *server_dequeue(Server *server);
-Code_t server_dispatch(ZNotice_t *notice, int auth,
- struct sockaddr_in *who);
-Code_t server_adispatch(ZNotice_t *notice, int auth,
- struct sockaddr_in *who, Server *server);
+void server_timo __P((void *which));
+void server_dump_servers __P((FILE *fp));
+void server_init __P((void));
+void server_shutdown __P((void));
+void server_forward __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who));
+void server_kill_clt __P((Client *client));
+void server_pending_free __P((Pending *pending));
+void server_self_queue __P((ZNotice_t *, int, struct sockaddr_in *));
+void server_send_queue __P((Server *));
+void server_reset __P((void));
+int is_server();
+Server *server_which_server __P((struct sockaddr_in *who));
+Pending *server_dequeue __P((Server *server));
+Code_t server_dispatch __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who));
+Code_t server_adispatch __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who, Server *server));
/* found in subscr.c */
-Code_t subscr_foreign_user(ZNotice_t *, struct sockaddr_in *, Server *, ZRealm *);
-Code_t subscr_cancel(struct sockaddr_in *sin, ZNotice_t *notice);
-Code_t subscr_subscribe(Client *who, ZNotice_t *notice, Server *server);
-Code_t subscr_send_subs(Client *client);
-void subscr_cancel_client(Client *client);
-void subscr_sendlist(ZNotice_t *notice, int auth,
- struct sockaddr_in *who);
-void subscr_dump_subs(FILE *fp, Destlist *subs);
-void subscr_reset(void);
-Code_t subscr_def_subs(Client *who);
-Code_t subscr_realm(ZRealm *, ZNotice_t *);
-Code_t subscr_send_realm_subs(ZRealm *);
-Code_t subscr_realm_cancel(struct sockaddr_in *, ZNotice_t *, ZRealm *);
+Code_t subscr_foreign_user __P((ZNotice_t *, struct sockaddr_in *, Server *, Realm *));
+Code_t subscr_cancel __P((struct sockaddr_in *sin, ZNotice_t *notice));
+Code_t subscr_subscribe __P((Client *who, ZNotice_t *notice, Server *server));
+Code_t subscr_send_subs __P((Client *client));
+void subscr_cancel_client __P((Client *client));
+void subscr_sendlist __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who));
+void subscr_dump_subs __P((FILE *fp, Destlist *subs));
+void subscr_reset __P((void));
+Code_t subscr_def_subs __P((Client *who));
/* found in uloc.c */
-void uloc_hflush(struct in_addr *addr);
-void uloc_flush_client(struct sockaddr_in *sin);
-void uloc_dump_locs(FILE *fp);
-Code_t ulogin_dispatch(ZNotice_t *notice, int auth,
- struct sockaddr_in *who, Server *server);
-Code_t ulocate_dispatch(ZNotice_t *notice, int auth,
- struct sockaddr_in *who, Server *server);
-Code_t uloc_send_locations(void);
-void ulogin_relay_locate(ZNotice_t *, struct sockaddr_in *);
-void ulogin_realm_locate(ZNotice_t *, struct sockaddr_in *, ZRealm *);
+void uloc_hflush __P((struct in_addr *addr));
+void uloc_flush_client __P((struct sockaddr_in *sin));
+void uloc_dump_locs __P((FILE *fp));
+Code_t ulogin_dispatch __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who, Server *server));
+Code_t ulocate_dispatch __P((ZNotice_t *notice, int auth,
+ struct sockaddr_in *who, Server *server));
+Code_t uloc_send_locations __P((void));
/* found in realm.c */
-int realm_sender_in_realm(char *realm, char *sender);
-int realm_bound_for_realm(char *realm, char *recip);
-ZRealm *realm_which_realm(struct sockaddr_in *who);
-ZRealm *realm_get_realm_by_name(char *name);
-ZRealm *realm_get_realm_by_pid(int);
-void realm_handoff(ZNotice_t *, int, struct sockaddr_in *, ZRealm *, int);
+int realm_sender_in_realm __P((char *realm, char *sender));
+int realm_bound_for_realm __P((char *realm, char *recip));
+Realm *realm_which_realm __P((struct sockaddr_in *who));
+Realm *realm_get_realm_by_name __P((char *name));
+Realm *realm_get_realm_by_pid __P((int));
+void realm_handoff(ZNotice_t *, int, struct sockaddr_in *, Realm *, int);
char *realm_expand_realm(char *);
-void realm_init(void);
-Code_t ZCheckZRealmAuthentication(ZNotice_t *, struct sockaddr_in *,
- char *);
-Code_t realm_control_dispatch(ZNotice_t *, int, struct sockaddr_in *,
- Server *, ZRealm *);
-void realm_shutdown(void);
-void realm_deathgram(Server *);
-Code_t realm_send_realms(void);
-Code_t realm_dispatch(ZNotice_t *, int, struct sockaddr_in *, Server *);
-void realm_wakeup(void);
-void kill_realm_pids(void);
-void realm_dump_realms(FILE *);
+void realm_init __P((void));
+Code_t ZCheckRealmAuthentication __P((ZNotice_t *, struct sockaddr_in *,
+ char *));
+Code_t realm_control_dispatch __P((ZNotice_t *, int, struct sockaddr_in *,
+ Server *, Realm *));
+void realm_shutdown __P((void));
+void realm_deathgram __P((Server *));
/* found in version.c */
-char *get_version(void);
-
-/* found in access.c */
-int access_check(char *, Acl *, Access);
+char *get_version __P((void));
/* global identifiers */
/* found in main.c */
-int packets_waiting(void);
+int packets_waiting __P((void));
extern struct sockaddr_in srv_addr; /* server socket address */
extern unsigned short hm_port; /* host manager receiver port */
extern unsigned short hm_srv_port; /* host manager server sending port */
extern int zdebug;
extern char myname[]; /* domain name of this host */
extern char list_file[];
-#ifdef HAVE_KRB5
-extern char keytab_file[];
-extern krb5_ccache Z_krb5_ccache;
-#endif
#ifdef HAVE_KRB4
extern char srvtab_file[];
extern char my_realm[];
extern String *empty;
extern String *wildcard_instance;
-extern ZRealm *otherrealms;
+extern Realm *otherrealms;
extern int nrealms;
extern struct in_addr my_addr; /* my inet address */
#define SERVER_LIST_FILE "server.list"
#define REALM_LIST_FILE "realm.list"
-#ifdef HAVE_KRB5
-#define ZEPHYR_KEYTAB "krb5.keytab"
-#define ZEPHYR_TK5FILE "z5tkts"
-#endif
#ifdef HAVE_KRB4
#define ZEPHYR_SRVTAB "srvtab"
#define ZEPHYR_TKFILE "ztkts"
ec ZSRV_NOSUB,
"No such subscription"
ec ZSRV_NOCLASS,
- "Class unknown"
+ "Class unkown"
ec ZSRV_CLASSXISTS,
"Class already registered"
ec ZSRV_CLASSRESTRICTED,
static String *zhash[STRING_HASH_TABLE_SIZE];
String *
-make_string(char *s,
- int downcase)
+make_string(s, downcase)
+ char *s;
+ int downcase;
{
char *new_s,*p;
String *new_z,*hp;
}
void
-free_string(String *z)
+free_string(z)
+ String *z;
{
if (z == (String *) NULL)
return;
}
String *
-find_string(char *s,
- int downcase)
+find_string(s,downcase)
+ char *s;
+ int downcase;
{
char *new_s,*p;
String *z;
}
int
-comp_string(String *a,
- String *b)
+comp_string(a,b)
+ String *a, *b;
{
if (a->hash_val > b->hash_val)
return 1;
}
void
-print_string_table(FILE *f)
+print_string_table(f)
+ FILE *f;
{
String *p;
int i;
}
String *
-dup_string(String *z)
+dup_string(z)
+ String *z;
{
z->ref_count++;
return z;
#ifndef lint
#ifndef SABER
-static const char rcsid_queue_c[] = "$Id$";
+static char rcsid_queue_c[] = "$Id$";
#endif /* SABER */
#endif /* lint */
static Queue *hm_queue;
static int retransmits_enabled = 0;
-static Queue *find_notice_in_queue(ZNotice_t *notice);
-static void queue_timeout(void *arg);
-
-extern void new_server(char *);
+static Queue *find_notice_in_queue __P((ZNotice_t *notice));
+static Code_t dump_queue __P((void));
+static void queue_timeout __P((void *arg));
int rexmit_times[] = { 2, 2, 4, 4, 8, -1 };
#ifdef DEBUG
-Code_t dump_queue(void);
+Code_t dump_queue();
#endif
-void
-init_queue(void)
+void init_queue()
{
Queue *q;
DPR("Queue initialized and flushed.\n");
}
-Code_t
-add_notice_to_queue(ZNotice_t *notice,
- char *packet,
- struct sockaddr_in *repl,
- int len)
+Code_t add_notice_to_queue(notice, packet, repl, len)
+ ZNotice_t *notice;
+ char * packet;
+ struct sockaddr_in *repl;
+ int len;
{
Queue *entry;
free(entry->packet);
} else {
entry->reply = *repl;
- /*LIST_INSERT(&hm_queue, entry);*/
-
- (entry)->next = *(&hm_queue);
- if (*&hm_queue) ((*(&hm_queue))->prev_p = &(entry)->next);
- (*&hm_queue) = (entry);
- (entry)->prev_p = (&hm_queue);
-
+ LIST_INSERT(&hm_queue, entry);
}
entry->timer = (retransmits_enabled) ?
timer_set_rel(rexmit_times[0], queue_timeout, entry) : NULL;
return(ZERR_NONE);
}
-Code_t
-remove_notice_from_queue(ZNotice_t *notice,
- ZNotice_Kind_t *kind,
- struct sockaddr_in *repl)
+Code_t remove_notice_from_queue(notice, kind, repl)
+ ZNotice_t *notice;
+ ZNotice_Kind_t *kind;
+ struct sockaddr_in *repl;
{
Queue *entry;
if (entry->timer)
timer_reset(entry->timer);
free(entry->packet);
- /*LIST_DELETE(entry);*/
- *(entry)->prev_p = (entry)->next;
- if((entry)->next) ((entry)->next->prev_p = (entry)->prev_p);
+ LIST_DELETE(entry);
#ifdef DEBUG
dump_queue();
#endif /* DEBUG */
}
/* We have a server; transmit all of our packets. */
-void
-retransmit_queue(struct sockaddr_in *sin)
+void retransmit_queue(sin)
+ struct sockaddr_in *sin;
{
Queue *entry;
Code_t ret;
}
/* We lost our server; nuke all of our timers. */
-void
-disable_queue_retransmits(void)
+void disable_queue_retransmits()
{
Queue *entry;
}
#ifdef DEBUG
-static Code_t
-dump_queue(void)
+static Code_t dump_queue()
{
Queue *entry;
caddr_t mp;
}
#endif /* DEBUG */
-int
-queue_len(void)
+int queue_len()
{
int length = 0;
Queue *entry;
return length;
}
-static Queue *
-find_notice_in_queue(ZNotice_t *notice)
+static Queue *find_notice_in_queue(notice)
+ ZNotice_t *notice;
{
Queue *entry;
return NULL;
}
-static void
-queue_timeout(void *arg)
+static void queue_timeout(arg)
+ void *arg;
{
Queue *entry = (Queue *) arg;
Code_t ret;
static int num_timers = 0;
static int heap_size = 0;
-static void timer_botch (void*);
-static Timer *add_timer (Timer *);
+static void timer_botch __P((void*));
+static Timer *add_timer __P((Timer *));
-Timer *
-timer_set_rel(long time_rel,
- void (*proc)(void *),
- void *arg)
+Timer *timer_set_rel(time_rel, proc, arg)
+ long time_rel;
+ void (*proc) __P((void *));
+ void *arg;
{
Timer *new_t;
}
void
-timer_reset(Timer *tmr)
+timer_reset(tmr)
+ Timer *tmr;
{
int pos, min;
#define set_timeval(t,s) ((t).tv_sec=(s),(t).tv_usec=0,(t))
static Timer *
-add_timer(Timer *new)
+add_timer(new)
+ Timer *new;
{
int pos;
}
void
-timer_process(void)
+timer_process()
{
Timer *t;
timer_proc func;
void *arg;
+ int valid = 0;
if (num_timers == 0 || heap[0]->abstime > time(NULL))
return;
}
struct timeval *
-timer_timeout(struct timeval *tvbuf)
+timer_timeout(tvbuf)
+ struct timeval *tvbuf;
{
if (num_timers > 0) {
tvbuf->tv_sec = heap[0]->abstime - time(NULL);
}
static void
-timer_botch(void *arg)
+timer_botch(arg)
+ void *arg;
{
syslog(LOG_CRIT, "timer botch\n");
abort();
char hostname[MAXHOSTNAMELEN], loopback[4];
char PidFile[128];
-static RETSIGTYPE deactivate(int);
-static RETSIGTYPE terminate(int);
-static void choose_server(void);
-static void init_hm(void);
-static void detach(void);
-static void send_stats(ZNotice_t *, struct sockaddr_in *);
-static char *strsave(const char *);
-
-extern void send_flush_notice(char *);
-extern void server_manager(ZNotice_t *);
-extern void send_boot_notice(char *);
-extern void find_next_server(char *);
+static RETSIGTYPE deactivate __P((void));
+static RETSIGTYPE terminate __P((void));
+static void choose_server __P((void));
+static void init_hm __P((void));
+static void detach __P((void));
+static void send_stats __P((ZNotice_t *, struct sockaddr_in *));
+static char *strsave __P((const char *));
extern int optind;
-static RETSIGTYPE
-deactivate(int ignored)
+static RETSIGTYPE deactivate()
{
deactivating = 1;
}
-static RETSIGTYPE
-terminate(int ignored)
+static RETSIGTYPE terminate()
{
terminating = 1;
}
-int
-main(int argc,
- char *argv[])
+main(argc, argv)
+char *argv[];
{
ZNotice_t notice;
ZPacket_t packet;
Code_t ret;
- int opt, pak_len, fd, count;
+ int opt, pak_len, i, j = 0, fd, count;
fd_set readers;
struct timeval tv;
}
}
-static void
-choose_server(void)
+static void choose_server()
{
int i = 0;
char **clust_info, **cpp;
}
}
-static void
-init_hm(void)
+static void init_hm()
{
struct servent *sp;
Code_t ret;
#endif
}
-static void
-detach(void)
+static void detach()
{
/* detach from terminal and fork. */
register int i, x = ZGetFD();
register long size;
-
- i = fork();
- if (i) {
+
+ if (i = fork()) {
if (i < 0)
perror("fork");
exit(0);
static char version[BUFSIZ];
-static void
-send_stats(ZNotice_t *notice,
- struct sockaddr_in *sin)
+static void send_stats(notice, sin)
+ ZNotice_t *notice;
+ struct sockaddr_in *sin;
{
ZNotice_t newnotice;
Code_t ret;
free(list[i]);
}
-void
-die_gracefully(void)
+void die_gracefully()
{
syslog(LOG_INFO, "Terminate signal caught...");
unlink(PidFile);
exit(0);
}
-static char *
-strsave(const char *sp)
+static char *strsave(sp)
+ const char *sp;
{
register char *ret;
- if((ret = strdup(sp)) == NULL) {
+ if((ret = malloc((unsigned) strlen(sp)+1)) == NULL) {
abort();
}
+ strcpy(ret,sp);
return(ret);
}
#include <zephyr/mit-copyright.h>
#include <internal.h>
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <sys/time.h>
#include "timer.h"
#ifndef lint
#ifndef SABER
-static const char rcsid_hm_client_c[] = "$Id$";
+static char rcsid_hm_client_c[] = "$Id$";
#endif /* SABER */
#endif /* lint */
extern int no_server, nclt, deactivated, noflushflag;
extern struct sockaddr_in cli_sin, serv_sin, from;
-extern void send_flush_notice(char *);
-extern void new_server(char *sugg_serv);
-
-void transmission_tower(ZNotice_t *notice,
- char *packet,
- int pak_len)
+void transmission_tower(notice, packet, pak_len)
+ ZNotice_t *notice;
+ char *packet;
+ int pak_len;
{
ZNotice_t gack;
Code_t ret;
Zperr(ret);
com_err("hm", ret, "setting destination");
}
- if ((ret = ZSendPacket(packet, pak_len, 0)) != ZERR_NONE) {
+ if ((ret = send_outgoing(notice)) != ZERR_NONE) {
Zperr(ret);
com_err("hm", ret, "while sending raw notice");
}
}
Code_t
-send_outgoing(ZNotice_t *notice)
+send_outgoing(notice)
+ZNotice_t *notice;
{
Code_t retval;
char *packet;
#ifndef lint
#ifndef SABER
-static const char rcsid_hm_server_c[] = "$Id$";
+static char rcsid_hm_server_c[] = "$Id$";
#endif /* SABER */
#endif /* lint */
extern int numserv;
extern char **serv_list;
extern char cur_serv[], prim_serv[];
-extern void die_gracefully(void);
+extern void die_gracefully();
-void hm_control(ZNotice_t *);
-void send_back(ZNotice_t *);
-void new_server(char *);
+void hm_control(), send_back(), new_server();
/* Argument is whether we are actually booting, or just attaching
* after a server switch */
void
-send_boot_notice(char *op)
+send_boot_notice(op)
+char *op;
{
ZNotice_t notice;
Code_t ret;
/* Argument is whether we are detaching or really going down */
void
-send_flush_notice(char *op)
+send_flush_notice(op)
+char *op;
{
ZNotice_t notice;
Code_t ret;
}
void
-find_next_server(char *sugg_serv)
+find_next_server(sugg_serv)
+char *sugg_serv;
{
struct hostent *hp;
int done = 0;
}
void
-server_manager(ZNotice_t *notice)
+server_manager(notice)
+ZNotice_t *notice;
{
if (memcmp((char *)&serv_sin.sin_addr, (char *)&from.sin_addr, 4) ||
(serv_sin.sin_port != from.sin_port)) {
}
void
-hm_control(ZNotice_t *notice)
+hm_control(notice)
+ZNotice_t *notice;
{
Code_t ret;
struct hostent *hp;
}
void
-send_back(ZNotice_t *notice)
+send_back(notice)
+ZNotice_t *notice;
{
ZNotice_Kind_t kind;
struct sockaddr_in repl;
}
void
-new_server(char *sugg_serv)
+new_server(sugg_serv)
+char *sugg_serv;
{
no_server = 1;
syslog (LOG_INFO, "Server went down, finding new server.");
disable_queue_retransmits();
}
-static void
-boot_timeout(void *arg)
+static void boot_timeout(arg)
+void *arg;
{
serv_timeouts++;
new_server(NULL);
parser.o: y.tab.c y.tab.h
${CC} -c ${ALL_CFLAGS} -o $@ y.tab.c
-y.tab.c y.tab.h: ${srcdir}/parser.y
+y.tab.c y.tab.h: parser.y
${YACC} ${YFLAGS} ${srcdir}/parser.y
.c.o:
#ifndef X_DISPLAY_MISSING
-#include "new_string.h"
#include "X_driver.h"
#include <X11/Xresource.h>
#include "new_memory.h"
#include "X_gram.h"
#include "xselect.h"
#include "unsigned_long_dictionary.h"
-#include "zephyr.h"
char *app_instance;
* returns -1.
*/
-static int
-convert_string_to_bool(string text)
+static int convert_string_to_bool(text)
+ string text;
{
if (!strcasecmp("yes", text) || !strcasecmp("y", text) ||
!strcasecmp("true", text) || !strcasecmp("t", text) ||
*
*/
-char *
-get_string_resource(string name,
- string class)
+char *get_string_resource(name, class)
+ string name;
+ string class;
{
string full_name, full_class;
int status;
*
*/
-int
-get_bool_resource(string name,
- string class,
- int default_value)
+int get_bool_resource(name, class, default_value)
+ string name;
+ string class;
+ int default_value;
{
int result;
char *temp;
* trip each time.
*/
-unsigned long
-x_string_to_color(char *name,
- unsigned long def)
+unsigned long x_string_to_color(name,def)
+ char *name;
+ unsigned long def;
{
unsigned_long_dictionary_binding *binding;
int exists;
*
*/
-int
-open_display_and_load_resources(int *pargc,
- char **argv)
+int open_display_and_load_resources(pargc, argv)
+ int *pargc;
+ char **argv;
{
XrmDatabase temp_db1, temp_db2, temp_db3;
char *filename, *res, *xdef;
char dbasename[128];
+ extern char *getenv();
/* Initialize X resource manager: */
XrmInitialize();
/*
* Get XENVIRONMENT resources, if they exist, and merge
*/
- filename = getenv("XENVIRONMENT");
- if (filename)
+ if (filename = getenv("XENVIRONMENT"))
{
temp_db3 = XrmGetFileDatabase(filename);
XrmMergeDatabases(temp_db3, &temp_db1);
*
*/
-int
-X_driver_ioerror(Display *display)
+int X_driver_ioerror(display)
+Display *display;
{
+ extern void finalize_zephyr();
+
ERROR2("X IO error on display '%s'--exiting\n", DisplayString(display));
finalize_zephyr();
exit(1);
/* */
/****************************************************************************/
+extern void x_get_input();
+
/*ARGSUSED*/
-int
-X_driver_init(char *drivername,
- char notfirst,
- int *pargc,
- char **argv)
+int X_driver_init(drivername, notfirst, pargc, argv)
+ char *drivername;
+ char notfirst;
+ int *pargc;
+ char **argv;
{
string temp;
int sync;
/*
* For now, set some useful variables using resources:
*/
- sync = get_bool_resource("synchronous", "Synchronous", 0);
- if (sync)
- XSynchronize(dpy, sync);
- temp = get_string_resource("geometry", "Geometry");
- if (temp)
+ if (sync=get_bool_resource("synchronous", "Synchronous", 0))
+ XSynchronize(dpy,sync);
+ if (temp = get_string_resource("geometry", "Geometry"))
var_set_variable("default_X_geometry", temp);
temp=strrchr(argv[0],'/');
x_gram_init(dpy);
xicccmInitAtoms(dpy);
- mux_add_input_source(ConnectionNumber(dpy), (void(*)(void *))x_get_input, dpy);
+ mux_add_input_source(ConnectionNumber(dpy), x_get_input, dpy);
return(0);
}
-void
-X_driver_reset(void)
+void X_driver_reset()
{
}
/* */
/****************************************************************************/
-char *
-X_driver(string text)
+char *X_driver(text)
+ string text;
{
string text_copy;
desctype *desc;
#include <X11/Xlib.h>
-#include "new_string.h"
-
extern Display *dpy;
-extern char *get_string_resource(string, string);
-extern int get_bool_resource(string, string, int);
-extern unsigned long x_string_to_color(char *, unsigned long);
+extern char *get_string_resource();
+extern int get_bool_resource();
#endif
static string face_to_string[] = { "roman", "bold", "italic", "bolditalic" };
static string size_to_string[] = { "small", "medium", "large" };
-static char *
-get_family(char *style,
- char *substyle)
+extern char *get_string_resources();
+
+static char *get_family(style,substyle)
+ char *style;
+ char *substyle;
{
char *desc;
pointer_dictionary_binding *binding;
}
}
-static char *
-get_specific_fontname(char *family,
- int size,
- int face)
+static char *get_specific_fontname(family,size,face)
+ char *family;
+ int size;
+ int face;
{
char *desc;
pointer_dictionary_binding *binding;
* that I know that Font us really an unsigned long. */
static char hexdigits[] = {"0123456789ABCDEF"};
-static char *
-Font_to_hex(Font num)
+static char *Font_to_hex(num)
+ Font num;
{
char *temp;
int i;
return(temp);
}
-void
-add_fid(XFontStruct *font)
+void add_fid(font)
+ XFontStruct *font;
{
char *fidstr;
}
/* requires that the font already be cached. */
-XFontStruct *
-get_fontst_from_fid(Font fid)
+XFontStruct *get_fontst_from_fid(fid)
+ Font fid;
{
char *fidstr;
pointer_dictionary_binding *binding;
#endif
}
-static XFontStruct *
-get_fontst(Display *dpy,
- char *fontname)
+static XFontStruct *get_fontst(dpy,fontname)
+ Display *dpy;
+ char *fontname;
{
pointer_dictionary_binding *binding;
int exists;
}
}
-static char *
-get_fontname(char *family,
- int size,
- int face)
+static char *get_fontname(family,size,face)
+ char *family;
+ int size;
+ int face;
{
char *fontname;
return(fontname);
}
-static XFontStruct *
-complete_get_fontst(Display *dpy,
- string style,
- string substyle,
- int size,
- int face)
+static XFontStruct *complete_get_fontst(dpy,style,substyle,size,face)
+ Display *dpy;
+ string style;
+ string substyle;
+ int size;
+ int face;
{
char *family,*fontname;
XFontStruct *fontst;
- if ((family=get_family(style,substyle)))
- if ((fontname=get_fontname(family,size,face)))
- if ((fontst=get_fontst(dpy,fontname)))
+ if (family=get_family(style,substyle))
+ if (fontname=get_fontname(family,size,face))
+ if (fontst=get_fontst(dpy,fontname))
return(fontst);
/* If any part fails, */
return(NULL);
* Effects: unknown
*/
-XFontStruct *
-get_font(Display *dpy,
- string style,
- string substyle,
- int size,
- int face)
+XFontStruct *get_font(dpy,style,substyle,size,face)
+ Display *dpy;
+ string style;
+ string substyle;
+ int size;
+ int face;
{
char *family,*fontname;
XFontStruct *fontst;
if (size == SPECIAL_SIZE) {
/* attempt to process @font explicitly */
- if ((fontst = get_fontst(dpy, substyle)))
+ if (fontst=get_fontst(dpy,substyle))
return(fontst);
} else {
- if ((family = get_family(style, substyle))) {
- if ((fontname = get_fontname(family, size,face)))
- if ((fontst = get_fontst(dpy, fontname)))
+ if (family=get_family(style,substyle)) {
+ if (fontname=get_fontname(family,size,face))
+ if (fontst=get_fontst(dpy,fontname))
return(fontst);
} else {
- if ((fontname = get_fontname(substyle, size, face)))
- if ((fontst = get_fontst(dpy, fontname)))
+ if (fontname=get_fontname(substyle,size,face))
+ if (fontst=get_fontst(dpy,fontname))
return(fontst);
}
of substyle being the fontfamily didn't happen, either. */
fontst=NULL;
- if (!(fontst = complete_get_fontst(dpy,style,"text",size,face)))
- if (!(fontst = complete_get_fontst(dpy,"default",substyle,size,face)))
- if (!(fontst = complete_get_fontst(dpy,"default","text",size,face)))
- if ((fontname = get_fontname("default",size,face)))
- fontst = get_fontst(dpy,fontname);
+ if (!(fontst=complete_get_fontst(dpy,style,"text",size,face)))
+ if (!(fontst=complete_get_fontst(dpy,"default",substyle,size,face)))
+ if (!(fontst=complete_get_fontst(dpy,"default","text",size,face)))
+ if (fontname=get_fontname("default",size,face))
+ fontst=get_fontst(dpy,fontname);
if (fontst) return(fontst);
}
/* If all else fails, try fixed */
- if ((fontst=get_fontst(dpy,"fixed"))) return(fontst);
+ if (fontst=get_fontst(dpy,"fixed")) return(fontst);
/* No fonts available. Die. */
* specified by default.medium.roman is used. <<<>>>
*/
-extern XFontStruct *get_font(Display *, string, string, int, int);
-extern XFontStruct *get_fontst_from_fid(Font);
+extern XFontStruct *get_font();
+extern XFontStruct *get_fontst_from_fid();
#endif
extern XContext desc_context;
extern char *app_instance;
+extern unsigned long x_string_to_color();
+extern char *getenv();
/*
*
*/
/*ARGSUSED*/
-void
-x_set_icccm_hints(Display *dpy,
- Window w,
- char *name,
- char *icon_name,
- XSizeHints *psizehints,
- XWMHints *pwmhints,
- Window main_window)
+void x_set_icccm_hints(dpy,w,name,icon_name,psizehints,pwmhints,main_window)
+ Display *dpy;
+ Window w;
+ char *name;
+ char *icon_name;
+ XSizeHints *psizehints;
+ XWMHints *pwmhints;
+ Window main_window;
{
XStoreName(dpy,w,name);
XSetIconName(dpy,w,icon_name);
XSetWMProtocols(dpy,w,&XA_WM_DELETE_WINDOW,1);
}
-void
-x_gram_init(Display *dpy)
+void x_gram_init(dpy)
+ Display *dpy;
{
char *temp;
XSizeHints sizehints;
default_fgcolor = default_bgcolor;
default_bgcolor = tc;
}
- temp = get_string_resource("foreground", "Foreground");
- if (temp)
- default_fgcolor = x_string_to_color(temp, default_fgcolor);
- temp = get_string_resource("background", "Background");
- if (temp)
- default_bgcolor = x_string_to_color(temp, default_bgcolor);
+ if (temp = get_string_resource("foreground","Foreground"))
+ default_fgcolor = x_string_to_color(temp,default_fgcolor);
+ if (temp = get_string_resource("background","Background"))
+ default_bgcolor = x_string_to_color(temp,default_bgcolor);
default_bordercolor = default_fgcolor;
- temp = get_string_resource("borderColor", "BorderColor");
- if (temp)
- default_bordercolor = x_string_to_color(temp, default_bordercolor);
+ if (temp = get_string_resource("borderColor","BorderColor"))
+ default_bordercolor = x_string_to_color(temp,default_bordercolor);
- temp = get_string_resource("minTimeToLive", "MinTimeToLive");
+ temp = get_string_resource("minTimeToLive","MinTimeToLive");
if (temp && atoi(temp)>=0)
ttl = atoi(temp);
}
}
-int
-x_calc_gravity(int xalign,
- int yalign)
+int x_calc_gravity(xalign, yalign)
+ int xalign, yalign;
{
if (yalign > 0) { /* North */
return (xalign > 0) ? NorthWestGravity
}
}
-void
-x_gram_create(Display *dpy,
- x_gram *gram,
- int xalign,
- int yalign,
- int xpos,
- int ypos,
- int xsize,
- int ysize,
- int beepcount)
+void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize,
+ beepcount)
+ Display *dpy;
+ x_gram *gram;
+ int xalign, yalign;
+ int xpos, ypos;
+ int xsize, ysize;
+ int beepcount;
{
Window w;
XSizeHints sizehints;
XWMHints wmhints;
XSetWindowAttributes attributes;
unsigned long all_desktops = 0xFFFFFFFF;
+ extern void x_get_input();
/*
* Adjust xpos, ypos based on the alignments xalign, yalign and the sizes:
xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xpos - xsize
- 2*border_width;
else if (xalign == 0)
- xpos = ((WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize
- - 2*border_width)>>1) + xpos;
+ xpos = (WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize
+ - 2*border_width)>>1 + xpos;
if (yalign<0)
ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ypos - ysize
- 2*border_width;
else if (yalign == 0)
- ypos = ((HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize
- - 2*border_width)>>1) + ypos;
+ ypos = (HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize
+ - 2*border_width)>>1 + ypos;
/*
* Create the window:
x_get_input(dpy);
}
-void
-x_gram_draw(Display *dpy,
- Window w,
- x_gram *gram,
- Region region)
+void x_gram_draw(dpy, w, gram, region)
+ Display *dpy;
+ Window w;
+ x_gram *gram;
+ Region region;
{
int i;
GC gc;
XFreeGC(dpy,gc);
}
-void
-x_gram_expose(Display *dpy,
- Window w,
- x_gram *gram,
- XExposeEvent *event)
+void x_gram_expose(dpy,w,gram,event)
+ Display *dpy;
+ Window w;
+ x_gram *gram;
+ XExposeEvent *event;
{
static Region region;
static int partregion;
#define x_gram_TYPE
#include <X11/Xlib.h>
-#include <X11/Xutil.h>
#include <sys/time.h>
-#include "formatter.h"
-
typedef struct _xblock {
unsigned long fgcolor;
Font fid;
#define CENTERALIGN 1
#define RIGHTALIGN 2
-extern void x_gram_init(Display *);
-extern void x_gram_create(Display *, x_gram *, int, int, int, int, int, int, int);
-extern void x_gram_expose(Display *, Window, x_gram *, XExposeEvent *);
-extern void xshow(Display *, desctype *, int, int);
-extern void xcut(Display *, XEvent *, XContext);
-extern void x_get_input(Display *);
-extern void xshowinit(void);
+extern void x_gram_init();
+extern void x_gram_create();
+extern void x_gram_expose();
+extern void xshow();
+extern void xcut();
#endif
static char *buffer = 0;
-string
-buffer_to_string(void)
+string buffer_to_string()
{
return(buffer);
}
-void
-clear_buffer(void)
+void clear_buffer()
{
if (buffer)
free(buffer);
buffer = string_Copy("");
}
-void
-append_buffer(char *str)
+void append_buffer(str)
+ char *str;
{
buffer = string_Concat2(buffer, str);
}
#include "new_string.h"
-extern string buffer_to_string(void);
-extern void clear_buffer(void);
-extern void append_buffer(char *);
+extern string buffer_to_string();
+extern void clear_buffer();
+extern void append_buffer();
#endif
static character_class cache;
/* character_class */
-char *
-string_to_character_class(string str)
+char * string_to_character_class(str)
+ string str;
{
int i;
(void) memset(cache, 0, sizeof(cache));
for (i=0; i<strlen(str); i++)
- cache[(int)str[i]] = 1;
+ cache[str[i]] = 1;
return(cache);
}
typedef char character_class[NUMBER_OF_CHARACTERS];
-extern /* character_class */ char * string_to_character_class(string);
+extern /* character_class */ char * string_to_character_class();
#endif
* that size is a prime number.
*/
-TYPE_T_dictionary
-TYPE_T_dictionary_Create(int size)
+TYPE_T_dictionary TYPE_T_dictionary_Create(size)
+ int size;
{
int i;
TYPE_T_dictionary result;
* TYPE_T_dictionary_Enumerate.
*/
-void
-TYPE_T_dictionary_Destroy(TYPE_T_dictionary d)
+void TYPE_T_dictionary_Destroy(d)
+ TYPE_T_dictionary d;
{
int i;
TYPE_T_dictionary_binding *binding_ptr, *new_binding_ptr;
* writable by proc.
*/
-void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d,
- void (*proc)(TYPE_T_dictionary_binding *))
+void TYPE_T_dictionary_Enumerate(d, proc)
+ TYPE_T_dictionary d;
+ void (*proc)(/* TYPE_T_dictionary_binding *b */);
{
int i;
TYPE_T_dictionary_binding *binding_ptr;
* keys over the table's slots.
*/
-static unsigned int
-dictionary__hash(char *s)
+static unsigned int dictionary__hash(s)
+ char *s;
{
unsigned int result = 0;
* Note the access restrictions on bindings...
*/
-TYPE_T_dictionary_binding *
-TYPE_T_dictionary_Lookup(TYPE_T_dictionary d,
- char *key)
+TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(d, key)
+ TYPE_T_dictionary d;
+ char *key;
{
TYPE_T_dictionary_binding *binding_ptr;
* in this case.
*/
-TYPE_T_dictionary_binding *
-TYPE_T_dictionary_Define(TYPE_T_dictionary d,
- char *key,
- int *already_existed)
+TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(d, key, already_existed)
+ TYPE_T_dictionary d;
+ char *key;
+ int *already_existed;
{
TYPE_T_dictionary_binding **ptr_to_the_slot, *binding_ptr;
* before making this call.
*/
-void TYPE_T_dictionary_Delete(TYPE_T_dictionary d,
- TYPE_T_dictionary_binding *b)
+void TYPE_T_dictionary_Delete(d, b)
+ TYPE_T_dictionary d;
+ TYPE_T_dictionary_binding *b;
{
TYPE_T_dictionary_binding **ptr_to_binding_ptr;
* that size is a prime number.
*/
-extern TYPE_T_dictionary TYPE_T_dictionary_Create(int);
+extern TYPE_T_dictionary TYPE_T_dictionary_Create(/* int size */);
/*
* void TYPE_T_dictionary_Destroy(TYPE_T_dictionary d):
* TYPE_T_dictionary_Enumerate.
*/
-extern void TYPE_T_dictionary_Destroy(TYPE_T_dictionary);
+extern void TYPE_T_dictionary_Destroy(/* TYPE_T_dictionary d */);
/*
- * void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d;
- * void (*proc)(TYPE_T_dictionary_binding *b)):
+ * void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d; void (*proc)()):
* Requires: proc is a void procedure taking 1 argument, a
* TYPE_T_dictionary_binding pointer, which does not
* make any calls using dictionary d.
* writable by proc.
*/
-extern void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary, void (*)(TYPE_T_dictionary_binding *));
+extern void TYPE_T_dictionary_Enumerate(/* TYPE_T_dictionary d,
+ void (*proc)() */);
/*
* TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(TYPE_T_dictionary d,
* Note the access restrictions on bindings...
*/
-extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(TYPE_T_dictionary,
- char *);
+extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(/* d, key */);
/*
* TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(TYPE_T_dictionary d,
* in this case.
*/
-extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(TYPE_T_dictionary,
- char *, int *);
+extern TYPE_T_dictionary_binding *TYPE_T_dictionary_Define();
/*
* void TYPE_T_dictionary_Delete(TYPE_T_dictionary d,
* before making this call.
*/
-extern void TYPE_T_dictionary_Delete(TYPE_T_dictionary,
- TYPE_T_dictionary_binding *);
+extern void TYPE_T_dictionary_Delete();
#endif
#include "port.h"
#include "buffer.h"
#include "regexp.h"
-#include "formatter.h"
#include "text_operations.h"
#include "zwgc.h"
#include "variables.h"
* eventually.
*/
-static string
-bool_to_string(int bool)
+static string bool_to_string(bool)
+ int bool;
{
return(bool ? string_Copy("TRUE") : string_Copy("FALSE"));
}
* NULL is defined to have the boolean value true.
*/
-int
-eval_bool_expr(Node *expr)
+int eval_bool_expr(expr)
+ Node *expr;
{
string temp;
int result;
* eventually.
*/
-string
-eval_expr(Node *expr)
+string eval_expr(expr)
+ Node *expr;
{
int opcode = expr->opcode;
int bool_result;
string first, second;
char *result;
string *text_ptr;
+ char *getenv(); /* UNIX get environment variable function */
/*
* Dispatch based on the opcode of the top node in the expression:
* eventually.
*/
-extern string eval_expr(Node *);
+extern string eval_expr();
/*
* int eval_bool_expr(Node *expr)
* NULL is defined to have the boolean value true.
*/
-extern int eval_bool_expr(Node *);
+extern int eval_bool_expr();
#endif
#include <zephyr/zephyr.h>
#include "new_memory.h"
-#include "node.h"
#include "exec.h"
#include "eval.h"
+#include "node.h"
#include "buffer.h"
#include "port.h"
#include "variables.h"
#include "notice.h"
-static int exec_subtree(Node *);
-static int exec_fields(Node *);
+static int exec_subtree(), exec_fields();
/****************************************************************************/
/* */
/* */
/****************************************************************************/
-static string
-eval_exprlist_to_string(Node *exprlist)
+static string eval_exprlist_to_string(exprlist)
+ Node *exprlist;
{
string result = string_Copy("");
string temp;
return(result);
}
-static char **
-eval_exprlist_to_args(Node *exprlist)
+static char **eval_exprlist_to_args(exprlist)
+ Node *exprlist;
{
char **result = (char **)malloc(sizeof(char *));
int argc = 0;
return(result);
}
-static void
-free_args(char **args)
+static void free_args(args)
+ char **args;
{
char **p;
#define EXIT 2
/*ARGSUSED*/
-static int
-exec_noop(Node *node)
+static int exec_noop(node)
+ Node *node;
{
return(NOBREAK);
}
/*ARGSUSED*/
-static int
-exec_break(Node *node)
+static int exec_break(node)
+ Node *node;
{
return(BREAK);
}
/*ARGSUSED*/
-static int
-exec_exit(Node *node)
+static int exec_exit(node)
+ Node *node;
{
return(EXIT);
}
-static int
-exec_set(Node *node)
+static int exec_set(node)
+ Node *node;
{
var_set_variable_then_free_value(node->d.nodes.first->d.string_constant,
eval_expr(node->d.nodes.second));
return(NOBREAK);
}
-static int
-exec_execport(Node *node)
+static int exec_execport(node)
+ Node *node;
{
string name = eval_expr(node->d.nodes.first);
char **argv = eval_exprlist_to_args(node->d.nodes.second);
return(NOBREAK);
}
-static int
-exec_appendport(Node *node)
+static int exec_appendport(node)
+ Node *node;
{
string name, filename;
return(NOBREAK);
}
-static int
-exec_inputport(Node *node)
+static int exec_inputport(node)
+ Node *node;
{
string name, filename;
return(NOBREAK);
}
-static int
-exec_outputport(Node *node)
+static int exec_outputport(node)
+ Node *node;
{
string name, filename;
return(NOBREAK);
}
-static int
-exec_closeinput(Node *node)
+static int exec_closeinput(node)
+ Node *node;
{
string name;
return(NOBREAK);
}
-static int
-exec_closeoutput(Node *node)
+static int exec_closeoutput(node)
+ Node *node;
{
string name;
return(NOBREAK);
}
-static int
-exec_closeport(Node *node)
+static int exec_closeport(node)
+ Node *node;
{
string name;
return(NOBREAK);
}
-static int
-exec_put(Node *node)
+static int exec_put(node)
+ Node *node;
{
string name, temp;
return(NOBREAK);
}
-static int
-exec_print(Node *node)
+static int exec_print(node)
+ Node *node;
{
string temp;
}
/*ARGSUSED*/
-static int
-exec_clearbuf(Node *node)
+static int exec_clearbuf(node)
+ Node *node;
{
clear_buffer();
return(NOBREAK);
}
-static int
-exec_case(Node *node)
+static int exec_case(node)
+ Node *node;
{
string constant,temp;
Node *match, *cond;
return(NOBREAK);
}
-static int
-exec_while(Node *node)
+static int exec_while(node)
+ Node *node;
{
int continue_code = NOBREAK;
return(continue_code);
}
-static int
-exec_if(Node *node)
+static int exec_if(node)
+ Node *node;
{
Node *conds;
return(NOBREAK);
}
-static int
-exec_exec(Node *node)
+static int exec_exec(node)
+ Node *node;
{
int pid;
char **argv = eval_exprlist_to_args(node->d.nodes.first);
}
static struct _Opstuff {
- int (*exec)(Node *);
+ int (*exec)();
} const opstuff[] = {
{ exec_noop }, /* string_constant */
{ exec_noop }, /* varref */
{ exec_noop }, /* default */
};
-static int
-exec_subtree(Node *node)
+static int exec_subtree(node)
+ Node *node;
{
int retval = NOBREAK;
static int notice_fields_length = 0;
static int number_of_fields = 0;
-static int
-exec_fields(Node *node)
+static int exec_fields(node)
+ Node *node;
{
for (node=node->d.nodes.first; node; node=node->next) {
var_set_variable_then_free_value(node->d.string_constant,
return(NOBREAK);
}
-void
-exec_process_packet(Node *program,
- ZNotice_t *notice)
+void exec_process_packet(program, notice)
+ Node *program;
+ ZNotice_t *notice;
{
notice_fields = notice->z_message;
notice_fields_length = notice->z_message_len;
#ifndef exec_MODULE
#define exec_MODULE
-extern void exec_process_packet(Node *, ZNotice_t *);
+extern void exec_process_packet();
#endif
* if necessary.
*/
-char *get_home_directory(void)
+char *get_home_directory()
{
char *result;
+ char *getenv();
struct passwd *passwd_entry;
- result = getenv("HOME");
- if (result)
+ if (result = getenv("HOME"))
return(result);
if (!(passwd_entry = getpwuid(getuid())))
*
*/
-FILE *locate_file(char *override_filename,
- char *home_dir_filename,
- char *fallback_filename)
+FILE *locate_file(override_filename, home_dir_filename, fallback_filename)
+ char *override_filename;
+ char *home_dir_filename;
+ char *fallback_filename;
{
char *filename;
FILE *result;
}
if (home_dir_filename) {
- filename = get_home_directory();
- if (filename) {
+ if (filename = get_home_directory()) {
filename = string_Concat(filename, "/");
filename = string_Concat2(filename, home_dir_filename);
result = fopen(filename, "r");
#include <stdio.h>
-extern FILE *locate_file(char *, char *, char *);
+extern FILE *locate_file();
#endif
#define const
#endif
-static int pure_text_length(char *, char);
-static int env_length(char *);
+static int pure_text_length(), env_length();
#ifdef notdef
static character_class atsign_set = { /* '@' = 0x40 */
static char *openbracket[]={"@<","@<","@[","@[","@{","@{","@(","@(","@("};
static char *closebracket[]={">",">","]","]","}","}",")",")",")"};
-static int
-not_contains(string str,
- const character_class set)
+static int not_contains(str, set)
+ string str;
+ const character_class set;
{
- while (*str && ! set[(int)*str]) str++;
+ while (*str && ! set[*str]) str++;
return (! *str);
}
-static int
-pure_text_length(char *text,
- char terminator)
+static int pure_text_length(text,terminator)
+ char *text;
+ char terminator;
{
int len=0;
}
}
-static char
-otherside(char opener)
+static char otherside(opener)
+char opener;
{
switch (opener) {
case '(':
#ifdef DEBUG
abort();
#endif
- return 0;
}
/* the char * that str points to is free'd by this function.
* if you want to keep it, save it yourself
*/
-string
-verbatim(string str, int bracketsonly)
+string verbatim(str, bracketsonly)
+ string str;
+ int bracketsonly;
{
char *temp,*temp2;
int bracketnum,len;
or the default terminator \0. The text will not be modified,
and @@ will be counted twice */
-string
-protect(string str)
+string protect(str)
+ string str;
{
string temp,temp2,temp3;
int len,templen;
temp[templen-2] = *str++;
char_stack_pop(chs);
temp[templen-1] = '\0';
- } else if ((len = pure_text_length(str,tos))) {
+ } else if (len = pure_text_length(str,tos)) {
if (tos) {
/* if the block is text in an environment, just copy it */
/* str points to a string. return value is another string
which is the original with all styles removed. */
-string
-stylestrip(string str)
+string stylestrip(str)
+ string str;
{
int templen = 0, otherchar;
char *temp = (char *) malloc(string_Length(str) + 1);
return(temp);
}
-void
-free_desc(desctype *desc)
+void free_desc(desc)
+ desctype *desc;
{
desctype *next_desc;
/* text points to beginning of possible env name. return value is
length of env name, not including @ or opener, or -1 if not a
possible env name. */
-static int
-env_length(char *text)
+static int env_length(text)
+ char *text;
{
int len=0;
length of string, up to but not including the passed terminator
or the default terminators \0 \n @. This can modify text, and 0
is a valid return value. */
-static int
-text_length(char *text,
- char terminator)
+static int text_length(text,terminator)
+ char *text;
+ char terminator;
{
int len=0;
/* parses str into a desc linked list. Returns number of strings and
newlines in *pstr and *pnl */
-desctype *
-disp_get_cmds(char *str,
- int *pstr,
- int *pnl)
+desctype *disp_get_cmds(str,pstr,pnl)
+char *str;
+int *pstr,*pnl;
{
desctype *desc,*here;
int len;
terminator = char_stack_top(terminators);
char_stack_pop(terminators);
curstr++;
- } else if ((len=text_length(curstr, terminator))) { /* if there is a text
- block here */
+ } else if (len=text_length(curstr,terminator)) { /* if there is a text
+ block here */
here->code=DT_STR;
here->str=curstr;
here->len=len;
#include <zephyr/mit-copyright.h>
-#include "new_string.h"
-
#ifndef formatter_MODULE
#define formatter_MODULE
ENV, STR, END. Undefined for EOF */
} desctype;
-extern desctype *disp_get_cmds(char *, int *, int *);
-extern void free_desc(desctype *);
+extern desctype *disp_get_cmds();
+extern void free_desc();
-extern string protect(string);
-extern string verbatim(string, int);
-extern string stylestrip(string);
#endif
static int pushback = -1;
-static char
-input(void)
+static char input()
{
int c;
return(c);
}
-static void
-unput(int c)
+static void unput(c)
+ int c;
{
#ifdef DEBUG
if (pushback != -1) {
* a file. Resets current line # to 1.
*/
-void
-lex_open(FILE *file)
+void lex_open(file)
+ FILE *file;
{
/*
* Initialize I/O:
#define is_octal_digit(c) (((c)>='0') && ((c)<='7'))
-static char
-eat_escape_code(void)
+static char eat_escape_code()
{
int c, coded_char;
* string we are eating started on.
*/
-static char *
-eat_string(int starting_line)
+static char *eat_string(starting_line)
+ int starting_line;
{
int c;
char buffer[500];
* instead of doing the above, we just eat the "endshow" & return 0.
*/
-static char *
-eat_show_line(int test_for_endshow)
+static char *eat_show_line(test_for_endshow)
+ int test_for_endshow;
{
int c;
int saw_escape_code = 0;
* messages.
*/
-static char *
-eat_til_endshow(int start_line_no)
+static char *eat_til_endshow(start_line_no)
+ int start_line_no;
{
register int c;
string text_so_far = string_Copy("");
* returned.
*/
-static int
-handle_show(void)
+static int handle_show()
{
int c;
int start_line_no = yylineno;
if (c!='\n')
unput(c);
- yylval.text = eat_til_endshow(start_line_no);
- if (yylval.text)
+ if (yylval.text = eat_til_endshow(start_line_no))
return(SHOW);
else
return(ERROR);
* yylex - performs as per. the yacc manual's requirements
*/
-int yylex(void)
+int yylex()
{
register int c, last_char;
register char *ptr;
* Handle constant strings:
*/
case '"':
- yylval.text = eat_string(yylineno);
- if (yylval.text)
+ if (yylval.text = eat_string(yylineno))
return(STRING);
else
return(ERROR);
* a file. Resets current line # to 1.
*/
-extern void lex_open(FILE *);
+extern void lex_open(/* FILE *file */);
/*
* yylex - performs as per. the yacc manual's requirements
*/
-extern int yylex(void);
+extern int yylex();
#endif
#include "variables.h"
#include "main.h"
-void notice_handler(ZNotice_t *);
-static void process_notice(ZNotice_t *, char *);
-static void setup_signals(int);
-static void detach(void);
-static void signal_exit(int);
+extern void notice_handler();
+static void process_notice(), setup_signals(), detach(), signal_exit();
#ifdef HAVE_ARES
-static void notice_callback(void *, int, struct hostent *);
+static void notice_callback();
#endif
/*
* <<<>>>
*/
-static void
-fake_startup_packet(void)
+static void fake_startup_packet()
{
ZNotice_t notice;
struct timezone tz;
char msgbuf[BUFSIZ];
- extern void Z_gettimeofday(struct _ZTimeval *, struct timezone *);
var_set_variable("version", zwgc_version_string);
notice.z_default_format = "Zwgc mark II version $version now running...\n";
notice.z_recipient = "";
notice.z_sender = "ZWGC";
- Z_gettimeofday(¬ice.z_time, &tz);
+ gettimeofday(¬ice.z_time,&tz);
notice.z_port = 0;
notice.z_kind = ACKED;
notice.z_auth = ZAUTH_YES;
process_notice(¬ice, NULL);
}
-static void
-read_in_description_file(void)
+static void read_in_description_file()
{
FILE *input_file;
char defdesc[128];
* program with error code 1.
*/
-void
-usage(void)
+void usage()
{
#ifdef DEBUG
fprintf(stderr, "\
* <<<>>>
*/
-static void
-run_initprogs(void)
+static void run_initprogs()
{
/*
* This code stolen from old zwgc: yuck. Clean up & fix. <<<>>>
* main -- the program entry point. Does parsing & top level control.
*/
-int
-main(int argc,
- char **argv)
+int main(argc, argv)
+ int argc;
+ char **argv;
{
char **new;
register char **current;
#define USER_SUPPRESS "SUPPRESS"
#define USER_UNSUPPRESS "UNSUPPRESS"
-void
-notice_handler(ZNotice_t *notice)
+void notice_handler(notice)
+ ZNotice_t *notice;
{
struct hostent *fromhost = NULL;
}
#ifdef HAVE_ARES
-static void
-notice_callback(void *arg,
- int status,
- struct hostent *fromhost)
+static void notice_callback(arg, status, fromhost)
+ void *arg;
+ int status;
+ struct hostent *fromhost;
{
ZNotice_t *notice = (ZNotice_t *) arg;
}
#endif
-static void
-process_notice(ZNotice_t *notice,
- char *hostname)
+static void process_notice(notice, hostname)
+ ZNotice_t *notice;
+ char *hostname;
{
char *control_opcode;
dprintf("Got a message\n");
- control_opcode = decode_notice(notice, hostname);
- if (control_opcode) {
+ if (control_opcode = decode_notice(notice, hostname)) {
#ifdef DEBUG
printf("got control opcode <%s>.\n", control_opcode);
#endif
free(instance);
free(recipient);
} else if (!strcasecmp(control_opcode, USER_EXIT)) {
- signal_exit(0);
+ signal_exit();
} else
printf("zwgc: unknown control opcode %s.\n", control_opcode);
*
*/
-static void
-signal_exit(int ignored)
+static void signal_exit()
{
mux_end_loop_p = 1;
}
/* clean up ALL the waiting children, in case we get hit with
multiple SIGCHLD's at once, and don't process in time. */
-static RETSIGTYPE
-signal_child(int ignored)
+static RETSIGTYPE signal_child()
{
#ifdef HAVE_WAITPID
int status;
#else
union wait status;
#endif
+ extern int errno;
int pid, old_errno = errno;
do {
}
/* rewrite the wgfile in case it has gone away */
-static RETSIGTYPE
-signal_usr1(int ignored)
+static RETSIGTYPE signal_usr1()
{
write_wgfile();
}
-static void
-setup_signals(int dofork)
+static void setup_signals(dofork)
+ int dofork;
{
#ifdef _POSIX_VERSION
struct sigaction sa;
/* detach() taken from old zwgc, with lots of stuff ripped out */
-static void
-detach(void)
+static void detach()
{
/* detach from terminal and fork. */
register int i;
* of finding the session leader; otherwise use the process group of
* the parent process, which is a good guess. */
#if defined(HAVE_GETSID)
-
setpgid(0, getsid(0));
#elif defined(HAVE_GETPGID)
setpgid(0, getpgid(getppid()));
#endif
/* fork off and let parent exit... */
- i = fork();
- if (i) {
+ if (i = fork()) {
if (i < 0) {
perror("zwgc: cannot fork, aborting:");
exit(1);
* program with error code 1.
*/
-extern void usage(void);
+extern void usage();
/* USRDESC points to a file (relative to user's homedir) which has a user's
description file */
*/
static fd_set input_sources;
-static void (*input_handler[MAX_SOURCES])(void *);
+static void (*input_handler[MAX_SOURCES])();
static pointer input_handler_arg[MAX_SOURCES];
-static int check_tty(void);
+static int check_tty();
/*
* void mux_init()
* any other mux call.
*/
-void
-mux_init(void)
+void mux_init()
{
int i;
* argument arg.
*/
-void
-mux_add_input_source(int descriptor,
- void (*handler)(void *),
- pointer arg)
+void mux_add_input_source(descriptor, handler, arg)
+ int descriptor;
+ void (*handler)();
+ pointer arg;
{
#ifdef DEBUG
if(descriptor < 0 || descriptor >= MAX_SOURCES)
* true, we return.
*/
-void
-mux_loop(void)
+void mux_loop()
{
int i, nfds;
fd_set inputs, outputs;
}
}
-static int
-check_tty(void)
+static int check_tty()
{
register int result;
int pgrp;
* any other mux call.
*/
-extern void mux_init(void);
+extern void mux_init();
/*
* void mux_add_input_source(int descriptior; void (*handler)(); void *arg)
* argument arg.
*/
-extern void mux_add_input_source(int, void (*)(void *), void *);
+extern void mux_add_input_source();
/*
* void mux_loop()
* true, we return.
*/
-extern void mux_loop(void);
+extern void mux_loop();
#endif
* string_Copy("foo").
*/
-string string__CreateFromData(char *data, int length)
+string string__CreateFromData(data, length)
+ char *data;
+ int length;
{
string result;
* freed eventually.
*/
-string
-string__Copy(string s)
+string string__Copy(s)
+ string s;
{
int length;
string result;
* returns string_Copy("abcdef").
*/
-string
-string__Concat(string a,
- string b)
+string string__Concat(a, b)
+ string a, b;
{
string result;
int a_length, b_size, result_size;
* only faster. I.e., uses realloc instead of malloc+memcpy.
*/
-string
-string__Concat2(string a,
- string b)
+string string__Concat2(a, b)
+ string a, b;
{
int a_length = string_Length(a);
int b_size = string_Length(b)+1;
* S is returned as a convenience.
*/
-string
-string_Downcase(string s)
+string string_Downcase(s)
+ string s;
{
char *ptr;
* S is returned as a convenience.
*/
-string
-string_Upcase(string s)
+string string_Upcase(s)
+ string s;
{
char *ptr;
* string_Copy("foo").
*/
-extern string string__CreateFromData(char *, int);
+extern string string__CreateFromData();
#ifdef DEBUG_MEMORY
#define string_CreateFromData(data,length) (set_module(__FILE__,__LINE__),\
string__CreateFromData(data,length))
* freed eventually.
*/
-extern string string__Copy(string);
+extern string string__Copy(/* string s */);
#ifdef DEBUG_MEMORY
#define string_Copy(data) (set_module(__FILE__,__LINE__),\
string__Copy(data))
* returns string_Copy("abcdef").
*/
-extern string string__Concat(string, string);
+extern string string__Concat(/* string a, b */);
#ifdef DEBUG_MEMORY
#define string_Concat(a,b) (set_module(__FILE__,__LINE__),\
string__Concat(a,b))
* only faster. I.e., uses realloc instead of malloc+bcopy.
*/
-extern string string__Concat2(string, string);
+extern string string__Concat2(/* string a, b */);
#ifdef DEBUG_MEMORY
#define string_Concat2(a,b) (set_module(__FILE__,__LINE__),\
string__Concat2(a,b))
* S is returned as a convenience.
*/
-extern string string_Downcase(string);
+extern string string_Downcase();
/*
* string string_Upcase(string s):
* S is returned as a convenience.
*/
-extern string string_Upcase(string);
+extern string string_Upcase();
#endif
* string on the heap when node_DestroyAllNodes is called.
*/
-static Node *
-node_create(int opcode)
+static Node *node_create(opcode)
+ int opcode;
{
Node *result;
*
*/
-void
-node_DestroyAllNodes(void)
+void node_DestroyAllNodes()
{
struct _bunch_of_nodes *next_bunch;
int i, last_node_used_in_this_bunch;
/* */
/****************************************************************************/
-Node *
-node_create_string_constant(int opcode,
- string text)
+Node *node_create_string_constant(opcode, text)
+ int opcode;
+ string text;
{
Node *n;
return(n);
}
-Node *
-node_create_noary(int opcode)
+Node *node_create_noary(opcode)
+ int opcode;
{
Node *n;
return(n);
}
-Node *
-node_create_unary(int opcode,
- Node *arg)
+Node *node_create_unary(opcode, arg)
+ int opcode;
+ Node *arg;
{
Node *n;
return(n);
}
-Node *
-node_create_binary(int opcode,
- Node *first_arg,
- Node *second_arg)
+Node *node_create_binary(opcode, first_arg, second_arg)
+ int opcode;
+ Node *first_arg;
+ Node *second_arg;
{
Node *n;
* the address of the (previously) last node.
*/
-Node *
-reverse_list_of_nodes(Node *list)
+Node *reverse_list_of_nodes(list)
+ Node *list;
{
Node *next_node;
Node *head = NULL;
#ifdef DEBUG
-static void
-print_stuff(Node *node,
- string format_string)
+static void print_stuff(node, format_string)
+ Node *node;
+ string format_string;
{
char c;
"match %1\n%2",
"default\n%2" };
-void node_display(Node *node)
+void node_display(node)
+ Node *node;
{
int opcode = LAST_EXPR_OPCODE + 1;
/* Function externs */
-extern void node_DestroyAllNodes(void);
+extern void node_DestroyAllNodes();
-extern Node *node_create_string_constant(int, string);
+extern Node *node_create_string_constant();
-extern Node *node_create_noary(int);
-extern Node *node_create_unary(int, Node *);
-extern Node *node_create_binary(int, Node *, Node *);
+extern Node *node_create_noary();
+extern Node *node_create_unary();
+extern Node *node_create_binary();
/*
* Node *reverse_list_of_nodes(Node *list)
* the address of the (previously) last node.
*/
-extern Node *reverse_list_of_nodes(Node *);
+extern Node *reverse_list_of_nodes();
#ifdef DEBUG
-extern void node_display(Node *);
+extern void node_display();
#endif
#endif
* Effects: Returns the # of nulls in data[0]..data[length-1]
*/
-int
-count_nulls(char *data,
- int length)
+int count_nulls(data, length)
+ char *data;
+ int length;
{
int count = 0;
* remain. (this is the case when *length_p == 0)
*/
-string
-get_next_field(char **data_p,
- int *length_p)
+string get_next_field(data_p, length_p)
+ char **data_p;
+ int *length_p;
{
char *data = *data_p;
int length = *length_p;
* "" is returned.
*/
-string get_field(char *data,
- int length,
- int num)
+string get_field(data, length, num)
+ char *data;
+ int length;
+ int num;
{
/*
* While num>1 and there are fields left, skip a field & decrement num:
* be freed.
*/
-string
-convert_nulls_to_newlines(char *data,
- int length)
+string convert_nulls_to_newlines(data, length)
+ char *data;
+ int length;
{
char *result, *ptr;
char c;
* eventually.
*/
-static string
-z_kind_to_ascii(ZNotice_Kind_t z_kind)
+static string z_kind_to_ascii(z_kind)
+ ZNotice_Kind_t z_kind;
{
string result;
* eventually.
*/
-static string
-z_auth_to_ascii(int z_auth)
+static string z_auth_to_ascii(z_auth)
+ int z_auth;
{
string result;
* Effects:
*/
-char *
-decode_notice(ZNotice_t *notice,
- char *hostname)
+char *decode_notice(notice, hostname)
+ ZNotice_t *notice;
+ char *hostname;
{
char *temp;
string time, notyear, year, date_string, time_string;
#ifndef notice_MODULE
#define notice_MODULE
-#include <zephyr/zephyr.h>
#include "new_string.h"
/*
* Effects: Returns the # of nulls in data[0]..data[length-1]
*/
-extern int count_nulls(char *, int);
+extern int count_nulls();
/*
* string get_next_field(char **data_p, int *length_p)
* remain. (this is the case when *length_p == 0)
*/
-extern string get_next_field(char **, int *);
+extern string get_next_field();
/*
* string get_field(char *data, int length, int num)
* "" is returned.
*/
-extern string get_field(char *, int, int);
+extern string get_field();
/*
* string convert_nulls_to_newlines(data, length)
* be freed.
*/
-extern string convert_nulls_to_newlines(char *, int);
+extern string convert_nulls_to_newlines();
-extern char *decode_notice(ZNotice_t *, char *);
+extern char *decode_notice();
#endif
* is reported to the user via stderr.
*/
-extern void report_parse_error(char *, int);
+extern void report_parse_error();
/*
* struct _Node *parse_file(FILE *input_file)
* is closed before this routine returns.
*/
-extern struct _Node *parse_file(FILE *);
+extern struct _Node *parse_file();
#endif
#include "node.h"
#include "zwgc.h"
-static void yyerror(char *);
+static void yyerror();
/*
* the_program - local variable used to communicate the program's node
* is reported to the user via stderr.
*/
-void
-report_parse_error(char *error_message,
- int line_number)
+void report_parse_error(error_message, line_number)
+ char *error_message;
+ int line_number;
{
if (error_occured)
return;
* stack overflow errors.
*/
-static void yyerror(char *message)
+static void yyerror(message)
+ char *message;
{
report_parse_error(message, yylineno);
}
* is closed before this routine returns.
*/
-struct _Node *
-parse_file(FILE *input_file)
+struct _Node *parse_file(input_file)
+ FILE *input_file;
{
the_program = NULL;
error_occured = 0;
/* */
/****************************************************************************/
-static string
-port_get(port *p)
+static string port_get(p)
+ port *p;
{
- char *(*get_proc)(port *, char **);
+ char *(*get_proc)();
char *error = NULL;
char *result;
return(result);
}
-static void
-port_put(port *p,
- char *data,
- int length)
+static void port_put(p, data, length)
+ port *p;
+ char *data;
+ int length;
{
- char *(*put_proc)(port *, char *, int);
+ char *(*put_proc)();
char *error;
if (p->status & OUTPUT_CLOSED) {
var_set_variable("error", error);
}
-static void
-port_close_input(port *p)
+static void port_close_input(p)
+ port *p;
{
- char *(*close_input_proc)(port *);
+ char *(*close_input_proc)();
char *error;
if (p->status & INPUT_CLOSED)
if (!close_input_proc)
return;
- error = close_input_proc(p);
- if (error)
+ if (error = close_input_proc(p))
var_set_variable("error", error);
}
-static void
-port_close_output(port *p)
+static void port_close_output(p)
+ port *p;
{
- char *(*close_output_proc)(port *);
+ char *(*close_output_proc)();
char *error;
if (p->status & OUTPUT_CLOSED)
if (!close_output_proc)
return;
- error = close_output_proc(p);
- if (error)
+ if (error = close_output_proc(p))
var_set_variable("error", error);
}
* any other port call is made.
*/
-static void
-close_port_from_binding(port_dictionary_binding *b)
+static void close_port_from_binding(b)
+ port_dictionary_binding *b;
{
port_close_input(&(b->value));
port_close_output(&(b->value));
}
-void
-init_ports(void)
+void init_ports()
{
if (port_dict) {
port_dictionary_Enumerate(port_dict, close_port_from_binding);
* various fields correctly.
*/
-static port *
-create_named_port(string name)
+static port *create_named_port(name)
+ string name;
{
int already_exists;
port_dictionary_binding *binding;
* it. Otherwise returns NULL.
*/
-static port *
-get_named_port(string name)
+static port *get_named_port(name)
+ string name;
{
port_dictionary_binding *binding;
* on the heap & must be eventually freed.
*/
-string
-read_from_port(string name)
+string read_from_port(name)
+ string name;
{
port *p;
* occurs, $error is set to the error message.
*/
-void
-write_on_port(string name,
- char *text,
- int length)
+void write_on_port(name, text, length)
+ string name;
+ char *text;
+ int length;
{
port *p;
* occurs, $error is set to the error message.
*/
-void
-close_port_input(string name)
+void close_port_input(name)
+ string name;
{
port_dictionary_binding *binding;
* occurs, $error is set to the error message.
*/
-void
-close_port_output(string name)
+void close_port_output(name)
+ string name;
{
port_dictionary_binding *binding;
/* */
/****************************************************************************/
-static string
-get_file(port *p,
- char **error_p)
+static string get_file(p, error_p)
+ port *p;
+ char **error_p;
{
char buffer[10000]; /* <<<>>> */
return(string_Copy(buffer));
}
-static char *
-put_file(port *p,
- string text,
- int length)
+static char *put_file(p, text, length)
+ port *p;
+ string text;
+ int length;
{
if (!p->data.file.output_connector)
return(NULL);
return(NULL);
}
-static char *
-close_file_input(port *p)
+static char *close_file_input(p)
+ port *p;
{
errno = 0;
if (p->data.file.input_connector) {
return(NULL);
}
-static char *
-close_file_output(port *p)
+static char *close_file_output(p)
+ port *p;
{
errno = 0;
if (p->data.file.output_connector) {
return(NULL);
}
-void create_port_from_files(string name,
- FILE *input,
- FILE *output)
+void create_port_from_files(name, input, output)
+ string name;
+ FILE *input;
+ FILE *output;
{
port *p = create_named_port(name);
/* */
/****************************************************************************/
-void
-create_subprocess_port(string name,
- char **argv)
+void create_subprocess_port(name, argv)
+ string name;
+ char **argv;
{
int pid;
int to_child_descriptors[2];
create_port_from_files(name, in, out);
}
-void
-create_file_append_port(string name,
- string filename)
+void create_file_append_port(name, filename)
+ string name;
+ string filename;
{
FILE *out;
int oumask;
create_port_from_files(name, 0, out);
}
-void
-create_file_input_port(string name,
- string filename)
+void create_file_input_port(name, filename)
+ string name;
+ string filename;
{
FILE *in;
create_port_from_files(name, in, 0);
}
-void
-create_file_output_port(string name,
- string filename)
+void create_file_output_port(name, filename)
+ string name;
+ string filename;
{
FILE *out;
int oumask;
/* */
/****************************************************************************/
-static string
-get_filter(port *p,
- char **error_p)
+static string get_filter(p, error_p)
+ port *p;
+ char **error_p;
{
string result;
return(result);
}
-static char *
-put_filter(port *p,
- string text,
- int length)
+static char *put_filter(p, text, length)
+ port *p;
+ string text;
+ int length;
{
string input;
string output;
return(NULL);
}
-static char *
-close_filter_input(port *p)
+static char *close_filter_input(p)
+ port *p;
{
while (!string_stack_empty(p->data.filter.waiting_packets))
string_stack_pop(p->data.filter.waiting_packets);
}
/*ARGSUSED*/
-static char *
-close_filter_output(port *p)
+static char *close_filter_output(p)
+ port *p;
{
return(NULL);
}
-void
-create_port_from_filter(string name,
- string (*filter)(string))
+void create_port_from_filter(name, filter)
+ string name;
+ string (*filter)();
{
port *p = create_named_port(name);
/* */
/****************************************************************************/
-static char *
-put_output(port *p,
- string text,
- int length)
+static char *put_output(p, text, length)
+ port *p;
+ string text;
+ int length;
{
string input;
char *error;
}
/*ARGSUSED*/
-static char *
-close_output(port *p)
+static char *close_output(p)
+ port *p;
{
return(NULL);
}
-void
-create_port_from_output_proc(string name,
- char *(*output)(string))
+void create_port_from_output_proc(name, output)
+ string name;
+ char *(*output)();
{
#ifdef SABER /* Yes, it's another ANSI incompatiblity */
port *p;
} file;
struct {
string_stack waiting_packets;
- string (*filter)(string);
+ string (*filter)();
} filter;
struct {
- char *(*output)(string);
+ char *(*output)();
} output;
};
-typedef struct port__struct { /* PRIVATE */
- char *(*get)(struct port__struct *, char **);
- char *(*put)(struct port__struct *, char *, int);
- char *(*close_input)(struct port__struct *);
- char *(*close_output)(struct port__struct *);
+typedef struct { /* PRIVATE */
+ char *(*get)();
+ char *(*put)();
+ char *(*close_input)();
+ char *(*close_output)();
#define INPUT_CLOSED 0x1
#define OUTPUT_CLOSED 0x2
#define PORT_CLOSED 0x3
* any other port call is made.
*/
-extern void init_ports(void);
+extern void init_ports();
/*
* string read_from_port(string name)
* on the heap & must be eventually freed.
*/
-extern string read_from_port(string);
+extern string read_from_port();
/*
* void write_on_port(string name, char *text, int length)
* occurs, $error is set to the error message.
*/
-extern void write_on_port(string, char *, int);
+extern void write_on_port();
/*
* void close_port_input(string name)
* occurs, $error is set to the error message.
*/
-extern void close_port_input(string);
+extern void close_port_input();
/*
* void close_port_output(string name)
* occurs, $error is set to the error message.
*/
-extern void close_port_output(string);
+extern void close_port_output();
-extern void create_subprocess_port(string, char **);
-extern void create_file_append_port(string, string);
-extern void create_file_input_port(string, string);
-extern void create_file_output_port(string, string);
-extern void create_port_from_filter(string, string (*)(string));
-extern void create_port_from_output_proc(string, char *(*)(string));
+extern void create_subprocess_port();
+extern void create_file_append_port();
+extern void create_file_input_port();
+extern void create_file_output_port();
+extern void create_port_from_filter();
+extern void create_port_from_output_proc();
-extern void init_standard_ports(int *, char **);
-extern void create_port_from_files(string, FILE *, FILE *);
+extern void init_standard_ports();
+extern void create_port_from_files();
#endif
#include "regexp.h"
-int
-ed_regexp_match_p(string test_string,
- string pattern)
+int ed_regexp_match_p(test_string, pattern)
+ string test_string;
+ string pattern;
{
regex_t RE;
int retval;
#include "new_string.h"
-extern int ed_regexp_match_p(string, string);
+extern int ed_regexp_match_p();
#endif
#include "main.h"
#include <zephyr/zephyr.h>
-extern char *tty_filter(string, int);
-extern int tty_filter_init(char *, char, int *, char **);
+extern string tty_filter();
+extern int tty_filter_init();
#ifndef X_DISPLAY_MISSING
-extern char *X_driver(string);
-extern int X_driver_init(char *, char, int *, char **);
+extern char *X_driver();
+extern int X_driver_init();
#endif
-extern void usage(void);
+extern void usage();
/*
*
*/
-char *
-plain_driver(string input)
+char *plain_driver(input)
+ string input;
{
string processed_input = tty_filter(input, 0);
*
*/
-char *
-tty_driver(string input)
+char *tty_driver(input)
+ string input;
{
string processed_input = tty_filter(input, 1);
*
*/
-string
-noop_filter(string input)
+string noop_filter(input)
+ string input;
{
return(input);
}
*
*/
-string
-plain_filter(string input)
+string plain_filter(input)
+ string input;
{
return(tty_filter(input, 0));
}
*
*/
-string
-fancy_filter(string input)
+string fancy_filter(input)
+ string input;
{
return(tty_filter(input, 1));
}
#define DISABLED 2
int port_setup_status;
- int (*port_init)(char *, char, int *, char **);
+ int (*port_init)();
#define INPUT_DESC 0
#define OUTPUT_DESC 1
#define FILTER 2
#define OUTPUT_PROC 3
int type;
- char *(*function)(string);
+ char *(*function)();
int setup_arg;
} standard_port_info_table[] = {
#ifndef X_DISPLAY_MISSING
* <<<>>>
*/
-static struct standard_port_info *
-get_standard_port_info(string port_name)
+static struct standard_port_info *get_standard_port_info(port_name)
+ string port_name;
{
struct standard_port_info *p;
* returns -1.
*/
-static int
-boolean_value_of(string text)
+static int boolean_value_of(text)
+ string text;
{
if (!text)
return(-1); /* not set */
*
*/
-void init_standard_ports(int *pargc,
- char **argv)
+void init_standard_ports(pargc, argv)
+ int *pargc;
+ char **argv;
{
struct standard_port_info *p;
string first_working_port = "";
current++; *pargc -= 2;
if (!*current)
usage();
- p = get_standard_port_info((string) *current);
- if (p)
+ if (p = get_standard_port_info((string) *current))
p->port_setup_status = DISABLED;
} else if (string_Eq((string) *current, "-default")) {
current++; *pargc -= 2;
if (!*current)
usage();
default_port = (string) *current;
- p = get_standard_port_info((string) *current);
- if (p)
+ if (p = get_standard_port_info((string) *current))
p->port_setup_status = DEFAULT_OK;
} else if (string_Eq((string) *current, "-ttymode")) {
default_port = (string) "tty";
(*pargc)--;
- p = get_standard_port_info(default_port);
- if (p) {
+ if (p = get_standard_port_info(default_port)) {
p->port_setup_status = DEFAULT_OK;
- p = get_standard_port_info ((string) "X");
- if (p)
+ if (p = get_standard_port_info ((string) "X"))
p->port_setup_status = DISABLED;
}
} else
*/
#if (!defined(lint) && !defined(SABER))
-static const char rcsid_string_dictionary_aux_c[] = "$Id$";
+static char rcsid_string_dictionary_aux_c[] = "$Id$";
#endif
/*
* heap.
*/
-void
-string__dictionary_Set(string_dictionary d,
- string key,
- string value)
+void string__dictionary_Set(d, key, value)
+ string_dictionary d;
+ string key;
+ string value;
{
string_dictionary_binding *binding;
int already_exists;
* disappear later if key is rebound.
*/
-char *
-string_dictionary_Fetch(string_dictionary d,
- string key)
+char *string_dictionary_Fetch(d, key)
+ string_dictionary d;
+ string key;
{
string_dictionary_binding *binding;
* all value's in the dictionary.
*/
-static void
-free_value_of_binding(string_dictionary_binding *b)
+static void free_value_of_binding(b)
+ string_dictionary_binding *b;
{
free(b->value);
}
-void
-string_dictionary_SafeDestroy(string_dictionary d)
+void string_dictionary_SafeDestroy(d)
+ string_dictionary d;
{
string_dictionary_Enumerate(d, free_value_of_binding);
string_dictionary_Destroy(d);
* heap.
*/
-extern void string__dictionary_Set(string_dictionary, string, string);
+extern void string__dictionary_Set();
#ifdef DEBUG_MEMORY
#define string_dictionary_Set(a,b,c) (set_module(__FILE__,__LINE__),\
string__dictionary_Set(a,b,c))
* disappear later if key is rebound.
*/
-extern char *string_dictionary_Fetch(string_dictionary,
- string);
+extern char *string_dictionary_Fetch();
/*
* void string_dictionary_SafeDestroy(string_dictionary d)
* all value's in the dictionary.
*/
-extern void string_dictionary_SafeDestroy(string_dictionary);
+extern void string_dictionary_SafeDestroy();
#endif
*/
#if (!defined(lint) && !defined(SABER))
-static const char rcsid_subscriptions_c[] = "$Id$";
+static char rcsid_subscriptions_c[] = "$Id$";
#endif
/****************************************************************************/
*/
static int_dictionary puntable_addresses_dict = 0;
-static void
-init_puntable_dict(void)
+static void init_puntable_dict()
{
puntable_addresses_dict = int_dictionary_Create(33);
}
-static string
-address_to_string(string class,
- string instance,
- string recipient)
+static string address_to_string(class, instance, recipient)
+ string class;
+ string instance;
+ string recipient;
{
string result;
return(result);
}
-int puntable_address_p(string class,
- string instance,
- string recipient)
+int puntable_address_p(class, instance, recipient)
+ string class;
+ string instance;
+ string recipient;
{
string temp;
return(0);
}
-void punt(string class,
- string instance,
- string recipient)
+void punt(class, instance, recipient)
+ string class;
+ string instance;
+ string recipient;
{
string temp;
free(temp);
}
-void unpunt(string class,
- string instance,
- string recipient)
+void unpunt(class, instance, recipient)
+ string class;
+ string instance;
+ string recipient;
{
string temp;
int_dictionary_binding *binding;
static int unsubscription_list_size = 0;
static ZSubscription_t unsubscription_list[BATCH_SIZE];
-static void
-free_subscription_list(ZSubscription_t *list,
- int number_of_elements)
+static void free_subscription_list(list, number_of_elements)
+ ZSubscription_t *list;
+ int number_of_elements;
{
int i;
}
}
-static void
-flush_subscriptions(void)
+static void flush_subscriptions()
{
TRAP(ZSubscribeTo(subscription_list,subscription_list_size, 0),
"while subscribing");
subscription_list_size = 0;
}
-static void
-flush_unsubscriptions(void)
+static void flush_unsubscriptions()
{
if (unsubscription_list_size)
TRAP(ZUnsubscribeTo(unsubscription_list, unsubscription_list_size, 0),
unsubscription_list_size = 0;
}
-static void
-subscribe(string class,
- string instance,
- string recipient)
+static void subscribe(class, instance, recipient)
+ string class;
+ string instance;
+ string recipient;
{
subscription_list[subscription_list_size].zsub_class = string_Copy(class);
subscription_list[subscription_list_size].zsub_classinst= string_Copy(instance);
flush_subscriptions();
}
-static void
-unsubscribe(string class,
- string instance,
- string recipient)
+static void unsubscribe(class, instance, recipient)
+ string class;
+ string instance;
+ string recipient;
{
unsubscription_list[unsubscription_list_size].zsub_class = string_Copy(class);
unsubscription_list[unsubscription_list_size].zsub_classinst
char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN];
-static void
-inithosts(void)
+static void inithosts()
{
struct hostent *hent;
if (gethostname(ourhost, sizeof(ourhost)-1) == -1) {
return;
}
-static void
-macro_sub(char *str)
+static void macro_sub(str)
+ char *str;
{
static int initedhosts = 0;
#define UNSUBSCRIBE_CHARACTER '!'
#define PUNT_CHARACTER '-'
-static void
-load_subscriptions_from_file(FILE *file)
+static void load_subscriptions_from_file(file)
+ FILE *file;
{
char line[BUFSIZ];
char class_buffer[BUFSIZ], instance[BUFSIZ], recipient[BUFSIZ];
/* Parse line */
/* <<<>>>
* The below does NOT work is the recipient field is "":
- */
- temp = strchr(line, '#');
- if (temp)
+ */
+ if (temp = strchr(line, '#'))
*temp = '\0';
for (temp=line; *temp && *temp==' '; temp++) ;
if (!*temp || *temp=='\n')
#define DEFSUBS "/dev/null"
-static void
-load_subscriptions(void)
+static void load_subscriptions()
{
FILE *subscriptions_file;
static ZSubscription_t *saved_subscriptions = NULL;
static int number_of_saved_subscriptions;
-void zwgc_shutdown(void)
+void zwgc_shutdown()
{
if (!zwgc_active)
return;
zwgc_active = 0;
}
-void zwgc_startup(void)
+void zwgc_startup()
{
if (zwgc_active)
return;
extern int zwgc_active;
-extern int puntable_address_p(string, string, string);
-extern void punt(string, string, string);
-extern void unpunt(string, string, string);
-extern void zwgc_shutdown(void);
-extern void zwgc_startup(void);
+extern int puntable_address_p(/* string class, instance, recipient */);
+extern void punt();
+extern void unpunt();
+extern void zwgc_shutdown();
+extern void zwgc_startup();
#define USRSUBS ".zephyr.subs"
*/
#if (!defined(lint) && !defined(SABER))
-static const char rcsid_substitute_c[] = "$Id$";
+static char rcsid_substitute_c[] = "$Id$";
#endif
#include <zephyr/mit-copyright.h>
* The returned string must not be freed.
*/
-static string
-eat_dollar_sign_stuff(string (*lookup)(string),
- string *text_ptr) /* Input/Output parameter */
+static string eat_dollar_sign_stuff(lookup, text_ptr)
+ string (*lookup)();
+ string *text_ptr; /* Input/Output parameter */
{
char c;
char closing_brace = 0;
* modified in any way or freed.
*/
-string
-substitute(string (*lookup)(string),
- string text)
+string substitute(lookup, text)
+ string (*lookup)();
+ string text;
{
string result_so_far = string_Copy("");
char *p, *temp;
* modified in any way or freed.
*/
-extern string substitute(string (*)(string), string);
+extern string substitute();
#endif
#include "text_operations.h"
#include "char_stack.h"
-string
-lany(string *text_ptr,
- string str)
+string lany(text_ptr, str)
+ string *text_ptr;
+ string str;
{
string result, whats_left;
char *p = *text_ptr;
return(result);
}
-string
-lbreak(string *text_ptr,
- const character_class set)
+string lbreak(text_ptr, set)
+ string *text_ptr;
+ character_class set;
{
string result, whats_left;
char *p = *text_ptr;
- while (*p && !set[(int)*p]) p++;
+ while (*p && !set[*p]) p++;
result = string_CreateFromData(*text_ptr, p - *text_ptr);
whats_left = string_Copy(p);
return(result);
}
-string
-lspan(string *text_ptr,
- character_class set)
+string lspan(text_ptr, set)
+ string *text_ptr;
+ character_class set;
{
string result, whats_left;
char *p = *text_ptr;
- while (*p && set[(int)*p]) p++;
+ while (*p && set[*p]) p++;
result = string_CreateFromData(*text_ptr, p - *text_ptr);
whats_left = string_Copy(p);
return(result);
}
-string
-rany(string *text_ptr,
- string str)
+string rany(text_ptr, str)
+ string *text_ptr;
+ string str;
{
string result, whats_left;
string text = *text_ptr;
return(result);
}
-string
-rbreak(string *text_ptr,
- character_class set)
+string rbreak(text_ptr, set)
+ string *text_ptr;
+ character_class set;
{
string result, whats_left;
string text = *text_ptr;
char *p = text + strlen(text);
- while (text<p && !set[(int)p[-1]]) p--;
+ while (text<p && !set[p[-1]]) p--;
result = string_Copy(p);
whats_left = string_CreateFromData(text, p - text);
return(result);
}
-string
-rspan(string *text_ptr,
- character_class set)
+string rspan(text_ptr, set)
+ string *text_ptr;
+ character_class set;
{
string result, whats_left;
string text = *text_ptr;
char *p = text + strlen(text);
- while (text<p && set[(int)p[-1]]) p--;
+ while (text<p && set[p[-1]]) p--;
result = string_Copy(p);
whats_left = string_CreateFromData(text, p - text);
#include "character_class.h"
-extern string lany(string *, string);
-extern string lbreak(string *, const character_class);
-extern string lspan(string *, character_class);
-extern string rany(string *, string);
-extern string rbreak(string *, character_class);
-extern string rspan(string *, character_class);
+extern string protect();
+extern string verbatim();
+extern string stylestrip();
+extern string lany();
+extern string lbreak();
+extern string lspan();
+extern string rany();
+extern string rbreak();
+extern string rspan();
#endif
/* The tty & plain filters: */
/* */
/****************************************************************************/
-#ifdef HAVE_TERMCAP_H
-#include <termcap.h>
-#else
-#ifdef HAVE_TERM_H
-#include <term.h>
-#endif
-#endif
#include "new_memory.h"
#include "new_string.h"
#include "error.h"
/***************************************************************************/
-#ifndef HAVE_TERMCAP_H
+
extern int tgetent();
extern char *tgetstr(),*getenv();
#ifdef linux
extern short ospeed;
#endif
char PC;
-#endif
/* Dictionary naming convention:
*code_buf_pos++ = 0, TD_SET(k, code))
static int
-tty_outc(int c)
+tty_outc(c)
+ int c;
{
*code_buf_pos++ = c;
return 0;
}
/* ARGSUSED */
-int
-tty_filter_init(char *drivername,
- char notfirst,
- int *pargc,
- char **argv)
+int tty_filter_init(drivername, notfirst, pargc, argv)
+char *drivername;
+char notfirst;
+int *pargc;
+char **argv;
{
static char st_buf[128];
char tc_buf[1024], *p = st_buf, *tmp, *term;
tmp = tgetstr("pc", &p);
PC = (tmp) ? *tmp : 0;
- tmp = tgetstr("md", &p);
- if (tmp) { /* bold ? */
+ if (tmp = tgetstr("md",&p)) { /* bold ? */
EXPAND("B.bold");
tmp = tgetstr("me",&p);
EXPAND("E.bold");
}
- tmp = tgetstr("mr", &p);
- if (tmp) { /* reverse video? */
+ if (tmp = tgetstr("mr",&p)) { /* reverse video? */
EXPAND("B.rw");
- tmp = tgetstr("me", &p);
+ tmp = tgetstr("me",&p);
EXPAND("E.rw");
}
- tmp = tgetstr("bl", &p);
- if (tmp) { /* Bell ? */
+ if (tmp = tgetstr("bl",&p)) { /* Bell ? */
EXPAND("B.bell");
TD_SET("E.bell", NULL);
}
- tmp = tgetstr("mb", &p);
- if (tmp) { /* Blink ? */
+ if (tmp = tgetstr("mb",&p)) { /* Blink ? */
EXPAND("B.blink");
- tmp = tgetstr("me", &p);
+ tmp = tgetstr("me",&p);
EXPAND("E.blink");
}
- tmp = tgetstr("us", &p);
- if (tmp) { /* Underline ? */
+ if (tmp = tgetstr("us",&p)) { /* Underline ? */
EXPAND("B.u");
- tmp = tgetstr("ue", &p);
+ tmp = tgetstr("ue",&p);
EXPAND("E.u");
}
- tmp = tgetstr("so", &p);
- if (tmp) { /* Standout ? */
+ if (tmp = tgetstr("so",&p)) { /* Standout ? */
EXPAND("B.so");
- tmp = tgetstr("se", &p);
+ tmp = tgetstr("se",&p);
EXPAND("E.so");
}
}
/* Step 2: alias others to the nearest substitute */
/* Bold = so, else rv, else ul */
- if (NULL == string_dictionary_Lookup(termcap_dict, "B.bold")) {
- if((b = string_dictionary_Lookup(termcap_dict, "B.so"))) {
- TD_SET("B.bold", b->value);
+ if (NULL == string_dictionary_Lookup(termcap_dict,"B.bold")) {
+ if(b = string_dictionary_Lookup(termcap_dict,"B.so")) {
+ TD_SET("B.bold",b->value);
TD_SET("E.bold",
- string_dictionary_Lookup(termcap_dict, "E.so")->value);
- } else if ((b = string_dictionary_Lookup(termcap_dict, "B.rv"))) {
- TD_SET("B.bold", b->value);
+ string_dictionary_Lookup(termcap_dict,"E.so")->value);
+ } else if (b = string_dictionary_Lookup(termcap_dict,"B.rv")) {
+ TD_SET("B.bold",b->value);
TD_SET("E.bold",
- string_dictionary_Lookup(termcap_dict, "E.rv")->value);
- } else if ((b = string_dictionary_Lookup(termcap_dict,"B.u"))) {
- TD_SET("B.bold", b->value);
+ string_dictionary_Lookup(termcap_dict,"E.rv")->value);
+ } else if (b = string_dictionary_Lookup(termcap_dict,"B.u")) {
+ TD_SET("B.bold",b->value);
TD_SET("E.bold",
- string_dictionary_Lookup(termcap_dict, "E.u")->value);
+ string_dictionary_Lookup(termcap_dict,"E.u")->value);
}
}
/* Bell = ^G */
- if (NULL == string_dictionary_Lookup(termcap_dict, "B.bell")) {
- TD_SET("B.bell", "\007");
- TD_SET("E.bell", NULL);
+ if (NULL == string_dictionary_Lookup(termcap_dict,"B.bell")) {
+ TD_SET("B.bell","\007");
+ TD_SET("E.bell",NULL);
}
/* Underline -> nothing */
-static int
-fixed_string_eq(string pattern,
- char *text,
- int text_length)
+static int fixed_string_eq(pattern, text, text_length)
+ string pattern;
+ char *text;
+ int text_length;
{
while (*pattern && text_length>0 && *pattern == *text) {
pattern++;
unsigned int ignore: 1;
} tty_str_info;
-static void
-free_info(tty_str_info *info)
+static void free_info(info)
+ tty_str_info *info;
{
tty_str_info *next_info;
}
}
-static int
-do_mode_change(tty_str_info *current_mode_p,
- char *text,
- int text_length)
+static int do_mode_change(current_mode_p, text, text_length)
+ tty_str_info *current_mode_p;
+ char *text;
+ int text_length;
{
/* alignment commands: */
if (fixed_string_eq("left", text, text_length) ||
return 0;
}
-static tty_str_info *
-convert_desc_to_tty_str_info(desctype *desc)
+static tty_str_info *convert_desc_to_tty_str_info(desc)
+ desctype *desc;
{
tty_str_info *temp;
tty_str_info *result = NULL;
#define max(a,b) ((a)>(b)?(a):(b))
-static int
-line_width(int left_width,
- int center_width,
- int right_width)
+static int line_width(left_width, center_width, right_width)
+ int left_width;
+ int center_width;
+ int right_width;
{
if (center_width>0) {
if (left_width==0 && right_width==0)
}
}
-static int
-calc_max_line_width(tty_str_info *info)
+static int calc_max_line_width(info)
+ tty_str_info *info;
{
int max_line_width = 0;
int left = 0;
return(max_line_width);
}
-string
-tty_filter(string text,
- int use_fonts)
+string tty_filter(text, use_fonts)
+ string text;
+ int use_fonts;
{
string text_copy = string_Copy(text);
string result_so_far = string_Copy("");
item = string_Copy("");
if (info->bold_p && use_fonts) {
- temp = string_dictionary_Fetch(termcap_dict, "B.bold");
- if (temp)
+ if (temp = string_dictionary_Fetch(termcap_dict, "B.bold"))
item = string_Concat2(item, temp);
} else if (info->italic_p && use_fonts) {
- temp = string_dictionary_Fetch(termcap_dict, "B.u");
- if (temp)
+ if (temp = string_dictionary_Fetch(termcap_dict, "B.u"))
item = string_Concat2(item, temp);
}
temp = string_CreateFromData(info->str, info->len);
free(temp);
if (info->bold_p && use_fonts) {
- temp = string_dictionary_Fetch(termcap_dict, "E.bold");
- if (temp)
+ if (temp = string_dictionary_Fetch(termcap_dict, "E.bold"))
item = string_Concat2(item, temp);
} else if (info->italic_p && use_fonts) {
- temp = string_dictionary_Fetch(termcap_dict, "E.u");
- if (temp)
+ if (temp = string_dictionary_Fetch(termcap_dict, "E.u"))
item = string_Concat2(item, temp);
}
* Effects: Returns true iff text matches [0-9]*. ("" matches...)
*/
-static int
-is_digits(string text)
+static int is_digits(text)
+ string text;
{
for (; *text; text++)
if (!isdigit(*text))
* Effects: Sets all description langauge variables to "".
*/
-void
-var_clear_all_variables(void)
+void var_clear_all_variables()
{
if (non_number_variable_dict) {
string_dictionary_SafeDestroy(non_number_variable_dict);
* call. DO NOT FREE THIS STRING.
*/
-string
-var_get_variable(string name)
+string var_get_variable(name)
+ string name;
{
char *result;
int field_to_get;
static string last_get_field_call_result = NULL;
if (is_number_variable(name)) {
- result = string_dictionary_Fetch(number_variable_dict, name);
- if (result)
+ if (result = string_dictionary_Fetch(number_variable_dict, name))
return(result);
/*
* to have the value value.
*/
-void
-var_set_variable(string name,
- string value)
+void var_set_variable(name, value)
+ string name;
+ string value;
{
string_dictionary_Set(is_number_variable(name) ? number_variable_dict
: non_number_variable_dict, name, value);
* to have as its value number's ascii representation.
*/
-void
-var_set_variable_to_number(string name,
- int number)
+void var_set_variable_to_number(name, number)
+ string name;
+ int number;
{
char buffer[20];
* convenience reasons.
*/
-void
-var_set_variable_then_free_value(string name,
- string value)
+void var_set_variable_then_free_value(name, value)
+ string name;
+ string value;
{
string_dictionary_binding *binding;
int exists;
* data or var_clear_all_variables is called.
*/
-void
-var_set_number_variables_to_fields(char *data,
- int length)
+void var_set_number_variables_to_fields(data, length)
+ char *data;
+ int length;
{
fields_data = data;
fields_data_length = length;
* Effects: Sets all description langauge variables to "".
*/
-extern void var_clear_all_variables(void);
+extern void var_clear_all_variables();
/*
* string var_get_variable(string name)
* call. DO NOT FREE THIS STRING.
*/
-extern string var_get_variable(string);
+extern string var_get_variable();
/*
* void var_set_variable(string name, value)
* to have the value value.
*/
-extern void var_set_variable(string, string);
+extern void var_set_variable();
/*
* void var_set_variable_to_number(string name; int number)
* to have as its value number's ascii representation.
*/
-extern void var_set_variable_to_number(string, int);
+extern void var_set_variable_to_number();
/*
* void var_set_variable_then_free_value(string name, value)
* convenience reasons.
*/
-extern void var_set_variable_then_free_value(string, string);
+extern void var_set_variable_then_free_value();
/*
* void var_set_number_variables_to_fields(char *data, int length)
* data or var_clear_all_variables is called.
*/
-extern void var_set_number_variables_to_fields(char *, int);
+extern void var_set_number_variables_to_fields();
#endif
#include "xmark.h"
#include "error.h"
#include "xrevstack.h"
-#include "X_driver.h"
/*
*
*/
+extern char *xmarkGetText();
+
extern long ttl;
static char *selected_text=NULL;
static Window selecting_in = 0;
-char *
-getSelectedText(void)
+char *getSelectedText()
{
return(selected_text);
}
#ifdef notdef
-static string
-x_gram_to_string(x_gram *gram)
+static string x_gram_to_string(gram)
+ x_gram *gram;
{
int i, index, len;
int last_y = -1;
*/
/*ARGSUSED*/
-Bool
-isShiftButton1(Display *dpy,
- XEvent *event,
- char *arg)
+Bool isShiftButton1(dpy,event,arg)
+ Display *dpy;
+ XEvent *event;
+ char *arg;
{
return(event->xbutton.state & (ShiftMask|Button1Mask));
}
/*ARGSUSED*/
-Bool
-isShiftButton3(Display *dpy,
- XEvent *event,
- char *arg)
+Bool isShiftButton3(dpy,event,arg)
+ Display *dpy;
+ XEvent *event;
+ char *arg;
{
return(event->xbutton.state & (ShiftMask|Button3Mask));
}
-void
-getLastEvent(Display *dpy,
- unsigned int state,
- XEvent *event)
+void getLastEvent(dpy,state,event)
+ Display *dpy;
+ unsigned int state;
+ XEvent *event;
{
XEvent xev;
}
}
-void
-xunmark(Display *dpy,
- Window w,
- x_gram *gram,
- XContext desc_context)
+void xunmark(dpy,w,gram,desc_context)
+ Display *dpy;
+ Window w;
+ x_gram *gram;
+ XContext desc_context;
{
if (gram == NULL)
if (XFindContext(dpy, w, desc_context, (caddr_t *) &gram))
static int current_pressop = PRESSOP_NONE;
-void
-xdestroygram(Display *dpy,
- Window w,
- XContext desc_context,
- x_gram *gram)
+void xdestroygram(dpy,w,desc_context,gram)
+ Display *dpy;
+ Window w;
+ XContext desc_context;
+ x_gram *gram;
{
struct timeval now;
}
}
-void
-xcut(Display *dpy,
- XEvent *event,
- XContext desc_context)
+void xcut(dpy,event,desc_context)
+ Display *dpy;
+ XEvent *event;
+ XContext desc_context;
{
x_gram *gram;
Window w = event->xany.window;
int xerror_happened;
/*ARGSUSED*/
-static int
-xerrortrap(Display *dpy,
- XErrorEvent *xerrev)
+static int xerrortrap(dpy,xerrev)
+ Display *dpy;
+ XErrorEvent *xerrev;
{
xerror_happened = 1;
return 0;
}
/*ARGSUSED*/
-void
-begin_xerror_trap(Display *dpy)
+void begin_xerror_trap(dpy)
+ Display *dpy;
{
xerror_happened = 0;
XSetErrorHandler(xerrortrap);
}
-void
-end_xerror_trap(Display *dpy)
+void end_xerror_trap(dpy)
+ Display *dpy;
{
XSync(dpy,False);
XSetErrorHandler(NULL);
extern int xerror_happened;
-void begin_xerror_trap(Display *);
-void end_xerror_trap(Display *);
+void begin_xerror_trap();
+void end_xerror_trap();
#endif
*/
#if (!defined(lint) && !defined(SABER))
-static const char rcsid_xmark_c[] = "$Id$";
+static char rcsid_xmark_c[] = "$Id$";
#endif
#include <zephyr/mit-copyright.h>
(STARTCHAR != -1) && (ENDCHAR != -1) && \
(STARTPIXEL != -1) && (ENDPIXEL != -1))
-void
-xmarkSetBound(x_gram *gram,
- int x,
- int y,
- int which)
+void xmarkSetBound(gram,x,y,which)
+ x_gram *gram;
+ int x,y;
+ int which;
{
int i,xofs,yofs;
XFontStruct *font;
}
/* needs both bounds to be valid (!= -1) */
-static int
-xmarkNearest(int x,
- int y)
+static int xmarkNearest(x,y)
+ int x,y;
{
int middle;
}
}
-void
-xmarkExpose(Display *dpy,
- Window w,
- x_gram *gram,
- unsigned int b1,
- unsigned int p1,
- unsigned int b2,
- unsigned int p2)
+void xmarkExpose(dpy,w,gram,b1,p1,b2,p2)
+ Display *dpy;
+ Window w;
+ x_gram *gram;
+ unsigned int b1,p1,b2,p2;
{
#define swap(x,y) temp=(x); (x)=(y); (y)=temp
int i,temp;
/* Public functions: */
-void
-xmarkRedraw(Display *dpy,
- Window w,
- x_gram *gram,
- int range)
+void xmarkRedraw(dpy,w,gram,range)
+ Display *dpy;
+ Window w;
+ x_gram *gram;
+ int range;
{
#define ob1 ((unsigned int) oldblock[XMARK_START_BOUND])
#define ob2 ((unsigned int) oldblock[XMARK_END_BOUND])
}
/* needs both bounds to be valid (!= -1) */
-int
-xmarkSecond(void)
+int xmarkSecond()
{
if (STARTBLOCK > ENDBLOCK)
return(XMARK_START_BOUND);
}
}
-void
-xmarkClear(void)
+void xmarkClear()
{
oldblock[0]=markblock[0];
oldblock[1]=markblock[1];
markgram=NULL;
}
-int
-xmarkExtendFromFirst(x_gram *gram,
- int x,
- int y)
+int xmarkExtendFromFirst(gram,x,y)
+ x_gram *gram;
+ int x,y;
{
if (markgram != gram) {
xmarkClear();
}
}
-int
-xmarkExtendFromNearest(x_gram *gram,
- int x,
- int y)
+int xmarkExtendFromNearest(gram,x,y)
+ x_gram *gram;
+ int x,y;
{
int bound;
}
}
-char *
-xmarkGetText(void)
+char *xmarkGetText()
{
int i, index, len;
int last_y = -1;
#define STARTPIXEL (markpixel[XMARK_START_BOUND])
#define ENDPIXEL (markpixel[XMARK_END_BOUND])
-extern void xmarkSetBound(x_gram *, int, int, int);
-extern int xmarkSecond(void);
-extern void xmarkRedraw(Display *, Window, x_gram *, int);
-extern void xmarkClear(void);
-extern int xmarkExtendFromFirst(x_gram *, int, int);
-extern int xmarkExtendFromNearest(x_gram *, int, int);
-extern char *xmarkGetText(void);
+extern void xmarkSetBound();
+extern int xmarkSecond();
+extern void xmarkRedraw();
+extern void xmarkClear();
+extern int xmarkExtendFromStart();
+extern int xmarkExtendFromNearest();
#endif
x_gram *unlinked = NULL;
int reverse_stack = 0;
-void
-add_to_bottom(x_gram *gram)
+void add_to_bottom(gram)
+ x_gram *gram;
{
if (bottom_gram) {
bottom_gram->below = gram;
}
/*ARGSUSED*/
-void
-pull_to_top(x_gram *gram)
-{
-}
+void pull_to_top(gram)
+ x_gram *gram;
+{}
/*ARGSUSED*/
-void
-push_to_bottom(x_gram *gram)
-{
-}
+void push_to_bottom(gram)
+ x_gram *gram;
+{}
-void
-delete_gram(x_gram *gram)
+void delete_gram(gram)
+ x_gram *gram;
{
if (gram == bottom_gram) {
if (gram->above) {
gram->above = gram;
}
-void
-unlink_gram(x_gram *gram)
+void unlink_gram(gram)
+ x_gram *gram;
{
delete_gram(gram);
static x_gram *top_gram=NULL;
#ifdef DEBUG
-void
-print_gram_list(char *str)
+void print_gram_list(str)
+char *str;
{
x_gram *gram;
char buf[80];
}
#endif
-void
-pull_to_top(x_gram *gram)
+void pull_to_top(gram)
+x_gram *gram;
{
if (gram==top_gram) {
/* already here */
#endif
}
-void
-push_to_bottom(x_gram *gram)
+void push_to_bottom(gram)
+x_gram *gram;
{
if (gram==bottom_gram) {
/* already here */
#endif
}
-void
-unlink_gram(x_gram *gram)
+void unlink_gram(gram)
+x_gram *gram;
{
if (top_gram==bottom_gram) {
/* the only gram in the stack */
}
#ifdef notdef
-void
-add_to_top(x_gram *gram)
+void add_to_top(gram)
+x_gram *gram;
{
if (top_gram==NULL) {
gram->above=NULL;
}
#endif
-void
-add_to_bottom(x_gram *gram)
+void add_to_bottom(gram)
+x_gram *gram;
{
if (bottom_gram==NULL) {
gram->above=NULL;
#define _XREVSTACK_H_
#if (!defined(lint) && !defined(SABER))
-static const char rcsid_xrevstack_h[] = "$Id$";
+static char rcsid_xrevstack_h[] = "$Id$";
#endif
#include <zephyr/mit-copyright.h>
extern x_gram *unlinked;
extern int reverse_stack; /* is reverse stack on? */
-extern void add_to_bottom(x_gram *);
-extern void delete_gram(x_gram *);
-extern void unlink_gram(x_gram *);
-extern void pull_to_top(x_gram *);
-extern void push_to_bottom(x_gram *);
+extern void add_to_bottom(/* x_gram */);
+extern void delete_gram(/* x_gram */);
+extern void unlink_gram(/* x_gram */);
+extern void pull_to_top(/* x_gram */);
+extern void push_to_bottom(/* x_gram */);
#endif /* _XREVSTACK_H_ */
#include "new_string.h"
#include "xselect.h"
-extern char *getSelectedText(void);
+extern char *getSelectedText();
static Time ownership_start = CurrentTime;
static Time ownership_end = CurrentTime;
/* internal static functions */
-static void
-xselNotify(Display *dpy,
- XSelectionRequestEvent *selreq,
- Atom property)
+static void xselNotify(dpy,selreq,property)
+ Display *dpy;
+ XSelectionRequestEvent *selreq;
+ Atom property;
{
XSelectionEvent ev;
XChangeProperty(dpy,w,PROP(property,target),(type),(format), \
PropModeReplace, (unsigned char *) (data),(size))
-static void
-xselSetProperties(Display *dpy,
- Window w,
- Atom property,
- Atom target,
- XSelectionRequestEvent *selreq)
+static void xselSetProperties(dpy,w,property,target,selreq)
+ Display *dpy;
+ Window w;
+ Atom property,target;
+ XSelectionRequestEvent *selreq;
{
if (target==ZA_TARGETS) {
} else if (target==XA_STRING) {
char *selected;
- selected = getSelectedText();
- if (selected) {
+ if (selected = getSelectedText()) {
ChangeProp(XA_STRING,8,selected,string_Length(selected));
} else {
/* This should only happen if the pasting client is out of
/* global functions */
-void
-xicccmInitAtoms(Display *dpy)
+void xicccmInitAtoms(dpy)
+ Display *dpy;
{
int i;
RequestAtoms[i] = *(pRequestAtoms[i]);
}
-int
-xselGetOwnership(Display *dpy,
- Window w,
- Time time)
+int xselGetOwnership(dpy,w,time)
+ Display *dpy;
+ Window w;
+ Time time;
{
int temp;
}
/* Get the selection. Return !0 if success, 0 if fail */
-int
-xselProcessSelection(Display *dpy,
- Window w,
- XEvent *event)
+int xselProcessSelection(dpy,w,event)
+ Display *dpy;
+ Window w;
+ XEvent *event;
{
XSelectionRequestEvent *selreq = &(event->xselectionrequest);
#endif
if ((ownership_start == CurrentTime) ||
- (((selreq->time != CurrentTime) &&
- (selreq->time < ownership_start)) ||
+ ((selreq->time != CurrentTime) &&
+ (selreq->time < ownership_start) ||
((ownership_end != CurrentTime) &&
(ownership_end > ownership_start) &&
(selreq->time > ownership_end))))
return(1);
}
-void
-xselOwnershipLost(Time time)
+void xselOwnershipLost(time)
+ Time time;
{
ownership_end = time;
}
/*ARGSUSED*/
-void
-xselGiveUpOwnership(Display *dpy,
- Window w)
+void xselGiveUpOwnership(dpy,w)
+ Display *dpy;
+ Window w;
{
XSetSelectionOwner(dpy,XA_PRIMARY,None,ownership_start);
#ifndef _XSELECT_H_
#define _XSELECT_H_
-extern void xicccmInitAtoms(Display *);
-extern int xselGetOwnership(Display *, Window, Time);
-extern int xselProcessSelection(Display *, Window, XEvent *);
-extern void xselOwnershipLost(Time);
-extern void xselGiveUpOwnership(Display *, Window);
+extern void xicccmInitAtoms();
+extern int xselGetOwnership();
+extern int xselProcessSelection();
+extern void xselOwnershipLost();
+extern void xselGiveUpOwnership();
-extern Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
+extern int xwmprotoDelete();
+
+extern Atom XA_WM_PROTOCOLS,XA_WM_DELETE_WINDOW;
#endif
#include <X11/Xresource.h>
#include "pointer_dictionary.h"
#include "new_memory.h"
-#include "new_string.h"
#include "formatter.h"
#include "variables.h"
#include "zwgc.h"
-#include "X_driver.h"
#include "X_fonts.h"
#include "X_gram.h"
#include "xmode_stack.h"
#define max(a,b) ((a)>(b)?(a):(b))
XContext desc_context;
+static pointer_dictionary colorname_dict = NULL;
extern int internal_border_width;
extern unsigned long default_bgcolor;
extern unsigned long default_fgcolor;
+extern unsigned long x_string_to_color();
void
-xshowinit(void)
+xshowinit()
{
desc_context = XUniqueContext();
}
char * resclass;
};
-static char *
-xres_get_resource(struct res_dict_type *restype,
- char *style)
+static char *xres_get_resource (restype, style)
+ struct res_dict_type *restype;
+ char *style;
{
char *desc;
pointer_dictionary_binding *binding;
};
/*ARGSUSED*/
-char *
-mode_to_colorname (Display *dpy,
- char *style,
- xmode *mode)
+char *mode_to_colorname (dpy, style, mode)
+ Display *dpy;
+ char *style;
+ xmode *mode;
{
char *desc, *result;
return result;
}
-void
-fixup_and_draw(Display *dpy,
- char *style,
- xauxblock *auxblocks,
- xblock *blocks,
- int num,
- xlinedesc *lines,
- int numlines,
- int beepcount)
+void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
+ beepcount)
+ Display *dpy;
+ char *style;
+ xblock *blocks;
+ xauxblock *auxblocks;
+ int num;
+ xlinedesc *lines;
+ int numlines;
+ int beepcount;
{
int gram_xalign = 1;
int gram_yalign = 1;
}
/* Silly almost-but-not-quite-useless helper function */
-char *
-no_dots_downcase_var(char *str)
+char *no_dots_downcase_var(str)
+ char *str;
{
register char *var, *var2;
#define MODE_TO_FONT(dpy,style,mode) \
get_font((dpy),(style),(mode)->font?(mode)->font:(mode)->substyle, \
(mode)->size, (mode)->bold+(mode)->italic*2)
-void
-xshow(Display *dpy,
- desctype *desc,
- int numstr,
- int numnl)
+void xshow(dpy, desc, numstr, numnl)
+ Display *dpy;
+ desctype *desc;
+ int numstr;
+ int numnl;
{
XFontStruct *font;
xmode_stack modes = xmode_stack_create();
free(style);
}
-static void
-xhandleevent(Display *dpy,
- Window w,
- XEvent *event)
+static void xhandleevent(dpy, w, event)
+ Display *dpy;
+ Window w;
+ XEvent *event;
{
x_gram *gram;
XFlush(dpy);
}
-void
-x_get_input(Display *dpy)
+void x_get_input(dpy)
+ Display *dpy;
{
XEvent event;
* modified in any way.
*/
-static string
-get_zwgc_port_number_filename(void)
+static string get_zwgc_port_number_filename()
{
static char buffer[40];
char *temp;
+ char *getenv();
- temp = getenv("WGFILE");
- if (temp)
+ if (temp = getenv("WGFILE"))
return(temp);
else {
sprintf(buffer, "/tmp/wg.%d", getuid());
* Write out the port number to the wg file.
*/
-void
-write_wgfile(void)
+void write_wgfile()
{
char *name = get_zwgc_port_number_filename();
FILE *port_file;
*
*/
-static void
-handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
+static void handle_zephyr_input(notice_handler)
+ void (*notice_handler)();
{
ZNotice_t *notice;
struct sockaddr_in from;
*
*/
-void zephyr_init(void (*notice_handler)(ZNotice_t *))
+void zephyr_init(notice_handler)
+ void (*notice_handler)();
{
char *temp;
char *exposure;
* not one of the allowed ones, print an error and treat it as
* EXPOSE_NONE.
*/
- temp = ZGetVariable("exposure");
- if (temp) {
+ if (temp = ZGetVariable("exposure")) {
if (!(exposure = ZParseExposureLevel(temp))) {
ERROR2("invalid exposure level %s, using exposure level none instead.\n", temp);
exposure = EXPOSE_NONE;
/*
* <<<>>>
*/
- mux_add_input_source(ZGetFD(), (void (*)(void *))handle_zephyr_input,
+ mux_add_input_source(ZGetFD(), (void (*)())handle_zephyr_input,
notice_handler);
zephyr_inited = 1;
return;
*
*/
-void finalize_zephyr(void) /* <<<>>> */
+void finalize_zephyr() /* <<<>>> */
{
string temp;
#ifndef zephyr_MODULE
#define zephyr_MODULE
-#include <zephyr/zephyr.h>
-
-extern void zephyr_init(void(*)(ZNotice_t *));
-extern void finalize_zephyr(void);
-extern void write_wgfile(void);
+extern void zephyr_init();
+extern void finalize_zephyr();
+extern void write_wgfile();
#endif