#define NOTIFY_PID_LIST_KEY "NOTIFY_PID_LIST"
-static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb)
+static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb, BOOL cleanlist)
{
TDB_DATA data;
size_t i;
}
if (data.dsize % 8) {
- DEBUG(0,("get_pid_list: Size of record for printer %s not a multiple of 8 !\n",
+ DEBUG(0,("get_printer_notify_pid_list: Size of record for printer %s not a multiple of 8 !\n",
pdb->printer_name ));
tdb_delete_by_string(pdb->tdb, NOTIFY_PID_LIST_KEY );
ZERO_STRUCT(data);
return data;
}
+ if (!cleanlist)
+ return data;
+
/*
* Weed out all dead entries.
*/
- for( i = 0; i < data.dsize; ) {
+ for( i = 0; i < data.dsize; i += 8) {
pid_t pid = (pid_t)IVAL(data.dptr, i);
if (pid == sys_getpid())
/* Entry is dead if process doesn't exist or refcount is zero. */
- if ((IVAL(data.dptr, i + 4) == 0) || !process_exists(pid)) {
+ while ((i < data.dsize) && ((IVAL(data.dptr, i + 4) == 0) || !process_exists(pid))) {
/* Refcount == zero is a logic error and should never happen. */
if (IVAL(data.dptr, i + 4) == 0) {
- DEBUG(0,("get_pid_list: Refcount == 0 for pid = %u printer %s !\n",
+ DEBUG(0,("get_printer_notify_pid_list: Refcount == 0 for pid = %u printer %s !\n",
(unsigned int)pid, pdb->printer_name ));
}
if (data.dsize - i > 8)
memmove( &data.dptr[i], &data.dptr[i+8], data.dsize - i - 8);
data.dsize -= 8;
- continue;
}
-
- i += 8;
}
return data;
if (!pdb)
return False;
- if (tdb_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ if (tdb_read_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
DEBUG(0,("print_notify_pid_list: Failed to lock printer %s database\n", printername));
release_print_db(pdb);
return False;
}
- data = get_printer_notify_pid_list( pdb );
+ data = get_printer_notify_pid_list( pdb, True );
if (!data.dptr) {
ret = True;
done:
- tdb_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY);
+ tdb_read_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY);
release_print_db(pdb);
SAFE_FREE(data.dptr);
return ret;
return False;
}
- data = get_printer_notify_pid_list( pdb );
+ data = get_printer_notify_pid_list( pdb, True );
/* Add ourselves and increase the refcount. */
return False;
}
- data = get_printer_notify_pid_list( pdb );
+ data = get_printer_notify_pid_list( pdb, True );
/* Reduce refcount. Remove ourselves if zero. */
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
DEBUG(3, ("delete denied by security descriptor\n"));
*errcode = WERR_ACCESS_DENIED;
+
+ /* BEGIN_ADMIN_LOG */
+ sys_adminlog( LOG_ERR, (char *)
+ "Permission denied-- user not allowed to delete, \
+pause, or resume print job. User name: %s. Printer name: %s.",
+ uidtoname(user->uid), PRINTERNAME(snum) );
+ /* END_ADMIN_LOG */
+
return False;
}
if (!is_owner(user, snum, jobid) &&
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
DEBUG(3, ("pause denied by security descriptor\n"));
+
+ /* BEGIN_ADMIN_LOG */
+ sys_adminlog( LOG_ERR, (char *)
+ "Permission denied-- user not allowed to delete, \
+pause, or resume print job. User name: %s. Printer name: %s.",
+ uidtoname(user->uid), PRINTERNAME(snum) );
+ /* END_ADMIN_LOG */
+
*errcode = WERR_ACCESS_DENIED;
return False;
}
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
DEBUG(3, ("resume denied by security descriptor\n"));
*errcode = WERR_ACCESS_DENIED;
+
+ /* BEGIN_ADMIN_LOG */
+ sys_adminlog( LOG_ERR, (char *)
+ "Permission denied-- user not allowed to delete, \
+pause, or resume print job. User name: %s. Printer name: %s.",
+ uidtoname(user->uid), PRINTERNAME(snum) );
+ /* END_ADMIN_LOG */
return False;
}