remove the force and duration options

This commit is contained in:
Aaron Bieber 2024-08-26 19:32:40 -06:00
parent 912cb41798
commit ec38dea803
No known key found for this signature in database
3 changed files with 14 additions and 24 deletions

View File

@ -31,12 +31,10 @@ type Traygent struct {
passphrase []byte
locked bool
addChan chan ssh.PublicKey
rmChan chan string
sigReq chan ssh.PublicKey
sigResp chan bool
force bool
forceDuration int
addChan chan ssh.PublicKey
rmChan chan string
sigReq chan ssh.PublicKey
sigResp chan bool
}
func (t *Traygent) log(_, msgFmt string, msg ...any) {
@ -238,7 +236,7 @@ func (t *Traygent) Add(key agent.AddedKey) error {
return err
}
p := NewPrivKey(signer, key, t.force, t.forceDuration)
p := NewPrivKey(signer, key)
t.mu.RLock()
for _, k := range t.keys {

14
main.go
View File

@ -24,8 +24,6 @@ func init() {
func main() {
sock := flag.String("s", path.Join(os.Getenv("HOME"), ".traygent"), "Socket path to create")
cmdList := flag.String("c", "/etc/traygent.json", "List of commands to execute")
force := flag.Bool("f", true, "force expiration of keys")
forceDuration := flag.Int("d", 300, "seconds for forced expiration")
flag.Parse()
os.Remove(*sock)
@ -48,13 +46,11 @@ func main() {
cmds := LoadCommands(*cmdList)
tagent := Traygent{
listener: l,
addChan: make(chan ssh.PublicKey),
rmChan: make(chan string),
sigReq: make(chan ssh.PublicKey),
sigResp: make(chan bool),
force: *force,
forceDuration: *forceDuration,
listener: l,
addChan: make(chan ssh.PublicKey),
rmChan: make(chan string),
sigReq: make(chan ssh.PublicKey),
sigResp: make(chan bool),
}
trayApp := app.NewWithID("com.bolddaemon.traygent")

View File

@ -40,22 +40,18 @@ func (p *privKey) GetComment() string {
return p.comment
}
func (p *privKey) setExpire(key agent.AddedKey, force bool, duration int) {
func (p *privKey) setExpire(key agent.AddedKey) {
exp := key.LifetimeSecs
if force && exp <= 0 {
exp = uint32(duration)
}
t := time.Now().Add(time.Duration(exp) * time.Second)
key.LifetimeSecs = exp
p.lifetime = key.LifetimeSecs
if exp > 0 {
p.expireTime = &t
}
}
func NewPrivKey(signer ssh.Signer, key agent.AddedKey, force bool, duration int) privKey {
func NewPrivKey(signer ssh.Signer, key agent.AddedKey) privKey {
pub := signer.PublicKey()
pk := privKey{
signer: signer,
@ -63,7 +59,7 @@ func NewPrivKey(signer ssh.Signer, key agent.AddedKey, force bool, duration int)
pubKey: pub,
fingerPrint: ssh.FingerprintSHA256(pub),
}
pk.setExpire(key, force, duration)
pk.setExpire(key)
return pk
}