shishi-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shishi/lib internal.h keys.c principal.c realm.c


From: shishi-commit
Subject: shishi/lib internal.h keys.c principal.c realm.c
Date: Tue, 23 Sep 2003 19:35:04 -0400

CVSROOT:        /cvsroot/shishi
Module name:    shishi
Branch:         
Changes by:     Simon Josefsson <address@hidden>        03/09/23 19:35:03

Modified files:
        lib            : internal.h keys.c principal.c realm.c 

Log message:
        Use xgethostname().

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/internal.h.diff?tr1=1.69&tr2=1.70&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/keys.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/principal.c.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/realm.c.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: shishi/lib/internal.h
diff -u shishi/lib/internal.h:1.69 shishi/lib/internal.h:1.70
--- shishi/lib/internal.h:1.69  Tue Sep 23 19:05:07 2003
+++ shishi/lib/internal.h       Tue Sep 23 19:35:03 2003
@@ -124,6 +124,7 @@
 #include "vasprintf.h"
 #include "xalloc.h"
 #include "xmemdup.h"
+#include "xgethostname.h"
 #include "xstrndup.h"
 
 #include "shishi.h"
Index: shishi/lib/keys.c
diff -u shishi/lib/keys.c:1.5 shishi/lib/keys.c:1.6
--- shishi/lib/keys.c:1.5       Wed Sep 10 11:07:02 2003
+++ shishi/lib/keys.c   Tue Sep 23 19:35:03 2003
@@ -118,19 +118,18 @@
                                           const char *service,
                                           const char *realm)
 {
-  char server[HOST_NAME_MAX];
-  int ret;
+  char *hostname;
+  char *server;
+  int rc;
 
-  strcpy (server, service);
-  strcat (server, "/");
+  hostname = xgethostname ();
 
-  ret = gethostname (&server[strlen (service) + 1],
-                    sizeof (server) - strlen (service) - 1);
-  server[sizeof (server) - 1] = '\0';
+  asprintf (&server, "%s/%s", service, hostname);
 
-  if (ret != 0)
-    strcpy (&server[strlen (service) + 1], "localhost");
+  rc = shishi_keys_for_serverrealm_in_file (handle, filename, server, realm);
 
-  return shishi_keys_for_serverrealm_in_file (handle, filename, server,
-                                             realm);
+  free (server);
+  free (hostname);
+
+  return rc;
 }
Index: shishi/lib/principal.c
diff -u shishi/lib/principal.c:1.24 shishi/lib/principal.c:1.25
--- shishi/lib/principal.c:1.24 Sat Sep  6 13:39:24 2003
+++ shishi/lib/principal.c      Tue Sep 23 19:35:03 2003
@@ -394,18 +394,14 @@
 char *
 shishi_server_for_local_service (Shishi * handle, const char *service)
 {
-  char buf[HOST_NAME_MAX];
-  int ret;
+  char *hostname;
+  char *server;
 
-  strcpy (buf, service);
-  strcat (buf, "/");
+  hostname = xgethostname ();
 
-  ret = gethostname (&buf[strlen (service) + 1],
-                    sizeof (buf) - strlen (service) - 1);
-  buf[sizeof (buf) - 1] = '\0';
+  asprintf (&server, "%s/%s", service, hostname);
 
-  if (ret != 0)
-    strcpy (&buf[strlen (service) + 1], "localhost");
+  free (hostname);
 
-  return xstrdup (buf);
+  return server;
 }
Index: shishi/lib/realm.c
diff -u shishi/lib/realm.c:1.12 shishi/lib/realm.c:1.13
--- shishi/lib/realm.c:1.12     Sat Sep  6 15:57:16 2003
+++ shishi/lib/realm.c  Tue Sep 23 19:35:03 2003
@@ -38,20 +38,23 @@
 shishi_realm_default_guess (void)
 {
   char buf[HOST_NAME_MAX];
+  char *realm;
   int ret;
 
+  /* XXX use a xgetdomainname() */
   ret = getdomainname (buf, sizeof (buf));
   buf[sizeof (buf) - 1] = '\0';
-  if (ret != 0 || strlen (buf) == 0 || strcmp (buf, "(none)") == 0)
-    {
-      ret = gethostname (buf, sizeof (buf));
-      buf[sizeof (buf) - 1] = '\0';
+  if (ret == 0 && strlen (buf) > 0 && strcmp (buf, "(none)") != 0)
+    return strdup(buf);
 
-      if (ret != 0)
-       strcpy (buf, "could-not-guess-default-realm");
+  realm = xgethostname ();
+  if (strlen (realm) == 0 || strcmp (realm, "(none)") == 0)
+    {
+      free (realm);
+      realm = strdup ("could-not-guess-default-realm");
     }
 
-  return xstrdup (buf);
+  return realm;
 }
 
 /**




reply via email to

[Prev in Thread] Current Thread [Next in Thread]