Skip to content

Commit

Permalink
Mirror changes from v1.4.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Sep 11, 2024
1 parent 651a37c commit b64c858
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
17 changes: 16 additions & 1 deletion pappl/client-auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,27 @@ http_status_t // O - HTTP status
papplClientIsAuthorized(
pappl_client_t *client) // I - Client
{
char admin_group[256]; // Admin group name
gid_t admin_gid; // Admin group ID


// Range check input...
if (!client)
return (HTTP_STATUS_BAD_REQUEST);

// Authorize for admin access...
return (_papplClientIsAuthorizedForGroup(client, false, client->system->admin_group, client->system->admin_gid));
_papplRWLockRead(client->system);

if (client->system->admin_group)
cupsCopyString(admin_group, client->system->admin_group, sizeof(admin_group));
else
admin_group[0] = '\0';

admin_gid = client->system->admin_gid;

_papplRWUnlock(client->system);

return (_papplClientIsAuthorizedForGroup(client, false, admin_group, admin_gid));
}


Expand Down
4 changes: 4 additions & 0 deletions pappl/job-ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,9 +1393,13 @@ ipp_get_job_attributes(

papplClientRespondIPP(client, IPP_STATUS_OK, NULL);

_papplRWLockRead(job);

ra = ippCreateRequestedArray(client->request);
_papplJobCopyAttributesNoLock(job, client, ra, /*include_status*/true);
cupsArrayDelete(ra);

_papplRWUnlock(job);
}


Expand Down
7 changes: 7 additions & 0 deletions pappl/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ _papplJobSubmitFile(
_pappl_doc_t *doc; // Document


_papplRWLockWrite(job);

if (job->num_documents >= _PAPPL_MAX_DOCUMENTS)
goto abort_job;

Expand Down Expand Up @@ -954,11 +956,14 @@ _papplJobSubmitFile(
if (job->printer->output_devices)
job->state_reasons |= PAPPL_JREASON_JOB_FETCHABLE;

_papplRWUnlock(job);
_papplRWLockWrite(job->printer);
_papplPrinterCheckJobsNoLock(job->printer);
_papplRWUnlock(job->printer);
return;
}

_papplRWUnlock(job);
return;
}

Expand All @@ -975,6 +980,8 @@ _papplJobSubmitFile(
job->state = IPP_JSTATE_ABORTED;
job->completed = time(NULL);

_papplRWUnlock(job);

if (!strncmp(filename, job->system->directory, dirlen) && filename[dirlen] == '/')
unlink(filename);

Expand Down
13 changes: 4 additions & 9 deletions pappl/system-accessors.c
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,9 @@ papplSystemSetAdminGroup(
// - `HTTP_STATUS_FORBIDDEN` if the authentication succeeded but the user is
// not part of the specified group.
//
// > Note: The authentication callback can only be set prior to calling
// > @link papplSystemRun@.
//

void
papplSystemSetAuthCallback(
Expand All @@ -1734,16 +1737,12 @@ papplSystemSetAuthCallback(
pappl_auth_cb_t auth_cb, // I - Callback function
void *auth_cbdata) // I - Callback data
{
if (system)
if (system && !system->is_running)
{
_papplRWLockWrite(system);

free(system->auth_scheme);
system->auth_scheme = auth_scheme ? strdup(auth_scheme) : NULL;
system->auth_cb = auth_cb;
system->auth_cbdata = auth_cbdata;

_papplRWUnlock(system);
}
}

Expand Down Expand Up @@ -1898,12 +1897,8 @@ papplSystemSetFooterHTML(
{
if (system && html && !system->is_running)
{
_papplRWLockWrite(system);

free(system->footer_html);
system->footer_html = strdup(html);

_papplRWUnlock(system);
}
}

Expand Down

0 comments on commit b64c858

Please sign in to comment.