ip/ipconfig: handle internationalized domain names
This commit is contained in:
parent
05f6c08985
commit
33682a5885
1 changed files with 30 additions and 10 deletions
|
@ -47,6 +47,9 @@ static void doremove(void);
|
||||||
static void dounbind(void);
|
static void dounbind(void);
|
||||||
static void ndbconfig(void);
|
static void ndbconfig(void);
|
||||||
|
|
||||||
|
static int Ufmt(Fmt*);
|
||||||
|
#pragma varargck type "U" char*
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
@ -61,11 +64,13 @@ static void
|
||||||
init(void)
|
init(void)
|
||||||
{
|
{
|
||||||
srand(truerand());
|
srand(truerand());
|
||||||
|
|
||||||
fmtinstall('H', encodefmt);
|
fmtinstall('H', encodefmt);
|
||||||
fmtinstall('E', eipfmt);
|
fmtinstall('E', eipfmt);
|
||||||
fmtinstall('I', eipfmt);
|
fmtinstall('I', eipfmt);
|
||||||
fmtinstall('M', eipfmt);
|
fmtinstall('M', eipfmt);
|
||||||
fmtinstall('V', eipfmt);
|
fmtinstall('V', eipfmt);
|
||||||
|
fmtinstall('U', Ufmt);
|
||||||
nsec(); /* make sure time file is open before forking */
|
nsec(); /* make sure time file is open before forking */
|
||||||
|
|
||||||
conf.cfd = -1;
|
conf.cfd = -1;
|
||||||
|
@ -193,7 +198,7 @@ parseargs(int argc, char **argv)
|
||||||
if(p == nil || *p == 0)
|
if(p == nil || *p == 0)
|
||||||
p = sysname();
|
p = sysname();
|
||||||
if(p != nil)
|
if(p != nil)
|
||||||
strncpy(conf.hostname, p, sizeof conf.hostname-1);
|
utf2idn(p, conf.hostname, sizeof(conf.hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* defaults */
|
/* defaults */
|
||||||
|
@ -636,11 +641,12 @@ putnames(char *p, char *e, char *attr, char *s)
|
||||||
char *x;
|
char *x;
|
||||||
|
|
||||||
for(; *s != 0; s = x+1){
|
for(; *s != 0; s = x+1){
|
||||||
if((x = strchr(s, ' ')) == nil)
|
if((x = strchr(s, ' ')) != nil)
|
||||||
x = strchr(s, 0);
|
*x = 0;
|
||||||
p = seprint(p, e, "%s=%.*s\n", attr, (int)(x - s), s);
|
p = seprint(p, e, "%s=%U\n", attr, s);
|
||||||
if(*x == 0)
|
if(x == nil)
|
||||||
break;
|
break;
|
||||||
|
*x = ' ';
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -665,9 +671,9 @@ putndb(void)
|
||||||
*np = 0;
|
*np = 0;
|
||||||
}
|
}
|
||||||
if(*conf.hostname)
|
if(*conf.hostname)
|
||||||
p = seprint(p, e, "\tsys=%s\n", conf.hostname);
|
p = seprint(p, e, "\tsys=%U\n", conf.hostname);
|
||||||
if(*conf.domainname)
|
if(*conf.domainname)
|
||||||
p = seprint(p, e, "\tdom=%s.%s\n",
|
p = seprint(p, e, "\tdom=%U.%U\n",
|
||||||
conf.hostname, conf.domainname);
|
conf.hostname, conf.domainname);
|
||||||
if(*conf.dnsdomain)
|
if(*conf.dnsdomain)
|
||||||
p = putnames(p, e, "\tdnsdomain", conf.dnsdomain);
|
p = putnames(p, e, "\tdnsdomain", conf.dnsdomain);
|
||||||
|
@ -967,6 +973,18 @@ gnames(char *d, int nd, uchar *s, int ns)
|
||||||
return d - (de - nd);
|
return d - (de - nd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
Ufmt(Fmt *f)
|
||||||
|
{
|
||||||
|
char d[256], *s;
|
||||||
|
|
||||||
|
s = va_arg(f->args, char*);
|
||||||
|
if(idn2utf(s, d, sizeof(d)) != nil)
|
||||||
|
s = d;
|
||||||
|
fmtprint(f, "%s", s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static Ndbtuple*
|
static Ndbtuple*
|
||||||
uniquent(Ndbtuple *t)
|
uniquent(Ndbtuple *t)
|
||||||
{
|
{
|
||||||
|
@ -990,7 +1008,7 @@ void
|
||||||
ndb2conf(Ndb *db, uchar *myip)
|
ndb2conf(Ndb *db, uchar *myip)
|
||||||
{
|
{
|
||||||
int nattr;
|
int nattr;
|
||||||
char *attrs[10], val[64];
|
char *attrs[10], val[256];
|
||||||
uchar ip[IPaddrlen];
|
uchar ip[IPaddrlen];
|
||||||
Ndbtuple *t, *nt;
|
Ndbtuple *t, *nt;
|
||||||
|
|
||||||
|
@ -1021,7 +1039,9 @@ ndb2conf(Ndb *db, uchar *myip)
|
||||||
t = ndbipinfo(db, "ip", val, attrs, nattr);
|
t = ndbipinfo(db, "ip", val, attrs, nattr);
|
||||||
for(nt = t; nt != nil; nt = nt->entry) {
|
for(nt = t; nt != nil; nt = nt->entry) {
|
||||||
if(strcmp(nt->attr, "dnsdomain") == 0) {
|
if(strcmp(nt->attr, "dnsdomain") == 0) {
|
||||||
addnames(conf.dnsdomain, nt->val, sizeof(conf.dnsdomain));
|
if(utf2idn(nt->val, val, sizeof(val)) == nil)
|
||||||
|
continue;
|
||||||
|
addnames(conf.dnsdomain, val, sizeof(conf.dnsdomain));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(strcmp(nt->attr, "ipmask") == 0) {
|
if(strcmp(nt->attr, "ipmask") == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue