mirror of
https://github.com/samba-team/samba.git
synced 2025-02-08 05:57:51 +03:00
s3:net: add command registry check
Signed-off-by: Michael Adam <obnox@samba.org>
This commit is contained in:
parent
e430c75d4c
commit
502f0b8edc
@ -1195,7 +1195,7 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
|
|||||||
utils/net_util.o utils/net_rpc_sh_acct.o utils/net_rpc_audit.o \
|
utils/net_util.o utils/net_rpc_sh_acct.o utils/net_rpc_audit.o \
|
||||||
$(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
|
$(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \
|
||||||
utils/net_conf.o utils/net_join.o utils/net_user.o \
|
utils/net_conf.o utils/net_join.o utils/net_user.o \
|
||||||
utils/net_group.o utils/net_file.o utils/net_registry.o \
|
utils/net_group.o utils/net_file.o utils/net_registry.o utils/net_registry_check.o\
|
||||||
auth/token_util.o utils/net_dom.o utils/net_share.o \
|
auth/token_util.o utils/net_dom.o utils/net_share.o \
|
||||||
utils/net_g_lock.o \
|
utils/net_g_lock.o \
|
||||||
utils/net_serverid.o \
|
utils/net_serverid.o \
|
||||||
|
@ -820,6 +820,10 @@ static struct functable net_func[] = {
|
|||||||
{"lock", 0, POPT_ARG_NONE, &c->opt_lock},
|
{"lock", 0, POPT_ARG_NONE, &c->opt_lock},
|
||||||
{"auto", 'a', POPT_ARG_NONE, &c->opt_auto},
|
{"auto", 'a', POPT_ARG_NONE, &c->opt_auto},
|
||||||
{"repair", 0, POPT_ARG_NONE, &c->opt_repair},
|
{"repair", 0, POPT_ARG_NONE, &c->opt_repair},
|
||||||
|
/* Options for 'net registry check'*/
|
||||||
|
{"reg-version", 0, POPT_ARG_INT, &c->opt_reg_version},
|
||||||
|
{"output", 'o', POPT_ARG_STRING, &c->opt_output},
|
||||||
|
{"wipe", 0, POPT_ARG_NONE, &c->opt_wipe},
|
||||||
POPT_COMMON_SAMBA
|
POPT_COMMON_SAMBA
|
||||||
{ 0, 0, 0, 0}
|
{ 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
@ -80,6 +80,9 @@ struct net_context {
|
|||||||
int opt_lock;
|
int opt_lock;
|
||||||
int opt_auto;
|
int opt_auto;
|
||||||
int opt_repair;
|
int opt_repair;
|
||||||
|
int opt_reg_version;
|
||||||
|
const char *opt_output;
|
||||||
|
int opt_wipe;
|
||||||
|
|
||||||
int opt_have_ip;
|
int opt_have_ip;
|
||||||
struct sockaddr_storage opt_dest_ip;
|
struct sockaddr_storage opt_dest_ip;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "../libcli/security/sddl.h"
|
#include "../libcli/security/sddl.h"
|
||||||
#include "../libcli/registry/util_reg.h"
|
#include "../libcli/registry/util_reg.h"
|
||||||
#include "passdb/machine_sid.h"
|
#include "passdb/machine_sid.h"
|
||||||
|
#include "net_registry_check.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -1243,6 +1244,54 @@ static int net_registry_convert(struct net_context *c, int argc,
|
|||||||
}
|
}
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
static int net_registry_check(struct net_context *c, int argc,
|
||||||
|
const char **argv)
|
||||||
|
{
|
||||||
|
const char* dbfile;
|
||||||
|
struct check_options opts;
|
||||||
|
|
||||||
|
if (argc > 1|| c->display_usage) {
|
||||||
|
d_printf("%s\n%s",
|
||||||
|
_("Usage:"),
|
||||||
|
_("net registry check [-vraTfl] [-o <ODB>] [--wipe] [<TDB>]\n"
|
||||||
|
" Check a registry database.\n"
|
||||||
|
" -v|--verbose\t be verbose\n"
|
||||||
|
" -r|--repair\t\t interactive repair mode\n"
|
||||||
|
" -a|--auto\t\t noninteractive repair mode\n"
|
||||||
|
" -T|--test\t\t dry run\n"
|
||||||
|
" -f|--force\t\t force\n"
|
||||||
|
" -l|--lock\t\t lock <TDB> while doing the check\n"
|
||||||
|
" -o|--output=<ODB>\t output database\n"
|
||||||
|
" --reg-version=n\t assume database format version {n|1,2,3}\n"
|
||||||
|
" --wipe\t\t create a new database from scratch\n"
|
||||||
|
" --db=<TDB>\t\t registry database to open\n"));
|
||||||
|
return c->display_usage ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbfile = c->opt_db ? c->opt_db : (
|
||||||
|
(argc > 0) ? argv[0] :
|
||||||
|
state_path("registry.tdb"));
|
||||||
|
if (dbfile == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
opts = (struct check_options) {
|
||||||
|
.lock = c->opt_lock || c->opt_long_list_entries,
|
||||||
|
.test = c->opt_testmode,
|
||||||
|
.automatic = c->opt_auto,
|
||||||
|
.verbose = c->opt_verbose,
|
||||||
|
.force = c->opt_force,
|
||||||
|
.repair = c->opt_repair || c->opt_reboot,
|
||||||
|
.version = c->opt_reg_version,
|
||||||
|
.output = c->opt_output,
|
||||||
|
.wipe = c->opt_wipe,
|
||||||
|
.implicit_db = (c->opt_db == NULL) && (argc == 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
return net_registry_check_db(dbfile, &opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
int net_registry(struct net_context *c, int argc, const char **argv)
|
int net_registry(struct net_context *c, int argc, const char **argv)
|
||||||
@ -1386,6 +1435,14 @@ int net_registry(struct net_context *c, int argc, const char **argv)
|
|||||||
N_("net registry convert\n"
|
N_("net registry convert\n"
|
||||||
" Convert .reg file")
|
" Convert .reg file")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"check",
|
||||||
|
net_registry_check,
|
||||||
|
NET_TRANSPORT_LOCAL,
|
||||||
|
N_("Check .reg file"),
|
||||||
|
N_("net registry check\n"
|
||||||
|
" Check .reg file")
|
||||||
|
},
|
||||||
{ NULL, NULL, 0, NULL, NULL }
|
{ NULL, NULL, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
1314
source3/utils/net_registry_check.c
Normal file
1314
source3/utils/net_registry_check.c
Normal file
File diff suppressed because it is too large
Load Diff
52
source3/utils/net_registry_check.h
Normal file
52
source3/utils/net_registry_check.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Samba Unix/Linux SMB client library
|
||||||
|
*
|
||||||
|
* Copyright (C) Gregor Beck 2011
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check the registry database.
|
||||||
|
* @author Gregor Beck <gb@sernet.de>
|
||||||
|
* @date Jun 2011
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NET_REGISTRY_CHECK_H
|
||||||
|
#define NET_REGISTRY_CHECK_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
struct net_context;
|
||||||
|
|
||||||
|
struct check_options {
|
||||||
|
bool test;
|
||||||
|
bool verbose;
|
||||||
|
bool lock;
|
||||||
|
bool automatic;
|
||||||
|
bool force;
|
||||||
|
bool repair;
|
||||||
|
int version;
|
||||||
|
const char *output;
|
||||||
|
bool wipe;
|
||||||
|
bool implicit_db;
|
||||||
|
};
|
||||||
|
|
||||||
|
int net_registry_check_db(const char* db, const struct check_options* opts);
|
||||||
|
|
||||||
|
#endif /* NET_REGISTRY_CHECK_H */
|
||||||
|
|
||||||
|
/*Local Variables:*/
|
||||||
|
/*mode: c*/
|
||||||
|
/*End:*/
|
@ -529,6 +529,7 @@ NET_SRC1 = '''utils/net.c utils/net_ads.c utils/net_help.c
|
|||||||
utils/net_rpc_join.c utils/net_time.c utils/net_lookup.c
|
utils/net_rpc_join.c utils/net_time.c utils/net_lookup.c
|
||||||
utils/net_cache.c utils/net_groupmap.c
|
utils/net_cache.c utils/net_groupmap.c
|
||||||
utils/net_idmap.c utils/net_idmap_check.c
|
utils/net_idmap.c utils/net_idmap_check.c
|
||||||
|
utils/interact.c
|
||||||
utils/net_status.c utils/net_rpc_printer.c utils/net_rpc_rights.c
|
utils/net_status.c utils/net_rpc_printer.c utils/net_rpc_rights.c
|
||||||
utils/net_rpc_service.c utils/net_rpc_registry.c utils/net_usershare.c
|
utils/net_rpc_service.c utils/net_rpc_registry.c utils/net_usershare.c
|
||||||
utils/netlookup.c utils/net_sam.c utils/net_rpc_shell.c
|
utils/netlookup.c utils/net_sam.c utils/net_rpc_shell.c
|
||||||
@ -536,6 +537,7 @@ NET_SRC1 = '''utils/net.c utils/net_ads.c utils/net_help.c
|
|||||||
utils/net_dns.c utils/net_ads_gpo.c
|
utils/net_dns.c utils/net_ads_gpo.c
|
||||||
utils/net_conf.c utils/net_join.c utils/net_user.c
|
utils/net_conf.c utils/net_join.c utils/net_user.c
|
||||||
utils/net_group.c utils/net_file.c utils/net_registry.c
|
utils/net_group.c utils/net_file.c utils/net_registry.c
|
||||||
|
utils/net_registry_check.c
|
||||||
utils/net_dom.c utils/net_share.c
|
utils/net_dom.c utils/net_share.c
|
||||||
utils/net_g_lock.c
|
utils/net_g_lock.c
|
||||||
utils/net_serverid.c
|
utils/net_serverid.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user