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) {
*/
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);
}
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);
#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 */
}
}
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
* 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);
}
strcat(tmpbuf,tmpfilename);
- system(tmpbuf);
+ if(-1 == system(tmpbuf)) {
+ perror(strerror(errno));
+ }
if ((f = fopen(tmpfilename,"r")) != (FILE *) NULL) {
fgets(tmpbuf,LINEBUFSIZE,f);
*
***************************************************************************/
-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 ) ;
++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");
}
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
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(
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)
/* 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 */
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", "/");
}
* set up communication pipes...
*/
- pipe(response);
- pipe(request);
+ if(-1 == pipe(response)) {
+ perror(strerror(errno));
+ }
+ if(-1 == pipe(request)) {
+ perror(strerror(errno));
+ }
rbytes = 0;
* 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]);
* 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]);
if ((p = (char *) strrchr(msg, '/')) == NULL)
strcpy(msg,"./");
else
- *(++p) = NULL;
+ *(++p) = '\0';
strcat(msg,"dtgreet");
TellGreeter(
RequestHeader *phdr)
{
- write(request[1], phdr, phdr->length);
+ if(-1 == write(request[1], phdr, phdr->length)) {
+ perror(strerror(errno));
+ }
}
static int
/*
* make sure program is back to super-user...
*/
-
- seteuid(0);
+ if(-1 == seteuid(0)) {
+ perror(strerror(errno));
+ }
return;
}
#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));
+ }
}
Terminate( int arg )
{
- write(1, "terminate", 9);
+ if(-1 == write(1, "terminate", 9)) {
+ perror(strerror(errno));
+ }
CleanupAndExit(NULL, NOTIFY_ABORT);
}
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;