[1493] in Moira
stella bug fix
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Tue Mar 28 20:02:11 2000
Message-Id: <200003290102.UAA02150@w20-spare-ultra2.mit.edu>
To: moiradev@MIT.EDU
Date: Tue, 28 Mar 2000 20:02:08 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
Currently, "stella -a" and "stella -d" call
canonicalize_hostname on their argument, which results in exciting
queries like "qy dhal kenmore.mit.edu kenmore.mit.edu" after
canonicalizing. "moira" uses partial_canonicalize_hostname instead,
which we should do instead. These patches move
partial_canonicalize_hostname out of "moira" and into libmoira, which is
where we define canonicalize_hostname, and change stella to use it.
Garry
Index: include/moira.h
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/include/moira.h,v
retrieving revision 1.28
diff -c -r1.28 moira.h
*** moira.h 2000/03/15 22:44:15 1.28
--- moira.h 2000/03/29 00:17:16
***************
*** 84,89 ****
--- 84,90 ----
/* prototypes from fixhost.c */
char *canonicalize_hostname(char *s);
+ char *partial_canonicalize_hostname(char *s);
/* prototypes from fixname.c */
void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle);
Index: lib/fixhost.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/lib/fixhost.c,v
retrieving revision 1.23
diff -c -r1.23 fixhost.c
*** fixhost.c 2000/03/15 22:44:18 1.23
--- fixhost.c 2000/03/29 00:22:20
***************
*** 139,141 ****
--- 139,182 ----
return host;
}
}
+
+ char *partial_canonicalize_hostname(char *s)
+ {
+ char buf[256], *cp;
+ static char *def_domain = NULL;
+
+ if (!def_domain)
+ {
+ if (mr_host(buf, sizeof(buf)) == MR_SUCCESS)
+ {
+ cp = strchr(buf, '.');
+ if (cp)
+ def_domain = strdup(++cp);
+ }
+ else
+ {
+ struct hostent *hp;
+ #ifdef HAVE_UNAME
+ struct utsname name;
+ uname(&name);
+ hp = gethostbyname(name.nodename);
+ #else
+ char name[256];
+ gethostname(name, sizeof(name));
+ name[sizeof(name)-1] = 0;
+ hp = gethostbyname(name);
+ #endif /* HAVE_UNAME */
+ cp = strchr(hp->h_name, '.');
+ if (cp)
+ def_domain = strdup(++cp);
+ }
+ if (!def_domain)
+ def_domain = "";
+ }
+
+ if (strchr(s, '.') || strchr(s, '*'))
+ return s;
+ sprintf(buf, "%s.%s", s, def_domain);
+ free(s);
+ return strdup(buf);
+ }
Index: clients/moira/cluster.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/cluster.c,v
retrieving revision 1.39
diff -c -r1.39 cluster.c
*** cluster.c 2000/03/15 22:44:02 1.39
--- cluster.c 2000/03/29 00:18:38
***************
*** 44,50 ****
char **AskMCDInfo(char **info, int type, Bool name);
int CheckAndRemoveFromCluster(char *name, Bool ask_user);
int CheckAndRemoveMachines(char *name, Bool ask_first);
- char *partial_canonicalize_hostname(char *s);
#define MACHINE 0
#define CLUSTER 1
--- 44,49 ----
***************
*** 983,1030 ****
FreeQueue(top);
free(tmpname);
return DM_NORMAL;
- }
-
-
- char *partial_canonicalize_hostname(char *s)
- {
- char buf[256], *cp;
- static char *def_domain = NULL;
-
- if (!def_domain)
- {
- if (mr_host(buf, sizeof(buf)) == MR_SUCCESS)
- {
- cp = strchr(buf, '.');
- if (cp)
- def_domain = strdup(++cp);
- }
- else
- {
- struct hostent *hp;
- #ifdef HAVE_UNAME
- struct utsname name;
- uname(&name);
- hp = gethostbyname(name.nodename);
- #else
- char name[256];
- gethostname(name, sizeof(name));
- name[sizeof(name)-1] = 0;
- hp = gethostbyname(name);
- #endif /* HAVE_UNAME */
- cp = strchr(hp->h_name, '.');
- if (cp)
- def_domain = strdup(++cp);
- }
- if (!def_domain)
- def_domain = "";
- }
-
- if (strchr(s, '.') || strchr(s, '*'))
- return s;
- sprintf(buf, "%s.%s", s, def_domain);
- free(s);
- return strdup(buf);
}
Index: clients/stella/stella.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/stella/stella.c,v
retrieving revision 1.3
diff -c -r1.3 stella.c
*** stella.c 2000/03/22 21:23:40 1.3
--- stella.c 2000/03/29 00:12:35
***************
*** 463,469 ****
char *alias = q->string;
char *args[2];
! args[0] = canonicalize_hostname(strdup(alias));
args[1] = canonicalize_hostname(strdup(hostname));
status = wrap_mr_query("add_hostalias", 2, args, NULL, NULL);
if (status) {
--- 463,469 ----
char *alias = q->string;
char *args[2];
! args[0] = partial_canonicalize_hostname(strdup(alias));
args[1] = canonicalize_hostname(strdup(hostname));
status = wrap_mr_query("add_hostalias", 2, args, NULL, NULL);
if (status) {
***************
*** 483,489 ****
char *alias = q->string;
char *args[2];
! args[0] = canonicalize_hostname(strdup(alias));
args[1] = canonicalize_hostname(strdup(hostname));
status = wrap_mr_query("delete_hostalias", 2, args, NULL, NULL);
if (status) {
--- 483,489 ----
char *alias = q->string;
char *args[2];
! args[0] = partial_canonicalize_hostname(strdup(alias));
args[1] = canonicalize_hostname(strdup(hostname));
status = wrap_mr_query("delete_hostalias", 2, args, NULL, NULL);
if (status) {