+/*
+ * 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
+ */
/* (c) Copyright 1997 The Open Group */
/* *
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
# include <sys/signal.h>
# include <sys/stat.h>
+#if defined(__FreeBSD__) && OSMAJORVERSION > 8
+# include <utmpx.h>
+#else
# include <utmp.h>
+#endif
# include <time.h>
# include <utime.h>
# include <pwd.h>
+#if defined(linux) || defined(__FreeBSD__)
+# include <stdarg.h>
+#else
# include <varargs.h>
+#endif
#if defined (SYSV) || defined (SVR4)
#ifndef F_TLOCK
static void TerminateProcess( int pid, int sig) ;
static void UnlockPidFile( void ) ;
static void dtMakeDefaultDir( void );
-static void dtmkdir(char *dir, mode_t dir_mode);
+static void dtmkdir(char *dir, mode_t dir_mode, int force);
int ChildReady = 0;
-#if !defined(SYSV) || defined(hpux) || defined(_AIX) || defined(__uxp__) || defined (__osf__) || defined(linux)
+#if !defined(SYSV) || defined(hpux) || defined(_AIX) || defined(__uxp__) || defined (__osf__) || defined(linux) || defined(CSRG_BASED)
static SIGVAL
ChildNotify( int arg )
{
* do process accounting...
*/
+#if !defined(CSRG_BASED)
Account(d, NULL, NULL, pid, DEAD_PROCESS, status);
+#endif
/*
* do process accounting...
*/
+#if !defined(CSRG_BASED)
Account(d, NULL, NULL, pid, DEAD_PROCESS, status);
+#endif
switch (d->status)
{
else {
strncpy(&(d->utmpId[strlen(d->utmpId)]), t++, 1);
}
- } while (*t != NULL);
+ } while (*t != '\0');
- if (*t == NULL) {
+ if (*t == '\0') {
Debug ("All DT utmp IDs already in use. Removing display %s\n",
d->name);
LogError ((unsigned char *)"All DT utmp IDs already in use. Removing display %s\n",
* are already in use...
*/
+#if !defined(CSRG_BASED)
if (d->utmpId == NULL) {
int i;
char *p, *q;
}
#endif
}
+#endif
}
if (NULL == d->authFile)
}
}
#endif
+#if !defined(CSRG_BASED)
Account(d, "LOGIN", line, getpid(), LOGIN_PROCESS, status);
+#endif
}
if (!WaitForServer (d))
else
if ((d->displayType.location == Local) || !dt_shutdown ) {
/* don't remove the console */
+#if !defined(CSRG_BASED)
Account(d, NULL, NULL, 0, DEAD_PROCESS, status);
+#endif
RemoveDisplay (d);
}
}
/*
* do process accounting...
*/
+#if !defined(CSRG_BASED)
Account(d, "LOGIN", NULL, getpid(), LOGIN_PROCESS, status);
+#endif
#ifdef _AIX
switch (msgnum) {
case 1:
- fprintf(tf,(char *)ReadCatalog(MC_LABEL_SET,MC_SUS1_LABEL,MC_DEF_SUS1_LABEL));
+ fprintf(tf, "%s", (char *)ReadCatalog(MC_LABEL_SET,MC_SUS1_LABEL,MC_DEF_SUS1_LABEL));
- fprintf(tf,(char *)ReadCatalog(MC_LABEL_SET,MC_SUS2_LABEL,MC_DEF_SUS2_LABEL));
+ fprintf(tf, "%s", (char *)ReadCatalog(MC_LABEL_SET,MC_SUS2_LABEL,MC_DEF_SUS2_LABEL));
- fprintf(tf,(char *)ReadCatalog(MC_LABEL_SET,MC_SUS3_LABEL,MC_DEF_SUS3_LABEL));
+ fprintf(tf, "%s", (char *)ReadCatalog(MC_LABEL_SET,MC_SUS3_LABEL,MC_DEF_SUS3_LABEL));
break;
case 2:
- fprintf(tf,(char *)ReadCatalog(MC_LABEL_SET,MC_RES_LABEL,MC_DEF_RES_LABEL));
+ fprintf(tf, "%s", (char *)ReadCatalog(MC_LABEL_SET,MC_RES_LABEL,MC_DEF_RES_LABEL));
break;
(char *)ReadCatalog(MC_LABEL_SET,MC_START_LBLDPY,MC_DEF_START_LBLDPY),
d->name);
- fprintf(tf,(char *)ReadCatalog(MC_LABEL_SET,MC_WAIT_LABEL,MC_DEF_WAIT_LABEL));
+ fprintf(tf, "%s", (char *)ReadCatalog(MC_LABEL_SET,MC_WAIT_LABEL,MC_DEF_WAIT_LABEL));
break;
int
GettyRunning( struct display *d )
{
+#if defined(__FreeBSD__) && OSMAJORVERSION > 8
+ struct utmpx utmp; /* local struct for new entry */
+ struct utmpx *u; /* pointer to entry in utmp file */
+#else
struct utmp utmp; /* local struct for new entry */
struct utmp *u; /* pointer to entry in utmp file */
+#endif
int rvalue; /* return value (TRUE or FALSE) */
char buf[32];
return FALSE;
+#if defined(__FreeBSD__) && OSMAJORVERSION > 8
+ bzero(&utmp, sizeof(struct utmpx));
+#else
bzero(&utmp, sizeof(struct utmp));
+#endif
#ifdef _AIX
if (!strcmp(d->gettyLine,"console")) {
Debug("Checking for a getty on line %s.\n", utmp.ut_line);
+#if !defined(CSRG_BASED)
setutent();
rvalue = FALSE;
}
endutent();
+#endif /* !CSRG_BASED */
return rvalue;
}
static void
dtMakeDefaultDir( void )
{
- dtmkdir("/var", 0775);
- dtmkdir("/var/dt", 0755);
- dtmkdir("/var/dt/tmp", 0755);
- dtmkdir("/var/dt/appconfig", 0755);
- dtmkdir("/var/dt/appconfig/appmanager", 0755);
+ dtmkdir("/var", 0755, 0);
+ dtmkdir("/var/dt", 0755, 1);
+ dtmkdir("/var/dt/tmp", 0755, 1);
+ dtmkdir("/var/dt/appconfig", 0755, 1);
+ dtmkdir("/var/dt/appconfig/appmanager", 0755, 1);
}
static void
-dtmkdir(char *dir, mode_t dir_mode)
+dtmkdir(char *dir, mode_t dir_mode, int force)
{
struct stat file_status;
LogError((unsigned char *)"Unable to create dir %s\n", dir);
}
} else {
- if ( (file_status.st_mode & dir_mode) != dir_mode) {
+ if ( force && (file_status.st_mode & dir_mode) != dir_mode) {
/** try to set correct permissions **/
if ( chmod(dir, file_status.st_mode | dir_mode) == 0) {
Debug("Set permissions on %s\n", dir);