From bc842043d246b68d2ec29cc6a44634048fad3bf8 Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Tue, 23 Dec 2014 22:01:51 +0000 Subject: [PATCH] dtlogin: Resolve 27 compiler warnings --- cde/programs/dtlogin/access.c | 2 +- cde/programs/dtlogin/account.c | 4 +++- cde/programs/dtlogin/auth.c | 24 +++++++++++++++----- cde/programs/dtlogin/chooser.c | 4 +++- cde/programs/dtlogin/error.c | 15 +++++++++---- cde/programs/dtlogin/policy.c | 4 +++- cde/programs/dtlogin/server.c | 14 +++++++----- cde/programs/dtlogin/session.c | 37 ++++++++++++++++++++++--------- cde/programs/dtlogin/sysauth.c | 5 +++-- cde/programs/dtlogin/vgcallback.c | 4 +++- cde/programs/dtlogin/vgmain.c | 4 +++- cde/programs/dtlogin/xdmcp.c | 7 +++++- 12 files changed, 90 insertions(+), 34 deletions(-) diff --git a/cde/programs/dtlogin/access.c b/cde/programs/dtlogin/access.c index e35aba47..6bf9ac85 100644 --- a/cde/programs/dtlogin/access.c +++ b/cde/programs/dtlogin/access.c @@ -220,7 +220,7 @@ FreeDisplayEntry( free (d->entry.displayPattern); break; case DISPLAY_ADDRESS: - XdmcpDisposeARRAY8 (&d->entry.displayAddress); + XdmcpDisposeARRAY8 (&d->entry.displayAddress.clientAddress); break; } for (h = d->hosts; h; h = next) { diff --git a/cde/programs/dtlogin/account.c b/cde/programs/dtlogin/account.c index 3999de3d..e6ac2121 100644 --- a/cde/programs/dtlogin/account.c +++ b/cde/programs/dtlogin/account.c @@ -291,7 +291,9 @@ Account( struct display *d, char *user, char *line, pid_t pid, */ if ((fd = open(WTMP_FILE, O_WRONLY | O_APPEND)) >= 0) { - write(fd, u, sizeof(utmp)); + if(-1 == write(fd, u, sizeof(utmp))) { + perror(strerror(errno)); + } close(fd); } diff --git a/cde/programs/dtlogin/auth.c b/cde/programs/dtlogin/auth.c index c563baa8..366e4ead 100644 --- a/cde/programs/dtlogin/auth.c +++ b/cde/programs/dtlogin/auth.c @@ -361,10 +361,18 @@ MakeServerAuthFile (struct display *d) sprintf (d->authFile, "%s/%s", authDir, authdir1); r = stat(d->authFile, &statb); if (r == 0) { - if (statb.st_uid != 0) - (void) chown(d->authFile, 0, statb.st_gid); - if ((statb.st_mode & 0077) != 0) - (void) chmod(d->authFile, statb.st_mode & 0700); + if (statb.st_uid != 0) { + if(-1 == chown(d->authFile, 0, statb.st_gid)) { + perror(strerror(errno)); + return FALSE; + } + } + if ((statb.st_mode & 0077) != 0) { + if(-1 == chmod(d->authFile, statb.st_mode & 0700)) { + perror(strerror(errno)); + return FALSE; + } + } } else { if (errno == ENOENT) r = mkdir(d->authFile, 0700); @@ -1284,11 +1292,15 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) #ifdef NGROUPS Debug ("SetUserAuthorization: chown(%s,%d,%d)\n", envname, verify->uid, verify->groups[0]); - chown (envname, verify->uid, verify->groups[0]); + if(-1 == chown (envname, verify->uid, verify->groups[0])) { + perror(strerror(errno)); + } #else Debug ("SetUserAuthorization: chown(%s,%d,%d)\n", envname, verify->uid, verify->gid); - chown (envname, verify->uid, verify->gid); + if(-1 == chown (envname, verify->uid, verify->gid)) { + perror(strerror(errno)); + } #endif /* NGROUPS */ } } diff --git a/cde/programs/dtlogin/chooser.c b/cde/programs/dtlogin/chooser.c index bfcc6947..6417c757 100644 --- a/cde/programs/dtlogin/chooser.c +++ b/cde/programs/dtlogin/chooser.c @@ -777,7 +777,9 @@ Choose (HostName *h) XdmcpWriteARRAY8 (&buffer, app_resources.clientAddress); XdmcpWriteCARD16 (&buffer, (CARD16) app_resources.connectionType); XdmcpWriteARRAY8 (&buffer, &h->hostaddr); - write (fd, (char *)buffer.data, buffer.pointer); + if(-1 == write (fd, (char *)buffer.data, buffer.pointer)) { + perror(strerror(errno)); + } close (fd); } else diff --git a/cde/programs/dtlogin/error.c b/cde/programs/dtlogin/error.c index 5633af31..9926f2eb 100644 --- a/cde/programs/dtlogin/error.c +++ b/cde/programs/dtlogin/error.c @@ -252,16 +252,23 @@ TrimErrorFile( void ) * shift bytes to be saved to the beginning of the file... */ - write (f1, p, n); + if(-1 == write (f1, p, n)) { + perror(strerror(errno)); + } - while ( (n = read(f2, buf, BUFSIZ)) > 0 ) - write(f1, buf, n); + while ( (n = read(f2, buf, BUFSIZ)) > 0 ) { + if(-1 == write(f1, buf, n)) { + perror(strerror(errno)); + } + } /* * truncate file to new length and close file pointers... */ - truncate(errorLogFile, statb.st_size - deleteBytes); + if(-1 == truncate(errorLogFile, statb.st_size - deleteBytes)) { + perror(strerror(errno)); + } close(f1); close(f2); } diff --git a/cde/programs/dtlogin/policy.c b/cde/programs/dtlogin/policy.c index 5fc456bc..b7854948 100644 --- a/cde/programs/dtlogin/policy.c +++ b/cde/programs/dtlogin/policy.c @@ -262,7 +262,9 @@ WillingMsg( void ) strcat(tmpbuf,tmpfilename); - system(tmpbuf); + if(-1 == system(tmpbuf)) { + perror(strerror(errno)); + } if ((f = fopen(tmpfilename,"r")) != (FILE *) NULL) { fgets(tmpbuf,LINEBUFSIZE,f); diff --git a/cde/programs/dtlogin/server.c b/cde/programs/dtlogin/server.c index a699e649..2445ed99 100644 --- a/cde/programs/dtlogin/server.c +++ b/cde/programs/dtlogin/server.c @@ -63,7 +63,7 @@ static receivedUsr1; * ***************************************************************************/ -static char * _SysErrorMsg( int n) ; +static const char * _SysErrorMsg( int n) ; static SIGVAL CatchUsr1( int arg ) ; static void GetRemoteAddress( struct display *d, int fd) ; static SIGVAL PingBlocked( int arg ) ; @@ -97,11 +97,11 @@ CatchUsr1( int arg ) ++receivedUsr1; } -static char * +static const char * _SysErrorMsg( int n ) { - char *s = ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error"); + const char *s = ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error"); return (s ? s : "no such error"); } @@ -146,8 +146,12 @@ StartServerOnce( struct display *d ) Debug ("Unable to set permissions on console devices ..\n"); else { #endif - setgid (puser.pw_gid); - setuid (puser.pw_uid); + if(-1 == setgid (puser.pw_gid)) { + Debug ("setgid() failed setting %d\n", puser.pw_gid); + } + if(-1 == setuid (puser.pw_uid)) { + Debug ("setuid() failed setting %d\n", puser.pw_uid); + } #ifdef sun } #endif diff --git a/cde/programs/dtlogin/session.c b/cde/programs/dtlogin/session.c index 4beea5e5..5aaba3cf 100644 --- a/cde/programs/dtlogin/session.c +++ b/cde/programs/dtlogin/session.c @@ -331,7 +331,7 @@ static int IOErrorHandler( Display *dpy ) { - char *s = ((errno >= 0 && errno < sys_nerr) ? sys_errlist[errno] + const char *s = ((errno >= 0 && errno < sys_nerr) ? sys_errlist[errno] : "unknown error"); LogError(ReadCatalog( @@ -712,7 +712,10 @@ LoadXloginResources( struct display *d ) auth_key, authority, d->xrdb, d->name, tmpname); Debug ("Loading resource file: %s\n", cmd); - system (cmd); + if(-1 == system (cmd)) { + Debug ("system() failed on cmd '%s'\n", cmd); + return -1; + } if (debugLevel <= 10) if (unlink (tmpname) == -1) @@ -1518,7 +1521,9 @@ StartClient( struct verify_info *verify, struct display *d, int *pidp ) /* setpenv() will set gid for AIX */ #if !defined (_AIX) - setgid (verify->groups[0]); + if(-1 == setgid (verify->groups[0])) { + perror(strerror(errno)); + } #endif # else /* ! NGROUPS */ @@ -1570,7 +1575,9 @@ StartClient( struct verify_info *verify, struct display *d, int *pidp ) LogError (ReadCatalog( MC_LOG_SET,MC_LOG_NO_HMDIR,MC_DEF_LOG_NO_HMDIR), home, getEnv (verify->userEnviron, "USER")); - chdir ("/"); + if(-1 == chdir ("/")) { + perror(strerror(errno)); + } verify->userEnviron = setEnv(verify->userEnviron, "HOME", "/"); } @@ -1986,8 +1993,12 @@ RunGreeter( struct display *d, struct greet_info *greet, * set up communication pipes... */ - pipe(response); - pipe(request); + if(-1 == pipe(response)) { + perror(strerror(errno)); + } + if(-1 == pipe(request)) { + perror(strerror(errno)); + } rbytes = 0; @@ -2115,7 +2126,9 @@ RunGreeter( struct display *d, struct greet_info *greet, * Writing to file descriptor 1 goes to response pipe instead. */ close(1); - dup(response[1]); + if(-1 == dup(response[1])) { + perror(strerror(errno)); + } close(response[0]); close(response[1]); @@ -2123,7 +2136,9 @@ RunGreeter( struct display *d, struct greet_info *greet, * Reading from file descriptor 0 reads from request pipe instead. */ close(0); - dup(request[0]); + if(-1 == dup(request[0])) { + perror(strerror(errno)); + } close(request[0]); close(request[1]); @@ -2138,7 +2153,7 @@ RunGreeter( struct display *d, struct greet_info *greet, if ((p = (char *) strrchr(msg, '/')) == NULL) strcpy(msg,"./"); else - *(++p) = NULL; + *(++p) = '\0'; strcat(msg,"dtgreet"); @@ -2934,7 +2949,9 @@ static void TellGreeter( RequestHeader *phdr) { - write(request[1], phdr, phdr->length); + if(-1 == write(request[1], phdr, phdr->length)) { + perror(strerror(errno)); + } } static int diff --git a/cde/programs/dtlogin/sysauth.c b/cde/programs/dtlogin/sysauth.c index d6280da5..801138b9 100644 --- a/cde/programs/dtlogin/sysauth.c +++ b/cde/programs/dtlogin/sysauth.c @@ -2336,8 +2336,9 @@ Audit( struct passwd *p, char *msg, int errnum ) /* * make sure program is back to super-user... */ - - seteuid(0); + if(-1 == seteuid(0)) { + perror(strerror(errno)); + } return; } diff --git a/cde/programs/dtlogin/vgcallback.c b/cde/programs/dtlogin/vgcallback.c index cc2fdff7..0fc965e3 100644 --- a/cde/programs/dtlogin/vgcallback.c +++ b/cde/programs/dtlogin/vgcallback.c @@ -1941,5 +1941,7 @@ TellRequester(char * buf, size_t nbytes) #ifdef VG_TRACE vg_TRACE_EXECUTION("main: entered TellRequester ..."); #endif /* VG_TRACE */ - write(1, buf, nbytes); + if(-1 == write(1, buf, nbytes)) { + perror(strerror(errno)); + } } diff --git a/cde/programs/dtlogin/vgmain.c b/cde/programs/dtlogin/vgmain.c index 2bb59904..91d41a7f 100644 --- a/cde/programs/dtlogin/vgmain.c +++ b/cde/programs/dtlogin/vgmain.c @@ -2177,7 +2177,9 @@ static SIGVAL Terminate( int arg ) { - write(1, "terminate", 9); + if(-1 == write(1, "terminate", 9)) { + perror(strerror(errno)); + } CleanupAndExit(NULL, NOTIFY_ABORT); } diff --git a/cde/programs/dtlogin/xdmcp.c b/cde/programs/dtlogin/xdmcp.c index 5c152365..79c692f6 100644 --- a/cde/programs/dtlogin/xdmcp.c +++ b/cde/programs/dtlogin/xdmcp.c @@ -119,13 +119,18 @@ extern ARRAY8Ptr ChooseAuthentication (); extern int SelectConnectionTypeIndex (); void query_respond (from, fromlen, length); +void broadcast_respond (struct sockaddr *from, int fromlen, int length); void forward_respond (struct sockaddr *from, int fromlen, int length); void request_respond (struct sockaddr *from, int fromlen, int length); void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status); void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status); void send_accept (struct sockaddr *to, int tolen, CARD32 sessionID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr authorizationName, ARRAY8Ptr authorizationData); void manage (struct sockaddr *from, int fromlen, int length); -void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status); +void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status); +void send_failed (struct sockaddr *from, int fromlen, char *name, CARD32 sessionID, char *reason); +void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID); +void send_alive (struct sockaddr *from, int fromlen, int length); + int xdmcpFd = -1; -- 2.25.1