Changeset 988 for vendor/current/source3/utils/smbcontrol.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/utils/smbcontrol.c
r860 r988 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 3 … … 33 33 #include "messages.h" 34 34 #include "util_tdb.h" 35 #include "../lib/util/pidfile.h" 36 #include "serverid.h" 35 37 36 38 #if HAVE_LIBUNWIND_H … … 65 67 return NT_STATUS_IS_OK( 66 68 messaging_send_buf(msg_ctx, pid, msg_type, 67 ( uint8*)buf, len));69 (const uint8_t *)buf, len)); 68 70 69 71 ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent); … … 86 88 /* Wait for one or more reply messages */ 87 89 88 static void wait_replies(struct messaging_context *msg_ctx, 90 static void wait_replies(struct tevent_context *ev_ctx, 91 struct messaging_context *msg_ctx, 89 92 bool multiple_replies) 90 93 { … … 92 95 bool timed_out = False; 93 96 94 if (!(te = tevent_add_timer(messaging_event_context(msg_ctx), NULL, 95 timeval_current_ofs(timeout, 0), 96 smbcontrol_timeout, (void *)&timed_out))) { 97 te = tevent_add_timer(ev_ctx, NULL, 98 timeval_current_ofs(timeout, 0), 99 smbcontrol_timeout, (void *)&timed_out); 100 if (te == NULL) { 97 101 DEBUG(0, ("tevent_add_timer failed\n")); 98 102 return; … … 103 107 if (num_replies > 0 && !multiple_replies) 104 108 break; 105 ret = tevent_loop_once( messaging_event_context(msg_ctx));109 ret = tevent_loop_once(ev_ctx); 106 110 if (ret != 0) { 107 111 break; … … 118 122 DATA_BLOB *data) 119 123 { 120 char *pidstr; 121 122 pidstr = procid_str(talloc_tos(), &pid); 123 printf("PID %s: %.*s", pidstr, (int)data->length, 124 (const char *)data->data); 125 TALLOC_FREE(pidstr); 124 struct server_id_buf pidstr; 125 126 printf("PID %s: %.*s", server_id_str_buf(pid, &pidstr), 127 (int)data->length, (const char *)data->data); 126 128 num_replies++; 127 129 } … … 141 143 /* Send no message. Useful for testing. */ 142 144 143 static bool do_noop(struct messaging_context *msg_ctx, 145 static bool do_noop(struct tevent_context *ev_ctx, 146 struct messaging_context *msg_ctx, 144 147 const struct server_id pid, 145 148 const int argc, const char **argv) … … 157 160 /* Send a debug string */ 158 161 159 static bool do_debug(struct messaging_context *msg_ctx, 162 static bool do_debug(struct tevent_context *ev_ctx, 163 struct messaging_context *msg_ctx, 160 164 const struct server_id pid, 161 165 const int argc, const char **argv) … … 172 176 173 177 174 static bool do_idmap(struct messaging_context *msg_ctx, 178 static bool do_idmap(struct tevent_context *ev, 179 struct messaging_context *msg_ctx, 175 180 const struct server_id pid, 176 181 const int argc, const char **argv) … … 178 183 static const char* usage = "Usage: " 179 184 "smbcontrol <dest> idmap <cmd> [arg]\n" 180 "\tcmd: \tflush [gid|uid]\n"181 "\t \tdelete \"UID <uid>\"|\"GID <gid>\"|<sid>\n"185 "\tcmd:" 186 "\tdelete \"UID <uid>\"|\"GID <gid>\"|<sid>\n" 182 187 "\t\tkill \"UID <uid>\"|\"GID <gid>\"|<sid>\n"; 183 188 const char* arg = NULL; … … 197 202 } 198 203 199 if (strcmp(argv[1], "flush") == 0) { 200 msg_type = MSG_IDMAP_FLUSH; 201 } 202 else if (strcmp(argv[1], "delete") == 0) { 203 msg_type = MSG_IDMAP_DELETE; 204 if (strcmp(argv[1], "delete") == 0) { 205 msg_type = ID_CACHE_DELETE; 204 206 } 205 207 else if (strcmp(argv[1], "kill") == 0) { 206 msg_type = MSG_IDMAP_KILL;208 msg_type = ID_CACHE_KILL; 207 209 } 208 210 else if (strcmp(argv[1], "help") == 0) { … … 222 224 223 225 /* Return the name of a process given it's PID. This will only work on Linux, 224 * but that's probably moot since this whole stack tracing implementati nois226 * but that's probably moot since this whole stack tracing implementation is 225 227 * Linux-specific anyway. 226 228 */ … … 320 322 } 321 323 322 static int stack_trace_connection(const struct connections_key *key, 323 const struct connections_data *crec, 324 void *priv) 325 { 326 print_stack_trace(procid_to_pid(&crec->pid), (int *)priv); 327 324 static int stack_trace_server(const struct server_id *id, 325 uint32_t msg_flags, 326 void *priv) 327 { 328 if (procid_is_local(id)) { 329 print_stack_trace(procid_to_pid(id), (int *)priv); 330 } 328 331 return 0; 329 332 } 330 333 331 static bool do_daemon_stack_trace(struct messaging_context *msg_ctx, 334 static bool do_daemon_stack_trace(struct tevent_context *ev_ctx, 335 struct messaging_context *msg_ctx, 332 336 const struct server_id pid, 333 337 const int argc, const char **argv) 334 338 { 335 339 pid_t dest; … … 351 355 print_stack_trace(dest, &count); 352 356 } else { 353 connections_forall_read(stack_trace_connection, &count);357 serverid_traverse_read(stack_trace_server, &count); 354 358 } 355 359 … … 359 363 #else /* defined(HAVE_LIBUNWIND_PTRACE) && defined(HAVE_LINUX_PTRACE) */ 360 364 361 static bool do_daemon_stack_trace(struct messaging_context *msg_ctx, 365 static bool do_daemon_stack_trace(struct tevent_context *ev_ctx, 366 struct messaging_context *msg_ctx, 362 367 const struct server_id pid, 363 368 const int argc, const char **argv) 364 369 { 365 370 fprintf(stderr, … … 372 377 /* Inject a fault (fatal signal) into a running smbd */ 373 378 374 static bool do_inject_fault(struct messaging_context *msg_ctx, 379 static bool do_inject_fault(struct tevent_context *ev_ctx, 380 struct messaging_context *msg_ctx, 375 381 const struct server_id pid, 376 382 const int argc, const char **argv) 377 383 { 378 384 if (argc != 2) { … … 414 420 /* Force a browser election */ 415 421 416 static bool do_election(struct messaging_context *msg_ctx, 422 static bool do_election(struct tevent_context *ev_ctx, 423 struct messaging_context *msg_ctx, 417 424 const struct server_id pid, 418 425 const int argc, const char **argv) … … 434 441 DATA_BLOB *data) 435 442 { 436 char *src_string = procid_str(NULL, &pid); 437 printf("PONG from pid %s\n", src_string); 438 TALLOC_FREE(src_string); 443 struct server_id_buf src_string; 444 printf("PONG from pid %s\n", server_id_str_buf(pid, &src_string)); 439 445 num_replies++; 440 446 } 441 447 442 static bool do_ping(struct messaging_context *msg_ctx, 448 static bool do_ping(struct tevent_context *ev_ctx, 449 struct messaging_context *msg_ctx, 443 450 const struct server_id pid, 444 451 const int argc, const char **argv) … … 456 463 messaging_register(msg_ctx, NULL, MSG_PONG, pong_cb); 457 464 458 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);465 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 459 466 460 467 /* No replies were received within the timeout period */ … … 470 477 /* Set profiling options */ 471 478 472 static bool do_profile(struct messaging_context *msg_ctx, 479 static bool do_profile(struct tevent_context *ev_ctx, 480 struct messaging_context *msg_ctx, 473 481 const struct server_id pid, 474 482 const int argc, const char **argv) … … 553 561 } 554 562 555 static bool do_profilelevel(struct messaging_context *msg_ctx, 563 static bool do_profilelevel(struct tevent_context *ev_ctx, 564 struct messaging_context *msg_ctx, 556 565 const struct server_id pid, 557 566 const int argc, const char **argv) … … 571 580 profilelevel_rqst); 572 581 573 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);582 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 574 583 575 584 /* No replies were received within the timeout period */ … … 585 594 /* Display debug level settings */ 586 595 587 static bool do_debuglevel(struct messaging_context *msg_ctx, 596 static bool do_debuglevel(struct tevent_context *ev_ctx, 597 struct messaging_context *msg_ctx, 588 598 const struct server_id pid, 589 599 const int argc, const char **argv) … … 601 611 messaging_register(msg_ctx, NULL, MSG_DEBUGLEVEL, print_pid_string_cb); 602 612 603 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);613 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 604 614 605 615 /* No replies were received within the timeout period */ … … 615 625 /* Send a print notify message */ 616 626 617 static bool do_printnotify(struct messaging_context *msg_ctx, 627 static bool do_printnotify(struct tevent_context *ev_ctx, 628 struct messaging_context *msg_ctx, 618 629 const struct server_id pid, 619 630 const int argc, const char **argv) … … 646 657 } 647 658 648 notify_printer_status_byname(messaging_event_context(msg_ctx), 649 msg_ctx, argv[2], 659 notify_printer_status_byname(ev_ctx, msg_ctx, argv[2], 650 660 PRINTER_STATUS_PAUSED); 651 661 … … 660 670 } 661 671 662 notify_printer_status_byname(messaging_event_context(msg_ctx), 663 msg_ctx, argv[2], 672 notify_printer_status_byname(ev_ctx, msg_ctx, argv[2], 664 673 PRINTER_STATUS_OK); 665 674 … … 678 687 679 688 notify_job_status_byname( 680 messaging_event_context(msg_ctx), msg_ctx,689 ev_ctx, msg_ctx, 681 690 argv[2], jobid, JOB_STATUS_PAUSED, 682 691 SPOOLSS_NOTIFY_MSG_UNIX_JOBID); … … 696 705 697 706 notify_job_status_byname( 698 messaging_event_context(msg_ctx), msg_ctx,707 ev_ctx, msg_ctx, 699 708 argv[2], jobid, JOB_STATUS_QUEUED, 700 709 SPOOLSS_NOTIFY_MSG_UNIX_JOBID); … … 714 723 715 724 notify_job_status_byname( 716 messaging_event_context(msg_ctx), msg_ctx,725 ev_ctx, msg_ctx, 717 726 argv[2], jobid, JOB_STATUS_DELETING, 718 727 SPOOLSS_NOTIFY_MSG_UNIX_JOBID); 719 728 720 729 notify_job_status_byname( 721 messaging_event_context(msg_ctx), msg_ctx,730 ev_ctx, msg_ctx, 722 731 argv[2], jobid, JOB_STATUS_DELETING| 723 732 JOB_STATUS_DELETED, … … 727 736 728 737 } else if (strcmp(cmd, "printer") == 0) { 729 uint32 attribute;738 uint32_t attribute; 730 739 731 740 if (argc != 5) { … … 748 757 } 749 758 750 notify_printer_byname(messaging_event_context(msg_ctx), 751 msg_ctx, argv[2], attribute, 752 CONST_DISCARD(char *, argv[4])); 759 notify_printer_byname(ev_ctx, msg_ctx, argv[2], attribute, 760 discard_const_p(char, argv[4])); 753 761 754 762 goto send; … … 765 773 /* Close a share */ 766 774 767 static bool do_closeshare(struct messaging_context *msg_ctx, 775 static bool do_closeshare(struct tevent_context *ev_ctx, 776 struct messaging_context *msg_ctx, 768 777 const struct server_id pid, 769 778 const int argc, const char **argv) … … 779 788 } 780 789 790 /* Kill a client by IP address */ 791 static bool do_kill_client_by_ip(struct tevent_context *ev_ctx, 792 struct messaging_context *msg_ctx, 793 const struct server_id pid, 794 const int argc, const char **argv) 795 { 796 if (argc != 2) { 797 fprintf(stderr, "Usage: smbcontrol <dest> kill-client-ip " 798 "<IP address>\n"); 799 return false; 800 } 801 802 if (!is_ipaddress_v4(argv[1]) && !is_ipaddress_v6(argv[1])) { 803 fprintf(stderr, "%s is not a valid IP address!\n", argv[1]); 804 return false; 805 } 806 807 return send_message(msg_ctx, pid, MSG_SMB_KILL_CLIENT_IP, 808 argv[1], strlen(argv[1]) + 1); 809 } 810 781 811 /* Tell winbindd an IP got dropped */ 782 812 783 static bool do_ip_dropped(struct messaging_context *msg_ctx, 813 static bool do_ip_dropped(struct tevent_context *ev_ctx, 814 struct messaging_context *msg_ctx, 784 815 const struct server_id pid, 785 816 const int argc, const char **argv) … … 797 828 /* force a blocking lock retry */ 798 829 799 static bool do_lockretry(struct messaging_context *msg_ctx, 830 static bool do_lockretry(struct tevent_context *ev_ctx, 831 struct messaging_context *msg_ctx, 800 832 const struct server_id pid, 801 833 const int argc, const char **argv) … … 811 843 /* force a validation of all brl entries, including re-sends. */ 812 844 813 static bool do_brl_revalidate(struct messaging_context *msg_ctx, 845 static bool do_brl_revalidate(struct tevent_context *ev_ctx, 846 struct messaging_context *msg_ctx, 814 847 const struct server_id pid, 815 848 const int argc, const char **argv) … … 823 856 } 824 857 825 /* Force a SAM synchronisation */826 827 static bool do_samsync(struct messaging_context *msg_ctx,828 const struct server_id pid,829 const int argc, const char **argv)830 {831 if (argc != 1) {832 fprintf(stderr, "Usage: smbcontrol <dest> samsync\n");833 return False;834 }835 836 return send_message(msg_ctx, pid, MSG_SMB_SAM_SYNC, NULL, 0);837 }838 839 /* Force a SAM replication */840 841 static bool do_samrepl(struct messaging_context *msg_ctx,842 const struct server_id pid,843 const int argc, const char **argv)844 {845 if (argc != 1) {846 fprintf(stderr, "Usage: smbcontrol <dest> samrepl\n");847 return False;848 }849 850 return send_message(msg_ctx, pid, MSG_SMB_SAM_REPL, NULL, 0);851 }852 853 858 /* Display talloc pool usage */ 854 859 855 static bool do_poolusage(struct messaging_context *msg_ctx, 860 static bool do_poolusage(struct tevent_context *ev_ctx, 861 struct messaging_context *msg_ctx, 856 862 const struct server_id pid, 857 863 const int argc, const char **argv) … … 869 875 return False; 870 876 871 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);877 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 872 878 873 879 /* No replies were received within the timeout period */ … … 883 889 /* Perform a dmalloc mark */ 884 890 885 static bool do_dmalloc_mark(struct messaging_context *msg_ctx, 891 static bool do_dmalloc_mark(struct tevent_context *ev_ctx, 892 struct messaging_context *msg_ctx, 886 893 const struct server_id pid, 887 894 const int argc, const char **argv) … … 897 904 /* Perform a dmalloc changed */ 898 905 899 static bool do_dmalloc_changed(struct messaging_context *msg_ctx, 906 static bool do_dmalloc_changed(struct tevent_context *ev_ctx, 907 struct messaging_context *msg_ctx, 900 908 const struct server_id pid, 901 909 const int argc, const char **argv) … … 911 919 } 912 920 921 static void print_uint32_cb(struct messaging_context *msg, void *private_data, 922 uint32_t msg_type, struct server_id pid, 923 DATA_BLOB *data) 924 { 925 uint32_t num_children; 926 927 if (data->length != sizeof(uint32_t)) { 928 printf("Invalid response: %d bytes long\n", 929 (int)data->length); 930 goto done; 931 } 932 num_children = IVAL(data->data, 0); 933 printf("%u children\n", (unsigned)num_children); 934 done: 935 num_replies++; 936 } 937 938 static bool do_num_children(struct tevent_context *ev_ctx, 939 struct messaging_context *msg_ctx, 940 const struct server_id pid, 941 const int argc, const char **argv) 942 { 943 if (argc != 1) { 944 fprintf(stderr, "Usage: smbcontrol <dest> num-children\n"); 945 return False; 946 } 947 948 messaging_register(msg_ctx, NULL, MSG_SMB_NUM_CHILDREN, 949 print_uint32_cb); 950 951 /* Send a message and register our interest in a reply */ 952 953 if (!send_message(msg_ctx, pid, MSG_SMB_TELL_NUM_CHILDREN, NULL, 0)) 954 return false; 955 956 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 957 958 /* No replies were received within the timeout period */ 959 960 if (num_replies == 0) 961 printf("No replies received\n"); 962 963 messaging_deregister(msg_ctx, MSG_SMB_NUM_CHILDREN, NULL); 964 965 return num_replies; 966 } 967 968 static bool do_msg_cleanup(struct tevent_context *ev_ctx, 969 struct messaging_context *msg_ctx, 970 const struct server_id pid, 971 const int argc, const char **argv) 972 { 973 int ret; 974 975 ret = messaging_cleanup(msg_ctx, pid.pid); 976 977 printf("cleanup(%u) returned %s\n", (unsigned)pid.pid, 978 ret ? strerror(ret) : "ok"); 979 980 return (ret == 0); 981 } 982 913 983 /* Shutdown a server process */ 914 984 915 static bool do_shutdown(struct messaging_context *msg_ctx, 985 static bool do_shutdown(struct tevent_context *ev_ctx, 986 struct messaging_context *msg_ctx, 916 987 const struct server_id pid, 917 988 const int argc, const char **argv) … … 927 998 /* Notify a driver upgrade */ 928 999 929 static bool do_drvupgrade(struct messaging_context *msg_ctx, 1000 static bool do_drvupgrade(struct tevent_context *ev_ctx, 1001 struct messaging_context *msg_ctx, 930 1002 const struct server_id pid, 931 1003 const int argc, const char **argv) … … 941 1013 } 942 1014 943 static bool do_winbind_online(struct messaging_context *msg_ctx, 1015 static bool do_winbind_online(struct tevent_context *ev_ctx, 1016 struct messaging_context *msg_ctx, 944 1017 const struct server_id pid, 945 const int argc, const char **argv)1018 const int argc, const char **argv) 946 1019 { 947 1020 TDB_CONTEXT *tdb; 1021 char *db_path; 948 1022 949 1023 if (argc != 1) { 950 1024 fprintf(stderr, "Usage: smbcontrol winbindd online\n"); 951 1025 return False; 1026 } 1027 1028 db_path = state_path("winbindd_cache.tdb"); 1029 if (db_path == NULL) { 1030 return false; 952 1031 } 953 1032 … … 955 1034 starting winbindd that we're online. */ 956 1035 957 tdb = tdb_open_log( cache_path("winbindd_cache.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);1036 tdb = tdb_open_log(db_path, 0, TDB_DEFAULT, O_RDWR, 0600); 958 1037 if (!tdb) { 959 1038 fprintf(stderr, "Cannot open the tdb %s for writing.\n", 960 cache_path("winbindd_cache.tdb")); 961 return False; 962 } 963 1039 db_path); 1040 TALLOC_FREE(db_path); 1041 return False; 1042 } 1043 1044 TALLOC_FREE(db_path); 964 1045 tdb_delete_bystring(tdb, "WINBINDD_OFFLINE"); 965 1046 tdb_close(tdb); … … 968 1049 } 969 1050 970 static bool do_winbind_offline(struct messaging_context *msg_ctx, 1051 static bool do_winbind_offline(struct tevent_context *ev_ctx, 1052 struct messaging_context *msg_ctx, 971 1053 const struct server_id pid, 972 const int argc, const char **argv)1054 const int argc, const char **argv) 973 1055 { 974 1056 TDB_CONTEXT *tdb; 975 1057 bool ret = False; 976 1058 int retry = 0; 1059 char *db_path; 977 1060 978 1061 if (argc != 1) { 979 1062 fprintf(stderr, "Usage: smbcontrol winbindd offline\n"); 980 1063 return False; 1064 } 1065 1066 db_path = state_path("winbindd_cache.tdb"); 1067 if (db_path == NULL) { 1068 return false; 981 1069 } 982 1070 … … 985 1073 it here... */ 986 1074 987 tdb = tdb_open_log( cache_path("winbindd_cache.tdb"),1075 tdb = tdb_open_log(db_path, 988 1076 WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, 989 1077 TDB_DEFAULT|TDB_INCOMPATIBLE_HASH /* TDB_CLEAR_IF_FIRST */, … … 992 1080 if (!tdb) { 993 1081 fprintf(stderr, "Cannot open the tdb %s for writing.\n", 994 cache_path("winbindd_cache.tdb")); 995 return False; 996 } 1082 db_path); 1083 TALLOC_FREE(db_path); 1084 return False; 1085 } 1086 TALLOC_FREE(db_path); 997 1087 998 1088 /* There's a potential race condition that if a child … … 1004 1094 1005 1095 for (retry = 0; retry < 5; retry++) { 1006 TDB_DATA d; 1007 uint8 buf[4]; 1008 1009 ZERO_STRUCT(d); 1096 uint8_t buf[4]; 1097 TDB_DATA d = { .dptr = buf, .dsize = sizeof(buf) }; 1010 1098 1011 1099 SIVAL(buf, 0, time(NULL)); 1012 d.dptr = buf;1013 d.dsize = 4;1014 1100 1015 1101 tdb_store_bystring(tdb, "WINBINDD_OFFLINE", d, TDB_INSERT); … … 1034 1120 } 1035 1121 1036 static bool do_winbind_onlinestatus(struct messaging_context *msg_ctx, 1122 static bool do_winbind_onlinestatus(struct tevent_context *ev_ctx, 1123 struct messaging_context *msg_ctx, 1037 1124 const struct server_id pid, 1038 1125 const int argc, const char **argv) … … 1054 1141 return False; 1055 1142 1056 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);1143 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 1057 1144 1058 1145 /* No replies were received within the timeout period */ … … 1066 1153 } 1067 1154 1068 static bool do_dump_event_list(struct messaging_context *msg_ctx, 1155 static bool do_dump_event_list(struct tevent_context *ev_ctx, 1156 struct messaging_context *msg_ctx, 1069 1157 const struct server_id pid, 1070 1158 const int argc, const char **argv) 1071 1159 { 1072 struct server_id myid;1073 1074 myid = messaging_server_id(msg_ctx);1075 1076 1160 if (argc != 1) { 1077 1161 fprintf(stderr, "Usage: smbcontrol <dest> dump-event-list\n"); … … 1082 1166 } 1083 1167 1084 static bool do_winbind_dump_domain_list(struct messaging_context *msg_ctx, 1168 static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx, 1169 struct messaging_context *msg_ctx, 1085 1170 const struct server_id pid, 1086 1171 const int argc, const char **argv) … … 1124 1209 } 1125 1210 1126 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);1211 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 1127 1212 1128 1213 /* No replies were received within the timeout period */ … … 1144 1229 DATA_BLOB *data) 1145 1230 { 1146 char *src_string = procid_str(NULL, &pid);1231 struct server_id_buf src_string; 1147 1232 printf("Winbindd cache is %svalid. (answer from pid %s)\n", 1148 (*(data->data) == 0 ? "" : "NOT "), src_string);1149 TALLOC_FREE(src_string);1233 (*(data->data) == 0 ? "" : "NOT "), 1234 server_id_str_buf(pid, &src_string)); 1150 1235 num_replies++; 1151 1236 } 1152 1237 1153 static bool do_winbind_validate_cache(struct messaging_context *msg_ctx, 1238 static bool do_winbind_validate_cache(struct tevent_context *ev_ctx, 1239 struct messaging_context *msg_ctx, 1154 1240 const struct server_id pid, 1155 1241 const int argc, const char **argv) … … 1172 1258 } 1173 1259 1174 wait_replies( msg_ctx, procid_to_pid(&pid) == 0);1260 wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0); 1175 1261 1176 1262 if (num_replies == 0) { … … 1183 1269 } 1184 1270 1185 static bool do_reload_config(struct messaging_context *msg_ctx, 1271 static bool do_reload_config(struct tevent_context *ev_ctx, 1272 struct messaging_context *msg_ctx, 1186 1273 const struct server_id pid, 1187 1274 const int argc, const char **argv) … … 1193 1280 1194 1281 return send_message(msg_ctx, pid, MSG_SMB_CONF_UPDATED, NULL, 0); 1282 } 1283 1284 static bool do_reload_printers(struct tevent_context *ev_ctx, 1285 struct messaging_context *msg_ctx, 1286 const struct server_id pid, 1287 const int argc, const char **argv) 1288 { 1289 if (argc != 1) { 1290 fprintf(stderr, "Usage: smbcontrol <dest> reload-printers\n"); 1291 return False; 1292 } 1293 1294 return send_message(msg_ctx, pid, MSG_PRINTER_PCAP, NULL, 0); 1195 1295 } 1196 1296 … … 1200 1300 memset( (char *)n, '\0', sizeof(struct nmb_name) ); 1201 1301 fstrcpy(unix_name, name); 1202 strupper_m(unix_name);1302 (void)strupper_m(unix_name); 1203 1303 push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE); 1204 1304 n->name_type = (unsigned int)type & 0xFF; 1205 push_ascii(n->scope, global_scope(), 64, STR_TERMINATE); 1206 } 1207 1208 static bool do_nodestatus(struct messaging_context *msg_ctx, 1305 push_ascii(n->scope, lp_netbios_scope(), 64, STR_TERMINATE); 1306 } 1307 1308 static bool do_nodestatus(struct tevent_context *ev_ctx, 1309 struct messaging_context *msg_ctx, 1209 1310 const struct server_id pid, 1210 1311 const int argc, const char **argv) … … 1243 1344 } 1244 1345 1346 static bool do_notify_cleanup(struct tevent_context *ev_ctx, 1347 struct messaging_context *msg_ctx, 1348 const struct server_id pid, 1349 const int argc, const char **argv) 1350 { 1351 if (argc != 1) { 1352 fprintf(stderr, "Usage: smbcontrol smbd notify-cleanup\n"); 1353 return false; 1354 } 1355 return send_message(msg_ctx, pid, MSG_SMB_NOTIFY_CLEANUP, NULL, 0); 1356 } 1357 1245 1358 /* A list of message type supported */ 1246 1359 1247 1360 static const struct { 1248 1361 const char *name; /* Option name */ 1249 bool (*fn)(struct messaging_context *msg_ctx, 1362 bool (*fn)(struct tevent_context *ev_ctx, 1363 struct messaging_context *msg_ctx, 1250 1364 const struct server_id pid, 1251 1365 const int argc, const char **argv); … … 1266 1380 { "printnotify", do_printnotify, "Send a print notify message" }, 1267 1381 { "close-share", do_closeshare, "Forcibly disconnect a share" }, 1382 { "kill-client-ip", do_kill_client_by_ip, 1383 "Forcibly disconnect a client with a specific IP address" }, 1268 1384 { "ip-dropped", do_ip_dropped, "Tell winbind that an IP got dropped" }, 1269 1385 { "lockretry", do_lockretry, "Force a blocking lock retry" }, 1270 1386 { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" }, 1271 { "samsync", do_samsync, "Initiate SAM synchronisation" },1272 { "samrepl", do_samrepl, "Initiate SAM replication" },1273 1387 { "pool-usage", do_poolusage, "Display talloc memory usage" }, 1274 1388 { "dmalloc-mark", do_dmalloc_mark, "" }, … … 1277 1391 { "drvupgrade", do_drvupgrade, "Notify a printer driver has changed" }, 1278 1392 { "reload-config", do_reload_config, "Force smbd or winbindd to reload config file"}, 1393 { "reload-printers", do_reload_printers, "Force smbd to reload printers"}, 1279 1394 { "nodestatus", do_nodestatus, "Ask nmbd to do a node status request"}, 1280 1395 { "online", do_winbind_online, "Ask winbind to go into online state"}, … … 1285 1400 "Validate winbind's credential cache" }, 1286 1401 { "dump-domain-list", do_winbind_dump_domain_list, "Dump winbind domain list"}, 1402 { "notify-cleanup", do_notify_cleanup }, 1403 { "num-children", do_num_children, 1404 "Print number of smbd child processes" }, 1405 { "msg-cleanup", do_msg_cleanup }, 1287 1406 { "noop", do_noop, "Do nothing" }, 1288 1407 { NULL } … … 1348 1467 /* Look up other destinations in pidfile directory */ 1349 1468 1350 if ((pid = pidfile_pid( dest)) != 0) {1469 if ((pid = pidfile_pid(lp_pid_directory(), dest)) != 0) { 1351 1470 return pid_to_procid(pid); 1352 1471 } … … 1359 1478 /* Execute smbcontrol command */ 1360 1479 1361 static bool do_command(struct messaging_context *msg_ctx, 1480 static bool do_command(struct tevent_context *ev_ctx, 1481 struct messaging_context *msg_ctx, 1362 1482 int argc, const char **argv) 1363 1483 { … … 1377 1497 for (i = 0; msg_types[i].name; i++) { 1378 1498 if (strequal(command, msg_types[i].name)) 1379 return msg_types[i].fn( msg_ctx, pid,1499 return msg_types[i].fn(ev_ctx, msg_ctx, pid, 1380 1500 argc - 1, argv + 1); 1381 1501 } … … 1431 1551 int ret = 0; 1432 1552 1433 load_case_tables();1553 smb_init_locale(); 1434 1554 1435 1555 setup_logging(argv[0], DEBUG_STDOUT); 1556 lp_set_cmdline("log level", "0"); 1436 1557 1437 1558 /* Parse command line arguments using popt */ … … 1472 1593 usage(pc); 1473 1594 1474 lp_load (get_dyn_CONFIGFILE(),False,False,False,True);1595 lp_load_global(get_dyn_CONFIGFILE()); 1475 1596 1476 1597 /* Need to invert sense of return code -- samba … … 1478 1599 * shell needs 0. */ 1479 1600 1480 if (!(evt_ctx = tevent_context_init(NULL)) ||1481 !(msg_ctx = messaging_init(NULL, procid_self(),evt_ctx))) {1601 if (!(evt_ctx = samba_tevent_context_init(NULL)) || 1602 !(msg_ctx = messaging_init(NULL, evt_ctx))) { 1482 1603 fprintf(stderr, "could not init messaging context\n"); 1483 1604 TALLOC_FREE(frame); … … 1485 1606 } 1486 1607 1487 ret = !do_command(msg_ctx, argc, argv); 1608 ret = !do_command(evt_ctx, msg_ctx, argc, argv); 1609 TALLOC_FREE(msg_ctx); 1488 1610 TALLOC_FREE(frame); 1489 1611 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.