Changeset 745 for trunk/server/source3/utils/smbcontrol.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/utils/smbcontrol.c
r414 r745 9 9 Copyright (C) Simo Sorce 2002 10 10 Copyright (C) James Peach 2006 11 11 12 12 This program is free software; you can redistribute it and/or modify 13 13 it under the terms of the GNU General Public License as published by 14 14 the Free Software Foundation; either version 3 of the License, or 15 15 (at your option) any later version. 16 16 17 17 This program is distributed in the hope that it will be useful, 18 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 20 GNU General Public License for more details. 21 21 22 22 You should have received a copy of the GNU General Public License 23 23 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 25 25 26 26 #include "includes.h" 27 #include "system/filesys.h" 28 #include "popt_common.h" 29 #include "librpc/gen_ndr/spoolss.h" 30 #include "nt_printing.h" 31 #include "printing/notify.h" 32 #include "libsmb/nmblib.h" 33 #include "messages.h" 34 #include "util_tdb.h" 27 35 28 36 #if HAVE_LIBUNWIND_H … … 62 70 DEBUG(10,("smbcontrol/send_message: broadcast message to " 63 71 "%d processes\n", n_sent)); 64 72 65 73 return ret; 66 74 } … … 110 118 DATA_BLOB *data) 111 119 { 112 printf("PID %u: %.*s", (unsigned int)procid_to_pid(&pid), 113 (int)data->length, (const char *)data->data); 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); 114 126 num_replies++; 115 127 } … … 123 135 DATA_BLOB *data) 124 136 { 125 printf("% .*s", (int)data->length, (const char *)data->data);137 printf("%*s", (int)data->length, (const char *)data->data); 126 138 num_replies++; 127 139 } … … 158 170 strlen(argv[1]) + 1); 159 171 } 172 173 174 static bool do_idmap(struct messaging_context *msg_ctx, 175 const struct server_id pid, 176 const int argc, const char **argv) 177 { 178 static const char* usage = "Usage: " 179 "smbcontrol <dest> idmap <cmd> [arg]\n" 180 "\tcmd:\tflush [gid|uid]\n" 181 "\t\tdelete \"UID <uid>\"|\"GID <gid>\"|<sid>\n" 182 "\t\tkill \"UID <uid>\"|\"GID <gid>\"|<sid>\n"; 183 const char* arg = NULL; 184 int arglen = 0; 185 int msg_type; 186 187 switch (argc) { 188 case 2: 189 break; 190 case 3: 191 arg = argv[2]; 192 arglen = strlen(arg) + 1; 193 break; 194 default: 195 fprintf(stderr, "%s", usage); 196 return false; 197 } 198 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 } 205 else if (strcmp(argv[1], "kill") == 0) { 206 msg_type = MSG_IDMAP_KILL; 207 } 208 else if (strcmp(argv[1], "help") == 0) { 209 fprintf(stdout, "%s", usage); 210 return true; 211 } 212 else { 213 fprintf(stderr, "%s", usage); 214 return false; 215 } 216 217 return send_message(msg_ctx, pid, msg_type, arg, arglen); 218 } 219 160 220 161 221 #if defined(HAVE_LIBUNWIND_PTRACE) && defined(HAVE_LINUX_PTRACE) … … 260 320 } 261 321 262 static int stack_trace_connection(struct db_record *rec, 263 const struct connections_key *key, 322 static int stack_trace_connection(const struct connections_key *key, 264 323 const struct connections_data *crec, 265 324 void *priv) … … 292 351 print_stack_trace(dest, &count); 293 352 } else { 294 connections_forall (stack_trace_connection, &count);353 connections_forall_read(stack_trace_connection, &count); 295 354 } 296 355 … … 477 536 break; 478 537 } 479 538 480 539 printf("Profiling %s on pid %u\n",s,(unsigned int)procid_to_pid(&pid)); 481 540 } … … 573 632 fprintf(stderr, "\tprinter <printername> <comment|port|" 574 633 "driver> <value>\n"); 575 634 576 635 return False; 577 636 } … … 586 645 return False; 587 646 } 588 589 notify_printer_status_byname(argv[2], PRINTER_STATUS_PAUSED); 647 648 notify_printer_status_byname(messaging_event_context(msg_ctx), 649 msg_ctx, argv[2], 650 PRINTER_STATUS_PAUSED); 590 651 591 652 goto send; … … 598 659 return False; 599 660 } 600 601 notify_printer_status_byname(argv[2], PRINTER_STATUS_OK); 661 662 notify_printer_status_byname(messaging_event_context(msg_ctx), 663 msg_ctx, argv[2], 664 PRINTER_STATUS_OK); 602 665 603 666 goto send; … … 615 678 616 679 notify_job_status_byname( 617 argv[2], jobid, JOB_STATUS_PAUSED, 680 messaging_event_context(msg_ctx), msg_ctx, 681 argv[2], jobid, JOB_STATUS_PAUSED, 618 682 SPOOLSS_NOTIFY_MSG_UNIX_JOBID); 619 683 … … 632 696 633 697 notify_job_status_byname( 698 messaging_event_context(msg_ctx), msg_ctx, 634 699 argv[2], jobid, JOB_STATUS_QUEUED, 635 700 SPOOLSS_NOTIFY_MSG_UNIX_JOBID); … … 649 714 650 715 notify_job_status_byname( 716 messaging_event_context(msg_ctx), msg_ctx, 651 717 argv[2], jobid, JOB_STATUS_DELETING, 652 718 SPOOLSS_NOTIFY_MSG_UNIX_JOBID); 653 719 654 720 notify_job_status_byname( 721 messaging_event_context(msg_ctx), msg_ctx, 655 722 argv[2], jobid, JOB_STATUS_DELETING| 656 723 JOB_STATUS_DELETED, … … 661 728 } else if (strcmp(cmd, "printer") == 0) { 662 729 uint32 attribute; 663 730 664 731 if (argc != 5) { 665 732 fprintf(stderr, "Usage: smbcontrol <dest> printnotify " … … 681 748 } 682 749 683 notify_printer_byname(argv[2], attribute, 750 notify_printer_byname(messaging_event_context(msg_ctx), 751 msg_ctx, argv[2], attribute, 684 752 CONST_DISCARD(char *, argv[4])); 685 753 … … 708 776 709 777 return send_message(msg_ctx, pid, MSG_SMB_FORCE_TDIS, argv[1], 778 strlen(argv[1]) + 1); 779 } 780 781 /* Tell winbindd an IP got dropped */ 782 783 static bool do_ip_dropped(struct messaging_context *msg_ctx, 784 const struct server_id pid, 785 const int argc, const char **argv) 786 { 787 if (argc != 2) { 788 fprintf(stderr, "Usage: smbcontrol <dest> ip-dropped " 789 "<ip-address>\n"); 790 return False; 791 } 792 793 return send_message(msg_ctx, pid, MSG_WINBIND_IP_DROPPED, argv[1], 710 794 strlen(argv[1]) + 1); 711 795 } … … 903 987 tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 904 988 WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE, 905 TDB_DEFAULT /* TDB_CLEAR_IF_FIRST */, O_RDWR|O_CREAT, 0600); 989 TDB_DEFAULT|TDB_INCOMPATIBLE_HASH /* TDB_CLEAR_IF_FIRST */, 990 O_RDWR|O_CREAT, 0600); 906 991 907 992 if (!tdb) { … … 935 1020 /* Check that the entry "WINBINDD_OFFLINE" still exists. */ 936 1021 d = tdb_fetch_bystring( tdb, "WINBINDD_OFFLINE" ); 937 1022 938 1023 if (!d.dptr || d.dsize != 4) { 939 1024 SAFE_FREE(d.dptr); … … 955 1040 struct server_id myid; 956 1041 957 myid = pid_to_procid(sys_getpid());1042 myid = messaging_server_id(msg_ctx); 958 1043 959 1044 if (argc != 1) { … … 987 1072 struct server_id myid; 988 1073 989 myid = pid_to_procid(sys_getpid());1074 myid = messaging_server_id(msg_ctx); 990 1075 991 1076 if (argc != 1) { … … 1007 1092 int buf_len = 0; 1008 1093 1009 myid = pid_to_procid(sys_getpid());1094 myid = messaging_server_id(msg_ctx); 1010 1095 1011 1096 if (argc < 1 || argc > 2) { 1012 fprintf(stderr, "Usage: smbcontrol <dest> dump _domain_list "1097 fprintf(stderr, "Usage: smbcontrol <dest> dump-domain-list " 1013 1098 "<domain>\n"); 1014 1099 return false; … … 1070 1155 const int argc, const char **argv) 1071 1156 { 1072 struct server_id myid = pid_to_procid(sys_getpid()); 1157 struct server_id myid; 1158 1159 myid = messaging_server_id(msg_ctx); 1073 1160 1074 1161 if (argc != 1) { … … 1166 1253 } msg_types[] = { 1167 1254 { "debug", do_debug, "Set debuglevel" }, 1255 { "idmap", do_idmap, "Manipulate idmap cache" }, 1168 1256 { "force-election", do_election, 1169 1257 "Force a browse election" }, … … 1178 1266 { "printnotify", do_printnotify, "Send a print notify message" }, 1179 1267 { "close-share", do_closeshare, "Forcibly disconnect a share" }, 1268 { "ip-dropped", do_ip_dropped, "Tell winbind that an IP got dropped" }, 1180 1269 { "lockretry", do_lockretry, "Force a blocking lock retry" }, 1181 1270 { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" }, … … 1226 1315 /* Return the pid number for a string destination */ 1227 1316 1228 static struct server_id parse_dest(const char *dest) 1317 static struct server_id parse_dest(struct messaging_context *msg, 1318 const char *dest) 1229 1319 { 1230 1320 struct server_id result = {-1}; … … 1240 1330 1241 1331 if (strequal(dest, "self")) { 1242 return pid_to_procid(sys_getpid());1332 return messaging_server_id(msg); 1243 1333 } 1244 1334 … … 1278 1368 /* Check destination */ 1279 1369 1280 pid = parse_dest( dest);1370 pid = parse_dest(msg_ctx, dest); 1281 1371 if (!procid_valid(&pid)) { 1282 1372 return False; … … 1343 1433 load_case_tables(); 1344 1434 1345 setup_logging(argv[0], True);1346 1435 setup_logging(argv[0], DEBUG_STDOUT); 1436 1347 1437 /* Parse command line arguments using popt */ 1348 1438 … … 1387 1477 * routines mostly return True==1 for success, but 1388 1478 * shell needs 0. */ 1389 1479 1390 1480 if (!(evt_ctx = tevent_context_init(NULL)) || 1391 !(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) {1481 !(msg_ctx = messaging_init(NULL, procid_self(), evt_ctx))) { 1392 1482 fprintf(stderr, "could not init messaging context\n"); 1393 1483 TALLOC_FREE(frame); 1394 1484 exit(1); 1395 1485 } 1396 1486 1397 1487 ret = !do_command(msg_ctx, argc, argv); 1398 1488 TALLOC_FREE(frame);
Note:
See TracChangeset
for help on using the changeset viewer.