]> andersk Git - moira.git/commitdiff
Solaris/POSIX changes
authordanw <danw>
Mon, 20 Jan 1997 18:22:15 +0000 (18:22 +0000)
committerdanw <danw>
Mon, 20 Jan 1997 18:22:15 +0000 (18:22 +0000)
Source tree should only have Imakefiles, not Makefiles

dcm/Imakefile
dcm/Makefile [deleted file]
dcm/dcm.c
dcm/startdcm.c
dcm/utils.c
reg_svr/Imakefile
reg_svr/Makefile [deleted file]
reg_svr/reg_svr.c
reg_svr/requests.c
reg_svr/startreg.c

index 1c00ff653ada90f478a62a1d82d5ef9f5eec4a40..ed30e4a439905ae09900b2f78e16ec787f7a9924 100644 (file)
@@ -11,9 +11,6 @@ SRCDIR = $(SRCTOP)/dcm
 SRCS= startdcm.c dcm.c utils.c
 CODE=$(SRCS)
 OBJS=dcm.o utils.o
-#ifdef GDSS
-GDSSLIB=/mit/gdss/`machtype`/libgdss.a
-#endif
 
-program(dcm, $(OBJS),,../server/libmrglue.a ../update/moira_update.o $(GDSSLIB) $(CLIBS) $(SQL_LIB), ${PROGDIR})
+program(dcm, $(OBJS),,../server/libmrglue.a $(LIBGDSS) ../update/moira_update.o $(CLIBS) $(SQL_LIB), ${PROGDIR})
 program(startdcm, startdcm.o,,,${PROGDIR})
diff --git a/dcm/Makefile b/dcm/Makefile
deleted file mode 100644 (file)
index 4d671de..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#      $Source$
-#      $Author$
-#      $Header$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-SMS_DIR = ..
-INGRES_DIR = /usr/rtingres
-UPDATE_DIR = ${SMS_DIR}/update
-
-INCDIR = -I${SMS_DIR}/include
-CFLAGS = ${INCDIR} -g
-LDFLAGS = -L${SMS_DIR}/lib -L${SMS_DIR}/server
-
-QLIBS= ${INGRES_DIR}/lib/libqlib ${INGRES_DIR}/lib/compatlib
-
-# Libraries that talk to the MOIRA server:
-SERVER_LIBS = -lmoiraglue -lmoira -lgdb -lzephyr -lkrb -ldes -lcom_err $(QLIBS)
-
-DCM_SRCS = dcm.c utils.c
-DCM_OBJS = dcm.o utils.o ../update/moira_update.o
-
-
-all: dcm startdcm
-
-dcm: ${DCM_OBJS}
-       rm -f $@
-       ${CC} ${LDFLAGS} -o $@ ${DCM_OBJS} ${SERVER_LIBS}
-
-startdcm: startdcm.o
-       ${CC} ${LDFLAGS} -o startdcm startdcm.o
-
-clean: 
-       rm -f *.o core *~
-       rm -f dcm startdcm .saber
-
-install: dcm startdcm
-       install -c dcm ${SMS_DIR}/bin/dcm
-       install -c startdcm ${SMS_DIR}/bin/startdcm
-
-lint:
-       lint ${INCDIR} ${DCM_SRCS} | grep -v "possible pointer alignment"
-
-
-.saber: Makefile
-       rm -rf $@
-       echo "setopt(\"load_options\", \"${CFLAGS} ${LDFLAGS}\");" >$@
-       echo "#define DCM_SRCS \"${DCM_SRCS} ${SMS_UPDATE}\"" >>$@
-       echo "#define FOO_SRCS \"${FOO_SRCS}\"" >>$@
-       echo "#define GLUE_LIBS \"${GLUE_LIBS}\"" >>$@
-       echo "#define SERVER_LIBS \"${SERVER_LIBS}\"" >>$@
-       echo "suppress(285); " >>$@
-
-depend:
-       mkdep ${CFLAGS} ${DCM_SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
-
-dcm.o: dcm.c /usr/include/stdio.h ../include/update.h /usr/include/sys/file.h
-dcm.o: /usr/include/sys/time.h /usr/include/sys/time.h
-dcm.o: /usr/include/sys/wait.h /usr/include/signal.h /usr/include/ctype.h
-dcm.o: ../include/moira.h ../include/mr_et.h ../include/moira_site.h
-dcm.o: ../include/mit-copyright.h ../include/dcm.h
-utils.o: utils.c ../include/mit-copyright.h /usr/include/stdio.h
-utils.o: /usr/include/strings.h /usr/include/errno.h /usr/include/varargs.h
-utils.o: /usr/include/sys/types.h /usr/include/sys/time.h
-utils.o: /usr/include/sys/time.h /usr/include/sys/file.h ../include/moira.h
-utils.o: ../include/mr_et.h ../include/moira_site.h ../include/dcm.h
index 89668a092dc524c7ed942a54a0b87a97f370db73..81ff34ad2367670669ecf2af8d7bfe8def2f76e5 100644 (file)
--- a/dcm/dcm.c
+++ b/dcm/dcm.c
@@ -19,12 +19,15 @@ static char rcsid_dcm_c[] = "$Header$";
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <signal.h>
 #include <ctype.h>
 #include <moira.h>
 #include <moira_site.h>
 #include "dcm.h"
 #include "mit-copyright.h"
+#include <unistd.h>
 
 extern char *ctime();
 extern char *getenv();
@@ -54,8 +57,9 @@ char *argv[];
        dbg = s ? atoi(s) : 0;
        umask(UMASK);
        log_flags = 0;
-       setlinebuf(stderr);
-       setlinebuf(stdout);
+
+       setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+       setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
        
        while(++arg - argv < argc) {
            if (**arg == '-')
@@ -157,7 +161,8 @@ do_services()
     int status, lock_fd, ex, (*cstat)();
     struct timezone tz;
     register char *p;
-    union wait waits;
+    int waits;
+    struct sigaction action, prevaction;
 
     if (dbg & DBG_VERBOSE)
        com_err(whoami, 0, "starting pass over services");
@@ -217,18 +222,23 @@ do_services()
                }
            
                com_err(whoami, status, " running %s", dfgen_prog);
-               cstat = signal(SIGCHLD, SIG_DFL);
-               waits.w_status = system(dfgen_cmd);
-               signal(SIGCHLD, cstat);
-               if (waits.w_termsig) {
+
+               action.sa_flags = 0;
+               sigemptyset(&action.sa_mask);
+               action.sa_handler = SIG_DFL;
+               sigaction(SIGCHLD, &action, &prevaction);
+               waits = system(dfgen_cmd);
+               sigaction(SIGCHLD, &prevaction, NULL);
+               if (WIFSIGNALED(waits)) {
                    status = MR_COREDUMP;
                    com_err(whoami, status, " %s exited on signal %d",
-                           dfgen_prog, waits.w_termsig);
-               } else if (waits.w_retcode) {
+                           dfgen_prog, WTERMSIG(waits));
+               } else if (WEXITSTATUS(waits)) {
                    /* extract the process's exit value */
-                   status = waits.w_retcode + ERROR_TABLE_BASE_sms;
+                   status = WEXITSTATUS(waits) + ERROR_TABLE_BASE_sms;
                    com_err(whoami, status, " %s exited", dfgen_prog);
                }
+
                if (SOFT_FAIL(status)) {
                    free(qargv[5]);
                    qargv[5] = strsave(error_message(status));
index 90451d513ee6c4d59ea3eb99396047cb4262ed36..e2fdac8bf02d79acfa2286dcdee93345c8415bd6 100644 (file)
@@ -23,33 +23,33 @@ static char *rcsid_mr_starter_c = "$Header$";
 #include <sys/wait.h>
 #include <sys/signal.h>
 #include <sys/ioctl.h>
+#include <fcntl.h>
+#include <sys/resource.h>
 #include <moira_site.h>
 
 #define PROG   "dcm"
 
 int rdpipe[2];
-extern char *sys_siglist[];
+extern int errno;
 
-cleanup()
+void cleanup()
 {
-       union wait stat;
+       int stat, serrno = errno;
        char buf[BUFSIZ];
-       extern int errno;
-       int serrno = errno;
 
        buf[0]='\0';
        
-       while (wait3(&stat, WNOHANG, 0) > 0) {
+       while (waitpid(-1, &stat, WNOHANG) > 0) {
                if (WIFEXITED(stat)) {
-                       if (stat.w_retcode)
+                       if (WEXITSTATUS(stat))
                                sprintf(buf,
                                        "exited with code %d\n",
-                                       stat.w_retcode);
+                                       WEXITSTATUS(stat));
                }
                if (WIFSIGNALED(stat)) {
-                       sprintf(buf, "exited on %s signal%s\n",
-                               sys_siglist[stat.w_termsig],
-                               (stat.w_coredump?"; Core dumped":0));
+                       sprintf(buf, "exited with signal %d%s\n",
+                               WTERMSIG(stat),
+                               (WCOREDUMP(stat)?"; Core dumped":0));
                }
                write(rdpipe[1], buf, strlen(buf));
                close(rdpipe[1]);
@@ -62,15 +62,22 @@ main(argc, argv)
        char buf[BUFSIZ];
        FILE *log, *prog;
        int logf, inf, i, done, pid, tty;
+       struct rlimit rl;
        
        extern int errno;
        extern char *sys_errlist[];
        
-       int nfds = getdtablesize();
-       
-       setreuid(0);
-       signal(SIGCHLD, cleanup);
-       
+       struct sigaction action;
+       int nfds;
+
+       getrlimit(RLIMIT_NOFILE, &rl);
+       nfds = rl.rlim_cur;
+
+       action.sa_handler = cleanup;
+       action.sa_flags = 0;
+       sigemptyset(&action.sa_mask);
+       sigaction(SIGCHLD, &action, NULL);
+
        sprintf(buf, "%s/%s.log", SMS_DIR, PROG);
        logf = open(buf, O_CREAT|O_WRONLY|O_APPEND, 0640);
        if (logf<0) {
@@ -94,9 +101,7 @@ main(argc, argv)
        dup2(inf, 1);
        dup2(inf, 2);
        
-       tty = open("/dev/tty");
-       ioctl(tty, TIOCNOTTY, 0);
-       close(tty);
+       setpgrp();
        sprintf(buf, "%s/%s", BIN_DIR, PROG);
        
        if ((pid = fork()) == 0) {
index db51555b7b79cd4136525f9e2baed15e6e18d583..6db3e19459eb9b4f983f78d2333408f32cc4cfa8 100644 (file)
@@ -23,6 +23,8 @@ static char *rcsid_utils_c = "$Header$";
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/file.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <moira.h>
 #include <moira_site.h>
 #include "dcm.h"
@@ -97,12 +99,15 @@ int exclusive;
 {
     char lock[BUFSIZ];
     int fd;
+    flock_t fl;
 
     sprintf(lock, "%s/%s.%s", LOCK_DIR, host, service);
-    if ((fd = open(lock, O_TRUNC |  O_CREAT, 0)) < 0)
+    fl.l_type = exclusive ? F_WRLCK : F_RDLCK;
+    fl.l_whence = fl.l_start = fl.l_len = 0;
+    if ((fd = open(lock, O_TRUNC |  O_CREAT | O_RDWR, 0)) < 0)
       com_err(whoami, errno, ": maybe_lock_update: opening %s", lock);
-    else if (flock(fd, (exclusive ? LOCK_EX : LOCK_SH) | LOCK_NB) != 0) {
-       if (errno != EWOULDBLOCK
+    else if (fcntl(fd, F_SETLK, &fl) != 0) {
+       if (errno != EAGAIN
          com_err(whoami, errno, ": maybe_lock_update: flock");
        else if (dbg & DBG_VERBOSE)
          com_err(whoami, 0, "%s already locked\n", lock);
index fb4aeabae9f7cc1d30220adab4707723cba830dc..6796812b6909307116d849d4ff13a9f2e080bad3 100644 (file)
@@ -11,9 +11,6 @@ SRCDIR = $(SRCTOP)/reg_svr
 SRCS= startreg.c reg_svr.c requests.c reg_svr.h
 CODE=$(SRCS)
 OBJS=requests.o reg_svr.o
-#ifdef GDSS
-GDSSLIB=/mit/gdss/`machtype`/libgdss.a
-#endif
 
-program(reg_svr, $(OBJS),,../server/libmrglue.a -lkadm $(GDSSLIB) $(CLIBS) $(SQL_LIB), ${PROGDIR})
+program(reg_svr, $(OBJS),,../server/libmrglue.a -lkadm $(LIBGDSS) $(CLIBS) $(SQL_LIB), ${PROGDIR})
 program(startreg, startreg.o,,,${PROGDIR})
diff --git a/reg_svr/Makefile b/reg_svr/Makefile
deleted file mode 100644 (file)
index b33767c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-#      $Source$
-#      $Author$
-#      $Locker$
-#      $Header$
-#
-# (c) Copyright 1988 by the Massachusetts Institute of Technology.
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-
-CFLAGS= -O -I../include -I../lib
-SRCS = requests.c reg_svr.c startreg.c
-OBJS = requests.o reg_svr.o
-
-all: reg_svr startreg
-
-reg_svr: $(OBJS)
-       cc ${CFLAGS} -o reg_svr $(OBJS) -L../lib \
-               ../server/libmoiraglue.a /mit/gdss/vax/libgdss.a \
-               -lmoira -lkadm -lkrb -ldes -lzephyr -lhesiod -lcom_err \
-               /usr/rtingres/lib/libqlib /usr/rtingres/lib/compatlib
-
-reg_svr.o requests.o: reg_svr.h 
-
-startreg: startreg.o
-       cc -o startreg startreg.o
-
-clean: /tmp
-       rm -f a.out core *.o
-       rm -f reg_svr startreg
-       rm -f unreg_user.c unreg_user
-
-install: all
-       install -c reg_svr ../bin/reg_svr
-       install -c startreg ../bin/startreg
-
-depend:
-       mkdep ${CFLAGS} ${SRCS}
-
-# DO NOT DELETE THIS LINE -- mkdep uses it.
index 60dd1006241068c2051b3a8eaa6c035c87f9e1c1..1bf8dd3f015ee2767ca0da3f28b288a330ca939c 100644 (file)
@@ -56,8 +56,8 @@ main(argc,argv)
     whoami = argv[0];
     
     /* Error messages sent one line at a time */
-    setlinebuf(stderr);
-    setlinebuf(stdout);
+    setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
     set_com_err_hook(reg_com_err_hook);
     
     /* Initialize com_err error tables */
@@ -318,7 +318,7 @@ int find_user(message)
 
     /* Zero the mit_id field in the formatted packet structure.  This
        being zeroed means that no user was found. */
-    bzero(message->db.mit_id,sizeof(message->db.mit_id));
+    memset(message->db.mit_id,0,sizeof(message->db.mit_id));
     
     if (status == SUCCESS)
     {
@@ -460,7 +460,7 @@ int ureg_kadm_init()
 
     if (!inited) {
        inited++;
-       bzero(krbrealm, sizeof(krbrealm));
+       memset(krbrealm, 0, sizeof(krbrealm));
        if (status = krb_get_lrealm(krbrealm, 1)) {
            status += krb_err_base;
            com_err(whoami, status, " fetching kerberos realm");
@@ -527,7 +527,7 @@ int reserve_krb(login)
 #endif DEBUG
 
     if ((status = ureg_kadm_init()) == SUCCESS) {
-       bzero((char *)&new, sizeof(new));
+       memset(&new, 0, sizeof(new));
        SET_FIELD(KADM_DESKEY, new.fields);
        SET_FIELD(KADM_NAME, new.fields);
        
@@ -541,7 +541,7 @@ int reserve_krb(login)
        if (status != KADM_SUCCESS) 
            com_err(whoami, status, " while reserving principal");
        
-       bzero((char *)&new, sizeof(new));
+       memset(&new, 0, sizeof(new));
     }
 
     dest_tkt();
@@ -563,7 +563,7 @@ int setpass_krb(login, password)
     u_long *lkey = (u_long *)key;
 
     if ((status = ureg_kadm_init()) == SUCCESS) {
-       bzero((char *)&new, sizeof(new));
+       memset(&new, 0, sizeof(new));
        SET_FIELD(KADM_DESKEY, new.fields);
        SET_FIELD(KADM_NAME, new.fields);
        
@@ -983,7 +983,7 @@ char *retval;
     
     creds.length = ntohl(*((int *)bp));
     bp += sizeof(int);
-    bcopy(bp, creds.dat, creds.length);
+    memcpy(creds.dat, bp, creds.length);
     creds.mbz = 0;
     bp += creds.length;
 
@@ -1014,7 +1014,7 @@ char *retval;
                     keys, auth.session, 0);
 
     id = buf;
-    passwd = index(buf, ',');
+    passwd = strchr(buf, ',');
     *passwd++ = 0;
 #ifdef DEBUG
     com_err(whoami, 0, "Got id: %s, passwd %d chars", id, strlen(passwd));
@@ -1039,7 +1039,7 @@ char *retval;
        return(status);
     }
 
-    bzero((char *)&kv, sizeof(kv));
+    memset(&kv, 0, sizeof(kv));
     SET_FIELD(KADM_DESKEY, kv.fields);
     SET_FIELD(KADM_NAME, kv.fields);
     SET_FIELD(KADM_INST, kv.fields);
index 98ec328980aea86799b642423394cee3735945ad..d0559000c4d3ff5fe9e4bc06443e0f877bb4e254 100644 (file)
@@ -87,7 +87,7 @@ void req_initialize()
        com_err(whoami,errno," socket");
        exit(1);
     }
-    bzero((char *)&sin,(int)sizeof(sin));
+    memset(&sin, 0, sizeof(sin));
     
     sin.sin_family = AF_INET;
     sin.sin_port = sp->s_port;
@@ -215,11 +215,11 @@ int format_pkt(packet, pktlenp, seqno, cl_status, message)
     U_32BIT vers = htonl((U_32BIT)CUR_UREG_VERSION);
     cl_status = htonl((U_32BIT)cl_status);
     /* Put current user registration protocol version into the packet */
-    bcopy((char *)&vers, packet, sizeof(U_32BIT));
+    memcpy(packet, &vers, sizeof(U_32BIT));
     /* Put sequence number into the packet */
-    bcopy((char *)&seqno, packet+sizeof(U_32BIT), sizeof(U_32BIT));
+    memcpy(packet+sizeof(U_32BIT), &seqno, sizeof(U_32BIT));
     /* Put error status into the packet */
-    bcopy((char *)&cl_status, packet+ 2*sizeof(U_32BIT), sizeof(U_32BIT));
+    memcpy(packet+ 2*sizeof(U_32BIT), &cl_status, sizeof(U_32BIT));
     
     /* Find out how much of the message to copy; truncate if too short. */
     /* How much room is there left? */
@@ -292,7 +292,7 @@ parse_pkt(packet, pktlen, message)
     if (status == SUCCESS)
     {
        /* Extract the user registration protocol version from the packet */
-       bcopy(packet, (char *)&message->version, sizeof(long));
+       memcpy(&message->version, packet, sizeof(long));
        /* Convert byte order from network to host */
        message->version = ntohl(message->version);
        /* Verify version */
@@ -312,7 +312,7 @@ parse_pkt(packet, pktlen, message)
     if (status == SUCCESS)
     {
        /* Extract the sequence number from the packet */
-       bcopy(packet, (char *)&CUR_REQ.seqno, sizeof(long));
+       memcpy(&CUR_REQ.seqno, packet, sizeof(long));
        
        packet += sizeof(U_32BIT);
        pktlen -= sizeof(U_32BIT);
@@ -324,7 +324,7 @@ parse_pkt(packet, pktlen, message)
     if (status == SUCCESS)
     {
        /* Extract the request from the packet */
-       bcopy(packet, (char *)(&message->request), sizeof(U_32BIT));
+       memcpy(&message->request, packet, sizeof(U_32BIT));
        message->request = ntohl(message->request);
        packet += sizeof(U_32BIT);
        pktlen -= sizeof(U_32BIT);
index 9cd4e21c1240315febf1986fdb0cd2e9c5e04140..92d6fc6c485d9e9e120797f9041bc5b07cc0f377 100644 (file)
@@ -23,33 +23,35 @@ static char *rcsid_mr_starter_c = "$Header$";
 #include <sys/wait.h>
 #include <sys/signal.h>
 #include <sys/ioctl.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
 #include <moira_site.h>
 
 #define PROG   "reg_svr"
 
 int rdpipe[2];
-extern char *sys_siglist[];
 
 cleanup()
 {
-       union wait stat;
+       int stat;        
        char buf[BUFSIZ];
        extern int errno;
        int serrno = errno;
 
        buf[0]='\0';
        
-       while (wait3(&stat, WNOHANG, 0) > 0) {
+       while (waitpid(-1, &stat, WNOHANG) > 0) {
                if (WIFEXITED(stat)) {
-                       if (stat.w_retcode)
+                       if (WEXITSTATUS(stat))
                                sprintf(buf,
                                        "exited with code %d\n",
-                                       stat.w_retcode);
+                                       WEXITSTATUS(stat));
                }
                if (WIFSIGNALED(stat)) {
-                       sprintf(buf, "exited on %s signal%s\n",
-                               sys_siglist[stat.w_termsig],
-                               (stat.w_coredump?"; Core dumped":0));
+                       sprintf(buf, "exited on signal %d%s\n",
+                               WTERMSIG(stat),
+                               (WCOREDUMP(stat)?"; Core dumped":0));
                }
                write(rdpipe[1], buf, strlen(buf));
                close(rdpipe[1]);
@@ -62,14 +64,21 @@ main(argc, argv)
        char buf[BUFSIZ];
        FILE *log, *prog;
        int logf, inf, i, done, pid, tty;
+       struct rlimit rl;
        
        extern int errno;
        extern char *sys_errlist[];
        
-       int nfds = getdtablesize();
+       struct sigaction action;
+       int nfds;
        
-       setreuid(0);
-       signal(SIGCHLD, cleanup);
+       getrlimit(RLIMIT_NOFILE, &rl);
+       nfds = rl.rlim_cur;
+
+       action.sa_handler = cleanup;
+       action.sa_flags = 0;
+       sigemptyset(&action.sa_mask);
+       sigaction(SIGCHLD, &action, NULL);
        
        sprintf(buf, "%s/%s.log", SMS_DIR, PROG);
        logf = open(buf, O_CREAT|O_WRONLY|O_APPEND, 0640);
@@ -94,9 +103,7 @@ main(argc, argv)
        dup2(inf, 1);
        dup2(inf, 2);
        
-       tty = open("/dev/tty");
-       ioctl(tty, TIOCNOTTY, 0);
-       close(tty);
+       setpgrp();
        sprintf(buf, "%s/%s", BIN_DIR, PROG);
        
        if ((pid = fork()) == 0) {
This page took 0.292698 seconds and 5 git commands to generate.