parsav  Diff

Differences From Artifact [aa223ca2fb]:

To Artifact [f2643e6a8b]:


    54     54   
    55     55   	all: bool
    56     56   	src: &lib.store.source
    57     57   	srv: &lib.srv.overlord
    58     58   
    59     59   	sid: uint64
    60     60   	iname: rawstring
           61  +
           62  +	cfgpool: lib.mem.pool
    61     63   }
    62     64   idelegate.metamethods.__methodmissing = macro(function(meth, self, ...)
    63     65   	local expr = {...}
    64     66   	local rt
    65     67   
    66     68   	for _,f in pairs(lib.store.backend.entries) do
    67     69   		local fn = f.field or f[1]
................................................................................
    74     76   		if self.all or (self.srv ~= nil and self.srv.sources.ct == 1)
    75     77   			then r=self.srv:[meth]([expr])
    76     78   			elseif self.src ~= nil then r=self.src:[meth]([expr])
    77     79   			else lib.bail('no data source specified')
    78     80   		end
    79     81   	in r end
    80     82   end)
           83  +
           84  +terra idelegate:conf(key: lib.str.t)
           85  +	return self:conf_get(&self.cfgpool, key)
           86  +end
    81     87   
    82     88   terra idelegate:ipc_send(cmd: lib.ipc.cmd.t, operand: uint64)
    83     89   	var emp = self.emperor
    84     90   	var acks: lib.mem.ptr(lib.ipc.ack)
    85     91   	if self.sid == 0 and self.iname == nil then
    86     92   		if not self.all and emp:countpeers() > 1 then
    87     93   			lib.bail('either specify the instance to control or pass --all to control all instances')
................................................................................
   155    161   	[lib.init]
   156    162   
   157    163   	var srv: lib.srv.overlord
   158    164   	var dlg = idelegate {
   159    165   		emperor = &emp, srv = &srv;
   160    166   		src = nil, sid = 0, iname = nil, all = false;
   161    167   	}
          168  +	dlg.cfgpool:init(128)
   162    169   
   163    170   	var mode: ctloptions
   164    171   	mode:parse(argc,argv) defer mode:free()
   165    172   	if mode.version then version() return 0 end
   166    173   	if mode.help then
   167    174   		[ lib.emit(false, 1, 'usage: ', `argv[0], ' ', ctloptions.helptxt.flags, ' <cmd> [<args>…]', ctloptions.helptxt.opts, cmdhelp(ctlcmds)) ]
   168    175   		return 0
................................................................................
   378    385   			if lib.str.cmp(mode.arglist(0),'mkroot') == 0 then
   379    386   				var cfmode: pbasic cfmode:parse(mode.arglist.ct, &mode.arglist(0))
   380    387   				if cfmode.help then
   381    388   					[ lib.emit(false, 1, 'usage: ', `argv[0], ' mkroot ', cfmode.type.helptxt.flags, ' <handle>', cfmode.type.helptxt.opts) ]
   382    389   					return 1
   383    390   				end
   384    391   				if cfmode.arglist.ct == 1 then
   385         -					var am = dlg:conf_get('credential-store')
          392  +					var am = dlg:conf('credential-store')
   386    393   					var mg: bool
   387    394   					if (not am) or am:cmp('managed') then
   388    395   						mg = true
   389    396   					elseif am:cmp('unmanaged') then
   390    397   						lib.warn('credential store is unmanaged; you will need to create credentials for the new root user manually!')
   391    398   						mg = false
   392    399   					else lib.bail('unknown credential store mode "',{am.ptr,am.ct},'"; should be either "managed" or "unmanaged"') end