Skip to content
Commits on Source (2)
  • Andrew Price's avatar
    Improve mw.service · 285b561f
    Andrew Price authored
    - Run as mw:mw
    - Make systemd create and cleanup /var/run/mw for us
    - Correct the path to mwserv
    285b561f
  • Andrew Price's avatar
    Migrate folders to directories after setuid · 54027aa0
    Andrew Price authored
    Makes sure we don't create the directories with root ownership.
    
    Also make mwserv's stdout line buffered to work better with logging
    systems which capture stdout.
    54027aa0
......@@ -3,9 +3,10 @@ Description=Milliways server
After=network.target
[Service]
ExecStartPre=-/bin/mkdir /var/run/mw
ExecStartPre=/bin/chown -R mw:mw /var/run/mw
ExecStart=/usr/bin/mwserv --foreground --port 9999
User=mw
Group=mw
RuntimeDirectory=mw
ExecStart=/usr/lib/mw/mwserv --foreground --port 9999
[Install]
WantedBy=multi-user.target
......@@ -177,7 +177,11 @@ int main(int argc, char **argv)
}
}
if (!cfg_get_bool("foreground")) daemon(0, 0);
migrate_old_folders();
if (cfg_get_bool("foreground"))
setlinebuf(stdout);
else
daemon(0, 0);
uptime = time(0);
watch_mainsock(mainsock);
......
......@@ -597,7 +597,7 @@ static char *has_suffix(char *str, const char *suffix)
return NULL;
}
static void migrate_old_folders(void)
void migrate_old_folders(void)
{
int dfd;
DIR *dirp;
......@@ -682,8 +682,6 @@ static void migrate_old_folders(void)
void init_server()
{
migrate_old_folders();
INIT_LIST_HEAD(&connection_list);
if (pollfd == -1) {
pollfd = epoll_create(30);
......
......@@ -15,6 +15,7 @@ int msg_attach_to_userid(ipc_message_t *msg, uint32_t userposn);
int msg_attach_to_username(ipc_message_t *msg, const char *username);
void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude);
void msg_attach(ipc_message_t *msg, ipc_connection_t *conn);
void migrate_old_folders(void);
void init_server(void);
void send_error(ipc_connection_t *conn, ipc_message_t *orig, const char *format, ...);
void msg_apply_gag(struct user * from, ipc_message_t * msg, const char * field);
......