dtcm: remove register keyword
[oweals/cde.git] / cde / programs / dtcm / server / svcmain.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: svcmain.c /main/10 1998/04/06 13:13:49 mgreess $ */
24 /*
25  *  (c) Copyright 1993, 1994 Hewlett-Packard Company
26  *  (c) Copyright 1993, 1994 International Business Machines Corp.
27  *  (c) Copyright 1993, 1994 Novell, Inc.
28  *  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
29  */
30
31 #if defined(__linux__)
32 #define _POSIX_C_SOURCE 2
33 #endif
34
35 #include <EUSCompat.h>
36 #include <stdio.h>
37 #include <errno.h>
38 #include <string.h>
39 #include <stdlib.h>
40 #include <unistd.h>
41 #include <sys/time.h>
42 #include <sys/resource.h>
43 #ifdef SVR4
44 #ifndef _NETINET_IN_H
45 #include <netinet/in.h>
46 #endif /* _NETINET_IN_H */
47 #endif
48
49 #if defined(SunOS)
50 #include <netconfig.h>
51 #include <netdir.h>
52 #include <sys/stropts.h>
53 #include <tiuser.h>
54 #endif /* SunOS */
55 #include <sys/param.h>
56 #include <sys/stat.h>
57 #include <fcntl.h>
58 #include <rpc/rpc.h>
59 #include <sys/file.h>
60 #include <sys/signal.h>
61 #include <pwd.h>
62 #include <grp.h>
63 #include "rpcextras.h"
64 #include "log.h"
65 #include "cmscalendar.h"
66 #include "repeat.h"
67 #include "lutil.h"
68 #include "cmsdata.h"
69
70 #ifndef S_IRWXU
71 #define S_IRWXU         (S_IRUSR|S_IWUSR|S_IXUSR)
72 #endif
73 #ifndef S_IRWXG
74 #define S_IRWXG         (S_IRGRP|S_IWGRP|S_IXGRP)
75 #endif
76 #ifndef S_IRWXO
77 #define S_IRWXO         (S_IROTH|S_IWOTH|S_IXOTH)
78 #endif
79
80 #define S_MASK  (S_INPUT|S_HIPRI|S_ERROR|S_HANGUP)
81
82 int debug;
83 static int standalone;                  /* default is 0 */
84 static int received_sighup = 0;         /* 1 means we get SIGHUP */
85 static int rpc_in_process = 0;          /* 1 means processing client request */
86 static int garbage_collection_time = 240; /* in min; default time is 4:00am */
87
88 char    *pgname;
89
90 uid_t daemon_uid;
91 gid_t daemon_gid;
92
93 /*
94  * get garbage collection time
95  * the given string should be in the format hhmm
96  * where hh is 0 - 23 and mm is 00 - 59
97  */
98 static int
99 _GetGtime(char *timestr)
100 {
101         int     hour, minute, len, i;
102
103         if (timestr == NULL)
104                 goto error;
105
106         if ((len = strlen(timestr)) > 4)
107                 goto error;
108
109         for (i = 0; i < len; i++) {
110                 if (timestr[i] < '0' || timestr[i] > '9')
111                         goto error;
112         }
113
114         minute = atoi(&timestr[len - 2]);
115         timestr[len - 2] = '\0';
116         hour = atoi(timestr);
117
118         if (hour > 23 || minute > 59)
119                 goto error;
120
121         garbage_collection_time = hour * 60 + minute;
122
123         return (0);
124
125 error:
126         fprintf(stderr, "The time specified is invalid.\n");
127         return (-1);
128 }
129
130 static void
131 parse_args(int argc, char **argv)
132 {
133         int     opt;
134
135         if (pgname = strrchr (argv[0], '/'))
136                 pgname++;
137         else
138                 pgname = argv[0];
139
140         while ((opt = getopt (argc, argv, "dsg:")) != -1)
141         {
142                 switch (opt)
143                 {
144                 case 'd':
145                         debug = 1;
146                         break;
147                 case 's':
148                         standalone = 1;
149                         break;
150                 case 'g':
151                         if (_GetGtime(optarg))
152                                 goto error;
153                         break;
154                 case '?':
155                         goto error;
156                 }
157         }
158
159         if (optind == argc)
160                 return;
161
162 #if defined(_aix)
163         /*
164          * rpc.cmsd gets started by the inetd.
165          * On AIX inetd requires that two arguments be supplied to the RPC
166          * programs as follows (from the inetd.conf man page):
167          *
168          * ServerArgs      Specifies the command line arguments that the
169          * inetd daemon should use to execute the server. The maximum number
170          * of arguments is five. The first argument specifies the name of the
171          * server used.  If the SocketType parameter is sunrpc_tcp or
172          * sunrpc_udp, * the second argument specifies the program name and
173          * the third argument specifies the version of the program. For
174          * services that the inetd daemon provides internally, this field
175          * should be empty.
176          */
177
178         else if (optind == 1 && argc >= 3)
179         {
180                 int i,j;
181                 char **argv_r;
182                 
183                 if (argc == 3)
184                   return;
185                   
186                 argv_r = (char **) malloc(argc * sizeof(char *));
187
188                 argv_r[0] = argv[0];
189                 for (i=optind+2, j=1; i<argc; i++,j++)
190                   argv_r[j] = argv[i];
191                 parse_args(argc-2, argv_r);
192
193                 free((void *) argv_r);
194                 return;
195         }
196 #endif
197                 
198 error:
199         fprintf (stderr, "Usage: %s [-d] [-s] [-g hhmm]\n", pgname);
200         exit (-1);
201 }
202
203 static void
204 init_dir(void)
205 {
206         char *dir = _DtCMS_DEFAULT_DIR;
207         char msgbuf[BUFSIZ];
208         int create_dir;
209         struct stat info;
210         mode_t mode;
211
212         if (geteuid() != 0)
213         {
214                 fprintf (stderr,
215                         "%s: must be run in super-user mode!  Exited.\n",
216                         pgname);
217                 exit (-1);
218         }
219
220         create_dir = 0;
221         if (stat(dir, &info))
222         {
223                 /* if directory does not exist, create the directory */
224                 if ((errno != ENOENT) || mkdir(dir, S_IRWXU|S_IRWXG|S_IRWXO))
225                 {
226                         if (errno == ENOENT)
227                                 sprintf(msgbuf, "%s: cannot create %s.\n%s: %s",
228                                         pgname, dir, pgname, "System error");
229                         else
230                                 sprintf(msgbuf, "%s: cannot access %s.\n%s: %s",
231                                         pgname, dir, pgname, "System error");
232                         perror (msgbuf);
233                         exit (-1);
234                 }
235                 create_dir = 1;
236         }
237
238         /* if dir is just created, we need to do chmod and chown.
239          * Otherwise, only do chmod and/or chown if permssion and/or
240          * ownership is wrong.
241          */
242         mode = S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO;
243
244         if (create_dir || info.st_mode != (mode | S_IFDIR)) {
245
246                 /* set directory permission to be "rwxrwsrwt" */
247                 if (chmod(dir, mode)) {
248                         sprintf(msgbuf, "%s: Permission on %s%s\n%s%s\n%s%s",
249                                 pgname, dir,
250                                 " is wrong but cannot be corrected.", pgname,
251                                 ": This might happen if you are mounting the directory.",
252                                 pgname, ": System error");
253                         perror(msgbuf);
254                         if (create_dir)
255                                 rmdir(dir);
256                         exit(-1);
257                 }
258         }
259
260         if (create_dir || info.st_uid!=daemon_uid || info.st_gid!=daemon_gid) {
261                 /* set directory ownership to: owner = 1, group = 1 */
262                 if (chown(dir, daemon_uid, daemon_gid)) {
263                         sprintf(msgbuf, "%s: Ownership on %s%s\n%s%s\n%s%s",
264                                 pgname, dir,
265                                 " is wrong but cannot be corrected.", pgname,
266                                 ": This might happen if you are mounting the directory.",
267                                 pgname, ": System error");
268                         perror(msgbuf);
269                         if (create_dir)
270                                 rmdir(dir);
271                         exit(-1);
272                 }
273         }
274
275         /* Change current directory, so core file can be dumped. */
276         if(-1 == chdir (dir)) {
277                 perror(strerror(errno));
278         }
279 }
280
281 /*
282  * send a SIGHUP signal to the rpc.cmsd that is already running
283  */
284 static void
285 send_hup(void)
286 {
287         FILE    *fp = NULL;
288         char    buf[BUFSIZ];
289         pid_t   pid, mypid = getpid();
290         extern FILE *popen(const char *, const char *);
291         extern int pclose(FILE *);
292
293         sprintf(buf, "ps -e|grep rpc.cmsd|grep -v grep");
294
295         if ((fp = popen(buf, "r")) == NULL) {
296                 if (debug)
297                         fprintf(stderr, "rpc.cmsd: popen failed\n");
298         } else {
299                 while (fgets(buf, sizeof(buf), fp) != NULL) {
300                         if ((pid = atol(buf)) != mypid) {
301                                 if (kill(pid, SIGHUP))
302                                     perror("rpc.cmsd: failed to send SIGHUP");
303                                 if (debug)
304                                     fprintf(stderr, "rpc.cmsd: %s %ld\n",
305                                                 "sent SIGHUP to", (long)pid);
306                         }
307                 }
308                 pclose(fp);
309         }
310 }
311
312 /*
313  * We only allow one rpc.cmsd to run on each machine.
314  */
315 static int
316 lock_it(void)
317 {
318         char *dir = _DtCMS_DEFAULT_DIR;
319         char    buff [MAXPATHLEN];
320         int     error;
321         int     fd;
322 #ifdef SVR4
323         struct flock locker;
324         locker.l_type = F_WRLCK;
325         locker.l_whence = 0;
326         locker.l_start = 0;
327         locker.l_len = 0;
328 #endif /* SVR4 */
329
330         strcpy (buff, dir);
331         strcat (buff, "/.lock.");
332
333         /* 
334          * /var/spool might be mounted.  Use .lock.hostname to
335          * prevent more than one cms running in each host.
336          */
337         strcat(buff, _DtCmGetLocalHost());
338
339         fd = open(buff, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
340         if (fd < 0)
341         {
342                 perror (buff);
343                 exit (-1);
344         }
345
346         /*
347          * Note, we have to use flock() instead of lockf() because cms process
348          * is run in each host.
349          */
350 #ifdef SVR4
351         if (fcntl (fd, F_SETLK, &locker) != 0)
352 #else
353         if (flock (fd, LOCK_EX|LOCK_NB) != 0)
354 #endif /* SVR4 */
355         {
356                 error = errno;
357
358                 close(fd);
359
360                 if (error != EWOULDBLOCK && error != EACCES) {
361
362                         perror ("rpc.cmsd: failed to lock lockfile");
363                         fprintf(stderr, "error = %d\n", error);
364                         exit (-1);
365
366                 } else {
367                         if (debug)
368                                 fprintf(stderr, "rpc.cmsd: %s\n",
369                                     "lock_it failed due to another process");
370                         
371                         /* cms has been running.... */
372                         return(error);
373                 }
374         }
375
376         return (0);
377 }
378
379 static void
380 program(struct svc_req *rqstp, SVCXPRT *transp)
381 {
382         char *result;
383         char *argument = NULL;
384         program_handle ph = getph();
385         struct rpcgen_table *proc;
386
387         /* set rpc_in_process so that sighup handler won't exit right away */
388         rpc_in_process = 1;
389  
390         /* first do some bounds checking: */
391         if (rqstp->rq_vers >= ph->nvers) {
392                 svcerr_noproc(transp);
393                 goto done;
394         }
395         if (ph->prog[rqstp->rq_vers].nproc == 0) {
396                 svcerr_noproc(transp);
397                 goto done;
398         }
399         if (rqstp->rq_proc >= ph->prog[rqstp->rq_vers].nproc) {
400                 svcerr_noproc(transp);
401                 goto done;
402         }
403
404         if (rqstp->rq_proc == NULLPROC) {
405                 if (debug) fprintf(stderr, "rpc.cmsd: ping\n");
406                 (void)svc_sendreply(transp, (xdrproc_t)xdr_void, (caddr_t)NULL);
407                 goto done;
408         }
409
410         /* assert - the program number, version and proc numbers are valid */
411         proc = &(ph->prog[rqstp->rq_vers].vers[rqstp->rq_proc]);
412         argument = (char*)calloc(proc->len_arg, sizeof(char));
413         if (!svc_getargs(transp, proc->xdr_arg, argument)) {
414                 svcerr_decode(transp);
415                 goto done;
416         }
417
418         result = (*proc->proc)(argument, rqstp);
419         if (result != NULL && !svc_sendreply(transp, proc->xdr_res, result)) {
420                 svcerr_systemerr(transp);
421         }
422
423         if (!svc_freeargs(transp, proc->xdr_arg, argument)) {
424                 (void)fprintf(stderr, "unable to free arguments");
425                 exit(1);
426         }
427         free(argument);
428
429 done:
430         rpc_in_process = 0;
431
432         /* exit if we have received the SIGHUP signal */
433         if (received_sighup == 1) {
434                 if (debug)
435                         fprintf(stderr, "rpc.cmsd: received SIGHUP, %s",
436                                 "exiting after finished processing\n");
437                 exit(0);
438         }
439 }
440
441 /*
442  * Signal handler for SIGHUP.
443  * If we are in the middle of processing a client request,
444  * finish processing before we exit.
445  */
446 static void
447 sighup_handler(int sig_num)
448 {
449         if (debug)
450                 fprintf(stderr, "rpc.cmsd: sighup received\n");
451
452         if (rpc_in_process == 0) {
453                 if (debug)
454                         fprintf(stderr, "rpc.cmsd: exit from sighup_handler\n");
455                 exit(0);
456         } else {
457                 if (debug)
458                         fprintf(stderr, "rpc.cmsd: set received_sighup to 1\n");
459                 received_sighup = 1;
460         }
461 }
462
463 /*
464  * garbage_collection_time (in min) is the time to do garbage collection
465  * each day
466  * This routine returns the difference between the first garbage collection
467  * time and now so that the calling routine can set the alarm.
468  */
469 static int
470 _GetFirstGarbageCollectionTime(void)
471 {
472         int n=0, midnight=0, gtime=0;
473
474         n = time(0);
475
476         /* try today first */
477         midnight = next_ndays(n, 0);
478         gtime = next_nmins(midnight, garbage_collection_time);
479
480         if (gtime < n) {
481                 /* the first garbage collection will be done tomorrow */
482                 midnight = next_ndays(n, 1);
483                 gtime = next_nmins(midnight, garbage_collection_time);
484         }
485
486         return (gtime - n);
487 }
488
489 static void
490 init_alarm(void)
491 {
492         int next;
493         extern void garbage_collect();
494         extern void debug_switch();
495
496 #if defined(SVR4) && !defined(__linux__)
497         extern void (*sigset(int, void (*)(int)))(int);
498         sigset(SIGUSR1, garbage_collect);
499         sigset(SIGALRM, garbage_collect);
500         sigset(SIGUSR2, debug_switch);
501 #else
502         signal(SIGUSR1, garbage_collect);
503         signal(SIGALRM, garbage_collect);
504         signal(SIGUSR2, debug_switch);
505 #endif /* SVR4 */
506
507         next = _GetFirstGarbageCollectionTime();
508         alarm((unsigned) next);
509 }
510
511 int
512 main(int argc, char **argv)
513 {
514         u_long version;
515         program_handle ph = newph();
516         struct passwd *pw;
517         struct group *gr;
518         struct rlimit rl;
519         struct sockaddr_in saddr;
520         int asize = sizeof (saddr);
521         SVCXPRT *tcp_transp = (SVCXPRT *)-1;
522         SVCXPRT *udp_transp = (SVCXPRT *)-1;
523         int     fd, error;
524
525 #if defined(SunOS)
526         struct netconfig *nconf_udp;
527         struct netconfig *nconf_tcp;
528         struct t_info info;
529         char mname[FMNAMESZ+1];
530 #endif /* SunOS */
531
532         pw = (struct passwd *)getpwnam("daemon");
533         gr = (struct group *)getgrnam("daemon");
534         if (pw != NULL) 
535                 daemon_uid = pw->pw_uid;
536         else
537                 daemon_uid = 1;
538         if (gr != NULL)
539                 daemon_gid = gr->gr_gid;
540         else 
541                 daemon_gid = 1;
542
543         parse_args(argc, argv);
544
545         /* check to see if we are started by inetd */
546         if (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {
547
548                 standalone = 0;
549
550 #if defined(SunOS)
551                 /* we need a TLI endpoint rather than a socket */
552                 if (ioctl(0, I_LOOK, mname) != 0) {
553                         perror("rpc.cmsd: ioctl failed to get module name");
554                         exit(1);
555                 }
556                 if (strcmp(mname, "sockmod") == 0) {
557                         /* Change socket fd to TLI fd */
558                         if (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, "timod")) {
559                                 perror("rpc.cmsd: ioctl I_POP/I_PUSH failed");
560                                 exit(1);
561                         }
562                 } else if (strcmp(mname, "timod") != 0) {
563                         fprintf(stderr, "rpc.cmsd: fd 0 is not timod\n");
564                         exit(1);
565                 }
566
567         } else if (t_getinfo(0, &info) == 0) {
568                 standalone = 0;
569
570 #endif /* SunOS */
571
572         } else
573                 standalone = 1;
574
575         /*
576          * if it is started by inetd, make stderr to be
577          * output to console.
578          */
579         if (!standalone) {
580                 if ((fd = open ("/dev/console", O_WRONLY)) >= 0) {
581                         if (fd != 2) {
582                                 dup2(fd, 2);
583                                 close (fd);
584                         }
585                 }
586         }
587
588         /* Set up private directory and switch euid/egid to daemon. */
589         umask (S_IWOTH);
590         init_dir();
591
592         /* Don't allow multiple cms processes running in the same host. */
593         if ((error = lock_it()) != 0 && !standalone) {
594                 /* we are invoked by inetd but another rpc.cmsd
595                  * is alreay running, so send SIGHUP to it
596                  */
597
598                 send_hup();
599
600                 /* try to lock it again */
601                 if (lock_it() != 0) {
602                         if (debug)
603                                 fprintf(stderr, "cm: rpc.cmsd is still running\n");
604                         exit(0);
605                 }
606
607         } else if (error != 0) {
608                 fprintf(stderr, "rpc.cmsd: rpc.cmsd is already running.\n");
609                 exit(0);
610         }
611
612         /* use signal because we only need it once */
613         signal(SIGHUP, sighup_handler);
614
615
616 #if defined(SunOS)
617         /* raise the soft limit of number of file descriptor */
618         /* this is to prevent the backend from running out of open file des */
619         getrlimit(RLIMIT_NOFILE, &rl);
620         rl.rlim_cur = (rl.rlim_max <= 256) ? rl.rlim_max : 256;
621         setrlimit(RLIMIT_NOFILE, &rl);
622 #endif
623
624 #if defined(SunOS)
625         nconf_udp = getnetconfigent("udp");
626         nconf_tcp = getnetconfigent("tcp");
627
628         for (version = 0; version < ph->nvers; version++) {
629                 /* don't register unsupported versions: */
630                 if (ph->prog[version].nproc == 0) continue;
631
632                 if (standalone) {
633                         rpcb_unset(ph->program_num, version, NULL);
634                         if (debug)
635                                 fprintf(stderr,
636                                         "rpc.cmsd: rpcb_unset for version %ld\n",
637                                         version);
638                 }
639
640                 /* brought up by inetd, use fd 0 which must be a TLI fd */
641                 if (udp_transp == (SVCXPRT *)-1) {
642                         udp_transp = svc_tli_create(standalone ? RPC_ANYFD : 0,
643                                 nconf_udp, (struct t_bind*) NULL, 0, 0); 
644
645                         if (udp_transp == NULL) {
646                                 t_error("rtable_main.c: svc_tli_create(udp)");
647                                 exit(2);
648                         }
649                 }
650
651                 if (svc_reg(udp_transp, ph->program_num, version, program,
652                                 standalone ? nconf_udp : NULL) == 0) {
653                         t_error("rtable_main.c: svc_reg");
654                         exit(3);
655                 }
656
657                 /* Set up tcp for calls that potentially return */
658                 /* large amount of data.  This transport is not */
659                 /* registered with inetd so need to register it */
660                 /* with rpcbind ourselves.                      */
661
662                 rpcb_unset(ph->program_num, version, nconf_tcp);
663
664                 if (tcp_transp == (SVCXPRT *)-1) {
665                         tcp_transp = svc_tli_create(RPC_ANYFD, nconf_tcp,
666                                         (struct t_bind *)NULL, 0, 0);
667
668                         if (tcp_transp == NULL) {
669                                 t_error("rtable_main.c: svc_til_create(tcp)");
670                                 exit(2);
671                         }
672                 }
673
674                 if (svc_reg(tcp_transp, ph->program_num, version, program,
675                                 nconf_tcp) == 0) {
676                         t_error("rtable_main.c: svc_reg(tcp)");
677                         exit(3);
678                 }
679         }/*for*/
680
681         if (nconf_udp)
682                 freenetconfigent(nconf_udp);
683         if (nconf_tcp)
684                 freenetconfigent(nconf_tcp);
685
686 #else
687
688         for (version = 0; version < ph->nvers; version++) {
689                 /* don't register unsupported versions: */
690                 if (ph->prog[version].nproc == 0) continue;
691
692 #ifndef HPUX
693                 if (standalone)
694 #endif
695                         (void) pmap_unset(ph->program_num, version);
696
697                 if (udp_transp == (SVCXPRT *)-1) {
698                         udp_transp = svcudp_create(standalone ? RPC_ANYSOCK : 0
699 #if defined(_AIX) || defined(hpV4) || defined(__linux__) || defined(CSRG_BASED)
700                                         );
701 #else
702                                         ,0,0);
703 #endif
704                         if (udp_transp == NULL) {
705                                 (void)fprintf(stderr,
706                                 "rtable_main.c: cannot create udp service.\n");
707                                 exit(1);
708                         }
709                 }
710
711 #ifndef HPUX
712                 if (!svc_register(udp_transp, ph->program_num, version, program,
713                                 standalone ? IPPROTO_UDP : 0)) {
714 #else
715                 if (!svc_register(udp_transp, ph->program_num, version, program,
716                                 IPPROTO_UDP)) {
717 #endif
718                         (void)fprintf(stderr, "rtable_main.c: unable to register");
719                         exit(1);
720                 }
721
722                 /* Set up tcp for calls that potentially return */
723                 /* large amount of data.  This transport is not */
724                 /* registered with inetd so need to register it */
725                 /* with rpcbind ourselves.                      */
726
727                 if (tcp_transp == (SVCXPRT *)-1) {
728                         tcp_transp = svctcp_create(RPC_ANYSOCK, 0, 0);
729                         if (tcp_transp == NULL) {
730                                 (void)fprintf(stderr,
731                                 "rtable_main.c: cannot create tcp service.\n");
732                                 exit(1);
733                         }
734                 }
735
736                 if (!svc_register(tcp_transp, ph->program_num, version, program,
737                                 IPPROTO_TCP)) {
738                         (void)fprintf(stderr, "rtable_main.c: unable to register(tcp)");
739                         exit(1);
740                 }
741         }
742
743 #endif /* SunOS */
744
745 #ifndef AIX
746 #ifdef HPUX
747         setgid (daemon_gid);
748         setuid (daemon_uid);
749 #else
750         if(-1 == setegid (daemon_gid)) {
751                 perror(strerror(errno));
752         }
753         if(-1 == seteuid (daemon_uid)) {
754                 perror(strerror(errno));
755         }
756 #endif /* HPUX */
757 #endif /* AIX */
758
759         init_time();
760         init_alarm();
761         _DtCm_init_hash();
762
763         svc_run();
764
765         (void)fprintf(stderr, "rpc.cmsd: svc_run returned\n");
766         return(1);
767 }
768