Hide non-allowed commands

SVN revision: 277
This commit is contained in:
Stefan Ritt 2002-11-05 15:40:58 +00:00
parent dfec9f845c
commit 0c43f301db

46
elogd.c
View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 2.94 2002/11/05 15:40:58 midas
Hide non-allowed commands
Revision 2.93 2002/11/05 15:14:37 midas Revision 2.93 2002/11/05 15:14:37 midas
Move whole thread on re-submission of individual entry Move whole thread on re-submission of individual entry
@ -1352,6 +1355,7 @@ static char old_language[256];
} while (p && *p); } while (p && *p);
porig[n] = NULL; porig[n] = NULL;
ptrans[n] = NULL;
} }
strcpy(old_language, language); strcpy(old_language, language);
@ -1706,7 +1710,7 @@ int eli_compare(const void *e1, const void *e2)
if (((EL_INDEX *)e1)->file_time < ((EL_INDEX *)e2)->file_time) if (((EL_INDEX *)e1)->file_time < ((EL_INDEX *)e2)->file_time)
return -1; return -1;
if (((EL_INDEX *)e1)->file_time > ((EL_INDEX *)e2)->file_time) if (((EL_INDEX *)e1)->file_time >= ((EL_INDEX *)e2)->file_time)
return 1; return 1;
return 0; return 0;
} }
@ -4184,10 +4188,17 @@ int i, n;
break; break;
if (i<n) if (i<n)
return FALSE;
}
/* check admin command */
if (equal_ustring(command, "Admin"))
{ {
sprintf(str, loc("Error: Command \"<b>%s</b>\" is not allowed for user \"<b>%s</b>\""), if (getcfg(lbs->name, "Admin user", str))
command, getparam("full_name")); {
show_error(str); if (strstr(str, getparam("unm")) != 0)
return TRUE;
else
return FALSE; return FALSE;
} }
} }
@ -4203,10 +4214,6 @@ int i, n;
if (equal_ustring(list[i], getparam("unm"))) if (equal_ustring(list[i], getparam("unm")))
return TRUE; return TRUE;
sprintf(str, loc("Error: Command \"<b>%s</b>\" is not allowed for user \"<b>%s</b>\""),
command, getparam("full_name"));
show_error(str);
return FALSE; return FALSE;
} }
@ -7270,19 +7277,9 @@ MSG_LIST *msg_list;
strcpy(menu_str, "New, Find, Select, "); strcpy(menu_str, "New, Find, Select, ");
if (getcfg(lbs->name, "Password file", str)) if (getcfg(lbs->name, "Password file", str))
{ strcat(menu_str, "Admin, Config, Logout, ");
if (getcfg(lbs->name, "Admin user", str) &&
strstr(str, getparam("unm")) != 0)
{
strcat(menu_str, "Admin");
strcat(menu_str, ", ");
}
strcat(menu_str, "Config, Logout, ");
}
else else
{
strcat(menu_str, "Config, "); strcat(menu_str, "Config, ");
}
strcat(menu_str, "Last x, Help"); strcat(menu_str, "Last x, Help");
} }
@ -7292,6 +7289,8 @@ MSG_LIST *msg_list;
if (atoi(gt("Use buttons")) == 1) if (atoi(gt("Use buttons")) == 1)
{ {
for (i=0 ; i<n ; i++) for (i=0 ; i<n ; i++)
{
if (allow_user(lbs, menu_item[i]))
{ {
if (equal_ustring(menu_item[i], "Last x")) if (equal_ustring(menu_item[i], "Last x"))
{ {
@ -7313,11 +7312,14 @@ MSG_LIST *msg_list;
rsprintf("<input type=submit name=cmd value=\"%s\">\n", loc(menu_item[i])); rsprintf("<input type=submit name=cmd value=\"%s\">\n", loc(menu_item[i]));
} }
} }
}
else else
{ {
rsprintf("<small>\n"); rsprintf("<small>\n");
for (i=0 ; i<n ; i++) for (i=0 ; i<n ; i++)
{
if (allow_user(lbs, menu_item[i]))
{ {
if (equal_ustring(menu_item[i], "Last x")) if (equal_ustring(menu_item[i], "Last x"))
{ {
@ -7368,6 +7370,7 @@ MSG_LIST *msg_list;
rsprintf("&nbsp;<a href=\"?cmd=%s\">%s</a>&nbsp;\n", str, loc(menu_item[i])); rsprintf("&nbsp;<a href=\"?cmd=%s\">%s</a>&nbsp;\n", str, loc(menu_item[i]));
} }
} }
}
rsprintf("</small>\n"); rsprintf("</small>\n");
} }
@ -9858,7 +9861,12 @@ FILE *f;
/* check if command allowed for current user */ /* check if command allowed for current user */
if (!allow_user(lbs, command)) if (!allow_user(lbs, command))
{
sprintf(str, loc("Error: Command \"<b>%s</b>\" is not allowed for user \"<b>%s</b>\""),
command, getparam("full_name"));
show_error(str);
return; return;
}
/*---- check for various commands --------------------------------*/ /*---- check for various commands --------------------------------*/