void get_mach(void);
int nbitsset(set_mask *set);
+int valid(char *name);
int do_passwd(void);
int do_groups(void);
EXEC SQL FETCH m_cursor INTO :name, :id;
if (sqlca.sqlcode)
break;
- hash_store(machines, id, strdup(strtrim(name)));
+ strtrim(name);
+ if (!valid(name))
+ continue;
+ hash_store(machines, id, strdup(name));
}
if (sqlca.sqlcode < 0)
db_error(sqlca.sqlcode);
}
+/* Determine whether or not a name is a valid DNS label.
+ (Can't start or end with . or have two .s in a row) */
+int valid(char *name)
+{
+ int sawdot;
+
+ for (sawdot = 1; *name; name++)
+ {
+ if (*name == '.')
+ {
+ if (sawdot)
+ return 0;
+ else
+ sawdot = 1;
+ }
+ else
+ sawdot = 0;
+ }
+ return !sawdot;
+}
+
+
int do_passwd(void)
{
FILE *pout, *uout, *bout;
if (sqlca.sqlcode)
break;
strtrim(name);
+ if (!valid(name))
+ continue;
sprintf(buf, "%s:%d", name, gid);
hash_store(groups, lid, strdup(buf));
fprintf(iout, "%d.gid\t%s CNAME %s.group\n", gid, HCLASS, name);
:mount, :comments, :fid;
if (sqlca.sqlcode)
break;
+ strtrim(name);
+ if (!valid(name))
+ continue;
strtrim(type);
if (!strcmp(type, "NFS") || !strcmp(type, "RVD"))
{
if ((mach = hash_lookup(machines, id)))
{
fprintf(out, "%s.filsys\t%s %s \"%s %s %s %s %s\"\n",
- strtrim(name), HCLASS, HTYPE, type, strtrim(loc),
+ name, HCLASS, HTYPE, type, strtrim(loc),
mach, strtrim(access), strtrim(mount));
}
}
else if (!strcmp(type, "AFS"))
{
fprintf(out, "%s.filsys\t%s %s \"AFS %s %s %s\"\n",
- strtrim(name), HCLASS, HTYPE, strtrim(loc),
+ name, HCLASS, HTYPE, strtrim(loc),
strtrim(access), strtrim(mount));
}
else if (!strcmp(type, "ERR"))
{
fprintf(out, "%s.filsys\t%s %s \"ERR %s\"\n",
- strtrim(name), HCLASS, HTYPE, strtrim(comments));
+ name, HCLASS, HTYPE, strtrim(comments));
}
else if (!strcmp(type, "FSGROUP"))
{
char buf[FILESYS_NAME_SIZE + 10];
- sprintf(buf, "%s:%d", strtrim(name), fid);
+ sprintf(buf, "%s:%d", name, fid);
sq_save_data(sq, strdup(buf));
}
else if (!strcmp(type, "MUL"))
{
char buf[FILESYS_NAME_SIZE + 10];
- sprintf(buf, "%s:%d", strtrim(name), fid);
+ sprintf(buf, "%s:%d", name, fid);
sq_save_data(sq2, strdup(buf));
}
}
EXEC SQL FETCH a_cursor INTO :aname, :trans;
if (sqlca.sqlcode)
break;
+ strtrim(aname);
+ strtrim(trans);
+ if (!valid(aname) || !valid(trans))
+ continue;
fprintf(out, "%s.filsys\t%s CNAME %s.filsys\n",
- strtrim(aname), HCLASS, strtrim(trans));
+ aname, HCLASS, trans);
}
EXEC SQL CLOSE a_cursor;
EXEC SQL SELECT name INTO :name FROM clusters WHERE clu_id = :cid;
strtrim(name);
+ if (!valid(name))
+ continue;
strcpy(clubuf, name);
}
if (sqlca.sqlcode)
break;
strtrim(name);
+ if (!valid(name))
+ continue;
strtrim(label);
strtrim(data);
fprintf(out, "%s.cluster\t%s %s \"%s %s\"\n",
if (!hash_lookup(machines, rm))
continue;
strtrim(name);
+ if (!valid(name))
+ continue;
strtrim(rp);
strtrim(sd);
fprintf(out, "%s.pcap\t%s %s \"%s:rp=%s:rm=%s:sd=%s:ka#%d:pc#%d",
if (!hash_lookup(machines, rm))
break;
strtrim(name);
+ if (!valid(name))
+ continue;
fprintf(out, "%s.palladium\t%s %s \"%s %d %s interface directory\"\n",
name, HCLASS, HTYPE, (char *)hash_lookup(machines, rm),
identifier, name);
if (sqlca.sqlcode)
break;
strtrim(aname);
+ if (!valid(aname))
+ continue;
strtrim(trans);
fprintf(out, "%s.palladium\t%s %s \"%s\"\n",
aname, HCLASS, HTYPE, trans);
if (sqlca.sqlcode)
break;
strtrim(service);
- if ((mach = hash_lookup(machines, id)))
+ if (valid(service) && (mach = hash_lookup(machines, id)))
fprintf(out, "%s.sloc\t%s %s %s\n", service, HCLASS, HTYPE, mach);
}
EXEC SQL CLOSE s_cursor;
break;
lowercase(protocol); /* Convert protocol to lowercase */
strtrim(service);
+ if (!valid(service))
+ continue;
strtrim(protocol);
fprintf(out, "%s.service\t%s %s \"%s %s %d\"\n",
service, HCLASS, HTYPE, service, protocol, port);
break;
strtrim(aname);
strtrim(trans);
+ if (!valid(aname) || !valid(trans))
+ continue;
fprintf(out, "%s.service\t%s CNAME %s.service\n", aname, HCLASS,
trans);
}