dtcm: Resolve CID 87822
[oweals/cde.git] / cde / programs / dtcm / server / svcmain.c
index 38176e9db76c4859cd797f46aaa9b5c2b3cd9cf5..7e14fc8539ff1d809443f8f5d16954c941025ad4 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2012, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
 /* $TOG: svcmain.c /main/10 1998/04/06 13:13:49 mgreess $ */
 /*
  *  (c) Copyright 1993, 1994 Hewlett-Packard Company
@@ -6,6 +28,10 @@
  *  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  */
 
+#if defined(linux)
+#define _POSIX_C_SOURCE 2
+#endif
+
 #include <EUSCompat.h>
 #include <stdio.h>
 #include <errno.h>
@@ -86,7 +112,7 @@ _GetGtime(char *timestr)
        }
 
        minute = atoi(&timestr[len - 2]);
-       timestr[len - 2] = NULL;
+       timestr[len - 2] = '\0';
        hour = atoi(timestr);
 
        if (hour > 23 || minute > 59)
@@ -247,7 +273,9 @@ init_dir()
        }
 
        /* Change current directory, so core file can be dumped. */
-       chdir (dir);
+       if(-1 == chdir (dir)) {
+               perror(strerror(errno));
+       }
 }
 
 /*
@@ -676,7 +704,8 @@ main(int argc, char **argv)
 
                if (udp_transp == (SVCXPRT *)-1) {
                        udp_transp = svcudp_create(standalone ? RPC_ANYSOCK : 0
-#if defined(_AIX) || defined(hpV4) || defined(__osf__) || defined(linux)
+#if defined(_AIX) || defined(hpV4) || defined(__osf__) || defined(linux) || \
+       defined(CSRG_BASED)
                                        );
 #else
                                        ,0,0);
@@ -727,8 +756,12 @@ main(int argc, char **argv)
        setgid (daemon_gid);
        setuid (daemon_uid);
 #else
-       setegid (daemon_gid);
-       seteuid (daemon_uid);
+       if(-1 == setegid (daemon_gid)) {
+               perror(strerror(errno));
+       }
+       if(-1 == seteuid (daemon_uid)) {
+               perror(strerror(errno));
+       }
 #endif /* HPUX */
 #endif /* AIX */