Buggy code:
HostRegistry . addHost ( MAIL , HostMail . class ) ; HostRegistry . addHost ( FTP , HostFTP . class ) ; HostHTTP . unpack ( ) ; HostCom . unpack ( ) ; HostDNS . unpack ( ) ; HostMail . unpack ( ) ; HostFTP . unpack ( ) ; AvunaHTTPD . hostsConfig = new Config ( "hosts" , new File ( AvunaHTTPD . mainConfig . getNode ( "hosts" ) . getValue ( ) ) , new ConfigFormat ( ) { @ Override public void format ( ConfigNode map ) { boolean nc = false ; boolean nd = false ; if ( ! ( map . containsNode ( "main" ) ) ) { map . insertNode ( "main" , null , "main<seq2seq4repair_space>node,<seq2seq4repair_space>must<seq2seq4repair_space>exist" ) ; } if ( ! ( map . containsNode ( "com" ) ) ) { map . insertNode ( "com" , null , "set<seq2seq4repair_space>enabled=true<seq2seq4repair_space>to<seq2seq4repair_space>use<seq2seq4repair_space>the<seq2seq4repair_space>local//remote<seq2seq4repair_space>command<seq2seq4repair_space>system." ) ; nc = true ; } for ( String key : map . getSubnodes ( ) ) { ConfigNode host = map . getNode ( key ) ; if ( ! ( host . containsNode ( "enabled" ) ) ) host . insertNode ( "enabled" , ( nc && ( key . equals ( "com" ) ) ? "false" : "true" ) ) ; if ( ! ( host . containsNode ( "protocol" ) ) ) host . insertNode ( "protocol" , ( nd && ( key . equals ( "dns" ) ) ? "dns" : nc && ( key . equals ( "com" ) ) ? "com" : "http" ) , "set<seq2seq4repair_space>to<seq2seq4repair_space>http//httpm//com//dns//mail<seq2seq4repair_space>for<seq2seq4repair_space>respective<seq2seq4repair_space>servers,<seq2seq4repair_space>load<seq2seq4repair_space>avuna<seq2seq4repair_space>with<seq2seq4repair_space>these<seq2seq4repair_space>to<seq2seq4repair_space>have<seq2seq4repair_space>other<seq2seq4repair_space>config<seq2seq4repair_space>options<seq2seq4repair_space>autofill." ) ; Protocol p = Protocol . fromString ( host . getNode ( "protocol" ) . getValue ( ) ) ; if ( p == null ) { Logger . log ( ( ( "Skipping<seq2seq4repair_space>Host:<seq2seq4repair_space>" + key ) + "<seq2seq4repair_space>due<seq2seq4repair_space>to<seq2seq4repair_space>invalid<seq2seq4repair_space>protocol!" ) ) ; continue ; } if ( ! ( host . getNode ( "enabled" ) . getValue ( ) . equals ( "true" ) ) ) { continue ; } try { Host h = ( ( Host ) ( HostRegistry . getHost ( p ) . getConstructors ( ) [ 0 ] . newInstance ( key ) ) ) ; h . formatConfig ( host ) ; AvunaHTTPD . hosts . put ( key , h ) ; } catch ( Exception e ) { Logger . logError ( e ) ; continue ; } } } } ) ; AvunaHTTPD . hostsConfig . load ( ) ; AvunaHTTPD . hostsConfig . save ( ) ; AvunaHTTPD . setupFolders ( ) ; File lf = new File ( AvunaHTTPD . fileManager . getLogs ( ) , ( "" + ( ( System . currentTimeMillis ( ) ) // 1000L ) ) ) ; lf . createNewFile ( ) ; Logger . INSTANCE = new Logger ( new PrintStream ( new FileOutputStream ( lf ) ) ) ; Logger . log ( "Loaded<seq2seq4repair_space>Configs" ) ; for ( Host host : AvunaHTTPD . hosts . values ( ) ) { if ( host instanceof HostHTTP ) { ( ( HostHTTP ) ( host ) ) . loadBases ( ) ; } } if ( unpack ) { Logger . log ( "Unpack<seq2seq4repair_space>complete,<seq2seq4repair_space>terminating." ) ; Logger . flush ( ) ; System . exit ( 0 ) ; } Logger . log ( "Loading<seq2seq4repair_space>Connection<seq2seq4repair_space>Handling" ) ; for ( Host h : AvunaHTTPD . hosts . values ( ) ) { if ( ! ( h . hasStarted ( ) ) ) h . start ( ) ; } if ( ( ! ( AvunaHTTPD . windows ) ) && ( AvunaHTTPD . mainConfig . getNode ( "safeMode" ) . getValue ( ) . equals ( "true" ) ) ) { <START_BUG> SafeMode . setPerms ( cfg . getParentFile ( ) , Integer . parseInt ( AvunaHTTPD . mainConfig . getNode ( "uid" ) . getValue ( ) ) , Integer . parseInt ( AvunaHTTPD . mainConfig . getNode ( "gid" ) . getValue ( ) ) ) ; <END_BUG> } if ( ( ( ! ( AvunaHTTPD . windows ) ) && ( ( CLib . getuid ( ) ) == 0 ) ) && ( ! ( AvunaHTTPD . mainConfig . getNode ( "uid" ) . getValue ( ) . equals ( "0" ) ) ) ) { major : while ( true ) { for ( Host h : AvunaHTTPD . hosts . values ( ) ) { if ( ! ( h . loaded ) ) { Thread . sleep ( 1L ) ; continue major ; } } break ; } CLib . setuid ( Integer . parseInt ( AvunaHTTPD . mainConfig . getNode ( "uid" ) . getValue ( ) ) ) ; CLib . setgid ( Integer . parseInt ( AvunaHTTPD . mainConfig . getNode ( "gid" ) . getValue ( ) ) ) ; Logger . log ( ( "[NOTIFY]<seq2seq4repair_space>De-escalated<seq2seq4repair_space>to<seq2seq4repair_space>uid<seq2seq4repair_space>" + ( CLib . getuid ( ) ) ) ) ; } else if ( ! ( AvunaHTTPD . windows ) ) { Logger . log ( ( "[NOTIFY]<seq2seq4repair_space>We<seq2seq4repair_space>did<seq2seq4repair_space>NOT<seq2seq4repair_space>de-escalate,<seq2seq4repair_space>currently<seq2seq4repair_space>running<seq2seq4repair_space>as<seq2seq4repair_space>uid<seq2seq4repair_space>" + ( CLib . getuid ( ) ) ) ) ; } for ( Host host : AvunaHTTPD . hosts . values ( ) ) { if ( host instanceof HostHTTP ) { ( ( HostHTTP ) ( host ) ) . loadCustoms ( ) ; } } Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { public void run ( ) { Logger . log ( "Softly<seq2seq4repair_space>Terminating!" ) ; for ( Host h : AvunaHTTPD . hosts . values ( ) ) { h . preExit ( ) ; } Logger . flush ( ) ; } } ) ; for ( Host host : AvunaHTTPD . hosts . values ( ) ) { if ( host instanceof HostHTTP ) { ( ( HostHTTP ) ( host ) ) . postload ( ) ; } }

Fix:
SafeMode . recurPerms ( cfg . getParentFile ( ) , Integer . parseInt ( AvunaHTTPD . mainConfig . getNode ( "uid" ) . getValue ( ) ) , Integer . parseInt ( AvunaHTTPD . mainConfig . getNode ( "gid" ) . getValue ( ) ) ) ;