/*********************************************************** Write entries from stdin to current local idmap **********************************************************/ static int net_idmap_restore(int argc, const char **argv) { if (!idmap_init(lp_idmap_backend())) { d_fprintf(stderr, "Could not init idmap\n"); return -1; } while (!feof(stdin)) { fstring line, sid_string, fmt_string; int len; unid_t id; int type = ID_EMPTY; DOM_SID sid; if (fgets(line, sizeof(line)-1, stdin) == NULL) break; len = strlen(line); if ( (len > 0) && (line[len-1] == '\n') ) line[len-1] = '\0'; /* Yuck - this is broken for sizeof(gid_t) != sizeof(int) */ snprintf(fmt_string, sizeof(fmt_string), "GID %%d %%%us", FSTRING_LEN); if (sscanf(line, fmt_string, &id.gid, sid_string) == 2) { type = ID_GROUPID; } /* Yuck - this is broken for sizeof(uid_t) != sizeof(int) */ snprintf(fmt_string, sizeof(fmt_string), "UID %%d %%%us", FSTRING_LEN); if (sscanf(line, fmt_string, &id.uid, sid_string) == 2) { type = ID_USERID; } if (type == ID_EMPTY) { d_printf("ignoring invalid line [%s]\n", line); continue; } if (!string_to_sid(&sid, sid_string)) { d_printf("ignoring invalid sid [%s]\n", sid_string); continue; } if (!NT_STATUS_IS_OK(idmap_set_mapping(&sid, id, type))) { d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s\n", (type == ID_GROUPID) ? "GID" : "UID", (type == ID_GROUPID) ? (unsigned long)id.gid: (unsigned long)id.uid, sid_string_static(&sid)); continue; } } idmap_close(); return NT_STATUS_IS_OK(net_idmap_fixup_hwm()) ? 0 : -1; }
static void terminate(void) { pstring path; idmap_close(); /* Remove socket file */ pstr_sprintf(path, "%s/%s", WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME); unlink(path); exit(0); }
static void terminate(bool is_parent) { if (is_parent) { /* When parent goes away we should * remove the socket file. Not so * when children terminate. */ char *path = NULL; if (asprintf(&path, "%s/%s", get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME) > 0) { unlink(path); SAFE_FREE(path); } } idmap_close(); trustdom_cache_shutdown(); gencache_stabilize(); #if 0 if (interactive) { TALLOC_CTX *mem_ctx = talloc_init("end_description"); char *description = talloc_describe_all(mem_ctx); DEBUG(3, ("tallocs left:\n%s\n", description)); talloc_destroy(mem_ctx); } #endif if (is_parent) { struct messaging_context *msg = winbind_messaging_context(); struct server_id self = messaging_server_id(msg); serverid_deregister(self); pidfile_unlink(lp_piddir(), "winbindd"); } exit(0); }