newbie warnings for files readable to others

This commit is contained in:
joonicks
2018-04-16 22:21:26 +02:00
parent 33f72e424b
commit a77a17161c
3 changed files with 45 additions and 11 deletions

7
.gitignore vendored
View File

@@ -23,14 +23,9 @@ trivia/mkindex
# mech typical user config files
*~
*.bak
mech.passwd
mech.conf
mech.users
mech.pid
mech.session
mech.*
root.zone*
trick.conf
mech.trivscore
trivia/megatrivia.txt
*.log
*.stats

View File

@@ -1,5 +1,6 @@
3.1 -- WORK IN PROGRESS (~April, 2018)
* Added: Newbie mode warnings about config/userfiles readable by others (exposing passwords)
* Fixed: Issue #25, clients lost when doing reset, no more
* Fixed: compiler warnings and missing defines/conflicting defines with certain options
* Added: configure now saves the options selected in ./myconfig for later re-use

View File

@@ -1066,6 +1066,27 @@ int main(int argc, char **argv, char **envp)
to_file(1,TEXT_HDR_FEAT,__mx_opts);
}
#ifdef NEWBIE
if (stat(configfile,&st));
{
if ((st.st_mode & (S_IWGRP|S_IWOTH)) != 0)
{
to_file(1,"error: configfile is writeable by others, exiting...\n");
_exit(0);
}
if ((st.st_mode & (S_IRGRP|S_IROTH)) != 0)
to_file(1,"warning: configfile is readable by others\n");
}
if (stat(".",&st));
{
if ((st.st_mode & (S_IWGRP|S_IWOTH)) != 0)
{
to_file(1,"error: energymech home directory is writeable by others, exiting...\n");
_exit(0);
}
}
#endif /* NEWBIE */
if (versiononly)
_exit(0); /* _exit() here because we dont want a profile file to be written */
@@ -1117,8 +1138,23 @@ int main(int argc, char **argv, char **envp)
for(current=botlist;current;current=current->next)
{
if ((opt = current->setting[STR_USERFILE].str_var))
#ifndef NEWBIE
read_userlist(opt);
#ifdef NEWBIE
}
#else
{
if (stat(opt,&st));
{
if ((st.st_mode & (S_IWGRP|S_IWOTH)) != 0)
{
to_file(1,"error: userfile(%s) is writeable by others, exiting...\n",opt);
_exit(0);
}
if ((st.st_mode & (S_IRGRP|S_IROTH)) != 0)
to_file(1,"warning: userfile(%s) is readable by others\n",opt);
}
read_userlist(opt);
}
if (current->userlist == NULL)
{
to_file(1,"init: No userlist loaded for %s\n",nullstr(current->nick));
@@ -1129,9 +1165,8 @@ int main(int argc, char **argv, char **envp)
{
_exit(1);
}
#else
}
#endif /* NEWBIE */
for(current=botlist;current;current=current->next)
{
mirror_userlist();
@@ -1143,7 +1178,7 @@ int main(int argc, char **argv, char **envp)
if (!mechresetenv)
to_file(1,INFO_RUNNING);
if (do_fork)
if (do_fork && startup != 666)
{
close(0);
close(1);
@@ -1205,7 +1240,10 @@ int main(int argc, char **argv, char **envp)
#endif
if (startup == 666)
exit(0);
{
to_file(1,"init: test run completed, exiting...\n");
_exit(0);
}
startup = FALSE;
doit();
}