diff options
author | Branden Robinson <branden@debian.org> | 2009-07-17 22:51:04 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 22:52:34 -0700 |
commit | 18f286641afbe1d3b61abd31d93c0ae8acb375e9 (patch) | |
tree | 7db570154b86d757454d0265b26a24a87d0293af | |
parent | 8d15af786d96bb70aceca116a588c2a4b7c45d63 (diff) |
Use _SysErrorMsg() in the log message in various error conditions.
Change LogError() invocations to use _SysErrorMsg() where errno might be
set (and not clobbered by intermediate calls). Also make LogError() the
first thing we do after an error condition in those cases.
Forward-ported by David Nusinow, Eugene Konev and Julien Cristau.
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r-- | auth.c | 41 | ||||
-rw-r--r-- | session.c | 33 | ||||
-rw-r--r-- | socket.c | 7 |
3 files changed, 50 insertions, 31 deletions
@@ -865,7 +865,8 @@ DefineSelf (int fd, FILE *file, Xauth *auth) int len, ipfd; if ((ipfd = open ("/dev/ip", O_RDWR, 0 )) < 0) - LogError ("Getting interface configuration"); + LogError ("cannot get interface configuration; cannot open /dev/ip: " + "%s\n", _SysErrorMsg (errno)); /* Indicate that we want to start at the begining */ ifnet.ib_next = (struct ipb *) 1; @@ -879,8 +880,9 @@ DefineSelf (int fd, FILE *file, Xauth *auth) if (ioctl (ipfd, (int) I_STR, (char *) &str) < 0) { + LogError ("cannot get interface configuration; ioctl failed: %s\n", + _SysErrorMsg (errno)); close (ipfd); - LogError ("Getting interface configuration"); } ifaddr.ia_next = (struct in_ifaddr *) ifnet.if_addrlist; @@ -891,8 +893,9 @@ DefineSelf (int fd, FILE *file, Xauth *auth) if (ioctl (ipfd, (int) I_STR, (char *) &str) < 0) { + LogError ("cannot get interface configuration; ioctl failed: %s\n", + _SysErrorMsg (errno)); close (ipfd); - LogError ("Getting interface configuration"); } /* @@ -1350,16 +1353,22 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) doneAddrs (); fclose (new); if (unlink (name) == -1) - Debug ("unlink %s failed\n", name); + if (errno != ENOENT) + LogError ("cannot remove old authorization file %s: %s\n", + name, _SysErrorMsg (errno)); envname = name; if (link (new_name, name) == -1) { - Debug ("link failed %s %s\n", new_name, name); - LogError ("Can't move authorization into place\n"); + LogError ("cannot link temporary authorization file %s to old " + "location %s: %s\n", new_name, name, + _SysErrorMsg (errno)); setenv = 1; envname = new_name; } else { - Debug ("new is in place, go for it!\n"); - unlink (new_name); + Debug ("authorization file %s successfully updated\n", name); + if (unlink (new_name)) + if (errno != ENOENT) + LogError ("cannot remove new authorization file %s:" + " %s\n", new_name, _SysErrorMsg (errno)); } if (setenv) { verify->userEnviron = setEnv (verify->userEnviron, @@ -1429,13 +1438,19 @@ RemoveUserAuthorization (struct display *d, struct verify_info *verify) doneAddrs (); fclose (new); if (unlink (name) == -1) - Debug ("unlink %s failed\n", name); + if (errno != ENOENT) + LogError ("cannot remove new authorization file %s: %s\n", + name, _SysErrorMsg (errno)); if (link (new_name, name) == -1) { - Debug ("link failed %s %s\n", new_name, name); - LogError ("Can't move authorization into place\n"); + LogError ("cannot link temporary authorization file %s to old " + "location %s: %s\n", new_name, name, + _SysErrorMsg (errno)); } else { - Debug ("new is in place, go for it!\n"); - unlink (new_name); + Debug ("authorization file %s successfully updated\n", name); + if (unlink (new_name)) + if (errno != ENOENT) + LogError ("cannot remove new authorization file %s:" + " %s\n", new_name, _SysErrorMsg (errno)); } } XauUnlockAuth (name); @@ -607,20 +607,22 @@ StartClient ( #ifndef AIXV3 # ifndef HAS_SETUSERCONTEXT - if (setgid(verify->gid) < 0) { - LogError ("setgid %d (user \"%s\") failed, errno=%d\n", - verify->gid, name, errno); + if (setgid (verify->gid) < 0) { + LogError ("setgid %d (user \"%s\") failed: %s\n", + verify->gid, name, _SysErrorMsg (errno)); return (0); } # if defined(BSD) && (BSD >= 199103) - if (setlogin(name) < 0) { - LogError ("setlogin for \"%s\" failed, errno=%d", name, errno); - return(0); + if (setlogin (name) < 0) { + LogError ("setlogin for \"%s\" failed: %s\n", + name, _SysErrorMsg (errno)); + return (0); } # endif # ifndef QNX4 - if (initgroups(name, verify->gid) < 0) { - LogError ("initgroups for \"%s\" failed, errno=%d\n", name, errno); + if (initgroups (name, verify->gid) < 0) { + LogError ("initgroups for \"%s\" failed: %s\n", + name, _SysErrorMsg (errno)); return (0); } # endif /* QNX4 doesn't support multi-groups, no initgroups() */ @@ -649,8 +651,8 @@ StartClient ( # ifndef HAS_SETUSERCONTEXT if (setuid(verify->uid) < 0) { - LogError ("setuid %d (user \"%s\") failed, errno=%d\n", - verify->uid, name, errno); + LogError ("setuid %d (user \"%s\") failed: %s\n", + verify->uid, name, _SysErrorMsg (errno)); return (0); } # else /* HAS_SETUSERCONTEXT */ @@ -661,13 +663,14 @@ StartClient ( pwd = getpwnam(name); if (pwd) { if (setusercontext(NULL, pwd, pwd->pw_uid, LOGIN_SETALL) < 0) { - LogError ("setusercontext for \"%s\" failed, errno=%d\n", name, - errno); + LogError ("setusercontext for \"%s\" failed: %s\n", + name, _SysErrorMsg (errno)); return (0); } endpwent(); } else { - LogError ("getpwnam for \"%s\" failed, errno=%d\n", name, errno); + LogError ("getpwnam for \"%s\" failed: %s\n", + name, _SysErrorMsg (errno)); return (0); } # endif /* HAS_SETUSERCONTEXT */ @@ -677,8 +680,8 @@ StartClient ( * audit classes, user limits, and umask. */ if (setpcred(name, NULL) == -1) { - LogError ("setpcred for \"%s\" failed: %s\n", name, - _SysErrorMsg (errno)); + LogError ("setpcred for \"%s\" failed: %s\n", + name, _SysErrorMsg (errno)); return (0); } #endif /* AIXV3 */ @@ -71,7 +71,7 @@ CreateWellKnownSockets (void) Debug ("Created chooser socket %d\n", chooserFd); if (chooserFd == -1) { - LogError ("chooser socket creation failed, errno %d\n", errno); + LogError ("chooser socket creation failed: %s\n", _SysErrorMsg (errno)); return; } listen (chooserFd, 5); @@ -149,14 +149,15 @@ CreateListeningSocket (struct sockaddr *sock_addr, int salen) fd = socket (sock_addr->sa_family, SOCK_DGRAM, 0); if (fd == -1) { - LogError ("XDMCP socket creation failed, errno %d\n", errno); + LogError ("XDMCP socket creation failed: %s\n", _SysErrorMsg (errno)); return fd; } RegisterCloseOnFork (fd); if (bind (fd, sock_addr, salen) == -1) { - LogError ("error %d binding socket address %d\n", errno, request_port); + LogError ("error binding socket address %d: %s\n", request_port, + _SysErrorMsg (errno)); close (fd); fd = -1; return fd; |