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

@ -35,8 +35,6 @@ type Traygent struct {
rmChan chan string
sigReq chan ssh.PublicKey
sigResp chan bool
force bool
forceDuration int
}
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 {

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)
@ -53,8 +51,6 @@ func main() {
rmChan: make(chan string),
sigReq: make(chan ssh.PublicKey),
sigResp: make(chan bool),
force: *force,
forceDuration: *forceDuration,
}
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
}