Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/utils/smbcontrol.c

    r860 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33
     
    3333#include "messages.h"
    3434#include "util_tdb.h"
     35#include "../lib/util/pidfile.h"
     36#include "serverid.h"
    3537
    3638#if HAVE_LIBUNWIND_H
     
    6567                return NT_STATUS_IS_OK(
    6668                        messaging_send_buf(msg_ctx, pid, msg_type,
    67                                            (uint8 *)buf, len));
     69                                           (const uint8_t *)buf, len));
    6870
    6971        ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
     
    8688/* Wait for one or more reply messages */
    8789
    88 static void wait_replies(struct messaging_context *msg_ctx,
     90static void wait_replies(struct tevent_context *ev_ctx,
     91                         struct messaging_context *msg_ctx,
    8992                         bool multiple_replies)
    9093{
     
    9295        bool timed_out = False;
    9396
    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) {
    97101                DEBUG(0, ("tevent_add_timer failed\n"));
    98102                return;
     
    103107                if (num_replies > 0 && !multiple_replies)
    104108                        break;
    105                 ret = tevent_loop_once(messaging_event_context(msg_ctx));
     109                ret = tevent_loop_once(ev_ctx);
    106110                if (ret != 0) {
    107111                        break;
     
    118122                                DATA_BLOB *data)
    119123{
    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);
    126128        num_replies++;
    127129}
     
    141143/* Send no message.  Useful for testing. */
    142144
    143 static bool do_noop(struct messaging_context *msg_ctx,
     145static bool do_noop(struct tevent_context *ev_ctx,
     146                    struct messaging_context *msg_ctx,
    144147                    const struct server_id pid,
    145148                    const int argc, const char **argv)
     
    157160/* Send a debug string */
    158161
    159 static bool do_debug(struct messaging_context *msg_ctx,
     162static bool do_debug(struct tevent_context *ev_ctx,
     163                     struct messaging_context *msg_ctx,
    160164                     const struct server_id pid,
    161165                     const int argc, const char **argv)
     
    172176
    173177
    174 static bool do_idmap(struct messaging_context *msg_ctx,
     178static bool do_idmap(struct tevent_context *ev,
     179                     struct messaging_context *msg_ctx,
    175180                     const struct server_id pid,
    176181                     const int argc, const char **argv)
     
    178183        static const char* usage = "Usage: "
    179184                "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"
    182187                "\t\tkill \"UID <uid>\"|\"GID <gid>\"|<sid>\n";
    183188        const char* arg = NULL;
     
    197202        }
    198203
    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;
    204206        }
    205207        else if (strcmp(argv[1], "kill") == 0) {
    206                 msg_type = MSG_IDMAP_KILL;
     208                msg_type = ID_CACHE_KILL;
    207209        }
    208210        else if (strcmp(argv[1], "help") == 0) {
     
    222224
    223225/* 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 implementatino is
     226 * but that's probably moot since this whole stack tracing implementation is
    225227 * Linux-specific anyway.
    226228 */
     
    320322}
    321323
    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 
     324static 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        }
    328331        return 0;
    329332}
    330333
    331 static bool do_daemon_stack_trace(struct messaging_context *msg_ctx,
     334static bool do_daemon_stack_trace(struct tevent_context *ev_ctx,
     335                                  struct messaging_context *msg_ctx,
    332336                                  const struct server_id pid,
    333                        const int argc, const char **argv)
     337                                  const int argc, const char **argv)
    334338{
    335339        pid_t   dest;
     
    351355                print_stack_trace(dest, &count);
    352356        } else {
    353                 connections_forall_read(stack_trace_connection, &count);
     357                serverid_traverse_read(stack_trace_server, &count);
    354358        }
    355359
     
    359363#else /* defined(HAVE_LIBUNWIND_PTRACE) && defined(HAVE_LINUX_PTRACE) */
    360364
    361 static bool do_daemon_stack_trace(struct messaging_context *msg_ctx,
     365static bool do_daemon_stack_trace(struct tevent_context *ev_ctx,
     366                                  struct messaging_context *msg_ctx,
    362367                                  const struct server_id pid,
    363                        const int argc, const char **argv)
     368                                  const int argc, const char **argv)
    364369{
    365370        fprintf(stderr,
     
    372377/* Inject a fault (fatal signal) into a running smbd */
    373378
    374 static bool do_inject_fault(struct messaging_context *msg_ctx,
     379static bool do_inject_fault(struct tevent_context *ev_ctx,
     380                            struct messaging_context *msg_ctx,
    375381                            const struct server_id pid,
    376                        const int argc, const char **argv)
     382                            const int argc, const char **argv)
    377383{
    378384        if (argc != 2) {
     
    414420/* Force a browser election */
    415421
    416 static bool do_election(struct messaging_context *msg_ctx,
     422static bool do_election(struct tevent_context *ev_ctx,
     423                        struct messaging_context *msg_ctx,
    417424                        const struct server_id pid,
    418425                        const int argc, const char **argv)
     
    434441                    DATA_BLOB *data)
    435442{
    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));
    439445        num_replies++;
    440446}
    441447
    442 static bool do_ping(struct messaging_context *msg_ctx,
     448static bool do_ping(struct tevent_context *ev_ctx,
     449                    struct messaging_context *msg_ctx,
    443450                    const struct server_id pid,
    444451                    const int argc, const char **argv)
     
    456463        messaging_register(msg_ctx, NULL, MSG_PONG, pong_cb);
    457464
    458         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     465        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    459466
    460467        /* No replies were received within the timeout period */
     
    470477/* Set profiling options */
    471478
    472 static bool do_profile(struct messaging_context *msg_ctx,
     479static bool do_profile(struct tevent_context *ev_ctx,
     480                       struct messaging_context *msg_ctx,
    473481                       const struct server_id pid,
    474482                       const int argc, const char **argv)
     
    553561}
    554562
    555 static bool do_profilelevel(struct messaging_context *msg_ctx,
     563static bool do_profilelevel(struct tevent_context *ev_ctx,
     564                            struct messaging_context *msg_ctx,
    556565                            const struct server_id pid,
    557566                            const int argc, const char **argv)
     
    571580                           profilelevel_rqst);
    572581
    573         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     582        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    574583
    575584        /* No replies were received within the timeout period */
     
    585594/* Display debug level settings */
    586595
    587 static bool do_debuglevel(struct messaging_context *msg_ctx,
     596static bool do_debuglevel(struct tevent_context *ev_ctx,
     597                          struct messaging_context *msg_ctx,
    588598                          const struct server_id pid,
    589599                          const int argc, const char **argv)
     
    601611        messaging_register(msg_ctx, NULL, MSG_DEBUGLEVEL, print_pid_string_cb);
    602612
    603         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     613        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    604614
    605615        /* No replies were received within the timeout period */
     
    615625/* Send a print notify message */
    616626
    617 static bool do_printnotify(struct messaging_context *msg_ctx,
     627static bool do_printnotify(struct tevent_context *ev_ctx,
     628                           struct messaging_context *msg_ctx,
    618629                           const struct server_id pid,
    619630                           const int argc, const char **argv)
     
    646657                }
    647658
    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],
    650660                                             PRINTER_STATUS_PAUSED);
    651661
     
    660670                }
    661671
    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],
    664673                                             PRINTER_STATUS_OK);
    665674
     
    678687
    679688                notify_job_status_byname(
    680                         messaging_event_context(msg_ctx), msg_ctx,
     689                        ev_ctx, msg_ctx,
    681690                        argv[2], jobid, JOB_STATUS_PAUSED,
    682691                        SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
     
    696705
    697706                notify_job_status_byname(
    698                         messaging_event_context(msg_ctx), msg_ctx,
     707                        ev_ctx, msg_ctx,
    699708                        argv[2], jobid, JOB_STATUS_QUEUED,
    700709                        SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
     
    714723
    715724                notify_job_status_byname(
    716                         messaging_event_context(msg_ctx), msg_ctx,
     725                        ev_ctx, msg_ctx,
    717726                        argv[2], jobid, JOB_STATUS_DELETING,
    718727                        SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
    719728
    720729                notify_job_status_byname(
    721                         messaging_event_context(msg_ctx), msg_ctx,
     730                        ev_ctx, msg_ctx,
    722731                        argv[2], jobid, JOB_STATUS_DELETING|
    723732                        JOB_STATUS_DELETED,
     
    727736
    728737        } else if (strcmp(cmd, "printer") == 0) {
    729                 uint32 attribute;
     738                uint32_t attribute;
    730739
    731740                if (argc != 5) {
     
    748757                }
    749758
    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]));
    753761
    754762                goto send;
     
    765773/* Close a share */
    766774
    767 static bool do_closeshare(struct messaging_context *msg_ctx,
     775static bool do_closeshare(struct tevent_context *ev_ctx,
     776                          struct messaging_context *msg_ctx,
    768777                          const struct server_id pid,
    769778                          const int argc, const char **argv)
     
    779788}
    780789
     790/* Kill a client by IP address */
     791static 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
    781811/* Tell winbindd an IP got dropped */
    782812
    783 static bool do_ip_dropped(struct messaging_context *msg_ctx,
     813static bool do_ip_dropped(struct tevent_context *ev_ctx,
     814                          struct messaging_context *msg_ctx,
    784815                          const struct server_id pid,
    785816                          const int argc, const char **argv)
     
    797828/* force a blocking lock retry */
    798829
    799 static bool do_lockretry(struct messaging_context *msg_ctx,
     830static bool do_lockretry(struct tevent_context *ev_ctx,
     831                         struct messaging_context *msg_ctx,
    800832                         const struct server_id pid,
    801833                         const int argc, const char **argv)
     
    811843/* force a validation of all brl entries, including re-sends. */
    812844
    813 static bool do_brl_revalidate(struct messaging_context *msg_ctx,
     845static bool do_brl_revalidate(struct tevent_context *ev_ctx,
     846                              struct messaging_context *msg_ctx,
    814847                              const struct server_id pid,
    815848                              const int argc, const char **argv)
     
    823856}
    824857
    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 
    853858/* Display talloc pool usage */
    854859
    855 static bool do_poolusage(struct messaging_context *msg_ctx,
     860static bool do_poolusage(struct tevent_context *ev_ctx,
     861                         struct messaging_context *msg_ctx,
    856862                         const struct server_id pid,
    857863                         const int argc, const char **argv)
     
    869875                return False;
    870876
    871         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     877        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    872878
    873879        /* No replies were received within the timeout period */
     
    883889/* Perform a dmalloc mark */
    884890
    885 static bool do_dmalloc_mark(struct messaging_context *msg_ctx,
     891static bool do_dmalloc_mark(struct tevent_context *ev_ctx,
     892                            struct messaging_context *msg_ctx,
    886893                            const struct server_id pid,
    887894                            const int argc, const char **argv)
     
    897904/* Perform a dmalloc changed */
    898905
    899 static bool do_dmalloc_changed(struct messaging_context *msg_ctx,
     906static bool do_dmalloc_changed(struct tevent_context *ev_ctx,
     907                               struct messaging_context *msg_ctx,
    900908                               const struct server_id pid,
    901909                               const int argc, const char **argv)
     
    911919}
    912920
     921static 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);
     934done:
     935        num_replies++;
     936}
     937
     938static 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
     968static 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
    913983/* Shutdown a server process */
    914984
    915 static bool do_shutdown(struct messaging_context *msg_ctx,
     985static bool do_shutdown(struct tevent_context *ev_ctx,
     986                        struct messaging_context *msg_ctx,
    916987                        const struct server_id pid,
    917988                        const int argc, const char **argv)
     
    927998/* Notify a driver upgrade */
    928999
    929 static bool do_drvupgrade(struct messaging_context *msg_ctx,
     1000static bool do_drvupgrade(struct tevent_context *ev_ctx,
     1001                          struct messaging_context *msg_ctx,
    9301002                          const struct server_id pid,
    9311003                          const int argc, const char **argv)
     
    9411013}
    9421014
    943 static bool do_winbind_online(struct messaging_context *msg_ctx,
     1015static bool do_winbind_online(struct tevent_context *ev_ctx,
     1016                              struct messaging_context *msg_ctx,
    9441017                              const struct server_id pid,
    945                              const int argc, const char **argv)
     1018                              const int argc, const char **argv)
    9461019{
    9471020        TDB_CONTEXT *tdb;
     1021        char *db_path;
    9481022
    9491023        if (argc != 1) {
    9501024                fprintf(stderr, "Usage: smbcontrol winbindd online\n");
    9511025                return False;
     1026        }
     1027
     1028        db_path = state_path("winbindd_cache.tdb");
     1029        if (db_path == NULL) {
     1030                return false;
    9521031        }
    9531032
     
    9551034           starting winbindd that we're online. */
    9561035
    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);
    9581037        if (!tdb) {
    9591038                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);
    9641045        tdb_delete_bystring(tdb, "WINBINDD_OFFLINE");
    9651046        tdb_close(tdb);
     
    9681049}
    9691050
    970 static bool do_winbind_offline(struct messaging_context *msg_ctx,
     1051static bool do_winbind_offline(struct tevent_context *ev_ctx,
     1052                               struct messaging_context *msg_ctx,
    9711053                               const struct server_id pid,
    972                              const int argc, const char **argv)
     1054                               const int argc, const char **argv)
    9731055{
    9741056        TDB_CONTEXT *tdb;
    9751057        bool ret = False;
    9761058        int retry = 0;
     1059        char *db_path;
    9771060
    9781061        if (argc != 1) {
    9791062                fprintf(stderr, "Usage: smbcontrol winbindd offline\n");
    9801063                return False;
     1064        }
     1065
     1066        db_path = state_path("winbindd_cache.tdb");
     1067        if (db_path == NULL) {
     1068                return false;
    9811069        }
    9821070
     
    9851073           it here... */
    9861074
    987         tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
     1075        tdb = tdb_open_log(db_path,
    9881076                                WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE,
    9891077                                TDB_DEFAULT|TDB_INCOMPATIBLE_HASH /* TDB_CLEAR_IF_FIRST */,
     
    9921080        if (!tdb) {
    9931081                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);
    9971087
    9981088        /* There's a potential race condition that if a child
     
    10041094
    10051095        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) };
    10101098
    10111099                SIVAL(buf, 0, time(NULL));
    1012                 d.dptr = buf;
    1013                 d.dsize = 4;
    10141100
    10151101                tdb_store_bystring(tdb, "WINBINDD_OFFLINE", d, TDB_INSERT);
     
    10341120}
    10351121
    1036 static bool do_winbind_onlinestatus(struct messaging_context *msg_ctx,
     1122static bool do_winbind_onlinestatus(struct tevent_context *ev_ctx,
     1123                                    struct messaging_context *msg_ctx,
    10371124                                    const struct server_id pid,
    10381125                                    const int argc, const char **argv)
     
    10541141                return False;
    10551142
    1056         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     1143        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    10571144
    10581145        /* No replies were received within the timeout period */
     
    10661153}
    10671154
    1068 static bool do_dump_event_list(struct messaging_context *msg_ctx,
     1155static bool do_dump_event_list(struct tevent_context *ev_ctx,
     1156                               struct messaging_context *msg_ctx,
    10691157                               const struct server_id pid,
    10701158                               const int argc, const char **argv)
    10711159{
    1072         struct server_id myid;
    1073 
    1074         myid = messaging_server_id(msg_ctx);
    1075 
    10761160        if (argc != 1) {
    10771161                fprintf(stderr, "Usage: smbcontrol <dest> dump-event-list\n");
     
    10821166}
    10831167
    1084 static bool do_winbind_dump_domain_list(struct messaging_context *msg_ctx,
     1168static bool do_winbind_dump_domain_list(struct tevent_context *ev_ctx,
     1169                                        struct messaging_context *msg_ctx,
    10851170                                        const struct server_id pid,
    10861171                                        const int argc, const char **argv)
     
    11241209        }
    11251210
    1126         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     1211        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    11271212
    11281213        /* No replies were received within the timeout period */
     
    11441229                                      DATA_BLOB *data)
    11451230{
    1146         char *src_string = procid_str(NULL, &pid);
     1231        struct server_id_buf src_string;
    11471232        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));
    11501235        num_replies++;
    11511236}
    11521237
    1153 static bool do_winbind_validate_cache(struct messaging_context *msg_ctx,
     1238static bool do_winbind_validate_cache(struct tevent_context *ev_ctx,
     1239                                      struct messaging_context *msg_ctx,
    11541240                                      const struct server_id pid,
    11551241                                      const int argc, const char **argv)
     
    11721258        }
    11731259
    1174         wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
     1260        wait_replies(ev_ctx, msg_ctx, procid_to_pid(&pid) == 0);
    11751261
    11761262        if (num_replies == 0) {
     
    11831269}
    11841270
    1185 static bool do_reload_config(struct messaging_context *msg_ctx,
     1271static bool do_reload_config(struct tevent_context *ev_ctx,
     1272                             struct messaging_context *msg_ctx,
    11861273                             const struct server_id pid,
    11871274                             const int argc, const char **argv)
     
    11931280
    11941281        return send_message(msg_ctx, pid, MSG_SMB_CONF_UPDATED, NULL, 0);
     1282}
     1283
     1284static 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);
    11951295}
    11961296
     
    12001300        memset( (char *)n, '\0', sizeof(struct nmb_name) );
    12011301        fstrcpy(unix_name, name);
    1202         strupper_m(unix_name);
     1302        (void)strupper_m(unix_name);
    12031303        push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
    12041304        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
     1308static bool do_nodestatus(struct tevent_context *ev_ctx,
     1309                          struct messaging_context *msg_ctx,
    12091310                          const struct server_id pid,
    12101311                          const int argc, const char **argv)
     
    12431344}
    12441345
     1346static 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
    12451358/* A list of message type supported */
    12461359
    12471360static const struct {
    12481361        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,
    12501364                   const struct server_id pid,
    12511365                   const int argc, const char **argv);
     
    12661380        { "printnotify", do_printnotify, "Send a print notify message" },
    12671381        { "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" },
    12681384        { "ip-dropped", do_ip_dropped, "Tell winbind that an IP got dropped" },
    12691385        { "lockretry", do_lockretry, "Force a blocking lock retry" },
    12701386        { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" },
    1271         { "samsync", do_samsync, "Initiate SAM synchronisation" },
    1272         { "samrepl", do_samrepl, "Initiate SAM replication" },
    12731387        { "pool-usage", do_poolusage, "Display talloc memory usage" },
    12741388        { "dmalloc-mark", do_dmalloc_mark, "" },
     
    12771391        { "drvupgrade", do_drvupgrade, "Notify a printer driver has changed" },
    12781392        { "reload-config", do_reload_config, "Force smbd or winbindd to reload config file"},
     1393        { "reload-printers", do_reload_printers, "Force smbd to reload printers"},
    12791394        { "nodestatus", do_nodestatus, "Ask nmbd to do a node status request"},
    12801395        { "online", do_winbind_online, "Ask winbind to go into online state"},
     
    12851400          "Validate winbind's credential cache" },
    12861401        { "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 },
    12871406        { "noop", do_noop, "Do nothing" },
    12881407        { NULL }
     
    13481467        /* Look up other destinations in pidfile directory */
    13491468
    1350         if ((pid = pidfile_pid(dest)) != 0) {
     1469        if ((pid = pidfile_pid(lp_pid_directory(), dest)) != 0) {
    13511470                return pid_to_procid(pid);
    13521471        }
     
    13591478/* Execute smbcontrol command */
    13601479
    1361 static bool do_command(struct messaging_context *msg_ctx,
     1480static bool do_command(struct tevent_context *ev_ctx,
     1481                       struct messaging_context *msg_ctx,
    13621482                       int argc, const char **argv)
    13631483{
     
    13771497        for (i = 0; msg_types[i].name; i++) {
    13781498                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,
    13801500                                               argc - 1, argv + 1);
    13811501        }
     
    14311551        int ret = 0;
    14321552
    1433         load_case_tables();
     1553        smb_init_locale();
    14341554
    14351555        setup_logging(argv[0], DEBUG_STDOUT);
     1556        lp_set_cmdline("log level", "0");
    14361557
    14371558        /* Parse command line arguments using popt */
     
    14721593                usage(pc);
    14731594
    1474         lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
     1595        lp_load_global(get_dyn_CONFIGFILE());
    14751596
    14761597        /* Need to invert sense of return code -- samba
     
    14781599         * shell needs 0. */
    14791600
    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))) {
    14821603                fprintf(stderr, "could not init messaging context\n");
    14831604                TALLOC_FREE(frame);
     
    14851606        }
    14861607
    1487         ret = !do_command(msg_ctx, argc, argv);
     1608        ret = !do_command(evt_ctx, msg_ctx, argc, argv);
     1609        TALLOC_FREE(msg_ctx);
    14881610        TALLOC_FREE(frame);
    14891611        return ret;
Note: See TracChangeset for help on using the changeset viewer.