X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cde%2Fprograms%2Fdtlogin%2Fdm.c;h=87fab04cc8ab78eb9f9f419780729d38e5229418;hb=aa470d2e3adede4d625a843a14ab663587645c1a;hp=48c8d88f232e25536b4c60e647d7c2894e165a00;hpb=83b6996daa2c5ae22fc2b69093814cb08314954a;p=oweals%2Fcde.git diff --git a/cde/programs/dtlogin/dm.c b/cde/programs/dtlogin/dm.c index 48c8d88f..87fab04c 100644 --- a/cde/programs/dtlogin/dm.c +++ b/cde/programs/dtlogin/dm.c @@ -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 + */ /* (c) Copyright 1997 The Open Group */ /* * * (c) Copyright 1993, 1994 Hewlett-Packard Company * @@ -31,11 +53,19 @@ # include # include +#if defined(__FreeBSD__) && OSMAJORVERSION > 8 +# include +#else # include +#endif # include # include # include +#if defined(linux) || defined(__FreeBSD__) +# include +#else # include +#endif #if defined (SYSV) || defined (SVR4) #ifndef F_TLOCK @@ -92,7 +122,7 @@ static long StorePid( void ) ; 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); @@ -489,7 +519,7 @@ StopAll( int arg ) 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 ) { @@ -573,7 +603,9 @@ ProcessChildDeath( int pid, waitType status ) * do process accounting... */ +#if !defined(CSRG_BASED) Account(d, NULL, NULL, pid, DEAD_PROCESS, status); +#endif /* @@ -706,7 +738,9 @@ ProcessChildDeath( int pid, waitType status ) * do process accounting... */ +#if !defined(CSRG_BASED) Account(d, NULL, NULL, pid, DEAD_PROCESS, status); +#endif switch (d->status) { @@ -906,9 +940,9 @@ StartDisplay( 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", @@ -1004,6 +1038,7 @@ StartDisplay( * are already in use... */ +#if !defined(CSRG_BASED) if (d->utmpId == NULL) { int i; char *p, *q; @@ -1035,6 +1070,7 @@ StartDisplay( } #endif } +#endif } if (NULL == d->authFile) @@ -1124,7 +1160,9 @@ StartDisplay( } } #endif +#if !defined(CSRG_BASED) Account(d, "LOGIN", line, getpid(), LOGIN_PROCESS, status); +#endif } if (!WaitForServer (d)) @@ -1218,7 +1256,9 @@ StopDisplay( struct display *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); } } @@ -1520,7 +1560,9 @@ StartGetty( struct display *d ) /* * do process accounting... */ +#if !defined(CSRG_BASED) Account(d, "LOGIN", NULL, getpid(), LOGIN_PROCESS, status); +#endif #ifdef _AIX @@ -1581,17 +1623,17 @@ GettyMessage( struct display *d, int msgnum ) 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; @@ -1601,7 +1643,7 @@ GettyMessage( struct display *d, int msgnum ) (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; @@ -1655,8 +1697,13 @@ GettyMessage( struct display *d, int msgnum ) 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]; @@ -1675,7 +1722,11 @@ GettyRunning( struct display *d ) 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")) { @@ -1697,6 +1748,7 @@ GettyRunning( struct display *d ) Debug("Checking for a getty on line %s.\n", utmp.ut_line); +#if !defined(CSRG_BASED) setutent(); rvalue = FALSE; @@ -1734,6 +1786,7 @@ GettyRunning( struct display *d ) } endutent(); +#endif /* !CSRG_BASED */ return rvalue; } @@ -1824,15 +1877,15 @@ MarkShutdownTime( void ) 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; @@ -1845,7 +1898,7 @@ dtmkdir(char *dir, mode_t dir_mode) 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);