Skip to content

Commit

Permalink
Fix setting groups via web ui
Browse files Browse the repository at this point in the history
The template is generated incorrectly, so when form data are sent via
POST, it does not contain new values for groups to save.

Additionally, set the default value to none and make sure the code does
not take the value as a bad value.
  • Loading branch information
zdohnal committed Mar 19, 2024
1 parent cf6c821 commit 916ca81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pappl/system-webif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,15 +1421,15 @@ _papplSystemWebSecurity(

if ((group = cupsGetOption("admin_group", num_form, form)) != NULL)
{
if (getgrnam_r(group, &grpbuf, buffer, sizeof(buffer), &grp) || !grp)
if (strcmp(group, "") && (getgrnam_r(group, &grpbuf, buffer, sizeof(buffer), &grp) || !grp))
status = _PAPPL_LOC("Bad administration group.");
else
papplSystemSetAdminGroup(system, group);
}

if ((group = cupsGetOption("print_group", num_form, form)) != NULL)
{
if (getgrnam_r(group, &grpbuf, buffer, sizeof(buffer), &grp) || !grp)
if (strcmp(group, "") && (getgrnam_r(group, &grpbuf, buffer, sizeof(buffer), &grp) || !grp))
{
status = _PAPPL_LOC("Bad print group.");
}
Expand Down Expand Up @@ -1471,7 +1471,7 @@ _papplSystemWebSecurity(
papplClientHTMLPrintf(client,
" <table class=\"form\">\n"
" <tbody>\n"
" <tr><th><label for=\"admin_group\">%s:</label></th><td><select name\"admin_group\"><option value=\"\">%s</option>", papplClientGetLocString(client, _PAPPL_LOC("Admin Group")), papplClientGetLocString(client, _PAPPL_LOC("None")));
" <tr><th><label for=\"admin_group\">%s:</label></th><td><select name=\"admin_group\"><option value=\"\">%s</option>", papplClientGetLocString(client, _PAPPL_LOC("Admin Group")), papplClientGetLocString(client, _PAPPL_LOC("None")));

setgrent();
while ((grp = getgrent()) != NULL)
Expand All @@ -1481,7 +1481,7 @@ _papplSystemWebSecurity(

papplClientHTMLPrintf(client,
"</select></td></tr>\n"
" <tr><th><label for=\"print_group\">%s:</label></th><td><select name\"print_group\"><option value=\"\">%s</option>", papplClientGetLocString(client, _PAPPL_LOC("Print Group")), papplClientGetLocString(client, _PAPPL_LOC("None")));
" <tr><th><label for=\"print_group\">%s:</label></th><td><select name=\"print_group\"><option value=\"\">%s</option>", papplClientGetLocString(client, _PAPPL_LOC("Print Group")), papplClientGetLocString(client, _PAPPL_LOC("None")));

setgrent();
while ((grp = getgrent()) != NULL)
Expand Down

0 comments on commit 916ca81

Please sign in to comment.