Checks for rhosts.cfg and parent directory
If the directory doesn't exist it tries to create it. If the config doesn't exist it fails with a log error explaining.stable
parent
f7b781ea6e
commit
75f393d8bd
|
|
@ -112,11 +112,11 @@ func sysdetect (tmpdir, hostsloc, cfgloc *string) {
|
||||||
//log.Fatal("Windows is not supported")
|
//log.Fatal("Windows is not supported")
|
||||||
*tmpdir = "/tmp"
|
*tmpdir = "/tmp"
|
||||||
*hostsloc = "/Windows/System32/drivers/etc/hosts"
|
*hostsloc = "/Windows/System32/drivers/etc/hosts"
|
||||||
*cfgloc = "/rhosts.cfg"
|
*cfgloc = "/ProgramData/rhosts/"
|
||||||
case "linux":
|
case "linux":
|
||||||
*tmpdir = "/tmp/"
|
*tmpdir = "/tmp/"
|
||||||
*hostsloc = "/etc/hosts"
|
*hostsloc = "/etc/hosts"
|
||||||
*cfgloc ="/etc/rhosts/rhosts.cfg"
|
*cfgloc ="/etc/rhosts/"
|
||||||
case "ios":
|
case "ios":
|
||||||
log.Fatal("IOS is not supported")
|
log.Fatal("IOS is not supported")
|
||||||
default:
|
default:
|
||||||
|
|
@ -126,9 +126,20 @@ func sysdetect (tmpdir, hostsloc, cfgloc *string) {
|
||||||
|
|
||||||
// cfgparse recieves the location of the config file and returns a list of sites to add and content to download
|
// cfgparse recieves the location of the config file and returns a list of sites to add and content to download
|
||||||
func cfgparse (sites, downloads, whitelist *[]string, cfgloc string) (error){
|
func cfgparse (sites, downloads, whitelist *[]string, cfgloc string) (error){
|
||||||
|
l := (cfgloc + "rhosts.cfg")
|
||||||
var err error=nil
|
var err error=nil
|
||||||
log.Print("Opening: ", cfgloc)
|
log.Print("Opening: ", l)
|
||||||
file, err := os.Open(cfgloc)
|
if _,err = os.Stat(cfgloc); os.IsNotExist(err) {
|
||||||
|
log.Print(cfgloc + " Does not exist, attempting to create it")
|
||||||
|
err = os.MkdirAll(cfgloc,731)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Could not create " + cfgloc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _,err = os.Stat(l); os.IsNotExist(err) {
|
||||||
|
log.Fatal(l + " does not exist, you need to create it")
|
||||||
|
}
|
||||||
|
file, err := os.Open(l)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue