From 0ac2b380018bd50eaaf6d6bcfbb6e949b85a6601 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 6 Apr 2003 09:35:16 +0000 Subject: This commit make winbindd copy winbindd_idmap.tdb into idmap.tdb on the first run if idmap.tdb is not found, and then eventually convert it to the new format. This is done to unify winbind and idmap databases and to make a backup of winbindd_idmap.tdb in case you want to downgrade (of course it will not be updated). This is needed because idmap.tdb contains also local mappings, not only foreign domains mappings. Added some other fixes/improvements Simo. (This used to be commit cf17261519fd8775500f9b9d6caa2bc462e04633) --- source3/nsswitch/winbindd_idmap_tdb.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'source3/nsswitch') diff --git a/source3/nsswitch/winbindd_idmap_tdb.c b/source3/nsswitch/winbindd_idmap_tdb.c index b47b7ed07d..12d6972bae 100644 --- a/source3/nsswitch/winbindd_idmap_tdb.c +++ b/source3/nsswitch/winbindd_idmap_tdb.c @@ -106,7 +106,7 @@ static int tdb_convert_fn(TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data, /***************************************************************************** Convert the idmap database from an older version. *****************************************************************************/ -static BOOL tdb_idmap_convert(const char *idmap_name) +static BOOL tdb_idmap_convert(void) { int32 vers = tdb_fetch_int32(idmap_tdb, "IDMAP_VERSION"); BOOL bigendianheader = @@ -280,8 +280,27 @@ static BOOL tdb_get_id_from_sid(DOM_SID * sid, uid_t * id, BOOL isgroup) *****************************************************************************/ static BOOL tdb_idmap_init(void) { + SMB_STRUCT_STAT stbuf; + + /* move to the new database on first startup */ + if (!file_exist(lock_path("idmap.tdb"), &stbuf)) { + if (file_exist(lock_path("winbindd_idmap.tdb"), &stbuf)) { + char *cmd = NULL; + + /* lazy file copy */ + if (asprintf(&cmd, "cp -p %s/winbindd_idmap.tdb %s/idmap.tdb", lp_lockdir(), lp_lockdir()) != -1) { + system(cmd); + free(cmd); + } + if (!file_exist(lock_path("idmap.tdb"), &stbuf)) { + DEBUG(0, ("idmap_init: Unable to make a new database copy\n")); + return False; + } + } + } + /* Open tdb cache */ - if (!(idmap_tdb = tdb_open_log(lock_path("winbindd_idmap.tdb"), 0, + if (!(idmap_tdb = tdb_open_log(lock_path("idmap.tdb"), 0, TDB_DEFAULT, O_RDWR | O_CREAT, 0600))) { DEBUG(0, @@ -290,9 +309,8 @@ static BOOL tdb_idmap_init(void) } /* possibly convert from an earlier version */ - if (!tdb_idmap_convert(lock_path("winbindd_idmap.tdb"))) { - DEBUG(0, - ("winbindd_idmap_init: Unable to open idmap database\n")); + if (!tdb_idmap_convert()) { + DEBUG(0, ("winbindd_idmap_init: Unable to open idmap database\n")); return False; } -- cgit From 25b1c37f6f67570dcfaff6081a74114d172dde1b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 7 Apr 2003 06:13:36 +0000 Subject: Remove duplicate "tallocdump" message from tdb messaging system. The same functionality exists as "pool-usage". Move initialisation of this and dmalloc messages inside message_init(). (This used to be commit af6ecafcbbf65dbedc49b3a86da39ce608bdadac) --- source3/nsswitch/winbindd.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'source3/nsswitch') diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index cd72a4f572..5cdddb6222 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -52,25 +52,6 @@ static BOOL reload_services_file(BOOL test) return(ret); } -/******************************************************************* - Print out all talloc memory info. -********************************************************************/ - -void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len) -{ - TALLOC_CTX *ctx = talloc_init("info context"); - char *info = NULL; - - if (!ctx) - return; - - info = talloc_describe_all(ctx); - if (info) - DEBUG(10,(info)); - message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1: 0, True); - talloc_destroy(ctx); -} - #if DUMP_CORE /**************************************************************************** ** @@ -916,14 +897,12 @@ int main(int argc, char **argv) } poptFreeContext(pc); - register_msg_pool_usage(); - message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info); - /* Loop waiting for requests */ process_loop(); trustdom_cache_shutdown(); uni_group_cache_shutdown(); + return 0; } -- cgit From 69e41084b94ea90a70d507e570ca71eb82353ecb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 7 Apr 2003 06:43:16 +0000 Subject: privilaged -> privileged (This changes the location of the winbindd privileged pipe) (This used to be commit f111f10076c7797e5fd39edcc0aad7d860bb5ac5) --- source3/nsswitch/winbindd.c | 8 ++++---- source3/nsswitch/winbindd.h | 2 +- source3/nsswitch/winbindd_misc.c | 2 +- source3/nsswitch/winbindd_nss.h | 4 ++-- source3/nsswitch/winbindd_pam.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/nsswitch') diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 5cdddb6222..c096ca9b0f 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -287,7 +287,7 @@ static void process_request(struct winbindd_cli_state *state) /* Process a new connection by adding it to the client connection list */ -static void new_connection(int listen_sock, BOOL privilaged) +static void new_connection(int listen_sock, BOOL privileged) { struct sockaddr_un sunaddr; struct winbindd_cli_state *state; @@ -318,7 +318,7 @@ static void new_connection(int listen_sock, BOOL privilaged) state->last_access = time(NULL); - state->privilaged = privilaged; + state->privileged = privileged; /* Add to connection list */ @@ -639,7 +639,7 @@ static void process_loop(void) break; } } - /* new, non-privilaged connection */ + /* new, non-privileged connection */ new_connection(listen_sock, False); } @@ -653,7 +653,7 @@ static void process_loop(void) break; } } - /* new, privilaged connection */ + /* new, privileged connection */ new_connection(listen_priv_sock, True); } diff --git a/source3/nsswitch/winbindd.h b/source3/nsswitch/winbindd.h index 192b058871..2d9a0b5949 100644 --- a/source3/nsswitch/winbindd.h +++ b/source3/nsswitch/winbindd.h @@ -43,7 +43,7 @@ struct winbindd_cli_state { BOOL finished; /* Can delete from list */ BOOL write_extra_data; /* Write extra_data field */ time_t last_access; /* Time of last access (read or write) */ - BOOL privilaged; /* Is the client 'privilaged' */ + BOOL privileged; /* Is the client 'privileged' */ struct winbindd_request request; /* Request from client */ struct winbindd_response response; /* Respose to client */ diff --git a/source3/nsswitch/winbindd_misc.c b/source3/nsswitch/winbindd_misc.c index 3b44d029c0..52889e85d4 100644 --- a/source3/nsswitch/winbindd_misc.c +++ b/source3/nsswitch/winbindd_misc.c @@ -239,7 +239,7 @@ enum winbindd_result winbindd_netbios_name(struct winbindd_cli_state *state) enum winbindd_result winbindd_priv_pipe_dir(struct winbindd_cli_state *state) { - DEBUG(3, ("[%5d]: request location of privilaged pipe\n", state->pid)); + DEBUG(3, ("[%5d]: request location of privileged pipe\n", state->pid)); state->response.extra_data = strdup(get_winbind_priv_pipe_dir()); if (!state->response.extra_data) diff --git a/source3/nsswitch/winbindd_nss.h b/source3/nsswitch/winbindd_nss.h index 88f4a11f87..cc1b144063 100644 --- a/source3/nsswitch/winbindd_nss.h +++ b/source3/nsswitch/winbindd_nss.h @@ -30,7 +30,7 @@ #define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */ #define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */ -#define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privilaged" /* name of subdirectory of lp_lockdir() to hold the 'privilaged' pipe */ +#define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */ #define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */ #define WINBINDD_DONT_ENV "_NO_WINBINDD" @@ -105,7 +105,7 @@ enum winbindd_cmd { WINBINDD_NETBIOS_NAME, /* The netbios name of the server */ /* Placeholder for end of cmd list */ - /* find the location of our privilaged pipe */ + /* find the location of our privileged pipe */ WINBINDD_PRIV_PIPE_DIR, WINBINDD_NUM_CMDS diff --git a/source3/nsswitch/winbindd_pam.c b/source3/nsswitch/winbindd_pam.c index e65d2bb0f6..e49a95f4b8 100644 --- a/source3/nsswitch/winbindd_pam.c +++ b/source3/nsswitch/winbindd_pam.c @@ -179,8 +179,8 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state) DATA_BLOB lm_resp, nt_resp; - if (!state->privilaged) { - DEBUG(2, ("winbindd_pam_auth_crap: non-privilaged access denied!\n")); + if (!state->privileged) { + DEBUG(2, ("winbindd_pam_auth_crap: non-privileged access denied!\n")); /* send a better message than ACCESS_DENIED */ push_utf8_fstring(state->response.data.auth.error_string, "winbind client not authorized to use winbindd_pam_auth_crap"); result = NT_STATUS_ACCESS_DENIED; -- cgit From 6254b9bd4422ad142625784bc99e72c2385918eb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 7 Apr 2003 07:12:25 +0000 Subject: Create a pidfile, even when running in interactive mode. (This used to be commit 1d7400e679df136f03daf79788ea998c5a787f89) --- source3/nsswitch/winbindd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/nsswitch') diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index c096ca9b0f..eb8a36af55 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -866,11 +866,10 @@ int main(int argc, char **argv) if (!init_names()) exit(1); - if (!interactive) { + if (!interactive) become_daemon(Fork); - pidfile_create("winbindd"); - } + pidfile_create("winbindd"); #if HAVE_SETPGID /* -- cgit