Your ROOT_URL in app.ini is unix://git.lalonde.me:3000/ but you are visiting https://git.lalonde.me/matth/subgraph-oz/commit/74d85b79a4ad550761b93e125bcd1ec2efb741d2?style=split&whitespace=ignore-eol
You should set ROOT_URL correctly, otherwise the web may not work correctly.
3 changed files with
51 additions and
6 deletions
@ -2,7 +2,11 @@ package oz
import (
import (
"encoding/json"
"encoding/json"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"path"
"syscall"
)
)
type Config struct {
type Config struct {
@ -36,8 +40,15 @@ func NewDefaultConfig() *Config {
}
}
}
}
func LoadConfig ( path string ) ( * Config , error ) {
func LoadConfig ( cpath string ) ( * Config , error ) {
bs , err := ioutil . ReadFile ( path )
if _ , err := os . Stat ( cpath ) ; os . IsNotExist ( err ) {
return nil , err
}
if err := checkConfigPermissions ( cpath ) ; err != nil {
return nil , err
}
bs , err := ioutil . ReadFile ( cpath )
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
@ -47,3 +58,27 @@ func LoadConfig(path string) (*Config, error) {
}
}
return c , nil
return c , nil
}
}
func checkConfigPermissions ( fpath string ) error {
pd := path . Dir ( fpath )
for _ , fp := range [ ] string { pd , fpath } {
if err := checkPathRootPermissions ( fp ) ; err != nil {
return fmt . Errorf ( "file (%s) is %s" , fp , err )
}
}
return nil
}
func checkPathRootPermissions ( fpath string ) error {
fstat , err := os . Stat ( fpath )
if err != nil {
return err
}
if ( fstat . Mode ( ) . Perm ( ) & syscall . S_IWOTH ) != 0 {
return fmt . Errorf ( "writable by everyone!" , fpath )
}
if ( fstat . Mode ( ) . Perm ( ) & syscall . S_IWGRP ) != 0 && fstat . Sys ( ) . ( * syscall . Stat_t ) . Gid != 0 {
return fmt . Errorf ( "writable by someone else than root!" , err )
}
return nil
}
@ -51,8 +51,13 @@ func initialize() *daemonState {
var config * oz . Config
var config * oz . Config
config , err := oz . LoadConfig ( oz . DefaultConfigPath )
config , err := oz . LoadConfig ( oz . DefaultConfigPath )
if err != nil {
if err != nil {
d . log . Info ( "Could not load config file (%s), using default config" , oz . DefaultConfigPath )
if os . IsNotExist ( err ) {
config = oz . NewDefaultConfig ( )
d . log . Info ( "Configuration file (%s) is missing, using defaults." , oz . DefaultConfigPath )
config = oz . NewDefaultConfig ( )
} else {
d . log . Error ( "Could not load configuration: %s" , oz . DefaultConfigPath , err )
os . Exit ( 1 )
}
}
}
d . log . Info ( "Oz Global Config: %+v" , config )
d . log . Info ( "Oz Global Config: %+v" , config )
d . config = config
d . config = config
@ -79,8 +79,13 @@ func parseArgs() *initState {
var config * oz . Config
var config * oz . Config
config , err := oz . LoadConfig ( oz . DefaultConfigPath )
config , err := oz . LoadConfig ( oz . DefaultConfigPath )
if err != nil {
if err != nil {
log . Info ( "Could not load config file (%s), using default config" , oz . DefaultConfigPath )
if os . IsNotExist ( err ) {
config = oz . NewDefaultConfig ( )
log . Info ( "Configuration file (%s) is missing, using defaults." , oz . DefaultConfigPath )
config = oz . NewDefaultConfig ( )
} else {
log . Error ( "Could not load configuration: %s" , oz . DefaultConfigPath , err )
os . Exit ( 1 )
}
}
}
p , err := loadProfile ( config . ProfileDir , pname )
p , err := loadProfile ( config . ProfileDir , pname )