Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/utils/smbcontrol.c

    r414 r745  
    99   Copyright (C) Simo Sorce 2002
    1010   Copyright (C) James Peach 2006
    11    
     11
    1212   This program is free software; you can redistribute it and/or modify
    1313   it under the terms of the GNU General Public License as published by
    1414   the Free Software Foundation; either version 3 of the License, or
    1515   (at your option) any later version.
    16    
     16
    1717   This program is distributed in the hope that it will be useful,
    1818   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2020   GNU General Public License for more details.
    21    
     21
    2222   You should have received a copy of the GNU General Public License
    2323   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2525
    2626#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"
    2735
    2836#if HAVE_LIBUNWIND_H
     
    6270        DEBUG(10,("smbcontrol/send_message: broadcast message to "
    6371                  "%d processes\n", n_sent));
    64        
     72
    6573        return ret;
    6674}
     
    110118                                DATA_BLOB *data)
    111119{
    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);
    114126        num_replies++;
    115127}
     
    123135                            DATA_BLOB *data)
    124136{
    125         printf("%.*s", (int)data->length, (const char *)data->data);
     137        printf("%*s", (int)data->length, (const char *)data->data);
    126138        num_replies++;
    127139}
     
    158170                            strlen(argv[1]) + 1);
    159171}
     172
     173
     174static 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
    160220
    161221#if defined(HAVE_LIBUNWIND_PTRACE) && defined(HAVE_LINUX_PTRACE)
     
    260320}
    261321
    262 static int stack_trace_connection(struct db_record *rec,
    263                                   const struct connections_key *key,
     322static int stack_trace_connection(const struct connections_key *key,
    264323                                  const struct connections_data *crec,
    265324                                  void *priv)
     
    292351                print_stack_trace(dest, &count);
    293352        } else {
    294                 connections_forall(stack_trace_connection, &count);
     353                connections_forall_read(stack_trace_connection, &count);
    295354        }
    296355
     
    477536                break;
    478537        }
    479        
     538
    480539        printf("Profiling %s on pid %u\n",s,(unsigned int)procid_to_pid(&pid));
    481540}
     
    573632                fprintf(stderr, "\tprinter <printername> <comment|port|"
    574633                        "driver> <value>\n");
    575                
     634
    576635                return False;
    577636        }
     
    586645                        return False;
    587646                }
    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);
    590651
    591652                goto send;
     
    598659                        return False;
    599660                }
    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);
    602665
    603666                goto send;
     
    615678
    616679                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,
    618682                        SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
    619683
     
    632696
    633697                notify_job_status_byname(
     698                        messaging_event_context(msg_ctx), msg_ctx,
    634699                        argv[2], jobid, JOB_STATUS_QUEUED,
    635700                        SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
     
    649714
    650715                notify_job_status_byname(
     716                        messaging_event_context(msg_ctx), msg_ctx,
    651717                        argv[2], jobid, JOB_STATUS_DELETING,
    652718                        SPOOLSS_NOTIFY_MSG_UNIX_JOBID);
    653                
     719
    654720                notify_job_status_byname(
     721                        messaging_event_context(msg_ctx), msg_ctx,
    655722                        argv[2], jobid, JOB_STATUS_DELETING|
    656723                        JOB_STATUS_DELETED,
     
    661728        } else if (strcmp(cmd, "printer") == 0) {
    662729                uint32 attribute;
    663                
     730
    664731                if (argc != 5) {
    665732                        fprintf(stderr, "Usage: smbcontrol <dest> printnotify "
     
    681748                }
    682749
    683                 notify_printer_byname(argv[2], attribute,
     750                notify_printer_byname(messaging_event_context(msg_ctx),
     751                                      msg_ctx, argv[2], attribute,
    684752                                      CONST_DISCARD(char *, argv[4]));
    685753
     
    708776
    709777        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
     783static 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],
    710794                            strlen(argv[1]) + 1);
    711795}
     
    903987        tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
    904988                                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);
    906991
    907992        if (!tdb) {
     
    9351020                /* Check that the entry "WINBINDD_OFFLINE" still exists. */
    9361021                d = tdb_fetch_bystring( tdb, "WINBINDD_OFFLINE" );
    937        
     1022
    9381023                if (!d.dptr || d.dsize != 4) {
    9391024                        SAFE_FREE(d.dptr);
     
    9551040        struct server_id myid;
    9561041
    957         myid = pid_to_procid(sys_getpid());
     1042        myid = messaging_server_id(msg_ctx);
    9581043
    9591044        if (argc != 1) {
     
    9871072        struct server_id myid;
    9881073
    989         myid = pid_to_procid(sys_getpid());
     1074        myid = messaging_server_id(msg_ctx);
    9901075
    9911076        if (argc != 1) {
     
    10071092        int buf_len = 0;
    10081093
    1009         myid = pid_to_procid(sys_getpid());
     1094        myid = messaging_server_id(msg_ctx);
    10101095
    10111096        if (argc < 1 || argc > 2) {
    1012                 fprintf(stderr, "Usage: smbcontrol <dest> dump_domain_list "
     1097                fprintf(stderr, "Usage: smbcontrol <dest> dump-domain-list "
    10131098                        "<domain>\n");
    10141099                return false;
     
    10701155                                      const int argc, const char **argv)
    10711156{
    1072         struct server_id myid = pid_to_procid(sys_getpid());
     1157        struct server_id myid;
     1158
     1159        myid = messaging_server_id(msg_ctx);
    10731160
    10741161        if (argc != 1) {
     
    11661253} msg_types[] = {
    11671254        { "debug", do_debug, "Set debuglevel"  },
     1255        { "idmap", do_idmap, "Manipulate idmap cache" },
    11681256        { "force-election", do_election,
    11691257          "Force a browse election" },
     
    11781266        { "printnotify", do_printnotify, "Send a print notify message" },
    11791267        { "close-share", do_closeshare, "Forcibly disconnect a share" },
     1268        { "ip-dropped", do_ip_dropped, "Tell winbind that an IP got dropped" },
    11801269        { "lockretry", do_lockretry, "Force a blocking lock retry" },
    11811270        { "brl-revalidate", do_brl_revalidate, "Revalidate all brl entries" },
     
    12261315/* Return the pid number for a string destination */
    12271316
    1228 static struct server_id parse_dest(const char *dest)
     1317static struct server_id parse_dest(struct messaging_context *msg,
     1318                                   const char *dest)
    12291319{
    12301320        struct server_id result = {-1};
     
    12401330
    12411331        if (strequal(dest, "self")) {
    1242                 return pid_to_procid(sys_getpid());
     1332                return messaging_server_id(msg);
    12431333        }
    12441334
     
    12781368        /* Check destination */
    12791369
    1280         pid = parse_dest(dest);
     1370        pid = parse_dest(msg_ctx, dest);
    12811371        if (!procid_valid(&pid)) {
    12821372                return False;
     
    13431433        load_case_tables();
    13441434
    1345         setup_logging(argv[0],True);
    1346        
     1435        setup_logging(argv[0], DEBUG_STDOUT);
     1436
    13471437        /* Parse command line arguments using popt */
    13481438
     
    13871477         * routines mostly return True==1 for success, but
    13881478         * shell needs 0. */
    1389        
     1479
    13901480        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))) {
    13921482                fprintf(stderr, "could not init messaging context\n");
    13931483                TALLOC_FREE(frame);
    13941484                exit(1);
    13951485        }
    1396        
     1486
    13971487        ret = !do_command(msg_ctx, argc, argv);
    13981488        TALLOC_FREE(frame);
Note: See TracChangeset for help on using the changeset viewer.