Removed old/deprecated decision code.

shw_dev
Stephen Watt 7 years ago
parent 819edd1962
commit 5ba55a2d96

@ -11,8 +11,6 @@ fw-prompt:
more nesting for similar prompts (by application, pid, target host, etc) more nesting for similar prompts (by application, pid, target host, etc)
remove old decision code
gnome-shell: gnome-shell:
Start using new async DBus methods Start using new async DBus methods

@ -25,14 +25,6 @@ type fpPreferences struct {
Winleft uint Winleft uint
} }
type decisionWaiter struct {
Cond *sync.Cond
Lock sync.Locker
Ready bool
Scope int
Rule string
}
type ruleColumns struct { type ruleColumns struct {
nrefs int nrefs int
Path string Path string
@ -83,7 +75,6 @@ var globalTS *gtk.TreeStore = nil
var globalTV *gtk.TreeView var globalTV *gtk.TreeView
var globalPromptLock = &sync.Mutex{} var globalPromptLock = &sync.Mutex{}
var globalIcon *gtk.Image var globalIcon *gtk.Image
var decisionWaiters []*decisionWaiter
var editApp, editTarget, editPort, editUser, editGroup *gtk.Entry var editApp, editTarget, editPort, editUser, editGroup *gtk.Entry
var comboProto *gtk.ComboBoxText var comboProto *gtk.ComboBoxText
@ -91,21 +82,6 @@ var radioOnce, radioProcess, radioParent, radioSession, radioPermanent *gtk.Radi
var btnApprove, btnDeny, btnIgnore *gtk.Button var btnApprove, btnDeny, btnIgnore *gtk.Button
var chkTLS, chkUser, chkGroup *gtk.CheckButton var chkTLS, chkUser, chkGroup *gtk.CheckButton
func dumpDecisions() {
return
fmt.Println("XXX Total of decisions pending: ", len(decisionWaiters))
for i := 0; i < len(decisionWaiters); i++ {
fmt.Printf("XXX %d ready = %v, rule = %v\n", i+1, decisionWaiters[i].Ready, decisionWaiters[i].Rule)
}
}
func addDecision() *decisionWaiter {
return nil
decision := decisionWaiter{Lock: &sync.Mutex{}, Ready: false, Scope: int(sgfw.APPLY_ONCE), Rule: ""}
decision.Cond = sync.NewCond(decision.Lock)
decisionWaiters = append(decisionWaiters, &decision)
return &decision
}
func promptInfo(msg string) { func promptInfo(msg string) {
dialog := gtk.MessageDialogNew(mainWin, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Displaying full log info:") dialog := gtk.MessageDialogNew(mainWin, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Displaying full log info:")
@ -391,7 +367,7 @@ remove_outer:
if err != nil { if err != nil {
break remove_outer break remove_outer
} else if rule.GUID == guid { } else if rule.GUID == guid {
removeSelectedRule(ridx, true) removeSelectedRule(ridx)
removed = true removed = true
break break
} }
@ -512,7 +488,7 @@ func addRequestAsync(treeStore *gtk.TreeStore, guid, path, icon, proto string, p
} }
func addRequest(treeStore *gtk.TreeStore, guid, path, icon, proto string, pid int, ipaddr, hostname string, port, uid, gid int, func addRequest(treeStore *gtk.TreeStore, guid, path, icon, proto string, pid int, ipaddr, hostname string, port, uid, gid int,
origin, timestamp string, is_socks bool, optstring string, sandbox string, action int) *decisionWaiter { origin, timestamp string, is_socks bool, optstring string, sandbox string, action int) bool {
if treeStore == nil { if treeStore == nil {
treeStore = globalTS treeStore = globalTS
waitTimes := []int{1, 2, 5, 10} waitTimes := []int{1, 2, 5, 10}
@ -541,11 +517,10 @@ func addRequest(treeStore *gtk.TreeStore, guid, path, icon, proto string, pid in
if addRequestInc(treeStore, guid, path, icon, proto, pid, ipaddr, hostname, port, uid, gid, origin, timestamp, is_socks, optstring, sandbox, action) { if addRequestInc(treeStore, guid, path, icon, proto, pid, ipaddr, hostname, port, uid, gid, origin, timestamp, is_socks, optstring, sandbox, action) {
fmt.Println("REQUEST WAS DUPLICATE") fmt.Println("REQUEST WAS DUPLICATE")
decision := addDecision()
globalPromptLock.Lock() globalPromptLock.Lock()
toggleHover() toggleHover()
globalPromptLock.Unlock() globalPromptLock.Unlock()
return decision return true
} else { } else {
fmt.Println("NOT DUPLICATE") fmt.Println("NOT DUPLICATE")
} }
@ -556,10 +531,8 @@ func addRequest(treeStore *gtk.TreeStore, guid, path, icon, proto string, pid in
iter := treeStore.Append(nil) iter := treeStore.Append(nil)
storeNewEntry(treeStore, iter, guid, path, icon, proto, pid, ipaddr, hostname, port, uid, gid, origin, timestamp, is_socks, optstring, sandbox, action) storeNewEntry(treeStore, iter, guid, path, icon, proto, pid, ipaddr, hostname, port, uid, gid, origin, timestamp, is_socks, optstring, sandbox, action)
decision := addDecision()
dumpDecisions()
toggleHover() toggleHover()
return decision return true
} }
func setup_settings() { func setup_settings() {
@ -663,14 +636,6 @@ func makeDecision(idx int, rule string, scope int) error {
} }
fmt.Println("makeDecision remote result:", dres) fmt.Println("makeDecision remote result:", dres)
return nil
decisionWaiters[idx].Cond.L.Lock()
decisionWaiters[idx].Rule = rule
decisionWaiters[idx].Scope = scope
decisionWaiters[idx].Ready = true
decisionWaiters[idx].Cond.Signal()
decisionWaiters[idx].Cond.L.Unlock()
return nil return nil
} }
@ -800,7 +765,7 @@ func clearEditor() {
chkTLS.SetActive(false) chkTLS.SetActive(false)
} }
func removeSelectedRule(idx int, rmdecision bool) error { func removeSelectedRule(idx int) error {
fmt.Println("XXX: attempting to remove idx = ", idx) fmt.Println("XXX: attempting to remove idx = ", idx)
path, err := gtk.TreePathNewFromString(fmt.Sprintf("%d", idx)) path, err := gtk.TreePathNewFromString(fmt.Sprintf("%d", idx))
@ -814,11 +779,6 @@ func removeSelectedRule(idx int, rmdecision bool) error {
} }
globalTS.Remove(iter) globalTS.Remove(iter)
if rmdecision {
// decisionWaiters = append(decisionWaiters[:idx], decisionWaiters[idx+1:]...)
}
toggleHover() toggleHover()
return nil return nil
} }
@ -1073,8 +1033,7 @@ func buttonAction(action string) {
rulestr += "|" + sgfw.RuleModeString[sgfw.RuleMode(rule.Scope)] rulestr += "|" + sgfw.RuleModeString[sgfw.RuleMode(rule.Scope)]
fmt.Println("RULESTR = ", rulestr) fmt.Println("RULESTR = ", rulestr)
makeDecision(idx, rulestr, int(rule.Scope)) makeDecision(idx, rulestr, int(rule.Scope))
fmt.Println("Decision made.") err = removeSelectedRule(idx)
err = removeSelectedRule(idx, true)
globalPromptLock.Unlock() globalPromptLock.Unlock()
if err == nil { if err == nil {
clearEditor() clearEditor()
@ -1085,7 +1044,6 @@ func buttonAction(action string) {
} }
func main() { func main() {
decisionWaiters = make([]*decisionWaiter, 0)
_, err := newDbusServer() _, err := newDbusServer()
if err != nil { if err != nil {
log.Fatal("Error:", err) log.Fatal("Error:", err)

Loading…
Cancel
Save