gssd: gethostname(3) returns zero or -1, not an errno
authorChuck Lever <chuck.lever@oracle.com>
Sat, 23 Mar 2013 12:13:22 +0000 (08:13 -0400)
committerSteve Dickson <steved@redhat.com>
Mon, 25 Mar 2013 14:09:11 +0000 (10:09 -0400)
According to "man gethostname," gssd is handling the return value of
gethostname(3) incorrectly.  It looks like other gethostname(3) call
sites in nfs-utils are already correct.

Acked-by: J. Bruce Fields <bfields@fieldses.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
utils/gssd/krb5_util.c

index 4df840e..20b55b3 100644 (file)
@@ -810,8 +810,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
                goto out;
 
        /* Get full local hostname */
-       retval = gethostname(myhostname, sizeof(myhostname));
-       if (retval) {
+       if (gethostname(myhostname, sizeof(myhostname)) == -1) {
+               retval = errno;
                k5err = gssd_k5_err_msg(context, retval);
                printerr(1, "%s while getting local hostname\n", k5err);
                goto out;