remove the force and duration options
This commit is contained in:
parent
912cb41798
commit
ec38dea803
4
agent.go
4
agent.go
@ -35,8 +35,6 @@ type Traygent struct {
|
|||||||
rmChan chan string
|
rmChan chan string
|
||||||
sigReq chan ssh.PublicKey
|
sigReq chan ssh.PublicKey
|
||||||
sigResp chan bool
|
sigResp chan bool
|
||||||
force bool
|
|
||||||
forceDuration int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Traygent) log(_, msgFmt string, msg ...any) {
|
func (t *Traygent) log(_, msgFmt string, msg ...any) {
|
||||||
@ -238,7 +236,7 @@ func (t *Traygent) Add(key agent.AddedKey) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
p := NewPrivKey(signer, key, t.force, t.forceDuration)
|
p := NewPrivKey(signer, key)
|
||||||
|
|
||||||
t.mu.RLock()
|
t.mu.RLock()
|
||||||
for _, k := range t.keys {
|
for _, k := range t.keys {
|
||||||
|
4
main.go
4
main.go
@ -24,8 +24,6 @@ func init() {
|
|||||||
func main() {
|
func main() {
|
||||||
sock := flag.String("s", path.Join(os.Getenv("HOME"), ".traygent"), "Socket path to create")
|
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")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
os.Remove(*sock)
|
os.Remove(*sock)
|
||||||
@ -53,8 +51,6 @@ func main() {
|
|||||||
rmChan: make(chan string),
|
rmChan: make(chan string),
|
||||||
sigReq: make(chan ssh.PublicKey),
|
sigReq: make(chan ssh.PublicKey),
|
||||||
sigResp: make(chan bool),
|
sigResp: make(chan bool),
|
||||||
force: *force,
|
|
||||||
forceDuration: *forceDuration,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trayApp := app.NewWithID("com.bolddaemon.traygent")
|
trayApp := app.NewWithID("com.bolddaemon.traygent")
|
||||||
|
12
privkey.go
12
privkey.go
@ -40,22 +40,18 @@ func (p *privKey) GetComment() string {
|
|||||||
return p.comment
|
return p.comment
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *privKey) setExpire(key agent.AddedKey, force bool, duration int) {
|
func (p *privKey) setExpire(key agent.AddedKey) {
|
||||||
exp := key.LifetimeSecs
|
exp := key.LifetimeSecs
|
||||||
|
|
||||||
if force && exp <= 0 {
|
|
||||||
exp = uint32(duration)
|
|
||||||
}
|
|
||||||
|
|
||||||
t := time.Now().Add(time.Duration(exp) * time.Second)
|
t := time.Now().Add(time.Duration(exp) * time.Second)
|
||||||
key.LifetimeSecs = exp
|
|
||||||
p.lifetime = key.LifetimeSecs
|
p.lifetime = key.LifetimeSecs
|
||||||
|
|
||||||
if exp > 0 {
|
if exp > 0 {
|
||||||
p.expireTime = &t
|
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()
|
pub := signer.PublicKey()
|
||||||
pk := privKey{
|
pk := privKey{
|
||||||
signer: signer,
|
signer: signer,
|
||||||
@ -63,7 +59,7 @@ func NewPrivKey(signer ssh.Signer, key agent.AddedKey, force bool, duration int)
|
|||||||
pubKey: pub,
|
pubKey: pub,
|
||||||
fingerPrint: ssh.FingerprintSHA256(pub),
|
fingerPrint: ssh.FingerprintSHA256(pub),
|
||||||
}
|
}
|
||||||
pk.setExpire(key, force, duration)
|
pk.setExpire(key)
|
||||||
|
|
||||||
return pk
|
return pk
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user