+ new Launcher().boot(in);
+ }
+
+ Server s;
+
+ GigiConfig conf;
+
+ private boolean isSystemPort(int port) {
+ return 1 <= port && port <= 1024;
+ }
+
+ public synchronized void boot(InputStream in) throws Exception {
+ Locale.setDefault(Locale.ENGLISH);
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ HttpURLConnection.setFollowRedirects(false);
+
+ conf = GigiConfig.parse(in);
+ ServerConstants.init(conf.getMainProps());
+ initEmails(conf);
+
+ s = new Server();
+
+ initConnectors();
+ initHandlers();
+
+ s.start();
+ if ((isSystemPort(ServerConstants.getSecurePort()) || isSystemPort(ServerConstants.getPort())) && !System.getProperty("os.name").toLowerCase().contains("win")) {
+ String uid_s = conf.getMainProps().getProperty("gigi.uid", Integer.toString(65536 - 2));
+ String gid_s = conf.getMainProps().getProperty("gigi.gid", Integer.toString(65536 - 2));
+ try {
+ int uid = Integer.parseInt(uid_s);
+ int gid = Integer.parseInt(gid_s);
+ if (uid == -1 && gid == -1) {
+ // skip setuid step
+ } else if (uid > 0 && gid > 0 && uid < 65536 && gid < 65536) {
+ SetUID.Status status = new SetUID().setUid(uid, gid);
+ if ( !status.getSuccess()) {
+ Log.getLogger(Launcher.class).warn(status.getMessage());
+ }
+ } else {
+ Log.getLogger(Launcher.class).warn("Invalid uid or gid (must satisfy 0 < id < 65536)");
+ }
+ } catch (NumberFormatException e) {
+ Log.getLogger(Launcher.class).warn("Invalid gigi.uid or gigi.gid", e);
+ }