Changeset 988 for vendor/current/source3/winbindd/winbindd.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/winbindd/winbindd.c
r860 r988 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 … … 32 32 #include "../librpc/gen_ndr/srv_samr.h" 33 33 #include "secrets.h" 34 #include "rpc_client/cli_netlogon.h" 34 35 #include "idmap.h" 35 36 #include "lib/addrchange.h" … … 37 38 #include "auth.h" 38 39 #include "messages.h" 40 #include "../lib/util/pidfile.h" 41 #include "util_cluster.h" 42 #include "source4/lib/messaging/irpc.h" 43 #include "source4/lib/messaging/messaging.h" 44 #include "lib/param/param.h" 45 #include "lib/async_req/async_sock.h" 39 46 40 47 #undef DBGC_CLASS 41 48 #define DBGC_CLASS DBGC_WINBIND 42 49 50 #define SCRUB_CLIENTS_INTERVAL 5 51 43 52 static bool client_is_idle(struct winbindd_cli_state *state); 44 53 static void remove_client(struct winbindd_cli_state *state); 54 static void winbindd_setup_max_fds(void); 45 55 46 56 static bool opt_nocache = False; … … 49 59 extern bool override_logfile; 50 60 61 struct tevent_context *winbind_event_context(void) 62 { 63 static struct tevent_context *ev = NULL; 64 65 if (ev != NULL) { 66 return ev; 67 } 68 69 /* 70 * Note we MUST use the NULL context here, not the autofree context, 71 * to avoid side effects in forked children exiting. 72 */ 73 ev = samba_tevent_context_init(NULL); 74 if (ev == NULL) { 75 smb_panic("Could not init winbindd's messaging context.\n"); 76 } 77 return ev; 78 } 79 51 80 struct messaging_context *winbind_messaging_context(void) 52 81 { 53 struct messaging_context *msg_ctx = server_messaging_context(); 54 if (likely(msg_ctx != NULL)) { 55 return msg_ctx; 56 } 57 smb_panic("Could not init winbindd's messaging context.\n"); 58 return NULL; 82 static struct messaging_context *msg = NULL; 83 84 if (msg != NULL) { 85 return msg; 86 } 87 88 /* 89 * Note we MUST use the NULL context here, not the autofree context, 90 * to avoid side effects in forked children exiting. 91 */ 92 msg = messaging_init(NULL, winbind_event_context()); 93 if (msg == NULL) { 94 smb_panic("Could not init winbindd's messaging context.\n"); 95 } 96 return msg; 97 } 98 99 struct imessaging_context *winbind_imessaging_context(void) 100 { 101 static struct imessaging_context *msg = NULL; 102 struct messaging_context *msg_ctx; 103 struct server_id myself; 104 struct loadparm_context *lp_ctx; 105 106 if (msg != NULL) { 107 return msg; 108 } 109 110 msg_ctx = server_messaging_context(); 111 if (msg_ctx == NULL) { 112 smb_panic("server_messaging_context failed\n"); 113 } 114 myself = messaging_server_id(msg_ctx); 115 116 lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers()); 117 if (lp_ctx == NULL) { 118 smb_panic("Could not load smb.conf to init winbindd's imessaging context.\n"); 119 } 120 121 /* 122 * Note we MUST use the NULL context here, not the autofree context, 123 * to avoid side effects in forked children exiting. 124 */ 125 msg = imessaging_init(NULL, lp_ctx, myself, winbind_event_context(), 126 false); 127 talloc_unlink(NULL, lp_ctx); 128 129 if (msg == NULL) { 130 smb_panic("Could not init winbindd's messaging context.\n"); 131 } 132 return msg; 59 133 } 60 134 … … 66 140 67 141 if (lp_loaded()) { 68 char *fname = lp_ configfile();142 char *fname = lp_next_configfile(talloc_tos()); 69 143 70 144 if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { … … 81 155 82 156 reopen_logs(); 83 ret = lp_load (get_dyn_CONFIGFILE(),False,False,True,True);157 ret = lp_load_global(get_dyn_CONFIGFILE()); 84 158 85 159 reopen_logs(); 86 160 load_interfaces(); 161 winbindd_setup_max_fds(); 87 162 88 163 return(ret); 89 164 } 90 165 91 92 /**************************************************************************** **93 Handle a fault..94 **************************************************************************** */95 96 static void fault_quit(void)97 {98 dump_core();99 }100 166 101 167 static void winbindd_status(void) … … 170 236 171 237 if (asprintf(&path, "%s/%s", 172 get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME) > 0) {238 lp_winbindd_socket_directory(), WINBINDD_SOCKET_NAME) > 0) { 173 239 unlink(path); 174 240 SAFE_FREE(path); … … 193 259 194 260 if (is_parent) { 195 serverid_deregister(procid_self()); 196 pidfile_unlink(); 261 struct messaging_context *msg = winbind_messaging_context(); 262 struct server_id self = messaging_server_id(msg); 263 serverid_deregister(self); 264 pidfile_unlink(lp_pid_directory(), "winbindd"); 197 265 } 198 266 … … 212 280 signum, (int)*is_parent)); 213 281 terminate(*is_parent); 282 } 283 284 /* 285 handle stdin becoming readable when we are in --foreground mode 286 */ 287 static void winbindd_stdin_handler(struct tevent_context *ev, 288 struct tevent_fd *fde, 289 uint16_t flags, 290 void *private_data) 291 { 292 char c; 293 if (read(0, &c, 1) != 1) { 294 bool *is_parent = talloc_get_type_abort(private_data, bool); 295 296 /* we have reached EOF on stdin, which means the 297 parent has exited. Shutdown the server */ 298 DEBUG(0,("EOF on stdin (is_parent=%d)\n", 299 (int)*is_parent)); 300 terminate(*is_parent); 301 } 214 302 } 215 303 … … 262 350 } 263 351 352 bool winbindd_setup_stdin_handler(bool parent, bool foreground) 353 { 354 bool *is_parent; 355 356 if (foreground) { 357 struct stat st; 358 359 is_parent = talloc(winbind_event_context(), bool); 360 if (!is_parent) { 361 return false; 362 } 363 364 *is_parent = parent; 365 366 /* if we are running in the foreground then look for 367 EOF on stdin, and exit if it happens. This allows 368 us to die if the parent process dies 369 Only do this on a pipe or socket, no other device. 370 */ 371 if (fstat(0, &st) != 0) { 372 return false; 373 } 374 if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { 375 tevent_add_fd(winbind_event_context(), 376 is_parent, 377 0, 378 TEVENT_FD_READ, 379 winbindd_stdin_handler, 380 is_parent); 381 } 382 } 383 384 return true; 385 } 386 264 387 static void winbindd_sig_hup_handler(struct tevent_context *ev, 265 388 struct tevent_signal *se, … … 388 511 DATA_BLOB *data) 389 512 { 390 uint8 ret;513 uint8_t ret; 391 514 pid_t child_pid; 392 515 NTSTATUS status; … … 400 523 * code can safely use fork/waitpid... 401 524 */ 402 child_pid = sys_fork();525 child_pid = fork(); 403 526 404 527 if (child_pid == -1) { … … 427 550 CatchSignal(SIGCHLD, SIG_DFL); 428 551 429 ret = (uint8 )winbindd_validate_cache_nobackup();552 ret = (uint8_t)winbindd_validate_cache_nobackup(); 430 553 DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret)); 431 554 messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_VALIDATE_CACHE, &ret, … … 460 583 { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" }, 461 584 { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" }, 462 463 /* WINS functions */464 465 { WINBINDD_WINS_BYNAME, winbindd_wins_byname, "WINS_BYNAME" },466 { WINBINDD_WINS_BYIP, winbindd_wins_byip, "WINS_BYIP" },467 585 468 586 /* End of list */ … … 556 674 winbindd_pam_chng_pswd_auth_crap_send, 557 675 winbindd_pam_chng_pswd_auth_crap_recv }, 676 { WINBINDD_WINS_BYIP, "WINS_BYIP", 677 winbindd_wins_byip_send, winbindd_wins_byip_recv }, 678 { WINBINDD_WINS_BYNAME, "WINS_BYNAME", 679 winbindd_wins_byname_send, winbindd_wins_byname_recv }, 558 680 559 681 { 0, NULL, NULL, NULL } … … 589 711 state->cmd_name = "unknown request"; 590 712 state->recv_fn = NULL; 591 state->last_access = time(NULL); 713 /* client is newest */ 714 winbindd_promote_client(state); 592 715 593 716 /* Process command */ … … 700 823 static void winbind_client_request_read(struct tevent_req *req); 701 824 static void winbind_client_response_written(struct tevent_req *req); 825 static void winbind_client_activity(struct tevent_req *req); 702 826 703 827 static void request_finished(struct winbindd_cli_state *state) 704 828 { 705 829 struct tevent_req *req; 830 831 /* free client socket monitoring request */ 832 TALLOC_FREE(state->io_req); 706 833 707 834 TALLOC_FREE(state->request); … … 717 844 } 718 845 tevent_req_set_callback(req, winbind_client_response_written, state); 846 state->io_req = req; 719 847 } 720 848 … … 725 853 ssize_t ret; 726 854 int err; 855 856 state->io_req = NULL; 727 857 728 858 ret = wb_resp_write_recv(req, &err); … … 752 882 } 753 883 tevent_req_set_callback(req, winbind_client_request_read, state); 884 state->io_req = req; 754 885 } 755 886 … … 786 917 if (sock == -1) { 787 918 if (errno != EINTR) { 788 DEBUG(0, ("Fail d to accept socket - %s\n",919 DEBUG(0, ("Failed to accept socket - %s\n", 789 920 strerror(errno))); 790 921 } … … 796 927 /* Create new connection structure */ 797 928 798 if ((state = TALLOC_ZERO_P(NULL, struct winbindd_cli_state)) == NULL) {929 if ((state = talloc_zero(NULL, struct winbindd_cli_state)) == NULL) { 799 930 close(sock); 800 931 return; … … 809 940 return; 810 941 } 811 812 state->last_access = time(NULL);813 942 814 943 state->privileged = privileged; … … 822 951 } 823 952 tevent_req_set_callback(req, winbind_client_request_read, state); 953 state->io_req = req; 824 954 825 955 /* Add to connection list */ … … 834 964 ssize_t ret; 835 965 int err; 966 967 state->io_req = NULL; 836 968 837 969 ret = wb_req_read_recv(req, state, &state->request, &err); … … 850 982 return; 851 983 } 984 985 req = wait_for_read_send(state, winbind_event_context(), state->sock, 986 true); 987 if (req == NULL) { 988 DEBUG(0, ("winbind_client_request_read[%d:%s]:" 989 " wait_for_read_send failed - removing client\n", 990 (int)state->pid, state->cmd_name)); 991 remove_client(state); 992 return; 993 } 994 tevent_req_set_callback(req, winbind_client_activity, state); 995 state->io_req = req; 996 852 997 process_request(state); 998 } 999 1000 static void winbind_client_activity(struct tevent_req *req) 1001 { 1002 struct winbindd_cli_state *state = 1003 tevent_req_callback_data(req, struct winbindd_cli_state); 1004 int err; 1005 bool has_data; 1006 1007 has_data = wait_for_read_recv(req, &err); 1008 1009 if (has_data) { 1010 DEBUG(0, ("winbind_client_activity[%d:%s]:" 1011 "unexpected data from client - removing client\n", 1012 (int)state->pid, state->cmd_name)); 1013 } else { 1014 if (err == EPIPE) { 1015 DEBUG(6, ("winbind_client_activity[%d:%s]: " 1016 "client has closed connection - removing " 1017 "client\n", 1018 (int)state->pid, state->cmd_name)); 1019 } else { 1020 DEBUG(2, ("winbind_client_activity[%d:%s]: " 1021 "client socket error (%s) - removing " 1022 "client\n", 1023 (int)state->pid, state->cmd_name, 1024 strerror(err))); 1025 } 1026 } 1027 1028 remove_client(state); 853 1029 } 854 1030 … … 865 1041 return; 866 1042 } 1043 1044 /* 1045 * We need to remove a pending wb_req_read_* 1046 * or wb_resp_write_* request before closing the 1047 * socket. 1048 * 1049 * This is important as they might have used tevent_add_fd() and we 1050 * use the epoll * backend on linux. So we must remove the tevent_fd 1051 * before closing the fd. 1052 * 1053 * Otherwise we might hit a race with close_conns_after_fork() (via 1054 * winbindd_reinit_after_fork()) where a file description 1055 * is still open in a child, which means it's still active in 1056 * the parents epoll queue, but the related tevent_fd is already 1057 * already gone in the parent. 1058 * 1059 * See bug #11141. 1060 */ 1061 TALLOC_FREE(state->io_req); 867 1062 868 1063 if (state->sock != -1) { … … 901 1096 { 902 1097 struct winbindd_cli_state *state, *remove_state = NULL; 903 time_t last_access = 0;904 1098 int nidle = 0; 905 1099 … … 907 1101 if (client_is_idle(state)) { 908 1102 nidle++; 909 if (!last_access || state->last_access < last_access) { 910 last_access = state->last_access; 911 remove_state = state; 912 } 1103 /* list is sorted by access time */ 1104 remove_state = state; 913 1105 } 914 1106 } … … 922 1114 923 1115 return False; 1116 } 1117 1118 /* 1119 * Terminate all clients whose requests have taken longer than 1120 * "winbind request timeout" seconds to process, or have been 1121 * idle for more than "winbind request timeout" seconds. 1122 */ 1123 1124 static void remove_timed_out_clients(void) 1125 { 1126 struct winbindd_cli_state *state, *prev = NULL; 1127 time_t curr_time = time(NULL); 1128 int timeout_val = lp_winbind_request_timeout(); 1129 1130 for (state = winbindd_client_list_tail(); state; state = prev) { 1131 time_t expiry_time; 1132 1133 prev = winbindd_client_list_prev(state); 1134 expiry_time = state->last_access + timeout_val; 1135 1136 if (curr_time > expiry_time) { 1137 if (client_is_idle(state)) { 1138 DEBUG(5,("Idle client timed out, " 1139 "shutting down sock %d, pid %u\n", 1140 state->sock, 1141 (unsigned int)state->pid)); 1142 } else { 1143 DEBUG(5,("Client request timed out, " 1144 "shutting down sock %d, pid %u\n", 1145 state->sock, 1146 (unsigned int)state->pid)); 1147 } 1148 remove_client(state); 1149 } else { 1150 /* list is sorted, previous clients in 1151 list are newer */ 1152 break; 1153 } 1154 } 1155 } 1156 1157 static void winbindd_scrub_clients_handler(struct tevent_context *ev, 1158 struct tevent_timer *te, 1159 struct timeval current_time, 1160 void *private_data) 1161 { 1162 remove_timed_out_clients(); 1163 if (tevent_add_timer(ev, ev, 1164 timeval_current_ofs(SCRUB_CLIENTS_INTERVAL, 0), 1165 winbindd_scrub_clients_handler, NULL) == NULL) { 1166 DEBUG(0, ("winbindd: failed to reschedule client scrubber\n")); 1167 exit(1); 1168 } 924 1169 } 925 1170 … … 949 1194 } 950 1195 } 1196 remove_timed_out_clients(); 951 1197 new_connection(s->fd, s->privileged); 952 1198 } … … 956 1202 */ 957 1203 958 const char *get_winbind_pipe_dir(void)959 {960 return lp_parm_const_string(-1, "winbindd", "socket dir", WINBINDD_SOCKET_DIR);961 }962 963 1204 char *get_winbind_priv_pipe_dir(void) 964 1205 { 965 return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR); 1206 return state_path(WINBINDD_PRIV_SOCKET_SUBDIR); 1207 } 1208 1209 static void winbindd_setup_max_fds(void) 1210 { 1211 int num_fds = MAX_OPEN_FUDGEFACTOR; 1212 int actual_fds; 1213 1214 num_fds += lp_winbind_max_clients(); 1215 /* Add some more to account for 2 sockets open 1216 when the client transitions from unprivileged 1217 to privileged socket 1218 */ 1219 num_fds += lp_winbind_max_clients() / 10; 1220 1221 /* Add one socket per child process 1222 (yeah there are child processes other than the 1223 domain children but only domain children can vary 1224 with configuration 1225 */ 1226 num_fds += lp_winbind_max_domain_connections() * 1227 (lp_allow_trusted_domains() ? WINBIND_MAX_DOMAINS_HINT : 1); 1228 1229 actual_fds = set_maxfiles(num_fds); 1230 1231 if (actual_fds < num_fds) { 1232 DEBUG(1, ("winbindd_setup_max_fds: Information only: " 1233 "requested %d open files, %d are available.\n", 1234 num_fds, actual_fds)); 1235 } 966 1236 } 967 1237 … … 971 1241 struct winbindd_listen_state *priv_state = NULL; 972 1242 struct tevent_fd *fde; 1243 int rc; 1244 char *socket_path; 973 1245 974 1246 pub_state = talloc(winbind_event_context(), … … 980 1252 pub_state->privileged = false; 981 1253 pub_state->fd = create_pipe_sock( 982 get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);1254 lp_winbindd_socket_directory(), WINBINDD_SOCKET_NAME, 0755); 983 1255 if (pub_state->fd == -1) { 1256 goto failed; 1257 } 1258 rc = listen(pub_state->fd, 5); 1259 if (rc < 0) { 984 1260 goto failed; 985 1261 } … … 1000 1276 } 1001 1277 1278 socket_path = get_winbind_priv_pipe_dir(); 1279 if (socket_path == NULL) { 1280 goto failed; 1281 } 1282 1002 1283 priv_state->privileged = true; 1003 1284 priv_state->fd = create_pipe_sock( 1004 get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750); 1285 socket_path, WINBINDD_SOCKET_NAME, 0750); 1286 TALLOC_FREE(socket_path); 1005 1287 if (priv_state->fd == -1) { 1288 goto failed; 1289 } 1290 rc = listen(priv_state->fd, 5); 1291 if (rc < 0) { 1006 1292 goto failed; 1007 1293 } … … 1016 1302 tevent_fd_set_auto_close(fde); 1017 1303 1304 winbindd_scrub_clients_handler(winbind_event_context(), NULL, 1305 timeval_current(), NULL); 1018 1306 return true; 1019 1307 failed: … … 1033 1321 } 1034 1322 1035 void winbindd_register_handlers(void) 1036 { 1323 static void winbindd_register_handlers(struct messaging_context *msg_ctx, 1324 bool foreground) 1325 { 1326 NTSTATUS status; 1037 1327 /* Setup signal handlers */ 1038 1328 1039 1329 if (!winbindd_setup_sig_term_handler(true)) 1330 exit(1); 1331 if (!winbindd_setup_stdin_handler(true, foreground)) 1040 1332 exit(1); 1041 1333 if (!winbindd_setup_sig_hup_handler(NULL)) … … 1058 1350 /* get broadcast messages */ 1059 1351 1060 if (!serverid_register(procid_self(), 1061 FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) { 1352 if (!serverid_register(messaging_server_id(msg_ctx), 1353 FLAG_MSG_GENERAL | 1354 FLAG_MSG_WINBIND | 1355 FLAG_MSG_DBWRAP)) { 1062 1356 DEBUG(1, ("Could not register myself in serverid.tdb\n")); 1063 1357 exit(1); … … 1066 1360 /* React on 'smbcontrol winbindd reload-config' in the same way 1067 1361 as to SIGHUP signal */ 1068 messaging_register( winbind_messaging_context(), NULL,1362 messaging_register(msg_ctx, NULL, 1069 1363 MSG_SMB_CONF_UPDATED, msg_reload_services); 1070 messaging_register( winbind_messaging_context(), NULL,1364 messaging_register(msg_ctx, NULL, 1071 1365 MSG_SHUTDOWN, msg_shutdown); 1072 1366 1073 1367 /* Handle online/offline messages. */ 1074 messaging_register( winbind_messaging_context(), NULL,1368 messaging_register(msg_ctx, NULL, 1075 1369 MSG_WINBIND_OFFLINE, winbind_msg_offline); 1076 messaging_register( winbind_messaging_context(), NULL,1370 messaging_register(msg_ctx, NULL, 1077 1371 MSG_WINBIND_ONLINE, winbind_msg_online); 1078 messaging_register( winbind_messaging_context(), NULL,1372 messaging_register(msg_ctx, NULL, 1079 1373 MSG_WINBIND_ONLINESTATUS, winbind_msg_onlinestatus); 1080 1374 … … 1085 1379 MSG_WINBIND_DOMAIN_ONLINE, winbind_msg_domain_online); 1086 1380 1087 messaging_register( winbind_messaging_context(), NULL,1381 messaging_register(msg_ctx, NULL, 1088 1382 MSG_DUMP_EVENT_LIST, winbind_msg_dump_event_list); 1089 1383 1090 messaging_register( winbind_messaging_context(), NULL,1384 messaging_register(msg_ctx, NULL, 1091 1385 MSG_WINBIND_VALIDATE_CACHE, 1092 1386 winbind_msg_validate_cache); 1093 1387 1094 messaging_register( winbind_messaging_context(), NULL,1388 messaging_register(msg_ctx, NULL, 1095 1389 MSG_WINBIND_DUMP_DOMAIN_LIST, 1096 1390 winbind_msg_dump_domain_list); 1097 1391 1098 messaging_register( winbind_messaging_context(), NULL,1392 messaging_register(msg_ctx, NULL, 1099 1393 MSG_WINBIND_IP_DROPPED, 1100 1394 winbind_msg_ip_dropped_parent); 1101 1395 1102 1396 /* Register handler for MSG_DEBUG. */ 1103 messaging_register( winbind_messaging_context(), NULL,1397 messaging_register(msg_ctx, NULL, 1104 1398 MSG_DEBUG, 1105 1399 winbind_msg_debug); … … 1130 1424 } 1131 1425 1426 status = wb_irpc_register(); 1427 1428 if (!NT_STATUS_IS_OK(status)) { 1429 DEBUG(0, ("Could not register IRPC handlers\n")); 1430 exit(1); 1431 } 1132 1432 } 1133 1433 … … 1218 1518 /* Main function */ 1219 1519 1220 int main(int argc, c har **argv, char **envp)1520 int main(int argc, const char **argv) 1221 1521 { 1222 1522 static bool is_daemon = False; … … 1245 1545 TALLOC_CTX *frame; 1246 1546 NTSTATUS status; 1547 bool ok; 1247 1548 1248 1549 /* … … 1252 1553 frame = talloc_stackframe(); 1253 1554 1555 /* 1556 * We want total control over the permissions on created files, 1557 * so set our umask to 0. 1558 */ 1559 umask(0); 1560 1561 setup_logging("winbindd", DEBUG_DEFAULT_STDOUT); 1562 1254 1563 /* glibc (?) likes to print "User defined signal 1" and exit if a 1255 1564 SIGUSR[12] is received before a handler is installed */ … … 1258 1567 CatchSignal(SIGUSR2, SIG_IGN); 1259 1568 1260 fault_setup( (void (*)(void *))fault_quit);1261 dump_core_setup("winbindd" );1262 1263 load_case_tables();1569 fault_setup(); 1570 dump_core_setup("winbindd", lp_logfile(talloc_tos())); 1571 1572 smb_init_locale(); 1264 1573 1265 1574 /* Initialise for running in non-root mode */ … … 1279 1588 /* Initialise samba/rpc client stuff */ 1280 1589 1281 pc = poptGetContext("winbindd", argc, (const char **)argv, long_options, 0);1590 pc = poptGetContext("winbindd", argc, argv, long_options, 0); 1282 1591 1283 1592 while ((opt = poptGetNextOpt(pc)) != -1) { … … 1319 1628 * in production. 1320 1629 */ 1321 dump_core_setup("winbindd"); 1322 1630 dump_core_setup("winbindd", lp_logfile(talloc_tos())); 1323 1631 if (is_daemon && interactive) { 1324 1632 d_fprintf(stderr,"\nERROR: " … … 1345 1653 } 1346 1654 } 1655 1347 1656 if (log_stdout) { 1348 1657 setup_logging("winbindd", DEBUG_STDOUT); … … 1356 1665 1357 1666 if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { 1358 DEBUG(0, ("error opening config file \n"));1667 DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE())); 1359 1668 exit(1); 1360 1669 } … … 1363 1672 * path is by default basename(lp_logfile()). 1364 1673 */ 1365 dump_core_setup("winbindd"); 1674 dump_core_setup("winbindd", lp_logfile(talloc_tos())); 1675 1676 if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC 1677 && !lp_parm_bool(-1, "server role check", "inhibit", false)) { 1678 DEBUG(0, ("server role = 'active directory domain controller' not compatible with running the winbindd binary. \n")); 1679 DEBUGADD(0, ("You should start 'samba' instead, and it will control starting the internal AD DC winbindd implementation, which is not the same as this one\n")); 1680 exit(1); 1681 } 1682 1683 if (!cluster_probe_ok()) { 1684 exit(1); 1685 } 1366 1686 1367 1687 /* Initialise messaging system */ … … 1376 1696 } 1377 1697 1378 if (!directory_exist(lp_lockdir())) { 1379 mkdir(lp_lockdir(), 0755); 1698 ok = directory_create_or_exist(lp_lock_directory(), 0755); 1699 if (!ok) { 1700 DEBUG(0, ("Failed to create directory %s for lock files - %s\n", 1701 lp_lock_directory(), strerror(errno))); 1702 exit(1); 1703 } 1704 1705 ok = directory_create_or_exist(lp_pid_directory(), 0755); 1706 if (!ok) { 1707 DEBUG(0, ("Failed to create directory %s for pid files - %s\n", 1708 lp_pid_directory(), strerror(errno))); 1709 exit(1); 1380 1710 } 1381 1711 … … 1391 1721 DEBUG(0,("Could not initialize domain trust account secrets. Giving up\n")); 1392 1722 return False; 1723 } 1724 1725 status = rpccli_pre_open_netlogon_creds(); 1726 if (!NT_STATUS_IS_OK(status)) { 1727 DEBUG(0, ("rpccli_pre_open_netlogon_creds() - %s\n", 1728 nt_errstr(status))); 1729 exit(1); 1393 1730 } 1394 1731 … … 1407 1744 become_daemon(Fork, no_process_group, log_stdout); 1408 1745 1409 pidfile_create( "winbindd");1746 pidfile_create(lp_pid_directory(), "winbindd"); 1410 1747 1411 1748 #if HAVE_SETPGID … … 1427 1764 status = reinit_after_fork(winbind_messaging_context(), 1428 1765 winbind_event_context(), 1429 procid_self(), false);1766 false, NULL); 1430 1767 if (!NT_STATUS_IS_OK(status)) { 1431 DEBUG(0,("reinit_after_fork() failed\n")); 1432 exit(1); 1433 } 1434 1435 winbindd_register_handlers(); 1436 1437 status = init_system_info(); 1768 exit_daemon("Winbindd reinit_after_fork() failed", map_errno_from_nt_status(status)); 1769 } 1770 1771 /* 1772 * Do not initialize the parent-child-pipe before becoming 1773 * a daemon: this is used to detect a died parent in the child 1774 * process. 1775 */ 1776 status = init_before_fork(); 1438 1777 if (!NT_STATUS_IS_OK(status)) { 1439 DEBUG(1, ("ERROR: failed to setup system user info: %s.\n", 1440 nt_errstr(status))); 1441 exit(1); 1778 exit_daemon(nt_errstr(status), map_errno_from_nt_status(status)); 1779 } 1780 1781 winbindd_register_handlers(winbind_messaging_context(), !Fork); 1782 1783 if (!messaging_parent_dgm_cleanup_init(winbind_messaging_context())) { 1784 exit(1); 1785 } 1786 1787 status = init_system_session_info(); 1788 if (!NT_STATUS_IS_OK(status)) { 1789 exit_daemon("Winbindd failed to setup system user info", map_errno_from_nt_status(status)); 1442 1790 } 1443 1791 … … 1451 1799 1452 1800 if (!winbindd_setup_listeners()) { 1453 DEBUG(0,("winbindd_setup_listeners() failed\n")); 1454 exit(1); 1455 } 1801 exit_daemon("Winbindd failed to setup listeners", EPIPE); 1802 } 1803 1804 irpc_add_name(winbind_imessaging_context(), "winbind_server"); 1456 1805 1457 1806 TALLOC_FREE(frame); 1807 1808 if (!interactive) { 1809 daemon_ready("winbindd"); 1810 } 1811 1458 1812 /* Loop waiting for requests */ 1459 1813 while (1) {
Note:
See TracChangeset
for help on using the changeset viewer.