Update to match current db-format.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2473 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
84
admin/load.c
84
admin/load.c
@@ -42,12 +42,44 @@ RCSID("$Id$");
|
|||||||
|
|
||||||
struct entry{
|
struct entry{
|
||||||
char *principal;
|
char *principal;
|
||||||
char *key;
|
|
||||||
char *kvno;
|
char *kvno;
|
||||||
|
char *keytype;
|
||||||
|
char *key;
|
||||||
char *max_life;
|
char *max_life;
|
||||||
char *max_renew;
|
char *max_renew;
|
||||||
|
char *last_change;
|
||||||
|
char *changed_by;
|
||||||
|
char *expires;
|
||||||
|
char *flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *
|
||||||
|
skip_next(char *p)
|
||||||
|
{
|
||||||
|
while(*p && !isspace(*p))
|
||||||
|
p++;
|
||||||
|
*p++ = 0;
|
||||||
|
while(*p && isspace(*p)) p++;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t
|
||||||
|
str2time(char *s)
|
||||||
|
{
|
||||||
|
int year, month, date, hour, minute, second;
|
||||||
|
struct tm tm;
|
||||||
|
sscanf(s, "%04d%02d%02d%02d%02d%02d",
|
||||||
|
&year, &month, &date, &hour, &minute, &second);
|
||||||
|
tm.tm_year = year - 1900;
|
||||||
|
tm.tm_mon = month - 1;
|
||||||
|
tm.tm_mday = date;
|
||||||
|
tm.tm_hour = hour;
|
||||||
|
tm.tm_min = minute;
|
||||||
|
tm.tm_sec = second;
|
||||||
|
tm.tm_isdst = 0;
|
||||||
|
return timegm(&tm);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doit(char *filename, int merge)
|
doit(char *filename, int merge)
|
||||||
{
|
{
|
||||||
@@ -88,28 +120,33 @@ doit(char *filename, int merge)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*p++ = 0;
|
p = skip_next(p);
|
||||||
while(*p && isspace(*p)) p++;
|
|
||||||
e.key = p;
|
|
||||||
while(*p && !isspace(*p))
|
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
|
||||||
while(*p && isspace(*p)) p++;
|
|
||||||
e.kvno = p;
|
e.kvno = p;
|
||||||
|
while(*p && isdigit(*p)) p++;
|
||||||
while(*p && !isspace(*p))
|
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
while(*p && isspace(*p)) p++;
|
e.keytype = p;
|
||||||
|
while(*p && isdigit(*p)) p++;
|
||||||
|
*p++ = 0;
|
||||||
|
e.key = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
e.max_life = p;
|
e.max_life = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
while(*p && !isspace(*p))
|
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
|
||||||
e.max_renew = p;
|
e.max_renew = p;
|
||||||
while(*p && !isspace(*p))
|
p = skip_next(p);
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
e.last_change = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
|
e.changed_by = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
|
e.expires = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
|
e.flags = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
err = krb5_parse_name(context, e.principal, &ent.principal);
|
err = krb5_parse_name(context, e.principal, &ent.principal);
|
||||||
if(err){
|
if(err){
|
||||||
@@ -123,7 +160,7 @@ doit(char *filename, int merge)
|
|||||||
|
|
||||||
ent.keyblock.keytype = KEYTYPE_DES;
|
ent.keyblock.keytype = KEYTYPE_DES;
|
||||||
ent.keyblock.keyvalue.data = malloc(strlen(e.key)/2+1);
|
ent.keyblock.keyvalue.data = malloc(strlen(e.key)/2+1);
|
||||||
for(i = 1; i < strlen(e.key) - 1; i += 2){
|
for(i = 0; i < strlen(e.key); i += 2){
|
||||||
unsigned tmp;
|
unsigned tmp;
|
||||||
sscanf(e.key + i, "%2x", &tmp);
|
sscanf(e.key + i, "%2x", &tmp);
|
||||||
((unsigned char *)ent.keyblock.keyvalue.data)[i/2] = tmp;
|
((unsigned char *)ent.keyblock.keyvalue.data)[i/2] = tmp;
|
||||||
@@ -132,11 +169,10 @@ doit(char *filename, int merge)
|
|||||||
ent.kvno = atoi(e.kvno);
|
ent.kvno = atoi(e.kvno);
|
||||||
ent.max_life = atoi(e.max_life);
|
ent.max_life = atoi(e.max_life);
|
||||||
ent.max_renew = atoi(e.max_renew);
|
ent.max_renew = atoi(e.max_renew);
|
||||||
krb5_build_principal(context, &ent.changed_by,
|
ent.last_change = str2time(e.last_change);
|
||||||
0,
|
krb5_parse_name(context, e.changed_by, &ent.changed_by);
|
||||||
""
|
ent.expires = str2time(e.expires);
|
||||||
"kadmin",
|
ent.flags.i = atoi(e.flags); /* XXX */
|
||||||
NULL);
|
|
||||||
db->store(context, db, &ent);
|
db->store(context, db, &ent);
|
||||||
hdb_free_entry (context, &ent);
|
hdb_free_entry (context, &ent);
|
||||||
}
|
}
|
||||||
|
@@ -42,12 +42,44 @@ RCSID("$Id$");
|
|||||||
|
|
||||||
struct entry{
|
struct entry{
|
||||||
char *principal;
|
char *principal;
|
||||||
char *key;
|
|
||||||
char *kvno;
|
char *kvno;
|
||||||
|
char *keytype;
|
||||||
|
char *key;
|
||||||
char *max_life;
|
char *max_life;
|
||||||
char *max_renew;
|
char *max_renew;
|
||||||
|
char *last_change;
|
||||||
|
char *changed_by;
|
||||||
|
char *expires;
|
||||||
|
char *flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *
|
||||||
|
skip_next(char *p)
|
||||||
|
{
|
||||||
|
while(*p && !isspace(*p))
|
||||||
|
p++;
|
||||||
|
*p++ = 0;
|
||||||
|
while(*p && isspace(*p)) p++;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
time_t
|
||||||
|
str2time(char *s)
|
||||||
|
{
|
||||||
|
int year, month, date, hour, minute, second;
|
||||||
|
struct tm tm;
|
||||||
|
sscanf(s, "%04d%02d%02d%02d%02d%02d",
|
||||||
|
&year, &month, &date, &hour, &minute, &second);
|
||||||
|
tm.tm_year = year - 1900;
|
||||||
|
tm.tm_mon = month - 1;
|
||||||
|
tm.tm_mday = date;
|
||||||
|
tm.tm_hour = hour;
|
||||||
|
tm.tm_min = minute;
|
||||||
|
tm.tm_sec = second;
|
||||||
|
tm.tm_isdst = 0;
|
||||||
|
return timegm(&tm);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doit(char *filename, int merge)
|
doit(char *filename, int merge)
|
||||||
{
|
{
|
||||||
@@ -88,28 +120,33 @@ doit(char *filename, int merge)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*p++ = 0;
|
p = skip_next(p);
|
||||||
while(*p && isspace(*p)) p++;
|
|
||||||
e.key = p;
|
|
||||||
while(*p && !isspace(*p))
|
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
|
||||||
while(*p && isspace(*p)) p++;
|
|
||||||
e.kvno = p;
|
e.kvno = p;
|
||||||
|
while(*p && isdigit(*p)) p++;
|
||||||
while(*p && !isspace(*p))
|
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
while(*p && isspace(*p)) p++;
|
e.keytype = p;
|
||||||
|
while(*p && isdigit(*p)) p++;
|
||||||
|
*p++ = 0;
|
||||||
|
e.key = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
e.max_life = p;
|
e.max_life = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
while(*p && !isspace(*p))
|
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
|
||||||
e.max_renew = p;
|
e.max_renew = p;
|
||||||
while(*p && !isspace(*p))
|
p = skip_next(p);
|
||||||
*p++;
|
|
||||||
*p++ = 0;
|
e.last_change = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
|
e.changed_by = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
|
e.expires = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
|
e.flags = p;
|
||||||
|
p = skip_next(p);
|
||||||
|
|
||||||
err = krb5_parse_name(context, e.principal, &ent.principal);
|
err = krb5_parse_name(context, e.principal, &ent.principal);
|
||||||
if(err){
|
if(err){
|
||||||
@@ -123,7 +160,7 @@ doit(char *filename, int merge)
|
|||||||
|
|
||||||
ent.keyblock.keytype = KEYTYPE_DES;
|
ent.keyblock.keytype = KEYTYPE_DES;
|
||||||
ent.keyblock.keyvalue.data = malloc(strlen(e.key)/2+1);
|
ent.keyblock.keyvalue.data = malloc(strlen(e.key)/2+1);
|
||||||
for(i = 1; i < strlen(e.key) - 1; i += 2){
|
for(i = 0; i < strlen(e.key); i += 2){
|
||||||
unsigned tmp;
|
unsigned tmp;
|
||||||
sscanf(e.key + i, "%2x", &tmp);
|
sscanf(e.key + i, "%2x", &tmp);
|
||||||
((unsigned char *)ent.keyblock.keyvalue.data)[i/2] = tmp;
|
((unsigned char *)ent.keyblock.keyvalue.data)[i/2] = tmp;
|
||||||
@@ -132,11 +169,10 @@ doit(char *filename, int merge)
|
|||||||
ent.kvno = atoi(e.kvno);
|
ent.kvno = atoi(e.kvno);
|
||||||
ent.max_life = atoi(e.max_life);
|
ent.max_life = atoi(e.max_life);
|
||||||
ent.max_renew = atoi(e.max_renew);
|
ent.max_renew = atoi(e.max_renew);
|
||||||
krb5_build_principal(context, &ent.changed_by,
|
ent.last_change = str2time(e.last_change);
|
||||||
0,
|
krb5_parse_name(context, e.changed_by, &ent.changed_by);
|
||||||
""
|
ent.expires = str2time(e.expires);
|
||||||
"kadmin",
|
ent.flags.i = atoi(e.flags); /* XXX */
|
||||||
NULL);
|
|
||||||
db->store(context, db, &ent);
|
db->store(context, db, &ent);
|
||||||
hdb_free_entry (context, &ent);
|
hdb_free_entry (context, &ent);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user