mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-29 16:14:43 +00:00
37
src/user.c
37
src/user.c
@@ -298,22 +298,34 @@ int read_userlist(char *filename)
|
|||||||
int r;
|
int r;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (!filename)
|
||||||
|
{
|
||||||
|
debug("(read_userlist) filename is NULL\n");
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if (*filename == '<') // read only userfile
|
||||||
|
filename++;
|
||||||
|
if ((r = is_safepath(filename,FILE_MUST_EXIST)) != FILE_IS_SAFE)
|
||||||
|
{
|
||||||
|
debug("(read_userlist) %s: unsafe filename (%i)...\n",filename,r);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
if ((in = open(filename,O_RDONLY)) < 0)
|
||||||
|
{
|
||||||
|
debug("(read_userlist) failed to open \"%s\": %s\n",filename,strerror(errno));
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
if (*filename == '<') // read only userfile
|
if (*filename == '<') // read only userfile
|
||||||
filename++;
|
filename++;
|
||||||
#ifdef DEBUG
|
|
||||||
if ((r = is_safepath(filename,FILE_MUST_EXIST)) != FILE_IS_SAFE)
|
|
||||||
{
|
|
||||||
debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (is_safepath(filename,FILE_MUST_EXIST) != FILE_IS_SAFE)
|
if (is_safepath(filename,FILE_MUST_EXIST) != FILE_IS_SAFE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
#endif
|
|
||||||
if ((in = open(filename,O_RDONLY)) < 0)
|
if ((in = open(filename,O_RDONLY)) < 0)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
#endif
|
||||||
|
|
||||||
olduserlist = current->userlist;
|
olduserlist = current->userlist;
|
||||||
cfgUser = current->userlist = NULL;
|
cfgUser = current->userlist = NULL;
|
||||||
@@ -369,23 +381,20 @@ int write_userlist(char *filename)
|
|||||||
if (!current->ul_save)
|
if (!current->ul_save)
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
||||||
if (*filename == '<') // we dont write to read only userfiles
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
if (*filename == '<') // we dont write to read only userfiles
|
||||||
{
|
{
|
||||||
debug("(write_userlist) %s: writing to read only userfile is prohibited...\n",filename);
|
debug("(write_userlist) %s: writing to read only userfile is prohibited...\n",filename);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return(FALSE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if ((r = is_safepath(filename,FILE_MAY_EXIST)) != FILE_IS_SAFE)
|
if ((r = is_safepath(filename,FILE_MAY_EXIST)) != FILE_IS_SAFE)
|
||||||
{
|
{
|
||||||
debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r);
|
debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
if (*filename == '<') // we dont write to read only userfiles
|
||||||
|
return(FALSE);
|
||||||
if (is_safepath(filename,FILE_MAY_EXIST) != FILE_IS_SAFE)
|
if (is_safepath(filename,FILE_MAY_EXIST) != FILE_IS_SAFE)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user