Booting galaxies again.

This commit is contained in:
C. Guy Yarvin 2017-06-11 22:46:25 -07:00
parent 1af4895a89
commit 976a9e4d2a
4 changed files with 106 additions and 58 deletions

View File

@ -608,20 +608,18 @@
/* u3_opts: command line configuration.
*/
typedef struct _u3_opts {
c3_c* imp_c; // -I, czar name
c3_c* nam_c; // -n, unix hostname
c3_c* raf_c; // -r, raft flotilla
c3_c* who_c; // -w, begin with ticket
c3_c* tic_c; // -t, ticket value
c3_c* pil_c; // -B, bootstrap from
c3_c* lit_c; // -J, ivory (fastboot) kernel
c3_c* gen_c; // -G, czar generator
c3_c* sec_c; // -s, secret
c3_w kno_w; // -k, kernel version
c3_w fuz_w; // -f, fuzz testing
c3_s por_s; // -p, ames port
c3_s rop_s; // -l, raft port
c3_o abo; // -a, abort aggressively
c3_o bat; // -b, batch create
c3_o sic; // -S, enter secret at prompt
c3_o gab; // -g, test garbage collection
c3_o dem; // -d, daemon
c3_o dry; // -D, dry compute, no checkpoint
@ -1475,6 +1473,11 @@
c3_l msc_l,
u3_noun job);
/* u3_pier_rand(): fill a 512-bit (16-word) buffer.
*/
void
u3_pier_rand(c3_w* rad_w);
/* u3_pier_exit(): trigger a gentle shutdown.
*/
void

View File

@ -323,21 +323,51 @@ _boothack_cb(uv_connect_t *conn, int status)
u3z(whu);
}
{
if ( !u3_Host.ops_u.tic_c ) {
fprintf(stderr, "boot: F A K E ship with null security (use -t)\r\n");
sec = 0;
}
else {
u3_noun suc = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.tic_c));
if ( c3y == u3_Host.ops_u.fak ) {
fprintf(stderr, "boot: F A K E ship with null security\r\n");
sec = 0;
tic = 0;
}
else {
if ( 0 == u3_Host.ops_u.sec_c ) {
c3_w eny_w[16];
u3_pier_rand(eny_w);
sec = u3i_words(2, eny_w);
{
u3_noun rot = u3dc("scot", 'p', u3k(sec));
c3_c* rot_c = u3r_string(rot);
fprintf(stderr, "boot: %s: R O O T P A S S W O R D %s\r\n",
u3_Host.ops_u.who_c,
rot_c);
fprintf(stderr, " (write it down and put it in your wallet)\r\n");
u3z(rot);
c3_free(rot_c);
}
} else {
u3_noun suc = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.sec_c));
if ( u3_nul == suc ) {
fprintf(stderr, "boot: malformed secret (-t)\r\n");
fprintf(stderr, "boot: malformed secret (-s)\r\n");
exit(1);
}
sec = u3k(u3t(suc));
u3z(suc);
}
{
u3_noun tuc = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.tic_c));
if ( u3_nul == tuc ) {
fprintf(stderr, "boot: malformed ticket (-t)\r\n");
exit(1);
}
tic = u3k(u3t(tuc));
u3z(tuc);
}
}
tic = u3k(sec);
pax = u3i_string(u3_Host.dir_c);

View File

@ -74,6 +74,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.tex = c3n;
u3_Host.ops_u.pro = c3n;
u3_Host.ops_u.dry = c3n;
u3_Host.ops_u.sic = c3n;
u3_Host.ops_u.veb = c3n;
u3_Host.ops_u.qui = c3n;
u3_Host.ops_u.nuu = c3n;
@ -81,7 +82,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.rep = c3n;
u3_Host.ops_u.kno_w = DefaultKernel;
while ( (ch_i=getopt(argc, argv,"G:B:I:w:t:f:k:l:n:p:r:LabcdgmqvxFMPDXR")) != -1 ) {
while ( (ch_i=getopt(argc, argv,"s:B:I:w:t:f:k:l:n:p:LSabcdgmqvxFMPDXR")) != -1 ) {
switch ( ch_i ) {
case 'M': {
u3_Host.ops_u.mem = c3y;
@ -91,12 +92,8 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.pil_c = strdup(optarg);
break;
}
case 'G': {
u3_Host.ops_u.gen_c = strdup(optarg);
break;
}
case 'I': {
u3_Host.ops_u.imp_c = _main_presig(optarg);
case 's': {
u3_Host.ops_u.sec_c = strdup(optarg);
break;
}
case 'w': {
@ -128,12 +125,6 @@ _main_getopt(c3_i argc, c3_c** argv)
}
break;
}
case 'l': {
if ( c3n == _main_readw(optarg, 65536, &arg_w) ) {
return c3n;
} else u3_Host.ops_u.rop_s = arg_w;
break;
}
case 'n': {
u3_Host.ops_u.nam_c = strdup(optarg);
break;
@ -144,10 +135,6 @@ _main_getopt(c3_i argc, c3_c** argv)
} else u3_Host.ops_u.por_s = arg_w;
break;
}
case 'r': {
u3_Host.ops_u.raf_c = strdup(optarg);
break;
}
case 'R': {
u3_Host.ops_u.rep = c3y;
return c3y;
@ -181,33 +168,55 @@ _main_getopt(c3_i argc, c3_c** argv)
exit(1); /* (avoid simple usage msg) */
}
if ( u3_Host.ops_u.gen_c != 0 && ( u3_Host.ops_u.imp_c == 0 ||
u3_Host.ops_u.nuu == c3n ) ) {
fprintf(stderr, "-G only makes sense when creating a new galaxy\n");
return c3n;
}
/* fill in any missing security data, etc
*/
if ( u3_Host.ops_u.nuu == c3y ) {
if ( u3_Host.ops_u.who_c == 0 ) {
fprintf(stderr, "comets are not yet supported; identify with -w\r\n");
return c3n;
}
else {
if ( c3n == u3_Host.ops_u.fak ) {
if ( (u3_Host.ops_u.tic_c == 0) &&
(strlen(u3_Host.ops_u.who_c) >= 4)
)
{
c3_c tic_c[29];
if ( u3_Host.ops_u.tic_c != 0 && ( u3_Host.ops_u.imp_c != 0 ||
u3_Host.ops_u.nuu == c3n ) ) {
fprintf(stderr, "-t only makes sense when creating a new non-galaxy\n");
return c3n;
}
printf("enter your ticket: ~");
scanf("%28s", tic_c);
u3_Host.ops_u.tic_c = _main_presig(tic_c);
}
if ( u3_Host.ops_u.rop_s == 0 && u3_Host.ops_u.raf_c != 0 ) {
fprintf(stderr, "The -r flag requires -l.\n");
return c3n;
}
if ( c3y == u3_Host.ops_u.sic ) {
c3_c sec_c[29];
if ( (u3_Host.ops_u.tic_c == 0) &&
(u3_Host.ops_u.who_c != 0) &&
(c3n == u3_Host.ops_u.fak)
)
{
c3_c tic_c[29];
printf("enter your secret: ~");
scanf("%28s", sec_c);
u3_Host.ops_u.sec_c = _main_presig(sec_c);
}
}
}
} else {
if ( u3_Host.ops_u.sec_c != 0 ) {
fprintf(stderr, "-s only makes sense when creating a new ship\n");
return c3n;
}
if ( u3_Host.ops_u.tic_c != 0 ) {
fprintf(stderr, "-t only makes sense when creating a new ship\n");
return c3n;
}
if ( u3_Host.ops_u.who_c != 0 ) {
fprintf(stderr, "-w only makes sense when creating a new ship\n");
return c3n;
}
if ( u3_Host.ops_u.pil_c != 0) {
fprintf(stderr, "-B only makes sense when creating a new ship\n");
return c3n;
}
printf("enter your secret: ~");
scanf("%28s",tic_c);
u3_Host.ops_u.tic_c = _main_presig(tic_c);
}
if ( c3y == u3_Host.ops_u.bat ) {
@ -215,11 +224,6 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.nuu = c3y;
}
if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.pil_c != 0) {
fprintf(stderr, "-B only makes sense when bootstrapping a new instance\n");
return c3n;
}
if ( u3_Host.ops_u.pil_c != 0 ) {
struct stat s;
if ( stat(u3_Host.ops_u.pil_c, &s) != 0 ) {

View File

@ -90,6 +90,17 @@ _reck_kick_term(u3_pier* pir_u, u3_noun pox, c3_l tid_l, u3_noun fav)
u3z(pox); u3z(fav); return c3y;
} break;
// this can return through dill due to our fscked up boot sequence
//
case c3__send: {
u3_noun lan = u3k(u3h(u3t(fav)));
u3_noun pac = u3k(u3t(u3t(fav)));
fprintf(stderr, "kick: strange send\r\n");
u3_ames_ef_send(pir_u, lan, pac);
u3z(pox); u3z(fav); return c3y;
} break;
case c3__logo:
{
u3_pier_exit();