about summary refs log tree commit diff stats
path: root/src/ui/windows.h
Commit message (Expand)AuthorAgeFilesLines
* Removed /duck commandJames Booth2014-10-181-1/+0
* Implemented /occupants showJames Booth2014-10-091-0/+1
* Implemented /occupants hideJames Booth2014-10-091-0/+1
* Added license exemption for OpenSSL to source headersJames Booth2014-08-241-0/+12
* Added command /wins swapJames Booth2014-04-241-0/+1
* Added XML Console windowJames Booth2014-04-151-0/+2
* Inlined wins_update_virtual_console and wins_update_virtual_currentJames Booth2014-04-061-2/+0
* Renamed refresh functions to update_virtualJames Booth2014-04-011-2/+2
* Updated copyrightJames Booth2014-03-091-1/+1
* Added simple mock test, refactored rosterJames Booth2013-12-141-2/+2
* Next and previous windows, handle KEY_CODE_YES terms, jump empty winsJames Booth2013-09-261-0/+2
* Fixed /close all and /close read to close extra windowsJames Booth2013-08-301-0/+1
* Removed limit on number of windows, WIPJames Booth2013-08-271-1/+0
* Free windows on exitJames Booth2013-08-261-0/+1
* Initial code refactor for growable window listJames Booth2013-08-201-0/+51
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// +build openbsd

package main

import (
	"fmt"
	"log"
	"strings"

	"golang.org/x/sys/unix"
	"tildegit.org/andinus/cetus/cache"
)

func main() {
	unveil()
	app()
}

func unveil() {
	unveilL := make(map[string]string)

	unveilL[cache.GetDir()] = "rw"
	unveilL["/dev/null"] = "rw" // required by feh

	unveilL["/etc/resolv.conf"] = "r"

	// ktrace output
	unveilL["/usr/libexec/ld.so"] = "r"
	unveilL["/var/run/ld.so.hints"] = "r"
	unveilL["/usr/lib/libpthread.so.26.1"] = "r"
	unveilL["/usr/lib/libc.so.95.1"] = "r"
	unveilL["/dev/urandom"] = "r"
	unveilL["/etc/mdns.allow"] = "r"
	unveilL["/etc/hosts"] = "r"
	unveilL["/usr/local/etc/ssl/cert.pem"] = "r"
	unveilL["/etc/ssl/cert.pem"] = "r"
	unveilL["/etc/ssl/certs"] = "r"
	unveilL["/system/etc/security/cacerts"] = "r"
	unveilL["/usr/local/share/certs"] = "r"
	unveilL["/etc/pki/tls/certs"] = "r"
	unveilL["/etc/openssl/certs"] = "r"
	unveilL["/var/ssl/certs"] = "r"

	for k, v := range unveilL {
		err = unix.Unveil(k, v)
		if err != nil && err.Error() != "no such file or directory" {
			log.Fatal(fmt.Sprintf("%s :: %s\n%s", k, v,
				err.Error()))
		}
	}

	err = unveilCmd("feh")
	if err != nil {
		log.Fatal(err)
	}

	// Block further unveil calls
	err = unix.UnveilBlock()
	if err != nil {
		log.Fatal(err)
	}
}

// unveilCmd will unveil commands.
func unveilCmd(cmd string) error {
	pathList := strings.Split(getEnv("PATH", ""), ":")
	for _, path := range pathList {
		err = unix.Unveil(fmt.Sprintf("%s/%s", path, cmd), "rx")

		if err != nil && err.Error() != "no such file or directory" {
			return err
		}
	}
	return nil
}