*/
#include "includes.h"
+#include "system/passwd.h" /* uid_wrapper */
#include "system/filesys.h"
#include "printing.h"
#include "util_tdb.h"
struct tdb_print_db *get_print_db_byname(const char *printername)
{
struct tdb_print_db *p = NULL, *last_entry = NULL;
- int num_open = 0;
+ size_t num_open = 0;
char *printdb_path = NULL;
bool done_become_root = False;
+ char *print_cache_path;
+ int ret;
SMB_ASSERT(printername != NULL);
if (p->ref_count)
continue;
if (p->tdb) {
- if (tdb_close(print_db_head->tdb)) {
+ if (tdb_close(p->tdb)) {
DEBUG(0,("get_print_db: Failed to close tdb for printer %s\n",
- print_db_head->printer_name ));
+ p->printer_name ));
return NULL;
}
}
DLIST_ADD(print_db_head, p);
}
- if (asprintf(&printdb_path, "%s%s.tdb",
- cache_path("printing/"),
- printername) < 0) {
+ print_cache_path = cache_path(talloc_tos(), "printing/");
+ if (print_cache_path == NULL) {
+ DLIST_REMOVE(print_db_head, p);
+ SAFE_FREE(p);
+ return NULL;
+ }
+ ret = asprintf(&printdb_path, "%s%s.tdb",
+ print_cache_path, printername);
+ TALLOC_FREE(print_cache_path);
+ if (ret < 0) {
DLIST_REMOVE(print_db_head, p);
SAFE_FREE(p);
return NULL;
for( i = 0; i < data.dsize; i += 8) {
pid_t pid = (pid_t)IVAL(data.dptr, i);
- if (pid == sys_getpid())
+ if (pid == getpid())
continue;
/* Entry is dead if process doesn't exist or refcount is zero. */